@ckeditor/ckeditor5-engine 44.1.0-alpha.5 → 44.2.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/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,496 +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
|
-
* @module engine/conversion/upcastdispatcher
|
|
11
|
-
*/
|
|
12
|
-
import ViewConsumable from './viewconsumable.js';
|
|
13
|
-
import ModelRange from '../model/range.js';
|
|
14
|
-
import ModelPosition from '../model/position.js';
|
|
15
|
-
import type ModelElement from '../model/element.js';
|
|
16
|
-
import type ModelNode from '../model/node.js';
|
|
17
|
-
import type ViewElement from '../view/element.js';
|
|
18
|
-
import type ViewText from '../view/text.js';
|
|
19
|
-
import type ViewDocumentFragment from '../view/documentfragment.js';
|
|
20
|
-
import type ModelDocumentFragment from '../model/documentfragment.js';
|
|
21
|
-
import type { default as Schema, SchemaContextDefinition } from '../model/schema.js';
|
|
22
|
-
import type ModelWriter from '../model/writer.js';
|
|
23
|
-
import type ViewItem from '../view/item.js';
|
|
24
|
-
declare const UpcastDispatcher_base: {
|
|
25
|
-
new (): import("@ckeditor/ckeditor5-utils").Emitter;
|
|
26
|
-
prototype: import("@ckeditor/ckeditor5-utils").Emitter;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Upcast dispatcher is a central point of the view-to-model conversion, which is a process of
|
|
30
|
-
* converting a given {@link module:engine/view/documentfragment~DocumentFragment view document fragment} or
|
|
31
|
-
* {@link module:engine/view/element~Element view element} into a correct model structure.
|
|
32
|
-
*
|
|
33
|
-
* During the conversion process, the dispatcher fires events for all {@link module:engine/view/node~Node view nodes}
|
|
34
|
-
* from the converted view document fragment.
|
|
35
|
-
* Special callbacks called "converters" should listen to these events in order to convert the view nodes.
|
|
36
|
-
*
|
|
37
|
-
* The second parameter of the callback is the `data` object with the following properties:
|
|
38
|
-
*
|
|
39
|
-
* * `data.viewItem` contains a {@link module:engine/view/node~Node view node} or a
|
|
40
|
-
* {@link module:engine/view/documentfragment~DocumentFragment view document fragment}
|
|
41
|
-
* that is converted at the moment and might be handled by the callback.
|
|
42
|
-
* * `data.modelRange` is used to point to the result
|
|
43
|
-
* of the current conversion (e.g. the element that is being inserted)
|
|
44
|
-
* and is always a {@link module:engine/model/range~Range} when the conversion succeeds.
|
|
45
|
-
* * `data.modelCursor` is a {@link module:engine/model/position~Position position} on which the converter should insert
|
|
46
|
-
* the newly created items.
|
|
47
|
-
*
|
|
48
|
-
* The third parameter of the callback is an instance of {@link module:engine/conversion/upcastdispatcher~UpcastConversionApi}
|
|
49
|
-
* which provides additional tools for converters.
|
|
50
|
-
*
|
|
51
|
-
* You can read more about conversion in the {@glink framework/deep-dive/conversion/upcast Upcast conversion} guide.
|
|
52
|
-
*
|
|
53
|
-
* Examples of event-based converters:
|
|
54
|
-
*
|
|
55
|
-
* ```ts
|
|
56
|
-
* // A converter for links (<a>).
|
|
57
|
-
* editor.data.upcastDispatcher.on( 'element:a', ( evt, data, conversionApi ) => {
|
|
58
|
-
* if ( conversionApi.consumable.consume( data.viewItem, { name: true, attributes: [ 'href' ] } ) ) {
|
|
59
|
-
* // The <a> element is inline and is represented by an attribute in the model.
|
|
60
|
-
* // This is why you need to convert only children.
|
|
61
|
-
* const { modelRange } = conversionApi.convertChildren( data.viewItem, data.modelCursor );
|
|
62
|
-
*
|
|
63
|
-
* for ( let item of modelRange.getItems() ) {
|
|
64
|
-
* if ( conversionApi.schema.checkAttribute( item, 'linkHref' ) ) {
|
|
65
|
-
* conversionApi.writer.setAttribute( 'linkHref', data.viewItem.getAttribute( 'href' ), item );
|
|
66
|
-
* }
|
|
67
|
-
* }
|
|
68
|
-
* }
|
|
69
|
-
* } );
|
|
70
|
-
*
|
|
71
|
-
* // Convert <p> element's font-size style.
|
|
72
|
-
* // Note: You should use a low-priority observer in order to ensure that
|
|
73
|
-
* // it is executed after the element-to-element converter.
|
|
74
|
-
* editor.data.upcastDispatcher.on( 'element:p', ( evt, data, conversionApi ) => {
|
|
75
|
-
* const { consumable, schema, writer } = conversionApi;
|
|
76
|
-
*
|
|
77
|
-
* if ( !consumable.consume( data.viewItem, { style: 'font-size' } ) ) {
|
|
78
|
-
* return;
|
|
79
|
-
* }
|
|
80
|
-
*
|
|
81
|
-
* const fontSize = data.viewItem.getStyle( 'font-size' );
|
|
82
|
-
*
|
|
83
|
-
* // Do not go for the model element after data.modelCursor because it might happen
|
|
84
|
-
* // that a single view element was converted to multiple model elements. Get all of them.
|
|
85
|
-
* for ( const item of data.modelRange.getItems( { shallow: true } ) ) {
|
|
86
|
-
* if ( schema.checkAttribute( item, 'fontSize' ) ) {
|
|
87
|
-
* writer.setAttribute( 'fontSize', fontSize, item );
|
|
88
|
-
* }
|
|
89
|
-
* }
|
|
90
|
-
* }, { priority: 'low' } );
|
|
91
|
-
*
|
|
92
|
-
* // Convert all elements which have no custom converter into a paragraph (autoparagraphing).
|
|
93
|
-
* editor.data.upcastDispatcher.on( 'element', ( evt, data, conversionApi ) => {
|
|
94
|
-
* // Check if an element can be converted.
|
|
95
|
-
* if ( !conversionApi.consumable.test( data.viewItem, { name: data.viewItem.name } ) ) {
|
|
96
|
-
* // When an element is already consumed by higher priority converters, do nothing.
|
|
97
|
-
* return;
|
|
98
|
-
* }
|
|
99
|
-
*
|
|
100
|
-
* const paragraph = conversionApi.writer.createElement( 'paragraph' );
|
|
101
|
-
*
|
|
102
|
-
* // Try to safely insert a paragraph at the model cursor - it will find an allowed parent for the current element.
|
|
103
|
-
* if ( !conversionApi.safeInsert( paragraph, data.modelCursor ) ) {
|
|
104
|
-
* // When an element was not inserted, it means that you cannot insert a paragraph at this position.
|
|
105
|
-
* return;
|
|
106
|
-
* }
|
|
107
|
-
*
|
|
108
|
-
* // Consume the inserted element.
|
|
109
|
-
* conversionApi.consumable.consume( data.viewItem, { name: data.viewItem.name } ) );
|
|
110
|
-
*
|
|
111
|
-
* // Convert the children to a paragraph.
|
|
112
|
-
* const { modelRange } = conversionApi.convertChildren( data.viewItem, paragraph ) );
|
|
113
|
-
*
|
|
114
|
-
* // Update `modelRange` and `modelCursor` in the `data` as a conversion result.
|
|
115
|
-
* conversionApi.updateConversionResult( paragraph, data );
|
|
116
|
-
* }, { priority: 'low' } );
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* @fires viewCleanup
|
|
120
|
-
* @fires element
|
|
121
|
-
* @fires text
|
|
122
|
-
* @fires documentFragment
|
|
123
|
-
*/
|
|
124
|
-
export default class UpcastDispatcher extends /* #__PURE__ */ UpcastDispatcher_base {
|
|
125
|
-
/**
|
|
126
|
-
* An interface passed by the dispatcher to the event callbacks.
|
|
127
|
-
*/
|
|
128
|
-
conversionApi: UpcastConversionApi;
|
|
129
|
-
/**
|
|
130
|
-
* The list of elements that were created during splitting.
|
|
131
|
-
*
|
|
132
|
-
* After the conversion process, the list is cleared.
|
|
133
|
-
*/
|
|
134
|
-
private _splitParts;
|
|
135
|
-
/**
|
|
136
|
-
* The list of cursor parent elements that were created during splitting.
|
|
137
|
-
*
|
|
138
|
-
* After the conversion process the list is cleared.
|
|
139
|
-
*/
|
|
140
|
-
private _cursorParents;
|
|
141
|
-
/**
|
|
142
|
-
* The position in the temporary structure where the converted content is inserted. The structure reflects the context of
|
|
143
|
-
* the target position where the content will be inserted. This property is built based on the context parameter of the
|
|
144
|
-
* convert method.
|
|
145
|
-
*/
|
|
146
|
-
private _modelCursor;
|
|
147
|
-
/**
|
|
148
|
-
* The list of elements that were created during the splitting but should not get removed on conversion end even if they are empty.
|
|
149
|
-
*
|
|
150
|
-
* The list is cleared after the conversion process.
|
|
151
|
-
*/
|
|
152
|
-
private _emptyElementsToKeep;
|
|
153
|
-
/**
|
|
154
|
-
* Creates an upcast dispatcher that operates using the passed API.
|
|
155
|
-
*
|
|
156
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastConversionApi
|
|
157
|
-
* @param conversionApi Additional properties for an interface that will be passed to events fired
|
|
158
|
-
* by the upcast dispatcher.
|
|
159
|
-
*/
|
|
160
|
-
constructor(conversionApi: Pick<UpcastConversionApi, 'schema'>);
|
|
161
|
-
/**
|
|
162
|
-
* Starts the conversion process. The entry point for the conversion.
|
|
163
|
-
*
|
|
164
|
-
* @fires element
|
|
165
|
-
* @fires text
|
|
166
|
-
* @fires documentFragment
|
|
167
|
-
* @param viewElement The part of the view to be converted.
|
|
168
|
-
* @param writer An instance of the model writer.
|
|
169
|
-
* @param context Elements will be converted according to this context.
|
|
170
|
-
* @returns Model data that is the result of the conversion process
|
|
171
|
-
* wrapped in `DocumentFragment`. Converted marker elements will be set as the document fragment's
|
|
172
|
-
* {@link module:engine/model/documentfragment~DocumentFragment#markers static markers map}.
|
|
173
|
-
*/
|
|
174
|
-
convert(viewElement: ViewElement | ViewDocumentFragment, writer: ModelWriter, context?: SchemaContextDefinition): ModelDocumentFragment;
|
|
175
|
-
/**
|
|
176
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastConversionApi#convertItem
|
|
177
|
-
*/
|
|
178
|
-
private _convertItem;
|
|
179
|
-
/**
|
|
180
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastConversionApi#convertChildren
|
|
181
|
-
*/
|
|
182
|
-
private _convertChildren;
|
|
183
|
-
/**
|
|
184
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastConversionApi#safeInsert
|
|
185
|
-
*/
|
|
186
|
-
private _safeInsert;
|
|
187
|
-
/**
|
|
188
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastConversionApi#updateConversionResult
|
|
189
|
-
*/
|
|
190
|
-
private _updateConversionResult;
|
|
191
|
-
/**
|
|
192
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastConversionApi#splitToAllowedParent
|
|
193
|
-
*/
|
|
194
|
-
private _splitToAllowedParent;
|
|
195
|
-
/**
|
|
196
|
-
* Registers that a `splitPart` element is a split part of the `originalPart` element.
|
|
197
|
-
*
|
|
198
|
-
* The data set by this method is used by {@link #_getSplitParts} and {@link #_removeEmptyElements}.
|
|
199
|
-
*/
|
|
200
|
-
private _registerSplitPair;
|
|
201
|
-
/**
|
|
202
|
-
* @see module:engine/conversion/upcastdispatcher~UpcastConversionApi#getSplitParts
|
|
203
|
-
*/
|
|
204
|
-
private _getSplitParts;
|
|
205
|
-
/**
|
|
206
|
-
* Mark an element that were created during the splitting to not get removed on conversion end even if it is empty.
|
|
207
|
-
*/
|
|
208
|
-
private _keepEmptyElement;
|
|
209
|
-
/**
|
|
210
|
-
* Checks if there are any empty elements created while splitting and removes them.
|
|
211
|
-
*
|
|
212
|
-
* This method works recursively to re-check empty elements again after at least one element was removed in the initial call,
|
|
213
|
-
* as some elements might have become empty after other empty elements were removed from them.
|
|
214
|
-
*/
|
|
215
|
-
private _removeEmptyElements;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Fired before the first conversion event, at the beginning of the upcast (view-to-model conversion) process.
|
|
219
|
-
*
|
|
220
|
-
* @eventName ~UpcastDispatcher#viewCleanup
|
|
221
|
-
* @param viewItem A part of the view to be converted.
|
|
222
|
-
*/
|
|
223
|
-
export type UpcastViewCleanupEvent = {
|
|
224
|
-
name: 'viewCleanup';
|
|
225
|
-
args: [ViewElement | ViewDocumentFragment];
|
|
226
|
-
};
|
|
227
|
-
export type UpcastEvent<TName extends string, TItem extends ViewItem | ViewDocumentFragment> = {
|
|
228
|
-
name: TName | `${TName}:${string}`;
|
|
229
|
-
args: [data: UpcastConversionData<TItem>, conversionApi: UpcastConversionApi];
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* Conversion data.
|
|
233
|
-
*
|
|
234
|
-
* **Note:** Keep in mind that this object is shared by reference between all conversion callbacks that will be called.
|
|
235
|
-
* This means that callbacks can override values if needed, and these values will be available in other callbacks.
|
|
236
|
-
*/
|
|
237
|
-
export interface UpcastConversionData<TItem extends ViewItem | ViewDocumentFragment = ViewItem | ViewDocumentFragment> {
|
|
238
|
-
/**
|
|
239
|
-
* The converted item.
|
|
240
|
-
*/
|
|
241
|
-
viewItem: TItem;
|
|
242
|
-
/**
|
|
243
|
-
* The position where the converter should start changes.
|
|
244
|
-
* Change this value for the next converter to tell where the conversion should continue.
|
|
245
|
-
*/
|
|
246
|
-
modelCursor: ModelPosition;
|
|
247
|
-
/**
|
|
248
|
-
* The current state of conversion result. Every change to
|
|
249
|
-
* the converted element should be reflected by setting or modifying this property.
|
|
250
|
-
*/
|
|
251
|
-
modelRange: ModelRange | null;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Fired when an {@link module:engine/view/element~Element} is converted.
|
|
255
|
-
*
|
|
256
|
-
* `element` is a namespace event for a class of events. Names of actually called events follow the pattern of
|
|
257
|
-
* `element:<elementName>` where `elementName` is the name of the converted element. This way listeners may listen to
|
|
258
|
-
* a conversion of all or just specific elements.
|
|
259
|
-
*
|
|
260
|
-
* @eventName ~UpcastDispatcher#element
|
|
261
|
-
* @param data The conversion data. Keep in mind that this object is shared by reference between all callbacks
|
|
262
|
-
* that will be called. This means that callbacks can override values if needed, and these values
|
|
263
|
-
* will be available in other callbacks.
|
|
264
|
-
* @param conversionApi Conversion utilities to be used by the callback.
|
|
265
|
-
*/
|
|
266
|
-
export type UpcastElementEvent = UpcastEvent<'element', ViewElement>;
|
|
267
|
-
/**
|
|
268
|
-
* Fired when a {@link module:engine/view/text~Text} is converted.
|
|
269
|
-
*
|
|
270
|
-
* @eventName ~UpcastDispatcher#text
|
|
271
|
-
* @see ~UpcastDispatcher#event:element
|
|
272
|
-
*/
|
|
273
|
-
export type UpcastTextEvent = UpcastEvent<'text', ViewText>;
|
|
274
|
-
/**
|
|
275
|
-
* Fired when a {@link module:engine/view/documentfragment~DocumentFragment} is converted.
|
|
276
|
-
*
|
|
277
|
-
* @eventName ~UpcastDispatcher#documentFragment
|
|
278
|
-
* @see ~UpcastDispatcher#event:element
|
|
279
|
-
*/
|
|
280
|
-
export type UpcastDocumentFragmentEvent = UpcastEvent<'documentFragment', ViewDocumentFragment>;
|
|
281
|
-
/**
|
|
282
|
-
* A set of conversion utilities available as the third parameter of the
|
|
283
|
-
* {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher upcast dispatcher}'s events.
|
|
284
|
-
*/
|
|
285
|
-
export interface UpcastConversionApi {
|
|
286
|
-
/**
|
|
287
|
-
* Stores information about what parts of the processed view item are still waiting to be handled. After a piece of view item
|
|
288
|
-
* was converted, an appropriate consumable value should be
|
|
289
|
-
* {@link module:engine/conversion/viewconsumable~ViewConsumable#consume consumed}.
|
|
290
|
-
*/
|
|
291
|
-
consumable: ViewConsumable;
|
|
292
|
-
/**
|
|
293
|
-
* The model's schema instance.
|
|
294
|
-
*/
|
|
295
|
-
schema: Schema;
|
|
296
|
-
/**
|
|
297
|
-
* The {@link module:engine/model/writer~Writer} instance used to manipulate the data during conversion.
|
|
298
|
-
*/
|
|
299
|
-
writer: ModelWriter;
|
|
300
|
-
/**
|
|
301
|
-
* Custom data stored by converters for the conversion process. Custom properties of this object can be defined and use to
|
|
302
|
-
* pass parameters between converters.
|
|
303
|
-
*
|
|
304
|
-
* The difference between this property and the `data` parameter of
|
|
305
|
-
* {@link module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element} is that the `data` parameters allow you
|
|
306
|
-
* to pass parameters within a single event and `store` within the whole conversion.
|
|
307
|
-
*/
|
|
308
|
-
store: unknown;
|
|
309
|
-
/**
|
|
310
|
-
* Starts the conversion of a given item by firing an appropriate event.
|
|
311
|
-
*
|
|
312
|
-
* Every fired event is passed (as the first parameter) an object with the `modelRange` property. Every event may set and/or
|
|
313
|
-
* modify that property. When all callbacks are done, the final value of the `modelRange` property is returned by this method.
|
|
314
|
-
* The `modelRange` must be a {@link module:engine/model/range~Range model range} or `null` (as set by default).
|
|
315
|
-
*
|
|
316
|
-
* @fires module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
317
|
-
* @fires module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:text
|
|
318
|
-
* @fires module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:documentFragment
|
|
319
|
-
* @param viewItem Item to convert.
|
|
320
|
-
* @param modelCursor The conversion position.
|
|
321
|
-
* @returns The conversion result:
|
|
322
|
-
* * `result.modelRange` The model range containing the result of the item conversion,
|
|
323
|
-
* created and modified by callbacks attached to the fired event, or `null` if the conversion result was incorrect.
|
|
324
|
-
* * `result.modelCursor` The position where the conversion should be continued.
|
|
325
|
-
*/
|
|
326
|
-
convertItem(viewItem: ViewItem, modelCursor: ModelPosition): {
|
|
327
|
-
modelRange: ModelRange | null;
|
|
328
|
-
modelCursor: ModelPosition;
|
|
329
|
-
};
|
|
330
|
-
/**
|
|
331
|
-
* Starts the conversion of all children of a given item by firing appropriate events for all the children.
|
|
332
|
-
*
|
|
333
|
-
* @fires module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
334
|
-
* @fires module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:text
|
|
335
|
-
* @fires module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:documentFragment
|
|
336
|
-
* @param viewElement An element whose children should be converted.
|
|
337
|
-
* @param positionOrElement A position or an element of
|
|
338
|
-
* the conversion.
|
|
339
|
-
* @returns The conversion result:
|
|
340
|
-
* * `result.modelRange` The model range containing the results of the conversion of all children
|
|
341
|
-
* of the given item. When no child was converted, the range is collapsed.
|
|
342
|
-
* * `result.modelCursor` The position where the conversion should be continued.
|
|
343
|
-
*/
|
|
344
|
-
convertChildren(viewElement: ViewElement | ViewDocumentFragment, positionOrElement: ModelPosition | ModelElement): {
|
|
345
|
-
modelRange: ModelRange | null;
|
|
346
|
-
modelCursor: ModelPosition;
|
|
347
|
-
};
|
|
348
|
-
/**
|
|
349
|
-
* Safely inserts an element to the document, checking the {@link module:engine/model/schema~Schema schema} to find an allowed parent
|
|
350
|
-
* for an element that you are going to insert, starting from the given position. If the current parent does not allow to insert
|
|
351
|
-
* the element but one of the ancestors does, then splits the nodes to allowed parent.
|
|
352
|
-
*
|
|
353
|
-
* If the schema allows to insert the node in a given position, nothing is split.
|
|
354
|
-
*
|
|
355
|
-
* If it was not possible to find an allowed parent, `false` is returned and nothing is split.
|
|
356
|
-
*
|
|
357
|
-
* Otherwise, ancestors are split.
|
|
358
|
-
*
|
|
359
|
-
* For instance, if `<imageBlock>` is not allowed in `<paragraph>` but is allowed in `$root`:
|
|
360
|
-
*
|
|
361
|
-
* ```
|
|
362
|
-
* <paragraph>foo[]bar</paragraph>
|
|
363
|
-
*
|
|
364
|
-
* -> safe insert for `<imageBlock>` will split ->
|
|
365
|
-
*
|
|
366
|
-
* <paragraph>foo</paragraph>[]<paragraph>bar</paragraph>
|
|
367
|
-
*```
|
|
368
|
-
*
|
|
369
|
-
* Example usage:
|
|
370
|
-
*
|
|
371
|
-
* ```
|
|
372
|
-
* const myElement = conversionApi.writer.createElement( 'myElement' );
|
|
373
|
-
*
|
|
374
|
-
* if ( !conversionApi.safeInsert( myElement, data.modelCursor ) ) {
|
|
375
|
-
* return;
|
|
376
|
-
* }
|
|
377
|
-
*```
|
|
378
|
-
*
|
|
379
|
-
* The split result is saved and {@link #updateConversionResult} should be used to update the
|
|
380
|
-
* {@link module:engine/conversion/upcastdispatcher~UpcastConversionData conversion data}.
|
|
381
|
-
*
|
|
382
|
-
* @param modelNode The node to insert.
|
|
383
|
-
* @param position The position where an element is going to be inserted.
|
|
384
|
-
* @returns The split result. If it was not possible to find an allowed position, `false` is returned.
|
|
385
|
-
*/
|
|
386
|
-
safeInsert(modelNode: ModelNode, position: ModelPosition): boolean;
|
|
387
|
-
/**
|
|
388
|
-
* Updates the conversion result and sets a proper {@link module:engine/conversion/upcastdispatcher~UpcastConversionData#modelRange} and
|
|
389
|
-
* the next {@link module:engine/conversion/upcastdispatcher~UpcastConversionData#modelCursor} after the conversion.
|
|
390
|
-
* Used together with {@link #safeInsert}, it enables you to easily convert elements without worrying if the node was split
|
|
391
|
-
* during the conversion of its children.
|
|
392
|
-
*
|
|
393
|
-
* A usage example in converter code:
|
|
394
|
-
*
|
|
395
|
-
* ```ts
|
|
396
|
-
* const myElement = conversionApi.writer.createElement( 'myElement' );
|
|
397
|
-
*
|
|
398
|
-
* if ( !conversionApi.safeInsert( myElement, data.modelCursor ) ) {
|
|
399
|
-
* return;
|
|
400
|
-
* }
|
|
401
|
-
*
|
|
402
|
-
* // Children conversion may split `myElement`.
|
|
403
|
-
* conversionApi.convertChildren( data.viewItem, myElement );
|
|
404
|
-
*
|
|
405
|
-
* conversionApi.updateConversionResult( myElement, data );
|
|
406
|
-
* ```
|
|
407
|
-
*/
|
|
408
|
-
updateConversionResult(modelElement: ModelElement, data: UpcastConversionData): void;
|
|
409
|
-
/**
|
|
410
|
-
* Checks the {@link module:engine/model/schema~Schema schema} to find an allowed parent for an element that is going to be inserted
|
|
411
|
-
* starting from the given position. If the current parent does not allow inserting an element but one of the ancestors does, the method
|
|
412
|
-
* splits nodes to allowed parent.
|
|
413
|
-
*
|
|
414
|
-
* If the schema allows inserting the node in the given position, nothing is split and an object with that position is returned.
|
|
415
|
-
*
|
|
416
|
-
* If it was not possible to find an allowed parent, `null` is returned and nothing is split.
|
|
417
|
-
*
|
|
418
|
-
* Otherwise, ancestors are split and an object with a position and the copy of the split element is returned.
|
|
419
|
-
*
|
|
420
|
-
* For instance, if `<imageBlock>` is not allowed in `<paragraph>` but is allowed in `$root`:
|
|
421
|
-
*
|
|
422
|
-
* ```
|
|
423
|
-
* <paragraph>foo[]bar</paragraph>
|
|
424
|
-
*
|
|
425
|
-
* -> split for `<imageBlock>` ->
|
|
426
|
-
*
|
|
427
|
-
* <paragraph>foo</paragraph>[]<paragraph>bar</paragraph>
|
|
428
|
-
* ```
|
|
429
|
-
*
|
|
430
|
-
* In the example above, the position between `<paragraph>` elements will be returned as `position` and the second `paragraph`
|
|
431
|
-
* as `cursorParent`.
|
|
432
|
-
*
|
|
433
|
-
* **Note:** This is an advanced method. For most cases {@link #safeInsert} and {@link #updateConversionResult} should be used.
|
|
434
|
-
*
|
|
435
|
-
* @param modelNode The node to insert.
|
|
436
|
-
* @param modelCursor The position where the element is going to be inserted.
|
|
437
|
-
* @returns The split result. If it was not possible to find an allowed position, `null` is returned.
|
|
438
|
-
* * `position` The position between split elements.
|
|
439
|
-
* * `cursorParent` The element inside which the cursor should be placed to
|
|
440
|
-
* continue the conversion. When the element is not defined it means that there was no split.
|
|
441
|
-
*/
|
|
442
|
-
splitToAllowedParent(modelNode: ModelNode, modelCursor: ModelPosition): {
|
|
443
|
-
position: ModelPosition;
|
|
444
|
-
cursorParent?: ModelElement | ModelDocumentFragment;
|
|
445
|
-
} | null;
|
|
446
|
-
/**
|
|
447
|
-
* Returns all the split parts of the given `element` that were created during upcasting through using {@link #splitToAllowedParent}.
|
|
448
|
-
* It enables you to easily track these elements and continue processing them after they are split during the conversion of their
|
|
449
|
-
* children.
|
|
450
|
-
*
|
|
451
|
-
* ```
|
|
452
|
-
* <paragraph>Foo<imageBlock />bar<imageBlock />baz</paragraph> ->
|
|
453
|
-
* <paragraph>Foo</paragraph><imageBlock /><paragraph>bar</paragraph><imageBlock /><paragraph>baz</paragraph>
|
|
454
|
-
* ```
|
|
455
|
-
*
|
|
456
|
-
* For a reference to any of above paragraphs, the function will return all three paragraphs (the original element included),
|
|
457
|
-
* sorted in the order of their creation (the original element is the first one).
|
|
458
|
-
*
|
|
459
|
-
* If the given `element` was not split, an array with a single element is returned.
|
|
460
|
-
*
|
|
461
|
-
* A usage example in the converter code:
|
|
462
|
-
*
|
|
463
|
-
* ```ts
|
|
464
|
-
* const myElement = conversionApi.writer.createElement( 'myElement' );
|
|
465
|
-
*
|
|
466
|
-
* // Children conversion may split `myElement`.
|
|
467
|
-
* conversionApi.convertChildren( data.viewItem, data.modelCursor );
|
|
468
|
-
*
|
|
469
|
-
* const splitParts = conversionApi.getSplitParts( myElement );
|
|
470
|
-
* const lastSplitPart = splitParts[ splitParts.length - 1 ];
|
|
471
|
-
*
|
|
472
|
-
* // Setting `data.modelRange` basing on split parts:
|
|
473
|
-
* data.modelRange = conversionApi.writer.createRange(
|
|
474
|
-
* conversionApi.writer.createPositionBefore( myElement ),
|
|
475
|
-
* conversionApi.writer.createPositionAfter( lastSplitPart )
|
|
476
|
-
* );
|
|
477
|
-
*
|
|
478
|
-
* // Setting `data.modelCursor` to continue after the last split element:
|
|
479
|
-
* data.modelCursor = conversionApi.writer.createPositionAfter( lastSplitPart );
|
|
480
|
-
* ```
|
|
481
|
-
*
|
|
482
|
-
* **Tip:** If you are unable to get a reference to the original element (for example because the code is split into multiple converters
|
|
483
|
-
* or even classes) but it has already been converted, you may want to check the first element in `data.modelRange`. This is a common
|
|
484
|
-
* situation if an attribute converter is separated from an element converter.
|
|
485
|
-
*
|
|
486
|
-
* **Note:** This is an advanced method. For most cases {@link #safeInsert} and {@link #updateConversionResult} should be used.
|
|
487
|
-
*/
|
|
488
|
-
getSplitParts(modelElement: ModelElement): Array<ModelElement>;
|
|
489
|
-
/**
|
|
490
|
-
* Mark an element that was created during splitting to not get removed on conversion end even if it is empty.
|
|
491
|
-
*
|
|
492
|
-
* **Note:** This is an advanced method. For most cases you will not need to keep the split empty element.
|
|
493
|
-
*/
|
|
494
|
-
keepEmptyElement(modelElement: ModelElement): void;
|
|
495
|
-
}
|
|
496
|
-
export {};
|