@ckeditor/ckeditor5-engine 45.2.1-alpha.9 → 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,20 +5,20 @@
5
5
  /**
6
6
  * @module engine/model/range
7
7
  */
8
- import TypeCheckable from './typecheckable.js';
9
- import Position from './position.js';
10
- import TreeWalker from './treewalker.js';
8
+ import { ModelTypeCheckable } from './typecheckable.js';
9
+ import { ModelPosition } from './position.js';
10
+ import { ModelTreeWalker } from './treewalker.js';
11
11
  import { CKEditorError, compareArrays } from '@ckeditor/ckeditor5-utils';
12
12
  /**
13
13
  * Represents a range in the model tree.
14
14
  *
15
- * A range is defined by its {@link module:engine/model/range~Range#start} and {@link module:engine/model/range~Range#end}
15
+ * A range is defined by its {@link module:engine/model/range~ModelRange#start} and {@link module:engine/model/range~ModelRange#end}
16
16
  * positions.
17
17
  *
18
18
  * You can create range instances via its constructor or the `createRange*()` factory methods of
19
- * {@link module:engine/model/model~Model} and {@link module:engine/model/writer~Writer}.
19
+ * {@link module:engine/model/model~Model} and {@link module:engine/model/writer~ModelWriter}.
20
20
  */
