@ckeditor/ckeditor5-engine 41.2.0 → 41.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 (134) hide show
  1. package/dist/content-index.css +4 -0
  2. package/dist/editor-index.css +23 -0
  3. package/dist/index.css +49 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.js +36728 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/types/controller/datacontroller.d.ts +335 -0
  8. package/dist/types/controller/editingcontroller.d.ts +98 -0
  9. package/dist/types/conversion/conversion.d.ts +478 -0
  10. package/dist/types/conversion/conversionhelpers.d.ts +26 -0
  11. package/dist/types/conversion/downcastdispatcher.d.ts +562 -0
  12. package/dist/types/conversion/downcasthelpers.d.ts +1190 -0
  13. package/dist/types/conversion/mapper.d.ts +503 -0
  14. package/dist/types/conversion/modelconsumable.d.ts +201 -0
  15. package/dist/types/conversion/upcastdispatcher.d.ts +492 -0
  16. package/dist/types/conversion/upcasthelpers.d.ts +499 -0
  17. package/dist/types/conversion/viewconsumable.d.ts +369 -0
  18. package/dist/types/dataprocessor/basichtmlwriter.d.ts +18 -0
  19. package/dist/types/dataprocessor/dataprocessor.d.ts +61 -0
  20. package/dist/types/dataprocessor/htmldataprocessor.d.ts +76 -0
  21. package/dist/types/dataprocessor/htmlwriter.d.ts +16 -0
  22. package/dist/types/dataprocessor/xmldataprocessor.d.ts +90 -0
  23. package/dist/types/dev-utils/model.d.ts +124 -0
  24. package/dist/types/dev-utils/operationreplayer.d.ts +51 -0
  25. package/dist/types/dev-utils/utils.d.ts +37 -0
  26. package/dist/types/dev-utils/view.d.ts +319 -0
  27. package/dist/types/index.d.ts +113 -0
  28. package/dist/types/model/batch.d.ts +106 -0
  29. package/dist/types/model/differ.d.ts +415 -0
  30. package/dist/types/model/document.d.ts +274 -0
  31. package/dist/types/model/documentfragment.d.ts +200 -0
  32. package/dist/types/model/documentselection.d.ts +420 -0
  33. package/dist/types/model/element.d.ts +165 -0
  34. package/dist/types/model/history.d.ts +114 -0
  35. package/dist/types/model/item.d.ts +14 -0
  36. package/dist/types/model/liveposition.d.ts +77 -0
  37. package/dist/types/model/liverange.d.ts +102 -0
  38. package/dist/types/model/markercollection.d.ts +335 -0
  39. package/dist/types/model/model.d.ts +919 -0
  40. package/dist/types/model/node.d.ts +255 -0
  41. package/dist/types/model/nodelist.d.ts +91 -0
  42. package/dist/types/model/operation/attributeoperation.d.ts +103 -0
  43. package/dist/types/model/operation/detachoperation.d.ts +60 -0
  44. package/dist/types/model/operation/insertoperation.d.ts +90 -0
  45. package/dist/types/model/operation/markeroperation.d.ts +91 -0
  46. package/dist/types/model/operation/mergeoperation.d.ts +100 -0
  47. package/dist/types/model/operation/moveoperation.d.ts +96 -0
  48. package/dist/types/model/operation/nooperation.d.ts +38 -0
  49. package/dist/types/model/operation/operation.d.ts +96 -0
  50. package/dist/types/model/operation/operationfactory.d.ts +18 -0
  51. package/dist/types/model/operation/renameoperation.d.ts +83 -0
  52. package/dist/types/model/operation/rootattributeoperation.d.ts +98 -0
  53. package/dist/types/model/operation/rootoperation.d.ts +76 -0
  54. package/dist/types/model/operation/splitoperation.d.ts +109 -0
  55. package/dist/types/model/operation/transform.d.ts +100 -0
  56. package/dist/types/model/operation/utils.d.ts +71 -0
  57. package/dist/types/model/position.d.ts +538 -0
  58. package/dist/types/model/range.d.ts +458 -0
  59. package/dist/types/model/rootelement.d.ts +60 -0
  60. package/dist/types/model/schema.d.ts +1206 -0
  61. package/dist/types/model/selection.d.ts +482 -0
  62. package/dist/types/model/text.d.ts +66 -0
  63. package/dist/types/model/textproxy.d.ts +144 -0
  64. package/dist/types/model/treewalker.d.ts +186 -0
  65. package/dist/types/model/typecheckable.d.ts +285 -0
  66. package/dist/types/model/utils/autoparagraphing.d.ts +37 -0
  67. package/dist/types/model/utils/deletecontent.d.ts +58 -0
  68. package/dist/types/model/utils/getselectedcontent.d.ts +30 -0
  69. package/dist/types/model/utils/insertcontent.d.ts +46 -0
  70. package/dist/types/model/utils/insertobject.d.ts +47 -0
  71. package/dist/types/model/utils/modifyselection.d.ts +48 -0
  72. package/dist/types/model/utils/selection-post-fixer.d.ts +74 -0
  73. package/dist/types/model/writer.d.ts +851 -0
  74. package/dist/types/view/attributeelement.d.ts +108 -0
  75. package/dist/types/view/containerelement.d.ts +49 -0
  76. package/dist/types/view/datatransfer.d.ts +79 -0
  77. package/dist/types/view/document.d.ts +184 -0
  78. package/dist/types/view/documentfragment.d.ts +153 -0
  79. package/dist/types/view/documentselection.d.ts +306 -0
  80. package/dist/types/view/domconverter.d.ts +652 -0
  81. package/dist/types/view/downcastwriter.d.ts +996 -0
  82. package/dist/types/view/editableelement.d.ts +62 -0
  83. package/dist/types/view/element.d.ts +468 -0
  84. package/dist/types/view/elementdefinition.d.ts +87 -0
  85. package/dist/types/view/emptyelement.d.ts +41 -0
  86. package/dist/types/view/filler.d.ts +111 -0
  87. package/dist/types/view/item.d.ts +14 -0
  88. package/dist/types/view/matcher.d.ts +486 -0
  89. package/dist/types/view/node.d.ts +162 -0
  90. package/dist/types/view/observer/arrowkeysobserver.d.ts +45 -0
  91. package/dist/types/view/observer/bubblingemittermixin.d.ts +166 -0
  92. package/dist/types/view/observer/bubblingeventinfo.d.ts +47 -0
  93. package/dist/types/view/observer/clickobserver.d.ts +43 -0
  94. package/dist/types/view/observer/compositionobserver.d.ts +82 -0
  95. package/dist/types/view/observer/domeventdata.d.ts +50 -0
  96. package/dist/types/view/observer/domeventobserver.d.ts +73 -0
  97. package/dist/types/view/observer/fakeselectionobserver.d.ts +47 -0
  98. package/dist/types/view/observer/focusobserver.d.ts +82 -0
  99. package/dist/types/view/observer/inputobserver.d.ts +86 -0
  100. package/dist/types/view/observer/keyobserver.d.ts +66 -0
  101. package/dist/types/view/observer/mouseobserver.d.ts +89 -0
  102. package/dist/types/view/observer/mutationobserver.d.ts +86 -0
  103. package/dist/types/view/observer/observer.d.ts +89 -0
  104. package/dist/types/view/observer/selectionobserver.d.ts +148 -0
  105. package/dist/types/view/observer/tabobserver.d.ts +46 -0
  106. package/dist/types/view/placeholder.d.ts +96 -0
  107. package/dist/types/view/position.d.ts +188 -0
  108. package/dist/types/view/range.d.ts +279 -0
  109. package/dist/types/view/rawelement.d.ts +73 -0
  110. package/dist/types/view/renderer.d.ts +265 -0
  111. package/dist/types/view/rooteditableelement.d.ts +41 -0
  112. package/dist/types/view/selection.d.ts +375 -0
  113. package/dist/types/view/styles/background.d.ts +33 -0
  114. package/dist/types/view/styles/border.d.ts +43 -0
  115. package/dist/types/view/styles/margin.d.ts +29 -0
  116. package/dist/types/view/styles/padding.d.ts +29 -0
  117. package/dist/types/view/styles/utils.d.ts +93 -0
  118. package/dist/types/view/stylesmap.d.ts +673 -0
  119. package/dist/types/view/text.d.ts +74 -0
  120. package/dist/types/view/textproxy.d.ts +97 -0
  121. package/dist/types/view/treewalker.d.ts +195 -0
  122. package/dist/types/view/typecheckable.d.ts +448 -0
  123. package/dist/types/view/uielement.d.ts +96 -0
  124. package/dist/types/view/upcastwriter.d.ts +417 -0
  125. package/dist/types/view/view.d.ts +487 -0
  126. package/package.json +3 -2
  127. package/src/model/node.d.ts +0 -1
  128. package/src/model/node.js +0 -2
  129. package/src/model/position.d.ts +0 -1
  130. package/src/model/position.js +0 -2
  131. package/src/view/node.d.ts +0 -1
  132. package/src/view/node.js +0 -2
  133. package/src/view/position.d.ts +0 -1
  134. package/src/view/position.js +0 -2
