@ckeditor/ckeditor5-engine 36.0.1 → 37.0.0-alpha.1

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.
Files changed (203) hide show
  1. package/README.md +1 -1
  2. package/package.json +25 -24
  3. package/src/controller/datacontroller.d.ts +331 -0
  4. package/src/controller/datacontroller.js +72 -116
  5. package/src/controller/editingcontroller.d.ts +98 -0
  6. package/src/controller/editingcontroller.js +22 -46
  7. package/src/conversion/conversion.d.ts +476 -0
  8. package/src/conversion/conversion.js +328 -347
  9. package/src/conversion/conversionhelpers.d.ts +26 -0
  10. package/src/conversion/conversionhelpers.js +1 -5
  11. package/src/conversion/downcastdispatcher.d.ts +547 -0
  12. package/src/conversion/downcastdispatcher.js +74 -152
  13. package/src/conversion/downcasthelpers.d.ts +1226 -0
  14. package/src/conversion/downcasthelpers.js +843 -762
  15. package/src/conversion/mapper.d.ts +503 -0
  16. package/src/conversion/mapper.js +84 -99
  17. package/src/conversion/modelconsumable.d.ts +201 -0
  18. package/src/conversion/modelconsumable.js +96 -99
  19. package/src/conversion/upcastdispatcher.d.ts +492 -0
  20. package/src/conversion/upcastdispatcher.js +73 -100
  21. package/src/conversion/upcasthelpers.d.ts +499 -0
  22. package/src/conversion/upcasthelpers.js +406 -373
  23. package/src/conversion/viewconsumable.d.ts +369 -0
  24. package/src/conversion/viewconsumable.js +139 -173
  25. package/src/dataprocessor/basichtmlwriter.d.ts +18 -0
  26. package/src/dataprocessor/basichtmlwriter.js +0 -9
  27. package/src/dataprocessor/dataprocessor.d.ts +61 -0
  28. package/src/dataprocessor/htmldataprocessor.d.ts +76 -0
  29. package/src/dataprocessor/htmldataprocessor.js +6 -28
  30. package/src/dataprocessor/htmlwriter.d.ts +16 -0
  31. package/src/dataprocessor/xmldataprocessor.d.ts +90 -0
  32. package/src/dataprocessor/xmldataprocessor.js +8 -40
  33. package/src/dev-utils/model.d.ts +124 -0
  34. package/src/dev-utils/model.js +41 -38
  35. package/src/dev-utils/operationreplayer.d.ts +51 -0
  36. package/src/dev-utils/operationreplayer.js +6 -14
  37. package/src/dev-utils/utils.d.ts +37 -0
  38. package/src/dev-utils/utils.js +5 -18
  39. package/src/dev-utils/view.d.ts +319 -0
  40. package/src/dev-utils/view.js +205 -226
  41. package/src/index.d.ts +108 -0
  42. package/src/index.js +4 -0
  43. package/src/model/batch.d.ts +106 -0
  44. package/src/model/differ.d.ts +329 -0
  45. package/src/model/document.d.ts +246 -0
  46. package/src/model/document.js +1 -1
  47. package/src/model/documentfragment.d.ts +196 -0
  48. package/src/model/documentfragment.js +2 -2
  49. package/src/model/documentselection.d.ts +420 -0
  50. package/src/model/element.d.ts +165 -0
  51. package/src/model/history.d.ts +114 -0
  52. package/src/model/item.d.ts +14 -0
  53. package/src/model/liveposition.d.ts +77 -0
  54. package/src/model/liverange.d.ts +102 -0
  55. package/src/model/markercollection.d.ts +335 -0
  56. package/src/model/model.d.ts +885 -0
  57. package/src/model/model.js +59 -81
  58. package/src/model/node.d.ts +256 -0
  59. package/src/model/nodelist.d.ts +91 -0
  60. package/src/model/operation/attributeoperation.d.ts +98 -0
  61. package/src/model/operation/detachoperation.d.ts +55 -0
  62. package/src/model/operation/insertoperation.d.ts +85 -0
  63. package/src/model/operation/markeroperation.d.ts +86 -0
  64. package/src/model/operation/mergeoperation.d.ts +95 -0
  65. package/src/model/operation/mergeoperation.js +1 -1
  66. package/src/model/operation/moveoperation.d.ts +91 -0
  67. package/src/model/operation/nooperation.d.ts +33 -0
  68. package/src/model/operation/operation.d.ts +89 -0
  69. package/src/model/operation/operationfactory.d.ts +18 -0
  70. package/src/model/operation/renameoperation.d.ts +78 -0
  71. package/src/model/operation/rootattributeoperation.d.ts +97 -0
  72. package/src/model/operation/rootattributeoperation.js +1 -1
  73. package/src/model/operation/splitoperation.d.ts +104 -0
  74. package/src/model/operation/splitoperation.js +1 -1
  75. package/src/model/operation/transform.d.ts +100 -0
  76. package/src/model/operation/utils.d.ts +71 -0
  77. package/src/model/operation/utils.js +1 -1
  78. package/src/model/position.d.ts +539 -0
  79. package/src/model/position.js +1 -1
  80. package/src/model/range.d.ts +458 -0
  81. package/src/model/range.js +1 -1
  82. package/src/model/rootelement.d.ts +40 -0
  83. package/src/model/schema.d.ts +1176 -0
  84. package/src/model/schema.js +19 -19
  85. package/src/model/selection.d.ts +472 -0
  86. package/src/model/text.d.ts +66 -0
  87. package/src/model/text.js +0 -2
  88. package/src/model/textproxy.d.ts +144 -0
  89. package/src/model/treewalker.d.ts +186 -0
  90. package/src/model/treewalker.js +19 -10
  91. package/src/model/typecheckable.d.ts +285 -0
  92. package/src/model/utils/autoparagraphing.d.ts +37 -0
  93. package/src/model/utils/deletecontent.d.ts +58 -0
  94. package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
  95. package/src/model/utils/getselectedcontent.d.ts +30 -0
  96. package/src/model/utils/insertcontent.d.ts +46 -0
  97. package/src/model/utils/insertcontent.js +2 -12
  98. package/src/model/utils/insertobject.d.ts +44 -0
  99. package/src/model/utils/insertobject.js +3 -14
  100. package/src/model/utils/modifyselection.d.ts +48 -0
  101. package/src/model/utils/selection-post-fixer.d.ts +65 -0
  102. package/src/model/writer.d.ts +823 -0
  103. package/src/model/writer.js +6 -61
  104. package/src/view/attributeelement.d.ts +108 -0
  105. package/src/view/attributeelement.js +25 -69
  106. package/src/view/containerelement.d.ts +49 -0
  107. package/src/view/containerelement.js +10 -43
  108. package/src/view/datatransfer.d.ts +75 -0
  109. package/src/view/document.d.ts +184 -0
  110. package/src/view/document.js +15 -84
  111. package/src/view/documentfragment.d.ts +149 -0
  112. package/src/view/documentfragment.js +39 -81
  113. package/src/view/documentselection.d.ts +306 -0
  114. package/src/view/documentselection.js +42 -143
  115. package/src/view/domconverter.d.ts +650 -0
  116. package/src/view/domconverter.js +157 -283
  117. package/src/view/downcastwriter.d.ts +996 -0
  118. package/src/view/downcastwriter.js +259 -426
  119. package/src/view/editableelement.d.ts +52 -0
  120. package/src/view/editableelement.js +9 -49
  121. package/src/view/element.d.ts +468 -0
  122. package/src/view/element.js +150 -222
  123. package/src/view/elementdefinition.d.ts +87 -0
  124. package/src/view/emptyelement.d.ts +41 -0
  125. package/src/view/emptyelement.js +11 -44
  126. package/src/view/filler.d.ts +111 -0
  127. package/src/view/filler.js +24 -21
  128. package/src/view/item.d.ts +14 -0
  129. package/src/view/matcher.d.ts +486 -0
  130. package/src/view/matcher.js +247 -218
  131. package/src/view/node.d.ts +163 -0
  132. package/src/view/node.js +26 -100
  133. package/src/view/observer/arrowkeysobserver.d.ts +41 -0
  134. package/src/view/observer/arrowkeysobserver.js +0 -13
  135. package/src/view/observer/bubblingemittermixin.d.ts +166 -0
  136. package/src/view/observer/bubblingemittermixin.js +36 -25
  137. package/src/view/observer/bubblingeventinfo.d.ts +47 -0
  138. package/src/view/observer/bubblingeventinfo.js +3 -29
  139. package/src/view/observer/clickobserver.d.ts +43 -0
  140. package/src/view/observer/clickobserver.js +9 -19
  141. package/src/view/observer/compositionobserver.d.ts +82 -0
  142. package/src/view/observer/compositionobserver.js +13 -42
  143. package/src/view/observer/domeventdata.d.ts +50 -0
  144. package/src/view/observer/domeventdata.js +5 -30
  145. package/src/view/observer/domeventobserver.d.ts +69 -0
  146. package/src/view/observer/domeventobserver.js +19 -21
  147. package/src/view/observer/fakeselectionobserver.d.ts +43 -0
  148. package/src/view/observer/fakeselectionobserver.js +0 -16
  149. package/src/view/observer/focusobserver.d.ts +82 -0
  150. package/src/view/observer/focusobserver.js +14 -40
  151. package/src/view/observer/inputobserver.d.ts +86 -0
  152. package/src/view/observer/inputobserver.js +18 -64
  153. package/src/view/observer/keyobserver.d.ts +66 -0
  154. package/src/view/observer/keyobserver.js +8 -42
  155. package/src/view/observer/mouseobserver.d.ts +89 -0
  156. package/src/view/observer/mouseobserver.js +8 -28
  157. package/src/view/observer/mutationobserver.d.ts +82 -0
  158. package/src/view/observer/mutationobserver.js +7 -37
  159. package/src/view/observer/observer.d.ts +84 -0
  160. package/src/view/observer/observer.js +12 -25
  161. package/src/view/observer/selectionobserver.d.ts +144 -0
  162. package/src/view/observer/selectionobserver.js +17 -107
  163. package/src/view/observer/tabobserver.d.ts +42 -0
  164. package/src/view/observer/tabobserver.js +0 -14
  165. package/src/view/placeholder.d.ts +85 -0
  166. package/src/view/placeholder.js +26 -43
  167. package/src/view/position.d.ts +189 -0
  168. package/src/view/position.js +36 -83
  169. package/src/view/range.d.ts +279 -0
  170. package/src/view/range.js +79 -122
  171. package/src/view/rawelement.d.ts +73 -0
  172. package/src/view/rawelement.js +34 -48
  173. package/src/view/renderer.d.ts +265 -0
  174. package/src/view/renderer.js +105 -193
  175. package/src/view/rooteditableelement.d.ts +41 -0
  176. package/src/view/rooteditableelement.js +12 -40
  177. package/src/view/selection.d.ts +375 -0
  178. package/src/view/selection.js +79 -153
  179. package/src/view/styles/background.d.ts +33 -0
  180. package/src/view/styles/background.js +14 -12
  181. package/src/view/styles/border.d.ts +43 -0
  182. package/src/view/styles/border.js +58 -48
  183. package/src/view/styles/margin.d.ts +29 -0
  184. package/src/view/styles/margin.js +13 -11
  185. package/src/view/styles/padding.d.ts +29 -0
  186. package/src/view/styles/padding.js +13 -11
  187. package/src/view/styles/utils.d.ts +93 -0
  188. package/src/view/styles/utils.js +22 -48
  189. package/src/view/stylesmap.d.ts +675 -0
  190. package/src/view/stylesmap.js +249 -244
  191. package/src/view/text.d.ts +74 -0
  192. package/src/view/text.js +16 -46
  193. package/src/view/textproxy.d.ts +97 -0
  194. package/src/view/textproxy.js +10 -59
  195. package/src/view/treewalker.d.ts +195 -0
  196. package/src/view/treewalker.js +43 -106
  197. package/src/view/typecheckable.d.ts +448 -0
  198. package/src/view/uielement.d.ts +96 -0
  199. package/src/view/uielement.js +29 -63
  200. package/src/view/upcastwriter.d.ts +417 -0
  201. package/src/view/upcastwriter.js +86 -157
  202. package/src/view/view.d.ts +417 -0
  203. package/src/view/view.js +47 -175
