@ckeditor/ckeditor5-engine 37.0.0-alpha.0 → 37.0.0-alpha.1

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 (63) hide show
  1. package/package.json +23 -23
  2. package/src/controller/datacontroller.d.ts +24 -24
  3. package/src/controller/datacontroller.js +10 -7
  4. package/src/conversion/downcastdispatcher.d.ts +8 -8
  5. package/src/conversion/mapper.d.ts +6 -2
  6. package/src/conversion/upcastdispatcher.d.ts +8 -8
  7. package/src/conversion/viewconsumable.d.ts +193 -1
  8. package/src/conversion/viewconsumable.js +1 -30
  9. package/src/index.d.ts +6 -3
  10. package/src/index.js +3 -0
  11. package/src/model/document.d.ts +2 -1
  12. package/src/model/documentselection.d.ts +4 -4
  13. package/src/model/liveposition.d.ts +1 -1
  14. package/src/model/liverange.d.ts +2 -2
  15. package/src/model/markercollection.d.ts +5 -5
  16. package/src/model/model.d.ts +97 -24
  17. package/src/model/model.js +0 -51
  18. package/src/model/operation/mergeoperation.d.ts +2 -2
  19. package/src/model/operation/mergeoperation.js +1 -1
  20. package/src/model/operation/splitoperation.d.ts +1 -1
  21. package/src/model/operation/splitoperation.js +1 -1
  22. package/src/model/operation/utils.d.ts +1 -1
  23. package/src/model/operation/utils.js +1 -1
  24. package/src/model/schema.d.ts +10 -10
  25. package/src/model/schema.js +4 -4
  26. package/src/model/selection.d.ts +2 -2
  27. package/src/model/typecheckable.d.ts +31 -1
  28. package/src/model/writer.d.ts +100 -3
  29. package/src/model/writer.js +0 -57
  30. package/src/view/document.d.ts +1 -1
  31. package/src/view/documentfragment.d.ts +0 -1
  32. package/src/view/documentfragment.js +0 -1
  33. package/src/view/documentselection.d.ts +88 -1
  34. package/src/view/documentselection.js +0 -55
  35. package/src/view/domconverter.d.ts +30 -0
  36. package/src/view/domconverter.js +0 -9
  37. package/src/view/downcastwriter.d.ts +192 -0
  38. package/src/view/downcastwriter.js +0 -123
  39. package/src/view/element.d.ts +2 -0
  40. package/src/view/node.d.ts +4 -1
  41. package/src/view/observer/arrowkeysobserver.d.ts +1 -1
  42. package/src/view/observer/clickobserver.d.ts +1 -1
  43. package/src/view/observer/compositionobserver.d.ts +3 -3
  44. package/src/view/observer/fakeselectionobserver.d.ts +0 -3
  45. package/src/view/observer/fakeselectionobserver.js +0 -3
  46. package/src/view/observer/focusobserver.d.ts +2 -2
  47. package/src/view/observer/inputobserver.d.ts +2 -2
  48. package/src/view/observer/keyobserver.d.ts +3 -4
  49. package/src/view/observer/mouseobserver.d.ts +4 -4
  50. package/src/view/observer/selectionobserver.d.ts +3 -2
  51. package/src/view/observer/selectionobserver.js +8 -8
  52. package/src/view/observer/tabobserver.d.ts +1 -1
  53. package/src/view/position.d.ts +1 -1
  54. package/src/view/position.js +1 -1
  55. package/src/view/selection.d.ts +1 -1
  56. package/src/view/stylesmap.d.ts +3 -3
  57. package/src/view/typecheckable.d.ts +49 -2
  58. package/src/view/uielement.d.ts +1 -1
  59. package/src/view/uielement.js +1 -1
  60. package/src/view/upcastwriter.d.ts +92 -3
  61. package/src/view/upcastwriter.js +0 -61
  62. package/src/view/view.d.ts +91 -1
  63. package/src/view/view.js +3 -60
