@ckeditor/ckeditor5-engine 35.0.1 → 35.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/package.json +30 -24
  3. package/src/controller/datacontroller.js +467 -561
  4. package/src/controller/editingcontroller.js +168 -204
  5. package/src/conversion/conversion.js +541 -565
  6. package/src/conversion/conversionhelpers.js +24 -28
  7. package/src/conversion/downcastdispatcher.js +457 -686
  8. package/src/conversion/downcasthelpers.js +1583 -1965
  9. package/src/conversion/mapper.js +518 -707
  10. package/src/conversion/modelconsumable.js +240 -283
  11. package/src/conversion/upcastdispatcher.js +372 -718
  12. package/src/conversion/upcasthelpers.js +707 -818
  13. package/src/conversion/viewconsumable.js +524 -581
  14. package/src/dataprocessor/basichtmlwriter.js +12 -16
  15. package/src/dataprocessor/dataprocessor.js +5 -0
  16. package/src/dataprocessor/htmldataprocessor.js +100 -116
  17. package/src/dataprocessor/htmlwriter.js +1 -18
  18. package/src/dataprocessor/xmldataprocessor.js +116 -137
  19. package/src/dev-utils/model.js +260 -352
  20. package/src/dev-utils/operationreplayer.js +106 -126
  21. package/src/dev-utils/utils.js +34 -51
  22. package/src/dev-utils/view.js +632 -753
  23. package/src/index.js +0 -11
  24. package/src/model/batch.js +111 -127
  25. package/src/model/differ.js +988 -1233
  26. package/src/model/document.js +340 -449
  27. package/src/model/documentfragment.js +327 -364
  28. package/src/model/documentselection.js +996 -1189
  29. package/src/model/element.js +306 -410
  30. package/src/model/history.js +224 -262
  31. package/src/model/item.js +5 -0
  32. package/src/model/liveposition.js +84 -145
  33. package/src/model/liverange.js +108 -185
  34. package/src/model/markercollection.js +379 -480
  35. package/src/model/model.js +883 -1034
  36. package/src/model/node.js +419 -463
  37. package/src/model/nodelist.js +175 -201
  38. package/src/model/operation/attributeoperation.js +153 -182
  39. package/src/model/operation/detachoperation.js +64 -83
  40. package/src/model/operation/insertoperation.js +135 -166
  41. package/src/model/operation/markeroperation.js +114 -140
  42. package/src/model/operation/mergeoperation.js +163 -191
  43. package/src/model/operation/moveoperation.js +157 -187
  44. package/src/model/operation/nooperation.js +28 -38
  45. package/src/model/operation/operation.js +106 -125
  46. package/src/model/operation/operationfactory.js +30 -34
  47. package/src/model/operation/renameoperation.js +109 -135
  48. package/src/model/operation/rootattributeoperation.js +155 -188
  49. package/src/model/operation/splitoperation.js +196 -232
  50. package/src/model/operation/transform.js +1833 -2204
  51. package/src/model/operation/utils.js +140 -204
  52. package/src/model/position.js +899 -1053
  53. package/src/model/range.js +910 -1028
  54. package/src/model/rootelement.js +77 -97
  55. package/src/model/schema.js +1189 -1835
  56. package/src/model/selection.js +745 -862
  57. package/src/model/text.js +90 -114
  58. package/src/model/textproxy.js +204 -240
  59. package/src/model/treewalker.js +316 -397
  60. package/src/model/typecheckable.js +16 -0
  61. package/src/model/utils/autoparagraphing.js +32 -44
  62. package/src/model/utils/deletecontent.js +334 -418
  63. package/src/model/utils/findoptimalinsertionrange.js +25 -36
  64. package/src/model/utils/getselectedcontent.js +96 -118
  65. package/src/model/utils/insertcontent.js +654 -773
  66. package/src/model/utils/insertobject.js +96 -119
  67. package/src/model/utils/modifyselection.js +120 -158
  68. package/src/model/utils/selection-post-fixer.js +153 -201
  69. package/src/model/writer.js +1305 -1474
  70. package/src/view/attributeelement.js +189 -225
  71. package/src/view/containerelement.js +75 -85
  72. package/src/view/document.js +172 -215
  73. package/src/view/documentfragment.js +200 -249
  74. package/src/view/documentselection.js +338 -367
  75. package/src/view/domconverter.js +1370 -1617
  76. package/src/view/downcastwriter.js +1747 -2076
  77. package/src/view/editableelement.js +81 -97
  78. package/src/view/element.js +739 -890
  79. package/src/view/elementdefinition.js +5 -0
  80. package/src/view/emptyelement.js +82 -92
  81. package/src/view/filler.js +35 -50
  82. package/src/view/item.js +5 -0
  83. package/src/view/matcher.js +260 -559
  84. package/src/view/node.js +274 -360
  85. package/src/view/observer/arrowkeysobserver.js +19 -28
  86. package/src/view/observer/bubblingemittermixin.js +120 -263
  87. package/src/view/observer/bubblingeventinfo.js +47 -55
  88. package/src/view/observer/clickobserver.js +7 -13
  89. package/src/view/observer/compositionobserver.js +14 -24
  90. package/src/view/observer/domeventdata.js +57 -67
  91. package/src/view/observer/domeventobserver.js +40 -64
  92. package/src/view/observer/fakeselectionobserver.js +81 -96
  93. package/src/view/observer/focusobserver.js +45 -61
  94. package/src/view/observer/inputobserver.js +7 -13
  95. package/src/view/observer/keyobserver.js +17 -27
  96. package/src/view/observer/mouseobserver.js +7 -14
  97. package/src/view/observer/mutationobserver.js +220 -315
  98. package/src/view/observer/observer.js +81 -102
  99. package/src/view/observer/selectionobserver.js +191 -246
  100. package/src/view/observer/tabobserver.js +23 -36
  101. package/src/view/placeholder.js +128 -173
  102. package/src/view/position.js +350 -401
  103. package/src/view/range.js +453 -513
  104. package/src/view/rawelement.js +85 -112
  105. package/src/view/renderer.js +874 -1018
  106. package/src/view/rooteditableelement.js +80 -90
  107. package/src/view/selection.js +608 -689
  108. package/src/view/styles/background.js +43 -44
  109. package/src/view/styles/border.js +220 -276
  110. package/src/view/styles/margin.js +8 -17
  111. package/src/view/styles/padding.js +8 -16
  112. package/src/view/styles/utils.js +127 -160
  113. package/src/view/stylesmap.js +728 -905
  114. package/src/view/text.js +102 -126
  115. package/src/view/textproxy.js +144 -170
  116. package/src/view/treewalker.js +383 -479
  117. package/src/view/typecheckable.js +19 -0
  118. package/src/view/uielement.js +166 -187
  119. package/src/view/upcastwriter.js +395 -449
  120. package/src/view/view.js +569 -664
  121. package/src/dataprocessor/dataprocessor.jsdoc +0 -64
  122. package/src/model/item.jsdoc +0 -14
  123. package/src/view/elementdefinition.jsdoc +0 -59
  124. package/src/view/item.jsdoc +0 -14
