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