@ckeditor/ckeditor5-engine 47.6.1 → 48.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/LICENSE.md +1 -1
- package/{src → dist}/engineconfig.d.ts +6 -15
- package/dist/index-editor.css +38 -15
- package/dist/index.css +37 -37
- package/dist/index.css.map +1 -1
- package/{src → dist}/index.d.ts +0 -1
- package/dist/index.js +588 -94
- package/dist/index.js.map +1 -1
- package/{src → dist}/model/model.d.ts +10 -4
- package/{src → dist}/model/selection.d.ts +1 -1
- package/{src → dist}/view/downcastwriter.d.ts +3 -2
- package/{src → dist}/view/element.d.ts +2 -2
- package/{src → dist}/view/matcher.d.ts +4 -2
- package/dist/view/styles/background.d.ts +18 -0
- package/{src → dist}/view/styles/border.d.ts +0 -12
- package/{src → dist}/view/styles/margin.d.ts +0 -13
- package/{src → dist}/view/styles/padding.d.ts +0 -13
- package/{src → dist}/view/styles/utils.d.ts +12 -0
- package/package.json +20 -39
- package/src/controller/datacontroller.js +0 -522
- package/src/controller/editingcontroller.js +0 -181
- package/src/conversion/conversion.js +0 -606
- package/src/conversion/conversionhelpers.js +0 -33
- package/src/conversion/downcastdispatcher.js +0 -563
- package/src/conversion/downcasthelpers.js +0 -2160
- package/src/conversion/mapper.js +0 -1050
- package/src/conversion/modelconsumable.js +0 -331
- package/src/conversion/upcastdispatcher.js +0 -470
- package/src/conversion/upcasthelpers.js +0 -952
- package/src/conversion/viewconsumable.js +0 -541
- package/src/dataprocessor/basichtmlwriter.js +0 -22
- package/src/dataprocessor/dataprocessor.js +0 -5
- package/src/dataprocessor/htmldataprocessor.js +0 -107
- package/src/dataprocessor/htmlwriter.js +0 -5
- package/src/dataprocessor/xmldataprocessor.js +0 -127
- package/src/dev-utils/model.js +0 -396
- package/src/dev-utils/operationreplayer.js +0 -116
- package/src/dev-utils/utils.js +0 -122
- package/src/dev-utils/view.js +0 -990
- package/src/engineconfig.js +0 -5
- package/src/index.js +0 -134
- package/src/legacyerrors.js +0 -17
- package/src/model/batch.js +0 -98
- package/src/model/differ.js +0 -1288
- package/src/model/document.js +0 -398
- package/src/model/documentfragment.js +0 -332
- package/src/model/documentselection.js +0 -1026
- package/src/model/element.js +0 -323
- package/src/model/history.js +0 -206
- package/src/model/item.js +0 -5
- package/src/model/liveposition.js +0 -93
- package/src/model/liverange.js +0 -121
- package/src/model/markercollection.js +0 -436
- package/src/model/model.js +0 -866
- package/src/model/node.js +0 -371
- package/src/model/nodelist.js +0 -244
- package/src/model/operation/attributeoperation.js +0 -172
- package/src/model/operation/detachoperation.js +0 -87
- package/src/model/operation/insertoperation.js +0 -153
- package/src/model/operation/markeroperation.js +0 -136
- package/src/model/operation/mergeoperation.js +0 -184
- package/src/model/operation/moveoperation.js +0 -179
- package/src/model/operation/nooperation.js +0 -48
- package/src/model/operation/operation.js +0 -78
- package/src/model/operation/operationfactory.js +0 -44
- package/src/model/operation/renameoperation.js +0 -128
- package/src/model/operation/rootattributeoperation.js +0 -173
- package/src/model/operation/rootoperation.js +0 -106
- package/src/model/operation/splitoperation.js +0 -214
- package/src/model/operation/transform.js +0 -2211
- package/src/model/operation/utils.js +0 -217
- package/src/model/position.js +0 -1041
- package/src/model/range.js +0 -880
- package/src/model/rootelement.js +0 -82
- package/src/model/schema.js +0 -1542
- package/src/model/selection.js +0 -814
- package/src/model/text.js +0 -92
- package/src/model/textproxy.js +0 -202
- package/src/model/treewalker.js +0 -313
- package/src/model/typecheckable.js +0 -16
- package/src/model/utils/autoparagraphing.js +0 -63
- package/src/model/utils/deletecontent.js +0 -509
- package/src/model/utils/getselectedcontent.js +0 -126
- package/src/model/utils/insertcontent.js +0 -750
- package/src/model/utils/insertobject.js +0 -135
- package/src/model/utils/modifyselection.js +0 -187
- package/src/model/utils/selection-post-fixer.js +0 -264
- package/src/model/writer.js +0 -1318
- package/src/view/attributeelement.js +0 -220
- package/src/view/containerelement.js +0 -91
- package/src/view/datatransfer.js +0 -106
- package/src/view/document.js +0 -139
- package/src/view/documentfragment.js +0 -251
- package/src/view/documentselection.js +0 -270
- package/src/view/domconverter.js +0 -1661
- package/src/view/downcastwriter.js +0 -1589
- package/src/view/editableelement.js +0 -74
- package/src/view/element.js +0 -1053
- package/src/view/elementdefinition.js +0 -5
- package/src/view/emptyelement.js +0 -83
- package/src/view/filler.js +0 -161
- package/src/view/item.js +0 -5
- package/src/view/matcher.js +0 -437
- package/src/view/node.js +0 -238
- package/src/view/observer/arrowkeysobserver.js +0 -40
- package/src/view/observer/bubblingemittermixin.js +0 -215
- package/src/view/observer/bubblingeventinfo.js +0 -49
- package/src/view/observer/clickobserver.js +0 -26
- package/src/view/observer/compositionobserver.js +0 -64
- package/src/view/observer/domeventdata.js +0 -63
- package/src/view/observer/domeventobserver.js +0 -81
- package/src/view/observer/fakeselectionobserver.js +0 -95
- package/src/view/observer/focusobserver.js +0 -166
- package/src/view/observer/inputobserver.js +0 -236
- package/src/view/observer/keyobserver.js +0 -36
- package/src/view/observer/mouseobserver.js +0 -26
- package/src/view/observer/mutationobserver.js +0 -219
- package/src/view/observer/observer.js +0 -92
- package/src/view/observer/pointerobserver.js +0 -26
- package/src/view/observer/selectionobserver.js +0 -318
- package/src/view/observer/tabobserver.js +0 -42
- package/src/view/observer/touchobserver.js +0 -26
- package/src/view/placeholder.js +0 -285
- package/src/view/position.js +0 -341
- package/src/view/range.js +0 -451
- package/src/view/rawelement.js +0 -115
- package/src/view/renderer.js +0 -1148
- package/src/view/rooteditableelement.js +0 -78
- package/src/view/selection.js +0 -594
- package/src/view/styles/background.d.ts +0 -33
- package/src/view/styles/background.js +0 -74
- package/src/view/styles/border.js +0 -316
- package/src/view/styles/margin.js +0 -34
- package/src/view/styles/padding.js +0 -34
- package/src/view/styles/utils.js +0 -219
- package/src/view/stylesmap.js +0 -941
- package/src/view/text.js +0 -110
- package/src/view/textproxy.js +0 -136
- package/src/view/tokenlist.js +0 -194
- package/src/view/treewalker.js +0 -389
- package/src/view/typecheckable.js +0 -19
- package/src/view/uielement.js +0 -194
- package/src/view/upcastwriter.js +0 -363
- package/src/view/view.js +0 -579
- package/theme/placeholder.css +0 -36
- package/theme/renderer.css +0 -9
- /package/{src → dist}/controller/datacontroller.d.ts +0 -0
- /package/{src → dist}/controller/editingcontroller.d.ts +0 -0
- /package/{src → dist}/conversion/conversion.d.ts +0 -0
- /package/{src → dist}/conversion/conversionhelpers.d.ts +0 -0
- /package/{src → dist}/conversion/downcastdispatcher.d.ts +0 -0
- /package/{src → dist}/conversion/downcasthelpers.d.ts +0 -0
- /package/{src → dist}/conversion/mapper.d.ts +0 -0
- /package/{src → dist}/conversion/modelconsumable.d.ts +0 -0
- /package/{src → dist}/conversion/upcastdispatcher.d.ts +0 -0
- /package/{src → dist}/conversion/upcasthelpers.d.ts +0 -0
- /package/{src → dist}/conversion/viewconsumable.d.ts +0 -0
- /package/{src → dist}/dataprocessor/basichtmlwriter.d.ts +0 -0
- /package/{src → dist}/dataprocessor/dataprocessor.d.ts +0 -0
- /package/{src → dist}/dataprocessor/htmldataprocessor.d.ts +0 -0
- /package/{src → dist}/dataprocessor/htmlwriter.d.ts +0 -0
- /package/{src → dist}/dataprocessor/xmldataprocessor.d.ts +0 -0
- /package/{src → dist}/dev-utils/model.d.ts +0 -0
- /package/{src → dist}/dev-utils/operationreplayer.d.ts +0 -0
- /package/{src → dist}/dev-utils/utils.d.ts +0 -0
- /package/{src → dist}/dev-utils/view.d.ts +0 -0
- /package/{src → dist}/legacyerrors.d.ts +0 -0
- /package/{src → dist}/model/batch.d.ts +0 -0
- /package/{src → dist}/model/differ.d.ts +0 -0
- /package/{src → dist}/model/document.d.ts +0 -0
- /package/{src → dist}/model/documentfragment.d.ts +0 -0
- /package/{src → dist}/model/documentselection.d.ts +0 -0
- /package/{src → dist}/model/element.d.ts +0 -0
- /package/{src → dist}/model/history.d.ts +0 -0
- /package/{src → dist}/model/item.d.ts +0 -0
- /package/{src → dist}/model/liveposition.d.ts +0 -0
- /package/{src → dist}/model/liverange.d.ts +0 -0
- /package/{src → dist}/model/markercollection.d.ts +0 -0
- /package/{src → dist}/model/node.d.ts +0 -0
- /package/{src → dist}/model/nodelist.d.ts +0 -0
- /package/{src → dist}/model/operation/attributeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/detachoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/insertoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/markeroperation.d.ts +0 -0
- /package/{src → dist}/model/operation/mergeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/moveoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/nooperation.d.ts +0 -0
- /package/{src → dist}/model/operation/operation.d.ts +0 -0
- /package/{src → dist}/model/operation/operationfactory.d.ts +0 -0
- /package/{src → dist}/model/operation/renameoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/rootattributeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/rootoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/splitoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/transform.d.ts +0 -0
- /package/{src → dist}/model/operation/utils.d.ts +0 -0
- /package/{src → dist}/model/position.d.ts +0 -0
- /package/{src → dist}/model/range.d.ts +0 -0
- /package/{src → dist}/model/rootelement.d.ts +0 -0
- /package/{src → dist}/model/schema.d.ts +0 -0
- /package/{src → dist}/model/text.d.ts +0 -0
- /package/{src → dist}/model/textproxy.d.ts +0 -0
- /package/{src → dist}/model/treewalker.d.ts +0 -0
- /package/{src → dist}/model/typecheckable.d.ts +0 -0
- /package/{src → dist}/model/utils/autoparagraphing.d.ts +0 -0
- /package/{src → dist}/model/utils/deletecontent.d.ts +0 -0
- /package/{src → dist}/model/utils/getselectedcontent.d.ts +0 -0
- /package/{src → dist}/model/utils/insertcontent.d.ts +0 -0
- /package/{src → dist}/model/utils/insertobject.d.ts +0 -0
- /package/{src → dist}/model/utils/modifyselection.d.ts +0 -0
- /package/{src → dist}/model/utils/selection-post-fixer.d.ts +0 -0
- /package/{src → dist}/model/writer.d.ts +0 -0
- /package/{src → dist}/view/attributeelement.d.ts +0 -0
- /package/{src → dist}/view/containerelement.d.ts +0 -0
- /package/{src → dist}/view/datatransfer.d.ts +0 -0
- /package/{src → dist}/view/document.d.ts +0 -0
- /package/{src → dist}/view/documentfragment.d.ts +0 -0
- /package/{src → dist}/view/documentselection.d.ts +0 -0
- /package/{src → dist}/view/domconverter.d.ts +0 -0
- /package/{src → dist}/view/editableelement.d.ts +0 -0
- /package/{src → dist}/view/elementdefinition.d.ts +0 -0
- /package/{src → dist}/view/emptyelement.d.ts +0 -0
- /package/{src → dist}/view/filler.d.ts +0 -0
- /package/{src → dist}/view/item.d.ts +0 -0
- /package/{src → dist}/view/node.d.ts +0 -0
- /package/{src → dist}/view/observer/arrowkeysobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/bubblingemittermixin.d.ts +0 -0
- /package/{src → dist}/view/observer/bubblingeventinfo.d.ts +0 -0
- /package/{src → dist}/view/observer/clickobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/compositionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/domeventdata.d.ts +0 -0
- /package/{src → dist}/view/observer/domeventobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/fakeselectionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/focusobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/inputobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/keyobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/mouseobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/mutationobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/observer.d.ts +0 -0
- /package/{src → dist}/view/observer/pointerobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/selectionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/tabobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/touchobserver.d.ts +0 -0
- /package/{src → dist}/view/placeholder.d.ts +0 -0
- /package/{src → dist}/view/position.d.ts +0 -0
- /package/{src → dist}/view/range.d.ts +0 -0
- /package/{src → dist}/view/rawelement.d.ts +0 -0
- /package/{src → dist}/view/renderer.d.ts +0 -0
- /package/{src → dist}/view/rooteditableelement.d.ts +0 -0
- /package/{src → dist}/view/selection.d.ts +0 -0
- /package/{src → dist}/view/stylesmap.d.ts +0 -0
- /package/{src → dist}/view/text.d.ts +0 -0
- /package/{src → dist}/view/textproxy.d.ts +0 -0
- /package/{src → dist}/view/tokenlist.d.ts +0 -0
- /package/{src → dist}/view/treewalker.d.ts +0 -0
- /package/{src → dist}/view/typecheckable.d.ts +0 -0
- /package/{src → dist}/view/uielement.d.ts +0 -0
- /package/{src → dist}/view/upcastwriter.d.ts +0 -0
- /package/{src → dist}/view/view.d.ts +0 -0
package/src/view/treewalker.js
DELETED
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { ViewTextProxy } from './textproxy.js';
|
|
6
|
-
import { ViewPosition } from './position.js';
|
|
7
|
-
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
8
|
-
/**
|
|
9
|
-
* Position iterator class. It allows to iterate forward and backward over the document.
|
|
10
|
-
*/
|
|
11
|
-
export class ViewTreeWalker {
|
|
12
|
-
/**
|
|
13
|
-
* Walking direction. Defaults `'forward'`.
|
|
14
|
-
*/
|
|
15
|
-
direction;
|
|
16
|
-
/**
|
|
17
|
-
* Iterator boundaries.
|
|
18
|
-
*
|
|
19
|
-
* When the iterator is walking `'forward'` on the end of boundary or is walking `'backward'`
|
|
20
|
-
* on the start of boundary, then `{ done: true }` is returned.
|
|
21
|
-
*
|
|
22
|
-
* If boundaries are not defined they are set before first and after last child of the root node.
|
|
23
|
-
*/
|
|
24
|
-
boundaries;
|
|
25
|
-
/**
|
|
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
|
-
*/
|
|
29
|
-
singleCharacters;
|
|
30
|
-
/**
|
|
31
|
-
* Flag indicating whether iterator should enter elements or not. If the iterator is shallow child nodes of any
|
|
32
|
-
* iterated node will not be returned along with `elementEnd` tag.
|
|
33
|
-
*/
|
|
34
|
-
shallow;
|
|
35
|
-
/**
|
|
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~ViewElement} will be returned once.
|
|
38
|
-
* When set to `false` each element might be returned twice: for `'elementStart'` and `'elementEnd'`.
|
|
39
|
-
*/
|
|
40
|
-
ignoreElementEnd;
|
|
41
|
-
/**
|
|
42
|
-
* Iterator position. If start position is not defined then position depends on {@link #direction}. If direction is
|
|
43
|
-
* `'forward'` position starts form the beginning, when direction is `'backward'` position starts from the end.
|
|
44
|
-
*/
|
|
45
|
-
_position;
|
|
46
|
-
/**
|
|
47
|
-
* Start boundary parent.
|
|
48
|
-
*/
|
|
49
|
-
_boundaryStartParent;
|
|
50
|
-
/**
|
|
51
|
-
* End boundary parent.
|
|
52
|
-
*/
|
|
53
|
-
_boundaryEndParent;
|
|
54
|
-
/**
|
|
55
|
-
* Creates a range iterator. All parameters are optional, but you have to specify either `boundaries` or `startPosition`.
|
|
56
|
-
*
|
|
57
|
-
* @param options Object with configuration.
|
|
58
|
-
*/
|
|
59
|
-
constructor(options = {}) {
|
|
60
|
-
if (!options.boundaries && !options.startPosition) {
|
|
61
|
-
/**
|
|
62
|
-
* Neither boundaries nor starting position have been defined.
|
|
63
|
-
*
|
|
64
|
-
* @error view-tree-walker-no-start-position
|
|
65
|
-
*/
|
|
66
|
-
throw new CKEditorError('view-tree-walker-no-start-position', null);
|
|
67
|
-
}
|
|
68
|
-
if (options.direction && options.direction != 'forward' && options.direction != 'backward') {
|
|
69
|
-
/**
|
|
70
|
-
* Only `backward` and `forward` direction allowed.
|
|
71
|
-
*
|
|
72
|
-
* @error view-tree-walker-unknown-direction
|
|
73
|
-
*/
|
|
74
|
-
throw new CKEditorError('view-tree-walker-unknown-direction', options.startPosition, { direction: options.direction });
|
|
75
|
-
}
|
|
76
|
-
this.boundaries = options.boundaries || null;
|
|
77
|
-
if (options.startPosition) {
|
|
78
|
-
this._position = ViewPosition._createAt(options.startPosition);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
this._position = ViewPosition._createAt(options.boundaries[options.direction == 'backward' ? 'end' : 'start']);
|
|
82
|
-
}
|
|
83
|
-
this.direction = options.direction || 'forward';
|
|
84
|
-
this.singleCharacters = !!options.singleCharacters;
|
|
85
|
-
this.shallow = !!options.shallow;
|
|
86
|
-
this.ignoreElementEnd = !!options.ignoreElementEnd;
|
|
87
|
-
this._boundaryStartParent = this.boundaries ? this.boundaries.start.parent : null;
|
|
88
|
-
this._boundaryEndParent = this.boundaries ? this.boundaries.end.parent : null;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Iterable interface.
|
|
92
|
-
*/
|
|
93
|
-
[Symbol.iterator]() {
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Iterator position. If start position is not defined then position depends on {@link #direction}. If direction is
|
|
98
|
-
* `'forward'` position starts form the beginning, when direction is `'backward'` position starts from the end.
|
|
99
|
-
*/
|
|
100
|
-
get position() {
|
|
101
|
-
return this._position;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Moves {@link #position} in the {@link #direction} skipping values as long as the callback function returns `true`.
|
|
105
|
-
*
|
|
106
|
-
* For example:
|
|
107
|
-
*
|
|
108
|
-
* ```ts
|
|
109
|
-
* walker.skip( value => value.type == 'text' ); // <p>{}foo</p> -> <p>foo[]</p>
|
|
110
|
-
* walker.skip( value => true ); // Move the position to the end: <p>{}foo</p> -> <p>foo</p>[]
|
|
111
|
-
* walker.skip( value => false ); // Do not move the position.
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* @param skip Callback function. Gets {@link module:engine/view/treewalker~ViewTreeWalkerValue} and should
|
|
115
|
-
* return `true` if the value should be skipped or `false` if not.
|
|
116
|
-
*/
|
|
117
|
-
skip(skip) {
|
|
118
|
-
let nextResult;
|
|
119
|
-
let prevPosition;
|
|
120
|
-
do {
|
|
121
|
-
prevPosition = this.position;
|
|
122
|
-
nextResult = this.next();
|
|
123
|
-
} while (!nextResult.done && skip(nextResult.value));
|
|
124
|
-
if (!nextResult.done) {
|
|
125
|
-
this._position = prevPosition;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Moves tree walker {@link #position} to provided `position`. Tree walker will
|
|
130
|
-
* continue traversing from that position.
|
|
131
|
-
*
|
|
132
|
-
* Note: in contrary to {@link ~ViewTreeWalker#skip}, this method does not iterate over the nodes along the way.
|
|
133
|
-
* It simply sets the current tree walker position to a new one.
|
|
134
|
-
* From the performance standpoint, it is better to use {@link ~ViewTreeWalker#jumpTo} rather than {@link ~ViewTreeWalker#skip}.
|
|
135
|
-
*
|
|
136
|
-
* If the provided position is before the start boundary, the position will be
|
|
137
|
-
* set to the start boundary. If the provided position is after the end boundary,
|
|
138
|
-
* the position will be set to the end boundary.
|
|
139
|
-
* This is done to prevent the treewalker from traversing outside the boundaries.
|
|
140
|
-
*
|
|
141
|
-
* @param position Position to jump to.
|
|
142
|
-
*/
|
|
143
|
-
jumpTo(position) {
|
|
144
|
-
if (this._boundaryStartParent && position.isBefore(this.boundaries.start)) {
|
|
145
|
-
position = this.boundaries.start;
|
|
146
|
-
}
|
|
147
|
-
else if (this._boundaryEndParent && position.isAfter(this.boundaries.end)) {
|
|
148
|
-
position = this.boundaries.end;
|
|
149
|
-
}
|
|
150
|
-
this._position = position.clone();
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Gets the next tree walker's value.
|
|
154
|
-
*
|
|
155
|
-
* @returns Object implementing iterator interface, returning
|
|
156
|
-
* information about taken step.
|
|
157
|
-
*/
|
|
158
|
-
next() {
|
|
159
|
-
if (this.direction == 'forward') {
|
|
160
|
-
return this._next();
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return this._previous();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Makes a step forward in view. Moves the {@link #position} to the next position and returns the encountered value.
|
|
168
|
-
*/
|
|
169
|
-
_next() {
|
|
170
|
-
let position = this.position.clone();
|
|
171
|
-
const previousPosition = this.position;
|
|
172
|
-
const parent = position.parent;
|
|
173
|
-
// We are at the end of the root.
|
|
174
|
-
if (parent.parent === null && position.offset === parent.childCount) {
|
|
175
|
-
return { done: true, value: undefined };
|
|
176
|
-
}
|
|
177
|
-
// We reached the walker boundary.
|
|
178
|
-
if (parent === this._boundaryEndParent && position.offset == this.boundaries.end.offset) {
|
|
179
|
-
return { done: true, value: undefined };
|
|
180
|
-
}
|
|
181
|
-
// Get node just after current position.
|
|
182
|
-
let node;
|
|
183
|
-
// Text is a specific parent because it contains string instead of child nodes.
|
|
184
|
-
if (parent && parent.is('view:$text')) {
|
|
185
|
-
if (position.isAtEnd) {
|
|
186
|
-
// Prevent returning "elementEnd" for Text node. Skip that value and return the next walker step.
|
|
187
|
-
this._position = ViewPosition._createAfter(parent);
|
|
188
|
-
return this._next();
|
|
189
|
-
}
|
|
190
|
-
node = parent.data[position.offset];
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
node = parent.getChild(position.offset);
|
|
194
|
-
}
|
|
195
|
-
if (typeof node == 'string') {
|
|
196
|
-
let textLength;
|
|
197
|
-
if (this.singleCharacters) {
|
|
198
|
-
textLength = 1;
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
// Check if text stick out of walker range.
|
|
202
|
-
const endOffset = parent === this._boundaryEndParent ? this.boundaries.end.offset : parent.data.length;
|
|
203
|
-
textLength = endOffset - position.offset;
|
|
204
|
-
}
|
|
205
|
-
const textProxy = new ViewTextProxy(parent, position.offset, textLength);
|
|
206
|
-
position.offset += textLength;
|
|
207
|
-
this._position = position;
|
|
208
|
-
return this._formatReturnValue('text', textProxy, previousPosition, position, textLength);
|
|
209
|
-
}
|
|
210
|
-
if (node && node.is('view:element')) {
|
|
211
|
-
if (!this.shallow) {
|
|
212
|
-
position = new ViewPosition(node, 0);
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
// We are past the walker boundaries.
|
|
216
|
-
if (this.boundaries && this.boundaries.end.isBefore(position)) {
|
|
217
|
-
return { done: true, value: undefined };
|
|
218
|
-
}
|
|
219
|
-
position.offset++;
|
|
220
|
-
}
|
|
221
|
-
this._position = position;
|
|
222
|
-
return this._formatReturnValue('elementStart', node, previousPosition, position, 1);
|
|
223
|
-
}
|
|
224
|
-
if (node && node.is('view:$text')) {
|
|
225
|
-
if (this.singleCharacters) {
|
|
226
|
-
position = new ViewPosition(node, 0);
|
|
227
|
-
this._position = position;
|
|
228
|
-
return this._next();
|
|
229
|
-
}
|
|
230
|
-
let charactersCount = node.data.length;
|
|
231
|
-
let item;
|
|
232
|
-
// If text stick out of walker range, we need to cut it and wrap in ViewTextProxy.
|
|
233
|
-
if (node == this._boundaryEndParent) {
|
|
234
|
-
charactersCount = this.boundaries.end.offset;
|
|
235
|
-
item = new ViewTextProxy(node, 0, charactersCount);
|
|
236
|
-
position = ViewPosition._createAfter(item);
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
item = new ViewTextProxy(node, 0, node.data.length);
|
|
240
|
-
// If not just keep moving forward.
|
|
241
|
-
position.offset++;
|
|
242
|
-
}
|
|
243
|
-
this._position = position;
|
|
244
|
-
return this._formatReturnValue('text', item, previousPosition, position, charactersCount);
|
|
245
|
-
}
|
|
246
|
-
// `node` is not set, we reached the end of current `parent`.
|
|
247
|
-
position = ViewPosition._createAfter(parent);
|
|
248
|
-
this._position = position;
|
|
249
|
-
if (this.ignoreElementEnd) {
|
|
250
|
-
return this._next();
|
|
251
|
-
}
|
|
252
|
-
return this._formatReturnValue('elementEnd', parent, previousPosition, position);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Makes a step backward in view. Moves the {@link #position} to the previous position and returns the encountered value.
|
|
256
|
-
*/
|
|
257
|
-
_previous() {
|
|
258
|
-
let position = this.position.clone();
|
|
259
|
-
const previousPosition = this.position;
|
|
260
|
-
const parent = position.parent;
|
|
261
|
-
// We are at the beginning of the root.
|
|
262
|
-
if (parent.parent === null && position.offset === 0) {
|
|
263
|
-
return { done: true, value: undefined };
|
|
264
|
-
}
|
|
265
|
-
// We reached the walker boundary.
|
|
266
|
-
if (parent == this._boundaryStartParent && position.offset == this.boundaries.start.offset) {
|
|
267
|
-
return { done: true, value: undefined };
|
|
268
|
-
}
|
|
269
|
-
// Get node just before current position.
|
|
270
|
-
let node;
|
|
271
|
-
// Text {@link module:engine/view/text~ViewText} element is a specific parent because contains string instead of child nodes.
|
|
272
|
-
if (parent.is('view:$text')) {
|
|
273
|
-
if (position.isAtStart) {
|
|
274
|
-
// Prevent returning "elementStart" for Text node. Skip that value and return the next walker step.
|
|
275
|
-
this._position = ViewPosition._createBefore(parent);
|
|
276
|
-
return this._previous();
|
|
277
|
-
}
|
|
278
|
-
node = parent.data[position.offset - 1];
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
node = parent.getChild(position.offset - 1);
|
|
282
|
-
}
|
|
283
|
-
if (typeof node == 'string') {
|
|
284
|
-
let textLength;
|
|
285
|
-
if (!this.singleCharacters) {
|
|
286
|
-
// Check if text stick out of walker range.
|
|
287
|
-
const startOffset = parent === this._boundaryStartParent ? this.boundaries.start.offset : 0;
|
|
288
|
-
textLength = position.offset - startOffset;
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
textLength = 1;
|
|
292
|
-
}
|
|
293
|
-
position.offset -= textLength;
|
|
294
|
-
const textProxy = new ViewTextProxy(parent, position.offset, textLength);
|
|
295
|
-
this._position = position;
|
|
296
|
-
return this._formatReturnValue('text', textProxy, previousPosition, position, textLength);
|
|
297
|
-
}
|
|
298
|
-
if (node && node.is('view:element')) {
|
|
299
|
-
if (this.shallow) {
|
|
300
|
-
position.offset--;
|
|
301
|
-
this._position = position;
|
|
302
|
-
return this._formatReturnValue('elementStart', node, previousPosition, position, 1);
|
|
303
|
-
}
|
|
304
|
-
position = new ViewPosition(node, node.childCount);
|
|
305
|
-
this._position = position;
|
|
306
|
-
if (this.ignoreElementEnd) {
|
|
307
|
-
return this._previous();
|
|
308
|
-
}
|
|
309
|
-
return this._formatReturnValue('elementEnd', node, previousPosition, position);
|
|
310
|
-
}
|
|
311
|
-
if (node && node.is('view:$text')) {
|
|
312
|
-
if (this.singleCharacters) {
|
|
313
|
-
position = new ViewPosition(node, node.data.length);
|
|
314
|
-
this._position = position;
|
|
315
|
-
return this._previous();
|
|
316
|
-
}
|
|
317
|
-
let charactersCount = node.data.length;
|
|
318
|
-
let item;
|
|
319
|
-
// If text stick out of walker range, we need to cut it and wrap in ViewTextProxy.
|
|
320
|
-
if (node == this._boundaryStartParent) {
|
|
321
|
-
const offset = this.boundaries.start.offset;
|
|
322
|
-
item = new ViewTextProxy(node, offset, node.data.length - offset);
|
|
323
|
-
charactersCount = item.data.length;
|
|
324
|
-
position = ViewPosition._createBefore(item);
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
item = new ViewTextProxy(node, 0, node.data.length);
|
|
328
|
-
// If not just keep moving backward.
|
|
329
|
-
position.offset--;
|
|
330
|
-
}
|
|
331
|
-
this._position = position;
|
|
332
|
-
return this._formatReturnValue('text', item, previousPosition, position, charactersCount);
|
|
333
|
-
}
|
|
334
|
-
// `node` is not set, we reached the beginning of current `parent`.
|
|
335
|
-
position = ViewPosition._createBefore(parent);
|
|
336
|
-
this._position = position;
|
|
337
|
-
return this._formatReturnValue('elementStart', parent, previousPosition, position, 1);
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Format returned data and adjust `previousPosition` and `nextPosition` if
|
|
341
|
-
* reach the bound of the {@link module:engine/view/text~ViewText}.
|
|
342
|
-
*
|
|
343
|
-
* @param type Type of step.
|
|
344
|
-
* @param item Item between old and new position.
|
|
345
|
-
* @param previousPosition Previous position of iterator.
|
|
346
|
-
* @param nextPosition Next position of iterator.
|
|
347
|
-
* @param length Length of the item.
|
|
348
|
-
*/
|
|
349
|
-
_formatReturnValue(type, item, previousPosition, nextPosition, length) {
|
|
350
|
-
// Text is a specific parent, because contains string instead of children.
|
|
351
|
-
// Walker doesn't enter to the Text except situations when walker is iterating over every single character,
|
|
352
|
-
// or the bound starts/ends inside the Text. So when the position is at the beginning or at the end of the Text
|
|
353
|
-
// we move it just before or just after Text.
|
|
354
|
-
if (item.is('view:$textProxy')) {
|
|
355
|
-
// Position is at the end of Text.
|
|
356
|
-
if (item.offsetInText + item.data.length == item.textNode.data.length) {
|
|
357
|
-
if (this.direction == 'forward' && !(this.boundaries && this.boundaries.end.isEqual(this.position))) {
|
|
358
|
-
nextPosition = ViewPosition._createAfter(item.textNode);
|
|
359
|
-
// When we change nextPosition of returned value we need also update walker current position.
|
|
360
|
-
this._position = nextPosition;
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
previousPosition = ViewPosition._createAfter(item.textNode);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
// Position is at the begining ot the text.
|
|
367
|
-
if (item.offsetInText === 0) {
|
|
368
|
-
if (this.direction == 'backward' && !(this.boundaries && this.boundaries.start.isEqual(this.position))) {
|
|
369
|
-
nextPosition = ViewPosition._createBefore(item.textNode);
|
|
370
|
-
// When we change nextPosition of returned value we need also update walker current position.
|
|
371
|
-
this._position = nextPosition;
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
374
|
-
previousPosition = ViewPosition._createBefore(item.textNode);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
return {
|
|
379
|
-
done: false,
|
|
380
|
-
value: {
|
|
381
|
-
type,
|
|
382
|
-
item,
|
|
383
|
-
previousPosition,
|
|
384
|
-
nextPosition,
|
|
385
|
-
length
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module engine/view/typecheckable
|
|
7
|
-
*/
|
|
8
|
-
export class ViewTypeCheckable {
|
|
9
|
-
/* istanbul ignore next -- @preserve */
|
|
10
|
-
is() {
|
|
11
|
-
// There are a lot of overloads above.
|
|
12
|
-
// Overriding method in derived classes remove them and only `is( type: string ): boolean` is visible which we don't want.
|
|
13
|
-
// One option would be to copy them all to all classes, but that's ugly.
|
|
14
|
-
// It's best when TypeScript compiler doesn't see those overloads, except the one in the top base class.
|
|
15
|
-
// To overload a method, but not let the compiler see it, do after class definition:
|
|
16
|
-
// `MyClass.prototype.is = function( type: string ) {...}`
|
|
17
|
-
throw new Error('is() method is abstract');
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/view/uielement.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module engine/view/uielement
|
|
7
|
-
*/
|
|
8
|
-
import { ViewElement } from './element.js';
|
|
9
|
-
import { ViewNode } from './node.js';
|
|
10
|
-
import { CKEditorError, keyCodes } from '@ckeditor/ckeditor5-utils';
|
|
11
|
-
/**
|
|
12
|
-
* UI element class. It should be used to represent editing UI which needs to be injected into the editing view
|
|
13
|
-
* If possible, you should keep your UI outside the editing view. However, if that is not possible,
|
|
14
|
-
* UI elements can be used.
|
|
15
|
-
*
|
|
16
|
-
* How a UI element is rendered is in your control (you pass a callback to
|
|
17
|
-
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createUIElement `downcastWriter#createUIElement()`}).
|
|
18
|
-
* The editor will ignore your UI element – the selection cannot be placed in it, it is skipped (invisible) when
|
|
19
|
-
* the user modifies the selection by using arrow keys and the editor does not listen to any mutations which
|
|
20
|
-
* happen inside your UI elements.
|
|
21
|
-
*
|
|
22
|
-
* The limitation is that you cannot convert a model element to a UI element. UI elements need to be
|
|
23
|
-
* created for {@link module:engine/model/markercollection~Marker markers} or as additinal elements
|
|
24
|
-
* inside normal {@link module:engine/view/containerelement~ViewContainerElement container elements}.
|
|
25
|
-
*
|
|
26
|
-
* To create a new UI element use the
|
|
27
|
-
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createUIElement `downcastWriter#createUIElement()`} method.
|
|
28
|
-
*/
|
|
29
|
-
export class ViewUIElement extends ViewElement {
|
|
30
|
-
/**
|
|
31
|
-
* Creates new instance of UIElement.
|
|
32
|
-
*
|
|
33
|
-
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-uielement-cannot-add` when third parameter is passed,
|
|
34
|
-
* to inform that usage of UIElement is incorrect (adding child nodes to UIElement is forbidden).
|
|
35
|
-
*
|
|
36
|
-
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createUIElement
|
|
37
|
-
* @internal
|
|
38
|
-
* @param document The document instance to which this element belongs.
|
|
39
|
-
* @param name Node name.
|
|
40
|
-
* @param attrs Collection of attributes.
|
|
41
|
-
* @param children A list of nodes to be inserted into created element.
|
|
42
|
-
*/
|
|
43
|
-
constructor(document, name, attrs, children) {
|
|
44
|
-
super(document, name, attrs, children);
|
|
45
|
-
this.getFillerOffset = getFillerOffset;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Overrides {@link module:engine/view/element~ViewElement#_insertChild} method.
|
|
49
|
-
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-uielement-cannot-add` to prevent adding any child nodes
|
|
50
|
-
* to UIElement.
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
_insertChild(index, items) {
|
|
55
|
-
if (items && (items instanceof ViewNode || Array.from(items).length > 0)) {
|
|
56
|
-
/**
|
|
57
|
-
* Cannot add children to {@link module:engine/view/uielement~ViewUIElement}.
|
|
58
|
-
*
|
|
59
|
-
* @error view-uielement-cannot-add
|
|
60
|
-
*/
|
|
61
|
-
throw new CKEditorError('view-uielement-cannot-add', [this, items]);
|
|
62
|
-
}
|
|
63
|
-
return 0;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Renders this {@link module:engine/view/uielement~ViewUIElement} to DOM. This method is called by
|
|
67
|
-
* {@link module:engine/view/domconverter~ViewDomConverter}.
|
|
68
|
-
* Do not use inheritance to create custom rendering method, replace `render()` method instead:
|
|
69
|
-
*
|
|
70
|
-
* ```ts
|
|
71
|
-
* const myUIElement = downcastWriter.createUIElement( 'span' );
|
|
72
|
-
* myUIElement.render = function( domDocument, domConverter ) {
|
|
73
|
-
* const domElement = this.toDomElement( domDocument );
|
|
74
|
-
*
|
|
75
|
-
* domConverter.setContentOf( domElement, '<b>this is ui element</b>' );
|
|
76
|
-
*
|
|
77
|
-
* return domElement;
|
|
78
|
-
* };
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* If changes in your UI element should trigger some editor UI update you should call
|
|
82
|
-
* the {@link module:ui/editorui/editorui~EditorUI#update `editor.ui.update()`} method
|
|
83
|
-
* after rendering your UI element.
|
|
84
|
-
*
|
|
85
|
-
* @param domConverter Instance of the ViewDomConverter used to optimize the output.
|
|
86
|
-
*/
|
|
87
|
-
render(domDocument, domConverter // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
88
|
-
) {
|
|
89
|
-
// Provide basic, default output.
|
|
90
|
-
return this.toDomElement(domDocument);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Creates DOM element based on this view UIElement.
|
|
94
|
-
* Note that each time this method is called new DOM element is created.
|
|
95
|
-
*/
|
|
96
|
-
toDomElement(domDocument) {
|
|
97
|
-
const domElement = domDocument.createElement(this.name);
|
|
98
|
-
for (const key of this.getAttributeKeys()) {
|
|
99
|
-
domElement.setAttribute(key, this.getAttribute(key));
|
|
100
|
-
}
|
|
101
|
-
return domElement;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Converts `ViewUIElement` instance to plain object and returns it.
|
|
105
|
-
*
|
|
106
|
-
* @returns `ViewUIElement` instance converted to plain object.
|
|
107
|
-
*/
|
|
108
|
-
toJSON() {
|
|
109
|
-
const json = super.toJSON();
|
|
110
|
-
json.type = 'UIElement';
|
|
111
|
-
return json;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
115
|
-
// Proper overload would interfere with that.
|
|
116
|
-
ViewUIElement.prototype.is = function (type, name) {
|
|
117
|
-
if (!name) {
|
|
118
|
-
return type === 'uiElement' || type === 'view:uiElement' ||
|
|
119
|
-
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
120
|
-
type === 'element' || type === 'view:element' ||
|
|
121
|
-
type === 'node' || type === 'view:node';
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
return name === this.name && (type === 'uiElement' || type === 'view:uiElement' ||
|
|
125
|
-
type === 'element' || type === 'view:element');
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* This function injects UI element handling to the given {@link module:engine/view/document~ViewDocument document}.
|
|
130
|
-
*
|
|
131
|
-
* A callback is added to {@link module:engine/view/document~ViewDocument#event:keydown document keydown event}.
|
|
132
|
-
* The callback handles the situation when right arrow key is pressed and selection is collapsed before a UI element.
|
|
133
|
-
* Without this handler, it would be impossible to "jump over" UI element using right arrow key.
|
|
134
|
-
*
|
|
135
|
-
* @param view View controller to which the quirks handling will be injected.
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
export function injectUiElementHandling(view) {
|
|
139
|
-
view.document.on('arrowKey', (evt, data) => jumpOverUiElement(evt, data, view.domConverter), { priority: 'low' });
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Returns `null` because block filler is not needed for UIElements.
|
|
143
|
-
*/
|
|
144
|
-
function getFillerOffset() {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Selection cannot be placed in a `UIElement`. Whenever it is placed there, it is moved before it. This
|
|
149
|
-
* causes a situation when it is impossible to jump over `UIElement` using right arrow key, because the selection
|
|
150
|
-
* ends up in ui element (in DOM) and is moved back to the left. This handler fixes this situation.
|
|
151
|
-
*/
|
|
152
|
-
function jumpOverUiElement(evt, data, domConverter) {
|
|
153
|
-
if (data.keyCode == keyCodes.arrowright) {
|
|
154
|
-
const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();
|
|
155
|
-
const domSelectionCollapsed = domSelection.rangeCount == 1 && domSelection.getRangeAt(0).collapsed;
|
|
156
|
-
// Jump over UI element if selection is collapsed or shift key is pressed. These are the cases when selection would extend.
|
|
157
|
-
if (domSelectionCollapsed || data.shiftKey) {
|
|
158
|
-
const domParent = domSelection.focusNode;
|
|
159
|
-
const domOffset = domSelection.focusOffset;
|
|
160
|
-
const viewPosition = domConverter.domPositionToView(domParent, domOffset);
|
|
161
|
-
// In case if dom element is not converted to view or is not mapped or something. Happens for example in some tests.
|
|
162
|
-
if (viewPosition === null) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
// Skip all following ui elements.
|
|
166
|
-
let jumpedOverAnyUiElement = false;
|
|
167
|
-
const nextViewPosition = viewPosition.getLastMatchingPosition(value => {
|
|
168
|
-
if (value.item.is('uiElement')) {
|
|
169
|
-
// Remember that there was at least one ui element.
|
|
170
|
-
jumpedOverAnyUiElement = true;
|
|
171
|
-
}
|
|
172
|
-
// Jump over ui elements, jump over empty attribute elements, move up from inside of attribute element.
|
|
173
|
-
if (value.item.is('uiElement') || value.item.is('attributeElement')) {
|
|
174
|
-
return true;
|
|
175
|
-
}
|
|
176
|
-
// Don't jump over text or don't get out of container element.
|
|
177
|
-
return false;
|
|
178
|
-
});
|
|
179
|
-
// If anything has been skipped, fix position.
|
|
180
|
-
// This `if` could be possibly omitted but maybe it is better not to mess with DOM selection if not needed.
|
|
181
|
-
if (jumpedOverAnyUiElement) {
|
|
182
|
-
const newDomPosition = domConverter.viewPositionToDom(nextViewPosition);
|
|
183
|
-
if (domSelectionCollapsed) {
|
|
184
|
-
// Selection was collapsed, so collapse it at further position.
|
|
185
|
-
domSelection.collapse(newDomPosition.parent, newDomPosition.offset);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
// Selection was not collapse, so extend it instead of collapsing.
|
|
189
|
-
domSelection.extend(newDomPosition.parent, newDomPosition.offset);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|