|
|
@@ -23,6 +23,15 @@ describe( 'ParagraphCommand', () => {
|
|
|
editor.commands.set( 'paragraph', command );
|
|
|
schema.registerItem( 'paragraph', '$block' );
|
|
|
schema.registerItem( 'heading1', '$block' );
|
|
|
+
|
|
|
+ schema.registerItem( 'notBlock' );
|
|
|
+ schema.allow( { name: 'notBlock', inside: '$root' } );
|
|
|
+ schema.allow( { name: '$text', inside: 'notBlock' } );
|
|
|
+
|
|
|
+ schema.registerItem( 'object' );
|
|
|
+ schema.allow( { name: 'object', inside: '$root' } );
|
|
|
+ schema.allow( { name: '$text', inside: 'object' } );
|
|
|
+ schema.objects.add( 'object' );
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
@@ -32,8 +41,6 @@ describe( 'ParagraphCommand', () => {
|
|
|
|
|
|
describe( 'value', () => {
|
|
|
it( 'has default value', () => {
|
|
|
- setData( document, '' );
|
|
|
-
|
|
|
expect( command.value ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
@@ -61,6 +68,19 @@ describe( 'ParagraphCommand', () => {
|
|
|
setData( document, '<paragraph>[bar</paragraph><heading1>foo]</heading1>' );
|
|
|
expect( command.value ).to.be.true;
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'has proper value when moved to element that is not a block', () => {
|
|
|
+ setData( document, '<paragraph>[foo]</paragraph><notBlock>foo</notBlock>' );
|
|
|
+ const element = document.getRoot().getChild( 1 );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.true;
|
|
|
+
|
|
|
+ document.enqueueChanges( () => {
|
|
|
+ document.selection.setRanges( [ Range.createIn( element ) ] );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.false;
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( '_doExecute', () => {
|
|
|
@@ -147,4 +167,30 @@ describe( 'ParagraphCommand', () => {
|
|
|
} );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'isEnabled', () => {
|
|
|
+ it( 'should be enabled when inside another block', () => {
|
|
|
+ setData( document, '<heading1>f{}oo</heading1>' );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.true;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled if inside non-block', () => {
|
|
|
+ setData( document, '<notBlock>f{}oo</notBlock>' );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled if inside object', () => {
|
|
|
+ setData( document, '<object>f{}oo</object>' );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be disabled if selection is placed on object', () => {
|
|
|
+ setData( document, '[<object>foo</object>]' );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|