@ckeditor/ckeditor5-engine 45.2.1 → 46.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +96 -91
  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,12 +5,12 @@
5
5
  /**
6
6
  * @module engine/model/utils/insertcontent
7
7
  */
8
- import DocumentSelection from '../documentselection.js';
9
- import Element from '../element.js';
10
- import LivePosition from '../liveposition.js';
11
- import LiveRange from '../liverange.js';
12
- import Position from '../position.js';
13
- import Range from '../range.js';
8
+ import { ModelDocumentSelection } from '../documentselection.js';
9
+ import { ModelElement } from '../element.js';
10
+ import { ModelLivePosition } from '../liveposition.js';
11
+ import { ModelLiveRange } from '../liverange.js';
12
+ import { ModelPosition } from '../position.js';
13
+ import { ModelRange } from '../range.js';
14
14
  import { CKEditorError } from '@ckeditor/ckeditor5-utils';
15
15
  /**
16
16
  * Inserts content into the editor (specified selection) as one would expect the paste functionality to work.
@@ -27,7 +27,7 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
27
27
  * <p>x</p>[<img />]<p>z</p> + <p>y</p> => <p>x</p>^<p>z</p> + <p>y</p> => <p>x</p><p>y[]</p><p>z</p>
28
28
  * ```
29
29
  *
30
- * If an instance of {@link module:engine/model/selection~Selection} is passed as `selectable` it will be modified
30
+ * If an instance of {@link module:engine/model/selection~ModelSelection} is passed as `selectable` it will be modified
31
31
  * to the insertion selection (equal to a range to be selected after insertion).
32
32
  *
33
33
  * If `selectable` is not passed, the content will be inserted using the current selection of the model document.
@@ -42,8 +42,9 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
42
42
  * @returns Range which contains all the performed changes. This is a range that, if removed,
43
43
  * would return the model to the state before the insertion. If no changes were preformed by `insertContent`, returns a range collapsed
44
44
  * at the insertion position.
45
+ * @internal
45
46
  */