21
- export default class Range extends TypeCheckable {
21
+ export class ModelRange extends ModelTypeCheckable {
22
22
  /**
23
23
  * Start position.
24
24
  */
@@ -35,8 +35,8 @@ export default class Range extends TypeCheckable {
35
35
  */
36
36
  constructor(start, end) {
37
37
  super();
38
- this.start = Position._createAt(start);
39
- this.end = end ? Position._createAt(end) : Position._createAt(start);
38
+ this.start = ModelPosition._createAt(start);
39
+ this.end = end ? ModelPosition._createAt(end) : ModelPosition._createAt(start);
40
40
  // If the range is collapsed, treat in a similar way as a position and set its boundaries stickiness to 'toNone'.
41
41
  // In other case, make the boundaries stick to the "inside" of the range.
42
42
  this.start.stickiness = this.isCollapsed ? 'toNone' : 'toNext';
@@ -45,17 +45,17 @@ export default class Range extends TypeCheckable {
45
45
  /**
46
46
  * Iterable interface.
47
47
  *
48
- * Iterates over all {@link module:engine/model/item~Item items} that are in this range and returns
49
- * them together with additional information like length or {@link module:engine/model/position~Position positions},
50
- * grouped as {@link module:engine/model/treewalker~TreeWalkerValue}.
51
- * It iterates over all {@link module:engine/model/textproxy~TextProxy text contents} that are inside the range
52
- * and all the {@link module:engine/model/element~Element}s that are entered into when iterating over this range.
48
+ * Iterates over all {@link module:engine/model/item~ModelItem items} that are in this range and returns
49
+ * them together with additional information like length or {@link module:engine/model/position~ModelPosition positions},
50
+ * grouped as {@link module:engine/model/treewalker~ModelTreeWalkerValue}.
51
+ * It iterates over all {@link module:engine/model/textproxy~ModelTextProxy text contents} that are inside the range
52
+ * and all the {@link module:engine/model/element~ModelElement}s that are entered into when iterating over this range.
53
53
  *
54
- * This iterator uses {@link module:engine/model/treewalker~TreeWalker} with `boundaries` set to this range
54
+ * This iterator uses {@link module:engine/model/treewalker~ModelTreeWalker} with `boundaries` set to this range
55
55
  * and `ignoreElementEnd` option set to `true`.
56
56
  */
57
57
  *[Symbol.iterator]() {
58
- yield* new TreeWalker({ boundaries: this, ignoreElementEnd: true });
58
+ yield* new ModelTreeWalker({ boundaries: this, ignoreElementEnd: true });
59
59
  }
60
60
  /**
61
61
  * Describes whether the range is collapsed, that is if {@link #start} and
@@ -66,7 +66,7 @@ export default class Range extends TypeCheckable {
66
66
  }
67
67
  /**
68
68
  * Describes whether this range is flat, that is if {@link #start} position and
69
- * {@link #end} position are in the same {@link module:engine/model/position~Position#parent}.
69
+ * {@link #end} position are in the same {@link module:engine/model/position~ModelPosition#parent}.
70
70
  */
71
71
  get isFlat() {
72
72
  const startParentPath = this.start.getParentPath();
@@ -80,23 +80,23 @@ export default class Range extends TypeCheckable {
80
80
  return this.start.root;
81
81
  }
82
82
  /**
83
- * Checks whether this range contains given {@link module:engine/model/position~Position position}.
83
+ * Checks whether this range contains given {@link module:engine/model/position~ModelPosition position}.
84
84
  *
85
85
  * @param position Position to check.
86
- * @returns `true` if given {@link module:engine/model/position~Position position} is contained
86
+ * @returns `true` if given {@link module:engine/model/position~ModelPosition position} is contained
87
87
  * in this range,`false` otherwise.
88
88
  */
89
89
  containsPosition(position) {
90
90
  return position.isAfter(this.start) && position.isBefore(this.end);
91
91
  }
92
92
  /**
93
- * Checks whether this range contains given {@link ~Range range}.
93
+ * Checks whether this range contains given {@link ~ModelRange range}.
94
94
  *
95
95
  * @param otherRange Range to check.
96
96
  * @param loose Whether the check is loose or strict. If the check is strict (`false`), compared range cannot
97
97
  * start or end at the same position as this range boundaries. If the check is loose (`true`), compared range can start, end or
98
98
  * even be equal to this range. Note that collapsed ranges are always compared in strict mode.
99
- * @returns {Boolean} `true` if given {@link ~Range range} boundaries are contained by this range, `false` otherwise.
99
+ * @returns {Boolean} `true` if given {@link ~ModelRange range} boundaries are contained by this range, `false` otherwise.
100
100
  */
101
101
  containsRange(otherRange, loose = false) {
102
102
  if (otherRange.isCollapsed) {
@@ -107,10 +107,10 @@ export default class Range extends TypeCheckable {
107
107
  return containsStart && containsEnd;
108
108
  }
109
109
  /**
110
- * Checks whether given {@link module:engine/model/item~Item} is inside this range.
110
+ * Checks whether given {@link module:engine/model/item~ModelItem} is inside this range.
111
111
  */
112
112
  containsItem(item) {
113
- const pos = Position._createBefore(item);
113
+ const pos = ModelPosition._createBefore(item);
114
114
  return this.containsPosition(pos) || this.start.isEqual(pos);
115
115
  }
116
116
  /**
@@ -132,8 +132,8 @@ export default class Range extends TypeCheckable {
132
132
  return this.start.isBefore(otherRange.end) && this.end.isAfter(otherRange.start);
133
133
  }
134
134
  /**
135
- * Computes which part(s) of this {@link ~Range range} is not a part of given {@link ~Range range}.
136
- * Returned array contains zero, one or two {@link ~Range ranges}.
135
+ * Computes which part(s) of this {@link ~ModelRange range} is not a part of given {@link ~ModelRange range}.
136
+ * Returned array contains zero, one or two {@link ~ModelRange ranges}.
137
137
  *
138
138
  * Examples:
139
139
  *
@@ -165,22 +165,22 @@ export default class Range extends TypeCheckable {
165
165
  if (this.containsPosition(otherRange.start)) {
166
166
  // Given range start is inside this range. This means that we have to
167
167
  // add shrunken range - from the start to the middle of this range.
168
- ranges.push(new Range(this.start, otherRange.start));
168
+ ranges.push(new ModelRange(this.start, otherRange.start));
169
169
  }
170
170
  if (this.containsPosition(otherRange.end)) {
171
171
  // Given range end is inside this range. This means that we have to
172
172
  // add shrunken range - from the middle of this range to the end.
173
- ranges.push(new Range(otherRange.end, this.end));
173
+ ranges.push(new ModelRange(otherRange.end, this.end));
174
174
  }
175
175
  }
176
176
  else {
177
177
  // Ranges do not intersect, return the original range.
178
- ranges.push(new Range(this.start, this.end));
178
+ ranges.push(new ModelRange(this.start, this.end));
179
179
  }
180
180
  return ranges;
181
181
  }
182
182
  /**
183
- * Returns an intersection of this {@link ~Range range} and given {@link ~Range range}.
183
+ * Returns an intersection of this {@link ~ModelRange range} and given {@link ~ModelRange range}.
184
184
  * Intersection is a common part of both of those ranges. If ranges has no common part, returns `null`.
185
185
  *
186
186
  * Examples:
@@ -216,13 +216,13 @@ export default class Range extends TypeCheckable {
216
216
  // shrink common range to the given range end.
217
217
  commonRangeEnd = otherRange.end;
218
218
  }
219
- return new Range(commonRangeStart, commonRangeEnd);
219
+ return new ModelRange(commonRangeStart, commonRangeEnd);
220
220
  }
221
221
  // Ranges do not intersect, so they do not have common part.
222
222
  return null;
223
223
  }
224
224
  /**
225
- * Returns a range created by joining this {@link ~Range range} with the given {@link ~Range range}.
225
+ * Returns a range created by joining this {@link ~ModelRange range} with the given {@link ~ModelRange range}.
226
226
  * If ranges have no common part, returns `null`.
227
227
  *
228
228
  * Examples:
@@ -248,7 +248,7 @@ export default class Range extends TypeCheckable {
248
248
  * @param otherRange Range to be joined.
249
249
  * @param loose Whether the intersection check is loose or strict. If the check is strict (`false`),
250
250
  * ranges are tested for intersection or whether start/end positions are equal. If the check is loose (`true`),
251
- * compared range is also checked if it's {@link module:engine/model/position~Position#isTouching touching} current range.
251
+ * compared range is also checked if it's {@link module:engine/model/position~ModelPosition#isTouching touching} current range.
252
252
  * @returns A sum of given ranges or `null` if ranges have no common part.
253
253
  */
254
254
  getJoined(otherRange, loose = false) {
@@ -272,7 +272,7 @@ export default class Range extends TypeCheckable {
272
272
  if (otherRange.end.isAfter(endPosition)) {
273
273
  endPosition = otherRange.end;
274
274
  }
275
- return new Range(startPosition, endPosition);
275
+ return new ModelRange(startPosition, endPosition);
276
276
  }
277
277
  /**
278
278
  * Computes and returns the smallest set of {@link #isFlat flat} ranges, that covers this range in whole.
@@ -309,7 +309,7 @@ export default class Range extends TypeCheckable {
309
309
  * ( [ 3, 0, 0 ], [ 3, 0, 2 ] ) = "se"
310
310
  * ```
311
311
  *
312
- * **Note:** if an {@link module:engine/model/element~Element element} is not wholly contained in this range, it won't be returned
312
+ * **Note:** if an {@link module:engine/model/element~ModelElement element} is not wholly contained in this range, it won't be returned
313
313
  * in any of the returned flat ranges. See in the example how `H` elements at the beginning and at the end of the range
314
314
  * were omitted. Only their parts that were wholly in the range were returned.
315
315
  *
@@ -320,13 +320,13 @@ export default class Range extends TypeCheckable {
320
320
  getMinimalFlatRanges() {
321
321
  const ranges = [];
322
322
  const diffAt = this.start.getCommonPath(this.end).length;
323
- const pos = Position._createAt(this.start);
323
+ const pos = ModelPosition._createAt(this.start);
324
324
  let posParent = pos.parent;
325
325
  // Go up.
326
326
  while (pos.path.length > diffAt + 1) {
327
327
  const howMany = posParent.maxOffset - pos.offset;
328
328
  if (howMany !== 0) {
329
- ranges.push(new Range(pos, pos.getShiftedBy(howMany)));
329
+ ranges.push(new ModelRange(pos, pos.getShiftedBy(howMany)));
330
330
  }
331
331
  pos.path = pos.path.slice(0, -1);
332
332
  pos.offset++;
@@ -337,7 +337,7 @@ export default class Range extends TypeCheckable {
337
337
  const offset = this.end.path[pos.path.length - 1];
338
338
  const howMany = offset - pos.offset;
339
339
  if (howMany !== 0) {
340
- ranges.push(new Range(pos, pos.getShiftedBy(howMany)));
340
+ ranges.push(new ModelRange(pos, pos.getShiftedBy(howMany)));
341
341
  }
342
342
  pos.offset = offset;
343
343
  pos.path.push(0);
@@ -345,7 +345,7 @@ export default class Range extends TypeCheckable {
345
345
  return ranges;
346
346
  }
347
347
  /**
348
- * Creates a {@link module:engine/model/treewalker~TreeWalker TreeWalker} instance with this range as a boundary.
348
+ * Creates a {@link module:engine/model/treewalker~ModelTreeWalker TreeWalker} instance with this range as a boundary.
349
349
  *
350
350
  * For example, to iterate over all items in the entire document root:
351
351
  *
@@ -359,48 +359,48 @@ export default class Range extends TypeCheckable {
359
359
  * }
360
360
  * ```
361
361
  *
362
- * @param options Object with configuration options. See {@link module:engine/model/treewalker~TreeWalker}.
362
+ * @param options Object with configuration options. See {@link module:engine/model/treewalker~ModelTreeWalker}.
363
363
  */
364
364
  getWalker(options = {}) {
365
365
  options.boundaries = this;
366
- return new TreeWalker(options);
366
+ return new ModelTreeWalker(options);
367
367
  }
368
368
  /**
369
- * Returns an iterator that iterates over all {@link module:engine/model/item~Item items} that are in this range and returns
369
+ * Returns an iterator that iterates over all {@link module:engine/model/item~ModelItem items} that are in this range and returns
370
370
  * them.
371
371
  *
372
- * This method uses {@link module:engine/model/treewalker~TreeWalker} with `boundaries` set to this range and `ignoreElementEnd` option
373
- * set to `true`. However it returns only {@link module:engine/model/item~Item model items},
374
- * not {@link module:engine/model/treewalker~TreeWalkerValue}.
372
+ * This method uses {@link module:engine/model/treewalker~ModelTreeWalker} with `boundaries` set to this range and
373
+ * `ignoreElementEnd` option set to `true`. However it returns only {@link module:engine/model/item~ModelItem model items},
374
+ * not {@link module:engine/model/treewalker~ModelTreeWalkerValue}.
375
375
  *
376
- * You may specify additional options for the tree walker. See {@link module:engine/model/treewalker~TreeWalker} for
376
+ * You may specify additional options for the tree walker. See {@link module:engine/model/treewalker~ModelTreeWalker} for
377
377
  * a full list of available options.
378
378
  *
379
- * @param options Object with configuration options. See {@link module:engine/model/treewalker~TreeWalker}.
379
+ * @param options Object with configuration options. See {@link module:engine/model/treewalker~ModelTreeWalker}.
380
380
  */
381
381
  *getItems(options = {}) {
382
382
  options.boundaries = this;
383
383
  options.ignoreElementEnd = true;
384
- const treeWalker = new TreeWalker(options);
384
+ const treeWalker = new ModelTreeWalker(options);
385
385
  for (const value of treeWalker) {
386
386
  yield value.item;
387
387
  }
388
388
  }
389
389
  /**
390
- * Returns an iterator that iterates over all {@link module:engine/model/position~Position positions} that are boundaries or
390
+ * Returns an iterator that iterates over all {@link module:engine/model/position~ModelPosition positions} that are boundaries or
391
391
  * contained in this range.
392
392
  *
393
- * This method uses {@link module:engine/model/treewalker~TreeWalker} with `boundaries` set to this range. However it returns only
394
- * {@link module:engine/model/position~Position positions}, not {@link module:engine/model/treewalker~TreeWalkerValue}.
393
+ * This method uses {@link module:engine/model/treewalker~ModelTreeWalker} with `boundaries` set to this range. However it returns only
394
+ * {@link module:engine/model/position~ModelPosition positions}, not {@link module:engine/model/treewalker~ModelTreeWalkerValue}.
395
395
  *
396
- * You may specify additional options for the tree walker. See {@link module:engine/model/treewalker~TreeWalker} for
396
+ * You may specify additional options for the tree walker. See {@link module:engine/model/treewalker~ModelTreeWalker} for
397
397
  * a full list of available options.
398
398
  *
399
- * @param options Object with configuration options. See {@link module:engine/model/treewalker~TreeWalker}.
399
+ * @param options Object with configuration options. See {@link module:engine/model/treewalker~ModelTreeWalker}.
400
400
  */
401
401
  *getPositions(options = {}) {
402
402
  options.boundaries = this;
403
- const treeWalker = new TreeWalker(options);
403
+ const treeWalker = new ModelTreeWalker(options);
404
404
  yield treeWalker.position;
405
405
  for (const value of treeWalker) {
406
406
  yield value.nextPosition;
@@ -429,17 +429,17 @@ export default class Range extends TypeCheckable {
429
429
  case 'merge':
430
430
  return [this._getTransformedByMergeOperation(operation)];
431
431
  }
432
- return [new Range(this.start, this.end)];
432
+ return [new ModelRange(this.start, this.end)];
433
433
  }
434
434
  /**
435
435
  * Returns a range that is a result of transforming this range by multiple `operations`.
436
436
  *
437
- * @see ~Range#getTransformedByOperation
437
+ * @see ~ModelRange#getTransformedByOperation
438
438
  * @param operations Operations to transform the range by.
439
439
  * @returns Range which is the result of transformation.
440
440
  */
441
441
  getTransformedByOperations(operations) {
442
- const ranges = [new Range(this.start, this.end)];
442
+ const ranges = [new ModelRange(this.start, this.end)];
443
443
  for (const operation of operations) {
444
444
  for (let i = 0; i < ranges.length; i++) {
445
445
  const result = ranges[i].getTransformedByOperation(operation);
@@ -463,14 +463,14 @@ export default class Range extends TypeCheckable {
463
463
  return ranges;
464
464
  }
465
465
  /**
466
- * Returns an {@link module:engine/model/element~Element} or {@link module:engine/model/documentfragment~DocumentFragment}
466
+ * Returns an {@link module:engine/model/element~ModelElement} or {@link module:engine/model/documentfragment~ModelDocumentFragment}
467
467
  * which is a common ancestor of the range's both ends (in which the entire range is contained).
468
468
  */
469
469
  getCommonAncestor() {
470
470
  return this.start.getCommonAncestor(this.end);
471
471
  }
472
472
  /**
473
- * Returns an {@link module:engine/model/element~Element Element} contained by the range.
473
+ * Returns an {@link module:engine/model/element~ModelElement Element} contained by the range.
474
474
  * The element will be returned when it is the **only** node within the range and **fully–contained**
475
475
  * at the same time.
476
476
  */
@@ -544,7 +544,7 @@ export default class Range extends TypeCheckable {
544
544
  // Fix it by using old `end` which has proper `root`.
545
545
  end = this.end.getShiftedBy(-1);
546
546
  }
547
- return new Range(start, end);
547
+ return new ModelRange(start, end);
548
548
  }
549
549
  /**
550
550
  * Returns a result of transforming a copy of this range by merge operation.
@@ -566,7 +566,7 @@ export default class Range extends TypeCheckable {
566
566
  // <p>F{}z</p>
567
567
  //
568
568
  if (this.start.isEqual(operation.targetPosition) && this.end.isEqual(operation.deletionPosition)) {
569
- return new Range(this.start);
569
+ return new ModelRange(this.start);
570
570
  }
571
571
  let start = this.start._getTransformedByMergeOperation(operation);
572
572
  let end = this.end._getTransformedByMergeOperation(operation);
@@ -604,7 +604,7 @@ export default class Range extends TypeCheckable {
604
604
  //
605
605
  if (operation.sourcePosition.isBefore(operation.targetPosition)) {
606
606
  // Case 1.
607
- start = Position._createAt(end);
607
+ start = ModelPosition._createAt(end);
608
608
  start.offset = 0;
609
609
  }
610
610
  else {
@@ -615,14 +615,14 @@ export default class Range extends TypeCheckable {
615
615
  // In both case 2 and 3 start is at the end of the merge-to element.
616
616
  start = operation.targetPosition;
617
617
  }
618
- return new Range(start, end);
618
+ return new ModelRange(start, end);
619
619
  }
620
- return new Range(start, end);
620
+ return new ModelRange(start, end);
621
621
  }
622
622
  /**
623
- * Returns an array containing one or two {@link ~Range ranges} that are a result of transforming this
624
- * {@link ~Range range} by inserting `howMany` nodes at `insertPosition`. Two {@link ~Range ranges} are
625
- * returned if the insertion was inside this {@link ~Range range} and `spread` is set to `true`.
623
+ * Returns an array containing one or two {@link ~ModelRange ranges} that are a result of transforming this
624
+ * {@link ~ModelRange range} by inserting `howMany` nodes at `insertPosition`. Two {@link ~ModelRange ranges} are
625
+ * returned if the insertion was inside this {@link ~ModelRange range} and `spread` is set to `true`.
626
626
  *
627
627
  * Examples:
628
628
  *
@@ -657,20 +657,20 @@ export default class Range extends TypeCheckable {
657
657
  // The other part is from spread point to the original end, but transformed by
658
658
  // insertion to reflect insertion changes.
659
659
  return [
660
- new Range(this.start, insertPosition),
661
- new Range(insertPosition.getShiftedBy(howMany), this.end._getTransformedByInsertion(insertPosition, howMany))
660
+ new ModelRange(this.start, insertPosition),
661
+ new ModelRange(insertPosition.getShiftedBy(howMany), this.end._getTransformedByInsertion(insertPosition, howMany))
662
662
  ];
663
663
  }
664
664
  else {
665
- const range = new Range(this.start, this.end);
665
+ const range = new ModelRange(this.start, this.end);
666
666
  range.start = range.start._getTransformedByInsertion(insertPosition, howMany);
667
667
  range.end = range.end._getTransformedByInsertion(insertPosition, howMany);
668
668
  return [range];
669
669
  }
670
670
  }
671
671
  /**
672
- * Returns an array containing {@link ~Range ranges} that are a result of transforming this
673
- * {@link ~Range range} by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
672
+ * Returns an array containing {@link ~ModelRange ranges} that are a result of transforming this
673
+ * {@link ~ModelRange range} by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
674
674
  *
675
675
  * @internal
676
676
  * @param sourcePosition Position from which nodes are moved.
@@ -683,7 +683,7 @@ export default class Range extends TypeCheckable {
683
683
  // Special case for transforming a collapsed range. Just transform it like a position.
684
684
  if (this.isCollapsed) {
685
685
  const newPos = this.start._getTransformedByMove(sourcePosition, targetPosition, howMany);
686
- return [new Range(newPos)];
686
+ return [new ModelRange(newPos)];
687
687
  }
688
688
  // Special case for transformation when a part of the range is moved towards the range.
689
689
  //
@@ -697,13 +697,13 @@ export default class Range extends TypeCheckable {
697
697
  // <div><p>ab</p><p>c[d</p></div><p>e]f</p> --> <div><p>ab</p>{</div>}<p>c[d</p><p>e]f</p>
698
698
  //
699
699
  // This special case is applied only if the range is to be kept together (not spread).
700
- const moveRange = Range._createFromPositionAndShift(sourcePosition, howMany);
700
+ const moveRange = ModelRange._createFromPositionAndShift(sourcePosition, howMany);
701
701
  const insertPosition = targetPosition._getTransformedByDeletion(sourcePosition, howMany);
702
702
  if (this.containsPosition(targetPosition) && !spread) {
703
703
  if (moveRange.containsPosition(this.start) || moveRange.containsPosition(this.end)) {
704
704
  const start = this.start._getTransformedByMove(sourcePosition, targetPosition, howMany);
705
705
  const end = this.end._getTransformedByMove(sourcePosition, targetPosition, howMany);
706
- return [new Range(start, end)];
706
+ return [new ModelRange(start, end)];
707
707
  }
708
708
  }
709
709
  // Default algorithm.
@@ -713,11 +713,11 @@ export default class Range extends TypeCheckable {
713
713
  const common = this.getIntersection(moveRange);
714
714
  if (differenceSet.length == 1) {
715
715
  // `moveRange` and this range may intersect but may be separate.
716
- difference = new Range(differenceSet[0].start._getTransformedByDeletion(sourcePosition, howMany), differenceSet[0].end._getTransformedByDeletion(sourcePosition, howMany));
716
+ difference = new ModelRange(differenceSet[0].start._getTransformedByDeletion(sourcePosition, howMany), differenceSet[0].end._getTransformedByDeletion(sourcePosition, howMany));
717
717
  }
718
718
  else if (differenceSet.length == 2) {
719
719
  // `moveRange` is inside this range.
720
- difference = new Range(this.start, this.end._getTransformedByDeletion(sourcePosition, howMany));
720
+ difference = new ModelRange(this.start, this.end._getTransformedByDeletion(sourcePosition, howMany));
721
721
  } // else, `moveRange` contains this range.
722
722
  if (difference) {
723
723
  result = difference._getTransformedByInsertion(insertPosition, howMany, common !== null || spread);
@@ -726,7 +726,7 @@ export default class Range extends TypeCheckable {
726
726
  result = [];
727
727
  }
728
728
  if (common) {
729
- const transformedCommon = new Range(common.start._getCombined(moveRange.start, insertPosition), common.end._getCombined(moveRange.start, insertPosition));
729
+ const transformedCommon = new ModelRange(common.start._getCombined(moveRange.start, insertPosition), common.end._getCombined(moveRange.start, insertPosition));
730
730
  if (result.length == 2) {
731
731
  result.splice(1, 0, transformedCommon);
732
732
  }
@@ -760,10 +760,10 @@ export default class Range extends TypeCheckable {
760
760
  if (newEnd == null) {
761
761
  newEnd = deletePosition;
762
762
  }
763
- return new Range(newStart, newEnd);
763
+ return new ModelRange(newStart, newEnd);
764
764
  }
765
765
  /**
766
- * Creates a new range, spreading from specified {@link module:engine/model/position~Position position} to a position moved by
766
+ * Creates a new range, spreading from specified {@link module:engine/model/position~ModelPosition position} to a position moved by
767
767
  * given `shift`. If `shift` is a negative value, shifted position is treated as the beginning of the range.
768
768
  *
769
769
  * @internal
@@ -776,22 +776,22 @@ export default class Range extends TypeCheckable {
776
776
  return shift > 0 ? new this(start, end) : new this(end, start);
777
777
  }
778
778
  /**
779
- * Creates a range inside an {@link module:engine/model/element~Element element} which starts before the first child of
779
+ * Creates a range inside an {@link module:engine/model/element~ModelElement element} which starts before the first child of
780
780
  * that element and ends after the last child of that element.
781
781
  *
782
782
  * @internal
783
783
  * @param element Element which is a parent for the range.
784
784
  */
785
785
  static _createIn(element) {
786
- return new this(Position._createAt(element, 0), Position._createAt(element, element.maxOffset));
786
+ return new this(ModelPosition._createAt(element, 0), ModelPosition._createAt(element, element.maxOffset));
787
787
  }
788
788
  /**
789
- * Creates a range that starts before given {@link module:engine/model/item~Item model item} and ends after it.
789
+ * Creates a range that starts before given {@link module:engine/model/item~ModelItem model item} and ends after it.
790
790
  *
791
791
  * @internal
792
792
  */
793
793
  static _createOn(item) {
794
- return this._createFromPositionAndShift(Position._createBefore(item), item.offsetSize);
794
+ return this._createFromPositionAndShift(ModelPosition._createBefore(item), item.offsetSize);
795
795
  }
796
796
  /**
797
797
  * Combines all ranges from the passed array into a one range. At least one range has to be passed.
@@ -815,7 +815,7 @@ export default class Range extends TypeCheckable {
815
815
  if (ranges.length === 0) {
816
816
  /**
817
817
  * At least one range has to be passed to
818
- * {@link module:engine/model/range~Range._createFromRanges `Range._createFromRanges()`}.
818
+ * {@link module:engine/model/range~ModelRange._createFromRanges `Range._createFromRanges()`}.
819
819
  *
820
820
  * @error range-create-from-ranges-empty-array
821
821
  */
@@ -842,7 +842,7 @@ export default class Range extends TypeCheckable {
842
842
  // Since ranges are sorted, start with the range with index that is closest to reference range index.
843
843
  for (let i = refIndex - 1; i >= 0; i--) {
844
844
  if (ranges[i].end.isEqual(result.start)) {
845
- result.start = Position._createAt(ranges[i].start);
845
+ result.start = ModelPosition._createAt(ranges[i].start);
846
846
  }
847
847
  else {
848
848
  // If ranges are not starting/ending at the same position there is no point in looking further.
@@ -853,7 +853,7 @@ export default class Range extends TypeCheckable {
853
853
  // Since ranges are sorted, start with the range with index that is closest to reference range index.
854
854
  for (let i = refIndex + 1; i < ranges.length; i++) {
855
855
  if (ranges[i].start.isEqual(result.end)) {
856
- result.end = Position._createAt(ranges[i].end);
856
+ result.end = ModelPosition._createAt(ranges[i].end);
857
857
  }
858
858
  else {
859
859
  // If ranges are not starting/ending at the same position there is no point in looking further.
@@ -870,11 +870,11 @@ export default class Range extends TypeCheckable {
870
870
  * @returns `Range` instance created using given plain object.
871
871
  */
872
872
  static fromJSON(json, doc) {
873
- return new this(Position.fromJSON(json.start, doc), Position.fromJSON(json.end, doc));
873
+ return new this(ModelPosition.fromJSON(json.start, doc), ModelPosition.fromJSON(json.end, doc));
874
874
  }
875
875
  }
876
876
  // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
877
877
  // Proper overload would interfere with that.
878
- Range.prototype.is = function (type) {
878
+ ModelRange.prototype.is = function (type) {
879
879
  return type === 'range' || type === 'model:range';
880
880
  };
@@ -5,14 +5,14 @@
5
5
  /**
6
6
  * @module engine/model/rootelement
7
7
  */
8
- import Element from './element.js';
9
- import type Document from './document.js';
8
+ import { ModelElement } from './element.js';
9
+ import { type ModelDocument } from './document.js';
10
10
  /**
11
- * Type of {@link module:engine/model/element~Element} that is a root of a model tree.
11
+ * Type of {@link module:engine/model/element~ModelElement} that is a root of a model tree.
12
12
  */
13
- export default class RootElement extends Element {
13
+ export declare class ModelRootElement extends ModelElement {
14
14
  /**
15
- * Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
15
+ * Unique root name used to identify this root element by {@link module:engine/model/document~ModelDocument}.
16
16
  */
17
17
  readonly rootName: string;
18
18
  /**
@@ -34,21 +34,21 @@ export default class RootElement extends Element {
34
34
  *
35
35
  * @param document Document that is an owner of this root.
36
36
  * @param name Node name.
37
- * @param rootName Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
37
+ * @param rootName Unique root name used to identify this root element by {@link module:engine/model/document~ModelDocument}.
38
38
  */
39
- constructor(document: Document, name: string, rootName?: string);
39
+ constructor(document: ModelDocument, name: string, rootName?: string);
40
40
  /**
41
- * {@link module:engine/model/document~Document Document} that owns this root element.
41
+ * {@link module:engine/model/document~ModelDocument Document} that owns this root element.
42
42
  */
43
- get document(): Document;
43
+ get document(): ModelDocument;
44
44
  /**
45
45
  * Informs if the root element is currently attached to the document, or not.
46
46
  *
47
47
  * A detached root is equivalent to being removed and cannot contain any children or markers.
48
48
  *
49
49
  * By default, a newly added root is attached. It can be detached using
50
- * {@link module:engine/model/writer~Writer#detachRoot `Writer#detachRoot`}. A detached root can be re-attached again using
51
- * {@link module:engine/model/writer~Writer#addRoot `Writer#addRoot`}.
50
+ * {@link module:engine/model/writer~ModelWriter#detachRoot `Writer#detachRoot`}. A detached root can be re-attached again using
51
+ * {@link module:engine/model/writer~ModelWriter#addRoot `Writer#addRoot`}.
52
52
  */
53
53
  isAttached(): boolean;
54
54
  /**
@@ -5,13 +5,13 @@
5
5
  /**
6
6
  * @module engine/model/rootelement
7
7
  */
8
- import Element from './element.js';
8
+ import { ModelElement } from './element.js';
9
9
  /**
10
- * Type of {@link module:engine/model/element~Element} that is a root of a model tree.
10
+ * Type of {@link module:engine/model/element~ModelElement} that is a root of a model tree.
11
11
  */
12
- export default class RootElement extends Element {
12
+ export class ModelRootElement extends ModelElement {
13
13
  /**
14
- * Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
14
+ * Unique root name used to identify this root element by {@link module:engine/model/document~ModelDocument}.
15
15
  */
16
16
  rootName;
17
17
  /**
@@ -33,7 +33,7 @@ export default class RootElement extends Element {
33
33
  *
34
34
  * @param document Document that is an owner of this root.
35
35
  * @param name Node name.
36
- * @param rootName Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
36
+ * @param rootName Unique root name used to identify this root element by {@link module:engine/model/document~ModelDocument}.
37
37
  */
38
38
  constructor(document, name, rootName = 'main') {
39
39
  super(name);
@@ -41,7 +41,7 @@ export default class RootElement extends Element {
41
41
  this.rootName = rootName;
42
42
  }
43
43
  /**
44
- * {@link module:engine/model/document~Document Document} that owns this root element.
44
+ * {@link module:engine/model/document~ModelDocument Document} that owns this root element.
45
45
  */
46
46
  get document() {
47
47
  return this._document;
@@ -52,8 +52,8 @@ export default class RootElement extends Element {
52
52
  * A detached root is equivalent to being removed and cannot contain any children or markers.
53
53
  *
54
54
  * By default, a newly added root is attached. It can be detached using
55
- * {@link module:engine/model/writer~Writer#detachRoot `Writer#detachRoot`}. A detached root can be re-attached again using
56
- * {@link module:engine/model/writer~Writer#addRoot `Writer#addRoot`}.
55
+ * {@link module:engine/model/writer~ModelWriter#detachRoot `Writer#detachRoot`}. A detached root can be re-attached again using
56
+ * {@link module:engine/model/writer~ModelWriter#addRoot `Writer#addRoot`}.
57
57
  */
58
58
  isAttached() {
59
59
  return this._isAttached;
@@ -69,7 +69,7 @@ export default class RootElement extends Element {
69
69
  }
70
70
  // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
71
71
  // Proper overload would interfere with that.
72
- RootElement.prototype.is = function (type, name) {
72
+ ModelRootElement.prototype.is = function (type, name) {
73
73
  if (!name) {
74
74
  return type === 'rootElement' || type === 'model:rootElement' ||
75
75
  // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.