/** * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ import ModelTestEditor from '/tests/ckeditor5/_utils/modeltesteditor.js'; import DeleteCommand from '/ckeditor5/typing/deletecommand.js'; import UndoEngine from '/ckeditor5/undo/undoengine.js'; import { getData, setData } from '/tests/engine/_utils/model.js'; let editor, doc; beforeEach( () => { return ModelTestEditor.create( { features: [ UndoEngine ], undo: { step: 3 } } ) .then( newEditor => { editor = newEditor; doc = editor.document; const command = new DeleteCommand( editor, 'backward' ); editor.commands.set( 'delete', command ); doc.schema.registerItem( 'p', '$block' ); doc.schema.registerItem( 'img', '$inline' ); doc.schema.allow( { name: '$text', inside: 'img' } ); } ); } ); function assertOutput( output ) { expect( getData( doc ) ).to.equal( output ); } describe( 'DeleteCommand integration', () => { it( 'deletes characters (and group changes in batches) and rollbacks', () => { setData( doc, '
123456789
123456789
123456789
123456
123456789
1
2
3
4
5
6
1
2
3
4
5
6
123456
does not count. // It's not the most elegant solution, but is the best if we don't want to make complicated algorithm. assertOutput( '
123
123456
12345
78
' ); editor.execute( 'delete' ); editor.execute( 'delete' ); editor.execute( 'delete' ); editor.execute( 'undo' ); assertOutput( '1234
12345
78
' ); } ); } );