@ckeditor/ckeditor5-engine 48.2.0-alpha.7 → 48.3.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/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
package/dist/view/matcher.d.ts
CHANGED
|
@@ -1,513 +1,438 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { type ViewElement } from
|
|
9
|
-
import { type Consumables } from
|
|
6
|
+
* @module engine/view/matcher
|
|
7
|
+
*/
|
|
8
|
+
import { type ViewElement } from "./element.js";
|
|
9
|
+
import { type Consumables } from "../conversion/viewconsumable.js";
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
* View matcher class.
|
|
12
|
+
* Instance of this class can be used to find {@link module:engine/view/element~ViewElement elements} that match given pattern.
|
|
13
|
+
*/
|
|
14
14
|
export declare class Matcher {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
15
|
+
private readonly _patterns;
|
|
16
|
+
/**
|
|
17
|
+
* Creates new instance of Matcher.
|
|
18
|
+
*
|
|
19
|
+
* @param pattern Match patterns. See {@link module:engine/view/matcher~Matcher#add add method} for more information.
|
|
20
|
+
*/
|
|
21
|
+
constructor(...pattern: Array<MatcherPattern>);
|
|
22
|
+
/**
|
|
23
|
+
* Adds pattern or patterns to matcher instance.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* // String.
|
|
27
|
+
* matcher.add( 'div' );
|
|
28
|
+
*
|
|
29
|
+
* // Regular expression.
|
|
30
|
+
* matcher.add( /^\w/ );
|
|
31
|
+
*
|
|
32
|
+
* // Single class.
|
|
33
|
+
* matcher.add( {
|
|
34
|
+
* classes: 'foobar'
|
|
35
|
+
* } );
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* See {@link module:engine/view/matcher~MatcherPattern} for more examples.
|
|
39
|
+
*
|
|
40
|
+
* Multiple patterns can be added in one call:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* matcher.add( 'div', { classes: 'foobar' } );
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param pattern Object describing pattern details. If string or regular expression
|
|
47
|
+
* is provided it will be used to match element's name. Pattern can be also provided in a form
|
|
48
|
+
* of a function - then this function will be called with each {@link module:engine/view/element~ViewElement element} as a parameter.
|
|
49
|
+
* Function's return value will be stored under `match` key of the object returned from
|
|
50
|
+
* {@link module:engine/view/matcher~Matcher#match match} or {@link module:engine/view/matcher~Matcher#matchAll matchAll} methods.
|
|
51
|
+
*/
|
|
52
|
+
add(...pattern: Array<MatcherPattern>): void;
|
|
53
|
+
/**
|
|
54
|
+
* Matches elements for currently stored patterns. Returns match information about first found
|
|
55
|
+
* {@link module:engine/view/element~ViewElement element}, otherwise returns `null`.
|
|
56
|
+
*
|
|
57
|
+
* Example of returned object:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* {
|
|
61
|
+
* element: <instance of found element>,
|
|
62
|
+
* pattern: <pattern used to match found element>,
|
|
63
|
+
* match: {
|
|
64
|
+
* name: true,
|
|
65
|
+
* attributes: [
|
|
66
|
+
* [ 'title' ],
|
|
67
|
+
* [ 'href' ],
|
|
68
|
+
* [ 'class', 'foo' ],
|
|
69
|
+
* [ 'style', 'color' ],
|
|
70
|
+
* [ 'style', 'position' ]
|
|
71
|
+
* ]
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* You could use the `match` field from the above returned object as an input for the
|
|
77
|
+
* {@link module:engine/conversion/viewconsumable~ViewConsumable#test `ViewConsumable#test()`} and
|
|
78
|
+
* {@link module:engine/conversion/viewconsumable~ViewConsumable#consume `ViewConsumable#consume()`} methods.
|
|
79
|
+
*
|
|
80
|
+
* @see module:engine/view/matcher~Matcher#add
|
|
81
|
+
* @see module:engine/view/matcher~Matcher#matchAll
|
|
82
|
+
* @param element View element to match against stored patterns.
|
|
83
|
+
* @returns The match information about found element or `null`.
|
|
84
|
+
*/
|
|
85
|
+
match(...element: Array<ViewElement>): MatchResult | null;
|
|
86
|
+
/**
|
|
87
|
+
* Matches elements for currently stored patterns. Returns array of match information with all found
|
|
88
|
+
* {@link module:engine/view/element~ViewElement elements}. If no element is found - returns `null`.
|
|
89
|
+
*
|
|
90
|
+
* @see module:engine/view/matcher~Matcher#add
|
|
91
|
+
* @see module:engine/view/matcher~Matcher#match
|
|
92
|
+
* @param element View element to match against stored patterns.
|
|
93
|
+
* @returns Array with match information about found elements or `null`. For more information
|
|
94
|
+
* see {@link module:engine/view/matcher~Matcher#match match method} description.
|
|
95
|
+
*/
|
|
96
|
+
matchAll(...element: Array<ViewElement>): Array<MatchResult> | null;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the name of the element to match if there is exactly one pattern added to the matcher instance
|
|
99
|
+
* and it matches element name defined by `string` (not `RegExp`). Otherwise, returns `null`.
|
|
100
|
+
*
|
|
101
|
+
* @returns Element name trying to match.
|
|
102
|
+
*/
|
|
103
|
+
getElementName(): string | null;
|
|
104
|
+
/**
|
|
105
|
+
* Returns match information if {@link module:engine/view/element~ViewElement element} is matching provided pattern.
|
|
106
|
+
* If element cannot be matched to provided pattern - returns `null`.
|
|
107
|
+
*
|
|
108
|
+
* @returns Returns object with match information or null if element is not matching.
|
|
109
|
+
*/
|
|
110
|
+
private _isElementMatching;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
* Returns true if the given `item` matches the pattern.
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
* @param pattern A pattern representing a key/value we want to match.
|
|
117
|
+
* @param item An actual item key/value (e.g. `'src'`, `'background-color'`, `'ck-widget'`) we're testing against pattern.
|
|
118
|
+
*/
|
|
119
119
|
export declare function isPatternMatched(pattern: true | string | RegExp, item: string): unknown;
|
|
120
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
121
|
+
* An entity that is a valid pattern recognized by a matcher. `MatcherPattern` is used by {@link ~Matcher} to recognize
|
|
122
|
+
* if a view element fits in a group of view elements described by the pattern.
|
|
123
|
+
*
|
|
124
|
+
* `MatcherPattern` can be given as a `String`, a `RegExp`, an `Object` or a `Function`.
|
|
125
|
+
*
|
|
126
|
+
* If `MatcherPattern` is given as a `String` or `RegExp`, it will match any view element that has a matching name:
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* // Match any element with name equal to 'div'.
|
|
130
|
+
* const pattern = 'div';
|
|
131
|
+
*
|
|
132
|
+
* // Match any element which name starts on 'p'.
|
|
133
|
+
* const pattern = /^p/;
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* If `MatcherPattern` is given as an `Object`, all the object's properties will be matched with view element properties.
|
|
137
|
+
* If the view element does not meet all of the object's pattern properties, the match will not happen.
|
|
138
|
+
* Available `Object` matching properties:
|
|
139
|
+
*
|
|
140
|
+
* Matching view element:
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* // Match view element's name using String:
|
|
144
|
+
* const pattern = { name: 'p' };
|
|
145
|
+
*
|
|
146
|
+
* // or by providing RegExp:
|
|
147
|
+
* const pattern = { name: /^(ul|ol)$/ };
|
|
148
|
+
*
|
|
149
|
+
* // The name can also be skipped to match any view element with matching attributes:
|
|
150
|
+
* const pattern = {
|
|
151
|
+
* attributes: {
|
|
152
|
+
* 'title': true
|
|
153
|
+
* }
|
|
154
|
+
* };
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* Matching view element attributes:
|
|
158
|
+
*
|
|
159
|
+
* ```ts
|
|
160
|
+
* // Match view element with any attribute value.
|
|
161
|
+
* const pattern = {
|
|
162
|
+
* name: 'p',
|
|
163
|
+
* attributes: true
|
|
164
|
+
* };
|
|
165
|
+
*
|
|
166
|
+
* // Match view element which has matching attributes (String).
|
|
167
|
+
* const pattern = {
|
|
168
|
+
* name: 'figure',
|
|
169
|
+
* attributes: 'title' // Match title attribute (can be empty).
|
|
170
|
+
* };
|
|
171
|
+
*
|
|
172
|
+
* // Match view element which has matching attributes (RegExp).
|
|
173
|
+
* const pattern = {
|
|
174
|
+
* name: 'figure',
|
|
175
|
+
* attributes: /^data-.*$/ // Match attributes starting with `data-` e.g. `data-foo` with any value (can be empty).
|
|
176
|
+
* };
|
|
177
|
+
*
|
|
178
|
+
* // Match view element which has matching attributes (Object).
|
|
179
|
+
* const pattern = {
|
|
180
|
+
* name: 'figure',
|
|
181
|
+
* attributes: {
|
|
182
|
+
* title: 'foobar', // Match `title` attribute with 'foobar' value.
|
|
183
|
+
* alt: true, // Match `alt` attribute with any value (can be empty).
|
|
184
|
+
* 'data-type': /^(jpg|png)$/ // Match `data-type` attribute with `jpg` or `png` value.
|
|
185
|
+
* }
|
|
186
|
+
* };
|
|
187
|
+
*
|
|
188
|
+
* // Match view element which has matching attributes (Array).
|
|
189
|
+
* const pattern = {
|
|
190
|
+
* name: 'figure',
|
|
191
|
+
* attributes: [
|
|
192
|
+
* 'title', // Match `title` attribute (can be empty).
|
|
193
|
+
* /^data-*$/ // Match attributes starting with `data-` e.g. `data-foo` with any value (can be empty).
|
|
194
|
+
* ]
|
|
195
|
+
* };
|
|
196
|
+
*
|
|
197
|
+
* // Match view element which has matching attributes (key-value pairs).
|
|
198
|
+
* const pattern = {
|
|
199
|
+
* name: 'input',
|
|
200
|
+
* attributes: [
|
|
201
|
+
* {
|
|
202
|
+
* key: 'type', // Match `type` as an attribute key.
|
|
203
|
+
* value: /^(text|number|date)$/ // Match `text`, `number` or `date` values.
|
|
204
|
+
* },
|
|
205
|
+
* {
|
|
206
|
+
* key: /^data-.*$/, // Match attributes starting with `data-` e.g. `data-foo`.
|
|
207
|
+
* value: true // Match any value (can be empty).
|
|
208
|
+
* }
|
|
209
|
+
* ]
|
|
210
|
+
* };
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* Matching view element styles:
|
|
214
|
+
*
|
|
215
|
+
* ```ts
|
|
216
|
+
* // Match view element with any style.
|
|
217
|
+
* const pattern = {
|
|
218
|
+
* name: 'p',
|
|
219
|
+
* styles: true
|
|
220
|
+
* };
|
|
221
|
+
*
|
|
222
|
+
* // Match view element which has matching styles (String).
|
|
223
|
+
* const pattern = {
|
|
224
|
+
* name: 'p',
|
|
225
|
+
* styles: 'color' // Match attributes with `color` style.
|
|
226
|
+
* };
|
|
227
|
+
*
|
|
228
|
+
* // Match view element which has matching styles (RegExp).
|
|
229
|
+
* const pattern = {
|
|
230
|
+
* name: 'p',
|
|
231
|
+
* styles: /^border.*$/ // Match view element with any border style.
|
|
232
|
+
* };
|
|
233
|
+
*
|
|
234
|
+
* // Match view element which has matching styles (Object).
|
|
235
|
+
* const pattern = {
|
|
236
|
+
* name: 'p',
|
|
237
|
+
* styles: {
|
|
238
|
+
* color: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/, // Match `color` in RGB format only.
|
|
239
|
+
* 'font-weight': 600, // Match `font-weight` only if it's `600`.
|
|
240
|
+
* 'text-decoration': true // Match any text decoration.
|
|
241
|
+
* }
|
|
242
|
+
* };
|
|
243
|
+
*
|
|
244
|
+
* // Match view element which has matching styles (Array).
|
|
245
|
+
* const pattern = {
|
|
246
|
+
* name: 'p',
|
|
247
|
+
* styles: [
|
|
248
|
+
* 'color', // Match `color` with any value.
|
|
249
|
+
* /^border.*$/ // Match all border properties.
|
|
250
|
+
* ]
|
|
251
|
+
* };
|
|
252
|
+
*
|
|
253
|
+
* // Match view element which has matching styles (key-value pairs).
|
|
254
|
+
* const pattern = {
|
|
255
|
+
* name: 'p',
|
|
256
|
+
* styles: [
|
|
257
|
+
* {
|
|
258
|
+
* key: 'color', // Match `color` as an property key.
|
|
259
|
+
* value: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/ // Match RGB format only.
|
|
260
|
+
* },
|
|
261
|
+
* {
|
|
262
|
+
* key: /^border.*$/, // Match any border style.
|
|
263
|
+
* value: true // Match any value.
|
|
264
|
+
* }
|
|
265
|
+
* ]
|
|
266
|
+
* };
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* Matching view element classes:
|
|
270
|
+
*
|
|
271
|
+
* ```ts
|
|
272
|
+
* // Match view element with any class.
|
|
273
|
+
* const pattern = {
|
|
274
|
+
* name: 'p',
|
|
275
|
+
* classes: true
|
|
276
|
+
* };
|
|
277
|
+
*
|
|
278
|
+
* // Match view element which has matching class (String).
|
|
279
|
+
* const pattern = {
|
|
280
|
+
* name: 'p',
|
|
281
|
+
* classes: 'highlighted' // Match `highlighted` class.
|
|
282
|
+
* };
|
|
283
|
+
*
|
|
284
|
+
* // Match view element which has matching classes (RegExp).
|
|
285
|
+
* const pattern = {
|
|
286
|
+
* name: 'figure',
|
|
287
|
+
* classes: /^image-side-(left|right)$/ // Match `image-side-left` or `image-side-right` class.
|
|
288
|
+
* };
|
|
289
|
+
*
|
|
290
|
+
* // Match view element which has matching classes (Object).
|
|
291
|
+
* const pattern = {
|
|
292
|
+
* name: 'p',
|
|
293
|
+
* classes: {
|
|
294
|
+
* highlighted: true, // Match `highlighted` class.
|
|
295
|
+
* marker: true // Match `marker` class.
|
|
296
|
+
* }
|
|
297
|
+
* };
|
|
298
|
+
*
|
|
299
|
+
* // Match view element which has matching classes (Array).
|
|
300
|
+
* const pattern = {
|
|
301
|
+
* name: 'figure',
|
|
302
|
+
* classes: [
|
|
303
|
+
* 'image', // Match `image` class.
|
|
304
|
+
* /^image-side-(left|right)$/ // Match `image-side-left` or `image-side-right` class.
|
|
305
|
+
* ]
|
|
306
|
+
* };
|
|
307
|
+
*
|
|
308
|
+
* // Match view element which has matching classes (key-value pairs).
|
|
309
|
+
* const pattern = {
|
|
310
|
+
* name: 'figure',
|
|
311
|
+
* classes: [
|
|
312
|
+
* {
|
|
313
|
+
* key: 'image', // Match `image` class.
|
|
314
|
+
* value: true
|
|
315
|
+
* },
|
|
316
|
+
* {
|
|
317
|
+
* key: /^image-side-(left|right)$/, // Match `image-side-left` or `image-side-right` class.
|
|
318
|
+
* value: true
|
|
319
|
+
* }
|
|
320
|
+
* ]
|
|
321
|
+
* };
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* Pattern can combine multiple properties allowing for more complex view element matching:
|
|
325
|
+
*
|
|
326
|
+
* ```ts
|
|
327
|
+
* const pattern = {
|
|
328
|
+
* name: 'span',
|
|
329
|
+
* attributes: [ 'title' ],
|
|
330
|
+
* styles: {
|
|
331
|
+
* 'font-weight': 'bold'
|
|
332
|
+
* },
|
|
333
|
+
* classes: 'highlighted'
|
|
334
|
+
* };
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* If `MatcherPattern` is given as a `Function`, the function takes a view element as a first and only parameter and
|
|
338
|
+
* the function should decide whether that element matches. If so, it should return what part of the view element has been matched.
|
|
339
|
+
* Otherwise, the function should return `null`. The returned result will be included in `match` property of the object
|
|
340
|
+
* returned by {@link ~Matcher#match} call.
|
|
341
|
+
*
|
|
342
|
+
* ```ts
|
|
343
|
+
* // Match an empty <div> element.
|
|
344
|
+
* const pattern = element => {
|
|
345
|
+
* if ( element.name == 'div' && element.childCount > 0 ) {
|
|
346
|
+
* // Return which part of the element was matched.
|
|
347
|
+
* return { name: true };
|
|
348
|
+
* }
|
|
349
|
+
*
|
|
350
|
+
* return null;
|
|
351
|
+
* };
|
|
352
|
+
*
|
|
353
|
+
* // Match a <p> element with big font ("heading-like" element).
|
|
354
|
+
* const pattern = element => {
|
|
355
|
+
* if ( element.name == 'p' ) {
|
|
356
|
+
* const fontSize = element.getStyle( 'font-size' );
|
|
357
|
+
* const size = fontSize.match( /(\d+)/px );
|
|
358
|
+
*
|
|
359
|
+
* if ( size && Number( size[ 1 ] ) > 26 ) {
|
|
360
|
+
* return { name: true, styles: [ 'font-size' ] };
|
|
361
|
+
* }
|
|
362
|
+
* }
|
|
363
|
+
*
|
|
364
|
+
* return null;
|
|
365
|
+
* };
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* `MatcherPattern` is defined in a way that it is a superset of {@link module:engine/view/elementdefinition~ViewElementDefinition},
|
|
369
|
+
* that is, every `ElementDefinition` also can be used as a `MatcherPattern`.
|
|
370
|
+
*/
|
|
371
371
|
export type MatcherPattern = string | RegExp | MatcherFunctionPattern | MatcherObjectPattern;
|
|
372
372
|
/**
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
* A function describing `MatcherPattern`. See {@link ~MatcherPattern} for examples and other options.
|
|
374
|
+
*/
|
|
375
375
|
export type MatcherFunctionPattern = (element: ViewElement) => Match | Consumables | null;
|
|
376
376
|
/**
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
* An object describing `MatcherPattern`. See {@link ~MatcherPattern} for examples and other options.
|
|
378
|
+
*/
|
|
379
379
|
export interface MatcherObjectPattern {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
380
|
+
/**
|
|
381
|
+
* View element name to match.
|
|
382
|
+
*/
|
|
383
|
+
name?: string | RegExp;
|
|
384
|
+
/**
|
|
385
|
+
* View element's classes to match.
|
|
386
|
+
*/
|
|
387
|
+
classes?: MatchClassPatterns;
|
|
388
|
+
/**
|
|
389
|
+
* View element's styles to match.
|
|
390
|
+
*/
|
|
391
|
+
styles?: MatchStylePatterns;
|
|
392
|
+
/**
|
|
393
|
+
* View element's attributes to match.
|
|
394
|
+
*/
|
|
395
|
+
attributes?: MatchAttributePatterns;
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
* An object representing matched element parts.
|
|
399
|
+
*/
|
|
400
400
|
export interface Match {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
401
|
+
/**
|
|
402
|
+
* True if name of the element was matched.
|
|
403
|
+
*/
|
|
404
|
+
name?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Array of matching tuples: attribute name, and optional token for tokenized attributes.
|
|
407
|
+
* Note that there could be multiple entries for the same attribute with different tokens (class names or style properties).
|
|
408
|
+
*/
|
|
409
|
+
attributes?: Array<[string, string?]>;
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
|
-
|
|
413
|
-
|
|
412
|
+
* The result of {@link ~Matcher#match}.
|
|
413
|
+
*/
|
|
414
414
|
export interface MatchResult {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
415
|
+
/**
|
|
416
|
+
* Matched view element.
|
|
417
|
+
*/
|
|
418
|
+
element: ViewElement;
|
|
419
|
+
/**
|
|
420
|
+
* Pattern that was used to find matched element.
|
|
421
|
+
*/
|
|
422
|
+
pattern: MatcherFunctionPattern | MatcherObjectPattern;
|
|
423
|
+
/**
|
|
424
|
+
* An object representing matched element parts.
|
|
425
|
+
*/
|
|
426
|
+
match: Match;
|
|
427
427
|
}
|
|
428
428
|
export type MatchPropertyPatterns<ValuePattern = string | RegExp> = true | string | RegExp | Record<string, true | ValuePattern> | Array<string | RegExp | {
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
key: string | RegExp;
|
|
430
|
+
value: true | ValuePattern;
|
|
431
431
|
}>;
|
|
432
432
|
export type MatchAttributePatterns = MatchPropertyPatterns;
|
|
433
433
|
export type MatchStylePatterns = MatchPropertyPatterns;
|
|
434
434
|
export type MatchClassPatterns = MatchPropertyPatterns<never>;
|
|
435
435
|
/**
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
export type NormalizedPropertyPattern = [
|
|
439
|
-
true | string | RegExp,
|
|
440
|
-
true | string | RegExp,
|
|
441
|
-
(true | string | RegExp)?
|
|
442
|
-
];
|
|
443
|
-
/**
|
|
444
|
-
* The key-value matcher pattern is missing key or value. Both must be present.
|
|
445
|
-
* Refer the documentation: {@link module:engine/view/matcher~MatcherPattern}.
|
|
446
|
-
*
|
|
447
|
-
* @param pattern Pattern with missing properties.
|
|
448
|
-
* @error matcher-pattern-missing-key-or-value
|
|
449
|
-
*/
|
|
450
|
-
/**
|
|
451
|
-
* The key-value matcher pattern for `attributes` option is using deprecated `style` key.
|
|
452
|
-
*
|
|
453
|
-
* Use `styles` matcher pattern option instead:
|
|
454
|
-
*
|
|
455
|
-
* ```ts
|
|
456
|
-
* // Instead of:
|
|
457
|
-
* const pattern = {
|
|
458
|
-
* attributes: {
|
|
459
|
-
* key1: 'value1',
|
|
460
|
-
* key2: 'value2',
|
|
461
|
-
* style: /^border.*$/
|
|
462
|
-
* }
|
|
463
|
-
* }
|
|
464
|
-
*
|
|
465
|
-
* // Use:
|
|
466
|
-
* const pattern = {
|
|
467
|
-
* attributes: {
|
|
468
|
-
* key1: 'value1',
|
|
469
|
-
* key2: 'value2'
|
|
470
|
-
* },
|
|
471
|
-
* styles: /^border.*$/
|
|
472
|
-
* }
|
|
473
|
-
* ```
|
|
474
|
-
*
|
|
475
|
-
* Refer to the `#update-to-ckeditor-5-v2910` section in the `Update to v29.x` section in the
|
|
476
|
-
* {@glink updating/guides/updating-from-older-versions updating from older versions} guide
|
|
477
|
-
* and {@link module:engine/view/matcher~MatcherPattern} documentation.
|
|
478
|
-
*
|
|
479
|
-
* @param pattern Pattern with missing properties.
|
|
480
|
-
* @error matcher-pattern-deprecated-attributes-style-key
|
|
481
|
-
*/
|
|
482
|
-
/**
|
|
483
|
-
* The key-value matcher pattern for `attributes` option is using deprecated `class` key.
|
|
484
|
-
*
|
|
485
|
-
* Use `classes` matcher pattern option instead:
|
|
486
|
-
*
|
|
487
|
-
* ```ts
|
|
488
|
-
* // Instead of:
|
|
489
|
-
* const pattern = {
|
|
490
|
-
* attributes: {
|
|
491
|
-
* key1: 'value1',
|
|
492
|
-
* key2: 'value2',
|
|
493
|
-
* class: 'foobar'
|
|
494
|
-
* }
|
|
495
|
-
* }
|
|
496
|
-
*
|
|
497
|
-
* // Use:
|
|
498
|
-
* const pattern = {
|
|
499
|
-
* attributes: {
|
|
500
|
-
* key1: 'value1',
|
|
501
|
-
* key2: 'value2'
|
|
502
|
-
* },
|
|
503
|
-
* classes: 'foobar'
|
|
504
|
-
* }
|
|
505
|
-
* ```
|
|
506
|
-
*
|
|
507
|
-
* Refer to the `#update-to-ckeditor-5-v2910` paragraph in the Update to v29.x guide in the
|
|
508
|
-
* {@glink updating/guides/updating-from-older-versions updating from older versions} guide
|
|
509
|
-
* and the {@link module:engine/view/matcher~MatcherPattern} documentation.
|
|
510
|
-
*
|
|
511
|
-
* @param pattern Pattern with missing properties.
|
|
512
|
-
* @error matcher-pattern-deprecated-attributes-class-key
|
|
513
|
-
*/
|
|
436
|
+
* @internal
|
|
437
|
+
*/
|
|
438
|
+
export type NormalizedPropertyPattern = [true | string | RegExp, true | string | RegExp, (true | string | RegExp)?];
|