@ckeditor/ckeditor5-engine 48.2.0 → 48.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller/datacontroller.d.ts +329 -328
- package/dist/controller/editingcontroller.d.ts +95 -94
- package/dist/conversion/comparemarkers.d.ts +45 -45
- package/dist/conversion/conversion.d.ts +474 -474
- package/dist/conversion/conversionhelpers.d.ts +21 -21
- package/dist/conversion/downcastdispatcher.d.ts +539 -538
- package/dist/conversion/downcasthelpers.d.ts +1129 -1129
- package/dist/conversion/mapper.d.ts +692 -697
- package/dist/conversion/modelconsumable.d.ts +196 -196
- package/dist/conversion/upcastdispatcher.d.ts +483 -482
- package/dist/conversion/upcasthelpers.d.ts +491 -491
- package/dist/conversion/viewconsumable.d.ts +330 -330
- package/dist/dataprocessor/basichtmlwriter.d.ts +15 -15
- package/dist/dataprocessor/dataprocessor.d.ts +57 -57
- package/dist/dataprocessor/htmldataprocessor.d.ts +72 -72
- package/dist/dataprocessor/htmlwriter.d.ts +11 -11
- package/dist/dataprocessor/xmldataprocessor.d.ts +86 -86
- package/dist/dev-utils/model.d.ts +128 -123
- package/dist/dev-utils/operationreplayer.d.ts +49 -49
- package/dist/dev-utils/utils.d.ts +33 -33
- package/dist/dev-utils/view.d.ts +314 -309
- package/dist/engineconfig.d.ts +39 -39
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +150 -150
- package/dist/index.js +34026 -40107
- package/dist/index.js.map +1 -1
- package/dist/legacyerrors.d.ts +0 -4
- package/dist/model/batch.d.ts +86 -86
- package/dist/model/differ.d.ts +504 -504
- package/dist/model/document.d.ts +265 -268
- package/dist/model/documentfragment.d.ts +214 -214
- package/dist/model/documentselection.d.ts +406 -410
- package/dist/model/element.d.ts +182 -182
- package/dist/model/history.d.ts +109 -109
- package/dist/model/item.d.ts +9 -9
- package/dist/model/liveposition.d.ts +70 -69
- package/dist/model/liverange.d.ts +93 -92
- package/dist/model/markercollection.d.ts +317 -324
- package/dist/model/model.d.ts +889 -909
- package/dist/model/node.d.ts +254 -254
- package/dist/model/nodelist.d.ts +110 -110
- package/dist/model/operation/attributeoperation.d.ts +98 -98
- package/dist/model/operation/detachoperation.d.ts +57 -57
- package/dist/model/operation/insertoperation.d.ts +85 -85
- package/dist/model/operation/markeroperation.d.ts +87 -87
- package/dist/model/operation/mergeoperation.d.ts +95 -95
- package/dist/model/operation/moveoperation.d.ts +97 -97
- package/dist/model/operation/nooperation.d.ts +33 -33
- package/dist/model/operation/operation.d.ts +94 -94
- package/dist/model/operation/operationfactory.d.ts +14 -14
- package/dist/model/operation/renameoperation.d.ts +78 -78
- package/dist/model/operation/rootattributeoperation.d.ts +93 -93
- package/dist/model/operation/rootoperation.d.ts +71 -71
- package/dist/model/operation/splitoperation.d.ts +104 -104
- package/dist/model/operation/transform.d.ts +91 -91
- package/dist/model/operation/utils.d.ts +58 -58
- package/dist/model/position.d.ts +535 -535
- package/dist/model/range.d.ts +458 -453
- package/dist/model/rootelement.d.ts +55 -55
- package/dist/model/schema.d.ts +1325 -1327
- package/dist/model/selection.d.ts +452 -471
- package/dist/model/text.d.ts +62 -62
- package/dist/model/textproxy.d.ts +140 -140
- package/dist/model/treewalker.d.ts +190 -190
- package/dist/model/typecheckable.d.ts +281 -281
- package/dist/model/utils/autoparagraphing.d.ts +29 -29
- package/dist/model/utils/deletecontent.d.ts +68 -68
- package/dist/model/utils/getselectedcontent.d.ts +27 -27
- package/dist/model/utils/insertcontent.d.ts +42 -42
- package/dist/model/utils/insertobject.d.ts +41 -41
- package/dist/model/utils/modifyselection.d.ts +44 -44
- package/dist/model/utils/selection-post-fixer.d.ts +71 -71
- package/dist/model/writer.d.ts +854 -854
- package/dist/view/attributeelement.d.ts +123 -123
- package/dist/view/containerelement.d.ts +49 -49
- package/dist/view/datatransfer.d.ts +70 -70
- package/dist/view/document.d.ts +175 -177
- package/dist/view/documentfragment.d.ts +158 -157
- package/dist/view/documentselection.d.ts +308 -307
- package/dist/view/domconverter.d.ts +612 -657
- package/dist/view/downcastwriter.d.ts +1006 -1006
- package/dist/view/editableelement.d.ts +64 -63
- package/dist/view/element.d.ts +754 -754
- package/dist/view/elementdefinition.d.ts +79 -79
- package/dist/view/emptyelement.d.ts +42 -42
- package/dist/view/filler.d.ts +75 -75
- package/dist/view/item.d.ts +9 -9
- package/dist/view/matcher.d.ts +412 -487
- package/dist/view/node.d.ts +164 -163
- package/dist/view/observer/arrowkeysobserver.d.ts +37 -37
- package/dist/view/observer/bubblingemittermixin.d.ts +163 -153
- package/dist/view/observer/bubblingeventinfo.d.ts +45 -42
- package/dist/view/observer/clickobserver.d.ts +36 -36
- package/dist/view/observer/compositionobserver.d.ts +67 -67
- package/dist/view/observer/domeventdata.d.ts +46 -46
- package/dist/view/observer/domeventobserver.d.ts +77 -74
- package/dist/view/observer/fakeselectionobserver.d.ts +42 -42
- package/dist/view/observer/focusobserver.d.ts +84 -84
- package/dist/view/observer/inputobserver.d.ts +76 -76
- package/dist/view/observer/keyobserver.d.ts +53 -53
- package/dist/view/observer/mouseobserver.d.ts +73 -73
- package/dist/view/observer/mutationobserver.d.ts +101 -101
- package/dist/view/observer/observer.d.ts +84 -83
- package/dist/view/observer/pointerobserver.d.ts +63 -63
- package/dist/view/observer/selectionobserver.d.ts +136 -136
- package/dist/view/observer/tabobserver.d.ts +38 -38
- package/dist/view/observer/touchobserver.d.ts +60 -60
- package/dist/view/placeholder.d.ts +80 -80
- package/dist/view/position.d.ts +187 -187
- package/dist/view/range.d.ts +282 -282
- package/dist/view/rawelement.d.ts +72 -72
- package/dist/view/renderer.d.ts +270 -272
- package/dist/view/rooteditableelement.d.ts +43 -43
- package/dist/view/selection.d.ts +356 -369
- package/dist/view/styles/background.d.ts +15 -15
- package/dist/view/styles/border.d.ts +27 -27
- package/dist/view/styles/margin.d.ts +12 -12
- package/dist/view/styles/padding.d.ts +12 -12
- package/dist/view/styles/utils.d.ts +72 -72
- package/dist/view/stylesmap.d.ts +715 -715
- package/dist/view/text.d.ts +75 -75
- package/dist/view/textproxy.d.ts +92 -92
- package/dist/view/tokenlist.d.ts +104 -104
- package/dist/view/treewalker.d.ts +201 -201
- package/dist/view/typecheckable.d.ts +445 -445
- package/dist/view/uielement.d.ts +93 -93
- package/dist/view/upcastwriter.d.ts +412 -412
- package/dist/view/view.d.ts +466 -469
- package/package.json +2 -2
package/dist/dev-utils/view.d.ts
CHANGED
|
@@ -1,321 +1,326 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* @module engine/dev-utils/view
|
|
7
|
+
*/
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { EditingView } from
|
|
12
|
-
import { ViewDocumentFragment } from
|
|
13
|
-
import { ViewElement } from
|
|
14
|
-
import { ViewDocumentSelection } from
|
|
15
|
-
import { ViewRange } from
|
|
16
|
-
import { ViewPosition } from
|
|
17
|
-
import { type ViewNode } from
|
|
18
|
-
import { type ViewDomConverter } from
|
|
9
|
+
* Collection of methods for manipulating the {@link module:engine/view/view view} for testing purposes.
|
|
10
|
+
*/
|
|
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
|
+
type GetViewDataOptions = {
|
|
20
|
+
withoutSelection?: boolean;
|
|
21
|
+
rootName?: string;
|
|
22
|
+
showType?: boolean;
|
|
23
|
+
showPriority?: boolean;
|
|
24
|
+
renderUIElements?: boolean;
|
|
25
|
+
renderRawElements?: boolean;
|
|
26
|
+
domConverter?: ViewDomConverter;
|
|
27
|
+
skipListItemIds?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type GetViewData = {
|
|
30
|
+
(view: EditingView, options?: GetViewDataOptions): string;
|
|
31
|
+
_stringify: typeof _stringifyView;
|
|
32
|
+
};
|
|
33
|
+
type SetViewDataOptions = {
|
|
34
|
+
rootName?: string;
|
|
35
|
+
};
|
|
36
|
+
type SetViewData = {
|
|
37
|
+
(view: EditingView, data: string, options?: SetViewDataOptions): void;
|
|
38
|
+
_parse: typeof _parseView;
|
|
39
|
+
};
|
|
19
40
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export declare
|
|
41
|
-
withoutSelection?: boolean;
|
|
42
|
-
rootName?: string;
|
|
43
|
-
showType?: boolean;
|
|
44
|
-
showPriority?: boolean;
|
|
45
|
-
renderUIElements?: boolean;
|
|
46
|
-
renderRawElements?: boolean;
|
|
47
|
-
domConverter?: ViewDomConverter;
|
|
48
|
-
skipListItemIds?: boolean;
|
|
49
|
-
}): string;
|
|
50
|
-
export declare namespace _getViewData {
|
|
51
|
-
var _stringify: typeof _stringifyView;
|
|
52
|
-
}
|
|
41
|
+
* Writes the content of the {@link module:engine/view/document~ViewDocument document} to an HTML-like string.
|
|
42
|
+
*
|
|
43
|
+
* @param view The view to stringify.
|
|
44
|
+
* @param options.withoutSelection Whether to write the selection. When set to `true`, the selection will
|
|
45
|
+
* not be included in the returned string.
|
|
46
|
+
* @param options.rootName The name of the root from which the data should be stringified. If not provided,
|
|
47
|
+
* the default `main` name will be used.
|
|
48
|
+
* @param options.showType When set to `true`, the type of elements will be printed (`<container:p>`
|
|
49
|
+
* instead of `<p>`, `<attribute:b>` instead of `<b>` and `<empty:img>` instead of `<img>`).
|
|
50
|
+
* @param options.showPriority When set to `true`, the attribute element's priority will be printed
|
|
51
|
+
* (`<span view-priority="12">`, `<b view-priority="10">`).
|
|
52
|
+
* @param options.renderUIElements When set to `true`, the inner content of each
|
|
53
|
+
* {@link module:engine/view/uielement~ViewUIElement} will be printed.
|
|
54
|
+
* @param options.renderRawElements When set to `true`, the inner content of each
|
|
55
|
+
* {@link module:engine/view/rawelement~ViewRawElement} will be printed.
|
|
56
|
+
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
|
|
57
|
+
* instance, it lets the conversion go through exactly the same flow the editing view is going through,
|
|
58
|
+
* i.e. with view data filtering. Otherwise the simple stub is used.
|
|
59
|
+
* @returns The stringified data.
|
|
60
|
+
*/
|
|
61
|
+
export declare const _getViewData: GetViewData;
|
|
53
62
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export declare
|
|
61
|
-
rootName?: string;
|
|
62
|
-
}): void;
|
|
63
|
-
export declare namespace _setViewData {
|
|
64
|
-
var _parse: typeof _parseView;
|
|
65
|
-
}
|
|
63
|
+
* Sets the content of a view {@link module:engine/view/document~ViewDocument document} provided as an HTML-like string.
|
|
64
|
+
*
|
|
65
|
+
* @param data An HTML-like string to write into the document.
|
|
66
|
+
* @param options.rootName The root name where _parseViewd data will be stored. If not provided,
|
|
67
|
+
* the default `main` name will be used.
|
|
68
|
+
*/
|
|
69
|
+
export declare const _setViewData: SetViewData;
|
|
66
70
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
71
|
+
* Converts view elements to HTML-like string representation.
|
|
72
|
+
*
|
|
73
|
+
* A root element can be provided as {@link module:engine/view/text~ViewText text}:
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* const text = downcastWriter.createText( 'foobar' );
|
|
77
|
+
* stringify( text ); // 'foobar'
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* or as an {@link module:engine/view/element~ViewElement element}:
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* const element = downcastWriter.createElement( 'p', null, downcastWriter.createText( 'foobar' ) );
|
|
84
|
+
* stringify( element ); // '<p>foobar</p>'
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* or as a {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}:
|
|
88
|
+
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* const text = downcastWriter.createText( 'foobar' );
|
|
91
|
+
* const b = downcastWriter.createElement( 'b', { name: 'test' }, text );
|
|
92
|
+
* const p = downcastWriter.createElement( 'p', { style: 'color:red;' } );
|
|
93
|
+
* const fragment = downcastWriter.createDocumentFragment( [ p, b ] );
|
|
94
|
+
*
|
|
95
|
+
* stringify( fragment ); // '<p style="color:red;"></p><b name="test">foobar</b>'
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* Additionally, a {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance can be provided.
|
|
99
|
+
* Ranges from the selection will then be included in the output data.
|
|
100
|
+
* If a range position is placed inside the element node, it will be represented with `[` and `]`:
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* const text = downcastWriter.createText( 'foobar' );
|
|
104
|
+
* const b = downcastWriter.createElement( 'b', null, text );
|
|
105
|
+
* const p = downcastWriter.createElement( 'p', null, b );
|
|
106
|
+
* const selection = downcastWriter.createSelection(
|
|
107
|
+
* downcastWriter.createRangeIn( p )
|
|
108
|
+
* );
|
|
109
|
+
*
|
|
110
|
+
* stringify( p, selection ); // '<p>[<b>foobar</b>]</p>'
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* If a range is placed inside the text node, it will be represented with `{` and `}`:
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* const text = downcastWriter.createText( 'foobar' );
|
|
117
|
+
* const b = downcastWriter.createElement( 'b', null, text );
|
|
118
|
+
* const p = downcastWriter.createElement( 'p', null, b );
|
|
119
|
+
* const selection = downcastWriter.createSelection(
|
|
120
|
+
* downcastWriter.createRange( downcastWriter.createPositionAt( text, 1 ), downcastWriter.createPositionAt( text, 5 ) )
|
|
121
|
+
* );
|
|
122
|
+
*
|
|
123
|
+
* stringify( p, selection ); // '<p><b>f{ooba}r</b></p>'
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* ** Note: **
|
|
127
|
+
* It is possible to unify selection markers to `[` and `]` for both (inside and outside text)
|
|
128
|
+
* by setting the `sameSelectionCharacters=true` option. It is mainly used when the view stringify option is used by
|
|
129
|
+
* model utilities.
|
|
130
|
+
*
|
|
131
|
+
* Multiple ranges are supported:
|
|
132
|
+
*
|
|
133
|
+
* ```ts
|
|
134
|
+
* const text = downcastWriter.createText( 'foobar' );
|
|
135
|
+
* const selection = downcastWriter.createSelection( [
|
|
136
|
+
* downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) ),
|
|
137
|
+
* downcastWriter.createRange( downcastWriter.createPositionAt( text, 3 ), downcastWriter.createPositionAt( text, 5 ) )
|
|
138
|
+
* ] );
|
|
139
|
+
*
|
|
140
|
+
* stringify( text, selection ); // '{f}oo{ba}r'
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* A {@link module:engine/view/range~ViewRange range} or {@link module:engine/view/position~ViewPosition position} instance can be provided
|
|
144
|
+
* instead of the {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance. If a range instance
|
|
145
|
+
* is provided, it will be converted to a selection containing this range. If a position instance is provided, it will
|
|
146
|
+
* be converted to a selection containing one range collapsed at this position.
|
|
147
|
+
*
|
|
148
|
+
* ```ts
|
|
149
|
+
* const text = downcastWriter.createText( 'foobar' );
|
|
150
|
+
* const range = downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) );
|
|
151
|
+
* const position = downcastWriter.createPositionAt( text, 3 );
|
|
152
|
+
*
|
|
153
|
+
* stringify( text, range ); // '{f}oobar'
|
|
154
|
+
* stringify( text, position ); // 'foo{}bar'
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* An additional `options` object can be provided.
|
|
158
|
+
* If `options.showType` is set to `true`, element's types will be
|
|
159
|
+
* presented for {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements},
|
|
160
|
+
* {@link module:engine/view/containerelement~ViewContainerElement container elements}
|
|
161
|
+
* {@link module:engine/view/emptyelement~ViewEmptyElement empty elements}
|
|
162
|
+
* and {@link module:engine/view/uielement~ViewUIElement UI elements}:
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const attribute = downcastWriter.createAttributeElement( 'b' );
|
|
166
|
+
* const container = downcastWriter.createContainerElement( 'p' );
|
|
167
|
+
* const empty = downcastWriter.createEmptyElement( 'img' );
|
|
168
|
+
* const ui = downcastWriter.createUIElement( 'span' );
|
|
169
|
+
* getData( attribute, null, { showType: true } ); // '<attribute:b></attribute:b>'
|
|
170
|
+
* getData( container, null, { showType: true } ); // '<container:p></container:p>'
|
|
171
|
+
* getData( empty, null, { showType: true } ); // '<empty:img></empty:img>'
|
|
172
|
+
* getData( ui, null, { showType: true } ); // '<ui:span></ui:span>'
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* If `options.showPriority` is set to `true`, a priority will be displayed for all
|
|
176
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements}.
|
|
177
|
+
*
|
|
178
|
+
* ```ts
|
|
179
|
+
* const attribute = downcastWriter.createAttributeElement( 'b' );
|
|
180
|
+
* attribute._priority = 20;
|
|
181
|
+
* getData( attribute, null, { showPriority: true } ); // <b view-priority="20"></b>
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* If `options.showAttributeElementId` is set to `true`, the attribute element's id will be displayed for all
|
|
185
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements} that have it set.
|
|
186
|
+
*
|
|
187
|
+
* ```ts
|
|
188
|
+
* const attribute = downcastWriter.createAttributeElement( 'span' );
|
|
189
|
+
* attribute._id = 'marker:foo';
|
|
190
|
+
* getData( attribute, null, { showAttributeElementId: true } ); // <span view-id="marker:foo"></span>
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @param node The node to stringify.
|
|
194
|
+
* @param selectionOrPositionOrRange A selection instance whose ranges will be included in the returned string data.
|
|
195
|
+
* If a range instance is provided, it will be converted to a selection containing this range. If a position instance
|
|
196
|
+
* is provided, it will be converted to a selection containing one range collapsed at this position.
|
|
197
|
+
* @param options An object with additional options.
|
|
198
|
+
* @param options.showType When set to `true`, the type of elements will be printed (`<container:p>`
|
|
199
|
+
* instead of `<p>`, `<attribute:b>` instead of `<b>` and `<empty:img>` instead of `<img>`).
|
|
200
|
+
* @param options.showPriority When set to `true`, the attribute element's priority will be printed
|
|
201
|
+
* (`<span view-priority="12">`, `<b view-priority="10">`).
|
|
202
|
+
* @param options.showAttributeElementId When set to `true`, attribute element's id will be printed
|
|
203
|
+
* (`<span id="marker:foo">`).
|
|
204
|
+
* @param options.ignoreRoot When set to `true`, the root's element opening and closing will not be printed.
|
|
205
|
+
* Mainly used by the `getData` function to ignore the {@link module:engine/view/document~ViewDocument document's} root element.
|
|
206
|
+
* @param options.sameSelectionCharacters When set to `true`, the selection inside the text will be marked as
|
|
207
|
+
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both will be marked as `[` and `]` only.
|
|
208
|
+
* @param options.renderUIElements When set to `true`, the inner content of each
|
|
209
|
+
* {@link module:engine/view/uielement~ViewUIElement} will be printed.
|
|
210
|
+
* @param options.renderRawElements When set to `true`, the inner content of each
|
|
211
|
+
* {@link module:engine/view/rawelement~ViewRawElement} will be printed.
|
|
212
|
+
* @param options.domConverter When set to an actual {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
|
|
213
|
+
* instance, it lets the conversion go through exactly the same flow the editing view is going through,
|
|
214
|
+
* i.e. with view data filtering. Otherwise the simple stub is used.
|
|
215
|
+
* @returns An HTML-like string representing the view.
|
|
216
|
+
*/
|
|
213
217
|
export declare function _stringifyView(node: ViewNode | ViewDocumentFragment, selectionOrPositionOrRange?: ViewDocumentSelection | ViewPosition | ViewRange | null, options?: {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
showType?: boolean;
|
|
219
|
+
showPriority?: boolean;
|
|
220
|
+
showAttributeElementId?: boolean;
|
|
221
|
+
ignoreRoot?: boolean;
|
|
222
|
+
sameSelectionCharacters?: boolean;
|
|
223
|
+
renderUIElements?: boolean;
|
|
224
|
+
renderRawElements?: boolean;
|
|
225
|
+
domConverter?: ViewDomConverter;
|
|
226
|
+
skipListItemIds?: boolean;
|
|
223
227
|
}): string;
|
|
224
228
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
229
|
+
* Parses an HTML-like string and returns a view tree.
|
|
230
|
+
* A simple string will be converted to a {@link module:engine/view/text~ViewText text} node:
|
|
231
|
+
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* _parseView( 'foobar' ); // Returns an instance of text.
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* {@link module:engine/view/element~ViewElement Elements} will be _parseViewd with attributes as children:
|
|
237
|
+
*
|
|
238
|
+
* ```ts
|
|
239
|
+
* _parseView( '<b name="baz">foobar</b>' ); // Returns an instance of element with the `baz` attribute and a text child node.
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* Multiple nodes provided on root level will be converted to a
|
|
243
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}:
|
|
244
|
+
*
|
|
245
|
+
* ```ts
|
|
246
|
+
* _parseView( '<b>foo</b><i>bar</i>' ); // Returns a document fragment with two child elements.
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* The method can _parseView multiple {@link module:engine/view/range~ViewRange ranges} provided in string data and return a
|
|
250
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance containing these ranges. Ranges placed inside
|
|
251
|
+
* {@link module:engine/view/text~ViewText text} nodes should be marked using `{` and `}` brackets:
|
|
252
|
+
*
|
|
253
|
+
* ```ts
|
|
254
|
+
* const { text, selection } = _parseView( 'f{ooba}r' );
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* Ranges placed outside text nodes should be marked using `[` and `]` brackets:
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* const { root, selection } = _parseView( '<p>[<b>foobar</b>]</p>' );
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
263
|
+
* ** Note: **
|
|
264
|
+
* It is possible to unify selection markers to `[` and `]` for both (inside and outside text)
|
|
265
|
+
* by setting `sameSelectionCharacters=true` option. It is mainly used when the view _parseView option is used by model utilities.
|
|
266
|
+
*
|
|
267
|
+
* Sometimes there is a need for defining the order of ranges inside the created selection. This can be achieved by providing
|
|
268
|
+
* the range order array as an additional parameter:
|
|
269
|
+
*
|
|
270
|
+
* ```ts
|
|
271
|
+
* const { root, selection } = _parseView( '{fo}ob{ar}{ba}z', { order: [ 2, 3, 1 ] } );
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* In the example above, the first range (`{fo}`) will be added to the selection as the second one, the second range (`{ar}`) will be
|
|
275
|
+
* added as the third and the third range (`{ba}`) will be added as the first one.
|
|
276
|
+
*
|
|
277
|
+
* If the selection's last range should be added as a backward one
|
|
278
|
+
* (so the {@link module:engine/view/documentselection~ViewDocumentSelection#anchor selection anchor} is represented
|
|
279
|
+
* by the `end` position and {@link module:engine/view/documentselection~ViewDocumentSelection#focus selection focus} is
|
|
280
|
+
* represented by the `start` position), use the `lastRangeBackward` flag:
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* const { root, selection } = _parseView( `{foo}bar{baz}`, { lastRangeBackward: true } );
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
286
|
+
* Some more examples and edge cases:
|
|
287
|
+
*
|
|
288
|
+
* ```ts
|
|
289
|
+
* // Returns an empty document fragment.
|
|
290
|
+
* _parseView( '' );
|
|
291
|
+
*
|
|
292
|
+
* // Returns an empty document fragment and a collapsed selection.
|
|
293
|
+
* const { root, selection } = _parseView( '[]' );
|
|
294
|
+
*
|
|
295
|
+
* // Returns an element and a selection that is placed inside the document fragment containing that element.
|
|
296
|
+
* const { root, selection } = _parseView( '[<a></a>]' );
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @param data An HTML-like string to be parsed.
|
|
300
|
+
* @param options.order An array with the order of parsed ranges added to the returned
|
|
301
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection Selection} instance. Each element should represent the
|
|
302
|
+
* desired position of each range in the selection instance. For example: `[2, 3, 1]` means that the first range will be
|
|
303
|
+
* placed as the second, the second as the third and the third as the first.
|
|
304
|
+
* @param options.lastRangeBackward If set to `true`, the last range will be added as backward to the returned
|
|
305
|
+
* {@link module:engine/view/documentselection~ViewDocumentSelection selection} instance.
|
|
306
|
+
* @param options.rootElement The default root to use when parsing elements.
|
|
307
|
+
* When set to `null`, the root element will be created automatically. If set to
|
|
308
|
+
* {@link module:engine/view/element~ViewElement Element} or
|
|
309
|
+
* {@link module:engine/view/documentfragment~ViewDocumentFragment DocumentFragment},
|
|
310
|
+
* this node will be used as the root for all parsed nodes.
|
|
311
|
+
* @param options.sameSelectionCharacters When set to `false`, the selection inside the text should be marked using
|
|
312
|
+
* `{` and `}` and the selection outside the ext using `[` and `]`. When set to `true`, both should be marked with `[` and `]` only.
|
|
313
|
+
* @returns Returns the parsed view node or an object with two fields: `view` and `selection` when selection ranges were included in the
|
|
314
|
+
* data to parse.
|
|
315
|
+
*/
|
|
312
316
|
export declare function _parseView(data: string, options?: {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
317
|
+
order?: Array<number>;
|
|
318
|
+
lastRangeBackward?: boolean;
|
|
319
|
+
rootElement?: ViewElement | ViewDocumentFragment;
|
|
320
|
+
sameSelectionCharacters?: boolean;
|
|
321
|
+
inlineObjectElements?: Array<string>;
|
|
318
322
|
}): ViewNode | ViewDocumentFragment | {
|
|
319
|
-
|
|
320
|
-
|
|
323
|
+
view: ViewNode | ViewDocumentFragment;
|
|
324
|
+
selection: ViewDocumentSelection;
|
|
321
325
|
};
|
|
326
|
+
export {};
|