operation.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. /**
  8. * Abstract base operation class.
  9. *
  10. * @abstract
  11. * @class document.operation.Operation
  12. */
  13. class Operation {
  14. /**
  15. * Base operation constructor.
  16. *
  17. * @param {Number} baseVersion {@link document.Document#version} on which the operation can be applied.
  18. * @constructor
  19. */
  20. constructor( baseVersion ) {
  21. /**
  22. * {@link document.Document#version} on which operation can be applied. If you try to
  23. * {@link document.Document#applyOperation apply} operation with different base version than the
  24. * {@link document.Document#version document version} the {@link document-applyOperation-wrong-version}
  25. * error is thrown.
  26. *
  27. * @property {Number}
  28. */
  29. this.baseVersion = baseVersion;
  30. /**
  31. * Operation type.
  32. *
  33. * @property {String} type
  34. */
  35. /**
  36. * {@link Document.Delta Delta} which the operation is a part of. This property is set by the
  37. * {@link Document.Delta delta} when the operations is added to it by the
  38. * {@link Document.Delta#addOperation} method.
  39. *
  40. * @property {Document.Delta} delta
  41. */
  42. /**
  43. * Creates and returns an operation that has the same parameters as this operation.
  44. *
  45. * @method clone
  46. * @returns {document.operation.Operation} Clone of this operation.
  47. */
  48. /**
  49. * Creates and returns a reverse operation. Reverse operation when executed right after
  50. * the original operation will bring back tree model state to the point before the original
  51. * operation execution. In other words, it reverses changes done by the original operation.
  52. *
  53. * Keep in mind that tree model state may change since executing the original operation,
  54. * so reverse operation will be "outdated". In that case you will need to
  55. * {@link document.operation.transform} it by all operations that were executed after the original operation.
  56. *
  57. * @method getReversed
  58. * @returns {document.operation.Operation} Reversed operation.
  59. */
  60. /**
  61. * Executes the operation - modifications described by the operation attributes
  62. * will be applied to the tree model.
  63. *
  64. * @protected
  65. * @method _execute
  66. * @returns {Object} Object with additional information about the applied changes. Always has `range`
  67. * property containing changed nodes. May have additional properties depending on the operation type.
  68. */
  69. }
  70. }
  71. return Operation;
  72. } );