46
- export default function insertContent(model, content, selectable) {
47
+ export function insertContent(model, content, selectable) {
47
48
  return model.change(writer => {
48
49
  const selection = selectable ? selectable : model.document.selection;
49
50
  if (!selection.isCollapsed) {
@@ -105,7 +106,7 @@ export default function insertContent(model, content, selectable) {
105
106
  // After insertion was done, the selection was set but the model contains fake <$marker> elements.
106
107
  // These <$marker> elements will be now removed. Because of that, we will need to fix the selection.
107
108
  // We will create a live range that will automatically be update as <$marker> elements are removed.
108
- const selectionLiveRange = newRange ? LiveRange.fromRange(newRange) : null;
109
+ const selectionLiveRange = newRange ? ModelLiveRange.fromRange(newRange) : null;
109
110
  // Marker name -> [ start position, end position ].
110
111
  const markersData = {};
111
112
  // Note: `fakeMarkerElements` are sorted backwards. However, now, we want to handle the markers
@@ -152,7 +153,7 @@ export default function insertContent(model, content, selectable) {
152
153
  writer.addMarker(name, {
153
154
  usingOperation: true,
154
155
  affectsData: true,
155
- range: new Range(start, end)
156
+ range: new ModelRange(start, end)
156
157
  });
157
158
  }
158
159
  }
@@ -163,7 +164,7 @@ export default function insertContent(model, content, selectable) {
163
164
  }
164
165
  /* istanbul ignore else -- @preserve */
165
166
  if (newRange) {
166
- if (selection instanceof DocumentSelection) {
167
+ if (selection instanceof ModelDocumentSelection) {
167
168
  writer.setSelection(newRange);
168
169
  }
169
170
  else {
@@ -213,11 +214,11 @@ class Insertion {
213
214
  */
214
215
  schema;
215
216
  /**
216
- * The temporary DocumentFragment used for grouping multiple nodes for single insert operation.
217
+ * The temporary ModelDocumentFragment used for grouping multiple nodes for single insert operation.
217
218
  */
218
219
  _documentFragment;
219
220
  /**
220
- * The current position in the temporary DocumentFragment.
221
+ * The current position in the temporary ModelDocumentFragment.
221
222
  */
222
223
  _documentFragmentPosition;
223
224
  /**
@@ -263,7 +264,7 @@ class Insertion {
263
264
  for (const node of Array.from(nodes)) {
264
265
  this._handleNode(node);
265
266
  }
266
- // Insert nodes collected in temporary DocumentFragment.
267
+ // Insert nodes collected in temporary ModelDocumentFragment.
267
268
  this._insertPartialFragment();
268
269
  // If there was an auto paragraph then we might need to adjust the end of insertion.
269
270
  if (this._lastAutoParagraph) {
@@ -304,7 +305,7 @@ class Insertion {
304
305
  */
305
306
  getSelectionRange() {
306
307
  if (this._nodeToSelect) {
307
- return Range._createOn(this._nodeToSelect);
308
+ return ModelRange._createOn(this._nodeToSelect);
308
309
  }
309
310
  return this.model.schema.getNearestSelectionRange(this.position);
310
311
  }
@@ -316,7 +317,7 @@ class Insertion {
316
317
  if (!this._affectedStart) {
317
318
  return null;
318
319
  }
319
- return new Range(this._affectedStart, this._affectedEnd);
320
+ return new ModelRange(this._affectedStart, this._affectedEnd);
320
321
  }
321
322
  /**
322
323
  * Destroys `Insertion` instance.
@@ -342,7 +343,7 @@ class Insertion {
342
343
  }
343
344
  return;
344
345
  }
345
- // Add node to the current temporary DocumentFragment.
346
+ // Add node to the current temporary ModelDocumentFragment.
346
347
  this._appendToFragment(node);
347
348
  // Store the first and last nodes for easy access for merging with sibling nodes.
348
349
  if (!this._firstNode) {
@@ -351,13 +352,13 @@ class Insertion {
351
352
  this._lastNode = node;
352
353
  }
353
354
  /**
354
- * Inserts the temporary DocumentFragment into the model.
355
+ * Inserts the temporary ModelDocumentFragment into the model.
355
356
  */
356
357
  _insertPartialFragment() {
357
358
  if (this._documentFragment.isEmpty) {
358
359
  return;
359
360
  }
360
- const livePosition = LivePosition.fromPosition(this.position, 'toNext');
361
+ const livePosition = ModelLivePosition.fromPosition(this.position, 'toNext');
361
362
  this._setAffectedBoundaries(this.position);
362
363
  // If the very first node of the whole insertion process is inserted, insert it separately for OT reasons (undo).
363
364
  // Note: there can be multiple calls to `_insertPartialFragment()` during one insertion process.
@@ -387,7 +388,7 @@ class Insertion {
387
388
  }
388
389
  }
389
390
  /**
390
- * Append a node to the temporary DocumentFragment.
391
+ * Append a node to the temporary ModelDocumentFragment.
391
392
  *
392
393
  * @param node The node to insert.
393
394
  */
@@ -400,8 +401,8 @@ class Insertion {
400
401
  * Given node cannot be inserted on the given position.
401
402
  *
402
403
  * @error insertcontent-wrong-position
403
- * @param {module:engine/model/node~Node} node Node to insert.
404
- * @param {module:engine/model/position~Position} position Position to insert the node at.
404
+ * @param {module:engine/model/node~ModelNode} node Node to insert.
405
+ * @param {module:engine/model/position~ModelPosition} position Position to insert the node at.
405
406
  */
406
407
  throw new CKEditorError('insertcontent-wrong-position', this, { node, position: this.position });
407
408
  }
@@ -428,7 +429,7 @@ class Insertion {
428
429
  // <paragraph>Foo][bar</paragraph> -> <paragraph>Foo]xx[bar</paragraph>
429
430
  // This is why it cannot be a range but two separate positions.
430
431
  if (!this._affectedStart) {
431
- this._affectedStart = LivePosition.fromPosition(position, 'toPrevious');
432
+ this._affectedStart = ModelLivePosition.fromPosition(position, 'toPrevious');
432
433
  }
433
434
  // If `_affectedEnd` is before the new boundary position, expand `_affectedEnd`. This can happen if first inserted node was
434
435
  // inserted into the parent but the next node is moved-out of that parent:
@@ -438,7 +439,7 @@ class Insertion {
438
439
  if (this._affectedEnd) {
439
440
  this._affectedEnd.detach();
440
441
  }
441
- this._affectedEnd = LivePosition.fromPosition(position, 'toNext');
442
+ this._affectedEnd = ModelLivePosition.fromPosition(position, 'toNext');
442
443
  }
443
444
  }
444
445
  /**
@@ -449,17 +450,17 @@ class Insertion {
449
450
  */
450
451
  _mergeOnLeft() {
451
452
  const node = this._firstNode;
452
- if (!(node instanceof Element)) {
453
+ if (!(node instanceof ModelElement)) {
453
454
  return;
454
455
  }
455
456
  if (!this._canMergeLeft(node)) {
456
457
  return;
457
458
  }
458
- const mergePosLeft = LivePosition._createBefore(node);
459
+ const mergePosLeft = ModelLivePosition._createBefore(node);
459
460
  mergePosLeft.stickiness = 'toNext';
460
- const livePosition = LivePosition.fromPosition(this.position, 'toNext');
461
+ const livePosition = ModelLivePosition.fromPosition(this.position, 'toNext');
461
462
  // If `_affectedStart` is sames as merge position, it means that the element "marked" by `_affectedStart` is going to be
462
- // removed and its contents will be moved. This won't transform `LivePosition` so `_affectedStart` needs to be moved
463
+ // removed and its contents will be moved. This won't transform `ModelLivePosition` so `_affectedStart` needs to be moved
463
464
  // by hand to properly reflect affected range. (Due to `_affectedStart` and `_affectedEnd` stickiness, the "range" is
464
465
  // shown as `][`).
465
466
  //
@@ -472,7 +473,7 @@ class Insertion {
472
473
  // Note, that if we are here then something must have been inserted, so `_affectedStart` and `_affectedEnd` have to be set.
473
474
  if (this._affectedStart.isEqual(mergePosLeft)) {
474
475
  this._affectedStart.detach();
475
- this._affectedStart = LivePosition._createAt(mergePosLeft.nodeBefore, 'end', 'toPrevious');
476
+ this._affectedStart = ModelLivePosition._createAt(mergePosLeft.nodeBefore, 'end', 'toPrevious');
476
477
  }
477
478
  // We need to update the references to the first and last nodes if they will be merged into the previous sibling node
478
479
  // because the reference would point to the removed node.
@@ -498,7 +499,7 @@ class Insertion {
498
499
  // <paragraph>Foo]Abc[</paragraph><paragraph>Bar</paragraph>
499
500
  if (mergePosLeft.isEqual(this._affectedEnd) && this._firstNode === this._lastNode) {
500
501
  this._affectedEnd.detach();
501
- this._affectedEnd = LivePosition._createAt(mergePosLeft.nodeBefore, 'end', 'toNext');
502
+ this._affectedEnd = ModelLivePosition._createAt(mergePosLeft.nodeBefore, 'end', 'toNext');
502
503
  }
503
504
  this.position = livePosition.toPosition();
504
505
  livePosition.detach();
@@ -515,13 +516,13 @@ class Insertion {
515
516
  */
516
517
  _mergeOnRight() {
517
518
  const node = this._lastNode;
518
- if (!(node instanceof Element)) {
519
+ if (!(node instanceof ModelElement)) {
519
520
  return;
520
521
  }
521
522
  if (!this._canMergeRight(node)) {
522
523
  return;
523
524
  }
524
- const mergePosRight = LivePosition._createAfter(node);
525
+ const mergePosRight = ModelLivePosition._createAfter(node);
525
526
  mergePosRight.stickiness = 'toNext';
526
527
  /* istanbul ignore if -- @preserve */
527
528
  if (!this.position.isEqual(mergePosRight)) {
@@ -541,15 +542,15 @@ class Insertion {
541
542
  }
542
543
  // Move the position to the previous node, so it isn't moved to the graveyard on merge.
543
544
  // <p>x</p>[]<p>y</p> => <p>x[]</p><p>y</p>
544
- this.position = Position._createAt(mergePosRight.nodeBefore, 'end');
545
+ this.position = ModelPosition._createAt(mergePosRight.nodeBefore, 'end');
545
546
  // Explanation of setting position stickiness to `'toPrevious'`:
546
547
  // OK: <p>xx[]</p> + <p>yy</p> => <p>xx[]yy</p> (when sticks to previous)
547
548
  // NOK: <p>xx[]</p> + <p>yy</p> => <p>xxyy[]</p> (when sticks to next)
548
- const livePosition = LivePosition.fromPosition(this.position, 'toPrevious');
549
+ const livePosition = ModelLivePosition.fromPosition(this.position, 'toPrevious');
549
550
  // See comment in `_mergeOnLeft()` on moving `_affectedStart`.
550
551
  if (this._affectedEnd.isEqual(mergePosRight)) {
551
552
  this._affectedEnd.detach();
552
- this._affectedEnd = LivePosition._createAt(mergePosRight.nodeBefore, 'end', 'toNext');
553
+ this._affectedEnd = ModelLivePosition._createAt(mergePosRight.nodeBefore, 'end', 'toNext');
553
554
  }
554
555
  // We need to update the references to the first and last nodes if they will be merged into the previous sibling node
555
556
  // because the reference would point to the removed node.
@@ -568,7 +569,7 @@ class Insertion {
568
569
  // See comment in `_mergeOnLeft()` on moving `_affectedStart`.
569
570
  if (mergePosRight.getShiftedBy(-1).isEqual(this._affectedStart) && this._firstNode === this._lastNode) {
570
571
  this._affectedStart.detach();
571
- this._affectedStart = LivePosition._createAt(mergePosRight.nodeBefore, 0, 'toPrevious');
572
+ this._affectedStart = ModelLivePosition._createAt(mergePosRight.nodeBefore, 0, 'toPrevious');
572
573
  }
573
574
  this.position = livePosition.toPosition();
574
575
  livePosition.detach();
@@ -584,7 +585,7 @@ class Insertion {
584
585
  */
585
586
  _canMergeLeft(node) {
586
587
  const previousSibling = node.previousSibling;
587
- return (previousSibling instanceof Element) &&
588
+ return (previousSibling instanceof ModelElement) &&
588
589
  this.canMergeWith.has(previousSibling) &&
589
590
  this.model.schema.checkMerge(previousSibling, node);
590
591
  }
@@ -595,7 +596,7 @@ class Insertion {
595
596
  */
596
597
  _canMergeRight(node) {
597
598
  const nextSibling = node.nextSibling;
598
- return (nextSibling instanceof Element) &&
599
+ return (nextSibling instanceof ModelElement) &&
599
600
  this.canMergeWith.has(nextSibling) &&
600
601
  this.model.schema.checkMerge(node, nextSibling);
601
602
  }
@@ -603,7 +604,7 @@ class Insertion {
603
604
  * Inserts a paragraph and moves the insertion position into it.
604
605
  */
605
606
  _insertAutoParagraph() {
606
- // Insert nodes collected in temporary DocumentFragment if the position parent needs change to process further nodes.
607
+ // Insert nodes collected in temporary ModelDocumentFragment if the position parent needs change to process further nodes.
607
608
  this._insertPartialFragment();
608
609
  // Insert a paragraph and move insertion position to it.
609
610
  const paragraph = this.writer.createElement('paragraph');
@@ -621,7 +622,7 @@ class Insertion {
621
622
  if (!allowedIn) {
622
623
  return false;
623
624
  }
624
- // Insert nodes collected in temporary DocumentFragment if the position parent needs change to process further nodes.
625
+ // Insert nodes collected in temporary ModelDocumentFragment if the position parent needs change to process further nodes.
625
626
  if (allowedIn != this.position.parent) {
626
627
  this._insertPartialFragment();
627
628
  }
@@ -5,11 +5,11 @@
5
5
  /**
6
6
  * @module engine/model/utils/insertobject
7
7
  */
8
- import type DocumentSelection from '../documentselection.js';
9
- import type Selection from '../selection.js';
10
- import type Element from '../element.js';
11
- import type Model from '../model.js';
12
- import type Range from '../range.js';
8
+ import { type ModelDocumentSelection } from '../documentselection.js';
9
+ import { type ModelSelection } from '../selection.js';
10
+ import { type ModelElement } from '../element.js';
11
+ import { type Model } from '../model.js';
12
+ import { type ModelRange } from '../range.js';
13
13
  /**
14
14
  * Inserts an {@glink framework/deep-dive/schema#object-elements object element} at a specific position in the editor content.
15
15
  *
@@ -22,7 +22,7 @@ import type Range from '../range.js';
22
22
  * @param model The model in context of which the insertion should be performed.
23
23
  * @param object An object to be inserted into the model document.
24
24
  * @param selectable A selectable where the content should be inserted. If not specified, the current
25
- * {@link module:engine/model/document~Document#selection document selection} will be used instead.
25
+ * {@link module:engine/model/document~ModelDocument#selection document selection} will be used instead.
26
26
  * @param options Additional options.
27
27
  * @param options.findOptimalPosition An option that, when set, adjusts the insertion position (relative to
28
28
  * `selectable` and `placeOrOffset`) so that the content of `selectable` is not split upon insertion (a.k.a. non-destructive insertion).
@@ -32,7 +32,7 @@ import type Range from '../range.js';
32
32
  *
33
33
  * Note that this option works only for block objects. Inline objects are inserted into text and do not split blocks.
34
34
  * @param options.setSelection An option that, when set, moves the
35
- * {@link module:engine/model/document~Document#selection document selection} after inserting the object.
35
+ * {@link module:engine/model/document~ModelDocument#selection document selection} after inserting the object.
36
36
  * * When `'on'`, the document selection will be set on the inserted object.
37
37
  * * When `'after'`, the document selection will move to the closest text node after the inserted object. If there is no
38
38
  * such text node, a paragraph will be created and the document selection will be moved inside it.
@@ -40,7 +40,7 @@ import type Range from '../range.js';
40
40
  * would return the model to the state before the insertion. If no changes were preformed by `insertObject()`, returns a range collapsed
41
41
  * at the insertion position.
42
42
  */
43
- export default function insertObject(model: Model, object: Element, selectable?: Selection | DocumentSelection | null, options?: {
43
+ export declare function insertObject(model: Model, object: ModelElement, selectable?: ModelSelection | ModelDocumentSelection | null, options?: {
44
44
  findOptimalPosition?: 'auto' | 'before' | 'after';
45
45
  setSelection?: 'on' | 'after';
46
- }): Range;
46
+ }): ModelRange;
@@ -15,7 +15,7 @@ import { CKEditorError, first } from '@ckeditor/ckeditor5-utils';
15
15
  * @param model The model in context of which the insertion should be performed.
16
16
  * @param object An object to be inserted into the model document.
17
17
  * @param selectable A selectable where the content should be inserted. If not specified, the current
18
- * {@link module:engine/model/document~Document#selection document selection} will be used instead.
18
+ * {@link module:engine/model/document~ModelDocument#selection document selection} will be used instead.
19
19
  * @param options Additional options.
20
20
  * @param options.findOptimalPosition An option that, when set, adjusts the insertion position (relative to
21
21
  * `selectable` and `placeOrOffset`) so that the content of `selectable` is not split upon insertion (a.k.a. non-destructive insertion).
@@ -25,7 +25,7 @@ import { CKEditorError, first } from '@ckeditor/ckeditor5-utils';
25
25
  *
26
26
  * Note that this option works only for block objects. Inline objects are inserted into text and do not split blocks.
27
27
  * @param options.setSelection An option that, when set, moves the
28
- * {@link module:engine/model/document~Document#selection document selection} after inserting the object.
28
+ * {@link module:engine/model/document~ModelDocument#selection document selection} after inserting the object.
29
29
  * * When `'on'`, the document selection will be set on the inserted object.
30
30
  * * When `'after'`, the document selection will move to the closest text node after the inserted object. If there is no
31
31
  * such text node, a paragraph will be created and the document selection will be moved inside it.
@@ -33,12 +33,12 @@ import { CKEditorError, first } from '@ckeditor/ckeditor5-utils';
33
33
  * would return the model to the state before the insertion. If no changes were preformed by `insertObject()`, returns a range collapsed
34
34
  * at the insertion position.
35
35
  */
36
- export default function insertObject(model, object, selectable, options = {}) {
36
+ export function insertObject(model, object, selectable, options = {}) {
37
37
  if (!model.schema.isObject(object)) {
38
38
  /**
39
39
  * Tried to insert an element with {@link module:engine/model/utils/insertobject insertObject()} function
40
40
  * that is not defined as an object in schema.
41
- * See {@link module:engine/model/schema~SchemaItemDefinition#isObject `SchemaItemDefinition`}.
41
+ * See {@link module:engine/model/schema~ModelSchemaItemDefinition#isObject `SchemaItemDefinition`}.
42
42
  * If you want to insert content that is not an object you might want to use
43
43
  * {@link module:engine/model/utils/insertcontent insertContent()} function.
44
44
  * @error insertobject-element-not-an-object
@@ -5,9 +5,9 @@
5
5
  /**
6
6
  * @module engine/model/utils/modifyselection
7
7
  */
8
- import DocumentSelection from '../documentselection.js';
9
- import type Model from '../model.js';
10
- import type Selection from '../selection.js';
8
+ import { ModelDocumentSelection } from '../documentselection.js';
9
+ import { type Model } from '../model.js';
10
+ import { type ModelSelection } from '../selection.js';
11
11
  /**
12
12
  * Modifies the selection. Currently, the supported modifications are:
13
13
  *
@@ -40,8 +40,9 @@ import type Selection from '../selection.js';
40
40
  * @param options.direction The direction in which the selection should be modified. Default 'forward'.
41
41
  * @param options.unit The unit by which selection should be modified. Default 'character'.
42
42
  * @param options.treatEmojiAsSingleUnit Whether multi-characer emoji sequences should be handled as single unit.
43
+ * @internal
43
44
  */
44
- export default function modifySelection(model: Model, selection: Selection | DocumentSelection, options?: {
45
+ export declare function modifySelection(model: Model, selection: ModelSelection | ModelDocumentSelection, options?: {
45
46
  direction?: 'forward' | 'backward';
46
47
  unit?: 'character' | 'codePoint' | 'word';
47
48
  treatEmojiAsSingleUnit?: boolean;
@@ -5,10 +5,10 @@
5
5
  /**
6
6
  * @module engine/model/utils/modifyselection
7
7
  */
8
- import DocumentSelection from '../documentselection.js';
9
- import Position from '../position.js';
10
- import Range from '../range.js';
11
- import TreeWalker from '../treewalker.js';
8
+ import { ModelDocumentSelection } from '../documentselection.js';
9
+ import { ModelPosition } from '../position.js';
10
+ import { ModelRange } from '../range.js';
11
+ import { ModelTreeWalker } from '../treewalker.js';
12
12
  import { isInsideSurrogatePair, isInsideCombinedSymbol, isInsideEmojiSequence } from '@ckeditor/ckeditor5-utils';
13
13
  const wordBoundaryCharacters = ' ,.?!:;"-()';
14
14
  /**
@@ -43,14 +43,15 @@ const wordBoundaryCharacters = ' ,.?!:;"-()';
43
43
  * @param options.direction The direction in which the selection should be modified. Default 'forward'.
44
44
  * @param options.unit The unit by which selection should be modified. Default 'character'.
45
45
  * @param options.treatEmojiAsSingleUnit Whether multi-characer emoji sequences should be handled as single unit.
46
+ * @internal
46
47
  */
47
- export default function modifySelection(model, selection, options = {}) {
48
+ export function modifySelection(model, selection, options = {}) {
48
49
  const schema = model.schema;
49
50
  const isForward = options.direction != 'backward';
50
51
  const unit = options.unit ? options.unit : 'character';
51
52
  const treatEmojiAsSingleUnit = !!options.treatEmojiAsSingleUnit;
52
53
  const focus = selection.focus;
53
- const walker = new TreeWalker({
54
+ const walker = new ModelTreeWalker({
54
55
  boundaries: getSearchRange(focus, isForward),
55
56
  singleCharacters: true,
56
57
  direction: isForward ? 'forward' : 'backward'
@@ -63,7 +64,7 @@ export default function modifySelection(model, selection, options = {}) {
63
64
  }
64
65
  const position = tryExtendingTo(data, next.value);
65
66
  if (position) {
66
- if (selection instanceof DocumentSelection) {
67
+ if (selection instanceof ModelDocumentSelection) {
67
68
  model.change(writer => {
68
69
  writer.setSelectionFocus(position);
69
70
  });
@@ -93,7 +94,7 @@ function tryExtendingTo(data, value) {
93
94
  if (type == (isForward ? 'elementStart' : 'elementEnd')) {
94
95
  // If it's a selectable, we can select it now.
95
96
  if (schema.isSelectable(item)) {
96
- return Position._createAt(item, isForward ? 'after' : 'before');
97
+ return ModelPosition._createAt(item, isForward ? 'after' : 'before');
97
98
  }
98
99
  // If text allowed on this position, extend to this place.
99
100
  if (schema.checkChild(nextPosition, '$text')) {
@@ -162,12 +163,12 @@ function getCorrectWordBreakPosition(walker, isForward) {
162
163
  }
163
164
  function getSearchRange(start, isForward) {
164
165
  const root = start.root;
165
- const searchEnd = Position._createAt(root, isForward ? 'end' : 0);
166
+ const searchEnd = ModelPosition._createAt(root, isForward ? 'end' : 0);
166
167
  if (isForward) {
167
- return new Range(start, searchEnd);
168
+ return new ModelRange(start, searchEnd);
168
169
  }
169
170
  else {
170
- return new Range(searchEnd, start);
171
+ return new ModelRange(searchEnd, start);
171
172
  }
172
173
  }
173
174
  /**
@@ -2,9 +2,9 @@
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 Range from '../range.js';
6
- import type Model from '../model.js';
7
- import type Schema from '../schema.js';
5
+ import { ModelRange } from '../range.js';
6
+ import { type Model } from '../model.js';
7
+ import { type ModelSchema } from '../schema.js';
8
8
  /**
9
9
  * Injects selection post-fixer to the model.
10
10
  *
@@ -13,11 +13,11 @@ import type Schema from '../schema.js';
13
13
  *
14
14
  * The correct position means that:
15
15
  *
16
- * * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~Schema}
16
+ * * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~ModelSchema}
17
17
  * allows a `$text`.
18
- * * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~Schema#isLimit limit element}
18
+ * * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~ModelSchema#isLimit limit element}
19
19
  * boundary (a range must be rooted within one limit element).
20
- * * Only {@link module:engine/model/schema~Schema#isSelectable selectable elements} can be selected from the outside
20
+ * * Only {@link module:engine/model/schema~ModelSchema#isSelectable selectable elements} can be selected from the outside
21
21
  * (e.g. `[<paragraph>foo</paragraph>]` is invalid). This rule applies independently to both selection ends, so this
22
22
  * selection is correct: `<paragraph>f[oo</paragraph><imageBlock></imageBlock>]`.
23
23
  *
@@ -55,6 +55,8 @@ import type Schema from '../schema.js';
55
55
  *
56
56
  * **Note** If the selection contains multiple ranges, the method returns a minimal set of ranges that are not intersecting after expanding
57
57
  * them to select `isLimit=true` elements.
58
+ *
59
+ * @internal
58
60
  */
59
61
  export declare function injectSelectionPostFixer(model: Model): void;
60
62
  /**
@@ -63,12 +65,14 @@ export declare function injectSelectionPostFixer(model: Model): void;
63
65
  * **Note:** This helper is used by the selection post-fixer and to fix the `beforeinput` target ranges.
64
66
  *
65
67
  * @returns Returns fixed range or null if range is valid.
68
+ * @internal
66
69
  */
67
- export declare function tryFixingRange(range: Range, schema: Schema): Range | null;
70
+ export declare function tryFixingRange(range: ModelRange, schema: ModelSchema): ModelRange | null;
68
71
  /**
69
72
  * Returns a minimal non-intersecting array of ranges without duplicates.
70
73
  *
71
74
  * @param ranges Ranges to merge.
72
75
  * @returns Array of unique and non-intersecting ranges.
76
+ * @internal
73
77
  */
74
- export declare function mergeIntersectingRanges(ranges: Array<Range>): Array<Range>;
78
+ export declare function mergeIntersectingRanges(ranges: Array<ModelRange>): Array<ModelRange>;
@@ -5,8 +5,8 @@
5
5
  /**
6
6
  * @module engine/model/utils/selection-post-fixer
7
7
  */
8
- import Position from '../position.js';
9
- import Range from '../range.js';
8
+ import { ModelPosition } from '../position.js';
9
+ import { ModelRange } from '../range.js';
10
10
  /**
11
11
  * Injects selection post-fixer to the model.
12
12
  *
@@ -15,11 +15,11 @@ import Range from '../range.js';
15
15
  *
16
16
  * The correct position means that:
17
17
  *
18
- * * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~Schema}
18
+ * * All collapsed selection ranges are in a place where the {@link module:engine/model/schema~ModelSchema}
19
19
  * allows a `$text`.
20
- * * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~Schema#isLimit limit element}
20
+ * * None of the selection's non-collapsed ranges crosses a {@link module:engine/model/schema~ModelSchema#isLimit limit element}
21
21
  * boundary (a range must be rooted within one limit element).
22
- * * Only {@link module:engine/model/schema~Schema#isSelectable selectable elements} can be selected from the outside
22
+ * * Only {@link module:engine/model/schema~ModelSchema#isSelectable selectable elements} can be selected from the outside
23
23
  * (e.g. `[<paragraph>foo</paragraph>]` is invalid). This rule applies independently to both selection ends, so this
24
24
  * selection is correct: `<paragraph>f[oo</paragraph><imageBlock></imageBlock>]`.
25
25
  *
@@ -57,6 +57,8 @@ import Range from '../range.js';
57
57
  *
58
58
  * **Note** If the selection contains multiple ranges, the method returns a minimal set of ranges that are not intersecting after expanding
59
59
  * them to select `isLimit=true` elements.
60
+ *
61
+ * @internal
60
62
  */
61
63
  export function injectSelectionPostFixer(model) {
62
64
  model.document.registerPostFixer(writer => selectionPostFixer(writer, model));
@@ -100,6 +102,7 @@ function selectionPostFixer(writer, model) {
100
102
  * **Note:** This helper is used by the selection post-fixer and to fix the `beforeinput` target ranges.
101
103
  *
102
104
  * @returns Returns fixed range or null if range is valid.
105
+ * @internal
103
106
  */
104
107
  export function tryFixingRange(range, schema) {
105
108
  if (range.isCollapsed) {
@@ -125,7 +128,7 @@ function tryFixingCollapsedRange(range, schema) {
125
128
  if (!nearestSelectionRange) {
126
129
  const ancestorObject = originalPosition.getAncestors().reverse().find((item) => schema.isObject(item));
127
130
  if (ancestorObject) {
128
- return Range._createOn(ancestorObject);
131
+ return ModelRange._createOn(ancestorObject);
129
132
  }
130
133
  return null;
131
134
  }
@@ -137,7 +140,7 @@ function tryFixingCollapsedRange(range, schema) {
137
140
  if (originalPosition.isEqual(fixedPosition)) {
138
141
  return null;
139
142
  }
140
- return new Range(fixedPosition);
143
+ return new ModelRange(fixedPosition);
141
144
  }
142
145
  /**
143
146
  * Tries to fix an expanded range.
@@ -172,7 +175,7 @@ function tryFixingNonCollapsedRage(range, schema) {
172
175
  // The schema.getNearestSelectionRange might return null - if that happens use original position.
173
176
  const rangeStart = fixedStart ? fixedStart.start : start;
174
177
  const rangeEnd = fixedEnd ? fixedEnd.end : end;
175
- return new Range(rangeStart, rangeEnd);
178
+ return new ModelRange(rangeStart, rangeEnd);
176
179
  }
177
180
  }
178
181
  const isStartInLimit = startLimitElement && !startLimitElement.is('rootElement');
@@ -188,12 +191,12 @@ function tryFixingNonCollapsedRage(range, schema) {
188
191
  let fixedStart = start;
189
192
  let fixedEnd = end;
190
193
  if (expandStart) {
191
- fixedStart = Position._createBefore(findOutermostLimitAncestor(startLimitElement, schema));
194
+ fixedStart = ModelPosition._createBefore(findOutermostLimitAncestor(startLimitElement, schema));
192
195
  }
193
196
  if (expandEnd) {
194
- fixedEnd = Position._createAfter(findOutermostLimitAncestor(endLimitElement, schema));
197
+ fixedEnd = ModelPosition._createAfter(findOutermostLimitAncestor(endLimitElement, schema));
195
198
  }
196
- return new Range(fixedStart, fixedEnd);
199
+ return new ModelRange(fixedStart, fixedEnd);
197
200
  }
198
201
  // Range was not fixed at this point so it is valid - ie it was placed around limit element already.
199
202
  return null;
@@ -225,6 +228,7 @@ function checkSelectionOnNonLimitElements(start, end, schema) {
225
228
  *
226
229
  * @param ranges Ranges to merge.
227
230
  * @returns Array of unique and non-intersecting ranges.
231
+ * @internal
228
232
  */
229
233
  export function mergeIntersectingRanges(ranges) {
230
234
  const rangesToMerge = [...ranges];