reinsertoperation.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. * See {@link document.Operation#getReversed}.
  22. */
  23. getReversed() {
  24. // Because of circular dependencies we need to re-require reinsert operation here.
  25. var RemoveOperation = CKEDITOR.require( 'document/removeoperation' );
  26. return new RemoveOperation( this.targetPosition, this.howMany, this.baseVersion + 1 );
  27. }
  28. }
  29. return ReinsertOperation;
  30. } );