@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.
- package/dist/index.js +2563 -2257
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/controller/datacontroller.d.ts +33 -32
- package/src/controller/datacontroller.js +29 -28
- package/src/controller/editingcontroller.d.ts +8 -8
- package/src/controller/editingcontroller.js +10 -10
- package/src/conversion/conversion.d.ts +18 -19
- package/src/conversion/conversion.js +4 -4
- package/src/conversion/conversionhelpers.d.ts +1 -1
- package/src/conversion/conversionhelpers.js +1 -1
- package/src/conversion/downcastdispatcher.d.ts +63 -69
- package/src/conversion/downcastdispatcher.js +16 -16
- package/src/conversion/downcasthelpers.d.ts +94 -83
- package/src/conversion/downcasthelpers.js +63 -53
- package/src/conversion/mapper.d.ts +27 -27
- package/src/conversion/mapper.js +15 -15
- package/src/conversion/modelconsumable.d.ts +26 -26
- package/src/conversion/modelconsumable.js +23 -23
- package/src/conversion/upcastdispatcher.d.ts +33 -32
- package/src/conversion/upcastdispatcher.js +19 -19
- package/src/conversion/upcasthelpers.d.ts +46 -38
- package/src/conversion/upcasthelpers.js +33 -24
- package/src/conversion/viewconsumable.d.ts +50 -45
- package/src/conversion/viewconsumable.js +32 -27
- package/src/dataprocessor/basichtmlwriter.d.ts +4 -2
- package/src/dataprocessor/basichtmlwriter.js +3 -1
- package/src/dataprocessor/dataprocessor.d.ts +7 -6
- package/src/dataprocessor/htmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/htmldataprocessor.js +6 -6
- package/src/dataprocessor/htmlwriter.d.ts +1 -1
- package/src/dataprocessor/xmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/xmldataprocessor.js +6 -6
- package/src/dev-utils/model.d.ts +25 -26
- package/src/dev-utils/model.js +35 -36
- package/src/dev-utils/operationreplayer.d.ts +5 -3
- package/src/dev-utils/operationreplayer.js +4 -2
- package/src/dev-utils/utils.d.ts +8 -0
- package/src/dev-utils/utils.js +8 -0
- package/src/dev-utils/view.d.ts +66 -63
- package/src/dev-utils/view.js +144 -134
- package/src/index.d.ts +135 -106
- package/src/index.js +120 -71
- package/src/legacyerrors.d.ts +5 -0
- package/src/legacyerrors.js +17 -0
- package/src/model/batch.d.ts +2 -15
- package/src/model/batch.js +1 -23
- package/src/model/differ.d.ts +54 -31
- package/src/model/differ.js +15 -15
- package/src/model/document.d.ts +31 -31
- package/src/model/document.js +13 -13
- package/src/model/documentfragment.d.ts +45 -45
- package/src/model/documentfragment.js +40 -40
- package/src/model/documentselection.d.ts +92 -92
- package/src/model/documentselection.js +71 -70
- package/src/model/element.d.ts +31 -31
- package/src/model/element.js +29 -29
- package/src/model/history.d.ts +3 -3
- package/src/model/history.js +2 -2
- package/src/model/item.d.ts +4 -5
- package/src/model/liveposition.d.ts +31 -31
- package/src/model/liveposition.js +18 -18
- package/src/model/liverange.d.ts +42 -38
- package/src/model/liverange.js +17 -16
- package/src/model/markercollection.d.ts +41 -40
- package/src/model/markercollection.js +22 -20
- package/src/model/model.d.ts +82 -81
- package/src/model/model.js +54 -54
- package/src/model/node.d.ts +48 -48
- package/src/model/node.js +31 -31
- package/src/model/nodelist.d.ts +17 -17
- package/src/model/nodelist.js +11 -11
- package/src/model/operation/attributeoperation.d.ts +10 -10
- package/src/model/operation/attributeoperation.js +7 -7
- package/src/model/operation/detachoperation.d.ts +11 -9
- package/src/model/operation/detachoperation.js +8 -6
- package/src/model/operation/insertoperation.d.ts +13 -13
- package/src/model/operation/insertoperation.js +15 -15
- package/src/model/operation/markeroperation.d.ts +12 -12
- package/src/model/operation/markeroperation.js +5 -5
- package/src/model/operation/mergeoperation.d.ts +16 -16
- package/src/model/operation/mergeoperation.js +18 -18
- package/src/model/operation/moveoperation.d.ts +16 -16
- package/src/model/operation/moveoperation.js +18 -15
- package/src/model/operation/nooperation.d.ts +4 -4
- package/src/model/operation/nooperation.js +2 -2
- package/src/model/operation/operation.d.ts +10 -10
- package/src/model/operation/operation.js +5 -5
- package/src/model/operation/operationfactory.d.ts +4 -4
- package/src/model/operation/operationfactory.js +12 -12
- package/src/model/operation/renameoperation.d.ts +10 -10
- package/src/model/operation/renameoperation.js +7 -7
- package/src/model/operation/rootattributeoperation.d.ts +12 -12
- package/src/model/operation/rootattributeoperation.js +8 -8
- package/src/model/operation/rootoperation.d.ts +8 -8
- package/src/model/operation/rootoperation.js +3 -3
- package/src/model/operation/splitoperation.d.ts +17 -17
- package/src/model/operation/splitoperation.js +19 -19
- package/src/model/operation/transform.d.ts +11 -8
- package/src/model/operation/transform.js +66 -49
- package/src/model/operation/utils.d.ts +24 -23
- package/src/model/operation/utils.js +20 -20
- package/src/model/position.d.ts +101 -97
- package/src/model/position.js +69 -64
- package/src/model/range.d.ts +90 -90
- package/src/model/range.js +87 -87
- package/src/model/rootelement.d.ts +11 -11
- package/src/model/rootelement.js +9 -9
- package/src/model/schema.d.ts +158 -154
- package/src/model/schema.js +93 -90
- package/src/model/selection.d.ts +73 -73
- package/src/model/selection.js +62 -62
- package/src/model/text.d.ts +11 -10
- package/src/model/text.js +11 -10
- package/src/model/textproxy.d.ts +39 -38
- package/src/model/textproxy.js +31 -30
- package/src/model/treewalker.d.ts +37 -37
- package/src/model/treewalker.js +14 -14
- package/src/model/typecheckable.d.ts +45 -45
- package/src/model/typecheckable.js +1 -1
- package/src/model/utils/autoparagraphing.d.ts +7 -7
- package/src/model/utils/deletecontent.d.ts +7 -5
- package/src/model/utils/deletecontent.js +13 -11
- package/src/model/utils/getselectedcontent.d.ts +6 -5
- package/src/model/utils/getselectedcontent.js +2 -1
- package/src/model/utils/insertcontent.d.ts +9 -8
- package/src/model/utils/insertcontent.js +41 -40
- package/src/model/utils/insertobject.d.ts +9 -9
- package/src/model/utils/insertobject.js +4 -4
- package/src/model/utils/modifyselection.d.ts +5 -4
- package/src/model/utils/modifyselection.js +12 -11
- package/src/model/utils/selection-post-fixer.d.ts +12 -8
- package/src/model/utils/selection-post-fixer.js +15 -11
- package/src/model/writer.d.ts +102 -101
- package/src/model/writer.js +99 -98
- package/src/view/attributeelement.d.ts +29 -29
- package/src/view/attributeelement.js +25 -25
- package/src/view/containerelement.d.ts +16 -15
- package/src/view/containerelement.js +15 -14
- package/src/view/datatransfer.d.ts +7 -7
- package/src/view/datatransfer.js +1 -1
- package/src/view/document.d.ts +25 -25
- package/src/view/document.js +15 -15
- package/src/view/documentfragment.d.ts +21 -21
- package/src/view/documentfragment.js +14 -14
- package/src/view/documentselection.d.ts +65 -63
- package/src/view/documentselection.js +27 -25
- package/src/view/domconverter.d.ts +96 -91
- package/src/view/domconverter.js +78 -73
- package/src/view/downcastwriter.d.ts +185 -181
- package/src/view/downcastwriter.js +222 -210
- package/src/view/editableelement.d.ts +13 -13
- package/src/view/editableelement.js +8 -8
- package/src/view/element.d.ts +75 -74
- package/src/view/element.js +58 -58
- package/src/view/elementdefinition.d.ts +3 -4
- package/src/view/emptyelement.d.ts +13 -13
- package/src/view/emptyelement.js +13 -13
- package/src/view/filler.d.ts +14 -3
- package/src/view/filler.js +12 -1
- package/src/view/item.d.ts +4 -5
- package/src/view/matcher.d.ts +22 -19
- package/src/view/matcher.js +6 -6
- package/src/view/node.d.ts +33 -33
- package/src/view/node.js +9 -9
- package/src/view/observer/arrowkeysobserver.d.ts +10 -10
- package/src/view/observer/arrowkeysobserver.js +5 -5
- package/src/view/observer/bubblingemittermixin.d.ts +5 -5
- package/src/view/observer/bubblingemittermixin.js +2 -9
- package/src/view/observer/bubblingeventinfo.d.ts +9 -9
- package/src/view/observer/bubblingeventinfo.js +1 -1
- package/src/view/observer/clickobserver.d.ts +8 -8
- package/src/view/observer/clickobserver.js +4 -4
- package/src/view/observer/compositionobserver.d.ts +19 -19
- package/src/view/observer/compositionobserver.js +6 -6
- package/src/view/observer/domeventdata.d.ts +9 -9
- package/src/view/observer/domeventdata.js +2 -2
- package/src/view/observer/domeventobserver.d.ts +3 -3
- package/src/view/observer/domeventobserver.js +5 -5
- package/src/view/observer/fakeselectionobserver.d.ts +9 -9
- package/src/view/observer/fakeselectionobserver.js +8 -8
- package/src/view/observer/focusobserver.d.ts +16 -16
- package/src/view/observer/focusobserver.js +7 -7
- package/src/view/observer/inputobserver.d.ts +18 -18
- package/src/view/observer/inputobserver.js +5 -5
- package/src/view/observer/keyobserver.d.ts +11 -11
- package/src/view/observer/keyobserver.js +3 -3
- package/src/view/observer/mouseobserver.d.ts +16 -16
- package/src/view/observer/mouseobserver.js +3 -3
- package/src/view/observer/mutationobserver.d.ts +21 -21
- package/src/view/observer/mutationobserver.js +7 -7
- package/src/view/observer/observer.d.ts +12 -12
- package/src/view/observer/observer.js +6 -6
- package/src/view/observer/selectionobserver.d.ts +33 -33
- package/src/view/observer/selectionobserver.js +14 -14
- package/src/view/observer/tabobserver.d.ts +10 -10
- package/src/view/observer/tabobserver.js +5 -5
- package/src/view/observer/touchobserver.d.ts +13 -13
- package/src/view/observer/touchobserver.js +3 -3
- package/src/view/placeholder.d.ts +21 -21
- package/src/view/placeholder.js +23 -23
- package/src/view/position.d.ts +49 -49
- package/src/view/position.js +42 -42
- package/src/view/range.d.ts +76 -74
- package/src/view/range.js +67 -65
- package/src/view/rawelement.d.ts +19 -19
- package/src/view/rawelement.js +16 -16
- package/src/view/renderer.d.ts +14 -14
- package/src/view/renderer.js +7 -7
- package/src/view/rooteditableelement.d.ts +8 -7
- package/src/view/rooteditableelement.js +7 -6
- package/src/view/selection.d.ts +66 -64
- package/src/view/selection.js +50 -48
- package/src/view/styles/background.d.ts +2 -2
- package/src/view/styles/background.js +9 -9
- package/src/view/styles/border.d.ts +2 -2
- package/src/view/styles/border.js +13 -13
- package/src/view/styles/margin.d.ts +2 -2
- package/src/view/styles/margin.js +5 -5
- package/src/view/styles/padding.d.ts +2 -2
- package/src/view/styles/padding.js +5 -5
- package/src/view/styles/utils.d.ts +24 -24
- package/src/view/styles/utils.js +25 -25
- package/src/view/stylesmap.d.ts +28 -32
- package/src/view/stylesmap.js +52 -39
- package/src/view/text.d.ts +11 -11
- package/src/view/text.js +10 -10
- package/src/view/textproxy.d.ts +33 -32
- package/src/view/textproxy.js +23 -22
- package/src/view/tokenlist.d.ts +14 -14
- package/src/view/tokenlist.js +10 -10
- package/src/view/treewalker.d.ts +42 -40
- package/src/view/treewalker.js +36 -35
- package/src/view/typecheckable.d.ts +76 -75
- package/src/view/typecheckable.js +1 -1
- package/src/view/uielement.d.ts +22 -21
- package/src/view/uielement.js +17 -16
- package/src/view/upcastwriter.d.ts +70 -70
- package/src/view/upcastwriter.js +42 -42
- package/src/view/view.d.ts +70 -69
- package/src/view/view.js +56 -55
package/src/model/position.d.ts
CHANGED
|
@@ -5,57 +5,57 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/position
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import { type
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
12
|
-
import type
|
|
13
|
-
import type InsertOperation from './operation/insertoperation.js';
|
|
14
|
-
import type
|
|
15
|
-
import type MergeOperation from './operation/mergeoperation.js';
|
|
16
|
-
import type MoveOperation from './operation/moveoperation.js';
|
|
17
|
-
import type
|
|
18
|
-
import type Operation from './operation/operation.js';
|
|
19
|
-
import type SplitOperation from './operation/splitoperation.js';
|
|
20
|
-
import type
|
|
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
22
|
* Represents a position in the model tree.
|
|
23
23
|
*
|
|
24
|
-
* A position is represented by its {@link module:engine/model/position~
|
|
25
|
-
* a {@link module:engine/model/position~
|
|
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
26
|
*
|
|
27
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~
|
|
28
|
+
* {@link module:engine/model/model~Model} and {@link module:engine/model/writer~ModelWriter}.
|
|
29
29
|
*
|
|
30
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~
|
|
31
|
+
* `foo` and `bar` has offset `3`, not `1`. See {@link module:engine/model/position~ModelPosition#path} for more information.
|
|
32
32
|
*
|
|
33
|
-
* Since a position in the model is represented by a {@link module:engine/model/position~
|
|
34
|
-
* {@link module:engine/model/position~
|
|
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
35
|
* This requirement is important for operational transformation algorithms.
|
|
36
36
|
*
|
|
37
37
|
* Also, {@link module:engine/model/operation/operation~Operation operations}
|
|
38
|
-
* kept in the {@link module:engine/model/document~
|
|
38
|
+
* kept in the {@link module:engine/model/document~ModelDocument#history document history}
|
|
39
39
|
* are storing positions (and ranges) which were correct when those operations were applied, but may not be correct
|
|
40
40
|
* after the document has changed.
|
|
41
41
|
*
|
|
42
|
-
* When changes are applied to the model, it may also happen that {@link module:engine/model/position~
|
|
42
|
+
* When changes are applied to the model, it may also happen that {@link module:engine/model/position~ModelPosition#parent position parent}
|
|
43
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~
|
|
44
|
+
* {@link module:engine/model/position~ModelPosition#parent} and some other properties and methods will throw errors.
|
|
45
45
|
*
|
|
46
46
|
* In most cases, position with wrong path is caused by an error in code, but it is sometimes needed, as described above.
|
|
47
47
|
*/
|
|
48
|
-
export
|
|
48
|
+
export declare class ModelPosition extends ModelTypeCheckable {
|
|
49
49
|
/**
|
|
50
50
|
* Root of the position path.
|
|
51
51
|
*/
|
|
52
|
-
readonly root:
|
|
52
|
+
readonly root: ModelElement | ModelDocumentFragment;
|
|
53
53
|
/**
|
|
54
54
|
* Position of the node in the tree. **Path contains offsets, not indexes.**
|
|
55
55
|
*
|
|
56
|
-
* Position can be placed before, after or in a {@link module:engine/model/node~
|
|
57
|
-
* {@link module:engine/model/node~
|
|
58
|
-
* {@link module:engine/model/node~
|
|
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
59
|
* down to the position offset in it's parent.
|
|
60
60
|
*
|
|
61
61
|
* ```
|
|
@@ -68,7 +68,7 @@ export default class Position extends TypeCheckable {
|
|
|
68
68
|
* |- bar before: [ 1, 1, 0 ] after: [ 1, 1, 3 ]
|
|
69
69
|
* ```
|
|
70
70
|
*
|
|
71
|
-
* `foo` and `bar` are representing {@link module:engine/model/text~
|
|
71
|
+
* `foo` and `bar` are representing {@link module:engine/model/text~ModelText text nodes}. Since text nodes has offset size
|
|
72
72
|
* greater than `1` you can place position offset between their start and end:
|
|
73
73
|
*
|
|
74
74
|
* ```
|
|
@@ -83,20 +83,20 @@ export default class Position extends TypeCheckable {
|
|
|
83
83
|
*/
|
|
84
84
|
readonly path: ReadonlyArray<number>;
|
|
85
85
|
/**
|
|
86
|
-
* Position stickiness. See {@link module:engine/model/position~
|
|
86
|
+
* Position stickiness. See {@link module:engine/model/position~ModelPositionStickiness}.
|
|
87
87
|
*/
|
|
88
|
-
stickiness:
|
|
88
|
+
stickiness: ModelPositionStickiness;
|
|
89
89
|
/**
|
|
90
90
|
* Creates a position.
|
|
91
91
|
*
|
|
92
92
|
* @param root Root of the position.
|
|
93
|
-
* @param path Position path. See {@link module:engine/model/position~
|
|
94
|
-
* @param stickiness Position stickiness. See {@link module:engine/model/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
95
|
*/
|
|
96
|
-
constructor(root:
|
|
96
|
+
constructor(root: ModelElement | ModelDocumentFragment, path: ReadonlyArray<number>, stickiness?: ModelPositionStickiness);
|
|
97
97
|
/**
|
|
98
|
-
* Offset at which this position is located in its {@link module:engine/model/position~
|
|
99
|
-
* to the last item in position {@link module:engine/model/position~
|
|
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
100
|
*
|
|
101
101
|
* @type {Number}
|
|
102
102
|
*/
|
|
@@ -106,37 +106,37 @@ export default class Position extends TypeCheckable {
|
|
|
106
106
|
* Parent element of this position.
|
|
107
107
|
*
|
|
108
108
|
* Keep in mind that `parent` value is calculated when the property is accessed.
|
|
109
|
-
* If {@link module:engine/model/position~
|
|
109
|
+
* If {@link module:engine/model/position~ModelPosition#path position path}
|
|
110
110
|
* leads to a non-existing element, `parent` property will throw error.
|
|
111
111
|
*
|
|
112
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
113
|
*/
|
|
114
|
-
get parent():
|
|
114
|
+
get parent(): ModelElement | ModelDocumentFragment;
|
|
115
115
|
/**
|
|
116
|
-
* Position {@link module:engine/model/position~
|
|
117
|
-
* equal to the {@link module:engine/model/node~
|
|
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
118
|
* in text node, position index is equal to the index of that text node.
|
|
119
119
|
*/
|
|
120
120
|
get index(): number;
|
|
121
121
|
/**
|
|
122
|
-
* Returns {@link module:engine/model/text~
|
|
122
|
+
* Returns {@link module:engine/model/text~ModelText text node} instance in which this position is placed or `null` if this
|
|
123
123
|
* position is not in a text node.
|
|
124
124
|
*/
|
|
125
|
-
get textNode():
|
|
125
|
+
get textNode(): ModelText | null;
|
|
126
126
|
/**
|
|
127
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
128
|
*/
|
|
129
|
-
get nodeAfter():
|
|
129
|
+
get nodeAfter(): ModelNode | null;
|
|
130
130
|
/**
|
|
131
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
132
|
*/
|
|
133
|
-
get nodeBefore():
|
|
133
|
+
get nodeBefore(): ModelNode | null;
|
|
134
134
|
/**
|
|
135
|
-
* Is `true` if position is at the beginning of its {@link module:engine/model/position~
|
|
135
|
+
* Is `true` if position is at the beginning of its {@link module:engine/model/position~ModelPosition#parent parent}, `false` otherwise.
|
|
136
136
|
*/
|
|
137
137
|
get isAtStart(): boolean;
|
|
138
138
|
/**
|
|
139
|
-
* Is `true` if position is at the end of its {@link module:engine/model/position~
|
|
139
|
+
* Is `true` if position is at the end of its {@link module:engine/model/position~ModelPosition#parent parent}, `false` otherwise.
|
|
140
140
|
*/
|
|
141
141
|
get isAtEnd(): boolean;
|
|
142
142
|
/**
|
|
@@ -148,10 +148,10 @@ export default class Position extends TypeCheckable {
|
|
|
148
148
|
*
|
|
149
149
|
* This method is safe to use it on non-existing positions (for example during operational transformation).
|
|
150
150
|
*/
|
|
151
|
-
compareWith(otherPosition:
|
|
151
|
+
compareWith(otherPosition: ModelPosition): ModelPositionRelation;
|
|
152
152
|
/**
|
|
153
153
|
* Gets the farthest position which matches the callback using
|
|
154
|
-
* {@link module:engine/model/treewalker~
|
|
154
|
+
* {@link module:engine/model/treewalker~ModelTreeWalker TreeWalker}.
|
|
155
155
|
*
|
|
156
156
|
* For example:
|
|
157
157
|
*
|
|
@@ -166,16 +166,16 @@ export default class Position extends TypeCheckable {
|
|
|
166
166
|
* // Do not move the position.
|
|
167
167
|
* ```
|
|
168
168
|
*
|
|
169
|
-
* @param skip Callback function. Gets {@link module:engine/model/treewalker~
|
|
169
|
+
* @param skip Callback function. Gets {@link module:engine/model/treewalker~ModelTreeWalkerValue} and should
|
|
170
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~
|
|
171
|
+
* @param options Object with configuration options. See {@link module:engine/model/treewalker~ModelTreeWalker}.
|
|
172
172
|
*
|
|
173
173
|
* @returns The position after the last item which matches the `skip` callback test.
|
|
174
174
|
*/
|
|
175
|
-
getLastMatchingPosition(skip: (value:
|
|
175
|
+
getLastMatchingPosition(skip: (value: ModelTreeWalkerValue) => boolean, options?: ModelTreeWalkerOptions): ModelPosition;
|
|
176
176
|
/**
|
|
177
|
-
* Returns a path to this position's parent. Parent path is equal to position
|
|
178
|
-
* but without the last item.
|
|
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
179
|
*
|
|
180
180
|
* This method is safe to use it on non-existing positions (for example during operational transformation).
|
|
181
181
|
*
|
|
@@ -187,13 +187,13 @@ export default class Position extends TypeCheckable {
|
|
|
187
187
|
*
|
|
188
188
|
* @returns Array with ancestors.
|
|
189
189
|
*/
|
|
190
|
-
getAncestors(): Array<
|
|
190
|
+
getAncestors(): Array<ModelElement | ModelDocumentFragment>;
|
|
191
191
|
/**
|
|
192
192
|
* Returns the parent element of the given name. Returns null if the position is not inside the desired parent.
|
|
193
193
|
*
|
|
194
194
|
* @param parentName The name of the parent element to find.
|
|
195
195
|
*/
|
|
196
|
-
findAncestor(parentName: string):
|
|
196
|
+
findAncestor(parentName: string): ModelElement | null;
|
|
197
197
|
/**
|
|
198
198
|
* Returns the slice of two position {@link #path paths} which is identical. The {@link #root roots}
|
|
199
199
|
* of these two paths must be identical.
|
|
@@ -203,14 +203,14 @@ export default class Position extends TypeCheckable {
|
|
|
203
203
|
* @param position The second position.
|
|
204
204
|
* @returns The common path.
|
|
205
205
|
*/
|
|
206
|
-
getCommonPath(position:
|
|
206
|
+
getCommonPath(position: ModelPosition): Array<number>;
|
|
207
207
|
/**
|
|
208
|
-
* Returns an {@link module:engine/model/element~
|
|
208
|
+
* Returns an {@link module:engine/model/element~ModelElement} or {@link module:engine/model/documentfragment~ModelDocumentFragment}
|
|
209
209
|
* which is a common ancestor of both positions. The {@link #root roots} of these two positions must be identical.
|
|
210
210
|
*
|
|
211
211
|
* @param position The second position.
|
|
212
212
|
*/
|
|
213
|
-
getCommonAncestor(position:
|
|
213
|
+
getCommonAncestor(position: ModelPosition): ModelElement | ModelDocumentFragment | null;
|
|
214
214
|
/**
|
|
215
215
|
* Returns a new instance of `Position`, that has same {@link #parent parent} but it's offset
|
|
216
216
|
* is shifted by `shift` value (can be a negative value).
|
|
@@ -220,17 +220,17 @@ export default class Position extends TypeCheckable {
|
|
|
220
220
|
* @param shift Offset shift. Can be a negative value.
|
|
221
221
|
* @returns Shifted position.
|
|
222
222
|
*/
|
|
223
|
-
getShiftedBy(shift: number):
|
|
223
|
+
getShiftedBy(shift: number): ModelPosition;
|
|
224
224
|
/**
|
|
225
225
|
* Checks whether this position is after given position.
|
|
226
226
|
*
|
|
227
227
|
* This method is safe to use it on non-existing positions (for example during operational transformation).
|
|
228
228
|
*
|
|
229
|
-
* @see module:engine/model/position~
|
|
229
|
+
* @see module:engine/model/position~ModelPosition#isBefore
|
|
230
230
|
* @param otherPosition Position to compare with.
|
|
231
231
|
* @returns True if this position is after given position.
|
|
232
232
|
*/
|
|
233
|
-
isAfter(otherPosition:
|
|
233
|
+
isAfter(otherPosition: ModelPosition): boolean;
|
|
234
234
|
/**
|
|
235
235
|
* Checks whether this position is before given position.
|
|
236
236
|
*
|
|
@@ -270,7 +270,7 @@ export default class Position extends TypeCheckable {
|
|
|
270
270
|
* @param otherPosition Position to compare with.
|
|
271
271
|
* @returns True if this position is before given position.
|
|
272
272
|
*/
|
|
273
|
-
isBefore(otherPosition:
|
|
273
|
+
isBefore(otherPosition: ModelPosition): boolean;
|
|
274
274
|
/**
|
|
275
275
|
* Checks whether this position is equal to given position.
|
|
276
276
|
*
|
|
@@ -279,7 +279,7 @@ export default class Position extends TypeCheckable {
|
|
|
279
279
|
* @param otherPosition Position to compare with.
|
|
280
280
|
* @returns True if positions are same.
|
|
281
281
|
*/
|
|
282
|
-
isEqual(otherPosition:
|
|
282
|
+
isEqual(otherPosition: ModelPosition): boolean;
|
|
283
283
|
/**
|
|
284
284
|
* Checks whether this position is touching given position. Positions touch when there are no text nodes
|
|
285
285
|
* or empty nodes in a range between them. Technically, those positions are not equal but in many cases
|
|
@@ -288,7 +288,7 @@ export default class Position extends TypeCheckable {
|
|
|
288
288
|
* @param otherPosition Position to compare with.
|
|
289
289
|
* @returns True if positions touch.
|
|
290
290
|
*/
|
|
291
|
-
isTouching(otherPosition:
|
|
291
|
+
isTouching(otherPosition: ModelPosition): boolean;
|
|
292
292
|
/**
|
|
293
293
|
* Checks if two positions are in the same parent.
|
|
294
294
|
*
|
|
@@ -297,13 +297,13 @@ export default class Position extends TypeCheckable {
|
|
|
297
297
|
* @param position Position to compare with.
|
|
298
298
|
* @returns `true` if positions have the same parent, `false` otherwise.
|
|
299
299
|
*/
|
|
300
|
-
hasSameParentAs(position:
|
|
300
|
+
hasSameParentAs(position: ModelPosition): boolean;
|
|
301
301
|
/**
|
|
302
302
|
* Returns a copy of this position that is transformed by given `operation`.
|
|
303
303
|
*
|
|
304
304
|
* The new position's parameters are updated accordingly to the effect of the `operation`.
|
|
305
305
|
*
|
|
306
|
-
* For example, if `n` nodes are inserted before the position, the returned position {@link ~
|
|
306
|
+
* For example, if `n` nodes are inserted before the position, the returned position {@link ~ModelPosition#offset} will be
|
|
307
307
|
* increased by `n`. If the position was in a merged element, it will be accordingly moved to the new element, etc.
|
|
308
308
|
*
|
|
309
309
|
* This method is safe to use it on non-existing positions (for example during operational transformation).
|
|
@@ -311,31 +311,31 @@ export default class Position extends TypeCheckable {
|
|
|
311
311
|
* @param operation Operation to transform by.
|
|
312
312
|
* @returns Transformed position.
|
|
313
313
|
*/
|
|
314
|
-
getTransformedByOperation(operation: Operation):
|
|
314
|
+
getTransformedByOperation(operation: Operation): ModelPosition;
|
|
315
315
|
/**
|
|
316
316
|
* Returns a copy of this position transformed by an insert operation.
|
|
317
317
|
*
|
|
318
318
|
* @internal
|
|
319
319
|
*/
|
|
320
|
-
_getTransformedByInsertOperation(operation: InsertOperation):
|
|
320
|
+
_getTransformedByInsertOperation(operation: InsertOperation): ModelPosition;
|
|
321
321
|
/**
|
|
322
322
|
* Returns a copy of this position transformed by a move operation.
|
|
323
323
|
*
|
|
324
324
|
* @internal
|
|
325
325
|
*/
|
|
326
|
-
_getTransformedByMoveOperation(operation: MoveOperation):
|
|
326
|
+
_getTransformedByMoveOperation(operation: MoveOperation): ModelPosition;
|
|
327
327
|
/**
|
|
328
328
|
* Returns a copy of this position transformed by a split operation.
|
|
329
329
|
*
|
|
330
330
|
* @internal
|
|
331
331
|
*/
|
|
332
|
-
_getTransformedBySplitOperation(operation: SplitOperation):
|
|
332
|
+
_getTransformedBySplitOperation(operation: SplitOperation): ModelPosition;
|
|
333
333
|
/**
|
|
334
334
|
* Returns a copy of this position transformed by merge operation.
|
|
335
335
|
*
|
|
336
336
|
* @internal
|
|
337
337
|
*/
|
|
338
|
-
_getTransformedByMergeOperation(operation: MergeOperation):
|
|
338
|
+
_getTransformedByMergeOperation(operation: MergeOperation): ModelPosition;
|
|
339
339
|
/**
|
|
340
340
|
* Returns a copy of this position that is updated by removing `howMany` nodes starting from `deletePosition`.
|
|
341
341
|
* It may happen that this position is in a removed node. If that is the case, `null` is returned instead.
|
|
@@ -345,7 +345,7 @@ export default class Position extends TypeCheckable {
|
|
|
345
345
|
* @param howMany How many nodes are removed.
|
|
346
346
|
* @returns Transformed position or `null`.
|
|
347
347
|
*/
|
|
348
|
-
_getTransformedByDeletion(deletePosition:
|
|
348
|
+
_getTransformedByDeletion(deletePosition: ModelPosition, howMany: number): ModelPosition | null;
|
|
349
349
|
/**
|
|
350
350
|
* Returns a copy of this position that is updated by inserting `howMany` nodes at `insertPosition`.
|
|
351
351
|
*
|
|
@@ -354,7 +354,7 @@ export default class Position extends TypeCheckable {
|
|
|
354
354
|
* @param howMany How many nodes are inserted.
|
|
355
355
|
* @returns Transformed position.
|
|
356
356
|
*/
|
|
357
|
-
_getTransformedByInsertion(insertPosition:
|
|
357
|
+
_getTransformedByInsertion(insertPosition: ModelPosition, howMany: number): ModelPosition;
|
|
358
358
|
/**
|
|
359
359
|
* Returns a copy of this position that is updated by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
|
|
360
360
|
*
|
|
@@ -364,7 +364,7 @@ export default class Position extends TypeCheckable {
|
|
|
364
364
|
* @param howMany How many consecutive nodes to move, starting from `sourcePosition`.
|
|
365
365
|
* @returns Transformed position.
|
|
366
366
|
*/
|
|
367
|
-
_getTransformedByMove(sourcePosition:
|
|
367
|
+
_getTransformedByMove(sourcePosition: ModelPosition, targetPosition: ModelPosition, howMany: number): ModelPosition;
|
|
368
368
|
/**
|
|
369
369
|
* Returns a new position that is a combination of this position and given positions.
|
|
370
370
|
*
|
|
@@ -394,7 +394,7 @@ export default class Position extends TypeCheckable {
|
|
|
394
394
|
* @param target Position where the range is moved.
|
|
395
395
|
* @returns Combined position.
|
|
396
396
|
*/
|
|
397
|
-
_getCombined(source:
|
|
397
|
+
_getCombined(source: ModelPosition, target: ModelPosition): ModelPosition;
|
|
398
398
|
/**
|
|
399
399
|
* @inheritDoc
|
|
400
400
|
*/
|
|
@@ -406,37 +406,38 @@ export default class Position extends TypeCheckable {
|
|
|
406
406
|
/**
|
|
407
407
|
* Creates position at the given location. The location can be specified as:
|
|
408
408
|
*
|
|
409
|
-
* * a {@link module:engine/model/position~
|
|
409
|
+
* * a {@link module:engine/model/position~ModelPosition position},
|
|
410
410
|
* * parent element and offset (offset defaults to `0`),
|
|
411
411
|
* * parent element and `'end'` (sets position at the end of that element),
|
|
412
|
-
* * {@link module:engine/model/item~
|
|
412
|
+
* * {@link module:engine/model/item~ModelItem model item} and `'before'` or `'after'` (sets position before or after given model item).
|
|
413
413
|
*
|
|
414
414
|
* This method is a shortcut to other factory methods such as:
|
|
415
415
|
*
|
|
416
|
-
* * {@link module:engine/model/position~
|
|
417
|
-
* * {@link module:engine/model/position~
|
|
416
|
+
* * {@link module:engine/model/position~ModelPosition._createBefore},
|
|
417
|
+
* * {@link module:engine/model/position~ModelPosition._createAfter}.
|
|
418
418
|
*
|
|
419
419
|
* @internal
|
|
420
|
-
* @param offset Offset or one of the flags. Used only when the first parameter
|
|
421
|
-
*
|
|
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}.
|
|
422
423
|
*/
|
|
423
|
-
static _createAt(itemOrPosition:
|
|
424
|
+
static _createAt(itemOrPosition: ModelItem | ModelPosition | ModelDocumentFragment, offset?: ModelPositionOffset, stickiness?: ModelPositionStickiness): ModelPosition;
|
|
424
425
|
/**
|
|
425
|
-
* Creates a new position, after given {@link module:engine/model/item~
|
|
426
|
+
* Creates a new position, after given {@link module:engine/model/item~ModelItem model item}.
|
|
426
427
|
*
|
|
427
428
|
* @internal
|
|
428
429
|
* @param item Item after which the position should be placed.
|
|
429
430
|
* @param stickiness Position stickiness.
|
|
430
431
|
*/
|
|
431
|
-
static _createAfter(item:
|
|
432
|
+
static _createAfter(item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness): ModelPosition;
|
|
432
433
|
/**
|
|
433
|
-
* Creates a new position, before the given {@link module:engine/model/item~
|
|
434
|
+
* Creates a new position, before the given {@link module:engine/model/item~ModelItem model item}.
|
|
434
435
|
*
|
|
435
436
|
* @internal
|
|
436
437
|
* @param item Item before which the position should be placed.
|
|
437
438
|
* @param stickiness Position stickiness.
|
|
438
439
|
*/
|
|
439
|
-
static _createBefore(item:
|
|
440
|
+
static _createBefore(item: ModelItem | ModelDocumentFragment, stickiness?: ModelPositionStickiness): ModelPosition;
|
|
440
441
|
/**
|
|
441
442
|
* Creates a `Position` instance from given plain object (i.e. parsed JSON string).
|
|
442
443
|
*
|
|
@@ -444,17 +445,17 @@ export default class Position extends TypeCheckable {
|
|
|
444
445
|
* @param doc Document object that will be position owner.
|
|
445
446
|
* @returns `Position` instance created using given plain object.
|
|
446
447
|
*/
|
|
447
|
-
static fromJSON(json: any, doc:
|
|
448
|
+
static fromJSON(json: any, doc: ModelDocument): ModelPosition;
|
|
448
449
|
}
|
|
449
450
|
/**
|
|
450
451
|
* A flag indicating whether this position is `'before'` or `'after'` or `'same'` as given position.
|
|
451
452
|
* If positions are in different roots `'different'` flag is returned.
|
|
452
453
|
*/
|
|
453
|
-
export type
|
|
454
|
+
export type ModelPositionRelation = 'before' | 'after' | 'same' | 'different';
|
|
454
455
|
/**
|
|
455
456
|
* Offset or one of the flags.
|
|
456
457
|
*/
|
|
457
|
-
export type
|
|
458
|
+
export type ModelPositionOffset = number | 'before' | 'after' | 'end';
|
|
458
459
|
/**
|
|
459
460
|
* Represents how position is "sticking" with neighbour nodes. Used to define how position should be transformed (moved)
|
|
460
461
|
* in edge cases. Possible values: `'toNone'`, `'toNext'`, `'toPrevious'`.
|
|
@@ -483,14 +484,14 @@ export type PositionOffset = number | 'before' | 'after' | 'end';
|
|
|
483
484
|
* - sticks to previous node: <p>f[oo]|</p><p>b^ar</p> -> <p>f</p><p>boo|ar</p>
|
|
484
485
|
* ```
|
|
485
486
|
*/
|
|
486
|
-
export type
|
|
487
|
+
export type ModelPositionStickiness = 'toNone' | 'toNext' | 'toPrevious';
|
|
487
488
|
/**
|
|
488
489
|
* Returns a text node at the given position.
|
|
489
490
|
*
|
|
490
491
|
* This is a helper function optimized to reuse the position parent instance for performance reasons.
|
|
491
492
|
*
|
|
492
|
-
* Normally, you should use {@link module:engine/model/position~
|
|
493
|
-
* If you start hitting performance issues with {@link module:engine/model/position~
|
|
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`}
|
|
494
495
|
* check if your algorithm does not access it multiple times (which can happen directly or indirectly via other position properties).
|
|
495
496
|
*
|
|
496
497
|
* See https://github.com/ckeditor/ckeditor5/issues/6579.
|
|
@@ -502,17 +503,18 @@ export type PositionStickiness = 'toNone' | 'toNext' | 'toPrevious';
|
|
|
502
503
|
*
|
|
503
504
|
* @param position
|
|
504
505
|
* @param positionParent The parent of the given position.
|
|
506
|
+
* @internal
|
|
505
507
|
*/
|
|
506
|
-
export declare function getTextNodeAtPosition(position:
|
|
508
|
+
export declare function getTextNodeAtPosition(position: ModelPosition, positionParent: ModelElement | ModelDocumentFragment): ModelText | null;
|
|
507
509
|
/**
|
|
508
510
|
* Returns the node after the given position.
|
|
509
511
|
*
|
|
510
512
|
* This is a helper function optimized to reuse the position parent instance and the calculation of the text node at the
|
|
511
513
|
* specific position for performance reasons.
|
|
512
514
|
*
|
|
513
|
-
* Normally, you should use {@link module:engine/model/position~
|
|
514
|
-
* If you start hitting performance issues with {@link module:engine/model/position~
|
|
515
|
-
* {@link module:engine/model/position~
|
|
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`}
|
|
516
518
|
* check if your algorithm does not access those properties multiple times
|
|
517
519
|
* (which can happen directly or indirectly via other position properties).
|
|
518
520
|
*
|
|
@@ -526,8 +528,9 @@ export declare function getTextNodeAtPosition(position: Position, positionParent
|
|
|
526
528
|
* @param position Position to check.
|
|
527
529
|
* @param positionParent The parent of the given position.
|
|
528
530
|
* @param textNode Text node at the given position.
|
|
531
|
+
* @internal
|
|
529
532
|
*/
|
|
530
|
-
export declare function getNodeAfterPosition(position:
|
|
533
|
+
export declare function getNodeAfterPosition(position: ModelPosition, positionParent: ModelElement | ModelDocumentFragment, textNode: ModelText | null): ModelNode | null;
|
|
531
534
|
/**
|
|
532
535
|
* Returns the node before the given position.
|
|
533
536
|
*
|
|
@@ -541,5 +544,6 @@ export declare function getNodeAfterPosition(position: Position, positionParent:
|
|
|
541
544
|
* @param position Position to check.
|
|
542
545
|
* @param positionParent The parent of the given position.
|
|
543
546
|
* @param textNode Text node at the given position.
|
|
547
|
+
* @internal
|
|
544
548
|
*/
|
|
545
|
-
export declare function getNodeBeforePosition(position:
|
|
549
|
+
export declare function getNodeBeforePosition(position: ModelPosition, positionParent: ModelElement | ModelDocumentFragment, textNode: ModelText | null): ModelNode | null;
|