/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
import Paragraph from '../src/paragraph';
import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
import UndoEditing from '@ckeditor/ckeditor5-undo/src/undoediting';
import HeadingEditing from '@ckeditor/ckeditor5-heading/src/headingediting';
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
import {
getData as getModelData,
setData as setModelData
} from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
import { parse as parseView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
describe( 'Paragraph feature – integration', () => {
describe( 'with clipboard', () => {
it( 'pastes h1+h2+p as p+p+p when heading feature is not present', () => {
return VirtualTestEditor
.create( { plugins: [ Paragraph, Clipboard ] } )
.then( newEditor => {
const editor = newEditor;
const clipboard = editor.plugins.get( 'Clipboard' );
setModelData( editor.model, '
bom
' ) } ); expect( getModelData( editor.model ) ).to.equal( 'bom
' ) } ); expect( getModelData( editor.model ) ).to.equal( 'bom
a
b' ); expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false; editor.setData( '
Foobar.
' ); editor.model.change( writer => { writer.remove( root.getChild( 0 ) ); } ); expect( editor.getData( { trim: 'none' } ) ).to.equal( '' ); editor.execute( 'undo' ); expect( editor.getData( { trim: 'none' } ) ).to.equal( '
Foobar.
' ); editor.execute( 'redo' ); expect( editor.getData( { trim: 'none' } ) ).to.equal( '' ); editor.execute( 'undo' ); expect( editor.getData( { trim: 'none' } ) ).to.equal( '
Foobar.
' ); } ); } ); it( 'fixing empty roots should be transparent to undo - multiple roots', () => { return VirtualTestEditor .create( { plugins: [ Paragraph, UndoEditing ] } ) .then( newEditor => { const editor = newEditor; const doc = editor.model.document; const root = doc.getRoot(); const otherRoot = doc.createRoot( '$root', 'otherRoot' ); editor.data.set( { main: 'Foobar.
' } ); editor.data.set( { otherRoot: 'Foobar.
' } ); editor.model.change( writer => { writer.remove( root.getChild( 0 ) ); } ); editor.model.change( writer => { writer.remove( otherRoot.getChild( 0 ) ); } ); expect( editor.data.get( { rootName: 'main', trim: 'none' } ) ).to.equal( '' ); expect( editor.data.get( { rootName: 'otherRoot', trim: 'none' } ) ).to.equal( '
' ); editor.execute( 'undo' ); expect( editor.data.get( { rootName: 'main', trim: 'none' } ) ).to.equal( '
' ); expect( editor.data.get( { rootName: 'otherRoot', trim: 'none' } ) ).to.equal( '
Foobar.
' ); editor.execute( 'undo' ); expect( editor.data.get( { rootName: 'main', trim: 'none' } ) ).to.equal( 'Foobar.
' ); expect( editor.data.get( { rootName: 'otherRoot', trim: 'none' } ) ).to.equal( 'Foobar.
' ); } ); } ); } ); } );