@@ -47,6 +47,8 @@ export default abstract class TypeCheckable {
47
47
  * imageElement.is( 'element', 'imageBlock' ); // -> same as above
48
48
  * imageElement.is( 'model:element', 'imageBlock' ); // -> same as above, but more precise
49
49
  * ```
50
+ *
51
+ * @label NODE
50
52
  */
51
53
  is(type: 'node' | 'model:node'): this is Node | Element | Text | RootElement;
52
54
  /**
@@ -69,6 +71,8 @@ export default abstract class TypeCheckable {
69
71
  * element.is( 'element', 'imageBlock' ); // -> true if this is an <imageBlock> element
70
72
  * text.is( 'element', 'imageBlock' ); -> false
71
73
  * ```
74
+ *
75
+ * @label ELEMENT
72
76
  */
73
77
  is(type: 'element' | 'model:element'): this is Element | RootElement;
74
78
  /**
@@ -92,6 +96,8 @@ export default abstract class TypeCheckable {
92
96
  * ```ts
93
97
  * rootElement.is( 'rootElement', '$root' ); // -> same as above
94
98
  * ```
99
+ *
100
+ * @label ROOT_ELEMENT
95
101
  */
96
102
  is(type: 'rootElement' | 'model:rootElement'): this is RootElement;
97
103
  /**
@@ -109,6 +115,8 @@ export default abstract class TypeCheckable {
109
115
  *
110
116
  * **Note:** Until version 20.0.0 this method wasn't accepting `'$text'` type. The legacy `'text'` type is still
111
117
  * accepted for backward compatibility.
118
+ *
119
+ * @label TEXT
112
120
  */
113
121
  is(type: '$text' | 'model:$text'): this is Text;
114
122
  /**
@@ -121,6 +129,8 @@ export default abstract class TypeCheckable {
121
129
  * position.is( 'view:position' ); // -> false
122
130
  * position.is( 'documentSelection' ); // -> false
123
131
  * ```
132
+ *
133
+ * @label POSITION
124
134
  */
125
135
  is(type: 'position' | 'model:position'): this is Position | LivePosition;
126
136
  /**
@@ -135,6 +145,8 @@ export default abstract class TypeCheckable {
135
145
  * livePosition.is( 'view:position' ); // -> false
136
146
  * livePosition.is( 'documentSelection' ); // -> false
137
147
  * ```
148
+ *
149
+ * @label LIVE_POSITION
138
150
  */
139
151
  is(type: 'livePosition' | 'model:livePosition'): this is LivePosition;
140
152
  /**
@@ -147,6 +159,8 @@ export default abstract class TypeCheckable {
147
159
  * range.is( 'view:range' ); // -> false
148
160
  * range.is( 'documentSelection' ); // -> false
149
161
  * ```
162
+ *
163
+ * @label RANGE
150
164
  */
151
165
  is(type: 'range' | 'model:range'): this is Range | LiveRange;
152
166
  /**
@@ -161,6 +175,8 @@ export default abstract class TypeCheckable {
161
175
  * liveRange.is( 'view:range' ); // -> false
162
176
  * liveRange.is( 'documentSelection' ); // -> false
163
177
  * ```
178
+ *
179
+ * @label LIVE_RANGE
164
180
  */
165
181
  is(type: 'liveRange' | 'model:liveRange'): this is LiveRange;
166
182
  /**
@@ -174,6 +190,8 @@ export default abstract class TypeCheckable {
174
190
  * docFrag.is( 'element' ); // -> false
175
191
  * docFrag.is( 'node' ); // -> false
176
192
  * ```
193
+ *
194
+ * @label DOCUMENT_FRAGMENT
177
195
  */
178
196
  is(type: 'documentFragment' | 'model:documentFragment'): this is DocumentFragment;
179
197
  /**
@@ -187,6 +205,8 @@ export default abstract class TypeCheckable {
187
205
  * selection.is( 'view:selection' ); // -> false
188
206
  * selection.is( 'range' ); // -> false
189
207
  * ```
208
+ *
209
+ * @label SELECTION
190
210
  */
191
211
  is(type: 'selection' | 'model:selection'): this is Selection | DocumentSelection;
192
212
  /**
@@ -202,10 +222,12 @@ export default abstract class TypeCheckable {
202
222
  * selection.is( 'element' ); // -> false
203
223
  * selection.is( 'node' ); // -> false
204
224
  * ```
225
+ *
226
+ * @label DOCUMENT_SELECTION
205
227
  */
206
228
  is(type: 'documentSelection' | 'model:documentSelection'): this is DocumentSelection;
207
229
  /**
208
- * Checks whether the object is of type {@link module:engine/model/marker~Marker}.
230
+ * Checks whether the object is of type {@link module:engine/model/markercollection~Marker}.
209
231
  *
210
232
  * ```ts
211
233
  * marker.is( 'marker' ); // -> true
@@ -214,6 +236,8 @@ export default abstract class TypeCheckable {
214
236
  * marker.is( 'view:element' ); // -> false
215
237
  * marker.is( 'documentSelection' ); // -> false
216
238
  * ```
239
+ *
240
+ * @label MARKER
217
241
  */
218
242
  is(type: 'marker' | 'model:marker'): this is Marker;
219
243
  /**
@@ -229,6 +253,8 @@ export default abstract class TypeCheckable {
229
253
  *
230
254
  * **Note:** Until version 20.0.0 this method wasn't accepting `'$textProxy'` type. The legacy `'textProxt'` type is still
231
255
  * accepted for backward compatibility.
256
+ *
257
+ * @label TEXT_PROXY
232
258
  */
233
259
  is(type: '$textProxy' | 'model:$textProxy'): this is TextProxy;
234
260
  /**
@@ -238,6 +264,8 @@ export default abstract class TypeCheckable {
238
264
  * element.is( 'element', 'imageBlock' ); // -> true if this is an <imageBlock> element
239
265
  * text.is( 'element', 'imageBlock' ); -> false
240
266
  * ```
267
+ *
268
+ * @label ELEMENT_NAME
241
269
  */
242
270
  is<N extends string>(type: 'element' | 'model:element', name: N): this is (Element | RootElement) & {
243
271
  name: N;
@@ -248,6 +276,8 @@ export default abstract class TypeCheckable {
248
276
  * ```ts
249
277
  * rootElement.is( 'rootElement', '$root' );
250
278
  * ```
279
+ *
280
+ * @label ROOT_ELEMENT_NAME
251
281
  */
252
282
  is<N extends string>(type: 'rootElement' | 'model:rootElement', name: N): this is RootElement & {
253
283
  name: N;
@@ -162,6 +162,7 @@ export default class Writer {
162
162
  *
163
163
  * These parameters work in the same way as {@link #createPositionAt `writer.createPositionAt()`}.
164
164
  *
165
+ * @label WITHOUT_ATTRIBUTES
165
166
  * @param text Text data.
166
167
  * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
167
168
  */
@@ -187,11 +188,12 @@ export default class Writer {
187
188
  *
188
189
  * These parameters work in the same way as {@link #createPositionAt `writer.createPositionAt()`}.
189
190
  *
191
+ * @label WITH_ATTRIBUTES
190
192
  * @param text Text data.
191
193
  * @param attributes Text attributes.
192
194
  * @param offset Offset or one of the flags. Used only when third parameter is a {@link module:engine/model/item~Item model item}.
193
195
  */
194
- insertText(text: string, attributes?: NodeAttributes, itemOrPosition?: Item | Position, offset?: number | 'end' | 'before' | 'after'): void;
196
+ insertText(text: string, attributes?: NodeAttributes, itemOrPosition?: Item | Position, offset?: PositionOffset): void;
195
197
  /**
196
198
  * Creates and inserts element on given position. You can optionally set attributes:
197
199
  *
@@ -213,10 +215,11 @@ export default class Writer {
213
215
  *
214
216
  * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
215
217
  *
218
+ * @label WITHOUT_ATTRIBUTES
216
219
  * @param name Name of the element.
217
220
  * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
218
221
  */
219
- insertElement(name: string, itemOrPosition: Item | DocumentFragment | Position, offset?: number | 'end' | 'before' | 'after'): void;
222
+ insertElement(name: string, itemOrPosition: Item | DocumentFragment | Position, offset?: PositionOffset): void;
220
223
  /**
221
224
  * Creates and inserts element with specified attributes on given position.
222
225
  *
@@ -238,11 +241,12 @@ export default class Writer {
238
241
  *
239
242
  * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
240
243
  *
244
+ * @label WITH_ATTRIBUTES
241
245
  * @param name Name of the element.
242
246
  * @param attributes Elements attributes.
243
247
  * @param offset Offset or one of the flags. Used only when third parameter is a {@link module:engine/model/item~Item model item}.
244
248
  */
245
- insertElement(name: string, attributes: NodeAttributes, itemOrPosition: Item | DocumentFragment | Position, offset?: number | 'end' | 'before' | 'after'): void;
249
+ insertElement(name: string, attributes: NodeAttributes, itemOrPosition: Item | DocumentFragment | Position, offset?: PositionOffset): void;
246
250
  /**
247
251
  * Inserts item at the end of the given parent.
248
252
  *
@@ -266,6 +270,7 @@ export default class Writer {
266
270
  * writer.appendText( 'foo', paragraph );
267
271
  * ```
268
272
  *
273
+ * @label WITHOUT_ATTRIBUTES
269
274
  * @param text Text data.
270
275
  */
271
276
  appendText(text: string, parent: Element | DocumentFragment): void;
@@ -276,6 +281,7 @@ export default class Writer {
276
281
  * writer.appendText( 'foo', { bold: true }, paragraph );
277
282
  * ```
278
283
  *
284
+ * @label WITH_ATTRIBUTES
279
285
  * @param text Text data.
280
286
  * @param attributes Text attributes.
281
287
  */
@@ -287,6 +293,7 @@ export default class Writer {
287
293
  * writer.appendElement( 'paragraph', root );
288
294
  * ```
289
295
  *
296
+ * @label WITHOUT_ATTRIBUTES
290
297
  * @param name Name of the element.
291
298
  */
292
299
  appendElement(name: string, parent: Element | DocumentFragment): void;
@@ -297,6 +304,7 @@ export default class Writer {
297
304
  * writer.appendElement( 'paragraph', { alignment: 'center' }, root );
298
305
  * ```
299
306
  *
307
+ * @label WITH_ATTRIBUTES
300
308
  * @param name Name of the element.
301
309
  * @param attributes Elements attributes.
302
310
  */
@@ -429,9 +437,19 @@ export default class Writer {
429
437
  * @param element Element which is a parent for the range.
430
438
  */
431
439
  createRangeOn(element: Item): Range;
440
+ /**
441
+ * Shortcut for {@link module:engine/model/model~Model#createSelection:NODE_OFFSET `Model#createSelection()`}.
442
+ *
443
+ * @label NODE_OFFSET
444
+ */
432
445
  createSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: {
433
446
  backward?: boolean;
434
447
  }): Selection;
448
+ /**
449
+ * Shortcut for {@link module:engine/model/model~Model#createSelection:SELECTABLE `Model#createSelection()`}.
450
+ *
451
+ * @label SELECTABLE
452
+ */
435
453
  createSelection(selectable?: Exclude<Selectable, Node>, options?: {
436
454
  backward?: boolean;
437
455
  }): Selection;
@@ -605,9 +623,86 @@ export default class Writer {
605
623
  * @param markerOrName Marker or marker name to remove.
606
624
  */
607
625
  removeMarker(markerOrName: string | Marker): void;
626
+ /**
627
+ * Sets the document's selection (ranges and direction) to the specified location based on the given
628
+ * {@link module:engine/model/selection~Selectable selectable} or creates an empty selection if no arguments were passed.
629
+ *
630
+ * ```ts
631
+ * // Sets collapsed selection at the position of the given node and an offset.
632
+ * writer.setSelection( paragraph, offset );
633
+ * ```
634
+ *
635
+ * Creates a range inside an {@link module:engine/model/element~Element element} which starts before the first child of
636
+ * that element and ends after the last child of that element.
637
+ *
638
+ * ```ts
639
+ * writer.setSelection( paragraph, 'in' );
640
+ * ```
641
+ *
642
+ * Creates a range on an {@link module:engine/model/item~Item item} which starts before the item and ends just after the item.
643
+ *
644
+ * ```ts
645
+ * writer.setSelection( paragraph, 'on' );
646
+ * ```
647
+ *
648
+ * `Writer#setSelection()` allow passing additional options (`backward`) as the last argument.
649
+ *
650
+ * ```ts
651
+ * // Sets selection as backward.
652
+ * writer.setSelection( element, 'in', { backward: true } );
653
+ * ```
654
+ *
655
+ * Throws `writer-incorrect-use` error when the writer is used outside the `change()` block.
656
+ *
657
+ * See also: {@link #setSelection:SELECTABLE `setSelection( selectable, options )`}.
658
+ *
659
+ * @label NODE_OFFSET
660
+ */
608
661
  setSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: {
609
662
  backward?: boolean;
610
663
  }): void;
664
+ /**
665
+ * Sets the document's selection (ranges and direction) to the specified location based on the given
666
+ * {@link module:engine/model/selection~Selectable selectable} or creates an empty selection if no arguments were passed.
667
+ *
668
+ * ```ts
669
+ * // Sets selection to the given range.
670
+ * const range = writer.createRange( start, end );
671
+ * writer.setSelection( range );
672
+ *
673
+ * // Sets selection to given ranges.
674
+ * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
675
+ * writer.setSelection( ranges );
676
+ *
677
+ * // Sets selection to other selection.
678
+ * const otherSelection = writer.createSelection();
679
+ * writer.setSelection( otherSelection );
680
+ *
681
+ * // Sets selection to the given document selection.
682
+ * const documentSelection = model.document.selection;
683
+ * writer.setSelection( documentSelection );
684
+ *
685
+ * // Sets collapsed selection at the given position.
686
+ * const position = writer.createPosition( root, path );
687
+ * writer.setSelection( position );
688
+ *
689
+ * // Removes all selection's ranges.
690
+ * writer.setSelection( null );
691
+ * ```
692
+ *
693
+ * `Writer#setSelection()` allow passing additional options (`backward`) as the last argument.
694
+ *
695
+ * ```ts
696
+ * // Sets selection as backward.
697
+ * writer.setSelection( range, { backward: true } );
698
+ * ```
699
+ *
700
+ * Throws `writer-incorrect-use` error when the writer is used outside the `change()` block.
701
+ *
702
+ * See also: {@link #setSelection:NODE_OFFSET `setSelection( node, placeOrOffset, options )`}.
703
+ *
704
+ * @label SELECTABLE
705
+ */
611
706
  setSelection(selectable: Exclude<Selectable, Node>, options?: {
612
707
  backward?: boolean;
613
708
  }): void;
@@ -628,6 +723,7 @@ export default class Writer {
628
723
  * writer.setSelectionAttribute( 'italic', true );
629
724
  * ```
630
725
  *
726
+ * @label KEY_VALUE
631
727
  * @param key Key of the attribute to set.
632
728
  * @param value Attribute value.
633
729
  */
@@ -647,6 +743,7 @@ export default class Writer {
647
743
  * writer.setSelectionAttribute( new Map( [ [ 'italic', true ] ] ) );
648
744
  * ```
649
745
  *
746
+ * @label OBJECT
650
747
  * @param objectOrIterable Object / iterable of key => value attribute pairs.
651
748
  */
652
749
  setSelectionAttribute(objectOrIterable: NodeAttributes): void;
@@ -521,9 +521,6 @@ export default class Writer {
521
521
  createRangeOn(element) {
522
522
  return this.model.createRangeOn(element);
523
523
  }
524
- /**
525
- * Shortcut for {@link module:engine/model/model~Model#createSelection `Model#createSelection()`}.
526
- */
527
524
  createSelection(...args) {
528
525
  return this.model.createSelection(...args);
529
526
  }
@@ -920,60 +917,6 @@ export default class Writer {
920
917
  const oldRange = marker.getRange();
921
918
  applyMarkerOperation(this, name, oldRange, null, marker.affectsData);
922
919
  }
923
- /**
924
- * Sets the document's selection (ranges and direction) to the specified location based on the given
925
- * {@link module:engine/model/selection~Selectable selectable} or creates an empty selection if no arguments were passed.
926
- *
927
- * ```ts
928
- * // Sets selection to the given range.
929
- * const range = writer.createRange( start, end );
930
- * writer.setSelection( range );
931
- *
932
- * // Sets selection to given ranges.
933
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
934
- * writer.setSelection( ranges );
935
- *
936
- * // Sets selection to other selection.
937
- * const otherSelection = writer.createSelection();
938
- * writer.setSelection( otherSelection );
939
- *
940
- * // Sets selection to the given document selection.
941
- * const documentSelection = model.document.selection;
942
- * writer.setSelection( documentSelection );
943
- *
944
- * // Sets collapsed selection at the given position.
945
- * const position = writer.createPosition( root, path );
946
- * writer.setSelection( position );
947
- *
948
- * // Sets collapsed selection at the position of the given node and an offset.
949
- * writer.setSelection( paragraph, offset );
950
- * ```
951
- *
952
- * Creates a range inside an {@link module:engine/model/element~Element element} which starts before the first child of
953
- * that element and ends after the last child of that element.
954
- *
955
- * ```ts
956
- * writer.setSelection( paragraph, 'in' );
957
- * ```
958
- *
959
- * Creates a range on an {@link module:engine/model/item~Item item} which starts before the item and ends just after the item.
960
- *
961
- * ```ts
962
- * writer.setSelection( paragraph, 'on' );
963
- *
964
- * // Removes all selection's ranges.
965
- * writer.setSelection( null );
966
- * ```
967
- *
968
- * `Writer#setSelection()` allow passing additional options (`backward`) as the last argument.
969
- *
970
- * ```ts
971
- * // Sets selection as backward.
972
- * writer.setSelection( range, { backward: true } );
973
- * ```
974
- *
975
- * Throws `writer-incorrect-use` error when the writer is used outside the `change()` block.
976
- */
977
920
  setSelection(...args) {
978
921
  this._assertWriterUsedCorrectly();
979
922
  this.model.document.selection._setTo(...args);
@@ -175,7 +175,7 @@ export type ChangeType = 'children' | 'attributes' | 'text';
175
175
  * {@link module:engine/view/view~View#event:render rendered}, but should be also fired by observers in case of
176
176
  * other actions which may change layout, for instance when image loads.
177
177
  *
178
- * @eventName layoutChanged
178
+ * @eventName ~Document#layoutChanged
179
179
  */
180
180
  export type ViewDocumentLayoutChangedEvent = {
181
181
  name: 'layoutChanged';
@@ -128,7 +128,6 @@ export default class DocumentFragment extends DocumentFragment_base implements I
128
128
  * @internal
129
129
  * @param type Type of the change.
130
130
  * @param node Changed node.
131
- * @fires change
132
131
  */
133
132
  _fireChange(type: ChangeType, node: Node | DocumentFragment): void;
134
133
  /**
@@ -174,7 +174,6 @@ export default class DocumentFragment extends EmitterMixin(TypeCheckable) {
174
174
  * @internal
175
175
  * @param type Type of the change.
176
176
  * @param node Changed node.
177
- * @fires change
178
177
  */
179
178
  _fireChange(type, node) {
180
179
  this.fire('change:' + type, node);
@@ -29,7 +29,94 @@ export default class DocumentSelection extends DocumentSelection_base {
29
29
  * Selection is used internally (`DocumentSelection` is a proxy to that selection).
30
30
  */
31
31
  private readonly _selection;
32
+ /**
33
+ * Creates new DocumentSelection 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 DocumentSelection( paragraph, offset );
39
+ *
40
+ * // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
41
+ * // first child of that element and ends after the last child of that element.
42
+ * const selection = new DocumentSelection( paragraph, 'in' );
43
+ *
44
+ * // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
45
+ * // just after the item.
46
+ * const selection = new DocumentSelection( 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 DocumentSelection( 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 DocumentSelection( element, 'in', { fake: true, label: 'foo' } );
66
+ * ```
67
+ *
68
+ * See also: {@link #constructor:SELECTABLE `constructor( selectable, options )`}.
69
+ *
70
+ * @label NODE_OFFSET
71
+ */
32
72
  constructor(selectable: Node, placeOrOffset: PlaceOrOffset, options?: SelectionOptions);
73
+ /**
74
+ * Creates new DocumentSelection instance.
75
+ *
76
+ * ```ts
77
+ * // Creates empty selection without ranges.
78
+ * const selection = new DocumentSelection();
79
+ *
80
+ * // Creates selection at the given range.
81
+ * const range = writer.createRange( start, end );
82
+ * const selection = new DocumentSelection( range );
83
+ *
84
+ * // Creates selection at the given ranges
85
+ * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
86
+ * const selection = new DocumentSelection( ranges );
87
+ *
88
+ * // Creates selection from the other selection.
89
+ * const otherSelection = writer.createSelection();
90
+ * const selection = new DocumentSelection( otherSelection );
91
+ *
92
+ * // Creates selection at the given position.
93
+ * const position = writer.createPositionAt( root, offset );
94
+ * const selection = new DocumentSelection( 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 DocumentSelection( 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 DocumentSelection( range, { fake: true, label: 'foo' } );
114
+ * ```
115
+ *
116
+ * See also: {@link #constructor:NODE_OFFSET `constructor( node, placeOrOffset, options )`}.
117
+ *
118
+ * @label SELECTABLE
119
+ */
33
120
  constructor(selectable?: Exclude<Selectable, Node>, options?: SelectionOptions);
34
121
  /**
35
122
  * Returns true if selection instance is marked as `fake`.
@@ -213,7 +300,7 @@ export default class DocumentSelection extends DocumentSelection_base {
213
300
  /**
214
301
  * Fired whenever selection ranges are changed through {@link ~DocumentSelection Selection API}.
215
302
  *
216
- * @eventName change
303
+ * @eventName ~DocumentSelection#change
217
304
  */
218
305
  export type ViewDocumentSelectionChangeEvent = ViewSelectionChangeEvent;
219
306
  export {};
@@ -19,61 +19,6 @@ import { EmitterMixin } from '@ckeditor/ckeditor5-utils';
19
19
  * (so via {@link module:engine/view/downcastwriter~DowncastWriter#setSelection `DowncastWriter#setSelection()`}).
20
20
  */
21
21
  export default class DocumentSelection extends EmitterMixin(TypeCheckable) {
22
- /**
23
- * Creates new DocumentSelection instance.
24
- *
25
- * ```ts
26
- * // Creates empty selection without ranges.
27
- * const selection = new DocumentSelection();
28
- *
29
- * // Creates selection at the given range.
30
- * const range = writer.createRange( start, end );
31
- * const selection = new DocumentSelection( range );
32
- *
33
- * // Creates selection at the given ranges
34
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
35
- * const selection = new DocumentSelection( ranges );
36
- *
37
- * // Creates selection from the other selection.
38
- * const otherSelection = writer.createSelection();
39
- * const selection = new DocumentSelection( otherSelection );
40
- *
41
- * // Creates selection at the given position.
42
- * const position = writer.createPositionAt( root, offset );
43
- * const selection = new DocumentSelection( position );
44
- *
45
- * // Creates collapsed selection at the position of given item and offset.
46
- * const paragraph = writer.createContainerElement( 'paragraph' );
47
- * const selection = new DocumentSelection( paragraph, offset );
48
- *
49
- * // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
50
- * // first child of that element and ends after the last child of that element.
51
- * const selection = new DocumentSelection( paragraph, 'in' );
52
- *
53
- * // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
54
- * // just after the item.
55
- * const selection = new DocumentSelection( paragraph, 'on' );
56
- * ```
57
- *
58
- * `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
59
- *
60
- * ```ts
61
- * // Creates backward selection.
62
- * const selection = new DocumentSelection( range, { backward: true } );
63
- * ```
64
- *
65
- * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
66
- * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
67
- * represented in other way, for example by applying proper CSS class.
68
- *
69
- * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
70
- * (and be properly handled by screen readers).
71
- *
72
- * ```ts
73
- * // Creates fake selection with label.
74
- * const selection = new DocumentSelection( range, { fake: true, label: 'foo' } );
75
- * ```
76
- */
77
22
  constructor(...args) {
78
23
  super();
79
24
  this._selection = new Selection();
@@ -338,8 +338,38 @@ export default class DomConverter {
338
338
  * @returns Corresponding view text node or `null`, if it was not possible to find a corresponding node.
339
339
  */
340
340
  findCorrespondingViewText(domText: DomText): ViewText | ViewUIElement | ViewRawElement | null;
341
+ /**
342
+ * Returns corresponding DOM item for provided {@link module:engine/view/element~Element Element} or
343
+ * {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment}.
344
+ * To find a corresponding text for {@link module:engine/view/text~Text view Text instance}
345
+ * use {@link #findCorrespondingDomText}.
346
+ *
347
+ * @label ELEMENT
348
+ * @param element View element or document fragment.
349
+ * @returns Corresponding DOM node or document fragment.
350
+ */
341
351
  mapViewToDom(element: ViewElement): DomElement | undefined;
352
+ /**
353
+ * Returns corresponding DOM item for provided {@link module:engine/view/element~Element Element} or
354
+ * {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment}.
355
+ * To find a corresponding text for {@link module:engine/view/text~Text view Text instance}
356
+ * use {@link #findCorrespondingDomText}.
357
+ *
358
+ * @label DOCUMENT_FRAGMENT
359
+ * @param documentFragment View element or document fragment.
360
+ * @returns Corresponding DOM node or document fragment.
361
+ */
342
362
  mapViewToDom(documentFragment: ViewDocumentFragment): DomDocumentFragment | undefined;
363
+ /**
364
+ * Returns corresponding DOM item for provided {@link module:engine/view/element~Element Element} or
365
+ * {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment}.
366
+ * To find a corresponding text for {@link module:engine/view/text~Text view Text instance}
367
+ * use {@link #findCorrespondingDomText}.
368
+ *
369
+ * @label DOCUMENT_FRAGMENT_OR_ELEMENT
370
+ * @param documentFragmentOrElement View element or document fragment.
371
+ * @returns Corresponding DOM node or document fragment.
372
+ */
343
373
  mapViewToDom(documentFragmentOrElement: ViewElement | ViewDocumentFragment): DomElement | DomDocumentFragment | undefined;
344
374
  /**
345
375
  * Finds corresponding text node. Text nodes are not {@link module:engine/view/domconverter~DomConverter#bindElements bound},
@@ -735,15 +735,6 @@ export default class DomConverter {
735
735
  }
736
736
  return null;
737
737
  }
738
- /**
739
- * Returns corresponding DOM item for provided {@link module:engine/view/element~Element Element} or
740
- * {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment}.
741
- * To find a corresponding text for {@link module:engine/view/text~Text view Text instance}
742
- * use {@link #findCorrespondingDomText}.
743
- *
744
- * @param documentFragmentOrElement View element or document fragment.
745
- * @returns Corresponding DOM node or document fragment.
746
- */
747
738
  mapViewToDom(documentFragmentOrElement) {
748
739
  return this._viewToDomMapping.get(documentFragmentOrElement);
749
740
  }