@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
@@ -44,26 +44,24 @@ const domConverterStub = {
44
44
  /**
45
45
  * Writes the content of the {@link module:engine/view/document~Document document} to an HTML-like string.
46
46
  *
47
- * @param {module:engine/view/view~View} view
48
- * @param {Object} [options]
49
- * @param {Boolean} [options.withoutSelection=false] Whether to write the selection. When set to `true`, the selection will
47
+ * @param options.withoutSelection Whether to write the selection. When set to `true`, the selection will
50
48
  * not be included in the returned string.
51
- * @param {Boolean} [options.rootName='main'] The name of the root from which the data should be stringified. If not provided,
49
+ * @param options.rootName The name of the root from which the data should be stringified. If not provided,
52
50
  * the default `main` name will be used.
53
- * @param {Boolean} [options.showType=false] When set to `true`, the type of elements will be printed (`<container:p>`
51
+ * @param options.showType When set to `true`, the type of elements will be printed (`<container:p>`
54
52
  * instead of `<p>`, `<attribute:b>` instead of `<b>` and `<empty:img>` instead of `<img>`).
55
- * @param {Boolean} [options.showPriority=false] When set to `true`, the attribute element's priority will be printed
53
+ * @param options.showPriority When set to `true`, the attribute element's priority will be printed
56
54
  * (`<span view-priority="12">`, `<b view-priority="10">`).
57
- * @param {Boolean} [options.showAttributeElementId=false] When set to `true`, the attribute element's ID will be printed
55
+ * @param options.showAttributeElementId When set to `true`, the attribute element's ID will be printed
58
56
  * (`<span id="marker:foo">`).
59
- * @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
57
+ * @param options.renderUIElements When set to `true`, the inner content of each
60
58
  * {@link module:engine/view/uielement~UIElement} will be printed.
61
- * @param {Boolean} [options.renderRawElements=false] When set to `true`, the inner content of each
59
+ * @param options.renderRawElements When set to `true`, the inner content of each
62
60
  * {@link module:engine/view/rawelement~RawElement} will be printed.
63
- * @param {Object} [options.domConverter=null] When set to an actual {@link module:engine/view/domconverter~DomConverter DomConverter}
61
+ * @param options.domConverter When set to an actual {@link module:engine/view/domconverter~DomConverter DomConverter}
64
62
  * instance, it lets the conversion go through exactly the same flow the editing view is going through,
65
63
  * i.e. with view data filtering. Otherwise the simple stub is used.
66
- * @returns {String} The stringified data.
64
+ * @returns The stringified data.
67
65
  */
68
66
  export function getData(view, options = {}) {
69
67
  if (!(view instanceof View)) {
@@ -90,10 +88,8 @@ getData._stringify = stringify;
90
88
  /**
91
89
  * Sets the content of a view {@link module:engine/view/document~Document document} provided as an HTML-like string.
92
90
  *
93
- * @param {module:engine/view/view~View} view
94
- * @param {String} data An HTML-like string to write into the document.
95
- * @param {Object} options
96
- * @param {String} [options.rootName='main'] The root name where parsed data will be stored. If not provided,
91
+ * @param data An HTML-like string to write into the document.
92
+ * @param options.rootName The root name where parsed data will be stored. If not provided,
97
93
  * the default `main` name will be used.
98
94
  */
99
95
  export function setData(view, data, options = {}) {
@@ -117,46 +113,56 @@ setData._parse = parse;
117
113
  *
118
114
  * A root element can be provided as {@link module:engine/view/text~Text text}:
119
115
  *
120
- * const text = downcastWriter.createText( 'foobar' );
121
- * stringify( text ); // 'foobar'
116
+ * ```ts
117
+ * const text = downcastWriter.createText( 'foobar' );
118
+ * stringify( text ); // 'foobar'
119
+ * ```
122
120
  *
123
121
  * or as an {@link module:engine/view/element~Element element}:
124
122
  *
125
- * const element = downcastWriter.createElement( 'p', null, downcastWriter.createText( 'foobar' ) );
126
- * stringify( element ); // '<p>foobar</p>'
123
+ * ```ts
124
+ * const element = downcastWriter.createElement( 'p', null, downcastWriter.createText( 'foobar' ) );
125
+ * stringify( element ); // '<p>foobar</p>'
126
+ * ```
127
127
  *
128
128
  * or as a {@link module:engine/view/documentfragment~DocumentFragment document fragment}:
129
129
  *
130
- * const text = downcastWriter.createText( 'foobar' );
131
- * const b = downcastWriter.createElement( 'b', { name: 'test' }, text );
132
- * const p = downcastWriter.createElement( 'p', { style: 'color:red;' } );
133
- * const fragment = downcastWriter.createDocumentFragment( [ p, b ] );
130
+ * ```ts
131
+ * const text = downcastWriter.createText( 'foobar' );
132
+ * const b = downcastWriter.createElement( 'b', { name: 'test' }, text );
133
+ * const p = downcastWriter.createElement( 'p', { style: 'color:red;' } );
134
+ * const fragment = downcastWriter.createDocumentFragment( [ p, b ] );
134
135
  *
135
- * stringify( fragment ); // '<p style="color:red;"></p><b name="test">foobar</b>'
136
+ * stringify( fragment ); // '<p style="color:red;"></p><b name="test">foobar</b>'
137
+ * ```
136
138
  *
137
139
  * Additionally, a {@link module:engine/view/documentselection~DocumentSelection selection} instance can be provided.
138
140
  * Ranges from the selection will then be included in the output data.
139
141
  * If a range position is placed inside the element node, it will be represented with `[` and `]`:
140
142
  *
141
- * const text = downcastWriter.createText( 'foobar' );
142
- * const b = downcastWriter.createElement( 'b', null, text );
143
- * const p = downcastWriter.createElement( 'p', null, b );
144
- * const selection = downcastWriter.createSelection(
145
- * downcastWriter.createRangeIn( p )
146
- * );
143
+ * ```ts
144
+ * const text = downcastWriter.createText( 'foobar' );
145
+ * const b = downcastWriter.createElement( 'b', null, text );
146
+ * const p = downcastWriter.createElement( 'p', null, b );
147
+ * const selection = downcastWriter.createSelection(
148
+ * downcastWriter.createRangeIn( p )
149
+ * );
147
150
  *
148
- * stringify( p, selection ); // '<p>[<b>foobar</b>]</p>'
151
+ * stringify( p, selection ); // '<p>[<b>foobar</b>]</p>'
152
+ * ```
149
153
  *
150
154
  * If a range is placed inside the text node, it will be represented with `{` and `}`:
151
155
  *
152
- * const text = downcastWriter.createText( 'foobar' );
153
- * const b = downcastWriter.createElement( 'b', null, text );
154
- * const p = downcastWriter.createElement( 'p', null, b );
155
- * const selection = downcastWriter.createSelection(
156
- * downcastWriter.createRange( downcastWriter.createPositionAt( text, 1 ), downcastWriter.createPositionAt( text, 5 ) )
157
- * );
156
+ * ```ts
157
+ * const text = downcastWriter.createText( 'foobar' );
158
+ * const b = downcastWriter.createElement( 'b', null, text );
159
+ * const p = downcastWriter.createElement( 'p', null, b );
160
+ * const selection = downcastWriter.createSelection(
161
+ * downcastWriter.createRange( downcastWriter.createPositionAt( text, 1 ), downcastWriter.createPositionAt( text, 5 ) )
162
+ * );
158
163
  *
159
- * stringify( p, selection ); // '<p><b>f{ooba}r</b></p>'
164
+ * stringify( p, selection ); // '<p><b>f{ooba}r</b></p>'
165
+ * ```
160
166
  *
161
167
  * ** Note: **
162
168
  * It is possible to unify selection markers to `[` and `]` for both (inside and outside text)
@@ -165,25 +171,29 @@ setData._parse = parse;
165
171
  *
166
172
  * Multiple ranges are supported:
167
173
  *
168
- * const text = downcastWriter.createText( 'foobar' );
169
- * const selection = downcastWriter.createSelection( [
170
- * downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) ),
171
- * downcastWriter.createRange( downcastWriter.createPositionAt( text, 3 ), downcastWriter.createPositionAt( text, 5 ) )
172
- * ] );
174
+ * ```ts
175
+ * const text = downcastWriter.createText( 'foobar' );
176
+ * const selection = downcastWriter.createSelection( [
177
+ * downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) ),
178
+ * downcastWriter.createRange( downcastWriter.createPositionAt( text, 3 ), downcastWriter.createPositionAt( text, 5 ) )
179
+ * ] );
173
180
  *
174
- * stringify( text, selection ); // '{f}oo{ba}r'
181
+ * stringify( text, selection ); // '{f}oo{ba}r'
182
+ * ```
175
183
  *
176
184
  * A {@link module:engine/view/range~Range range} or {@link module:engine/view/position~Position position} instance can be provided
177
185
  * instead of the {@link module:engine/view/documentselection~DocumentSelection selection} instance. If a range instance
178
186
  * is provided, it will be converted to a selection containing this range. If a position instance is provided, it will
179
187
  * be converted to a selection containing one range collapsed at this position.
180
188
  *
181
- * const text = downcastWriter.createText( 'foobar' );
182
- * const range = downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) );
183
- * const position = downcastWriter.createPositionAt( text, 3 );
189
+ * ```ts
190
+ * const text = downcastWriter.createText( 'foobar' );
191
+ * const range = downcastWriter.createRange( downcastWriter.createPositionAt( text, 0 ), downcastWriter.createPositionAt( text, 1 ) );
192
+ * const position = downcastWriter.createPositionAt( text, 3 );
184
193
  *
185
- * stringify( text, range ); // '{f}oobar'
186
- * stringify( text, position ); // 'foo{}bar'
194
+ * stringify( text, range ); // '{f}oobar'
195
+ * stringify( text, position ); // 'foo{}bar'
196
+ * ```
187
197
  *
