@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.
- package/package.json +23 -23
- package/src/controller/datacontroller.d.ts +24 -24
- package/src/controller/datacontroller.js +10 -7
- package/src/conversion/downcastdispatcher.d.ts +8 -8
- package/src/conversion/mapper.d.ts +6 -2
- package/src/conversion/upcastdispatcher.d.ts +8 -8
- package/src/conversion/viewconsumable.d.ts +193 -1
- package/src/conversion/viewconsumable.js +1 -30
- package/src/index.d.ts +6 -3
- package/src/index.js +3 -0
- package/src/model/document.d.ts +2 -1
- package/src/model/documentselection.d.ts +4 -4
- package/src/model/liveposition.d.ts +1 -1
- package/src/model/liverange.d.ts +2 -2
- package/src/model/markercollection.d.ts +5 -5
- package/src/model/model.d.ts +97 -24
- package/src/model/model.js +0 -51
- package/src/model/operation/mergeoperation.d.ts +2 -2
- package/src/model/operation/mergeoperation.js +1 -1
- package/src/model/operation/splitoperation.d.ts +1 -1
- package/src/model/operation/splitoperation.js +1 -1
- package/src/model/operation/utils.d.ts +1 -1
- package/src/model/operation/utils.js +1 -1
- package/src/model/schema.d.ts +10 -10
- package/src/model/schema.js +4 -4
- package/src/model/selection.d.ts +2 -2
- package/src/model/typecheckable.d.ts +31 -1
- package/src/model/writer.d.ts +100 -3
- package/src/model/writer.js +0 -57
- package/src/view/document.d.ts +1 -1
- package/src/view/documentfragment.d.ts +0 -1
- package/src/view/documentfragment.js +0 -1
- package/src/view/documentselection.d.ts +88 -1
- package/src/view/documentselection.js +0 -55
- package/src/view/domconverter.d.ts +30 -0
- package/src/view/domconverter.js +0 -9
- package/src/view/downcastwriter.d.ts +192 -0
- package/src/view/downcastwriter.js +0 -123
- package/src/view/element.d.ts +2 -0
- package/src/view/node.d.ts +4 -1
- package/src/view/observer/arrowkeysobserver.d.ts +1 -1
- package/src/view/observer/clickobserver.d.ts +1 -1
- package/src/view/observer/compositionobserver.d.ts +3 -3
- package/src/view/observer/fakeselectionobserver.d.ts +0 -3
- package/src/view/observer/fakeselectionobserver.js +0 -3
- package/src/view/observer/focusobserver.d.ts +2 -2
- package/src/view/observer/inputobserver.d.ts +2 -2
- package/src/view/observer/keyobserver.d.ts +3 -4
- package/src/view/observer/mouseobserver.d.ts +4 -4
- package/src/view/observer/selectionobserver.d.ts +3 -2
- package/src/view/observer/selectionobserver.js +8 -8
- package/src/view/observer/tabobserver.d.ts +1 -1
- package/src/view/position.d.ts +1 -1
- package/src/view/position.js +1 -1
- package/src/view/selection.d.ts +1 -1
- package/src/view/stylesmap.d.ts +3 -3
- package/src/view/typecheckable.d.ts +49 -2
- package/src/view/uielement.d.ts +1 -1
- package/src/view/uielement.js +1 -1
- package/src/view/upcastwriter.d.ts +92 -3
- package/src/view/upcastwriter.js +0 -61
- package/src/view/view.d.ts +91 -1
- package/src/view/view.js +3 -60
|
@@ -57,7 +57,105 @@ export default class DowncastWriter {
|
|
|
57
57
|
* @param document The view document instance.
|
|
58
58
|
*/
|
|
59
59
|
constructor(document: Document);
|
|
60
|
+
/**
|
|
61
|
+
* Sets {@link module:engine/view/documentselection~DocumentSelection selection's} ranges and direction to the
|
|
62
|
+
* specified location based on the given {@link module:engine/view/selection~Selectable selectable}.
|
|
63
|
+
*
|
|
64
|
+
* Usage:
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* // Sets collapsed selection at the position of given item and offset.
|
|
68
|
+
* const paragraph = writer.createContainerElement( 'p' );
|
|
69
|
+
* writer.setSelection( paragraph, offset );
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* Creates a range inside an {@link module:engine/view/element~Element element} which starts before the first child of
|
|
73
|
+
* that element and ends after the last child of that element.
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* writer.setSelection( paragraph, 'in' );
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* Creates a range on the {@link module:engine/view/item~Item item} which starts before the item and ends just after the item.
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* writer.setSelection( paragraph, 'on' );
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* `DowncastWriter#setSelection()` allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* // Sets selection as backward.
|
|
89
|
+
* writer.setSelection( element, 'in', { backward: true } );
|
|
90
|
+
*
|
|
91
|
+
* // Sets selection as fake.
|
|
92
|
+
* // Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
93
|
+
* // This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
94
|
+
* // represented in other way, for example by applying proper CSS class.
|
|
95
|
+
* writer.setSelection( element, 'in', { fake: true } );
|
|
96
|
+
*
|
|
97
|
+
* // Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
98
|
+
* // (and be properly handled by screen readers).
|
|
99
|
+
* writer.setSelection( element, 'in', { fake: true, label: 'foo' } );
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* See also: {@link #setSelection:SELECTABLE `setSelection( selectable, options )`}.
|
|
103
|
+
*
|
|
104
|
+
* @label NODE_OFFSET
|
|
105
|
+
*/
|
|
60
106
|
setSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: SelectionOptions): void;
|
|
107
|
+
/**
|
|
108
|
+
* Sets {@link module:engine/view/documentselection~DocumentSelection selection's} ranges and direction to the
|
|
109
|
+
* specified location based on the given {@link module:engine/view/selection~Selectable selectable}.
|
|
110
|
+
*
|
|
111
|
+
* Usage:
|
|
112
|
+
*
|
|
113
|
+
* ```ts
|
|
114
|
+
* // Sets selection to the given range.
|
|
115
|
+
* const range = writer.createRange( start, end );
|
|
116
|
+
* writer.setSelection( range );
|
|
117
|
+
*
|
|
118
|
+
* // Sets backward selection to the given range.
|
|
119
|
+
* const range = writer.createRange( start, end );
|
|
120
|
+
* writer.setSelection( range );
|
|
121
|
+
*
|
|
122
|
+
* // Sets selection to given ranges.
|
|
123
|
+
* const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
|
|
124
|
+
* writer.setSelection( range );
|
|
125
|
+
*
|
|
126
|
+
* // Sets selection to the other selection.
|
|
127
|
+
* const otherSelection = writer.createSelection();
|
|
128
|
+
* writer.setSelection( otherSelection );
|
|
129
|
+
*
|
|
130
|
+
* // Sets collapsed selection at the given position.
|
|
131
|
+
* const position = writer.createPositionFromPath( root, path );
|
|
132
|
+
* writer.setSelection( position );
|
|
133
|
+
*
|
|
134
|
+
* // Removes all ranges.
|
|
135
|
+
* writer.setSelection( null );
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* `DowncastWriter#setSelection()` allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
139
|
+
*
|
|
140
|
+
* ```ts
|
|
141
|
+
* // Sets selection as backward.
|
|
142
|
+
* writer.setSelection( range, { backward: true } );
|
|
143
|
+
*
|
|
144
|
+
* // Sets selection as fake.
|
|
145
|
+
* // Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
146
|
+
* // This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
147
|
+
* // represented in other way, for example by applying proper CSS class.
|
|
148
|
+
* writer.setSelection( range, { fake: true } );
|
|
149
|
+
*
|
|
150
|
+
* // Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
151
|
+
* // (and be properly handled by screen readers).
|
|
152
|
+
* writer.setSelection( range, { fake: true, label: 'foo' } );
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* See also: {@link #setSelection:NODE_OFFSET `setSelection( node, placeOrOffset, options )`}.
|
|
156
|
+
*
|
|
157
|
+
* @label SELECTABLE
|
|
158
|
+
*/
|
|
61
159
|
setSelection(selectable: Exclude<Selectable, Node>, options?: SelectionOptions): void;
|
|
62
160
|
/**
|
|
63
161
|
* Moves {@link module:engine/view/documentselection~DocumentSelection#focus selection's focus} to the specified location.
|
|
@@ -133,6 +231,7 @@ export default class DowncastWriter {
|
|
|
133
231
|
* writer.createContainerElement( 'span', { class: 'placeholder' }, { renderUnsafeAttributes: [ 'foo' ] } );
|
|
134
232
|
* ```
|
|
135
233
|
*
|
|
234
|
+
* @label WITHOUT_CHILDREN
|
|
136
235
|
* @param name Name of the element.
|
|
137
236
|
* @param attributes Elements attributes.
|
|
138
237
|
* @param options Element's options.
|
|
@@ -160,6 +259,7 @@ export default class DowncastWriter {
|
|
|
160
259
|
* ], { renderUnsafeAttributes: [ 'foo' ] } );
|
|
161
260
|
* ```
|
|
162
261
|
*
|
|
262
|
+
* @label WITH_CHILDREN
|
|
163
263
|
* @param name Name of the element.
|
|
164
264
|
* @param attributes Elements attributes.
|
|
165
265
|
* @param children A node or a list of nodes to be inserted into the created element.
|
|
@@ -323,6 +423,7 @@ export default class DowncastWriter {
|
|
|
323
423
|
* {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules a particular style processor rule is enabled}.
|
|
324
424
|
* See {@link module:engine/view/stylesmap~StylesMap#set `StylesMap#set()`} for details.
|
|
325
425
|
*
|
|
426
|
+
* @label KEY_VALUE
|
|
326
427
|
* @param property Property name.
|
|
327
428
|
* @param value Value to set.
|
|
328
429
|
* @param element Element to set styles on.
|
|
@@ -342,6 +443,7 @@ export default class DowncastWriter {
|
|
|
342
443
|
* {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules a particular style processor rule is enabled}.
|
|
343
444
|
* See {@link module:engine/view/stylesmap~StylesMap#set `StylesMap#set()`} for details.
|
|
344
445
|
*
|
|
446
|
+
* @label OBJECT
|
|
345
447
|
* @param property Object with key - value pairs.
|
|
346
448
|
* @param element Element to set styles on.
|
|
347
449
|
*/
|
|
@@ -647,7 +749,97 @@ export default class DowncastWriter {
|
|
|
647
749
|
* @param element Element which is a parent for the range.
|
|
648
750
|
*/
|
|
649
751
|
createRangeIn(element: Element | DocumentFragment): Range;
|
|
752
|
+
/**
|
|
753
|
+
* Creates new {@link module:engine/view/selection~Selection} instance.
|
|
754
|
+
*
|
|
755
|
+
* ```ts
|
|
756
|
+
* // Creates collapsed selection at the position of given item and offset.
|
|
757
|
+
* const paragraph = writer.createContainerElement( 'p' );
|
|
758
|
+
* const selection = writer.createSelection( paragraph, offset );
|
|
759
|
+
*
|
|
760
|
+
* // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
|
|
761
|
+
* // first child of that element and ends after the last child of that element.
|
|
762
|
+
* const selection = writer.createSelection( paragraph, 'in' );
|
|
763
|
+
*
|
|
764
|
+
* // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
|
|
765
|
+
* // just after the item.
|
|
766
|
+
* const selection = writer.createSelection( paragraph, 'on' );
|
|
767
|
+
* ```
|
|
768
|
+
*
|
|
769
|
+
* `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
770
|
+
*
|
|
771
|
+
* ```ts
|
|
772
|
+
* // Creates backward selection.
|
|
773
|
+
* const selection = writer.createSelection( element, 'in', { backward: true } );
|
|
774
|
+
* ```
|
|
775
|
+
*
|
|
776
|
+
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
777
|
+
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
778
|
+
* represented in other way, for example by applying proper CSS class.
|
|
779
|
+
*
|
|
780
|
+
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
781
|
+
* (and be properly handled by screen readers).
|
|
782
|
+
*
|
|
783
|
+
* ```ts
|
|
784
|
+
* // Creates fake selection with label.
|
|
785
|
+
* const selection = writer.createSelection( element, 'in', { fake: true, label: 'foo' } );
|
|
786
|
+
* ```
|
|
787
|
+
*
|
|
788
|
+
* See also: {@link #createSelection:SELECTABLE `createSelection( selectable, options )`}.
|
|
789
|
+
*
|
|
790
|
+
* @label NODE_OFFSET
|
|
791
|
+
*/
|
|
650
792
|
createSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: SelectionOptions): Selection;
|
|
793
|
+
/**
|
|
794
|
+
* Creates new {@link module:engine/view/selection~Selection} instance.
|
|
795
|
+
*
|
|
796
|
+
* ```ts
|
|
797
|
+
* // Creates empty selection without ranges.
|
|
798
|
+
* const selection = writer.createSelection();
|
|
799
|
+
*
|
|
800
|
+
* // Creates selection at the given range.
|
|
801
|
+
* const range = writer.createRange( start, end );
|
|
802
|
+
* const selection = writer.createSelection( range );
|
|
803
|
+
*
|
|
804
|
+
* // Creates selection at the given ranges
|
|
805
|
+
* const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
|
|
806
|
+
* const selection = writer.createSelection( ranges );
|
|
807
|
+
*
|
|
808
|
+
* // Creates selection from the other selection.
|
|
809
|
+
* const otherSelection = writer.createSelection();
|
|
810
|
+
* const selection = writer.createSelection( otherSelection );
|
|
811
|
+
*
|
|
812
|
+
* // Creates selection from the document selection.
|
|
813
|
+
* const selection = writer.createSelection( editor.editing.view.document.selection );
|
|
814
|
+
*
|
|
815
|
+
* // Creates selection at the given position.
|
|
816
|
+
* const position = writer.createPositionFromPath( root, path );
|
|
817
|
+
* const selection = writer.createSelection( position );
|
|
818
|
+
* ```
|
|
819
|
+
*
|
|
820
|
+
* `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
821
|
+
*
|
|
822
|
+
* ```ts
|
|
823
|
+
* // Creates backward selection.
|
|
824
|
+
* const selection = writer.createSelection( range, { backward: true } );
|
|
825
|
+
* ```
|
|
826
|
+
*
|
|
827
|
+
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
828
|
+
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
829
|
+
* represented in other way, for example by applying proper CSS class.
|
|
830
|
+
*
|
|
831
|
+
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
832
|
+
* (and be properly handled by screen readers).
|
|
833
|
+
*
|
|
834
|
+
* ```ts
|
|
835
|
+
* // Creates fake selection with label.
|
|
836
|
+
* const selection = writer.createSelection( range, { fake: true, label: 'foo' } );
|
|
837
|
+
* ```
|
|
838
|
+
*
|
|
839
|
+
* See also: {@link #createSelection:NODE_OFFSET `createSelection( node, placeOrOffset, options )`}.
|
|
840
|
+
*
|
|
841
|
+
* @label SELECTABLE
|
|
842
|
+
*/
|
|
651
843
|
createSelection(selectable?: Exclude<Selectable, Node>, option?: SelectionOptions): Selection;
|
|
652
844
|
/**
|
|
653
845
|
* Creates placeholders for child elements of the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure
|
|
@@ -49,71 +49,6 @@ export default class DowncastWriter {
|
|
|
49
49
|
this._slotFactory = null;
|
|
50
50
|
this.document = document;
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Sets {@link module:engine/view/documentselection~DocumentSelection selection's} ranges and direction to the
|
|
54
|
-
* specified location based on the given {@link module:engine/view/selection~Selectable selectable}.
|
|
55
|
-
*
|
|
56
|
-
* Usage:
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* // Sets selection to the given range.
|
|
60
|
-
* const range = writer.createRange( start, end );
|
|
61
|
-
* writer.setSelection( range );
|
|
62
|
-
*
|
|
63
|
-
* // Sets backward selection to the given range.
|
|
64
|
-
* const range = writer.createRange( start, end );
|
|
65
|
-
* writer.setSelection( range );
|
|
66
|
-
*
|
|
67
|
-
* // Sets selection to given ranges.
|
|
68
|
-
* const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
|
|
69
|
-
* writer.setSelection( range );
|
|
70
|
-
*
|
|
71
|
-
* // Sets selection to the other selection.
|
|
72
|
-
* const otherSelection = writer.createSelection();
|
|
73
|
-
* writer.setSelection( otherSelection );
|
|
74
|
-
*
|
|
75
|
-
* // Sets collapsed selection at the given position.
|
|
76
|
-
* const position = writer.createPositionFromPath( root, path );
|
|
77
|
-
* writer.setSelection( position );
|
|
78
|
-
*
|
|
79
|
-
* // Sets collapsed selection at the position of given item and offset.
|
|
80
|
-
* const paragraph = writer.createContainerElement( 'p' );
|
|
81
|
-
* writer.setSelection( paragraph, offset );
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* Creates a range inside an {@link module:engine/view/element~Element element} which starts before the first child of
|
|
85
|
-
* that element and ends after the last child of that element.
|
|
86
|
-
*
|
|
87
|
-
* ```ts
|
|
88
|
-
* writer.setSelection( paragraph, 'in' );
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* Creates a range on the {@link module:engine/view/item~Item item} which starts before the item and ends just after the item.
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* writer.setSelection( paragraph, 'on' );
|
|
95
|
-
*
|
|
96
|
-
* // Removes all ranges.
|
|
97
|
-
* writer.setSelection( null );
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* `DowncastWriter#setSelection()` allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
101
|
-
*
|
|
102
|
-
* ```ts
|
|
103
|
-
* // Sets selection as backward.
|
|
104
|
-
* writer.setSelection( range, { backward: true } );
|
|
105
|
-
*
|
|
106
|
-
* // Sets selection as fake.
|
|
107
|
-
* // Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
108
|
-
* // This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
109
|
-
* // represented in other way, for example by applying proper CSS class.
|
|
110
|
-
* writer.setSelection( range, { fake: true } );
|
|
111
|
-
*
|
|
112
|
-
* // Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
113
|
-
* // (and be properly handled by screen readers).
|
|
114
|
-
* writer.setSelection( range, { fake: true, label: 'foo' } );
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
52
|
setSelection(...args) {
|
|
118
53
|
this.document.selection._setTo(...args);
|
|
119
54
|
}
|
|
@@ -957,64 +892,6 @@ export default class DowncastWriter {
|
|
|
957
892
|
createRangeIn(element) {
|
|
958
893
|
return Range._createIn(element);
|
|
959
894
|
}
|
|
960
|
-
/**
|
|
961
|
-
* Creates new {@link module:engine/view/selection~Selection} instance.
|
|
962
|
-
*
|
|
963
|
-
* ```ts
|
|
964
|
-
* // Creates empty selection without ranges.
|
|
965
|
-
* const selection = writer.createSelection();
|
|
966
|
-
*
|
|
967
|
-
* // Creates selection at the given range.
|
|
968
|
-
* const range = writer.createRange( start, end );
|
|
969
|
-
* const selection = writer.createSelection( range );
|
|
970
|
-
*
|
|
971
|
-
* // Creates selection at the given ranges
|
|
972
|
-
* const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
|
|
973
|
-
* const selection = writer.createSelection( ranges );
|
|
974
|
-
*
|
|
975
|
-
* // Creates selection from the other selection.
|
|
976
|
-
* const otherSelection = writer.createSelection();
|
|
977
|
-
* const selection = writer.createSelection( otherSelection );
|
|
978
|
-
*
|
|
979
|
-
* // Creates selection from the document selection.
|
|
980
|
-
* const selection = writer.createSelection( editor.editing.view.document.selection );
|
|
981
|
-
*
|
|
982
|
-
* // Creates selection at the given position.
|
|
983
|
-
* const position = writer.createPositionFromPath( root, path );
|
|
984
|
-
* const selection = writer.createSelection( position );
|
|
985
|
-
*
|
|
986
|
-
* // Creates collapsed selection at the position of given item and offset.
|
|
987
|
-
* const paragraph = writer.createContainerElement( 'p' );
|
|
988
|
-
* const selection = writer.createSelection( paragraph, offset );
|
|
989
|
-
*
|
|
990
|
-
* // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
|
|
991
|
-
* // first child of that element and ends after the last child of that element.
|
|
992
|
-
* const selection = writer.createSelection( paragraph, 'in' );
|
|
993
|
-
*
|
|
994
|
-
* // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
|
|
995
|
-
* // just after the item.
|
|
996
|
-
* const selection = writer.createSelection( paragraph, 'on' );
|
|
997
|
-
* ```
|
|
998
|
-
*
|
|
999
|
-
* `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
1000
|
-
*
|
|
1001
|
-
* ```ts
|
|
1002
|
-
* // Creates backward selection.
|
|
1003
|
-
* const selection = writer.createSelection( range, { backward: true } );
|
|
1004
|
-
* ```
|
|
1005
|
-
*
|
|
1006
|
-
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
1007
|
-
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
1008
|
-
* represented in other way, for example by applying proper CSS class.
|
|
1009
|
-
*
|
|
1010
|
-
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
1011
|
-
* (and be properly handled by screen readers).
|
|
1012
|
-
*
|
|
1013
|
-
* ```ts
|
|
1014
|
-
* // Creates fake selection with label.
|
|
1015
|
-
* const selection = writer.createSelection( range, { fake: true, label: 'foo' } );
|
|
1016
|
-
* ```
|
|
1017
|
-
*/
|
|
1018
895
|
createSelection(...args) {
|
|
1019
896
|
return new Selection(...args);
|
|
1020
897
|
}
|
package/src/view/element.d.ts
CHANGED
|
@@ -396,6 +396,7 @@ export default class Element extends Node {
|
|
|
396
396
|
* See {@link module:engine/view/stylesmap~StylesMap#set `StylesMap#set()`} for details.
|
|
397
397
|
*
|
|
398
398
|
* @see module:engine/view/downcastwriter~DowncastWriter#setStyle
|
|
399
|
+
* @label KEY_VALUE
|
|
399
400
|
* @internal
|
|
400
401
|
* @param property Property name.
|
|
401
402
|
* @param value Value to set.
|
|
@@ -417,6 +418,7 @@ export default class Element extends Node {
|
|
|
417
418
|
* See {@link module:engine/view/stylesmap~StylesMap#set `StylesMap#set()`} for details.
|
|
418
419
|
*
|
|
419
420
|
* @see module:engine/view/downcastwriter~DowncastWriter#setStyle
|
|
421
|
+
* @label OBJECT
|
|
420
422
|
* @internal
|
|
421
423
|
* @param properties Object with key - value pairs.
|
|
422
424
|
* @fires change
|
package/src/view/node.d.ts
CHANGED
|
@@ -151,7 +151,10 @@ export default abstract class Node extends Node_base {
|
|
|
151
151
|
*
|
|
152
152
|
* Change event is bubbled – it is fired on all ancestors.
|
|
153
153
|
*
|
|
154
|
-
* @eventName change
|
|
154
|
+
* @eventName ~Node#change
|
|
155
|
+
* @eventName ~Node#change:children
|
|
156
|
+
* @eventName ~Node#change:attributes
|
|
157
|
+
* @eventName ~Node#change:text
|
|
155
158
|
*/
|
|
156
159
|
export type ViewNodeChangeEvent = {
|
|
157
160
|
name: 'change' | `change:${ChangeType}`;
|
|
@@ -32,7 +32,7 @@ export default class ArrowKeysObserver extends Observer {
|
|
|
32
32
|
* Note that because {@link module:engine/view/observer/arrowkeysobserver~ArrowKeysObserver} is attached by the
|
|
33
33
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
34
34
|
*
|
|
35
|
-
* @eventName arrowKey
|
|
35
|
+
* @eventName module:engine/view/document~Document#arrowKey
|
|
36
36
|
* @param data
|
|
37
37
|
*/
|
|
38
38
|
export type ViewDocumentArrowKeyEvent = BubblingEvent<{
|
|
@@ -34,7 +34,7 @@ export default class ClickObserver extends DomEventObserver<'click'> {
|
|
|
34
34
|
* to {@link module:engine/view/view~View} by a {@link module:engine/view/view~View#addObserver} method.
|
|
35
35
|
*
|
|
36
36
|
* @see module:engine/view/observer/clickobserver~ClickObserver
|
|
37
|
-
* @eventName click
|
|
37
|
+
* @eventName module:engine/view/document~Document#click
|
|
38
38
|
* @param data Event data.
|
|
39
39
|
*/
|
|
40
40
|
export type ViewDocumentClickEvent = BubblingEvent<{
|
|
@@ -41,7 +41,7 @@ export interface CompositionEventData extends DomEventData<CompositionEvent> {
|
|
|
41
41
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
42
42
|
*
|
|
43
43
|
* @see module:engine/view/observer/compositionobserver~CompositionObserver
|
|
44
|
-
* @eventName compositionstart
|
|
44
|
+
* @eventName module:engine/view/document~Document#compositionstart
|
|
45
45
|
* @param data Event data.
|
|
46
46
|
*/
|
|
47
47
|
export type ViewDocumentCompositionStartEvent = {
|
|
@@ -57,7 +57,7 @@ export type ViewDocumentCompositionStartEvent = {
|
|
|
57
57
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
58
58
|
*
|
|
59
59
|
* @see module:engine/view/observer/compositionobserver~CompositionObserver
|
|
60
|
-
* @eventName compositionupdate
|
|
60
|
+
* @eventName module:engine/view/document~Document#compositionupdate
|
|
61
61
|
* @param data Event data.
|
|
62
62
|
*/
|
|
63
63
|
export type ViewDocumentCompositionUpdateEvent = {
|
|
@@ -73,7 +73,7 @@ export type ViewDocumentCompositionUpdateEvent = {
|
|
|
73
73
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
74
74
|
*
|
|
75
75
|
* @see module:engine/view/observer/compositionobserver~CompositionObserver
|
|
76
|
-
* @eventName compositionend
|
|
76
|
+
* @eventName module:engine/view/document~Document#compositionend
|
|
77
77
|
* @param data Event data.
|
|
78
78
|
*/
|
|
79
79
|
export type ViewDocumentCompositionEndEvent = {
|
|
@@ -38,9 +38,6 @@ export default class FakeSelectionObserver extends Observer {
|
|
|
38
38
|
* This method fires {@link module:engine/view/document~Document#event:selectionChange} and
|
|
39
39
|
* {@link module:engine/view/document~Document#event:selectionChangeDone} events imitating behaviour of
|
|
40
40
|
* {@link module:engine/view/observer/selectionobserver~SelectionObserver}.
|
|
41
|
-
*
|
|
42
|
-
* @fires selectionChange
|
|
43
|
-
* @fires selectionChangeDone
|
|
44
41
|
*/
|
|
45
42
|
private _handleSelectionMove;
|
|
46
43
|
}
|
|
@@ -59,9 +59,6 @@ export default class FakeSelectionObserver extends Observer {
|
|
|
59
59
|
* This method fires {@link module:engine/view/document~Document#event:selectionChange} and
|
|
60
60
|
* {@link module:engine/view/document~Document#event:selectionChangeDone} events imitating behaviour of
|
|
61
61
|
* {@link module:engine/view/observer/selectionobserver~SelectionObserver}.
|
|
62
|
-
*
|
|
63
|
-
* @fires selectionChange
|
|
64
|
-
* @fires selectionChangeDone
|
|
65
62
|
*/
|
|
66
63
|
_handleSelectionMove(keyCode) {
|
|
67
64
|
const selection = this.document.selection;
|
|
@@ -57,7 +57,7 @@ export default class FocusObserver extends DomEventObserver<'focus' | 'blur'> {
|
|
|
57
57
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
58
58
|
*
|
|
59
59
|
* @see module:engine/view/observer/focusobserver~FocusObserver
|
|
60
|
-
* @eventName focus
|
|
60
|
+
* @eventName module:engine/view/document~Document#focus
|
|
61
61
|
* @param data Event data.
|
|
62
62
|
*/
|
|
63
63
|
export type ViewDocumentFocusEvent = {
|
|
@@ -73,7 +73,7 @@ export type ViewDocumentFocusEvent = {
|
|
|
73
73
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
74
74
|
*
|
|
75
75
|
* @see module:engine/view/observer/focusobserver~FocusObserver
|
|
76
|
-
* @eventName blur
|
|
76
|
+
* @eventName module:engine/view/document~Document#blur
|
|
77
77
|
* @param data Event data.
|
|
78
78
|
*/
|
|
79
79
|
export type ViewDocumentBlurEvent = {
|
|
@@ -32,7 +32,7 @@ export default class InputObserver extends DomEventObserver<'beforeinput'> {
|
|
|
32
32
|
* by default in all editor instances (attached by {@link module:engine/view/view~View}).
|
|
33
33
|
*
|
|
34
34
|
* @see module:engine/view/observer/inputobserver~InputObserver
|
|
35
|
-
* @eventName beforeinput
|
|
35
|
+
* @eventName module:engine/view/document~Document#beforeinput
|
|
36
36
|
* @param data Event data containing detailed information about the event.
|
|
37
37
|
*/
|
|
38
38
|
export type ViewDocumentInputEvent = {
|
|
@@ -40,7 +40,7 @@ export type ViewDocumentInputEvent = {
|
|
|
40
40
|
args: [data: InputEventData];
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
|
-
* The value of the {@link
|
|
43
|
+
* The value of the {@link ~ViewDocumentInputEvent} event.
|
|
44
44
|
*/
|
|
45
45
|
export interface InputEventData extends DomEventData<InputEvent> {
|
|
46
46
|
/**
|
|
@@ -34,7 +34,7 @@ export default class KeyObserver extends DomEventObserver<'keydown' | 'keyup', K
|
|
|
34
34
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
35
35
|
*
|
|
36
36
|
* @see module:engine/view/observer/keyobserver~KeyObserver
|
|
37
|
-
* @eventName keydown
|
|
37
|
+
* @eventName module:engine/view/document~Document#keydown
|
|
38
38
|
*/
|
|
39
39
|
export type ViewDocumentKeyDownEvent = {
|
|
40
40
|
name: 'keydown';
|
|
@@ -49,15 +49,14 @@ export type ViewDocumentKeyDownEvent = {
|
|
|
49
49
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
50
50
|
*
|
|
51
51
|
* @see module:engine/view/observer/keyobserver~KeyObserver
|
|
52
|
-
* @eventName keyup
|
|
52
|
+
* @eventName module:engine/view/document~Document#keyup
|
|
53
53
|
*/
|
|
54
54
|
export type ViewDocumentKeyUpEvent = {
|
|
55
55
|
name: 'keyup';
|
|
56
56
|
args: [data: KeyEventData];
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
|
-
* The value of both events - {@link
|
|
60
|
-
* {@link module:engine/view/document~ViewDocumentKeyUpEvent}.
|
|
59
|
+
* The value of both events - {@link ~ViewDocumentKeyDownEvent} and {@link ~ViewDocumentKeyUpEvent}.
|
|
61
60
|
*/
|
|
62
61
|
export interface KeyEventData extends DomEventData<KeyboardEvent>, KeystrokeInfo {
|
|
63
62
|
/**
|
|
@@ -32,7 +32,7 @@ export default class MouseObserver extends DomEventObserver<'mousedown' | 'mouse
|
|
|
32
32
|
* needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
|
|
33
33
|
*
|
|
34
34
|
* @see module:engine/view/observer/mouseobserver~MouseObserver
|
|
35
|
-
* @eventName mousedown
|
|
35
|
+
* @eventName module:engine/view/document~Document#mousedown
|
|
36
36
|
* @param data The event data.
|
|
37
37
|
*/
|
|
38
38
|
export type ViewDocumentMouseDownEvent = {
|
|
@@ -48,7 +48,7 @@ export type ViewDocumentMouseDownEvent = {
|
|
|
48
48
|
* needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
|
|
49
49
|
*
|
|
50
50
|
* @see module:engine/view/observer/mouseobserver~MouseObserver
|
|
51
|
-
* @eventName mouseup
|
|
51
|
+
* @eventName module:engine/view/document~Document#mouseup
|
|
52
52
|
* @param data The event data.
|
|
53
53
|
*/
|
|
54
54
|
export type ViewDocumentMouseUpEvent = {
|
|
@@ -64,7 +64,7 @@ export type ViewDocumentMouseUpEvent = {
|
|
|
64
64
|
* needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
|
|
65
65
|
*
|
|
66
66
|
* @see module:engine/view/observer/mouseobserver~MouseObserver
|
|
67
|
-
* @eventName
|
|
67
|
+
* @eventName module:engine/view/document~Document#mouseover
|
|
68
68
|
* @param data The event data.
|
|
69
69
|
*/
|
|
70
70
|
export type ViewDocumentMouseOverEvent = {
|
|
@@ -80,7 +80,7 @@ export type ViewDocumentMouseOverEvent = {
|
|
|
80
80
|
* needs to be added to {@link module:engine/view/view~View} by the {@link module:engine/view/view~View#addObserver} method.
|
|
81
81
|
*
|
|
82
82
|
* @see module:engine/view/observer/mouseobserver~MouseObserver
|
|
83
|
-
* @eventName
|
|
83
|
+
* @eventName module:engine/view/document~Document#mouseout
|
|
84
84
|
* @param data The event data.
|
|
85
85
|
*/
|
|
86
86
|
export type ViewDocumentMouseOutEvent = {
|
|
@@ -78,6 +78,7 @@ export default class SelectionObserver extends Observer {
|
|
|
78
78
|
* @inheritDoc
|
|
79
79
|
*/
|
|
80
80
|
destroy(): void;
|
|
81
|
+
private _reportInfiniteLoop;
|
|
81
82
|
/**
|
|
82
83
|
* Selection change listener. {@link module:engine/view/observer/mutationobserver~MutationObserver#flush Flush} mutations, check if
|
|
83
84
|
* a selection changes and fires {@link module:engine/view/document~Document#event:selectionChange} event on every change
|
|
@@ -119,7 +120,7 @@ export type ViewDocumentSelectionEventData = {
|
|
|
119
120
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
120
121
|
*
|
|
121
122
|
* @see module:engine/view/observer/selectionobserver~SelectionObserver
|
|
122
|
-
* @eventName selectionChange
|
|
123
|
+
* @eventName module:engine/view/document~Document#selectionChange
|
|
123
124
|
*/
|
|
124
125
|
export type ViewDocumentSelectionChangeEvent = {
|
|
125
126
|
name: 'selectionChange';
|
|
@@ -134,7 +135,7 @@ export type ViewDocumentSelectionChangeEvent = {
|
|
|
134
135
|
* {@link module:engine/view/view~View} this event is available by default.
|
|
135
136
|
*
|
|
136
137
|
* @see module:engine/view/observer/selectionobserver~SelectionObserver
|
|
137
|
-
* @eventName selectionChangeDone
|
|
138
|
+
* @eventName module:engine/view/document~Document#selectionChangeDone
|
|
138
139
|
*/
|
|
139
140
|
export type ViewDocumentSelectionChangeDoneEvent = {
|
|
140
141
|
name: 'selectionChangeDone';
|
|
@@ -110,12 +110,13 @@ export default class SelectionObserver extends Observer {
|
|
|
110
110
|
this._fireSelectionChangeDoneDebounced.cancel();
|
|
111
111
|
this._documentIsSelectingInactivityTimeoutDebounced.cancel();
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
/* istanbul ignore next */
|
|
114
|
+
_reportInfiniteLoop() {
|
|
115
|
+
// @if CK_DEBUG // throw new Error(
|
|
116
|
+
// @if CK_DEBUG // 'Selection change observer detected an infinite rendering loop.\n\n' +
|
|
117
|
+
// @if CK_DEBUG // '⚠️⚠️ Report this error on https://github.com/ckeditor/ckeditor5/issues/11658.'
|
|
118
|
+
// @if CK_DEBUG // );
|
|
119
|
+
}
|
|
119
120
|
/**
|
|
120
121
|
* Selection change listener. {@link module:engine/view/observer/mutationobserver~MutationObserver#flush Flush} mutations, check if
|
|
121
122
|
* a selection changes and fires {@link module:engine/view/document~Document#event:selectionChange} event on every change
|
|
@@ -155,8 +156,7 @@ export default class SelectionObserver extends Observer {
|
|
|
155
156
|
// Most probably you try to put the selection in the position which is not allowed
|
|
156
157
|
// by the browser and browser fixes it automatically what causes `selectionchange` event on
|
|
157
158
|
// which a loopback through a model tries to re-render the wrong selection and again.
|
|
158
|
-
|
|
159
|
-
// @if CK_DEBUG // this._reportInfiniteLoop();
|
|
159
|
+
this._reportInfiniteLoop();
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
// Mark the latest focus change as complete (we got new selection after the focus so the selection is in the focused element).
|
|
@@ -33,7 +33,7 @@ export default class TabObserver extends Observer {
|
|
|
33
33
|
* Note that because {@link module:engine/view/observer/tabobserver~TabObserver} is attached by the
|
|
34
34
|
* {@link module:engine/view/view~View}, this event is available by default.
|
|
35
35
|
*
|
|
36
|
-
* @eventName tab
|
|
36
|
+
* @eventName module:engine/view/document~Document#tab
|
|
37
37
|
* @param data
|
|
38
38
|
*/
|
|
39
39
|
export type ViewDocumentTabEvent = BubblingEvent<{
|
package/src/view/position.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export default class Position extends TypeCheckable {
|
|
|
83
83
|
* getLastMatchingPosition( value => false ); // Do not move the position.
|
|
84
84
|
* ```
|
|
85
85
|
*
|
|
86
|
-
* @param skip Callback function. Gets {@link module:engine/view/treewalker~
|
|
86
|
+
* @param skip Callback function. Gets {@link module:engine/view/treewalker~TreeWalkerValue} and should
|
|
87
87
|
* return `true` if the value should be skipped or `false` if not.
|
|
88
88
|
* @param options Object with configuration options. See {@link module:engine/view/treewalker~TreeWalker}.
|
|
89
89
|
* @returns The position after the last item which matches the `skip` callback test.
|
package/src/view/position.js
CHANGED
|
@@ -111,7 +111,7 @@ export default class Position extends TypeCheckable {
|
|
|
111
111
|
* getLastMatchingPosition( value => false ); // Do not move the position.
|
|
112
112
|
* ```
|
|
113
113
|
*
|
|
114
|
-
* @param skip Callback function. Gets {@link module:engine/view/treewalker~
|
|
114
|
+
* @param skip Callback function. Gets {@link module:engine/view/treewalker~TreeWalkerValue} and should
|
|
115
115
|
* return `true` if the value should be skipped or `false` if not.
|
|
116
116
|
* @param options Object with configuration options. See {@link module:engine/view/treewalker~TreeWalker}.
|
|
117
117
|
* @returns The position after the last item which matches the `skip` callback test.
|