@ckeditor/ckeditor5-engine 45.2.1 → 46.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.
Files changed (241) hide show
  1. package/dist/index.js +2563 -2257
  2. package/dist/index.js.map +1 -1
  3. package/package.json +3 -3
  4. package/src/controller/datacontroller.d.ts +33 -32
  5. package/src/controller/datacontroller.js +29 -28
  6. package/src/controller/editingcontroller.d.ts +8 -8
  7. package/src/controller/editingcontroller.js +10 -10
  8. package/src/conversion/conversion.d.ts +18 -19
  9. package/src/conversion/conversion.js +4 -4
  10. package/src/conversion/conversionhelpers.d.ts +1 -1
  11. package/src/conversion/conversionhelpers.js +1 -1
  12. package/src/conversion/downcastdispatcher.d.ts +63 -69
  13. package/src/conversion/downcastdispatcher.js +16 -16
  14. package/src/conversion/downcasthelpers.d.ts +94 -83
  15. package/src/conversion/downcasthelpers.js +63 -53
  16. package/src/conversion/mapper.d.ts +27 -27
  17. package/src/conversion/mapper.js +15 -15
  18. package/src/conversion/modelconsumable.d.ts +26 -26
  19. package/src/conversion/modelconsumable.js +23 -23
  20. package/src/conversion/upcastdispatcher.d.ts +33 -32
  21. package/src/conversion/upcastdispatcher.js +19 -19
  22. package/src/conversion/upcasthelpers.d.ts +46 -38
  23. package/src/conversion/upcasthelpers.js +33 -24
  24. package/src/conversion/viewconsumable.d.ts +50 -45
  25. package/src/conversion/viewconsumable.js +32 -27
  26. package/src/dataprocessor/basichtmlwriter.d.ts +4 -2
  27. package/src/dataprocessor/basichtmlwriter.js +3 -1
  28. package/src/dataprocessor/dataprocessor.d.ts +7 -6
  29. package/src/dataprocessor/htmldataprocessor.d.ts +10 -10
  30. package/src/dataprocessor/htmldataprocessor.js +6 -6
  31. package/src/dataprocessor/htmlwriter.d.ts +1 -1
  32. package/src/dataprocessor/xmldataprocessor.d.ts +10 -10
  33. package/src/dataprocessor/xmldataprocessor.js +6 -6
  34. package/src/dev-utils/model.d.ts +25 -26
  35. package/src/dev-utils/model.js +35 -36
  36. package/src/dev-utils/operationreplayer.d.ts +5 -3
  37. package/src/dev-utils/operationreplayer.js +4 -2
  38. package/src/dev-utils/utils.d.ts +8 -0
  39. package/src/dev-utils/utils.js +8 -0
  40. package/src/dev-utils/view.d.ts +66 -63
  41. package/src/dev-utils/view.js +144 -134
  42. package/src/index.d.ts +135 -106
  43. package/src/index.js +120 -71
  44. package/src/legacyerrors.d.ts +5 -0
  45. package/src/legacyerrors.js +17 -0
  46. package/src/model/batch.d.ts +2 -15
  47. package/src/model/batch.js +1 -23
  48. package/src/model/differ.d.ts +54 -31
  49. package/src/model/differ.js +15 -15
  50. package/src/model/document.d.ts +31 -31
  51. package/src/model/document.js +13 -13
  52. package/src/model/documentfragment.d.ts +45 -45
  53. package/src/model/documentfragment.js +40 -40
  54. package/src/model/documentselection.d.ts +92 -92
  55. package/src/model/documentselection.js +71 -70
  56. package/src/model/element.d.ts +31 -31
  57. package/src/model/element.js +29 -29
  58. package/src/model/history.d.ts +3 -3
  59. package/src/model/history.js +2 -2
  60. package/src/model/item.d.ts +4 -5
  61. package/src/model/liveposition.d.ts +31 -31
  62. package/src/model/liveposition.js +18 -18
  63. package/src/model/liverange.d.ts +42 -38
  64. package/src/model/liverange.js +17 -16
  65. package/src/model/markercollection.d.ts +41 -40
  66. package/src/model/markercollection.js +22 -20
  67. package/src/model/model.d.ts +82 -81
  68. package/src/model/model.js +54 -54
  69. package/src/model/node.d.ts +48 -48
  70. package/src/model/node.js +31 -31
  71. package/src/model/nodelist.d.ts +17 -17
  72. package/src/model/nodelist.js +11 -11
  73. package/src/model/operation/attributeoperation.d.ts +10 -10
  74. package/src/model/operation/attributeoperation.js +7 -7
  75. package/src/model/operation/detachoperation.d.ts +11 -9
  76. package/src/model/operation/detachoperation.js +8 -6
  77. package/src/model/operation/insertoperation.d.ts +13 -13
  78. package/src/model/operation/insertoperation.js +15 -15
  79. package/src/model/operation/markeroperation.d.ts +12 -12
  80. package/src/model/operation/markeroperation.js +5 -5
  81. package/src/model/operation/mergeoperation.d.ts +16 -16
  82. package/src/model/operation/mergeoperation.js +18 -18
  83. package/src/model/operation/moveoperation.d.ts +16 -16
  84. package/src/model/operation/moveoperation.js +18 -15
  85. package/src/model/operation/nooperation.d.ts +4 -4
  86. package/src/model/operation/nooperation.js +2 -2
  87. package/src/model/operation/operation.d.ts +10 -10
  88. package/src/model/operation/operation.js +5 -5
  89. package/src/model/operation/operationfactory.d.ts +4 -4
  90. package/src/model/operation/operationfactory.js +12 -12
  91. package/src/model/operation/renameoperation.d.ts +10 -10
  92. package/src/model/operation/renameoperation.js +7 -7
  93. package/src/model/operation/rootattributeoperation.d.ts +12 -12
  94. package/src/model/operation/rootattributeoperation.js +8 -8
  95. package/src/model/operation/rootoperation.d.ts +8 -8
  96. package/src/model/operation/rootoperation.js +3 -3
  97. package/src/model/operation/splitoperation.d.ts +17 -17
  98. package/src/model/operation/splitoperation.js +19 -19
  99. package/src/model/operation/transform.d.ts +11 -8
  100. package/src/model/operation/transform.js +66 -49
  101. package/src/model/operation/utils.d.ts +24 -23
  102. package/src/model/operation/utils.js +20 -20
  103. package/src/model/position.d.ts +101 -97
  104. package/src/model/position.js +69 -64
  105. package/src/model/range.d.ts +90 -90
  106. package/src/model/range.js +87 -87
  107. package/src/model/rootelement.d.ts +11 -11
  108. package/src/model/rootelement.js +9 -9
  109. package/src/model/schema.d.ts +158 -154
  110. package/src/model/schema.js +93 -90
  111. package/src/model/selection.d.ts +73 -73
  112. package/src/model/selection.js +62 -62
  113. package/src/model/text.d.ts +11 -10
  114. package/src/model/text.js +11 -10
  115. package/src/model/textproxy.d.ts +39 -38
  116. package/src/model/textproxy.js +31 -30
  117. package/src/model/treewalker.d.ts +37 -37
  118. package/src/model/treewalker.js +14 -14
  119. package/src/model/typecheckable.d.ts +45 -45
  120. package/src/model/typecheckable.js +1 -1
  121. package/src/model/utils/autoparagraphing.d.ts +7 -7
  122. package/src/model/utils/deletecontent.d.ts +7 -5
  123. package/src/model/utils/deletecontent.js +13 -11
  124. package/src/model/utils/getselectedcontent.d.ts +6 -5
  125. package/src/model/utils/getselectedcontent.js +2 -1
  126. package/src/model/utils/insertcontent.d.ts +9 -8
  127. package/src/model/utils/insertcontent.js +41 -40
  128. package/src/model/utils/insertobject.d.ts +9 -9
  129. package/src/model/utils/insertobject.js +4 -4
  130. package/src/model/utils/modifyselection.d.ts +5 -4
  131. package/src/model/utils/modifyselection.js +12 -11
  132. package/src/model/utils/selection-post-fixer.d.ts +12 -8
  133. package/src/model/utils/selection-post-fixer.js +15 -11
  134. package/src/model/writer.d.ts +102 -101
  135. package/src/model/writer.js +99 -98
  136. package/src/view/attributeelement.d.ts +29 -29
  137. package/src/view/attributeelement.js +25 -25
  138. package/src/view/containerelement.d.ts +16 -15
  139. package/src/view/containerelement.js +15 -14
  140. package/src/view/datatransfer.d.ts +7 -7
  141. package/src/view/datatransfer.js +1 -1
  142. package/src/view/document.d.ts +25 -25
  143. package/src/view/document.js +15 -15
  144. package/src/view/documentfragment.d.ts +21 -21
  145. package/src/view/documentfragment.js +14 -14
  146. package/src/view/documentselection.d.ts +65 -63
  147. package/src/view/documentselection.js +27 -25
  148. package/src/view/domconverter.d.ts +94 -89
  149. package/src/view/domconverter.js +78 -73
  150. package/src/view/downcastwriter.d.ts +185 -181
  151. package/src/view/downcastwriter.js +222 -210
  152. package/src/view/editableelement.d.ts +13 -13
  153. package/src/view/editableelement.js +8 -8
  154. package/src/view/element.d.ts +75 -74
  155. package/src/view/element.js +58 -58
  156. package/src/view/elementdefinition.d.ts +3 -4
  157. package/src/view/emptyelement.d.ts +13 -13
  158. package/src/view/emptyelement.js +13 -13
  159. package/src/view/filler.d.ts +14 -3
  160. package/src/view/filler.js +12 -1
  161. package/src/view/item.d.ts +4 -5
  162. package/src/view/matcher.d.ts +22 -19
  163. package/src/view/matcher.js +6 -6
  164. package/src/view/node.d.ts +33 -33
  165. package/src/view/node.js +9 -9
  166. package/src/view/observer/arrowkeysobserver.d.ts +10 -10
  167. package/src/view/observer/arrowkeysobserver.js +5 -5
  168. package/src/view/observer/bubblingemittermixin.d.ts +5 -5
  169. package/src/view/observer/bubblingemittermixin.js +2 -9
  170. package/src/view/observer/bubblingeventinfo.d.ts +9 -9
  171. package/src/view/observer/bubblingeventinfo.js +1 -1
  172. package/src/view/observer/clickobserver.d.ts +8 -8
  173. package/src/view/observer/clickobserver.js +4 -4
  174. package/src/view/observer/compositionobserver.d.ts +19 -19
  175. package/src/view/observer/compositionobserver.js +6 -6
  176. package/src/view/observer/domeventdata.d.ts +9 -9
  177. package/src/view/observer/domeventdata.js +2 -2
  178. package/src/view/observer/domeventobserver.d.ts +3 -3
  179. package/src/view/observer/domeventobserver.js +5 -5
  180. package/src/view/observer/fakeselectionobserver.d.ts +9 -9
  181. package/src/view/observer/fakeselectionobserver.js +8 -8
  182. package/src/view/observer/focusobserver.d.ts +16 -16
  183. package/src/view/observer/focusobserver.js +7 -7
  184. package/src/view/observer/inputobserver.d.ts +18 -18
  185. package/src/view/observer/inputobserver.js +5 -5
  186. package/src/view/observer/keyobserver.d.ts +11 -11
  187. package/src/view/observer/keyobserver.js +3 -3
  188. package/src/view/observer/mouseobserver.d.ts +16 -16
  189. package/src/view/observer/mouseobserver.js +3 -3
  190. package/src/view/observer/mutationobserver.d.ts +21 -21
  191. package/src/view/observer/mutationobserver.js +7 -7
  192. package/src/view/observer/observer.d.ts +12 -12
  193. package/src/view/observer/observer.js +6 -6
  194. package/src/view/observer/selectionobserver.d.ts +33 -33
  195. package/src/view/observer/selectionobserver.js +14 -14
  196. package/src/view/observer/tabobserver.d.ts +10 -10
  197. package/src/view/observer/tabobserver.js +5 -5
  198. package/src/view/observer/touchobserver.d.ts +13 -13
  199. package/src/view/observer/touchobserver.js +3 -3
  200. package/src/view/placeholder.d.ts +21 -21
  201. package/src/view/placeholder.js +23 -23
  202. package/src/view/position.d.ts +49 -49
  203. package/src/view/position.js +42 -42
  204. package/src/view/range.d.ts +76 -74
  205. package/src/view/range.js +67 -65
  206. package/src/view/rawelement.d.ts +19 -19
  207. package/src/view/rawelement.js +16 -16
  208. package/src/view/renderer.d.ts +14 -14
  209. package/src/view/renderer.js +7 -7
  210. package/src/view/rooteditableelement.d.ts +8 -7
  211. package/src/view/rooteditableelement.js +7 -6
  212. package/src/view/selection.d.ts +66 -64
  213. package/src/view/selection.js +50 -48
  214. package/src/view/styles/background.d.ts +2 -2
  215. package/src/view/styles/background.js +9 -9
  216. package/src/view/styles/border.d.ts +2 -2
  217. package/src/view/styles/border.js +13 -13
  218. package/src/view/styles/margin.d.ts +2 -2
  219. package/src/view/styles/margin.js +5 -5
  220. package/src/view/styles/padding.d.ts +2 -2
  221. package/src/view/styles/padding.js +5 -5
  222. package/src/view/styles/utils.d.ts +24 -24
  223. package/src/view/styles/utils.js +25 -25
  224. package/src/view/stylesmap.d.ts +28 -32
  225. package/src/view/stylesmap.js +52 -39
  226. package/src/view/text.d.ts +11 -11
  227. package/src/view/text.js +10 -10
  228. package/src/view/textproxy.d.ts +33 -32
  229. package/src/view/textproxy.js +23 -22
  230. package/src/view/tokenlist.d.ts +14 -14
  231. package/src/view/tokenlist.js +10 -10
  232. package/src/view/treewalker.d.ts +42 -40
  233. package/src/view/treewalker.js +36 -35
  234. package/src/view/typecheckable.d.ts +76 -75
  235. package/src/view/typecheckable.js +1 -1
  236. package/src/view/uielement.d.ts +22 -21
  237. package/src/view/uielement.js +17 -16
  238. package/src/view/upcastwriter.d.ts +70 -70
  239. package/src/view/upcastwriter.js +42 -42
  240. package/src/view/view.d.ts +70 -69
  241. package/src/view/view.js +56 -55
