|
@@ -9,9 +9,9 @@ import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictest
|
|
|
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
-import HorizontalRuleEditing from '../src/horizontalruleediting';
|
|
|
|
|
|
|
+import HorizontalLineEditing from '../src/horizontallineediting';
|
|
|
|
|
|
|
|
-describe( 'HorizontalRuleCommand', () => {
|
|
|
|
|
|
|
+describe( 'HorizontalLineCommand', () => {
|
|
|
let editor, model, editorElement, command;
|
|
let editor, model, editorElement, command;
|
|
|
|
|
|
|
|
testUtils.createSinonSandbox();
|
|
testUtils.createSinonSandbox();
|
|
@@ -22,12 +22,12 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
|
|
|
|
|
return ClassicTestEditor
|
|
return ClassicTestEditor
|
|
|
.create( editorElement, {
|
|
.create( editorElement, {
|
|
|
- plugins: [ Paragraph, HorizontalRuleEditing ]
|
|
|
|
|
|
|
+ plugins: [ Paragraph, HorizontalLineEditing ]
|
|
|
} )
|
|
} )
|
|
|
.then( newEditor => {
|
|
.then( newEditor => {
|
|
|
editor = newEditor;
|
|
editor = newEditor;
|
|
|
model = editor.model;
|
|
model = editor.model;
|
|
|
- command = editor.commands.get( 'horizontalRule' );
|
|
|
|
|
|
|
+ command = editor.commands.get( 'horizontalLine' );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -68,8 +68,8 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should be false when the selection is on other horizontal rule element', () => {
|
|
|
|
|
- setModelData( model, '[<horizontalRule></horizontalRule>]' );
|
|
|
|
|
|
|
+ it( 'should be false when the selection is on other horizontal line element', () => {
|
|
|
|
|
+ setModelData( model, '[<horizontalLine></horizontalLine>]' );
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -81,7 +81,7 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should be true when the selection is inside block element inside isLimit element which allows horizontal rule', () => {
|
|
|
|
|
|
|
+ it( 'should be true when the selection is inside block element inside isLimit element which allows horizontal line', () => {
|
|
|
model.schema.register( 'table', { allowWhere: '$block', isLimit: true, isObject: true, isBlock: true } );
|
|
model.schema.register( 'table', { allowWhere: '$block', isLimit: true, isObject: true, isBlock: true } );
|
|
|
model.schema.register( 'tableRow', { allowIn: 'table', isLimit: true } );
|
|
model.schema.register( 'tableRow', { allowIn: 'table', isLimit: true } );
|
|
|
model.schema.register( 'tableCell', { allowIn: 'tableRow', isLimit: true } );
|
|
model.schema.register( 'tableCell', { allowIn: 'tableRow', isLimit: true } );
|
|
@@ -93,12 +93,12 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
setModelData( model, '<table><tableRow><tableCell><paragraph>foo[]</paragraph></tableCell></tableRow></table>' );
|
|
setModelData( model, '<table><tableRow><tableCell><paragraph>foo[]</paragraph></tableCell></tableRow></table>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should be false when schema disallows horizontal rule', () => {
|
|
|
|
|
|
|
+ it( 'should be false when schema disallows horizontal line', () => {
|
|
|
model.schema.register( 'block', { inheritAllFrom: '$block' } );
|
|
model.schema.register( 'block', { inheritAllFrom: '$block' } );
|
|
|
model.schema.extend( 'paragraph', { allowIn: 'block' } );
|
|
model.schema.extend( 'paragraph', { allowIn: 'block' } );
|
|
|
- // Block horizontal rule in block.
|
|
|
|
|
|
|
+ // Block horizontal line in block.
|
|
|
model.schema.addChildCheck( ( context, childDefinition ) => {
|
|
model.schema.addChildCheck( ( context, childDefinition ) => {
|
|
|
- if ( childDefinition.name === 'horizontalRule' && context.last.name === 'block' ) {
|
|
|
|
|
|
|
+ if ( childDefinition.name === 'horizontalLine' && context.last.name === 'block' ) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
} );
|
|
} );
|
|
@@ -131,7 +131,7 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
sinon.assert.calledOnce( spy );
|
|
sinon.assert.calledOnce( spy );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should insert a horizontal rule in an empty root and select it (a paragraph cannot be inserted)', () => {
|
|
|
|
|
|
|
+ it( 'should insert a horizontal line in an empty root and select it (a paragraph cannot be inserted)', () => {
|
|
|
// Block a paragraph in $root.
|
|
// Block a paragraph in $root.
|
|
|
model.schema.addChildCheck( ( context, childDefinition ) => {
|
|
model.schema.addChildCheck( ( context, childDefinition ) => {
|
|
|
if ( childDefinition.name === 'paragraph' && context.last.name === '$root' ) {
|
|
if ( childDefinition.name === 'paragraph' && context.last.name === '$root' ) {
|
|
@@ -143,116 +143,116 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
- expect( getModelData( model ) ).to.equal( '[<horizontalRule></horizontalRule>]' );
|
|
|
|
|
|
|
+ expect( getModelData( model ) ).to.equal( '[<horizontalLine></horizontalLine>]' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should split an element where selection is placed and insert a horizontal rule (non-collapsed selection)', () => {
|
|
|
|
|
|
|
+ it( 'should split an element where selection is placed and insert a horizontal line (non-collapsed selection)', () => {
|
|
|
setModelData( model, '<paragraph>f[o]o</paragraph>' );
|
|
setModelData( model, '<paragraph>f[o]o</paragraph>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<paragraph>f</paragraph><horizontalRule></horizontalRule><paragraph>[]o</paragraph>'
|
|
|
|
|
|
|
+ '<paragraph>f</paragraph><horizontalLine></horizontalLine><paragraph>[]o</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should split an element where selection is placed and insert a horizontal rule (collapsed selection)', () => {
|
|
|
|
|
|
|
+ it( 'should split an element where selection is placed and insert a horizontal line (collapsed selection)', () => {
|
|
|
setModelData( model, '<paragraph>fo[]o</paragraph>' );
|
|
setModelData( model, '<paragraph>fo[]o</paragraph>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<paragraph>fo</paragraph><horizontalRule></horizontalRule><paragraph>[]o</paragraph>'
|
|
|
|
|
|
|
+ '<paragraph>fo</paragraph><horizontalLine></horizontalLine><paragraph>[]o</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should create an empty paragraph after inserting a horizontal rule after a paragraph and place selection inside', () => {
|
|
|
|
|
|
|
+ it( 'should create an empty paragraph after inserting a horizontal line after a paragraph and place selection inside', () => {
|
|
|
setModelData( model, '<paragraph>foo[]</paragraph>' );
|
|
setModelData( model, '<paragraph>foo[]</paragraph>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<paragraph>foo</paragraph><horizontalRule></horizontalRule><paragraph>[]</paragraph>'
|
|
|
|
|
|
|
+ '<paragraph>foo</paragraph><horizontalLine></horizontalLine><paragraph>[]</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should create an empty paragraph after inserting a horizontal rule after a heading and place selection inside', () => {
|
|
|
|
|
|
|
+ it( 'should create an empty paragraph after inserting a horizontal line after a heading and place selection inside', () => {
|
|
|
setModelData( model, '<heading1>foo[]</heading1>' );
|
|
setModelData( model, '<heading1>foo[]</heading1>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<heading1>foo</heading1><horizontalRule></horizontalRule><paragraph>[]</paragraph>'
|
|
|
|
|
|
|
+ '<heading1>foo</heading1><horizontalLine></horizontalLine><paragraph>[]</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should create an empty paragraph after inserting a horizontal rule and next element must not having text', () => {
|
|
|
|
|
|
|
+ it( 'should create an empty paragraph after inserting a horizontal line and next element must not having text', () => {
|
|
|
setModelData( model, '<paragraph>foo[]</paragraph><media></media>' );
|
|
setModelData( model, '<paragraph>foo[]</paragraph><media></media>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<paragraph>foo</paragraph><horizontalRule></horizontalRule><paragraph>[]</paragraph><media></media>'
|
|
|
|
|
|
|
+ '<paragraph>foo</paragraph><horizontalLine></horizontalLine><paragraph>[]</paragraph><media></media>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should create an empty paragraph after inserting a horizontal rule in heading and next element must not having text', () => {
|
|
|
|
|
|
|
+ it( 'should create an empty paragraph after inserting a horizontal line in heading and next element must not having text', () => {
|
|
|
setModelData( model, '<heading1>foo[]</heading1><media></media>' );
|
|
setModelData( model, '<heading1>foo[]</heading1><media></media>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<heading1>foo</heading1><horizontalRule></horizontalRule><paragraph>[]</paragraph><media></media>'
|
|
|
|
|
|
|
+ '<heading1>foo</heading1><horizontalLine></horizontalLine><paragraph>[]</paragraph><media></media>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should not create an empty paragraph if a horizontal rule split an element with text', () => {
|
|
|
|
|
|
|
+ it( 'should not create an empty paragraph if a horizontal line split an element with text', () => {
|
|
|
setModelData( model, '<heading1>foo[]bar</heading1>' );
|
|
setModelData( model, '<heading1>foo[]bar</heading1>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<heading1>foo</heading1><horizontalRule></horizontalRule><heading1>[]bar</heading1>'
|
|
|
|
|
|
|
+ '<heading1>foo</heading1><horizontalLine></horizontalLine><heading1>[]bar</heading1>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should replace an empty paragraph with a horizontal rule and insert another paragraph next to', () => {
|
|
|
|
|
|
|
+ it( 'should replace an empty paragraph with a horizontal line and insert another paragraph next to', () => {
|
|
|
setModelData( model, '<paragraph>[]</paragraph>' );
|
|
setModelData( model, '<paragraph>[]</paragraph>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<horizontalRule></horizontalRule><paragraph>[]</paragraph>'
|
|
|
|
|
|
|
+ '<horizontalLine></horizontalLine><paragraph>[]</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should replace an empty paragraph with a horizontal rule and move the selection to next paragraph', () => {
|
|
|
|
|
|
|
+ it( 'should replace an empty paragraph with a horizontal line and move the selection to next paragraph', () => {
|
|
|
setModelData( model, '<paragraph>foo</paragraph><paragraph>[]</paragraph><paragraph>bar</paragraph>' );
|
|
setModelData( model, '<paragraph>foo</paragraph><paragraph>[]</paragraph><paragraph>bar</paragraph>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<paragraph>foo</paragraph><horizontalRule></horizontalRule><paragraph>[]bar</paragraph>'
|
|
|
|
|
|
|
+ '<paragraph>foo</paragraph><horizontalLine></horizontalLine><paragraph>[]bar</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should replace an empty paragraph with a horizontal rule and move the selection to next element that has text', () => {
|
|
|
|
|
|
|
+ it( 'should replace an empty paragraph with a horizontal line and move the selection to next element that has text', () => {
|
|
|
setModelData( model, '<paragraph>foo</paragraph><paragraph>[]</paragraph><heading1>bar</heading1>' );
|
|
setModelData( model, '<paragraph>foo</paragraph><paragraph>[]</paragraph><heading1>bar</heading1>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<paragraph>foo</paragraph><horizontalRule></horizontalRule><heading1>[]bar</heading1>'
|
|
|
|
|
|
|
+ '<paragraph>foo</paragraph><horizontalLine></horizontalLine><heading1>[]bar</heading1>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should replace an empty block element with a horizontal rule and insert a paragraph next to', () => {
|
|
|
|
|
|
|
+ it( 'should replace an empty block element with a horizontal line and insert a paragraph next to', () => {
|
|
|
setModelData( model, '<heading1>[]</heading1>' );
|
|
setModelData( model, '<heading1>[]</heading1>' );
|
|
|
|
|
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<horizontalRule></horizontalRule><paragraph>[]</paragraph>'
|
|
|
|
|
|
|
+ '<horizontalLine></horizontalLine><paragraph>[]</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -262,7 +262,7 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<paragraph>foo</paragraph><horizontalRule></horizontalRule><heading1>[]bar</heading1>'
|
|
|
|
|
|
|
+ '<paragraph>foo</paragraph><horizontalLine></horizontalLine><heading1>[]bar</heading1>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -272,7 +272,7 @@ describe( 'HorizontalRuleCommand', () => {
|
|
|
command.execute();
|
|
command.execute();
|
|
|
|
|
|
|
|
expect( getModelData( model ) ).to.equal(
|
|
expect( getModelData( model ) ).to.equal(
|
|
|
- '<heading1>foo</heading1><horizontalRule></horizontalRule><paragraph>[]bar</paragraph>'
|
|
|
|
|
|
|
+ '<heading1>foo</heading1><horizontalLine></horizontalLine><paragraph>[]bar</paragraph>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|