@ckeditor/ckeditor5-engine 48.2.0-alpha.7 → 48.3.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.
Files changed (129) hide show
  1. package/dist/controller/datacontroller.d.ts +329 -328
  2. package/dist/controller/editingcontroller.d.ts +95 -94
  3. package/dist/conversion/comparemarkers.d.ts +45 -45
  4. package/dist/conversion/conversion.d.ts +474 -474
  5. package/dist/conversion/conversionhelpers.d.ts +21 -21
  6. package/dist/conversion/downcastdispatcher.d.ts +539 -538
  7. package/dist/conversion/downcasthelpers.d.ts +1129 -1129
  8. package/dist/conversion/mapper.d.ts +692 -697
  9. package/dist/conversion/modelconsumable.d.ts +196 -196
  10. package/dist/conversion/upcastdispatcher.d.ts +483 -482
  11. package/dist/conversion/upcasthelpers.d.ts +491 -491
  12. package/dist/conversion/viewconsumable.d.ts +330 -330
  13. package/dist/dataprocessor/basichtmlwriter.d.ts +15 -15
  14. package/dist/dataprocessor/dataprocessor.d.ts +57 -57
  15. package/dist/dataprocessor/htmldataprocessor.d.ts +72 -72
  16. package/dist/dataprocessor/htmlwriter.d.ts +11 -11
  17. package/dist/dataprocessor/xmldataprocessor.d.ts +86 -86
  18. package/dist/dev-utils/model.d.ts +128 -123
  19. package/dist/dev-utils/operationreplayer.d.ts +49 -49
  20. package/dist/dev-utils/utils.d.ts +33 -33
  21. package/dist/dev-utils/view.d.ts +314 -309
  22. package/dist/engineconfig.d.ts +39 -39
  23. package/dist/index.css.map +1 -1
  24. package/dist/index.d.ts +150 -150
  25. package/dist/index.js +34026 -40107
  26. package/dist/index.js.map +1 -1
  27. package/dist/legacyerrors.d.ts +0 -4
  28. package/dist/model/batch.d.ts +86 -86
  29. package/dist/model/differ.d.ts +504 -504
  30. package/dist/model/document.d.ts +265 -268
  31. package/dist/model/documentfragment.d.ts +214 -214
  32. package/dist/model/documentselection.d.ts +406 -410
  33. package/dist/model/element.d.ts +182 -182
  34. package/dist/model/history.d.ts +109 -109
  35. package/dist/model/item.d.ts +9 -9
  36. package/dist/model/liveposition.d.ts +70 -69
  37. package/dist/model/liverange.d.ts +93 -92
  38. package/dist/model/markercollection.d.ts +317 -324
  39. package/dist/model/model.d.ts +889 -909
  40. package/dist/model/node.d.ts +254 -254
  41. package/dist/model/nodelist.d.ts +110 -110
  42. package/dist/model/operation/attributeoperation.d.ts +98 -98
  43. package/dist/model/operation/detachoperation.d.ts +57 -57
  44. package/dist/model/operation/insertoperation.d.ts +85 -85
  45. package/dist/model/operation/markeroperation.d.ts +87 -87
  46. package/dist/model/operation/mergeoperation.d.ts +95 -95
  47. package/dist/model/operation/moveoperation.d.ts +97 -97
  48. package/dist/model/operation/nooperation.d.ts +33 -33
  49. package/dist/model/operation/operation.d.ts +94 -94
  50. package/dist/model/operation/operationfactory.d.ts +14 -14
  51. package/dist/model/operation/renameoperation.d.ts +78 -78
  52. package/dist/model/operation/rootattributeoperation.d.ts +93 -93
  53. package/dist/model/operation/rootoperation.d.ts +71 -71
  54. package/dist/model/operation/splitoperation.d.ts +104 -104
  55. package/dist/model/operation/transform.d.ts +91 -91
  56. package/dist/model/operation/utils.d.ts +58 -58
  57. package/dist/model/position.d.ts +535 -535
  58. package/dist/model/range.d.ts +458 -453
  59. package/dist/model/rootelement.d.ts +55 -55
  60. package/dist/model/schema.d.ts +1325 -1327
  61. package/dist/model/selection.d.ts +452 -471
  62. package/dist/model/text.d.ts +62 -62
  63. package/dist/model/textproxy.d.ts +140 -140
  64. package/dist/model/treewalker.d.ts +190 -190
  65. package/dist/model/typecheckable.d.ts +281 -281
  66. package/dist/model/utils/autoparagraphing.d.ts +29 -29
  67. package/dist/model/utils/deletecontent.d.ts +68 -68
  68. package/dist/model/utils/getselectedcontent.d.ts +27 -27
  69. package/dist/model/utils/insertcontent.d.ts +42 -42
  70. package/dist/model/utils/insertobject.d.ts +41 -41
  71. package/dist/model/utils/modifyselection.d.ts +44 -44
  72. package/dist/model/utils/selection-post-fixer.d.ts +71 -71
  73. package/dist/model/writer.d.ts +854 -854
  74. package/dist/view/attributeelement.d.ts +123 -123
  75. package/dist/view/containerelement.d.ts +49 -49
  76. package/dist/view/datatransfer.d.ts +70 -70
  77. package/dist/view/document.d.ts +175 -177
  78. package/dist/view/documentfragment.d.ts +158 -157
  79. package/dist/view/documentselection.d.ts +308 -307
  80. package/dist/view/domconverter.d.ts +612 -657
  81. package/dist/view/downcastwriter.d.ts +1006 -1006
  82. package/dist/view/editableelement.d.ts +64 -63
  83. package/dist/view/element.d.ts +754 -754
  84. package/dist/view/elementdefinition.d.ts +79 -79
  85. package/dist/view/emptyelement.d.ts +42 -42
  86. package/dist/view/filler.d.ts +75 -75
  87. package/dist/view/item.d.ts +9 -9
  88. package/dist/view/matcher.d.ts +412 -487
  89. package/dist/view/node.d.ts +164 -163
  90. package/dist/view/observer/arrowkeysobserver.d.ts +37 -37
  91. package/dist/view/observer/bubblingemittermixin.d.ts +163 -153
  92. package/dist/view/observer/bubblingeventinfo.d.ts +45 -42
  93. package/dist/view/observer/clickobserver.d.ts +36 -36
  94. package/dist/view/observer/compositionobserver.d.ts +67 -67
  95. package/dist/view/observer/domeventdata.d.ts +46 -46
  96. package/dist/view/observer/domeventobserver.d.ts +77 -74
  97. package/dist/view/observer/fakeselectionobserver.d.ts +42 -42
  98. package/dist/view/observer/focusobserver.d.ts +84 -84
  99. package/dist/view/observer/inputobserver.d.ts +76 -76
  100. package/dist/view/observer/keyobserver.d.ts +53 -53
  101. package/dist/view/observer/mouseobserver.d.ts +73 -73
  102. package/dist/view/observer/mutationobserver.d.ts +101 -101
  103. package/dist/view/observer/observer.d.ts +84 -83
  104. package/dist/view/observer/pointerobserver.d.ts +63 -63
  105. package/dist/view/observer/selectionobserver.d.ts +136 -136
  106. package/dist/view/observer/tabobserver.d.ts +38 -38
  107. package/dist/view/observer/touchobserver.d.ts +60 -60
  108. package/dist/view/placeholder.d.ts +80 -80
  109. package/dist/view/position.d.ts +187 -187
  110. package/dist/view/range.d.ts +282 -282
  111. package/dist/view/rawelement.d.ts +72 -72
  112. package/dist/view/renderer.d.ts +270 -272
  113. package/dist/view/rooteditableelement.d.ts +43 -43
  114. package/dist/view/selection.d.ts +356 -369
  115. package/dist/view/styles/background.d.ts +15 -15
  116. package/dist/view/styles/border.d.ts +27 -27
  117. package/dist/view/styles/margin.d.ts +12 -12
  118. package/dist/view/styles/padding.d.ts +12 -12
  119. package/dist/view/styles/utils.d.ts +72 -72
  120. package/dist/view/stylesmap.d.ts +715 -715
  121. package/dist/view/text.d.ts +75 -75
  122. package/dist/view/textproxy.d.ts +92 -92
  123. package/dist/view/tokenlist.d.ts +104 -104
  124. package/dist/view/treewalker.d.ts +201 -201
  125. package/dist/view/typecheckable.d.ts +445 -445
  126. package/dist/view/uielement.d.ts +93 -93
  127. package/dist/view/upcastwriter.d.ts +412 -412
  128. package/dist/view/view.d.ts +466 -469
  129. package/package.json +2 -2
