|
|
@@ -418,6 +418,67 @@ 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( 'clipboard', () => {
|
|
|
let model, viewDoc;
|
|
|
|