|
|
@@ -271,13 +271,17 @@ describe( 'RestrictedEditingEditing', () => {
|
|
|
} );
|
|
|
|
|
|
const commandsEnabledOnWholeRange = [
|
|
|
- 'input', 'bold', 'typing'
|
|
|
+ 'input', 'bold', 'link', 'italic'
|
|
|
];
|
|
|
|
|
|
for ( const commandName of commandsEnabledOnWholeRange ) {
|
|
|
describe( commandName, () => {
|
|
|
beforeEach( () => {
|
|
|
editor.commands.add( commandName, buildFakeCommand( editor ) );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( firstParagraph, 'end' );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
it( 'should be disabled when caret is outside exception marker', () => {
|
|
|
@@ -372,6 +376,10 @@ describe( 'RestrictedEditingEditing', () => {
|
|
|
describe( 'delete', () => {
|
|
|
beforeEach( () => {
|
|
|
editor.commands.add( 'delete', buildFakeCommand( editor ) );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( firstParagraph, 'end' );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
it( 'should be disabled when caret is outside exception marker', () => {
|
|
|
@@ -465,6 +473,10 @@ describe( 'RestrictedEditingEditing', () => {
|
|
|
describe( 'forwardDelete', () => {
|
|
|
beforeEach( () => {
|
|
|
editor.commands.add( 'forwardDelete', buildFakeCommand( editor ) );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( firstParagraph, 'end' );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
it( 'should be disabled when caret is outside exception marker', () => {
|
|
|
@@ -558,6 +570,10 @@ describe( 'RestrictedEditingEditing', () => {
|
|
|
describe( 'other', () => {
|
|
|
beforeEach( () => {
|
|
|
editor.commands.add( 'other', buildFakeCommand( editor ) );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( firstParagraph, 'end' );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
it( 'should be disabled outside exception marker', () => {
|
|
|
@@ -578,6 +594,85 @@ describe( 'RestrictedEditingEditing', () => {
|
|
|
|
|
|
expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should be disabled when caret is inside exception marker (not touching boundaries)', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( firstParagraph, 5 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled when caret is inside exception marker (start boundary)', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( firstParagraph, 4 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled when caret is inside exception marker (end boundary)', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( firstParagraph, 7 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled for non-collapsed selection that expands over exception marker', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( writer.createRange(
|
|
|
+ writer.createPositionAt( firstParagraph, 0 ),
|
|
|
+ writer.createPositionAt( firstParagraph, 5 )
|
|
|
+ ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled for non-collapsed selection that is fully contained inside exception marker', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( writer.createRange(
|
|
|
+ writer.createPositionAt( firstParagraph, 5 ),
|
|
|
+ writer.createPositionAt( firstParagraph, 6 )
|
|
|
+ ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled for non-collapsed selection inside exception marker (start position on marker boundary)', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( writer.createRange(
|
|
|
+ writer.createPositionAt( firstParagraph, 4 ),
|
|
|
+ writer.createPositionAt( firstParagraph, 6 )
|
|
|
+ ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled for non-collapsed selection inside exception marker (end position on marker boundary)', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( writer.createRange(
|
|
|
+ writer.createPositionAt( firstParagraph, 5 ),
|
|
|
+ writer.createPositionAt( firstParagraph, 7 )
|
|
|
+ ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled for non-collapsed selection is equal to exception marker', () => {
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( writer.createRange(
|
|
|
+ writer.createPositionAt( firstParagraph, 4 ),
|
|
|
+ writer.createPositionAt( firstParagraph, 7 )
|
|
|
+ ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'other' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|
|
|
|