|
|
@@ -4,17 +4,22 @@
|
|
|
*/
|
|
|
|
|
|
import Autoformat from '../src/autoformat';
|
|
|
+
|
|
|
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import ListEngine from '@ckeditor/ckeditor5-list/src/listengine';
|
|
|
import HeadingEngine from '@ckeditor/ckeditor5-heading/src/headingengine';
|
|
|
import BoldEngine from '@ckeditor/ckeditor5-basic-styles/src/boldengine';
|
|
|
import ItalicEngine from '@ckeditor/ckeditor5-basic-styles/src/italicengine';
|
|
|
import BlockQuoteEngine from '@ckeditor/ckeditor5-block-quote/src/blockquoteengine';
|
|
|
-import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
|
|
|
import Enter from '@ckeditor/ckeditor5-enter/src/enter';
|
|
|
+
|
|
|
+import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
|
|
|
+
|
|
|
import { setData, getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
|
|
|
+import Command from '@ckeditor/ckeditor5-core/src/command/command';
|
|
|
+
|
|
|
testUtils.createSinonSandbox();
|
|
|
|
|
|
describe( 'Autoformat', () => {
|
|
|
@@ -31,6 +36,10 @@ describe( 'Autoformat', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
+ afterEach( () => {
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+
|
|
|
describe( 'Bulleted list', () => {
|
|
|
it( 'should replace asterisk with bulleted list item', () => {
|
|
|
setData( doc, '<paragraph>*[]</paragraph>' );
|
|
|
@@ -99,7 +108,7 @@ describe( 'Autoformat', () => {
|
|
|
expect( getData( doc ) ).to.equal( '<heading2>[]</heading2>' );
|
|
|
} );
|
|
|
|
|
|
- it( 'should not replace minus character when inside heading', () => {
|
|
|
+ it( 'should not replace hash character when inside heading', () => {
|
|
|
setData( doc, '<heading1>#[]</heading1>' );
|
|
|
doc.enqueueChanges( () => {
|
|
|
batch.insert( doc.selection.getFirstPosition(), ' ' );
|
|
|
@@ -107,6 +116,53 @@ describe( 'Autoformat', () => {
|
|
|
|
|
|
expect( getData( doc ) ).to.equal( '<heading1># []</heading1>' );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should work with heading1-heading6 commands regardless of the config of the heading feature', () => {
|
|
|
+ const spy1 = sinon.spy();
|
|
|
+ const spy6 = sinon.spy();
|
|
|
+
|
|
|
+ class Heading6 extends Command {
|
|
|
+ _doExecute() {
|
|
|
+ spy6();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ class Heading1 extends Command {
|
|
|
+ _doExecute() {
|
|
|
+ spy1();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function HeadingPlugin( editor ) {
|
|
|
+ editor.commands.set( 'heading1', new Heading1() );
|
|
|
+ editor.commands.set( 'heading6', new Heading6() );
|
|
|
+ }
|
|
|
+
|
|
|
+ return VirtualTestEditor
|
|
|
+ .create( {
|
|
|
+ plugins: [
|
|
|
+ Paragraph, Autoformat, HeadingPlugin
|
|
|
+ ]
|
|
|
+ } )
|
|
|
+ .then( editor => {
|
|
|
+ const doc = editor.document;
|
|
|
+
|
|
|
+ setData( doc, '<paragraph>#[]</paragraph>' );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), ' ' );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( spy1.calledOnce ).to.be.true;
|
|
|
+
|
|
|
+ setData( doc, '<paragraph>######[]</paragraph>' );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), ' ' );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( spy6.calledOnce ).to.be.true;
|
|
|
+
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'Block quote', () => {
|