@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.
Files changed (129) hide show
  1. package/dist/controller/datacontroller.d.ts +329 -328
  2. package/dist/controller/editingcontroller.d.ts +95 -94
  3. package/dist/conversion/comparemarkers.d.ts +45 -45
  4. package/dist/conversion/conversion.d.ts +474 -474
  5. package/dist/conversion/conversionhelpers.d.ts +21 -21
  6. package/dist/conversion/downcastdispatcher.d.ts +539 -538
  7. package/dist/conversion/downcasthelpers.d.ts +1129 -1129
  8. package/dist/conversion/mapper.d.ts +692 -697
  9. package/dist/conversion/modelconsumable.d.ts +196 -196
  10. package/dist/conversion/upcastdispatcher.d.ts +483 -482
  11. package/dist/conversion/upcasthelpers.d.ts +491 -491
  12. package/dist/conversion/viewconsumable.d.ts +330 -330
  13. package/dist/dataprocessor/basichtmlwriter.d.ts +15 -15
  14. package/dist/dataprocessor/dataprocessor.d.ts +57 -57
  15. package/dist/dataprocessor/htmldataprocessor.d.ts +72 -72
  16. package/dist/dataprocessor/htmlwriter.d.ts +11 -11
  17. package/dist/dataprocessor/xmldataprocessor.d.ts +86 -86
  18. package/dist/dev-utils/model.d.ts +128 -123
  19. package/dist/dev-utils/operationreplayer.d.ts +49 -49
  20. package/dist/dev-utils/utils.d.ts +33 -33
  21. package/dist/dev-utils/view.d.ts +314 -309
  22. package/dist/engineconfig.d.ts +39 -39
  23. package/dist/index.css.map +1 -1
  24. package/dist/index.d.ts +150 -150
  25. package/dist/index.js +34026 -40107
  26. package/dist/index.js.map +1 -1
  27. package/dist/legacyerrors.d.ts +0 -4
  28. package/dist/model/batch.d.ts +86 -86
  29. package/dist/model/differ.d.ts +504 -504
  30. package/dist/model/document.d.ts +265 -268
  31. package/dist/model/documentfragment.d.ts +214 -214
  32. package/dist/model/documentselection.d.ts +406 -410
  33. package/dist/model/element.d.ts +182 -182
  34. package/dist/model/history.d.ts +109 -109
  35. package/dist/model/item.d.ts +9 -9
  36. package/dist/model/liveposition.d.ts +70 -69
  37. package/dist/model/liverange.d.ts +93 -92
  38. package/dist/model/markercollection.d.ts +317 -324
  39. package/dist/model/model.d.ts +889 -909
  40. package/dist/model/node.d.ts +254 -254
  41. package/dist/model/nodelist.d.ts +110 -110
  42. package/dist/model/operation/attributeoperation.d.ts +98 -98
  43. package/dist/model/operation/detachoperation.d.ts +57 -57
  44. package/dist/model/operation/insertoperation.d.ts +85 -85
  45. package/dist/model/operation/markeroperation.d.ts +87 -87
  46. package/dist/model/operation/mergeoperation.d.ts +95 -95
  47. package/dist/model/operation/moveoperation.d.ts +97 -97
  48. package/dist/model/operation/nooperation.d.ts +33 -33
  49. package/dist/model/operation/operation.d.ts +94 -94
  50. package/dist/model/operation/operationfactory.d.ts +14 -14
  51. package/dist/model/operation/renameoperation.d.ts +78 -78
  52. package/dist/model/operation/rootattributeoperation.d.ts +93 -93
  53. package/dist/model/operation/rootoperation.d.ts +71 -71
  54. package/dist/model/operation/splitoperation.d.ts +104 -104
  55. package/dist/model/operation/transform.d.ts +91 -91
  56. package/dist/model/operation/utils.d.ts +58 -58
  57. package/dist/model/position.d.ts +535 -535
  58. package/dist/model/range.d.ts +458 -453
  59. package/dist/model/rootelement.d.ts +55 -55
  60. package/dist/model/schema.d.ts +1325 -1327
  61. package/dist/model/selection.d.ts +452 -471
  62. package/dist/model/text.d.ts +62 -62
  63. package/dist/model/textproxy.d.ts +140 -140
  64. package/dist/model/treewalker.d.ts +190 -190
  65. package/dist/model/typecheckable.d.ts +281 -281
  66. package/dist/model/utils/autoparagraphing.d.ts +29 -29
  67. package/dist/model/utils/deletecontent.d.ts +68 -68
  68. package/dist/model/utils/getselectedcontent.d.ts +27 -27
  69. package/dist/model/utils/insertcontent.d.ts +42 -42
  70. package/dist/model/utils/insertobject.d.ts +41 -41
  71. package/dist/model/utils/modifyselection.d.ts +44 -44
  72. package/dist/model/utils/selection-post-fixer.d.ts +71 -71
  73. package/dist/model/writer.d.ts +854 -854
  74. package/dist/view/attributeelement.d.ts +123 -123
  75. package/dist/view/containerelement.d.ts +49 -49
  76. package/dist/view/datatransfer.d.ts +70 -70
  77. package/dist/view/document.d.ts +175 -177
  78. package/dist/view/documentfragment.d.ts +158 -157
  79. package/dist/view/documentselection.d.ts +308 -307
  80. package/dist/view/domconverter.d.ts +612 -657
  81. package/dist/view/downcastwriter.d.ts +1006 -1006
  82. package/dist/view/editableelement.d.ts +64 -63
  83. package/dist/view/element.d.ts +754 -754
  84. package/dist/view/elementdefinition.d.ts +79 -79
  85. package/dist/view/emptyelement.d.ts +42 -42
  86. package/dist/view/filler.d.ts +75 -75
  87. package/dist/view/item.d.ts +9 -9
  88. package/dist/view/matcher.d.ts +412 -487
  89. package/dist/view/node.d.ts +164 -163
  90. package/dist/view/observer/arrowkeysobserver.d.ts +37 -37
  91. package/dist/view/observer/bubblingemittermixin.d.ts +163 -153
  92. package/dist/view/observer/bubblingeventinfo.d.ts +45 -42
  93. package/dist/view/observer/clickobserver.d.ts +36 -36
  94. package/dist/view/observer/compositionobserver.d.ts +67 -67
  95. package/dist/view/observer/domeventdata.d.ts +46 -46
  96. package/dist/view/observer/domeventobserver.d.ts +77 -74
  97. package/dist/view/observer/fakeselectionobserver.d.ts +42 -42
  98. package/dist/view/observer/focusobserver.d.ts +84 -84
  99. package/dist/view/observer/inputobserver.d.ts +76 -76
  100. package/dist/view/observer/keyobserver.d.ts +53 -53
  101. package/dist/view/observer/mouseobserver.d.ts +73 -73
  102. package/dist/view/observer/mutationobserver.d.ts +101 -101
  103. package/dist/view/observer/observer.d.ts +84 -83
  104. package/dist/view/observer/pointerobserver.d.ts +63 -63
  105. package/dist/view/observer/selectionobserver.d.ts +136 -136
  106. package/dist/view/observer/tabobserver.d.ts +38 -38
  107. package/dist/view/observer/touchobserver.d.ts +60 -60
  108. package/dist/view/placeholder.d.ts +80 -80
  109. package/dist/view/position.d.ts +187 -187
  110. package/dist/view/range.d.ts +282 -282
  111. package/dist/view/rawelement.d.ts +72 -72
  112. package/dist/view/renderer.d.ts +270 -272
  113. package/dist/view/rooteditableelement.d.ts +43 -43
  114. package/dist/view/selection.d.ts +356 -369
  115. package/dist/view/styles/background.d.ts +15 -15
  116. package/dist/view/styles/border.d.ts +27 -27
  117. package/dist/view/styles/margin.d.ts +12 -12
  118. package/dist/view/styles/padding.d.ts +12 -12
  119. package/dist/view/styles/utils.d.ts +72 -72
  120. package/dist/view/stylesmap.d.ts +715 -715
  121. package/dist/view/text.d.ts +75 -75
  122. package/dist/view/textproxy.d.ts +92 -92
  123. package/dist/view/tokenlist.d.ts +104 -104
  124. package/dist/view/treewalker.d.ts +201 -201
  125. package/dist/view/typecheckable.d.ts +445 -445
  126. package/dist/view/uielement.d.ts +93 -93
  127. package/dist/view/upcastwriter.d.ts +412 -412
  128. package/dist/view/view.d.ts +466 -469
  129. package/package.json +2 -2