188
198
  * An additional `options` object can be provided.
189
199
  * If `options.showType` is set to `true`, element's types will be
@@ -192,55 +202,58 @@ setData._parse = parse;
192
202
  * {@link module:engine/view/emptyelement~EmptyElement empty elements}
193
203
  * and {@link module:engine/view/uielement~UIElement UI elements}:
194
204
  *
195
- * const attribute = downcastWriter.createAttributeElement( 'b' );
196
- * const container = downcastWriter.createContainerElement( 'p' );
197
- * const empty = downcastWriter.createEmptyElement( 'img' );
198
- * const ui = downcastWriter.createUIElement( 'span' );
199
- * getData( attribute, null, { showType: true } ); // '<attribute:b></attribute:b>'
200
- * getData( container, null, { showType: true } ); // '<container:p></container:p>'
201
- * getData( empty, null, { showType: true } ); // '<empty:img></empty:img>'
202
- * getData( ui, null, { showType: true } ); // '<ui:span></ui:span>'
205
+ * ```ts
206
+ * const attribute = downcastWriter.createAttributeElement( 'b' );
207
+ * const container = downcastWriter.createContainerElement( 'p' );
208
+ * const empty = downcastWriter.createEmptyElement( 'img' );
209
+ * const ui = downcastWriter.createUIElement( 'span' );
210
+ * getData( attribute, null, { showType: true } ); // '<attribute:b></attribute:b>'
211
+ * getData( container, null, { showType: true } ); // '<container:p></container:p>'
212
+ * getData( empty, null, { showType: true } ); // '<empty:img></empty:img>'
213
+ * getData( ui, null, { showType: true } ); // '<ui:span></ui:span>'
214
+ * ```
203
215
  *
