@ckeditor/ckeditor5-engine 41.4.2 → 42.0.0-alpha.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/README.md +6 -0
- package/dist/index.js +15151 -13052
- package/dist/index.js.map +1 -1
- package/dist/types/controller/datacontroller.d.ts +1 -1
- package/dist/types/controller/editingcontroller.d.ts +1 -1
- package/dist/types/conversion/downcastdispatcher.d.ts +1 -1
- package/dist/types/conversion/mapper.d.ts +1 -1
- package/dist/types/conversion/upcastdispatcher.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/model/differ.d.ts +134 -42
- package/dist/types/model/document.d.ts +1 -1
- package/dist/types/model/documentselection.d.ts +1 -1
- package/dist/types/model/liveposition.d.ts +1 -1
- package/dist/types/model/liverange.d.ts +1 -1
- package/dist/types/model/markercollection.d.ts +2 -2
- package/dist/types/model/model.d.ts +1 -1
- package/dist/types/model/schema.d.ts +32 -6
- package/dist/types/model/selection.d.ts +1 -1
- package/dist/types/view/document.d.ts +1 -1
- package/dist/types/view/documentfragment.d.ts +1 -1
- package/dist/types/view/documentselection.d.ts +1 -1
- package/dist/types/view/domconverter.d.ts +9 -0
- package/dist/types/view/editableelement.d.ts +1 -1
- package/dist/types/view/node.d.ts +1 -1
- package/dist/types/view/observer/observer.d.ts +1 -1
- package/dist/types/view/renderer.d.ts +1 -1
- package/dist/types/view/selection.d.ts +1 -1
- package/dist/types/view/view.d.ts +1 -1
- package/package.json +2 -2
- package/src/controller/datacontroller.d.ts +1 -1
- package/src/controller/datacontroller.js +1 -1
- package/src/controller/editingcontroller.d.ts +1 -1
- package/src/controller/editingcontroller.js +1 -1
- package/src/conversion/downcastdispatcher.d.ts +1 -1
- package/src/conversion/downcastdispatcher.js +1 -1
- package/src/conversion/mapper.d.ts +1 -1
- package/src/conversion/mapper.js +1 -1
- package/src/conversion/upcastdispatcher.d.ts +1 -1
- package/src/conversion/upcastdispatcher.js +1 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +1 -0
- package/src/model/differ.d.ts +134 -42
- package/src/model/differ.js +247 -125
- package/src/model/document.d.ts +1 -1
- package/src/model/document.js +1 -1
- package/src/model/documentselection.d.ts +1 -1
- package/src/model/documentselection.js +1 -1
- package/src/model/liveposition.d.ts +1 -1
- package/src/model/liveposition.js +1 -1
- package/src/model/liverange.d.ts +1 -1
- package/src/model/liverange.js +1 -1
- package/src/model/markercollection.d.ts +2 -2
- package/src/model/markercollection.js +2 -2
- package/src/model/model.d.ts +1 -1
- package/src/model/model.js +1 -1
- package/src/model/schema.d.ts +32 -6
- package/src/model/schema.js +208 -101
- package/src/model/selection.d.ts +1 -1
- package/src/model/selection.js +1 -1
- package/src/view/document.d.ts +1 -1
- package/src/view/document.js +1 -1
- package/src/view/documentfragment.d.ts +1 -1
- package/src/view/documentfragment.js +1 -1
- package/src/view/documentselection.d.ts +1 -1
- package/src/view/documentselection.js +1 -1
- package/src/view/domconverter.d.ts +9 -0
- package/src/view/domconverter.js +27 -5
- package/src/view/editableelement.d.ts +1 -1
- package/src/view/editableelement.js +1 -1
- package/src/view/node.d.ts +1 -1
- package/src/view/node.js +1 -1
- package/src/view/observer/observer.d.ts +1 -1
- package/src/view/observer/observer.js +1 -1
- package/src/view/renderer.d.ts +1 -1
- package/src/view/renderer.js +1 -1
- package/src/view/selection.d.ts +1 -1
- package/src/view/selection.js +1 -1
- package/src/view/view.d.ts +1 -1
- package/src/view/view.js +1 -1
|
@@ -38,7 +38,7 @@ declare const DataController_base: {
|
|
|
38
38
|
* editor.data.get( { rootName: 'customRoot' } ); // -> '<p>Hello!</p>'
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export default class DataController extends DataController_base {
|
|
41
|
+
export default class DataController extends /* #__PURE__ */ DataController_base {
|
|
42
42
|
/**
|
|
43
43
|
* Data model.
|
|
44
44
|
*/
|
|
@@ -34,7 +34,7 @@ import HtmlDataProcessor from '../dataprocessor/htmldataprocessor.js';
|
|
|
34
34
|
* editor.data.get( { rootName: 'customRoot' } ); // -> '<p>Hello!</p>'
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export default class DataController extends EmitterMixin() {
|
|
37
|
+
export default class DataController extends /* #__PURE__ */ EmitterMixin() {
|
|
38
38
|
/**
|
|
39
39
|
* Creates a data controller instance.
|
|
40
40
|
*
|
|
@@ -18,7 +18,7 @@ declare const EditingController_base: {
|
|
|
18
18
|
* including selection handling. It also creates the {@link ~EditingController#view view} which builds a
|
|
19
19
|
* browser-independent virtualization over the DOM elements. The editing controller also attaches default converters.
|
|
20
20
|
*/
|
|
21
|
-
export default class EditingController extends EditingController_base {
|
|
21
|
+
export default class EditingController extends /* #__PURE__ */ EditingController_base {
|
|
22
22
|
/**
|
|
23
23
|
* Editor model.
|
|
24
24
|
*/
|
|
@@ -19,7 +19,7 @@ import { tryFixingRange } from '../model/utils/selection-post-fixer.js';
|
|
|
19
19
|
* including selection handling. It also creates the {@link ~EditingController#view view} which builds a
|
|
20
20
|
* browser-independent virtualization over the DOM elements. The editing controller also attaches default converters.
|
|
21
21
|
*/
|
|
22
|
-
export default class EditingController extends ObservableMixin() {
|
|
22
|
+
export default class EditingController extends /* #__PURE__ */ ObservableMixin() {
|
|
23
23
|
/**
|
|
24
24
|
* Creates an editing controller instance.
|
|
25
25
|
*
|
|
@@ -113,7 +113,7 @@ declare const DowncastDispatcher_base: {
|
|
|
113
113
|
* } );
|
|
114
114
|
* ```
|
|
115
115
|
*/
|
|
116
|
-
export default class DowncastDispatcher extends DowncastDispatcher_base {
|
|
116
|
+
export default class DowncastDispatcher extends /* #__PURE__ */ DowncastDispatcher_base {
|
|
117
117
|
/**
|
|
118
118
|
* A template for an interface passed by the dispatcher to the event callbacks.
|
|
119
119
|
*
|
|
@@ -99,7 +99,7 @@ import { EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
|
99
99
|
* } );
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
|
-
export default class DowncastDispatcher extends EmitterMixin() {
|
|
102
|
+
export default class DowncastDispatcher extends /* #__PURE__ */ EmitterMixin() {
|
|
103
103
|
/**
|
|
104
104
|
* Creates a downcast dispatcher instance.
|
|
105
105
|
*
|
|
@@ -37,7 +37,7 @@ declare const Mapper_base: {
|
|
|
37
37
|
* with `'lowest'` priority. To override default `Mapper` mapping, add custom callback with higher priority and
|
|
38
38
|
* stop the event.
|
|
39
39
|
*/
|
|
40
|
-
export default class Mapper extends Mapper_base {
|
|
40
|
+
export default class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
41
41
|
/**
|
|
42
42
|
* Model element to view element mapping.
|
|
43
43
|
*/
|
package/src/conversion/mapper.js
CHANGED
|
@@ -30,7 +30,7 @@ import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
|
30
30
|
* with `'lowest'` priority. To override default `Mapper` mapping, add custom callback with higher priority and
|
|
31
31
|
* stop the event.
|
|
32
32
|
*/
|
|
33
|
-
export default class Mapper extends EmitterMixin() {
|
|
33
|
+
export default class Mapper extends /* #__PURE__ */ EmitterMixin() {
|
|
34
34
|
/**
|
|
35
35
|
* Creates an instance of the mapper.
|
|
36
36
|
*/
|
|
@@ -117,7 +117,7 @@ declare const UpcastDispatcher_base: {
|
|
|
117
117
|
* @fires text
|
|
118
118
|
* @fires documentFragment
|
|
119
119
|
*/
|
|
120
|
-
export default class UpcastDispatcher extends UpcastDispatcher_base {
|
|
120
|
+
export default class UpcastDispatcher extends /* #__PURE__ */ UpcastDispatcher_base {
|
|
121
121
|
/**
|
|
122
122
|
* An interface passed by the dispatcher to the event callbacks.
|
|
123
123
|
*/
|
|
@@ -107,7 +107,7 @@ import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
|
107
107
|
* @fires text
|
|
108
108
|
* @fires documentFragment
|
|
109
109
|
*/
|
|
110
|
-
export default class UpcastDispatcher extends EmitterMixin() {
|
|
110
|
+
export default class UpcastDispatcher extends /* #__PURE__ */ EmitterMixin() {
|
|
111
111
|
/**
|
|
112
112
|
* Creates an upcast dispatcher that operates using the passed API.
|
|
113
113
|
*
|
package/src/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type { default as ModelConsumable } from './conversion/modelconsumable.js
|
|
|
17
17
|
export type { Consumables, default as ViewConsumable } from './conversion/viewconsumable.js';
|
|
18
18
|
export type { default as DataProcessor } from './dataprocessor/dataprocessor.js';
|
|
19
19
|
export { default as HtmlDataProcessor } from './dataprocessor/htmldataprocessor.js';
|
|
20
|
+
export { default as XmlDataProcessor } from './dataprocessor/xmldataprocessor.js';
|
|
20
21
|
export type { default as Operation } from './model/operation/operation.js';
|
|
21
22
|
export { default as InsertOperation } from './model/operation/insertoperation.js';
|
|
22
23
|
export { default as MoveOperation } from './model/operation/moveoperation.js';
|
|
@@ -88,7 +89,7 @@ export { default as ClickObserver } from './view/observer/clickobserver.js';
|
|
|
88
89
|
export { default as DomEventObserver } from './view/observer/domeventobserver.js';
|
|
89
90
|
export { default as MouseObserver } from './view/observer/mouseobserver.js';
|
|
90
91
|
export { default as TabObserver } from './view/observer/tabobserver.js';
|
|
91
|
-
export { default as FocusObserver } from './view/observer/focusobserver.js';
|
|
92
|
+
export { default as FocusObserver, type ViewDocumentBlurEvent, type ViewDocumentFocusEvent } from './view/observer/focusobserver.js';
|
|
92
93
|
export { default as DowncastWriter } from './view/downcastwriter.js';
|
|
93
94
|
export { default as UpcastWriter } from './view/upcastwriter.js';
|
|
94
95
|
export { default as Matcher, type MatcherPattern, type MatcherObjectPattern, type Match, type MatchResult } from './view/matcher.js';
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { default as DataController } from './controller/datacontroller.js';
|
|
|
12
12
|
// Conversion.
|
|
13
13
|
export { default as Conversion } from './conversion/conversion.js';
|
|
14
14
|
export { default as HtmlDataProcessor } from './dataprocessor/htmldataprocessor.js';
|
|
15
|
+
export { default as XmlDataProcessor } from './dataprocessor/xmldataprocessor.js';
|
|
15
16
|
export { default as InsertOperation } from './model/operation/insertoperation.js';
|
|
16
17
|
export { default as MoveOperation } from './model/operation/moveoperation.js';
|
|
17
18
|
export { default as MergeOperation } from './model/operation/mergeoperation.js';
|
package/src/model/differ.d.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import Position from './position.js';
|
|
9
9
|
import Range from './range.js';
|
|
10
10
|
import type { default as MarkerCollection, MarkerData } from './markercollection.js';
|
|
11
|
-
import type Element from './element.js';
|
|
12
11
|
import type Item from './item.js';
|
|
12
|
+
import type Node from './node.js';
|
|
13
13
|
import type RootElement from './rootelement.js';
|
|
14
14
|
import type Operation from './operation/operation.js';
|
|
15
15
|
/**
|
|
@@ -21,6 +21,11 @@ import type Operation from './operation/operation.js';
|
|
|
21
21
|
* elements and new ones and returns a change set.
|
|
22
22
|
*/
|
|
23
23
|
export default class Differ {
|
|
24
|
+
/**
|
|
25
|
+
* Priority of the {@link ~Differ#_elementState element states}. States on higher indexes of the array can overwrite states on the lower
|
|
26
|
+
* indexes.
|
|
27
|
+
*/
|
|
28
|
+
private static readonly _statesPriority;
|
|
24
29
|
/**
|
|
25
30
|
* Reference to the model's marker collection.
|
|
26
31
|
*/
|
|
@@ -33,18 +38,48 @@ export default class Differ {
|
|
|
33
38
|
*/
|
|
34
39
|
private readonly _changesInElement;
|
|
35
40
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
41
|
+
* Stores a snapshot for these model nodes that might have changed.
|
|
42
|
+
*
|
|
43
|
+
* This complements {@link ~Differ#_elementChildrenSnapshots `_elementChildrenSnapshots`}.
|
|
44
|
+
*
|
|
45
|
+
* See also {@link ~DifferSnapshot}.
|
|
39
46
|
*/
|
|
40
|
-
private readonly
|
|
47
|
+
private readonly _elementsSnapshots;
|
|
48
|
+
/**
|
|
49
|
+
* For each element or document fragment inside which there was a change, it stores a snapshot of the child nodes list (an array
|
|
50
|
+
* of children snapshots that represent the state in the element / fragment before any change has happened).
|
|
51
|
+
*
|
|
52
|
+
* This complements {@link ~Differ#_elementsSnapshots `_elementsSnapshots`}.
|
|
53
|
+
*
|
|
54
|
+
* See also {@link ~DifferSnapshot}.
|
|
55
|
+
*/
|
|
56
|
+
private readonly _elementChildrenSnapshots;
|
|
57
|
+
/**
|
|
58
|
+
* Keeps the state for a given element, describing how the element was changed so far. It is used to evaluate the `action` property
|
|
59
|
+
* of diff items returned by {@link ~Differ#getChanges}.
|
|
60
|
+
*
|
|
61
|
+
* Possible values, in the order from the lowest priority to the highest priority:
|
|
62
|
+
*
|
|
63
|
+
* * `'refresh'` - element was refreshed,
|
|
64
|
+
* * `'rename'` - element was renamed,
|
|
65
|
+
* * `'move'` - element was moved (or, usually, removed, that is moved to the graveyard).
|
|
66
|
+
*
|
|
67
|
+
* Element that was refreshed, may change its state to `'rename'` if it was later renamed, or to `'move'` if it was removed.
|
|
68
|
+
* But the element cannot change its state from `'move'` to `'rename'`, or from `'rename'` to `'refresh'`.
|
|
69
|
+
*
|
|
70
|
+
* Only already existing elements are registered in `_elementState`. If a new element was inserted as a result of a buffered operation,
|
|
71
|
+
* it is not be registered in `_elementState`.
|
|
72
|
+
*/
|
|
73
|
+
private readonly _elementState;
|
|
41
74
|
/**
|
|
42
75
|
* A map that stores all changed markers.
|
|
43
76
|
*
|
|
44
77
|
* The keys of the map are marker names.
|
|
78
|
+
*
|
|
45
79
|
* The values of the map are objects with the following properties:
|
|
46
|
-
*
|
|
47
|
-
*
|
|
80
|
+
*
|
|
81
|
+
* * `oldMarkerData`,
|
|
82
|
+
* * `newMarkerData`.
|
|
48
83
|
*/
|
|
49
84
|
private readonly _changedMarkers;
|
|
50
85
|
/**
|
|
@@ -89,7 +124,7 @@ export default class Differ {
|
|
|
89
124
|
*/
|
|
90
125
|
get isEmpty(): boolean;
|
|
91
126
|
/**
|
|
92
|
-
* Buffers the given operation. An operation has to be buffered before it is executed
|
|
127
|
+
* Buffers the given operation. **An operation has to be buffered before it is executed.**
|
|
93
128
|
*
|
|
94
129
|
* @param operationToBuffer An operation to buffer.
|
|
95
130
|
*/
|
|
@@ -177,14 +212,6 @@ export default class Differ {
|
|
|
177
212
|
* Resets `Differ`. Removes all buffered changes.
|
|
178
213
|
*/
|
|
179
214
|
reset(): void;
|
|
180
|
-
/**
|
|
181
|
-
* Buffers the root state change after the root was attached or detached
|
|
182
|
-
*/
|
|
183
|
-
private _bufferRootStateChange;
|
|
184
|
-
/**
|
|
185
|
-
* Buffers a root attribute change.
|
|
186
|
-
*/
|
|
187
|
-
private _bufferRootAttributeChange;
|
|
188
215
|
/**
|
|
189
216
|
* Marks the given `item` in differ to be "refreshed". It means that the item will be marked as removed and inserted
|
|
190
217
|
* in the differ changes set, so it will be effectively re-converted when the differ changes are handled by a dispatcher.
|
|
@@ -206,6 +233,14 @@ export default class Differ {
|
|
|
206
233
|
* @internal
|
|
207
234
|
*/
|
|
208
235
|
_bufferRootLoad(root: RootElement): void;
|
|
236
|
+
/**
|
|
237
|
+
* Buffers the root state change after the root was attached or detached
|
|
238
|
+
*/
|
|
239
|
+
private _bufferRootStateChange;
|
|
240
|
+
/**
|
|
241
|
+
* Buffers a root attribute change.
|
|
242
|
+
*/
|
|
243
|
+
private _bufferRootAttributeChange;
|
|
209
244
|
/**
|
|
210
245
|
* Saves and handles an insert change.
|
|
211
246
|
*/
|
|
@@ -222,14 +257,34 @@ export default class Differ {
|
|
|
222
257
|
* Saves and handles a model change.
|
|
223
258
|
*/
|
|
224
259
|
private _markChange;
|
|
260
|
+
/**
|
|
261
|
+
* Tries to set given state for given item.
|
|
262
|
+
*
|
|
263
|
+
* This method does simple validation (it sets the state only for model elements, not for text proxy nodes). It also follows state
|
|
264
|
+
* setting rules, that is, `'refresh'` cannot overwrite `'rename'`, and `'rename'` cannot overwrite `'move'`.
|
|
265
|
+
*/
|
|
266
|
+
private _setElementState;
|
|
267
|
+
/**
|
|
268
|
+
* Returns a value for {@link ~DifferItemAction `action`} property for diff items returned by {@link ~Differ#getChanges}.
|
|
269
|
+
* This method aims to return `'rename'` or `'refresh'` when it should, and `diffItemType` ("default action") in all other cases.
|
|
270
|
+
*
|
|
271
|
+
* It bases on a few factors:
|
|
272
|
+
*
|
|
273
|
+
* * for text nodes, the method always returns `diffItemType`,
|
|
274
|
+
* * for newly inserted element, the method returns `diffItemType`,
|
|
275
|
+
* * if {@link ~Differ#_elementState element state} was not recorded, the method returns `diffItemType`,
|
|
276
|
+
* * if state was recorded, and it was `'move'` (default action), the method returns `diffItemType`,
|
|
277
|
+
* * finally, if state was `'refresh'` or `'rename'`, the method returns the state value.
|
|
278
|
+
*/
|
|
279
|
+
private _getDiffActionForNode;
|
|
225
280
|
/**
|
|
226
281
|
* Gets an array of changes that have already been saved for a given element.
|
|
227
282
|
*/
|
|
228
283
|
private _getChangesForElement;
|
|
229
284
|
/**
|
|
230
|
-
*
|
|
285
|
+
* Creates and saves a snapshot for all children of the given element.
|
|
231
286
|
*/
|
|
232
|
-
private
|
|
287
|
+
private _makeSnapshots;
|
|
233
288
|
/**
|
|
234
289
|
* For a given newly saved change, compares it with a change already done on the element and modifies the incoming
|
|
235
290
|
* change and/or the old change.
|
|
@@ -243,7 +298,9 @@ export default class Differ {
|
|
|
243
298
|
*
|
|
244
299
|
* @param parent The element in which the change happened.
|
|
245
300
|
* @param offset The offset at which change happened.
|
|
246
|
-
* @param
|
|
301
|
+
* @param action Further specifies what kind of action led to generating this change.
|
|
302
|
+
* @param elementSnapshot Snapshot of the inserted node after changes.
|
|
303
|
+
* @param elementSnapshotBefore Snapshot of the inserted node before changes.
|
|
247
304
|
* @returns The diff item.
|
|
248
305
|
*/
|
|
249
306
|
private _getInsertDiff;
|
|
@@ -252,7 +309,8 @@ export default class Differ {
|
|
|
252
309
|
*
|
|
253
310
|
* @param parent The element in which change happened.
|
|
254
311
|
* @param offset The offset at which change happened.
|
|
255
|
-
* @param
|
|
312
|
+
* @param action Further specifies what kind of action led to generating this change.
|
|
313
|
+
* @param elementSnapshot The snapshot of the removed node before changes.
|
|
256
314
|
* @returns The diff item.
|
|
257
315
|
*/
|
|
258
316
|
private _getRemoveDiff;
|
|
@@ -275,6 +333,32 @@ export default class Differ {
|
|
|
275
333
|
*/
|
|
276
334
|
private _removeAllNestedChanges;
|
|
277
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Further specifies what kind of action led to generating a change:
|
|
338
|
+
*
|
|
339
|
+
* * `'insert'` if element was inserted,
|
|
340
|
+
* * `'remove'` if element was removed,
|
|
341
|
+
* * `'rename'` if element got renamed (e.g. `writer.rename()`),
|
|
342
|
+
* * `'refresh'` if element got refreshed (e.g. `model.editing.reconvertItem()`).
|
|
343
|
+
*/
|
|
344
|
+
export type DifferItemAction = 'insert' | 'remove' | 'rename' | 'refresh';
|
|
345
|
+
/**
|
|
346
|
+
* A snapshot is representing state of a given element before the first change was applied on that element.
|
|
347
|
+
*/
|
|
348
|
+
export interface DifferSnapshot {
|
|
349
|
+
/**
|
|
350
|
+
* Node for which was snapshot was made.
|
|
351
|
+
*/
|
|
352
|
+
node: Node;
|
|
353
|
+
/**
|
|
354
|
+
* Name of the element at the time when the snapshot was made. For text node snapshots, it is set to `'$text'`.
|
|
355
|
+
*/
|
|
356
|
+
name: string;
|
|
357
|
+
/**
|
|
358
|
+
* Attributes of the node at the time when the snapshot was made.
|
|
359
|
+
*/
|
|
360
|
+
attributes: Map<string, unknown>;
|
|
361
|
+
}
|
|
278
362
|
/**
|
|
279
363
|
* The single diff item.
|
|
280
364
|
*
|
|
@@ -294,19 +378,19 @@ export interface DiffItemInsert {
|
|
|
294
378
|
*/
|
|
295
379
|
type: 'insert';
|
|
296
380
|
/**
|
|
297
|
-
*
|
|
381
|
+
* Further specifies what kind of action led to generating this change.
|
|
298
382
|
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
383
|
+
* The action is set in relation to the document state before any change. It means that, for example, if an element was added and
|
|
384
|
+
* then renamed (during the same {@link module:engine/model/batch~Batch batch}), the action will be set to `'insert'`, because when
|
|
385
|
+
* compared to the document state before changes, a new element was inserted, and the renaming does not matter from this point of view.
|
|
302
386
|
*/
|
|
303
|
-
|
|
387
|
+
action: DifferItemAction;
|
|
304
388
|
/**
|
|
305
389
|
* The name of the inserted elements or `'$text'` for a text node.
|
|
306
390
|
*/
|
|
307
391
|
name: string;
|
|
308
392
|
/**
|
|
309
|
-
* Map of attributes
|
|
393
|
+
* Map of attributes of the inserted element.
|
|
310
394
|
*/
|
|
311
395
|
attributes: Map<string, unknown>;
|
|
312
396
|
/**
|
|
@@ -317,6 +401,25 @@ export interface DiffItemInsert {
|
|
|
317
401
|
* The length of an inserted text node. For elements, it is always 1 as each inserted element is counted as a one.
|
|
318
402
|
*/
|
|
319
403
|
length: number;
|
|
404
|
+
/**
|
|
405
|
+
* Holds information about the element state before all changes happened.
|
|
406
|
+
*
|
|
407
|
+
* For example, when `<paragraph textAlign="right">` was changed to `<codeBlock language="plaintext">`,
|
|
408
|
+
* `before.name` will be equal to `'paragraph'` and `before.attributes` map will have one entry: `'textAlign' -> 'right'`.
|
|
409
|
+
*
|
|
410
|
+
* The property is available only if the insertion change was due to element rename or refresh (when `action` property is `'rename'`
|
|
411
|
+
* or `'refresh'`). As such, `before` property is never available for text node changes.
|
|
412
|
+
*/
|
|
413
|
+
before?: {
|
|
414
|
+
/**
|
|
415
|
+
* The name of the inserted element before all changes.
|
|
416
|
+
*/
|
|
417
|
+
name: string;
|
|
418
|
+
/**
|
|
419
|
+
* Map of the attributes of the inserted element before all changes.
|
|
420
|
+
*/
|
|
421
|
+
attributes: Map<string, unknown>;
|
|
422
|
+
};
|
|
320
423
|
}
|
|
321
424
|
/**
|
|
322
425
|
* A single diff item for removed nodes.
|
|
@@ -327,24 +430,13 @@ export interface DiffItemRemove {
|
|
|
327
430
|
*/
|
|
328
431
|
type: 'remove';
|
|
329
432
|
/**
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
* Undefined if the diff item is related to text node deletion.
|
|
433
|
+
* Further specifies what kind of action led to generating this change.
|
|
333
434
|
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* Instead, you should use {@link ~DiffItemRemove#name `DiffItemRemove#name`},
|
|
339
|
-
* {@link ~DiffItemRemove#attributes `DiffItemRemove#attributes`}, and {@link ~DiffItemRemove#position `DiffItemRemove#position`}.
|
|
340
|
-
*
|
|
341
|
-
* This property should be only used to check instance reference equality. For example, if you want to detect that some particular
|
|
342
|
-
* element was removed, you can check `_element` property. You can use it together with {@link ~DiffItemInsert#_element `#_element`} on
|
|
343
|
-
* insert diff items to detect move, refresh, or rename changes.
|
|
344
|
-
*
|
|
345
|
-
* @internal
|
|
435
|
+
* The action is set in relation to the document state before any change. It means that, for example, if an element was renamed and
|
|
436
|
+
* then removed (during the same {@link module:engine/model/batch~Batch batch}), the action will be set to `'remove'`, because when
|
|
437
|
+
* compared to the document state before changes, the element was removed, and it does not matter that it was also renamed at one point.
|
|
346
438
|
*/
|
|
347
|
-
|
|
439
|
+
action: DifferItemAction;
|
|
348
440
|
/**
|
|
349
441
|
* The name of the removed element or `'$text'` for a text node.
|
|
350
442
|
*/
|