@ckeditor/ckeditor5-engine 45.2.1-alpha.9 → 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/model/selection.js
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/selection
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
8
|
+
import { ModelTypeCheckable } from './typecheckable.js';
|
|
9
|
+
import { ModelNode } from './node.js';
|
|
10
|
+
import { ModelPosition } from './position.js';
|
|
11
|
+
import { ModelRange } from './range.js';
|
|
12
12
|
import { CKEditorError, EmitterMixin, isIterable } from '@ckeditor/ckeditor5-utils';
|
|
13
13
|
/**
|
|
14
|
-
* Selection is a set of {@link module:engine/model/range~
|
|
15
|
-
* {@link module:engine/model/selection~
|
|
16
|
-
* (it can be {@link module:engine/model/selection~
|
|
14
|
+
* Selection is a set of {@link module:engine/model/range~ModelRange ranges}. It has a direction specified by its
|
|
15
|
+
* {@link module:engine/model/selection~ModelSelection#anchor anchor} and {@link module:engine/model/selection~ModelSelection#focus focus}
|
|
16
|
+
* (it can be {@link module:engine/model/selection~ModelSelection#isBackward forward or backward}).
|
|
17
17
|
* Additionally, selection may have its own attributes (think – whether text typed in in this selection
|
|
18
18
|
* should have those attributes – e.g. whether you type a bolded text).
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export class ModelSelection extends /* #__PURE__ */ EmitterMixin(ModelTypeCheckable) {
|
|
21
21
|
/**
|
|
22
22
|
* Specifies whether the last added range was added as a backward or forward range.
|
|
23
23
|
*/
|
|
@@ -29,7 +29,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
29
29
|
/** @internal */
|
|
30
30
|
_ranges = [];
|
|
31
31
|
/**
|
|
32
|
-
* Creates a new selection instance based on the given {@link module:engine/model/selection~
|
|
32
|
+
* Creates a new selection instance based on the given {@link module:engine/model/selection~ModelSelectable selectable}
|
|
33
33
|
* or creates an empty selection if no arguments were passed.
|
|
34
34
|
*
|
|
35
35
|
* ```ts
|
|
@@ -62,11 +62,11 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
62
62
|
* const paragraph = writer.createElement( 'paragraph' );
|
|
63
63
|
* const selection = writer.createSelection( paragraph, offset );
|
|
64
64
|
*
|
|
65
|
-
* // Creates a range inside an {@link module:engine/model/element~
|
|
65
|
+
* // Creates a range inside an {@link module:engine/model/element~ModelElement element} which starts before the
|
|
66
66
|
* // first child of that element and ends after the last child of that element.
|
|
67
67
|
* const selection = writer.createSelection( paragraph, 'in' );
|
|
68
68
|
*
|
|
69
|
-
* // Creates a range on an {@link module:engine/model/item~
|
|
69
|
+
* // Creates a range on an {@link module:engine/model/item~ModelItem item} which starts before the item and ends
|
|
70
70
|
* // just after the item.
|
|
71
71
|
* const selection = writer.createSelection( paragraph, 'on' );
|
|
72
72
|
* ```
|
|
@@ -93,8 +93,8 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
93
93
|
* Anchor and {@link #focus} define the direction of the selection, which is important
|
|
94
94
|
* when expanding/shrinking selection. The focus moves, while the anchor should remain in the same place.
|
|
95
95
|
*
|
|
96
|
-
* Anchor is always set to the {@link module:engine/model/range~
|
|
97
|
-
* {@link module:engine/model/range~
|
|
96
|
+
* Anchor is always set to the {@link module:engine/model/range~ModelRange#start start} or
|
|
97
|
+
* {@link module:engine/model/range~ModelRange#end end} position of the last of selection's ranges. Whether it is
|
|
98
98
|
* the `start` or `end` depends on the specified `options.backward`. See the {@link #setTo `setTo()`} method.
|
|
99
99
|
*
|
|
100
100
|
* May be set to `null` if there are no ranges in the selection.
|
|
@@ -184,13 +184,13 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
184
184
|
*/
|
|
185
185
|
*getRanges() {
|
|
186
186
|
for (const range of this._ranges) {
|
|
187
|
-
yield new
|
|
187
|
+
yield new ModelRange(range.start, range.end);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Returns a copy of the first range in the selection.
|
|
192
|
-
* First range is the one which {@link module:engine/model/range~
|
|
193
|
-
* {@link module:engine/model/position~
|
|
192
|
+
* First range is the one which {@link module:engine/model/range~ModelRange#start start} position
|
|
193
|
+
* {@link module:engine/model/position~ModelPosition#isBefore is before} start position of all other ranges
|
|
194
194
|
* (not to confuse with the first range added to the selection).
|
|
195
195
|
*
|
|
196
196
|
* Returns `null` if there are no ranges in selection.
|
|
@@ -202,13 +202,13 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
202
202
|
first = range;
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
return first ? new
|
|
205
|
+
return first ? new ModelRange(first.start, first.end) : null;
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
208
|
* Returns a copy of the last range in the selection.
|
|
209
|
-
* Last range is the one which {@link module:engine/model/range~
|
|
210
|
-
* {@link module:engine/model/position~
|
|
211
|
-
* recently added to the selection).
|
|
209
|
+
* Last range is the one which {@link module:engine/model/range~ModelRange#end end} position
|
|
210
|
+
* {@link module:engine/model/position~ModelPosition#isAfter is after} end position of all other
|
|
211
|
+
* ranges (not to confuse with the range most recently added to the selection).
|
|
212
212
|
*
|
|
213
213
|
* Returns `null` if there are no ranges in selection.
|
|
214
214
|
*/
|
|
@@ -219,11 +219,11 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
219
219
|
last = range;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
return last ? new
|
|
222
|
+
return last ? new ModelRange(last.start, last.end) : null;
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
225
|
* Returns the first position in the selection.
|
|
226
|
-
* First position is the position that {@link module:engine/model/position~
|
|
226
|
+
* First position is the position that {@link module:engine/model/position~ModelPosition#isBefore is before}
|
|
227
227
|
* any other position in the selection.
|
|
228
228
|
*
|
|
229
229
|
* Returns `null` if there are no ranges in selection.
|
|
@@ -234,7 +234,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Returns the last position in the selection.
|
|
237
|
-
* Last position is the position that {@link module:engine/model/position~
|
|
237
|
+
* Last position is the position that {@link module:engine/model/position~ModelPosition#isAfter is after}
|
|
238
238
|
* any other position in the selection.
|
|
239
239
|
*
|
|
240
240
|
* Returns `null` if there are no ranges in selection.
|
|
@@ -245,7 +245,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
247
|
* Sets this selection's ranges and direction to the specified location based on the given
|
|
248
|
-
* {@link module:engine/model/selection~
|
|
248
|
+
* {@link module:engine/model/selection~ModelSelectable selectable}.
|
|
249
249
|
*
|
|
250
250
|
* ```ts
|
|
251
251
|
* // Removes all selection's ranges.
|
|
@@ -266,7 +266,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
266
266
|
*
|
|
267
267
|
* // Sets selection to the given document selection.
|
|
268
268
|
* // Note: It doesn't copy selection attributes.
|
|
269
|
-
* const documentSelection = new
|
|
269
|
+
* const documentSelection = new ModelDocumentSelection( doc );
|
|
270
270
|
* selection.setTo( documentSelection );
|
|
271
271
|
*
|
|
272
272
|
* // Sets collapsed selection at the given position.
|
|
@@ -277,14 +277,14 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
277
277
|
* selection.setTo( paragraph, offset );
|
|
278
278
|
* ```
|
|
279
279
|
*
|
|
280
|
-
* Creates a range inside an {@link module:engine/model/element~
|
|
280
|
+
* Creates a range inside an {@link module:engine/model/element~ModelElement element} which starts before the first child of
|
|
281
281
|
* that element and ends after the last child of that element.
|
|
282
282
|
*
|
|
283
283
|
* ```ts
|
|
284
284
|
* selection.setTo( paragraph, 'in' );
|
|
285
285
|
* ```
|
|
286
286
|
*
|
|
287
|
-
* Creates a range on an {@link module:engine/model/item~
|
|
287
|
+
* Creates a range on an {@link module:engine/model/item~ModelItem item} which starts before the item and ends just after the item.
|
|
288
288
|
*
|
|
289
289
|
* ```ts
|
|
290
290
|
* selection.setTo( paragraph, 'on' );
|
|
@@ -306,31 +306,31 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
306
306
|
if (selectable === null) {
|
|
307
307
|
this._setRanges([]);
|
|
308
308
|
}
|
|
309
|
-
else if (selectable instanceof
|
|
309
|
+
else if (selectable instanceof ModelSelection) {
|
|
310
310
|
this._setRanges(selectable.getRanges(), selectable.isBackward);
|
|
311
311
|
}
|
|
312
312
|
else if (selectable && typeof selectable.getRanges == 'function') {
|
|
313
|
-
// We assume that the selectable is a
|
|
313
|
+
// We assume that the selectable is a ModelDocumentSelection.
|
|
314
314
|
// It can't be imported here, because it would lead to circular imports.
|
|
315
315
|
this._setRanges(selectable.getRanges(), selectable.isBackward);
|
|
316
316
|
}
|
|
317
|
-
else if (selectable instanceof
|
|
317
|
+
else if (selectable instanceof ModelRange) {
|
|
318
318
|
this._setRanges([selectable], !!options && !!options.backward);
|
|
319
319
|
}
|
|
320
|
-
else if (selectable instanceof
|
|
321
|
-
this._setRanges([new
|
|
320
|
+
else if (selectable instanceof ModelPosition) {
|
|
321
|
+
this._setRanges([new ModelRange(selectable)]);
|
|
322
322
|
}
|
|
323
|
-
else if (selectable instanceof
|
|
323
|
+
else if (selectable instanceof ModelNode) {
|
|
324
324
|
const backward = !!options && !!options.backward;
|
|
325
325
|
let range;
|
|
326
326
|
if (placeOrOffset == 'in') {
|
|
327
|
-
range =
|
|
327
|
+
range = ModelRange._createIn(selectable);
|
|
328
328
|
}
|
|
329
329
|
else if (placeOrOffset == 'on') {
|
|
330
|
-
range =
|
|
330
|
+
range = ModelRange._createOn(selectable);
|
|
331
331
|
}
|
|
332
332
|
else if (placeOrOffset !== undefined) {
|
|
333
|
-
range = new
|
|
333
|
+
range = new ModelRange(ModelPosition._createAt(selectable, placeOrOffset));
|
|
334
334
|
}
|
|
335
335
|
else {
|
|
336
336
|
/**
|
|
@@ -352,8 +352,8 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
352
352
|
*
|
|
353
353
|
* Invalid parameters were specified when setting the selection. Common issues:
|
|
354
354
|
*
|
|
355
|
-
* * A {@link module:engine/model/textproxy~
|
|
356
|
-
* a real {@link module:engine/model/text~
|
|
355
|
+
* * A {@link module:engine/model/textproxy~ModelTextProxy} instance was passed instead of
|
|
356
|
+
* a real {@link module:engine/model/text~ModelText}.
|
|
357
357
|
* * View nodes were passed instead of model nodes.
|
|
358
358
|
* * `null`/`undefined` was passed.
|
|
359
359
|
*
|
|
@@ -364,8 +364,8 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
366
366
|
* Replaces all ranges that were added to the selection with given array of ranges. Last range of the array
|
|
367
|
-
* is treated like the last added range and is used to set {@link module:engine/model/selection~
|
|
368
|
-
* {@link module:engine/model/selection~
|
|
367
|
+
* is treated like the last added range and is used to set {@link module:engine/model/selection~ModelSelection#anchor} and
|
|
368
|
+
* {@link module:engine/model/selection~ModelSelection#focus}. Accepts a flag describing in which direction the selection is made.
|
|
369
369
|
*
|
|
370
370
|
* @fires change:range
|
|
371
371
|
* @param newRanges Ranges to set.
|
|
@@ -376,11 +376,11 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
376
376
|
const ranges = Array.from(newRanges);
|
|
377
377
|
// Check whether there is any range in new ranges set that is different than all already added ranges.
|
|
378
378
|
const anyNewRange = ranges.some(newRange => {
|
|
379
|
-
if (!(newRange instanceof
|
|
379
|
+
if (!(newRange instanceof ModelRange)) {
|
|
380
380
|
/**
|
|
381
|
-
* Selection range set to an object that is not an instance of {@link module:engine/model/range~
|
|
381
|
+
* Selection range set to an object that is not an instance of {@link module:engine/model/range~ModelRange}.
|
|
382
382
|
*
|
|
383
|
-
* Only {@link module:engine/model/range~
|
|
383
|
+
* Only {@link module:engine/model/range~ModelRange} instances can be used to set a selection.
|
|
384
384
|
* Common mistakes leading to this error are:
|
|
385
385
|
*
|
|
386
386
|
* * using DOM `Range` object,
|
|
@@ -403,13 +403,13 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
403
403
|
this.fire('change:range', { directChange: true });
|
|
404
404
|
}
|
|
405
405
|
/**
|
|
406
|
-
* Moves {@link module:engine/model/selection~
|
|
406
|
+
* Moves {@link module:engine/model/selection~ModelSelection#focus} to the specified location.
|
|
407
407
|
*
|
|
408
408
|
* The location can be specified in the same form as
|
|
409
|
-
* {@link module:engine/model/writer~
|
|
409
|
+
* {@link module:engine/model/writer~ModelWriter#createPositionAt writer.createPositionAt()} parameters.
|
|
410
410
|
*
|
|
411
411
|
* @fires change:range
|
|
412
|
-
* @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~
|
|
412
|
+
* @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~ModelItem model item}.
|
|
413
413
|
*/
|
|
414
414
|
setFocus(itemOrPosition, offset) {
|
|
415
415
|
if (this.anchor === null) {
|
|
@@ -420,7 +420,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
420
420
|
*/
|
|
421
421
|
throw new CKEditorError('model-selection-setfocus-no-ranges', [this, itemOrPosition]);
|
|
422
422
|
}
|
|
423
|
-
const newFocus =
|
|
423
|
+
const newFocus = ModelPosition._createAt(itemOrPosition, offset);
|
|
424
424
|
if (newFocus.compareWith(this.focus) == 'same') {
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
@@ -429,11 +429,11 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
429
429
|
this._popRange();
|
|
430
430
|
}
|
|
431
431
|
if (newFocus.compareWith(anchor) == 'before') {
|
|
432
|
-
this._pushRange(new
|
|
432
|
+
this._pushRange(new ModelRange(newFocus, anchor));
|
|
433
433
|
this._lastRangeBackward = true;
|
|
434
434
|
}
|
|
435
435
|
else {
|
|
436
|
-
this._pushRange(new
|
|
436
|
+
this._pushRange(new ModelRange(anchor, newFocus));
|
|
437
437
|
this._lastRangeBackward = false;
|
|
438
438
|
}
|
|
439
439
|
this.fire('change:range', { directChange: true });
|
|
@@ -503,7 +503,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
/**
|
|
506
|
-
* Returns the selected element. {@link module:engine/model/element~
|
|
506
|
+
* Returns the selected element. {@link module:engine/model/element~ModelElement Element} is considered as selected if there is only
|
|
507
507
|
* one range in the selection, and that range contains exactly one element.
|
|
508
508
|
* Returns `null` if there is no selected element.
|
|
509
509
|
*/
|
|
@@ -514,7 +514,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
514
514
|
return this.getFirstRange().getContainedElement();
|
|
515
515
|
}
|
|
516
516
|
/**
|
|
517
|
-
* Gets elements of type {@link module:engine/model/schema~
|
|
517
|
+
* Gets elements of type {@link module:engine/model/schema~ModelSchema#isBlock "block"} touched by the selection.
|
|
518
518
|
*
|
|
519
519
|
* This method's result can be used for example to apply block styling to all blocks covered by this selection.
|
|
520
520
|
*
|
|
@@ -594,7 +594,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
594
594
|
else if (value.type == 'elementStart' &&
|
|
595
595
|
block.is('model:element') &&
|
|
596
596
|
block.root.document.model.schema.isBlock(block)) {
|
|
597
|
-
treewalker.jumpTo(
|
|
597
|
+
treewalker.jumpTo(ModelPosition._createAt(block, 'end'));
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
const endBlock = getParentBlock(range.end, visited);
|
|
@@ -605,15 +605,15 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
607
607
|
* Checks whether the selection contains the entire content of the given element. This means that selection must start
|
|
608
|
-
* at a position {@link module:engine/model/position~
|
|
608
|
+
* at a position {@link module:engine/model/position~ModelPosition#isTouching touching} the element's start and ends at position
|
|
609
609
|
* touching the element's end.
|
|
610
610
|
*
|
|
611
611
|
* By default, this method will check whether the entire content of the selection's current root is selected.
|
|
612
612
|
* Useful to check if e.g. the user has just pressed <kbd>Ctrl</kbd> + <kbd>A</kbd>.
|
|
613
613
|
*/
|
|
614
614
|
containsEntireContent(element = this.anchor.root) {
|
|
615
|
-
const limitStartPosition =
|
|
616
|
-
const limitEndPosition =
|
|
615
|
+
const limitStartPosition = ModelPosition._createAt(element, 0);
|
|
616
|
+
const limitEndPosition = ModelPosition._createAt(element, 'end');
|
|
617
617
|
return limitStartPosition.isTouching(this.getFirstPosition()) &&
|
|
618
618
|
limitEndPosition.isTouching(this.getLastPosition());
|
|
619
619
|
}
|
|
@@ -623,7 +623,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
623
623
|
*/
|
|
624
624
|
_pushRange(range) {
|
|
625
625
|
this._checkRange(range);
|
|
626
|
-
this._ranges.push(new
|
|
626
|
+
this._ranges.push(new ModelRange(range.start, range.end));
|
|
627
627
|
}
|
|
628
628
|
/**
|
|
629
629
|
* Checks if given range intersects with ranges that are already in the selection. Throws an error if it does.
|
|
@@ -635,8 +635,8 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
635
635
|
* Trying to add a range that intersects with another range in the selection.
|
|
636
636
|
*
|
|
637
637
|
* @error model-selection-range-intersects
|
|
638
|
-
* @param {module:engine/model/range~
|
|
639
|
-
* @param {module:engine/model/range~
|
|
638
|
+
* @param {module:engine/model/range~ModelRange} addedRange Range that was added to the selection.
|
|
639
|
+
* @param {module:engine/model/range~ModelRange} intersectingRange Range in the selection that intersects with `addedRange`.
|
|
640
640
|
*/
|
|
641
641
|
throw new CKEditorError('model-selection-range-intersects', [this, range], { addedRange: range, intersectingRange: this._ranges[i] });
|
|
642
642
|
}
|
|
@@ -670,7 +670,7 @@ export default class Selection extends /* #__PURE__ */ EmitterMixin(TypeCheckabl
|
|
|
670
670
|
}
|
|
671
671
|
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
672
672
|
// Proper overload would interfere with that.
|
|
673
|
-
|
|
673
|
+
ModelSelection.prototype.is = function (type) {
|
|
674
674
|
return type === 'selection' || type === 'model:selection';
|
|
675
675
|
};
|
|
676
676
|
/**
|
|
@@ -722,7 +722,7 @@ function isTopBlockInRange(block, range) {
|
|
|
722
722
|
return true;
|
|
723
723
|
}
|
|
724
724
|
// Add loose flag to check as parentRange can be equal to range.
|
|
725
|
-
const isParentInRange = range.containsRange(
|
|
725
|
+
const isParentInRange = range.containsRange(ModelRange._createOn(parentBlock), true);
|
|
726
726
|
return !isParentInRange;
|
|
727
727
|
}
|
|
728
728
|
/**
|
|
@@ -748,7 +748,7 @@ function isStartBlockSelected(startBlock, range) {
|
|
|
748
748
|
if (range.isCollapsed || startBlock.isEmpty) {
|
|
749
749
|
return true;
|
|
750
750
|
}
|
|
751
|
-
if (range.start.isTouching(
|
|
751
|
+
if (range.start.isTouching(ModelPosition._createAt(startBlock, startBlock.maxOffset))) {
|
|
752
752
|
return false;
|
|
753
753
|
}
|
|
754
754
|
return isTopBlockInRange(startBlock, range);
|
|
@@ -776,7 +776,7 @@ function isEndBlockSelected(endBlock, range) {
|
|
|
776
776
|
if (range.isCollapsed || endBlock.isEmpty) {
|
|
777
777
|
return true;
|
|
778
778
|
}
|
|
779
|
-
if (range.end.isTouching(
|
|
779
|
+
if (range.end.isTouching(ModelPosition._createAt(endBlock, 0))) {
|
|
780
780
|
return false;
|
|
781
781
|
}
|
|
782
782
|
return isTopBlockInRange(endBlock, range);
|
package/src/model/text.d.ts
CHANGED
|
@@ -5,19 +5,20 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/text
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { ModelNode, type ModelNodeAttributes } from './node.js';
|
|
9
9
|
/**
|
|
10
|
-
* Model text node. Type of {@link module:engine/model/node~
|
|
10
|
+
* Model text node. Type of {@link module:engine/model/node~ModelNode node} that
|
|
11
|
+
* contains {@link module:engine/model/text~ModelText#data text data}.
|
|
11
12
|
*
|
|
12
|
-
* **Important:** see {@link module:engine/model/node~
|
|
13
|
+
* **Important:** see {@link module:engine/model/node~ModelNode} to read about restrictions using `Text` and `Node` API.
|
|
13
14
|
*
|
|
14
15
|
* **Note:** keep in mind that `Text` instances might indirectly got removed from model tree when model is changed.
|
|
15
|
-
* This happens when {@link module:engine/model/writer~
|
|
16
|
+
* This happens when {@link module:engine/model/writer~ModelWriter model writer} is used to change model and the text node is merged with
|
|
16
17
|
* another text node. Then, both text nodes are removed and a new text node is inserted into the model. Because of
|
|
17
18
|
* this behavior, keeping references to `Text` is not recommended. Instead, consider creating
|
|
18
|
-
* {@link module:engine/model/liveposition~
|
|
19
|
+
* {@link module:engine/model/liveposition~ModelLivePosition live position} placed before the text node.
|
|
19
20
|
*/
|
|
20
|
-
export
|
|
21
|
+
export declare class ModelText extends ModelNode {
|
|
21
22
|
/**
|
|
22
23
|
* Text data contained in this text node.
|
|
23
24
|
*
|
|
@@ -28,13 +29,13 @@ export default class Text extends Node {
|
|
|
28
29
|
* Creates a text node.
|
|
29
30
|
*
|
|
30
31
|
* **Note:** Constructor of this class shouldn't be used directly in the code.
|
|
31
|
-
* Use the {@link module:engine/model/writer~
|
|
32
|
+
* Use the {@link module:engine/model/writer~ModelWriter#createText} method instead.
|
|
32
33
|
*
|
|
33
34
|
* @internal
|
|
34
35
|
* @param data Node's text.
|
|
35
36
|
* @param attrs Node's attributes. See {@link module:utils/tomap~toMap} for a list of accepted values.
|
|
36
37
|
*/
|
|
37
|
-
constructor(data?: string, attrs?:
|
|
38
|
+
constructor(data?: string, attrs?: ModelNodeAttributes);
|
|
38
39
|
/**
|
|
39
40
|
* @inheritDoc
|
|
40
41
|
*/
|
|
@@ -55,12 +56,12 @@ export default class Text extends Node {
|
|
|
55
56
|
* @internal
|
|
56
57
|
* @returns `Text` instance created using given plain object.
|
|
57
58
|
*/
|
|
58
|
-
_clone():
|
|
59
|
+
_clone(): ModelText;
|
|
59
60
|
/**
|
|
60
61
|
* Creates a `Text` instance from given plain object (i.e. parsed JSON string).
|
|
61
62
|
*
|
|
62
63
|
* @param json Plain object to be converted to `Text`.
|
|
63
64
|
* @returns `Text` instance created using given plain object.
|
|
64
65
|
*/
|
|
65
|
-
static fromJSON(json: any):
|
|
66
|
+
static fromJSON(json: any): ModelText;
|
|
66
67
|
}
|
package/src/model/text.js
CHANGED
|
@@ -5,20 +5,21 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/text
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { ModelNode } from './node.js';
|
|
9
9
|
// @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-utils/utils' );
|
|
10
10
|
/**
|
|
11
|
-
* Model text node. Type of {@link module:engine/model/node~
|
|
11
|
+
* Model text node. Type of {@link module:engine/model/node~ModelNode node} that
|
|
12
|
+
* contains {@link module:engine/model/text~ModelText#data text data}.
|
|
12
13
|
*
|
|
13
|
-
* **Important:** see {@link module:engine/model/node~
|
|
14
|
+
* **Important:** see {@link module:engine/model/node~ModelNode} to read about restrictions using `Text` and `Node` API.
|
|
14
15
|
*
|
|
15
16
|
* **Note:** keep in mind that `Text` instances might indirectly got removed from model tree when model is changed.
|
|
16
|
-
* This happens when {@link module:engine/model/writer~
|
|
17
|
+
* This happens when {@link module:engine/model/writer~ModelWriter model writer} is used to change model and the text node is merged with
|
|
17
18
|
* another text node. Then, both text nodes are removed and a new text node is inserted into the model. Because of
|
|
18
19
|
* this behavior, keeping references to `Text` is not recommended. Instead, consider creating
|
|
19
|
-
* {@link module:engine/model/liveposition~
|
|
20
|
+
* {@link module:engine/model/liveposition~ModelLivePosition live position} placed before the text node.
|
|
20
21
|
*/
|
|
21
|
-
export
|
|
22
|
+
export class ModelText extends ModelNode {
|
|
22
23
|
/**
|
|
23
24
|
* Text data contained in this text node.
|
|
24
25
|
*
|
|
@@ -29,7 +30,7 @@ export default class Text extends Node {
|
|
|
29
30
|
* Creates a text node.
|
|
30
31
|
*
|
|
31
32
|
* **Note:** Constructor of this class shouldn't be used directly in the code.
|
|
32
|
-
* Use the {@link module:engine/model/writer~
|
|
33
|
+
* Use the {@link module:engine/model/writer~ModelWriter#createText} method instead.
|
|
33
34
|
*
|
|
34
35
|
* @internal
|
|
35
36
|
* @param data Node's text.
|
|
@@ -68,7 +69,7 @@ export default class Text extends Node {
|
|
|
68
69
|
* @returns `Text` instance created using given plain object.
|
|
69
70
|
*/
|
|
70
71
|
_clone() {
|
|
71
|
-
return new
|
|
72
|
+
return new ModelText(this.data, this.getAttributes());
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* Creates a `Text` instance from given plain object (i.e. parsed JSON string).
|
|
@@ -77,12 +78,12 @@ export default class Text extends Node {
|
|
|
77
78
|
* @returns `Text` instance created using given plain object.
|
|
78
79
|
*/
|
|
79
80
|
static fromJSON(json) {
|
|
80
|
-
return new
|
|
81
|
+
return new ModelText(json.data, json.attributes);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
84
85
|
// Proper overload would interfere with that.
|
|
85
|
-
|
|
86
|
+
ModelText.prototype.is = function (type) {
|
|
86
87
|
return type === '$text' || type === 'model:$text' ||
|
|
87
88
|
// This are legacy values kept for backward compatibility.
|
|
88
89
|
type === 'text' || type === 'model:text' ||
|
package/src/model/textproxy.d.ts
CHANGED
|
@@ -5,51 +5,51 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/textproxy
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import type
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
12
|
-
import type
|
|
8
|
+
import { ModelTypeCheckable } from './typecheckable.js';
|
|
9
|
+
import { type ModelDocumentFragment } from './documentfragment.js';
|
|
10
|
+
import { type ModelElement } from './element.js';
|
|
11
|
+
import { type ModelNode } from './node.js';
|
|
12
|
+
import { type ModelText } from './text.js';
|
|
13
13
|
/**
|
|
14
|
-
* `
|
|
14
|
+
* `ModelTextProxy` represents a part of {@link module:engine/model/text~ModelText text node}.
|
|
15
15
|
*
|
|
16
|
-
* Since {@link module:engine/model/position~
|
|
17
|
-
* {@link module:engine/model/range~
|
|
18
|
-
* getting items}
|
|
16
|
+
* Since {@link module:engine/model/position~ModelPosition positions} can be placed between characters of a text node,
|
|
17
|
+
* {@link module:engine/model/range~ModelRange ranges} may contain only parts of text nodes.
|
|
18
|
+
* When {@link module:engine/model/range~ModelRange#getItems getting items}
|
|
19
19
|
* contained in such range, we need to represent a part of that text node, since returning the whole text node would be incorrect.
|
|
20
|
-
* `
|
|
20
|
+
* `ModelTextProxy` solves this issue.
|
|
21
21
|
*
|
|
22
|
-
* `
|
|
23
|
-
* on model nodes.
|
|
22
|
+
* `ModelTextProxy` has an API similar to {@link module:engine/model/text~ModelText Text} and allows to do
|
|
23
|
+
* most of the common tasks performed on model nodes.
|
|
24
24
|
*
|
|
25
|
-
* **Note:** Some `
|
|
26
|
-
* See {@link module:engine/model/textproxy~
|
|
25
|
+
* **Note:** Some `ModelTextProxy` instances may represent whole text node, not just a part of it.
|
|
26
|
+
* See {@link module:engine/model/textproxy~ModelTextProxy#isPartial}.
|
|
27
27
|
*
|
|
28
|
-
* **Note:** `
|
|
28
|
+
* **Note:** `ModelTextProxy` is not an instance of {@link module:engine/model/node~ModelNode node}. Keep this in mind when using it as a
|
|
29
29
|
* parameter of methods.
|
|
30
30
|
*
|
|
31
|
-
* **Note:** `
|
|
32
|
-
* use {@link module:engine/model/writer~
|
|
31
|
+
* **Note:** `ModelTextProxy` is a readonly interface. If you want to perform changes on model data represented by a `ModelTextProxy`
|
|
32
|
+
* use {@link module:engine/model/writer~ModelWriter model writer API}.
|
|
33
33
|
*
|
|
34
|
-
* **Note:** `
|
|
35
|
-
* highly unrecommended to store references to `
|
|
36
|
-
* model changes, so they might get invalidated. Instead, consider creating {@link module:engine/model/liveposition~
|
|
34
|
+
* **Note:** `ModelTextProxy` instances are created on the fly, basing on the current state of model. Because of this, it is
|
|
35
|
+
* highly unrecommended to store references to `ModelTextProxy` instances. `ModelTextProxy` instances are not refreshed when
|
|
36
|
+
* model changes, so they might get invalidated. Instead, consider creating {@link module:engine/model/liveposition~ModelLivePosition live
|
|
37
37
|
* position}.
|
|
38
38
|
*
|
|
39
|
-
* `
|
|
40
|
-
* an instance of this class by your own.
|
|
39
|
+
* `ModelTextProxy` instances are created by {@link module:engine/model/treewalker~ModelTreeWalker model tree walker}.
|
|
40
|
+
* You should not need to create an instance of this class by your own.
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
42
|
+
export declare class ModelTextProxy extends ModelTypeCheckable {
|
|
43
43
|
/**
|
|
44
44
|
* Text node which part is represented by this text proxy.
|
|
45
45
|
*/
|
|
46
|
-
readonly textNode:
|
|
46
|
+
readonly textNode: ModelText;
|
|
47
47
|
/**
|
|
48
48
|
* Text data represented by this text proxy.
|
|
49
49
|
*/
|
|
50
50
|
readonly data: string;
|
|
51
51
|
/**
|
|
52
|
-
* Offset in {@link module:engine/model/textproxy~
|
|
52
|
+
* Offset in {@link module:engine/model/textproxy~ModelTextProxy#textNode text node} from which the text proxy starts.
|
|
53
53
|
*/
|
|
54
54
|
readonly offsetInText: number;
|
|
55
55
|
/**
|
|
@@ -57,50 +57,51 @@ export default class TextProxy extends TypeCheckable {
|
|
|
57
57
|
*
|
|
58
58
|
* @internal
|
|
59
59
|
* @param textNode Text node which part is represented by this text proxy.
|
|
60
|
-
* @param offsetInText Offset in {@link module:engine/model/textproxy~
|
|
60
|
+
* @param offsetInText Offset in {@link module:engine/model/textproxy~ModelTextProxy#textNode text node} from which the text proxy
|
|
61
61
|
* starts.
|
|
62
62
|
* @param length Text proxy length, that is how many text node's characters, starting from `offsetInText` it represents.
|
|
63
63
|
*/
|
|
64
|
-
constructor(textNode:
|
|
64
|
+
constructor(textNode: ModelText, offsetInText: number, length: number);
|
|
65
65
|
/**
|
|
66
66
|
* Offset at which this text proxy starts in it's parent.
|
|
67
67
|
*
|
|
68
|
-
* @see module:engine/model/node~
|
|
68
|
+
* @see module:engine/model/node~ModelNode#startOffset
|
|
69
69
|
*/
|
|
70
70
|
get startOffset(): number | null;
|
|
71
71
|
/**
|
|
72
72
|
* Offset size of this text proxy. Equal to the number of characters represented by the text proxy.
|
|
73
73
|
*
|
|
74
|
-
* @see module:engine/model/node~
|
|
74
|
+
* @see module:engine/model/node~ModelNode#offsetSize
|
|
75
75
|
*/
|
|
76
76
|
get offsetSize(): number;
|
|
77
77
|
/**
|
|
78
78
|
* Offset at which this text proxy ends in it's parent.
|
|
79
79
|
*
|
|
80
|
-
* @see module:engine/model/node~
|
|
80
|
+
* @see module:engine/model/node~ModelNode#endOffset
|
|
81
81
|
*/
|
|
82
82
|
get endOffset(): number | null;
|
|
83
83
|
/**
|
|
84
|
-
* Flag indicating whether `
|
|
85
|
-
* (`true`) or the whole text node (`false`).
|
|
84
|
+
* Flag indicating whether `ModelTextProxy` instance covers only part of the original
|
|
85
|
+
* {@link module:engine/model/text~ModelText text node} (`true`) or the whole text node (`false`).
|
|
86
86
|
*
|
|
87
|
-
* This is `false` when text proxy starts at the very beginning of
|
|
88
|
-
*
|
|
87
|
+
* This is `false` when text proxy starts at the very beginning of
|
|
88
|
+
* {@link module:engine/model/textproxy~ModelTextProxy#textNode textNode}
|
|
89
|
+
* ({@link module:engine/model/textproxy~ModelTextProxy#offsetInText offsetInText} equals `0`) and text proxy sizes is equal to
|
|
89
90
|
* text node size.
|
|
90
91
|
*/
|
|
91
92
|
get isPartial(): boolean;
|
|
92
93
|
/**
|
|
93
94
|
* Parent of this text proxy, which is same as parent of text node represented by this text proxy.
|
|
94
95
|
*/
|
|
95
|
-
get parent():
|
|
96
|
+
get parent(): ModelElement | ModelDocumentFragment | null;
|
|
96
97
|
/**
|
|
97
98
|
* Root of this text proxy, which is same as root of text node represented by this text proxy.
|
|
98
99
|
*/
|
|
99
|
-
get root():
|
|
100
|
+
get root(): ModelNode | ModelDocumentFragment;
|
|
100
101
|
/**
|
|
101
102
|
* Gets path to this text proxy.
|
|
102
103
|
*
|
|
103
|
-
* @see module:engine/model/node~
|
|
104
|
+
* @see module:engine/model/node~ModelNode#getPath
|
|
104
105
|
*/
|
|
105
106
|
getPath(): Array<number>;
|
|
106
107
|
/**
|
|
@@ -115,7 +116,7 @@ export default class TextProxy extends TypeCheckable {
|
|
|
115
116
|
getAncestors(options?: {
|
|
116
117
|
includeSelf?: boolean;
|
|
117
118
|
parentFirst?: boolean;
|
|
118
|
-
}): Array<
|
|
119
|
+
}): Array<ModelTextProxy | ModelElement | ModelDocumentFragment>;
|
|
119
120
|
/**
|
|
120
121
|
* Checks if this text proxy has an attribute for given key.
|
|
121
122
|
*
|