@ckeditor/ckeditor5-engine 41.3.0-alpha.4 → 41.3.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 (132) hide show
  1. package/package.json +2 -3
  2. package/src/model/node.d.ts +1 -0
  3. package/src/model/node.js +2 -0
  4. package/src/model/position.d.ts +1 -0
  5. package/src/model/position.js +2 -0
  6. package/src/view/node.d.ts +1 -0
  7. package/src/view/node.js +2 -0
  8. package/src/view/position.d.ts +1 -0
  9. package/src/view/position.js +2 -0
  10. package/dist/content-index.css +0 -4
  11. package/dist/editor-index.css +0 -23
  12. package/dist/index.css +0 -49
  13. package/dist/index.css.map +0 -1
  14. package/dist/types/controller/datacontroller.d.ts +0 -339
  15. package/dist/types/controller/editingcontroller.d.ts +0 -102
  16. package/dist/types/conversion/conversion.d.ts +0 -482
  17. package/dist/types/conversion/conversionhelpers.d.ts +0 -30
  18. package/dist/types/conversion/downcastdispatcher.d.ts +0 -566
  19. package/dist/types/conversion/downcasthelpers.d.ts +0 -1194
  20. package/dist/types/conversion/mapper.d.ts +0 -507
  21. package/dist/types/conversion/modelconsumable.d.ts +0 -205
  22. package/dist/types/conversion/upcastdispatcher.d.ts +0 -496
  23. package/dist/types/conversion/upcasthelpers.d.ts +0 -503
  24. package/dist/types/conversion/viewconsumable.d.ts +0 -373
  25. package/dist/types/dataprocessor/basichtmlwriter.d.ts +0 -22
  26. package/dist/types/dataprocessor/dataprocessor.d.ts +0 -65
  27. package/dist/types/dataprocessor/htmldataprocessor.d.ts +0 -80
  28. package/dist/types/dataprocessor/htmlwriter.d.ts +0 -20
  29. package/dist/types/dataprocessor/xmldataprocessor.d.ts +0 -94
  30. package/dist/types/dev-utils/model.d.ts +0 -128
  31. package/dist/types/dev-utils/operationreplayer.d.ts +0 -55
  32. package/dist/types/dev-utils/utils.d.ts +0 -41
  33. package/dist/types/dev-utils/view.d.ts +0 -323
  34. package/dist/types/index.d.ts +0 -117
  35. package/dist/types/model/batch.d.ts +0 -110
  36. package/dist/types/model/differ.d.ts +0 -419
  37. package/dist/types/model/document.d.ts +0 -278
  38. package/dist/types/model/documentfragment.d.ts +0 -204
  39. package/dist/types/model/documentselection.d.ts +0 -424
  40. package/dist/types/model/element.d.ts +0 -169
  41. package/dist/types/model/history.d.ts +0 -118
  42. package/dist/types/model/item.d.ts +0 -18
  43. package/dist/types/model/liveposition.d.ts +0 -81
  44. package/dist/types/model/liverange.d.ts +0 -106
  45. package/dist/types/model/markercollection.d.ts +0 -339
  46. package/dist/types/model/model.d.ts +0 -923
  47. package/dist/types/model/node.d.ts +0 -259
  48. package/dist/types/model/nodelist.d.ts +0 -95
  49. package/dist/types/model/operation/attributeoperation.d.ts +0 -107
  50. package/dist/types/model/operation/detachoperation.d.ts +0 -64
  51. package/dist/types/model/operation/insertoperation.d.ts +0 -94
  52. package/dist/types/model/operation/markeroperation.d.ts +0 -95
  53. package/dist/types/model/operation/mergeoperation.d.ts +0 -104
  54. package/dist/types/model/operation/moveoperation.d.ts +0 -100
  55. package/dist/types/model/operation/nooperation.d.ts +0 -42
  56. package/dist/types/model/operation/operation.d.ts +0 -100
  57. package/dist/types/model/operation/operationfactory.d.ts +0 -22
  58. package/dist/types/model/operation/renameoperation.d.ts +0 -87
  59. package/dist/types/model/operation/rootattributeoperation.d.ts +0 -102
  60. package/dist/types/model/operation/rootoperation.d.ts +0 -80
  61. package/dist/types/model/operation/splitoperation.d.ts +0 -113
  62. package/dist/types/model/operation/transform.d.ts +0 -104
  63. package/dist/types/model/operation/utils.d.ts +0 -75
  64. package/dist/types/model/position.d.ts +0 -542
  65. package/dist/types/model/range.d.ts +0 -462
  66. package/dist/types/model/rootelement.d.ts +0 -64
  67. package/dist/types/model/schema.d.ts +0 -1210
  68. package/dist/types/model/selection.d.ts +0 -486
  69. package/dist/types/model/text.d.ts +0 -70
  70. package/dist/types/model/textproxy.d.ts +0 -148
  71. package/dist/types/model/treewalker.d.ts +0 -190
  72. package/dist/types/model/typecheckable.d.ts +0 -289
  73. package/dist/types/model/utils/autoparagraphing.d.ts +0 -41
  74. package/dist/types/model/utils/deletecontent.d.ts +0 -62
  75. package/dist/types/model/utils/getselectedcontent.d.ts +0 -34
  76. package/dist/types/model/utils/insertcontent.d.ts +0 -50
  77. package/dist/types/model/utils/insertobject.d.ts +0 -51
  78. package/dist/types/model/utils/modifyselection.d.ts +0 -52
  79. package/dist/types/model/utils/selection-post-fixer.d.ts +0 -78
  80. package/dist/types/model/writer.d.ts +0 -855
  81. package/dist/types/view/attributeelement.d.ts +0 -112
  82. package/dist/types/view/containerelement.d.ts +0 -53
  83. package/dist/types/view/datatransfer.d.ts +0 -83
  84. package/dist/types/view/document.d.ts +0 -188
  85. package/dist/types/view/documentfragment.d.ts +0 -157
  86. package/dist/types/view/documentselection.d.ts +0 -310
  87. package/dist/types/view/domconverter.d.ts +0 -656
  88. package/dist/types/view/downcastwriter.d.ts +0 -1000
  89. package/dist/types/view/editableelement.d.ts +0 -66
  90. package/dist/types/view/element.d.ts +0 -472
  91. package/dist/types/view/elementdefinition.d.ts +0 -91
  92. package/dist/types/view/emptyelement.d.ts +0 -45
  93. package/dist/types/view/filler.d.ts +0 -115
  94. package/dist/types/view/item.d.ts +0 -18
  95. package/dist/types/view/matcher.d.ts +0 -490
  96. package/dist/types/view/node.d.ts +0 -166
  97. package/dist/types/view/observer/arrowkeysobserver.d.ts +0 -49
  98. package/dist/types/view/observer/bubblingemittermixin.d.ts +0 -170
  99. package/dist/types/view/observer/bubblingeventinfo.d.ts +0 -51
  100. package/dist/types/view/observer/clickobserver.d.ts +0 -47
  101. package/dist/types/view/observer/compositionobserver.d.ts +0 -86
  102. package/dist/types/view/observer/domeventdata.d.ts +0 -54
  103. package/dist/types/view/observer/domeventobserver.d.ts +0 -77
  104. package/dist/types/view/observer/fakeselectionobserver.d.ts +0 -51
  105. package/dist/types/view/observer/focusobserver.d.ts +0 -86
  106. package/dist/types/view/observer/inputobserver.d.ts +0 -90
  107. package/dist/types/view/observer/keyobserver.d.ts +0 -70
  108. package/dist/types/view/observer/mouseobserver.d.ts +0 -93
  109. package/dist/types/view/observer/mutationobserver.d.ts +0 -90
  110. package/dist/types/view/observer/observer.d.ts +0 -93
  111. package/dist/types/view/observer/selectionobserver.d.ts +0 -152
  112. package/dist/types/view/observer/tabobserver.d.ts +0 -50
  113. package/dist/types/view/placeholder.d.ts +0 -100
  114. package/dist/types/view/position.d.ts +0 -192
  115. package/dist/types/view/range.d.ts +0 -283
  116. package/dist/types/view/rawelement.d.ts +0 -77
  117. package/dist/types/view/renderer.d.ts +0 -269
  118. package/dist/types/view/rooteditableelement.d.ts +0 -45
  119. package/dist/types/view/selection.d.ts +0 -379
  120. package/dist/types/view/styles/background.d.ts +0 -37
  121. package/dist/types/view/styles/border.d.ts +0 -47
  122. package/dist/types/view/styles/margin.d.ts +0 -33
  123. package/dist/types/view/styles/padding.d.ts +0 -33
  124. package/dist/types/view/styles/utils.d.ts +0 -97
  125. package/dist/types/view/stylesmap.d.ts +0 -677
  126. package/dist/types/view/text.d.ts +0 -78
  127. package/dist/types/view/textproxy.d.ts +0 -101
  128. package/dist/types/view/treewalker.d.ts +0 -199
  129. package/dist/types/view/typecheckable.d.ts +0 -452
  130. package/dist/types/view/uielement.d.ts +0 -100
  131. package/dist/types/view/upcastwriter.d.ts +0 -421
  132. package/dist/types/view/view.d.ts +0 -491
