@ckeditor/ckeditor5-engine 45.2.1 → 46.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2563 -2257
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/controller/datacontroller.d.ts +33 -32
- package/src/controller/datacontroller.js +29 -28
- package/src/controller/editingcontroller.d.ts +8 -8
- package/src/controller/editingcontroller.js +10 -10
- package/src/conversion/conversion.d.ts +18 -19
- package/src/conversion/conversion.js +4 -4
- package/src/conversion/conversionhelpers.d.ts +1 -1
- package/src/conversion/conversionhelpers.js +1 -1
- package/src/conversion/downcastdispatcher.d.ts +63 -69
- package/src/conversion/downcastdispatcher.js +16 -16
- package/src/conversion/downcasthelpers.d.ts +94 -83
- package/src/conversion/downcasthelpers.js +63 -53
- package/src/conversion/mapper.d.ts +27 -27
- package/src/conversion/mapper.js +15 -15
- package/src/conversion/modelconsumable.d.ts +26 -26
- package/src/conversion/modelconsumable.js +23 -23
- package/src/conversion/upcastdispatcher.d.ts +33 -32
- package/src/conversion/upcastdispatcher.js +19 -19
- package/src/conversion/upcasthelpers.d.ts +46 -38
- package/src/conversion/upcasthelpers.js +33 -24
- package/src/conversion/viewconsumable.d.ts +50 -45
- package/src/conversion/viewconsumable.js +32 -27
- package/src/dataprocessor/basichtmlwriter.d.ts +4 -2
- package/src/dataprocessor/basichtmlwriter.js +3 -1
- package/src/dataprocessor/dataprocessor.d.ts +7 -6
- package/src/dataprocessor/htmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/htmldataprocessor.js +6 -6
- package/src/dataprocessor/htmlwriter.d.ts +1 -1
- package/src/dataprocessor/xmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/xmldataprocessor.js +6 -6
- package/src/dev-utils/model.d.ts +25 -26
- package/src/dev-utils/model.js +35 -36
- package/src/dev-utils/operationreplayer.d.ts +5 -3
- package/src/dev-utils/operationreplayer.js +4 -2
- package/src/dev-utils/utils.d.ts +8 -0
- package/src/dev-utils/utils.js +8 -0
- package/src/dev-utils/view.d.ts +66 -63
- package/src/dev-utils/view.js +144 -134
- package/src/index.d.ts +135 -106
- package/src/index.js +120 -71
- package/src/legacyerrors.d.ts +5 -0
- package/src/legacyerrors.js +17 -0
- package/src/model/batch.d.ts +2 -15
- package/src/model/batch.js +1 -23
- package/src/model/differ.d.ts +54 -31
- package/src/model/differ.js +15 -15
- package/src/model/document.d.ts +31 -31
- package/src/model/document.js +13 -13
- package/src/model/documentfragment.d.ts +45 -45
- package/src/model/documentfragment.js +40 -40
- package/src/model/documentselection.d.ts +92 -92
- package/src/model/documentselection.js +71 -70
- package/src/model/element.d.ts +31 -31
- package/src/model/element.js +29 -29
- package/src/model/history.d.ts +3 -3
- package/src/model/history.js +2 -2
- package/src/model/item.d.ts +4 -5
- package/src/model/liveposition.d.ts +31 -31
- package/src/model/liveposition.js +18 -18
- package/src/model/liverange.d.ts +42 -38
- package/src/model/liverange.js +17 -16
- package/src/model/markercollection.d.ts +41 -40
- package/src/model/markercollection.js +22 -20
- package/src/model/model.d.ts +82 -81
- package/src/model/model.js +54 -54
- package/src/model/node.d.ts +48 -48
- package/src/model/node.js +31 -31
- package/src/model/nodelist.d.ts +17 -17
- package/src/model/nodelist.js +11 -11
- package/src/model/operation/attributeoperation.d.ts +10 -10
- package/src/model/operation/attributeoperation.js +7 -7
- package/src/model/operation/detachoperation.d.ts +11 -9
- package/src/model/operation/detachoperation.js +8 -6
- package/src/model/operation/insertoperation.d.ts +13 -13
- package/src/model/operation/insertoperation.js +15 -15
- package/src/model/operation/markeroperation.d.ts +12 -12
- package/src/model/operation/markeroperation.js +5 -5
- package/src/model/operation/mergeoperation.d.ts +16 -16
- package/src/model/operation/mergeoperation.js +18 -18
- package/src/model/operation/moveoperation.d.ts +16 -16
- package/src/model/operation/moveoperation.js +18 -15
- package/src/model/operation/nooperation.d.ts +4 -4
- package/src/model/operation/nooperation.js +2 -2
- package/src/model/operation/operation.d.ts +10 -10
- package/src/model/operation/operation.js +5 -5
- package/src/model/operation/operationfactory.d.ts +4 -4
- package/src/model/operation/operationfactory.js +12 -12
- package/src/model/operation/renameoperation.d.ts +10 -10
- package/src/model/operation/renameoperation.js +7 -7
- package/src/model/operation/rootattributeoperation.d.ts +12 -12
- package/src/model/operation/rootattributeoperation.js +8 -8
- package/src/model/operation/rootoperation.d.ts +8 -8
- package/src/model/operation/rootoperation.js +3 -3
- package/src/model/operation/splitoperation.d.ts +17 -17
- package/src/model/operation/splitoperation.js +19 -19
- package/src/model/operation/transform.d.ts +11 -8
- package/src/model/operation/transform.js +66 -49
- package/src/model/operation/utils.d.ts +24 -23
- package/src/model/operation/utils.js +20 -20
- package/src/model/position.d.ts +101 -97
- package/src/model/position.js +69 -64
- package/src/model/range.d.ts +90 -90
- package/src/model/range.js +87 -87
- package/src/model/rootelement.d.ts +11 -11
- package/src/model/rootelement.js +9 -9
- package/src/model/schema.d.ts +158 -154
- package/src/model/schema.js +93 -90
- package/src/model/selection.d.ts +73 -73
- package/src/model/selection.js +62 -62
- package/src/model/text.d.ts +11 -10
- package/src/model/text.js +11 -10
- package/src/model/textproxy.d.ts +39 -38
- package/src/model/textproxy.js +31 -30
- package/src/model/treewalker.d.ts +37 -37
- package/src/model/treewalker.js +14 -14
- package/src/model/typecheckable.d.ts +45 -45
- package/src/model/typecheckable.js +1 -1
- package/src/model/utils/autoparagraphing.d.ts +7 -7
- package/src/model/utils/deletecontent.d.ts +7 -5
- package/src/model/utils/deletecontent.js +13 -11
- package/src/model/utils/getselectedcontent.d.ts +6 -5
- package/src/model/utils/getselectedcontent.js +2 -1
- package/src/model/utils/insertcontent.d.ts +9 -8
- package/src/model/utils/insertcontent.js +41 -40
- package/src/model/utils/insertobject.d.ts +9 -9
- package/src/model/utils/insertobject.js +4 -4
- package/src/model/utils/modifyselection.d.ts +5 -4
- package/src/model/utils/modifyselection.js +12 -11
- package/src/model/utils/selection-post-fixer.d.ts +12 -8
- package/src/model/utils/selection-post-fixer.js +15 -11
- package/src/model/writer.d.ts +102 -101
- package/src/model/writer.js +99 -98
- package/src/view/attributeelement.d.ts +29 -29
- package/src/view/attributeelement.js +25 -25
- package/src/view/containerelement.d.ts +16 -15
- package/src/view/containerelement.js +15 -14
- package/src/view/datatransfer.d.ts +7 -7
- package/src/view/datatransfer.js +1 -1
- package/src/view/document.d.ts +25 -25
- package/src/view/document.js +15 -15
- package/src/view/documentfragment.d.ts +21 -21
- package/src/view/documentfragment.js +14 -14
- package/src/view/documentselection.d.ts +65 -63
- package/src/view/documentselection.js +27 -25
- package/src/view/domconverter.d.ts +94 -89
- package/src/view/domconverter.js +78 -73
- package/src/view/downcastwriter.d.ts +185 -181
- package/src/view/downcastwriter.js +222 -210
- package/src/view/editableelement.d.ts +13 -13
- package/src/view/editableelement.js +8 -8
- package/src/view/element.d.ts +75 -74
- package/src/view/element.js +58 -58
- package/src/view/elementdefinition.d.ts +3 -4
- package/src/view/emptyelement.d.ts +13 -13
- package/src/view/emptyelement.js +13 -13
- package/src/view/filler.d.ts +14 -3
- package/src/view/filler.js +12 -1
- package/src/view/item.d.ts +4 -5
- package/src/view/matcher.d.ts +22 -19
- package/src/view/matcher.js +6 -6
- package/src/view/node.d.ts +33 -33
- package/src/view/node.js +9 -9
- package/src/view/observer/arrowkeysobserver.d.ts +10 -10
- package/src/view/observer/arrowkeysobserver.js +5 -5
- package/src/view/observer/bubblingemittermixin.d.ts +5 -5
- package/src/view/observer/bubblingemittermixin.js +2 -9
- package/src/view/observer/bubblingeventinfo.d.ts +9 -9
- package/src/view/observer/bubblingeventinfo.js +1 -1
- package/src/view/observer/clickobserver.d.ts +8 -8
- package/src/view/observer/clickobserver.js +4 -4
- package/src/view/observer/compositionobserver.d.ts +19 -19
- package/src/view/observer/compositionobserver.js +6 -6
- package/src/view/observer/domeventdata.d.ts +9 -9
- package/src/view/observer/domeventdata.js +2 -2
- package/src/view/observer/domeventobserver.d.ts +3 -3
- package/src/view/observer/domeventobserver.js +5 -5
- package/src/view/observer/fakeselectionobserver.d.ts +9 -9
- package/src/view/observer/fakeselectionobserver.js +8 -8
- package/src/view/observer/focusobserver.d.ts +16 -16
- package/src/view/observer/focusobserver.js +7 -7
- package/src/view/observer/inputobserver.d.ts +18 -18
- package/src/view/observer/inputobserver.js +5 -5
- package/src/view/observer/keyobserver.d.ts +11 -11
- package/src/view/observer/keyobserver.js +3 -3
- package/src/view/observer/mouseobserver.d.ts +16 -16
- package/src/view/observer/mouseobserver.js +3 -3
- package/src/view/observer/mutationobserver.d.ts +21 -21
- package/src/view/observer/mutationobserver.js +7 -7
- package/src/view/observer/observer.d.ts +12 -12
- package/src/view/observer/observer.js +6 -6
- package/src/view/observer/selectionobserver.d.ts +33 -33
- package/src/view/observer/selectionobserver.js +14 -14
- package/src/view/observer/tabobserver.d.ts +10 -10
- package/src/view/observer/tabobserver.js +5 -5
- package/src/view/observer/touchobserver.d.ts +13 -13
- package/src/view/observer/touchobserver.js +3 -3
- package/src/view/placeholder.d.ts +21 -21
- package/src/view/placeholder.js +23 -23
- package/src/view/position.d.ts +49 -49
- package/src/view/position.js +42 -42
- package/src/view/range.d.ts +76 -74
- package/src/view/range.js +67 -65
- package/src/view/rawelement.d.ts +19 -19
- package/src/view/rawelement.js +16 -16
- package/src/view/renderer.d.ts +14 -14
- package/src/view/renderer.js +7 -7
- package/src/view/rooteditableelement.d.ts +8 -7
- package/src/view/rooteditableelement.js +7 -6
- package/src/view/selection.d.ts +66 -64
- package/src/view/selection.js +50 -48
- package/src/view/styles/background.d.ts +2 -2
- package/src/view/styles/background.js +9 -9
- package/src/view/styles/border.d.ts +2 -2
- package/src/view/styles/border.js +13 -13
- package/src/view/styles/margin.d.ts +2 -2
- package/src/view/styles/margin.js +5 -5
- package/src/view/styles/padding.d.ts +2 -2
- package/src/view/styles/padding.js +5 -5
- package/src/view/styles/utils.d.ts +24 -24
- package/src/view/styles/utils.js +25 -25
- package/src/view/stylesmap.d.ts +28 -32
- package/src/view/stylesmap.js +52 -39
- package/src/view/text.d.ts +11 -11
- package/src/view/text.js +10 -10
- package/src/view/textproxy.d.ts +33 -32
- package/src/view/textproxy.js +23 -22
- package/src/view/tokenlist.d.ts +14 -14
- package/src/view/tokenlist.js +10 -10
- package/src/view/treewalker.d.ts +42 -40
- package/src/view/treewalker.js +36 -35
- package/src/view/typecheckable.d.ts +76 -75
- package/src/view/typecheckable.js +1 -1
- package/src/view/uielement.d.ts +22 -21
- package/src/view/uielement.js +17 -16
- package/src/view/upcastwriter.d.ts +70 -70
- package/src/view/upcastwriter.js +42 -42
- package/src/view/view.d.ts +70 -69
- package/src/view/view.js +56 -55
package/src/dev-utils/model.js
CHANGED
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Collection of methods for manipulating the {@link module:engine/model/model model} for testing purposes.
|
|
10
10
|
*/
|
|
11
|
-
import
|
|
12
|
-
import Model from '../model/model.js';
|
|
13
|
-
import ModelRange from '../model/range.js';
|
|
14
|
-
import ModelPosition from '../model/position.js';
|
|
15
|
-
import ModelSelection from '../model/selection.js';
|
|
16
|
-
import ModelDocumentFragment from '../model/documentfragment.js';
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import ViewContainerElement from '../view/containerelement.js';
|
|
20
|
-
import ViewRootEditableElement from '../view/rooteditableelement.js';
|
|
21
|
-
import {
|
|
22
|
-
import Mapper from '../conversion/mapper.js';
|
|
11
|
+
import { ModelRootElement } from '../model/rootelement.js';
|
|
12
|
+
import { Model } from '../model/model.js';
|
|
13
|
+
import { ModelRange } from '../model/range.js';
|
|
14
|
+
import { ModelPosition } from '../model/position.js';
|
|
15
|
+
import { ModelSelection } from '../model/selection.js';
|
|
16
|
+
import { ModelDocumentFragment } from '../model/documentfragment.js';
|
|
17
|
+
import { ModelDocumentSelection } from '../model/documentselection.js';
|
|
18
|
+
import { EditingView } from '../view/view.js';
|
|
19
|
+
import { ViewContainerElement } from '../view/containerelement.js';
|
|
20
|
+
import { ViewRootEditableElement } from '../view/rooteditableelement.js';
|
|
21
|
+
import { _parseView, _stringifyView } from '../../src/dev-utils/view.js';
|
|
22
|
+
import { Mapper } from '../conversion/mapper.js';
|
|
23
23
|
import { convertCollapsedSelection, convertRangeSelection, insertAttributesAndChildren, insertElement, insertText, insertUIElement, wrap } from '../conversion/downcasthelpers.js';
|
|
24
24
|
import { StylesProcessor } from '../view/stylesmap.js';
|
|
25
|
-
import DowncastDispatcher from '../conversion/downcastdispatcher.js';
|
|
26
|
-
import UpcastDispatcher from '../conversion/upcastdispatcher.js';
|
|
25
|
+
import { DowncastDispatcher } from '../conversion/downcastdispatcher.js';
|
|
26
|
+
import { UpcastDispatcher } from '../conversion/upcastdispatcher.js';
|
|
27
27
|
import { toMap } from '@ckeditor/ckeditor5-utils';
|
|
28
28
|
import { isPlainObject } from 'es-toolkit/compat';
|
|
29
29
|
/**
|
|
30
|
-
* Writes the content of a model {@link module:engine/model/document~
|
|
30
|
+
* Writes the content of a model {@link module:engine/model/document~ModelDocument document} to an HTML-like string.
|
|
31
31
|
*
|
|
32
32
|
* ```ts
|
|
33
33
|
* getData( editor.model ); // -> '<paragraph>Foo![]</paragraph>'
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
-
* **Note:** A {@link module:engine/model/text~
|
|
36
|
+
* **Note:** A {@link module:engine/model/text~ModelText text} node that contains attributes will be represented as:
|
|
37
37
|
*
|
|
38
38
|
* ```xml
|
|
39
39
|
* <$text attribute="value">Text data</$text>
|
|
@@ -49,18 +49,18 @@ import { isPlainObject } from 'es-toolkit/compat';
|
|
|
49
49
|
* @param options.convertMarkers Whether to include markers in the returned string.
|
|
50
50
|
* @returns The stringified data.
|
|
51
51
|
*/
|
|
52
|
-
export function
|
|
52
|
+
export function _getModelData(model, options = {}) {
|
|
53
53
|
if (!(model instanceof Model)) {
|
|
54
54
|
throw new TypeError('Model needs to be an instance of module:engine/model/model~Model.');
|
|
55
55
|
}
|
|
56
56
|
const rootName = options.rootName || 'main';
|
|
57
57
|
const root = model.document.getRoot(rootName);
|
|
58
|
-
return
|
|
58
|
+
return _getModelData._stringify(root, options.withoutSelection ? null : model.document.selection, options.convertMarkers ? model.markers : null);
|
|
59
59
|
}
|
|
60
60
|
// Set stringify as getData private method - needed for testing/spying.
|
|
61
|
-
|
|
61
|
+
_getModelData._stringify = _stringifyModel;
|
|
62
62
|
/**
|
|
63
|
-
* Sets the content of a model {@link module:engine/model/document~
|
|
63
|
+
* Sets the content of a model {@link module:engine/model/document~ModelDocument document} provided as an HTML-like string.
|
|
64
64
|
*
|
|
65
65
|
* ```ts
|
|
66
66
|
* setData( editor.model, '<paragraph>Foo![]</paragraph>' );
|
|
@@ -69,7 +69,7 @@ getData._stringify = stringify;
|
|
|
69
69
|
* **Note:** Remember to register elements in the {@link module:engine/model/model~Model#schema model's schema} before
|
|
70
70
|
* trying to use them.
|
|
71
71
|
*
|
|
72
|
-
* **Note:** To create a {@link module:engine/model/text~
|
|
72
|
+
* **Note:** To create a {@link module:engine/model/text~ModelText text} node that contains attributes use:
|
|
73
73
|
*
|
|
74
74
|
* ```xml
|
|
75
75
|
* <$text attribute="value">Text data</$text>
|
|
@@ -84,9 +84,8 @@ getData._stringify = stringify;
|
|
|
84
84
|
* @param options.selectionAttributes A list of attributes which will be passed to the selection.
|
|
85
85
|
* @param options.lastRangeBackward If set to `true`, the last range will be added as backward.
|
|
86
86
|
* @param options.batchType Batch type used for inserting elements. See {@link module:engine/model/batch~Batch#constructor}.
|
|
87
|
-
* See {@link module:engine/model/batch~Batch#type}.
|
|
88
87
|
*/
|
|
89
|
-
export function
|
|
88
|
+
export function _setModelData(model, data, options = {}) {
|
|
90
89
|
if (!(model instanceof Model)) {
|
|
91
90
|
throw new TypeError('Model needs to be an instance of module:engine/model/model~Model.');
|
|
92
91
|
}
|
|
@@ -94,7 +93,7 @@ export function setData(model, data, options = {}) {
|
|
|
94
93
|
let selection = null;
|
|
95
94
|
const modelRoot = model.document.getRoot(options.rootName || 'main');
|
|
96
95
|
// Parse data string to model.
|
|
97
|
-
const parsedResult =
|
|
96
|
+
const parsedResult = _setModelData._parse(data, model.schema, {
|
|
98
97
|
lastRangeBackward: options.lastRangeBackward,
|
|
99
98
|
selectionAttributes: options.selectionAttributes,
|
|
100
99
|
context: [modelRoot.name],
|
|
@@ -137,11 +136,11 @@ export function setData(model, data, options = {}) {
|
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
// Set parse as setData private method - needed for testing/spying.
|
|
140
|
-
|
|
139
|
+
_setModelData._parse = _parseModel;
|
|
141
140
|
/**
|
|
142
141
|
* Converts model nodes to HTML-like string representation.
|
|
143
142
|
*
|
|
144
|
-
* **Note:** A {@link module:engine/model/text~
|
|
143
|
+
* **Note:** A {@link module:engine/model/text~ModelText text} node that contains attributes will be represented as:
|
|
145
144
|
*
|
|
146
145
|
* ```xml
|
|
147
146
|
* <$text attribute="value">Text data</$text>
|
|
@@ -154,13 +153,13 @@ setData._parse = parse;
|
|
|
154
153
|
* @param markers Markers to include.
|
|
155
154
|
* @returns An HTML-like string representing the model.
|
|
156
155
|
*/
|
|
157
|
-
export function
|
|
156
|
+
export function _stringifyModel(node, selectionOrPositionOrRange = null, markers = null) {
|
|
158
157
|
const model = new Model();
|
|
159
158
|
const mapper = new Mapper();
|
|
160
159
|
let selection = null;
|
|
161
160
|
let range;
|
|
162
161
|
// Create a range witch wraps passed node.
|
|
163
|
-
if (node instanceof
|
|
162
|
+
if (node instanceof ModelRootElement || node instanceof ModelDocumentFragment) {
|
|
164
163
|
range = model.createRangeIn(node);
|
|
165
164
|
}
|
|
166
165
|
else {
|
|
@@ -177,7 +176,7 @@ export function stringify(node, selectionOrPositionOrRange = null, markers = nul
|
|
|
177
176
|
if (selectionOrPositionOrRange instanceof ModelSelection) {
|
|
178
177
|
selection = selectionOrPositionOrRange;
|
|
179
178
|
}
|
|
180
|
-
else if (selectionOrPositionOrRange instanceof
|
|
179
|
+
else if (selectionOrPositionOrRange instanceof ModelDocumentSelection) {
|
|
181
180
|
selection = selectionOrPositionOrRange;
|
|
182
181
|
}
|
|
183
182
|
else if (selectionOrPositionOrRange instanceof ModelRange) {
|
|
@@ -189,7 +188,7 @@ export function stringify(node, selectionOrPositionOrRange = null, markers = nul
|
|
|
189
188
|
// Set up conversion.
|
|
190
189
|
// Create a temporary view controller.
|
|
191
190
|
const stylesProcessor = new StylesProcessor();
|
|
192
|
-
const view = new
|
|
191
|
+
const view = new EditingView(stylesProcessor);
|
|
193
192
|
const viewDocument = view.document;
|
|
194
193
|
const viewRoot = new ViewRootEditableElement(viewDocument, 'div');
|
|
195
194
|
// Create a temporary root element in view document.
|
|
@@ -202,7 +201,7 @@ export function stringify(node, selectionOrPositionOrRange = null, markers = nul
|
|
|
202
201
|
downcastDispatcher.on('insert:$text', insertText());
|
|
203
202
|
downcastDispatcher.on('insert', insertAttributesAndChildren(), { priority: 'lowest' });
|
|
204
203
|
downcastDispatcher.on('attribute', (evt, data, conversionApi) => {
|
|
205
|
-
if (data.item instanceof ModelSelection || data.item instanceof
|
|
204
|
+
if (data.item instanceof ModelSelection || data.item instanceof ModelDocumentSelection || data.item.is('$textProxy')) {
|
|
206
205
|
const converter = wrap((modelAttributeValue, { writer }) => {
|
|
207
206
|
return writer.createAttributeElement('model-text-with-attributes', { [data.attributeKey]: stringifyAttributeValue(modelAttributeValue) });
|
|
208
207
|
});
|
|
@@ -235,7 +234,7 @@ export function stringify(node, selectionOrPositionOrRange = null, markers = nul
|
|
|
235
234
|
downcastDispatcher.convertSelection(selection, markers || model.markers, writer);
|
|
236
235
|
}
|
|
237
236
|
// Parse view to data string.
|
|
238
|
-
let data =
|
|
237
|
+
let data = _stringifyView(viewRoot, viewDocument.selection, { sameSelectionCharacters: true });
|
|
239
238
|
// Removing unnecessary <div> and </div> added because `viewRoot` was also stringified alongside input data.
|
|
240
239
|
data = data.substr(5, data.length - 11);
|
|
241
240
|
view.destroy();
|
|
@@ -243,9 +242,9 @@ export function stringify(node, selectionOrPositionOrRange = null, markers = nul
|
|
|
243
242
|
return data.replace(new RegExp('model-text-with-attributes', 'g'), '$text');
|
|
244
243
|
}
|
|
245
244
|
/**
|
|
246
|
-
* Parses an HTML-like string and returns the model {@link module:engine/model/rootelement~
|
|
245
|
+
* Parses an HTML-like string and returns the model {@link module:engine/model/rootelement~ModelRootElement rootElement}.
|
|
247
246
|
*
|
|
248
|
-
* **Note:** To create a {@link module:engine/model/text~
|
|
247
|
+
* **Note:** To create a {@link module:engine/model/text~ModelText text} node that contains attributes use:
|
|
249
248
|
*
|
|
250
249
|
* ```xml
|
|
251
250
|
* <$text attribute="value">Text data</$text>
|
|
@@ -260,12 +259,12 @@ export function stringify(node, selectionOrPositionOrRange = null, markers = nul
|
|
|
260
259
|
* @returns Returns the parsed model node or an object with two fields: `model` and `selection`,
|
|
261
260
|
* when selection ranges were included in the data to parse.
|
|
262
261
|
*/
|
|
263
|
-
export function
|
|
262
|
+
export function _parseModel(data, schema, options = {}) {
|
|
264
263
|
const mapper = new Mapper();
|
|
265
264
|
// Replace not accepted by XML `$text` tag name by valid one `model-text-with-attributes`.
|
|
266
265
|
data = data.replace(new RegExp('\\$text', 'g'), 'model-text-with-attributes');
|
|
267
266
|
// Parse data to view using view utils.
|
|
268
|
-
const parsedResult =
|
|
267
|
+
const parsedResult = _parseView(data, {
|
|
269
268
|
sameSelectionCharacters: true,
|
|
270
269
|
lastRangeBackward: !!options.lastRangeBackward,
|
|
271
270
|
inlineObjectElements: options.inlineObjectElements
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import type Model from '../model/model.js';
|
|
6
|
-
import type Operation from '../model/operation/operation.js';
|
|
5
|
+
import { type Model } from '../model/model.js';
|
|
6
|
+
import { type Operation } from '../model/operation/operation.js';
|
|
7
7
|
/**
|
|
8
8
|
* Operation replayer is a development tool created for easy replaying of operations on the document from stringified operations.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
9
11
|
*/
|
|
10
|
-
export
|
|
12
|
+
export declare class OperationReplayer {
|
|
11
13
|
private _model;
|
|
12
14
|
private _logSeparator;
|
|
13
15
|
private _operationsToReplay;
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/dev-utils/operationreplayer
|
|
7
7
|
*/
|
|
8
|
-
import OperationFactory from '../model/operation/operationfactory.js';
|
|
8
|
+
import { OperationFactory } from '../model/operation/operationfactory.js';
|
|
9
9
|
/**
|
|
10
10
|
* Operation replayer is a development tool created for easy replaying of operations on the document from stringified operations.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
14
|
+
export class OperationReplayer {
|
|
13
15
|
_model;
|
|
14
16
|
_logSeparator;
|
|
15
17
|
_operationsToReplay;
|
package/src/dev-utils/utils.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @param map Map to convert.
|
|
16
16
|
* @returns Converted map.
|
|
17
|
+
* @internal
|
|
17
18
|
*/
|
|
18
19
|
export declare function convertMapToTags(map: Iterable<[string, unknown]>): string;
|
|
19
20
|
/**
|
|
@@ -21,17 +22,24 @@ export declare function convertMapToTags(map: Iterable<[string, unknown]>): stri
|
|
|
21
22
|
*
|
|
22
23
|
* @param map Map to convert.
|
|
23
24
|
* @returns Converted map.
|
|
25
|
+
* @internal
|
|
24
26
|
*/
|
|
25
27
|
export declare function convertMapToStringifiedObject(map: Iterable<[string, unknown]>): string;
|
|
26
28
|
/**
|
|
27
29
|
* Helper function that stores the `document` state for a given `version`.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
28
32
|
*/
|
|
29
33
|
export declare function dumpTrees(document: any, version: any): void;
|
|
30
34
|
/**
|
|
31
35
|
* Helper function that initializes document dumping.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
32
38
|
*/
|
|
33
39
|
export declare function initDocumentDumping(document: any): void;
|
|
34
40
|
/**
|
|
35
41
|
* Helper function that logs document for the given version.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
36
44
|
*/
|
|
37
45
|
export declare function logDocument(document: any, version: any): void;
|
package/src/dev-utils/utils.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @param map Map to convert.
|
|
17
17
|
* @returns Converted map.
|
|
18
|
+
* @internal
|
|
18
19
|
*/
|
|
19
20
|
export function convertMapToTags(map) {
|
|
20
21
|
let string = '';
|
|
@@ -28,6 +29,7 @@ export function convertMapToTags(map) {
|
|
|
28
29
|
*
|
|
29
30
|
* @param map Map to convert.
|
|
30
31
|
* @returns Converted map.
|
|
32
|
+
* @internal
|
|
31
33
|
*/
|
|
32
34
|
export function convertMapToStringifiedObject(map) {
|
|
33
35
|
const obj = {};
|
|
@@ -40,6 +42,8 @@ const treeDump = Symbol('_treeDump');
|
|
|
40
42
|
const maxTreeDumpLength = 20;
|
|
41
43
|
/**
|
|
42
44
|
* Helper function that stores the `document` state for a given `version`.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
43
47
|
*/
|
|
44
48
|
export function dumpTrees(document, version) {
|
|
45
49
|
console.log(document, version);
|
|
@@ -55,12 +59,16 @@ export function dumpTrees(document, version) {
|
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* Helper function that initializes document dumping.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
58
64
|
*/
|
|
59
65
|
export function initDocumentDumping(document) {
|
|
60
66
|
document[treeDump] = [];
|
|
61
67
|
}
|
|
62
68
|
/**
|
|
63
69
|
* Helper function that logs document for the given version.
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
64
72
|
*/
|
|
65
73
|
export function logDocument(document, version) {
|
|
66
74
|
console.log('--------------------');
|
package/src/dev-utils/view.d.ts
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Collection of methods for manipulating the {@link module:engine/view/view view} for testing purposes.
|
|
10
10
|
*/
|
|
11
|
-
import
|
|
12
|
-
import ViewDocumentFragment from '../view/documentfragment.js';
|
|
13
|
-
import ViewElement from '../view/element.js';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import type ViewNode from '../view/node.js';
|
|
18
|
-
import type
|
|
11
|
+
import { EditingView } from '../view/view.js';
|
|
12
|
+
import { ViewDocumentFragment } from '../view/documentfragment.js';
|
|
13
|
+
import { ViewElement } from '../view/element.js';
|
|
14
|
+
import { ViewDocumentSelection } from '../view/documentselection.js';
|
|
15
|
+
import { ViewRange } from '../view/range.js';
|
|
16
|
+
import { ViewPosition } from '../view/position.js';
|
|
17
|
+
import { type ViewNode } from '../view/node.js';
|
|
18
|
+
import { type ViewDomConverter } from '../view/domconverter.js';
|
|
19
19
|
/**
|
|
20
|
-
* Writes the content of the {@link module:engine/view/document~
|
|
20
|
+
* Writes the content of the {@link module:engine/view/document~ViewDocument document} to an HTML-like string.
|
|
21
21
|
*
|
|
22
22
|
* @param view The view to stringify.
|
|
23
23
|
* @param options.withoutSelection Whether to write the selection. When set to `true`, the selection will
|
|
@@ -29,57 +29,58 @@ import type DomConverter from '../view/domconverter.js';
|
|
|
29
29
|
* @param options.showPriority When set to `true`, the attribute element's priority will be printed
|
|
30
30
|
* (`<span view-priority="12">`, `<b view-priority="10">`).
|
|
31
31
|
* @param options.renderUIElements When set to `true`, the inner content of each
|
|
32
|
-
* {@link module:engine/view/uielement~
|
|
32
|
+
* {@link module:engine/view/uielement~ViewUIElement} will be printed.
|
|
33
33
|
* @param options.renderRawElements When set to `true`, the inner content of each
|
|
34
|
-
* {@link module:engine/view/rawelement~
|
|
35
|
-
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~
|
|
34
|
+
* {@link module:engine/view/rawelement~ViewRawElement} will be printed.
|
|
35
|
+
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
|
|
36
36
|
* instance, it lets the conversion go through exactly the same flow the editing view is going through,
|
|
37
37
|
* i.e. with view data filtering. Otherwise the simple stub is used.
|
|
38
38
|
* @returns The stringified data.
|
|
39
39
|
*/
|
|
40
|
-
export declare function
|
|
40
|
+
export declare function _getViewData(view: EditingView, options?: {
|
|
41
41
|
withoutSelection?: boolean;
|
|
42
42
|
rootName?: string;
|
|
43
43
|
showType?: boolean;
|
|
44
44
|
showPriority?: boolean;
|
|
45
45
|
renderUIElements?: boolean;
|
|
46
46
|
renderRawElements?: boolean;
|
|
47
|
-
domConverter?:
|
|
47
|
+
domConverter?: ViewDomConverter;
|
|
48
|
+
skipListItemIds?: boolean;
|
|
48
49
|
}): string;
|
|
49
|
-
export declare namespace
|
|
50
|
-
var _stringify: typeof
|
|
50
|
+
export declare namespace _getViewData {
|
|
51
|
+
var _stringify: typeof _stringifyView;
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
|
-
* Sets the content of a view {@link module:engine/view/document~
|
|
54
|
+
* Sets the content of a view {@link module:engine/view/document~ViewDocument document} provided as an HTML-like string.
|
|
54
55
|
*
|
|
55
56
|
* @param data An HTML-like string to write into the document.
|
|
56
|
-
* @param options.rootName The root name where
|
|
57
|
+
* @param options.rootName The root name where _parseViewd data will be stored. If not provided,
|
|
57
58
|
* the default `main` name will be used.
|
|
58
59
|
*/
|
|
59
|
-
export declare function
|
|
60
|
+
export declare function _setViewData(view: EditingView, data: string, options?: {
|
|
60
61
|
rootName?: string;
|
|
61
62
|
}): void;
|
|
62
|
-
export declare namespace
|
|
63
|
-
var _parse: typeof
|
|
63
|
+
export declare namespace _setViewData {
|
|
64
|
+
var _parse: typeof _parseView;
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* Converts view elements to HTML-like string representation.
|
|
67
68
|
*
|
|
68
|
-
* A root element can be provided as {@link module:engine/view/text~
|
|
69
|
+
* A root element can be provided as {@link module:engine/view/text~ViewText text}:
|
|
69
70
|
*
|
|
70
71
|
* ```ts
|
|
71
72
|
* const text = downcastWriter.createText( 'foobar' );
|
|
72
73
|
* stringify( text ); // 'foobar'
|
|
73
74
|
* ```
|
|
74
75
|
*
|
|
75
|
-
* or as an {@link module:engine/view/element~
|
|
76
|
+
* or as an {@link module:engine/view/element~ViewElement element}:
|
|
76
77
|
*
|
|
77
78
|
* ```ts
|
|
78
79
|
* const element = downcastWriter.createElement( 'p', null, downcastWriter.createText( 'foobar' ) );
|
|
79
80
|
* stringify( element ); // '<p>foobar</p>'
|
|
80
81
|
* ```
|
|
81
82
|
*
|
|
82
|
-
* or as a {@link module:engine/view/documentfragment~
|
|
83
|
+
* or as a {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}:
|
|
83
84
|
*
|
|
84
85
|
* ```ts
|
|
85
86
|
* const text = downcastWriter.createText( 'foobar' );
|
|
@@ -90,7 +91,7 @@ export declare namespace setData {
|
|
|
90
91
|
* stringify( fragment ); // '<p style="color:red;"></p><b name="test">foobar</b>'
|
|
91
92
|
* ```
|
|
92
93
|
*
|
|
93
|
-
* Additionally, a {@link module:engine/view/documentselection~
|
|
94
|
+
* Additionally, a {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance can be provided.
|
|
94
95
|
* Ranges from the selection will then be included in the output data.
|
|
95
96
|
* If a range position is placed inside the element node, it will be represented with `[` and `]`:
|
|
96
97
|
*
|
|
@@ -135,8 +136,8 @@ export declare namespace setData {
|
|
|
135
136
|
* stringify( text, selection ); // '{f}oo{ba}r'
|
|
136
137
|
* ```
|
|
137
138
|
*
|
|
138
|
-
* A {@link module:engine/view/range~
|
|
139
|
-
* instead of the {@link module:engine/view/documentselection~
|
|
139
|
+
* A {@link module:engine/view/range~ViewRange range} or {@link module:engine/view/position~ViewPosition position} instance can be provided
|
|
140
|
+
* instead of the {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance. If a range instance
|
|
140
141
|
* is provided, it will be converted to a selection containing this range. If a position instance is provided, it will
|
|
141
142
|
* be converted to a selection containing one range collapsed at this position.
|
|
142
143
|
*
|
|
@@ -151,10 +152,10 @@ export declare namespace setData {
|
|
|
151
152
|
*
|
|
152
153
|
* An additional `options` object can be provided.
|
|
153
154
|
* If `options.showType` is set to `true`, element's types will be
|
|
154
|
-
* presented for {@link module:engine/view/attributeelement~
|
|
155
|
-
* {@link module:engine/view/containerelement~
|
|
156
|
-
* {@link module:engine/view/emptyelement~
|
|
157
|
-
* and {@link module:engine/view/uielement~
|
|
155
|
+
* presented for {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements},
|
|
156
|
+
* {@link module:engine/view/containerelement~ViewContainerElement container elements}
|
|
157
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement empty elements}
|
|
158
|
+
* and {@link module:engine/view/uielement~ViewUIElement UI elements}:
|
|
158
159
|
*
|
|
159
160
|
* ```ts
|
|
160
161
|
* const attribute = downcastWriter.createAttributeElement( 'b' );
|
|
@@ -168,7 +169,7 @@ export declare namespace setData {
|
|
|
168
169
|
* ```
|
|
169
170
|
*
|
|
170
171
|
* If `options.showPriority` is set to `true`, a priority will be displayed for all
|
|
171
|
-
* {@link module:engine/view/attributeelement~
|
|
172
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements}.
|
|
172
173
|
*
|
|
173
174
|
* ```ts
|
|
174
175
|
* const attribute = downcastWriter.createAttributeElement( 'b' );
|
|
@@ -177,7 +178,7 @@ export declare namespace setData {
|
|
|
177
178
|
* ```
|
|
178
179
|
*
|
|
179
180
|
* If `options.showAttributeElementId` is set to `true`, the attribute element's id will be displayed for all
|
|
180
|
-
* {@link module:engine/view/attributeelement~
|
|
181
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements} that have it set.
|
|
181
182
|
*
|
|
182
183
|
* ```ts
|
|
183
184
|
* const attribute = downcastWriter.createAttributeElement( 'span' );
|
|
@@ -197,19 +198,19 @@ export declare namespace setData {
|
|
|
197
198
|
* @param options.showAttributeElementId When set to `true`, attribute element's id will be printed
|
|
198
199
|
* (`<span id="marker:foo">`).
|
|
199
200
|
* @param options.ignoreRoot When set to `true`, the root's element opening and closing will not be printed.
|
|
200
|
-
* Mainly used by the `getData` function to ignore the {@link module:engine/view/document~
|
|
201
|
+
* Mainly used by the `getData` function to ignore the {@link module:engine/view/document~ViewDocument document's} root element.
|
|
201
202
|
* @param options.sameSelectionCharacters When set to `true`, the selection inside the text will be marked as
|
|
202
203
|
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both will be marked as `[` and `]` only.
|
|
203
204
|
* @param options.renderUIElements When set to `true`, the inner content of each
|
|
204
|
-
* {@link module:engine/view/uielement~
|
|
205
|
+
* {@link module:engine/view/uielement~ViewUIElement} will be printed.
|
|
205
206
|
* @param options.renderRawElements When set to `true`, the inner content of each
|
|
206
|
-
* {@link module:engine/view/rawelement~
|
|
207
|
-
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~
|
|
207
|
+
* {@link module:engine/view/rawelement~ViewRawElement} will be printed.
|
|
208
|
+
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
|
|
208
209
|
* instance, it lets the conversion go through exactly the same flow the editing view is going through,
|
|
209
210
|
* i.e. with view data filtering. Otherwise the simple stub is used.
|
|
210
211
|
* @returns An HTML-like string representing the view.
|
|
211
212
|
*/
|
|
212
|
-
export declare function
|
|
213
|
+
export declare function _stringifyView(node: ViewNode | ViewDocumentFragment, selectionOrPositionOrRange?: ViewDocumentSelection | ViewPosition | ViewRange | null, options?: {
|
|
213
214
|
showType?: boolean;
|
|
214
215
|
showPriority?: boolean;
|
|
215
216
|
showAttributeElementId?: boolean;
|
|
@@ -217,96 +218,98 @@ export declare function stringify(node: ViewNode | ViewDocumentFragment, selecti
|
|
|
217
218
|
sameSelectionCharacters?: boolean;
|
|
218
219
|
renderUIElements?: boolean;
|
|
219
220
|
renderRawElements?: boolean;
|
|
220
|
-
domConverter?:
|
|
221
|
+
domConverter?: ViewDomConverter;
|
|
222
|
+
skipListItemIds?: boolean;
|
|
221
223
|
}): string;
|
|
222
224
|
/**
|
|
223
225
|
* Parses an HTML-like string and returns a view tree.
|
|
224
|
-
* A simple string will be converted to a {@link module:engine/view/text~
|
|
226
|
+
* A simple string will be converted to a {@link module:engine/view/text~ViewText text} node:
|
|
225
227
|
*
|
|
226
228
|
* ```ts
|
|
227
|
-
*
|
|
229
|
+
* _parseView( 'foobar' ); // Returns an instance of text.
|
|
228
230
|
* ```
|
|
229
231
|
*
|
|
230
|
-
* {@link module:engine/view/element~
|
|
232
|
+
* {@link module:engine/view/element~ViewElement Elements} will be _parseViewd with attributes as children:
|
|
231
233
|
*
|
|
232
234
|
* ```ts
|
|
233
|
-
*
|
|
235
|
+
* _parseView( '<b name="baz">foobar</b>' ); // Returns an instance of element with the `baz` attribute and a text child node.
|
|
234
236
|
* ```
|
|
235
237
|
*
|
|
236
238
|
* Multiple nodes provided on root level will be converted to a
|
|
237
|
-
* {@link module:engine/view/documentfragment~
|
|
239
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}:
|
|
238
240
|
*
|
|
239
241
|
* ```ts
|
|
240
|
-
*
|
|
242
|
+
* _parseView( '<b>foo</b><i>bar</i>' ); // Returns a document fragment with two child elements.
|
|
241
243
|
* ```
|
|
242
244
|
*
|
|
243
|
-
* The method can
|
|
244
|
-
* {@link module:engine/view/documentselection~
|
|
245
|
-
* {@link module:engine/view/text~
|
|
245
|
+
* The method can _parseView multiple {@link module:engine/view/range~ViewRange ranges} provided in string data and return a
|
|
246
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance containing these ranges. Ranges placed inside
|
|
247
|
+
* {@link module:engine/view/text~ViewText text} nodes should be marked using `{` and `}` brackets:
|
|
246
248
|
*
|
|
247
249
|
* ```ts
|
|
248
|
-
* const { text, selection } =
|
|
250
|
+
* const { text, selection } = _parseView( 'f{ooba}r' );
|
|
249
251
|
* ```
|
|
250
252
|
*
|
|
251
253
|
* Ranges placed outside text nodes should be marked using `[` and `]` brackets:
|
|
252
254
|
*
|
|
253
255
|
* ```ts
|
|
254
|
-
* const { root, selection } =
|
|
256
|
+
* const { root, selection } = _parseView( '<p>[<b>foobar</b>]</p>' );
|
|
255
257
|
* ```
|
|
256
258
|
*
|
|
257
259
|
* ** Note: **
|
|
258
260
|
* It is possible to unify selection markers to `[` and `]` for both (inside and outside text)
|
|
259
|
-
* by setting `sameSelectionCharacters=true` option. It is mainly used when the view
|
|
261
|
+
* by setting `sameSelectionCharacters=true` option. It is mainly used when the view _parseView option is used by model utilities.
|
|
260
262
|
*
|
|
261
263
|
* Sometimes there is a need for defining the order of ranges inside the created selection. This can be achieved by providing
|
|
262
264
|
* the range order array as an additional parameter:
|
|
263
265
|
*
|
|
264
266
|
* ```ts
|
|
265
|
-
* const { root, selection } =
|
|
267
|
+
* const { root, selection } = _parseView( '{fo}ob{ar}{ba}z', { order: [ 2, 3, 1 ] } );
|
|
266
268
|
* ```
|
|
267
269
|
*
|
|
268
270
|
* In the example above, the first range (`{fo}`) will be added to the selection as the second one, the second range (`{ar}`) will be
|
|
269
271
|
* added as the third and the third range (`{ba}`) will be added as the first one.
|
|
270
272
|
*
|
|
271
273
|
* If the selection's last range should be added as a backward one
|
|
272
|
-
* (so the {@link module:engine/view/documentselection~
|
|
273
|
-
* by the `end` position and {@link module:engine/view/documentselection~
|
|
274
|
+
* (so the {@link module:engine/view/documentselection~ViewDocumentSelection#anchor selection anchor} is represented
|
|
275
|
+
* by the `end` position and {@link module:engine/view/documentselection~ViewDocumentSelection#focus selection focus} is
|
|
274
276
|
* represented by the `start` position), use the `lastRangeBackward` flag:
|
|
275
277
|
*
|
|
276
278
|
* ```ts
|
|
277
|
-
* const { root, selection } =
|
|
279
|
+
* const { root, selection } = _parseView( `{foo}bar{baz}`, { lastRangeBackward: true } );
|
|
278
280
|
* ```
|
|
279
281
|
*
|
|
280
282
|
* Some more examples and edge cases:
|
|
281
283
|
*
|
|
282
284
|
* ```ts
|
|
283
285
|
* // Returns an empty document fragment.
|
|
284
|
-
*
|
|
286
|
+
* _parseView( '' );
|
|
285
287
|
*
|
|
286
288
|
* // Returns an empty document fragment and a collapsed selection.
|
|
287
|
-
* const { root, selection } =
|
|
289
|
+
* const { root, selection } = _parseView( '[]' );
|
|
288
290
|
*
|
|
289
291
|
* // Returns an element and a selection that is placed inside the document fragment containing that element.
|
|
290
|
-
* const { root, selection } =
|
|
292
|
+
* const { root, selection } = _parseView( '[<a></a>]' );
|
|
291
293
|
* ```
|
|
292
294
|
*
|
|
293
295
|
* @param data An HTML-like string to be parsed.
|
|
294
296
|
* @param options.order An array with the order of parsed ranges added to the returned
|
|
295
|
-
* {@link module:engine/view/documentselection~
|
|
297
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection Selection} instance. Each element should represent the
|
|
296
298
|
* desired position of each range in the selection instance. For example: `[2, 3, 1]` means that the first range will be
|
|
297
299
|
* placed as the second, the second as the third and the third as the first.
|
|
298
300
|
* @param options.lastRangeBackward If set to `true`, the last range will be added as backward to the returned
|
|
299
|
-
* {@link module:engine/view/documentselection~
|
|
301
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance.
|
|
300
302
|
* @param options.rootElement The default root to use when parsing elements.
|
|
301
303
|
* When set to `null`, the root element will be created automatically. If set to
|
|
302
|
-
* {@link module:engine/view/element~
|
|
304
|
+
* {@link module:engine/view/element~ViewElement Element} or
|
|
305
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment DocumentFragment},
|
|
303
306
|
* this node will be used as the root for all parsed nodes.
|
|
304
307
|
* @param options.sameSelectionCharacters When set to `false`, the selection inside the text should be marked using
|
|
305
308
|
* `{` and `}` and the selection outside the ext using `[` and `]`. When set to `true`, both should be marked with `[` and `]` only.
|
|
306
309
|
* @returns Returns the parsed view node or an object with two fields: `view` and `selection` when selection ranges were included in the
|
|
307
310
|
* data to parse.
|
|
308
311
|
*/
|
|
309
|
-
export declare function
|
|
312
|
+
export declare function _parseView(data: string, options?: {
|
|
310
313
|
order?: Array<number>;
|
|
311
314
|
lastRangeBackward?: boolean;
|
|
312
315
|
rootElement?: ViewElement | ViewDocumentFragment;
|
|
@@ -314,5 +317,5 @@ export declare function parse(data: string, options?: {
|
|
|
314
317
|
inlineObjectElements?: Array<string>;
|
|
315
318
|
}): ViewNode | ViewDocumentFragment | {
|
|
316
319
|
view: ViewNode | ViewDocumentFragment;
|
|
317
|
-
selection:
|
|
320
|
+
selection: ViewDocumentSelection;
|
|
318
321
|
};
|