|
|
@@ -11,6 +11,7 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import Enter from '@ckeditor/ckeditor5-enter/src/enter';
|
|
|
import Image from '@ckeditor/ckeditor5-image/src/image';
|
|
|
import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
|
|
|
+import Undo from '@ckeditor/ckeditor5-undo/src/undo';
|
|
|
|
|
|
import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
|
|
|
import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
@@ -23,7 +24,7 @@ describe( 'Heading integration', () => {
|
|
|
document.body.appendChild( element );
|
|
|
|
|
|
return ClassicTestEditor.create( element, {
|
|
|
- plugins: [ Paragraph, Heading, Enter, Image, ImageCaption ]
|
|
|
+ plugins: [ Paragraph, Heading, Enter, Image, ImageCaption, Undo ]
|
|
|
} )
|
|
|
.then( newEditor => {
|
|
|
editor = newEditor;
|
|
|
@@ -80,4 +81,24 @@ describe( 'Heading integration', () => {
|
|
|
);
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'with the undo feature', () => {
|
|
|
+ it( 'does not create undo steps when applied to an existing heading (collapsed selection)', () => {
|
|
|
+ setModelData( editor.document, '<heading1>foo[]bar</heading1>' );
|
|
|
+
|
|
|
+ editor.execute( 'heading1' );
|
|
|
+ expect( getModelData( editor.document ) ).to.equal( '<heading1>foo[]bar</heading1>' );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'does not create undo steps when applied to an existing heading (non–collapsed selection)', () => {
|
|
|
+ setModelData( editor.document, '<heading1>[foo</heading1><heading1>bar]</heading1>' );
|
|
|
+
|
|
|
+ editor.execute( 'heading1' );
|
|
|
+ expect( getModelData( editor.document ) ).to.equal( '<heading1>[foo</heading1><heading1>bar]</heading1>' );
|
|
|
+
|
|
|
+ expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|