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