8
0

reinsertoperation.js 1.2 KB

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