@ckeditor/ckeditor5-engine 48.2.0 → 48.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/controller/datacontroller.d.ts +329 -328
  2. package/dist/controller/editingcontroller.d.ts +95 -94
  3. package/dist/conversion/comparemarkers.d.ts +45 -45
  4. package/dist/conversion/conversion.d.ts +474 -474
  5. package/dist/conversion/conversionhelpers.d.ts +21 -21
  6. package/dist/conversion/downcastdispatcher.d.ts +539 -538
  7. package/dist/conversion/downcasthelpers.d.ts +1129 -1129
  8. package/dist/conversion/mapper.d.ts +692 -697
  9. package/dist/conversion/modelconsumable.d.ts +196 -196
  10. package/dist/conversion/upcastdispatcher.d.ts +483 -482
  11. package/dist/conversion/upcasthelpers.d.ts +491 -491
  12. package/dist/conversion/viewconsumable.d.ts +330 -330
  13. package/dist/dataprocessor/basichtmlwriter.d.ts +15 -15
  14. package/dist/dataprocessor/dataprocessor.d.ts +57 -57
  15. package/dist/dataprocessor/htmldataprocessor.d.ts +72 -72
  16. package/dist/dataprocessor/htmlwriter.d.ts +11 -11
  17. package/dist/dataprocessor/xmldataprocessor.d.ts +86 -86
  18. package/dist/dev-utils/model.d.ts +128 -123
  19. package/dist/dev-utils/operationreplayer.d.ts +49 -49
  20. package/dist/dev-utils/utils.d.ts +33 -33
  21. package/dist/dev-utils/view.d.ts +314 -309
  22. package/dist/engineconfig.d.ts +39 -39
  23. package/dist/index.css.map +1 -1
  24. package/dist/index.d.ts +150 -150
  25. package/dist/index.js +34026 -40107
  26. package/dist/index.js.map +1 -1
  27. package/dist/legacyerrors.d.ts +0 -4
  28. package/dist/model/batch.d.ts +86 -86
  29. package/dist/model/differ.d.ts +504 -504
  30. package/dist/model/document.d.ts +265 -268
  31. package/dist/model/documentfragment.d.ts +214 -214
  32. package/dist/model/documentselection.d.ts +406 -410
  33. package/dist/model/element.d.ts +182 -182
  34. package/dist/model/history.d.ts +109 -109
  35. package/dist/model/item.d.ts +9 -9
  36. package/dist/model/liveposition.d.ts +70 -69
  37. package/dist/model/liverange.d.ts +93 -92
  38. package/dist/model/markercollection.d.ts +317 -324
  39. package/dist/model/model.d.ts +889 -909
  40. package/dist/model/node.d.ts +254 -254
  41. package/dist/model/nodelist.d.ts +110 -110
  42. package/dist/model/operation/attributeoperation.d.ts +98 -98
  43. package/dist/model/operation/detachoperation.d.ts +57 -57
  44. package/dist/model/operation/insertoperation.d.ts +85 -85
  45. package/dist/model/operation/markeroperation.d.ts +87 -87
  46. package/dist/model/operation/mergeoperation.d.ts +95 -95
  47. package/dist/model/operation/moveoperation.d.ts +97 -97
  48. package/dist/model/operation/nooperation.d.ts +33 -33
  49. package/dist/model/operation/operation.d.ts +94 -94
  50. package/dist/model/operation/operationfactory.d.ts +14 -14
  51. package/dist/model/operation/renameoperation.d.ts +78 -78
  52. package/dist/model/operation/rootattributeoperation.d.ts +93 -93
  53. package/dist/model/operation/rootoperation.d.ts +71 -71
  54. package/dist/model/operation/splitoperation.d.ts +104 -104
  55. package/dist/model/operation/transform.d.ts +91 -91
  56. package/dist/model/operation/utils.d.ts +58 -58
  57. package/dist/model/position.d.ts +535 -535
  58. package/dist/model/range.d.ts +458 -453
  59. package/dist/model/rootelement.d.ts +55 -55
  60. package/dist/model/schema.d.ts +1325 -1327
  61. package/dist/model/selection.d.ts +452 -471
  62. package/dist/model/text.d.ts +62 -62
  63. package/dist/model/textproxy.d.ts +140 -140
  64. package/dist/model/treewalker.d.ts +190 -190
  65. package/dist/model/typecheckable.d.ts +281 -281
  66. package/dist/model/utils/autoparagraphing.d.ts +29 -29
  67. package/dist/model/utils/deletecontent.d.ts +68 -68
  68. package/dist/model/utils/getselectedcontent.d.ts +27 -27
  69. package/dist/model/utils/insertcontent.d.ts +42 -42
  70. package/dist/model/utils/insertobject.d.ts +41 -41
  71. package/dist/model/utils/modifyselection.d.ts +44 -44
  72. package/dist/model/utils/selection-post-fixer.d.ts +71 -71
  73. package/dist/model/writer.d.ts +854 -854
  74. package/dist/view/attributeelement.d.ts +123 -123
  75. package/dist/view/containerelement.d.ts +49 -49
  76. package/dist/view/datatransfer.d.ts +70 -70
  77. package/dist/view/document.d.ts +175 -177
  78. package/dist/view/documentfragment.d.ts +158 -157
  79. package/dist/view/documentselection.d.ts +308 -307
  80. package/dist/view/domconverter.d.ts +612 -657
  81. package/dist/view/downcastwriter.d.ts +1006 -1006
  82. package/dist/view/editableelement.d.ts +64 -63
  83. package/dist/view/element.d.ts +754 -754
  84. package/dist/view/elementdefinition.d.ts +79 -79
  85. package/dist/view/emptyelement.d.ts +42 -42
  86. package/dist/view/filler.d.ts +75 -75
  87. package/dist/view/item.d.ts +9 -9
  88. package/dist/view/matcher.d.ts +412 -487
  89. package/dist/view/node.d.ts +164 -163
  90. package/dist/view/observer/arrowkeysobserver.d.ts +37 -37
  91. package/dist/view/observer/bubblingemittermixin.d.ts +163 -153
  92. package/dist/view/observer/bubblingeventinfo.d.ts +45 -42
  93. package/dist/view/observer/clickobserver.d.ts +36 -36
  94. package/dist/view/observer/compositionobserver.d.ts +67 -67
  95. package/dist/view/observer/domeventdata.d.ts +46 -46
  96. package/dist/view/observer/domeventobserver.d.ts +77 -74
  97. package/dist/view/observer/fakeselectionobserver.d.ts +42 -42
  98. package/dist/view/observer/focusobserver.d.ts +84 -84
  99. package/dist/view/observer/inputobserver.d.ts +76 -76
  100. package/dist/view/observer/keyobserver.d.ts +53 -53
  101. package/dist/view/observer/mouseobserver.d.ts +73 -73
  102. package/dist/view/observer/mutationobserver.d.ts +101 -101
  103. package/dist/view/observer/observer.d.ts +84 -83
  104. package/dist/view/observer/pointerobserver.d.ts +63 -63
  105. package/dist/view/observer/selectionobserver.d.ts +136 -136
  106. package/dist/view/observer/tabobserver.d.ts +38 -38
  107. package/dist/view/observer/touchobserver.d.ts +60 -60
  108. package/dist/view/placeholder.d.ts +80 -80
  109. package/dist/view/position.d.ts +187 -187
  110. package/dist/view/range.d.ts +282 -282
  111. package/dist/view/rawelement.d.ts +72 -72
  112. package/dist/view/renderer.d.ts +270 -272
  113. package/dist/view/rooteditableelement.d.ts +43 -43
  114. package/dist/view/selection.d.ts +356 -369
  115. package/dist/view/styles/background.d.ts +15 -15
  116. package/dist/view/styles/border.d.ts +27 -27
  117. package/dist/view/styles/margin.d.ts +12 -12
  118. package/dist/view/styles/padding.d.ts +12 -12
  119. package/dist/view/styles/utils.d.ts +72 -72
  120. package/dist/view/stylesmap.d.ts +715 -715
  121. package/dist/view/text.d.ts +75 -75
  122. package/dist/view/textproxy.d.ts +92 -92
  123. package/dist/view/tokenlist.d.ts +104 -104
  124. package/dist/view/treewalker.d.ts +201 -201
  125. package/dist/view/typecheckable.d.ts +445 -445
  126. package/dist/view/uielement.d.ts +93 -93
  127. package/dist/view/upcastwriter.d.ts +412 -412
  128. package/dist/view/view.d.ts +466 -469
  129. package/package.json +2 -2