@@ -5,19 +5,19 @@
5
5
  /**
6
6
  * @module engine/model/element
7
7
  */
8
- import Node from './node.js';
9
- import NodeList from './nodelist.js';
10
- import Text from './text.js';
11
- import TextProxy from './textproxy.js';
8
+ import { ModelNode } from './node.js';
9
+ import { ModelNodeList } from './nodelist.js';
10
+ import { ModelText } from './text.js';
11
+ import { ModelTextProxy } from './textproxy.js';
12
12
  import { isIterable } from '@ckeditor/ckeditor5-utils';
13
13
  // @if CK_DEBUG_ENGINE // const { stringifyMap, convertMapToStringifiedObject, convertMapToTags } = require( '../dev-utils/utils' );
14
14
  /**
15
- * Model element. Type of {@link module:engine/model/node~Node node} that has a {@link module:engine/model/element~Element#name name} and
16
- * {@link module:engine/model/element~Element#getChildren child nodes}.
15
+ * Model element. Type of {@link module:engine/model/node~ModelNode node} that has a
16
+ * {@link module:engine/model/element~ModelElement#name name} and {@link module:engine/model/element~ModelElement#getChildren child nodes}.
17
17
  *
18
- * **Important**: see {@link module:engine/model/node~Node} to read about restrictions using `Element` and `Node` API.
18
+ * **Important**: see {@link module:engine/model/node~ModelNode} to read about restrictions using `Element` and `Node` API.
19
19
  */
