8
0

insertoperation.js 855 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. CKEDITOR.define( [ 'document/operation', 'document/nodelist', 'document/removeoperation' ], function( Operation, NodeList ) {
  7. /**
  8. *
  9. *
  10. * @class document.Operation
  11. */
  12. class InsertOperation extends Operation {
  13. /**
  14. *
  15. */
  16. constructor( position, nodeList, baseVersion ) {
  17. super( baseVersion );
  18. this.position = position;
  19. this.nodeList = new NodeList( nodeList );
  20. }
  21. _execute() {
  22. this.position.parent.children.insert( this.position.offset, this.nodeList );
  23. }
  24. reverseOperation() {
  25. var RemoveOperation = CKEDITOR.require( 'document/removeoperation' );
  26. return new RemoveOperation( this.position, this.nodeList, this.baseVersion + 1 );
  27. }
  28. }
  29. return InsertOperation;
  30. } );