@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/range.js
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/range
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
8
|
+
import { ViewTypeCheckable } from './typecheckable.js';
|
|
9
|
+
import { ViewPosition } from './position.js';
|
|
10
|
+
import { ViewTreeWalker } from './treewalker.js';
|
|
11
11
|
/**
|
|
12
|
-
* Range in the view tree. A range is represented by its start and end {@link module:engine/view/position~
|
|
12
|
+
* Range in the view tree. A range is represented by its start and end {@link module:engine/view/position~ViewPosition positions}.
|
|
13
13
|
*
|
|
14
14
|
* In order to create a new position instance use the `createPosition*()` factory methods available in:
|
|
15
15
|
*
|
|
16
|
-
* * {@link module:engine/view/view~
|
|
17
|
-
* * {@link module:engine/view/downcastwriter~
|
|
18
|
-
* * {@link module:engine/view/upcastwriter~
|
|
16
|
+
* * {@link module:engine/view/view~EditingView}
|
|
17
|
+
* * {@link module:engine/view/downcastwriter~ViewDowncastWriter}
|
|
18
|
+
* * {@link module:engine/view/upcastwriter~ViewUpcastWriter}
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export class ViewRange extends ViewTypeCheckable {
|
|
21
21
|
/**
|
|
22
22
|
* Start position.
|
|
23
23
|
*/
|
|
@@ -29,7 +29,7 @@ export default class Range extends TypeCheckable {
|
|
|
29
29
|
/**
|
|
30
30
|
* Creates a range spanning from `start` position to `end` position.
|
|
31
31
|
*
|
|
32
|
-
* **Note:** Constructor creates it's own {@link module:engine/view/position~
|
|
32
|
+
* **Note:** Constructor creates it's own {@link module:engine/view/position~ViewPosition} instances basing on passed values.
|
|
33
33
|
*
|
|
34
34
|
* @param start Start position.
|
|
35
35
|
* @param end End position. If not set, range will be collapsed at the `start` position.
|
|
@@ -42,16 +42,16 @@ export default class Range extends TypeCheckable {
|
|
|
42
42
|
/**
|
|
43
43
|
* Iterable interface.
|
|
44
44
|
*
|
|
45
|
-
* Iterates over all {@link module:engine/view/item~
|
|
46
|
-
* them together with additional information like length or {@link module:engine/view/position~
|
|
47
|
-
* grouped as {@link module:engine/view/treewalker~
|
|
45
|
+
* Iterates over all {@link module:engine/view/item~ViewItem view items} that are in this range and returns
|
|
46
|
+
* them together with additional information like length or {@link module:engine/view/position~ViewPosition positions},
|
|
47
|
+
* grouped as {@link module:engine/view/treewalker~ViewTreeWalkerValue}.
|
|
48
48
|
*
|
|
49
|
-
* This iterator uses {@link module:engine/view/treewalker~
|
|
49
|
+
* This iterator uses {@link module:engine/view/treewalker~ViewTreeWalker TreeWalker} with `boundaries` set to this range and
|
|
50
50
|
* `ignoreElementEnd` option
|
|
51
51
|
* set to `true`.
|
|
52
52
|
*/
|
|
53
53
|
*[Symbol.iterator]() {
|
|
54
|
-
yield* new
|
|
54
|
+
yield* new ViewTreeWalker({ boundaries: this, ignoreElementEnd: true });
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Returns whether the range is collapsed, that is it start and end positions are equal.
|
|
@@ -60,8 +60,9 @@ export default class Range extends TypeCheckable {
|
|
|
60
60
|
return this.start.isEqual(this.end);
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* Returns whether this range is flat, that is if {@link module:engine/view/range~
|
|
64
|
-
* {@link module:engine/view/range~
|
|
63
|
+
* Returns whether this range is flat, that is if {@link module:engine/view/range~ViewRange#start start} position and
|
|
64
|
+
* {@link module:engine/view/range~ViewRange#end end} position are in the same
|
|
65
|
+
* {@link module:engine/view/position~ViewPosition#parent parent}.
|
|
65
66
|
*/
|
|
66
67
|
get isFlat() {
|
|
67
68
|
return this.start.parent === this.end.parent;
|
|
@@ -85,9 +86,9 @@ export default class Range extends TypeCheckable {
|
|
|
85
86
|
*
|
|
86
87
|
* Note that in the sample above:
|
|
87
88
|
*
|
|
88
|
-
* - `<p>` have type of {@link module:engine/view/containerelement~
|
|
89
|
-
* - `<b>` have type of {@link module:engine/view/attributeelement~
|
|
90
|
-
* - `<span>` have type of {@link module:engine/view/uielement~
|
|
89
|
+
* - `<p>` have type of {@link module:engine/view/containerelement~ViewContainerElement},
|
|
90
|
+
* - `<b>` have type of {@link module:engine/view/attributeelement~ViewAttributeElement},
|
|
91
|
+
* - `<span>` have type of {@link module:engine/view/uielement~ViewUIElement}.
|
|
91
92
|
*
|
|
92
93
|
* @returns Enlarged range.
|
|
93
94
|
*/
|
|
@@ -96,12 +97,12 @@ export default class Range extends TypeCheckable {
|
|
|
96
97
|
let end = this.end.getLastMatchingPosition(enlargeTrimSkip);
|
|
97
98
|
// Fix positions, in case if they are in Text node.
|
|
98
99
|
if (start.parent.is('$text') && start.isAtStart) {
|
|
99
|
-
start =
|
|
100
|
+
start = ViewPosition._createBefore(start.parent);
|
|
100
101
|
}
|
|
101
102
|
if (end.parent.is('$text') && end.isAtEnd) {
|
|
102
|
-
end =
|
|
103
|
+
end = ViewPosition._createAfter(end.parent);
|
|
103
104
|
}
|
|
104
|
-
return new
|
|
105
|
+
return new ViewRange(start, end);
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* Creates a minimum range that has the same content as this range but is trimmed in both ways (at the beginning
|
|
@@ -116,28 +117,28 @@ export default class Range extends TypeCheckable {
|
|
|
116
117
|
*
|
|
117
118
|
* Note that in the sample above:
|
|
118
119
|
*
|
|
119
|
-
* - `<p>` have type of {@link module:engine/view/containerelement~
|
|
120
|
-
* - `<b>` have type of {@link module:engine/view/attributeelement~
|
|
121
|
-
* - `<span>` have type of {@link module:engine/view/uielement~
|
|
120
|
+
* - `<p>` have type of {@link module:engine/view/containerelement~ViewContainerElement},
|
|
121
|
+
* - `<b>` have type of {@link module:engine/view/attributeelement~ViewAttributeElement},
|
|
122
|
+
* - `<span>` have type of {@link module:engine/view/uielement~ViewUIElement}.
|
|
122
123
|
*
|
|
123
124
|
* @returns Shrunk range.
|
|
124
125
|
*/
|
|
125
126
|
getTrimmed() {
|
|
126
127
|
let start = this.start.getLastMatchingPosition(enlargeTrimSkip);
|
|
127
128
|
if (start.isAfter(this.end) || start.isEqual(this.end)) {
|
|
128
|
-
return new
|
|
129
|
+
return new ViewRange(start, start);
|
|
129
130
|
}
|
|
130
131
|
let end = this.end.getLastMatchingPosition(enlargeTrimSkip, { direction: 'backward' });
|
|
131
132
|
const nodeAfterStart = start.nodeAfter;
|
|
132
133
|
const nodeBeforeEnd = end.nodeBefore;
|
|
133
134
|
// Because TreeWalker prefers positions next to text node, we need to move them manually into these text nodes.
|
|
134
135
|
if (nodeAfterStart && nodeAfterStart.is('$text')) {
|
|
135
|
-
start = new
|
|
136
|
+
start = new ViewPosition(nodeAfterStart, 0);
|
|
136
137
|
}
|
|
137
138
|
if (nodeBeforeEnd && nodeBeforeEnd.is('$text')) {
|
|
138
|
-
end = new
|
|
139
|
+
end = new ViewPosition(nodeBeforeEnd, nodeBeforeEnd.data.length);
|
|
139
140
|
}
|
|
140
|
-
return new
|
|
141
|
+
return new ViewRange(start, end);
|
|
141
142
|
}
|
|
142
143
|
/**
|
|
143
144
|
* Two ranges are equal if their start and end positions are equal.
|
|
@@ -149,22 +150,22 @@ export default class Range extends TypeCheckable {
|
|
|
149
150
|
return this == otherRange || (this.start.isEqual(otherRange.start) && this.end.isEqual(otherRange.end));
|
|
150
151
|
}
|
|
151
152
|
/**
|
|
152
|
-
* Checks whether this range contains given {@link module:engine/view/position~
|
|
153
|
+
* Checks whether this range contains given {@link module:engine/view/position~ViewPosition position}.
|
|
153
154
|
*
|
|
154
155
|
* @param position Position to check.
|
|
155
|
-
* @returns `true` if given {@link module:engine/view/position~
|
|
156
|
+
* @returns `true` if given {@link module:engine/view/position~ViewPosition position} is contained in this range, `false` otherwise.
|
|
156
157
|
*/
|
|
157
158
|
containsPosition(position) {
|
|
158
159
|
return position.isAfter(this.start) && position.isBefore(this.end);
|
|
159
160
|
}
|
|
160
161
|
/**
|
|
161
|
-
* Checks whether this range contains given {@link module:engine/view/range~
|
|
162
|
+
* Checks whether this range contains given {@link module:engine/view/range~ViewRange range}.
|
|
162
163
|
*
|
|
163
164
|
* @param otherRange Range to check.
|
|
164
165
|
* @param loose Whether the check is loose or strict. If the check is strict (`false`), compared range cannot
|
|
165
166
|
* start or end at the same position as this range boundaries. If the check is loose (`true`), compared range can start, end or
|
|
166
167
|
* even be equal to this range. Note that collapsed ranges are always compared in strict mode.
|
|
167
|
-
* @returns `true` if given {@link module:engine/view/range~
|
|
168
|
+
* @returns `true` if given {@link module:engine/view/range~ViewRange range} boundaries are contained by this range, `false`
|
|
168
169
|
* otherwise.
|
|
169
170
|
*/
|
|
170
171
|
containsRange(otherRange, loose = false) {
|
|
@@ -176,9 +177,9 @@ export default class Range extends TypeCheckable {
|
|
|
176
177
|
return containsStart && containsEnd;
|
|
177
178
|
}
|
|
178
179
|
/**
|
|
179
|
-
* Computes which part(s) of this {@link module:engine/view/range~
|
|
180
|
-
* {@link module:engine/view/range~
|
|
181
|
-
* Returned array contains zero, one or two {@link module:engine/view/range~
|
|
180
|
+
* Computes which part(s) of this {@link module:engine/view/range~ViewRange range} is not a part of given
|
|
181
|
+
* {@link module:engine/view/range~ViewRange range}.
|
|
182
|
+
* Returned array contains zero, one or two {@link module:engine/view/range~ViewRange ranges}.
|
|
182
183
|
*
|
|
183
184
|
* Examples:
|
|
184
185
|
*
|
|
@@ -215,12 +216,12 @@ export default class Range extends TypeCheckable {
|
|
|
215
216
|
if (this.containsPosition(otherRange.start)) {
|
|
216
217
|
// Given range start is inside this range. This means that we have to
|
|
217
218
|
// add shrunken range - from the start to the middle of this range.
|
|
218
|
-
ranges.push(new
|
|
219
|
+
ranges.push(new ViewRange(this.start, otherRange.start));
|
|
219
220
|
}
|
|
220
221
|
if (this.containsPosition(otherRange.end)) {
|
|
221
222
|
// Given range end is inside this range. This means that we have to
|
|
222
223
|
// add shrunken range - from the middle of this range to the end.
|
|
223
|
-
ranges.push(new
|
|
224
|
+
ranges.push(new ViewRange(otherRange.end, this.end));
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
227
|
else {
|
|
@@ -230,7 +231,8 @@ export default class Range extends TypeCheckable {
|
|
|
230
231
|
return ranges;
|
|
231
232
|
}
|
|
232
233
|
/**
|
|
233
|
-
* Returns an intersection of this {@link module:engine/view/range~
|
|
234
|
+
* Returns an intersection of this {@link module:engine/view/range~ViewRange range}
|
|
235
|
+
* and given {@link module:engine/view/range~ViewRange range}.
|
|
234
236
|
* Intersection is a common part of both of those ranges. If ranges has no common part, returns `null`.
|
|
235
237
|
*
|
|
236
238
|
* Examples:
|
|
@@ -268,29 +270,29 @@ export default class Range extends TypeCheckable {
|
|
|
268
270
|
// shrink common range to the given range end.
|
|
269
271
|
commonRangeEnd = otherRange.end;
|
|
270
272
|
}
|
|
271
|
-
return new
|
|
273
|
+
return new ViewRange(commonRangeStart, commonRangeEnd);
|
|
272
274
|
}
|
|
273
275
|
// Ranges do not intersect, so they do not have common part.
|
|
274
276
|
return null;
|
|
275
277
|
}
|
|
276
278
|
/**
|
|
277
|
-
* Creates a {@link module:engine/view/treewalker~
|
|
279
|
+
* Creates a {@link module:engine/view/treewalker~ViewTreeWalker TreeWalker} instance with this range as a boundary.
|
|
278
280
|
*
|
|
279
|
-
* @param options Object with configuration options. See {@link module:engine/view/treewalker~
|
|
281
|
+
* @param options Object with configuration options. See {@link module:engine/view/treewalker~ViewTreeWalker}.
|
|
280
282
|
*/
|
|
281
283
|
getWalker(options = {}) {
|
|
282
284
|
options.boundaries = this;
|
|
283
|
-
return new
|
|
285
|
+
return new ViewTreeWalker(options);
|
|
284
286
|
}
|
|
285
287
|
/**
|
|
286
|
-
* Returns a {@link module:engine/view/node~
|
|
288
|
+
* Returns a {@link module:engine/view/node~ViewNode} or {@link module:engine/view/documentfragment~ViewDocumentFragment}
|
|
287
289
|
* which is a common ancestor of range's both ends (in which the entire range is contained).
|
|
288
290
|
*/
|
|
289
291
|
getCommonAncestor() {
|
|
290
292
|
return this.start.getCommonAncestor(this.end);
|
|
291
293
|
}
|
|
292
294
|
/**
|
|
293
|
-
* Returns an {@link module:engine/view/element~
|
|
295
|
+
* Returns an {@link module:engine/view/element~ViewElement Element} contained by the range.
|
|
294
296
|
* The element will be returned when it is the **only** node within the range and **fully–contained**
|
|
295
297
|
* at the same time.
|
|
296
298
|
*/
|
|
@@ -324,44 +326,44 @@ export default class Range extends TypeCheckable {
|
|
|
324
326
|
* Clones this range.
|
|
325
327
|
*/
|
|
326
328
|
clone() {
|
|
327
|
-
return new
|
|
329
|
+
return new ViewRange(this.start, this.end);
|
|
328
330
|
}
|
|
329
331
|
/**
|
|
330
|
-
* Returns an iterator that iterates over all {@link module:engine/view/item~
|
|
332
|
+
* Returns an iterator that iterates over all {@link module:engine/view/item~ViewItem view items} that are in this range and returns
|
|
331
333
|
* them.
|
|
332
334
|
*
|
|
333
|
-
* This method uses {@link module:engine/view/treewalker~
|
|
334
|
-
* set to `true`. However it returns only {@link module:engine/view/item~
|
|
335
|
-
* not {@link module:engine/view/treewalker~
|
|
335
|
+
* This method uses {@link module:engine/view/treewalker~ViewTreeWalker} with `boundaries` set to this range
|
|
336
|
+
* and `ignoreElementEnd` option set to `true`. However it returns only {@link module:engine/view/item~ViewItem items},
|
|
337
|
+
* not {@link module:engine/view/treewalker~ViewTreeWalkerValue}.
|
|
336
338
|
*
|
|
337
|
-
* You may specify additional options for the tree walker. See {@link module:engine/view/treewalker~
|
|
339
|
+
* You may specify additional options for the tree walker. See {@link module:engine/view/treewalker~ViewTreeWalker} for
|
|
338
340
|
* a full list of available options.
|
|
339
341
|
*
|
|
340
|
-
* @param options Object with configuration options. See {@link module:engine/view/treewalker~
|
|
342
|
+
* @param options Object with configuration options. See {@link module:engine/view/treewalker~ViewTreeWalker}.
|
|
341
343
|
*/
|
|
342
344
|
*getItems(options = {}) {
|
|
343
345
|
options.boundaries = this;
|
|
344
346
|
options.ignoreElementEnd = true;
|
|
345
|
-
const treeWalker = new
|
|
347
|
+
const treeWalker = new ViewTreeWalker(options);
|
|
346
348
|
for (const value of treeWalker) {
|
|
347
349
|
yield value.item;
|
|
348
350
|
}
|
|
349
351
|
}
|
|
350
352
|
/**
|
|
351
|
-
* Returns an iterator that iterates over all {@link module:engine/view/position~
|
|
353
|
+
* Returns an iterator that iterates over all {@link module:engine/view/position~ViewPosition positions} that are boundaries or
|
|
352
354
|
* contained in this range.
|
|
353
355
|
*
|
|
354
|
-
* This method uses {@link module:engine/view/treewalker~
|
|
355
|
-
* {@link module:engine/view/position~
|
|
356
|
+
* This method uses {@link module:engine/view/treewalker~ViewTreeWalker} with `boundaries` set to this range. However it returns only
|
|
357
|
+
* {@link module:engine/view/position~ViewPosition positions}, not {@link module:engine/view/treewalker~ViewTreeWalkerValue}.
|
|
356
358
|
*
|
|
357
|
-
* You may specify additional options for the tree walker. See {@link module:engine/view/treewalker~
|
|
359
|
+
* You may specify additional options for the tree walker. See {@link module:engine/view/treewalker~ViewTreeWalker} for
|
|
358
360
|
* a full list of available options.
|
|
359
361
|
*
|
|
360
|
-
* @param options Object with configuration options. See {@link module:engine/view/treewalker~
|
|
362
|
+
* @param options Object with configuration options. See {@link module:engine/view/treewalker~ViewTreeWalker}.
|
|
361
363
|
*/
|
|
362
364
|
*getPositions(options = {}) {
|
|
363
365
|
options.boundaries = this;
|
|
364
|
-
const treeWalker = new
|
|
366
|
+
const treeWalker = new ViewTreeWalker(options);
|
|
365
367
|
yield treeWalker.position;
|
|
366
368
|
for (const value of treeWalker) {
|
|
367
369
|
yield value.nextPosition;
|
|
@@ -387,10 +389,10 @@ export default class Range extends TypeCheckable {
|
|
|
387
389
|
* @returns Created range.
|
|
388
390
|
*/
|
|
389
391
|
static _createFromParentsAndOffsets(startElement, startOffset, endElement, endOffset) {
|
|
390
|
-
return new this(new
|
|
392
|
+
return new this(new ViewPosition(startElement, startOffset), new ViewPosition(endElement, endOffset));
|
|
391
393
|
}
|
|
392
394
|
/**
|
|
393
|
-
* Creates a new range, spreading from specified {@link module:engine/view/position~
|
|
395
|
+
* Creates a new range, spreading from specified {@link module:engine/view/position~ViewPosition position} to a position moved by
|
|
394
396
|
* given `shift`. If `shift` is a negative value, shifted position is treated as the beginning of the range.
|
|
395
397
|
*
|
|
396
398
|
* @internal
|
|
@@ -403,7 +405,7 @@ export default class Range extends TypeCheckable {
|
|
|
403
405
|
return shift > 0 ? new this(start, end) : new this(end, start);
|
|
404
406
|
}
|
|
405
407
|
/**
|
|
406
|
-
* Creates a range inside an {@link module:engine/view/element~
|
|
408
|
+
* Creates a range inside an {@link module:engine/view/element~ViewElement element} which starts before the first child of
|
|
407
409
|
* that element and ends after the last child of that element.
|
|
408
410
|
*
|
|
409
411
|
* @internal
|
|
@@ -413,18 +415,18 @@ export default class Range extends TypeCheckable {
|
|
|
413
415
|
return this._createFromParentsAndOffsets(element, 0, element, element.childCount);
|
|
414
416
|
}
|
|
415
417
|
/**
|
|
416
|
-
* Creates a range that starts before given {@link module:engine/view/item~
|
|
418
|
+
* Creates a range that starts before given {@link module:engine/view/item~ViewItem view item} and ends after it.
|
|
417
419
|
*
|
|
418
420
|
* @internal
|
|
419
421
|
*/
|
|
420
422
|
static _createOn(item) {
|
|
421
423
|
const size = item.is('$textProxy') ? item.offsetSize : 1;
|
|
422
|
-
return this._createFromPositionAndShift(
|
|
424
|
+
return this._createFromPositionAndShift(ViewPosition._createBefore(item), size);
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
426
428
|
// Proper overload would interfere with that.
|
|
427
|
-
|
|
429
|
+
ViewRange.prototype.is = function (type) {
|
|
428
430
|
return type === 'range' || type === 'view:range';
|
|
429
431
|
};
|
|
430
432
|
/**
|
package/src/view/rawelement.d.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/rawelement
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
12
|
-
import type
|
|
8
|
+
import { ViewElement, type ViewElementAttributes } from './element.js';
|
|
9
|
+
import { ViewNode } from './node.js';
|
|
10
|
+
import { type ViewDocument } from './document.js';
|
|
11
|
+
import { type ViewDomConverter } from './domconverter.js';
|
|
12
|
+
import { type ViewItem } from './item.js';
|
|
13
13
|
type DomElement = globalThis.HTMLElement;
|
|
14
14
|
/**
|
|
15
15
|
* The raw element class.
|
|
@@ -19,40 +19,40 @@ type DomElement = globalThis.HTMLElement;
|
|
|
19
19
|
* in the editor content without, for instance, worrying about compatibility with other editor features.
|
|
20
20
|
* Raw elements are a perfect tool for integration with external frameworks and data sources.
|
|
21
21
|
*
|
|
22
|
-
* Unlike {@link module:engine/view/uielement~
|
|
23
|
-
* content (similar to {@link module:engine/view/containerelement~
|
|
24
|
-
* {@link module:engine/view/emptyelement~
|
|
22
|
+
* Unlike {@link module:engine/view/uielement~ViewUIElement UI elements}, raw elements act like real editor
|
|
23
|
+
* content (similar to {@link module:engine/view/containerelement~ViewContainerElement} or
|
|
24
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement}), they are considered by the editor selection and
|
|
25
25
|
* {@link module:widget/utils~toWidget they can work as widgets}.
|
|
26
26
|
*
|
|
27
27
|
* To create a new raw element, use the
|
|
28
|
-
* {@link module:engine/view/downcastwriter~
|
|
28
|
+
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createRawElement `downcastWriter#createRawElement()`} method.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export declare class ViewRawElement extends ViewElement {
|
|
31
31
|
/**
|
|
32
32
|
* Creates a new instance of a raw element.
|
|
33
33
|
*
|
|
34
34
|
* Throws the `view-rawelement-cannot-add` {@link module:utils/ckeditorerror~CKEditorError CKEditorError} when the `children`
|
|
35
|
-
* parameter is passed to inform that the usage of `
|
|
35
|
+
* parameter is passed to inform that the usage of `ViewRawElement` is incorrect (adding child nodes to `ViewRawElement` is forbidden).
|
|
36
36
|
*
|
|
37
|
-
* @see module:engine/view/downcastwriter~
|
|
37
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createRawElement
|
|
38
38
|
* @internal
|
|
39
39
|
* @param document The document instance to which this element belongs.
|
|
40
40
|
* @param name Node name.
|
|
41
41
|
* @param attrs Collection of attributes.
|
|
42
42
|
* @param children A list of nodes to be inserted into created element.
|
|
43
43
|
*/
|
|
44
|
-
constructor(document:
|
|
44
|
+
constructor(document: ViewDocument, name: string, attrs?: ViewElementAttributes, children?: ViewNode | Iterable<ViewNode>);
|
|
45
45
|
/**
|
|
46
|
-
* Overrides the {@link module:engine/view/element~
|
|
46
|
+
* Overrides the {@link module:engine/view/element~ViewElement#_insertChild} method.
|
|
47
47
|
* Throws the `view-rawelement-cannot-add` {@link module:utils/ckeditorerror~CKEditorError CKEditorError} to prevent
|
|
48
48
|
* adding any child nodes to a raw element.
|
|
49
49
|
*
|
|
50
50
|
* @internal
|
|
51
51
|
*/
|
|
52
|
-
_insertChild(index: number, items:
|
|
52
|
+
_insertChild(index: number, items: ViewItem | Iterable<ViewItem>): number;
|
|
53
53
|
/**
|
|
54
|
-
* This allows rendering the children of a {@link module:engine/view/rawelement~
|
|
55
|
-
* This method is called by the {@link module:engine/view/domconverter~
|
|
54
|
+
* This allows rendering the children of a {@link module:engine/view/rawelement~ViewRawElement} on the DOM level.
|
|
55
|
+
* This method is called by the {@link module:engine/view/domconverter~ViewDomConverter} with the raw DOM element
|
|
56
56
|
* passed as an argument, leaving the number and shape of the children up to the integrator.
|
|
57
57
|
*
|
|
58
58
|
* This method **must be defined** for the raw element to work:
|
|
@@ -66,8 +66,8 @@ export default class RawElement extends Element {
|
|
|
66
66
|
* ```
|
|
67
67
|
*
|
|
68
68
|
* @param domElement The native DOM element representing the raw view element.
|
|
69
|
-
* @param domConverter Instance of the
|
|
69
|
+
* @param domConverter Instance of the ViewDomConverter used to optimize the output.
|
|
70
70
|
*/
|
|
71
|
-
render(domElement: DomElement, domConverter:
|
|
71
|
+
render(domElement: DomElement, domConverter: ViewDomConverter): void;
|
|
72
72
|
}
|
|
73
73
|
export {};
|
package/src/view/rawelement.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @module engine/view/rawelement
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import { ViewElement } from './element.js';
|
|
10
|
+
import { ViewNode } from './node.js';
|
|
11
11
|
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
12
12
|
/**
|
|
13
13
|
* The raw element class.
|
|
@@ -17,22 +17,22 @@ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
|
17
17
|
* in the editor content without, for instance, worrying about compatibility with other editor features.
|
|
18
18
|
* Raw elements are a perfect tool for integration with external frameworks and data sources.
|
|
19
19
|
*
|
|
20
|
-
* Unlike {@link module:engine/view/uielement~
|
|
21
|
-
* content (similar to {@link module:engine/view/containerelement~
|
|
22
|
-
* {@link module:engine/view/emptyelement~
|
|
20
|
+
* Unlike {@link module:engine/view/uielement~ViewUIElement UI elements}, raw elements act like real editor
|
|
21
|
+
* content (similar to {@link module:engine/view/containerelement~ViewContainerElement} or
|
|
22
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement}), they are considered by the editor selection and
|
|
23
23
|
* {@link module:widget/utils~toWidget they can work as widgets}.
|
|
24
24
|
*
|
|
25
25
|
* To create a new raw element, use the
|
|
26
|
-
* {@link module:engine/view/downcastwriter~
|
|
26
|
+
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createRawElement `downcastWriter#createRawElement()`} method.
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export class ViewRawElement extends ViewElement {
|
|
29
29
|
/**
|
|
30
30
|
* Creates a new instance of a raw element.
|
|
31
31
|
*
|
|
32
32
|
* Throws the `view-rawelement-cannot-add` {@link module:utils/ckeditorerror~CKEditorError CKEditorError} when the `children`
|
|
33
|
-
* parameter is passed to inform that the usage of `
|
|
33
|
+
* parameter is passed to inform that the usage of `ViewRawElement` is incorrect (adding child nodes to `ViewRawElement` is forbidden).
|
|
34
34
|
*
|
|
35
|
-
* @see module:engine/view/downcastwriter~
|
|
35
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createRawElement
|
|
36
36
|
* @internal
|
|
37
37
|
* @param document The document instance to which this element belongs.
|
|
38
38
|
* @param name Node name.
|
|
@@ -45,16 +45,16 @@ export default class RawElement extends Element {
|
|
|
45
45
|
this.getFillerOffset = getFillerOffset;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Overrides the {@link module:engine/view/element~
|
|
48
|
+
* Overrides the {@link module:engine/view/element~ViewElement#_insertChild} method.
|
|
49
49
|
* Throws the `view-rawelement-cannot-add` {@link module:utils/ckeditorerror~CKEditorError CKEditorError} to prevent
|
|
50
50
|
* adding any child nodes to a raw element.
|
|
51
51
|
*
|
|
52
52
|
* @internal
|
|
53
53
|
*/
|
|
54
54
|
_insertChild(index, items) {
|
|
55
|
-
if (items && (items instanceof
|
|
55
|
+
if (items && (items instanceof ViewNode || Array.from(items).length > 0)) {
|
|
56
56
|
/**
|
|
57
|
-
* Cannot add children to a {@link module:engine/view/rawelement~
|
|
57
|
+
* Cannot add children to a {@link module:engine/view/rawelement~ViewRawElement} instance.
|
|
58
58
|
*
|
|
59
59
|
* @error view-rawelement-cannot-add
|
|
60
60
|
*/
|
|
@@ -63,8 +63,8 @@ export default class RawElement extends Element {
|
|
|
63
63
|
return 0;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* This allows rendering the children of a {@link module:engine/view/rawelement~
|
|
67
|
-
* This method is called by the {@link module:engine/view/domconverter~
|
|
66
|
+
* This allows rendering the children of a {@link module:engine/view/rawelement~ViewRawElement} on the DOM level.
|
|
67
|
+
* This method is called by the {@link module:engine/view/domconverter~ViewDomConverter} with the raw DOM element
|
|
68
68
|
* passed as an argument, leaving the number and shape of the children up to the integrator.
|
|
69
69
|
*
|
|
70
70
|
* This method **must be defined** for the raw element to work:
|
|
@@ -78,13 +78,13 @@ export default class RawElement extends Element {
|
|
|
78
78
|
* ```
|
|
79
79
|
*
|
|
80
80
|
* @param domElement The native DOM element representing the raw view element.
|
|
81
|
-
* @param domConverter Instance of the
|
|
81
|
+
* @param domConverter Instance of the ViewDomConverter used to optimize the output.
|
|
82
82
|
*/
|
|
83
83
|
render(domElement, domConverter) { }
|
|
84
84
|
}
|
|
85
85
|
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
86
86
|
// Proper overload would interfere with that.
|
|
87
|
-
|
|
87
|
+
ViewRawElement.prototype.is = function (type, name) {
|
|
88
88
|
if (!name) {
|
|
89
89
|
return type === 'rawElement' || type === 'view:rawElement' ||
|
|
90
90
|
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
package/src/view/renderer.d.ts
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
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 type {
|
|
6
|
-
import type
|
|
7
|
-
import type
|
|
8
|
-
import type ViewElement from './element.js';
|
|
9
|
-
import type ViewNode from './node.js';
|
|
5
|
+
import type { ViewDocumentChangeType } from './document.js';
|
|
6
|
+
import { type ViewDocumentSelection } from './documentselection.js';
|
|
7
|
+
import { type ViewDomConverter } from './domconverter.js';
|
|
8
|
+
import { type ViewElement } from './element.js';
|
|
9
|
+
import { type ViewNode } from './node.js';
|
|
10
10
|
import '../../theme/renderer.css';
|
|
11
11
|
type DomDocument = globalThis.Document;
|
|
12
|
-
declare const
|
|
12
|
+
declare const ViewRenderer_base: {
|
|
13
13
|
new (): import("@ckeditor/ckeditor5-utils").Observable;
|
|
14
14
|
prototype: import("@ckeditor/ckeditor5-utils").Observable;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Renderer is responsible for updating the DOM structure and the DOM selection based on
|
|
18
|
-
* the {@link module:engine/view/renderer~
|
|
18
|
+
* the {@link module:engine/view/renderer~ViewRenderer#markToSync information about updated view nodes}.
|
|
19
19
|
* In other words, it renders the view to the DOM.
|
|
20
20
|
*
|
|
21
21
|
* Its main responsibility is to make only the necessary, minimal changes to the DOM. However, unlike in many
|
|
@@ -23,10 +23,10 @@ declare const Renderer_base: {
|
|
|
23
23
|
* that native editing features such as text composition, autocompletion, spell checking, selection's x-index are
|
|
24
24
|
* affected as little as possible.
|
|
25
25
|
*
|
|
26
|
-
* Renderer uses {@link module:engine/view/domconverter~
|
|
26
|
+
* Renderer uses {@link module:engine/view/domconverter~ViewDomConverter} to transform view nodes and positions
|
|
27
27
|
* to and from the DOM.
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
29
|
+
export declare class ViewRenderer extends /* #__PURE__ */ ViewRenderer_base {
|
|
30
30
|
/**
|
|
31
31
|
* Set of DOM Documents instances.
|
|
32
32
|
*/
|
|
@@ -34,7 +34,7 @@ export default class Renderer extends /* #__PURE__ */ Renderer_base {
|
|
|
34
34
|
/**
|
|
35
35
|
* Converter instance.
|
|
36
36
|
*/
|
|
37
|
-
readonly domConverter:
|
|
37
|
+
readonly domConverter: ViewDomConverter;
|
|
38
38
|
/**
|
|
39
39
|
* Set of nodes which attributes changed and may need to be rendered.
|
|
40
40
|
*/
|
|
@@ -50,7 +50,7 @@ export default class Renderer extends /* #__PURE__ */ Renderer_base {
|
|
|
50
50
|
/**
|
|
51
51
|
* View selection. Renderer updates DOM selection based on the view selection.
|
|
52
52
|
*/
|
|
53
|
-
readonly selection:
|
|
53
|
+
readonly selection: ViewDocumentSelection;
|
|
54
54
|
/**
|
|
55
55
|
* Indicates if the view document is focused and selection can be rendered. Selection will not be rendered if
|
|
56
56
|
* this is set to `false`.
|
|
@@ -72,7 +72,7 @@ export default class Renderer extends /* #__PURE__ */ Renderer_base {
|
|
|
72
72
|
/**
|
|
73
73
|
* True if composition is in progress inside the document.
|
|
74
74
|
*
|
|
75
|
-
* This property is bound to the {@link module:engine/view/document~
|
|
75
|
+
* This property is bound to the {@link module:engine/view/document~ViewDocument#isComposing `Document#isComposing`} property.
|
|
76
76
|
*
|
|
77
77
|
* @observable
|
|
78
78
|
*/
|
|
@@ -91,7 +91,7 @@ export default class Renderer extends /* #__PURE__ */ Renderer_base {
|
|
|
91
91
|
* @param domConverter Converter instance.
|
|
92
92
|
* @param selection View selection.
|
|
93
93
|
*/
|
|
94
|
-
constructor(domConverter:
|
|
94
|
+
constructor(domConverter: ViewDomConverter, selection: ViewDocumentSelection);
|
|
95
95
|
/**
|
|
96
96
|
* Marks a view node to be updated in the DOM by {@link #render `render()`}.
|
|
97
97
|
*
|
|
@@ -104,7 +104,7 @@ export default class Renderer extends /* #__PURE__ */ Renderer_base {
|
|
|
104
104
|
* @param type Type of the change.
|
|
105
105
|
* @param node ViewNode to be marked.
|
|
106
106
|
*/
|
|
107
|
-
markToSync(type:
|
|
107
|
+
markToSync(type: ViewDocumentChangeType, node: ViewNode): void;
|
|
108
108
|
/**
|
|
109
109
|
* Renders all buffered changes ({@link #markedAttributes}, {@link #markedChildren} and {@link #markedTexts}) and
|
|
110
110
|
* the current view selection (if needed) to the DOM by applying a minimal set of changes to it.
|
package/src/view/renderer.js
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/renderer
|
|
7
7
|
*/
|
|
8
|
-
import ViewText from './text.js';
|
|
9
|
-
import ViewPosition from './position.js';
|
|
8
|
+
import { ViewText } from './text.js';
|
|
9
|
+
import { ViewPosition } from './position.js';
|
|
10
10
|
import { INLINE_FILLER, INLINE_FILLER_LENGTH, startsWithFiller, isInlineFiller } from './filler.js';
|
|
11
11
|
import { CKEditorError, ObservableMixin, diff, env, fastDiff, insertAt, isComment, isNode, isText, remove, indexOf } from '@ckeditor/ckeditor5-utils';
|
|
12
12
|
// @if CK_DEBUG_TYPING // const { _buildLogMessage } = require( '../dev-utils/utils.js' );
|
|
13
13
|
import '../../theme/renderer.css';
|
|
14
14
|
/**
|
|
15
15
|
* Renderer is responsible for updating the DOM structure and the DOM selection based on
|
|
16
|
-
* the {@link module:engine/view/renderer~
|
|
16
|
+
* the {@link module:engine/view/renderer~ViewRenderer#markToSync information about updated view nodes}.
|
|
17
17
|
* In other words, it renders the view to the DOM.
|
|
18
18
|
*
|
|
19
19
|
* Its main responsibility is to make only the necessary, minimal changes to the DOM. However, unlike in many
|
|
@@ -21,10 +21,10 @@ import '../../theme/renderer.css';
|
|
|
21
21
|
* that native editing features such as text composition, autocompletion, spell checking, selection's x-index are
|
|
22
22
|
* affected as little as possible.
|
|
23
23
|
*
|
|
24
|
-
* Renderer uses {@link module:engine/view/domconverter~
|
|
24
|
+
* Renderer uses {@link module:engine/view/domconverter~ViewDomConverter} to transform view nodes and positions
|
|
25
25
|
* to and from the DOM.
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export class ViewRenderer extends /* #__PURE__ */ ObservableMixin() {
|
|
28
28
|
/**
|
|
29
29
|
* Set of DOM Documents instances.
|
|
30
30
|
*/
|
|
@@ -182,7 +182,7 @@ export default class Renderer extends /* #__PURE__ */ ObservableMixin() {
|
|
|
182
182
|
this.markedChildren.add(inlineFillerPosition.parent);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
// Make sure the inline filler has any parent, so it can be mapped to view position by
|
|
185
|
+
// Make sure the inline filler has any parent, so it can be mapped to view position by ViewDomConverter.
|
|
186
186
|
else if (this._inlineFiller && this._inlineFiller.parentNode) {
|
|
187
187
|
// While the user is making selection, preserve the inline filler at its original position.
|
|
188
188
|
inlineFillerPosition = this.domConverter.domPositionToView(this._inlineFiller);
|
|
@@ -1061,7 +1061,7 @@ function areTextNodes(node1, node2) {
|
|
|
1061
1061
|
* * Element nodes represented by the same object.
|
|
1062
1062
|
* * Two block filler elements.
|
|
1063
1063
|
*
|
|
1064
|
-
* @param blockFillerMode Block filler mode, see {@link module:engine/view/domconverter~
|
|
1064
|
+
* @param blockFillerMode Block filler mode, see {@link module:engine/view/domconverter~ViewDomConverter#blockFillerMode}.
|
|
1065
1065
|
*/
|
|
1066
1066
|
function sameNodes(domConverter, actualDomChild, expectedDomChild) {
|
|
1067
1067
|
// Elements.
|