operation.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * {@link Document.Delta Delta} which the operation is a part of. This property is set by the
  32. * {@link Document.Delta delta} when the operations is added to it by the
  33. * {@link Document.Delta#addOperation} method.
  34. *
  35. * @property {Document.Delta} delta
  36. */
  37. /**
  38. * Creates and returns an operation that has the same parameters as this operation.
  39. *
  40. * @method clone
  41. * @returns {document.operation.Operation} Clone of this operation.
  42. */
  43. /**
  44. * Creates and returns a reverse operation. Reverse operation when executed right after
  45. * the original operation will bring back tree model state to the point before the original
  46. * operation execution. In other words, it reverses changes done by the original operation.
  47. *
  48. * Keep in mind that tree model state may change since executing the original operation,
  49. * so reverse operation will be "outdated". In that case you will need to
  50. * {@link document.operation.transform} it by all operations that were executed after the original operation.
  51. *
  52. * @method getReversed
  53. * @returns {document.operation.Operation} Reversed operation.
  54. */
  55. /**
  56. * Executes the operation - modifications described by the operation attributes
  57. * will be applied to the tree model.
  58. *
  59. * @method _execute
  60. * @protected
  61. */
  62. }
  63. }
  64. return Operation;
  65. } );