@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
package/dist/view/stylesmap.d.ts
CHANGED
|
@@ -1,739 +1,739 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type { ViewElementAttributeValue } from
|
|
6
|
-
import { type ArrayOrItem } 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 { ViewElementAttributeValue } from "./element.js";
|
|
6
|
+
import { type ArrayOrItem } from "@ckeditor/ckeditor5-utils";
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* Styles map. Allows handling (adding, removing, retrieving) a set of style rules (usually, of an element).
|
|
9
|
+
*/
|
|
10
10
|
export declare class StylesMap implements ViewElementAttributeValue {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Keeps an internal representation of styles map. Normalized styles are kept as object tree to allow unified modification and
|
|
13
|
+
* value access model using lodash's get, set, unset, etc methods.
|
|
14
|
+
*
|
|
15
|
+
* When no style processor rules are defined it acts as simple key-value storage.
|
|
16
|
+
*/
|
|
17
|
+
private _styles;
|
|
18
|
+
/**
|
|
19
|
+
* Cached list of style names for faster access.
|
|
20
|
+
*/
|
|
21
|
+
private _cachedStyleNames;
|
|
22
|
+
/**
|
|
23
|
+
* Cached list of expanded style names for faster access.
|
|
24
|
+
*/
|
|
25
|
+
private _cachedExpandedStyleNames;
|
|
26
|
+
/**
|
|
27
|
+
* An instance of the {@link module:engine/view/stylesmap~StylesProcessor}.
|
|
28
|
+
*/
|
|
29
|
+
private readonly _styleProcessor;
|
|
30
|
+
/**
|
|
31
|
+
* Creates Styles instance.
|
|
32
|
+
*/
|
|
33
|
+
constructor(styleProcessor: StylesProcessor);
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if style map has no styles set.
|
|
36
|
+
*/
|
|
37
|
+
get isEmpty(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Number of styles defined.
|
|
40
|
+
*/
|
|
41
|
+
get size(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Set styles map to a new value.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* styles.setTo( 'border:1px solid blue;margin-top:1px;' );
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
setTo(inlineStyle: string): this;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a given style is set.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* styles.setTo( 'margin-left:1px;' );
|
|
55
|
+
*
|
|
56
|
+
* styles.has( 'margin-left' ); // -> true
|
|
57
|
+
* styles.has( 'padding' ); // -> false
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* **Note**: This check supports normalized style names.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* // Enable 'margin' shorthand processing:
|
|
64
|
+
* editor.data.addStyleProcessorRules( addMarginStylesRules );
|
|
65
|
+
*
|
|
66
|
+
* styles.setTo( 'margin:2px;' );
|
|
67
|
+
*
|
|
68
|
+
* styles.has( 'margin' ); // -> true
|
|
69
|
+
* styles.has( 'margin-top' ); // -> true
|
|
70
|
+
* styles.has( 'margin-left' ); // -> true
|
|
71
|
+
*
|
|
72
|
+
* styles.remove( 'margin-top' );
|
|
73
|
+
*
|
|
74
|
+
* styles.has( 'margin' ); // -> false
|
|
75
|
+
* styles.has( 'margin-top' ); // -> false
|
|
76
|
+
* styles.has( 'margin-left' ); // -> true
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @param name Style name.
|
|
80
|
+
*/
|
|
81
|
+
has(name: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Sets a given style.
|
|
84
|
+
*
|
|
85
|
+
* Can insert one by one:
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* styles.set( 'color', 'blue' );
|
|
89
|
+
* styles.set( 'margin-right', '1em' );
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* ***Note**:* This method uses {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules
|
|
93
|
+
* enabled style processor rules} to normalize passed values.
|
|
94
|
+
*
|
|
95
|
+
* ```ts
|
|
96
|
+
* // Enable 'margin' shorthand processing:
|
|
97
|
+
* editor.data.addStyleProcessorRules( addMarginStylesRules );
|
|
98
|
+
*
|
|
99
|
+
* styles.set( 'margin', '2px' );
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* The above code will set margin to:
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* styles.getNormalized( 'margin' );
|
|
106
|
+
* // -> { top: '2px', right: '2px', bottom: '2px', left: '2px' }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* Which makes it possible to retrieve a "sub-value":
|
|
110
|
+
*
|
|
111
|
+
* ```ts
|
|
112
|
+
* styles.get( 'margin-left' ); // -> '2px'
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* Or modify it:
|
|
116
|
+
*
|
|
117
|
+
* ```ts
|
|
118
|
+
* styles.remove( 'margin-left' );
|
|
119
|
+
*
|
|
120
|
+
* styles.getNormalized( 'margin' ); // -> { top: '1px', bottom: '1px', right: '1px' }
|
|
121
|
+
* styles.toString(); // -> 'margin-bottom:1px;margin-right:1px;margin-top:1px;'
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* This method also allows to set normalized values directly (if a particular styles processor rule was enabled):
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* styles.set( 'border-color', { top: 'blue' } );
|
|
128
|
+
* styles.set( 'margin', { right: '2em' } );
|
|
129
|
+
*
|
|
130
|
+
* styles.toString(); // -> 'border-color-top:blue;margin-right:2em;'
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @label KEY_VALUE
|
|
134
|
+
* @param name Style property name.
|
|
135
|
+
* @param value Value to set.
|
|
136
|
+
*/
|
|
137
|
+
set(name: string, value: StyleValue): void;
|
|
138
|
+
/**
|
|
139
|
+
* Sets many styles at once:
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* styles.set( {
|
|
143
|
+
* color: 'blue',
|
|
144
|
+
* 'margin-right': '1em'
|
|
145
|
+
* } );
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* It is equivalent to:
|
|
149
|
+
*
|
|
150
|
+
* ```ts
|
|
151
|
+
* styles.set( 'color', 'blue' );
|
|
152
|
+
* styles.set( 'margin-right', '1em' );
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* See {@link #set:KEY_VALUE}
|
|
156
|
+
*
|
|
157
|
+
* @label CONFIG_OBJECT
|
|
158
|
+
*/
|
|
159
|
+
set(styles: Styles): void;
|
|
160
|
+
/**
|
|
161
|
+
* Removes given style.
|
|
162
|
+
*
|
|
163
|
+
* ```ts
|
|
164
|
+
* styles.setTo( 'background:#f00;margin-right:2px;' );
|
|
165
|
+
*
|
|
166
|
+
* styles.remove( 'background' );
|
|
167
|
+
*
|
|
168
|
+
* styles.toString(); // -> 'margin-right:2px;'
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* ***Note**:* This method uses {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules
|
|
172
|
+
* enabled style processor rules} to normalize passed values.
|
|
173
|
+
*
|
|
174
|
+
* ```ts
|
|
175
|
+
* // Enable 'margin' shorthand processing:
|
|
176
|
+
* editor.data.addStyleProcessorRules( addMarginStylesRules );
|
|
177
|
+
*
|
|
178
|
+
* styles.setTo( 'margin:1px' );
|
|
179
|
+
*
|
|
180
|
+
* styles.remove( 'margin-top' );
|
|
181
|
+
* styles.remove( 'margin-right' );
|
|
182
|
+
*
|
|
183
|
+
* styles.toString(); // -> 'margin-bottom:1px;margin-left:1px;'
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @param names Style name or an array of names.
|
|
187
|
+
*/
|
|
188
|
+
remove(names: ArrayOrItem<string>): void;
|
|
189
|
+
/**
|
|
190
|
+
* Returns a normalized style object or a single value.
|
|
191
|
+
*
|
|
192
|
+
* ```ts
|
|
193
|
+
* // Enable 'margin' shorthand processing:
|
|
194
|
+
* editor.data.addStyleProcessorRules( addMarginStylesRules );
|
|
195
|
+
*
|
|
196
|
+
* const styles = new Styles();
|
|
197
|
+
* styles.setTo( 'margin:1px 2px 3em;' );
|
|
198
|
+
*
|
|
199
|
+
* styles.getNormalized( 'margin' );
|
|
200
|
+
* // will log:
|
|
201
|
+
* // {
|
|
202
|
+
* // top: '1px',
|
|
203
|
+
* // right: '2px',
|
|
204
|
+
* // bottom: '3em',
|
|
205
|
+
* // left: '2px' // normalized value from margin shorthand
|
|
206
|
+
* // }
|
|
207
|
+
*
|
|
208
|
+
* styles.getNormalized( 'margin-left' ); // -> '2px'
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* **Note**: This method will only return normalized styles if a style processor was defined.
|
|
212
|
+
*
|
|
213
|
+
* @param name Style name.
|
|
214
|
+
*/
|
|
215
|
+
getNormalized(name?: string): StyleValue | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* Returns a normalized style string. Styles are sorted by name.
|
|
218
|
+
*
|
|
219
|
+
* ```ts
|
|
220
|
+
* styles.set( 'margin' , '1px' );
|
|
221
|
+
* styles.set( 'background', '#f00' );
|
|
222
|
+
*
|
|
223
|
+
* styles.toString(); // -> 'background:#f00;margin:1px;'
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* **Note**: This method supports normalized styles if defined.
|
|
227
|
+
*
|
|
228
|
+
* ```ts
|
|
229
|
+
* // Enable 'margin' shorthand processing:
|
|
230
|
+
* editor.data.addStyleProcessorRules( addMarginStylesRules );
|
|
231
|
+
*
|
|
232
|
+
* styles.set( 'margin' , '1px' );
|
|
233
|
+
* styles.set( 'background', '#f00' );
|
|
234
|
+
* styles.remove( 'margin-top' );
|
|
235
|
+
* styles.remove( 'margin-right' );
|
|
236
|
+
*
|
|
237
|
+
* styles.toString(); // -> 'background:#f00;margin-bottom:1px;margin-left:1px;'
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
toString(): string;
|
|
241
|
+
/**
|
|
242
|
+
* Returns property as a value string or undefined if property is not set.
|
|
243
|
+
*
|
|
244
|
+
* ```ts
|
|
245
|
+
* // Enable 'margin' shorthand processing:
|
|
246
|
+
* editor.data.addStyleProcessorRules( addMarginStylesRules );
|
|
247
|
+
*
|
|
248
|
+
* const styles = new Styles();
|
|
249
|
+
* styles.setTo( 'margin:1px;' );
|
|
250
|
+
* styles.set( 'margin-bottom', '3em' );
|
|
251
|
+
*
|
|
252
|
+
* styles.getAsString( 'margin' ); // -> 'margin: 1px 1px 3em;'
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* Note, however, that all sub-values must be set for the longhand property name to return a value:
|
|
256
|
+
*
|
|
257
|
+
* ```ts
|
|
258
|
+
* const styles = new Styles();
|
|
259
|
+
* styles.setTo( 'margin:1px;' );
|
|
260
|
+
* styles.remove( 'margin-bottom' );
|
|
261
|
+
*
|
|
262
|
+
* styles.getAsString( 'margin' ); // -> undefined
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* In the above scenario, it is not possible to return a `margin` value, so `undefined` is returned.
|
|
266
|
+
* Instead, you should use:
|
|
267
|
+
*
|
|
268
|
+
* ```ts
|
|
269
|
+
* const styles = new Styles();
|
|
270
|
+
* styles.setTo( 'margin:1px;' );
|
|
271
|
+
* styles.remove( 'margin-bottom' );
|
|
272
|
+
*
|
|
273
|
+
* for ( const styleName of styles.getStyleNames() ) {
|
|
274
|
+
* console.log( styleName, styles.getAsString( styleName ) );
|
|
275
|
+
* }
|
|
276
|
+
* // 'margin-top', '1px'
|
|
277
|
+
* // 'margin-right', '1px'
|
|
278
|
+
* // 'margin-left', '1px'
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* In general, it is recommend to iterate over style names like in the example above. This way, you will always get all
|
|
282
|
+
* the currently set style values. So, if all the 4 margin values would be set
|
|
283
|
+
* the for-of loop above would yield only `'margin'`, `'1px'`:
|
|
284
|
+
*
|
|
285
|
+
* ```ts
|
|
286
|
+
* const styles = new Styles();
|
|
287
|
+
* styles.setTo( 'margin:1px;' );
|
|
288
|
+
*
|
|
289
|
+
* for ( const styleName of styles.getStyleNames() ) {
|
|
290
|
+
* console.log( styleName, styles.getAsString( styleName ) );
|
|
291
|
+
* }
|
|
292
|
+
* // 'margin', '1px'
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* **Note**: To get a normalized version of a longhand property use the {@link #getNormalized `#getNormalized()`} method.
|
|
296
|
+
*/
|
|
297
|
+
getAsString(propertyName: string): string | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* Returns all style properties names as they would appear when using {@link #toString `#toString()`}.
|
|
300
|
+
*
|
|
301
|
+
* When `expand` is set to true and there's a shorthand style property set, it will also return all equivalent styles:
|
|
302
|
+
*
|
|
303
|
+
* ```ts
|
|
304
|
+
* stylesMap.setTo( 'margin: 1em' )
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* will be expanded to:
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* [ 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ]
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* @param expand Expand shorthand style properties and all return equivalent style representations.
|
|
314
|
+
*/
|
|
315
|
+
getStyleNames(expand?: boolean): Array<string>;
|
|
316
|
+
/**
|
|
317
|
+
* Alias for {@link #getStyleNames}.
|
|
318
|
+
*/
|
|
319
|
+
keys(): Array<string>;
|
|
320
|
+
/**
|
|
321
|
+
* Removes all styles.
|
|
322
|
+
*/
|
|
323
|
+
clear(): void;
|
|
324
|
+
/**
|
|
325
|
+
* Returns `true` if both attributes have the same styles.
|
|
326
|
+
*/
|
|
327
|
+
isSimilar(other: StylesMap): boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Returns normalized styles entries for further processing.
|
|
330
|
+
*/
|
|
331
|
+
getStylesEntries(): Array<StylePropertyDescriptor>;
|
|
332
|
+
/**
|
|
333
|
+
* Clones the attribute value.
|
|
334
|
+
*
|
|
335
|
+
* @internal
|
|
336
|
+
*/
|
|
337
|
+
_clone(): this;
|
|
338
|
+
/**
|
|
339
|
+
* Used by the {@link module:engine/view/matcher~Matcher Matcher} to collect matching styles.
|
|
340
|
+
*
|
|
341
|
+
* @internal
|
|
342
|
+
* @param tokenPattern The matched style name pattern.
|
|
343
|
+
* @param valuePattern The matched style value pattern.
|
|
344
|
+
* @returns An array of matching tokens (style names).
|
|
345
|
+
*/
|
|
346
|
+
_getTokensMatch(tokenPattern: true | string | RegExp, valuePattern: true | string | RegExp): Array<string> | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* Returns a list of consumables for the attribute. This includes related styles.
|
|
349
|
+
*
|
|
350
|
+
* Could be filtered by the given style name.
|
|
351
|
+
*
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
_getConsumables(name?: string): Array<string>;
|
|
355
|
+
/**
|
|
356
|
+
* Used by {@link module:engine/view/element~ViewElement#_canMergeAttributesFrom} to verify if the given attribute can be merged without
|
|
357
|
+
* conflicts into the attribute.
|
|
358
|
+
*
|
|
359
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
360
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
|
|
361
|
+
*
|
|
362
|
+
* @internal
|
|
363
|
+
*/
|
|
364
|
+
_canMergeFrom(other: StylesMap): boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Used by {@link module:engine/view/element~ViewElement#_mergeAttributesFrom} to merge a given attribute into the attribute.
|
|
367
|
+
*
|
|
368
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
369
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
|
|
370
|
+
*
|
|
371
|
+
* @internal
|
|
372
|
+
*/
|
|
373
|
+
_mergeFrom(other: StylesMap): void;
|
|
374
|
+
/**
|
|
375
|
+
* Used by {@link module:engine/view/element~ViewElement#_canSubtractAttributesOf} to verify if the given attribute can be fully
|
|
376
|
+
* subtracted from the attribute.
|
|
377
|
+
*
|
|
378
|
+
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
379
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to unwrap the ViewAttributeElement.
|
|
380
|
+
*
|
|
381
|
+
* @internal
|
|
382
|
+
*/
|
|
383
|
+
_isMatching(other: StylesMap): boolean;
|
|
384
384
|
}
|
|
385
385
|
/**
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
* Style processor is responsible for writing and reading a normalized styles object.
|
|
387
|
+
*/
|
|
388
388
|
export declare class StylesProcessor {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
389
|
+
private readonly _normalizers;
|
|
390
|
+
private readonly _extractors;
|
|
391
|
+
private readonly _reducers;
|
|
392
|
+
private readonly _consumables;
|
|
393
|
+
/**
|
|
394
|
+
* Creates StylesProcessor instance.
|
|
395
|
+
*
|
|
396
|
+
* @internal
|
|
397
|
+
*/
|
|
398
|
+
constructor();
|
|
399
|
+
/**
|
|
400
|
+
* Parse style string value to a normalized object and appends it to styles object.
|
|
401
|
+
*
|
|
402
|
+
* ```ts
|
|
403
|
+
* const styles = {};
|
|
404
|
+
*
|
|
405
|
+
* stylesProcessor.toNormalizedForm( 'margin', '1px', styles );
|
|
406
|
+
*
|
|
407
|
+
* // styles will consist: { margin: { top: '1px', right: '1px', bottom: '1px', left: '1px; } }
|
|
408
|
+
* ```
|
|
409
|
+
*
|
|
410
|
+
* **Note**: To define normalizer callbacks use {@link #setNormalizer}.
|
|
411
|
+
*
|
|
412
|
+
* @param name Name of style property.
|
|
413
|
+
* @param propertyValue Value of style property.
|
|
414
|
+
* @param styles Object holding normalized styles.
|
|
415
|
+
*/
|
|
416
|
+
toNormalizedForm(name: string, propertyValue: StyleValue, styles: Styles): void;
|
|
417
|
+
/**
|
|
418
|
+
* Returns a normalized version of a style property.
|
|
419
|
+
*
|
|
420
|
+
* ```ts
|
|
421
|
+
* const styles = {
|
|
422
|
+
* margin: { top: '1px', right: '1px', bottom: '1px', left: '1px; },
|
|
423
|
+
* background: { color: '#f00' }
|
|
424
|
+
* };
|
|
425
|
+
*
|
|
426
|
+
* stylesProcessor.getNormalized( 'background' );
|
|
427
|
+
* // will return: { color: '#f00' }
|
|
428
|
+
*
|
|
429
|
+
* stylesProcessor.getNormalized( 'margin-top' );
|
|
430
|
+
* // will return: '1px'
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* **Note**: In some cases extracting single value requires defining an extractor callback {@link #setExtractor}.
|
|
434
|
+
*
|
|
435
|
+
* @param name Name of style property.
|
|
436
|
+
* @param styles Object holding normalized styles.
|
|
437
|
+
*/
|
|
438
|
+
getNormalized(name: string | undefined, styles: Styles): StyleValue | undefined;
|
|
439
|
+
/**
|
|
440
|
+
* Returns a reduced form of style property form normalized object.
|
|
441
|
+
*
|
|
442
|
+
* For default margin reducer, the below code:
|
|
443
|
+
*
|
|
444
|
+
* ```ts
|
|
445
|
+
* stylesProcessor.getReducedForm( 'margin', {
|
|
446
|
+
* margin: { top: '1px', right: '1px', bottom: '2px', left: '1px; }
|
|
447
|
+
* } );
|
|
448
|
+
* ```
|
|
449
|
+
*
|
|
450
|
+
* will return:
|
|
451
|
+
*
|
|
452
|
+
* ```ts
|
|
453
|
+
* [
|
|
454
|
+
* [ 'margin', '1px 1px 2px' ]
|
|
455
|
+
* ]
|
|
456
|
+
* ```
|
|
457
|
+
*
|
|
458
|
+
* because it might be represented as a shorthand 'margin' value. However if one of margin long hand values is missing it should return:
|
|
459
|
+
*
|
|
460
|
+
* ```ts
|
|
461
|
+
* [
|
|
462
|
+
* [ 'margin-top', '1px' ],
|
|
463
|
+
* [ 'margin-right', '1px' ],
|
|
464
|
+
* [ 'margin-bottom', '2px' ]
|
|
465
|
+
* // the 'left' value is missing - cannot use 'margin' shorthand.
|
|
466
|
+
* ]
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
469
|
+
* **Note**: To define reducer callbacks use {@link #setReducer}.
|
|
470
|
+
*
|
|
471
|
+
* @param name Name of style property.
|
|
472
|
+
*/
|
|
473
|
+
getReducedForm(name: string, styles: Styles): Array<StylePropertyDescriptor>;
|
|
474
|
+
/**
|
|
475
|
+
* Return all style properties. Also expand shorthand properties (e.g. `margin`, `background`) if respective extractor is available.
|
|
476
|
+
*
|
|
477
|
+
* @param styles Object holding normalized styles.
|
|
478
|
+
*/
|
|
479
|
+
getStyleNames(styles: Styles): Array<string>;
|
|
480
|
+
/**
|
|
481
|
+
* Returns related style names.
|
|
482
|
+
*
|
|
483
|
+
* ```ts
|
|
484
|
+
* stylesProcessor.getRelatedStyles( 'margin' );
|
|
485
|
+
* // will return: [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ];
|
|
486
|
+
*
|
|
487
|
+
* stylesProcessor.getRelatedStyles( 'margin-top' );
|
|
488
|
+
* // will return: [ 'margin' ];
|
|
489
|
+
* ```
|
|
490
|
+
*
|
|
491
|
+
* **Note**: To define new style relations load an existing style processor or use
|
|
492
|
+
* {@link module:engine/view/stylesmap~StylesProcessor#setStyleRelation `StylesProcessor.setStyleRelation()`}.
|
|
493
|
+
*/
|
|
494
|
+
getRelatedStyles(name: string): Array<string>;
|
|
495
|
+
/**
|
|
496
|
+
* Adds a normalizer method for a style property.
|
|
497
|
+
*
|
|
498
|
+
* A normalizer returns describing how the value should be normalized.
|
|
499
|
+
*
|
|
500
|
+
* For instance 'margin' style is a shorthand for four margin values:
|
|
501
|
+
*
|
|
502
|
+
* - 'margin-top'
|
|
503
|
+
* - 'margin-right'
|
|
504
|
+
* - 'margin-bottom'
|
|
505
|
+
* - 'margin-left'
|
|
506
|
+
*
|
|
507
|
+
* and can be written in various ways if some values are equal to others. For instance `'margin: 1px 2em;'` is a shorthand for
|
|
508
|
+
* `'margin-top: 1px;margin-right: 2em;margin-bottom: 1px;margin-left: 2em'`.
|
|
509
|
+
*
|
|
510
|
+
* A normalizer should parse various margin notations as a single object:
|
|
511
|
+
*
|
|
512
|
+
* ```ts
|
|
513
|
+
* const styles = {
|
|
514
|
+
* margin: {
|
|
515
|
+
* top: '1px',
|
|
516
|
+
* right: '2em',
|
|
517
|
+
* bottom: '1px',
|
|
518
|
+
* left: '2em'
|
|
519
|
+
* }
|
|
520
|
+
* };
|
|
521
|
+
* ```
|
|
522
|
+
*
|
|
523
|
+
* Thus a normalizer for 'margin' style should return an object defining style path and value to store:
|
|
524
|
+
*
|
|
525
|
+
* ```ts
|
|
526
|
+
* const returnValue = {
|
|
527
|
+
* path: 'margin',
|
|
528
|
+
* value: {
|
|
529
|
+
* top: '1px',
|
|
530
|
+
* right: '2em',
|
|
531
|
+
* bottom: '1px',
|
|
532
|
+
* left: '2em'
|
|
533
|
+
* }
|
|
534
|
+
* };
|
|
535
|
+
* ```
|
|
536
|
+
*
|
|
537
|
+
* Additionally to fully support all margin notations there should be also defined 4 normalizers for longhand margin notations. Below
|
|
538
|
+
* is an example for 'margin-top' style property normalizer:
|
|
539
|
+
*
|
|
540
|
+
* ```ts
|
|
541
|
+
* stylesProcessor.setNormalizer( 'margin-top', valueString => {
|
|
542
|
+
* return {
|
|
543
|
+
* path: 'margin.top',
|
|
544
|
+
* value: valueString
|
|
545
|
+
* }
|
|
546
|
+
* } );
|
|
547
|
+
* ```
|
|
548
|
+
*/
|
|
549
|
+
setNormalizer(name: string, callback: StylesNormalizer): void;
|
|
550
|
+
/**
|
|
551
|
+
* Adds a extractor callback for a style property.
|
|
552
|
+
*
|
|
553
|
+
* Most normalized style values are stored as one level objects. It is assumed that `'margin-top'` style will be stored as:
|
|
554
|
+
*
|
|
555
|
+
* ```ts
|
|
556
|
+
* const styles = {
|
|
557
|
+
* margin: {
|
|
558
|
+
* top: 'value'
|
|
559
|
+
* }
|
|
560
|
+
* }
|
|
561
|
+
* ```
|
|
562
|
+
*
|
|
563
|
+
* However, some styles can have conflicting notations and thus it might be harder to extract a style value from shorthand. For instance
|
|
564
|
+
* the 'border-top-style' can be defined using `'border-top:solid'`, `'border-style:solid none none none'` or by `'border:solid'`
|
|
565
|
+
* shorthands. The default border styles processors stores styles as:
|
|
566
|
+
*
|
|
567
|
+
* ```ts
|
|
568
|
+
* const styles = {
|
|
569
|
+
* border: {
|
|
570
|
+
* style: {
|
|
571
|
+
* top: 'solid'
|
|
572
|
+
* }
|
|
573
|
+
* }
|
|
574
|
+
* }
|
|
575
|
+
* ```
|
|
576
|
+
*
|
|
577
|
+
* as it is better to modify border style independently from other values. On the other part the output of the border might be
|
|
578
|
+
* desired as `border-top`, `border-left`, etc notation.
|
|
579
|
+
*
|
|
580
|
+
* In the above example an extractor should return a side border value that combines style, color and width:
|
|
581
|
+
*
|
|
582
|
+
* ```ts
|
|
583
|
+
* styleProcessor.setExtractor( 'border-top', styles => {
|
|
584
|
+
* return {
|
|
585
|
+
* color: styles.border.color.top,
|
|
586
|
+
* style: styles.border.style.top,
|
|
587
|
+
* width: styles.border.width.top
|
|
588
|
+
* }
|
|
589
|
+
* } );
|
|
590
|
+
* ```
|
|
591
|
+
*
|
|
592
|
+
* @param callbackOrPath Callback that return a requested value or path string for single values.
|
|
593
|
+
*/
|
|
594
|
+
setExtractor(name: string, callbackOrPath: StylesExtractor): void;
|
|
595
|
+
/**
|
|
596
|
+
* Adds a reducer callback for a style property.
|
|
597
|
+
*
|
|
598
|
+
* Reducer returns a minimal notation for given style name. For longhand properties it is not required to write a reducer as
|
|
599
|
+
* by default the direct value from style path is taken.
|
|
600
|
+
*
|
|
601
|
+
* For shorthand styles a reducer should return minimal style notation either by returning single name-value tuple or multiple tuples
|
|
602
|
+
* if a shorthand cannot be used. For instance for a margin shorthand a reducer might return:
|
|
603
|
+
*
|
|
604
|
+
* ```ts
|
|
605
|
+
* const marginShortHandTuple = [
|
|
606
|
+
* [ 'margin', '1px 1px 2px' ]
|
|
607
|
+
* ];
|
|
608
|
+
* ```
|
|
609
|
+
*
|
|
610
|
+
* or a longhand tuples for defined values:
|
|
611
|
+
*
|
|
612
|
+
* ```ts
|
|
613
|
+
* // Considering margin.bottom and margin.left are undefined.
|
|
614
|
+
* const marginLonghandsTuples = [
|
|
615
|
+
* [ 'margin-top', '1px' ],
|
|
616
|
+
* [ 'margin-right', '1px' ]
|
|
617
|
+
* ];
|
|
618
|
+
* ```
|
|
619
|
+
*
|
|
620
|
+
* A reducer obtains a normalized style value:
|
|
621
|
+
*
|
|
622
|
+
* ```ts
|
|
623
|
+
* // Simplified reducer that always outputs 4 values which are always present:
|
|
624
|
+
* stylesProcessor.setReducer( 'margin', margin => {
|
|
625
|
+
* return [
|
|
626
|
+
* [ 'margin', `${ margin.top } ${ margin.right } ${ margin.bottom } ${ margin.left }` ]
|
|
627
|
+
* ]
|
|
628
|
+
* } );
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
setReducer(name: string, callback: StylesReducer): void;
|
|
632
|
+
/**
|
|
633
|
+
* Defines a style shorthand relation to other style notations.
|
|
634
|
+
*
|
|
635
|
+
* ```ts
|
|
636
|
+
* stylesProcessor.setStyleRelation( 'margin', [
|
|
637
|
+
* 'margin-top',
|
|
638
|
+
* 'margin-right',
|
|
639
|
+
* 'margin-bottom',
|
|
640
|
+
* 'margin-left'
|
|
641
|
+
* ] );
|
|
642
|
+
* ```
|
|
643
|
+
*
|
|
644
|
+
* This enables expanding of style names for shorthands. For instance, if defined,
|
|
645
|
+
* {@link module:engine/conversion/viewconsumable~ViewConsumable view consumable} items are automatically created
|
|
646
|
+
* for long-hand margin style notation alongside the `'margin'` item.
|
|
647
|
+
*
|
|
648
|
+
* This means that when an element being converted has a style `margin`, a converter for `margin-left` will work just
|
|
649
|
+
* fine since the view consumable will contain a consumable `margin-left` item (thanks to the relation) and
|
|
650
|
+
* `element.getStyle( 'margin-left' )` will work as well assuming that the style processor was correctly configured.
|
|
651
|
+
* However, once `margin-left` is consumed, `margin` will not be consumable anymore.
|
|
652
|
+
*/
|
|
653
|
+
setStyleRelation(shorthandName: string, styleNames: Array<string>): void;
|
|
654
|
+
/**
|
|
655
|
+
* Set two-way binding of style names.
|
|
656
|
+
*/
|
|
657
|
+
private _mapStyleNames;
|
|
658
658
|
}
|
|
659
659
|
/**
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
660
|
+
* A CSS style property descriptor that contains tuple of two strings:
|
|
661
|
+
*
|
|
662
|
+
* - first string describes property name
|
|
663
|
+
* - second string describes property value
|
|
664
|
+
*
|
|
665
|
+
* ```ts
|
|
666
|
+
* const marginDescriptor = [ 'margin', '2px 3em' ];
|
|
667
|
+
* const marginTopDescriptor = [ 'margin-top', '2px' ];
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
670
|
export type StylePropertyDescriptor = [name: string, value: string];
|
|
671
671
|
/**
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
672
|
+
* An object describing values associated with the sides of a box, for instance margins, paddings,
|
|
673
|
+
* border widths, border colors, etc.
|
|
674
|
+
*
|
|
675
|
+
* ```ts
|
|
676
|
+
* const margin = {
|
|
677
|
+
* top: '1px',
|
|
678
|
+
* right: '3px',
|
|
679
|
+
* bottom: '3px',
|
|
680
|
+
* left: '7px'
|
|
681
|
+
* };
|
|
682
|
+
*
|
|
683
|
+
* const borderColor = {
|
|
684
|
+
* top: 'red',
|
|
685
|
+
* right: 'blue',
|
|
686
|
+
* bottom: 'blue',
|
|
687
|
+
* left: 'red'
|
|
688
|
+
* };
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
691
|
export type BoxStyleSides = {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
692
|
+
/**
|
|
693
|
+
* Top side value.
|
|
694
|
+
*/
|
|
695
|
+
top: undefined | string;
|
|
696
|
+
/**
|
|
697
|
+
* Left side value.
|
|
698
|
+
*/
|
|
699
|
+
left: undefined | string;
|
|
700
|
+
/**
|
|
701
|
+
* Right side value.
|
|
702
|
+
*/
|
|
703
|
+
right: undefined | string;
|
|
704
|
+
/**
|
|
705
|
+
* Bottom side value.
|
|
706
|
+
*/
|
|
707
|
+
bottom: undefined | string;
|
|
708
708
|
};
|
|
709
709
|
/**
|
|
710
|
-
|
|
711
|
-
|
|
710
|
+
* Object holding styles as key-value pairs.
|
|
711
|
+
*/
|
|
712
712
|
export interface Styles {
|
|
713
|
-
|
|
713
|
+
[name: string]: StyleValue;
|
|
714
714
|
}
|
|
715
715
|
/**
|
|
716
|
-
|
|
717
|
-
|
|
716
|
+
* The value of style.
|
|
717
|
+
*/
|
|
718
718
|
export type StyleValue = string | Array<string> | Styles | BoxStyleSides;
|
|
719
719
|
/**
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
720
|
+
* A normalizer method for a style property.
|
|
721
|
+
*
|
|
722
|
+
* @see ~StylesProcessor#setNormalizer
|
|
723
|
+
*/
|
|
724
724
|
export type StylesNormalizer = (name: string) => {
|
|
725
|
-
|
|
726
|
-
|
|
725
|
+
path: string;
|
|
726
|
+
value: StyleValue;
|
|
727
727
|
};
|
|
728
728
|
/**
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
729
|
+
* An extractor callback for a style property or path string for single values.
|
|
730
|
+
*
|
|
731
|
+
* @see ~StylesProcessor#setExtractor
|
|
732
|
+
*/
|
|
733
733
|
export type StylesExtractor = string | ((name: string, styles: Styles) => StyleValue | undefined);
|
|
734
734
|
/**
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
735
|
+
* A reducer callback for a style property.
|
|
736
|
+
*
|
|
737
|
+
* @see ~StylesProcessor#setReducer
|
|
738
|
+
*/
|
|
739
739
|
export type StylesReducer = (value: StyleValue) => Array<StylePropertyDescriptor>;
|