@@ -1,549 +1,549 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module engine/model/position
7
- */
8
- import { ModelTypeCheckable } from './typecheckable.js';
9
- import { type ModelTreeWalkerOptions, type ModelTreeWalkerValue } from './treewalker.js';
10
- import { type ModelDocument } from './document.js';
11
- import { type ModelDocumentFragment } from './documentfragment.js';
12
- import { type ModelElement } from './element.js';
13
- import { type InsertOperation } from './operation/insertoperation.js';
14
- import { type ModelItem } from './item.js';
15
- import { type MergeOperation } from './operation/mergeoperation.js';
16
- import { type MoveOperation } from './operation/moveoperation.js';
17
- import { type ModelNode } from './node.js';
18
- import { type Operation } from './operation/operation.js';
19
- import { type SplitOperation } from './operation/splitoperation.js';
20
- import { type ModelText } from './text.js';
6
+ * @module engine/model/position
7
+ */
8
+ import { ModelTypeCheckable } from "./typecheckable.js";
9
+ import { type ModelTreeWalkerOptions, type ModelTreeWalkerValue } from "./treewalker.js";
10
+ import { type ModelDocument } from "./document.js";
11
+ import { type ModelDocumentFragment } from "./documentfragment.js";
12
+ import { type ModelElement } from "./element.js";
13
+ import { type InsertOperation } from "./operation/insertoperation.js";
14
+ import { type ModelItem } from "./item.js";
15
+ import { type MergeOperation } from "./operation/mergeoperation.js";
16
+ import { type MoveOperation } from "./operation/moveoperation.js";
17
+ import { type ModelNode } from "./node.js";
18
+ import { type Operation } from "./operation/operation.js";
19
+ import { type SplitOperation } from "./operation/splitoperation.js";
20
+ import { type ModelText } from "./text.js";
21
21
  /**
22
- * Represents a position in the model tree.
23
- *
24
- * A position is represented by its {@link module:engine/model/position~ModelPosition#root} and
25
- * a {@link module:engine/model/position~ModelPosition#path} in that root.
26
- *
27
- * You can create position instances via its constructor or the `createPosition*()` factory methods of
28
- * {@link module:engine/model/model~Model} and {@link module:engine/model/writer~ModelWriter}.
29
- *
30
- * **Note:** Position is based on offsets, not indexes. This means that a position between two text nodes
31
- * `foo` and `bar` has offset `3`, not `1`. See {@link module:engine/model/position~ModelPosition#path} for more information.
32
- *
33
- * Since a position in the model is represented by a {@link module:engine/model/position~ModelPosition#root position root} and
34
- * {@link module:engine/model/position~ModelPosition#path position path} it is possible to create positions placed in non-existing places.
35
- * This requirement is important for operational transformation algorithms.
36
- *
37
- * Also, {@link module:engine/model/operation/operation~Operation operations}
38
- * kept in the {@link module:engine/model/document~ModelDocument#history document history}
39
- * are storing positions (and ranges) which were correct when those operations were applied, but may not be correct
40
- * after the document has changed.
41
- *
42
- * When changes are applied to the model, it may also happen that {@link module:engine/model/position~ModelPosition#parent position parent}
43
- * will change even if position path has not changed. Keep in mind, that if a position leads to non-existing element,
44
- * {@link module:engine/model/position~ModelPosition#parent} and some other properties and methods will throw errors.
45
- *
46
- * In most cases, position with wrong path is caused by an error in code, but it is sometimes needed, as described above.
47
- */
22
+ * Represents a position in the model tree.
23
+ *
24
+ * A position is represented by its {@link module:engine/model/position~ModelPosition#root} and
25
+ * a {@link module:engine/model/position~ModelPosition#path} in that root.
26
+ *
27
+ * You can create position instances via its constructor or the `createPosition*()` factory methods of
28
+ * {@link module:engine/model/model~Model} and {@link module:engine/model/writer~ModelWriter}.
29
+ *
30
+ * **Note:** Position is based on offsets, not indexes. This means that a position between two text nodes
31
+ * `foo` and `bar` has offset `3`, not `1`. See {@link module:engine/model/position~ModelPosition#path} for more information.
32
+ *
33
+ * Since a position in the model is represented by a {@link module:engine/model/position~ModelPosition#root position root} and
34
+ * {@link module:engine/model/position~ModelPosition#path position path} it is possible to create positions placed in non-existing places.
35
+ * This requirement is important for operational transformation algorithms.
36
+ *
37
+ * Also, {@link module:engine/model/operation/operation~Operation operations}
38
+ * kept in the {@link module:engine/model/document~ModelDocument#history document history}
39
+ * are storing positions (and ranges) which were correct when those operations were applied, but may not be correct
40
+ * after the document has changed.
41
+ *
42
+ * When changes are applied to the model, it may also happen that {@link module:engine/model/position~ModelPosition#parent position parent}
43
+ * will change even if position path has not changed. Keep in mind, that if a position leads to non-existing element,
44
+ * {@link module:engine/model/position~ModelPosition#parent} and some other properties and methods will throw errors.
45
+ *
46
+ * In most cases, position with wrong path is caused by an error in code, but it is sometimes needed, as described above.
47
+ */
48
48
  export declare class ModelPosition extends ModelTypeCheckable {
49
- /**
50
- * Root of the position path.
51
- */
52
- readonly root: ModelElement | ModelDocumentFragment;
53
- /**
54
- * Position of the node in the tree. **Path contains offsets, not indexes.**
55
- *
56
- * Position can be placed before, after or in a {@link module:engine/model/node~ModelNode node} if that node has
57
- * {@link module:engine/model/node~ModelNode#offsetSize} greater than `1`. Items in position path are
58
- * {@link module:engine/model/node~ModelNode#startOffset starting offsets} of position ancestors, starting from direct root children,
59
- * down to the position offset in it's parent.
60
- *
61
- * ```
62
- * ROOT
63
- * |- P before: [ 0 ] after: [ 1 ]
64
- * |- UL before: [ 1 ] after: [ 2 ]
65
- * |- LI before: [ 1, 0 ] after: [ 1, 1 ]
66
- * | |- foo before: [ 1, 0, 0 ] after: [ 1, 0, 3 ]
67
- * |- LI before: [ 1, 1 ] after: [ 1, 2 ]
68
- * |- bar before: [ 1, 1, 0 ] after: [ 1, 1, 3 ]
69
- * ```
70
- *
71
- * `foo` and `bar` are representing {@link module:engine/model/text~ModelText text nodes}. Since text nodes has offset size
72
- * greater than `1` you can place position offset between their start and end:
73
- *
74
- * ```
75
- * ROOT
76
- * |- P
77
- * |- UL
78
- * |- LI
79
- * | |- f^o|o ^ has path: [ 1, 0, 1 ] | has path: [ 1, 0, 2 ]
80
- * |- LI
81
- * |- b^a|r ^ has path: [ 1, 1, 1 ] | has path: [ 1, 1, 2 ]
82
- * ```
83
- */
84
- readonly path: ReadonlyArray<number>;
85
- /**
86
- * Position stickiness. See {@link module:engine/model/position~ModelPositionStickiness}.
87
- */
88
- stickiness: ModelPositionStickiness;
89
- /**
90
- * Creates a position.
91
- *
92
- * @param root Root of the position.
93
- * @param path Position path. See {@link module:engine/model/position~ModelPosition#path}.
94
- * @param stickiness Position stickiness. See {@link module:engine/model/position~ModelPositionStickiness}.
95
- */
96
- constructor(root: ModelElement | ModelDocumentFragment, path: ReadonlyArray<number>, stickiness?: ModelPositionStickiness);
97
- /**
98
- * Offset at which this position is located in its {@link module:engine/model/position~ModelPosition#parent parent}. It is equal
99
- * to the last item in position {@link module:engine/model/position~ModelPosition#path path}.
100
- *
101
- * @type {Number}
102
- */
103
- get offset(): number;
104
- set offset(newOffset: number);
105
- /**
106
- * Parent element of this position.
107
- *
108
- * Keep in mind that `parent` value is calculated when the property is accessed.
109
- * If {@link module:engine/model/position~ModelPosition#path position path}
110
- * leads to a non-existing element, `parent` property will throw error.
111
- *
112
- * Also it is a good idea to cache `parent` property if it is used frequently in an algorithm (i.e. in a long loop).
113
- */
114
- get parent(): ModelElement | ModelDocumentFragment;
115
- /**
116
- * Position {@link module:engine/model/position~ModelPosition#offset offset} converted to an index in position's parent node. It is
117
- * equal to the {@link module:engine/model/node~ModelNode#index index} of a node after this position. If position is placed
118
- * in text node, position index is equal to the index of that text node.
119
- */
120
- get index(): number;
121
- /**
122
- * Returns {@link module:engine/model/text~ModelText text node} instance in which this position is placed or `null` if this
123
- * position is not in a text node.
124
- */
125
- get textNode(): ModelText | null;
126
- /**
127
- * Node directly after this position. Returns `null` if this position is at the end of its parent, or if it is in a text node.
128
- */
129
- get nodeAfter(): ModelNode | null;
130
- /**
131
- * Node directly before this position. Returns `null` if this position is at the start of its parent, or if it is in a text node.
132
- */
133
- get nodeBefore(): ModelNode | null;
134
- /**
135
- * Is `true` if position is at the beginning of its {@link module:engine/model/position~ModelPosition#parent parent}, `false` otherwise.
136
- */
137
- get isAtStart(): boolean;
138
- /**
139
- * Is `true` if position is at the end of its {@link module:engine/model/position~ModelPosition#parent parent}, `false` otherwise.
140
- */
141
- get isAtEnd(): boolean;
142
- /**
143
- * Checks whether the position is valid in current model tree, that is whether it points to an existing place in the model.
144
- */
145
- isValid(): boolean;
146
- /**
147
- * Checks whether this position is before or after given position.
148
- *
149
- * This method is safe to use it on non-existing positions (for example during operational transformation).
150
- */
151
- compareWith(otherPosition: ModelPosition): ModelPositionRelation;
152
- /**
153
- * Gets the farthest position which matches the callback using
154
- * {@link module:engine/model/treewalker~ModelTreeWalker TreeWalker}.
155
- *
156
- * For example:
157
- *
158
- * ```ts
159
- * getLastMatchingPosition( value => value.type == 'text' );
160
- * // <paragraph>[]foo</paragraph> -> <paragraph>foo[]</paragraph>
161
- *
162
- * getLastMatchingPosition( value => value.type == 'text', { direction: 'backward' } );
163
- * // <paragraph>foo[]</paragraph> -> <paragraph>[]foo</paragraph>
164
- *
165
- * getLastMatchingPosition( value => false );
166
- * // Do not move the position.
167
- * ```
168
- *
169
- * @param skip Callback function. Gets {@link module:engine/model/treewalker~ModelTreeWalkerValue} and should
170
- * return `true` if the value should be skipped or `false` if not.
171
- * @param options Object with configuration options. See {@link module:engine/model/treewalker~ModelTreeWalker}.
172
- *
173
- * @returns The position after the last item which matches the `skip` callback test.
174
- */
175
- getLastMatchingPosition(skip: (value: ModelTreeWalkerValue) => boolean, options?: ModelTreeWalkerOptions): ModelPosition;
176
- /**
177
- * Returns a path to this position's parent. Parent path is equal to position
178
- * {@link module:engine/model/position~ModelPosition#path path} but without the last item.
179
- *
180
- * This method is safe to use it on non-existing positions (for example during operational transformation).
181
- *
182
- * @returns Path to the parent.
183
- */
184
- getParentPath(): Array<number>;
185
- /**
186
- * Returns ancestors array of this position, that is this position's parent and its ancestors.
187
- *
188
- * @returns Array with ancestors.
189
- */
190
- getAncestors(): Array<ModelElement | ModelDocumentFragment>;
191
- /**
192
- * Returns the parent element of the given name. Returns null if the position is not inside the desired parent.
193
- *
194
- * @param parentName The name of the parent element to find.
195
- */
196
- findAncestor(parentName: string): ModelElement | null;
197
- /**
198
- * Returns the slice of two position {@link #path paths} which is identical. The {@link #root roots}
199
- * of these two paths must be identical.
200
- *
201
- * This method is safe to use it on non-existing positions (for example during operational transformation).
202
- *
203
- * @param position The second position.
204
- * @returns The common path.
205
- */
206
- getCommonPath(position: ModelPosition): Array<number>;
207
- /**
208
- * Returns an {@link module:engine/model/element~ModelElement} or {@link module:engine/model/documentfragment~ModelDocumentFragment}
209
- * which is a common ancestor of both positions. The {@link #root roots} of these two positions must be identical.
210
- *
211
- * @param position The second position.
212
- */
213
- getCommonAncestor(position: ModelPosition): ModelElement | ModelDocumentFragment | null;
214
- /**
215
- * Returns a new instance of `Position`, that has same {@link #parent parent} but it's offset
216
- * is shifted by `shift` value (can be a negative value).
217
- *
218
- * This method is safe to use it on non-existing positions (for example during operational transformation).
219
- *
220
- * @param shift Offset shift. Can be a negative value.
221
- * @returns Shifted position.
222
- */
223
- getShiftedBy(shift: number): ModelPosition;
224
- /**
225
- * Checks whether this position is after given position.
226
- *
227
- * This method is safe to use it on non-existing positions (for example during operational transformation).
228
- *
229
- * @see module:engine/model/position~ModelPosition#isBefore
230
- * @param otherPosition Position to compare with.
231
- * @returns True if this position is after given position.
232
- */
233
- isAfter(otherPosition: ModelPosition): boolean;
234
- /**
235
- * Checks whether this position is before given position.
236
- *
237
- * **Note:** watch out when using negation of the value returned by this method, because the negation will also
238
- * be `true` if positions are in different roots and you might not expect this. You should probably use
239
- * `a.isAfter( b ) || a.isEqual( b )` or `!a.isBefore( p ) && a.root == b.root` in most scenarios. If your
240
- * condition uses multiple `isAfter` and `isBefore` checks, build them so they do not use negated values, i.e.:
241
- *
242
- * ```ts
243
- * if ( a.isBefore( b ) && c.isAfter( d ) ) {
244
- * // do A.
245
- * } else {
246
- * // do B.
247
- * }
248
- * ```
249
- *
250
- * or, if you have only one if-branch:
251
- *
252
- * ```ts
253
- * if ( !( a.isBefore( b ) && c.isAfter( d ) ) {
254
- * // do B.
255
- * }
256
- * ```
257
- *
258
- * rather than:
259
- *
260
- * ```ts
261
- * if ( !a.isBefore( b ) || && !c.isAfter( d ) ) {
262
- * // do B.
263
- * } else {
264
- * // do A.
265
- * }
266
- * ```
267
- *
268
- * This method is safe to use it on non-existing positions (for example during operational transformation).
269
- *
270
- * @param otherPosition Position to compare with.
271
- * @returns True if this position is before given position.
272
- */
273
- isBefore(otherPosition: ModelPosition): boolean;
274
- /**
275
- * Checks whether this position is equal to given position.
276
- *
277
- * This method is safe to use it on non-existing positions (for example during operational transformation).
278
- *
279
- * @param otherPosition Position to compare with.
280
- * @returns True if positions are same.
281
- */
282
- isEqual(otherPosition: ModelPosition): boolean;
283
- /**
284
- * Checks whether this position is touching given position. Positions touch when there are no text nodes
285
- * or empty nodes in a range between them. Technically, those positions are not equal but in many cases
286
- * they are very similar or even indistinguishable.
287
- *
288
- * @param otherPosition Position to compare with.
289
- * @returns True if positions touch.
290
- */
291
- isTouching(otherPosition: ModelPosition): boolean;
292
- /**
293
- * Checks if two positions are in the same parent.
294
- *
295
- * This method is safe to use it on non-existing positions (for example during operational transformation).
296
- *
297
- * @param position Position to compare with.
298
- * @returns `true` if positions have the same parent, `false` otherwise.
299
- */
300
- hasSameParentAs(position: ModelPosition): boolean;
301
- /**
302
- * Returns a copy of this position that is transformed by given `operation`.
303
- *
304
- * The new position's parameters are updated accordingly to the effect of the `operation`.
305
- *
306
- * For example, if `n` nodes are inserted before the position, the returned position {@link ~ModelPosition#offset} will be
307
- * increased by `n`. If the position was in a merged element, it will be accordingly moved to the new element, etc.
308
- *
309
- * This method is safe to use it on non-existing positions (for example during operational transformation).
310
- *
311
- * @param operation Operation to transform by.
312
- * @returns Transformed position.
313
- */
314
- getTransformedByOperation(operation: Operation): ModelPosition;
315
- /**
316
- * Returns a copy of this position transformed by an insert operation.
317
- *
318
- * @internal
319
- */
320
- _getTransformedByInsertOperation(operation: InsertOperation): ModelPosition;
321
- /**
322
- * Returns a copy of this position transformed by a move operation.
323
- *
324
- * @internal
325
- */
326
- _getTransformedByMoveOperation(operation: MoveOperation): ModelPosition;
327
- /**
328
- * Returns a copy of this position transformed by a split operation.
329
- *
330
- * @internal
331
- */
332
- _getTransformedBySplitOperation(operation: SplitOperation): ModelPosition;
333
- /**
334
- * Returns a copy of this position transformed by merge operation.
335
- *
336
- * @internal
337
- */
338
- _getTransformedByMergeOperation(operation: MergeOperation): ModelPosition;
339
- /**
340
- * Returns a copy of this position that is updated by removing `howMany` nodes starting from `deletePosition`.
341
- * It may happen that this position is in a removed node. If that is the case, `null` is returned instead.
342
- *
343
- * @internal
344
- * @param deletePosition Position before the first removed node.
345
- * @param howMany How many nodes are removed.
346
- * @returns Transformed position or `null`.
347
- */
348
- _getTransformedByDeletion(deletePosition: ModelPosition, howMany: number): ModelPosition | null;
349
- /**
350
- * Returns a copy of this position that is updated by inserting `howMany` nodes at `insertPosition`.
351
- *
352
- * @internal
353
- * @param insertPosition Position where nodes are inserted.
354
- * @param howMany How many nodes are inserted.
355
- * @returns Transformed position.
356
- */
357
- _getTransformedByInsertion(insertPosition: ModelPosition, howMany: number): ModelPosition;
358
- /**
359
- * Returns a copy of this position that is updated by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
360
- *
361
- * @internal
362
- * @param sourcePosition Position before the first element to move.
363
- * @param targetPosition Position where moved elements will be inserted.
364
- * @param howMany How many consecutive nodes to move, starting from `sourcePosition`.
365
- * @returns Transformed position.
366
- */
367
- _getTransformedByMove(sourcePosition: ModelPosition, targetPosition: ModelPosition, howMany: number): ModelPosition;
368
- /**
369
- * Returns a new position that is a combination of this position and given positions.
370
- *
371
- * The combined position is a copy of this position transformed by moving a range starting at `source` position
372
- * to the `target` position. It is expected that this position is inside the moved range.
373
- *
374
- * Example:
375
- *
376
- * ```ts
377
- * let original = model.createPositionFromPath( root, [ 2, 3, 1 ] );
378
- * let source = model.createPositionFromPath( root, [ 2, 2 ] );
379
- * let target = model.createPositionFromPath( otherRoot, [ 1, 1, 3 ] );
380
- * original._getCombined( source, target ); // path is [ 1, 1, 4, 1 ], root is `otherRoot`
381
- * ```
382
- *
383
- * Explanation:
384
- *
385
- * We have a position `[ 2, 3, 1 ]` and move some nodes from `[ 2, 2 ]` to `[ 1, 1, 3 ]`. The original position
386
- * was inside moved nodes and now should point to the new place. The moved nodes will be after
387
- * positions `[ 1, 1, 3 ]`, `[ 1, 1, 4 ]`, `[ 1, 1, 5 ]`. Since our position was in the second moved node,
388
- * the transformed position will be in a sub-tree of a node at `[ 1, 1, 4 ]`. Looking at original path, we
389
- * took care of `[ 2, 3 ]` part of it. Now we have to add the rest of the original path to the transformed path.
390
- * Finally, the transformed position will point to `[ 1, 1, 4, 1 ]`.
391
- *
392
- * @internal
393
- * @param source Beginning of the moved range.
394
- * @param target Position where the range is moved.
395
- * @returns Combined position.
396
- */
397
- _getCombined(source: ModelPosition, target: ModelPosition): ModelPosition;
398
- /**
399
- * @inheritDoc
400
- */
401
- toJSON(): unknown;
402
- /**
403
- * Returns a new position that is equal to current position.
404
- */
405
- clone(): this;
406
- /**
407
- * Creates position at the given location. The location can be specified as:
408
- *
409
- * * a {@link module:engine/model/position~ModelPosition position},
410
- * * parent element and offset (offset defaults to `0`),
411
- * * parent element and `'end'` (sets position at the end of that element),
412
- * * {@link module:engine/model/item~ModelItem model item} and `'before'` or `'after'` (sets position before or after given model item).
413
- *
414
- * This method is a shortcut to other factory methods such as:
415
- *
416
- * * {@link module:engine/model/position~ModelPosition._createBefore},
417
- * * {@link module:engine/model/position~ModelPosition._createAfter}.
418
- *
419
- * @internal
420
- * @param offset Offset or one of the flags. Used only when the first parameter
421
- * is a {@link module:engine/model/item~ModelItem model item}.
422
- * @param stickiness Position stickiness. Used only when the first parameter is a {@link module:engine/model/item~ModelItem model item}.
423
- */
424
- static _createAt(itemOrPosition: ModelItem | ModelPosition | ModelDocumentFragment, offset?: ModelPositionOffset, stickiness?: ModelPositionStickiness): ModelPosition;
425
- /**
426
- * Creates a new position, after given {@link module:engine/model/item~ModelItem model item}.
427
- *
428
- * @internal
429
- * @param item Item after which the position should be placed.
430
- * @param stickiness Position stickiness.
431
- */
432
- static _createAfter(item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness): ModelPosition;
433
- /**
434
- * Creates a new position, before the given {@link module:engine/model/item~ModelItem model item}.
435
- *
436
- * @internal
437
- * @param item Item before which the position should be placed.
438
- * @param stickiness Position stickiness.
439
- */
440
- static _createBefore(item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness): ModelPosition;
441
- /**
442
- * Creates a `Position` instance from given plain object (i.e. parsed JSON string).
443
- *
444
- * @param json Plain object to be converted to `Position`.
445
- * @param doc Document object that will be position owner.
446
- * @returns `Position` instance created using given plain object.
447
- */
448
- static fromJSON(json: any, doc: ModelDocument): ModelPosition;
49
+ /**
50
+ * Root of the position path.
51
+ */
52
+ readonly root: ModelElement | ModelDocumentFragment;
53
+ /**
54
+ * Position of the node in the tree. **Path contains offsets, not indexes.**
55
+ *
56
+ * Position can be placed before, after or in a {@link module:engine/model/node~ModelNode node} if that node has
57
+ * {@link module:engine/model/node~ModelNode#offsetSize} greater than `1`. Items in position path are
58
+ * {@link module:engine/model/node~ModelNode#startOffset starting offsets} of position ancestors, starting from direct root children,
59
+ * down to the position offset in it's parent.
60
+ *
61
+ * ```
62
+ * ROOT
63
+ * |- P before: [ 0 ] after: [ 1 ]
64
+ * |- UL before: [ 1 ] after: [ 2 ]
65
+ * |- LI before: [ 1, 0 ] after: [ 1, 1 ]
66
+ * | |- foo before: [ 1, 0, 0 ] after: [ 1, 0, 3 ]
67
+ * |- LI before: [ 1, 1 ] after: [ 1, 2 ]
68
+ * |- bar before: [ 1, 1, 0 ] after: [ 1, 1, 3 ]
69
+ * ```
70
+ *
71
+ * `foo` and `bar` are representing {@link module:engine/model/text~ModelText text nodes}. Since text nodes has offset size
72
+ * greater than `1` you can place position offset between their start and end:
73
+ *
74
+ * ```
75
+ * ROOT
76
+ * |- P
77
+ * |- UL
78
+ * |- LI
79
+ * | |- f^o|o ^ has path: [ 1, 0, 1 ] | has path: [ 1, 0, 2 ]
80
+ * |- LI
81
+ * |- b^a|r ^ has path: [ 1, 1, 1 ] | has path: [ 1, 1, 2 ]
82
+ * ```
83
+ */
84
+ readonly path: ReadonlyArray<number>;
85
+ /**
86
+ * Position stickiness. See {@link module:engine/model/position~ModelPositionStickiness}.
87
+ */
88
+ stickiness: ModelPositionStickiness;
89
+ /**
90
+ * Creates a position.
91
+ *
92
+ * @param root Root of the position.
93
+ * @param path Position path. See {@link module:engine/model/position~ModelPosition#path}.
94
+ * @param stickiness Position stickiness. See {@link module:engine/model/position~ModelPositionStickiness}.
95
+ */
96
+ constructor(root: ModelElement | ModelDocumentFragment, path: ReadonlyArray<number>, stickiness?: ModelPositionStickiness);
97
+ /**
98
+ * Offset at which this position is located in its {@link module:engine/model/position~ModelPosition#parent parent}. It is equal
99
+ * to the last item in position {@link module:engine/model/position~ModelPosition#path path}.
100
+ *
101
+ * @type {Number}
102
+ */
103
+ get offset(): number;
104
+ set offset(newOffset: number);
105
+ /**
106
+ * Parent element of this position.
107
+ *
108
+ * Keep in mind that `parent` value is calculated when the property is accessed.
109
+ * If {@link module:engine/model/position~ModelPosition#path position path}
110
+ * leads to a non-existing element, `parent` property will throw error.
111
+ *
112
+ * Also it is a good idea to cache `parent` property if it is used frequently in an algorithm (i.e. in a long loop).
113
+ */
114
+ get parent(): ModelElement | ModelDocumentFragment;
115
+ /**
116
+ * Position {@link module:engine/model/position~ModelPosition#offset offset} converted to an index in position's parent node. It is
117
+ * equal to the {@link module:engine/model/node~ModelNode#index index} of a node after this position. If position is placed
118
+ * in text node, position index is equal to the index of that text node.
119
+ */
120
+ get index(): number;
121
+ /**
122
+ * Returns {@link module:engine/model/text~ModelText text node} instance in which this position is placed or `null` if this
123
+ * position is not in a text node.
124
+ */
125
+ get textNode(): ModelText | null;
126
+ /**
127
+ * Node directly after this position. Returns `null` if this position is at the end of its parent, or if it is in a text node.
128
+ */
129
+ get nodeAfter(): ModelNode | null;
130
+ /**
131
+ * Node directly before this position. Returns `null` if this position is at the start of its parent, or if it is in a text node.
132
+ */
133
+ get nodeBefore(): ModelNode | null;
134
+ /**
135
+ * Is `true` if position is at the beginning of its {@link module:engine/model/position~ModelPosition#parent parent}, `false` otherwise.
136
+ */
137
+ get isAtStart(): boolean;
138
+ /**
139
+ * Is `true` if position is at the end of its {@link module:engine/model/position~ModelPosition#parent parent}, `false` otherwise.
140
+ */
141
+ get isAtEnd(): boolean;
142
+ /**
143
+ * Checks whether the position is valid in current model tree, that is whether it points to an existing place in the model.
144
+ */
145
+ isValid(): boolean;
146
+ /**
147
+ * Checks whether this position is before or after given position.
148
+ *
149
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
150
+ */
151
+ compareWith(otherPosition: ModelPosition): ModelPositionRelation;
152
+ /**
153
+ * Gets the farthest position which matches the callback using
154
+ * {@link module:engine/model/treewalker~ModelTreeWalker TreeWalker}.
155
+ *
156
+ * For example:
157
+ *
158
+ * ```ts
159
+ * getLastMatchingPosition( value => value.type == 'text' );
160
+ * // <paragraph>[]foo</paragraph> -> <paragraph>foo[]</paragraph>
161
+ *
162
+ * getLastMatchingPosition( value => value.type == 'text', { direction: 'backward' } );
163
+ * // <paragraph>foo[]</paragraph> -> <paragraph>[]foo</paragraph>
164
+ *
165
+ * getLastMatchingPosition( value => false );
166
+ * // Do not move the position.
167
+ * ```
168
+ *
169
+ * @param skip Callback function. Gets {@link module:engine/model/treewalker~ModelTreeWalkerValue} and should
170
+ * return `true` if the value should be skipped or `false` if not.
171
+ * @param options Object with configuration options. See {@link module:engine/model/treewalker~ModelTreeWalker}.
172
+ *
173
+ * @returns The position after the last item which matches the `skip` callback test.
174
+ */
175
+ getLastMatchingPosition(skip: (value: ModelTreeWalkerValue) => boolean, options?: ModelTreeWalkerOptions): ModelPosition;
176
+ /**
177
+ * Returns a path to this position's parent. Parent path is equal to position
178
+ * {@link module:engine/model/position~ModelPosition#path path} but without the last item.
179
+ *
180
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
181
+ *
182
+ * @returns Path to the parent.
183
+ */
184
+ getParentPath(): Array<number>;
185
+ /**
186
+ * Returns ancestors array of this position, that is this position's parent and its ancestors.
187
+ *
188
+ * @returns Array with ancestors.
189
+ */
190
+ getAncestors(): Array<ModelElement | ModelDocumentFragment>;
191
+ /**
192
+ * Returns the parent element of the given name. Returns null if the position is not inside the desired parent.
193
+ *
194
+ * @param parentName The name of the parent element to find.
195
+ */
196
+ findAncestor(parentName: string): ModelElement | null;
197
+ /**
198
+ * Returns the slice of two position {@link #path paths} which is identical. The {@link #root roots}
199
+ * of these two paths must be identical.
200
+ *
201
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
202
+ *
203
+ * @param position The second position.
204
+ * @returns The common path.
205
+ */
206
+ getCommonPath(position: ModelPosition): Array<number>;
207
+ /**
208
+ * Returns an {@link module:engine/model/element~ModelElement} or {@link module:engine/model/documentfragment~ModelDocumentFragment}
209
+ * which is a common ancestor of both positions. The {@link #root roots} of these two positions must be identical.
210
+ *
211
+ * @param position The second position.
212
+ */
213
+ getCommonAncestor(position: ModelPosition): ModelElement | ModelDocumentFragment | null;
214
+ /**
215
+ * Returns a new instance of `Position`, that has same {@link #parent parent} but it's offset
216
+ * is shifted by `shift` value (can be a negative value).
217
+ *
218
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
219
+ *
220
+ * @param shift Offset shift. Can be a negative value.
221
+ * @returns Shifted position.
222
+ */
223
+ getShiftedBy(shift: number): ModelPosition;
224
+ /**
225
+ * Checks whether this position is after given position.
226
+ *
227
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
228
+ *
229
+ * @see module:engine/model/position~ModelPosition#isBefore
230
+ * @param otherPosition Position to compare with.
231
+ * @returns True if this position is after given position.
232
+ */
233
+ isAfter(otherPosition: ModelPosition): boolean;
234
+ /**
235
+ * Checks whether this position is before given position.
236
+ *
237
+ * **Note:** watch out when using negation of the value returned by this method, because the negation will also
238
+ * be `true` if positions are in different roots and you might not expect this. You should probably use
239
+ * `a.isAfter( b ) || a.isEqual( b )` or `!a.isBefore( p ) && a.root == b.root` in most scenarios. If your
240
+ * condition uses multiple `isAfter` and `isBefore` checks, build them so they do not use negated values, i.e.:
241
+ *
242
+ * ```ts
243
+ * if ( a.isBefore( b ) && c.isAfter( d ) ) {
244
+ * // do A.
245
+ * } else {
246
+ * // do B.
247
+ * }
248
+ * ```
249
+ *
250
+ * or, if you have only one if-branch:
251
+ *
252
+ * ```ts
253
+ * if ( !( a.isBefore( b ) && c.isAfter( d ) ) {
254
+ * // do B.
255
+ * }
256
+ * ```
257
+ *
258
+ * rather than:
259
+ *
260
+ * ```ts
261
+ * if ( !a.isBefore( b ) || && !c.isAfter( d ) ) {
262
+ * // do B.
263
+ * } else {
264
+ * // do A.
265
+ * }
266
+ * ```
267
+ *
268
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
269
+ *
270
+ * @param otherPosition Position to compare with.
271
+ * @returns True if this position is before given position.
272
+ */
273
+ isBefore(otherPosition: ModelPosition): boolean;
274
+ /**
275
+ * Checks whether this position is equal to given position.
276
+ *
277
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
278
+ *
279
+ * @param otherPosition Position to compare with.
280
+ * @returns True if positions are same.
281
+ */
282
+ isEqual(otherPosition: ModelPosition): boolean;
283
+ /**
284
+ * Checks whether this position is touching given position. Positions touch when there are no text nodes
285
+ * or empty nodes in a range between them. Technically, those positions are not equal but in many cases
286
+ * they are very similar or even indistinguishable.
287
+ *
288
+ * @param otherPosition Position to compare with.
289
+ * @returns True if positions touch.
290
+ */
291
+ isTouching(otherPosition: ModelPosition): boolean;
292
+ /**
293
+ * Checks if two positions are in the same parent.
294
+ *
295
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
296
+ *
297
+ * @param position Position to compare with.
298
+ * @returns `true` if positions have the same parent, `false` otherwise.
299
+ */
300
+ hasSameParentAs(position: ModelPosition): boolean;
301
+ /**
302
+ * Returns a copy of this position that is transformed by given `operation`.
303
+ *
304
+ * The new position's parameters are updated accordingly to the effect of the `operation`.
305
+ *
306
+ * For example, if `n` nodes are inserted before the position, the returned position {@link ~ModelPosition#offset} will be
307
+ * increased by `n`. If the position was in a merged element, it will be accordingly moved to the new element, etc.
308
+ *
309
+ * This method is safe to use it on non-existing positions (for example during operational transformation).
310
+ *
311
+ * @param operation Operation to transform by.
312
+ * @returns Transformed position.
313
+ */
314
+ getTransformedByOperation(operation: Operation): ModelPosition;
315
+ /**
316
+ * Returns a copy of this position transformed by an insert operation.
317
+ *
318
+ * @internal
319
+ */
320
+ _getTransformedByInsertOperation(operation: InsertOperation): ModelPosition;
321
+ /**
322
+ * Returns a copy of this position transformed by a move operation.
323
+ *
324
+ * @internal
325
+ */
326
+ _getTransformedByMoveOperation(operation: MoveOperation): ModelPosition;
327
+ /**
328
+ * Returns a copy of this position transformed by a split operation.
329
+ *
330
+ * @internal
331
+ */
332
+ _getTransformedBySplitOperation(operation: SplitOperation): ModelPosition;
333
+ /**
334
+ * Returns a copy of this position transformed by merge operation.
335
+ *
336
+ * @internal
337
+ */
338
+ _getTransformedByMergeOperation(operation: MergeOperation): ModelPosition;
339
+ /**
340
+ * Returns a copy of this position that is updated by removing `howMany` nodes starting from `deletePosition`.
341
+ * It may happen that this position is in a removed node. If that is the case, `null` is returned instead.
342
+ *
343
+ * @internal
344
+ * @param deletePosition Position before the first removed node.
345
+ * @param howMany How many nodes are removed.
346
+ * @returns Transformed position or `null`.
347
+ */
348
+ _getTransformedByDeletion(deletePosition: ModelPosition, howMany: number): ModelPosition | null;
349
+ /**
350
+ * Returns a copy of this position that is updated by inserting `howMany` nodes at `insertPosition`.
351
+ *
352
+ * @internal
353
+ * @param insertPosition Position where nodes are inserted.
354
+ * @param howMany How many nodes are inserted.
355
+ * @returns Transformed position.
356
+ */
357
+ _getTransformedByInsertion(insertPosition: ModelPosition, howMany: number): ModelPosition;
358
+ /**
359
+ * Returns a copy of this position that is updated by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
360
+ *
361
+ * @internal
362
+ * @param sourcePosition Position before the first element to move.
363
+ * @param targetPosition Position where moved elements will be inserted.
364
+ * @param howMany How many consecutive nodes to move, starting from `sourcePosition`.
365
+ * @returns Transformed position.
366
+ */
367
+ _getTransformedByMove(sourcePosition: ModelPosition, targetPosition: ModelPosition, howMany: number): ModelPosition;
368
+ /**
369
+ * Returns a new position that is a combination of this position and given positions.
370
+ *
371
+ * The combined position is a copy of this position transformed by moving a range starting at `source` position
372
+ * to the `target` position. It is expected that this position is inside the moved range.
373
+ *
374
+ * Example:
375
+ *
376
+ * ```ts
377
+ * let original = model.createPositionFromPath( root, [ 2, 3, 1 ] );
378
+ * let source = model.createPositionFromPath( root, [ 2, 2 ] );
379
+ * let target = model.createPositionFromPath( otherRoot, [ 1, 1, 3 ] );
380
+ * original._getCombined( source, target ); // path is [ 1, 1, 4, 1 ], root is `otherRoot`
381
+ * ```
382
+ *
383
+ * Explanation:
384
+ *
385
+ * We have a position `[ 2, 3, 1 ]` and move some nodes from `[ 2, 2 ]` to `[ 1, 1, 3 ]`. The original position
386
+ * was inside moved nodes and now should point to the new place. The moved nodes will be after
387
+ * positions `[ 1, 1, 3 ]`, `[ 1, 1, 4 ]`, `[ 1, 1, 5 ]`. Since our position was in the second moved node,
388
+ * the transformed position will be in a sub-tree of a node at `[ 1, 1, 4 ]`. Looking at original path, we
389
+ * took care of `[ 2, 3 ]` part of it. Now we have to add the rest of the original path to the transformed path.
390
+ * Finally, the transformed position will point to `[ 1, 1, 4, 1 ]`.
391
+ *
392
+ * @internal
393
+ * @param source Beginning of the moved range.
394
+ * @param target Position where the range is moved.
395
+ * @returns Combined position.
396
+ */
397
+ _getCombined(source: ModelPosition, target: ModelPosition): ModelPosition;
398
+ /**
399
+ * @inheritDoc
400
+ */
401
+ toJSON(): unknown;
402
+ /**
403
+ * Returns a new position that is equal to current position.
404
+ */
405
+ clone(): this;
406
+ /**
407
+ * Creates position at the given location. The location can be specified as:
408
+ *
409
+ * * a {@link module:engine/model/position~ModelPosition position},
410
+ * * parent element and offset (offset defaults to `0`),
411
+ * * parent element and `'end'` (sets position at the end of that element),
412
+ * * {@link module:engine/model/item~ModelItem model item} and `'before'` or `'after'` (sets position before or after given model item).
413
+ *
414
+ * This method is a shortcut to other factory methods such as:
415
+ *
416
+ * * {@link module:engine/model/position~ModelPosition._createBefore},
417
+ * * {@link module:engine/model/position~ModelPosition._createAfter}.
418
+ *
419
+ * @internal
420
+ * @param offset Offset or one of the flags. Used only when the first parameter
421
+ * is a {@link module:engine/model/item~ModelItem model item}.
422
+ * @param stickiness Position stickiness. Used only when the first parameter is a {@link module:engine/model/item~ModelItem model item}.
423
+ */
424
+ static _createAt(itemOrPosition: ModelItem | ModelPosition | ModelDocumentFragment, offset?: ModelPositionOffset, stickiness?: ModelPositionStickiness): ModelPosition;
425
+ /**
426
+ * Creates a new position, after given {@link module:engine/model/item~ModelItem model item}.
427
+ *
428
+ * @internal
429
+ * @param item Item after which the position should be placed.
430
+ * @param stickiness Position stickiness.
431
+ */
432
+ static _createAfter(item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness): ModelPosition;
433
+ /**
434
+ * Creates a new position, before the given {@link module:engine/model/item~ModelItem model item}.
435
+ *
436
+ * @internal
437
+ * @param item Item before which the position should be placed.
438
+ * @param stickiness Position stickiness.
439
+ */
440
+ static _createBefore(item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness): ModelPosition;
441
+ /**
442
+ * Creates a `Position` instance from given plain object (i.e. parsed JSON string).
443
+ *
444
+ * @param json Plain object to be converted to `Position`.
445
+ * @param doc Document object that will be position owner.
446
+ * @returns `Position` instance created using given plain object.
447
+ */
448
+ static fromJSON(json: any, doc: ModelDocument): ModelPosition;
449
449
  }
450
450
  /**
451
- * A flag indicating whether this position is `'before'` or `'after'` or `'same'` as given position.
452
- * If positions are in different roots `'different'` flag is returned.
453
- */
454
- export type ModelPositionRelation = 'before' | 'after' | 'same' | 'different';
451
+ * A flag indicating whether this position is `'before'` or `'after'` or `'same'` as given position.
452
+ * If positions are in different roots `'different'` flag is returned.
453
+ */
454
+ export type ModelPositionRelation = "before" | "after" | "same" | "different";
455
455
  /**
456
- * Offset or one of the flags.
457
- */
458
- export type ModelPositionOffset = number | 'before' | 'after' | 'end';
456
+ * Offset or one of the flags.
457
+ */
458
+ export type ModelPositionOffset = number | "before" | "after" | "end";
459
459
  /**
460
- * Represents how position is "sticking" with neighbour nodes. Used to define how position should be transformed (moved)
461
- * in edge cases. Possible values: `'toNone'`, `'toNext'`, `'toPrevious'`.
462
- *
463
- * Examples:
464
- *
465
- * ```
466
- * Insert. Position is at | and nodes are inserted at the same position, marked as ^:
467
- *
468
- * - sticks to none: <p>f^|oo</p> -> <p>fbar|oo</p>
469
- * - sticks to next node: <p>f^|oo</p> -> <p>fbar|oo</p>
470
- * - sticks to previous node: <p>f|^oo</p> -> <p>f|baroo</p>
471
- * ```
472
- *
473
- *
474
- * Move. Position is at | and range [oo] is moved to position ^:
475
- *
476
- * ```
477
- * - sticks to none: <p>f|[oo]</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
478
- * - sticks to none: <p>f[oo]|</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
479
- *
480
- * - sticks to next node: <p>f|[oo]</p><p>b^ar</p> -> <p>f</p><p>b|ooar</p>
481
- * - sticks to next node: <p>f[oo]|</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
482
- *
483
- * - sticks to previous node: <p>f|[oo]</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
484
- * - sticks to previous node: <p>f[oo]|</p><p>b^ar</p> -> <p>f</p><p>boo|ar</p>
485
- * ```
486
- */
487
- export type ModelPositionStickiness = 'toNone' | 'toNext' | 'toPrevious';
460
+ * Represents how position is "sticking" with neighbour nodes. Used to define how position should be transformed (moved)
461
+ * in edge cases. Possible values: `'toNone'`, `'toNext'`, `'toPrevious'`.
462
+ *
463
+ * Examples:
464
+ *
465
+ * ```
466
+ * Insert. Position is at | and nodes are inserted at the same position, marked as ^:
467
+ *
468
+ * - sticks to none: <p>f^|oo</p> -> <p>fbar|oo</p>
469
+ * - sticks to next node: <p>f^|oo</p> -> <p>fbar|oo</p>
470
+ * - sticks to previous node: <p>f|^oo</p> -> <p>f|baroo</p>
471
+ * ```
472
+ *
473
+ *
474
+ * Move. Position is at | and range [oo] is moved to position ^:
475
+ *
476
+ * ```
477
+ * - sticks to none: <p>f|[oo]</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
478
+ * - sticks to none: <p>f[oo]|</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
479
+ *
480
+ * - sticks to next node: <p>f|[oo]</p><p>b^ar</p> -> <p>f</p><p>b|ooar</p>
481
+ * - sticks to next node: <p>f[oo]|</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
482
+ *
483
+ * - sticks to previous node: <p>f|[oo]</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
484
+ * - sticks to previous node: <p>f[oo]|</p><p>b^ar</p> -> <p>f</p><p>boo|ar</p>
485
+ * ```
486
+ */
487
+ export type ModelPositionStickiness = "toNone" | "toNext" | "toPrevious";
488
488
  /**
489
- * Returns a text node at the given position.
490
- *
491
- * This is a helper function optimized to reuse the position parent instance for performance reasons.
492
- *
493
- * Normally, you should use {@link module:engine/model/position~ModelPosition#textNode `Position#textNode`}.
494
- * If you start hitting performance issues with {@link module:engine/model/position~ModelPosition#parent `Position#parent`}
495
- * check if your algorithm does not access it multiple times (which can happen directly or indirectly via other position properties).
496
- *
497
- * See https://github.com/ckeditor/ckeditor5/issues/6579.
498
- *
499
- * See also:
500
- *
501
- * * {@link module:engine/model/position~getNodeAfterPosition}
502
- * * {@link module:engine/model/position~getNodeBeforePosition}
503
- *
504
- * @param position
505
- * @param positionParent The parent of the given position.
506
- * @internal
507
- */
489
+ * Returns a text node at the given position.
490
+ *
491
+ * This is a helper function optimized to reuse the position parent instance for performance reasons.
492
+ *
493
+ * Normally, you should use {@link module:engine/model/position~ModelPosition#textNode `Position#textNode`}.
494
+ * If you start hitting performance issues with {@link module:engine/model/position~ModelPosition#parent `Position#parent`}
495
+ * check if your algorithm does not access it multiple times (which can happen directly or indirectly via other position properties).
496
+ *
497
+ * See https://github.com/ckeditor/ckeditor5/issues/6579.
498
+ *
499
+ * See also:
500
+ *
501
+ * * {@link module:engine/model/position~getNodeAfterPosition}
502
+ * * {@link module:engine/model/position~getNodeBeforePosition}
503
+ *
504
+ * @param position
505
+ * @param positionParent The parent of the given position.
506
+ * @internal
507
+ */
508
508
  export declare function getTextNodeAtPosition(position: ModelPosition, positionParent: ModelElement | ModelDocumentFragment): ModelText | null;
509
509
  /**
510
- * Returns the node after the given position.
511
- *
512
- * This is a helper function optimized to reuse the position parent instance and the calculation of the text node at the
513
- * specific position for performance reasons.
514
- *
515
- * Normally, you should use {@link module:engine/model/position~ModelPosition#nodeAfter `Position#nodeAfter`}.
516
- * If you start hitting performance issues with {@link module:engine/model/position~ModelPosition#parent `Position#parent`} and/or
517
- * {@link module:engine/model/position~ModelPosition#textNode `Position#textNode`}
518
- * check if your algorithm does not access those properties multiple times
519
- * (which can happen directly or indirectly via other position properties).
520
- *
521
- * See https://github.com/ckeditor/ckeditor5/issues/6579 and https://github.com/ckeditor/ckeditor5/issues/6582.
522
- *
523
- * See also:
524
- *
525
- * * {@link module:engine/model/position~getTextNodeAtPosition}
526
- * * {@link module:engine/model/position~getNodeBeforePosition}
527
- *
528
- * @param position Position to check.
529
- * @param positionParent The parent of the given position.
530
- * @param textNode Text node at the given position.
531
- * @internal
532
- */
510
+ * Returns the node after the given position.
511
+ *
512
+ * This is a helper function optimized to reuse the position parent instance and the calculation of the text node at the
513
+ * specific position for performance reasons.
514
+ *
515
+ * Normally, you should use {@link module:engine/model/position~ModelPosition#nodeAfter `Position#nodeAfter`}.
516
+ * If you start hitting performance issues with {@link module:engine/model/position~ModelPosition#parent `Position#parent`} and/or
517
+ * {@link module:engine/model/position~ModelPosition#textNode `Position#textNode`}
518
+ * check if your algorithm does not access those properties multiple times
519
+ * (which can happen directly or indirectly via other position properties).
520
+ *
521
+ * See https://github.com/ckeditor/ckeditor5/issues/6579 and https://github.com/ckeditor/ckeditor5/issues/6582.
522
+ *
523
+ * See also:
524
+ *
525
+ * * {@link module:engine/model/position~getTextNodeAtPosition}
526
+ * * {@link module:engine/model/position~getNodeBeforePosition}
527
+ *
528
+ * @param position Position to check.
529
+ * @param positionParent The parent of the given position.
530
+ * @param textNode Text node at the given position.
531
+ * @internal
532
+ */
533
533
  export declare function getNodeAfterPosition(position: ModelPosition, positionParent: ModelElement | ModelDocumentFragment, textNode: ModelText | null): ModelNode | null;
534
534
  /**
535
- * Returns the node before the given position.
536
- *
537
- * Refer to {@link module:engine/model/position~getNodeBeforePosition} for documentation on when to use this util method.
538
- *
539
- * See also:
540
- *
541
- * * {@link module:engine/model/position~getTextNodeAtPosition}
542
- * * {@link module:engine/model/position~getNodeAfterPosition}
543
- *
544
- * @param position Position to check.
545
- * @param positionParent The parent of the given position.
546
- * @param textNode Text node at the given position.
547
- * @internal
548
- */
535
+ * Returns the node before the given position.
536
+ *
537
+ * Refer to {@link module:engine/model/position~getNodeBeforePosition} for documentation on when to use this util method.
538
+ *
539
+ * See also:
540
+ *
541
+ * * {@link module:engine/model/position~getTextNodeAtPosition}
542
+ * * {@link module:engine/model/position~getNodeAfterPosition}
543
+ *
544
+ * @param position Position to check.
545
+ * @param positionParent The parent of the given position.
546
+ * @param textNode Text node at the given position.
547
+ * @internal
548
+ */
549
549
  export declare function getNodeBeforePosition(position: ModelPosition, positionParent: ModelElement | ModelDocumentFragment, textNode: ModelText | null): ModelNode | null;