@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/view.js
CHANGED
|
@@ -8,40 +8,40 @@
|
|
|
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 ViewDocument from '../view/document.js';
|
|
13
|
-
import ViewDocumentFragment from '../view/documentfragment.js';
|
|
14
|
-
import XmlDataProcessor from '../dataprocessor/xmldataprocessor.js';
|
|
15
|
-
import ViewElement from '../view/element.js';
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
11
|
+
import { EditingView } from '../view/view.js';
|
|
12
|
+
import { ViewDocument } from '../view/document.js';
|
|
13
|
+
import { ViewDocumentFragment } from '../view/documentfragment.js';
|
|
14
|
+
import { XmlDataProcessor } from '../dataprocessor/xmldataprocessor.js';
|
|
15
|
+
import { ViewElement } from '../view/element.js';
|
|
16
|
+
import { ViewDocumentSelection } from '../view/documentselection.js';
|
|
17
|
+
import { ViewRange } from '../view/range.js';
|
|
18
|
+
import { ViewPosition } from '../view/position.js';
|
|
19
|
+
import { ViewAttributeElement } from '../view/attributeelement.js';
|
|
20
|
+
import { ViewContainerElement } from '../view/containerelement.js';
|
|
21
|
+
import { ViewEmptyElement } from '../view/emptyelement.js';
|
|
22
|
+
import { ViewUIElement } from '../view/uielement.js';
|
|
23
|
+
import { ViewRawElement } from '../view/rawelement.js';
|
|
24
24
|
import { StylesProcessor } from '../view/stylesmap.js';
|
|
25
25
|
const ELEMENT_RANGE_START_TOKEN = '[';
|
|
26
26
|
const ELEMENT_RANGE_END_TOKEN = ']';
|
|
27
27
|
const TEXT_RANGE_START_TOKEN = '{';
|
|
28
28
|
const TEXT_RANGE_END_TOKEN = '}';
|
|
29
29
|
const allowedTypes = {
|
|
30
|
-
'container':
|
|
31
|
-
'attribute':
|
|
32
|
-
'empty':
|
|
33
|
-
'ui':
|
|
34
|
-
'raw':
|
|
30
|
+
'container': ViewContainerElement,
|
|
31
|
+
'attribute': ViewAttributeElement,
|
|
32
|
+
'empty': ViewEmptyElement,
|
|
33
|
+
'ui': ViewUIElement,
|
|
34
|
+
'raw': ViewRawElement
|
|
35
35
|
};
|
|
36
|
-
// Returns simplified implementation of {@link module:engine/view/domconverter~
|
|
37
|
-
// Used to render UIElement and RawElement.
|
|
36
|
+
// Returns simplified implementation of {@link module:engine/view/domconverter~ViewDomConverter#setContentOf ViewDomConverter.setContentOf}
|
|
37
|
+
// method. Used to render UIElement and RawElement.
|
|
38
38
|
const domConverterStub = {
|
|
39
39
|
setContentOf: (node, html) => {
|
|
40
40
|
node.innerHTML = html;
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
-
* Writes the content of the {@link module:engine/view/document~
|
|
44
|
+
* Writes the content of the {@link module:engine/view/document~ViewDocument document} to an HTML-like string.
|
|
45
45
|
*
|
|
46
46
|
* @param view The view to stringify.
|
|
47
47
|
* @param options.withoutSelection Whether to write the selection. When set to `true`, the selection will
|
|
@@ -53,17 +53,17 @@ const domConverterStub = {
|
|
|
53
53
|
* @param options.showPriority When set to `true`, the attribute element's priority will be printed
|
|
54
54
|
* (`<span view-priority="12">`, `<b view-priority="10">`).
|
|
55
55
|
* @param options.renderUIElements When set to `true`, the inner content of each
|
|
56
|
-
* {@link module:engine/view/uielement~
|
|
56
|
+
* {@link module:engine/view/uielement~ViewUIElement} will be printed.
|
|
57
57
|
* @param options.renderRawElements When set to `true`, the inner content of each
|
|
58
|
-
* {@link module:engine/view/rawelement~
|
|
59
|
-
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~
|
|
58
|
+
* {@link module:engine/view/rawelement~ViewRawElement} will be printed.
|
|
59
|
+
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
|
|
60
60
|
* instance, it lets the conversion go through exactly the same flow the editing view is going through,
|
|
61
61
|
* i.e. with view data filtering. Otherwise the simple stub is used.
|
|
62
62
|
* @returns The stringified data.
|
|
63
63
|
*/
|
|
64
|
-
export function
|
|
65
|
-
if (!(view instanceof
|
|
66
|
-
throw new TypeError('View needs to be an instance of module:engine/view/view~
|
|
64
|
+
export function _getViewData(view, options = {}) {
|
|
65
|
+
if (!(view instanceof EditingView)) {
|
|
66
|
+
throw new TypeError('View needs to be an instance of module:engine/view/view~EditingView.');
|
|
67
67
|
}
|
|
68
68
|
const document = view.document;
|
|
69
69
|
const withoutSelection = !!options.withoutSelection;
|
|
@@ -75,55 +75,56 @@ export function getData(view, options = {}) {
|
|
|
75
75
|
renderUIElements: options.renderUIElements,
|
|
76
76
|
renderRawElements: options.renderRawElements,
|
|
77
77
|
ignoreRoot: true,
|
|
78
|
-
domConverter: options.domConverter
|
|
78
|
+
domConverter: options.domConverter,
|
|
79
|
+
skipListItemIds: options.skipListItemIds
|
|
79
80
|
};
|
|
80
81
|
return withoutSelection ?
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
_getViewData._stringify(root, null, stringifyOptions) :
|
|
83
|
+
_getViewData._stringify(root, document.selection, stringifyOptions);
|
|
83
84
|
}
|
|
84
85
|
// Set stringify as getData private method - needed for testing/spying.
|
|
85
|
-
|
|
86
|
+
_getViewData._stringify = _stringifyView;
|
|
86
87
|
/**
|
|
87
|
-
* Sets the content of a view {@link module:engine/view/document~
|
|
88
|
+
* Sets the content of a view {@link module:engine/view/document~ViewDocument document} provided as an HTML-like string.
|
|
88
89
|
*
|
|
89
90
|
* @param data An HTML-like string to write into the document.
|
|
90
|
-
* @param options.rootName The root name where
|
|
91
|
+
* @param options.rootName The root name where _parseViewd data will be stored. If not provided,
|
|
91
92
|
* the default `main` name will be used.
|
|
92
93
|
*/
|
|
93
|
-
export function
|
|
94
|
-
if (!(view instanceof
|
|
95
|
-
throw new TypeError('View needs to be an instance of module:engine/view/view~
|
|
94
|
+
export function _setViewData(view, data, options = {}) {
|
|
95
|
+
if (!(view instanceof EditingView)) {
|
|
96
|
+
throw new TypeError('View needs to be an instance of module:engine/view/view~EditingView.');
|
|
96
97
|
}
|
|
97
98
|
const document = view.document;
|
|
98
99
|
const rootName = options.rootName || 'main';
|
|
99
100
|
const root = document.getRoot(rootName);
|
|
100
101
|
view.change(writer => {
|
|
101
|
-
const result =
|
|
102
|
+
const result = _setViewData._parse(data, { rootElement: root });
|
|
102
103
|
if (result.view && result.selection) {
|
|
103
104
|
writer.setSelection(result.selection);
|
|
104
105
|
}
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
// Set
|
|
108
|
-
|
|
108
|
+
// Set _parseView as _setViewData private method - needed for testing/spying.
|
|
109
|
+
_setViewData._parse = _parseView;
|
|
109
110
|
/**
|
|
110
111
|
* Converts view elements to HTML-like string representation.
|
|
111
112
|
*
|
|
112
|
-
* A root element can be provided as {@link module:engine/view/text~
|
|
113
|
+
* A root element can be provided as {@link module:engine/view/text~ViewText text}:
|
|
113
114
|
*
|
|
114
115
|
* ```ts
|
|
115
116
|
* const text = downcastWriter.createText( 'foobar' );
|
|
116
117
|
* stringify( text ); // 'foobar'
|
|
117
118
|
* ```
|
|
118
119
|
*
|
|
119
|
-
* or as an {@link module:engine/view/element~
|
|
120
|
+
* or as an {@link module:engine/view/element~ViewElement element}:
|
|
120
121
|
*
|
|
121
122
|
* ```ts
|
|
122
123
|
* const element = downcastWriter.createElement( 'p', null, downcastWriter.createText( 'foobar' ) );
|
|
123
124
|
* stringify( element ); // '<p>foobar</p>'
|
|
124
125
|
* ```
|
|
125
126
|
*
|
|
126
|
-
* or as a {@link module:engine/view/documentfragment~
|
|
127
|
+
* or as a {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}:
|
|
127
128
|
*
|
|
128
129
|
* ```ts
|
|
129
130
|
* const text = downcastWriter.createText( 'foobar' );
|
|
@@ -134,7 +135,7 @@ setData._parse = parse;
|
|
|
134
135
|
* stringify( fragment ); // '<p style="color:red;"></p><b name="test">foobar</b>'
|
|
135
136
|
* ```
|
|
136
137
|
*
|
|
137
|
-
* Additionally, a {@link module:engine/view/documentselection~
|
|
138
|
+
* Additionally, a {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance can be provided.
|
|
138
139
|
* Ranges from the selection will then be included in the output data.
|
|
139
140
|
* If a range position is placed inside the element node, it will be represented with `[` and `]`:
|
|
140
141
|
*
|
|
@@ -179,8 +180,8 @@ setData._parse = parse;
|
|
|
179
180
|
* stringify( text, selection ); // '{f}oo{ba}r'
|
|
180
181
|
* ```
|
|
181
182
|
*
|
|
182
|
-
* A {@link module:engine/view/range~
|
|
183
|
-
* instead of the {@link module:engine/view/documentselection~
|
|
183
|
+
* A {@link module:engine/view/range~ViewRange range} or {@link module:engine/view/position~ViewPosition position} instance can be provided
|
|
184
|
+
* instead of the {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance. If a range instance
|
|
184
185
|
* is provided, it will be converted to a selection containing this range. If a position instance is provided, it will
|
|
185
186
|
* be converted to a selection containing one range collapsed at this position.
|
|
186
187
|
*
|
|
@@ -195,10 +196,10 @@ setData._parse = parse;
|
|
|
195
196
|
*
|
|
196
197
|
* An additional `options` object can be provided.
|
|
197
198
|
* If `options.showType` is set to `true`, element's types will be
|
|
198
|
-
* presented for {@link module:engine/view/attributeelement~
|
|
199
|
-
* {@link module:engine/view/containerelement~
|
|
200
|
-
* {@link module:engine/view/emptyelement~
|
|
201
|
-
* and {@link module:engine/view/uielement~
|
|
199
|
+
* presented for {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements},
|
|
200
|
+
* {@link module:engine/view/containerelement~ViewContainerElement container elements}
|
|
201
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement empty elements}
|
|
202
|
+
* and {@link module:engine/view/uielement~ViewUIElement UI elements}:
|
|
202
203
|
*
|
|
203
204
|
* ```ts
|
|
204
205
|
* const attribute = downcastWriter.createAttributeElement( 'b' );
|
|
@@ -212,7 +213,7 @@ setData._parse = parse;
|
|
|
212
213
|
* ```
|
|
213
214
|
*
|
|
214
215
|
* If `options.showPriority` is set to `true`, a priority will be displayed for all
|
|
215
|
-
* {@link module:engine/view/attributeelement~
|
|
216
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements}.
|
|
216
217
|
*
|
|
217
218
|
* ```ts
|
|
218
219
|
* const attribute = downcastWriter.createAttributeElement( 'b' );
|
|
@@ -221,7 +222,7 @@ setData._parse = parse;
|
|
|
221
222
|
* ```
|
|
222
223
|
*
|
|
223
224
|
* If `options.showAttributeElementId` is set to `true`, the attribute element's id will be displayed for all
|
|
224
|
-
* {@link module:engine/view/attributeelement~
|
|
225
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements} that have it set.
|
|
225
226
|
*
|
|
226
227
|
* ```ts
|
|
227
228
|
* const attribute = downcastWriter.createAttributeElement( 'span' );
|
|
@@ -241,23 +242,23 @@ setData._parse = parse;
|
|
|
241
242
|
* @param options.showAttributeElementId When set to `true`, attribute element's id will be printed
|
|
242
243
|
* (`<span id="marker:foo">`).
|
|
243
244
|
* @param options.ignoreRoot When set to `true`, the root's element opening and closing will not be printed.
|
|
244
|
-
* Mainly used by the `getData` function to ignore the {@link module:engine/view/document~
|
|
245
|
+
* Mainly used by the `getData` function to ignore the {@link module:engine/view/document~ViewDocument document's} root element.
|
|
245
246
|
* @param options.sameSelectionCharacters When set to `true`, the selection inside the text will be marked as
|
|
246
247
|
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both will be marked as `[` and `]` only.
|
|
247
248
|
* @param options.renderUIElements When set to `true`, the inner content of each
|
|
248
|
-
* {@link module:engine/view/uielement~
|
|
249
|
+
* {@link module:engine/view/uielement~ViewUIElement} will be printed.
|
|
249
250
|
* @param options.renderRawElements When set to `true`, the inner content of each
|
|
250
|
-
* {@link module:engine/view/rawelement~
|
|
251
|
-
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~
|
|
251
|
+
* {@link module:engine/view/rawelement~ViewRawElement} will be printed.
|
|
252
|
+
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
|
|
252
253
|
* instance, it lets the conversion go through exactly the same flow the editing view is going through,
|
|
253
254
|
* i.e. with view data filtering. Otherwise the simple stub is used.
|
|
254
255
|
* @returns An HTML-like string representing the view.
|
|
255
256
|
*/
|
|
256
|
-
export function
|
|
257
|
+
export function _stringifyView(node, selectionOrPositionOrRange = null, options = {}) {
|
|
257
258
|
let selection;
|
|
258
|
-
if (selectionOrPositionOrRange instanceof
|
|
259
|
-
selectionOrPositionOrRange instanceof
|
|
260
|
-
selection = new
|
|
259
|
+
if (selectionOrPositionOrRange instanceof ViewPosition ||
|
|
260
|
+
selectionOrPositionOrRange instanceof ViewRange) {
|
|
261
|
+
selection = new ViewDocumentSelection(selectionOrPositionOrRange);
|
|
261
262
|
}
|
|
262
263
|
else {
|
|
263
264
|
selection = selectionOrPositionOrRange;
|
|
@@ -267,92 +268,93 @@ export function stringify(node, selectionOrPositionOrRange = null, options = {})
|
|
|
267
268
|
}
|
|
268
269
|
/**
|
|
269
270
|
* Parses an HTML-like string and returns a view tree.
|
|
270
|
-
* A simple string will be converted to a {@link module:engine/view/text~
|
|
271
|
+
* A simple string will be converted to a {@link module:engine/view/text~ViewText text} node:
|
|
271
272
|
*
|
|
272
273
|
* ```ts
|
|
273
|
-
*
|
|
274
|
+
* _parseView( 'foobar' ); // Returns an instance of text.
|
|
274
275
|
* ```
|
|
275
276
|
*
|
|
276
|
-
* {@link module:engine/view/element~
|
|
277
|
+
* {@link module:engine/view/element~ViewElement Elements} will be _parseViewd with attributes as children:
|
|
277
278
|
*
|
|
278
279
|
* ```ts
|
|
279
|
-
*
|
|
280
|
+
* _parseView( '<b name="baz">foobar</b>' ); // Returns an instance of element with the `baz` attribute and a text child node.
|
|
280
281
|
* ```
|
|
281
282
|
*
|
|
282
283
|
* Multiple nodes provided on root level will be converted to a
|
|
283
|
-
* {@link module:engine/view/documentfragment~
|
|
284
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}:
|
|
284
285
|
*
|
|
285
286
|
* ```ts
|
|
286
|
-
*
|
|
287
|
+
* _parseView( '<b>foo</b><i>bar</i>' ); // Returns a document fragment with two child elements.
|
|
287
288
|
* ```
|
|
288
289
|
*
|
|
289
|
-
* The method can
|
|
290
|
-
* {@link module:engine/view/documentselection~
|
|
291
|
-
* {@link module:engine/view/text~
|
|
290
|
+
* The method can _parseView multiple {@link module:engine/view/range~ViewRange ranges} provided in string data and return a
|
|
291
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance containing these ranges. Ranges placed inside
|
|
292
|
+
* {@link module:engine/view/text~ViewText text} nodes should be marked using `{` and `}` brackets:
|
|
292
293
|
*
|
|
293
294
|
* ```ts
|
|
294
|
-
* const { text, selection } =
|
|
295
|
+
* const { text, selection } = _parseView( 'f{ooba}r' );
|
|
295
296
|
* ```
|
|
296
297
|
*
|
|
297
298
|
* Ranges placed outside text nodes should be marked using `[` and `]` brackets:
|
|
298
299
|
*
|
|
299
300
|
* ```ts
|
|
300
|
-
* const { root, selection } =
|
|
301
|
+
* const { root, selection } = _parseView( '<p>[<b>foobar</b>]</p>' );
|
|
301
302
|
* ```
|
|
302
303
|
*
|
|
303
304
|
* ** Note: **
|
|
304
305
|
* It is possible to unify selection markers to `[` and `]` for both (inside and outside text)
|
|
305
|
-
* by setting `sameSelectionCharacters=true` option. It is mainly used when the view
|
|
306
|
+
* by setting `sameSelectionCharacters=true` option. It is mainly used when the view _parseView option is used by model utilities.
|
|
306
307
|
*
|
|
307
308
|
* Sometimes there is a need for defining the order of ranges inside the created selection. This can be achieved by providing
|
|
308
309
|
* the range order array as an additional parameter:
|
|
309
310
|
*
|
|
310
311
|
* ```ts
|
|
311
|
-
* const { root, selection } =
|
|
312
|
+
* const { root, selection } = _parseView( '{fo}ob{ar}{ba}z', { order: [ 2, 3, 1 ] } );
|
|
312
313
|
* ```
|
|
313
314
|
*
|
|
314
315
|
* In the example above, the first range (`{fo}`) will be added to the selection as the second one, the second range (`{ar}`) will be
|
|
315
316
|
* added as the third and the third range (`{ba}`) will be added as the first one.
|
|
316
317
|
*
|
|
317
318
|
* If the selection's last range should be added as a backward one
|
|
318
|
-
* (so the {@link module:engine/view/documentselection~
|
|
319
|
-
* by the `end` position and {@link module:engine/view/documentselection~
|
|
319
|
+
* (so the {@link module:engine/view/documentselection~ViewDocumentSelection#anchor selection anchor} is represented
|
|
320
|
+
* by the `end` position and {@link module:engine/view/documentselection~ViewDocumentSelection#focus selection focus} is
|
|
320
321
|
* represented by the `start` position), use the `lastRangeBackward` flag:
|
|
321
322
|
*
|
|
322
323
|
* ```ts
|
|
323
|
-
* const { root, selection } =
|
|
324
|
+
* const { root, selection } = _parseView( `{foo}bar{baz}`, { lastRangeBackward: true } );
|
|
324
325
|
* ```
|
|
325
326
|
*
|
|
326
327
|
* Some more examples and edge cases:
|
|
327
328
|
*
|
|
328
329
|
* ```ts
|
|
329
330
|
* // Returns an empty document fragment.
|
|
330
|
-
*
|
|
331
|
+
* _parseView( '' );
|
|
331
332
|
*
|
|
332
333
|
* // Returns an empty document fragment and a collapsed selection.
|
|
333
|
-
* const { root, selection } =
|
|
334
|
+
* const { root, selection } = _parseView( '[]' );
|
|
334
335
|
*
|
|
335
336
|
* // Returns an element and a selection that is placed inside the document fragment containing that element.
|
|
336
|
-
* const { root, selection } =
|
|
337
|
+
* const { root, selection } = _parseView( '[<a></a>]' );
|
|
337
338
|
* ```
|
|
338
339
|
*
|
|
339
340
|
* @param data An HTML-like string to be parsed.
|
|
340
341
|
* @param options.order An array with the order of parsed ranges added to the returned
|
|
341
|
-
* {@link module:engine/view/documentselection~
|
|
342
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection Selection} instance. Each element should represent the
|
|
342
343
|
* desired position of each range in the selection instance. For example: `[2, 3, 1]` means that the first range will be
|
|
343
344
|
* placed as the second, the second as the third and the third as the first.
|
|
344
345
|
* @param options.lastRangeBackward If set to `true`, the last range will be added as backward to the returned
|
|
345
|
-
* {@link module:engine/view/documentselection~
|
|
346
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance.
|
|
346
347
|
* @param options.rootElement The default root to use when parsing elements.
|
|
347
348
|
* When set to `null`, the root element will be created automatically. If set to
|
|
348
|
-
* {@link module:engine/view/element~
|
|
349
|
+
* {@link module:engine/view/element~ViewElement Element} or
|
|
350
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment DocumentFragment},
|
|
349
351
|
* this node will be used as the root for all parsed nodes.
|
|
350
352
|
* @param options.sameSelectionCharacters When set to `false`, the selection inside the text should be marked using
|
|
351
353
|
* `{` and `}` and the selection outside the ext using `[` and `]`. When set to `true`, both should be marked with `[` and `]` only.
|
|
352
354
|
* @returns Returns the parsed view node or an object with two fields: `view` and `selection` when selection ranges were included in the
|
|
353
355
|
* data to parse.
|
|
354
356
|
*/
|
|
355
|
-
export function
|
|
357
|
+
export function _parseView(data, options = {}) {
|
|
356
358
|
const viewDocument = new ViewDocument(new StylesProcessor());
|
|
357
359
|
options.order = options.order || [];
|
|
358
360
|
const rangeParser = new RangeParser({
|
|
@@ -367,7 +369,7 @@ export function parse(data, options = {}) {
|
|
|
367
369
|
// Convert data to view.
|
|
368
370
|
let view = processor.toView(data);
|
|
369
371
|
// At this point we have a view tree with Elements that could have names like `attribute:b:1`. In the next step
|
|
370
|
-
// we need to parse Element's names and convert them to
|
|
372
|
+
// we need to parse Element's names and convert them to ViewAttributeElements and ViewContainerElements.
|
|
371
373
|
view = _convertViewElements(view);
|
|
372
374
|
// If custom root is provided - move all nodes there.
|
|
373
375
|
if (options.rootElement) {
|
|
@@ -378,14 +380,14 @@ export function parse(data, options = {}) {
|
|
|
378
380
|
view = root;
|
|
379
381
|
}
|
|
380
382
|
// Parse ranges included in view text nodes.
|
|
381
|
-
const ranges = rangeParser.
|
|
383
|
+
const ranges = rangeParser._parseView(view, options.order);
|
|
382
384
|
// If only one element is returned inside DocumentFragment - return that element.
|
|
383
385
|
if (view.is('documentFragment') && view.childCount === 1) {
|
|
384
386
|
view = view.getChild(0);
|
|
385
387
|
}
|
|
386
388
|
// When ranges are present - return object containing view, and selection.
|
|
387
389
|
if (ranges.length) {
|
|
388
|
-
const selection = new
|
|
390
|
+
const selection = new ViewDocumentSelection(ranges, { backward: !!options.lastRangeBackward });
|
|
389
391
|
return {
|
|
390
392
|
view,
|
|
391
393
|
selection
|
|
@@ -398,7 +400,7 @@ export function parse(data, options = {}) {
|
|
|
398
400
|
return view;
|
|
399
401
|
}
|
|
400
402
|
/**
|
|
401
|
-
* Private helper class used for converting ranges represented as text inside view {@link module:engine/view/text~
|
|
403
|
+
* Private helper class used for converting ranges represented as text inside view {@link module:engine/view/text~ViewText text nodes}.
|
|
402
404
|
*/
|
|
403
405
|
class RangeParser {
|
|
404
406
|
sameSelectionCharacters;
|
|
@@ -414,7 +416,7 @@ class RangeParser {
|
|
|
414
416
|
this.sameSelectionCharacters = !!options.sameSelectionCharacters;
|
|
415
417
|
}
|
|
416
418
|
/**
|
|
417
|
-
* Parses the view and returns ranges represented inside {@link module:engine/view/text~
|
|
419
|
+
* Parses the view and returns ranges represented inside {@link module:engine/view/text~ViewText text nodes}.
|
|
418
420
|
* The method will remove all occurrences of `{`, `}`, `[` and `]` from found text nodes. If a text node is empty after
|
|
419
421
|
* the process, it will be removed, too.
|
|
420
422
|
*
|
|
@@ -424,7 +426,7 @@ class RangeParser {
|
|
|
424
426
|
* as the first.
|
|
425
427
|
* @returns An array with ranges found.
|
|
426
428
|
*/
|
|
427
|
-
|
|
429
|
+
_parseView(node, order) {
|
|
428
430
|
this._positions = [];
|
|
429
431
|
// Remove all range brackets from view nodes and save their positions.
|
|
430
432
|
this._getPositions(node);
|
|
@@ -487,7 +489,7 @@ class RangeParser {
|
|
|
487
489
|
// Store information about text range delimiter.
|
|
488
490
|
this._positions.push({
|
|
489
491
|
bracket: item.bracket,
|
|
490
|
-
position: new
|
|
492
|
+
position: new ViewPosition(node, item.textOffset)
|
|
491
493
|
});
|
|
492
494
|
}
|
|
493
495
|
else {
|
|
@@ -500,7 +502,7 @@ class RangeParser {
|
|
|
500
502
|
// Store information about element range delimiter.
|
|
501
503
|
this._positions.push({
|
|
502
504
|
bracket: item.bracket,
|
|
503
|
-
position: new
|
|
505
|
+
position: new ViewPosition(parent, offset)
|
|
504
506
|
});
|
|
505
507
|
}
|
|
506
508
|
}
|
|
@@ -513,7 +515,7 @@ class RangeParser {
|
|
|
513
515
|
// Store information about element range delimiter.
|
|
514
516
|
this._positions.push({
|
|
515
517
|
bracket: item.bracket,
|
|
516
|
-
position: new
|
|
518
|
+
position: new ViewPosition(parent, index)
|
|
517
519
|
});
|
|
518
520
|
}
|
|
519
521
|
}
|
|
@@ -558,7 +560,7 @@ class RangeParser {
|
|
|
558
560
|
throw new Error(`Parse error - start of range was found '${item.bracket}' but one range is already started.`);
|
|
559
561
|
}
|
|
560
562
|
if (item.bracket == ELEMENT_RANGE_START_TOKEN || item.bracket == TEXT_RANGE_START_TOKEN) {
|
|
561
|
-
range = new
|
|
563
|
+
range = new ViewRange(item.position, item.position);
|
|
562
564
|
}
|
|
563
565
|
else {
|
|
564
566
|
range.end = item.position;
|
|
@@ -588,6 +590,7 @@ class ViewStringify {
|
|
|
588
590
|
renderUIElements;
|
|
589
591
|
renderRawElements;
|
|
590
592
|
domConverter;
|
|
593
|
+
skipListItemIds;
|
|
591
594
|
/**
|
|
592
595
|
* Creates a view stringify instance.
|
|
593
596
|
*
|
|
@@ -601,12 +604,14 @@ class ViewStringify {
|
|
|
601
604
|
* @param options.sameSelectionCharacters When set to `true`, the selection inside the text is marked as
|
|
602
605
|
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both are marked as `[` and `]`.
|
|
603
606
|
* @param options.renderUIElements When set to `true`, the inner content of each
|
|
604
|
-
* {@link module:engine/view/uielement~
|
|
607
|
+
* {@link module:engine/view/uielement~ViewUIElement} will be printed.
|
|
605
608
|
* @param options.renderRawElements When set to `true`, the inner content of each
|
|
606
|
-
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~
|
|
609
|
+
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
|
|
607
610
|
* instance, it lets the conversion go through exactly the same flow the editing view is going through,
|
|
608
611
|
* i.e. with view data filtering. Otherwise the simple stub is used.
|
|
609
|
-
* {@link module:engine/view/rawelement~
|
|
612
|
+
* {@link module:engine/view/rawelement~ViewRawElement} will be printed.
|
|
613
|
+
* @param options.skipListItemIds When set to `true`, `<li>` elements will not have `listItemId` attribute. By default it's hidden
|
|
614
|
+
* because it's randomly generated and hard to verify properly, while bringing little value.
|
|
610
615
|
*/
|
|
611
616
|
constructor(root, selection, options) {
|
|
612
617
|
this.root = root;
|
|
@@ -623,6 +628,7 @@ class ViewStringify {
|
|
|
623
628
|
this.renderUIElements = !!options.renderUIElements;
|
|
624
629
|
this.renderRawElements = !!options.renderRawElements;
|
|
625
630
|
this.domConverter = options.domConverter || domConverterStub;
|
|
631
|
+
this.skipListItemIds = options.skipListItemIds !== undefined ? !!options.skipListItemIds : true;
|
|
626
632
|
}
|
|
627
633
|
/**
|
|
628
634
|
* Converts the view to a string.
|
|
@@ -634,6 +640,9 @@ class ViewStringify {
|
|
|
634
640
|
this._walkView(this.root, chunk => {
|
|
635
641
|
result += chunk;
|
|
636
642
|
});
|
|
643
|
+
if (this.skipListItemIds) {
|
|
644
|
+
result = result.replaceAll(/ data-list-item-id="[^"]+"/g, '');
|
|
645
|
+
}
|
|
637
646
|
return result;
|
|
638
647
|
}
|
|
639
648
|
/**
|
|
@@ -674,8 +683,9 @@ class ViewStringify {
|
|
|
674
683
|
}
|
|
675
684
|
}
|
|
676
685
|
/**
|
|
677
|
-
* Checks if a given {@link module:engine/view/element~
|
|
678
|
-
*
|
|
686
|
+
* Checks if a given {@link module:engine/view/element~ViewElement element} has
|
|
687
|
+
* a {@link module:engine/view/range~ViewRange#start range start}
|
|
688
|
+
* or a {@link module:engine/view/range~ViewRange#start range end} placed at a given offset and returns its string representation.
|
|
679
689
|
*/
|
|
680
690
|
_stringifyElementRanges(element, offset) {
|
|
681
691
|
let start = '';
|
|
@@ -697,9 +707,9 @@ class ViewStringify {
|
|
|
697
707
|
return end + collapsed + start;
|
|
698
708
|
}
|
|
699
709
|
/**
|
|
700
|
-
* Checks if a given {@link module:engine/view/element~
|
|
701
|
-
* {@link module:engine/view/range~
|
|
702
|
-
* {@link module:engine/view/range~
|
|
710
|
+
* Checks if a given {@link module:engine/view/element~ViewElement Text node} has a
|
|
711
|
+
* {@link module:engine/view/range~ViewRange#start range start} or a
|
|
712
|
+
* {@link module:engine/view/range~ViewRange#start range end} placed somewhere inside. Returns a string representation of text
|
|
703
713
|
* with range delimiters placed inside.
|
|
704
714
|
*/
|
|
705
715
|
_stringifyTextRanges(node) {
|
|
@@ -743,7 +753,7 @@ class ViewStringify {
|
|
|
743
753
|
return result.map(item => item.end + item.collapsed + item.start + item.letter).join('');
|
|
744
754
|
}
|
|
745
755
|
/**
|
|
746
|
-
* Converts the passed {@link module:engine/view/element~
|
|
756
|
+
* Converts the passed {@link module:engine/view/element~ViewElement element} to an opening tag.
|
|
747
757
|
*
|
|
748
758
|
* Depending on the current configuration, the opening tag can be simple (`<a>`), contain a type prefix (`<container:p>`,
|
|
749
759
|
* `<attribute:a>` or `<empty:img>`), contain priority information ( `<attribute:a view-priority="20">` ),
|
|
@@ -760,7 +770,7 @@ class ViewStringify {
|
|
|
760
770
|
return `<${parts.filter(i => i !== '').join(' ')}>`;
|
|
761
771
|
}
|
|
762
772
|
/**
|
|
763
|
-
* Converts the passed {@link module:engine/view/element~
|
|
773
|
+
* Converts the passed {@link module:engine/view/element~ViewElement element} to a closing tag.
|
|
764
774
|
* Depending on the current configuration, the closing tag can be simple (`</a>`) or contain a type prefix (`</container:p>`,
|
|
765
775
|
* `</attribute:a>` or `</empty:img>`).
|
|
766
776
|
*/
|
|
@@ -770,14 +780,14 @@ class ViewStringify {
|
|
|
770
780
|
return `</${name}>`;
|
|
771
781
|
}
|
|
772
782
|
/**
|
|
773
|
-
* Converts the passed {@link module:engine/view/element~
|
|
783
|
+
* Converts the passed {@link module:engine/view/element~ViewElement element's} type to its string representation
|
|
774
784
|
*
|
|
775
785
|
* Returns:
|
|
776
|
-
* * 'attribute' for {@link module:engine/view/attributeelement~
|
|
777
|
-
* * 'container' for {@link module:engine/view/containerelement~
|
|
778
|
-
* * 'empty' for {@link module:engine/view/emptyelement~
|
|
779
|
-
* * 'ui' for {@link module:engine/view/uielement~
|
|
780
|
-
* * 'raw' for {@link module:engine/view/rawelement~
|
|
786
|
+
* * 'attribute' for {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements},
|
|
787
|
+
* * 'container' for {@link module:engine/view/containerelement~ViewContainerElement container elements},
|
|
788
|
+
* * 'empty' for {@link module:engine/view/emptyelement~ViewEmptyElement empty elements},
|
|
789
|
+
* * 'ui' for {@link module:engine/view/uielement~ViewUIElement UI elements},
|
|
790
|
+
* * 'raw' for {@link module:engine/view/rawelement~ViewRawElement raw elements},
|
|
781
791
|
* * an empty string when the current configuration is preventing showing elements' types.
|
|
782
792
|
*/
|
|
783
793
|
_stringifyElementType(element) {
|
|
@@ -791,10 +801,10 @@ class ViewStringify {
|
|
|
791
801
|
return '';
|
|
792
802
|
}
|
|
793
803
|
/**
|
|
794
|
-
* Converts the passed {@link module:engine/view/element~
|
|
804
|
+
* Converts the passed {@link module:engine/view/element~ViewElement element} to its priority representation.
|
|
795
805
|
*
|
|
796
806
|
* The priority string representation will be returned when the passed element is an instance of
|
|
797
|
-
* {@link module:engine/view/attributeelement~
|
|
807
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute element} and the current configuration allows to show the
|
|
798
808
|
* priority. Otherwise returns an empty string.
|
|
799
809
|
*/
|
|
800
810
|
_stringifyElementPriority(element) {
|
|
@@ -804,10 +814,10 @@ class ViewStringify {
|
|
|
804
814
|
return '';
|
|
805
815
|
}
|
|
806
816
|
/**
|
|
807
|
-
* Converts the passed {@link module:engine/view/element~
|
|
817
|
+
* Converts the passed {@link module:engine/view/element~ViewElement element} to its id representation.
|
|
808
818
|
*
|
|
809
819
|
* The id string representation will be returned when the passed element is an instance of
|
|
810
|
-
* {@link module:engine/view/attributeelement~
|
|
820
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute element}, the element has an id
|
|
811
821
|
* and the current configuration allows to show the id. Otherwise returns an empty string.
|
|
812
822
|
*/
|
|
813
823
|
_stringifyElementId(element) {
|
|
@@ -817,7 +827,7 @@ class ViewStringify {
|
|
|
817
827
|
return '';
|
|
818
828
|
}
|
|
819
829
|
/**
|
|
820
|
-
* Converts the passed {@link module:engine/view/element~
|
|
830
|
+
* Converts the passed {@link module:engine/view/element~ViewElement element} attributes to their string representation.
|
|
821
831
|
* If an element has no attributes, an empty string is returned.
|
|
822
832
|
*/
|
|
823
833
|
_stringifyElementAttributes(element) {
|
|
@@ -845,11 +855,11 @@ class ViewStringify {
|
|
|
845
855
|
}
|
|
846
856
|
}
|
|
847
857
|
/**
|
|
848
|
-
* Converts {@link module:engine/view/element~
|
|
849
|
-
* {@link module:engine/view/attributeelement~
|
|
850
|
-
* {@link module:engine/view/containerelement~
|
|
851
|
-
* {@link module:engine/view/emptyelement~
|
|
852
|
-
* {@link module:engine/view/uielement~
|
|
858
|
+
* Converts {@link module:engine/view/element~ViewElement elements} to
|
|
859
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements},
|
|
860
|
+
* {@link module:engine/view/containerelement~ViewContainerElement container elements},
|
|
861
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement empty elements} or
|
|
862
|
+
* {@link module:engine/view/uielement~ViewUIElement UI elements}.
|
|
853
863
|
* It converts the whole tree starting from the `rootNode`. The conversion is based on element names.
|
|
854
864
|
* See the `_convertElement` method for more details.
|
|
855
865
|
*
|
|
@@ -867,7 +877,7 @@ function _convertViewElements(rootNode) {
|
|
|
867
877
|
// from `rootNode` to `convertedElement`. This would interfere with iteration.
|
|
868
878
|
for (const child of [...rootNode.getChildren()]) {
|
|
869
879
|
if (convertedElement.is('emptyElement')) {
|
|
870
|
-
throw new Error('Parse error - cannot parse inside
|
|
880
|
+
throw new Error('Parse error - cannot parse inside ViewEmptyElement.');
|
|
871
881
|
}
|
|
872
882
|
else if (convertedElement.is('uiElement')) {
|
|
873
883
|
throw new Error('Parse error - cannot parse inside UIElement.');
|
|
@@ -882,22 +892,22 @@ function _convertViewElements(rootNode) {
|
|
|
882
892
|
return rootNode;
|
|
883
893
|
}
|
|
884
894
|
/**
|
|
885
|
-
* Converts an {@link module:engine/view/element~
|
|
886
|
-
* {@link module:engine/view/attributeelement~
|
|
887
|
-
* {@link module:engine/view/containerelement~
|
|
888
|
-
* {@link module:engine/view/emptyelement~
|
|
889
|
-
* {@link module:engine/view/uielement~
|
|
895
|
+
* Converts an {@link module:engine/view/element~ViewElement element} to
|
|
896
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute element},
|
|
897
|
+
* {@link module:engine/view/containerelement~ViewContainerElement container element},
|
|
898
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement empty element} or
|
|
899
|
+
* {@link module:engine/view/uielement~ViewUIElement UI element}.
|
|
890
900
|
* If the element's name is in the format of `attribute:b`, it will be converted to
|
|
891
|
-
* an {@link module:engine/view/attributeelement~
|
|
901
|
+
* an {@link module:engine/view/attributeelement~ViewAttributeElement attribute element} with a priority of 11.
|
|
892
902
|
* Additionally, attribute elements may have specified priority (for example `view-priority="11"`) and/or
|
|
893
903
|
* id (for example `view-id="foo"`).
|
|
894
904
|
* If the element's name is in the format of `container:p`, it will be converted to
|
|
895
|
-
* a {@link module:engine/view/containerelement~
|
|
905
|
+
* a {@link module:engine/view/containerelement~ViewContainerElement container element}.
|
|
896
906
|
* If the element's name is in the format of `empty:img`, it will be converted to
|
|
897
|
-
* an {@link module:engine/view/emptyelement~
|
|
907
|
+
* an {@link module:engine/view/emptyelement~ViewEmptyElement empty element}.
|
|
898
908
|
* If the element's name is in the format of `ui:span`, it will be converted to
|
|
899
|
-
* a {@link module:engine/view/uielement~
|
|
900
|
-
* If the element's name does not contain any additional information, a {@link module:engine/view/element~
|
|
909
|
+
* a {@link module:engine/view/uielement~ViewUIElement UI element}.
|
|
910
|
+
* If the element's name does not contain any additional information, a {@link module:engine/view/element~ViewElement view Element} will be
|
|
901
911
|
* returned.
|
|
902
912
|
*
|
|
903
913
|
* @param viewElement A view element to convert.
|
|
@@ -922,11 +932,11 @@ function _convertElement(viewDocument, viewElement) {
|
|
|
922
932
|
return newElement;
|
|
923
933
|
}
|
|
924
934
|
/**
|
|
925
|
-
* Converts the `view-priority` attribute and the {@link module:engine/view/element~
|
|
926
|
-
* creating {@link module:engine/view/attributeelement~
|
|
927
|
-
* {@link module:engine/view/containerelement~
|
|
928
|
-
* {@link module:engine/view/emptyelement~
|
|
929
|
-
* {@link module:engine/view/uielement~
|
|
935
|
+
* Converts the `view-priority` attribute and the {@link module:engine/view/element~ViewElement#name element's name} information needed for
|
|
936
|
+
* creating {@link module:engine/view/attributeelement~ViewAttributeElement attribute element},
|
|
937
|
+
* {@link module:engine/view/containerelement~ViewContainerElement container element},
|
|
938
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement empty element} or
|
|
939
|
+
* {@link module:engine/view/uielement~ViewUIElement UI element}.
|
|
930
940
|
* The name can be provided in two formats: as a simple element's name (`div`), or as a type and name (`container:div`,
|
|
931
941
|
* `attribute:span`, `empty:img`, `ui:span`);
|
|
932
942
|
*
|