@ckeditor/ckeditor5-engine 45.2.1-alpha.9 → 46.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2563 -2257
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/controller/datacontroller.d.ts +33 -32
- package/src/controller/datacontroller.js +29 -28
- package/src/controller/editingcontroller.d.ts +8 -8
- package/src/controller/editingcontroller.js +10 -10
- package/src/conversion/conversion.d.ts +18 -19
- package/src/conversion/conversion.js +4 -4
- package/src/conversion/conversionhelpers.d.ts +1 -1
- package/src/conversion/conversionhelpers.js +1 -1
- package/src/conversion/downcastdispatcher.d.ts +63 -69
- package/src/conversion/downcastdispatcher.js +16 -16
- package/src/conversion/downcasthelpers.d.ts +94 -83
- package/src/conversion/downcasthelpers.js +63 -53
- package/src/conversion/mapper.d.ts +27 -27
- package/src/conversion/mapper.js +15 -15
- package/src/conversion/modelconsumable.d.ts +26 -26
- package/src/conversion/modelconsumable.js +23 -23
- package/src/conversion/upcastdispatcher.d.ts +33 -32
- package/src/conversion/upcastdispatcher.js +19 -19
- package/src/conversion/upcasthelpers.d.ts +46 -38
- package/src/conversion/upcasthelpers.js +33 -24
- package/src/conversion/viewconsumable.d.ts +50 -45
- package/src/conversion/viewconsumable.js +32 -27
- package/src/dataprocessor/basichtmlwriter.d.ts +4 -2
- package/src/dataprocessor/basichtmlwriter.js +3 -1
- package/src/dataprocessor/dataprocessor.d.ts +7 -6
- package/src/dataprocessor/htmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/htmldataprocessor.js +6 -6
- package/src/dataprocessor/htmlwriter.d.ts +1 -1
- package/src/dataprocessor/xmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/xmldataprocessor.js +6 -6
- package/src/dev-utils/model.d.ts +25 -26
- package/src/dev-utils/model.js +35 -36
- package/src/dev-utils/operationreplayer.d.ts +5 -3
- package/src/dev-utils/operationreplayer.js +4 -2
- package/src/dev-utils/utils.d.ts +8 -0
- package/src/dev-utils/utils.js +8 -0
- package/src/dev-utils/view.d.ts +66 -63
- package/src/dev-utils/view.js +144 -134
- package/src/index.d.ts +135 -106
- package/src/index.js +120 -71
- package/src/legacyerrors.d.ts +5 -0
- package/src/legacyerrors.js +17 -0
- package/src/model/batch.d.ts +2 -15
- package/src/model/batch.js +1 -23
- package/src/model/differ.d.ts +54 -31
- package/src/model/differ.js +15 -15
- package/src/model/document.d.ts +31 -31
- package/src/model/document.js +13 -13
- package/src/model/documentfragment.d.ts +45 -45
- package/src/model/documentfragment.js +40 -40
- package/src/model/documentselection.d.ts +92 -92
- package/src/model/documentselection.js +71 -70
- package/src/model/element.d.ts +31 -31
- package/src/model/element.js +29 -29
- package/src/model/history.d.ts +3 -3
- package/src/model/history.js +2 -2
- package/src/model/item.d.ts +4 -5
- package/src/model/liveposition.d.ts +31 -31
- package/src/model/liveposition.js +18 -18
- package/src/model/liverange.d.ts +42 -38
- package/src/model/liverange.js +17 -16
- package/src/model/markercollection.d.ts +41 -40
- package/src/model/markercollection.js +22 -20
- package/src/model/model.d.ts +82 -81
- package/src/model/model.js +54 -54
- package/src/model/node.d.ts +48 -48
- package/src/model/node.js +31 -31
- package/src/model/nodelist.d.ts +17 -17
- package/src/model/nodelist.js +11 -11
- package/src/model/operation/attributeoperation.d.ts +10 -10
- package/src/model/operation/attributeoperation.js +7 -7
- package/src/model/operation/detachoperation.d.ts +11 -9
- package/src/model/operation/detachoperation.js +8 -6
- package/src/model/operation/insertoperation.d.ts +13 -13
- package/src/model/operation/insertoperation.js +15 -15
- package/src/model/operation/markeroperation.d.ts +12 -12
- package/src/model/operation/markeroperation.js +5 -5
- package/src/model/operation/mergeoperation.d.ts +16 -16
- package/src/model/operation/mergeoperation.js +18 -18
- package/src/model/operation/moveoperation.d.ts +16 -16
- package/src/model/operation/moveoperation.js +18 -15
- package/src/model/operation/nooperation.d.ts +4 -4
- package/src/model/operation/nooperation.js +2 -2
- package/src/model/operation/operation.d.ts +10 -10
- package/src/model/operation/operation.js +5 -5
- package/src/model/operation/operationfactory.d.ts +4 -4
- package/src/model/operation/operationfactory.js +12 -12
- package/src/model/operation/renameoperation.d.ts +10 -10
- package/src/model/operation/renameoperation.js +7 -7
- package/src/model/operation/rootattributeoperation.d.ts +12 -12
- package/src/model/operation/rootattributeoperation.js +8 -8
- package/src/model/operation/rootoperation.d.ts +8 -8
- package/src/model/operation/rootoperation.js +3 -3
- package/src/model/operation/splitoperation.d.ts +17 -17
- package/src/model/operation/splitoperation.js +19 -19
- package/src/model/operation/transform.d.ts +11 -8
- package/src/model/operation/transform.js +66 -49
- package/src/model/operation/utils.d.ts +24 -23
- package/src/model/operation/utils.js +20 -20
- package/src/model/position.d.ts +101 -97
- package/src/model/position.js +69 -64
- package/src/model/range.d.ts +90 -90
- package/src/model/range.js +87 -87
- package/src/model/rootelement.d.ts +11 -11
- package/src/model/rootelement.js +9 -9
- package/src/model/schema.d.ts +158 -154
- package/src/model/schema.js +93 -90
- package/src/model/selection.d.ts +73 -73
- package/src/model/selection.js +62 -62
- package/src/model/text.d.ts +11 -10
- package/src/model/text.js +11 -10
- package/src/model/textproxy.d.ts +39 -38
- package/src/model/textproxy.js +31 -30
- package/src/model/treewalker.d.ts +37 -37
- package/src/model/treewalker.js +14 -14
- package/src/model/typecheckable.d.ts +45 -45
- package/src/model/typecheckable.js +1 -1
- package/src/model/utils/autoparagraphing.d.ts +7 -7
- package/src/model/utils/deletecontent.d.ts +7 -5
- package/src/model/utils/deletecontent.js +13 -11
- package/src/model/utils/getselectedcontent.d.ts +6 -5
- package/src/model/utils/getselectedcontent.js +2 -1
- package/src/model/utils/insertcontent.d.ts +9 -8
- package/src/model/utils/insertcontent.js +41 -40
- package/src/model/utils/insertobject.d.ts +9 -9
- package/src/model/utils/insertobject.js +4 -4
- package/src/model/utils/modifyselection.d.ts +5 -4
- package/src/model/utils/modifyselection.js +12 -11
- package/src/model/utils/selection-post-fixer.d.ts +12 -8
- package/src/model/utils/selection-post-fixer.js +15 -11
- package/src/model/writer.d.ts +102 -101
- package/src/model/writer.js +99 -98
- package/src/view/attributeelement.d.ts +29 -29
- package/src/view/attributeelement.js +25 -25
- package/src/view/containerelement.d.ts +16 -15
- package/src/view/containerelement.js +15 -14
- package/src/view/datatransfer.d.ts +7 -7
- package/src/view/datatransfer.js +1 -1
- package/src/view/document.d.ts +25 -25
- package/src/view/document.js +15 -15
- package/src/view/documentfragment.d.ts +21 -21
- package/src/view/documentfragment.js +14 -14
- package/src/view/documentselection.d.ts +65 -63
- package/src/view/documentselection.js +27 -25
- package/src/view/domconverter.d.ts +94 -89
- package/src/view/domconverter.js +78 -73
- package/src/view/downcastwriter.d.ts +185 -181
- package/src/view/downcastwriter.js +222 -210
- package/src/view/editableelement.d.ts +13 -13
- package/src/view/editableelement.js +8 -8
- package/src/view/element.d.ts +75 -74
- package/src/view/element.js +58 -58
- package/src/view/elementdefinition.d.ts +3 -4
- package/src/view/emptyelement.d.ts +13 -13
- package/src/view/emptyelement.js +13 -13
- package/src/view/filler.d.ts +14 -3
- package/src/view/filler.js +12 -1
- package/src/view/item.d.ts +4 -5
- package/src/view/matcher.d.ts +22 -19
- package/src/view/matcher.js +6 -6
- package/src/view/node.d.ts +33 -33
- package/src/view/node.js +9 -9
- package/src/view/observer/arrowkeysobserver.d.ts +10 -10
- package/src/view/observer/arrowkeysobserver.js +5 -5
- package/src/view/observer/bubblingemittermixin.d.ts +5 -5
- package/src/view/observer/bubblingemittermixin.js +2 -9
- package/src/view/observer/bubblingeventinfo.d.ts +9 -9
- package/src/view/observer/bubblingeventinfo.js +1 -1
- package/src/view/observer/clickobserver.d.ts +8 -8
- package/src/view/observer/clickobserver.js +4 -4
- package/src/view/observer/compositionobserver.d.ts +19 -19
- package/src/view/observer/compositionobserver.js +6 -6
- package/src/view/observer/domeventdata.d.ts +9 -9
- package/src/view/observer/domeventdata.js +2 -2
- package/src/view/observer/domeventobserver.d.ts +3 -3
- package/src/view/observer/domeventobserver.js +5 -5
- package/src/view/observer/fakeselectionobserver.d.ts +9 -9
- package/src/view/observer/fakeselectionobserver.js +8 -8
- package/src/view/observer/focusobserver.d.ts +16 -16
- package/src/view/observer/focusobserver.js +7 -7
- package/src/view/observer/inputobserver.d.ts +18 -18
- package/src/view/observer/inputobserver.js +5 -5
- package/src/view/observer/keyobserver.d.ts +11 -11
- package/src/view/observer/keyobserver.js +3 -3
- package/src/view/observer/mouseobserver.d.ts +16 -16
- package/src/view/observer/mouseobserver.js +3 -3
- package/src/view/observer/mutationobserver.d.ts +21 -21
- package/src/view/observer/mutationobserver.js +7 -7
- package/src/view/observer/observer.d.ts +12 -12
- package/src/view/observer/observer.js +6 -6
- package/src/view/observer/selectionobserver.d.ts +33 -33
- package/src/view/observer/selectionobserver.js +14 -14
- package/src/view/observer/tabobserver.d.ts +10 -10
- package/src/view/observer/tabobserver.js +5 -5
- package/src/view/observer/touchobserver.d.ts +13 -13
- package/src/view/observer/touchobserver.js +3 -3
- package/src/view/placeholder.d.ts +21 -21
- package/src/view/placeholder.js +23 -23
- package/src/view/position.d.ts +49 -49
- package/src/view/position.js +42 -42
- package/src/view/range.d.ts +76 -74
- package/src/view/range.js +67 -65
- package/src/view/rawelement.d.ts +19 -19
- package/src/view/rawelement.js +16 -16
- package/src/view/renderer.d.ts +14 -14
- package/src/view/renderer.js +7 -7
- package/src/view/rooteditableelement.d.ts +8 -7
- package/src/view/rooteditableelement.js +7 -6
- package/src/view/selection.d.ts +66 -64
- package/src/view/selection.js +50 -48
- package/src/view/styles/background.d.ts +2 -2
- package/src/view/styles/background.js +9 -9
- package/src/view/styles/border.d.ts +2 -2
- package/src/view/styles/border.js +13 -13
- package/src/view/styles/margin.d.ts +2 -2
- package/src/view/styles/margin.js +5 -5
- package/src/view/styles/padding.d.ts +2 -2
- package/src/view/styles/padding.js +5 -5
- package/src/view/styles/utils.d.ts +24 -24
- package/src/view/styles/utils.js +25 -25
- package/src/view/stylesmap.d.ts +28 -32
- package/src/view/stylesmap.js +52 -39
- package/src/view/text.d.ts +11 -11
- package/src/view/text.js +10 -10
- package/src/view/textproxy.d.ts +33 -32
- package/src/view/textproxy.js +23 -22
- package/src/view/tokenlist.d.ts +14 -14
- package/src/view/tokenlist.js +10 -10
- package/src/view/treewalker.d.ts +42 -40
- package/src/view/treewalker.js +36 -35
- package/src/view/typecheckable.d.ts +76 -75
- package/src/view/typecheckable.js +1 -1
- package/src/view/uielement.d.ts +22 -21
- package/src/view/uielement.js +17 -16
- package/src/view/upcastwriter.d.ts +70 -70
- package/src/view/upcastwriter.js +42 -42
- package/src/view/view.d.ts +70 -69
- package/src/view/view.js +56 -55
package/src/view/element.js
CHANGED
|
@@ -5,49 +5,49 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/element
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import { ViewNode } from './node.js';
|
|
9
|
+
import { ViewText } from './text.js';
|
|
10
|
+
import { ViewTextProxy } from './textproxy.js';
|
|
11
11
|
import { isIterable, toMap } from '@ckeditor/ckeditor5-utils';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
12
|
+
import { Matcher, isPatternMatched } from './matcher.js';
|
|
13
|
+
import { StylesMap } from './stylesmap.js';
|
|
14
|
+
import { ViewTokenList } from './tokenlist.js';
|
|
15
15
|
// @if CK_DEBUG_ENGINE // const { convertMapToTags } = require( '../dev-utils/utils' );
|
|
16
16
|
/**
|
|
17
17
|
* View element.
|
|
18
18
|
*
|
|
19
19
|
* The editing engine does not define a fixed semantics of its elements (it is "DTD-free").
|
|
20
|
-
* This is why the type of the {@link module:engine/view/element~
|
|
20
|
+
* This is why the type of the {@link module:engine/view/element~ViewElement} need to
|
|
21
21
|
* be defined by the feature developer. When creating an element you should use one of the following methods:
|
|
22
22
|
*
|
|
23
|
-
* * {@link module:engine/view/downcastwriter~
|
|
24
|
-
* in order to create a {@link module:engine/view/containerelement~
|
|
25
|
-
* * {@link module:engine/view/downcastwriter~
|
|
26
|
-
* in order to create a {@link module:engine/view/attributeelement~
|
|
27
|
-
* * {@link module:engine/view/downcastwriter~
|
|
28
|
-
* in order to create a {@link module:engine/view/emptyelement~
|
|
29
|
-
* * {@link module:engine/view/downcastwriter~
|
|
30
|
-
* in order to create a {@link module:engine/view/uielement~
|
|
31
|
-
* * {@link module:engine/view/downcastwriter~
|
|
32
|
-
* in order to create a {@link module:engine/view/editableelement~
|
|
23
|
+
* * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createContainerElement `downcastWriter#createContainerElement()`}
|
|
24
|
+
* in order to create a {@link module:engine/view/containerelement~ViewContainerElement},
|
|
25
|
+
* * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createAttributeElement `downcastWriter#createAttributeElement()`}
|
|
26
|
+
* in order to create a {@link module:engine/view/attributeelement~ViewAttributeElement},
|
|
27
|
+
* * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createEmptyElement `downcastWriter#createEmptyElement()`}
|
|
28
|
+
* in order to create a {@link module:engine/view/emptyelement~ViewEmptyElement}.
|
|
29
|
+
* * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createUIElement `downcastWriter#createUIElement()`}
|
|
30
|
+
* in order to create a {@link module:engine/view/uielement~ViewUIElement}.
|
|
31
|
+
* * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createEditableElement `downcastWriter#createEditableElement()`}
|
|
32
|
+
* in order to create a {@link module:engine/view/editableelement~ViewEditableElement}.
|
|
33
33
|
*
|
|
34
34
|
* Note that for view elements which are not created from the model, like elements from mutations, paste or
|
|
35
35
|
* {@link module:engine/controller/datacontroller~DataController#set data.set} it is not possible to define the type of the element.
|
|
36
|
-
* In such cases the {@link module:engine/view/upcastwriter~
|
|
36
|
+
* In such cases the {@link module:engine/view/upcastwriter~ViewUpcastWriter#createElement `UpcastWriter#createElement()`} method
|
|
37
37
|
* should be used to create generic view elements.
|
|
38
38
|
*/
|
|
39
|
-
export
|
|
39
|
+
export class ViewElement extends ViewNode {
|
|
40
40
|
/**
|
|
41
41
|
* Name of the element.
|
|
42
42
|
*/
|
|
43
43
|
name;
|
|
44
44
|
/**
|
|
45
45
|
* A list of attribute names that should be rendered in the editing pipeline even though filtering mechanisms
|
|
46
|
-
* implemented in the {@link module:engine/view/domconverter~
|
|
47
|
-
* {@link module:engine/view/domconverter~
|
|
46
|
+
* implemented in the {@link module:engine/view/domconverter~ViewDomConverter} (for instance,
|
|
47
|
+
* {@link module:engine/view/domconverter~ViewDomConverter#shouldRenderAttribute}) would filter them out.
|
|
48
48
|
*
|
|
49
49
|
* These attributes can be specified as an option when the element is created by
|
|
50
|
-
* the {@link module:engine/view/downcastwriter~
|
|
50
|
+
* the {@link module:engine/view/downcastwriter~ViewDowncastWriter}. To check whether an unsafe an attribute should
|
|
51
51
|
* be permitted, use the {@link #shouldRenderUnsafeAttribute} method.
|
|
52
52
|
*
|
|
53
53
|
* @internal
|
|
@@ -212,7 +212,7 @@ export default class Element extends Node {
|
|
|
212
212
|
* can contain different set of children nodes.
|
|
213
213
|
*/
|
|
214
214
|
isSimilar(otherElement) {
|
|
215
|
-
if (!(otherElement instanceof
|
|
215
|
+
if (!(otherElement instanceof ViewElement)) {
|
|
216
216
|
return false;
|
|
217
217
|
}
|
|
218
218
|
// If exactly the same Element is provided - return true immediately.
|
|
@@ -284,7 +284,7 @@ export default class Element extends Node {
|
|
|
284
284
|
*
|
|
285
285
|
* ```ts
|
|
286
286
|
* // Enable 'margin' shorthand processing:
|
|
287
|
-
* editor.data.addStyleProcessorRules(
|
|
287
|
+
* editor.data.addStyleProcessorRules( addMarginStylesRules );
|
|
288
288
|
*
|
|
289
289
|
* const element = view.change( writer => {
|
|
290
290
|
* const element = writer.createElement();
|
|
@@ -433,9 +433,9 @@ export default class Element extends Node {
|
|
|
433
433
|
}
|
|
434
434
|
/**
|
|
435
435
|
* Decides whether an unsafe attribute is whitelisted and should be rendered in the editing pipeline even though filtering mechanisms
|
|
436
|
-
* like {@link module:engine/view/domconverter~
|
|
436
|
+
* like {@link module:engine/view/domconverter~ViewDomConverter#shouldRenderAttribute} say it should not.
|
|
437
437
|
*
|
|
438
|
-
* Unsafe attribute names can be specified when creating an element via {@link module:engine/view/downcastwriter~
|
|
438
|
+
* Unsafe attribute names can be specified when creating an element via {@link module:engine/view/downcastwriter~ViewDowncastWriter}.
|
|
439
439
|
*
|
|
440
440
|
* @param attributeName The name of the attribute to be checked.
|
|
441
441
|
*/
|
|
@@ -457,7 +457,7 @@ export default class Element extends Node {
|
|
|
457
457
|
childrenClone.push(child._clone(deep));
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
//
|
|
460
|
+
// ViewContainerElement and ViewAttributeElement should be also cloned properly.
|
|
461
461
|
const cloned = new this.constructor(this.document, this.name, this._attrs, childrenClone);
|
|
462
462
|
// Clone custom properties.
|
|
463
463
|
cloned._customProperties = new Map(this._customProperties);
|
|
@@ -470,10 +470,10 @@ export default class Element extends Node {
|
|
|
470
470
|
return cloned;
|
|
471
471
|
}
|
|
472
472
|
/**
|
|
473
|
-
* {@link module:engine/view/element~
|
|
473
|
+
* {@link module:engine/view/element~ViewElement#_insertChild Insert} a child node or a list of child nodes at the end of this node
|
|
474
474
|
* and sets the parent of these nodes to this element.
|
|
475
475
|
*
|
|
476
|
-
* @see module:engine/view/downcastwriter~
|
|
476
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#insert
|
|
477
477
|
* @internal
|
|
478
478
|
* @param items Items to be inserted.
|
|
479
479
|
* @fires change
|
|
@@ -487,7 +487,7 @@ export default class Element extends Node {
|
|
|
487
487
|
* this element.
|
|
488
488
|
*
|
|
489
489
|
* @internal
|
|
490
|
-
* @see module:engine/view/downcastwriter~
|
|
490
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#insert
|
|
491
491
|
* @param index Position where nodes should be inserted.
|
|
492
492
|
* @param items Items to be inserted.
|
|
493
493
|
* @fires change
|
|
@@ -513,7 +513,7 @@ export default class Element extends Node {
|
|
|
513
513
|
/**
|
|
514
514
|
* Removes number of child nodes starting at the given index and set the parent of these nodes to `null`.
|
|
515
515
|
*
|
|
516
|
-
* @see module:engine/view/downcastwriter~
|
|
516
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#remove
|
|
517
517
|
* @internal
|
|
518
518
|
* @param index Number of the first node to remove.
|
|
519
519
|
* @param howMany Number of nodes to remove.
|
|
@@ -530,7 +530,7 @@ export default class Element extends Node {
|
|
|
530
530
|
/**
|
|
531
531
|
* Adds or overwrite attribute with a specified key and value.
|
|
532
532
|
*
|
|
533
|
-
* @see module:engine/view/downcastwriter~
|
|
533
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#setAttribute
|
|
534
534
|
* @internal
|
|
535
535
|
* @param key Attribute key.
|
|
536
536
|
* @param value Attribute value.
|
|
@@ -544,7 +544,7 @@ export default class Element extends Node {
|
|
|
544
544
|
if (!currentValue) {
|
|
545
545
|
currentValue = usesStylesMap(this.name, key) ?
|
|
546
546
|
new StylesMap(this.document.stylesProcessor) :
|
|
547
|
-
new
|
|
547
|
+
new ViewTokenList();
|
|
548
548
|
this._attrs.set(key, currentValue);
|
|
549
549
|
}
|
|
550
550
|
if (overwrite) {
|
|
@@ -570,7 +570,7 @@ export default class Element extends Node {
|
|
|
570
570
|
/**
|
|
571
571
|
* Removes attribute from the element.
|
|
572
572
|
*
|
|
573
|
-
* @see module:engine/view/downcastwriter~
|
|
573
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#removeAttribute
|
|
574
574
|
* @internal
|
|
575
575
|
* @param key Attribute key.
|
|
576
576
|
* @param tokens Attribute value tokens to remove. The whole attribute is removed if not specified.
|
|
@@ -603,7 +603,7 @@ export default class Element extends Node {
|
|
|
603
603
|
* element._addClass( [ 'foo', 'bar' ] ); // Adds 'foo' and 'bar' classes.
|
|
604
604
|
* ```
|
|
605
605
|
*
|
|
606
|
-
* @see module:engine/view/downcastwriter~
|
|
606
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#addClass
|
|
607
607
|
* @internal
|
|
608
608
|
* @fires change
|
|
609
609
|
*/
|
|
@@ -618,7 +618,7 @@ export default class Element extends Node {
|
|
|
618
618
|
* element._removeClass( [ 'foo', 'bar' ] ); // Removes both 'foo' and 'bar' classes.
|
|
619
619
|
* ```
|
|
620
620
|
*
|
|
621
|
-
* @see module:engine/view/downcastwriter~
|
|
621
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#removeClass
|
|
622
622
|
* @internal
|
|
623
623
|
* @fires change
|
|
624
624
|
*/
|
|
@@ -645,7 +645,7 @@ export default class Element extends Node {
|
|
|
645
645
|
* {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules a particular style processor rule is enabled}.
|
|
646
646
|
* See {@link module:engine/view/stylesmap~StylesMap#remove `StylesMap#remove()`} for details.
|
|
647
647
|
*
|
|
648
|
-
* @see module:engine/view/downcastwriter~
|
|
648
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#removeStyle
|
|
649
649
|
* @internal
|
|
650
650
|
* @fires change
|
|
651
651
|
*/
|
|
@@ -774,7 +774,7 @@ export default class Element extends Node {
|
|
|
774
774
|
}
|
|
775
775
|
/**
|
|
776
776
|
* Used by the {@link module:engine/conversion/viewconsumable~ViewConsumable} to collect the
|
|
777
|
-
* {@link module:engine/view/element~
|
|
777
|
+
* {@link module:engine/view/element~ViewNormalizedConsumables} for the element.
|
|
778
778
|
*
|
|
779
779
|
* When `key` and `token` parameters are provided the output is filtered for the specified attribute and it's tokens and related tokens.
|
|
780
780
|
*
|
|
@@ -817,10 +817,10 @@ export default class Element extends Node {
|
|
|
817
817
|
/**
|
|
818
818
|
* Verify if the given element can be merged without conflicts into the element.
|
|
819
819
|
*
|
|
820
|
-
* Note that this method is extended by the {@link module:engine/view/attributeelement~
|
|
820
|
+
* Note that this method is extended by the {@link module:engine/view/attributeelement~ViewAttributeElement} implementation.
|
|
821
821
|
*
|
|
822
|
-
* This method is used by the {@link module:engine/view/downcastwriter~
|
|
823
|
-
* an {@link module:engine/view/attributeelement~
|
|
822
|
+
* This method is used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
823
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
|
|
824
824
|
*
|
|
825
825
|
* @internal
|
|
826
826
|
* @returns Returns `true` if elements can be merged.
|
|
@@ -851,14 +851,14 @@ export default class Element extends Node {
|
|
|
851
851
|
*
|
|
852
852
|
* Note that you should make sure there are no conflicts before merging (see {@link #_canMergeAttributesFrom}).
|
|
853
853
|
*
|
|
854
|
-
* This method is used by the {@link module:engine/view/downcastwriter~
|
|
855
|
-
* an {@link module:engine/view/attributeelement~
|
|
854
|
+
* This method is used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
855
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
|
|
856
856
|
*
|
|
857
857
|
* @internal
|
|
858
858
|
*/
|
|
859
859
|
_mergeAttributesFrom(otherElement) {
|
|
860
860
|
this._fireChange('attributes', this);
|
|
861
|
-
// Move all attributes/classes/styles from wrapper to wrapped
|
|
861
|
+
// Move all attributes/classes/styles from wrapper to wrapped ViewAttributeElement.
|
|
862
862
|
for (const [key, otherValue] of otherElement._attrs) {
|
|
863
863
|
const value = this._attrs.get(key);
|
|
864
864
|
if (value === undefined || typeof value == 'string' || typeof otherValue == 'string') {
|
|
@@ -872,10 +872,10 @@ export default class Element extends Node {
|
|
|
872
872
|
/**
|
|
873
873
|
* Verify if the given element attributes can be fully subtracted from the element.
|
|
874
874
|
*
|
|
875
|
-
* Note that this method is extended by the {@link module:engine/view/attributeelement~
|
|
875
|
+
* Note that this method is extended by the {@link module:engine/view/attributeelement~ViewAttributeElement} implementation.
|
|
876
876
|
*
|
|
877
|
-
* This method is used by the {@link module:engine/view/downcastwriter~
|
|
878
|
-
* an {@link module:engine/view/attributeelement~
|
|
877
|
+
* This method is used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
878
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to unwrap the ViewAttributeElement.
|
|
879
879
|
*
|
|
880
880
|
* @internal
|
|
881
881
|
* @returns Returns `true` if elements attributes can be fully subtracted.
|
|
@@ -907,8 +907,8 @@ export default class Element extends Node {
|
|
|
907
907
|
*
|
|
908
908
|
* Note that you should make sure all attributes could be subtracted before subtracting them (see {@link #_canSubtractAttributesOf}).
|
|
909
909
|
*
|
|
910
|
-
* This method is used by the {@link module:engine/view/downcastwriter~
|
|
911
|
-
* an {@link module:engine/view/attributeelement~
|
|
910
|
+
* This method is used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
911
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to unwrap the ViewAttributeElement.
|
|
912
912
|
*
|
|
913
913
|
* @internal
|
|
914
914
|
*/
|
|
@@ -931,7 +931,7 @@ export default class Element extends Node {
|
|
|
931
931
|
* Sets a custom property. Unlike attributes, custom properties are not rendered to the DOM,
|
|
932
932
|
* so they can be used to add special data to elements.
|
|
933
933
|
*
|
|
934
|
-
* @see module:engine/view/downcastwriter~
|
|
934
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#setCustomProperty
|
|
935
935
|
* @internal
|
|
936
936
|
*/
|
|
937
937
|
_setCustomProperty(key, value) {
|
|
@@ -940,7 +940,7 @@ export default class Element extends Node {
|
|
|
940
940
|
/**
|
|
941
941
|
* Removes the custom property stored under the given key.
|
|
942
942
|
*
|
|
943
|
-
* @see module:engine/view/downcastwriter~
|
|
943
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#removeCustomProperty
|
|
944
944
|
* @internal
|
|
945
945
|
* @returns Returns true if property was removed.
|
|
946
946
|
*/
|
|
@@ -970,9 +970,9 @@ export default class Element extends Node {
|
|
|
970
970
|
}
|
|
971
971
|
else if (usesTokenList(this.name, key)) {
|
|
972
972
|
// This is either an element clone so we need to clone token list, or a new instance which requires value to be parsed.
|
|
973
|
-
const newValue = value instanceof
|
|
973
|
+
const newValue = value instanceof ViewTokenList ?
|
|
974
974
|
value._clone() :
|
|
975
|
-
new
|
|
975
|
+
new ViewTokenList().setTo(String(value));
|
|
976
976
|
attrsMap.set(key, newValue);
|
|
977
977
|
}
|
|
978
978
|
else if (typeof value != 'string') {
|
|
@@ -984,7 +984,7 @@ export default class Element extends Node {
|
|
|
984
984
|
}
|
|
985
985
|
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
986
986
|
// Proper overload would interfere with that.
|
|
987
|
-
|
|
987
|
+
ViewElement.prototype.is = function (type, name) {
|
|
988
988
|
if (!name) {
|
|
989
989
|
return type === 'element' || type === 'view:element' ||
|
|
990
990
|
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
@@ -1000,7 +1000,7 @@ Element.prototype.is = function (type, name) {
|
|
|
1000
1000
|
function normalize(document, nodes) {
|
|
1001
1001
|
// Separate condition because string is iterable.
|
|
1002
1002
|
if (typeof nodes == 'string') {
|
|
1003
|
-
return [new
|
|
1003
|
+
return [new ViewText(document, nodes)];
|
|
1004
1004
|
}
|
|
1005
1005
|
if (!isIterable(nodes)) {
|
|
1006
1006
|
nodes = [nodes];
|
|
@@ -1008,10 +1008,10 @@ function normalize(document, nodes) {
|
|
|
1008
1008
|
const normalizedNodes = [];
|
|
1009
1009
|
for (const node of nodes) {
|
|
1010
1010
|
if (typeof node == 'string') {
|
|
1011
|
-
normalizedNodes.push(new
|
|
1011
|
+
normalizedNodes.push(new ViewText(document, node));
|
|
1012
1012
|
}
|
|
1013
|
-
else if (node instanceof
|
|
1014
|
-
normalizedNodes.push(new
|
|
1013
|
+
else if (node instanceof ViewTextProxy) {
|
|
1014
|
+
normalizedNodes.push(new ViewText(document, node.data));
|
|
1015
1015
|
}
|
|
1016
1016
|
else {
|
|
1017
1017
|
normalizedNodes.push(node);
|
|
@@ -43,7 +43,7 @@ import type { ArrayOrItem } from '@ckeditor/ckeditor5-utils';
|
|
|
43
43
|
* <span style="font-size:12px;font-weight:bold" data-id="123"></span>
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
export interface
|
|
46
|
+
export interface ViewElementObjectDefinition {
|
|
47
47
|
/**
|
|
48
48
|
* View element name.
|
|
49
49
|
*/
|
|
@@ -62,7 +62,7 @@ export interface ElementObjectDefinition {
|
|
|
62
62
|
*/
|
|
63
63
|
attributes?: Record<string, string>;
|
|
64
64
|
/**
|
|
65
|
-
* Element's {@link module:engine/view/attributeelement~
|
|
65
|
+
* Element's {@link module:engine/view/attributeelement~ViewAttributeElement#priority priority}.
|
|
66
66
|
*/
|
|
67
67
|
priority?: number;
|
|
68
68
|
}
|
|
@@ -83,5 +83,4 @@ export interface ElementObjectDefinition {
|
|
|
83
83
|
* };
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
|
-
type
|
|
87
|
-
export default ElementDefinition;
|
|
86
|
+
export type ViewElementDefinition = string | ViewElementObjectDefinition;
|
|
@@ -5,37 +5,37 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/emptyelement
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
8
|
+
import { ViewElement, type ViewElementAttributes } from './element.js';
|
|
9
|
+
import { ViewNode } from './node.js';
|
|
10
|
+
import { type ViewDocument } from './document.js';
|
|
11
|
+
import { type ViewItem } from './item.js';
|
|
12
12
|
/**
|
|
13
13
|
* Empty element class. It is used to represent elements that cannot contain any child nodes (for example `<img>` elements).
|
|
14
14
|
*
|
|
15
15
|
* To create a new empty element use the
|
|
16
|
-
* {@link module:engine/view/downcastwriter~
|
|
16
|
+
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createEmptyElement `downcastWriter#createEmptyElement()`} method.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export declare class ViewEmptyElement extends ViewElement {
|
|
19
19
|
/**
|
|
20
|
-
* Creates new instance of
|
|
20
|
+
* Creates new instance of ViewEmptyElement.
|
|
21
21
|
*
|
|
22
22
|
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` when third parameter is passed,
|
|
23
|
-
* to inform that usage of
|
|
23
|
+
* to inform that usage of ViewEmptyElement is incorrect (adding child nodes to ViewEmptyElement is forbidden).
|
|
24
24
|
*
|
|
25
|
-
* @see module:engine/view/downcastwriter~
|
|
25
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createEmptyElement
|
|
26
26
|
* @internal
|
|
27
27
|
* @param document The document instance to which this element belongs.
|
|
28
28
|
* @param name Node name.
|
|
29
29
|
* @param attributes Collection of attributes.
|
|
30
30
|
* @param children A list of nodes to be inserted into created element.
|
|
31
31
|
*/
|
|
32
|
-
constructor(document:
|
|
32
|
+
constructor(document: ViewDocument, name: string, attributes?: ViewElementAttributes, children?: ViewNode | Iterable<ViewNode>);
|
|
33
33
|
/**
|
|
34
|
-
* Overrides {@link module:engine/view/element~
|
|
34
|
+
* Overrides {@link module:engine/view/element~ViewElement#_insertChild} method.
|
|
35
35
|
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` to prevent
|
|
36
|
-
* adding any child nodes to
|
|
36
|
+
* adding any child nodes to ViewEmptyElement.
|
|
37
37
|
*
|
|
38
38
|
* @internal
|
|
39
39
|
*/
|
|
40
|
-
_insertChild(index: number, items:
|
|
40
|
+
_insertChild(index: number, items: ViewItem | Iterable<ViewItem>): number;
|
|
41
41
|
}
|
package/src/view/emptyelement.js
CHANGED
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/emptyelement
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import { ViewElement } from './element.js';
|
|
9
|
+
import { ViewNode } from './node.js';
|
|
10
10
|
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
11
11
|
/**
|
|
12
12
|
* Empty element class. It is used to represent elements that cannot contain any child nodes (for example `<img>` elements).
|
|
13
13
|
*
|
|
14
14
|
* To create a new empty element use the
|
|
15
|
-
* {@link module:engine/view/downcastwriter~
|
|
15
|
+
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createEmptyElement `downcastWriter#createEmptyElement()`} method.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export class ViewEmptyElement extends ViewElement {
|
|
18
18
|
/**
|
|
19
|
-
* Creates new instance of
|
|
19
|
+
* Creates new instance of ViewEmptyElement.
|
|
20
20
|
*
|
|
21
21
|
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` when third parameter is passed,
|
|
22
|
-
* to inform that usage of
|
|
22
|
+
* to inform that usage of ViewEmptyElement is incorrect (adding child nodes to ViewEmptyElement is forbidden).
|
|
23
23
|
*
|
|
24
|
-
* @see module:engine/view/downcastwriter~
|
|
24
|
+
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createEmptyElement
|
|
25
25
|
* @internal
|
|
26
26
|
* @param document The document instance to which this element belongs.
|
|
27
27
|
* @param name Node name.
|
|
@@ -33,16 +33,16 @@ export default class EmptyElement extends Element {
|
|
|
33
33
|
this.getFillerOffset = getFillerOffset;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Overrides {@link module:engine/view/element~
|
|
36
|
+
* Overrides {@link module:engine/view/element~ViewElement#_insertChild} method.
|
|
37
37
|
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` to prevent
|
|
38
|
-
* adding any child nodes to
|
|
38
|
+
* adding any child nodes to ViewEmptyElement.
|
|
39
39
|
*
|
|
40
40
|
* @internal
|
|
41
41
|
*/
|
|
42
42
|
_insertChild(index, items) {
|
|
43
|
-
if (items && (items instanceof
|
|
43
|
+
if (items && (items instanceof ViewNode || Array.from(items).length > 0)) {
|
|
44
44
|
/**
|
|
45
|
-
* Cannot add children to {@link module:engine/view/emptyelement~
|
|
45
|
+
* Cannot add children to {@link module:engine/view/emptyelement~ViewEmptyElement}.
|
|
46
46
|
*
|
|
47
47
|
* @error view-emptyelement-cannot-add
|
|
48
48
|
*/
|
|
@@ -53,7 +53,7 @@ export default class EmptyElement extends Element {
|
|
|
53
53
|
}
|
|
54
54
|
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
55
55
|
// Proper overload would interfere with that.
|
|
56
|
-
|
|
56
|
+
ViewEmptyElement.prototype.is = function (type, name) {
|
|
57
57
|
if (!name) {
|
|
58
58
|
return type === 'emptyElement' || type === 'view:emptyElement' ||
|
|
59
59
|
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
@@ -66,7 +66,7 @@ EmptyElement.prototype.is = function (type, name) {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
-
* Returns `null` because block filler is not needed for
|
|
69
|
+
* Returns `null` because block filler is not needed for ViewEmptyElements.
|
|
70
70
|
*/
|
|
71
71
|
function getFillerOffset() {
|
|
72
72
|
return null;
|
package/src/view/filler.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import type
|
|
5
|
+
import { type EditingView } from './view.js';
|
|
6
6
|
/**
|
|
7
7
|
* Set of utilities related to handling block and inline fillers.
|
|
8
8
|
*
|
|
@@ -26,7 +26,7 @@ import type View from './view.js';
|
|
|
26
26
|
* transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional
|
|
27
27
|
* code is needed to handle the caret.
|
|
28
28
|
*
|
|
29
|
-
* Both inline and block fillers are handled by the {@link module:engine/view/renderer~
|
|
29
|
+
* Both inline and block fillers are handled by the {@link module:engine/view/renderer~ViewRenderer renderer} and are not present in the
|
|
30
30
|
* view.
|
|
31
31
|
*
|
|
32
32
|
* @module engine/view/filler
|
|
@@ -37,6 +37,7 @@ import type View from './view.js';
|
|
|
37
37
|
*
|
|
38
38
|
* @see module:engine/view/filler~MARKED_NBSP_FILLER
|
|
39
39
|
* @see module:engine/view/filler~BR_FILLER
|
|
40
|
+
* @internal
|
|
40
41
|
*/
|
|
41
42
|
export declare const NBSP_FILLER: (domDocument: Document) => Text;
|
|
42
43
|
/**
|
|
@@ -45,6 +46,7 @@ export declare const NBSP_FILLER: (domDocument: Document) => Text;
|
|
|
45
46
|
*
|
|
46
47
|
* @see module:engine/view/filler~NBSP_FILLER
|
|
47
48
|
* @see module:engine/view/filler~BR_FILLER
|
|
49
|
+
* @internal
|
|
48
50
|
*/
|
|
49
51
|
export declare const MARKED_NBSP_FILLER: (domDocument: Document) => HTMLSpanElement;
|
|
50
52
|
/**
|
|
@@ -53,14 +55,19 @@ export declare const MARKED_NBSP_FILLER: (domDocument: Document) => HTMLSpanElem
|
|
|
53
55
|
*
|
|
54
56
|
* @see module:engine/view/filler~NBSP_FILLER
|
|
55
57
|
* @see module:engine/view/filler~MARKED_NBSP_FILLER
|
|
58
|
+
* @internal
|
|
56
59
|
*/
|
|
57
60
|
export declare const BR_FILLER: (domDocument: Document) => HTMLBRElement;
|
|
58
61
|
/**
|
|
59
62
|
* Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
60
65
|
*/
|
|
61
66
|
export declare const INLINE_FILLER_LENGTH = 7;
|
|
62
67
|
/**
|
|
63
68
|
* Inline filler which is a sequence of the word joiners.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
64
71
|
*/
|
|
65
72
|
export declare const INLINE_FILLER: string;
|
|
66
73
|
/**
|
|
@@ -75,6 +82,7 @@ export declare const INLINE_FILLER: string;
|
|
|
75
82
|
*
|
|
76
83
|
* @param domNode DOM node.
|
|
77
84
|
* @returns True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
85
|
+
* @internal
|
|
78
86
|
*/
|
|
79
87
|
export declare function startsWithFiller(domNode: Node | string): boolean;
|
|
80
88
|
/**
|
|
@@ -87,6 +95,7 @@ export declare function startsWithFiller(domNode: Node | string): boolean;
|
|
|
87
95
|
*
|
|
88
96
|
* @param domText DOM text node.
|
|
89
97
|
* @returns True if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
98
|
+
* @internal
|
|
90
99
|
*/
|
|
91
100
|
export declare function isInlineFiller(domText: Text): boolean;
|
|
92
101
|
/**
|
|
@@ -100,6 +109,7 @@ export declare function isInlineFiller(domText: Text): boolean;
|
|
|
100
109
|
*
|
|
101
110
|
* @param domText DOM text node, possible with inline filler.
|
|
102
111
|
* @returns Data without filler.
|
|
112
|
+
* @internal
|
|
103
113
|
*/
|
|
104
114
|
export declare function getDataWithoutFiller(domText: Text | string): string;
|
|
105
115
|
/**
|
|
@@ -107,5 +117,6 @@ export declare function getDataWithoutFiller(domText: Text | string): string;
|
|
|
107
117
|
* the left arrow is pressed, so the filler does not break navigation.
|
|
108
118
|
*
|
|
109
119
|
* @param view View controller instance we should inject quirks handling on.
|
|
120
|
+
* @internal
|
|
110
121
|
*/
|
|
111
|
-
export declare function injectQuirksHandling(view:
|
|
122
|
+
export declare function injectQuirksHandling(view: EditingView): void;
|
package/src/view/filler.js
CHANGED
|
@@ -26,7 +26,7 @@ import { keyCodes, isText } from '@ckeditor/ckeditor5-utils';
|
|
|
26
26
|
* transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional
|
|
27
27
|
* code is needed to handle the caret.
|
|
28
28
|
*
|
|
29
|
-
* Both inline and block fillers are handled by the {@link module:engine/view/renderer~
|
|
29
|
+
* Both inline and block fillers are handled by the {@link module:engine/view/renderer~ViewRenderer renderer} and are not present in the
|
|
30
30
|
* view.
|
|
31
31
|
*
|
|
32
32
|
* @module engine/view/filler
|
|
@@ -37,6 +37,7 @@ import { keyCodes, isText } from '@ckeditor/ckeditor5-utils';
|
|
|
37
37
|
*
|
|
38
38
|
* @see module:engine/view/filler~MARKED_NBSP_FILLER
|
|
39
39
|
* @see module:engine/view/filler~BR_FILLER
|
|
40
|
+
* @internal
|
|
40
41
|
*/
|
|
41
42
|
export const NBSP_FILLER = (domDocument) => domDocument.createTextNode('\u00A0');
|
|
42
43
|
/**
|
|
@@ -45,6 +46,7 @@ export const NBSP_FILLER = (domDocument) => domDocument.createTextNode('\u00A0')
|
|
|
45
46
|
*
|
|
46
47
|
* @see module:engine/view/filler~NBSP_FILLER
|
|
47
48
|
* @see module:engine/view/filler~BR_FILLER
|
|
49
|
+
* @internal
|
|
48
50
|
*/
|
|
49
51
|
export const MARKED_NBSP_FILLER = (domDocument) => {
|
|
50
52
|
const span = domDocument.createElement('span');
|
|
@@ -58,6 +60,7 @@ export const MARKED_NBSP_FILLER = (domDocument) => {
|
|
|
58
60
|
*
|
|
59
61
|
* @see module:engine/view/filler~NBSP_FILLER
|
|
60
62
|
* @see module:engine/view/filler~MARKED_NBSP_FILLER
|
|
63
|
+
* @internal
|
|
61
64
|
*/
|
|
62
65
|
export const BR_FILLER = (domDocument) => {
|
|
63
66
|
const fillerBr = domDocument.createElement('br');
|
|
@@ -66,10 +69,14 @@ export const BR_FILLER = (domDocument) => {
|
|
|
66
69
|
};
|
|
67
70
|
/**
|
|
68
71
|
* Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
69
74
|
*/
|
|
70
75
|
export const INLINE_FILLER_LENGTH = 7;
|
|
71
76
|
/**
|
|
72
77
|
* Inline filler which is a sequence of the word joiners.
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
73
80
|
*/
|
|
74
81
|
export const INLINE_FILLER = '\u2060'.repeat(INLINE_FILLER_LENGTH);
|
|
75
82
|
/**
|
|
@@ -84,6 +91,7 @@ export const INLINE_FILLER = '\u2060'.repeat(INLINE_FILLER_LENGTH);
|
|
|
84
91
|
*
|
|
85
92
|
* @param domNode DOM node.
|
|
86
93
|
* @returns True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
94
|
+
* @internal
|
|
87
95
|
*/
|
|
88
96
|
export function startsWithFiller(domNode) {
|
|
89
97
|
if (typeof domNode == 'string') {
|
|
@@ -101,6 +109,7 @@ export function startsWithFiller(domNode) {
|
|
|
101
109
|
*
|
|
102
110
|
* @param domText DOM text node.
|
|
103
111
|
* @returns True if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
112
|
+
* @internal
|
|
104
113
|
*/
|
|
105
114
|
export function isInlineFiller(domText) {
|
|
106
115
|
return domText.data.length == INLINE_FILLER_LENGTH && startsWithFiller(domText);
|
|
@@ -116,6 +125,7 @@ export function isInlineFiller(domText) {
|
|
|
116
125
|
*
|
|
117
126
|
* @param domText DOM text node, possible with inline filler.
|
|
118
127
|
* @returns Data without filler.
|
|
128
|
+
* @internal
|
|
119
129
|
*/
|
|
120
130
|
export function getDataWithoutFiller(domText) {
|
|
121
131
|
const data = typeof domText == 'string' ? domText : domText.data;
|
|
@@ -129,6 +139,7 @@ export function getDataWithoutFiller(domText) {
|
|
|
129
139
|
* the left arrow is pressed, so the filler does not break navigation.
|
|
130
140
|
*
|
|
131
141
|
* @param view View controller instance we should inject quirks handling on.
|
|
142
|
+
* @internal
|
|
132
143
|
*/
|
|
133
144
|
export function injectQuirksHandling(view) {
|
|
134
145
|
view.document.on('arrowKey', jumpOverInlineFiller, { priority: 'low' });
|
package/src/view/item.d.ts
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import type
|
|
6
|
-
import type
|
|
5
|
+
import { type ViewNode } from './node.js';
|
|
6
|
+
import { type ViewTextProxy } from './textproxy.js';
|
|
7
7
|
/**
|
|
8
8
|
* @module engine/view/item
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Item is a {@link module:engine/view/node~
|
|
11
|
+
* Item is a {@link module:engine/view/node~ViewNode Node} or {@link module:engine/view/textproxy~ViewTextProxy ViewTextProxy}.
|
|
12
12
|
*/
|
|
13
|
-
type
|
|
14
|
-
export default Item;
|
|
13
|
+
export type ViewItem = ViewNode | ViewTextProxy;
|