204
216
  * If `options.showPriority` is set to `true`, a priority will be displayed for all
205
217
  * {@link module:engine/view/attributeelement~AttributeElement attribute elements}.
206
218
  *
207
- * const attribute = downcastWriter.createAttributeElement( 'b' );
208
- * attribute._priority = 20;
209
- * getData( attribute, null, { showPriority: true } ); // <b view-priority="20"></b>
219
+ * ```ts
220
+ * const attribute = downcastWriter.createAttributeElement( 'b' );
221
+ * attribute._priority = 20;
222
+ * getData( attribute, null, { showPriority: true } ); // <b view-priority="20"></b>
223
+ * ```
210
224
  *
211
225
  * If `options.showAttributeElementId` is set to `true`, the attribute element's id will be displayed for all
212
226
  * {@link module:engine/view/attributeelement~AttributeElement attribute elements} that have it set.
213
227
  *
214
- * const attribute = downcastWriter.createAttributeElement( 'span' );
215
- * attribute._id = 'marker:foo';
216
- * getData( attribute, null, { showAttributeElementId: true } ); // <span view-id="marker:foo"></span>
217
- *
218
- * @param {module:engine/view/text~Text|module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment}
219
- * node The node to stringify.
220
- * @param {module:engine/view/documentselection~DocumentSelection|module:engine/view/position~Position|module:engine/view/range~Range}
221
- * [selectionOrPositionOrRange = null ]
222
- * A selection instance whose ranges will be included in the returned string data. If a range instance is provided, it will be
223
- * converted to a selection containing this range. If a position instance is provided, it will be converted to a selection
224
- * containing one range collapsed at this position.
225
- * @param {Object} [options] An object with additional options.
226
- * @param {Boolean} [options.showType=false] When set to `true`, the type of elements will be printed (`<container:p>`
228
+ * ```ts
229
+ * const attribute = downcastWriter.createAttributeElement( 'span' );
230
+ * attribute._id = 'marker:foo';
231
+ * getData( attribute, null, { showAttributeElementId: true } ); // <span view-id="marker:foo"></span>
232
+ * ```
233
+ *
234
+ * @param node The node to stringify.
235
+ * @param selectionOrPositionOrRange A selection instance whose ranges will be included in the returned string data.
236
+ * If a range instance is provided, it will be converted to a selection containing this range. If a position instance
237
+ * is provided, it will be converted to a selection containing one range collapsed at this position.
238
+ * @param options An object with additional options.
239
+ * @param options.showType When set to `true`, the type of elements will be printed (`<container:p>`
227
240
  * instead of `<p>`, `<attribute:b>` instead of `<b>` and `<empty:img>` instead of `<img>`).
228
- * @param {Boolean} [options.showPriority=false] When set to `true`, the attribute element's priority will be printed
241
+ * @param options.showPriority When set to `true`, the attribute element's priority will be printed
229
242
  * (`<span view-priority="12">`, `<b view-priority="10">`).
230
- * @param {Boolean} [options.showAttributeElementId=false] When set to `true`, attribute element's id will be printed
243
+ * @param options.showAttributeElementId When set to `true`, attribute element's id will be printed
231
244
  * (`<span id="marker:foo">`).
232
- * @param {Boolean} [options.ignoreRoot=false] When set to `true`, the root's element opening and closing will not be printed.
245
+ * @param options.ignoreRoot When set to `true`, the root's element opening and closing will not be printed.
233
246
  * Mainly used by the `getData` function to ignore the {@link module:engine/view/document~Document document's} root element.
234
- * @param {Boolean} [options.sameSelectionCharacters=false] When set to `true`, the selection inside the text will be marked as
247
+ * @param options.sameSelectionCharacters When set to `true`, the selection inside the text will be marked as
235
248
  * `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both will be marked as `[` and `]` only.
236
- * @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
249
+ * @param options.renderUIElements When set to `true`, the inner content of each
237
250
  * {@link module:engine/view/uielement~UIElement} will be printed.
238
- * @param {Boolean} [options.renderRawElements=false] When set to `true`, the inner content of each
251
+ * @param options.renderRawElements When set to `true`, the inner content of each
239
252
  * {@link module:engine/view/rawelement~RawElement} will be printed.
240
- * @param {Object} [options.domConverter={}] When set to an actual {@link module:engine/view/domconverter~DomConverter DomConverter}
253
+ * @param options.domConverter When set to an actual {@link module:engine/view/domconverter~DomConverter DomConverter}
241
254
  * instance, it lets the conversion go through exactly the same flow the editing view is going through,
242
255
  * i.e. with view data filtering. Otherwise the simple stub is used.
243
- * @returns {String} An HTML-like string representing the view.
256
+ * @returns An HTML-like string representing the view.
244
257
  */
245
258
  export function stringify(node, selectionOrPositionOrRange = null, options = {}) {
246
259
  let selection;
@@ -258,26 +271,36 @@ export function stringify(node, selectionOrPositionOrRange = null, options = {})
258
271
  * Parses an HTML-like string and returns a view tree.
259
272
  * A simple string will be converted to a {@link module:engine/view/text~Text text} node:
260
273
  *
261
- * parse( 'foobar' ); // Returns an instance of text.
274
+ * ```ts
275
+ * parse( 'foobar' ); // Returns an instance of text.
276
+ * ```
262
277
  *
263
278
  * {@link module:engine/view/element~Element Elements} will be parsed with attributes as children:
264
279
  *
265
- * parse( '<b name="baz">foobar</b>' ); // Returns an instance of element with the `baz` attribute and a text child node.
280
+ * ```ts
281
+ * parse( '<b name="baz">foobar</b>' ); // Returns an instance of element with the `baz` attribute and a text child node.
282
+ * ```
266
283
  *
267
284
  * Multiple nodes provided on root level will be converted to a
268
285
  * {@link module:engine/view/documentfragment~DocumentFragment document fragment}:
269
286
  *
270
- * parse( '<b>foo</b><i>bar</i>' ); // Returns a document fragment with two child elements.
287
+ * ```ts
288
+ * parse( '<b>foo</b><i>bar</i>' ); // Returns a document fragment with two child elements.
289
+ * ```
271
290
  *
272
291
  * The method can parse multiple {@link module:engine/view/range~Range ranges} provided in string data and return a
273
292
  * {@link module:engine/view/documentselection~DocumentSelection selection} instance containing these ranges. Ranges placed inside
274
293
  * {@link module:engine/view/text~Text text} nodes should be marked using `{` and `}` brackets:
275
294
  *
276
- * const { text, selection } = parse( 'f{ooba}r' );
295
+ * ```ts
296
+ * const { text, selection } = parse( 'f{ooba}r' );
297
+ * ```
277
298
  *
278
299
  * Ranges placed outside text nodes should be marked using `[` and `]` brackets:
279
300
  *
280
- * const { root, selection } = parse( '<p>[<b>foobar</b>]</p>' );
301
+ * ```ts
302
+ * const { root, selection } = parse( '<p>[<b>foobar</b>]</p>' );
303
+ * ```
281
304
  *
282
305
  * ** Note: **
283
306
  * It is possible to unify selection markers to `[` and `]` for both (inside and outside text)
@@ -286,7 +309,9 @@ export function stringify(node, selectionOrPositionOrRange = null, options = {})
286
309
  * Sometimes there is a need for defining the order of ranges inside the created selection. This can be achieved by providing
287
310
  * the range order array as an additional parameter:
288
311
  *
289
- * const { root, selection } = parse( '{fo}ob{ar}{ba}z', { order: [ 2, 3, 1 ] } );
312
+ * ```ts
313
+ * const { root, selection } = parse( '{fo}ob{ar}{ba}z', { order: [ 2, 3, 1 ] } );
314
+ * ```
290
315
  *
291
316
  * In the example above, the first range (`{fo}`) will be added to the selection as the second one, the second range (`{ar}`) will be
292
317
  * added as the third and the third range (`{ba}`) will be added as the first one.
@@ -296,38 +321,39 @@ export function stringify(node, selectionOrPositionOrRange = null, options = {})
296
321
  * by the `end` position and {@link module:engine/view/documentselection~DocumentSelection#focus selection focus} is
297
322
  * represented by the `start` position), use the `lastRangeBackward` flag:
298
323
  *
299
- * const { root, selection } = parse( `{foo}bar{baz}`, { lastRangeBackward: true } );
324
+ * ```ts
325
+ * const { root, selection } = parse( `{foo}bar{baz}`, { lastRangeBackward: true } );
326
+ * ```
300
327
  *
301
328
  * Some more examples and edge cases:
302
329
  *
303
- * // Returns an empty document fragment.
304
- * parse( '' );
330
+ * ```ts
331
+ * // Returns an empty document fragment.
332
+ * parse( '' );
305
333
  *
306
- * // Returns an empty document fragment and a collapsed selection.
307
- * const { root, selection } = parse( '[]' );
334
+ * // Returns an empty document fragment and a collapsed selection.
335
+ * const { root, selection } = parse( '[]' );
308
336
  *
309
- * // Returns an element and a selection that is placed inside the document fragment containing that element.
310
- * const { root, selection } = parse( '[<a></a>]' );
337
+ * // Returns an element and a selection that is placed inside the document fragment containing that element.
338
+ * const { root, selection } = parse( '[<a></a>]' );
339
+ * ```
311
340
  *
312
- * @param {String} data An HTML-like string to be parsed.
313
- * @param {Object} options
314
- * @param {Array.<Number>} [options.order] An array with the order of parsed ranges added to the returned
341
+ * @param data An HTML-like string to be parsed.
342
+ * @param options.order An array with the order of parsed ranges added to the returned
315
343
  * {@link module:engine/view/documentselection~DocumentSelection Selection} instance. Each element should represent the
316
344
  * desired position of each range in the selection instance. For example: `[2, 3, 1]` means that the first range will be
317
345
  * placed as the second, the second as the third and the third as the first.
318
- * @param {Boolean} [options.lastRangeBackward=false] If set to `true`, the last range will be added as backward to the returned
346
+ * @param options.lastRangeBackward If set to `true`, the last range will be added as backward to the returned
319
347
  * {@link module:engine/view/documentselection~DocumentSelection selection} instance.
320
- * @param {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment}
321
- * [options.rootElement=null] The default root to use when parsing elements.
348
+ * @param options.rootElement The default root to use when parsing elements.
322
349
  * When set to `null`, the root element will be created automatically. If set to
323
350
  * {@link module:engine/view/element~Element Element} or {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment},
324
351
  * this node will be used as the root for all parsed nodes.
325
- * @param {Boolean} [options.sameSelectionCharacters=false] When set to `false`, the selection inside the text should be marked using
352
+ * @param options.sameSelectionCharacters When set to `false`, the selection inside the text should be marked using
326
353
  * `{` and `}` and the selection outside the ext using `[` and `]`. When set to `true`, both should be marked with `[` and `]` only.
327
- * @param {module:engine/view/stylesmap~StylesProcessor} [options.stylesProcessor] Styles processor.
328
- * @returns {module:engine/view/text~Text|module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment|Object}
329
- * Returns the parsed view node or an object with two fields: `view` and `selection` when selection ranges were included in the data
330
- * to parse.
354
+ * @param options.stylesProcessor Styles processor.
355
+ * @returns Returns the parsed view node or an object with two fields: `view` and `selection` when selection ranges were included in the
356
+ * data to parse.
331
357
  */
332
358
  export function parse(data, options = {}) {
333
359
  const viewDocument = new ViewDocument(new StylesProcessor());
@@ -373,15 +399,13 @@ export function parse(data, options = {}) {
373
399
  }
374
400
  /**
375
401
  * Private helper class used for converting ranges represented as text inside view {@link module:engine/view/text~Text text nodes}.
376
- *
377
- * @private
378
402
  */
379
403
  class RangeParser {
380
404
  /**
381
405
  * Creates a range parser instance.
382
406
  *
383
- * @param {Object} options The range parser configuration.
384
- * @param {Boolean} [options.sameSelectionCharacters=false] When set to `true`, the selection inside the text is marked as
407
+ * @param options The range parser configuration.
408
+ * @param options.sameSelectionCharacters When set to `true`, the selection inside the text is marked as
385
409
  * `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both are marked as `[` and `]`.
386
410
  */
387
411
  constructor(options) {
@@ -392,11 +416,11 @@ class RangeParser {
392
416
  * The method will remove all occurrences of `{`, `}`, `[` and `]` from found text nodes. If a text node is empty after
393
417
  * the process, it will be removed, too.
394
418
  *
395
- * @param {module:engine/view/node~Node} node The starting node.
396
- * @param {Array.<Number>} order The order of ranges. Each element should represent the desired position of the range after
419
+ * @param node The starting node.
420
+ * @param order The order of ranges. Each element should represent the desired position of the range after
397
421
  * sorting. For example: `[2, 3, 1]` means that the first range will be placed as the second, the second as the third and the third
398
422
  * as the first.
399
- * @returns {Array.<module:engine/view/range~Range>} An array with ranges found.
423
+ * @returns An array with ranges found.
400
424
  */
401
425
  parse(node, order) {
402
426
  this._positions = [];
@@ -417,8 +441,7 @@ class RangeParser {
417
441
  * Gathers positions of brackets inside the view tree starting from the provided node. The method will remove all occurrences of
418
442
  * `{`, `}`, `[` and `]` from found text nodes. If a text node is empty after the process, it will be removed, too.
419
443
  *
420
- * @private
421
- * @param {module:engine/view/node~Node} node Staring node.
444
+ * @param node Staring node.
422
445
  */
423
446
  _getPositions(node) {
424
447
  if (node.is('documentFragment') || node.is('element')) {
@@ -500,10 +523,9 @@ class RangeParser {
500
523
  * For example: `[2, 3, 1]` means that the first range will be placed as the second, the second as the third and the third
501
524
  * as the first.
502
525
  *
503
- * @private
504
- * @param {Array.<module:engine/view/range~Range>} ranges Ranges to sort.
505
- * @param {Array.<Number>} rangesOrder An array with new range order.
506
- * @returns {Array} Sorted ranges array.
526
+ * @param ranges Ranges to sort.
527
+ * @param rangesOrder An array with new range order.
528
+ * @returns Sorted ranges array.
507
529
  */
508
530
  _sortRanges(ranges, rangesOrder) {
509
531
  const sortedRanges = [];
@@ -519,9 +541,6 @@ class RangeParser {
519
541
  }
520
542
  /**
521
543
  * Uses all found bracket positions to create ranges from them.
522
- *
523
- * @private
524
- * @returns {Array.<module:engine/view/range~Range>}
525
544
  */
526
545
  _createRanges() {
527
546
  const ranges = [];
@@ -554,28 +573,24 @@ class RangeParser {
554
573
  }
555
574
  /**
556
575
  * Private helper class used for converting the view tree to a string.
557
- *
558
- * @private
559
576
  */
560
577
  class ViewStringify {
561
578
  /**
562
579
  * Creates a view stringify instance.
563
580
  *
564
- * @param root
565
- * @param {module:engine/view/documentselection~DocumentSelection} selection A selection whose ranges
566
- * should also be converted to a string.
567
- * @param {Object} options An options object.
568
- * @param {Boolean} [options.showType=false] When set to `true`, the type of elements will be printed (`<container:p>`
581
+ * @param selection A selection whose ranges should also be converted to a string.
582
+ * @param options An options object.
583
+ * @param options.showType When set to `true`, the type of elements will be printed (`<container:p>`
569
584
  * instead of `<p>`, `<attribute:b>` instead of `<b>` and `<empty:img>` instead of `<img>`).
570
- * @param {Boolean} [options.showPriority=false] When set to `true`, the attribute element's priority will be printed.
571
- * @param {Boolean} [options.ignoreRoot=false] When set to `true`, the root's element opening and closing tag will not
585
+ * @param options.showPriority When set to `true`, the attribute element's priority will be printed.
586
+ * @param options.ignoreRoot When set to `true`, the root's element opening and closing tag will not
572
587
  * be outputted.
573
- * @param {Boolean} [options.sameSelectionCharacters=false] When set to `true`, the selection inside the text is marked as
588
+ * @param options.sameSelectionCharacters When set to `true`, the selection inside the text is marked as
574
589
  * `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both are marked as `[` and `]`.
575
- * @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
590
+ * @param options.renderUIElements When set to `true`, the inner content of each
576
591
  * {@link module:engine/view/uielement~UIElement} will be printed.
577
- * @param {Boolean} [options.renderRawElements=false] When set to `true`, the inner content of each
578
- * @param {Object} [options.domConverter={}] When set to an actual {@link module:engine/view/domconverter~DomConverter DomConverter}
592
+ * @param options.renderRawElements When set to `true`, the inner content of each
593
+ * @param options.domConverter When set to an actual {@link module:engine/view/domconverter~DomConverter DomConverter}
579
594
  * instance, it lets the conversion go through exactly the same flow the editing view is going through,
580
595
  * i.e. with view data filtering. Otherwise the simple stub is used.
581
596
  * {@link module:engine/view/rawelement~RawElement} will be printed.
@@ -599,7 +614,7 @@ class ViewStringify {
599
614
  /**
600
615
  * Converts the view to a string.
601
616
  *
602
- * @returns {String} String representation of the view elements.
617
+ * @returns String representation of the view elements.
603
618
  */
604
619
  stringify() {
605
620
  let result = '';
@@ -611,10 +626,6 @@ class ViewStringify {
611
626
  /**
612
627
  * Executes a simple walker that iterates over all elements in the view tree starting from the root element.
613
628
  * Calls the `callback` with parsed chunks of string data.
614
- *
615
- * @private
616
- * @param {module:engine/view/documentfragment~DocumentFragment|module:engine/view/element~Element|module:engine/view/text~Text} root
617
- * @param {Function} callback
618
629
  */
619
630
  _walkView(root, callback) {
620
631
  const ignore = this.ignoreRoot && this.root === root;
@@ -652,10 +663,6 @@ class ViewStringify {
652
663
  /**
653
664
  * Checks if a given {@link module:engine/view/element~Element element} has a {@link module:engine/view/range~Range#start range start}
654
665
  * or a {@link module:engine/view/range~Range#start range end} placed at a given offset and returns its string representation.
655
- *
656
- * @private
657
- * @param {module:engine/view/element~Element} element
658
- * @param {Number} offset
659
666
  */
660
667
  _stringifyElementRanges(element, offset) {
661
668
  let start = '';
@@ -681,9 +688,6 @@ class ViewStringify {
681
688
  * {@link module:engine/view/range~Range#start range start} or a
682
689
  * {@link module:engine/view/range~Range#start range end} placed somewhere inside. Returns a string representation of text
683
690
  * with range delimiters placed inside.
684
- *
685
- * @private
686
- * @param {module:engine/view/text~Text} node
687
691
  */
688
692
  _stringifyTextRanges(node) {
689
693
  const length = node.data.length;
@@ -732,10 +736,6 @@ class ViewStringify {
732
736
  * `<attribute:a>` or `<empty:img>`), contain priority information ( `<attribute:a view-priority="20">` ),
733
737
  * or contain element id ( `<attribute:span view-id="foo">` ). Element attributes will also be included
734
738
  * (`<a href="https://ckeditor.com" name="foobar">`).
735
- *
736
- * @private
737
- * @param {module:engine/view/element~Element} element
738
- * @returns {String}
739
739
  */
740
740
  _stringifyElementOpen(element) {
741
741
  const priority = this._stringifyElementPriority(element);
@@ -750,10 +750,6 @@ class ViewStringify {
750
750
  * Converts the passed {@link module:engine/view/element~Element element} to a closing tag.
751
751
  * Depending on the current configuration, the closing tag can be simple (`</a>`) or contain a type prefix (`</container:p>`,
752
752
  * `</attribute:a>` or `</empty:img>`).
753
- *
754
- * @private
755
- * @param {module:engine/view/element~Element} element
756
- * @returns {String}
757
753
  */
758
754
  _stringifyElementClose(element) {
759
755
  const type = this._stringifyElementType(element);
@@ -770,10 +766,6 @@ class ViewStringify {
770
766
  * * 'ui' for {@link module:engine/view/uielement~UIElement UI elements},
771
767
  * * 'raw' for {@link module:engine/view/rawelement~RawElement raw elements},
772
768
  * * an empty string when the current configuration is preventing showing elements' types.
773
- *
774
- * @private
775
- * @param {module:engine/view/element~Element} element
776
- * @returns {String}
777
769
  */
778
770
  _stringifyElementType(element) {
779
771
  if (this.showType) {
@@ -791,10 +783,6 @@ class ViewStringify {
791
783
  * The priority string representation will be returned when the passed element is an instance of
792
784
  * {@link module:engine/view/attributeelement~AttributeElement attribute element} and the current configuration allows to show the
793
785
  * priority. Otherwise returns an empty string.
794
- *
795
- * @private
796
- * @param {module:engine/view/element~Element} element
797
- * @returns {String}
798
786
  */
799
787
  _stringifyElementPriority(element) {
800
788
  if (this.showPriority && element.is('attributeElement')) {
@@ -808,10 +796,6 @@ class ViewStringify {
808
796
  * The id string representation will be returned when the passed element is an instance of
809
797
  * {@link module:engine/view/attributeelement~AttributeElement attribute element}, the element has an id
810
798
  * and the current configuration allows to show the id. Otherwise returns an empty string.
811
- *
812
- * @private
813
- * @param {module:engine/view/element~Element} element
814
- * @returns {String}
815
799
  */
816
800
  _stringifyElementId(element) {
817
801
  if (this.showAttributeElementId && element.is('attributeElement') && element.id) {
@@ -822,10 +806,6 @@ class ViewStringify {
822
806
  /**
823
807
  * Converts the passed {@link module:engine/view/element~Element element} attributes to their string representation.
824
808
  * If an element has no attributes, an empty string is returned.
825
- *
826
- * @private
827
- * @param {module:engine/view/element~Element} element
828
- * @returns {String}
829
809
  */
830
810
  _stringifyElementAttributes(element) {
831
811
  const attributes = [];
@@ -851,18 +831,18 @@ class ViewStringify {
851
831
  return attributes.join(' ');
852
832
  }
853
833
  }
854
- // Converts {@link module:engine/view/element~Element elements} to
855
- // {@link module:engine/view/attributeelement~AttributeElement attribute elements},
856
- // {@link module:engine/view/containerelement~ContainerElement container elements},
857
- // {@link module:engine/view/emptyelement~EmptyElement empty elements} or
858
- // {@link module:engine/view/uielement~UIElement UI elements}.
859
- // It converts the whole tree starting from the `rootNode`. The conversion is based on element names.
860
- // See the `_convertElement` method for more details.
861
- //
862
- // @param {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment|module:engine/view/text~Text}
863
- // rootNode The root node to convert.
864
- // @returns {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment|
865
- // module:engine/view/text~Text} The root node of converted elements.
834
+ /**
835
+ * Converts {@link module:engine/view/element~Element elements} to
836
+ * {@link module:engine/view/attributeelement~AttributeElement attribute elements},
837
+ * {@link module:engine/view/containerelement~ContainerElement container elements},
838
+ * {@link module:engine/view/emptyelement~EmptyElement empty elements} or
839
+ * {@link module:engine/view/uielement~UIElement UI elements}.
840
+ * It converts the whole tree starting from the `rootNode`. The conversion is based on element names.
841
+ * See the `_convertElement` method for more details.
842
+ *
843
+ * @param rootNode The root node to convert.
844
+ * @returns The root node of converted elements.
845
+ */
866
846
  function _convertViewElements(rootNode) {
867
847
  if (rootNode.is('element') || rootNode.is('documentFragment')) {
868
848
  // Convert element or leave document fragment.
@@ -888,29 +868,28 @@ function _convertViewElements(rootNode) {
888
868
  }
889
869
  return rootNode;
890
870
  }
891
- // Converts an {@link module:engine/view/element~Element element} to
892
- // {@link module:engine/view/attributeelement~AttributeElement attribute element},
893
- // {@link module:engine/view/containerelement~ContainerElement container element},
894
- // {@link module:engine/view/emptyelement~EmptyElement empty element} or
895
- // {@link module:engine/view/uielement~UIElement UI element}.
896
- // If the element's name is in the format of `attribute:b`, it will be converted to
897
- // an {@link module:engine/view/attributeelement~AttributeElement attribute element} with a priority of 11.
898
- // Additionally, attribute elements may have specified priority (for example `view-priority="11"`) and/or
899
- // id (for example `view-id="foo"`).
900
- // If the element's name is in the format of `container:p`, it will be converted to
901
- // a {@link module:engine/view/containerelement~ContainerElement container element}.
902
- // If the element's name is in the format of `empty:img`, it will be converted to
903
- // an {@link module:engine/view/emptyelement~EmptyElement empty element}.
904
- // If the element's name is in the format of `ui:span`, it will be converted to
905
- // a {@link module:engine/view/uielement~UIElement UI element}.
906
- // If the element's name does not contain any additional information, a {@link module:engine/view/element~Element view Element} will be
907
- // returned.
908
- //
909
- // @param {module:engine/view/element~Element} viewElement A view element to convert.
910
- // @returns {module:engine/view/element~Element|module:engine/view/attributeelement~AttributeElement|
911
- // module:engine/view/emptyelement~EmptyElement|module:engine/view/uielement~UIElement|
912
- // module:engine/view/containerelement~ContainerElement} A tree view
913
- // element converted according to its name.
871
+ /**
872
+ * Converts an {@link module:engine/view/element~Element element} to
873
+ * {@link module:engine/view/attributeelement~AttributeElement attribute element},
874
+ * {@link module:engine/view/containerelement~ContainerElement container element},
875
+ * {@link module:engine/view/emptyelement~EmptyElement empty element} or
876
+ * {@link module:engine/view/uielement~UIElement UI element}.
877
+ * If the element's name is in the format of `attribute:b`, it will be converted to
878
+ * an {@link module:engine/view/attributeelement~AttributeElement attribute element} with a priority of 11.
879
+ * Additionally, attribute elements may have specified priority (for example `view-priority="11"`) and/or
880
+ * id (for example `view-id="foo"`).
881
+ * If the element's name is in the format of `container:p`, it will be converted to
882
+ * a {@link module:engine/view/containerelement~ContainerElement container element}.
883
+ * If the element's name is in the format of `empty:img`, it will be converted to
884
+ * an {@link module:engine/view/emptyelement~EmptyElement empty element}.
885
+ * If the element's name is in the format of `ui:span`, it will be converted to
886
+ * a {@link module:engine/view/uielement~UIElement UI element}.
887
+ * If the element's name does not contain any additional information, a {@link module:engine/view/element~Element view Element} will be
888
+ * returned.
889
+ *
890
+ * @param viewElement A view element to convert.
891
+ * @returns A tree view element converted according to its name.
892
+ */
914
893
  function _convertElement(viewDocument, viewElement) {
915
894
  const info = _convertElementNameAndInfo(viewElement);
916
895
  const ElementConstructor = allowedTypes[info.type];
@@ -929,19 +908,21 @@ function _convertElement(viewDocument, viewElement) {
929
908
  }
930
909
  return newElement;
931
910
  }
932
- // Converts the `view-priority` attribute and the {@link module:engine/view/element~Element#name element's name} information needed for
933
- // creating {@link module:engine/view/attributeelement~AttributeElement attribute element},
934
- // {@link module:engine/view/containerelement~ContainerElement container element},
935
- // {@link module:engine/view/emptyelement~EmptyElement empty element} or
936
- // {@link module:engine/view/uielement~UIElement UI element}.
937
- // The name can be provided in two formats: as a simple element's name (`div`), or as a type and name (`container:div`,
938
- // `attribute:span`, `empty:img`, `ui:span`);
939
- //
940
- // @param {module:engine/view/element~Element} element The element whose name should be converted.
941
- // @returns {Object} info An object with parsed information.
942
- // @returns {String} info.name The parsed name of the element.
943
- // @returns {String|null} info.type The parsed type of the element. It can be `attribute`, `container` or `empty`.
944
- // returns {Number|null} info.priority The parsed priority of the element.
911
+ /**
912
+ * Converts the `view-priority` attribute and the {@link module:engine/view/element~Element#name element's name} information needed for
913
+ * creating {@link module:engine/view/attributeelement~AttributeElement attribute element},
914
+ * {@link module:engine/view/containerelement~ContainerElement container element},
915
+ * {@link module:engine/view/emptyelement~EmptyElement empty element} or
916
+ * {@link module:engine/view/uielement~UIElement UI element}.
917
+ * The name can be provided in two formats: as a simple element's name (`div`), or as a type and name (`container:div`,
918
+ * `attribute:span`, `empty:img`, `ui:span`);
919
+ *
920
+ * @param viewElement The element whose name should be converted.
921
+ * @returns An object with parsed information:
922
+ * * `name` The parsed name of the element.
923
+ * * `type` The parsed type of the element. It can be `attribute`, `container` or `empty`.
924
+ * * `priority` The parsed priority of the element.
925
+ */
945
926
  function _convertElementNameAndInfo(viewElement) {
946
927
  const parts = viewElement.name.split(':');
947
928
  const priority = _convertPriority(viewElement.getAttribute('view-priority'));
@@ -968,17 +949,15 @@ function _convertElementNameAndInfo(viewElement) {
968
949
  }
969
950
  throw new Error(`Parse error - cannot parse element's name: ${viewElement.name}.`);
970
951
  }
971
- // Checks if the element's type is allowed. Returns `attribute`, `container`, `empty` or `null`.
972
- //
973
- // @param {String} type
974
- // @returns {String|null}
952
+ /**
953
+ * Checks if the element's type is allowed. Returns `attribute`, `container`, `empty` or `null`.
954
+ */
975
955
  function _convertType(type) {
976
956
  return type in allowedTypes ? type : null;
977
957
  }
978
- // Checks if a given priority is allowed. Returns null if the priority cannot be converted.
979
- //
980
- // @param {String} priorityString
981
- // returns {Number|null}
958
+ /**
959
+ * Checks if a given priority is allowed. Returns null if the priority cannot be converted.
960
+ */
982
961
  function _convertPriority(priorityString) {
983
962
  const priority = parseInt(priorityString, 10);
984
963
  if (!isNaN(priority)) {