@ckeditor/ckeditor5-engine 41.2.0 → 41.3.0-alpha.1
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/dist/content-index.css +4 -0
- package/dist/editor-index.css +23 -0
- package/dist/index.css +49 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +36728 -0
- package/dist/index.js.map +1 -0
- package/dist/types/controller/datacontroller.d.ts +335 -0
- package/dist/types/controller/editingcontroller.d.ts +98 -0
- package/dist/types/conversion/conversion.d.ts +478 -0
- package/dist/types/conversion/conversionhelpers.d.ts +26 -0
- package/dist/types/conversion/downcastdispatcher.d.ts +562 -0
- package/dist/types/conversion/downcasthelpers.d.ts +1190 -0
- package/dist/types/conversion/mapper.d.ts +503 -0
- package/dist/types/conversion/modelconsumable.d.ts +201 -0
- package/dist/types/conversion/upcastdispatcher.d.ts +492 -0
- package/dist/types/conversion/upcasthelpers.d.ts +499 -0
- package/dist/types/conversion/viewconsumable.d.ts +369 -0
- package/dist/types/dataprocessor/basichtmlwriter.d.ts +18 -0
- package/dist/types/dataprocessor/dataprocessor.d.ts +61 -0
- package/dist/types/dataprocessor/htmldataprocessor.d.ts +76 -0
- package/dist/types/dataprocessor/htmlwriter.d.ts +16 -0
- package/dist/types/dataprocessor/xmldataprocessor.d.ts +90 -0
- package/dist/types/dev-utils/model.d.ts +124 -0
- package/dist/types/dev-utils/operationreplayer.d.ts +51 -0
- package/dist/types/dev-utils/utils.d.ts +37 -0
- package/dist/types/dev-utils/view.d.ts +319 -0
- package/dist/types/index.d.ts +113 -0
- package/dist/types/model/batch.d.ts +106 -0
- package/dist/types/model/differ.d.ts +415 -0
- package/dist/types/model/document.d.ts +274 -0
- package/dist/types/model/documentfragment.d.ts +200 -0
- package/dist/types/model/documentselection.d.ts +420 -0
- package/dist/types/model/element.d.ts +165 -0
- package/dist/types/model/history.d.ts +114 -0
- package/dist/types/model/item.d.ts +14 -0
- package/dist/types/model/liveposition.d.ts +77 -0
- package/dist/types/model/liverange.d.ts +102 -0
- package/dist/types/model/markercollection.d.ts +335 -0
- package/dist/types/model/model.d.ts +919 -0
- package/dist/types/model/node.d.ts +255 -0
- package/dist/types/model/nodelist.d.ts +91 -0
- package/dist/types/model/operation/attributeoperation.d.ts +103 -0
- package/dist/types/model/operation/detachoperation.d.ts +60 -0
- package/dist/types/model/operation/insertoperation.d.ts +90 -0
- package/dist/types/model/operation/markeroperation.d.ts +91 -0
- package/dist/types/model/operation/mergeoperation.d.ts +100 -0
- package/dist/types/model/operation/moveoperation.d.ts +96 -0
- package/dist/types/model/operation/nooperation.d.ts +38 -0
- package/dist/types/model/operation/operation.d.ts +96 -0
- package/dist/types/model/operation/operationfactory.d.ts +18 -0
- package/dist/types/model/operation/renameoperation.d.ts +83 -0
- package/dist/types/model/operation/rootattributeoperation.d.ts +98 -0
- package/dist/types/model/operation/rootoperation.d.ts +76 -0
- package/dist/types/model/operation/splitoperation.d.ts +109 -0
- package/dist/types/model/operation/transform.d.ts +100 -0
- package/dist/types/model/operation/utils.d.ts +71 -0
- package/dist/types/model/position.d.ts +538 -0
- package/dist/types/model/range.d.ts +458 -0
- package/dist/types/model/rootelement.d.ts +60 -0
- package/dist/types/model/schema.d.ts +1206 -0
- package/dist/types/model/selection.d.ts +482 -0
- package/dist/types/model/text.d.ts +66 -0
- package/dist/types/model/textproxy.d.ts +144 -0
- package/dist/types/model/treewalker.d.ts +186 -0
- package/dist/types/model/typecheckable.d.ts +285 -0
- package/dist/types/model/utils/autoparagraphing.d.ts +37 -0
- package/dist/types/model/utils/deletecontent.d.ts +58 -0
- package/dist/types/model/utils/getselectedcontent.d.ts +30 -0
- package/dist/types/model/utils/insertcontent.d.ts +46 -0
- package/dist/types/model/utils/insertobject.d.ts +47 -0
- package/dist/types/model/utils/modifyselection.d.ts +48 -0
- package/dist/types/model/utils/selection-post-fixer.d.ts +74 -0
- package/dist/types/model/writer.d.ts +851 -0
- package/dist/types/view/attributeelement.d.ts +108 -0
- package/dist/types/view/containerelement.d.ts +49 -0
- package/dist/types/view/datatransfer.d.ts +79 -0
- package/dist/types/view/document.d.ts +184 -0
- package/dist/types/view/documentfragment.d.ts +153 -0
- package/dist/types/view/documentselection.d.ts +306 -0
- package/dist/types/view/domconverter.d.ts +652 -0
- package/dist/types/view/downcastwriter.d.ts +996 -0
- package/dist/types/view/editableelement.d.ts +62 -0
- package/dist/types/view/element.d.ts +468 -0
- package/dist/types/view/elementdefinition.d.ts +87 -0
- package/dist/types/view/emptyelement.d.ts +41 -0
- package/dist/types/view/filler.d.ts +111 -0
- package/dist/types/view/item.d.ts +14 -0
- package/dist/types/view/matcher.d.ts +486 -0
- package/dist/types/view/node.d.ts +162 -0
- package/dist/types/view/observer/arrowkeysobserver.d.ts +45 -0
- package/dist/types/view/observer/bubblingemittermixin.d.ts +166 -0
- package/dist/types/view/observer/bubblingeventinfo.d.ts +47 -0
- package/dist/types/view/observer/clickobserver.d.ts +43 -0
- package/dist/types/view/observer/compositionobserver.d.ts +82 -0
- package/dist/types/view/observer/domeventdata.d.ts +50 -0
- package/dist/types/view/observer/domeventobserver.d.ts +73 -0
- package/dist/types/view/observer/fakeselectionobserver.d.ts +47 -0
- package/dist/types/view/observer/focusobserver.d.ts +82 -0
- package/dist/types/view/observer/inputobserver.d.ts +86 -0
- package/dist/types/view/observer/keyobserver.d.ts +66 -0
- package/dist/types/view/observer/mouseobserver.d.ts +89 -0
- package/dist/types/view/observer/mutationobserver.d.ts +86 -0
- package/dist/types/view/observer/observer.d.ts +89 -0
- package/dist/types/view/observer/selectionobserver.d.ts +148 -0
- package/dist/types/view/observer/tabobserver.d.ts +46 -0
- package/dist/types/view/placeholder.d.ts +96 -0
- package/dist/types/view/position.d.ts +188 -0
- package/dist/types/view/range.d.ts +279 -0
- package/dist/types/view/rawelement.d.ts +73 -0
- package/dist/types/view/renderer.d.ts +265 -0
- package/dist/types/view/rooteditableelement.d.ts +41 -0
- package/dist/types/view/selection.d.ts +375 -0
- package/dist/types/view/styles/background.d.ts +33 -0
- package/dist/types/view/styles/border.d.ts +43 -0
- package/dist/types/view/styles/margin.d.ts +29 -0
- package/dist/types/view/styles/padding.d.ts +29 -0
- package/dist/types/view/styles/utils.d.ts +93 -0
- package/dist/types/view/stylesmap.d.ts +673 -0
- package/dist/types/view/text.d.ts +74 -0
- package/dist/types/view/textproxy.d.ts +97 -0
- package/dist/types/view/treewalker.d.ts +195 -0
- package/dist/types/view/typecheckable.d.ts +448 -0
- package/dist/types/view/uielement.d.ts +96 -0
- package/dist/types/view/upcastwriter.d.ts +417 -0
- package/dist/types/view/view.d.ts +487 -0
- package/package.json +3 -2
- package/src/model/node.d.ts +0 -1
- package/src/model/node.js +0 -2
- package/src/model/position.d.ts +0 -1
- package/src/model/position.js +0 -2
- package/src/view/node.d.ts +0 -1
- package/src/view/node.js +0 -2
- package/src/view/position.d.ts +0 -1
- package/src/view/position.js +0 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
+
import type Operation from './operation/operation.js';
|
|
6
|
+
/**
|
|
7
|
+
* A batch instance groups model changes ({@link module:engine/model/operation/operation~Operation operations}). All operations
|
|
8
|
+
* grouped in a single batch can be reverted together, so you can also think about a batch as of a single undo step. If you want
|
|
9
|
+
* to extend a given undo step, you can add more changes to the batch using {@link module:engine/model/model~Model#enqueueChange}:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* model.enqueueChange( batch, writer => {
|
|
13
|
+
* writer.insertText( 'foo', paragraph, 'end' );
|
|
14
|
+
* } );
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @see module:engine/model/model~Model#enqueueChange
|
|
18
|
+
* @see module:engine/model/model~Model#change
|
|
19
|
+
*/
|
|
20
|
+
export default class Batch implements BatchType {
|
|
21
|
+
/**
|
|
22
|
+
* An array of operations that compose this batch.
|
|
23
|
+
*/
|
|
24
|
+
readonly operations: Array<Operation>;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the batch can be undone through the undo feature.
|
|
27
|
+
*/
|
|
28
|
+
readonly isUndoable: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the batch includes operations created locally (`true`) or operations created on other, remote editors (`false`).
|
|
31
|
+
*/
|
|
32
|
+
readonly isLocal: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the batch was created by the undo feature and undoes other operations.
|
|
35
|
+
*/
|
|
36
|
+
readonly isUndo: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the batch includes operations connected with typing.
|
|
39
|
+
*/
|
|
40
|
+
readonly isTyping: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a batch instance.
|
|
43
|
+
*
|
|
44
|
+
* @see module:engine/model/model~Model#enqueueChange
|
|
45
|
+
* @see module:engine/model/model~Model#change
|
|
46
|
+
* @param type A set of flags that specify the type of the batch. Batch type can alter how some of the features work
|
|
47
|
+
* when encountering a given `Batch` instance (for example, when a feature listens to applied operations).
|
|
48
|
+
*/
|
|
49
|
+
constructor(type?: BatchType);
|
|
50
|
+
/**
|
|
51
|
+
* The type of the batch.
|
|
52
|
+
*
|
|
53
|
+
* **This property has been deprecated and is always set to the `'default'` value.**
|
|
54
|
+
*
|
|
55
|
+
* It can be one of the following values:
|
|
56
|
+
* * `'default'` – All "normal" batches. This is the most commonly used type.
|
|
57
|
+
* * `'transparent'` – A batch that should be ignored by other features, i.e. an initial batch or collaborative editing
|
|
58
|
+
* changes.
|
|
59
|
+
*
|
|
60
|
+
* @deprecated
|
|
61
|
+
*/
|
|
62
|
+
get type(): 'default';
|
|
63
|
+
/**
|
|
64
|
+
* Returns the base version of this batch, which is equal to the base version of the first operation in the batch.
|
|
65
|
+
* If there are no operations in the batch or neither operation has the base version set, it returns `null`.
|
|
66
|
+
*/
|
|
67
|
+
get baseVersion(): number | null;
|
|
68
|
+
/**
|
|
69
|
+
* Adds an operation to the batch instance.
|
|
70
|
+
*
|
|
71
|
+
* @param operation An operation to add.
|
|
72
|
+
* @returns The added operation.
|
|
73
|
+
*/
|
|
74
|
+
addOperation(operation: Operation): Operation;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A set of flags that specify the type of the batch. Batch type can alter how some of the features work
|
|
78
|
+
* when encountering a given `Batch` instance (for example, when a feature listens to applied operations).
|
|
79
|
+
*/
|
|
80
|
+
export interface BatchType {
|
|
81
|
+
/**
|
|
82
|
+
* Whether a batch can be undone through undo feature.
|
|
83
|
+
*
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
isUndoable?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Whether a batch includes operations created locally (`true`) or operations created on
|
|
89
|
+
* other, remote editors (`false`).
|
|
90
|
+
*
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
isLocal?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Whether a batch was created by the undo feature and undoes other operations.
|
|
96
|
+
*
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
isUndo?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a batch includes operations connected with a typing action.
|
|
102
|
+
*
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
isTyping?: boolean;
|
|
106
|
+
}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
+
/**
|
|
6
|
+
* @module engine/model/differ
|
|
7
|
+
*/
|
|
8
|
+
import Position from './position.js';
|
|
9
|
+
import Range from './range.js';
|
|
10
|
+
import type { default as MarkerCollection, MarkerData } from './markercollection.js';
|
|
11
|
+
import type Element from './element.js';
|
|
12
|
+
import type Item from './item.js';
|
|
13
|
+
import type RootElement from './rootelement.js';
|
|
14
|
+
import type Operation from './operation/operation.js';
|
|
15
|
+
/**
|
|
16
|
+
* Calculates the difference between two model states.
|
|
17
|
+
*
|
|
18
|
+
* Receives operations that are to be applied on the model document. Marks parts of the model document tree which
|
|
19
|
+
* are changed and saves the state of these elements before the change. Then, it compares saved elements with the
|
|
20
|
+
* changed elements, after all changes are applied on the model document. Calculates the diff between saved
|
|
21
|
+
* elements and new ones and returns a change set.
|
|
22
|
+
*/
|
|
23
|
+
export default class Differ {
|
|
24
|
+
/**
|
|
25
|
+
* Reference to the model's marker collection.
|
|
26
|
+
*/
|
|
27
|
+
private readonly _markerCollection;
|
|
28
|
+
/**
|
|
29
|
+
* A map that stores changes that happened in a given element.
|
|
30
|
+
*
|
|
31
|
+
* The keys of the map are references to the model elements.
|
|
32
|
+
* The values of the map are arrays with changes that were done on this element.
|
|
33
|
+
*/
|
|
34
|
+
private readonly _changesInElement;
|
|
35
|
+
/**
|
|
36
|
+
* A map that stores "element's children snapshots". A snapshot is representing children of a given element before
|
|
37
|
+
* the first change was applied on that element. Snapshot items are objects with two properties: `name`,
|
|
38
|
+
* containing the element name (or `'$text'` for a text node) and `attributes` which is a map of the node's attributes.
|
|
39
|
+
*/
|
|
40
|
+
private readonly _elementSnapshots;
|
|
41
|
+
/**
|
|
42
|
+
* A map that stores all changed markers.
|
|
43
|
+
*
|
|
44
|
+
* The keys of the map are marker names.
|
|
45
|
+
* The values of the map are objects with the following properties:
|
|
46
|
+
* - `oldMarkerData`,
|
|
47
|
+
* - `newMarkerData`.
|
|
48
|
+
*/
|
|
49
|
+
private readonly _changedMarkers;
|
|
50
|
+
/**
|
|
51
|
+
* A map that stores all roots that have been changed.
|
|
52
|
+
*
|
|
53
|
+
* The keys are the names of the roots while value represents the changes.
|
|
54
|
+
*/
|
|
55
|
+
private readonly _changedRoots;
|
|
56
|
+
/**
|
|
57
|
+
* Stores the number of changes that were processed. Used to order the changes chronologically. It is important
|
|
58
|
+
* when changes are sorted.
|
|
59
|
+
*/
|
|
60
|
+
private _changeCount;
|
|
61
|
+
/**
|
|
62
|
+
* For efficiency purposes, `Differ` stores the change set returned by the differ after {@link #getChanges} call.
|
|
63
|
+
* Cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
|
|
64
|
+
* return the cached value instead of calculating it again.
|
|
65
|
+
*
|
|
66
|
+
* This property stores those changes that did not take place in graveyard root.
|
|
67
|
+
*/
|
|
68
|
+
private _cachedChanges;
|
|
69
|
+
/**
|
|
70
|
+
* For efficiency purposes, `Differ` stores the change set returned by the differ after the {@link #getChanges} call.
|
|
71
|
+
* The cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
|
|
72
|
+
* return the cached value instead of calculating it again.
|
|
73
|
+
*
|
|
74
|
+
* This property stores all changes evaluated by `Differ`, including those that took place in the graveyard.
|
|
75
|
+
*/
|
|
76
|
+
private _cachedChangesWithGraveyard;
|
|
77
|
+
/**
|
|
78
|
+
* Set of model items that were marked to get refreshed in {@link #_refreshItem}.
|
|
79
|
+
*/
|
|
80
|
+
private _refreshedItems;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a `Differ` instance.
|
|
83
|
+
*
|
|
84
|
+
* @param markerCollection Model's marker collection.
|
|
85
|
+
*/
|
|
86
|
+
constructor(markerCollection: MarkerCollection);
|
|
87
|
+
/**
|
|
88
|
+
* Informs whether there are any changes buffered in `Differ`.
|
|
89
|
+
*/
|
|
90
|
+
get isEmpty(): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Buffers the given operation. An operation has to be buffered before it is executed.
|
|
93
|
+
*
|
|
94
|
+
* @param operationToBuffer An operation to buffer.
|
|
95
|
+
*/
|
|
96
|
+
bufferOperation(operationToBuffer: Operation): void;
|
|
97
|
+
/**
|
|
98
|
+
* Buffers a marker change.
|
|
99
|
+
*
|
|
100
|
+
* @param markerName The name of the marker that changed.
|
|
101
|
+
* @param oldMarkerData Marker data before the change.
|
|
102
|
+
* @param newMarkerData Marker data after the change.
|
|
103
|
+
*/
|
|
104
|
+
bufferMarkerChange(markerName: string, oldMarkerData: MarkerData, newMarkerData: MarkerData): void;
|
|
105
|
+
/**
|
|
106
|
+
* Returns all markers that should be removed as a result of buffered changes.
|
|
107
|
+
*
|
|
108
|
+
* @returns Markers to remove. Each array item is an object containing the `name` and `range` properties.
|
|
109
|
+
*/
|
|
110
|
+
getMarkersToRemove(): Array<{
|
|
111
|
+
name: string;
|
|
112
|
+
range: Range;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Returns all markers which should be added as a result of buffered changes.
|
|
116
|
+
*
|
|
117
|
+
* @returns Markers to add. Each array item is an object containing the `name` and `range` properties.
|
|
118
|
+
*/
|
|
119
|
+
getMarkersToAdd(): Array<{
|
|
120
|
+
name: string;
|
|
121
|
+
range: Range;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Returns all markers which changed.
|
|
125
|
+
*/
|
|
126
|
+
getChangedMarkers(): Array<{
|
|
127
|
+
name: string;
|
|
128
|
+
data: {
|
|
129
|
+
oldRange: Range | null;
|
|
130
|
+
newRange: Range | null;
|
|
131
|
+
};
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Checks whether some of the buffered changes affect the editor data.
|
|
135
|
+
*
|
|
136
|
+
* Types of changes which affect the editor data:
|
|
137
|
+
*
|
|
138
|
+
* * model structure changes,
|
|
139
|
+
* * attribute changes,
|
|
140
|
+
* * a root is added or detached,
|
|
141
|
+
* * changes of markers which were defined as `affectsData`,
|
|
142
|
+
* * changes of markers' `affectsData` property.
|
|
143
|
+
*/
|
|
144
|
+
hasDataChanges(): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Calculates the diff between the old model tree state (the state before the first buffered operations since the last {@link #reset}
|
|
147
|
+
* call) and the new model tree state (actual one). It should be called after all buffered operations are executed.
|
|
148
|
+
*
|
|
149
|
+
* The diff set is returned as an array of {@link module:engine/model/differ~DiffItem diff items}, each describing a change done
|
|
150
|
+
* on the model. The items are sorted by the position on which the change happened. If a position
|
|
151
|
+
* {@link module:engine/model/position~Position#isBefore is before} another one, it will be on an earlier index in the diff set.
|
|
152
|
+
*
|
|
153
|
+
* **Note**: Elements inside inserted element will not have a separate diff item, only the top most element change will be reported.
|
|
154
|
+
*
|
|
155
|
+
* Because calculating the diff is a costly operation, the result is cached. If no new operation was buffered since the
|
|
156
|
+
* previous {@link #getChanges} call, the next call will return the cached value.
|
|
157
|
+
*
|
|
158
|
+
* @param options Additional options.
|
|
159
|
+
* @param options.includeChangesInGraveyard If set to `true`, also changes that happened
|
|
160
|
+
* in the graveyard root will be returned. By default, changes in the graveyard root are not returned.
|
|
161
|
+
* @returns Diff between the old and the new model tree state.
|
|
162
|
+
*/
|
|
163
|
+
getChanges(options?: {
|
|
164
|
+
includeChangesInGraveyard?: boolean;
|
|
165
|
+
}): Array<DiffItem>;
|
|
166
|
+
/**
|
|
167
|
+
* Returns all roots that have changed (either were attached, or detached, or their attributes changed).
|
|
168
|
+
*
|
|
169
|
+
* @returns Diff between the old and the new roots state.
|
|
170
|
+
*/
|
|
171
|
+
getChangedRoots(): Array<DiffItemRoot>;
|
|
172
|
+
/**
|
|
173
|
+
* Returns a set of model items that were marked to get refreshed.
|
|
174
|
+
*/
|
|
175
|
+
getRefreshedItems(): Set<Item>;
|
|
176
|
+
/**
|
|
177
|
+
* Resets `Differ`. Removes all buffered changes.
|
|
178
|
+
*/
|
|
179
|
+
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
|
+
/**
|
|
189
|
+
* Marks the given `item` in differ to be "refreshed". It means that the item will be marked as removed and inserted
|
|
190
|
+
* in the differ changes set, so it will be effectively re-converted when the differ changes are handled by a dispatcher.
|
|
191
|
+
*
|
|
192
|
+
* @internal
|
|
193
|
+
* @param item Item to refresh.
|
|
194
|
+
*/
|
|
195
|
+
_refreshItem(item: Item): void;
|
|
196
|
+
/**
|
|
197
|
+
* Buffers all the data related to given root like it was all just added to the editor.
|
|
198
|
+
*
|
|
199
|
+
* Following changes are buffered:
|
|
200
|
+
*
|
|
201
|
+
* * root is attached,
|
|
202
|
+
* * all root content is inserted,
|
|
203
|
+
* * all root attributes are added,
|
|
204
|
+
* * all markers inside the root are added.
|
|
205
|
+
*
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
_bufferRootLoad(root: RootElement): void;
|
|
209
|
+
/**
|
|
210
|
+
* Saves and handles an insert change.
|
|
211
|
+
*/
|
|
212
|
+
private _markInsert;
|
|
213
|
+
/**
|
|
214
|
+
* Saves and handles a remove change.
|
|
215
|
+
*/
|
|
216
|
+
private _markRemove;
|
|
217
|
+
/**
|
|
218
|
+
* Saves and handles an attribute change.
|
|
219
|
+
*/
|
|
220
|
+
private _markAttribute;
|
|
221
|
+
/**
|
|
222
|
+
* Saves and handles a model change.
|
|
223
|
+
*/
|
|
224
|
+
private _markChange;
|
|
225
|
+
/**
|
|
226
|
+
* Gets an array of changes that have already been saved for a given element.
|
|
227
|
+
*/
|
|
228
|
+
private _getChangesForElement;
|
|
229
|
+
/**
|
|
230
|
+
* Saves a children snapshot for a given element.
|
|
231
|
+
*/
|
|
232
|
+
private _makeSnapshot;
|
|
233
|
+
/**
|
|
234
|
+
* For a given newly saved change, compares it with a change already done on the element and modifies the incoming
|
|
235
|
+
* change and/or the old change.
|
|
236
|
+
*
|
|
237
|
+
* @param inc Incoming (new) change.
|
|
238
|
+
* @param changes An array containing all the changes done on that element.
|
|
239
|
+
*/
|
|
240
|
+
private _handleChange;
|
|
241
|
+
/**
|
|
242
|
+
* Returns an object with a single insert change description.
|
|
243
|
+
*
|
|
244
|
+
* @param parent The element in which the change happened.
|
|
245
|
+
* @param offset The offset at which change happened.
|
|
246
|
+
* @param elementSnapshot The snapshot of the removed element a character.
|
|
247
|
+
* @returns The diff item.
|
|
248
|
+
*/
|
|
249
|
+
private _getInsertDiff;
|
|
250
|
+
/**
|
|
251
|
+
* Returns an object with a single remove change description.
|
|
252
|
+
*
|
|
253
|
+
* @param parent The element in which change happened.
|
|
254
|
+
* @param offset The offset at which change happened.
|
|
255
|
+
* @param elementSnapshot The snapshot of the removed element a character.
|
|
256
|
+
* @returns The diff item.
|
|
257
|
+
*/
|
|
258
|
+
private _getRemoveDiff;
|
|
259
|
+
/**
|
|
260
|
+
* Returns an array of objects where each one is a single attribute change description.
|
|
261
|
+
*
|
|
262
|
+
* @param range The range where the change happened.
|
|
263
|
+
* @param oldAttributes A map, map iterator or compatible object that contains attributes before the change.
|
|
264
|
+
* @param newAttributes A map, map iterator or compatible object that contains attributes after the change.
|
|
265
|
+
* @returns An array containing one or more diff items.
|
|
266
|
+
*/
|
|
267
|
+
private _getAttributesDiff;
|
|
268
|
+
/**
|
|
269
|
+
* Checks whether given element or any of its parents is an element that is buffered as an inserted element.
|
|
270
|
+
*/
|
|
271
|
+
private _isInInsertedElement;
|
|
272
|
+
/**
|
|
273
|
+
* Removes deeply all buffered changes that are registered in elements from range specified by `parent`, `offset`
|
|
274
|
+
* and `howMany`.
|
|
275
|
+
*/
|
|
276
|
+
private _removeAllNestedChanges;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The single diff item.
|
|
280
|
+
*
|
|
281
|
+
* Could be one of:
|
|
282
|
+
*
|
|
283
|
+
* * {@link module:engine/model/differ~DiffItemInsert `DiffItemInsert`},
|
|
284
|
+
* * {@link module:engine/model/differ~DiffItemRemove `DiffItemRemove`},
|
|
285
|
+
* * {@link module:engine/model/differ~DiffItemAttribute `DiffItemAttribute`}.
|
|
286
|
+
*/
|
|
287
|
+
export type DiffItem = DiffItemInsert | DiffItemRemove | DiffItemAttribute;
|
|
288
|
+
/**
|
|
289
|
+
* A single diff item for inserted nodes.
|
|
290
|
+
*/
|
|
291
|
+
export interface DiffItemInsert {
|
|
292
|
+
/**
|
|
293
|
+
* The type of diff item.
|
|
294
|
+
*/
|
|
295
|
+
type: 'insert';
|
|
296
|
+
/**
|
|
297
|
+
* Reference to the model element that was inserted.
|
|
298
|
+
*
|
|
299
|
+
* Undefined if the diff item is related to text node insertion.
|
|
300
|
+
*
|
|
301
|
+
* @internal
|
|
302
|
+
*/
|
|
303
|
+
_element?: Element;
|
|
304
|
+
/**
|
|
305
|
+
* The name of the inserted elements or `'$text'` for a text node.
|
|
306
|
+
*/
|
|
307
|
+
name: string;
|
|
308
|
+
/**
|
|
309
|
+
* Map of attributes that were set on the item while it was inserted.
|
|
310
|
+
*/
|
|
311
|
+
attributes: Map<string, unknown>;
|
|
312
|
+
/**
|
|
313
|
+
* The position where the node was inserted.
|
|
314
|
+
*/
|
|
315
|
+
position: Position;
|
|
316
|
+
/**
|
|
317
|
+
* The length of an inserted text node. For elements, it is always 1 as each inserted element is counted as a one.
|
|
318
|
+
*/
|
|
319
|
+
length: number;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* A single diff item for removed nodes.
|
|
323
|
+
*/
|
|
324
|
+
export interface DiffItemRemove {
|
|
325
|
+
/**
|
|
326
|
+
* The type of diff item.
|
|
327
|
+
*/
|
|
328
|
+
type: 'remove';
|
|
329
|
+
/**
|
|
330
|
+
* Reference to the model element that was removed.
|
|
331
|
+
*
|
|
332
|
+
* Undefined if the diff item is related to text node deletion.
|
|
333
|
+
*
|
|
334
|
+
* Note that this element will have the state after all changes has been performed on the model, not before. For example, if a paragraph
|
|
335
|
+
* was first renamed to `heading1`, and then removed, `element.name` will be `heading1`. Similarly, with attributes. Also, you should
|
|
336
|
+
* not read the element's position, as it will no longer point to the original element position.
|
|
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
|
|
346
|
+
*/
|
|
347
|
+
_element?: Element;
|
|
348
|
+
/**
|
|
349
|
+
* The name of the removed element or `'$text'` for a text node.
|
|
350
|
+
*/
|
|
351
|
+
name: string;
|
|
352
|
+
/**
|
|
353
|
+
* Map of attributes that were set on the item while it was removed.
|
|
354
|
+
*/
|
|
355
|
+
attributes: Map<string, unknown>;
|
|
356
|
+
/**
|
|
357
|
+
* The position where the node was removed.
|
|
358
|
+
*/
|
|
359
|
+
position: Position;
|
|
360
|
+
/**
|
|
361
|
+
* The length of a removed text node. For elements, it is always 1, as each removed element is counted as a one.
|
|
362
|
+
*/
|
|
363
|
+
length: number;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* A single diff item for attribute change.
|
|
367
|
+
*/
|
|
368
|
+
export interface DiffItemAttribute {
|
|
369
|
+
/**
|
|
370
|
+
* The type of diff item.
|
|
371
|
+
*/
|
|
372
|
+
type: 'attribute';
|
|
373
|
+
/**
|
|
374
|
+
* The name of the changed attribute.
|
|
375
|
+
*/
|
|
376
|
+
attributeKey: string;
|
|
377
|
+
/**
|
|
378
|
+
* An attribute previous value (before change).
|
|
379
|
+
*/
|
|
380
|
+
attributeOldValue: unknown;
|
|
381
|
+
/**
|
|
382
|
+
* An attribute new value (after change).
|
|
383
|
+
*/
|
|
384
|
+
attributeNewValue: unknown;
|
|
385
|
+
/**
|
|
386
|
+
* The range where the change happened.
|
|
387
|
+
*/
|
|
388
|
+
range: Range;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* A single diff item for a changed root.
|
|
392
|
+
*/
|
|
393
|
+
export interface DiffItemRoot {
|
|
394
|
+
/**
|
|
395
|
+
* Name of the changed root.
|
|
396
|
+
*/
|
|
397
|
+
name: string;
|
|
398
|
+
/**
|
|
399
|
+
* Set accordingly if the root got attached or detached. Otherwise, not set.
|
|
400
|
+
*/
|
|
401
|
+
state?: 'attached' | 'detached';
|
|
402
|
+
/**
|
|
403
|
+
* Keeps all attribute changes that happened on the root.
|
|
404
|
+
*
|
|
405
|
+
* The keys are keys of the changed attributes. The values are objects containing the attribute value before the change
|
|
406
|
+
* (`oldValue`) and after the change (`newValue`).
|
|
407
|
+
*
|
|
408
|
+
* Note, that if the root state changed (`state` is set), then `attributes` property will not be set. All attributes should be
|
|
409
|
+
* handled together with the root being attached or detached.
|
|
410
|
+
*/
|
|
411
|
+
attributes?: Record<string, {
|
|
412
|
+
oldValue: unknown;
|
|
413
|
+
newValue: unknown;
|
|
414
|
+
}>;
|
|
415
|
+
}
|