浏览代码

Remove attribute restriction enforcing.

Maciej Gołaszewski 6 年之前
父节点
当前提交
acd9b405e0

+ 0 - 25
packages/ckeditor5-restricted-editing/src/restrictededitingmodeediting.js

@@ -175,7 +175,6 @@ export default class RestrictedEditingModeEditing extends Plugin {
 		const editor = this.editor;
 
 		this.listenTo( editor.model, 'deleteContent', restrictDeleteContent( editor ), { priority: 'high' } );
-		this.listenTo( editor.model, 'applyOperation', restrictAttributeOperation( editor ), { priority: 'high' } );
 
 		const inputCommand = this.editor.commands.get( 'input' );
 
@@ -336,30 +335,6 @@ function restrictDeleteContent( editor ) {
 	};
 }
 
-// Ensures that remove attribute operation is executed on proper range.
-//
-// The restriction is enforced by trimming range of an AttributeOperation.
-function restrictAttributeOperation( editor ) {
-	return ( evt, args ) => {
-		const [ operation ] = args;
-
-		if ( operation.type != 'removeAttribute' ) {
-			return;
-		}
-
-		const marker = getMarkerAtPosition( editor, operation.range.start ) || getMarkerAtPosition( editor, operation.range.end );
-
-		// Stop method execution if marker was not found at selection focus.
-		if ( !marker ) {
-			evt.stop();
-
-			return;
-		}
-
-		operation.range = operation.range.getIntersection( marker.getRange() );
-	};
-}
-
 // Ensures that input command is executed with a range that is inside exception marker.
 //
 // This restriction is due to fact that using native spell check changes text outside exception marker.

+ 0 - 61
packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js

@@ -418,67 +418,6 @@ describe( 'RestrictedEditingModeEditing', () => {
 		} );
 	} );
 
-	describe( 'enforcing restrictions on remove attribute operation', () => {
-		beforeEach( async () => {
-			editor = await VirtualTestEditor.create( { plugins: [ Paragraph, Typing, RestrictedEditingModeEditing ] } );
-			model = editor.model;
-
-			editor.model.schema.extend( '$text', { allowAttributes: [ 'link' ] } );
-		} );
-
-		afterEach( async () => {
-			await editor.destroy();
-		} );
-
-		it( 'should not allow to delete content outside restricted area', () => {
-			setModelData( model, '<paragraph><$text link="true">[]foo bar</$text> baz</paragraph>' );
-			const firstParagraph = model.document.getRoot().getChild( 0 );
-			addExceptionMarker( 4, 7, firstParagraph );
-
-			model.change( writer => {
-				writer.removeAttribute( 'link', writer.createRange(
-					writer.createPositionAt( firstParagraph, 0 ),
-					writer.createPositionAt( firstParagraph, 1 )
-				) );
-			} );
-
-			assertEqualMarkup( getModelData( model ), '<paragraph><$text link="true">[]foo bar</$text> baz</paragraph>' );
-		} );
-
-		it( 'should trim deleted content to a exception marker (end in marker)', () => {
-			setModelData( model, '<paragraph><$text link="true">[]foo bar</$text> baz</paragraph>' );
-			const firstParagraph = model.document.getRoot().getChild( 0 );
-			addExceptionMarker( 4, 7, firstParagraph );
-
-			model.change( writer => {
-				writer.removeAttribute( 'link', writer.createRange(
-					writer.createPositionAt( firstParagraph, 0 ),
-					writer.createPositionAt( firstParagraph, 7 )
-				) );
-			} );
-
-			assertEqualMarkup( getModelData( model ), '<paragraph><$text link="true">[]foo </$text>bar baz</paragraph>' );
-		} );
-
-		it( 'should trim deleted content to a exception marker (start in marker)', () => {
-			setModelData( model, '<paragraph><$text link="true">[]foo bar baz</$text></paragraph>' );
-			const firstParagraph = model.document.getRoot().getChild( 0 );
-			addExceptionMarker( 4, 7, firstParagraph );
-
-			model.change( writer => {
-				writer.removeAttribute( 'link', writer.createRange(
-					writer.createPositionAt( firstParagraph, 5 ),
-					writer.createPositionAt( firstParagraph, 8 )
-				) );
-			} );
-
-			assertEqualMarkup(
-				getModelData( model ),
-				'<paragraph><$text link="true">[]foo b</$text>ar<$text link="true"> baz</$text></paragraph>'
-			);
-		} );
-	} );
-
 	describe( 'enforcing restrictions on input command', () => {
 		let firstParagraph;