@ckeditor/ckeditor5-engine 41.2.0 → 41.3.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.
Files changed (134) hide show
  1. package/dist/content-index.css +4 -0
  2. package/dist/editor-index.css +23 -0
  3. package/dist/index.css +49 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.js +36728 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/types/controller/datacontroller.d.ts +335 -0
  8. package/dist/types/controller/editingcontroller.d.ts +98 -0
  9. package/dist/types/conversion/conversion.d.ts +478 -0
  10. package/dist/types/conversion/conversionhelpers.d.ts +26 -0
  11. package/dist/types/conversion/downcastdispatcher.d.ts +562 -0
  12. package/dist/types/conversion/downcasthelpers.d.ts +1190 -0
  13. package/dist/types/conversion/mapper.d.ts +503 -0
  14. package/dist/types/conversion/modelconsumable.d.ts +201 -0
  15. package/dist/types/conversion/upcastdispatcher.d.ts +492 -0
  16. package/dist/types/conversion/upcasthelpers.d.ts +499 -0
  17. package/dist/types/conversion/viewconsumable.d.ts +369 -0
  18. package/dist/types/dataprocessor/basichtmlwriter.d.ts +18 -0
  19. package/dist/types/dataprocessor/dataprocessor.d.ts +61 -0
  20. package/dist/types/dataprocessor/htmldataprocessor.d.ts +76 -0
  21. package/dist/types/dataprocessor/htmlwriter.d.ts +16 -0
  22. package/dist/types/dataprocessor/xmldataprocessor.d.ts +90 -0
  23. package/dist/types/dev-utils/model.d.ts +124 -0
  24. package/dist/types/dev-utils/operationreplayer.d.ts +51 -0
  25. package/dist/types/dev-utils/utils.d.ts +37 -0
  26. package/dist/types/dev-utils/view.d.ts +319 -0
  27. package/dist/types/index.d.ts +113 -0
  28. package/dist/types/model/batch.d.ts +106 -0
  29. package/dist/types/model/differ.d.ts +415 -0
  30. package/dist/types/model/document.d.ts +274 -0
  31. package/dist/types/model/documentfragment.d.ts +200 -0
  32. package/dist/types/model/documentselection.d.ts +420 -0
  33. package/dist/types/model/element.d.ts +165 -0
  34. package/dist/types/model/history.d.ts +114 -0
  35. package/dist/types/model/item.d.ts +14 -0
  36. package/dist/types/model/liveposition.d.ts +77 -0
  37. package/dist/types/model/liverange.d.ts +102 -0
  38. package/dist/types/model/markercollection.d.ts +335 -0
  39. package/dist/types/model/model.d.ts +919 -0
  40. package/dist/types/model/node.d.ts +255 -0
  41. package/dist/types/model/nodelist.d.ts +91 -0
  42. package/dist/types/model/operation/attributeoperation.d.ts +103 -0
  43. package/dist/types/model/operation/detachoperation.d.ts +60 -0
  44. package/dist/types/model/operation/insertoperation.d.ts +90 -0
  45. package/dist/types/model/operation/markeroperation.d.ts +91 -0
  46. package/dist/types/model/operation/mergeoperation.d.ts +100 -0
  47. package/dist/types/model/operation/moveoperation.d.ts +96 -0
  48. package/dist/types/model/operation/nooperation.d.ts +38 -0
  49. package/dist/types/model/operation/operation.d.ts +96 -0
  50. package/dist/types/model/operation/operationfactory.d.ts +18 -0
  51. package/dist/types/model/operation/renameoperation.d.ts +83 -0
  52. package/dist/types/model/operation/rootattributeoperation.d.ts +98 -0
  53. package/dist/types/model/operation/rootoperation.d.ts +76 -0
  54. package/dist/types/model/operation/splitoperation.d.ts +109 -0
  55. package/dist/types/model/operation/transform.d.ts +100 -0
  56. package/dist/types/model/operation/utils.d.ts +71 -0
  57. package/dist/types/model/position.d.ts +538 -0
  58. package/dist/types/model/range.d.ts +458 -0
  59. package/dist/types/model/rootelement.d.ts +60 -0
  60. package/dist/types/model/schema.d.ts +1206 -0
  61. package/dist/types/model/selection.d.ts +482 -0
  62. package/dist/types/model/text.d.ts +66 -0
  63. package/dist/types/model/textproxy.d.ts +144 -0
  64. package/dist/types/model/treewalker.d.ts +186 -0
  65. package/dist/types/model/typecheckable.d.ts +285 -0
  66. package/dist/types/model/utils/autoparagraphing.d.ts +37 -0
  67. package/dist/types/model/utils/deletecontent.d.ts +58 -0
  68. package/dist/types/model/utils/getselectedcontent.d.ts +30 -0
  69. package/dist/types/model/utils/insertcontent.d.ts +46 -0
  70. package/dist/types/model/utils/insertobject.d.ts +47 -0
  71. package/dist/types/model/utils/modifyselection.d.ts +48 -0
  72. package/dist/types/model/utils/selection-post-fixer.d.ts +74 -0
  73. package/dist/types/model/writer.d.ts +851 -0
  74. package/dist/types/view/attributeelement.d.ts +108 -0
  75. package/dist/types/view/containerelement.d.ts +49 -0
  76. package/dist/types/view/datatransfer.d.ts +79 -0
  77. package/dist/types/view/document.d.ts +184 -0
  78. package/dist/types/view/documentfragment.d.ts +153 -0
  79. package/dist/types/view/documentselection.d.ts +306 -0
  80. package/dist/types/view/domconverter.d.ts +652 -0
  81. package/dist/types/view/downcastwriter.d.ts +996 -0
  82. package/dist/types/view/editableelement.d.ts +62 -0
  83. package/dist/types/view/element.d.ts +468 -0
  84. package/dist/types/view/elementdefinition.d.ts +87 -0
  85. package/dist/types/view/emptyelement.d.ts +41 -0
  86. package/dist/types/view/filler.d.ts +111 -0
  87. package/dist/types/view/item.d.ts +14 -0
  88. package/dist/types/view/matcher.d.ts +486 -0
  89. package/dist/types/view/node.d.ts +162 -0
  90. package/dist/types/view/observer/arrowkeysobserver.d.ts +45 -0
  91. package/dist/types/view/observer/bubblingemittermixin.d.ts +166 -0
  92. package/dist/types/view/observer/bubblingeventinfo.d.ts +47 -0
  93. package/dist/types/view/observer/clickobserver.d.ts +43 -0
  94. package/dist/types/view/observer/compositionobserver.d.ts +82 -0
  95. package/dist/types/view/observer/domeventdata.d.ts +50 -0
  96. package/dist/types/view/observer/domeventobserver.d.ts +73 -0
  97. package/dist/types/view/observer/fakeselectionobserver.d.ts +47 -0
  98. package/dist/types/view/observer/focusobserver.d.ts +82 -0
  99. package/dist/types/view/observer/inputobserver.d.ts +86 -0
  100. package/dist/types/view/observer/keyobserver.d.ts +66 -0
  101. package/dist/types/view/observer/mouseobserver.d.ts +89 -0
  102. package/dist/types/view/observer/mutationobserver.d.ts +86 -0
  103. package/dist/types/view/observer/observer.d.ts +89 -0
  104. package/dist/types/view/observer/selectionobserver.d.ts +148 -0
  105. package/dist/types/view/observer/tabobserver.d.ts +46 -0
  106. package/dist/types/view/placeholder.d.ts +96 -0
  107. package/dist/types/view/position.d.ts +188 -0
  108. package/dist/types/view/range.d.ts +279 -0
  109. package/dist/types/view/rawelement.d.ts +73 -0
  110. package/dist/types/view/renderer.d.ts +265 -0
  111. package/dist/types/view/rooteditableelement.d.ts +41 -0
  112. package/dist/types/view/selection.d.ts +375 -0
  113. package/dist/types/view/styles/background.d.ts +33 -0
  114. package/dist/types/view/styles/border.d.ts +43 -0
  115. package/dist/types/view/styles/margin.d.ts +29 -0
  116. package/dist/types/view/styles/padding.d.ts +29 -0
  117. package/dist/types/view/styles/utils.d.ts +93 -0
  118. package/dist/types/view/stylesmap.d.ts +673 -0
  119. package/dist/types/view/text.d.ts +74 -0
  120. package/dist/types/view/textproxy.d.ts +97 -0
  121. package/dist/types/view/treewalker.d.ts +195 -0
  122. package/dist/types/view/typecheckable.d.ts +448 -0
  123. package/dist/types/view/uielement.d.ts +96 -0
  124. package/dist/types/view/upcastwriter.d.ts +417 -0
  125. package/dist/types/view/view.d.ts +487 -0
  126. package/package.json +3 -2
  127. package/src/model/node.d.ts +0 -1
  128. package/src/model/node.js +0 -2
  129. package/src/model/position.d.ts +0 -1
  130. package/src/model/position.js +0 -2
  131. package/src/view/node.d.ts +0 -1
  132. package/src/view/node.js +0 -2
  133. package/src/view/position.d.ts +0 -1
  134. package/src/view/position.js +0 -2
