@ckeditor/ckeditor5-engine 35.0.1 → 35.2.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.
- package/CHANGELOG.md +4 -4
- package/package.json +30 -24
- package/src/controller/datacontroller.js +467 -561
- package/src/controller/editingcontroller.js +168 -204
- package/src/conversion/conversion.js +541 -565
- package/src/conversion/conversionhelpers.js +24 -28
- package/src/conversion/downcastdispatcher.js +457 -686
- package/src/conversion/downcasthelpers.js +1583 -1965
- package/src/conversion/mapper.js +518 -707
- package/src/conversion/modelconsumable.js +240 -283
- package/src/conversion/upcastdispatcher.js +372 -718
- package/src/conversion/upcasthelpers.js +707 -818
- package/src/conversion/viewconsumable.js +524 -581
- package/src/dataprocessor/basichtmlwriter.js +12 -16
- package/src/dataprocessor/dataprocessor.js +5 -0
- package/src/dataprocessor/htmldataprocessor.js +100 -116
- package/src/dataprocessor/htmlwriter.js +1 -18
- package/src/dataprocessor/xmldataprocessor.js +116 -137
- package/src/dev-utils/model.js +260 -352
- package/src/dev-utils/operationreplayer.js +106 -126
- package/src/dev-utils/utils.js +34 -51
- package/src/dev-utils/view.js +632 -753
- package/src/index.js +0 -11
- package/src/model/batch.js +111 -127
- package/src/model/differ.js +988 -1233
- package/src/model/document.js +340 -449
- package/src/model/documentfragment.js +327 -364
- package/src/model/documentselection.js +996 -1189
- package/src/model/element.js +306 -410
- package/src/model/history.js +224 -262
- package/src/model/item.js +5 -0
- package/src/model/liveposition.js +84 -145
- package/src/model/liverange.js +108 -185
- package/src/model/markercollection.js +379 -480
- package/src/model/model.js +883 -1034
- package/src/model/node.js +419 -463
- package/src/model/nodelist.js +176 -201
- package/src/model/operation/attributeoperation.js +153 -182
- package/src/model/operation/detachoperation.js +64 -83
- package/src/model/operation/insertoperation.js +135 -166
- package/src/model/operation/markeroperation.js +114 -140
- package/src/model/operation/mergeoperation.js +163 -191
- package/src/model/operation/moveoperation.js +157 -187
- package/src/model/operation/nooperation.js +28 -38
- package/src/model/operation/operation.js +106 -125
- package/src/model/operation/operationfactory.js +30 -34
- package/src/model/operation/renameoperation.js +109 -135
- package/src/model/operation/rootattributeoperation.js +155 -188
- package/src/model/operation/splitoperation.js +196 -232
- package/src/model/operation/transform.js +1833 -2204
- package/src/model/operation/utils.js +140 -204
- package/src/model/position.js +980 -1053
- package/src/model/range.js +910 -1028
- package/src/model/rootelement.js +77 -97
- package/src/model/schema.js +1189 -1835
- package/src/model/selection.js +745 -862
- package/src/model/text.js +90 -114
- package/src/model/textproxy.js +204 -240
- package/src/model/treewalker.js +316 -397
- package/src/model/typecheckable.js +16 -0
- package/src/model/utils/autoparagraphing.js +32 -44
- package/src/model/utils/deletecontent.js +334 -418
- package/src/model/utils/findoptimalinsertionrange.js +25 -36
- package/src/model/utils/getselectedcontent.js +96 -118
- package/src/model/utils/insertcontent.js +757 -773
- package/src/model/utils/insertobject.js +96 -119
- package/src/model/utils/modifyselection.js +120 -158
- package/src/model/utils/selection-post-fixer.js +153 -201
- package/src/model/writer.js +1305 -1474
- package/src/view/attributeelement.js +189 -225
- package/src/view/containerelement.js +75 -85
- package/src/view/document.js +172 -215
- package/src/view/documentfragment.js +200 -249
- package/src/view/documentselection.js +338 -367
- package/src/view/domconverter.js +1370 -1617
- package/src/view/downcastwriter.js +1747 -2076
- package/src/view/editableelement.js +81 -97
- package/src/view/element.js +739 -890
- package/src/view/elementdefinition.js +5 -0
- package/src/view/emptyelement.js +82 -92
- package/src/view/filler.js +35 -50
- package/src/view/item.js +5 -0
- package/src/view/matcher.js +260 -559
- package/src/view/node.js +274 -360
- package/src/view/observer/arrowkeysobserver.js +19 -28
- package/src/view/observer/bubblingemittermixin.js +120 -263
- package/src/view/observer/bubblingeventinfo.js +47 -55
- package/src/view/observer/clickobserver.js +7 -13
- package/src/view/observer/compositionobserver.js +14 -24
- package/src/view/observer/domeventdata.js +57 -67
- package/src/view/observer/domeventobserver.js +40 -64
- package/src/view/observer/fakeselectionobserver.js +81 -96
- package/src/view/observer/focusobserver.js +45 -61
- package/src/view/observer/inputobserver.js +7 -13
- package/src/view/observer/keyobserver.js +17 -27
- package/src/view/observer/mouseobserver.js +7 -14
- package/src/view/observer/mutationobserver.js +220 -315
- package/src/view/observer/observer.js +81 -102
- package/src/view/observer/selectionobserver.js +199 -246
- package/src/view/observer/tabobserver.js +23 -36
- package/src/view/placeholder.js +128 -173
- package/src/view/position.js +350 -401
- package/src/view/range.js +453 -513
- package/src/view/rawelement.js +85 -112
- package/src/view/renderer.js +874 -1018
- package/src/view/rooteditableelement.js +80 -90
- package/src/view/selection.js +608 -689
- package/src/view/styles/background.js +43 -44
- package/src/view/styles/border.js +220 -276
- package/src/view/styles/margin.js +8 -17
- package/src/view/styles/padding.js +8 -16
- package/src/view/styles/utils.js +127 -160
- package/src/view/stylesmap.js +728 -905
- package/src/view/text.js +102 -126
- package/src/view/textproxy.js +144 -170
- package/src/view/treewalker.js +383 -479
- package/src/view/typecheckable.js +19 -0
- package/src/view/uielement.js +166 -187
- package/src/view/upcastwriter.js +395 -449
- package/src/view/view.js +569 -664
- package/src/dataprocessor/dataprocessor.jsdoc +0 -64
- package/src/model/item.jsdoc +0 -14
- package/src/view/elementdefinition.jsdoc +0 -59
- package/src/view/item.jsdoc +0 -14
package/src/model/history.js
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
}
|