@ckeditor/ckeditor5-engine 36.0.1 → 37.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/README.md +1 -1
- package/package.json +24 -23
- package/src/controller/datacontroller.d.ts +331 -0
- package/src/controller/datacontroller.js +62 -109
- package/src/controller/editingcontroller.d.ts +98 -0
- package/src/controller/editingcontroller.js +22 -46
- package/src/conversion/conversion.d.ts +476 -0
- package/src/conversion/conversion.js +328 -347
- package/src/conversion/conversionhelpers.d.ts +26 -0
- package/src/conversion/conversionhelpers.js +1 -5
- package/src/conversion/downcastdispatcher.d.ts +547 -0
- package/src/conversion/downcastdispatcher.js +74 -152
- package/src/conversion/downcasthelpers.d.ts +1226 -0
- package/src/conversion/downcasthelpers.js +843 -762
- package/src/conversion/mapper.d.ts +499 -0
- package/src/conversion/mapper.js +84 -99
- package/src/conversion/modelconsumable.d.ts +201 -0
- package/src/conversion/modelconsumable.js +96 -99
- package/src/conversion/upcastdispatcher.d.ts +492 -0
- package/src/conversion/upcastdispatcher.js +73 -100
- package/src/conversion/upcasthelpers.d.ts +499 -0
- package/src/conversion/upcasthelpers.js +406 -373
- package/src/conversion/viewconsumable.d.ts +177 -0
- package/src/conversion/viewconsumable.js +157 -162
- package/src/dataprocessor/basichtmlwriter.d.ts +18 -0
- package/src/dataprocessor/basichtmlwriter.js +0 -9
- package/src/dataprocessor/dataprocessor.d.ts +61 -0
- package/src/dataprocessor/htmldataprocessor.d.ts +76 -0
- package/src/dataprocessor/htmldataprocessor.js +6 -28
- package/src/dataprocessor/htmlwriter.d.ts +16 -0
- package/src/dataprocessor/xmldataprocessor.d.ts +90 -0
- package/src/dataprocessor/xmldataprocessor.js +8 -40
- package/src/dev-utils/model.d.ts +124 -0
- package/src/dev-utils/model.js +41 -38
- package/src/dev-utils/operationreplayer.d.ts +51 -0
- package/src/dev-utils/operationreplayer.js +6 -14
- package/src/dev-utils/utils.d.ts +37 -0
- package/src/dev-utils/utils.js +5 -18
- package/src/dev-utils/view.d.ts +319 -0
- package/src/dev-utils/view.js +205 -226
- package/src/index.d.ts +105 -0
- package/src/index.js +1 -0
- package/src/model/batch.d.ts +106 -0
- package/src/model/differ.d.ts +329 -0
- package/src/model/document.d.ts +245 -0
- package/src/model/document.js +1 -1
- package/src/model/documentfragment.d.ts +196 -0
- package/src/model/documentfragment.js +2 -2
- package/src/model/documentselection.d.ts +420 -0
- package/src/model/element.d.ts +165 -0
- package/src/model/history.d.ts +114 -0
- package/src/model/item.d.ts +14 -0
- package/src/model/liveposition.d.ts +77 -0
- package/src/model/liverange.d.ts +102 -0
- package/src/model/markercollection.d.ts +335 -0
- package/src/model/model.d.ts +812 -0
- package/src/model/model.js +59 -30
- package/src/model/node.d.ts +256 -0
- package/src/model/nodelist.d.ts +91 -0
- package/src/model/operation/attributeoperation.d.ts +98 -0
- package/src/model/operation/detachoperation.d.ts +55 -0
- package/src/model/operation/insertoperation.d.ts +85 -0
- package/src/model/operation/markeroperation.d.ts +86 -0
- package/src/model/operation/mergeoperation.d.ts +95 -0
- package/src/model/operation/moveoperation.d.ts +91 -0
- package/src/model/operation/nooperation.d.ts +33 -0
- package/src/model/operation/operation.d.ts +89 -0
- package/src/model/operation/operationfactory.d.ts +18 -0
- package/src/model/operation/renameoperation.d.ts +78 -0
- package/src/model/operation/rootattributeoperation.d.ts +97 -0
- package/src/model/operation/rootattributeoperation.js +1 -1
- package/src/model/operation/splitoperation.d.ts +104 -0
- package/src/model/operation/transform.d.ts +100 -0
- package/src/model/operation/utils.d.ts +71 -0
- package/src/model/position.d.ts +539 -0
- package/src/model/position.js +1 -1
- package/src/model/range.d.ts +458 -0
- package/src/model/range.js +1 -1
- package/src/model/rootelement.d.ts +40 -0
- package/src/model/schema.d.ts +1176 -0
- package/src/model/schema.js +15 -15
- package/src/model/selection.d.ts +472 -0
- package/src/model/text.d.ts +66 -0
- package/src/model/text.js +0 -2
- package/src/model/textproxy.d.ts +144 -0
- package/src/model/treewalker.d.ts +186 -0
- package/src/model/treewalker.js +19 -10
- package/src/model/typecheckable.d.ts +255 -0
- package/src/model/utils/autoparagraphing.d.ts +37 -0
- package/src/model/utils/deletecontent.d.ts +58 -0
- package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
- package/src/model/utils/getselectedcontent.d.ts +30 -0
- package/src/model/utils/insertcontent.d.ts +46 -0
- package/src/model/utils/insertcontent.js +2 -12
- package/src/model/utils/insertobject.d.ts +44 -0
- package/src/model/utils/insertobject.js +3 -14
- package/src/model/utils/modifyselection.d.ts +48 -0
- package/src/model/utils/selection-post-fixer.d.ts +65 -0
- package/src/model/writer.d.ts +726 -0
- package/src/model/writer.js +6 -4
- package/src/view/attributeelement.d.ts +108 -0
- package/src/view/attributeelement.js +25 -69
- package/src/view/containerelement.d.ts +49 -0
- package/src/view/containerelement.js +10 -43
- package/src/view/datatransfer.d.ts +75 -0
- package/src/view/document.d.ts +184 -0
- package/src/view/document.js +15 -84
- package/src/view/documentfragment.d.ts +150 -0
- package/src/view/documentfragment.js +40 -81
- package/src/view/documentselection.d.ts +219 -0
- package/src/view/documentselection.js +75 -121
- package/src/view/domconverter.d.ts +620 -0
- package/src/view/domconverter.js +159 -276
- package/src/view/downcastwriter.d.ts +804 -0
- package/src/view/downcastwriter.js +336 -380
- package/src/view/editableelement.d.ts +52 -0
- package/src/view/editableelement.js +9 -49
- package/src/view/element.d.ts +466 -0
- package/src/view/element.js +150 -222
- package/src/view/elementdefinition.d.ts +87 -0
- package/src/view/emptyelement.d.ts +41 -0
- package/src/view/emptyelement.js +11 -44
- package/src/view/filler.d.ts +111 -0
- package/src/view/filler.js +24 -21
- package/src/view/item.d.ts +14 -0
- package/src/view/matcher.d.ts +486 -0
- package/src/view/matcher.js +247 -218
- package/src/view/node.d.ts +160 -0
- package/src/view/node.js +26 -100
- package/src/view/observer/arrowkeysobserver.d.ts +41 -0
- package/src/view/observer/arrowkeysobserver.js +0 -13
- package/src/view/observer/bubblingemittermixin.d.ts +166 -0
- package/src/view/observer/bubblingemittermixin.js +36 -25
- package/src/view/observer/bubblingeventinfo.d.ts +47 -0
- package/src/view/observer/bubblingeventinfo.js +3 -29
- package/src/view/observer/clickobserver.d.ts +43 -0
- package/src/view/observer/clickobserver.js +9 -19
- package/src/view/observer/compositionobserver.d.ts +82 -0
- package/src/view/observer/compositionobserver.js +13 -42
- package/src/view/observer/domeventdata.d.ts +50 -0
- package/src/view/observer/domeventdata.js +5 -30
- package/src/view/observer/domeventobserver.d.ts +69 -0
- package/src/view/observer/domeventobserver.js +19 -21
- package/src/view/observer/fakeselectionobserver.d.ts +46 -0
- package/src/view/observer/fakeselectionobserver.js +2 -15
- package/src/view/observer/focusobserver.d.ts +82 -0
- package/src/view/observer/focusobserver.js +14 -40
- package/src/view/observer/inputobserver.d.ts +86 -0
- package/src/view/observer/inputobserver.js +18 -64
- package/src/view/observer/keyobserver.d.ts +67 -0
- package/src/view/observer/keyobserver.js +8 -42
- package/src/view/observer/mouseobserver.d.ts +89 -0
- package/src/view/observer/mouseobserver.js +8 -28
- package/src/view/observer/mutationobserver.d.ts +82 -0
- package/src/view/observer/mutationobserver.js +7 -37
- package/src/view/observer/observer.d.ts +84 -0
- package/src/view/observer/observer.js +12 -25
- package/src/view/observer/selectionobserver.d.ts +143 -0
- package/src/view/observer/selectionobserver.js +9 -99
- package/src/view/observer/tabobserver.d.ts +42 -0
- package/src/view/observer/tabobserver.js +0 -14
- package/src/view/placeholder.d.ts +85 -0
- package/src/view/placeholder.js +26 -43
- package/src/view/position.d.ts +189 -0
- package/src/view/position.js +36 -83
- package/src/view/range.d.ts +279 -0
- package/src/view/range.js +79 -122
- package/src/view/rawelement.d.ts +73 -0
- package/src/view/rawelement.js +34 -48
- package/src/view/renderer.d.ts +265 -0
- package/src/view/renderer.js +105 -193
- package/src/view/rooteditableelement.d.ts +41 -0
- package/src/view/rooteditableelement.js +12 -40
- package/src/view/selection.d.ts +375 -0
- package/src/view/selection.js +79 -153
- package/src/view/styles/background.d.ts +33 -0
- package/src/view/styles/background.js +14 -12
- package/src/view/styles/border.d.ts +43 -0
- package/src/view/styles/border.js +58 -48
- package/src/view/styles/margin.d.ts +29 -0
- package/src/view/styles/margin.js +13 -11
- package/src/view/styles/padding.d.ts +29 -0
- package/src/view/styles/padding.js +13 -11
- package/src/view/styles/utils.d.ts +93 -0
- package/src/view/styles/utils.js +22 -48
- package/src/view/stylesmap.d.ts +675 -0
- package/src/view/stylesmap.js +249 -244
- package/src/view/text.d.ts +74 -0
- package/src/view/text.js +16 -46
- package/src/view/textproxy.d.ts +97 -0
- package/src/view/textproxy.js +10 -59
- package/src/view/treewalker.d.ts +195 -0
- package/src/view/treewalker.js +43 -106
- package/src/view/typecheckable.d.ts +401 -0
- package/src/view/uielement.d.ts +96 -0
- package/src/view/uielement.js +28 -62
- package/src/view/upcastwriter.d.ts +328 -0
- package/src/view/upcastwriter.js +124 -134
- package/src/view/view.d.ts +327 -0
- package/src/view/view.js +79 -150
package/src/view/upcastwriter.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* @module
|
|
6
|
+
* @module engine/view/upcastwriter
|
|
7
7
|
*/
|
|
8
8
|
import DocumentFragment from './documentfragment';
|
|
9
9
|
import Element from './element';
|
|
@@ -20,36 +20,31 @@ import Selection from './selection';
|
|
|
20
20
|
* To manipulate a view which was or is being downcasted from the the model use the
|
|
21
21
|
* {@link module:engine/view/downcastwriter~DowncastWriter downcast writer}.
|
|
22
22
|
*
|
|
23
|
-
* Read more about changing the view in the {@glink framework/
|
|
24
|
-
* section of the {@glink framework/
|
|
23
|
+
* Read more about changing the view in the {@glink framework/architecture/editing-engine#changing-the-view Changing the view}
|
|
24
|
+
* section of the {@glink framework/architecture/editing-engine Editing engine architecture} guide.
|
|
25
25
|
*
|
|
26
26
|
* Unlike `DowncastWriter`, which is available in the {@link module:engine/view/view~View#change `View#change()`} block,
|
|
27
27
|
* `UpcastWriter` can be created wherever you need it:
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const writer = new UpcastWriter( viewDocument );
|
|
31
|
+
* const text = writer.createText( 'foo!' );
|
|
31
32
|
*
|
|
32
|
-
*
|
|
33
|
+
* writer.appendChild( text, someViewElement );
|
|
34
|
+
* ```
|
|
33
35
|
*/
|
|
34
36
|
export default class UpcastWriter {
|
|
35
37
|
/**
|
|
36
|
-
* @param
|
|
38
|
+
* @param document The view document instance in which this upcast writer operates.
|
|
37
39
|
*/
|
|
38
40
|
constructor(document) {
|
|
39
|
-
/**
|
|
40
|
-
* The view document instance in which this upcast writer operates.
|
|
41
|
-
*
|
|
42
|
-
* @readonly
|
|
43
|
-
* @type {module:engine/view/document~Document}
|
|
44
|
-
*/
|
|
45
41
|
this.document = document;
|
|
46
42
|
}
|
|
47
43
|
/**
|
|
48
44
|
* Creates a new {@link module:engine/view/documentfragment~DocumentFragment} instance.
|
|
49
45
|
*
|
|
50
|
-
* @param
|
|
51
|
-
*
|
|
52
|
-
* @returns {module:engine/view/documentfragment~DocumentFragment} The created document fragment.
|
|
46
|
+
* @param children A list of nodes to be inserted into the created document fragment.
|
|
47
|
+
* @returns The created document fragment.
|
|
53
48
|
*/
|
|
54
49
|
createDocumentFragment(children) {
|
|
55
50
|
return new DocumentFragment(this.document, children);
|
|
@@ -59,15 +54,16 @@ export default class UpcastWriter {
|
|
|
59
54
|
*
|
|
60
55
|
* Attributes can be passed in various formats:
|
|
61
56
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* upcastWriter.createElement( 'div', { class: 'editor', contentEditable: 'true' } ); // object
|
|
59
|
+
* upcastWriter.createElement( 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
|
|
60
|
+
* upcastWriter.createElement( 'div', mapOfAttributes ); // map
|
|
61
|
+
* ```
|
|
65
62
|
*
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
69
|
-
*
|
|
70
|
-
* @returns {module:engine/view/element~Element} Created element.
|
|
63
|
+
* @param name Node name.
|
|
64
|
+
* @param attrs Collection of attributes.
|
|
65
|
+
* @param children A list of nodes to be inserted into created element.
|
|
66
|
+
* @returns Created element.
|
|
71
67
|
*/
|
|
72
68
|
createElement(name, attrs, children) {
|
|
73
69
|
return new Element(this.document, name, attrs, children);
|
|
@@ -75,8 +71,8 @@ export default class UpcastWriter {
|
|
|
75
71
|
/**
|
|
76
72
|
* Creates a new {@link module:engine/view/text~Text} instance.
|
|
77
73
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* @returns
|
|
74
|
+
* @param data The text's data.
|
|
75
|
+
* @returns The created text node.
|
|
80
76
|
*/
|
|
81
77
|
createText(data) {
|
|
82
78
|
return new Text(this.document, data);
|
|
@@ -85,10 +81,10 @@ export default class UpcastWriter {
|
|
|
85
81
|
* Clones the provided element.
|
|
86
82
|
*
|
|
87
83
|
* @see module:engine/view/element~Element#_clone
|
|
88
|
-
* @param
|
|
89
|
-
* @param
|
|
84
|
+
* @param element Element to be cloned.
|
|
85
|
+
* @param deep If set to `true` clones element and all its children recursively. When set to `false`,
|
|
90
86
|
* element will be cloned without any children.
|
|
91
|
-
* @returns
|
|
87
|
+
* @returns Clone of this element.
|
|
92
88
|
*/
|
|
93
89
|
clone(element, deep = false) {
|
|
94
90
|
return element._clone(deep);
|
|
@@ -98,11 +94,10 @@ export default class UpcastWriter {
|
|
|
98
94
|
* and sets the parent of these nodes to this element.
|
|
99
95
|
*
|
|
100
96
|
* @see module:engine/view/element~Element#_appendChild
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
*
|
|
104
|
-
* @
|
|
105
|
-
* @returns {Number} Number of appended nodes.
|
|
97
|
+
* @param items Items to be inserted.
|
|
98
|
+
* @param element Element to which items will be appended.
|
|
99
|
+
* @fires change
|
|
100
|
+
* @returns Number of appended nodes.
|
|
106
101
|
*/
|
|
107
102
|
appendChild(items, element) {
|
|
108
103
|
return element._appendChild(items);
|
|
@@ -112,12 +107,11 @@ export default class UpcastWriter {
|
|
|
112
107
|
* this element.
|
|
113
108
|
*
|
|
114
109
|
* @see module:engine/view/element~Element#_insertChild
|
|
115
|
-
* @param
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
*
|
|
119
|
-
* @
|
|
120
|
-
* @returns {Number} Number of inserted nodes.
|
|
110
|
+
* @param index Offset at which nodes should be inserted.
|
|
111
|
+
* @param items Items to be inserted.
|
|
112
|
+
* @param element Element to which items will be inserted.
|
|
113
|
+
* @fires change
|
|
114
|
+
* @returns Number of inserted nodes.
|
|
121
115
|
*/
|
|
122
116
|
insertChild(index, items, element) {
|
|
123
117
|
return element._insertChild(index, items);
|
|
@@ -126,12 +120,11 @@ export default class UpcastWriter {
|
|
|
126
120
|
* Removes the given number of child nodes starting at the given index and set the parent of these nodes to `null`.
|
|
127
121
|
*
|
|
128
122
|
* @see module:engine/view/element~Element#_removeChildren
|
|
129
|
-
* @param
|
|
130
|
-
* @param
|
|
131
|
-
* @param
|
|
132
|
-
*
|
|
133
|
-
* @
|
|
134
|
-
* @returns {Array.<module:engine/view/node~Node>} The array containing removed nodes.
|
|
123
|
+
* @param index Offset from which nodes will be removed.
|
|
124
|
+
* @param howMany Number of nodes to remove.
|
|
125
|
+
* @param element Element which children will be removed.
|
|
126
|
+
* @fires change
|
|
127
|
+
* @returns The array containing removed nodes.
|
|
135
128
|
*/
|
|
136
129
|
removeChildren(index, howMany, element) {
|
|
137
130
|
return element._removeChildren(index, howMany);
|
|
@@ -139,8 +132,8 @@ export default class UpcastWriter {
|
|
|
139
132
|
/**
|
|
140
133
|
* Removes given element from the view structure. Will not have effect on detached elements.
|
|
141
134
|
*
|
|
142
|
-
* @param
|
|
143
|
-
* @returns
|
|
135
|
+
* @param element Element which will be removed.
|
|
136
|
+
* @returns The array containing removed nodes.
|
|
144
137
|
*/
|
|
145
138
|
remove(element) {
|
|
146
139
|
const parent = element.parent;
|
|
@@ -152,9 +145,9 @@ export default class UpcastWriter {
|
|
|
152
145
|
/**
|
|
153
146
|
* Replaces given element with the new one in the view structure. Will not have effect on detached elements.
|
|
154
147
|
*
|
|
155
|
-
* @param
|
|
156
|
-
* @param
|
|
157
|
-
* @returns
|
|
148
|
+
* @param oldElement Element which will be replaced.
|
|
149
|
+
* @param newElement Element which will be inserted in the place of the old element.
|
|
150
|
+
* @returns Whether old element was successfully replaced.
|
|
158
151
|
*/
|
|
159
152
|
replace(oldElement, newElement) {
|
|
160
153
|
const parent = oldElement.parent;
|
|
@@ -170,7 +163,7 @@ export default class UpcastWriter {
|
|
|
170
163
|
* Removes given element from view structure and places its children in its position.
|
|
171
164
|
* It does nothing if element has no parent.
|
|
172
165
|
*
|
|
173
|
-
* @param
|
|
166
|
+
* @param element Element to unwrap.
|
|
174
167
|
*/
|
|
175
168
|
unwrapElement(element) {
|
|
176
169
|
const parent = element.parent;
|
|
@@ -186,10 +179,9 @@ export default class UpcastWriter {
|
|
|
186
179
|
*
|
|
187
180
|
* Since this function creates a new element and removes the given one, the new element is returned to keep reference.
|
|
188
181
|
*
|
|
189
|
-
* @param
|
|
190
|
-
* @param
|
|
191
|
-
* @returns
|
|
192
|
-
* was not replaced (happens for detached elements).
|
|
182
|
+
* @param newName New element name.
|
|
183
|
+
* @param element Element to be renamed.
|
|
184
|
+
* @returns New element or null if the old element was not replaced (happens for detached elements).
|
|
193
185
|
*/
|
|
194
186
|
rename(newName, element) {
|
|
195
187
|
const newElement = new Element(this.document, newName, element.getAttributes(), element.getChildren());
|
|
@@ -198,12 +190,14 @@ export default class UpcastWriter {
|
|
|
198
190
|
/**
|
|
199
191
|
* Adds or overwrites element's attribute with a specified key and value.
|
|
200
192
|
*
|
|
201
|
-
*
|
|
193
|
+
* ```ts
|
|
194
|
+
* writer.setAttribute( 'href', 'http://ckeditor.com', linkElement );
|
|
195
|
+
* ```
|
|
202
196
|
*
|
|
203
197
|
* @see module:engine/view/element~Element#_setAttribute
|
|
204
|
-
* @param
|
|
205
|
-
* @param
|
|
206
|
-
* @param
|
|
198
|
+
* @param key Attribute key.
|
|
199
|
+
* @param value Attribute value.
|
|
200
|
+
* @param element Element for which attribute will be set.
|
|
207
201
|
*/
|
|
208
202
|
setAttribute(key, value, element) {
|
|
209
203
|
element._setAttribute(key, value);
|
|
@@ -211,11 +205,13 @@ export default class UpcastWriter {
|
|
|
211
205
|
/**
|
|
212
206
|
* Removes attribute from the element.
|
|
213
207
|
*
|
|
214
|
-
*
|
|
208
|
+
* ```ts
|
|
209
|
+
* writer.removeAttribute( 'href', linkElement );
|
|
210
|
+
* ```
|
|
215
211
|
*
|
|
216
212
|
* @see module:engine/view/element~Element#_removeAttribute
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
213
|
+
* @param key Attribute key.
|
|
214
|
+
* @param element Element from which attribute will be removed.
|
|
219
215
|
*/
|
|
220
216
|
removeAttribute(key, element) {
|
|
221
217
|
element._removeAttribute(key);
|
|
@@ -223,12 +219,14 @@ export default class UpcastWriter {
|
|
|
223
219
|
/**
|
|
224
220
|
* Adds specified class to the element.
|
|
225
221
|
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
222
|
+
* ```ts
|
|
223
|
+
* writer.addClass( 'foo', linkElement );
|
|
224
|
+
* writer.addClass( [ 'foo', 'bar' ], linkElement );
|
|
225
|
+
* ```
|
|
228
226
|
*
|
|
229
227
|
* @see module:engine/view/element~Element#_addClass
|
|
230
|
-
* @param
|
|
231
|
-
* @param
|
|
228
|
+
* @param className Single class name or array of class names which will be added.
|
|
229
|
+
* @param element Element for which class will be added.
|
|
232
230
|
*/
|
|
233
231
|
addClass(className, element) {
|
|
234
232
|
element._addClass(className);
|
|
@@ -236,12 +234,14 @@ export default class UpcastWriter {
|
|
|
236
234
|
/**
|
|
237
235
|
* Removes specified class from the element.
|
|
238
236
|
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
237
|
+
* ```ts
|
|
238
|
+
* writer.removeClass( 'foo', linkElement );
|
|
239
|
+
* writer.removeClass( [ 'foo', 'bar' ], linkElement );
|
|
240
|
+
* ```
|
|
241
241
|
*
|
|
242
242
|
* @see module:engine/view/element~Element#_removeClass
|
|
243
|
-
* @param
|
|
244
|
-
* @param
|
|
243
|
+
* @param className Single class name or array of class names which will be removed.
|
|
244
|
+
* @param element Element from which class will be removed.
|
|
245
245
|
*/
|
|
246
246
|
removeClass(className, element) {
|
|
247
247
|
element._removeClass(className);
|
|
@@ -257,16 +257,18 @@ export default class UpcastWriter {
|
|
|
257
257
|
/**
|
|
258
258
|
* Removes specified style from the element.
|
|
259
259
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
260
|
+
* ```ts
|
|
261
|
+
* writer.removeStyle( 'color', element ); // Removes 'color' style.
|
|
262
|
+
* writer.removeStyle( [ 'color', 'border-top' ], element ); // Removes both 'color' and 'border-top' styles.
|
|
263
|
+
* ```
|
|
262
264
|
*
|
|
263
265
|
* **Note**: This method can work with normalized style names if
|
|
264
266
|
* {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules a particular style processor rule is enabled}.
|
|
265
267
|
* See {@link module:engine/view/stylesmap~StylesMap#remove `StylesMap#remove()`} for details.
|
|
266
268
|
*
|
|
267
269
|
* @see module:engine/view/element~Element#_removeStyle
|
|
268
|
-
* @param
|
|
269
|
-
* @param
|
|
270
|
+
* @param property Style property name or names to be removed.
|
|
271
|
+
* @param element Element from which style will be removed.
|
|
270
272
|
*/
|
|
271
273
|
removeStyle(property, element) {
|
|
272
274
|
element._removeStyle(property);
|
|
@@ -276,9 +278,9 @@ export default class UpcastWriter {
|
|
|
276
278
|
* so they can be used to add special data to elements.
|
|
277
279
|
*
|
|
278
280
|
* @see module:engine/view/element~Element#_setCustomProperty
|
|
279
|
-
* @param
|
|
280
|
-
* @param
|
|
281
|
-
* @param
|
|
281
|
+
* @param key Custom property name/key.
|
|
282
|
+
* @param value Custom property value to be stored.
|
|
283
|
+
* @param element Element for which custom property will be set.
|
|
282
284
|
*/
|
|
283
285
|
setCustomProperty(key, value, element) {
|
|
284
286
|
element._setCustomProperty(key, value);
|
|
@@ -287,9 +289,9 @@ export default class UpcastWriter {
|
|
|
287
289
|
* Removes a custom property stored under the given key.
|
|
288
290
|
*
|
|
289
291
|
* @see module:engine/view/element~Element#_removeCustomProperty
|
|
290
|
-
* @param
|
|
291
|
-
* @param
|
|
292
|
-
* @returns
|
|
292
|
+
* @param key Name/key of the custom property to be removed.
|
|
293
|
+
* @param element Element from which the custom property will be removed.
|
|
294
|
+
* @returns Returns true if property was removed.
|
|
293
295
|
*/
|
|
294
296
|
removeCustomProperty(key, element) {
|
|
295
297
|
return element._removeCustomProperty(key);
|
|
@@ -307,10 +309,7 @@ export default class UpcastWriter {
|
|
|
307
309
|
* * {@link #createPositionBefore},
|
|
308
310
|
* * {@link #createPositionAfter},
|
|
309
311
|
*
|
|
310
|
-
* @param {module:engine/view/item~Item
|
|
311
|
-
* @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
|
|
312
|
-
* first parameter is a {@link module:engine/view/item~Item view item}.
|
|
313
|
-
* @returns {module:engine/view/position~Position}
|
|
312
|
+
* @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/view/item~Item view item}.
|
|
314
313
|
*/
|
|
315
314
|
createPositionAt(itemOrPosition, offset) {
|
|
316
315
|
return Position._createAt(itemOrPosition, offset);
|
|
@@ -318,8 +317,7 @@ export default class UpcastWriter {
|
|
|
318
317
|
/**
|
|
319
318
|
* Creates a new position after given view item.
|
|
320
319
|
*
|
|
321
|
-
* @param
|
|
322
|
-
* @returns {module:engine/view/position~Position}
|
|
320
|
+
* @param item View item after which the position should be located.
|
|
323
321
|
*/
|
|
324
322
|
createPositionAfter(item) {
|
|
325
323
|
return Position._createAfter(item);
|
|
@@ -327,8 +325,7 @@ export default class UpcastWriter {
|
|
|
327
325
|
/**
|
|
328
326
|
* Creates a new position before given view item.
|
|
329
327
|
*
|
|
330
|
-
* @param
|
|
331
|
-
* @returns {module:engine/view/position~Position}
|
|
328
|
+
* @param item View item before which the position should be located.
|
|
332
329
|
*/
|
|
333
330
|
createPositionBefore(item) {
|
|
334
331
|
return Position._createBefore(item);
|
|
@@ -338,18 +335,14 @@ export default class UpcastWriter {
|
|
|
338
335
|
*
|
|
339
336
|
* **Note:** This factory method creates it's own {@link module:engine/view/position~Position} instances basing on passed values.
|
|
340
337
|
*
|
|
341
|
-
* @param
|
|
342
|
-
* @param
|
|
343
|
-
* @returns {module:engine/view/range~Range}
|
|
338
|
+
* @param start Start position.
|
|
339
|
+
* @param end End position. If not set, range will be collapsed at `start` position.
|
|
344
340
|
*/
|
|
345
341
|
createRange(start, end) {
|
|
346
342
|
return new Range(start, end);
|
|
347
343
|
}
|
|
348
344
|
/**
|
|
349
345
|
* Creates a range that starts before given {@link module:engine/view/item~Item view item} and ends after it.
|
|
350
|
-
*
|
|
351
|
-
* @param {module:engine/view/item~Item} item
|
|
352
|
-
* @returns {module:engine/view/range~Range}
|
|
353
346
|
*/
|
|
354
347
|
createRangeOn(item) {
|
|
355
348
|
return Range._createOn(item);
|
|
@@ -358,8 +351,7 @@ export default class UpcastWriter {
|
|
|
358
351
|
* Creates a range inside an {@link module:engine/view/element~Element element} which starts before the first child of
|
|
359
352
|
* that element and ends after the last child of that element.
|
|
360
353
|
*
|
|
361
|
-
* @param
|
|
362
|
-
* @returns {module:engine/view/range~Range}
|
|
354
|
+
* @param element Element which is a parent for the range.
|
|
363
355
|
*/
|
|
364
356
|
createRangeIn(element) {
|
|
365
357
|
return Range._createIn(element);
|
|
@@ -367,44 +359,48 @@ export default class UpcastWriter {
|
|
|
367
359
|
/**
|
|
368
360
|
* Creates a new {@link module:engine/view/selection~Selection} instance.
|
|
369
361
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
362
|
+
* ```ts
|
|
363
|
+
* // Creates empty selection without ranges.
|
|
364
|
+
* const selection = writer.createSelection();
|
|
372
365
|
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
366
|
+
* // Creates selection at the given range.
|
|
367
|
+
* const range = writer.createRange( start, end );
|
|
368
|
+
* const selection = writer.createSelection( range );
|
|
376
369
|
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
370
|
+
* // Creates selection at the given ranges
|
|
371
|
+
* const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
|
|
372
|
+
* const selection = writer.createSelection( ranges );
|
|
380
373
|
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
374
|
+
* // Creates selection from the other selection.
|
|
375
|
+
* const otherSelection = writer.createSelection();
|
|
376
|
+
* const selection = writer.createSelection( otherSelection );
|
|
384
377
|
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
378
|
+
* // Creates selection from the document selection.
|
|
379
|
+
* const selection = writer.createSelection( editor.editing.view.document.selection );
|
|
387
380
|
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
381
|
+
* // Creates selection at the given position.
|
|
382
|
+
* const position = writer.createPositionFromPath( root, path );
|
|
383
|
+
* const selection = writer.createSelection( position );
|
|
391
384
|
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
385
|
+
* // Creates collapsed selection at the position of given item and offset.
|
|
386
|
+
* const paragraph = writer.createContainerElement( 'paragraph' );
|
|
387
|
+
* const selection = writer.createSelection( paragraph, offset );
|
|
395
388
|
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
389
|
+
* // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
|
|
390
|
+
* // first child of that element and ends after the last child of that element.
|
|
391
|
+
* const selection = writer.createSelection( paragraph, 'in' );
|
|
399
392
|
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
393
|
+
* // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
|
|
394
|
+
* // just after the item.
|
|
395
|
+
* const selection = writer.createSelection( paragraph, 'on' );
|
|
396
|
+
* ```
|
|
403
397
|
*
|
|
404
398
|
* `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
|
|
405
399
|
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
400
|
+
* ```ts
|
|
401
|
+
* // Creates backward selection.
|
|
402
|
+
* const selection = writer.createSelection( range, { backward: true } );
|
|
403
|
+
* ```
|
|
408
404
|
*
|
|
409
405
|
* Fake selection does not render as browser native selection over selected elements and is hidden to the user.
|
|
410
406
|
* This way, no native selection UI artifacts are displayed to the user and selection over elements can be
|
|
@@ -413,16 +409,10 @@ export default class UpcastWriter {
|
|
|
413
409
|
* Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
|
|
414
410
|
* (and be properly handled by screen readers).
|
|
415
411
|
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
* @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Offset or place when selectable is an `Item`.
|
|
421
|
-
* @param {Object} [options]
|
|
422
|
-
* @param {Boolean} [options.backward] Sets this selection instance to be backward.
|
|
423
|
-
* @param {Boolean} [options.fake] Sets this selection instance to be marked as `fake`.
|
|
424
|
-
* @param {String} [options.label] Label for the fake selection.
|
|
425
|
-
* @returns {module:engine/view/selection~Selection}
|
|
412
|
+
* ```ts
|
|
413
|
+
* // Creates fake selection with label.
|
|
414
|
+
* const selection = writer.createSelection( range, { fake: true, label: 'foo' } );
|
|
415
|
+
* ```
|
|
426
416
|
*/
|
|
427
417
|
createSelection(...args) {
|
|
428
418
|
return new Selection(...args);
|