@ckeditor/ckeditor5-engine 35.4.0 → 36.0.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/LICENSE.md +1 -1
- package/package.json +22 -22
- package/src/controller/datacontroller.js +5 -1
- package/src/controller/editingcontroller.js +1 -1
- package/src/conversion/conversion.js +1 -1
- package/src/conversion/conversionhelpers.js +1 -1
- package/src/conversion/downcastdispatcher.js +1 -1
- package/src/conversion/downcasthelpers.js +1 -1
- package/src/conversion/mapper.js +1 -1
- package/src/conversion/modelconsumable.js +1 -1
- package/src/conversion/upcastdispatcher.js +1 -1
- package/src/conversion/upcasthelpers.js +8 -1
- package/src/conversion/viewconsumable.js +1 -1
- package/src/dataprocessor/basichtmlwriter.js +1 -1
- package/src/dataprocessor/dataprocessor.js +1 -1
- package/src/dataprocessor/htmldataprocessor.js +1 -2
- package/src/dataprocessor/htmlwriter.js +1 -1
- package/src/dataprocessor/xmldataprocessor.js +1 -1
- package/src/dev-utils/model.js +1 -1
- package/src/dev-utils/operationreplayer.js +1 -1
- package/src/dev-utils/utils.js +1 -1
- package/src/dev-utils/view.js +1 -1
- package/src/index.js +3 -2
- package/src/model/batch.js +9 -46
- package/src/model/differ.js +81 -174
- package/src/model/document.js +36 -92
- package/src/model/documentfragment.js +43 -96
- package/src/model/documentselection.js +151 -245
- package/src/model/element.js +47 -100
- package/src/model/history.js +15 -46
- package/src/model/item.js +1 -1
- package/src/model/liveposition.js +10 -36
- package/src/model/liverange.js +13 -36
- package/src/model/markercollection.js +40 -111
- package/src/model/model.js +212 -289
- package/src/model/node.js +35 -125
- package/src/model/nodelist.js +11 -39
- package/src/model/operation/attributeoperation.js +13 -44
- package/src/model/operation/detachoperation.js +3 -16
- package/src/model/operation/insertoperation.js +6 -34
- package/src/model/operation/markeroperation.js +9 -48
- package/src/model/operation/mergeoperation.js +8 -41
- package/src/model/operation/moveoperation.js +14 -37
- package/src/model/operation/nooperation.js +1 -7
- package/src/model/operation/operation.js +5 -63
- package/src/model/operation/operationfactory.js +3 -6
- package/src/model/operation/renameoperation.js +8 -28
- package/src/model/operation/rootattributeoperation.js +18 -47
- package/src/model/operation/splitoperation.js +9 -47
- package/src/model/operation/transform.js +109 -150
- package/src/model/operation/utils.js +36 -50
- package/src/model/position.js +117 -228
- package/src/model/range.js +145 -200
- package/src/model/rootelement.js +8 -47
- package/src/model/schema.js +236 -272
- package/src/model/selection.js +134 -192
- package/src/model/text.js +10 -37
- package/src/model/textproxy.js +15 -69
- package/src/model/treewalker.js +10 -101
- package/src/model/typecheckable.js +1 -1
- package/src/model/utils/autoparagraphing.js +11 -12
- package/src/model/utils/deletecontent.js +93 -62
- package/src/model/utils/findoptimalinsertionrange.js +24 -24
- package/src/model/utils/getselectedcontent.js +3 -6
- package/src/model/utils/insertcontent.js +36 -129
- package/src/model/utils/insertobject.js +19 -21
- package/src/model/utils/modifyselection.js +23 -33
- package/src/model/utils/selection-post-fixer.js +53 -59
- package/src/model/writer.js +208 -314
- package/src/view/attributeelement.js +1 -1
- package/src/view/containerelement.js +1 -1
- package/src/view/datatransfer.js +1 -1
- package/src/view/document.js +1 -17
- package/src/view/documentfragment.js +49 -1
- package/src/view/documentselection.js +1 -1
- package/src/view/domconverter.js +4 -3
- package/src/view/downcastwriter.js +1 -1
- package/src/view/editableelement.js +1 -1
- package/src/view/element.js +5 -5
- package/src/view/elementdefinition.js +1 -1
- package/src/view/emptyelement.js +1 -1
- package/src/view/filler.js +1 -1
- package/src/view/item.js +1 -1
- package/src/view/matcher.js +1 -1
- package/src/view/node.js +1 -1
- package/src/view/observer/arrowkeysobserver.js +1 -1
- package/src/view/observer/bubblingemittermixin.js +1 -1
- package/src/view/observer/bubblingeventinfo.js +1 -1
- package/src/view/observer/clickobserver.js +1 -1
- package/src/view/observer/compositionobserver.js +1 -1
- package/src/view/observer/domeventdata.js +1 -1
- package/src/view/observer/domeventobserver.js +1 -1
- package/src/view/observer/fakeselectionobserver.js +1 -1
- package/src/view/observer/focusobserver.js +22 -4
- package/src/view/observer/inputobserver.js +1 -1
- package/src/view/observer/keyobserver.js +1 -1
- package/src/view/observer/mouseobserver.js +1 -1
- package/src/view/observer/mutationobserver.js +1 -1
- package/src/view/observer/observer.js +1 -1
- package/src/view/observer/selectionobserver.js +13 -2
- package/src/view/observer/tabobserver.js +1 -1
- package/src/view/placeholder.js +1 -1
- package/src/view/position.js +1 -1
- package/src/view/range.js +1 -1
- package/src/view/rawelement.js +1 -1
- package/src/view/renderer.js +1 -14
- package/src/view/rooteditableelement.js +1 -1
- package/src/view/selection.js +1 -1
- package/src/view/styles/background.js +1 -1
- package/src/view/styles/border.js +1 -1
- package/src/view/styles/margin.js +1 -1
- package/src/view/styles/padding.js +1 -1
- package/src/view/styles/utils.js +1 -1
- package/src/view/stylesmap.js +1 -1
- package/src/view/text.js +1 -1
- package/src/view/textproxy.js +1 -1
- package/src/view/treewalker.js +1 -1
- package/src/view/typecheckable.js +1 -1
- package/src/view/uielement.js +1 -1
- package/src/view/upcastwriter.js +1 -1
- package/src/view/view.js +5 -5
- package/theme/placeholder.css +1 -1
- package/theme/renderer.css +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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
5
|
/**
|
|
@@ -16,50 +16,24 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
|
16
16
|
* requires a range to change and root element can't
|
|
17
17
|
* be a part of range because every {@link module:engine/model/position~Position} has to be inside a root.
|
|
18
18
|
* {@link module:engine/model/position~Position} can't be created before a root element.
|
|
19
|
-
*
|
|
20
|
-
* @extends module:engine/model/operation/operation~Operation
|
|
21
19
|
*/
|
|
22
20
|
export default class RootAttributeOperation extends Operation {
|
|
23
21
|
/**
|
|
24
22
|
* Creates an operation that changes, removes or adds attributes on root element.
|
|
25
23
|
*
|
|
26
24
|
* @see module:engine/model/operation/attributeoperation~AttributeOperation
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
25
|
+
* @param root Root element to change.
|
|
26
|
+
* @param key Key of an attribute to change or remove.
|
|
27
|
+
* @param oldValue Old value of the attribute with given key or `null` if adding a new attribute.
|
|
28
|
+
* @param newValue New value to set for the attribute. If `null`, then the operation just removes the attribute.
|
|
29
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
32
30
|
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
33
31
|
*/
|
|
34
32
|
constructor(root, key, oldValue, newValue, baseVersion) {
|
|
35
33
|
super(baseVersion);
|
|
36
|
-
/**
|
|
37
|
-
* Root element to change.
|
|
38
|
-
*
|
|
39
|
-
* @readonly
|
|
40
|
-
* @member {module:engine/model/rootelement~RootElement}
|
|
41
|
-
*/
|
|
42
34
|
this.root = root;
|
|
43
|
-
/**
|
|
44
|
-
* Key of an attribute to change or remove.
|
|
45
|
-
*
|
|
46
|
-
* @readonly
|
|
47
|
-
* @member {String}
|
|
48
|
-
*/
|
|
49
35
|
this.key = key;
|
|
50
|
-
/**
|
|
51
|
-
* Old value of the attribute with given key or `null` if adding a new attribute.
|
|
52
|
-
*
|
|
53
|
-
* @readonly
|
|
54
|
-
* @member {*}
|
|
55
|
-
*/
|
|
56
36
|
this.oldValue = oldValue;
|
|
57
|
-
/**
|
|
58
|
-
* New value to set for the attribute. If `null`, then the operation just removes the attribute.
|
|
59
|
-
*
|
|
60
|
-
* @readonly
|
|
61
|
-
* @member {*}
|
|
62
|
-
*/
|
|
63
37
|
this.newValue = newValue;
|
|
64
38
|
}
|
|
65
39
|
/**
|
|
@@ -79,15 +53,13 @@ export default class RootAttributeOperation extends Operation {
|
|
|
79
53
|
/**
|
|
80
54
|
* Creates and returns an operation that has the same parameters as this operation.
|
|
81
55
|
*
|
|
82
|
-
* @returns
|
|
56
|
+
* @returns Clone of this operation.
|
|
83
57
|
*/
|
|
84
58
|
clone() {
|
|
85
59
|
return new RootAttributeOperation(this.root, this.key, this.oldValue, this.newValue, this.baseVersion);
|
|
86
60
|
}
|
|
87
61
|
/**
|
|
88
62
|
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
89
|
-
*
|
|
90
|
-
* @returns {module:engine/model/operation/rootattributeoperation~RootAttributeOperation}
|
|
91
63
|
*/
|
|
92
64
|
getReversed() {
|
|
93
65
|
return new RootAttributeOperation(this.root, this.key, this.newValue, this.oldValue, this.baseVersion + 1);
|
|
@@ -102,9 +74,9 @@ export default class RootAttributeOperation extends Operation {
|
|
|
102
74
|
* The element to change is not a root element.
|
|
103
75
|
*
|
|
104
76
|
* @error rootattribute-operation-not-a-root
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
77
|
+
* @param root
|
|
78
|
+
* @param key
|
|
79
|
+
* @param value
|
|
108
80
|
*/
|
|
109
81
|
throw new CKEditorError('rootattribute-operation-not-a-root', this, { root: this.root, key: this.key });
|
|
110
82
|
}
|
|
@@ -113,9 +85,9 @@ export default class RootAttributeOperation extends Operation {
|
|
|
113
85
|
* The attribute which should be removed does not exists for the given node.
|
|
114
86
|
*
|
|
115
87
|
* @error rootattribute-operation-wrong-old-value
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
88
|
+
* @param root
|
|
89
|
+
* @param key
|
|
90
|
+
* @param value
|
|
119
91
|
*/
|
|
120
92
|
throw new CKEditorError('rootattribute-operation-wrong-old-value', this, { root: this.root, key: this.key });
|
|
121
93
|
}
|
|
@@ -124,8 +96,8 @@ export default class RootAttributeOperation extends Operation {
|
|
|
124
96
|
* The attribute with given key already exists for the given node.
|
|
125
97
|
*
|
|
126
98
|
* @error rootattribute-operation-attribute-exists
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
99
|
+
* @param root
|
|
100
|
+
* @param key
|
|
129
101
|
*/
|
|
130
102
|
throw new CKEditorError('rootattribute-operation-attribute-exists', this, { root: this.root, key: this.key });
|
|
131
103
|
}
|
|
@@ -159,9 +131,8 @@ export default class RootAttributeOperation extends Operation {
|
|
|
159
131
|
/**
|
|
160
132
|
* Creates RootAttributeOperation object from deserilized object, i.e. from parsed JSON string.
|
|
161
133
|
*
|
|
162
|
-
* @param
|
|
163
|
-
* @param
|
|
164
|
-
* @returns {module:engine/model/operation/rootattributeoperation~RootAttributeOperation}
|
|
134
|
+
* @param json Deserialized JSON object.
|
|
135
|
+
* @param document Document on which this operation will be applied.
|
|
165
136
|
*/
|
|
166
137
|
static fromJSON(json, document) {
|
|
167
138
|
if (!document.getRoot(json.root)) {
|
|
@@ -169,7 +140,7 @@ export default class RootAttributeOperation extends Operation {
|
|
|
169
140
|
* Cannot create RootAttributeOperation for document. Root with specified name does not exist.
|
|
170
141
|
*
|
|
171
142
|
* @error rootattribute-operation-fromjson-no-root
|
|
172
|
-
* @param
|
|
143
|
+
* @param rootName
|
|
173
144
|
*/
|
|
174
145
|
throw new CKEditorError('rootattribute-operation-fromjson-no-root', this, { rootName: json.root });
|
|
175
146
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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
5
|
/**
|
|
@@ -15,53 +15,27 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
|
15
15
|
* Operation to split {@link module:engine/model/element~Element an element} at given
|
|
16
16
|
* {@link module:engine/model/operation/splitoperation~SplitOperation#splitPosition split position} into two elements,
|
|
17
17
|
* both containing a part of the element's original content.
|
|
18
|
-
*
|
|
19
|
-
* @extends module:engine/model/operation/operation~Operation
|
|
20
18
|
*/
|
|
21
19
|
export default class SplitOperation extends Operation {
|
|
22
20
|
/**
|
|
23
21
|
* Creates a split operation.
|
|
24
22
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
*
|
|
29
|
-
* @param {module:engine/model/position~Position|null} graveyardPosition Position in the graveyard root before the element which
|
|
23
|
+
* @param splitPosition Position at which an element should be split.
|
|
24
|
+
* @param howMany Total offset size of elements that are in the split element after `position`.
|
|
25
|
+
* @param insertionPosition Position at which the clone of split element (or element from graveyard) will be inserted.
|
|
26
|
+
* @param graveyardPosition Position in the graveyard root before the element which
|
|
30
27
|
* should be used as a parent of the nodes after `position`. If it is not set, a copy of the the `position` parent will be used.
|
|
31
|
-
* @param
|
|
28
|
+
* @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
|
|
32
29
|
* can be applied or `null` if the operation operates on detached (non-document) tree.
|
|
33
30
|
*/
|
|
34
31
|
constructor(splitPosition, howMany, insertionPosition, graveyardPosition, baseVersion) {
|
|
35
32
|
super(baseVersion);
|
|
36
|
-
/**
|
|
37
|
-
* Position at which an element should be split.
|
|
38
|
-
*
|
|
39
|
-
* @member {module:engine/model/position~Position} module:engine/model/operation/splitoperation~SplitOperation#splitPosition
|
|
40
|
-
*/
|
|
41
33
|
this.splitPosition = splitPosition.clone();
|
|
42
34
|
// Keep position sticking to the next node. This way any new content added at the place where the element is split
|
|
43
35
|
// will be left in the original element.
|
|
44
36
|
this.splitPosition.stickiness = 'toNext';
|
|
45
|
-
/**
|
|
46
|
-
* Total offset size of elements that are in the split element after `position`.
|
|
47
|
-
*
|
|
48
|
-
* @member {Number} module:engine/model/operation/splitoperation~SplitOperation#howMany
|
|
49
|
-
*/
|
|
50
37
|
this.howMany = howMany;
|
|
51
|
-
/**
|
|
52
|
-
* Position at which the clone of split element (or element from graveyard) will be inserted.
|
|
53
|
-
*
|
|
54
|
-
* @member {module:engine/model/position~Position} module:engine/model/operation/splitoperation~SplitOperation#insertionPosition
|
|
55
|
-
*/
|
|
56
38
|
this.insertionPosition = insertionPosition;
|
|
57
|
-
/**
|
|
58
|
-
* Position in the graveyard root before the element which should be used as a parent of the nodes after `position`.
|
|
59
|
-
* If it is not set, a copy of the the `position` parent will be used.
|
|
60
|
-
*
|
|
61
|
-
* The default behavior is to clone the split element. Element from graveyard is used during undo.
|
|
62
|
-
*
|
|
63
|
-
* @member {module:engine/model/position~Position|null} #graveyardPosition
|
|
64
|
-
*/
|
|
65
39
|
this.graveyardPosition = graveyardPosition ? graveyardPosition.clone() : null;
|
|
66
40
|
if (this.graveyardPosition) {
|
|
67
41
|
this.graveyardPosition.stickiness = 'toNext';
|
|
@@ -77,9 +51,6 @@ export default class SplitOperation extends Operation {
|
|
|
77
51
|
* Position inside the new clone of a split element.
|
|
78
52
|
*
|
|
79
53
|
* This is a position where nodes that are after the split position will be moved to.
|
|
80
|
-
*
|
|
81
|
-
* @readonly
|
|
82
|
-
* @type {module:engine/model/position~Position}
|
|
83
54
|
*/
|
|
84
55
|
get moveTargetPosition() {
|
|
85
56
|
const path = this.insertionPosition.path.slice();
|
|
@@ -89,9 +60,6 @@ export default class SplitOperation extends Operation {
|
|
|
89
60
|
/**
|
|
90
61
|
* Artificial range that contains all the nodes from the split element that will be moved to the new element.
|
|
91
62
|
* The range starts at {@link ~#splitPosition} and ends in the same parent, at `POSITIVE_INFINITY` offset.
|
|
92
|
-
*
|
|
93
|
-
* @readonly
|
|
94
|
-
* @type {module:engine/model/range~Range}
|
|
95
63
|
*/
|
|
96
64
|
get movedRange() {
|
|
97
65
|
const end = this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);
|
|
@@ -100,15 +68,13 @@ export default class SplitOperation extends Operation {
|
|
|
100
68
|
/**
|
|
101
69
|
* Creates and returns an operation that has the same parameters as this operation.
|
|
102
70
|
*
|
|
103
|
-
* @returns
|
|
71
|
+
* @returns Clone of this operation.
|
|
104
72
|
*/
|
|
105
73
|
clone() {
|
|
106
74
|
return new SplitOperation(this.splitPosition, this.howMany, this.insertionPosition, this.graveyardPosition, this.baseVersion);
|
|
107
75
|
}
|
|
108
76
|
/**
|
|
109
77
|
* See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
|
|
110
|
-
*
|
|
111
|
-
* @returns {module:engine/model/operation/mergeoperation~MergeOperation}
|
|
112
78
|
*/
|
|
113
79
|
getReversed() {
|
|
114
80
|
const graveyard = this.splitPosition.root.document.graveyard;
|
|
@@ -193,9 +159,6 @@ export default class SplitOperation extends Operation {
|
|
|
193
159
|
/**
|
|
194
160
|
* Helper function that returns a default insertion position basing on given `splitPosition`. The default insertion
|
|
195
161
|
* position is after the split element.
|
|
196
|
-
*
|
|
197
|
-
* @param {module:engine/model/position~Position} splitPosition
|
|
198
|
-
* @returns {module:engine/model/position~Position}
|
|
199
162
|
*/
|
|
200
163
|
static getInsertionPosition(splitPosition) {
|
|
201
164
|
const path = splitPosition.path.slice(0, -1);
|
|
@@ -205,9 +168,8 @@ export default class SplitOperation extends Operation {
|
|
|
205
168
|
/**
|
|
206
169
|
* Creates `SplitOperation` object from deserilized object, i.e. from parsed JSON string.
|
|
207
170
|
*
|
|
208
|
-
* @param
|
|
209
|
-
* @param
|
|
210
|
-
* @returns {module:engine/model/operation/splitoperation~SplitOperation}
|
|
171
|
+
* @param json Deserialized JSON object.
|
|
172
|
+
* @param document Document on which this operation will be applied.
|
|
211
173
|
*/
|
|
212
174
|
static fromJSON(json, document) {
|
|
213
175
|
const splitPosition = Position.fromJSON(json.splitPosition, document);
|