@ckeditor/ckeditor5-engine 48.2.0 → 48.3.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/dist/controller/datacontroller.d.ts +329 -328
- package/dist/controller/editingcontroller.d.ts +95 -94
- package/dist/conversion/comparemarkers.d.ts +45 -45
- package/dist/conversion/conversion.d.ts +474 -474
- package/dist/conversion/conversionhelpers.d.ts +21 -21
- package/dist/conversion/downcastdispatcher.d.ts +539 -538
- package/dist/conversion/downcasthelpers.d.ts +1129 -1129
- package/dist/conversion/mapper.d.ts +692 -697
- package/dist/conversion/modelconsumable.d.ts +196 -196
- package/dist/conversion/upcastdispatcher.d.ts +483 -482
- package/dist/conversion/upcasthelpers.d.ts +491 -491
- package/dist/conversion/viewconsumable.d.ts +330 -330
- package/dist/dataprocessor/basichtmlwriter.d.ts +15 -15
- package/dist/dataprocessor/dataprocessor.d.ts +57 -57
- package/dist/dataprocessor/htmldataprocessor.d.ts +72 -72
- package/dist/dataprocessor/htmlwriter.d.ts +11 -11
- package/dist/dataprocessor/xmldataprocessor.d.ts +86 -86
- package/dist/dev-utils/model.d.ts +128 -123
- package/dist/dev-utils/operationreplayer.d.ts +49 -49
- package/dist/dev-utils/utils.d.ts +33 -33
- package/dist/dev-utils/view.d.ts +314 -309
- package/dist/engineconfig.d.ts +39 -39
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +150 -150
- package/dist/index.js +34026 -40107
- package/dist/index.js.map +1 -1
- package/dist/legacyerrors.d.ts +0 -4
- package/dist/model/batch.d.ts +86 -86
- package/dist/model/differ.d.ts +504 -504
- package/dist/model/document.d.ts +265 -268
- package/dist/model/documentfragment.d.ts +214 -214
- package/dist/model/documentselection.d.ts +406 -410
- package/dist/model/element.d.ts +182 -182
- package/dist/model/history.d.ts +109 -109
- package/dist/model/item.d.ts +9 -9
- package/dist/model/liveposition.d.ts +70 -69
- package/dist/model/liverange.d.ts +93 -92
- package/dist/model/markercollection.d.ts +317 -324
- package/dist/model/model.d.ts +889 -909
- package/dist/model/node.d.ts +254 -254
- package/dist/model/nodelist.d.ts +110 -110
- package/dist/model/operation/attributeoperation.d.ts +98 -98
- package/dist/model/operation/detachoperation.d.ts +57 -57
- package/dist/model/operation/insertoperation.d.ts +85 -85
- package/dist/model/operation/markeroperation.d.ts +87 -87
- package/dist/model/operation/mergeoperation.d.ts +95 -95
- package/dist/model/operation/moveoperation.d.ts +97 -97
- package/dist/model/operation/nooperation.d.ts +33 -33
- package/dist/model/operation/operation.d.ts +94 -94
- package/dist/model/operation/operationfactory.d.ts +14 -14
- package/dist/model/operation/renameoperation.d.ts +78 -78
- package/dist/model/operation/rootattributeoperation.d.ts +93 -93
- package/dist/model/operation/rootoperation.d.ts +71 -71
- package/dist/model/operation/splitoperation.d.ts +104 -104
- package/dist/model/operation/transform.d.ts +91 -91
- package/dist/model/operation/utils.d.ts +58 -58
- package/dist/model/position.d.ts +535 -535
- package/dist/model/range.d.ts +458 -453
- package/dist/model/rootelement.d.ts +55 -55
- package/dist/model/schema.d.ts +1325 -1327
- package/dist/model/selection.d.ts +452 -471
- package/dist/model/text.d.ts +62 -62
- package/dist/model/textproxy.d.ts +140 -140
- package/dist/model/treewalker.d.ts +190 -190
- package/dist/model/typecheckable.d.ts +281 -281
- package/dist/model/utils/autoparagraphing.d.ts +29 -29
- package/dist/model/utils/deletecontent.d.ts +68 -68
- package/dist/model/utils/getselectedcontent.d.ts +27 -27
- package/dist/model/utils/insertcontent.d.ts +42 -42
- package/dist/model/utils/insertobject.d.ts +41 -41
- package/dist/model/utils/modifyselection.d.ts +44 -44
- package/dist/model/utils/selection-post-fixer.d.ts +71 -71
- package/dist/model/writer.d.ts +854 -854
- package/dist/view/attributeelement.d.ts +123 -123
- package/dist/view/containerelement.d.ts +49 -49
- package/dist/view/datatransfer.d.ts +70 -70
- package/dist/view/document.d.ts +175 -177
- package/dist/view/documentfragment.d.ts +158 -157
- package/dist/view/documentselection.d.ts +308 -307
- package/dist/view/domconverter.d.ts +612 -657
- package/dist/view/downcastwriter.d.ts +1006 -1006
- package/dist/view/editableelement.d.ts +64 -63
- package/dist/view/element.d.ts +754 -754
- package/dist/view/elementdefinition.d.ts +79 -79
- package/dist/view/emptyelement.d.ts +42 -42
- package/dist/view/filler.d.ts +75 -75
- package/dist/view/item.d.ts +9 -9
- package/dist/view/matcher.d.ts +412 -487
- package/dist/view/node.d.ts +164 -163
- package/dist/view/observer/arrowkeysobserver.d.ts +37 -37
- package/dist/view/observer/bubblingemittermixin.d.ts +163 -153
- package/dist/view/observer/bubblingeventinfo.d.ts +45 -42
- package/dist/view/observer/clickobserver.d.ts +36 -36
- package/dist/view/observer/compositionobserver.d.ts +67 -67
- package/dist/view/observer/domeventdata.d.ts +46 -46
- package/dist/view/observer/domeventobserver.d.ts +77 -74
- package/dist/view/observer/fakeselectionobserver.d.ts +42 -42
- package/dist/view/observer/focusobserver.d.ts +84 -84
- package/dist/view/observer/inputobserver.d.ts +76 -76
- package/dist/view/observer/keyobserver.d.ts +53 -53
- package/dist/view/observer/mouseobserver.d.ts +73 -73
- package/dist/view/observer/mutationobserver.d.ts +101 -101
- package/dist/view/observer/observer.d.ts +84 -83
- package/dist/view/observer/pointerobserver.d.ts +63 -63
- package/dist/view/observer/selectionobserver.d.ts +136 -136
- package/dist/view/observer/tabobserver.d.ts +38 -38
- package/dist/view/observer/touchobserver.d.ts +60 -60
- package/dist/view/placeholder.d.ts +80 -80
- package/dist/view/position.d.ts +187 -187
- package/dist/view/range.d.ts +282 -282
- package/dist/view/rawelement.d.ts +72 -72
- package/dist/view/renderer.d.ts +270 -272
- package/dist/view/rooteditableelement.d.ts +43 -43
- package/dist/view/selection.d.ts +356 -369
- package/dist/view/styles/background.d.ts +15 -15
- package/dist/view/styles/border.d.ts +27 -27
- package/dist/view/styles/margin.d.ts +12 -12
- package/dist/view/styles/padding.d.ts +12 -12
- package/dist/view/styles/utils.d.ts +72 -72
- package/dist/view/stylesmap.d.ts +715 -715
- package/dist/view/text.d.ts +75 -75
- package/dist/view/textproxy.d.ts +92 -92
- package/dist/view/tokenlist.d.ts +104 -104
- package/dist/view/treewalker.d.ts +201 -201
- package/dist/view/typecheckable.d.ts +445 -445
- package/dist/view/uielement.d.ts +93 -93
- package/dist/view/upcastwriter.d.ts +412 -412
- package/dist/view/view.d.ts +466 -469
- package/package.json +2 -2
|
@@ -1,342 +1,342 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type { ViewElement, ViewNormalizedConsumables } from
|
|
6
|
-
import { type ViewNode } from
|
|
7
|
-
import { type ViewText } from
|
|
8
|
-
import { type ViewDocumentFragment } from
|
|
9
|
-
import type { Match } from
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewElement, ViewNormalizedConsumables } from "../view/element.js";
|
|
6
|
+
import { type ViewNode } from "../view/node.js";
|
|
7
|
+
import { type ViewText } from "../view/text.js";
|
|
8
|
+
import { type ViewDocumentFragment } from "../view/documentfragment.js";
|
|
9
|
+
import type { Match } from "../view/matcher.js";
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
* Class used for handling consumption of view {@link module:engine/view/element~ViewElement elements},
|
|
12
|
+
* {@link module:engine/view/text~ViewText text nodes} and
|
|
13
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragments}.
|
|
14
|
+
* Element's name and its parts (attributes, classes and styles) can be consumed separately. Consuming an element's name
|
|
15
|
+
* does not consume its attributes, classes and styles.
|
|
16
|
+
* To add items for consumption use {@link module:engine/conversion/viewconsumable~ViewConsumable#add add method}.
|
|
17
|
+
* To test items use {@link module:engine/conversion/viewconsumable~ViewConsumable#test test method}.
|
|
18
|
+
* To consume items use {@link module:engine/conversion/viewconsumable~ViewConsumable#consume consume method}.
|
|
19
|
+
* To revert already consumed items use {@link module:engine/conversion/viewconsumable~ViewConsumable#revert revert method}.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* viewConsumable.add( element, { name: true } ); // Adds element's name as ready to be consumed.
|
|
23
|
+
* viewConsumable.add( textNode ); // Adds text node for consumption.
|
|
24
|
+
* viewConsumable.add( docFragment ); // Adds document fragment for consumption.
|
|
25
|
+
* viewConsumable.test( element, { name: true } ); // Tests if element's name can be consumed.
|
|
26
|
+
* viewConsumable.test( textNode ); // Tests if text node can be consumed.
|
|
27
|
+
* viewConsumable.test( docFragment ); // Tests if document fragment can be consumed.
|
|
28
|
+
* viewConsumable.consume( element, { name: true } ); // Consume element's name.
|
|
29
|
+
* viewConsumable.consume( textNode ); // Consume text node.
|
|
30
|
+
* viewConsumable.consume( docFragment ); // Consume document fragment.
|
|
31
|
+
* viewConsumable.revert( element, { name: true } ); // Revert already consumed element's name.
|
|
32
|
+
* viewConsumable.revert( textNode ); // Revert already consumed text node.
|
|
33
|
+
* viewConsumable.revert( docFragment ); // Revert already consumed document fragment.
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
36
|
export declare class ViewConsumable {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Map of consumable elements. If {@link module:engine/view/element~ViewElement element} is used as a key,
|
|
39
|
+
* {@link module:engine/conversion/viewconsumable~ViewElementConsumables ViewElementConsumables} instance is stored as value.
|
|
40
|
+
* For {@link module:engine/view/text~ViewText text nodes} and
|
|
41
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragments} boolean value is stored as value.
|
|
42
|
+
*/
|
|
43
|
+
private _consumables;
|
|
44
|
+
/**
|
|
45
|
+
* Adds view {@link module:engine/view/element~ViewElement element}, {@link module:engine/view/text~ViewText text node} or
|
|
46
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment} as ready to be consumed.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* viewConsumable.add( p, { name: true } ); // Adds element's name to consume.
|
|
50
|
+
* viewConsumable.add( p, { attributes: 'name' } ); // Adds element's attribute.
|
|
51
|
+
* viewConsumable.add( p, { classes: 'foobar' } ); // Adds element's class.
|
|
52
|
+
* viewConsumable.add( p, { styles: 'color' } ); // Adds element's style
|
|
53
|
+
* viewConsumable.add( p, { attributes: 'name', styles: 'color' } ); // Adds attribute and style.
|
|
54
|
+
* viewConsumable.add( p, { classes: [ 'baz', 'bar' ] } ); // Multiple consumables can be provided.
|
|
55
|
+
* viewConsumable.add( textNode ); // Adds text node to consume.
|
|
56
|
+
* viewConsumable.add( docFragment ); // Adds document fragment to consume.
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `viewconsumable-invalid-attribute` when `class` or `style`
|
|
60
|
+
* attribute is provided - it should be handled separately by providing actual style/class.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* viewConsumable.add( p, { attributes: 'style' } ); // This call will throw an exception.
|
|
64
|
+
* viewConsumable.add( p, { styles: 'color' } ); // This is properly handled style.
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @param consumables Used only if first parameter is {@link module:engine/view/element~ViewElement view element} instance.
|
|
68
|
+
* @param consumables.name If set to true element's name will be included.
|
|
69
|
+
* @param consumables.attributes Attribute name or array of attribute names.
|
|
70
|
+
* @param consumables.classes Class name or array of class names.
|
|
71
|
+
* @param consumables.styles Style name or array of style names.
|
|
72
|
+
*/
|
|
73
|
+
add(element: ViewText | ViewElement | ViewDocumentFragment, consumables?: Consumables | ViewNormalizedConsumables): void;
|
|
74
|
+
/**
|
|
75
|
+
* Tests if {@link module:engine/view/element~ViewElement view element}, {@link module:engine/view/text~ViewText text node} or
|
|
76
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment} can be consumed.
|
|
77
|
+
* It returns `true` when all items included in method's call can be consumed. Returns `false` when
|
|
78
|
+
* first already consumed item is found and `null` when first non-consumable item is found.
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* viewConsumable.test( p, { name: true } ); // Tests element's name.
|
|
82
|
+
* viewConsumable.test( p, { attributes: 'name' } ); // Tests attribute.
|
|
83
|
+
* viewConsumable.test( p, { classes: 'foobar' } ); // Tests class.
|
|
84
|
+
* viewConsumable.test( p, { styles: 'color' } ); // Tests style.
|
|
85
|
+
* viewConsumable.test( p, { attributes: 'name', styles: 'color' } ); // Tests attribute and style.
|
|
86
|
+
* viewConsumable.test( p, { classes: [ 'baz', 'bar' ] } ); // Multiple consumables can be tested.
|
|
87
|
+
* viewConsumable.test( textNode ); // Tests text node.
|
|
88
|
+
* viewConsumable.test( docFragment ); // Tests document fragment.
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* Testing classes and styles as attribute will test if all added classes/styles can be consumed.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* viewConsumable.test( p, { attributes: 'class' } ); // Tests if all added classes can be consumed.
|
|
95
|
+
* viewConsumable.test( p, { attributes: 'style' } ); // Tests if all added styles can be consumed.
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param consumables Used only if first parameter is {@link module:engine/view/element~ViewElement view element} instance.
|
|
99
|
+
* @param consumables.name If set to true element's name will be included.
|
|
100
|
+
* @param consumables.attributes Attribute name or array of attribute names.
|
|
101
|
+
* @param consumables.classes Class name or array of class names.
|
|
102
|
+
* @param consumables.styles Style name or array of style names.
|
|
103
|
+
* @returns Returns `true` when all items included in method's call can be consumed. Returns `false`
|
|
104
|
+
* when first already consumed item is found and `null` when first non-consumable item is found.
|
|
105
|
+
*/
|
|
106
|
+
test(element: ViewNode | ViewDocumentFragment, consumables?: Consumables | Match): boolean | null;
|
|
107
|
+
/**
|
|
108
|
+
* Consumes {@link module:engine/view/element~ViewElement view element}, {@link module:engine/view/text~ViewText text node} or
|
|
109
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}.
|
|
110
|
+
* It returns `true` when all items included in method's call can be consumed, otherwise returns `false`.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* viewConsumable.consume( p, { name: true } ); // Consumes element's name.
|
|
114
|
+
* viewConsumable.consume( p, { attributes: 'name' } ); // Consumes element's attribute.
|
|
115
|
+
* viewConsumable.consume( p, { classes: 'foobar' } ); // Consumes element's class.
|
|
116
|
+
* viewConsumable.consume( p, { styles: 'color' } ); // Consumes element's style.
|
|
117
|
+
* viewConsumable.consume( p, { attributes: 'name', styles: 'color' } ); // Consumes attribute and style.
|
|
118
|
+
* viewConsumable.consume( p, { classes: [ 'baz', 'bar' ] } ); // Multiple consumables can be consumed.
|
|
119
|
+
* viewConsumable.consume( textNode ); // Consumes text node.
|
|
120
|
+
* viewConsumable.consume( docFragment ); // Consumes document fragment.
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* Consuming classes and styles as attribute will test if all added classes/styles can be consumed.
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* viewConsumable.consume( p, { attributes: 'class' } ); // Consume only if all added classes can be consumed.
|
|
127
|
+
* viewConsumable.consume( p, { attributes: 'style' } ); // Consume only if all added styles can be consumed.
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @param consumables Used only if first parameter is {@link module:engine/view/element~ViewElement view element} instance.
|
|
131
|
+
* @param consumables.name If set to true element's name will be included.
|
|
132
|
+
* @param consumables.attributes Attribute name or array of attribute names.
|
|
133
|
+
* @param consumables.classes Class name or array of class names.
|
|
134
|
+
* @param consumables.styles Style name or array of style names.
|
|
135
|
+
* @returns Returns `true` when all items included in method's call can be consumed,
|
|
136
|
+
* otherwise returns `false`.
|
|
137
|
+
*/
|
|
138
|
+
consume(element: ViewNode | ViewDocumentFragment, consumables?: Consumables | Match): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Reverts {@link module:engine/view/element~ViewElement view element}, {@link module:engine/view/text~ViewText text node} or
|
|
141
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment} so they can be consumed once again.
|
|
142
|
+
* Method does not revert items that were never previously added for consumption, even if they are included in
|
|
143
|
+
* method's call.
|
|
144
|
+
*
|
|
145
|
+
* ```ts
|
|
146
|
+
* viewConsumable.revert( p, { name: true } ); // Reverts element's name.
|
|
147
|
+
* viewConsumable.revert( p, { attributes: 'name' } ); // Reverts element's attribute.
|
|
148
|
+
* viewConsumable.revert( p, { classes: 'foobar' } ); // Reverts element's class.
|
|
149
|
+
* viewConsumable.revert( p, { styles: 'color' } ); // Reverts element's style.
|
|
150
|
+
* viewConsumable.revert( p, { attributes: 'name', styles: 'color' } ); // Reverts attribute and style.
|
|
151
|
+
* viewConsumable.revert( p, { classes: [ 'baz', 'bar' ] } ); // Multiple names can be reverted.
|
|
152
|
+
* viewConsumable.revert( textNode ); // Reverts text node.
|
|
153
|
+
* viewConsumable.revert( docFragment ); // Reverts document fragment.
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* Reverting classes and styles as attribute will revert all classes/styles that were previously added for
|
|
157
|
+
* consumption.
|
|
158
|
+
*
|
|
159
|
+
* ```ts
|
|
160
|
+
* viewConsumable.revert( p, { attributes: 'class' } ); // Reverts all classes added for consumption.
|
|
161
|
+
* viewConsumable.revert( p, { attributes: 'style' } ); // Reverts all styles added for consumption.
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @param consumables Used only if first parameter is {@link module:engine/view/element~ViewElement view element} instance.
|
|
165
|
+
* @param consumables.name If set to true element's name will be included.
|
|
166
|
+
* @param consumables.attributes Attribute name or array of attribute names.
|
|
167
|
+
* @param consumables.classes Class name or array of class names.
|
|
168
|
+
* @param consumables.styles Style name or array of style names.
|
|
169
|
+
*/
|
|
170
|
+
revert(element: ViewNode, consumables: Consumables | Match): void;
|
|
171
|
+
/**
|
|
172
|
+
* Creates {@link module:engine/conversion/viewconsumable~ViewConsumable ViewConsumable} instance from
|
|
173
|
+
* {@link module:engine/view/node~ViewNode node} or {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}.
|
|
174
|
+
* Instance will contain all elements, child nodes, attributes, styles and classes added for consumption.
|
|
175
|
+
*
|
|
176
|
+
* @param from View node or document fragment from which `ViewConsumable` will be created.
|
|
177
|
+
* @param instance If provided, given `ViewConsumable` instance will be used
|
|
178
|
+
* to add all consumables. It will be returned instead of a new instance.
|
|
179
|
+
*/
|
|
180
|
+
static createFrom(from: ViewNode | ViewDocumentFragment, instance?: ViewConsumable): ViewConsumable;
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
183
|
+
* Object describing all features of a view element that could be consumed and converted individually.
|
|
184
|
+
* This is a non-normalized form of {@link module:engine/view/element~ViewNormalizedConsumables} generated from the view Element.
|
|
185
|
+
*
|
|
186
|
+
* Example element:
|
|
187
|
+
*
|
|
188
|
+
* ```html
|
|
189
|
+
* <a class="foo bar" style="color: red; margin: 5px" href="https://ckeditor.com" rel="nofollow noreferrer" target="_blank">
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* The `Consumables` would include:
|
|
193
|
+
*
|
|
194
|
+
* ```json
|
|
195
|
+
* {
|
|
196
|
+
* name: true,
|
|
197
|
+
* classes: [ "foo", "bar" ],
|
|
198
|
+
* styles: [ "color", "margin" ]
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* You could convert a `Consumable` into a {@link module:engine/view/element~ViewNormalizedConsumables}
|
|
203
|
+
* using the {@link module:engine/conversion/viewconsumable~normalizeConsumables} helper.
|
|
204
|
+
*/
|
|
205
205
|
export interface Consumables {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
206
|
+
/**
|
|
207
|
+
* If set to `true` element's name will be included in a consumable.
|
|
208
|
+
* Depending on the usage context it would be added as consumable, tested for being available for consume or consumed.
|
|
209
|
+
*/
|
|
210
|
+
name?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Attribute name or array of attribute names.
|
|
213
|
+
*/
|
|
214
|
+
attributes?: string | Array<string>;
|
|
215
|
+
/**
|
|
216
|
+
* Class name or array of class names.
|
|
217
|
+
*/
|
|
218
|
+
classes?: string | Array<string>;
|
|
219
|
+
/**
|
|
220
|
+
* Style name or array of style names.
|
|
221
|
+
*/
|
|
222
|
+
styles?: string | Array<string>;
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
225
|
+
* This is a private helper-class for {@link module:engine/conversion/viewconsumable~ViewConsumable}.
|
|
226
|
+
* It represents and manipulates consumable parts of a single {@link module:engine/view/element~ViewElement}.
|
|
227
|
+
*
|
|
228
|
+
* @internal
|
|
229
|
+
*/
|
|
230
230
|
export declare class ViewElementConsumables {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
231
|
+
readonly element: ViewElement;
|
|
232
|
+
/**
|
|
233
|
+
* Flag indicating if name of the element can be consumed.
|
|
234
|
+
*/
|
|
235
|
+
private _canConsumeName;
|
|
236
|
+
/**
|
|
237
|
+
* A map of element's consumables.
|
|
238
|
+
* * For plain attributes the value is a boolean indicating whether the attribute is available to consume.
|
|
239
|
+
* * For token based attributes (like class list and style) the value is a map of tokens to booleans
|
|
240
|
+
* indicating whether the token is available to consume on the given attribute.
|
|
241
|
+
*/
|
|
242
|
+
private readonly _attributes;
|
|
243
|
+
/**
|
|
244
|
+
* Creates ViewElementConsumables instance.
|
|
245
|
+
*
|
|
246
|
+
* @param from View element from which `ViewElementConsumables` is being created.
|
|
247
|
+
*/
|
|
248
|
+
constructor(from: ViewElement);
|
|
249
|
+
/**
|
|
250
|
+
* Adds consumable parts of the {@link module:engine/view/element~ViewElement view element}.
|
|
251
|
+
* Element's name itself can be marked to be consumed (when element's name is consumed its attributes, classes and
|
|
252
|
+
* styles still could be consumed):
|
|
253
|
+
*
|
|
254
|
+
* ```ts
|
|
255
|
+
* consumables.add( { name: true } );
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* Attributes classes and styles:
|
|
259
|
+
*
|
|
260
|
+
* ```ts
|
|
261
|
+
* consumables.add( { attributes: [ [ 'title' ], [ 'class', 'foo' ], [ 'style', 'color'] ] } );
|
|
262
|
+
* consumables.add( { attributes: [ [ 'title' ], [ 'name' ], [ 'class', 'foo' ], [ 'class', 'bar' ] ] } );
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* Note: This method accepts only {@link module:engine/view/element~ViewNormalizedConsumables}.
|
|
266
|
+
* You can use {@link module:engine/conversion/viewconsumable~normalizeConsumables} helper to convert from
|
|
267
|
+
* {@link module:engine/conversion/viewconsumable~Consumables} to `ViewNormalizedConsumables`.
|
|
268
|
+
*
|
|
269
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `viewconsumable-invalid-attribute` when `class` or `style`
|
|
270
|
+
* attribute is provided - it should be handled separately by providing `style` and `class` in consumables object.
|
|
271
|
+
*
|
|
272
|
+
* @param consumables Object describing which parts of the element can be consumed.
|
|
273
|
+
*/
|
|
274
|
+
add(consumables: ViewNormalizedConsumables): void;
|
|
275
|
+
/**
|
|
276
|
+
* Tests if parts of the {@link module:engine/view/element~ViewElement view element} can be consumed.
|
|
277
|
+
*
|
|
278
|
+
* Element's name can be tested:
|
|
279
|
+
*
|
|
280
|
+
* ```ts
|
|
281
|
+
* consumables.test( { name: true } );
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* Attributes classes and styles:
|
|
285
|
+
*
|
|
286
|
+
* ```ts
|
|
287
|
+
* consumables.test( { attributes: [ [ 'title' ], [ 'class', 'foo' ], [ 'style', 'color' ] ] } );
|
|
288
|
+
* consumables.test( { attributes: [ [ 'title' ], [ 'name' ], [ 'class', 'foo' ], [ 'class', 'bar' ] ] } );
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @param consumables Object describing which parts of the element should be tested.
|
|
292
|
+
* @returns `true` when all tested items can be consumed, `null` when even one of the items
|
|
293
|
+
* was never marked for consumption and `false` when even one of the items was already consumed.
|
|
294
|
+
*/
|
|
295
|
+
test(consumables: ViewNormalizedConsumables): boolean | null;
|
|
296
|
+
/**
|
|
297
|
+
* Tests if parts of the {@link module:engine/view/element~ViewElement view element} can be consumed and consumes them if available.
|
|
298
|
+
* It returns `true` when all items included in method's call can be consumed, otherwise returns `false`.
|
|
299
|
+
*
|
|
300
|
+
* Element's name can be consumed:
|
|
301
|
+
*
|
|
302
|
+
* ```ts
|
|
303
|
+
* consumables.consume( { name: true } );
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* Attributes classes and styles:
|
|
307
|
+
*
|
|
308
|
+
* ```ts
|
|
309
|
+
* consumables.consume( { attributes: [ [ 'title' ], [ 'class', 'foo' ], [ 'style', 'color' ] ] } );
|
|
310
|
+
* consumables.consume( { attributes: [ [ 'title' ], [ 'name' ], [ 'class', 'foo' ], [ 'class', 'bar' ] ] } );
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* @param consumables Object describing which parts of the element should be consumed.
|
|
314
|
+
* @returns `true` when all tested items can be consumed and `false` when even one of the items could not be consumed.
|
|
315
|
+
*/
|
|
316
|
+
consume(consumables: ViewNormalizedConsumables): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Revert already consumed parts of {@link module:engine/view/element~ViewElement view Element}, so they can be consumed once again.
|
|
319
|
+
* Element's name can be reverted:
|
|
320
|
+
*
|
|
321
|
+
* ```ts
|
|
322
|
+
* consumables.revert( { name: true } );
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* Attributes classes and styles:
|
|
326
|
+
*
|
|
327
|
+
* ```ts
|
|
328
|
+
* consumables.revert( { attributes: [ [ 'title' ], [ 'class', 'foo' ], [ 'style', 'color' ] ] } );
|
|
329
|
+
* consumables.revert( { attributes: [ [ 'title' ], [ 'name' ], [ 'class', 'foo' ], [ 'class', 'bar' ] ] } );
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @param consumables Object describing which parts of the element should be reverted.
|
|
333
|
+
*/
|
|
334
|
+
revert(consumables: ViewNormalizedConsumables): void;
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
* Normalizes a {@link module:engine/conversion/viewconsumable~Consumables} or {@link module:engine/view/matcher~Match}
|
|
338
|
+
* to a {@link module:engine/view/element~ViewNormalizedConsumables}.
|
|
339
|
+
*
|
|
340
|
+
* @internal
|
|
341
|
+
*/
|
|
342
342
|
export declare function normalizeConsumables(consumables: Consumables | Match): ViewNormalizedConsumables;
|