@@ -11,7 +11,6 @@ import TextProxy from './textproxy';
11
11
  import { isIterable, toArray, toMap } from '@ckeditor/ckeditor5-utils';
12
12
  import { default as Matcher } from './matcher';
13
13
  import { default as StylesMap } from './stylesmap';
14
- import { isPlainObject } from 'lodash-es';
15
14
  // @if CK_DEBUG_ENGINE // const { convertMapToTags } = require( '../dev-utils/utils' );
16
15
  /**
17
16
  * View element.
@@ -35,8 +34,6 @@ import { isPlainObject } from 'lodash-es';
35
34
  * {@link module:engine/controller/datacontroller~DataController#set data.set} it is not possible to define the type of the element.
36
35
  * In such cases the {@link module:engine/view/upcastwriter~UpcastWriter#createElement `UpcastWriter#createElement()`} method
37
36
  * should be used to create generic view elements.
38
- *
39
- * @extends module:engine/view/node~Node
40
37
  */
41
38
  export default class Element extends Node {
42
39
  /**
@@ -44,49 +41,43 @@ export default class Element extends Node {
44
41
  *
45
42
  * Attributes can be passed in various formats:
46
43
  *
47
- * new Element( viewDocument, 'div', { class: 'editor', contentEditable: 'true' } ); // object
48
- * new Element( viewDocument, 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
49
- * new Element( viewDocument, 'div', mapOfAttributes ); // map
44
+ * ```ts
45
+ * new Element( viewDocument, 'div', { class: 'editor', contentEditable: 'true' } ); // object
46
+ * new Element( viewDocument, 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
47
+ * new Element( viewDocument, 'div', mapOfAttributes ); // map
48
+ * ```
50
49
  *
51
- * @protected
52
- * @param {module:engine/view/document~Document} document The document instance to which this element belongs.
53
- * @param {String} name Node name.
54
- * @param {Object|Iterable} [attrs] Collection of attributes.
55
- * @param {module:engine/view/node~Node|Iterable.<module:engine/view/node~Node>} [children]
56
- * A list of nodes to be inserted into created element.
50
+ * @internal
51
+ * @param document The document instance to which this element belongs.
52
+ * @param name Node name.
53
+ * @param attrs Collection of attributes.
54
+ * @param children A list of nodes to be inserted into created element.
57
55
  */
58
56
  constructor(document, name, attrs, children) {
59
57
  super(document);
60
58
  /**
61
- * Name of the element.
59
+ * A list of attribute names that should be rendered in the editing pipeline even though filtering mechanisms
60
+ * implemented in the {@link module:engine/view/domconverter~DomConverter} (for instance,
61
+ * {@link module:engine/view/domconverter~DomConverter#shouldRenderAttribute}) would filter them out.
62
62
  *
63
- * @readonly
64
- * @member {String}
65
- */
66
- this.name = name;
67
- /**
68
- * Map of attributes, where attributes names are keys and attributes values are values.
63
+ * These attributes can be specified as an option when the element is created by
64
+ * the {@link module:engine/view/downcastwriter~DowncastWriter}. To check whether an unsafe an attribute should
65
+ * be permitted, use the {@link #shouldRenderUnsafeAttribute} method.
69
66
  *
70
- * @protected
71
- * @member {Map} #_attrs
67
+ * @internal
72
68
  */
73
- this._attrs = parseAttributes(attrs);
69
+ this._unsafeAttributesToRender = [];
74
70
  /**
75
- * Array of child nodes.
76
- *
77
- * @protected
78
- * @member {Array.<module:engine/view/node~Node>}
71
+ * Map of custom properties.
72
+ * Custom properties can be added to element instance, will be cloned but not rendered into DOM.
79
73
  */
74
+ this._customProperties = new Map();
75
+ this.name = name;
76
+ this._attrs = parseAttributes(attrs);
80
77
  this._children = [];
81
78
  if (children) {
82
79
  this._insertChild(0, children);
83
80
  }
84
- /**
85
- * Set of classes associated with element instance.
86
- *
87
- * @protected
88
- * @member {Set}
89
- */
90
81
  this._classes = new Set();
91
82
  if (this._attrs.has('class')) {
92
83
  // Remove class attribute and handle it by class set.
@@ -94,55 +85,21 @@ export default class Element extends Node {
94
85
  parseClasses(this._classes, classString);
95
86
  this._attrs.delete('class');
96
87
  }
97
- /**
98
- * Normalized styles.
99
- *
100
- * @protected
101
- * @member {module:engine/view/stylesmap~StylesMap} module:engine/view/element~Element#_styles
102
- */
103
88
  this._styles = new StylesMap(this.document.stylesProcessor);
104
89
  if (this._attrs.has('style')) {
105
90
  // Remove style attribute and handle it by styles map.
106
91
  this._styles.setTo(this._attrs.get('style'));
107
92
  this._attrs.delete('style');
108
93
  }
109
- /**
110
- * Map of custom properties.
111
- * Custom properties can be added to element instance, will be cloned but not rendered into DOM.
112
- *
113
- * @protected
114
- * @member {Map}
115
- */
116
- this._customProperties = new Map();
117
- /**
118
- * A list of attribute names that should be rendered in the editing pipeline even though filtering mechanisms
119
- * implemented in the {@link module:engine/view/domconverter~DomConverter} (for instance,
120
- * {@link module:engine/view/domconverter~DomConverter#shouldRenderAttribute}) would filter them out.
121
- *
122
- * These attributes can be specified as an option when the element is created by
123
- * the {@link module:engine/view/downcastwriter~DowncastWriter}. To check whether an unsafe an attribute should
124
- * be permitted, use the {@link #shouldRenderUnsafeAttribute} method.
125
- *
126
- * @private
127
- * @readonly
128
- * @member {Array.<String>}
129
- */
130
- this._unsafeAttributesToRender = [];
131
94
  }
132
95
  /**
133
96
  * Number of element's children.
134
- *
135
- * @readonly
136
- * @type {Number}
137
97
  */
138
98
  get childCount() {
139
99
  return this._children.length;
140
100
  }
141
101
  /**
142
102
  * Is `true` if there are no nodes inside this element, `false` otherwise.
143
- *
144
- * @readonly
145
- * @type {Boolean}
146
103
  */
147
104
  get isEmpty() {
148
105
  return this._children.length === 0;
@@ -150,8 +107,8 @@ export default class Element extends Node {
150
107
  /**
151
108
  * Gets child at the given index.
152
109
  *
153
- * @param {Number} index Index of child.
154
- * @returns {module:engine/view/node~Node} Child node.
110
+ * @param index Index of child.
111
+ * @returns Child node.
155
112
  */
156
113
  getChild(index) {
157
114
  return this._children[index];
@@ -159,8 +116,8 @@ export default class Element extends Node {
159
116
  /**
160
117
  * Gets index of the given child node. Returns `-1` if child node is not found.
161
118
  *
162
- * @param {module:engine/view/node~Node} node Child node.
163
- * @returns {Number} Index of the child node.
119
+ * @param node Child node.
120
+ * @returns Index of the child node.
164
121
  */
165
122
  getChildIndex(node) {
166
123
  return this._children.indexOf(node);
@@ -168,7 +125,7 @@ export default class Element extends Node {
168
125
  /**
169
126
  * Gets child nodes iterator.
170
127
  *
171
- * @returns {Iterable.<module:engine/view/node~Node>} Child nodes iterator.
128
+ * @returns Child nodes iterator.
172
129
  */
173
130
  getChildren() {
174
131
  return this._children[Symbol.iterator]();
@@ -176,7 +133,7 @@ export default class Element extends Node {
176
133
  /**
177
134
  * Returns an iterator that contains the keys for attributes. Order of inserting attributes is not preserved.
178
135
  *
179
- * @returns {Iterable.<String>} Keys for attributes.
136
+ * @returns Keys for attributes.
180
137
  */
181
138
  *getAttributeKeys() {
182
139
  if (this._classes.size > 0) {
@@ -192,8 +149,6 @@ export default class Element extends Node {
192
149
  *
193
150
  * Attributes are returned as arrays containing two items. First one is attribute key and second is attribute value.
194
151
  * This format is accepted by native `Map` object and also can be passed in `Node` constructor.
195
- *
196
- * @returns {Iterable.<*>}
197
152
  */
198
153
  *getAttributes() {
199
154
  yield* this._attrs.entries();
@@ -207,8 +162,8 @@ export default class Element extends Node {
207
162
  /**
208
163
  * Gets attribute by key. If attribute is not present - returns undefined.
209
164
  *
210
- * @param {String} key Attribute key.
211
- * @returns {String|undefined} Attribute value.
165
+ * @param key Attribute key.
166
+ * @returns Attribute value.
212
167
  */
213
168
  getAttribute(key) {
214
169
  if (key == 'class') {
@@ -226,8 +181,8 @@ export default class Element extends Node {
226
181
  /**
227
182
  * Returns a boolean indicating whether an attribute with the specified key exists in the element.
228
183
  *
229
- * @param {String} key Attribute key.
230
- * @returns {Boolean} `true` if attribute with the specified key exists in the element, false otherwise.
184
+ * @param key Attribute key.
185
+ * @returns `true` if attribute with the specified key exists in the element, `false` otherwise.
231
186
  */
232
187
  hasAttribute(key) {
233
188
  if (key == 'class') {
@@ -242,9 +197,6 @@ export default class Element extends Node {
242
197
  * Checks if this element is similar to other element.
243
198
  * Both elements should have the same name and attributes to be considered as similar. Two similar elements
244
199
  * can contain different set of children nodes.
245
- *
246
- * @param {module:engine/view/element~Element} otherElement
247
- * @returns {Boolean}
248
200
  */
249
201
  isSimilar(otherElement) {
250
202
  if (!(otherElement instanceof Element)) {
@@ -288,10 +240,10 @@ export default class Element extends Node {
288
240
  * Returns true if class is present.
289
241
  * If more then one class is provided - returns true only when all classes are present.
290
242
  *
291
- * element.hasClass( 'foo' ); // Returns true if 'foo' class is present.
292
- * element.hasClass( 'foo', 'bar' ); // Returns true if 'foo' and 'bar' classes are both present.
293
- *
294
- * @param {...String} className
243
+ * ```ts
244
+ * element.hasClass( 'foo' ); // Returns true if 'foo' class is present.
245
+ * element.hasClass( 'foo', 'bar' ); // Returns true if 'foo' and 'bar' classes are both present.
246
+ * ```
295
247
  */
296
248
  hasClass(...className) {
297
249
  for (const name of className) {
@@ -303,8 +255,6 @@ export default class Element extends Node {
303
255
  }
304
256
  /**
305
257
  * Returns iterator that contains all class names.
306
- *
307
- * @returns {Iterable.<String>}
308
258
  */
309
259
  getClassNames() {
310
260
  return this._classes.keys();
@@ -319,21 +269,20 @@ export default class Element extends Node {
319
269
  *
320
270
  * For an element with style set to `'margin:1px'`:
321
271
  *
322
- * // Enable 'margin' shorthand processing:
323
- * editor.data.addStyleProcessorRules( addMarginRules );
272
+ * ```ts
273
+ * // Enable 'margin' shorthand processing:
274
+ * editor.data.addStyleProcessorRules( addMarginRules );
324
275
  *
325
- * const element = view.change( writer => {
326
- * const element = writer.createElement();
327
- * writer.setStyle( 'margin', '1px' );
328
- * writer.setStyle( 'margin-bottom', '3em' );
276
+ * const element = view.change( writer => {
277
+ * const element = writer.createElement();
278
+ * writer.setStyle( 'margin', '1px' );
279
+ * writer.setStyle( 'margin-bottom', '3em' );
329
280
  *
330
- * return element;
331
- * } );
281
+ * return element;
282
+ * } );
332
283
  *
333
- * element.getStyle( 'margin' ); // -> 'margin: 1px 1px 3em;'
334
- *
335
- * @param {String} property
336
- * @returns {String|undefined}
284
+ * element.getStyle( 'margin' ); // -> 'margin: 1px 1px 3em;'
285
+ * ```
337
286
  */
338
287
  getStyle(property) {
339
288
  return this._styles.getAsString(property);
@@ -343,20 +292,26 @@ export default class Element extends Node {
343
292
  *
344
293
  * For an element with style set to: margin:1px 2px 3em;
345
294
  *
346
- * element.getNormalizedStyle( 'margin' ) );
295
+ * ```ts
296
+ * element.getNormalizedStyle( 'margin' ) );
297
+ * ```
347
298
  *
348
299
  * will return:
349
300
  *
350
- * {
351
- * top: '1px',
352
- * right: '2px',
353
- * bottom: '3em',
354
- * left: '2px' // a normalized value from margin shorthand
355
- * }
301
+ * ```ts
302
+ * {
303
+ * top: '1px',
304
+ * right: '2px',
305
+ * bottom: '3em',
306
+ * left: '2px' // a normalized value from margin shorthand
307
+ * }
308
+ * ```
356
309
  *
357
310
  * and reading for single style value:
358
311
  *
359
- * styles.getNormalizedStyle( 'margin-left' );
312
+ * ```ts
313
+ * styles.getNormalizedStyle( 'margin-left' );
314
+ * ```
360
315
  *
361
316
  * Will return a `2px` string.
362
317
  *
@@ -364,9 +319,7 @@ export default class Element extends Node {
364
319
  * {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules a particular style processor rule is enabled}.
365
320
  * See {@link module:engine/view/stylesmap~StylesMap#getNormalized `StylesMap#getNormalized()`} for details.
366
321
  *
367
- *
368
- * @param {String} property Name of CSS property
369
- * @returns {Object|String|undefined}
322
+ * @param property Name of CSS property
370
323
  */
371
324
  getNormalizedStyle(property) {
372
325
  return this._styles.getNormalized(property);
@@ -374,8 +327,7 @@ export default class Element extends Node {
374
327
  /**
375
328
  * Returns iterator that contains all style names.
376
329
  *
377
- * @param {Boolean} [expand=false] Expand shorthand style properties and return all equivalent style representations.
378
- * @returns {Iterable.<String>}
330
+ * @param expand Expand shorthand style properties and return all equivalent style representations.
379
331
  */
380
332
  getStyleNames(expand) {
381
333
  return this._styles.getStyleNames(expand);
@@ -384,10 +336,10 @@ export default class Element extends Node {
384
336
  * Returns true if style keys are present.
385
337
  * If more then one style property is provided - returns true only when all properties are present.
386
338
  *
387
- * element.hasStyle( 'color' ); // Returns true if 'border-top' style is present.
388
- * element.hasStyle( 'color', 'border-top' ); // Returns true if 'color' and 'border-top' styles are both present.
389
- *
390
- * @param {...String} property
339
+ * ```ts
340
+ * element.hasStyle( 'color' ); // Returns true if 'border-top' style is present.
341
+ * element.hasStyle( 'color', 'border-top' ); // Returns true if 'color' and 'border-top' styles are both present.
342
+ * ```
391
343
  */
392
344
  hasStyle(...property) {
393
345
  for (const name of property) {
@@ -402,9 +354,8 @@ export default class Element extends Node {
402
354
  * Provided patterns should be compatible with {@link module:engine/view/matcher~Matcher Matcher} as it is used internally.
403
355
  *
404
356
  * @see module:engine/view/matcher~Matcher
405
- * @param {Object|String|RegExp|Function} patterns Patterns used to match correct ancestor.
406
- * See {@link module:engine/view/matcher~Matcher}.
407
- * @returns {module:engine/view/element~Element|null} Found element or `null` if no matching ancestor was found.
357
+ * @param patterns Patterns used to match correct ancestor. See {@link module:engine/view/matcher~Matcher}.
358
+ * @returns Found element or `null` if no matching ancestor was found.
408
359
  */
409
360
  findAncestor(...patterns) {
410
361
  const matcher = new Matcher(...patterns);
@@ -419,9 +370,6 @@ export default class Element extends Node {
419
370
  }
420
371
  /**
421
372
  * Returns the custom property value for the given key.
422
- *
423
- * @param {String|Symbol} key
424
- * @returns {*}
425
373
  */
426
374
  getCustomProperty(key) {
427
375
  return this._customProperties.get(key);
@@ -429,8 +377,6 @@ export default class Element extends Node {
429
377
  /**
430
378
  * Returns an iterator which iterates over this element's custom properties.
431
379
  * Iterator provides `[ key, value ]` pairs for each stored property.
432
- *
433
- * @returns {Iterable.<*>}
434
380
  */
435
381
  *getCustomProperties() {
436
382
  yield* this._customProperties.entries();
@@ -440,23 +386,25 @@ export default class Element extends Node {
440
386
  * Two elements that {@link #isSimilar are similar} will have same identity string.
441
387
  * It has the following format:
442
388
  *
443
- * 'name class="class1,class2" style="style1:value1;style2:value2" attr1="val1" attr2="val2"'
389
+ * ```ts
390
+ * 'name class="class1,class2" style="style1:value1;style2:value2" attr1="val1" attr2="val2"'
391
+ * ```
444
392
  *
445
393
  * For example:
446
394
  *
447
- * const element = writer.createContainerElement( 'foo', {
448
- * banana: '10',
449
- * apple: '20',
450
- * style: 'color: red; border-color: white;',
451
- * class: 'baz'
452
- * } );
395
+ * ```ts
396
+ * const element = writer.createContainerElement( 'foo', {
397
+ * banana: '10',
398
+ * apple: '20',
399
+ * style: 'color: red; border-color: white;',
400
+ * class: 'baz'
401
+ * } );
453
402
  *
454
- * // returns 'foo class="baz" style="border-color:white;color:red" apple="20" banana="10"'
455
- * element.getIdentity();
403
+ * // returns 'foo class="baz" style="border-color:white;color:red" apple="20" banana="10"'
404
+ * element.getIdentity();
405
+ * ```
456
406
  *
457
407
  * **Note**: Classes, styles and other attributes are sorted alphabetically.
458
- *
459
- * @returns {String}
460
408
  */
461
409
  getIdentity() {
462
410
  const classes = Array.from(this._classes).sort().join(',');
@@ -473,8 +421,7 @@ export default class Element extends Node {
473
421
  *
474
422
  * Unsafe attribute names can be specified when creating an element via {@link module:engine/view/downcastwriter~DowncastWriter}.
475
423
  *
476
- * @param {String} attributeName The name of the attribute to be checked.
477
- * @returns {Boolean}
424
+ * @param attributeName The name of the attribute to be checked.
478
425
  */
479
426
  shouldRenderUnsafeAttribute(attributeName) {
480
427
  return this._unsafeAttributesToRender.includes(attributeName);
@@ -482,10 +429,10 @@ export default class Element extends Node {
482
429
  /**
483
430
  * Clones provided element.
484
431
  *
485
- * @protected
486
- * @param {Boolean} [deep=false] If set to `true` clones element and all its children recursively. When set to `false`,
432
+ * @internal
433
+ * @param deep If set to `true` clones element and all its children recursively. When set to `false`,
487
434
  * element will be cloned without any children.
488
- * @returns {module:engine/view/element~Element} Clone of this element.
435
+ * @returns Clone of this element.
489
436
  */
490
437
  _clone(deep = false) {
491
438
  const childrenClone = [];
@@ -515,10 +462,10 @@ export default class Element extends Node {
515
462
  * and sets the parent of these nodes to this element.
516
463
  *
517
464
  * @see module:engine/view/downcastwriter~DowncastWriter#insert
518
- * @protected
519
- * @param {module:engine/view/item~Item|Iterable.<module:engine/view/item~Item>} items Items to be inserted.
520
- * @fires module:engine/view/node~Node#change
521
- * @returns {Number} Number of appended nodes.
465
+ * @internal
466
+ * @param items Items to be inserted.
467
+ * @fires change
468
+ * @returns Number of appended nodes.
522
469
  */
523
470
  _appendChild(items) {
524
471
  return this._insertChild(this.childCount, items);
@@ -529,11 +476,10 @@ export default class Element extends Node {
529
476
  *
530
477
  * @internal
531
478
  * @see module:engine/view/downcastwriter~DowncastWriter#insert
532
- * @protected
533
- * @param {Number} index Position where nodes should be inserted.
534
- * @param {module:engine/view/item~Item|Iterable.<module:engine/view/item~Item>} items Items to be inserted.
535
- * @fires module:engine/view/node~Node#change
536
- * @returns {Number} Number of inserted nodes.
479
+ * @param index Position where nodes should be inserted.
480
+ * @param items Items to be inserted.
481
+ * @fires change
482
+ * @returns Number of inserted nodes.
537
483
  */
538
484
  _insertChild(index, items) {
539
485
  this._fireChange('children', this);
@@ -556,11 +502,11 @@ export default class Element extends Node {
556
502
  * Removes number of child nodes starting at the given index and set the parent of these nodes to `null`.
557
503
  *
558
504
  * @see module:engine/view/downcastwriter~DowncastWriter#remove
559
- * @protected
560
- * @param {Number} index Number of the first node to remove.
561
- * @param {Number} [howMany=1] Number of nodes to remove.
562
- * @fires module:engine/view/node~Node#change
563
- * @returns {Array.<module:engine/view/node~Node>} The array of removed nodes.
505
+ * @internal
506
+ * @param index Number of the first node to remove.
507
+ * @param howMany Number of nodes to remove.
508
+ * @fires change
509
+ * @returns The array of removed nodes.
564
510
  */
565
511
  _removeChildren(index, howMany = 1) {
566
512
  this._fireChange('children', this);
@@ -573,10 +519,10 @@ export default class Element extends Node {
573
519
  * Adds or overwrite attribute with a specified key and value.
574
520
  *
575
521
  * @see module:engine/view/downcastwriter~DowncastWriter#setAttribute
576
- * @protected
577
- * @param {String} key Attribute key.
578
- * @param {String} value Attribute value.
579
- * @fires module:engine/view/node~Node#change
522
+ * @internal
523
+ * @param key Attribute key.
524
+ * @param value Attribute value.
525
+ * @fires change
580
526
  */
581
527
  _setAttribute(key, value) {
582
528
  const stringValue = String(value);
@@ -595,10 +541,10 @@ export default class Element extends Node {
595
541
  * Removes attribute from the element.
596
542
  *
597
543
  * @see module:engine/view/downcastwriter~DowncastWriter#removeAttribute
598
- * @protected
599
- * @param {String} key Attribute key.
600
- * @returns {Boolean} Returns true if an attribute existed and has been removed.
601
- * @fires module:engine/view/node~Node#change
544
+ * @internal
545
+ * @param key Attribute key.
546
+ * @returns Returns true if an attribute existed and has been removed.
547
+ * @fires change
602
548
  */
603
549
  _removeAttribute(key) {
604
550
  this._fireChange('attributes', this);
@@ -624,13 +570,14 @@ export default class Element extends Node {
624
570
  /**
625
571
  * Adds specified class.
626
572
  *
627
- * element._addClass( 'foo' ); // Adds 'foo' class.
628
- * element._addClass( [ 'foo', 'bar' ] ); // Adds 'foo' and 'bar' classes.
573
+ * ```ts
574
+ * element._addClass( 'foo' ); // Adds 'foo' class.
575
+ * element._addClass( [ 'foo', 'bar' ] ); // Adds 'foo' and 'bar' classes.
576
+ * ```
629
577
  *
630
578
  * @see module:engine/view/downcastwriter~DowncastWriter#addClass
631
- * @protected
632
- * @param {Array.<String>|String} className
633
- * @fires module:engine/view/node~Node#change
579
+ * @internal
580
+ * @fires change
634
581
  */
635
582
  _addClass(className) {
636
583
  this._fireChange('attributes', this);
@@ -641,13 +588,14 @@ export default class Element extends Node {
641
588
  /**
642
589
  * Removes specified class.
643
590
  *
644
- * element._removeClass( 'foo' ); // Removes 'foo' class.
645
- * element._removeClass( [ 'foo', 'bar' ] ); // Removes both 'foo' and 'bar' classes.
591
+ * ```ts
592
+ * element._removeClass( 'foo' ); // Removes 'foo' class.
593
+ * element._removeClass( [ 'foo', 'bar' ] ); // Removes both 'foo' and 'bar' classes.
594
+ * ```
646
595
  *
647
596
  * @see module:engine/view/downcastwriter~DowncastWriter#removeClass
648
- * @protected
649
- * @param {Array.<String>|String} className
650
- * @fires module:engine/view/node~Node#change
597
+ * @internal
598
+ * @fires change
651
599
  */
652
600
  _removeClass(className) {
653
601
  this._fireChange('attributes', this);
@@ -657,7 +605,7 @@ export default class Element extends Node {
657
605
  }
658
606
  _setStyle(property, value) {
659
607
  this._fireChange('attributes', this);
660
- if (isPlainObject(property)) {
608
+ if (typeof property != 'string') {
661
609
  this._styles.set(property);
662
610
  }
663
611
  else {
@@ -667,17 +615,18 @@ export default class Element extends Node {
667
615
  /**
668
616
  * Removes specified style.
669
617
  *
670
- * element._removeStyle( 'color' ); // Removes 'color' style.
671
- * element._removeStyle( [ 'color', 'border-top' ] ); // Removes both 'color' and 'border-top' styles.
618
+ * ```ts
619
+ * element._removeStyle( 'color' ); // Removes 'color' style.
620
+ * element._removeStyle( [ 'color', 'border-top' ] ); // Removes both 'color' and 'border-top' styles.
621
+ * ```
672
622
  *
673
623
  * **Note**: This method can work with normalized style names if
674
624
  * {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules a particular style processor rule is enabled}.
675
625
  * See {@link module:engine/view/stylesmap~StylesMap#remove `StylesMap#remove()`} for details.
676
626
  *
677
627
  * @see module:engine/view/downcastwriter~DowncastWriter#removeStyle
678
- * @protected
679
- * @param {Array.<String>|String} property
680
- * @fires module:engine/view/node~Node#change
628
+ * @internal
629
+ * @fires change
681
630
  */
682
631
  _removeStyle(property) {
683
632
  this._fireChange('attributes', this);
@@ -690,9 +639,7 @@ export default class Element extends Node {
690
639
  * so they can be used to add special data to elements.
691
640
  *
692
641
  * @see module:engine/view/downcastwriter~DowncastWriter#setCustomProperty
693
- * @protected
694
- * @param {String|Symbol} key
695
- * @param {*} value
642
+ * @internal
696
643
  */
697
644
  _setCustomProperty(key, value) {
698
645
  this._customProperties.set(key, value);
@@ -701,37 +648,15 @@ export default class Element extends Node {
701
648
  * Removes the custom property stored under the given key.
702
649
  *
703
650
  * @see module:engine/view/downcastwriter~DowncastWriter#removeCustomProperty
704
- * @protected
705
- * @param {String|Symbol} key
706
- * @returns {Boolean} Returns true if property was removed.
651
+ * @internal
652
+ * @returns Returns true if property was removed.
707
653
  */
708
654
  _removeCustomProperty(key) {
709
655
  return this._customProperties.delete(key);
710
656
  }
711
657
  }
712
- /**
713
- * Checks whether this object is of the given.
714
- *
715
- * element.is( 'element' ); // -> true
716
- * element.is( 'node' ); // -> true
717
- * element.is( 'view:element' ); // -> true
718
- * element.is( 'view:node' ); // -> true
719
- *
720
- * element.is( 'model:element' ); // -> false
721
- * element.is( 'documentSelection' ); // -> false
722
- *
723
- * Assuming that the object being checked is an element, you can also check its
724
- * {@link module:engine/view/element~Element#name name}:
725
- *
726
- * element.is( 'element', 'img' ); // -> true if this is an <img> element
727
- * text.is( 'element', 'img' ); -> false
728
- *
729
- * {@link module:engine/view/node~Node#is Check the entire list of view objects} which implement the `is()` method.
730
- *
731
- * @param {String} type Type to check.
732
- * @param {String} [name] Element name.
733
- * @returns {Boolean}
734
- */
658
+ // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
659
+ // Proper overload would interfere with that.
735
660
  Element.prototype.is = function (type, name) {
736
661
  if (!name) {
737
662
  return type === 'element' || type === 'view:element' ||
@@ -742,12 +667,14 @@ Element.prototype.is = function (type, name) {
742
667
  return name === this.name && (type === 'element' || type === 'view:element');
743
668
  }
744
669
  };
745
- // Parses attributes provided to the element constructor before they are applied to an element. If attributes are passed
746
- // as an object (instead of `Iterable`), the object is transformed to the map. Attributes with `null` value are removed.
747
- // Attributes with non-`String` value are converted to `String`.
748
- //
749
- // @param {Object|Iterable} attrs Attributes to parse.
750
- // @returns {Map} Parsed attributes.
670
+ /**
671
+ * Parses attributes provided to the element constructor before they are applied to an element. If attributes are passed
672
+ * as an object (instead of `Iterable`), the object is transformed to the map. Attributes with `null` value are removed.
673
+ * Attributes with non-`String` value are converted to `String`.
674
+ *
675
+ * @param attrs Attributes to parse.
676
+ * @returns Parsed attributes.
677
+ */
751
678
  function parseAttributes(attrs) {
752
679
  const attrsMap = toMap(attrs);
753
680
  for (const [key, value] of attrsMap) {
@@ -760,20 +687,21 @@ function parseAttributes(attrs) {
760
687
  }
761
688
  return attrsMap;
762
689
  }
763
- // Parses class attribute and puts all classes into classes set.
764
- // Classes set s cleared before insertion.
765
- //
766
- // @param {Set.<String>} classesSet Set to insert parsed classes.
767
- // @param {String} classesString String with classes to parse.
690
+ /**
691
+ * Parses class attribute and puts all classes into classes set.
692
+ * Classes set s cleared before insertion.
693
+ *
694
+ * @param classesSet Set to insert parsed classes.
695
+ * @param classesString String with classes to parse.
696
+ */
768
697
  function parseClasses(classesSet, classesString) {
769
698
  const classArray = classesString.split(/\s+/);
770
699
  classesSet.clear();
771
700
  classArray.forEach(name => classesSet.add(name));
772
701
  }
773
- // Converts strings to Text and non-iterables to arrays.
774
- //
775
- // @param {String|module:engine/view/item~Item|Iterable.<String|module:engine/view/item~Item>}
776
- // @returns {Iterable.<module:engine/view/node~Node>}
702
+ /**
703
+ * Converts strings to Text and non-iterables to arrays.
704
+ */
777
705
  function normalize(document, nodes) {
778
706
  // Separate condition because string is iterable.
779
707
  if (typeof nodes == 'string') {