8
0

reinsertoperation.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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( [
  7. 'document/moveoperation',
  8. 'document/removeoperation'
  9. ], function( MoveOperation ) {
  10. /**
  11. * Operation to reinsert previously removed nodes back to the non-graveyard root.
  12. * This is basically MoveOperation but it returns RemoveOperation when reversed.
  13. * We achieve two goals: by having separate classes it's easier to distinguish whether move
  14. * operation is actually a remove/reinsert operation and fire proper events. Also it
  15. * will be easier to expand if we need to change operation's behavior if it is remove/reinsert.
  16. *
  17. * @class document.ReinsertOperation
  18. */
  19. class ReinsertOperation extends MoveOperation {
  20. /**
  21. * Creates a reverse operation.
  22. *
  23. * @returns {document.RemoveOperation} Reverse operation.
  24. */
  25. reverseOperation() {
  26. // Because of circular dependencies we need to re-require reinsert operation here.
  27. var RemoveOperation = CKEDITOR.require( 'document/removeoperation' );
  28. return new RemoveOperation( this.targetPosition, this.howMany, this.baseVersion + 1 );
  29. }
  30. }
  31. return ReinsertOperation;
  32. } );