@@ -0,0 +1,1190 @@
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
+ * Contains downcast (model-to-view) converters for {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher}.
7
+ *
8
+ * @module engine/conversion/downcasthelpers
9
+ */
10
+ import ModelRange from '../model/range.js';
11
+ import ModelSelection from '../model/selection.js';
12
+ import ModelDocumentSelection from '../model/documentselection.js';
13
+ import ModelElement from '../model/element.js';
14
+ import ModelPosition from '../model/position.js';
15
+ import ViewAttributeElement from '../view/attributeelement.js';
16
+ import ConversionHelpers from './conversionhelpers.js';
17
+ import type { default as DowncastDispatcher, DowncastConversionApi } from './downcastdispatcher.js';
18
+ import type ModelConsumable from './modelconsumable.js';
19
+ import type ModelNode from '../model/node.js';
20
+ import type ModelItem from '../model/item.js';
21
+ import type ModelTextProxy from '../model/textproxy.js';
22
+ import type ModelText from '../model/text.js';
23
+ import type DowncastWriter from '../view/downcastwriter.js';
24
+ import type ElementDefinition from '../view/elementdefinition.js';
25
+ import type UIElement from '../view/uielement.js';
26
+ import type ViewElement from '../view/element.js';
27
+ import { type EventInfo, type PriorityString } from '@ckeditor/ckeditor5-utils';
28
+ /**
29
+ * Downcast conversion helper functions.
30
+ *
31
+ * Learn more about {@glink framework/deep-dive/conversion/downcast downcast helpers}.
32
+ *
33
+ * @extends module:engine/conversion/conversionhelpers~ConversionHelpers
34
+ */
35
+ export default class DowncastHelpers extends ConversionHelpers<DowncastDispatcher> {
36
+ /**
37
+ * Model element to view element conversion helper.
38
+ *
39
+ * This conversion results in creating a view element. For example, model `<paragraph>Foo</paragraph>` becomes `<p>Foo</p>` in the view.
40
+ *
41
+ * ```ts
42
+ * editor.conversion.for( 'downcast' ).elementToElement( {
43
+ * model: 'paragraph',
44
+ * view: 'p'
45
+ * } );
46
+ *
47
+ * editor.conversion.for( 'downcast' ).elementToElement( {
48
+ * model: 'paragraph',
49
+ * view: 'div',
50
+ * converterPriority: 'high'
51
+ * } );
52
+ *
53
+ * editor.conversion.for( 'downcast' ).elementToElement( {
54
+ * model: 'fancyParagraph',
55
+ * view: {
56
+ * name: 'p',
57
+ * classes: 'fancy'
58
+ * }
59
+ * } );
60
+ *
61
+ * editor.conversion.for( 'downcast' ).elementToElement( {
62
+ * model: 'heading',
63
+ * view: ( modelElement, conversionApi ) => {
64
+ * const { writer } = conversionApi;
65
+ *
66
+ * return writer.createContainerElement( 'h' + modelElement.getAttribute( 'level' ) );
67
+ * }
68
+ * } );
69
+ * ```
70
+ *
71
+ * The element-to-element conversion supports the reconversion mechanism. It can be enabled by using either the `attributes` or
72
+ * the `children` props on a model description. You will find a couple examples below.
73
+ *
74
+ * In order to reconvert an element if any of its direct children have been added or removed, use the `children` property on a `model`
75
+ * description. For example, this model:
76
+ *
77
+ * ```xml
78
+ * <box>
79
+ * <paragraph>Some text.</paragraph>
80
+ * </box>
81
+ * ```
82
+ *
83
+ * will be converted into this structure in the view:
84
+ *
85
+ * ```html
86
+ * <div class="box" data-type="single">
87
+ * <p>Some text.</p>
88
+ * </div>
89
+ * ```
90
+ *
91
+ * But if more items were inserted in the model:
92
+ *
93
+ * ```xml
94
+ * <box>
95
+ * <paragraph>Some text.</paragraph>
96
+ * <paragraph>Other item.</paragraph>
97
+ * </box>
98
+ * ```
99
+ *
100
+ * it will be converted into this structure in the view (note the element `data-type` change):
101
+ *
102
+ * ```html
103
+ * <div class="box" data-type="multiple">
104
+ * <p>Some text.</p>
105
+ * <p>Other item.</p>
106
+ * </div>
107
+ * ```
108
+ *
109
+ * Such a converter would look like this (note that the `paragraph` elements are converted separately):
110
+ *
111
+ * ```ts
112
+ * editor.conversion.for( 'downcast' ).elementToElement( {
113
+ * model: {
114
+ * name: 'box',
115
+ * children: true
116
+ * },
117
+ * view: ( modelElement, conversionApi ) => {
118
+ * const { writer } = conversionApi;
119
+ *
120
+ * return writer.createContainerElement( 'div', {
121
+ * class: 'box',
122
+ * 'data-type': modelElement.childCount == 1 ? 'single' : 'multiple'
123
+ * } );
124
+ * }
125
+ * } );
126
+ * ```
127
+ *
128
+ * In order to reconvert element if any of its attributes have been updated, use the `attributes` property on a `model`
129
+ * description. For example, this model:
130
+ *
131
+ * ```xml
132
+ * <heading level="2">Some text.</heading>
133
+ * ```
134
+ *
135
+ * will be converted into this structure in the view:
136
+ *
137
+ * ```html
138
+ * <h2>Some text.</h2>
139
+ * ```
140
+ *
141
+ * But if the `heading` element's `level` attribute has been updated to `3` for example, then
142
+ * it will be converted into this structure in the view:
143
+ *
144
+ * ```html
145
+ * <h3>Some text.</h3>
146
+ * ```
147
+ *
148
+ * Such a converter would look as follows:
149
+ *
150
+ * ```ts
151
+ * editor.conversion.for( 'downcast' ).elementToElement( {
152
+ * model: {
153
+ * name: 'heading',
154
+ * attributes: 'level'
155
+ * },
156
+ * view: ( modelElement, conversionApi ) => {
157
+ * const { writer } = conversionApi;
158
+ *
159
+ * return writer.createContainerElement( 'h' + modelElement.getAttribute( 'level' ) );
160
+ * }
161
+ * } );
162
+ * ```
163
+ *
164
+ * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
165
+ * to the conversion process.
166
+ *
167
+ * You can read more about the element-to-element conversion in the
168
+ * {@glink framework/deep-dive/conversion/downcast downcast conversion} guide.
169
+ *
170
+ * @param config Conversion configuration.
171
+ * @param config.model The description or a name of the model element to convert.
172
+ * @param config.model.attributes The list of attribute names that should be consumed while creating
173
+ * the view element. Note that the view will be reconverted if any of the listed attributes changes.
174
+ * @param config.model.children Specifies whether the view element requires reconversion if the list
175
+ * of the model child nodes changed.
176
+ * @param config.view A view element definition or a function that takes the model element and
177
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API}
178
+ * as parameters and returns a view container element.
179
+ */
180
+ elementToElement(config: {
181
+ model: string | {
182
+ name: string;
183
+ attributes?: string | Array<string>;
184
+ children?: boolean;
185
+ };
186
+ view: ElementDefinition | ElementCreatorFunction;
187
+ converterPriority?: PriorityString;
188
+ }): this;
189
+ /**
190
+ * The model element to view structure (several elements) conversion helper.
191
+ *
192
+ * This conversion results in creating a view structure with one or more slots defined for the child nodes.
193
+ * For example, a model `<table>` may become this structure in the view:
194
+ *
195
+ * ```html
196
+ * <figure class="table">
197
+ * <table>
198
+ * <tbody>${ slot for table rows }</tbody>
199
+ * </table>
200
+ * </figure>
201
+ * ```
202
+ *
203
+ * The children of the model's `<table>` element will be inserted into the `<tbody>` element.
204
+ * If the `elementToElement()` helper was used, the children would be inserted into the `<figure>`.
205
+ *
206
+ * Imagine a table feature where for this model structure:
207
+ *
208
+ * ```xml
209
+ * <table headingRows="1">
210
+ * <tableRow> ... table cells 1 ... </tableRow>
211
+ * <tableRow> ... table cells 2 ... </tableRow>
212
+ * <tableRow> ... table cells 3 ... </tableRow>
213
+ * <caption>Caption text</caption>
214
+ * </table>
215
+ * ```
216
+ *
217
+ * we want to generate this view structure:
218
+ *
219
+ * ```html
220
+ * <figure class="table">
221
+ * <table>
222
+ * <thead>
223
+ * <tr> ... table cells 1 ... </tr>
224
+ * </thead>
225
+ * <tbody>
226
+ * <tr> ... table cells 2 ... </tr>
227
+ * <tr> ... table cells 3 ... </tr>
228
+ * </tbody>
229
+ * </table>
230
+ * <figcaption>Caption text</figcaption>
231
+ * </figure>
232
+ * ```
233
+ *
234
+ * The converter has to take the `headingRows` attribute into consideration when allocating the `<tableRow>` elements
235
+ * into the `<tbody>` and `<thead>` elements. Hence, we need two slots and need to define proper filter callbacks for them.
236
+ *
237
+ * Additionally, all elements other than `<tableRow>` should be placed outside the `<table>` tag.
238
+ * In the example above, this will handle the table caption.
239
+ *
240
+ * Such a converter would look like this:
241
+ *
242
+ * ```ts
243
+ * editor.conversion.for( 'downcast' ).elementToStructure( {
244
+ * model: {
245
+ * name: 'table',
246
+ * attributes: [ 'headingRows' ]
247
+ * },
248
+ * view: ( modelElement, conversionApi ) => {
249
+ * const { writer } = conversionApi;
250
+ *
251
+ * const figureElement = writer.createContainerElement( 'figure', { class: 'table' } );
252
+ * const tableElement = writer.createContainerElement( 'table' );
253
+ *
254
+ * writer.insert( writer.createPositionAt( figureElement, 0 ), tableElement );
255
+ *
256
+ * const headingRows = modelElement.getAttribute( 'headingRows' ) || 0;
257
+ *
258
+ * if ( headingRows > 0 ) {
259
+ * const tableHead = writer.createContainerElement( 'thead' );
260
+ *
261
+ * const headSlot = writer.createSlot( node => node.is( 'element', 'tableRow' ) && node.index < headingRows );
262
+ *
263
+ * writer.insert( writer.createPositionAt( tableElement, 'end' ), tableHead );
264
+ * writer.insert( writer.createPositionAt( tableHead, 0 ), headSlot );
265
+ * }
266
+ *
267
+ * if ( headingRows < tableUtils.getRows( table ) ) {
268
+ * const tableBody = writer.createContainerElement( 'tbody' );
269
+ *
270
+ * const bodySlot = writer.createSlot( node => node.is( 'element', 'tableRow' ) && node.index >= headingRows );
271
+ *
272
+ * writer.insert( writer.createPositionAt( tableElement, 'end' ), tableBody );
273
+ * writer.insert( writer.createPositionAt( tableBody, 0 ), bodySlot );
274
+ * }
275
+ *
276
+ * const restSlot = writer.createSlot( node => !node.is( 'element', 'tableRow' ) );
277
+ *
278
+ * writer.insert( writer.createPositionAt( figureElement, 'end' ), restSlot );
279
+ *
280
+ * return figureElement;
281
+ * }
282
+ * } );
283
+ * ```
284
+ *
285
+ * Note: The children of a model element that's being converted must be allocated in the same order in the view
286
+ * in which they are placed in the model.
287
+ *
288
+ * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
289
+ * to the conversion process.
290
+ *
291
+ * @param config Conversion configuration.
292
+ * @param config.model The description or a name of the model element to convert.
293
+ * @param config.model.name The name of the model element to convert.
294
+ * @param config.model.attributes The list of attribute names that should be consumed while creating
295
+ * the view structure. Note that the view will be reconverted if any of the listed attributes will change.
296
+ * @param config.view A function that takes the model element and
297
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API} as parameters
298
+ * and returns a view container element with slots for model child nodes to be converted into.
299
+ */
300
+ elementToStructure(config: {
301
+ model: string | {
302
+ name: string;
303
+ attributes?: string | Array<string>;
304
+ };
305
+ view: StructureCreatorFunction;
306
+ converterPriority?: PriorityString;
307
+ }): this;
308
+ /**
309
+ * Model attribute to view element conversion helper.
310
+ *
311
+ * This conversion results in wrapping view nodes with a view attribute element. For example, a model text node with
312
+ * `"Foo"` as data and the `bold` attribute becomes `<strong>Foo</strong>` in the view.
313
+ *
314
+ * ```ts
315
+ * editor.conversion.for( 'downcast' ).attributeToElement( {
316
+ * model: 'bold',
317
+ * view: 'strong'
318
+ * } );
319
+ *
320
+ * editor.conversion.for( 'downcast' ).attributeToElement( {
321
+ * model: 'bold',
322
+ * view: 'b',
323
+ * converterPriority: 'high'
324
+ * } );
325
+ *
326
+ * editor.conversion.for( 'downcast' ).attributeToElement( {
327
+ * model: 'invert',
328
+ * view: {
329
+ * name: 'span',
330
+ * classes: [ 'font-light', 'bg-dark' ]
331
+ * }
332
+ * } );
333
+ *
334
+ * editor.conversion.for( 'downcast' ).attributeToElement( {
335
+ * model: {
336
+ * key: 'fontSize',
337
+ * values: [ 'big', 'small' ]
338
+ * },
339
+ * view: {
340
+ * big: {
341
+ * name: 'span',
342
+ * styles: {
343
+ * 'font-size': '1.2em'
344
+ * }
345
+ * },
346
+ * small: {
347
+ * name: 'span',
348
+ * styles: {
349
+ * 'font-size': '0.8em'
350
+ * }
351
+ * }
352
+ * }
353
+ * } );
354
+ *
355
+ * editor.conversion.for( 'downcast' ).attributeToElement( {
356
+ * model: 'bold',
357
+ * view: ( modelAttributeValue, conversionApi ) => {
358
+ * const { writer } = conversionApi;
359
+ *
360
+ * return writer.createAttributeElement( 'span', {
361
+ * style: 'font-weight:' + modelAttributeValue
362
+ * } );
363
+ * }
364
+ * } );
365
+ *
366
+ * editor.conversion.for( 'downcast' ).attributeToElement( {
367
+ * model: {
368
+ * key: 'color',
369
+ * name: '$text'
370
+ * },
371
+ * view: ( modelAttributeValue, conversionApi ) => {
372
+ * const { writer } = conversionApi;
373
+ *
374
+ * return writer.createAttributeElement( 'span', {
375
+ * style: 'color:' + modelAttributeValue
376
+ * } );
377
+ * }
378
+ * } );
379
+ * ```
380
+ *
381
+ * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
382
+ * to the conversion process.
383
+ *
384
+ * @param config Conversion configuration.
385
+ * @param config.model The key of the attribute to convert from or a `{ key, values }` object. `values` is an array
386
+ * of `String`s with possible values if the model attribute is an enumerable.
387
+ * @param config.view A view element definition or a function
388
+ * that takes the model attribute value and
389
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API} as parameters and returns a view
390
+ * attribute element. If `config.model.values` is given, `config.view` should be an object assigning values from `config.model.values`
391
+ * to view element definitions or functions.
392
+ * @param config.converterPriority Converter priority.
393
+ */
394
+ attributeToElement<TValues extends string>(config: {
395
+ model: string | {
396
+ key: string;
397
+ name?: string;
398
+ };
399
+ view: ElementDefinition | AttributeElementCreatorFunction;
400
+ converterPriority?: PriorityString;
401
+ } | {
402
+ model: {
403
+ key: string;
404
+ name?: string;
405
+ values: Array<TValues>;
406
+ };
407
+ view: Record<TValues, ElementDefinition | AttributeElementCreatorFunction>;
408
+ converterPriority?: PriorityString;
409
+ }): this;
410
+ /**
411
+ * Model attribute to view attribute conversion helper.
412
+ *
413
+ * This conversion results in adding an attribute to a view node, basing on an attribute from a model node. For example,
414
+ * `<imageInline src='foo.jpg'></imageInline>` is converted to `<img src='foo.jpg'></img>`.
415
+ *
416
+ * ```ts
417
+ * editor.conversion.for( 'downcast' ).attributeToAttribute( {
418
+ * model: 'source',
419
+ * view: 'src'
420
+ * } );
421
+ *
422
+ * editor.conversion.for( 'downcast' ).attributeToAttribute( {
423
+ * model: 'source',
424
+ * view: 'href',
425
+ * converterPriority: 'high'
426
+ * } );
427
+ *
428
+ * editor.conversion.for( 'downcast' ).attributeToAttribute( {
429
+ * model: {
430
+ * name: 'imageInline',
431
+ * key: 'source'
432
+ * },
433
+ * view: 'src'
434
+ * } );
435
+ *
436
+ * editor.conversion.for( 'downcast' ).attributeToAttribute( {
437
+ * model: {
438
+ * name: 'styled',
439
+ * values: [ 'dark', 'light' ]
440
+ * },
441
+ * view: {
442
+ * dark: {
443
+ * key: 'class',
444
+ * value: [ 'styled', 'styled-dark' ]
445
+ * },
446
+ * light: {
447
+ * key: 'class',
448
+ * value: [ 'styled', 'styled-light' ]
449
+ * }
450
+ * }
451
+ * } );
452
+ *
453
+ * editor.conversion.for( 'downcast' ).attributeToAttribute( {
454
+ * model: 'styled',
455
+ * view: modelAttributeValue => ( {
456
+ * key: 'class',
457
+ * value: 'styled-' + modelAttributeValue
458
+ * } )
459
+ * } );
460
+ * ```
461
+ *
462
+ * **Note**: Downcasting to a style property requires providing `value` as an object:
463
+ *
464
+ * ```ts
465
+ * editor.conversion.for( 'downcast' ).attributeToAttribute( {
466
+ * model: 'lineHeight',
467
+ * view: modelAttributeValue => ( {
468
+ * key: 'style',
469
+ * value: {
470
+ * 'line-height': modelAttributeValue,
471
+ * 'border-bottom': '1px dotted #ba2'
472
+ * }
473
+ * } )
474
+ * } );
475
+ * ```
476
+ *
477
+ * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
478
+ * to the conversion process.
479
+ *
480
+ * @param config Conversion configuration.
481
+ * @param config.model The key of the attribute to convert from or a `{ key, values, [ name ] }` object describing
482
+ * the attribute key, possible values and, optionally, an element name to convert from.
483
+ * @param config.view A view attribute key, or a `{ key, value }` object or a function that takes the model attribute value and
484
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API}
485
+ * as parameters and returns a `{ key, value }` object. If the `key` is `'class'`, the `value` can be a `String` or an
486
+ * array of `String`s. If the `key` is `'style'`, the `value` is an object with key-value pairs. In other cases, `value` is a `String`.
487
+ * If `config.model.values` is set, `config.view` should be an object assigning values from `config.model.values` to
488
+ * `{ key, value }` objects or a functions.
489
+ * @param config.converterPriority Converter priority.
490
+ */
491
+ attributeToAttribute<TValues extends string>(config: {
492
+ model: string | {
493
+ key: string;
494
+ name?: string;
495
+ };
496
+ view: string | AttributeDescriptor | AttributeCreatorFunction;
497
+ converterPriority?: PriorityString;
498
+ } | {
499
+ model: {
500
+ key: string;
501
+ name?: string;
502
+ values?: Array<TValues>;
503
+ };
504
+ view: Record<TValues, AttributeDescriptor | AttributeCreatorFunction>;
505
+ converterPriority?: PriorityString;
506
+ }): this;
507
+ /**
508
+ * Model marker to view element conversion helper.
509
+ *
510
+ * **Note**: This method should be used mainly for editing the downcast and it is recommended
511
+ * to use the {@link #markerToData `#markerToData()`} helper instead.
512
+ *
513
+ * This helper may produce invalid HTML code (e.g. a span between table cells).
514
+ * It should only be used when you are sure that the produced HTML will be semantically correct.
515
+ *
516
+ * This conversion results in creating a view element on the boundaries of the converted marker. If the converted marker
517
+ * is collapsed, only one element is created. For example, a model marker set like this: `<paragraph>F[oo b]ar</paragraph>`
518
+ * becomes `<p>F<span data-marker="search"></span>oo b<span data-marker="search"></span>ar</p>` in the view.
519
+ *
520
+ * ```ts
521
+ * editor.conversion.for( 'editingDowncast' ).markerToElement( {
522
+ * model: 'search',
523
+ * view: 'marker-search'
524
+ * } );
525
+ *
526
+ * editor.conversion.for( 'editingDowncast' ).markerToElement( {
527
+ * model: 'search',
528
+ * view: 'search-result',
529
+ * converterPriority: 'high'
530
+ * } );
531
+ *
532
+ * editor.conversion.for( 'editingDowncast' ).markerToElement( {
533
+ * model: 'search',
534
+ * view: {
535
+ * name: 'span',
536
+ * attributes: {
537
+ * 'data-marker': 'search'
538
+ * }
539
+ * }
540
+ * } );
541
+ *
542
+ * editor.conversion.for( 'editingDowncast' ).markerToElement( {
543
+ * model: 'search',
544
+ * view: ( markerData, conversionApi ) => {
545
+ * const { writer } = conversionApi;
546
+ *
547
+ * return writer.createUIElement( 'span', {
548
+ * 'data-marker': 'search',
549
+ * 'data-start': markerData.isOpening
550
+ * } );
551
+ * }
552
+ * } );
553
+ * ```
554
+ *
555
+ * If a function is passed as the `config.view` parameter, it will be used to generate both boundary elements. The function
556
+ * receives the `data` object and {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API}
557
+ * as a parameters and should return an instance of the
558
+ * {@link module:engine/view/uielement~UIElement view UI element}. The `data` object and
559
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi `conversionApi`} are passed from
560
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:addMarker}. Additionally,
561
+ * the `data.isOpening` parameter is passed, which is set to `true` for the marker start boundary element, and `false` for
562
+ * the marker end boundary element.
563
+ *
564
+ * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
565
+ * to the conversion process.
566
+ *
567
+ * @param config Conversion configuration.
568
+ * @param config.model The name of the model marker (or model marker group) to convert.
569
+ * @param config.view A view element definition or a function that takes the model marker data and
570
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API} as a parameters
571
+ * and returns a view UI element.
572
+ * @param config.converterPriority Converter priority.
573
+ */
574
+ markerToElement(config: {
575
+ model: string;
576
+ view: ElementDefinition | MarkerElementCreatorFunction;
577
+ converterPriority?: PriorityString;
578
+ }): this;
579
+ /**
580
+ * Model marker to highlight conversion helper.
581
+ *
582
+ * This conversion results in creating a highlight on view nodes. For this kind of conversion,
583
+ * the {@link module:engine/conversion/downcasthelpers~HighlightDescriptor} should be provided.
584
+ *
585
+ * For text nodes, a `<span>` {@link module:engine/view/attributeelement~AttributeElement} is created and it wraps all text nodes
586
+ * in the converted marker range. For example, a model marker set like this: `<paragraph>F[oo b]ar</paragraph>` becomes
587
+ * `<p>F<span class="comment">oo b</span>ar</p>` in the view.
588
+ *
589
+ * {@link module:engine/view/containerelement~ContainerElement} may provide a custom way of handling highlight. Most often,
590
+ * the element itself is given classes and attributes described in the highlight descriptor (instead of being wrapped in `<span>`).
591
+ * For example, a model marker set like this:
592
+ * `[<imageInline src="foo.jpg"></imageInline>]` becomes `<img src="foo.jpg" class="comment"></img>` in the view.
593
+ *
594
+ * For container elements, the conversion is two-step. While the converter processes the highlight descriptor and passes it
595
+ * to a container element, it is the container element instance itself that applies values from the highlight descriptor.
596
+ * So, in a sense, the converter takes care of stating what should be applied on what, while the element decides how to apply that.
597
+ *
598
+ * ```ts
599
+ * editor.conversion.for( 'downcast' ).markerToHighlight( { model: 'comment', view: { classes: 'comment' } } );
600
+ *
601
+ * editor.conversion.for( 'downcast' ).markerToHighlight( {
602
+ * model: 'comment',
603
+ * view: { classes: 'comment' },
604
+ * converterPriority: 'high'
605
+ * } );
606
+ *
607
+ * editor.conversion.for( 'downcast' ).markerToHighlight( {
608
+ * model: 'comment',
609
+ * view: ( data, conversionApi ) => {
610
+ * // Assuming that the marker name is in a form of comment:commentType:commentId.
611
+ * const [ , commentType, commentId ] = data.markerName.split( ':' );
612
+ *
613
+ * return {
614
+ * classes: [ 'comment', 'comment-' + commentType ],
615
+ * attributes: { 'data-comment-id': commentId }
616
+ * };
617
+ * }
618
+ * } );
619
+ * ```
620
+ *
621
+ * If a function is passed as the `config.view` parameter, it will be used to generate the highlight descriptor. The function
622
+ * receives the `data` object and {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API}
623
+ * as the parameters and should return a
624
+ * {@link module:engine/conversion/downcasthelpers~HighlightDescriptor highlight descriptor}.
625
+ * The `data` object properties are passed from {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:addMarker}.
626
+ *
627
+ * See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
628
+ * to the conversion process.
629
+ *
630
+ * @param config Conversion configuration.
631
+ * @param config.model The name of the model marker (or model marker group) to convert.
632
+ * @param config.view A highlight descriptor that will be used for highlighting or a function that takes the model marker data and
633
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API} as a parameters
634
+ * and returns a highlight descriptor.
635
+ * @param config.converterPriority Converter priority.
636
+ */
637
+ markerToHighlight(config: {
638
+ model: string;
639
+ view: HighlightDescriptor | HighlightDescriptorCreatorFunction;
640
+ converterPriority?: PriorityString;
641
+ }): this;
642
+ /**
643
+ * Model marker converter for data downcast.
644
+ *
645
+ * This conversion creates a representation for model marker boundaries in the view:
646
+ *
647
+ * * If the marker boundary is before or after a model element, a view attribute is set on a corresponding view element.
648
+ * * In other cases, a view element with the specified tag name is inserted at the corresponding view position.
649
+ *
650
+ * Typically, the marker names use the `group:uniqueId:otherData` convention. For example: `comment:e34zfk9k2n459df53sjl34:zx32c`.
651
+ * The default configuration for this conversion is that the first part is the `group` part and the rest of
652
+ * the marker name becomes the `name` part.
653
+ *
654
+ * Tag and attribute names and values are generated from the marker name:
655
+ *
656
+ * * The templates for attributes are `data-[group]-start-before="[name]"`, `data-[group]-start-after="[name]"`,
657
+ * `data-[group]-end-before="[name]"` and `data-[group]-end-after="[name]"`.
658
+ * * The templates for view elements are `<[group]-start name="[name]">` and `<[group]-end name="[name]">`.
659
+ *
660
+ * Attributes mark whether the given marker's start or end boundary is before or after the given element.
661
+ * The `data-[group]-start-before` and `data-[group]-end-after` attributes are favored.
662
+ * The other two are used when the former two cannot be used.
663
+ *
664
+ * The conversion configuration can take a function that will generate different group and name parts.
665
+ * If such a function is set as the `config.view` parameter, it is passed a marker name and it is expected to return an object with two
666
+ * properties: `group` and `name`. If the function returns a falsy value, the conversion will not take place.
667
+ *
668
+ * Basic usage:
669
+ *
670
+ * ```ts
671
+ * // Using the default conversion.
672
+ * // In this case, all markers with names starting with 'comment:' will be converted.
673
+ * // The `group` parameter will be set to `comment`.
674
+ * // The `name` parameter will be the rest of the marker name (without the `:`).
675
+ * editor.conversion.for( 'dataDowncast' ).markerToData( {
676
+ * model: 'comment'
677
+ * } );
678
+ * ```
679
+ *
680
+ * An example of a view that may be generated by this conversion (assuming a marker with the name `comment:commentId:uid` marked
681
+ * by `[]`):
682
+ *
683
+ * ```
684
+ * // Model:
685
+ * <paragraph>Foo[bar</paragraph>
686
+ * <imageBlock src="abc.jpg"></imageBlock>]
687
+ *
688
+ * // View:
689
+ * <p>Foo<comment-start name="commentId:uid"></comment-start>bar</p>
690
+ * <figure data-comment-end-after="commentId:uid" class="image"><img src="abc.jpg" /></figure>
691
+ * ```
692
+ *
693
+ * In the example above, the comment starts before "bar" and ends after the image.
694
+ *
695
+ * If the `name` part is empty, the following view may be generated:
696
+ *
697
+ * ```html
698
+ * <p>Foo <myMarker-start></myMarker-start>bar</p>
699
+ * <figure data-myMarker-end-after="" class="image"><img src="abc.jpg" /></figure>
700
+ * ```
701
+ *
702
+ * **Note:** A situation where some markers have the `name` part and some do not, is incorrect and should be avoided.
703
+ *
704
+ * Examples where `data-group-start-after` and `data-group-end-before` are used:
705
+ *
706
+ * ```
707
+ * // Model:
708
+ * <blockQuote>[]<paragraph>Foo</paragraph></blockQuote>
709
+ *
710
+ * // View:
711
+ * <blockquote><p data-group-end-before="name" data-group-start-before="name">Foo</p></blockquote>
712
+ * ```
713
+ *
714
+ * Similarly, when a marker is collapsed after the last element:
715
+ *
716
+ * ```
717
+ * // Model:
718
+ * <blockQuote><paragraph>Foo</paragraph>[]</blockQuote>
719
+ *
720
+ * // View:
721
+ * <blockquote><p data-group-end-after="name" data-group-start-after="name">Foo</p></blockquote>
722
+ * ```
723
+ *
724
+ * When there are multiple markers from the same group stored in the same attribute of the same element, their
725
+ * name parts are put together in the attribute value, for example: `data-group-start-before="name1,name2,name3"`.
726
+ *
727
+ * Other examples of usage:
728
+ *
729
+ * ```ts
730
+ * // Using a custom function which is the same as the default conversion:
731
+ * editor.conversion.for( 'dataDowncast' ).markerToData( {
732
+ * model: 'comment',
733
+ * view: markerName => ( {
734
+ * group: 'comment',
735
+ * name: markerName.substr( 8 ) // Removes 'comment:' part.
736
+ * } )
737
+ * } );
738
+ *
739
+ * // Using the converter priority:
740
+ * editor.conversion.for( 'dataDowncast' ).markerToData( {
741
+ * model: 'comment',
742
+ * view: markerName => ( {
743
+ * group: 'comment',
744
+ * name: markerName.substr( 8 ) // Removes 'comment:' part.
745
+ * } ),
746
+ * converterPriority: 'high'
747
+ * } );
748
+ * ```
749
+ *
750
+ * This kind of conversion is useful for saving data into the database, so it should be used in the data conversion pipeline.
751
+ *
752
+ * See the {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} API guide to learn how to
753
+ * add a converter to the conversion process.
754
+ *
755
+ * @param config Conversion configuration.
756
+ * @param config.model The name of the model marker (or the model marker group) to convert.
757
+ * @param config.view A function that takes the model marker name and
758
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API} as the parameters
759
+ * and returns an object with the `group` and `name` properties.
760
+ * @param config.converterPriority Converter priority.
761
+ */
762
+ markerToData(config: {
763
+ model: string;
764
+ view?: MarkerDataCreatorFunction;
765
+ converterPriority?: PriorityString;
766
+ }): this;
767
+ }
768
+ /**
769
+ * Function factory that creates a default downcast converter for text insertion changes.
770
+ *
771
+ * The converter automatically consumes the corresponding value from the consumables list and stops the event (see
772
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher}).
773
+ *
774
+ * ```ts
775
+ * modelDispatcher.on( 'insert:$text', insertText() );
776
+ * ```
777
+ *
778
+ * @returns Insert text event converter.
779
+ */
780
+ export declare function insertText(): (evt: EventInfo, data: {
781
+ item: ModelText | ModelTextProxy;
782
+ range: ModelRange;
783
+ }, conversionApi: DowncastConversionApi) => void;
784
+ /**
785
+ * Function factory that creates a default downcast converter for triggering attributes and children conversion.
786
+ *
787
+ * @returns The converter.
788
+ */
789
+ export declare function insertAttributesAndChildren(): (evt: unknown, data: {
790
+ item: ModelItem;
791
+ reconversion?: boolean;
792
+ }, conversionApi: DowncastConversionApi) => void;
793
+ /**
794
+ * Function factory that creates a default downcast converter for node remove changes.
795
+ *
796
+ * ```ts
797
+ * modelDispatcher.on( 'remove', remove() );
798
+ * ```
799
+ *
800
+ * @returns Remove event converter.
801
+ */
802
+ export declare function remove(): (evt: unknown, data: {
803
+ position: ModelPosition;
804
+ length: number;
805
+ }, conversionApi: DowncastConversionApi) => void;
806
+ /**
807
+ * Creates a `<span>` {@link module:engine/view/attributeelement~AttributeElement view attribute element} from the information
808
+ * provided by the {@link module:engine/conversion/downcasthelpers~HighlightDescriptor highlight descriptor} object. If the priority
809
+ * is not provided in the descriptor, the default priority will be used.
810
+ */
811
+ export declare function createViewElementFromHighlightDescriptor(writer: DowncastWriter, descriptor: HighlightDescriptor): ViewAttributeElement;
812
+ /**
813
+ * Function factory that creates a converter which converts a non-collapsed {@link module:engine/model/selection~Selection model selection}
814
+ * to a {@link module:engine/view/documentselection~DocumentSelection view selection}. The converter consumes appropriate
815
+ * value from the `consumable` object and maps model positions from the selection to view positions.
816
+ *
817
+ * ```ts
818
+ * modelDispatcher.on( 'selection', convertRangeSelection() );
819
+ * ```
820
+ *
821
+ * @returns Selection converter.
822
+ */
823
+ export declare function convertRangeSelection(): (evt: EventInfo, data: {
824
+ selection: ModelSelection | ModelDocumentSelection;
825
+ }, conversionApi: DowncastConversionApi) => void;
826
+ /**
827
+ * Function factory that creates a converter which converts a collapsed {@link module:engine/model/selection~Selection model selection} to
828
+ * a {@link module:engine/view/documentselection~DocumentSelection view selection}. The converter consumes appropriate
829
+ * value from the `consumable` object, maps the model selection position to the view position and breaks
830
+ * {@link module:engine/view/attributeelement~AttributeElement attribute elements} at the selection position.
831
+ *
832
+ * ```ts
833
+ * modelDispatcher.on( 'selection', convertCollapsedSelection() );
834
+ * ```
835
+ *
836
+ * An example of the view state before and after converting the collapsed selection:
837
+ *
838
+ * ```
839
+ * <p><strong>f^oo<strong>bar</p>
840
+ * -> <p><strong>f</strong>^<strong>oo</strong>bar</p>
841
+ * ```
842
+ *
843
+ * By breaking attribute elements like `<strong>`, the selection is in a correct element. Then, when the selection attribute is
844
+ * converted, broken attributes might be merged again, or the position where the selection is may be wrapped
845
+ * with different, appropriate attribute elements.
846
+ *
847
+ * See also {@link module:engine/conversion/downcasthelpers~cleanSelection} which does a clean-up
848
+ * by merging attributes.
849
+ *
850
+ * @returns Selection converter.
851
+ */
852
+ export declare function convertCollapsedSelection(): (evt: EventInfo, data: {
853
+ selection: ModelSelection | ModelDocumentSelection;
854
+ }, conversionApi: DowncastConversionApi) => void;
855
+ /**
856
+ * Function factory that creates a converter which cleans artifacts after the previous
857
+ * {@link module:engine/model/selection~Selection model selection} conversion. It removes all empty
858
+ * {@link module:engine/view/attributeelement~AttributeElement view attribute elements} and merges sibling attributes at all start and end
859
+ * positions of all ranges.
860
+ *
861
+ * ```
862
+ * <p><strong>^</strong></p>
863
+ * -> <p>^</p>
864
+ *
865
+ * <p><strong>foo</strong>^<strong>bar</strong>bar</p>
866
+ * -> <p><strong>foo^bar<strong>bar</p>
867
+ *
868
+ * <p><strong>foo</strong><em>^</em><strong>bar</strong>bar</p>
869
+ * -> <p><strong>foo^bar<strong>bar</p>
870
+ * ```
871
+ *
872
+ * This listener should be assigned before any converter for the new selection:
873
+ *
874
+ * ```ts
875
+ * modelDispatcher.on( 'cleanSelection', cleanSelection() );
876
+ * ```
877
+ *
878
+ * See {@link module:engine/conversion/downcasthelpers~convertCollapsedSelection}
879
+ * which does the opposite by breaking attributes in the selection position.
880
+ *
881
+ * @returns Selection converter.
882
+ */
883
+ export declare function cleanSelection(): (evt: EventInfo, data: unknown, conversionApi: DowncastConversionApi) => void;
884
+ /**
885
+ * Function factory that creates a converter which converts the set/change/remove attribute changes from the model to the view.
886
+ * It can also be used to convert selection attributes. In that case, an empty attribute element will be created and the
887
+ * selection will be put inside it.
888
+ *
889
+ * Attributes from the model are converted to a view element that will be wrapping these view nodes that are bound to
890
+ * model elements having the given attribute. This is useful for attributes like `bold` that may be set on text nodes in the model
891
+ * but are represented as an element in the view:
892
+ *
893
+ * ```
894
+ * [paragraph] MODEL ====> VIEW <p>
895
+ * |- a {bold: true} |- <b>
896
+ * |- b {bold: true} | |- ab
897
+ * |- c |- c
898
+ * ```
899
+ *
900
+ * Passed `Function` will be provided with the attribute value and then all the parameters of the
901
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute `attribute` event}.
902
+ * It is expected that the function returns an {@link module:engine/view/element~Element}.
903
+ * The result of the function will be the wrapping element.
904
+ * When the provided `Function` does not return any element, no conversion will take place.
905
+ *
906
+ * The converter automatically consumes the corresponding value from the consumables list and stops the event (see
907
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher}).
908
+ *
909
+ * ```ts
910
+ * modelDispatcher.on( 'attribute:bold', wrap( ( modelAttributeValue, { writer } ) => {
911
+ * return writer.createAttributeElement( 'strong' );
912
+ * } );
913
+ * ```
914
+ *
915
+ * @internal
916
+ * @param elementCreator Function returning a view element that will be used for wrapping.
917
+ * @returns Set/change attribute converter.
918
+ */
919
+ export declare function wrap(elementCreator: AttributeElementCreatorFunction): (evt: EventInfo, data: {
920
+ item: ModelItem | ModelSelection | ModelDocumentSelection;
921
+ range: ModelRange;
922
+ attributeKey: string;
923
+ attributeOldValue: unknown;
924
+ attributeNewValue: unknown;
925
+ }, conversionApi: DowncastConversionApi) => void;
926
+ /**
927
+ * Function factory that creates a converter which converts node insertion changes from the model to the view.
928
+ * The function passed will be provided with all the parameters of the dispatcher's
929
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert `insert` event}.
930
+ * It is expected that the function returns an {@link module:engine/view/element~Element}.
931
+ * The result of the function will be inserted into the view.
932
+ *
933
+ * The converter automatically consumes the corresponding value from the consumables list and binds the model and view elements.
934
+ *
935
+ * ```ts
936
+ * downcastDispatcher.on(
937
+ * 'insert:myElem',
938
+ * insertElement( ( modelItem, { writer } ) => {
939
+ * const text = writer.createText( 'myText' );
940
+ * const myElem = writer.createElement( 'myElem', { myAttr: 'my-' + modelItem.getAttribute( 'myAttr' ) }, text );
941
+ *
942
+ * // Do something fancy with `myElem` using `modelItem` or other parameters.
943
+ *
944
+ * return myElem;
945
+ * }
946
+ * ) );
947
+ * ```
948
+ *
949
+ * @internal
950
+ * @param elementCreator Function returning a view element, which will be inserted.
951
+ * @param consumer Function defining element consumption process.
952
+ * By default this function just consume passed item insertion.
953
+ * @returns Insert element event converter.
954
+ */
955
+ export declare function insertElement(elementCreator: ElementCreatorFunction, consumer?: ConsumerFunction): (evt: unknown, data: {
956
+ item: ModelElement;
957
+ range: ModelRange;
958
+ reconversion?: boolean;
959
+ }, conversionApi: DowncastConversionApi) => void;
960
+ /**
961
+ * Function factory that creates a converter which converts a single model node insertion to a view structure.
962
+ *
963
+ * It is expected that the passed element creator function returns an {@link module:engine/view/element~Element} with attached slots
964
+ * created with `writer.createSlot()` to indicate where child nodes should be converted.
965
+ *
966
+ * @see module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure
967
+ *
968
+ * @internal
969
+ * @param elementCreator Function returning a view structure, which will be inserted.
970
+ * @param consumer A callback that is expected to consume all the consumables
971
+ * that were used by the element creator.
972
+ * @returns Insert element event converter.
973
+ */
974
+ export declare function insertStructure(elementCreator: StructureCreatorFunction, consumer: ConsumerFunction): (evt: unknown, data: {
975
+ item: ModelElement;
976
+ range: ModelRange;
977
+ reconversion?: boolean;
978
+ }, conversionApi: DowncastConversionApi) => void;
979
+ /**
980
+ * Function factory that creates a converter which converts marker adding change to the
981
+ * {@link module:engine/view/uielement~UIElement view UI element}.
982
+ *
983
+ * The view UI element that will be added to the view depends on the passed parameter. See {@link ~insertElement}.
984
+ * In case of a non-collapsed range, the UI element will not wrap nodes but separate elements will be placed at the beginning
985
+ * and at the end of the range.
986
+ *
987
+ * This converter binds created UI elements with the marker name using {@link module:engine/conversion/mapper~Mapper#bindElementToMarker}.
988
+ *
989
+ * @internal
990
+ * @param elementCreator A view UI element or a function returning the view element that will be inserted.
991
+ * @returns Insert element event converter.
992
+ */
993
+ export declare function insertUIElement(elementCreator: MarkerElementCreatorFunction): (evt: EventInfo, data: {
994
+ markerRange: ModelRange;
995
+ markerName: string;
996
+ isOpening?: boolean;
997
+ }, conversionApi: DowncastConversionApi) => void;
998
+ /**
999
+ * An object describing how the marker highlight should be represented in the view.
1000
+ *
1001
+ * Each text node contained in a highlighted range will be wrapped in a `<span>`
1002
+ * {@link module:engine/view/attributeelement~AttributeElement view attribute element} with CSS class(es), attributes and a priority
1003
+ * described by this object.
1004
+ *
1005
+ * Additionally, each {@link module:engine/view/containerelement~ContainerElement container element} can handle displaying the highlight
1006
+ * separately by providing the `addHighlight` and `removeHighlight` custom properties. In this case:
1007
+ *
1008
+ * * The `HighlightDescriptor` object is passed to the `addHighlight` function upon conversion and should be used to apply the highlight to
1009
+ * the element.
1010
+ * * The descriptor `id` is passed to the `removeHighlight` function upon conversion and should be used to remove the highlight with the
1011
+ * given ID from the element.
1012
+ */
1013
+ export interface HighlightDescriptor {
1014
+ /**
1015
+ * A CSS class or an array of classes to set. If the descriptor is used to
1016
+ * create an {@link module:engine/view/attributeelement~AttributeElement attribute element} over text nodes, these classes will be set
1017
+ * on that attribute element. If the descriptor is applied to an element, usually these classes will be set on that element, however,
1018
+ * this depends on how the element converts the descriptor.
1019
+ */
1020
+ classes: string | Array<string>;
1021
+ /**
1022
+ * Descriptor identifier. If not provided, it defaults to the converted marker's name.
1023
+ */
1024
+ id?: string;
1025
+ /**
1026
+ * Descriptor priority. If not provided, it defaults to `10`. If the descriptor is used to create
1027
+ * an {@link module:engine/view/attributeelement~AttributeElement attribute element}, it will be that element's
1028
+ * {@link module:engine/view/attributeelement~AttributeElement#priority priority}. If the descriptor is applied to an element,
1029
+ * the priority will be used to determine which descriptor is more important.
1030
+ */
1031
+ priority?: number;
1032
+ /**
1033
+ * Attributes to set. If the descriptor is used to create
1034
+ * an {@link module:engine/view/attributeelement~AttributeElement attribute element} over text nodes, these attributes will be set
1035
+ * on that attribute element. If the descriptor is applied to an element, usually these attributes will be set on that element, however,
1036
+ * this depends on how the element converts the descriptor.
1037
+ */
1038
+ attributes?: Record<string, string>;
1039
+ }
1040
+ /**
1041
+ * A filtering function used to choose model child nodes to be downcasted into the specific view
1042
+ * {@link module:engine/view/downcastwriter~DowncastWriter#createSlot "slot"} while executing the
1043
+ * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure `elementToStructure()`} converter.
1044
+ *
1045
+ * @callback module:engine/conversion/downcasthelpers~SlotFilter
1046
+ *
1047
+ * @param node A model node.
1048
+ * @returns Whether the provided model node should be downcasted into this slot.
1049
+ *
1050
+ * @see module:engine/view/downcastwriter~DowncastWriter#createSlot
1051
+ * @see module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure
1052
+ * @see module:engine/conversion/downcasthelpers~insertStructure
1053
+ */
1054
+ export type SlotFilter = (node: ModelNode) => boolean;
1055
+ /**
1056
+ * A view element creator function that takes the model element and {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi
1057
+ * downcast conversion API} as parameters and returns a view container element.
1058
+ *
1059
+ * @callback module:engine/conversion/downcasthelpers~ElementCreatorFunction
1060
+ *
1061
+ * @param element The model element to be converted to the view structure.
1062
+ * @param conversionApi The conversion interface.
1063
+ * @param data Additional information about the change (same as for
1064
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert `insert`} event).
1065
+ * @param data.item Inserted item.
1066
+ * @param data.range Range spanning over inserted item.
1067
+ * @returns The view element.
1068
+ *
1069
+ * @see module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement
1070
+ * @see module:engine/conversion/downcasthelpers~insertElement
1071
+ */
1072
+ export type ElementCreatorFunction = (element: ModelElement, conversionApi: DowncastConversionApi, data: {
1073
+ item: ModelItem;
1074
+ range: ModelRange;
1075
+ }) => ViewElement | null;
1076
+ /**
1077
+ * A function that takes the model element and {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast
1078
+ * conversion API} as parameters and returns a view container element with slots for model child nodes to be converted into.
1079
+ *
1080
+ * @callback module:engine/conversion/downcasthelpers~StructureCreatorFunction
1081
+ *
1082
+ * @param element The model element to be converted to the view structure.
1083
+ * @param conversionApi The conversion interface.
1084
+ * @param data Additional information about the change (same as for
1085
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert `insert`} event).
1086
+ * @param data.item Inserted item.
1087
+ * @param data.range Range spanning over inserted item.
1088
+ * @returns The view structure with slots for model child nodes.
1089
+ *
1090
+ * @see module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure
1091
+ * @see module:engine/conversion/downcasthelpers~insertStructure
1092
+ */
1093
+ export type StructureCreatorFunction = ElementCreatorFunction;
1094
+ /**
1095
+ * A view element creator function that takes the model attribute value and
1096
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API} as parameters and returns a view
1097
+ * attribute element.
1098
+ *
1099
+ * @callback module:engine/conversion/downcasthelpers~AttributeElementCreatorFunction
1100
+ *
1101
+ * @param attributeValue The model attribute value to be converted to the view attribute element.
1102
+ * @param conversionApi The conversion interface.
1103
+ * @param data Additional information about the change (same as for
1104
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute `attribute`} event).
1105
+ * @param data.item Changed item or converted selection.
1106
+ * @param data.range Range spanning over changed item or selection range.
1107
+ * @param data.attributeKey Attribute key.
1108
+ * @param data.attributeOldValue Attribute value before the change. This is `null` when selection attribute is converted.
1109
+ * @param data.attributeNewValue New attribute value.
1110
+ * @returns The view attribute element.
1111
+ *
1112
+ * @see module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement
1113
+ * @see module:engine/conversion/downcasthelpers~wrap
1114
+ */
1115
+ export type AttributeElementCreatorFunction = (attributeValue: any, conversionApi: DowncastConversionApi, data: {
1116
+ item: ModelItem | ModelSelection | ModelDocumentSelection;
1117
+ range: ModelRange;
1118
+ attributeKey: string;
1119
+ attributeOldValue: unknown;
1120
+ attributeNewValue: unknown;
1121
+ }) => ViewAttributeElement | null;
1122
+ /**
1123
+ * A function that takes the model attribute value and
1124
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API}
1125
+ * as parameters.
1126
+ *
1127
+ * @callback module:engine/conversion/downcasthelpers~AttributeCreatorFunction
1128
+ *
1129
+ * @param attributeValue The model attribute value to be converted to the view attribute element.
1130
+ * @param conversionApi The conversion interface.
1131
+ * @param data Additional information about the change (same as for
1132
+ * {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute `attribute`} event).
1133
+ * @param data.item Changed item or converted selection.
1134
+ * @param data.range Range spanning over changed item or selection range.
1135
+ * @param data.attributeKey Attribute key.
1136
+ * @param data.attributeOldValue Attribute value before the change. This is `null` when selection attribute is converted.
1137
+ * @param data.attributeNewValue New attribute value.
1138
+ * @returns A `{ key, value }` object. If `key` is `'class'`, `value` can be a `String` or an
1139
+ * array of `String`s. If `key` is `'style'`, `value` is an object with key-value pairs. In other cases, `value` is a `String`.
1140
+ *
1141
+ * @see module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToAttribute
1142
+ */
1143
+ export type AttributeCreatorFunction = (attributeValue: unknown, conversionApi: DowncastConversionApi, data: {
1144
+ item: ModelItem;
1145
+ range: ModelRange;
1146
+ attributeKey: string;
1147
+ attributeOldValue: unknown;
1148
+ attributeNewValue: unknown;
1149
+ }) => AttributeDescriptor | null;
1150
+ export type AttributeDescriptor = {
1151
+ key: 'class';
1152
+ value: string | Array<string>;
1153
+ } | {
1154
+ key: 'style';
1155
+ value: Record<string, string>;
1156
+ } | {
1157
+ key: Exclude<string, 'class' | 'style'>;
1158
+ value: string;
1159
+ };
1160
+ export type MarkerElementCreatorFunction = (data: {
1161
+ markerRange: ModelRange;
1162
+ markerName: string;
1163
+ isOpening?: boolean;
1164
+ }, conversionApi: DowncastConversionApi) => UIElement | null;
1165
+ export type HighlightDescriptorCreatorFunction = (data: {
1166
+ markerRange: ModelRange;
1167
+ markerName: string;
1168
+ }, conversionApi: DowncastConversionApi) => HighlightDescriptor | null;
1169
+ export type AddHighlightCallback = (viewElement: ViewElement, descriptor: HighlightDescriptor, writer: DowncastWriter) => void;
1170
+ export type RemoveHighlightCallback = (viewElement: ViewElement, id: string, writer: DowncastWriter) => void;
1171
+ export type MarkerDataCreatorFunction = (markerName: string, conversionApi: DowncastConversionApi) => {
1172
+ name: string;
1173
+ group: string;
1174
+ } | null;
1175
+ /**
1176
+ * A function that is expected to consume all the consumables that were used by the element creator.
1177
+ *
1178
+ * @callback module:engine/conversion/downcasthelpers~ConsumerFunction
1179
+ *
1180
+ * @param element The model element to be converted to the view structure.
1181
+ * @param consumable The `ModelConsumable` same as in
1182
+ * {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi#consumable `DowncastConversionApi.consumable`}.
1183
+ * @param options.preflight Whether should consume or just check if can be consumed.
1184
+ * @returns `true` if all consumable values were available and were consumed, `false` otherwise.
1185
+ *
1186
+ * @see module:engine/conversion/downcasthelpers~insertStructure
1187
+ */
1188
+ export type ConsumerFunction = (element: ModelElement, consumable: ModelConsumable, options?: {
1189
+ preflight?: boolean;
1190
+ }) => boolean | null;