@@ -2,275 +2,237 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  import { CKEditorError } from '@ckeditor/ckeditor5-utils';
7
-
8
6
  /**
9
7
  * @module engine/model/history
10
8
  */
11
-
12
9
  /**
13
10
  * `History` keeps the track of all the operations applied to the {@link module:engine/model/document~Document document}.
14
11
  */
15
12
  export default class History {
16
- /**
17
- * Creates an empty History instance.
18
- */
19
- constructor() {
20
- /**
21
- * Operations added to the history.
22
- *
23
- * @private
24
- * @readonly
25
- * @type {Array.<module:engine/model/operation/operation~Operation>}
26
- */
27
- this._operations = [];
28
-
29
- /**
30
- * Holds an information which {@link module:engine/model/operation/operation~Operation operation} undoes which
31
- * {@link module:engine/model/operation/operation~Operation operation}.
32
- *
33
- * Keys of the map are "undoing operations", that is operations that undone some other operations. For each key, the
34
- * value is an operation that has been undone by the "undoing operation".
35
- *
36
- * @private
37
- * @member {Map} module:engine/model/history~History#_undoPairs
38
- */
39
- this._undoPairs = new Map();
40
-
41
- /**
42
- * Holds all undone operations.
43
- *
44
- * @private
45
- * @type {Set.<module:engine/model/operation/operation~Operation>}
46
- */
47
- this._undoneOperations = new Set();
48
-
49
- /**
50
- * A map that allows retrieving the operations fast based on the given base version.
51
- *
52
- * @private
53
- * @type Map.<Number,Number>
54
- */
55
- this._baseVersionToOperationIndex = new Map();
56
-
57
- /**
58
- * The history version.
59
- *
60
- * @private
61
- * @type {Number}
62
- */
63
- this._version = 0;
64
-
65
- /**
66
- * The gap pairs kept in the <from,to> format.
67
- *
68
- * Anytime the `history.version` is set to a version larger than `history.version + 1`,
69
- * a new <lastHistoryVersion, newHistoryVersion> entry is added to the map.
70
- *
71
- * @private
72
- * @type Map.<number,number>
73
- */
74
- this._gaps = new Map();
75
- }
76
-
77
- /**
78
- * The version of the last operation in the history.
79
- *
80
- * The history version is incremented automatically when a new operation is added to the history.
81
- * Setting the version manually should be done only in rare circumstances when a gap is planned
82
- * between history versions. When doing so, a gap will be created and the history will accept adding
83
- * an operation with base version equal to the new history version.
84
- *
85
- * @type {Number}
86
- */
87
- get version() {
88
- return this._version;
89
- }
90
-
91
- set version( version ) {
92
- // Store a gap if there are some operations already in the history and the
93
- // new version does not increment the latest one.
94
- if ( this._operations.length && version > this._version + 1 ) {
95
- this._gaps.set( this._version, version );
96
- }
97
-
98
- this._version = version;
99
- }
100
-
101
- /**
102
- * The last history operation.
103
- *
104
- * @readonly
105
- * @type {module:engine/model/operation/operation~Operation|undefined}
106
- */
107
- get lastOperation() {
108
- return this._operations[ this._operations.length - 1 ];
109
- }
110
-
111
- /**
112
- * Adds an operation to the history and increments the history version.
113
- *
114
- * The operation's base version should be equal to the history version. Otherwise an error is thrown.
115
- *
116
- * @param {module:engine/model/operation/operation~Operation} operation Operation to add.
117
- */
118
- addOperation( operation ) {
119
- if ( operation.baseVersion !== this.version ) {
120
- /**
121
- * Only operations with matching versions can be added to the history.
122
- *
123
- * @error model-document-history-addoperation-incorrect-version
124
- * @param {Object} errorData The operation and the current document history version.
125
- */
126
- throw new CKEditorError( 'model-document-history-addoperation-incorrect-version', this, {
127
- operation,
128
- historyVersion: this.version
129
- } );
130
- }
131
-
132
- this._operations.push( operation );
133
- this._version++;
134
-
135
- this._baseVersionToOperationIndex.set( operation.baseVersion, this._operations.length - 1 );
136
- }
137
-
138
- /**
139
- * Returns operations from the given range of operation base versions that were added to the history.
140
- *
141
- * Note that there may be gaps in operations base versions.
142
- *
143
- * @param {Number} [fromBaseVersion] Base version from which operations should be returned (inclusive).
144
- * @param {Number} [toBaseVersion] Base version up to which operations should be returned (exclusive).
13
+ /**
14
+ * Creates an empty History instance.
15
+ */
16
+ constructor() {
17
+ /**
18
+ * Operations added to the history.
19
+ *
20
+ * @private
21
+ * @readonly
22
+ * @type {Array.<module:engine/model/operation/operation~Operation>}
23
+ */
24
+ this._operations = [];
25
+ /**
26
+ * Holds an information which {@link module:engine/model/operation/operation~Operation operation} undoes which
27
+ * {@link module:engine/model/operation/operation~Operation operation}.
28
+ *
29
+ * Keys of the map are "undoing operations", that is operations that undone some other operations. For each key, the
30
+ * value is an operation that has been undone by the "undoing operation".
31
+ *
32
+ * @private
33
+ * @member {Map} module:engine/model/history~History#_undoPairs
34
+ */
35
+ this._undoPairs = new Map();
36
+ /**
37
+ * Holds all undone operations.
38
+ *
39
+ * @private
40
+ * @type {Set.<module:engine/model/operation/operation~Operation>}
41
+ */
42
+ this._undoneOperations = new Set();
43
+ /**
44
+ * A map that allows retrieving the operations fast based on the given base version.
45
+ *
46
+ * @private
47
+ * @type Map.<Number,Number>
48
+ */
49
+ this._baseVersionToOperationIndex = new Map();
50
+ /**
51
+ * The history version.
52
+ *
53
+ * @private
54
+ * @type {Number}
55
+ */
56
+ this._version = 0;
57
+ /**
58
+ * The gap pairs kept in the <from,to> format.
59
+ *
60
+ * Anytime the `history.version` is set to a version larger than `history.version + 1`,
61
+ * a new <lastHistoryVersion, newHistoryVersion> entry is added to the map.
62
+ *
63
+ * @private
64
+ * @type Map.<number,number>
65
+ */
66
+ this._gaps = new Map();
67
+ }
68
+ /**
69
+ * The version of the last operation in the history.
70
+ *
71
+ * The history version is incremented automatically when a new operation is added to the history.
72
+ * Setting the version manually should be done only in rare circumstances when a gap is planned
73
+ * between history versions. When doing so, a gap will be created and the history will accept adding
74
+ * an operation with base version equal to the new history version.
75
+ *
76
+ * @type {Number}
77
+ */
78
+ get version() {
79
+ return this._version;
80
+ }
81
+ set version(version) {
82
+ // Store a gap if there are some operations already in the history and the
83
+ // new version does not increment the latest one.
84
+ if (this._operations.length && version > this._version + 1) {
85
+ this._gaps.set(this._version, version);
86
+ }
87
+ this._version = version;
88
+ }
89
+ /**
90
+ * The last history operation.
91
+ *
92
+ * @readonly
93
+ * @type {module:engine/model/operation/operation~Operation|undefined}
94
+ */
95
+ get lastOperation() {
96
+ return this._operations[this._operations.length - 1];
97
+ }
98
+ /**
99
+ * Adds an operation to the history and increments the history version.
100
+ *
101
+ * The operation's base version should be equal to the history version. Otherwise an error is thrown.
102
+ *
103
+ * @param {module:engine/model/operation/operation~Operation} operation Operation to add.
104
+ */
105
+ addOperation(operation) {
106
+ if (operation.baseVersion !== this.version) {
107
+ /**
108
+ * Only operations with matching versions can be added to the history.
109
+ *
110
+ * @error model-document-history-addoperation-incorrect-version
111
+ * @param {Object} errorData The operation and the current document history version.
112
+ */
113
+ throw new CKEditorError('model-document-history-addoperation-incorrect-version', this, {
114
+ operation,
115
+ historyVersion: this.version
116
+ });
117
+ }
118
+ this._operations.push(operation);
119
+ this._version++;
120
+ this._baseVersionToOperationIndex.set(operation.baseVersion, this._operations.length - 1);
121
+ }
122
+ /**
123
+ * Returns operations from the given range of operation base versions that were added to the history.
124
+ *
125
+ * Note that there may be gaps in operations base versions.
126
+ *
127
+ * @param {Number} [fromBaseVersion] Base version from which operations should be returned (inclusive).
128
+ * @param {Number} [toBaseVersion] Base version up to which operations should be returned (exclusive).
145
129
  * @returns {Array.<module:engine/model/operation/operation~Operation>} History operations for the given range, in chronological order.
146
- */
147
- getOperations( fromBaseVersion, toBaseVersion = this.version ) {
148
- // When there is no operation in the history, return an empty array.
149
- // After that we can be sure that `firstOperation`, `lastOperation` are not nullish.
150
- if ( !this._operations.length ) {
151
- return [];
152
- }
153
-
154
- const firstOperation = this._operations[ 0 ];
155
-
156
- if ( fromBaseVersion === undefined ) {
157
- fromBaseVersion = firstOperation.baseVersion;
158
- }
159
-
160
- // Change exclusive `toBaseVersion` to inclusive, so it will refer to the actual index.
161
- // Thanks to that mapping from base versions to operation indexes are possible.
162
- let inclusiveTo = toBaseVersion - 1;
163
-
164
- // Check if "from" or "to" point to a gap between versions.
165
- // If yes, then change the incorrect position to the proper side of the gap.
166
- // Thanks to it, it will be possible to get index of the operation.
167
- for ( const [ gapFrom, gapTo ] of this._gaps ) {
168
- if ( fromBaseVersion > gapFrom && fromBaseVersion < gapTo ) {
169
- fromBaseVersion = gapTo;
170
- }
171
-
172
- if ( inclusiveTo > gapFrom && inclusiveTo < gapTo ) {
173
- inclusiveTo = gapFrom - 1;
174
- }
175
- }
176
-
177
- // If the whole range is outside of the operation versions, then return an empty array.
178
- if ( inclusiveTo < firstOperation.baseVersion || fromBaseVersion > this.lastOperation.baseVersion ) {
179
- return [];
180
- }
181
-
182
- let fromIndex = this._baseVersionToOperationIndex.get( fromBaseVersion );
183
-
184
- // If the range starts before the first operation, then use the first operation as the range's start.
185
- if ( fromIndex === undefined ) {
186
- fromIndex = 0;
187
- }
188
-
189
- let toIndex = this._baseVersionToOperationIndex.get( inclusiveTo );
190
-
191
- // If the range ends after the last operation, then use the last operation as the range's end.
192
- if ( toIndex === undefined ) {
193
- toIndex = this._operations.length - 1;
194
- }
195
-
196
- // Return the part of the history operations based on the calculated start index and end index.
197
- return this._operations.slice(
198
- fromIndex,
199
-
200
- // The `toIndex` should be included in the returned operations, so add `1`.
201
- toIndex + 1
202
- );
203
- }
204
-
205
- /**
206
- * Returns operation from the history that bases on given `baseVersion`.
207
- *
208
- * @param {Number} baseVersion Base version of the operation to get.
209
- * @returns {module:engine/model/operation/operation~Operation|undefined} Operation with given base version or `undefined` if
210
- * there is no such operation in history.
211
- */
212
- getOperation( baseVersion ) {
213
- const operationIndex = this._baseVersionToOperationIndex.get( baseVersion );
214
-
215
- if ( operationIndex === undefined ) {
216
- return;
217
- }
218
-
219
- return this._operations[ operationIndex ];
220
- }
221
-
222
- /**
223
- * Marks in history that one operation is an operation that is undoing the other operation. By marking operation this way,
224
- * history is keeping more context information about operations, which helps in operational transformation.
225
- *
226
- * @param {module:engine/model/operation/operation~Operation} undoneOperation Operation which is undone by `undoingOperation`.
227
- * @param {module:engine/model/operation/operation~Operation} undoingOperation Operation which undoes `undoneOperation`.
228
- */
229
- setOperationAsUndone( undoneOperation, undoingOperation ) {
230
- this._undoPairs.set( undoingOperation, undoneOperation );
231
- this._undoneOperations.add( undoneOperation );
232
- }
233
-
234
- /**
235
- * Checks whether given `operation` is undoing any other operation.
236
- *
237
- * @param {module:engine/model/operation/operation~Operation} operation Operation to check.
238
- * @returns {Boolean} `true` if given `operation` is undoing any other operation, `false` otherwise.
239
- */
240
- isUndoingOperation( operation ) {
241
- return this._undoPairs.has( operation );
242
- }
243
-
244
- /**
245
- * Checks whether given `operation` has been undone by any other operation.
246
- *
247
- * @param {module:engine/model/operation/operation~Operation} operation Operation to check.
248
- * @returns {Boolean} `true` if given `operation` has been undone any other operation, `false` otherwise.
249
- */
250
- isUndoneOperation( operation ) {
251
- return this._undoneOperations.has( operation );
252
- }
253
-
254
- /**
255
- * For given `undoingOperation`, returns the operation which has been undone by it.
256
- *
257
- * @param {module:engine/model/operation/operation~Operation} undoingOperation
258
- * @returns {module:engine/model/operation/operation~Operation|undefined} Operation that has been undone by given
259
- * `undoingOperation` or `undefined` if given `undoingOperation` is not undoing any other operation.
260
- */
261
- getUndoneOperation( undoingOperation ) {
262
- return this._undoPairs.get( undoingOperation );
263
- }
264
-
265
- /**
266
- * Resets the history of operations.
267
- */
268
- reset() {
269
- this._version = 0;
270
- this._undoPairs = new Map();
271
- this._operations = [];
272
- this._undoneOperations = new Set();
273
- this._gaps = new Map();
274
- this._baseVersionToOperationIndex = new Map();
275
- }
130
+ */
131
+ getOperations(fromBaseVersion, toBaseVersion = this.version) {
132
+ // When there is no operation in the history, return an empty array.
133
+ // After that we can be sure that `firstOperation`, `lastOperation` are not nullish.
134
+ if (!this._operations.length) {
135
+ return [];
136
+ }
137
+ const firstOperation = this._operations[0];
138
+ if (fromBaseVersion === undefined) {
139
+ fromBaseVersion = firstOperation.baseVersion;
140
+ }
141
+ // Change exclusive `toBaseVersion` to inclusive, so it will refer to the actual index.
142
+ // Thanks to that mapping from base versions to operation indexes are possible.
143
+ let inclusiveTo = toBaseVersion - 1;
144
+ // Check if "from" or "to" point to a gap between versions.
145
+ // If yes, then change the incorrect position to the proper side of the gap.
146
+ // Thanks to it, it will be possible to get index of the operation.
147
+ for (const [gapFrom, gapTo] of this._gaps) {
148
+ if (fromBaseVersion > gapFrom && fromBaseVersion < gapTo) {
149
+ fromBaseVersion = gapTo;
150
+ }
151
+ if (inclusiveTo > gapFrom && inclusiveTo < gapTo) {
152
+ inclusiveTo = gapFrom - 1;
153
+ }
154
+ }
155
+ // If the whole range is outside of the operation versions, then return an empty array.
156
+ if (inclusiveTo < firstOperation.baseVersion || fromBaseVersion > this.lastOperation.baseVersion) {
157
+ return [];
158
+ }
159
+ let fromIndex = this._baseVersionToOperationIndex.get(fromBaseVersion);
160
+ // If the range starts before the first operation, then use the first operation as the range's start.
161
+ if (fromIndex === undefined) {
162
+ fromIndex = 0;
163
+ }
164
+ let toIndex = this._baseVersionToOperationIndex.get(inclusiveTo);
165
+ // If the range ends after the last operation, then use the last operation as the range's end.
166
+ if (toIndex === undefined) {
167
+ toIndex = this._operations.length - 1;
168
+ }
169
+ // Return the part of the history operations based on the calculated start index and end index.
170
+ return this._operations.slice(fromIndex,
171
+ // The `toIndex` should be included in the returned operations, so add `1`.
172
+ toIndex + 1);
173
+ }
174
+ /**
175
+ * Returns operation from the history that bases on given `baseVersion`.
176
+ *
177
+ * @param {Number} baseVersion Base version of the operation to get.
178
+ * @returns {module:engine/model/operation/operation~Operation|undefined} Operation with given base version or `undefined` if
179
+ * there is no such operation in history.
180
+ */
181
+ getOperation(baseVersion) {
182
+ const operationIndex = this._baseVersionToOperationIndex.get(baseVersion);
183
+ if (operationIndex === undefined) {
184
+ return;
185
+ }
186
+ return this._operations[operationIndex];
187
+ }
188
+ /**
189
+ * Marks in history that one operation is an operation that is undoing the other operation. By marking operation this way,
190
+ * history is keeping more context information about operations, which helps in operational transformation.
191
+ *
192
+ * @param {module:engine/model/operation/operation~Operation} undoneOperation Operation which is undone by `undoingOperation`.
193
+ * @param {module:engine/model/operation/operation~Operation} undoingOperation Operation which undoes `undoneOperation`.
194
+ */
195
+ setOperationAsUndone(undoneOperation, undoingOperation) {
196
+ this._undoPairs.set(undoingOperation, undoneOperation);
197
+ this._undoneOperations.add(undoneOperation);
198
+ }
199
+ /**
200
+ * Checks whether given `operation` is undoing any other operation.
201
+ *
202
+ * @param {module:engine/model/operation/operation~Operation} operation Operation to check.
203
+ * @returns {Boolean} `true` if given `operation` is undoing any other operation, `false` otherwise.
204
+ */
205
+ isUndoingOperation(operation) {
206
+ return this._undoPairs.has(operation);
207
+ }
208
+ /**
209
+ * Checks whether given `operation` has been undone by any other operation.
210
+ *
211
+ * @param {module:engine/model/operation/operation~Operation} operation Operation to check.
212
+ * @returns {Boolean} `true` if given `operation` has been undone any other operation, `false` otherwise.
213
+ */
214
+ isUndoneOperation(operation) {
215
+ return this._undoneOperations.has(operation);
216
+ }
217
+ /**
218
+ * For given `undoingOperation`, returns the operation which has been undone by it.
219
+ *
220
+ * @param {module:engine/model/operation/operation~Operation} undoingOperation
221
+ * @returns {module:engine/model/operation/operation~Operation|undefined} Operation that has been undone by given
222
+ * `undoingOperation` or `undefined` if given `undoingOperation` is not undoing any other operation.
223
+ */
224
+ getUndoneOperation(undoingOperation) {
225
+ return this._undoPairs.get(undoingOperation);
226
+ }
227
+ /**
228
+ * Resets the history of operations.
229
+ */
230
+ reset() {
231
+ this._version = 0;
232
+ this._undoPairs = new Map();
233
+ this._operations = [];
234
+ this._undoneOperations = new Set();
235
+ this._gaps = new Map();
236
+ this._baseVersionToOperationIndex = new Map();
237
+ }
276
238
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ export {};