@@ -1,482 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module engine/conversion/conversion
11
- */
12
- import { type ArrayOrItem, type PriorityString } from '@ckeditor/ckeditor5-utils';
13
- import UpcastHelpers from './upcasthelpers.js';
14
- import DowncastHelpers, { type AttributeCreatorFunction, type AttributeDescriptor } from './downcasthelpers.js';
15
- import type DowncastDispatcher from './downcastdispatcher.js';
16
- import type UpcastDispatcher from './upcastdispatcher.js';
17
- import type ElementDefinition from '../view/elementdefinition.js';
18
- import type { MatcherPattern } from '../view/matcher.js';
19
- /**
20
- * A utility class that helps add converters to upcast and downcast dispatchers.
21
- *
22
- * We recommend reading the {@glink framework/deep-dive/conversion/intro editor conversion} guide first to
23
- * understand the core concepts of the conversion mechanisms.
24
- *
25
- * An instance of the conversion manager is available in the
26
- * {@link module:core/editor/editor~Editor#conversion `editor.conversion`} property
27
- * and by default has the following groups of dispatchers (i.e. directions of conversion):
28
- *
29
- * * `downcast` (editing and data downcasts)
30
- * * `editingDowncast`
31
- * * `dataDowncast`
32
- * * `upcast`
33
- *
34
- * # One-way converters
35
- *
36
- * To add a converter to a specific group, use the {@link module:engine/conversion/conversion~Conversion#for `for()`}
37
- * method:
38
- *
39
- * ```ts
40
- * // Add a converter to editing downcast and data downcast.
41
- * editor.conversion.for( 'downcast' ).elementToElement( config ) );
42
- *
43
- * // Add a converter to the data pipepline only:
44
- * editor.conversion.for( 'dataDowncast' ).elementToElement( dataConversionConfig ) );
45
- *
46
- * // And a slightly different one for the editing pipeline:
47
- * editor.conversion.for( 'editingDowncast' ).elementToElement( editingConversionConfig ) );
48
- * ```
49
- *
50
- * See {@link module:engine/conversion/conversion~Conversion#for `for()`} method documentation to learn more about
51
- * available conversion helpers and how to use your custom ones.
52
- *
53
- * # Two-way converters
54
- *
55
- * Besides using one-way converters via the `for()` method, you can also use other methods available in this
56
- * class to add two-way converters (upcast and downcast):
57
- *
58
- * * {@link module:engine/conversion/conversion~Conversion#elementToElement `elementToElement()`} –
59
- * Model element to view element and vice versa.
60
- * * {@link module:engine/conversion/conversion~Conversion#attributeToElement `attributeToElement()`} –
61
- * Model attribute to view element and vice versa.
62
- * * {@link module:engine/conversion/conversion~Conversion#attributeToAttribute `attributeToAttribute()`} –
63
- * Model attribute to view attribute and vice versa.
64
- */
65
- export default class Conversion {
66
- /**
67
- * Maps dispatchers group name to ConversionHelpers instances.
68
- */
69
- private readonly _helpers;
70
- private readonly _downcast;
71
- private readonly _upcast;
72
- /**
73
- * Creates a new conversion instance.
74
- */
75
- constructor(downcastDispatchers: ArrayOrItem<DowncastDispatcher>, upcastDispatchers: ArrayOrItem<UpcastDispatcher>);
76
- addAlias(alias: `${string}Downcast`, dispatcher: DowncastDispatcher): void;
77
- addAlias(alias: `${string}Upcast`, dispatcher: UpcastDispatcher): void;
78
- addAlias(alias: string, dispatcher: DowncastDispatcher | UpcastDispatcher): void;
79
- for(groupName: 'downcast' | 'dataDowncast' | 'editingDowncast'): DowncastHelpers;
80
- for(groupName: 'upcast'): UpcastHelpers;
81
- for<T extends string>(groupName: T): ConversionType<T>;
82
- /**
83
- * Sets up converters between the model and the view that convert a model element to a view element (and vice versa).
84
- * For example, the model `<paragraph>Foo</paragraph>` is turned into `<p>Foo</p>` in the view.
85
- *
86
- * ```ts
87
- * // A simple conversion from the `paragraph` model element to the `<p>` view element (and vice versa).
88
- * editor.conversion.elementToElement( { model: 'paragraph', view: 'p' } );
89
- *
90
- * // Override other converters by specifying a converter definition with a higher priority.
91
- * editor.conversion.elementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
92
- *
93
- * // View specified as an object instead of a string.
94
- * editor.conversion.elementToElement( {
95
- * model: 'fancyParagraph',
96
- * view: {
97
- * name: 'p',
98
- * classes: 'fancy'
99
- * }
100
- * } );
101
- *
102
- * // Use `upcastAlso` to define other view elements that should also be converted to a `paragraph` element.
103
- * editor.conversion.elementToElement( {
104
- * model: 'paragraph',
105
- * view: 'p',
106
- * upcastAlso: [
107
- * 'div',
108
- * {
109
- * // Any element with the `display: block` style.
110
- * styles: {
111
- * display: 'block'
112
- * }
113
- * }
114
- * ]
115
- * } );
116
- *
117
- * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
118
- * editor.conversion.elementToElement( {
119
- * model: 'heading',
120
- * view: 'h2',
121
- * // Convert "heading-like" paragraphs to headings.
122
- * upcastAlso: viewElement => {
123
- * const fontSize = viewElement.getStyle( 'font-size' );
124
- *
125
- * if ( !fontSize ) {
126
- * return null;
127
- * }
128
- *
129
- * const match = fontSize.match( /(\d+)\s*px/ );
130
- *
131
- * if ( !match ) {
132
- * return null;
133
- * }
134
- *
135
- * const size = Number( match[ 1 ] );
136
- *
137
- * if ( size > 26 ) {
138
- * // Returned value can be an object with the matched properties.
139
- * // These properties will be "consumed" during the conversion.
140
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
141
- *
142
- * return { name: true, styles: [ 'font-size' ] };
143
- * }
144
- *
145
- * return null;
146
- * }
147
- * } );
148
- * ```
149
- *
150
- * `definition.model` is a `String` with a model element name to convert from or to.
151
- *
152
- * @param definition The converter definition.
153
- */
154
- elementToElement(definition: {
155
- model: string;
156
- view: ElementDefinition;
157
- upcastAlso?: ArrayOrItem<ElementDefinition | MatcherPattern>;
158
- converterPriority?: PriorityString;
159
- }): void;
160
- /**
161
- * Sets up converters between the model and the view that convert a model attribute to a view element (and vice versa).
162
- * For example, a model text node with `"Foo"` as data and the `bold` attribute will be turned to `<strong>Foo</strong>` in the view.
163
- *
164
- * ```ts
165
- * // A simple conversion from the `bold=true` attribute to the `<strong>` view element (and vice versa).
166
- * editor.conversion.attributeToElement( { model: 'bold', view: 'strong' } );
167
- *
168
- * // Override other converters by specifying a converter definition with a higher priority.
169
- * editor.conversion.attributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
170
- *
171
- * // View specified as an object instead of a string.
172
- * editor.conversion.attributeToElement( {
173
- * model: 'bold',
174
- * view: {
175
- * name: 'span',
176
- * classes: 'bold'
177
- * }
178
- * } );
179
- *
180
- * // Use `config.model.name` to define the conversion only from a given node type, `$text` in this case.
181
- * // The same attribute on different elements may then be handled by a different converter.
182
- * editor.conversion.attributeToElement( {
183
- * model: {
184
- * key: 'textDecoration',
185
- * values: [ 'underline', 'lineThrough' ],
186
- * name: '$text'
187
- * },
188
- * view: {
189
- * underline: {
190
- * name: 'span',
191
- * styles: {
192
- * 'text-decoration': 'underline'
193
- * }
194
- * },
195
- * lineThrough: {
196
- * name: 'span',
197
- * styles: {
198
- * 'text-decoration': 'line-through'
199
- * }
200
- * }
201
- * }
202
- * } );
203
- *
204
- * // Use `upcastAlso` to define other view elements that should also be converted to the `bold` attribute.
205
- * editor.conversion.attributeToElement( {
206
- * model: 'bold',
207
- * view: 'strong',
208
- * upcastAlso: [
209
- * 'b',
210
- * {
211
- * name: 'span',
212
- * classes: 'bold'
213
- * },
214
- * {
215
- * name: 'span',
216
- * styles: {
217
- * 'font-weight': 'bold'
218
- * }
219
- * },
220
- * viewElement => {
221
- * const fontWeight = viewElement.getStyle( 'font-weight' );
222
- *
223
- * if ( viewElement.is( 'element', 'span' ) && fontWeight && /\d+/.test() && Number( fontWeight ) > 500 ) {
224
- * // Returned value can be an object with the matched properties.
225
- * // These properties will be "consumed" during the conversion.
226
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
227
- *
228
- * return {
229
- * name: true,
230
- * styles: [ 'font-weight' ]
231
- * };
232
- * }
233
- * }
234
- * ]
235
- * } );
236
- *
237
- * // Conversion from and to a model attribute key whose value is an enum (`fontSize=big|small`).
238
- * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
239
- * editor.conversion.attributeToElement( {
240
- * model: {
241
- * key: 'fontSize',
242
- * values: [ 'big', 'small' ]
243
- * },
244
- * view: {
245
- * big: {
246
- * name: 'span',
247
- * styles: {
248
- * 'font-size': '1.2em'
249
- * }
250
- * },
251
- * small: {
252
- * name: 'span',
253
- * styles: {
254
- * 'font-size': '0.8em'
255
- * }
256
- * }
257
- * },
258
- * upcastAlso: {
259
- * big: viewElement => {
260
- * const fontSize = viewElement.getStyle( 'font-size' );
261
- *
262
- * if ( !fontSize ) {
263
- * return null;
264
- * }
265
- *
266
- * const match = fontSize.match( /(\d+)\s*px/ );
267
- *
268
- * if ( !match ) {
269
- * return null;
270
- * }
271
- *
272
- * const size = Number( match[ 1 ] );
273
- *
274
- * if ( viewElement.is( 'element', 'span' ) && size > 10 ) {
275
- * // Returned value can be an object with the matched properties.
276
- * // These properties will be "consumed" during the conversion.
277
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
278
- *
279
- * return { name: true, styles: [ 'font-size' ] };
280
- * }
281
- *
282
- * return null;
283
- * },
284
- * small: viewElement => {
285
- * const fontSize = viewElement.getStyle( 'font-size' );
286
- *
287
- * if ( !fontSize ) {
288
- * return null;
289
- * }
290
- *
291
- * const match = fontSize.match( /(\d+)\s*px/ );
292
- *
293
- * if ( !match ) {
294
- * return null;
295
- * }
296
- *
297
- * const size = Number( match[ 1 ] );
298
- *
299
- * if ( viewElement.is( 'element', 'span' ) && size < 10 ) {
300
- * // Returned value can be an object with the matched properties.
301
- * // These properties will be "consumed" during the conversion.
302
- * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
303
- *
304
- * return { name: true, styles: [ 'font-size' ] };
305
- * }
306
- *
307
- * return null;
308
- * }
309
- * }
310
- * } );
311
- * ```
312
- *
313
- * The `definition.model` parameter specifies which model attribute should be converted from or to. It can be a `{ key, value }` object
314
- * describing the attribute key and value to convert or a `String` specifying just the attribute key (in such a case
315
- * `value` is set to `true`).
316
- *
317
- * @param definition The converter definition.
318
- */
319
- attributeToElement<TValues extends string>(definition: {
320
- model: string | {
321
- key: string;
322
- name?: string;
323
- };
324
- view: ElementDefinition;
325
- upcastAlso?: ArrayOrItem<MatcherPattern>;
326
- converterPriority?: PriorityString;
327
- } | {
328
- model: {
329
- key: string;
330
- name?: string;
331
- values: Array<TValues>;
332
- };
333
- view: Record<TValues, ElementDefinition>;
334
- upcastAlso?: Record<TValues, ArrayOrItem<MatcherPattern>>;
335
- converterPriority?: PriorityString;
336
- }): void;
337
- /**
338
- * Sets up converters between the model and the view that convert a model attribute to a view attribute (and vice versa). For example,
339
- * `<imageBlock src='foo.jpg'></imageBlock>` is converted to `<img src='foo.jpg'></img>` (the same attribute key and value).
340
- * This type of converters is intended to be used with {@link module:engine/model/element~Element model element} nodes.
341
- * To convert the text attributes,
342
- * the {@link module:engine/conversion/conversion~Conversion#attributeToElement `attributeToElement converter`}should be set up.
343
- *
344
- * ```ts
345
- * // A simple conversion from the `source` model attribute to the `src` view attribute (and vice versa).
346
- * editor.conversion.attributeToAttribute( { model: 'source', view: 'src' } );
347
- *
348
- * // Attribute values are strictly specified.
349
- * editor.conversion.attributeToAttribute( {
350
- * model: {
351
- * name: 'imageInline',
352
- * key: 'aside',
353
- * values: [ 'aside' ]
354
- * },
355
- * view: {
356
- * aside: {
357
- * name: 'img',
358
- * key: 'class',
359
- * value: [ 'aside', 'half-size' ]
360
- * }
361
- * }
362
- * } );
363
- *
364
- * // Set the style attribute.
365
- * editor.conversion.attributeToAttribute( {
366
- * model: {
367
- * name: 'imageInline',
368
- * key: 'aside',
369
- * values: [ 'aside' ]
370
- * },
371
- * view: {
372
- * aside: {
373
- * name: 'img',
374
- * key: 'style',
375
- * value: {
376
- * float: 'right',
377
- * width: '50%',
378
- * margin: '5px'
379
- * }
380
- * }
381
- * }
382
- * } );
383
- *
384
- * // Conversion from and to a model attribute key whose value is an enum (`align=right|center`).
385
- * // Use `upcastAlso` to define other view elements that should also be converted to the `align=right` attribute.
386
- * editor.conversion.attributeToAttribute( {
387
- * model: {
388
- * key: 'align',
389
- * values: [ 'right', 'center' ]
390
- * },
391
- * view: {
392
- * right: {
393
- * key: 'class',
394
- * value: 'align-right'
395
- * },
396
- * center: {
397
- * key: 'class',
398
- * value: 'align-center'
399
- * }
400
- * },
401
- * upcastAlso: {
402
- * right: {
403
- * styles: {
404
- * 'text-align': 'right'
405
- * }
406
- * },
407
- * center: {
408
- * styles: {
409
- * 'text-align': 'center'
410
- * }
411
- * }
412
- * }
413
- * } );
414
- * ```
415
- *
416
- * The `definition.model` parameter specifies which model attribute should be converted from and to.
417
- * It can be a `{ key, [ values ], [ name ] }` object or a `String`, which will be treated like `{ key: definition.model }`.
418
- * The `key` property is the model attribute key to convert from and to.
419
- * The `values` are the possible model attribute values. If the `values` parameter is not set, the model attribute value
420
- * will be the same as the view attribute value.
421
- * If `name` is set, the conversion will be set up only for model elements with the given name.
422
- *
423
- * The `definition.view` parameter specifies which view attribute should be converted from and to.
424
- * It can be a `{ key, value, [ name ] }` object or a `String`, which will be treated like `{ key: definition.view }`.
425
- * The `key` property is the view attribute key to convert from and to.
426
- * The `value` is the view attribute value to convert from and to. If `definition.value` is not set, the view attribute value will be
427
- * the same as the model attribute value.
428
- * If `key` is `'class'`, `value` can be a `String` or an array of `String`s.
429
- * If `key` is `'style'`, `value` is an object with key-value pairs.
430
- * In other cases, `value` is a `String`.
431
- * If `name` is set, the conversion will be set up only for model elements with the given name.
432
- * If `definition.model.values` is set, `definition.view` is an object that assigns values from `definition.model.values`
433
- * to `{ key, value, [ name ] }` objects.
434
- *
435
- * `definition.upcastAlso` specifies which other matching view elements should also be upcast to the given model configuration.
436
- * If `definition.model.values` is set, `definition.upcastAlso` should be an object assigning values from `definition.model.values`
437
- * to {@link module:engine/view/matcher~MatcherPattern}s or arrays of {@link module:engine/view/matcher~MatcherPattern}s.
438
- *
439
- * **Note:** `definition.model` and `definition.view` form should be mirrored, so the same types of parameters should
440
- * be given in both parameters.
441
- *
442
- * @param definition The converter definition.
443
- * @param definition.model The model attribute to convert from and to.
444
- * @param definition.view The view attribute to convert from and to.
445
- * @param definition.upcastAlso Any view element matching `definition.upcastAlso` will also be converted to the given model attribute.
446
- * `definition.upcastAlso` is used only if `config.model.values` is specified.
447
- */
448
- attributeToAttribute<TValues extends string>(definition: {
449
- model: string | {
450
- key: string;
451
- name?: string;
452
- };
453
- view: string | (AttributeDescriptor & {
454
- name?: string;
455
- });
456
- upcastAlso?: ArrayOrItem<string | (AttributeDescriptor & {
457
- name?: string;
458
- }) | AttributeCreatorFunction>;
459
- converterPriority?: PriorityString;
460
- } | {
461
- model: {
462
- key: string;
463
- name?: string;
464
- values: Array<TValues>;
465
- };
466
- view: Record<TValues, (AttributeDescriptor & {
467
- name?: string;
468
- })>;
469
- upcastAlso?: Record<TValues, (AttributeDescriptor & {
470
- name?: string;
471
- }) | AttributeCreatorFunction>;
472
- converterPriority?: PriorityString;
473
- }): void;
474
- /**
475
- * Creates and caches conversion helpers for given dispatchers group.
476
- *
477
- * @param options.name Group name.
478
- */
479
- private _createConversionHelpers;
480
- }
481
- type ConversionType<T extends string> = T extends `${string}Downcast` ? DowncastHelpers : T extends `${string}Upcast` ? UpcastHelpers : DowncastHelpers | UpcastHelpers;
482
- export {};
@@ -1,30 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module engine/conversion/conversionhelpers
11
- */
12
- /**
13
- * Base class for conversion helpers.
14
- */
15
- export default class ConversionHelpers<TDispatcher> {
16
- private readonly _dispatchers;
17
- /**
18
- * Creates a conversion helpers instance.
19
- */
20
- constructor(dispatchers: Array<TDispatcher>);
21
- /**
22
- * Registers a conversion helper.
23
- *
24
- * **Note**: See full usage example in the `{@link module:engine/conversion/conversion~Conversion#for conversion.for()}`
25
- * method description.
26
- *
27
- * @param conversionHelper The function to be called on event.
28
- */
29
- add(conversionHelper: (dispatcher: TDispatcher) => void): this;
30
- }