@@ -1,314 +1,315 @@
1
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
- */
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
5
  /**
6
- * @module engine/view/documentselection
7
- */
8
- import { ViewTypeCheckable } from './typecheckable.js';
9
- import { ViewSelection, type ViewPlaceOrOffset, type ViewSelectable, type ViewSelectionOptions, type ViewSelectionChangeEvent } from './selection.js';
10
- import { type ViewEditableElement } from './editableelement.js';
11
- import { type ViewElement } from './element.js';
12
- import { type ViewNode } from './node.js';
13
- import { type ViewItem } from './item.js';
14
- import type { ViewPosition, ViewPositionOffset } from './position.js';
15
- import { type ViewRange } from './range.js';
16
- declare const ViewDocumentSelection_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof ViewTypeCheckable, import("@ckeditor/ckeditor5-utils").Emitter>;
6
+ * @module engine/view/documentselection
7
+ */
8
+ import { ViewTypeCheckable } from "./typecheckable.js";
9
+ import { ViewSelection, type ViewPlaceOrOffset, type ViewSelectable, type ViewSelectionOptions, type ViewSelectionChangeEvent } from "./selection.js";
10
+ import { type EmitterMixinConstructor } from "@ckeditor/ckeditor5-utils";
11
+ import { type ViewEditableElement } from "./editableelement.js";
12
+ import { type ViewElement } from "./element.js";
13
+ import { type ViewNode } from "./node.js";
14
+ import { type ViewItem } from "./item.js";
15
+ import type { ViewPosition, ViewPositionOffset } from "./position.js";
16
+ import { type ViewRange } from "./range.js";
17
+ declare const ViewDocumentSelectionBase: EmitterMixinConstructor<typeof ViewTypeCheckable>;
17
18
  /**
18
- * Class representing the document selection in the view.
19
- *
20
- * Its instance is available in {@link module:engine/view/document~ViewDocument#selection `Document#selection`}.
21
- *
22
- * It is similar to {@link module:engine/view/selection~ViewSelection} but
23
- * it has a read-only API and can be modified only by the writer available in
24
- * the {@link module:engine/view/view~EditingView#change `View#change()`} block
25
- * (so via {@link module:engine/view/downcastwriter~ViewDowncastWriter#setSelection `ViewDowncastWriter#setSelection()`}).
26
- */
27
- export declare class ViewDocumentSelection extends /* #__PURE__ */ ViewDocumentSelection_base {
28
- /**
29
- * Selection is used internally (`ViewDocumentSelection` is a proxy to that selection).
30
- */
31
- private readonly _selection;
32
- /**
33
- * Creates new ViewDocumentSelection instance.
34
- *
35
- * ```ts
36
- * // Creates collapsed selection at the position of given item and offset.
37
- * const paragraph = writer.createContainerElement( 'paragraph' );
38
- * const selection = new ViewDocumentSelection( paragraph, offset );
39
- *
40
- * // Creates a range inside an {@link module:engine/view/element~ViewElement element} which starts before the
41
- * // first child of that element and ends after the last child of that element.
42
- * const selection = new ViewDocumentSelection( paragraph, 'in' );
43
- *
44
- * // Creates a range on an {@link module:engine/view/item~ViewItem item} which starts before the item and ends
45
- * // just after the item.
46
- * const selection = new ViewDocumentSelection( paragraph, 'on' );
47
- * ```
48
- *
49
- * `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
50
- *
51
- * ```ts
52
- * // Creates backward selection.
53
- * const selection = new ViewDocumentSelection( element, 'in', { backward: true } );
54
- * ```
55
- *
56
- * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
57
- * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
58
- * represented in other way, for example by applying proper CSS class.
59
- *
60
- * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
61
- * (and be properly handled by screen readers).
62
- *
63
- * ```ts
64
- * // Creates fake selection with label.
65
- * const selection = new ViewDocumentSelection( element, 'in', { fake: true, label: 'foo' } );
66
- * ```
67
- *
68
- * See also: {@link #constructor:SELECTABLE `constructor( selectable, options )`}.
69
- *
70
- * @label NODE_OFFSET
71
- */
72
- constructor(selectable: ViewNode, placeOrOffset: ViewPlaceOrOffset, options?: ViewSelectionOptions);
73
- /**
74
- * Creates new ViewDocumentSelection instance.
75
- *
76
- * ```ts
77
- * // Creates empty selection without ranges.
78
- * const selection = new ViewDocumentSelection();
79
- *
80
- * // Creates selection at the given range.
81
- * const range = writer.createRange( start, end );
82
- * const selection = new ViewDocumentSelection( range );
83
- *
84
- * // Creates selection at the given ranges
85
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
86
- * const selection = new ViewDocumentSelection( ranges );
87
- *
88
- * // Creates selection from the other selection.
89
- * const otherSelection = writer.createSelection();
90
- * const selection = new ViewDocumentSelection( otherSelection );
91
- *
92
- * // Creates selection at the given position.
93
- * const position = writer.createPositionAt( root, offset );
94
- * const selection = new ViewDocumentSelection( position );
95
- * ```
96
- *
97
- * `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
98
- *
99
- * ```ts
100
- * // Creates backward selection.
101
- * const selection = new ViewDocumentSelection( range, { backward: true } );
102
- * ```
103
- *
104
- * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
105
- * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
106
- * represented in other way, for example by applying proper CSS class.
107
- *
108
- * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
109
- * (and be properly handled by screen readers).
110
- *
111
- * ```ts
112
- * // Creates fake selection with label.
113
- * const selection = new ViewDocumentSelection( range, { fake: true, label: 'foo' } );
114
- * ```
115
- *
116
- * See also: {@link #constructor:NODE_OFFSET `constructor( node, placeOrOffset, options )`}.
117
- *
118
- * @label SELECTABLE
119
- */
120
- constructor(selectable?: Exclude<ViewSelectable, ViewNode>, options?: ViewSelectionOptions);
121
- /**
122
- * Returns true if selection instance is marked as `fake`.
123
- *
124
- * @see #_setTo
125
- */
126
- get isFake(): boolean;
127
- /**
128
- * Returns fake selection label.
129
- *
130
- * @see #_setTo
131
- */
132
- get fakeSelectionLabel(): string;
133
- /**
134
- * Selection anchor. Anchor may be described as a position where the selection starts. Together with
135
- * {@link #focus focus} they define the direction of selection, which is important
136
- * when expanding/shrinking selection. Anchor is always the start or end of the most recent added range.
137
- * It may be a bit unintuitive when there are multiple ranges in selection.
138
- *
139
- * @see #focus
140
- */
141
- get anchor(): ViewPosition | null;
142
- /**
143
- * Selection focus. Focus is a position where the selection ends.
144
- *
145
- * @see #anchor
146
- */
147
- get focus(): ViewPosition | null;
148
- /**
149
- * Returns whether the selection is collapsed. Selection is collapsed when there is exactly one range which is
150
- * collapsed.
151
- */
152
- get isCollapsed(): boolean;
153
- /**
154
- * Returns number of ranges in selection.
155
- */
156
- get rangeCount(): number;
157
- /**
158
- * Specifies whether the {@link #focus} precedes {@link #anchor}.
159
- */
160
- get isBackward(): boolean;
161
- /**
162
- * {@link module:engine/view/editableelement~ViewEditableElement ViewEditableElement} instance that contains this selection, or `null`
163
- * if the selection is not inside an editable element.
164
- */
165
- get editableElement(): ViewEditableElement | null;
166
- /**
167
- * Used for the compatibility with the {@link module:engine/view/selection~ViewSelection#isEqual} method.
168
- *
169
- * @internal
170
- */
171
- get _ranges(): Array<ViewRange>;
172
- /**
173
- * Returns an iterable that contains copies of all ranges added to the selection.
174
- */
175
- getRanges(): IterableIterator<ViewRange>;
176
- /**
177
- * Returns copy of the first range in the selection. First range is the one which
178
- * {@link module:engine/view/range~ViewRange#start start} position
179
- * {@link module:engine/view/position~ViewPosition#isBefore is before} start
180
- * position of all other ranges (not to confuse with the first range added to the selection).
181
- * Returns `null` if no ranges are added to selection.
182
- */
183
- getFirstRange(): ViewRange | null;
184
- /**
185
- * Returns copy of the last range in the selection. Last range is the one which {@link module:engine/view/range~ViewRange#end end}
186
- * position {@link module:engine/view/position~ViewPosition#isAfter is after} end position of all other ranges (not to confuse
187
- * with the last range added to the selection). Returns `null` if no ranges are added to selection.
188
- */
189
- getLastRange(): ViewRange | null;
190
- /**
191
- * Returns copy of the first position in the selection. First position is the position that
192
- * {@link module:engine/view/position~ViewPosition#isBefore is before} any other position in the selection ranges.
193
- * Returns `null` if no ranges are added to selection.
194
- */
195
- getFirstPosition(): ViewPosition | null;
196
- /**
197
- * Returns copy of the last position in the selection. Last position is the position that
198
- * {@link module:engine/view/position~ViewPosition#isAfter is after} any other position in the selection ranges.
199
- * Returns `null` if no ranges are added to selection.
200
- */
201
- getLastPosition(): ViewPosition | null;
202
- /**
203
- * Returns the selected element. {@link module:engine/view/element~ViewElement Element} is considered as selected if there is only
204
- * one range in the selection, and that range contains exactly one element.
205
- * Returns `null` if there is no selected element.
206
- */
207
- getSelectedElement(): ViewElement | null;
208
- /**
209
- * Checks whether, this selection is equal to given selection. Selections are equal if they have same directions,
210
- * same number of ranges and all ranges from one selection equal to a range from other selection.
211
- *
212
- * @param otherSelection Selection to compare with.
213
- * @returns `true` if selections are equal, `false` otherwise.
214
- */
215
- isEqual(otherSelection: ViewSelection | ViewDocumentSelection): boolean;
216
- /**
217
- * Checks whether this selection is similar to given selection. Selections are similar if they have same directions, same
218
- * number of ranges, and all {@link module:engine/view/range~ViewRange#getTrimmed trimmed} ranges from one selection are
219
- * equal to any trimmed range from other selection.
220
- *
221
- * @param otherSelection Selection to compare with.
222
- * @returns `true` if selections are similar, `false` otherwise.
223
- */
224
- isSimilar(otherSelection: ViewSelection | ViewDocumentSelection): boolean;
225
- /**
226
- * Converts `ViewDocumentSelection` instance to plain object and returns it.
227
- *
228
- * @returns `ViewDocumentSelection` instance converted to plain object.
229
- */
230
- toJSON(): unknown;
231
- /**
232
- * Sets this selection's ranges and direction to the specified location based on the given
233
- * {@link module:engine/view/selection~ViewSelectable selectable}.
234
- *
235
- * ```ts
236
- * // Sets selection to the given range.
237
- * const range = writer.createRange( start, end );
238
- * documentSelection._setTo( range );
239
- *
240
- * // Sets selection to given ranges.
241
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
242
- * documentSelection._setTo( range );
243
- *
244
- * // Sets selection to the other selection.
245
- * const otherSelection = writer.createSelection();
246
- * documentSelection._setTo( otherSelection );
247
- *
248
- * // Sets collapsed selection at the given position.
249
- * const position = writer.createPositionAt( root, offset );
250
- * documentSelection._setTo( position );
251
- *
252
- * // Sets collapsed selection at the position of given item and offset.
253
- * documentSelection._setTo( paragraph, offset );
254
- * ```
255
- *
256
- * Creates a range inside an {@link module:engine/view/element~ViewElement element} which starts before the first child of
257
- * that element and ends after the last child of that element.
258
- *
259
- * ```ts
260
- * documentSelection._setTo( paragraph, 'in' );
261
- * ```
262
- *
263
- * Creates a range on an {@link module:engine/view/item~ViewItem item} which starts before the item and ends just after the item.
264
- *
265
- * ```ts
266
- * documentSelection._setTo( paragraph, 'on' );
267
- *
268
- * // Clears selection. Removes all ranges.
269
- * documentSelection._setTo( null );
270
- * ```
271
- *
272
- * `Selection#_setTo()` method allow passing additional options (`backward`, `fake` and `label`) as the last argument.
273
- *
274
- * ```ts
275
- * // Sets selection as backward.
276
- * documentSelection._setTo( range, { backward: true } );
277
- * ```
278
- *
279
- * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
280
- * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
281
- * represented in other way, for example by applying proper CSS class.
282
- *
283
- * Additionally fake's selection label can be provided. It will be used to des cribe fake selection in DOM
284
- * (and be properly handled by screen readers).
285
- *
286
- * ```ts
287
- * // Creates fake selection with label.
288
- * documentSelection._setTo( range, { fake: true, label: 'foo' } );
289
- * ```
290
- *
291
- * @internal
292
- * @fires change
293
- */
294
- _setTo(...args: Parameters<ViewSelection['setTo']>): void;
295
- /**
296
- * Moves {@link #focus} to the specified location.
297
- *
298
- * The location can be specified in the same form as
299
- * {@link module:engine/view/view~EditingView#createPositionAt view.createPositionAt()}
300
- * parameters.
301
- *
302
- * @internal
303
- * @fires change
304
- * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/view/item~ViewItem view item}.
305
- */
306
- _setFocus(itemOrPosition: ViewItem | ViewPosition, offset?: ViewPositionOffset): void;
19
+ * Class representing the document selection in the view.
20
+ *
21
+ * Its instance is available in {@link module:engine/view/document~ViewDocument#selection `Document#selection`}.
22
+ *
23
+ * It is similar to {@link module:engine/view/selection~ViewSelection} but
24
+ * it has a read-only API and can be modified only by the writer available in
25
+ * the {@link module:engine/view/view~EditingView#change `View#change()`} block
26
+ * (so via {@link module:engine/view/downcastwriter~ViewDowncastWriter#setSelection `ViewDowncastWriter#setSelection()`}).
27
+ */
28
+ export declare class ViewDocumentSelection extends ViewDocumentSelectionBase {
29
+ /**
30
+ * Selection is used internally (`ViewDocumentSelection` is a proxy to that selection).
31
+ */
32
+ private readonly _selection;
33
+ /**
34
+ * Creates new ViewDocumentSelection instance.
35
+ *
36
+ * ```ts
37
+ * // Creates collapsed selection at the position of given item and offset.
38
+ * const paragraph = writer.createContainerElement( 'paragraph' );
39
+ * const selection = new ViewDocumentSelection( paragraph, offset );
40
+ *
41
+ * // Creates a range inside an {@link module:engine/view/element~ViewElement element} which starts before the
42
+ * // first child of that element and ends after the last child of that element.
43
+ * const selection = new ViewDocumentSelection( paragraph, 'in' );
44
+ *
45
+ * // Creates a range on an {@link module:engine/view/item~ViewItem item} which starts before the item and ends
46
+ * // just after the item.
47
+ * const selection = new ViewDocumentSelection( paragraph, 'on' );
48
+ * ```
49
+ *
50
+ * `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
51
+ *
52
+ * ```ts
53
+ * // Creates backward selection.
54
+ * const selection = new ViewDocumentSelection( element, 'in', { backward: true } );
55
+ * ```
56
+ *
57
+ * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
58
+ * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
59
+ * represented in other way, for example by applying proper CSS class.
60
+ *
61
+ * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
62
+ * (and be properly handled by screen readers).
63
+ *
64
+ * ```ts
65
+ * // Creates fake selection with label.
66
+ * const selection = new ViewDocumentSelection( element, 'in', { fake: true, label: 'foo' } );
67
+ * ```
68
+ *
69
+ * See also: {@link #constructor:SELECTABLE `constructor( selectable, options )`}.
70
+ *
71
+ * @label NODE_OFFSET
72
+ */
73
+ constructor(selectable: ViewNode, placeOrOffset: ViewPlaceOrOffset, options?: ViewSelectionOptions);
74
+ /**
75
+ * Creates new ViewDocumentSelection instance.
76
+ *
77
+ * ```ts
78
+ * // Creates empty selection without ranges.
79
+ * const selection = new ViewDocumentSelection();
80
+ *
81
+ * // Creates selection at the given range.
82
+ * const range = writer.createRange( start, end );
83
+ * const selection = new ViewDocumentSelection( range );
84
+ *
85
+ * // Creates selection at the given ranges
86
+ * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
87
+ * const selection = new ViewDocumentSelection( ranges );
88
+ *
89
+ * // Creates selection from the other selection.
90
+ * const otherSelection = writer.createSelection();
91
+ * const selection = new ViewDocumentSelection( otherSelection );
92
+ *
93
+ * // Creates selection at the given position.
94
+ * const position = writer.createPositionAt( root, offset );
95
+ * const selection = new ViewDocumentSelection( position );
96
+ * ```
97
+ *
98
+ * `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
99
+ *
100
+ * ```ts
101
+ * // Creates backward selection.
102
+ * const selection = new ViewDocumentSelection( range, { backward: true } );
103
+ * ```
104
+ *
105
+ * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
106
+ * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
107
+ * represented in other way, for example by applying proper CSS class.
108
+ *
109
+ * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
110
+ * (and be properly handled by screen readers).
111
+ *
112
+ * ```ts
113
+ * // Creates fake selection with label.
114
+ * const selection = new ViewDocumentSelection( range, { fake: true, label: 'foo' } );
115
+ * ```
116
+ *
117
+ * See also: {@link #constructor:NODE_OFFSET `constructor( node, placeOrOffset, options )`}.
118
+ *
119
+ * @label SELECTABLE
120
+ */
121
+ constructor(selectable?: Exclude<ViewSelectable, ViewNode>, options?: ViewSelectionOptions);
122
+ /**
123
+ * Returns true if selection instance is marked as `fake`.
124
+ *
125
+ * @see #_setTo
126
+ */
127
+ get isFake(): boolean;
128
+ /**
129
+ * Returns fake selection label.
130
+ *
131
+ * @see #_setTo
132
+ */
133
+ get fakeSelectionLabel(): string;
134
+ /**
135
+ * Selection anchor. Anchor may be described as a position where the selection starts. Together with
136
+ * {@link #focus focus} they define the direction of selection, which is important
137
+ * when expanding/shrinking selection. Anchor is always the start or end of the most recent added range.
138
+ * It may be a bit unintuitive when there are multiple ranges in selection.
139
+ *
140
+ * @see #focus
141
+ */
142
+ get anchor(): ViewPosition | null;
143
+ /**
144
+ * Selection focus. Focus is a position where the selection ends.
145
+ *
146
+ * @see #anchor
147
+ */
148
+ get focus(): ViewPosition | null;
149
+ /**
150
+ * Returns whether the selection is collapsed. Selection is collapsed when there is exactly one range which is
151
+ * collapsed.
152
+ */
153
+ get isCollapsed(): boolean;
154
+ /**
155
+ * Returns number of ranges in selection.
156
+ */
157
+ get rangeCount(): number;
158
+ /**
159
+ * Specifies whether the {@link #focus} precedes {@link #anchor}.
160
+ */
161
+ get isBackward(): boolean;
162
+ /**
163
+ * {@link module:engine/view/editableelement~ViewEditableElement ViewEditableElement} instance that contains this selection, or `null`
164
+ * if the selection is not inside an editable element.
165
+ */
166
+ get editableElement(): ViewEditableElement | null;
167
+ /**
168
+ * Used for the compatibility with the {@link module:engine/view/selection~ViewSelection#isEqual} method.
169
+ *
170
+ * @internal
171
+ */
172
+ get _ranges(): Array<ViewRange>;
173
+ /**
174
+ * Returns an iterable that contains copies of all ranges added to the selection.
175
+ */
176
+ getRanges(): IterableIterator<ViewRange>;
177
+ /**
178
+ * Returns copy of the first range in the selection. First range is the one which
179
+ * {@link module:engine/view/range~ViewRange#start start} position
180
+ * {@link module:engine/view/position~ViewPosition#isBefore is before} start
181
+ * position of all other ranges (not to confuse with the first range added to the selection).
182
+ * Returns `null` if no ranges are added to selection.
183
+ */
184
+ getFirstRange(): ViewRange | null;
185
+ /**
186
+ * Returns copy of the last range in the selection. Last range is the one which {@link module:engine/view/range~ViewRange#end end}
187
+ * position {@link module:engine/view/position~ViewPosition#isAfter is after} end position of all other ranges (not to confuse
188
+ * with the last range added to the selection). Returns `null` if no ranges are added to selection.
189
+ */
190
+ getLastRange(): ViewRange | null;
191
+ /**
192
+ * Returns copy of the first position in the selection. First position is the position that
193
+ * {@link module:engine/view/position~ViewPosition#isBefore is before} any other position in the selection ranges.
194
+ * Returns `null` if no ranges are added to selection.
195
+ */
196
+ getFirstPosition(): ViewPosition | null;
197
+ /**
198
+ * Returns copy of the last position in the selection. Last position is the position that
199
+ * {@link module:engine/view/position~ViewPosition#isAfter is after} any other position in the selection ranges.
200
+ * Returns `null` if no ranges are added to selection.
201
+ */
202
+ getLastPosition(): ViewPosition | null;
203
+ /**
204
+ * Returns the selected element. {@link module:engine/view/element~ViewElement Element} is considered as selected if there is only
205
+ * one range in the selection, and that range contains exactly one element.
206
+ * Returns `null` if there is no selected element.
207
+ */
208
+ getSelectedElement(): ViewElement | null;
209
+ /**
210
+ * Checks whether, this selection is equal to given selection. Selections are equal if they have same directions,
211
+ * same number of ranges and all ranges from one selection equal to a range from other selection.
212
+ *
213
+ * @param otherSelection Selection to compare with.
214
+ * @returns `true` if selections are equal, `false` otherwise.
215
+ */
216
+ isEqual(otherSelection: ViewSelection | ViewDocumentSelection): boolean;
217
+ /**
218
+ * Checks whether this selection is similar to given selection. Selections are similar if they have same directions, same
219
+ * number of ranges, and all {@link module:engine/view/range~ViewRange#getTrimmed trimmed} ranges from one selection are
220
+ * equal to any trimmed range from other selection.
221
+ *
222
+ * @param otherSelection Selection to compare with.
223
+ * @returns `true` if selections are similar, `false` otherwise.
224
+ */
225
+ isSimilar(otherSelection: ViewSelection | ViewDocumentSelection): boolean;
226
+ /**
227
+ * Converts `ViewDocumentSelection` instance to plain object and returns it.
228
+ *
229
+ * @returns `ViewDocumentSelection` instance converted to plain object.
230
+ */
231
+ toJSON(): unknown;
232
+ /**
233
+ * Sets this selection's ranges and direction to the specified location based on the given
234
+ * {@link module:engine/view/selection~ViewSelectable selectable}.
235
+ *
236
+ * ```ts
237
+ * // Sets selection to the given range.
238
+ * const range = writer.createRange( start, end );
239
+ * documentSelection._setTo( range );
240
+ *
241
+ * // Sets selection to given ranges.
242
+ * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
243
+ * documentSelection._setTo( range );
244
+ *
245
+ * // Sets selection to the other selection.
246
+ * const otherSelection = writer.createSelection();
247
+ * documentSelection._setTo( otherSelection );
248
+ *
249
+ * // Sets collapsed selection at the given position.
250
+ * const position = writer.createPositionAt( root, offset );
251
+ * documentSelection._setTo( position );
252
+ *
253
+ * // Sets collapsed selection at the position of given item and offset.
254
+ * documentSelection._setTo( paragraph, offset );
255
+ * ```
256
+ *
257
+ * Creates a range inside an {@link module:engine/view/element~ViewElement element} which starts before the first child of
258
+ * that element and ends after the last child of that element.
259
+ *
260
+ * ```ts
261
+ * documentSelection._setTo( paragraph, 'in' );
262
+ * ```
263
+ *
264
+ * Creates a range on an {@link module:engine/view/item~ViewItem item} which starts before the item and ends just after the item.
265
+ *
266
+ * ```ts
267
+ * documentSelection._setTo( paragraph, 'on' );
268
+ *
269
+ * // Clears selection. Removes all ranges.
270
+ * documentSelection._setTo( null );
271
+ * ```
272
+ *
273
+ * `Selection#_setTo()` method allow passing additional options (`backward`, `fake` and `label`) as the last argument.
274
+ *
275
+ * ```ts
276
+ * // Sets selection as backward.
277
+ * documentSelection._setTo( range, { backward: true } );
278
+ * ```
279
+ *
280
+ * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
281
+ * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
282
+ * represented in other way, for example by applying proper CSS class.
283
+ *
284
+ * Additionally fake's selection label can be provided. It will be used to des cribe fake selection in DOM
285
+ * (and be properly handled by screen readers).
286
+ *
287
+ * ```ts
288
+ * // Creates fake selection with label.
289
+ * documentSelection._setTo( range, { fake: true, label: 'foo' } );
290
+ * ```
291
+ *
292
+ * @internal
293
+ * @fires change
294
+ */
295
+ _setTo(...args: Parameters<ViewSelection["setTo"]>): void;
296
+ /**
297
+ * Moves {@link #focus} to the specified location.
298
+ *
299
+ * The location can be specified in the same form as
300
+ * {@link module:engine/view/view~EditingView#createPositionAt view.createPositionAt()}
301
+ * parameters.
302
+ *
303
+ * @internal
304
+ * @fires change
305
+ * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/view/item~ViewItem view item}.
306
+ */
307
+ _setFocus(itemOrPosition: ViewItem | ViewPosition, offset?: ViewPositionOffset): void;
307
308
  }
308
309
  /**
309
- * Fired whenever selection ranges are changed through {@link ~ViewDocumentSelection Selection API}.
310
- *
311
- * @eventName ~ViewDocumentSelection#change
312
- */
310
+ * Fired whenever selection ranges are changed through {@link ~ViewDocumentSelection Selection API}.
311
+ *
312
+ * @eventName ~ViewDocumentSelection#change
313
+ */
313
314
  export type ViewDocumentSelectionChangeEvent = ViewSelectionChangeEvent;
314
315
  export {};