|
|
@@ -117,6 +117,25 @@ describe( 'RestrictedEditingExceptionCommand', () => {
|
|
|
expect( model.document.selection.hasAttribute( 'restrictedEditingException' ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
+ it( 'should not set the selection attribute if there is a text without the attribute (forceValue="false")', () => {
|
|
|
+ setData( model, '<p>abcfoo[]barbaz</p>' );
|
|
|
+
|
|
|
+ command.execute( { forceValue: false } );
|
|
|
+
|
|
|
+ expect( model.document.selection.hasAttribute( 'restrictedEditingException' ) ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should not change the selection attribute if selection has the attribute already (forceValue="true")', () => {
|
|
|
+ setData( model, '<p>abcfoo[]barbaz</p>' );
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelectionAttribute( 'restrictedEditingException', true );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( model.document.selection.hasAttribute( 'restrictedEditingException' ) ).to.be.true;
|
|
|
+
|
|
|
+ command.execute( { forceValue: true } );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should remove attribute from text node if a text has the non-restricted attribute', () => {
|
|
|
setData( model, '<p>abc<$text restrictedEditingException="true">foo[]bar</$text>baz</p>' );
|
|
|
|
|
|
@@ -126,6 +145,24 @@ describe( 'RestrictedEditingExceptionCommand', () => {
|
|
|
expect( getData( model ) ).to.equal( '<p>abcfoo[]barbaz</p>' );
|
|
|
} );
|
|
|
|
|
|
+ it( 'should remove attribute from text node if a text has the non-restricted attribute (forceValue="false")', () => {
|
|
|
+ setData( model, '<p>abc<$text restrictedEditingException="true">foo[]bar</$text>baz</p>' );
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ expect( model.document.selection.hasAttribute( 'restrictedEditingException' ) ).to.be.false;
|
|
|
+ expect( getData( model ) ).to.equal( '<p>abcfoo[]barbaz</p>' );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should not remove attribute from text node if a text has the non-restricted attribute (forceValue="true")', () => {
|
|
|
+ setData( model, '<p>abc<$text restrictedEditingException="true">foo[]bar</$text>baz</p>' );
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ expect( model.document.selection.hasAttribute( 'restrictedEditingException' ) ).to.be.true;
|
|
|
+ expect( getData( model ) ).to.equal( '<p>abc<$text restrictedEditingException="true">foo[]bar</$text>baz</p>' );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should not remove exception when selection is at the beginning of restricted text', () => {
|
|
|
setData( model, '<p>abc<$text restrictedEditingException="true">[]foobar</$text>baz</p>' );
|
|
|
|