20
- export default class Element extends Node {
20
+ export class ModelElement extends ModelNode {
21
21
  /**
22
22
  * Element name.
23
23
  */
@@ -25,12 +25,12 @@ export default class Element extends Node {
25
25
  /**
26
26
  * List of children nodes.
27
27
  */
28
- _children = new NodeList();
28
+ _children = new ModelNodeList();
29
29
  /**
30
30
  * Creates a model element.
31
31
  *
32
32
  * **Note:** Constructor of this class shouldn't be used directly in the code.
33
- * Use the {@link module:engine/model/writer~Writer#createElement} method instead.
33
+ * Use the {@link module:engine/model/writer~ModelWriter#createElement} method instead.
34
34
  *
35
35
  * @internal
36
36
  * @param name Element's name.
@@ -51,7 +51,7 @@ export default class Element extends Node {
51
51
  return this._children.length;
52
52
  }
53
53
  /**
54
- * Sum of {@link module:engine/model/node~Node#offsetSize offset sizes} of all of this element's children.
54
+ * Sum of {@link module:engine/model/node~ModelNode#offsetSize offset sizes} of all of this element's children.
55
55
  */
56
56
  get maxOffset() {
57
57
  return this._children.maxOffset;
@@ -97,7 +97,7 @@ export default class Element extends Node {
97
97
  }
98
98
  /**
99
99
  * Returns the starting offset of given child. Starting offset is equal to the sum of
100
- * {@link module:engine/model/node~Node#offsetSize offset sizes} of all node's siblings that are before it. Returns `null` if
100
+ * {@link module:engine/model/node~ModelNode#offsetSize offset sizes} of all node's siblings that are before it. Returns `null` if
101
101
  * given node is not a child of this element.
102
102
  *
103
103
  * @param node Child node to look for.
@@ -108,7 +108,7 @@ export default class Element extends Node {
108
108
  }
109
109
  /**
110
110
  * Returns index of a node that occupies given offset. If given offset is too low, returns `0`. If given offset is
111
- * too high, returns {@link module:engine/model/element~Element#getChildIndex index after last child}.
111
+ * too high, returns {@link module:engine/model/element~ModelElement#getChildIndex index after last child}.
112
112
  *
113
113
  * ```ts
114
114
  * const textNode = new Text( 'foo' );
@@ -188,12 +188,12 @@ export default class Element extends Node {
188
188
  */
189
189
  _clone(deep = false) {
190
190
  const children = deep ? cloneNodes(this._children) : undefined;
191
- return new Element(this.name, this.getAttributes(), children);
191
+ return new ModelElement(this.name, this.getAttributes(), children);
192
192
  }
193
193
  /**
194
- * {@link module:engine/model/element~Element#_insertChild Inserts} one or more nodes at the end of this element.
194
+ * {@link module:engine/model/element~ModelElement#_insertChild Inserts} one or more nodes at the end of this element.
195
195
  *
196
- * @see module:engine/model/writer~Writer#append
196
+ * @see module:engine/model/writer~ModelWriter#append
197
197
  * @internal
198
198
  * @param nodes Nodes to be inserted.
199
199
  */
@@ -201,10 +201,10 @@ export default class Element extends Node {
201
201
  this._insertChild(this.childCount, nodes);
202
202
  }
203
203
  /**
204
- * Inserts one or more nodes at the given index and sets {@link module:engine/model/node~Node#parent parent} of these nodes
204
+ * Inserts one or more nodes at the given index and sets {@link module:engine/model/node~ModelNode#parent parent} of these nodes
205
205
  * to this element.
206
206
  *
207
- * @see module:engine/model/writer~Writer#insert
207
+ * @see module:engine/model/writer~ModelWriter#insert
208
208
  * @internal
209
209
  * @param index Index at which nodes should be inserted.
210
210
  * @param items Items to be inserted.
@@ -222,9 +222,9 @@ export default class Element extends Node {
222
222
  }
223
223
  /**
224
224
  * Removes one or more nodes starting at the given index and sets
225
- * {@link module:engine/model/node~Node#parent parent} of these nodes to `null`.
225
+ * {@link module:engine/model/node~ModelNode#parent parent} of these nodes to `null`.
226
226
  *
227
- * @see module:engine/model/writer~Writer#remove
227
+ * @see module:engine/model/writer~ModelWriter#remove
228
228
  * @internal
229
229
  * @param index Index of the first node to remove.
230
230
  * @param howMany Number of nodes to remove.
@@ -239,7 +239,7 @@ export default class Element extends Node {
239
239
  }
240
240
  /**
241
241
  * Removes children nodes provided as an array and sets
242
- * the {@link module:engine/model/node~Node#parent parent} of these nodes to `null`.
242
+ * the {@link module:engine/model/node~ModelNode#parent parent} of these nodes to `null`.
243
243
  *
244
244
  * These nodes do not need to be direct siblings.
245
245
  *
@@ -268,20 +268,20 @@ export default class Element extends Node {
268
268
  for (const child of json.children) {
269
269
  if (child.name) {
270
270
  // If child has name property, it is an Element.
271
- children.push(Element.fromJSON(child));
271
+ children.push(ModelElement.fromJSON(child));
272
272
  }
273
273
  else {
274
274
  // Otherwise, it is a Text node.
275
- children.push(Text.fromJSON(child));
275
+ children.push(ModelText.fromJSON(child));
276
276
  }
277
277
  }
278
278
  }
279
- return new Element(json.name, json.attributes, children);
279
+ return new ModelElement(json.name, json.attributes, children);
280
280
  }
281
281
  }
282
282
  // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
283
283
  // Proper overload would interfere with that.
284
- Element.prototype.is = function (type, name) {
284
+ ModelElement.prototype.is = function (type, name) {
285
285
  if (!name) {
286
286
  return type === 'element' || type === 'model:element' ||
287
287
  // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
@@ -295,7 +295,7 @@ Element.prototype.is = function (type, name) {
295
295
  function normalize(nodes) {
296
296
  // Separate condition because string is iterable.
297
297
  if (typeof nodes == 'string') {
298
- return [new Text(nodes)];
298
+ return [new ModelText(nodes)];
299
299
  }
300
300
  if (!isIterable(nodes)) {
301
301
  nodes = [nodes];
@@ -303,10 +303,10 @@ function normalize(nodes) {
303
303
  const normalizedNodes = [];
304
304
  for (const node of nodes) {
305
305
  if (typeof node == 'string') {
306
- normalizedNodes.push(new Text(node));
306
+ normalizedNodes.push(new ModelText(node));
307
307
  }
308
- else if (node instanceof TextProxy) {
309
- normalizedNodes.push(new Text(node.data, node.getAttributes()));
308
+ else if (node instanceof ModelTextProxy) {
309
+ normalizedNodes.push(new ModelText(node.data, node.getAttributes()));
310
310
  }
311
311
  else {
312
312
  normalizedNodes.push(node);
@@ -2,14 +2,14 @@
2
2
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import type Operation from './operation/operation.js';
5
+ import { type Operation } from './operation/operation.js';
6
6
  /**
7
7
  * @module engine/model/history
8
8
  */
9
9
  /**
10
- * `History` keeps the track of all the operations applied to the {@link module:engine/model/document~Document document}.
10
+ * `History` keeps the track of all the operations applied to the {@link module:engine/model/document~ModelDocument document}.
11
11
  */
12
- export default class History {
12
+ export declare class History {
13
13
  /**
14
14
  * Operations added to the history.
15
15
  */
@@ -7,9 +7,9 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
7
7
  * @module engine/model/history
8
8
  */
9
9
  /**
10
- * `History` keeps the track of all the operations applied to the {@link module:engine/model/document~Document document}.
10
+ * `History` keeps the track of all the operations applied to the {@link module:engine/model/document~ModelDocument document}.
11
11
  */
12
- export default class History {
12
+ export class History {
13
13
  /**
14
14
  * Operations added to the history.
15
15
  */
@@ -2,13 +2,12 @@
2
2
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import type Node from './node.js';
6
- import type TextProxy from './textproxy.js';
5
+ import { type ModelNode } from './node.js';
6
+ import { type ModelTextProxy } from './textproxy.js';
7
7
  /**
8
8
  * @module engine/model/item
9
9
  */
10
10
  /**
11
- * Item is a {@link module:engine/model/node~Node} or {@link module:engine/model/textproxy~TextProxy}.
11
+ * Item is a {@link module:engine/model/node~ModelNode} or {@link module:engine/model/textproxy~ModelTextProxy}.
12
12
  */
13
- type Item = Node | TextProxy;
14
- export default Item;
13
+ export type ModelItem = ModelNode | ModelTextProxy;
@@ -5,73 +5,73 @@
5
5
  /**
6
6
  * @module engine/model/liveposition
7
7
  */
8
- import Position, { type PositionOffset, type PositionStickiness } from './position.js';
9
- import type DocumentFragment from './documentfragment.js';
10
- import type Item from './item.js';
11
- import type RootElement from './rootelement.js';
12
- declare const LivePosition_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof Position, import("@ckeditor/ckeditor5-utils").Emitter>;
8
+ import { ModelPosition, type ModelPositionOffset, type ModelPositionStickiness } from './position.js';
9
+ import { type ModelDocumentFragment } from './documentfragment.js';
10
+ import { type ModelItem } from './item.js';
11
+ import { type ModelRootElement } from './rootelement.js';
12
+ declare const ModelLivePosition_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof ModelPosition, import("@ckeditor/ckeditor5-utils").Emitter>;
13
13
  /**
14
- * `LivePosition` is a type of {@link module:engine/model/position~Position Position}
15
- * that updates itself as {@link module:engine/model/document~Document document}
14
+ * `ModelLivePosition` is a type of {@link module:engine/model/position~ModelPosition Position}
15
+ * that updates itself as {@link module:engine/model/document~ModelDocument document}
16
16
  * is changed through operations. It may be used as a bookmark.
17
17
  *
18
- * **Note:** Contrary to {@link module:engine/model/position~Position}, `LivePosition` works only in roots that are
19
- * {@link module:engine/model/rootelement~RootElement}.
20
- * If {@link module:engine/model/documentfragment~DocumentFragment} is passed, error will be thrown.
18
+ * **Note:** Contrary to {@link module:engine/model/position~ModelPosition}, `ModelLivePosition` works only in roots that are
19
+ * {@link module:engine/model/rootelement~ModelRootElement}.
20
+ * If {@link module:engine/model/documentfragment~ModelDocumentFragment} is passed, error will be thrown.
21
21
  *
22
- * **Note:** Be very careful when dealing with `LivePosition`. Each `LivePosition` instance bind events that might
22
+ * **Note:** Be very careful when dealing with `ModelLivePosition`. Each `ModelLivePosition` instance bind events that might
23
23
  * have to be unbound.
24
- * Use {@link module:engine/model/liveposition~LivePosition#detach} whenever you don't need `LivePosition` anymore.
24
+ * Use {@link module:engine/model/liveposition~ModelLivePosition#detach} whenever you don't need `ModelLivePosition` anymore.
25
25
  */
26
- export default class LivePosition extends /* #__PURE__ */ LivePosition_base {
26
+ export declare class ModelLivePosition extends /* #__PURE__ */ ModelLivePosition_base {
27
27
  /**
28
28
  * Root of the position path.
29
29
  */
30
- readonly root: RootElement;
30
+ readonly root: ModelRootElement;
31
31
  /**
32
32
  * Creates a live position.
33
33
  *
34
- * @see module:engine/model/position~Position
34
+ * @see module:engine/model/position~ModelPosition
35
35
  */
36
- constructor(root: RootElement, path: Array<number>, stickiness?: PositionStickiness);
36
+ constructor(root: ModelRootElement, path: Array<number>, stickiness?: ModelPositionStickiness);
37
37
  /**
38
- * Unbinds all events previously bound by `LivePosition`. Use it whenever you don't need `LivePosition` instance
38
+ * Unbinds all events previously bound by `ModelLivePosition`. Use it whenever you don't need `ModelLivePosition` instance
39
39
  * anymore (i.e. when leaving scope in which it was declared or before re-assigning variable that was
40
40
  * referring to it).
41
41
  */
42
42
  detach(): void;
43
43
  /**
44
- * Creates a {@link module:engine/model/position~Position position instance}, which is equal to this live position.
44
+ * Creates a {@link module:engine/model/position~ModelPosition position instance}, which is equal to this live position.
45
45
  */
46
- toPosition(): Position;
46
+ toPosition(): ModelPosition;
47
47
  /**
48
- * Creates a `LivePosition` instance that is equal to position.
48
+ * Creates a `ModelLivePosition` instance that is equal to position.
49
49
  */
50
- static fromPosition(position: Position, stickiness?: PositionStickiness): LivePosition;
50
+ static fromPosition(position: ModelPosition, stickiness?: ModelPositionStickiness): ModelLivePosition;
51
51
  /**
52
52
  * @internal
53
- * @see module:engine/model/position~Position._createAfter
53
+ * @see module:engine/model/position~ModelPosition._createAfter
54
54
  */
55
- static readonly _createAfter: (item: Item | DocumentFragment, stickiness?: PositionStickiness) => LivePosition;
55
+ static readonly _createAfter: (item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness) => ModelLivePosition;
56
56
  /**
57
57
  * @internal
58
- * @see module:engine/model/position~Position._createBefore
58
+ * @see module:engine/model/position~ModelPosition._createBefore
59
59
  */
60
- static readonly _createBefore: (item: Item | DocumentFragment, stickiness?: PositionStickiness) => LivePosition;
60
+ static readonly _createBefore: (item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness) => ModelLivePosition;
61
61
  /**
62
62
  * @internal
63
- * @see module:engine/model/position~Position._createAt
63
+ * @see module:engine/model/position~ModelPosition._createAt
64
64
  */
65
- static readonly _createAt: (itemOrPosition: Item | Position | DocumentFragment, offset?: PositionOffset, stickiness?: PositionStickiness) => LivePosition;
65
+ static readonly _createAt: (itemOrPosition: ModelItem | ModelPosition | ModelDocumentFragment, offset?: ModelPositionOffset, stickiness?: ModelPositionStickiness) => ModelLivePosition;
66
66
  }
67
67
  /**
68
- * Fired when `LivePosition` instance is changed due to changes on {@link module:engine/model/document~Document}.
68
+ * Fired when `ModelLivePosition` instance is changed due to changes on {@link module:engine/model/document~ModelDocument}.
69
69
  *
70
- * @eventName ~LivePosition#change
70
+ * @eventName ~ModelLivePosition#change
71
71
  * @param oldPosition Position equal to this live position before it got changed.
72
72
  */
73
- export type LivePositionChangeEvent = {
73
+ export type ModelLivePositionChangeEvent = {
74
74
  name: 'change';
75
- args: [oldPosition: Position];
75
+ args: [oldPosition: ModelPosition];
76
76
  };
77
77
  export {};
@@ -5,32 +5,32 @@
5
5
  /**
6
6
  * @module engine/model/liveposition
7
7
  */
8
- import Position from './position.js';
8
+ import { ModelPosition } from './position.js';
9
9
  import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
10
10
  /**
11
- * `LivePosition` is a type of {@link module:engine/model/position~Position Position}
12
- * that updates itself as {@link module:engine/model/document~Document document}
11
+ * `ModelLivePosition` is a type of {@link module:engine/model/position~ModelPosition Position}
12
+ * that updates itself as {@link module:engine/model/document~ModelDocument document}
13
13
  * is changed through operations. It may be used as a bookmark.
14
14
  *
15
- * **Note:** Contrary to {@link module:engine/model/position~Position}, `LivePosition` works only in roots that are
16
- * {@link module:engine/model/rootelement~RootElement}.
17
- * If {@link module:engine/model/documentfragment~DocumentFragment} is passed, error will be thrown.
15
+ * **Note:** Contrary to {@link module:engine/model/position~ModelPosition}, `ModelLivePosition` works only in roots that are
16
+ * {@link module:engine/model/rootelement~ModelRootElement}.
17
+ * If {@link module:engine/model/documentfragment~ModelDocumentFragment} is passed, error will be thrown.
18
18
  *
19
- * **Note:** Be very careful when dealing with `LivePosition`. Each `LivePosition` instance bind events that might
19
+ * **Note:** Be very careful when dealing with `ModelLivePosition`. Each `ModelLivePosition` instance bind events that might
20
20
  * have to be unbound.
21
- * Use {@link module:engine/model/liveposition~LivePosition#detach} whenever you don't need `LivePosition` anymore.
21
+ * Use {@link module:engine/model/liveposition~ModelLivePosition#detach} whenever you don't need `ModelLivePosition` anymore.
22
22
  */
23
- export default class LivePosition extends /* #__PURE__ */ EmitterMixin(Position) {
23
+ export class ModelLivePosition extends /* #__PURE__ */ EmitterMixin(ModelPosition) {
24
24
  /**
25
25
  * Creates a live position.
26
26
  *
27
- * @see module:engine/model/position~Position
27
+ * @see module:engine/model/position~ModelPosition
28
28
  */
29
29
  constructor(root, path, stickiness = 'toNone') {
30
30
  super(root, path, stickiness);
31
31
  if (!this.root.is('rootElement')) {
32
32
  /**
33
- * LivePosition's root has to be an instance of RootElement.
33
+ * LivePosition's root has to be an instance of ModelRootElement.
34
34
  *
35
35
  * @error model-liveposition-root-not-rootelement
36
36
  */
@@ -39,7 +39,7 @@ export default class LivePosition extends /* #__PURE__ */ EmitterMixin(Position)
39
39
  bindWithDocument.call(this);
40
40
  }
41
41
  /**
42
- * Unbinds all events previously bound by `LivePosition`. Use it whenever you don't need `LivePosition` instance
42
+ * Unbinds all events previously bound by `ModelLivePosition`. Use it whenever you don't need `ModelLivePosition` instance
43
43
  * anymore (i.e. when leaving scope in which it was declared or before re-assigning variable that was
44
44
  * referring to it).
45
45
  */
@@ -47,13 +47,13 @@ export default class LivePosition extends /* #__PURE__ */ EmitterMixin(Position)
47
47
  this.stopListening();
48
48
  }
49
49
  /**
50
- * Creates a {@link module:engine/model/position~Position position instance}, which is equal to this live position.
50
+ * Creates a {@link module:engine/model/position~ModelPosition position instance}, which is equal to this live position.
51
51
  */
52
52
  toPosition() {
53
- return new Position(this.root, this.path.slice(), this.stickiness);
53
+ return new ModelPosition(this.root, this.path.slice(), this.stickiness);
54
54
  }
55
55
  /**
56
- * Creates a `LivePosition` instance that is equal to position.
56
+ * Creates a `ModelLivePosition` instance that is equal to position.
57
57
  */
58
58
  static fromPosition(position, stickiness) {
59
59
  return new this(position.root, position.path.slice(), stickiness ? stickiness : position.stickiness);
@@ -61,14 +61,14 @@ export default class LivePosition extends /* #__PURE__ */ EmitterMixin(Position)
61
61
  }
62
62
  // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
63
63
  // Proper overload would interfere with that.
64
- LivePosition.prototype.is = function (type) {
64
+ ModelLivePosition.prototype.is = function (type) {
65
65
  return type === 'livePosition' || type === 'model:livePosition' ||
66
66
  // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
67
67
  type == 'position' || type === 'model:position';
68
68
  };
69
69
  /**
70
- * Binds this `LivePosition` to the {@link module:engine/model/document~Document document} that owns
71
- * this position's {@link module:engine/model/position~Position#root root}.
70
+ * Binds this `ModelLivePosition` to the {@link module:engine/model/document~ModelDocument document} that owns
71
+ * this position's {@link module:engine/model/position~ModelPosition#root root}.
72
72
  */
73
73
  function bindWithDocument() {
74
74
  this.listenTo(this.root.document.model, 'applyOperation', (event, args) => {
@@ -5,98 +5,102 @@
5
5
  /**
6
6
  * @module engine/model/liverange
7
7
  */
8
- import Range from './range.js';
9
- import type DocumentFragment from './documentfragment.js';
10
- import type Element from './element.js';
11
- import type Item from './item.js';
12
- import type Position from './position.js';
13
- declare const LiveRange_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof Range, import("@ckeditor/ckeditor5-utils").Emitter>;
8
+ import { ModelRange } from './range.js';
9
+ import { type ModelDocumentFragment } from './documentfragment.js';
10
+ import { type ModelElement } from './element.js';
11
+ import { type ModelItem } from './item.js';
12
+ import { type ModelPosition } from './position.js';
13
+ declare const ModelLiveRange_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof ModelRange, import("@ckeditor/ckeditor5-utils").Emitter>;
14
14
  /**
15
- * `LiveRange` is a type of {@link module:engine/model/range~Range Range}
16
- * that updates itself as {@link module:engine/model/document~Document document}
15
+ * `ModelLiveRange` is a type of {@link module:engine/model/range~ModelRange Range}
16
+ * that updates itself as {@link module:engine/model/document~ModelDocument document}
17
17
  * is changed through operations. It may be used as a bookmark.
18
18
  *
19
- * **Note:** Be very careful when dealing with `LiveRange`. Each `LiveRange` instance bind events that might
20
- * have to be unbound. Use {@link module:engine/model/liverange~LiveRange#detach detach} whenever you don't need `LiveRange` anymore.
19
+ * **Note:** Be very careful when dealing with `ModelLiveRange`. Each `ModelLiveRange` instance bind events that might
20
+ * have to be unbound. Use {@link module:engine/model/liverange~ModelLiveRange#detach detach} whenever you don't need
21
+ * `ModelLiveRange` anymore.
21
22
  */
22
- export default class LiveRange extends /* #__PURE__ */ LiveRange_base {
23
+ export declare class ModelLiveRange extends /* #__PURE__ */ ModelLiveRange_base {
23
24
  /**
24
25
  * Creates a live range.
25
26
  *
26
- * @see module:engine/model/range~Range
27
+ * @see module:engine/model/range~ModelRange
27
28
  */
28
- constructor(start: Position, end?: Position | null);
29
+ constructor(start: ModelPosition, end?: ModelPosition | null);
29
30
  /**
30
- * Unbinds all events previously bound by `LiveRange`. Use it whenever you don't need `LiveRange` instance
31
+ * Unbinds all events previously bound by `ModelLiveRange`. Use it whenever you don't need `ModelLiveRange` instance
31
32
  * anymore (i.e. when leaving scope in which it was declared or before re-assigning variable that was
32
33
  * referring to it).
33
34
  */
34
35
  detach(): void;
35
36
  /**
36
- * Creates a {@link module:engine/model/range~Range range instance} that is equal to this live range.
37
+ * Creates a {@link module:engine/model/range~ModelRange range instance} that is equal to this live range.
37
38
  */
38
- toRange(): Range;
39
+ toRange(): ModelRange;
39
40
  /**
40
- * Creates a `LiveRange` instance that is equal to the given range.
41
+ * Creates a `ModelLiveRange` instance that is equal to the given range.
41
42
  */
42
- static fromRange(range: Range): LiveRange;
43
+ static fromRange(range: ModelRange): ModelLiveRange;
43
44
  /**
44
- * @see module:engine/model/range~Range._createIn
45
+ * @see module:engine/model/range~ModelRange._createIn
45
46
  * @internal
46
47
  */
47
- static readonly _createIn: (element: Element | DocumentFragment) => LiveRange;
48
+ static readonly _createIn: (element: ModelElement | ModelDocumentFragment) => ModelLiveRange;
48
49
  /**
49
- * @see module:engine/model/range~Range._createOn
50
+ * @see module:engine/model/range~ModelRange._createOn
50
51
  * @internal
51
52
  */
52
- static readonly _createOn: (element: Item | DocumentFragment) => LiveRange;
53
+ static readonly _createOn: (element: ModelItem | ModelDocumentFragment) => ModelLiveRange;
53
54
  /**
54
- * @see module:engine/model/range~Range._createFromPositionAndShift
55
+ * @see module:engine/model/range~ModelRange._createFromPositionAndShift
55
56
  * @internal
56
57
  */
57
- static readonly _createFromPositionAndShift: (position: Position, shift: number) => LiveRange;
58
+ static readonly _createFromPositionAndShift: (position: ModelPosition, shift: number) => ModelLiveRange;
58
59
  }
59
60
  /**
60
- * Fired when `LiveRange` instance boundaries have changed due to changes in the
61
- * {@link module:engine/model/document~Document document}.
61
+ * Fired when `ModelLiveRange` instance boundaries have changed due to changes in the
62
+ * {@link module:engine/model/document~ModelDocument document}.
62
63
  *
63
- * @eventName ~LiveRange#change:range
64
+ * @eventName ~ModelLiveRange#change:range
64
65
  * @param oldRange Range with start and end position equal to start and end position of this live
65
66
  * range before it got changed.
66
67
  * @param data Object with additional information about the change.
67
68
  * @param data.deletionPosition Source position for remove and merge changes.
68
69
  * Available if the range was moved to the graveyard root, `null` otherwise.
69
70
  */
70
- export type LiveRangeChangeRangeEvent = {
71
+ export type ModelLiveRangeChangeRangeEvent = {
71
72
  name: 'change' | 'change:range';
72
- args: [range: Range, data: {
73
- deletionPosition: Position | null;
73
+ args: [range: ModelRange, data: {
74
+ deletionPosition: ModelPosition | null;
74
75
  }];
75
76
  };
76
77
  /**
77
- * Fired when `LiveRange` instance boundaries have not changed after a change in {@link module:engine/model/document~Document document}
78
+ * Fired when `ModelLiveRange` instance boundaries have not changed after
79
+ * a change in {@link module:engine/model/document~ModelDocument document}
78
80
  * but the change took place inside the range, effectively changing its content.
79
81
  *
80
- * @eventName ~LiveRange#change:content
82
+ * @eventName ~ModelLiveRange#change:content
81
83
  * @param range Range with start and end position equal to start and end position of
82
84
  * change range.
83
85
  * @param data Object with additional information about the change.
84
86
  * @param data.deletionPosition Due to the nature of this event, this property is always set to `null`. It is passed
85
- * for compatibility with the {@link module:engine/model/liverange~LiveRange#event:change:range} event.
87
+ * for compatibility with the {@link module:engine/model/liverange~ModelLiveRange#event:change:range} event.
86
88
  */
87
- export type LiveRangeChangeContentEvent = {
89
+ export type ModelLiveRangeChangeContentEvent = {
88
90
  name: 'change' | 'change:content';
89
- args: [range: Range, data: {
91
+ args: [range: ModelRange, data: {
90
92
  deletionPosition: null;
91
93
  }];
92
94
  };
93
95
  /**
94
96
  * Describes `change:range` or `change:content` event.
97
+ *
98
+ * @eventName ~ModelLiveRange#change
95
99
  */
96
- export type LiveRangeChangeEvent = {
100
+ export type ModelLiveRangeChangeEvent = {
97
101
  name: 'change' | 'change:range' | 'change:content';
98
- args: [range: Range, data: {
99
- deletionPosition: Position | null;
102
+ args: [range: ModelRange, data: {
103
+ deletionPosition: ModelPosition | null;
100
104
  }];
101
105
  };
102
106
  export {};
@@ -5,28 +5,29 @@
5
5
  /**
6
6
  * @module engine/model/liverange
7
7
  */
8
- import Range from './range.js';
8
+ import { ModelRange } from './range.js';
9
9
  import { EmitterMixin } from '@ckeditor/ckeditor5-utils';
10
10
  /**
11
- * `LiveRange` is a type of {@link module:engine/model/range~Range Range}
12
- * that updates itself as {@link module:engine/model/document~Document document}
11
+ * `ModelLiveRange` is a type of {@link module:engine/model/range~ModelRange Range}
12
+ * that updates itself as {@link module:engine/model/document~ModelDocument document}
13
13
  * is changed through operations. It may be used as a bookmark.
14
14
  *
15
- * **Note:** Be very careful when dealing with `LiveRange`. Each `LiveRange` instance bind events that might
16
- * have to be unbound. Use {@link module:engine/model/liverange~LiveRange#detach detach} whenever you don't need `LiveRange` anymore.
15
+ * **Note:** Be very careful when dealing with `ModelLiveRange`. Each `ModelLiveRange` instance bind events that might
16
+ * have to be unbound. Use {@link module:engine/model/liverange~ModelLiveRange#detach detach} whenever you don't need
17
+ * `ModelLiveRange` anymore.
17
18
  */
18
- export default class LiveRange extends /* #__PURE__ */ EmitterMixin(Range) {
19
+ export class ModelLiveRange extends /* #__PURE__ */ EmitterMixin(ModelRange) {
19
20
  /**
20
21
  * Creates a live range.
21
22
  *
22
- * @see module:engine/model/range~Range
23
+ * @see module:engine/model/range~ModelRange
23
24
  */
24
25
  constructor(start, end) {
25
26
  super(start, end);
26
27
  bindWithDocument.call(this);
27
28
  }
28
29
  /**
29
- * Unbinds all events previously bound by `LiveRange`. Use it whenever you don't need `LiveRange` instance
30
+ * Unbinds all events previously bound by `ModelLiveRange`. Use it whenever you don't need `ModelLiveRange` instance
30
31
  * anymore (i.e. when leaving scope in which it was declared or before re-assigning variable that was
31
32
  * referring to it).
32
33
  */
@@ -34,28 +35,28 @@ export default class LiveRange extends /* #__PURE__ */ EmitterMixin(Range) {
34
35
  this.stopListening();
35
36
  }
36
37
  /**
37
- * Creates a {@link module:engine/model/range~Range range instance} that is equal to this live range.
38
+ * Creates a {@link module:engine/model/range~ModelRange range instance} that is equal to this live range.
38
39
  */
39
40
  toRange() {
40
- return new Range(this.start, this.end);
41
+ return new ModelRange(this.start, this.end);
41
42
  }
42
43
  /**
43
- * Creates a `LiveRange` instance that is equal to the given range.
44
+ * Creates a `ModelLiveRange` instance that is equal to the given range.
44
45
  */
45
46
  static fromRange(range) {
46
- return new LiveRange(range.start, range.end);
47
+ return new ModelLiveRange(range.start, range.end);
47
48
  }
48
49
  }
49
50
  // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
50
51
  // Proper overload would interfere with that.
51
- LiveRange.prototype.is = function (type) {
52
+ ModelLiveRange.prototype.is = function (type) {
52
53
  return type === 'liveRange' || type === 'model:liveRange' ||
53
54
  // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
54
55
  type == 'range' || type === 'model:range';
55
56
  };
56
57
  /**
57
- * Binds this `LiveRange` to the {@link module:engine/model/document~Document document}
58
- * that owns this range's {@link module:engine/model/range~Range#root root}.
58
+ * Binds this `ModelLiveRange` to the {@link module:engine/model/document~ModelDocument document}
59
+ * that owns this range's {@link module:engine/model/range~ModelRange#root root}.
59
60
  */
60
61
  function bindWithDocument() {
61
62
  this.listenTo(this.root.document.model, 'applyOperation', (event, args) => {
@@ -72,7 +73,7 @@ function bindWithDocument() {
72
73
  function transform(operation) {
73
74
  // Transform the range by the operation. Join the result ranges if needed.
74
75
  const ranges = this.getTransformedByOperation(operation);
75
- const result = Range._createFromRanges(ranges);
76
+ const result = ModelRange._createFromRanges(ranges);
76
77
  const boundariesChanged = !result.isEqual(this);
77
78
  const contentChanged = doesOperationChangeRangeContent(this, operation);
78
79
  let deletionPosition = null;