@ckeditor/ckeditor5-engine 45.2.1 → 46.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +94 -89
- 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/view/textproxy.js
CHANGED
|
@@ -5,31 +5,32 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/textproxy
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { ViewTypeCheckable } from './typecheckable.js';
|
|
9
9
|
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* {@link module:engine/view/treewalker~
|
|
11
|
+
* ViewTextProxy is a wrapper for substring of {@link module:engine/view/text~ViewText}. Instance of this class is created by
|
|
12
|
+
* {@link module:engine/view/treewalker~ViewTreeWalker} when only a part of {@link module:engine/view/text~ViewText} needs to be returned.
|
|
13
13
|
*
|
|
14
|
-
* `
|
|
14
|
+
* `ViewTextProxy` has an API similar to {@link module:engine/view/text~ViewText Text} and allows to do most of the common tasks performed
|
|
15
15
|
* on view nodes.
|
|
16
16
|
*
|
|
17
|
-
* **Note:** Some `
|
|
18
|
-
* See {@link module:engine/view/textproxy~
|
|
17
|
+
* **Note:** Some `ViewTextProxy` instances may represent whole text node, not just a part of it.
|
|
18
|
+
* See {@link module:engine/view/textproxy~ViewTextProxy#isPartial}.
|
|
19
19
|
*
|
|
20
|
-
* **Note:** `
|
|
20
|
+
* **Note:** `ViewTextProxy` is a readonly interface.
|
|
21
21
|
*
|
|
22
|
-
* **Note:** `
|
|
22
|
+
* **Note:** `ViewTextProxy` instances are created on the fly basing
|
|
23
|
+
* on the current state of parent {@link module:engine/view/text~ViewText}.
|
|
23
24
|
* Because of this it is highly unrecommended to store references to `TextProxy instances because they might get
|
|
24
|
-
* invalidated due to operations on Document. Also
|
|
25
|
-
* inserted as a child of {@link module:engine/view/element~
|
|
25
|
+
* invalidated due to operations on Document. Also ViewTextProxy is not a {@link module:engine/view/node~ViewNode} so it cannot be
|
|
26
|
+
* inserted as a child of {@link module:engine/view/element~ViewElement}.
|
|
26
27
|
*
|
|
27
|
-
* `
|
|
28
|
-
* an instance of this class by your own.
|
|
28
|
+
* `ViewTextProxy` instances are created by {@link module:engine/view/treewalker~ViewTreeWalker view tree walker}.
|
|
29
|
+
* You should not need to create an instance of this class by your own.
|
|
29
30
|
*/
|
|
30
|
-
export
|
|
31
|
+
export class ViewTextProxy extends ViewTypeCheckable {
|
|
31
32
|
/**
|
|
32
|
-
* Reference to the {@link module:engine/view/text~
|
|
33
|
+
* Reference to the {@link module:engine/view/text~ViewText} element which ViewTextProxy is a substring.
|
|
33
34
|
*/
|
|
34
35
|
textNode;
|
|
35
36
|
/**
|
|
@@ -37,7 +38,7 @@ export default class TextProxy extends TypeCheckable {
|
|
|
37
38
|
*/
|
|
38
39
|
data;
|
|
39
40
|
/**
|
|
40
|
-
* Offset in the `textNode` where this `
|
|
41
|
+
* Offset in the `textNode` where this `ViewTextProxy` instance starts.
|
|
41
42
|
*/
|
|
42
43
|
offsetInText;
|
|
43
44
|
/**
|
|
@@ -45,7 +46,7 @@ export default class TextProxy extends TypeCheckable {
|
|
|
45
46
|
*
|
|
46
47
|
* @internal
|
|
47
48
|
* @param textNode Text node which part is represented by this text proxy.
|
|
48
|
-
* @param offsetInText Offset in {@link module:engine/view/textproxy~
|
|
49
|
+
* @param offsetInText Offset in {@link module:engine/view/textproxy~ViewTextProxy#textNode text node}
|
|
49
50
|
* from which the text proxy starts.
|
|
50
51
|
* @param length Text proxy length, that is how many text node's characters, starting from `offsetInText` it represents.
|
|
51
52
|
*/
|
|
@@ -78,11 +79,11 @@ export default class TextProxy extends TypeCheckable {
|
|
|
78
79
|
return this.data.length;
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
81
|
-
* Flag indicating whether `
|
|
82
|
+
* Flag indicating whether `ViewTextProxy` instance covers only part of the original {@link module:engine/view/text~ViewText text node}
|
|
82
83
|
* (`true`) or the whole text node (`false`).
|
|
83
84
|
*
|
|
84
|
-
* This is `false` when text proxy starts at the very beginning of {@link module:engine/view/textproxy~
|
|
85
|
-
* ({@link module:engine/view/textproxy~
|
|
85
|
+
* This is `false` when text proxy starts at the very beginning of {@link module:engine/view/textproxy~ViewTextProxy#textNode textNode}
|
|
86
|
+
* ({@link module:engine/view/textproxy~ViewTextProxy#offsetInText offsetInText} equals `0`) and text proxy sizes is equal to
|
|
86
87
|
* text node size.
|
|
87
88
|
*/
|
|
88
89
|
get isPartial() {
|
|
@@ -101,8 +102,8 @@ export default class TextProxy extends TypeCheckable {
|
|
|
101
102
|
return this.textNode.root;
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
|
-
* {@link module:engine/view/document~
|
|
105
|
-
* {@link module:engine/view/documentfragment~
|
|
105
|
+
* {@link module:engine/view/document~ViewDocument View document} that owns this text proxy, or `null` if the text proxy is inside
|
|
106
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}.
|
|
106
107
|
*/
|
|
107
108
|
get document() {
|
|
108
109
|
return this.textNode.document;
|
|
@@ -128,7 +129,7 @@ export default class TextProxy extends TypeCheckable {
|
|
|
128
129
|
}
|
|
129
130
|
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
130
131
|
// Proper overload would interfere with that.
|
|
131
|
-
|
|
132
|
+
ViewTextProxy.prototype.is = function (type) {
|
|
132
133
|
return type === '$textProxy' || type === 'view:$textProxy' ||
|
|
133
134
|
// This are legacy values kept for backward compatibility.
|
|
134
135
|
type === 'textProxy' || type === 'view:textProxy';
|
package/src/view/tokenlist.d.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module engine/view/tokenlist
|
|
7
7
|
*/
|
|
8
8
|
import { type ArrayOrItem } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ViewElementAttributeValue } from './element.js';
|
|
10
10
|
/**
|
|
11
11
|
* Token list. Allows handling (adding, removing, retrieving) a set of tokens (for example class names).
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare class ViewTokenList implements ViewElementAttributeValue {
|
|
14
14
|
/**
|
|
15
15
|
* The set of tokens.
|
|
16
16
|
*/
|
|
@@ -54,7 +54,7 @@ export default class TokenList implements ElementAttributeValue {
|
|
|
54
54
|
/**
|
|
55
55
|
* Returns `true` if both attributes have the same tokens.
|
|
56
56
|
*/
|
|
57
|
-
isSimilar(other:
|
|
57
|
+
isSimilar(other: ViewTokenList): boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Clones the attribute value.
|
|
60
60
|
*
|
|
@@ -78,32 +78,32 @@ export default class TokenList implements ElementAttributeValue {
|
|
|
78
78
|
*/
|
|
79
79
|
_getConsumables(name?: string): Array<string>;
|
|
80
80
|
/**
|
|
81
|
-
* Used by {@link module:engine/view/element~
|
|
81
|
+
* Used by {@link module:engine/view/element~ViewElement#_canMergeAttributesFrom} to verify if the given attribute
|
|
82
82
|
* can be merged without conflicts into the attribute.
|
|
83
83
|
*
|
|
84
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~
|
|
85
|
-
* an {@link module:engine/view/attributeelement~
|
|
84
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while downcasting
|
|
85
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other `AttributeElement`.
|
|
86
86
|
*
|
|
87
87
|
* @internal
|
|
88
88
|
*/
|
|
89
89
|
_canMergeFrom(): boolean;
|
|
90
90
|
/**
|
|
91
|
-
* Used by {@link module:engine/view/element~
|
|
91
|
+
* Used by {@link module:engine/view/element~ViewElement#_mergeAttributesFrom} to merge a given attribute into the attribute.
|
|
92
92
|
*
|
|
93
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~
|
|
94
|
-
* an {@link module:engine/view/attributeelement~
|
|
93
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
94
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
|
|
95
95
|
*
|
|
96
96
|
* @internal
|
|
97
97
|
*/
|
|
98
|
-
_mergeFrom(other:
|
|
98
|
+
_mergeFrom(other: ViewTokenList): void;
|
|
99
99
|
/**
|
|
100
|
-
* Used by {@link module:engine/view/element~
|
|
100
|
+
* Used by {@link module:engine/view/element~ViewElement#_canSubtractAttributesOf} to verify if the given attribute
|
|
101
101
|
* can be fully subtracted from the attribute.
|
|
102
102
|
*
|
|
103
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~
|
|
104
|
-
* an {@link module:engine/view/attributeelement~
|
|
103
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
104
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to unwrap the ViewAttributeElement.
|
|
105
105
|
*
|
|
106
106
|
* @internal
|
|
107
107
|
*/
|
|
108
|
-
_isMatching(other:
|
|
108
|
+
_isMatching(other: ViewTokenList): boolean;
|
|
109
109
|
}
|
package/src/view/tokenlist.js
CHANGED
|
@@ -9,7 +9,7 @@ import { toArray } from '@ckeditor/ckeditor5-utils';
|
|
|
9
9
|
/**
|
|
10
10
|
* Token list. Allows handling (adding, removing, retrieving) a set of tokens (for example class names).
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export class ViewTokenList {
|
|
13
13
|
/**
|
|
14
14
|
* The set of tokens.
|
|
15
15
|
*/
|
|
@@ -148,11 +148,11 @@ export default class TokenList {
|
|
|
148
148
|
return name ? [name] : this.keys();
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
* Used by {@link module:engine/view/element~
|
|
151
|
+
* Used by {@link module:engine/view/element~ViewElement#_canMergeAttributesFrom} to verify if the given attribute
|
|
152
152
|
* can be merged without conflicts into the attribute.
|
|
153
153
|
*
|
|
154
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~
|
|
155
|
-
* an {@link module:engine/view/attributeelement~
|
|
154
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while downcasting
|
|
155
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other `AttributeElement`.
|
|
156
156
|
*
|
|
157
157
|
* @internal
|
|
158
158
|
*/
|
|
@@ -160,10 +160,10 @@ export default class TokenList {
|
|
|
160
160
|
return true;
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
|
-
* Used by {@link module:engine/view/element~
|
|
163
|
+
* Used by {@link module:engine/view/element~ViewElement#_mergeAttributesFrom} to merge a given attribute into the attribute.
|
|
164
164
|
*
|
|
165
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~
|
|
166
|
-
* an {@link module:engine/view/attributeelement~
|
|
165
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
166
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
|
|
167
167
|
*
|
|
168
168
|
* @internal
|
|
169
169
|
*/
|
|
@@ -175,11 +175,11 @@ export default class TokenList {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
|
-
* Used by {@link module:engine/view/element~
|
|
178
|
+
* Used by {@link module:engine/view/element~ViewElement#_canSubtractAttributesOf} to verify if the given attribute
|
|
179
179
|
* can be fully subtracted from the attribute.
|
|
180
180
|
*
|
|
181
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~
|
|
182
|
-
* an {@link module:engine/view/attributeelement~
|
|
181
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
182
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to unwrap the ViewAttributeElement.
|
|
183
183
|
*
|
|
184
184
|
* @internal
|
|
185
185
|
*/
|
package/src/view/treewalker.d.ts
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import type
|
|
7
|
-
import type
|
|
5
|
+
import { ViewPosition } from './position.js';
|
|
6
|
+
import { type ViewItem } from './item.js';
|
|
7
|
+
import { type ViewRange } from './range.js';
|
|
8
8
|
/**
|
|
9
9
|
* Position iterator class. It allows to iterate forward and backward over the document.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export declare class ViewTreeWalker implements IterableIterator<ViewTreeWalkerValue> {
|
|
12
12
|
/**
|
|
13
13
|
* Walking direction. Defaults `'forward'`.
|
|
14
14
|
*/
|
|
15
|
-
readonly direction:
|
|
15
|
+
readonly direction: ViewTreeWalkerDirection;
|
|
16
16
|
/**
|
|
17
17
|
* Iterator boundaries.
|
|
18
18
|
*
|
|
@@ -21,10 +21,10 @@ export default class TreeWalker implements IterableIterator<TreeWalkerValue> {
|
|
|
21
21
|
*
|
|
22
22
|
* If boundaries are not defined they are set before first and after last child of the root node.
|
|
23
23
|
*/
|
|
24
|
-
readonly boundaries:
|
|
24
|
+
readonly boundaries: ViewRange | null;
|
|
25
25
|
/**
|
|
26
|
-
* Flag indicating whether all characters from {@link module:engine/view/text~
|
|
27
|
-
* {@link module:engine/view/text~
|
|
26
|
+
* Flag indicating whether all characters from {@link module:engine/view/text~ViewText} should be returned as one
|
|
27
|
+
* {@link module:engine/view/text~ViewText} or one by one as {@link module:engine/view/textproxy~ViewTextProxy}.
|
|
28
28
|
*/
|
|
29
29
|
readonly singleCharacters: boolean;
|
|
30
30
|
/**
|
|
@@ -34,7 +34,7 @@ export default class TreeWalker implements IterableIterator<TreeWalkerValue> {
|
|
|
34
34
|
readonly shallow: boolean;
|
|
35
35
|
/**
|
|
36
36
|
* Flag indicating whether iterator should ignore `elementEnd` tags. If set to `true`, walker will not
|
|
37
|
-
* return a parent node of the start position. Each {@link module:engine/view/element~
|
|
37
|
+
* return a parent node of the start position. Each {@link module:engine/view/element~ViewElement} will be returned once.
|
|
38
38
|
* When set to `false` each element might be returned twice: for `'elementStart'` and `'elementEnd'`.
|
|
39
39
|
*/
|
|
40
40
|
readonly ignoreElementEnd: boolean;
|
|
@@ -56,16 +56,16 @@ export default class TreeWalker implements IterableIterator<TreeWalkerValue> {
|
|
|
56
56
|
*
|
|
57
57
|
* @param options Object with configuration.
|
|
58
58
|
*/
|
|
59
|
-
constructor(options?:
|
|
59
|
+
constructor(options?: ViewTreeWalkerOptions);
|
|
60
60
|
/**
|
|
61
61
|
* Iterable interface.
|
|
62
62
|
*/
|
|
63
|
-
[Symbol.iterator](): IterableIterator<
|
|
63
|
+
[Symbol.iterator](): IterableIterator<ViewTreeWalkerValue>;
|
|
64
64
|
/**
|
|
65
65
|
* Iterator position. If start position is not defined then position depends on {@link #direction}. If direction is
|
|
66
66
|
* `'forward'` position starts form the beginning, when direction is `'backward'` position starts from the end.
|
|
67
67
|
*/
|
|
68
|
-
get position():
|
|
68
|
+
get position(): ViewPosition;
|
|
69
69
|
/**
|
|
70
70
|
* Moves {@link #position} in the {@link #direction} skipping values as long as the callback function returns `true`.
|
|
71
71
|
*
|
|
@@ -77,17 +77,17 @@ export default class TreeWalker implements IterableIterator<TreeWalkerValue> {
|
|
|
77
77
|
* walker.skip( value => false ); // Do not move the position.
|
|
78
78
|
* ```
|
|
79
79
|
*
|
|
80
|
-
* @param skip Callback function. Gets {@link module:engine/view/treewalker~
|
|
80
|
+
* @param skip Callback function. Gets {@link module:engine/view/treewalker~ViewTreeWalkerValue} and should
|
|
81
81
|
* return `true` if the value should be skipped or `false` if not.
|
|
82
82
|
*/
|
|
83
|
-
skip(skip: (value:
|
|
83
|
+
skip(skip: (value: ViewTreeWalkerValue) => boolean): void;
|
|
84
84
|
/**
|
|
85
85
|
* Moves tree walker {@link #position} to provided `position`. Tree walker will
|
|
86
86
|
* continue traversing from that position.
|
|
87
87
|
*
|
|
88
|
-
* Note: in contrary to {@link ~
|
|
88
|
+
* Note: in contrary to {@link ~ViewTreeWalker#skip}, this method does not iterate over the nodes along the way.
|
|
89
89
|
* It simply sets the current tree walker position to a new one.
|
|
90
|
-
* From the performance standpoint, it is better to use {@link ~
|
|
90
|
+
* From the performance standpoint, it is better to use {@link ~ViewTreeWalker#jumpTo} rather than {@link ~ViewTreeWalker#skip}.
|
|
91
91
|
*
|
|
92
92
|
* If the provided position is before the start boundary, the position will be
|
|
93
93
|
* set to the start boundary. If the provided position is after the end boundary,
|
|
@@ -96,14 +96,14 @@ export default class TreeWalker implements IterableIterator<TreeWalkerValue> {
|
|
|
96
96
|
*
|
|
97
97
|
* @param position Position to jump to.
|
|
98
98
|
*/
|
|
99
|
-
jumpTo(position:
|
|
99
|
+
jumpTo(position: ViewPosition): void;
|
|
100
100
|
/**
|
|
101
101
|
* Gets the next tree walker's value.
|
|
102
102
|
*
|
|
103
103
|
* @returns Object implementing iterator interface, returning
|
|
104
104
|
* information about taken step.
|
|
105
105
|
*/
|
|
106
|
-
next(): IteratorResult<
|
|
106
|
+
next(): IteratorResult<ViewTreeWalkerValue, undefined>;
|
|
107
107
|
/**
|
|
108
108
|
* Makes a step forward in view. Moves the {@link #position} to the next position and returns the encountered value.
|
|
109
109
|
*/
|
|
@@ -113,7 +113,8 @@ export default class TreeWalker implements IterableIterator<TreeWalkerValue> {
|
|
|
113
113
|
*/
|
|
114
114
|
private _previous;
|
|
115
115
|
/**
|
|
116
|
-
* Format returned data and adjust `previousPosition` and `nextPosition` if
|
|
116
|
+
* Format returned data and adjust `previousPosition` and `nextPosition` if
|
|
117
|
+
* reach the bound of the {@link module:engine/view/text~ViewText}.
|
|
117
118
|
*
|
|
118
119
|
* @param type Type of step.
|
|
119
120
|
* @param item Item between old and new position.
|
|
@@ -124,44 +125,44 @@ export default class TreeWalker implements IterableIterator<TreeWalkerValue> {
|
|
|
124
125
|
private _formatReturnValue;
|
|
125
126
|
}
|
|
126
127
|
/**
|
|
127
|
-
* Type of the step made by {@link module:engine/view/treewalker~
|
|
128
|
+
* Type of the step made by {@link module:engine/view/treewalker~ViewTreeWalker}.
|
|
128
129
|
* Possible values: `'elementStart'` if walker is at the beginning of a node, `'elementEnd'` if walker is at the end
|
|
129
130
|
* of node, or `'text'` if walker traversed over single and multiple characters.
|
|
130
|
-
* For {@link module:engine/view/text~
|
|
131
|
+
* For {@link module:engine/view/text~ViewText} `elementStart` and `elementEnd` is not returned.
|
|
131
132
|
*/
|
|
132
|
-
export type
|
|
133
|
+
export type ViewTreeWalkerValueType = 'elementStart' | 'elementEnd' | 'text';
|
|
133
134
|
/**
|
|
134
|
-
* Object returned by {@link module:engine/view/treewalker~
|
|
135
|
+
* Object returned by {@link module:engine/view/treewalker~ViewTreeWalker} when traversing tree view.
|
|
135
136
|
*/
|
|
136
|
-
export interface
|
|
137
|
+
export interface ViewTreeWalkerValue {
|
|
137
138
|
/**
|
|
138
|
-
* Type of the step made by {@link module:engine/view/treewalker~
|
|
139
|
+
* Type of the step made by {@link module:engine/view/treewalker~ViewTreeWalker}.
|
|
139
140
|
*/
|
|
140
|
-
type:
|
|
141
|
+
type: ViewTreeWalkerValueType;
|
|
141
142
|
/**
|
|
142
143
|
* Item between the old and the new positions of the tree walker.
|
|
143
144
|
*/
|
|
144
|
-
item:
|
|
145
|
+
item: ViewItem;
|
|
145
146
|
/**
|
|
146
147
|
* Previous position of the iterator.
|
|
147
148
|
* * Forward iteration: For `'elementEnd'` it is the last position inside the element. For all other types it is the
|
|
148
149
|
* position before the item.
|
|
149
150
|
* * Backward iteration: For `'elementStart'` it is the first position inside the element. For all other types it is
|
|
150
151
|
* the position after item.
|
|
151
|
-
* * If the position is at the beginning or at the end of the {@link module:engine/view/text~
|
|
152
|
+
* * If the position is at the beginning or at the end of the {@link module:engine/view/text~ViewText} it is always moved from the
|
|
152
153
|
* inside of the text to its parent just before or just after that text.
|
|
153
154
|
*/
|
|
154
|
-
previousPosition:
|
|
155
|
+
previousPosition: ViewPosition;
|
|
155
156
|
/**
|
|
156
157
|
* Next position of the iterator.
|
|
157
158
|
* * Forward iteration: For `'elementStart'` it is the first position inside the element. For all other types it is
|
|
158
159
|
* the position after the item.
|
|
159
160
|
* * Backward iteration: For `'elementEnd'` it is last position inside element. For all other types it is the position
|
|
160
161
|
* before the item.
|
|
161
|
-
* * If the position is at the beginning or at the end of the {@link module:engine/view/text~
|
|
162
|
+
* * If the position is at the beginning or at the end of the {@link module:engine/view/text~ViewText} it is always moved from the
|
|
162
163
|
* inside of the text to its parent just before or just after that text.
|
|
163
164
|
*/
|
|
164
|
-
nextPosition:
|
|
165
|
+
nextPosition: ViewPosition;
|
|
165
166
|
/**
|
|
166
167
|
* Length of the item. For `'elementStart'` it is `1`. For `'text'` it is
|
|
167
168
|
* the length of that text. For `'elementEnd'` it is `undefined`.
|
|
@@ -171,29 +172,30 @@ export interface TreeWalkerValue {
|
|
|
171
172
|
/**
|
|
172
173
|
* Tree walking direction.
|
|
173
174
|
*/
|
|
174
|
-
export type
|
|
175
|
+
export type ViewTreeWalkerDirection = 'forward' | 'backward';
|
|
175
176
|
/**
|
|
176
|
-
* The configuration of {@link ~
|
|
177
|
+
* The configuration of {@link ~ViewTreeWalker}.
|
|
177
178
|
*/
|
|
178
|
-
export interface
|
|
179
|
+
export interface ViewTreeWalkerOptions {
|
|
179
180
|
/**
|
|
180
181
|
* Walking direction.
|
|
181
182
|
*
|
|
182
183
|
* @default 'forward'
|
|
183
184
|
*/
|
|
184
|
-
direction?:
|
|
185
|
+
direction?: ViewTreeWalkerDirection;
|
|
185
186
|
/**
|
|
186
187
|
* Range to define boundaries of the iterator.
|
|
187
188
|
*/
|
|
188
|
-
boundaries?:
|
|
189
|
+
boundaries?: ViewRange | null;
|
|
189
190
|
/**
|
|
190
191
|
* Starting position.
|
|
191
192
|
*/
|
|
192
|
-
startPosition?:
|
|
193
|
+
startPosition?: ViewPosition;
|
|
193
194
|
/**
|
|
194
195
|
* Flag indicating whether all characters from
|
|
195
|
-
* {@link module:engine/view/text~
|
|
196
|
-
* {@link module:engine/view/
|
|
196
|
+
* {@link module:engine/view/text~ViewText} should be returned as one
|
|
197
|
+
* {@link module:engine/view/text~ViewText} (`false`) or one by one as
|
|
198
|
+
* {@link module:engine/view/textproxy~ViewTextProxy} (`true`).
|
|
197
199
|
*/
|
|
198
200
|
singleCharacters?: boolean;
|
|
199
201
|
/**
|
|
@@ -204,7 +206,7 @@ export interface TreeWalkerOptions {
|
|
|
204
206
|
/**
|
|
205
207
|
* Flag indicating whether iterator should ignore `elementEnd`
|
|
206
208
|
* tags. If the option is true walker will not return a parent node of start position. If this option is `true`
|
|
207
|
-
* each {@link module:engine/view/element~
|
|
209
|
+
* each {@link module:engine/view/element~ViewElement} will be returned once, while if the option is `false` they might be returned
|
|
208
210
|
* twice: for `'elementStart'` and `'elementEnd'`.
|
|
209
211
|
*/
|
|
210
212
|
ignoreElementEnd?: boolean;
|