@ckeditor/ckeditor5-engine 37.0.0-alpha.0 → 37.0.0-alpha.2
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
package/src/view/selection.d.ts
CHANGED
|
@@ -360,7 +360,7 @@ export type PlaceOrOffset = number | 'before' | 'end' | 'after' | 'on' | 'in';
|
|
|
360
360
|
/**
|
|
361
361
|
* Fired whenever selection ranges are changed through {@link ~Selection Selection API}.
|
|
362
362
|
*
|
|
363
|
-
* @eventName change
|
|
363
|
+
* @eventName ~Selection#change
|
|
364
364
|
*/
|
|
365
365
|
export type ViewSelectionChangeEvent = {
|
|
366
366
|
name: 'change';
|
package/src/view/stylesmap.d.ts
CHANGED
|
@@ -655,7 +655,7 @@ export type StyleValue = string | Array<string> | Styles | BoxSides;
|
|
|
655
655
|
/**
|
|
656
656
|
* A normalizer method for a style property.
|
|
657
657
|
*
|
|
658
|
-
* @see
|
|
658
|
+
* @see ~StylesProcessor#setNormalizer
|
|
659
659
|
*/
|
|
660
660
|
export type Normalizer = (name: string) => {
|
|
661
661
|
path: string;
|
|
@@ -664,12 +664,12 @@ export type Normalizer = (name: string) => {
|
|
|
664
664
|
/**
|
|
665
665
|
* An extractor callback for a style property or path string for single values.
|
|
666
666
|
*
|
|
667
|
-
* @see
|
|
667
|
+
* @see ~StylesProcessor#setExtractor
|
|
668
668
|
*/
|
|
669
669
|
export type Extractor = string | ((name: string, styles: Styles) => StyleValue | undefined);
|
|
670
670
|
/**
|
|
671
671
|
* A reducer callback for a style property.
|
|
672
672
|
*
|
|
673
|
-
* @see
|
|
673
|
+
* @see ~StylesProcessor#setReducer
|
|
674
674
|
*/
|
|
675
675
|
export type Reducer = (value: StyleValue) => Array<PropertyDescriptor>;
|
|
@@ -49,6 +49,7 @@ export default abstract class TypeCheckable {
|
|
|
49
49
|
* imgElement.is( 'element', 'img' ); // -> true
|
|
50
50
|
* imgElement.is( 'view:element', 'img' ); // -> same as above, but more precise
|
|
51
51
|
* ```
|
|
52
|
+
* @label NODE
|
|
52
53
|
*/
|
|
53
54
|
is(type: 'node' | 'view:node'): this is (Node | Text | Element | AttributeElement | ContainerElement | EditableElement | EmptyElement | RawElement | RootEditableElement | UIElement);
|
|
54
55
|
/**
|
|
@@ -71,6 +72,8 @@ export default abstract class TypeCheckable {
|
|
|
71
72
|
* element.is( 'element', 'img' ); // -> true if this is an <img> element
|
|
72
73
|
* text.is( 'element', 'img' ); -> false
|
|
73
74
|
* ```
|
|
75
|
+
*
|
|
76
|
+
* @label ELEMENT
|
|
74
77
|
*/
|
|
75
78
|
is(type: 'element' | 'view:element'): this is (Element | AttributeElement | ContainerElement | EditableElement | EmptyElement | RawElement | RootEditableElement | UIElement);
|
|
76
79
|
/**
|
|
@@ -96,6 +99,8 @@ export default abstract class TypeCheckable {
|
|
|
96
99
|
* attributeElement.is( 'attributeElement', 'b' ); // -> same as above
|
|
97
100
|
* text.is( 'element', 'b' ); -> false
|
|
98
101
|
* ```
|
|
102
|
+
*
|
|
103
|
+
* @label ATTRIBUTE_ELEMENT
|
|
99
104
|
*/
|
|
100
105
|
is(type: 'attributeElement' | 'view:attributeElement'): this is AttributeElement;
|
|
101
106
|
/**
|
|
@@ -121,6 +126,8 @@ export default abstract class TypeCheckable {
|
|
|
121
126
|
* containerElement.is( 'contaienrElement', 'div' ); // -> same as above
|
|
122
127
|
* text.is( 'element', 'div' ); -> false
|
|
123
128
|
* ```
|
|
129
|
+
*
|
|
130
|
+
* @label CONTAINER_ELEMENT
|
|
124
131
|
*/
|
|
125
132
|
is(type: 'containerElement' | 'view:containerElement'): this is ContainerElement | EditableElement | RootEditableElement;
|
|
126
133
|
/**
|
|
@@ -146,6 +153,8 @@ export default abstract class TypeCheckable {
|
|
|
146
153
|
* editableElement.is( 'editableElement', 'div' ); // -> same as above
|
|
147
154
|
* text.is( 'element', 'div' ); -> false
|
|
148
155
|
* ```
|
|
156
|
+
*
|
|
157
|
+
* @label EDITABLE_ELEMENT
|
|
149
158
|
*/
|
|
150
159
|
is(type: 'editableElement' | 'view:editableElement'): this is EditableElement | RootEditableElement;
|
|
151
160
|
/**
|
|
@@ -171,6 +180,8 @@ export default abstract class TypeCheckable {
|
|
|
171
180
|
* emptyElement.is( 'emptyElement', 'img' ); // -> same as above
|
|
172
181
|
* text.is( 'element', 'img' ); -> false
|
|
173
182
|
* ```
|
|
183
|
+
*
|
|
184
|
+
* @label EMPTY_ELEMENT
|
|
174
185
|
*/
|
|
175
186
|
is(type: 'emptyElement' | 'view:emptyElement'): this is EmptyElement;
|
|
176
187
|
/**
|
|
@@ -196,6 +207,8 @@ export default abstract class TypeCheckable {
|
|
|
196
207
|
* rawElement.is( 'rawElement', 'img' ); // -> same as above
|
|
197
208
|
* text.is( 'img' ); -> false
|
|
198
209
|
* ```
|
|
210
|
+
*
|
|
211
|
+
* @label RAW_ELEMENT
|
|
199
212
|
*/
|
|
200
213
|
is(type: 'rawElement' | 'view:rawElement'): this is RawElement;
|
|
201
214
|
/**
|
|
@@ -222,6 +235,8 @@ export default abstract class TypeCheckable {
|
|
|
222
235
|
* rootEditableElement.is( 'rootElement', 'div' ); // -> same as above
|
|
223
236
|
* text.is( 'element', 'div' ); -> false
|
|
224
237
|
* ```
|
|
238
|
+
*
|
|
239
|
+
* @label ROOT_ELEMENT
|
|
225
240
|
*/
|
|
226
241
|
is(type: 'rootElement' | 'view:rootElement'): this is RootEditableElement;
|
|
227
242
|
/**
|
|
@@ -247,6 +262,8 @@ export default abstract class TypeCheckable {
|
|
|
247
262
|
* uiElement.is( 'uiElement', 'span' ); // -> same as above
|
|
248
263
|
* text.is( 'element', 'span' ); -> false
|
|
249
264
|
* ```
|
|
265
|
+
*
|
|
266
|
+
* @label UI_ELEMENT
|
|
250
267
|
*/
|
|
251
268
|
is(type: 'uiElement' | 'view:uiElement'): this is UIElement;
|
|
252
269
|
/**
|
|
@@ -262,6 +279,8 @@ export default abstract class TypeCheckable {
|
|
|
262
279
|
* text.is( 'element' ); // -> false
|
|
263
280
|
* text.is( 'range' ); // -> false
|
|
264
281
|
* ```
|
|
282
|
+
*
|
|
283
|
+
* @label TEXT
|
|
265
284
|
*/
|
|
266
285
|
is(type: '$text' | 'view:$text'): this is Text;
|
|
267
286
|
/**
|
|
@@ -275,6 +294,8 @@ export default abstract class TypeCheckable {
|
|
|
275
294
|
* docFrag.is( 'element' ); // -> false
|
|
276
295
|
* docFrag.is( 'node' ); // -> false
|
|
277
296
|
* ```
|
|
297
|
+
*
|
|
298
|
+
* @label DOCUMENT_FRAGMENT
|
|
278
299
|
*/
|
|
279
300
|
is(type: 'documentFragment' | 'view:documentFragment'): this is DocumentFragment;
|
|
280
301
|
/**
|
|
@@ -291,6 +312,8 @@ export default abstract class TypeCheckable {
|
|
|
291
312
|
*
|
|
292
313
|
* **Note:** Until version 20.0.0 this method wasn't accepting `'$textProxy'` type. The legacy `'textProxy'` type is still
|
|
293
314
|
* accepted for backward compatibility.
|
|
315
|
+
*
|
|
316
|
+
* @label TEXT_PROXY
|
|
294
317
|
*/
|
|
295
318
|
is(type: '$textProxy' | 'view:$textProxy'): this is TextProxy;
|
|
296
319
|
/**
|
|
@@ -304,6 +327,8 @@ export default abstract class TypeCheckable {
|
|
|
304
327
|
* position.is( 'element' ); // -> false
|
|
305
328
|
* position.is( 'range' ); // -> false
|
|
306
329
|
* ```
|
|
330
|
+
*
|
|
331
|
+
* @label POSITION
|
|
307
332
|
*/
|
|
308
333
|
is(type: 'position' | 'view:position'): this is Position;
|
|
309
334
|
/**
|
|
@@ -317,6 +342,8 @@ export default abstract class TypeCheckable {
|
|
|
317
342
|
* range.is( 'element' ); // -> false
|
|
318
343
|
* range.is( 'selection' ); // -> false
|
|
319
344
|
* ```
|
|
345
|
+
*
|
|
346
|
+
* @label RANGE
|
|
320
347
|
*/
|
|
321
348
|
is(type: 'range' | 'view:range'): this is Range;
|
|
322
349
|
/**
|
|
@@ -331,6 +358,8 @@ export default abstract class TypeCheckable {
|
|
|
331
358
|
* selection.is( 'element' ); // -> false
|
|
332
359
|
* selection.is( 'range' ); // -> false
|
|
333
360
|
* ```
|
|
361
|
+
*
|
|
362
|
+
* @label SELECTION
|
|
334
363
|
*/
|
|
335
364
|
is(type: 'selection' | 'view:selection'): this is Selection | DocumentSelection;
|
|
336
365
|
/**
|
|
@@ -346,54 +375,72 @@ export default abstract class TypeCheckable {
|
|
|
346
375
|
* docSelection.is( 'element' ); // -> false
|
|
347
376
|
* docSelection.is( 'node' ); // -> false
|
|
348
377
|
* ```
|
|
378
|
+
*
|
|
379
|
+
* @label DOCUMENT_SELECTION
|
|
349
380
|
*/
|
|
350
381
|
is(type: 'documentSelection' | 'view:documentSelection'): this is DocumentSelection;
|
|
351
382
|
/**
|
|
352
383
|
* Checks whether the object is of type {@link module:engine/view/element~Element} or its subclass and has the specified `name`.
|
|
384
|
+
*
|
|
385
|
+
* @label ELEMENT_NAME
|
|
353
386
|
*/
|
|
354
387
|
is<N extends string>(type: 'element' | 'view:element', name: N): this is (Element | AttributeElement | ContainerElement | EditableElement | EmptyElement | RawElement | RootEditableElement | UIElement) & {
|
|
355
388
|
name: N;
|
|
356
389
|
};
|
|
357
390
|
/**
|
|
358
391
|
* Checks whether the object is of type {@link module:engine/view/attributeelement~AttributeElement} and has the specified `name`.
|
|
392
|
+
*
|
|
393
|
+
* @label ATTRIBUTE_ELEMENT_NAME
|
|
359
394
|
*/
|
|
360
395
|
is<N extends string>(type: 'attributeElement' | 'view:attributeElement', name: N): this is AttributeElement & {
|
|
361
396
|
name: N;
|
|
362
397
|
};
|
|
363
398
|
/**
|
|
364
|
-
* Checks whether the object is of type {@link module:engine/view/
|
|
399
|
+
* Checks whether the object is of type {@link module:engine/view/containerelement~ContainerElement}
|
|
365
400
|
* or its subclass and has the specified `name`.
|
|
401
|
+
*
|
|
402
|
+
* @label CONTAINER_ELEMENT_NAME
|
|
366
403
|
*/
|
|
367
404
|
is<N extends string>(type: 'containerElement' | 'view:containerElement', name: N): this is (ContainerElement | EditableElement | RootEditableElement) & {
|
|
368
405
|
name: N;
|
|
369
406
|
};
|
|
370
407
|
/**
|
|
371
|
-
* Checks whether the object is of type {@link module:engine/view/
|
|
408
|
+
* Checks whether the object is of type {@link module:engine/view/editableelement~EditableElement}
|
|
372
409
|
* or its subclass and has the specified `name`.
|
|
410
|
+
*
|
|
411
|
+
* @label EDITABLE_ELEMENT_NAME
|
|
373
412
|
*/
|
|
374
413
|
is<N extends string>(type: 'editableElement' | 'view:editableElement', name: N): this is (EditableElement | RootEditableElement) & {
|
|
375
414
|
name: N;
|
|
376
415
|
};
|
|
377
416
|
/**
|
|
378
417
|
* Checks whether the object is of type {@link module:engine/view/emptyelement~EmptyElement} has the specified `name`.
|
|
418
|
+
*
|
|
419
|
+
* @label EMPTY_ELEMENT_NAME
|
|
379
420
|
*/
|
|
380
421
|
is<N extends string>(type: 'emptyElement' | 'view:emptyElement', name: N): this is EmptyElement & {
|
|
381
422
|
name: N;
|
|
382
423
|
};
|
|
383
424
|
/**
|
|
384
425
|
* Checks whether the object is of type {@link module:engine/view/rawelement~RawElement} and has the specified `name`.
|
|
426
|
+
*
|
|
427
|
+
* @label RAW_ELEMENT_NAME
|
|
385
428
|
*/
|
|
386
429
|
is<N extends string>(type: 'rawElement' | 'view:rawElement', name: N): this is RawElement & {
|
|
387
430
|
name: N;
|
|
388
431
|
};
|
|
389
432
|
/**
|
|
390
433
|
* Checks whether the object is of type {@link module:engine/view/rooteditableelement~RootEditableElement} and has the specified `name`.
|
|
434
|
+
*
|
|
435
|
+
* @label ROOT_ELEMENT_NAME
|
|
391
436
|
*/
|
|
392
437
|
is<N extends string>(type: 'rootElement' | 'view:rootElement', name: N): this is RootEditableElement & {
|
|
393
438
|
name: N;
|
|
394
439
|
};
|
|
395
440
|
/**
|
|
396
441
|
* Checks whether the object is of type {@link module:engine/view/uielement~UIElement} and has the specified `name`.
|
|
442
|
+
*
|
|
443
|
+
* @label UI_ELEMENT_NAME
|
|
397
444
|
*/
|
|
398
445
|
is<N extends string>(type: 'uiElement' | 'view:uiElement', name: N): this is UIElement & {
|
|
399
446
|
name: N;
|
package/src/view/uielement.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export default class UIElement extends Element {
|
|
|
71
71
|
* ```
|
|
72
72
|
*
|
|
73
73
|
* If changes in your UI element should trigger some editor UI update you should call
|
|
74
|
-
* the {@link module:
|
|
74
|
+
* the {@link module:ui/editorui/editorui~EditorUI#update `editor.ui.update()`} method
|
|
75
75
|
* after rendering your UI element.
|
|
76
76
|
*
|
|
77
77
|
* @param domConverter Instance of the DomConverter used to optimize the output.
|
package/src/view/uielement.js
CHANGED
|
@@ -79,7 +79,7 @@ export default class UIElement extends Element {
|
|
|
79
79
|
* ```
|
|
80
80
|
*
|
|
81
81
|
* If changes in your UI element should trigger some editor UI update you should call
|
|
82
|
-
* the {@link module:
|
|
82
|
+
* the {@link module:ui/editorui/editorui~EditorUI#update `editor.ui.update()`} method
|
|
83
83
|
* after rendering your UI element.
|
|
84
84
|
*
|
|
85
85
|
* @param domConverter Instance of the DomConverter used to optimize the output.
|
|
@@ -92,7 +92,6 @@ export default class UpcastWriter {
|
|
|
92
92
|
* @see module:engine/view/element~Element#_appendChild
|
|
93
93
|
* @param items Items to be inserted.
|
|
94
94
|
* @param element Element to which items will be appended.
|
|
95
|
-
* @fires change
|
|
96
95
|
* @returns Number of appended nodes.
|
|
97
96
|
*/
|
|
98
97
|
appendChild(items: Item | string | Iterable<Item | string>, element: Element | DocumentFragment): number;
|
|
@@ -104,7 +103,6 @@ export default class UpcastWriter {
|
|
|
104
103
|
* @param index Offset at which nodes should be inserted.
|
|
105
104
|
* @param items Items to be inserted.
|
|
106
105
|
* @param element Element to which items will be inserted.
|
|
107
|
-
* @fires change
|
|
108
106
|
* @returns Number of inserted nodes.
|
|
109
107
|
*/
|
|
110
108
|
insertChild(index: number, items: Item | Iterable<Item>, element: Element | DocumentFragment): number;
|
|
@@ -115,7 +113,6 @@ export default class UpcastWriter {
|
|
|
115
113
|
* @param index Offset from which nodes will be removed.
|
|
116
114
|
* @param howMany Number of nodes to remove.
|
|
117
115
|
* @param element Element which children will be removed.
|
|
118
|
-
* @fires change
|
|
119
116
|
* @returns The array containing removed nodes.
|
|
120
117
|
*/
|
|
121
118
|
removeChildren(index: number, howMany: number, element: Element | DocumentFragment): Array<Node>;
|
|
@@ -215,6 +212,7 @@ export default class UpcastWriter {
|
|
|
215
212
|
* See {@link module:engine/view/stylesmap~StylesMap#set `StylesMap#set()`} for details.
|
|
216
213
|
*
|
|
217
214
|
* @see module:engine/view/element~Element#_setStyle
|
|
215
|
+
* @label KEY_VALUE
|
|
218
216
|
* @param property Property name.
|
|
219
217
|
* @param value Value to set.
|
|
220
218
|
* @param element Element for which style will be added.
|
|
@@ -235,6 +233,7 @@ export default class UpcastWriter {
|
|
|
235
233
|
* See {@link module:engine/view/stylesmap~StylesMap#set `StylesMap#set()`} for details.
|
|
236
234
|
*
|
|
237
235
|
* @see module:engine/view/element~Element#_setStyle
|
|
236
|
+
* @label OBJECT
|
|
238
237
|
* @param properties Object with key - value pairs.
|
|
239
238
|
* @param element Element for which style will be added.
|
|
240
239
|
*/
|
|
@@ -323,6 +322,96 @@ export default class UpcastWriter {
|
|
|
323
322
|
* @param element Element which is a parent for the range.
|
|
324
323
|
*/
|
|
325
324
|
createRangeIn(element: Element | DocumentFragment): Range;
|
|
325
|
+
/**
|
|
326
|
+
* Creates a new {@link module:engine/view/selection~Selection} instance.
|
|
327
|
+
*
|
|
328
|
+
* ```ts
|
|
329
|
+
* // Creates collapsed selection at the position of given item and offset.
|
|
330
|
+
* const paragraph = writer.createContainerElement( 'paragraph' );
|
|
331
|
+
* const selection = writer.createSelection( paragraph, offset );
|
|
332
|
+
*
|
|
333
|
+
* // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
|
|
334
|
+
* // first child of that element and ends after the last child of that element.
|
|
335
|
+
* const selection = writer.createSelection( paragraph, 'in' );
|
|
336
|
+
*
|
|
337
|
+
* // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
|
|
338
|
+
* // just after the item.
|
|
339
|
+
* const selection = writer.createSelection( paragraph, 'on' );
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
343
|
+
*
|
|
344
|
+
* ```ts
|
|
345
|
+
* // Creates backward selection.
|
|
346
|
+
* const selection = writer.createSelection( element, 'in', { backward: true } );
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
350
|
+
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
351
|
+
* represented in other way, for example by applying proper CSS class.
|
|
352
|
+
*
|
|
353
|
+
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
354
|
+
* (and be properly handled by screen readers).
|
|
355
|
+
*
|
|
356
|
+
* ```ts
|
|
357
|
+
* // Creates fake selection with label.
|
|
358
|
+
* const selection = writer.createSelection( element, 'in', { fake: true, label: 'foo' } );
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* See also: {@link #createSelection:SELECTABLE `createSelection( selectable, options )`}.
|
|
362
|
+
*
|
|
363
|
+
* @label NODE_OFFSET
|
|
364
|
+
*/
|
|
326
365
|
createSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: SelectionOptions): Selection;
|
|
366
|
+
/**
|
|
367
|
+
* Creates a new {@link module:engine/view/selection~Selection} instance.
|
|
368
|
+
*
|
|
369
|
+
* ```ts
|
|
370
|
+
* // Creates empty selection without ranges.
|
|
371
|
+
* const selection = writer.createSelection();
|
|
372
|
+
*
|
|
373
|
+
* // Creates selection at the given range.
|
|
374
|
+
* const range = writer.createRange( start, end );
|
|
375
|
+
* const selection = writer.createSelection( range );
|
|
376
|
+
*
|
|
377
|
+
* // Creates selection at the given ranges
|
|
378
|
+
* const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
|
|
379
|
+
* const selection = writer.createSelection( ranges );
|
|
380
|
+
*
|
|
381
|
+
* // Creates selection from the other selection.
|
|
382
|
+
* const otherSelection = writer.createSelection();
|
|
383
|
+
* const selection = writer.createSelection( otherSelection );
|
|
384
|
+
*
|
|
385
|
+
* // Creates selection from the document selection.
|
|
386
|
+
* const selection = writer.createSelection( editor.editing.view.document.selection );
|
|
387
|
+
*
|
|
388
|
+
* // Creates selection at the given position.
|
|
389
|
+
* const position = writer.createPositionFromPath( root, path );
|
|
390
|
+
* const selection = writer.createSelection( position );
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
394
|
+
*
|
|
395
|
+
* ```ts
|
|
396
|
+
* // Creates backward selection.
|
|
397
|
+
* const selection = writer.createSelection( range, { backward: true } );
|
|
398
|
+
* ```
|
|
399
|
+
*
|
|
400
|
+
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
401
|
+
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
402
|
+
* represented in other way, for example by applying proper CSS class.
|
|
403
|
+
*
|
|
404
|
+
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
405
|
+
* (and be properly handled by screen readers).
|
|
406
|
+
*
|
|
407
|
+
* ```ts
|
|
408
|
+
* // Creates fake selection with label.
|
|
409
|
+
* const selection = writer.createSelection( range, { fake: true, label: 'foo' } );
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* See also: {@link #createSelection:NODE_OFFSET `createSelection( node, placeOrOffset, options )`}.
|
|
413
|
+
*
|
|
414
|
+
* @label SELECTABLE
|
|
415
|
+
*/
|
|
327
416
|
createSelection(selectable?: Exclude<Selectable, Node>, options?: SelectionOptions): Selection;
|
|
328
417
|
}
|
package/src/view/upcastwriter.js
CHANGED
|
@@ -96,7 +96,6 @@ export default class UpcastWriter {
|
|
|
96
96
|
* @see module:engine/view/element~Element#_appendChild
|
|
97
97
|
* @param items Items to be inserted.
|
|
98
98
|
* @param element Element to which items will be appended.
|
|
99
|
-
* @fires change
|
|
100
99
|
* @returns Number of appended nodes.
|
|
101
100
|
*/
|
|
102
101
|
appendChild(items, element) {
|
|
@@ -110,7 +109,6 @@ export default class UpcastWriter {
|
|
|
110
109
|
* @param index Offset at which nodes should be inserted.
|
|
111
110
|
* @param items Items to be inserted.
|
|
112
111
|
* @param element Element to which items will be inserted.
|
|
113
|
-
* @fires change
|
|
114
112
|
* @returns Number of inserted nodes.
|
|
115
113
|
*/
|
|
116
114
|
insertChild(index, items, element) {
|
|
@@ -123,7 +121,6 @@ export default class UpcastWriter {
|
|
|
123
121
|
* @param index Offset from which nodes will be removed.
|
|
124
122
|
* @param howMany Number of nodes to remove.
|
|
125
123
|
* @param element Element which children will be removed.
|
|
126
|
-
* @fires change
|
|
127
124
|
* @returns The array containing removed nodes.
|
|
128
125
|
*/
|
|
129
126
|
removeChildren(index, howMany, element) {
|
|
@@ -356,64 +353,6 @@ export default class UpcastWriter {
|
|
|
356
353
|
createRangeIn(element) {
|
|
357
354
|
return Range._createIn(element);
|
|
358
355
|
}
|
|
359
|
-
/**
|
|
360
|
-
* Creates a new {@link module:engine/view/selection~Selection} instance.
|
|
361
|
-
*
|
|
362
|
-
* ```ts
|
|
363
|
-
* // Creates empty selection without ranges.
|
|
364
|
-
* const selection = writer.createSelection();
|
|
365
|
-
*
|
|
366
|
-
* // Creates selection at the given range.
|
|
367
|
-
* const range = writer.createRange( start, end );
|
|
368
|
-
* const selection = writer.createSelection( range );
|
|
369
|
-
*
|
|
370
|
-
* // Creates selection at the given ranges
|
|
371
|
-
* const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
|
|
372
|
-
* const selection = writer.createSelection( ranges );
|
|
373
|
-
*
|
|
374
|
-
* // Creates selection from the other selection.
|
|
375
|
-
* const otherSelection = writer.createSelection();
|
|
376
|
-
* const selection = writer.createSelection( otherSelection );
|
|
377
|
-
*
|
|
378
|
-
* // Creates selection from the document selection.
|
|
379
|
-
* const selection = writer.createSelection( editor.editing.view.document.selection );
|
|
380
|
-
*
|
|
381
|
-
* // Creates selection at the given position.
|
|
382
|
-
* const position = writer.createPositionFromPath( root, path );
|
|
383
|
-
* const selection = writer.createSelection( position );
|
|
384
|
-
*
|
|
385
|
-
* // Creates collapsed selection at the position of given item and offset.
|
|
386
|
-
* const paragraph = writer.createContainerElement( 'paragraph' );
|
|
387
|
-
* const selection = writer.createSelection( paragraph, offset );
|
|
388
|
-
*
|
|
389
|
-
* // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
|
|
390
|
-
* // first child of that element and ends after the last child of that element.
|
|
391
|
-
* const selection = writer.createSelection( paragraph, 'in' );
|
|
392
|
-
*
|
|
393
|
-
* // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
|
|
394
|
-
* // just after the item.
|
|
395
|
-
* const selection = writer.createSelection( paragraph, 'on' );
|
|
396
|
-
* ```
|
|
397
|
-
*
|
|
398
|
-
* `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
399
|
-
*
|
|
400
|
-
* ```ts
|
|
401
|
-
* // Creates backward selection.
|
|
402
|
-
* const selection = writer.createSelection( range, { backward: true } );
|
|
403
|
-
* ```
|
|
404
|
-
*
|
|
405
|
-
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
406
|
-
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
407
|
-
* represented in other way, for example by applying proper CSS class.
|
|
408
|
-
*
|
|
409
|
-
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
410
|
-
* (and be properly handled by screen readers).
|
|
411
|
-
*
|
|
412
|
-
* ```ts
|
|
413
|
-
* // Creates fake selection with label.
|
|
414
|
-
* const selection = writer.createSelection( range, { fake: true, label: 'foo' } );
|
|
415
|
-
* ```
|
|
416
|
-
*/
|
|
417
356
|
createSelection(...args) {
|
|
418
357
|
return new Selection(...args);
|
|
419
358
|
}
|
package/src/view/view.d.ts
CHANGED
|
@@ -286,7 +286,97 @@ export default class View extends View_base {
|
|
|
286
286
|
* @param element Element which is a parent for the range.
|
|
287
287
|
*/
|
|
288
288
|
createRangeIn(element: Element): Range;
|
|
289
|
+
/**
|
|
290
|
+
* Creates new {@link module:engine/view/selection~Selection} instance.
|
|
291
|
+
*
|
|
292
|
+
* ```ts
|
|
293
|
+
* // Creates collapsed selection at the position of given item and offset.
|
|
294
|
+
* const paragraph = view.createContainerElement( 'paragraph' );
|
|
295
|
+
* const selection = view.createSelection( paragraph, offset );
|
|
296
|
+
*
|
|
297
|
+
* // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
|
|
298
|
+
* // first child of that element and ends after the last child of that element.
|
|
299
|
+
* const selection = view.createSelection( paragraph, 'in' );
|
|
300
|
+
*
|
|
301
|
+
* // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
|
|
302
|
+
* // just after the item.
|
|
303
|
+
* const selection = view.createSelection( paragraph, 'on' );
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* `Selection`'s factory method allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
307
|
+
*
|
|
308
|
+
* ```ts
|
|
309
|
+
* // Creates backward selection.
|
|
310
|
+
* const selection = view.createSelection( paragraph, 'in', { backward: true } );
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
314
|
+
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
315
|
+
* represented in other way, for example by applying proper CSS class.
|
|
316
|
+
*
|
|
317
|
+
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
318
|
+
* (and be properly handled by screen readers).
|
|
319
|
+
*
|
|
320
|
+
* ```ts
|
|
321
|
+
* // Creates fake selection with label.
|
|
322
|
+
* const selection = view.createSelection( element, 'in', { fake: true, label: 'foo' } );
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* See also: {@link #createSelection:SELECTABLE `createSelection( selectable, options )`}.
|
|
326
|
+
*
|
|
327
|
+
* @label NODE_OFFSET
|
|
328
|
+
*/
|
|
289
329
|
createSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: SelectionOptions): Selection;
|
|
330
|
+
/**
|
|
331
|
+
* Creates new {@link module:engine/view/selection~Selection} instance.
|
|
332
|
+
*
|
|
333
|
+
* ```ts
|
|
334
|
+
* // Creates empty selection without ranges.
|
|
335
|
+
* const selection = view.createSelection();
|
|
336
|
+
*
|
|
337
|
+
* // Creates selection at the given range.
|
|
338
|
+
* const range = view.createRange( start, end );
|
|
339
|
+
* const selection = view.createSelection( range );
|
|
340
|
+
*
|
|
341
|
+
* // Creates selection at the given ranges
|
|
342
|
+
* const ranges = [ view.createRange( start1, end2 ), view.createRange( star2, end2 ) ];
|
|
343
|
+
* const selection = view.createSelection( ranges );
|
|
344
|
+
*
|
|
345
|
+
* // Creates selection from the other selection.
|
|
346
|
+
* const otherSelection = view.createSelection();
|
|
347
|
+
* const selection = view.createSelection( otherSelection );
|
|
348
|
+
*
|
|
349
|
+
* // Creates selection from the document selection.
|
|
350
|
+
* const selection = view.createSelection( editor.editing.view.document.selection );
|
|
351
|
+
*
|
|
352
|
+
* // Creates selection at the given position.
|
|
353
|
+
* const position = view.createPositionFromPath( root, path );
|
|
354
|
+
* const selection = view.createSelection( position );
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* `Selection`'s factory method allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
358
|
+
*
|
|
359
|
+
* ```ts
|
|
360
|
+
* // Creates backward selection.
|
|
361
|
+
* const selection = view.createSelection( range, { backward: true } );
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
365
|
+
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
366
|
+
* represented in other way, for example by applying proper CSS class.
|
|
367
|
+
*
|
|
368
|
+
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
369
|
+
* (and be properly handled by screen readers).
|
|
370
|
+
*
|
|
371
|
+
* ```ts
|
|
372
|
+
* // Creates fake selection with label.
|
|
373
|
+
* const selection = view.createSelection( range, { fake: true, label: 'foo' } );
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* See also: {@link #createSelection:NODE_OFFSET `createSelection( node, placeOrOffset, options )`}.
|
|
377
|
+
*
|
|
378
|
+
* @label SELECTABLE
|
|
379
|
+
*/
|
|
290
380
|
createSelection(selectable?: Exclude<Selectable, Node>, options?: SelectionOptions): Selection;
|
|
291
381
|
/**
|
|
292
382
|
* Disables or enables rendering. If the flag is set to `true` then the rendering will be disabled.
|
|
@@ -318,7 +408,7 @@ export default class View extends View_base {
|
|
|
318
408
|
* balloon panel. If you wants to change view structure use
|
|
319
409
|
* {@link module:engine/view/document~Document#registerPostFixer post-fixers}.
|
|
320
410
|
*
|
|
321
|
-
* @eventName render
|
|
411
|
+
* @eventName ~View#render
|
|
322
412
|
*/
|
|
323
413
|
export type ViewRenderEvent = {
|
|
324
414
|
name: 'render';
|
package/src/view/view.js
CHANGED
|
@@ -347,8 +347,9 @@ export default class View extends ObservableMixin() {
|
|
|
347
347
|
* cause some unexpected behaviour and inconsistency between the DOM and the view.
|
|
348
348
|
* This may be caused by:
|
|
349
349
|
*
|
|
350
|
-
* * calling {@link #change} or {@link #forceRender} during rendering
|
|
351
|
-
*
|
|
350
|
+
* * calling {@link module:engine/view/view~View#change} or {@link module:engine/view/view~View#forceRender} during rendering
|
|
351
|
+
* process,
|
|
352
|
+
* * calling {@link module:engine/view/view~View#change} or {@link module:engine/view/view~View#forceRender} inside of
|
|
352
353
|
* {@link module:engine/view/document~Document#registerPostFixer post-fixer function}.
|
|
353
354
|
*
|
|
354
355
|
* @error cannot-change-view-tree
|
|
@@ -467,64 +468,6 @@ export default class View extends ObservableMixin() {
|
|
|
467
468
|
createRangeIn(element) {
|
|
468
469
|
return Range._createIn(element);
|
|
469
470
|
}
|
|
470
|
-
/**
|
|
471
|
-
Creates new {@link module:engine/view/selection~Selection} instance.
|
|
472
|
-
*
|
|
473
|
-
* ```ts
|
|
474
|
-
* // Creates empty selection without ranges.
|
|
475
|
-
* const selection = view.createSelection();
|
|
476
|
-
*
|
|
477
|
-
* // Creates selection at the given range.
|
|
478
|
-
* const range = view.createRange( start, end );
|
|
479
|
-
* const selection = view.createSelection( range );
|
|
480
|
-
*
|
|
481
|
-
* // Creates selection at the given ranges
|
|
482
|
-
* const ranges = [ view.createRange( start1, end2 ), view.createRange( star2, end2 ) ];
|
|
483
|
-
* const selection = view.createSelection( ranges );
|
|
484
|
-
*
|
|
485
|
-
* // Creates selection from the other selection.
|
|
486
|
-
* const otherSelection = view.createSelection();
|
|
487
|
-
* const selection = view.createSelection( otherSelection );
|
|
488
|
-
*
|
|
489
|
-
* // Creates selection from the document selection.
|
|
490
|
-
* const selection = view.createSelection( editor.editing.view.document.selection );
|
|
491
|
-
*
|
|
492
|
-
* // Creates selection at the given position.
|
|
493
|
-
* const position = view.createPositionFromPath( root, path );
|
|
494
|
-
* const selection = view.createSelection( position );
|
|
495
|
-
*
|
|
496
|
-
* // Creates collapsed selection at the position of given item and offset.
|
|
497
|
-
* const paragraph = view.createContainerElement( 'paragraph' );
|
|
498
|
-
* const selection = view.createSelection( paragraph, offset );
|
|
499
|
-
*
|
|
500
|
-
* // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
|
|
501
|
-
* // first child of that element and ends after the last child of that element.
|
|
502
|
-
* const selection = view.createSelection( paragraph, 'in' );
|
|
503
|
-
*
|
|
504
|
-
* // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
|
|
505
|
-
* // just after the item.
|
|
506
|
-
* const selection = view.createSelection( paragraph, 'on' );
|
|
507
|
-
* ```
|
|
508
|
-
*
|
|
509
|
-
* `Selection`'s factory method allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
510
|
-
*
|
|
511
|
-
* ```ts
|
|
512
|
-
* // Creates backward selection.
|
|
513
|
-
* const selection = view.createSelection( range, { backward: true } );
|
|
514
|
-
* ```
|
|
515
|
-
*
|
|
516
|
-
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
517
|
-
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
518
|
-
* represented in other way, for example by applying proper CSS class.
|
|
519
|
-
*
|
|
520
|
-
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
521
|
-
* (and be properly handled by screen readers).
|
|
522
|
-
*
|
|
523
|
-
* ```ts
|
|
524
|
-
* // Creates fake selection with label.
|
|
525
|
-
* const selection = view.createSelection( range, { fake: true, label: 'foo' } );
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
471
|
createSelection(...args) {
|
|
529
472
|
return new Selection(...args);
|
|
530
473
|
}
|