| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- 'use strict';
- CKEDITOR.define( [
- 'document/operation/operation',
- 'document/nodelist',
- 'document/operation/removeoperation'
- ], ( Operation, NodeList ) => {
- /**
- * Operation to insert list of nodes on the given position in the tree data model.
- *
- * @class document.operation.InsertOperation
- */
- class InsertOperation extends Operation {
- /**
- * Creates an insert operation.
- *
- * @param {document.Position} position Position of insertion.
- * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes The list of nodes to be inserted.
- * List of nodes can be any type accepted by the {@link document.NodeList} constructor.
- * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
- * @constructor
- */
- constructor( position, nodes, baseVersion ) {
- super( baseVersion );
- /**
- * Position of insertion.
- *
- * @readonly
- * @type {document.Position}
- */
- this.position = position;
- /**
- * List of nodes to insert.
- *
- * @readonly
- * @type {document.NodeList}
- */
- this.nodeList = new NodeList( nodes );
- }
- _execute() {
- this.position.parent.insertChildren( this.position.offset, this.nodeList );
- }
- getReversed() {
- // Because of circular dependencies we need to re-require remove operation here.
- const RemoveOperation = CKEDITOR.require( 'document/operation/removeoperation' );
- return new RemoveOperation( this.position, this.nodeList.length, this.baseVersion + 1 );
- }
- clone() {
- return new InsertOperation( this.position, this.nodeList, this.baseVersion );
- }
- }
- return InsertOperation;
- } );
|