@@ -0,0 +1,255 @@
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/node
7
+ */
8
+ import TypeCheckable from './typecheckable.js';
9
+ import type Document from './document.js';
10
+ import type DocumentFragment from './documentfragment.js';
11
+ import type Element from './element.js';
12
+ /**
13
+ * Model node. Most basic structure of model tree.
14
+ *
15
+ * This is an abstract class that is a base for other classes representing different nodes in model.
16
+ *
17
+ * **Note:** If a node is detached from the model tree, you can manipulate it using it's API.
18
+ * However, it is **very important** that nodes already attached to model tree should be only changed through
19
+ * {@link module:engine/model/writer~Writer Writer API}.
20
+ *
21
+ * Changes done by `Node` methods, like {@link module:engine/model/element~Element#_insertChild _insertChild} or
22
+ * {@link module:engine/model/node~Node#_setAttribute _setAttribute}
23
+ * do not generate {@link module:engine/model/operation/operation~Operation operations}
24
+ * which are essential for correct editor work if you modify nodes in {@link module:engine/model/document~Document document} root.
25
+ *
26
+ * The flow of working on `Node` (and classes that inherits from it) is as such:
27
+ * 1. You can create a `Node` instance, modify it using it's API.
28
+ * 2. Add `Node` to the model using `Batch` API.
29
+ * 3. Change `Node` that was already added to the model using `Batch` API.
30
+ *
31
+ * Similarly, you cannot use `Batch` API on a node that has not been added to the model tree, with the exception
32
+ * of {@link module:engine/model/writer~Writer#insert inserting} that node to the model tree.
33
+ *
34
+ * Be aware that using {@link module:engine/model/writer~Writer#remove remove from Batch API} does not allow to use `Node` API because
35
+ * the information about `Node` is still kept in model document.
36
+ *
37
+ * In case of {@link module:engine/model/element~Element element node}, adding and removing children also counts as changing a node and
38
+ * follows same rules.
39
+ */
40
+ export default abstract class Node extends TypeCheckable {
41
+ /**
42
+ * Parent of this node. It could be {@link module:engine/model/element~Element}
43
+ * or {@link module:engine/model/documentfragment~DocumentFragment}.
44
+ * Equals to `null` if the node has no parent.
45
+ */
46
+ readonly parent: Element | DocumentFragment | null;
47
+ /**
48
+ * Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
49
+ */
50
+ readonly rootName: string | undefined;
51
+ /**
52
+ * Attributes set on this node.
53
+ */
54
+ private _attrs;
55
+ /**
56
+ * Creates a model node.
57
+ *
58
+ * This is an abstract class, so this constructor should not be used directly.
59
+ *
60
+ * @param attrs Node's attributes. See {@link module:utils/tomap~toMap} for a list of accepted values.
61
+ */
62
+ constructor(attrs?: NodeAttributes);
63
+ /**
64
+ * {@link module:engine/model/document~Document Document} that owns this root element.
65
+ */
66
+ get document(): Document | null;
67
+ /**
68
+ * Index of this node in its parent or `null` if the node has no parent.
69
+ *
70
+ * Accessing this property throws an error if this node's parent element does not contain it.
71
+ * This means that model tree got broken.
72
+ */
73
+ get index(): number | null;
74
+ /**
75
+ * Offset at which this node starts in its parent. It is equal to the sum of {@link #offsetSize offsetSize}
76
+ * of all its previous siblings. Equals to `null` if node has no parent.
77
+ *
78
+ * Accessing this property throws an error if this node's parent element does not contain it.
79
+ * This means that model tree got broken.
80
+ */
81
+ get startOffset(): number | null;
82
+ /**
83
+ * Offset size of this node. Represents how much "offset space" is occupied by the node in it's parent.
84
+ * It is important for {@link module:engine/model/position~Position position}. When node has `offsetSize` greater than `1`, position
85
+ * can be placed between that node start and end. `offsetSize` greater than `1` is for nodes that represents more
86
+ * than one entity, i.e. {@link module:engine/model/text~Text text node}.
87
+ */
88
+ get offsetSize(): number;
89
+ /**
90
+ * Offset at which this node ends in it's parent. It is equal to the sum of this node's
91
+ * {@link module:engine/model/node~Node#startOffset start offset} and {@link #offsetSize offset size}.
92
+ * Equals to `null` if the node has no parent.
93
+ */
94
+ get endOffset(): number | null;
95
+ /**
96
+ * Node's next sibling or `null` if the node is a last child of it's parent or if the node has no parent.
97
+ */
98
+ get nextSibling(): Node | null;
99
+ /**
100
+ * Node's previous sibling or `null` if the node is a first child of it's parent or if the node has no parent.
101
+ */
102
+ get previousSibling(): Node | null;
103
+ /**
104
+ * The top-most ancestor of the node. If node has no parent it is the root itself. If the node is a part
105
+ * of {@link module:engine/model/documentfragment~DocumentFragment}, it's `root` is equal to that `DocumentFragment`.
106
+ */
107
+ get root(): Node | DocumentFragment;
108
+ /**
109
+ * Returns `true` if the node is inside a document root that is attached to the document.
110
+ */
111
+ isAttached(): boolean;
112
+ /**
113
+ * Gets path to the node. The path is an array containing starting offsets of consecutive ancestors of this node,
114
+ * beginning from {@link module:engine/model/node~Node#root root}, down to this node's starting offset. The path can be used to
115
+ * create {@link module:engine/model/position~Position Position} instance.
116
+ *
117
+ * ```ts
118
+ * const abc = new Text( 'abc' );
119
+ * const foo = new Text( 'foo' );
120
+ * const h1 = new Element( 'h1', null, new Text( 'header' ) );
121
+ * const p = new Element( 'p', null, [ abc, foo ] );
122
+ * const div = new Element( 'div', null, [ h1, p ] );
123
+ * foo.getPath(); // Returns [ 1, 3 ]. `foo` is in `p` which is in `div`. `p` starts at offset 1, while `foo` at 3.
124
+ * h1.getPath(); // Returns [ 0 ].
125
+ * div.getPath(); // Returns [].
126
+ * ```
127
+ */
128
+ getPath(): Array<number>;
129
+ /**
130
+ * Returns ancestors array of this node.
131
+ *
132
+ * @param options Options object.
133
+ * @param options.includeSelf When set to `true` this node will be also included in parent's array.
134
+ * @param options.parentFirst When set to `true`, array will be sorted from node's parent to root element,
135
+ * otherwise root element will be the first item in the array.
136
+ * @returns Array with ancestors.
137
+ */
138
+ getAncestors(options?: {
139
+ includeSelf?: boolean;
140
+ parentFirst?: boolean;
141
+ }): Array<Node | DocumentFragment>;
142
+ /**
143
+ * Returns a {@link module:engine/model/element~Element} or {@link module:engine/model/documentfragment~DocumentFragment}
144
+ * which is a common ancestor of both nodes.
145
+ *
146
+ * @param node The second node.
147
+ * @param options Options object.
148
+ * @param options.includeSelf When set to `true` both nodes will be considered "ancestors" too.
149
+ * Which means that if e.g. node A is inside B, then their common ancestor will be B.
150
+ */
151
+ getCommonAncestor(node: Node, options?: {
152
+ includeSelf?: boolean;
153
+ }): Element | DocumentFragment | null;
154
+ /**
155
+ * Returns whether this node is before given node. `false` is returned if nodes are in different trees (for example,
156
+ * in different {@link module:engine/model/documentfragment~DocumentFragment}s).
157
+ *
158
+ * @param node Node to compare with.
159
+ */
160
+ isBefore(node: Node): boolean;
161
+ /**
162
+ * Returns whether this node is after given node. `false` is returned if nodes are in different trees (for example,
163
+ * in different {@link module:engine/model/documentfragment~DocumentFragment}s).
164
+ *
165
+ * @param node Node to compare with.
166
+ */
167
+ isAfter(node: Node): boolean;
168
+ /**
169
+ * Checks if the node has an attribute with given key.
170
+ *
171
+ * @param key Key of attribute to check.
172
+ * @returns `true` if attribute with given key is set on node, `false` otherwise.
173
+ */
174
+ hasAttribute(key: string): boolean;
175
+ /**
176
+ * Gets an attribute value for given key or `undefined` if that attribute is not set on node.
177
+ *
178
+ * @param key Key of attribute to look for.
179
+ * @returns Attribute value or `undefined`.
180
+ */
181
+ getAttribute(key: string): unknown;
182
+ /**
183
+ * Returns iterator that iterates over this node's attributes.
184
+ *
185
+ * Attributes are returned as arrays containing two items. First one is attribute key and second is attribute value.
186
+ * This format is accepted by native `Map` object and also can be passed in `Node` constructor.
187
+ */
188
+ getAttributes(): IterableIterator<[string, unknown]>;
189
+ /**
190
+ * Returns iterator that iterates over this node's attribute keys.
191
+ */
192
+ getAttributeKeys(): IterableIterator<string>;
193
+ /**
194
+ * Converts `Node` to plain object and returns it.
195
+ *
196
+ * @returns `Node` converted to plain object.
197
+ */
198
+ toJSON(): unknown;
199
+ /**
200
+ * Creates a copy of this node, that is a node with exactly same attributes, and returns it.
201
+ *
202
+ * @internal
203
+ * @returns Node with same attributes as this node.
204
+ */
205
+ _clone(_deep?: boolean): Node;
206
+ /**
207
+ * Removes this node from it's parent.
208
+ *
209
+ * @internal
210
+ * @see module:engine/model/writer~Writer#remove
211
+ */
212
+ _remove(): void;
213
+ /**
214
+ * Sets attribute on the node. If attribute with the same key already is set, it's value is overwritten.
215
+ *
216
+ * @see module:engine/model/writer~Writer#setAttribute
217
+ * @internal
218
+ * @param key Key of attribute to set.
219
+ * @param value Attribute value.
220
+ */
221
+ _setAttribute(key: string, value: unknown): void;
222
+ /**
223
+ * Removes all attributes from the node and sets given attributes.
224
+ *
225
+ * @see module:engine/model/writer~Writer#setAttributes
226
+ * @internal
227
+ * @param attrs Attributes to set. See {@link module:utils/tomap~toMap} for a list of accepted values.
228
+ */
229
+ _setAttributesTo(attrs: NodeAttributes): void;
230
+ /**
231
+ * Removes an attribute with given key from the node.
232
+ *
233
+ * @see module:engine/model/writer~Writer#removeAttribute
234
+ * @internal
235
+ * @param key Key of attribute to remove.
236
+ * @returns `true` if the attribute was set on the element, `false` otherwise.
237
+ */
238
+ _removeAttribute(key: string): boolean;
239
+ /**
240
+ * Removes all attributes from the node.
241
+ *
242
+ * @see module:engine/model/writer~Writer#clearAttributes
243
+ * @internal
244
+ */
245
+ _clearAttributes(): void;
246
+ }
247
+ /**
248
+ * The node's parent does not contain this node.
249
+ *
250
+ * @error model-node-not-found-in-parent
251
+ */
252
+ /**
253
+ * Node's attributes. See {@link module:utils/tomap~toMap} for a list of accepted values.
254
+ */
255
+ export type NodeAttributes = Record<string, unknown> | Iterable<[string, unknown]>;
@@ -0,0 +1,91 @@
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/nodelist
7
+ */
8
+ import Node from './node.js';
9
+ /**
10
+ * Provides an interface to operate on a list of {@link module:engine/model/node~Node nodes}. `NodeList` is used internally
11
+ * in classes like {@link module:engine/model/element~Element Element}
12
+ * or {@link module:engine/model/documentfragment~DocumentFragment DocumentFragment}.
13
+ */
14
+ export default class NodeList implements Iterable<Node> {
15
+ /**
16
+ * Nodes contained in this node list.
17
+ */
18
+ private _nodes;
19
+ /**
20
+ * Creates an empty node list.
21
+ *
22
+ * @internal
23
+ * @param nodes Nodes contained in this node list.
24
+ */
25
+ constructor(nodes?: Iterable<Node>);
26
+ /**
27
+ * Iterable interface.
28
+ *
29
+ * Iterates over all nodes contained inside this node list.
30
+ */
31
+ [Symbol.iterator](): IterableIterator<Node>;
32
+ /**
33
+ * Number of nodes contained inside this node list.
34
+ */
35
+ get length(): number;
36
+ /**
37
+ * Sum of {@link module:engine/model/node~Node#offsetSize offset sizes} of all nodes contained inside this node list.
38
+ */
39
+ get maxOffset(): number;
40
+ /**
41
+ * Gets the node at the given index. Returns `null` if incorrect index was passed.
42
+ */
43
+ getNode(index: number): Node | null;
44
+ /**
45
+ * Returns an index of the given node. Returns `null` if given node is not inside this node list.
46
+ */
47
+ getNodeIndex(node: Node): number | null;
48
+ /**
49
+ * Returns the starting offset of given node. Starting offset is equal to the sum of
50
+ * {@link module:engine/model/node~Node#offsetSize offset sizes} of all nodes that are before this node in this node list.
51
+ */
52
+ getNodeStartOffset(node: Node): number | null;
53
+ /**
54
+ * Converts index to offset in node list.
55
+ *
56
+ * Returns starting offset of a node that is at given index. Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError}
57
+ * `model-nodelist-index-out-of-bounds` if given index is less than `0` or more than {@link #length}.
58
+ */
59
+ indexToOffset(index: number): number;
60
+ /**
61
+ * Converts offset in node list to index.
62
+ *
63
+ * Returns index of a node that occupies given offset. Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError}
64
+ * `model-nodelist-offset-out-of-bounds` if given offset is less than `0` or more than {@link #maxOffset}.
65
+ */
66
+ offsetToIndex(offset: number): number;
67
+ /**
68
+ * Inserts given nodes at given index.
69
+ *
70
+ * @internal
71
+ * @param index Index at which nodes should be inserted.
72
+ * @param nodes Nodes to be inserted.
73
+ */
74
+ _insertNodes(index: number, nodes: Iterable<Node>): void;
75
+ /**
76
+ * Removes one or more nodes starting at the given index.
77
+ *
78
+ * @internal
79
+ * @param indexStart Index of the first node to remove.
80
+ * @param howMany Number of nodes to remove.
81
+ * @returns Array containing removed nodes.
82
+ */
83
+ _removeNodes(indexStart: number, howMany?: number): Array<Node>;
84
+ /**
85
+ * Converts `NodeList` instance to an array containing nodes that were inserted in the node list. Nodes
86
+ * are also converted to their plain object representation.
87
+ *
88
+ * @returns `NodeList` instance converted to `Array`.
89
+ */
90
+ toJSON(): unknown;
91
+ }
@@ -0,0 +1,103 @@
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/operation/attributeoperation
7
+ */
8
+ import Operation from './operation.js';
9
+ import Range from '../range.js';
10
+ import type Document from '../document.js';
11
+ import type { Selectable } from '../selection.js';
12
+ /**
13
+ * Operation to change nodes' attribute.
14
+ *
15
+ * Using this class you can add, remove or change value of the attribute.
16
+ */
17
+ export default class AttributeOperation extends Operation {
18
+ /**
19
+ * Range on which operation should be applied.
20
+ *
21
+ * @readonly
22
+ */
23
+ range: Range;
24
+ /**
25
+ * Key of an attribute to change or remove.
26
+ *
27
+ * @readonly
28
+ */
29
+ key: string;
30
+ /**
31
+ * Old value of the attribute with given key or `null`, if attribute was not set before.
32
+ *
33
+ * @readonly
34
+ */
35
+ oldValue: unknown;
36
+ /**
37
+ * New value of the attribute with given key or `null`, if operation should remove attribute.
38
+ *
39
+ * @readonly
40
+ */
41
+ newValue: unknown;
42
+ /**
43
+ * Creates an operation that changes, removes or adds attributes.
44
+ *
45
+ * If only `newValue` is set, attribute will be added on a node. Note that all nodes in operation's range must not
46
+ * have an attribute with the same key as the added attribute.
47
+ *
48
+ * If only `oldValue` is set, then attribute with given key will be removed. Note that all nodes in operation's range
49
+ * must have an attribute with that key added.
50
+ *
51
+ * If both `newValue` and `oldValue` are set, then the operation will change the attribute value. Note that all nodes in
52
+ * operation's ranges must already have an attribute with given key and `oldValue` as value
53
+ *
54
+ * @param range Range on which the operation should be applied. Must be a flat range.
55
+ * @param key Key of an attribute to change or remove.
56
+ * @param oldValue Old value of the attribute with given key or `null`, if attribute was not set before.
57
+ * @param newValue New value of the attribute with given key or `null`, if operation should remove attribute.
58
+ * @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
59
+ * can be applied or `null` if the operation operates on detached (non-document) tree.
60
+ */
61
+ constructor(range: Range, key: string, oldValue: unknown, newValue: unknown, baseVersion: number | null);
62
+ /**
63
+ * @inheritDoc
64
+ */
65
+ get type(): 'addAttribute' | 'removeAttribute' | 'changeAttribute';
66
+ /**
67
+ * @inheritDoc
68
+ */
69
+ get affectedSelectable(): Selectable;
70
+ /**
71
+ * Creates and returns an operation that has the same parameters as this operation.
72
+ */
73
+ clone(): AttributeOperation;
74
+ /**
75
+ * See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
76
+ */
77
+ getReversed(): Operation;
78
+ /**
79
+ * @inheritDoc
80
+ */
81
+ toJSON(): unknown;
82
+ /**
83
+ * @inheritDoc
84
+ * @internal
85
+ */
86
+ _validate(): void;
87
+ /**
88
+ * @inheritDoc
89
+ * @internal
90
+ */
91
+ _execute(): void;
92
+ /**
93
+ * @inheritDoc
94
+ */
95
+ static get className(): string;
96
+ /**
97
+ * Creates `AttributeOperation` object from deserialized object, i.e. from parsed JSON string.
98
+ *
99
+ * @param json Deserialized JSON object.
100
+ * @param document Document on which this operation will be applied.
101
+ */
102
+ static fromJSON(json: any, document: Document): AttributeOperation;
103
+ }
@@ -0,0 +1,60 @@
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/operation/detachoperation
7
+ */
8
+ import Operation from './operation.js';
9
+ import type Position from '../position.js';
10
+ import type { Selectable } from '../selection.js';
11
+ /**
12
+ * Operation to permanently remove node from detached root.
13
+ * Note this operation is only a local operation and won't be send to the other clients.
14
+ */
15
+ export default class DetachOperation extends Operation {
16
+ /**
17
+ * Position before the first {@link module:engine/model/item~Item model item} to detach.
18
+ */
19
+ sourcePosition: Position;
20
+ /**
21
+ * Offset size of moved range.
22
+ */
23
+ howMany: number;
24
+ clone: never;
25
+ getReversed: never;
26
+ /**
27
+ * Creates an insert operation.
28
+ *
29
+ * @param sourcePosition Position before the first {@link module:engine/model/item~Item model item} to move.
30
+ * @param howMany Offset size of moved range. Moved range will start from `sourcePosition` and end at
31
+ * `sourcePosition` with offset shifted by `howMany`.
32
+ */
33
+ constructor(sourcePosition: Position, howMany: number);
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ get type(): 'detach';
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ get affectedSelectable(): Selectable;
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ toJSON(): unknown;
46
+ /**
47
+ * @inheritDoc
48
+ * @internal
49
+ */
50
+ _validate(): void;
51
+ /**
52
+ * @inheritDoc
53
+ * @internal
54
+ */
55
+ _execute(): void;
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ static get className(): string;
60
+ }
@@ -0,0 +1,90 @@
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/operation/insertoperation
7
+ */
8
+ import Operation from './operation.js';
9
+ import Position from '../position.js';
10
+ import NodeList from '../nodelist.js';
11
+ import { type NodeSet } from './utils.js';
12
+ import type { Selectable } from '../selection.js';
13
+ import type Document from '../document.js';
14
+ /**
15
+ * Operation to insert one or more nodes at given position in the model.
16
+ */
17
+ export default class InsertOperation extends Operation {
18
+ /**
19
+ * Position of insertion.
20
+ *
21
+ * @readonly
22
+ */
23
+ position: Position;
24
+ /**
25
+ * List of nodes to insert.
26
+ *
27
+ * @readonly
28
+ */
29
+ nodes: NodeList;
30
+ /**
31
+ * Flag deciding how the operation should be transformed. If set to `true`, nodes might get additional attributes
32
+ * during operational transformation. This happens when the operation insertion position is inside of a range
33
+ * where attributes have changed.
34
+ */
35
+ shouldReceiveAttributes: boolean;
36
+ /**
37
+ * Creates an insert operation.
38
+ *
39
+ * @param position Position of insertion.
40
+ * @param nodes The list of nodes to be inserted.
41
+ * @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
42
+ * can be applied or `null` if the operation operates on detached (non-document) tree.
43
+ */
44
+ constructor(position: Position, nodes: NodeSet, baseVersion: number | null);
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ get type(): 'insert';
49
+ /**
50
+ * Total offset size of inserted nodes.
51
+ */
52
+ get howMany(): number;
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ get affectedSelectable(): Selectable;
57
+ /**
58
+ * Creates and returns an operation that has the same parameters as this operation.
59
+ */
60
+ clone(): InsertOperation;
61
+ /**
62
+ * See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
63
+ */
64
+ getReversed(): Operation;
65
+ /**
66
+ * @inheritDoc
67
+ * @internal
68
+ */
69
+ _validate(): void;
70
+ /**
71
+ * @inheritDoc
72
+ * @internal
73
+ */
74
+ _execute(): void;
75
+ /**
76
+ * @inheritDoc
77
+ */
78
+ toJSON(): unknown;
79
+ /**
80
+ * @inheritDoc
81
+ */
82
+ static get className(): string;
83
+ /**
84
+ * Creates `InsertOperation` object from deserialized object, i.e. from parsed JSON string.
85
+ *
86
+ * @param json Deserialized JSON object.
87
+ * @param document Document on which this operation will be applied.
88
+ */
89
+ static fromJSON(json: any, document: Document): InsertOperation;
90
+ }
@@ -0,0 +1,91 @@
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/operation/markeroperation
7
+ */
8
+ import Operation from './operation.js';
9
+ import Range from '../range.js';
10
+ import type Document from '../document.js';
11
+ import type MarkerCollection from '../markercollection.js';
12
+ import type { Selectable } from '../selection.js';
13
+ export default class MarkerOperation extends Operation {
14
+ /**
15
+ * Marker name.
16
+ *
17
+ * @readonly
18
+ */
19
+ name: string;
20
+ /**
21
+ * Marker range before the change.
22
+ *
23
+ * @readonly
24
+ */
25
+ oldRange: Range | null;
26
+ /**
27
+ * Marker range after the change.
28
+ *
29
+ * @readonly
30
+ */
31
+ newRange: Range | null;
32
+ /**
33
+ * Specifies whether the marker operation affects the data produced by the data pipeline
34
+ * (is persisted in the editor's data).
35
+ *
36
+ * @readonly
37
+ */
38
+ affectsData: boolean;
39
+ /**
40
+ * Marker collection on which change should be executed.
41
+ */
42
+ private readonly _markers;
43
+ /**
44
+ * @param name Marker name.
45
+ * @param oldRange Marker range before the change.
46
+ * @param newRange Marker range after the change.
47
+ * @param markers Marker collection on which change should be executed.
48
+ * @param affectsData Specifies whether the marker operation affects the data produced by the data pipeline
49
+ * (is persisted in the editor's data).
50
+ * @param baseVersion Document {@link module:engine/model/document~Document#version} on which operation
51
+ * can be applied or `null` if the operation operates on detached (non-document) tree.
52
+ */
53
+ constructor(name: string, oldRange: Range | null, newRange: Range | null, markers: MarkerCollection, affectsData: boolean, baseVersion: number | null);
54
+ /**
55
+ * @inheritDoc
56
+ */
57
+ get type(): 'marker';
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ get affectedSelectable(): Selectable;
62
+ /**
63
+ * Creates and returns an operation that has the same parameters as this operation.
64
+ */
65
+ clone(): MarkerOperation;
66
+ /**
67
+ * See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
68
+ */
69
+ getReversed(): Operation;
70
+ /**
71
+ * @inheritDoc
72
+ * @internal
73
+ */
74
+ _execute(): void;
75
+ /**
76
+ * @inheritDoc
77
+ * @internal
78
+ */
79
+ toJSON(): unknown;
80
+ /**
81
+ * @inheritDoc
82
+ */
83
+ static get className(): string;
84
+ /**
85
+ * Creates `MarkerOperation` object from deserialized object, i.e. from parsed JSON string.
86
+ *
87
+ * @param json Deserialized JSON object.
88
+ * @param document Document on which this operation will be applied.
89
+ */
90
+ static fromJSON(json: any, document: Document): MarkerOperation;
91
+ }