@@ -1,739 +1,739 @@
1
1
  /**
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';
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
- * Styles map. Allows handling (adding, removing, retrieving) a set of style rules (usually, of an element).
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
- * 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;
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
- * Style processor is responsible for writing and reading a normalized styles object.
387
- */
386
+ * Style processor is responsible for writing and reading a normalized styles object.
387
+ */
388
388
  export declare class StylesProcessor {
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;
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
- * 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
- */
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
- * 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
- */
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
- * 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;
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
- * Object holding styles as key-value pairs.
711
- */
710
+ * Object holding styles as key-value pairs.
711
+ */
712
712
  export interface Styles {
713
- [name: string]: StyleValue;
713
+ [name: string]: StyleValue;
714
714
  }
715
715
  /**
716
- * The value of style.
717
- */
716
+ * The value of style.
717
+ */
718
718
  export type StyleValue = string | Array<string> | Styles | BoxStyleSides;
719
719
  /**
720
- * A normalizer method for a style property.
721
- *
722
- * @see ~StylesProcessor#setNormalizer
723
- */
720
+ * A normalizer method for a style property.
721
+ *
722
+ * @see ~StylesProcessor#setNormalizer
723
+ */
724
724
  export type StylesNormalizer = (name: string) => {
725
- path: string;
726
- value: StyleValue;
725
+ path: string;
726
+ value: StyleValue;
727
727
  };
728
728
  /**
729
- * An extractor callback for a style property or path string for single values.
730
- *
731
- * @see ~StylesProcessor#setExtractor
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
- * A reducer callback for a style property.
736
- *
737
- * @see ~StylesProcessor#setReducer
738
- */
735
+ * A reducer callback for a style property.
736
+ *
737
+ * @see ~StylesProcessor#setReducer
738
+ */
739
739
  export type StylesReducer = (value: StyleValue) => Array<StylePropertyDescriptor>;