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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +1 -1
  2. package/package.json +24 -23
  3. package/src/controller/datacontroller.d.ts +331 -0
  4. package/src/controller/datacontroller.js +62 -109
  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 +499 -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 +177 -0
  24. package/src/conversion/viewconsumable.js +157 -162
  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 +105 -0
  42. package/src/index.js +1 -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 +245 -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 +812 -0
  57. package/src/model/model.js +59 -30
  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/moveoperation.d.ts +91 -0
  66. package/src/model/operation/nooperation.d.ts +33 -0
  67. package/src/model/operation/operation.d.ts +89 -0
  68. package/src/model/operation/operationfactory.d.ts +18 -0
  69. package/src/model/operation/renameoperation.d.ts +78 -0
  70. package/src/model/operation/rootattributeoperation.d.ts +97 -0
  71. package/src/model/operation/rootattributeoperation.js +1 -1
  72. package/src/model/operation/splitoperation.d.ts +104 -0
  73. package/src/model/operation/transform.d.ts +100 -0
  74. package/src/model/operation/utils.d.ts +71 -0
  75. package/src/model/position.d.ts +539 -0
  76. package/src/model/position.js +1 -1
  77. package/src/model/range.d.ts +458 -0
  78. package/src/model/range.js +1 -1
  79. package/src/model/rootelement.d.ts +40 -0
  80. package/src/model/schema.d.ts +1176 -0
  81. package/src/model/schema.js +15 -15
  82. package/src/model/selection.d.ts +472 -0
  83. package/src/model/text.d.ts +66 -0
  84. package/src/model/text.js +0 -2
  85. package/src/model/textproxy.d.ts +144 -0
  86. package/src/model/treewalker.d.ts +186 -0
  87. package/src/model/treewalker.js +19 -10
  88. package/src/model/typecheckable.d.ts +255 -0
  89. package/src/model/utils/autoparagraphing.d.ts +37 -0
  90. package/src/model/utils/deletecontent.d.ts +58 -0
  91. package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
  92. package/src/model/utils/getselectedcontent.d.ts +30 -0
  93. package/src/model/utils/insertcontent.d.ts +46 -0
  94. package/src/model/utils/insertcontent.js +2 -12
  95. package/src/model/utils/insertobject.d.ts +44 -0
  96. package/src/model/utils/insertobject.js +3 -14
  97. package/src/model/utils/modifyselection.d.ts +48 -0
  98. package/src/model/utils/selection-post-fixer.d.ts +65 -0
  99. package/src/model/writer.d.ts +726 -0
  100. package/src/model/writer.js +6 -4
  101. package/src/view/attributeelement.d.ts +108 -0
  102. package/src/view/attributeelement.js +25 -69
  103. package/src/view/containerelement.d.ts +49 -0
  104. package/src/view/containerelement.js +10 -43
  105. package/src/view/datatransfer.d.ts +75 -0
  106. package/src/view/document.d.ts +184 -0
  107. package/src/view/document.js +15 -84
  108. package/src/view/documentfragment.d.ts +150 -0
  109. package/src/view/documentfragment.js +40 -81
  110. package/src/view/documentselection.d.ts +219 -0
  111. package/src/view/documentselection.js +75 -121
  112. package/src/view/domconverter.d.ts +620 -0
  113. package/src/view/domconverter.js +159 -276
  114. package/src/view/downcastwriter.d.ts +804 -0
  115. package/src/view/downcastwriter.js +336 -380
  116. package/src/view/editableelement.d.ts +52 -0
  117. package/src/view/editableelement.js +9 -49
  118. package/src/view/element.d.ts +466 -0
  119. package/src/view/element.js +150 -222
  120. package/src/view/elementdefinition.d.ts +87 -0
  121. package/src/view/emptyelement.d.ts +41 -0
  122. package/src/view/emptyelement.js +11 -44
  123. package/src/view/filler.d.ts +111 -0
  124. package/src/view/filler.js +24 -21
  125. package/src/view/item.d.ts +14 -0
  126. package/src/view/matcher.d.ts +486 -0
  127. package/src/view/matcher.js +247 -218
  128. package/src/view/node.d.ts +160 -0
  129. package/src/view/node.js +26 -100
  130. package/src/view/observer/arrowkeysobserver.d.ts +41 -0
  131. package/src/view/observer/arrowkeysobserver.js +0 -13
  132. package/src/view/observer/bubblingemittermixin.d.ts +166 -0
  133. package/src/view/observer/bubblingemittermixin.js +36 -25
  134. package/src/view/observer/bubblingeventinfo.d.ts +47 -0
  135. package/src/view/observer/bubblingeventinfo.js +3 -29
  136. package/src/view/observer/clickobserver.d.ts +43 -0
  137. package/src/view/observer/clickobserver.js +9 -19
  138. package/src/view/observer/compositionobserver.d.ts +82 -0
  139. package/src/view/observer/compositionobserver.js +13 -42
  140. package/src/view/observer/domeventdata.d.ts +50 -0
  141. package/src/view/observer/domeventdata.js +5 -30
  142. package/src/view/observer/domeventobserver.d.ts +69 -0
  143. package/src/view/observer/domeventobserver.js +19 -21
  144. package/src/view/observer/fakeselectionobserver.d.ts +46 -0
  145. package/src/view/observer/fakeselectionobserver.js +2 -15
  146. package/src/view/observer/focusobserver.d.ts +82 -0
  147. package/src/view/observer/focusobserver.js +14 -40
  148. package/src/view/observer/inputobserver.d.ts +86 -0
  149. package/src/view/observer/inputobserver.js +18 -64
  150. package/src/view/observer/keyobserver.d.ts +67 -0
  151. package/src/view/observer/keyobserver.js +8 -42
  152. package/src/view/observer/mouseobserver.d.ts +89 -0
  153. package/src/view/observer/mouseobserver.js +8 -28
  154. package/src/view/observer/mutationobserver.d.ts +82 -0
  155. package/src/view/observer/mutationobserver.js +7 -37
  156. package/src/view/observer/observer.d.ts +84 -0
  157. package/src/view/observer/observer.js +12 -25
  158. package/src/view/observer/selectionobserver.d.ts +143 -0
  159. package/src/view/observer/selectionobserver.js +9 -99
  160. package/src/view/observer/tabobserver.d.ts +42 -0
  161. package/src/view/observer/tabobserver.js +0 -14
  162. package/src/view/placeholder.d.ts +85 -0
  163. package/src/view/placeholder.js +26 -43
  164. package/src/view/position.d.ts +189 -0
  165. package/src/view/position.js +36 -83
  166. package/src/view/range.d.ts +279 -0
  167. package/src/view/range.js +79 -122
  168. package/src/view/rawelement.d.ts +73 -0
  169. package/src/view/rawelement.js +34 -48
  170. package/src/view/renderer.d.ts +265 -0
  171. package/src/view/renderer.js +105 -193
  172. package/src/view/rooteditableelement.d.ts +41 -0
  173. package/src/view/rooteditableelement.js +12 -40
  174. package/src/view/selection.d.ts +375 -0
  175. package/src/view/selection.js +79 -153
  176. package/src/view/styles/background.d.ts +33 -0
  177. package/src/view/styles/background.js +14 -12
  178. package/src/view/styles/border.d.ts +43 -0
  179. package/src/view/styles/border.js +58 -48
  180. package/src/view/styles/margin.d.ts +29 -0
  181. package/src/view/styles/margin.js +13 -11
  182. package/src/view/styles/padding.d.ts +29 -0
  183. package/src/view/styles/padding.js +13 -11
  184. package/src/view/styles/utils.d.ts +93 -0
  185. package/src/view/styles/utils.js +22 -48
  186. package/src/view/stylesmap.d.ts +675 -0
  187. package/src/view/stylesmap.js +249 -244
  188. package/src/view/text.d.ts +74 -0
  189. package/src/view/text.js +16 -46
  190. package/src/view/textproxy.d.ts +97 -0
  191. package/src/view/textproxy.js +10 -59
  192. package/src/view/treewalker.d.ts +195 -0
  193. package/src/view/treewalker.js +43 -106
  194. package/src/view/typecheckable.d.ts +401 -0
  195. package/src/view/uielement.d.ts +96 -0
  196. package/src/view/uielement.js +28 -62
  197. package/src/view/upcastwriter.d.ts +328 -0
  198. package/src/view/upcastwriter.js +124 -134
  199. package/src/view/view.d.ts +327 -0
  200. package/src/view/view.js +79 -150
@@ -3,7 +3,7 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
- * @module module:engine/view/downcastwriter
6
+ * @module engine/view/downcastwriter
7
7
  */
8
8
  import Position from './position';
9
9
  import Range from './range';
@@ -30,36 +30,24 @@ import { isPlainObject } from 'lodash-es';
30
30
  * To work with ordinary views (e.g. parsed from a pasted content) use the
31
31
  * {@link module:engine/view/upcastwriter~UpcastWriter upcast writer}.
32
32
  *
33
- * Read more about changing the view in the {@glink framework/guides/architecture/editing-engine#changing-the-view Changing the view}
34
- * section of the {@glink framework/guides/architecture/editing-engine Editing engine architecture} guide.
33
+ * Read more about changing the view in the {@glink framework/architecture/editing-engine#changing-the-view Changing the view}
34
+ * section of the {@glink framework/architecture/editing-engine Editing engine architecture} guide.
35
35
  */
36
36
  export default class DowncastWriter {
37
37
  /**
38
- * @param {module:engine/view/document~Document} document The view document instance.
38
+ * @param document The view document instance.
39
39
  */
40
40
  constructor(document) {
41
- /**
42
- * The view document instance in which this writer operates.
43
- *
44
- * @readonly
45
- * @type {module:engine/view/document~Document}
46
- */
47
- this.document = document;
48
41
  /**
49
42
  * Holds references to the attribute groups that share the same {@link module:engine/view/attributeelement~AttributeElement#id id}.
50
43
  * The keys are `id`s, the values are `Set`s holding {@link module:engine/view/attributeelement~AttributeElement}s.
51
- *
52
- * @private
53
- * @type {Map.<String,Set>}
54
44
  */
55
45
  this._cloneGroups = new Map();
56
46
  /**
57
47
  * The slot factory used by the `elementToStructure` downcast helper.
58
- *
59
- * @private
60
- * @type {Function|null}
61
48
  */
62
49
  this._slotFactory = null;
50
+ this.document = document;
63
51
  }
64
52
  /**
65
53
  * Sets {@link module:engine/view/documentselection~DocumentSelection selection's} ranges and direction to the
@@ -67,63 +55,64 @@ export default class DowncastWriter {
67
55
  *
68
56
  * Usage:
69
57
  *
70
- * // Sets selection to the given range.
71
- * const range = writer.createRange( start, end );
72
- * writer.setSelection( range );
58
+ * ```ts
59
+ * // Sets selection to the given range.
60
+ * const range = writer.createRange( start, end );
61
+ * writer.setSelection( range );
73
62
  *
74
- * // Sets backward selection to the given range.
75
- * const range = writer.createRange( start, end );
76
- * writer.setSelection( range );
63
+ * // Sets backward selection to the given range.
64
+ * const range = writer.createRange( start, end );
65
+ * writer.setSelection( range );
77
66
  *
78
- * // Sets selection to given ranges.
79
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
80
- * writer.setSelection( range );
67
+ * // Sets selection to given ranges.
68
+ * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( start2, end2 ) ];
69
+ * writer.setSelection( range );
81
70
  *
82
- * // Sets selection to the other selection.
83
- * const otherSelection = writer.createSelection();
84
- * writer.setSelection( otherSelection );
71
+ * // Sets selection to the other selection.
72
+ * const otherSelection = writer.createSelection();
73
+ * writer.setSelection( otherSelection );
85
74
  *
86
- * // Sets collapsed selection at the given position.
87
- * const position = writer.createPositionFromPath( root, path );
88
- * writer.setSelection( position );
75
+ * // Sets collapsed selection at the given position.
76
+ * const position = writer.createPositionFromPath( root, path );
77
+ * writer.setSelection( position );
89
78
  *
90
- * // Sets collapsed selection at the position of given item and offset.
91
- * const paragraph = writer.createContainerElement( 'p' );
92
- * writer.setSelection( paragraph, offset );
79
+ * // Sets collapsed selection at the position of given item and offset.
80
+ * const paragraph = writer.createContainerElement( 'p' );
81
+ * writer.setSelection( paragraph, offset );
82
+ * ```
93
83
  *
94
84
  * Creates a range inside an {@link module:engine/view/element~Element element} which starts before the first child of
95
85
  * that element and ends after the last child of that element.
96
86
  *
97
- * writer.setSelection( paragraph, 'in' );
87
+ * ```ts
88
+ * writer.setSelection( paragraph, 'in' );
89
+ * ```
98
90
  *
99
91
  * Creates a range on the {@link module:engine/view/item~Item item} which starts before the item and ends just after the item.
100
92
  *
101
- * writer.setSelection( paragraph, 'on' );
93
+ * ```ts
94
+ * writer.setSelection( paragraph, 'on' );
102
95
  *
103
- * // Removes all ranges.
104
- * writer.setSelection( null );
96
+ * // Removes all ranges.
97
+ * writer.setSelection( null );
98
+ * ```
105
99
  *
106
100
  * `DowncastWriter#setSelection()` allow passing additional options (`backward`, `fake` and `label`) as the last argument.
107
101
  *
108
- * // Sets selection as backward.
109
- * writer.setSelection( range, { backward: true } );
110
- *
111
- * // Sets selection as fake.
112
- * // Fake selection does not render as browser native selection over selected elements and is hidden to the user.
113
- * // This way, no native selection UI artifacts are displayed to the user and selection over elements can be
114
- * // represented in other way, for example by applying proper CSS class.
115
- * writer.setSelection( range, { fake: true } );
116
- *
117
- * // Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
118
- * // (and be properly handled by screen readers).
119
- * writer.setSelection( range, { fake: true, label: 'foo' } );
120
- *
121
- * @param {module:engine/view/selection~Selectable} selectable
122
- * @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Sets place or offset of the selection.
123
- * @param {Object} [options]
124
- * @param {Boolean} [options.backward] Sets this selection instance to be backward.
125
- * @param {Boolean} [options.fake] Sets this selection instance to be marked as `fake`.
126
- * @param {String} [options.label] Label for the fake selection.
102
+ * ```ts
103
+ * // Sets selection as backward.
104
+ * writer.setSelection( range, { backward: true } );
105
+ *
106
+ * // Sets selection as fake.
107
+ * // Fake selection does not render as browser native selection over selected elements and is hidden to the user.
108
+ * // This way, no native selection UI artifacts are displayed to the user and selection over elements can be
109
+ * // represented in other way, for example by applying proper CSS class.
110
+ * writer.setSelection( range, { fake: true } );
111
+ *
112
+ * // Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
113
+ * // (and be properly handled by screen readers).
114
+ * writer.setSelection( range, { fake: true, label: 'foo' } );
115
+ * ```
127
116
  */
128
117
  setSelection(...args) {
129
118
  this.document.selection._setTo(...args);
@@ -134,19 +123,16 @@ export default class DowncastWriter {
134
123
  * The location can be specified in the same form as {@link module:engine/view/view~View#createPositionAt view.createPositionAt()}
135
124
  * parameters.
136
125
  *
137
- * @param {module:engine/view/item~Item|module:engine/view/position~Position} itemOrPosition
138
- * @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
139
- * first parameter is a {@link module:engine/view/item~Item view item}.
126
+ * @param Offset or one of the flags. Used only when the first parameter is a {@link module:engine/view/item~Item view item}.
140
127
  */
141
- setSelectionFocus(...args) {
142
- this.document.selection._setFocus(...args);
128
+ setSelectionFocus(itemOrPosition, offset) {
129
+ this.document.selection._setFocus(itemOrPosition, offset);
143
130
  }
144
131
  /**
145
132
  * Creates a new {@link module:engine/view/documentfragment~DocumentFragment} instance.
146
133
  *
147
- * @param {module:engine/view/node~Node|Iterable.<module:engine/view/node~Node>} [children]
148
- * A list of nodes to be inserted into the created document fragment.
149
- * @returns {module:engine/view/documentfragment~DocumentFragment} The created document fragment.
134
+ * @param children A list of nodes to be inserted into the created document fragment.
135
+ * @returns The created document fragment.
150
136
  */
151
137
  createDocumentFragment(children) {
152
138
  return new DocumentFragment(this.document, children);
@@ -154,10 +140,12 @@ export default class DowncastWriter {
154
140
  /**
155
141
  * Creates a new {@link module:engine/view/text~Text text node}.
156
142
  *
157
- * writer.createText( 'foo' );
143
+ * ```ts
144
+ * writer.createText( 'foo' );
145
+ * ```
158
146
  *
159
- * @param {String} data The text's data.
160
- * @returns {module:engine/view/text~Text} The created text node.
147
+ * @param data The text's data.
148
+ * @returns The created text node.
161
149
  */
162
150
  createText(data) {
163
151
  return new Text(this.document, data);
@@ -165,23 +153,25 @@ export default class DowncastWriter {
165
153
  /**
166
154
  * Creates a new {@link module:engine/view/attributeelement~AttributeElement}.
167
155
  *
168
- * writer.createAttributeElement( 'strong' );
169
- * writer.createAttributeElement( 'a', { href: 'foo.bar' } );
156
+ * ```ts
157
+ * writer.createAttributeElement( 'strong' );
158
+ * writer.createAttributeElement( 'a', { href: 'foo.bar' } );
170
159
  *
171
- * // Make `<a>` element contain other attributes element so the `<a>` element is not broken.
172
- * writer.createAttributeElement( 'a', { href: 'foo.bar' }, { priority: 5 } );
160
+ * // Make `<a>` element contain other attributes element so the `<a>` element is not broken.
161
+ * writer.createAttributeElement( 'a', { href: 'foo.bar' }, { priority: 5 } );
173
162
  *
174
- * // Set `id` of a marker element so it is not joined or merged with "normal" elements.
175
- * writer.createAttributeElement( 'span', { class: 'my-marker' }, { id: 'marker:my' } );
163
+ * // Set `id` of a marker element so it is not joined or merged with "normal" elements.
164
+ * writer.createAttributeElement( 'span', { class: 'my-marker' }, { id: 'marker:my' } );
165
+ * ```
176
166
  *
177
- * @param {String} name Name of the element.
178
- * @param {Object} [attributes] Element's attributes.
179
- * @param {Object} [options] Element's options.
180
- * @param {Number} [options.priority] Element's {@link module:engine/view/attributeelement~AttributeElement#priority priority}.
181
- * @param {Number|String} [options.id] Element's {@link module:engine/view/attributeelement~AttributeElement#id id}.
182
- * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
167
+ * @param name Name of the element.
168
+ * @param attributes Element's attributes.
169
+ * @param options Element's options.
170
+ * @param options.priority Element's {@link module:engine/view/attributeelement~AttributeElement#priority priority}.
171
+ * @param options.id Element's {@link module:engine/view/attributeelement~AttributeElement#id id}.
172
+ * @param options.renderUnsafeAttributes A list of attribute names that should be rendered in the editing
183
173
  * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
184
- * @returns {module:engine/view/attributeelement~AttributeElement} Created element.
174
+ * @returns Created element.
185
175
  */
186
176
  createAttributeElement(name, attributes, options = {}) {
187
177
  const attributeElement = new AttributeElement(this.document, name, attributes);
@@ -213,18 +203,20 @@ export default class DowncastWriter {
213
203
  /**
214
204
  * Creates a new {@link module:engine/view/editableelement~EditableElement}.
215
205
  *
216
- * writer.createEditableElement( 'div' );
217
- * writer.createEditableElement( 'div', { id: 'foo-1234' } );
206
+ * ```ts
207
+ * writer.createEditableElement( 'div' );
208
+ * writer.createEditableElement( 'div', { id: 'foo-1234' } );
209
+ * ```
218
210
  *
219
211
  * Note: The editable element is to be used in the editing pipeline. Usually, together with
220
212
  * {@link module:widget/utils~toWidgetEditable `toWidgetEditable()`}.
221
213
  *
222
- * @param {String} name Name of the element.
223
- * @param {Object} [attributes] Elements attributes.
224
- * @param {Object} [options] Element's options.
225
- * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
214
+ * @param name Name of the element.
215
+ * @param attributes Elements attributes.
216
+ * @param options Element's options.
217
+ * @param options.renderUnsafeAttributes A list of attribute names that should be rendered in the editing
226
218
  * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
227
- * @returns {module:engine/view/editableelement~EditableElement} Created element.
219
+ * @returns Created element.
228
220
  */
229
221
  createEditableElement(name, attributes, options = {}) {
230
222
  const editableElement = new EditableElement(this.document, name, attributes);
@@ -236,15 +228,17 @@ export default class DowncastWriter {
236
228
  /**
237
229
  * Creates a new {@link module:engine/view/emptyelement~EmptyElement}.
238
230
  *
239
- * writer.createEmptyElement( 'img' );
240
- * writer.createEmptyElement( 'img', { id: 'foo-1234' } );
231
+ * ```ts
232
+ * writer.createEmptyElement( 'img' );
233
+ * writer.createEmptyElement( 'img', { id: 'foo-1234' } );
234
+ * ```
241
235
  *
242
- * @param {String} name Name of the element.
243
- * @param {Object} [attributes] Elements attributes.
244
- * @param {Object} [options] Element's options.
245
- * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
236
+ * @param name Name of the element.
237
+ * @param attributes Elements attributes.
238
+ * @param options Element's options.
239
+ * @param options.renderUnsafeAttributes A list of attribute names that should be rendered in the editing
246
240
  * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
247
- * @returns {module:engine/view/emptyelement~EmptyElement} Created element.
241
+ * @returns Created element.
248
242
  */
249
243
  createEmptyElement(name, attributes, options = {}) {
250
244
  const emptyElement = new EmptyElement(this.document, name, attributes);
@@ -256,27 +250,31 @@ export default class DowncastWriter {
256
250
  /**
257
251
  * Creates a new {@link module:engine/view/uielement~UIElement}.
258
252
  *
259
- * writer.createUIElement( 'span' );
260
- * writer.createUIElement( 'span', { id: 'foo-1234' } );
253
+ * ```ts
254
+ * writer.createUIElement( 'span' );
255
+ * writer.createUIElement( 'span', { id: 'foo-1234' } );
256
+ * ```
261
257
  *
262
258
  * A custom render function can be provided as the third parameter:
263
259
  *
264
- * writer.createUIElement( 'span', null, function( domDocument ) {
265
- * const domElement = this.toDomElement( domDocument );
266
- * domElement.innerHTML = '<b>this is ui element</b>';
260
+ * ```ts
261
+ * writer.createUIElement( 'span', null, function( domDocument ) {
262
+ * const domElement = this.toDomElement( domDocument );
263
+ * domElement.innerHTML = '<b>this is ui element</b>';
267
264
  *
268
- * return domElement;
269
- * } );
265
+ * return domElement;
266
+ * } );
267
+ * ```
270
268
  *
271
269
  * Unlike {@link #createRawElement raw elements}, UI elements are by no means editor content, for instance,
272
270
  * they are ignored by the editor selection system.
273
271
  *
274
272
  * You should not use UI elements as data containers. Check out {@link #createRawElement} instead.
275
273
  *
276
- * @param {String} name The name of the element.
277
- * @param {Object} [attributes] Element attributes.
278
- * @param {Function} [renderFunction] A custom render function.
279
- * @returns {module:engine/view/uielement~UIElement} The created element.
274
+ * @param name The name of the element.
275
+ * @param attributes Element attributes.
276
+ * @param renderFunction A custom render function.
277
+ * @returns The created element.
280
278
  */
281
279
  createUIElement(name, attributes, renderFunction) {
282
280
  const uiElement = new UIElement(this.document, name, attributes);
@@ -288,9 +286,11 @@ export default class DowncastWriter {
288
286
  /**
289
287
  * Creates a new {@link module:engine/view/rawelement~RawElement}.
290
288
  *
291
- * writer.createRawElement( 'span', { id: 'foo-1234' }, function( domElement ) {
292
- * domElement.innerHTML = '<b>This is the raw content of the raw element.</b>';
293
- * } );
289
+ * ```ts
290
+ * writer.createRawElement( 'span', { id: 'foo-1234' }, function( domElement ) {
291
+ * domElement.innerHTML = '<b>This is the raw content of the raw element.</b>';
292
+ * } );
293
+ * ```
294
294
  *
295
295
  * Raw elements work as data containers ("wrappers", "sandboxes") but their children are not managed or
296
296
  * even recognized by the editor. This encapsulation allows integrations to maintain custom DOM structures
@@ -304,13 +304,13 @@ export default class DowncastWriter {
304
304
  * You should not use raw elements to render the UI in the editor content. Check out {@link #createUIElement `#createUIElement()`}
305
305
  * instead.
306
306
  *
307
- * @param {String} name The name of the element.
308
- * @param {Object} [attributes] Element attributes.
309
- * @param {Function} [renderFunction] A custom render function.
310
- * @param {Object} [options] Element's options.
311
- * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
307
+ * @param name The name of the element.
308
+ * @param attributes Element attributes.
309
+ * @param renderFunction A custom render function.
310
+ * @param options Element's options.
311
+ * @param options.renderUnsafeAttributes A list of attribute names that should be rendered in the editing
312
312
  * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
313
- * @returns {module:engine/view/rawelement~RawElement} The created element.
313
+ * @returns The created element.
314
314
  */
315
315
  createRawElement(name, attributes, renderFunction, options = {}) {
316
316
  const rawElement = new RawElement(this.document, name, attributes);
@@ -325,11 +325,12 @@ export default class DowncastWriter {
325
325
  /**
326
326
  * Adds or overwrites the element's attribute with a specified key and value.
327
327
  *
328
- * writer.setAttribute( 'href', 'http://ckeditor.com', linkElement );
328
+ * ```ts
329
+ * writer.setAttribute( 'href', 'http://ckeditor.com', linkElement );
330
+ * ```
329
331
  *
330
- * @param {String} key The attribute key.
331
- * @param {String} value The attribute value.
332
- * @param {module:engine/view/element~Element} element
332
+ * @param key The attribute key.
333
+ * @param value The attribute value.
333
334
  */
334
335
  setAttribute(key, value, element) {
335
336
  element._setAttribute(key, value);
@@ -337,10 +338,11 @@ export default class DowncastWriter {
337
338
  /**
338
339
  * Removes attribute from the element.
339
340
  *
340
- * writer.removeAttribute( 'href', linkElement );
341
+ * ```ts
342
+ * writer.removeAttribute( 'href', linkElement );
343
+ * ```
341
344
  *
342
- * @param {String} key Attribute key.
343
- * @param {module:engine/view/element~Element} element
345
+ * @param key Attribute key.
344
346
  */
345
347
  removeAttribute(key, element) {
346
348
  element._removeAttribute(key);
@@ -348,11 +350,10 @@ export default class DowncastWriter {
348
350
  /**
349
351
  * Adds specified class to the element.
350
352
  *
351
- * writer.addClass( 'foo', linkElement );
352
- * writer.addClass( [ 'foo', 'bar' ], linkElement );
353
- *
354
- * @param {Array.<String>|String} className
355
- * @param {module:engine/view/element~Element} element
353
+ * ```ts
354
+ * writer.addClass( 'foo', linkElement );
355
+ * writer.addClass( [ 'foo', 'bar' ], linkElement );
356
+ * ```
356
357
  */
357
358
  addClass(className, element) {
358
359
  element._addClass(className);
@@ -360,11 +361,10 @@ export default class DowncastWriter {
360
361
  /**
361
362
  * Removes specified class from the element.
362
363
  *
363
- * writer.removeClass( 'foo', linkElement );
364
- * writer.removeClass( [ 'foo', 'bar' ], linkElement );
365
- *
366
- * @param {Array.<String>|String} className
367
- * @param {module:engine/view/element~Element} element
364
+ * ```ts
365
+ * writer.removeClass( 'foo', linkElement );
366
+ * writer.removeClass( [ 'foo', 'bar' ], linkElement );
367
+ * ```
368
368
  */
369
369
  removeClass(className, element) {
370
370
  element._removeClass(className);
@@ -380,15 +380,14 @@ export default class DowncastWriter {
380
380
  /**
381
381
  * Removes specified style from the element.
382
382
  *
383
- * writer.removeStyle( 'color', element ); // Removes 'color' style.
384
- * writer.removeStyle( [ 'color', 'border-top' ], element ); // Removes both 'color' and 'border-top' styles.
383
+ * ```ts
384
+ * writer.removeStyle( 'color', element ); // Removes 'color' style.
385
+ * writer.removeStyle( [ 'color', 'border-top' ], element ); // Removes both 'color' and 'border-top' styles.
386
+ * ```
385
387
  *
386
388
  * **Note**: This method can work with normalized style names if
387
389
  * {@link module:engine/controller/datacontroller~DataController#addStyleProcessorRules a particular style processor rule is enabled}.
388
390
  * See {@link module:engine/view/stylesmap~StylesMap#remove `StylesMap#remove()`} for details.
389
- *
390
- * @param {Array.<String>|String} property
391
- * @param {module:engine/view/element~Element} element
392
391
  */
393
392
  removeStyle(property, element) {
394
393
  element._removeStyle(property);
@@ -396,10 +395,6 @@ export default class DowncastWriter {
396
395
  /**
397
396
  * Sets a custom property on element. Unlike attributes, custom properties are not rendered to the DOM,
398
397
  * so they can be used to add special data to elements.
399
- *
400
- * @param {String|Symbol} key
401
- * @param {*} value
402
- * @param {module:engine/view/element~Element} element
403
398
  */
404
399
  setCustomProperty(key, value, element) {
405
400
  element._setCustomProperty(key, value);
@@ -407,9 +402,7 @@ export default class DowncastWriter {
407
402
  /**
408
403
  * Removes a custom property stored under the given key.
409
404
  *
410
- * @param {String|Symbol} key
411
- * @param {module:engine/view/element~Element} element
412
- * @returns {Boolean} Returns true if property was removed.
405
+ * @returns Returns true if property was removed.
413
406
  */
414
407
  removeCustomProperty(key, element) {
415
408
  return element._removeCustomProperty(key);
@@ -420,10 +413,12 @@ export default class DowncastWriter {
420
413
  *
421
414
  * In following examples `<p>` is a container, `<b>` and `<u>` are attribute elements:
422
415
  *
423
- * <p>foo<b><u>bar{}</u></b></p> -> <p>foo<b><u>bar</u></b>[]</p>
424
- * <p>foo<b><u>{}bar</u></b></p> -> <p>foo{}<b><u>bar</u></b></p>
425
- * <p>foo<b><u>b{}ar</u></b></p> -> <p>foo<b><u>b</u></b>[]<b><u>ar</u></b></p>
426
- * <p><b>fo{o</b><u>ba}r</u></p> -> <p><b>fo</b><b>o</b><u>ba</u><u>r</u></b></p>
416
+ * ```html
417
+ * <p>foo<b><u>bar{}</u></b></p> -> <p>foo<b><u>bar</u></b>[]</p>
418
+ * <p>foo<b><u>{}bar</u></b></p> -> <p>foo{}<b><u>bar</u></b></p>
419
+ * <p>foo<b><u>b{}ar</u></b></p> -> <p>foo<b><u>b</u></b>[]<b><u>ar</u></b></p>
420
+ * <p><b>fo{o</b><u>ba}r</u></p> -> <p><b>fo</b><b>o</b><u>ba</u><u>r</u></b></p>
421
+ * ```
427
422
  *
428
423
  * **Note:** {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment} is treated like a container.
429
424
  *
@@ -446,10 +441,8 @@ export default class DowncastWriter {
446
441
  * @see module:engine/view/attributeelement~AttributeElement
447
442
  * @see module:engine/view/containerelement~ContainerElement
448
443
  * @see module:engine/view/downcastwriter~DowncastWriter#breakContainer
449
- * @param {module:engine/view/position~Position|module:engine/view/range~Range} positionOrRange The position where
450
- * to break attribute elements.
451
- * @returns {module:engine/view/position~Position|module:engine/view/range~Range} The new position or range, after breaking the
452
- * attribute elements.
444
+ * @param positionOrRange The position where to break attribute elements.
445
+ * @returns The new position or range, after breaking the attribute elements.
453
446
  */
454
447
  breakAttributes(positionOrRange) {
455
448
  if (positionOrRange instanceof Position) {
@@ -464,10 +457,12 @@ export default class DowncastWriter {
464
457
  * The position has to be directly inside the container element and cannot be in the root. It does not break the conrainer view element
465
458
  * if the position is at the beginning or at the end of its parent element.
466
459
  *
467
- * <p>foo^bar</p> -> <p>foo</p><p>bar</p>
468
- * <div><p>foo</p>^<p>bar</p></div> -> <div><p>foo</p></div><div><p>bar</p></div>
469
- * <p>^foobar</p> -> ^<p>foobar</p>
470
- * <p>foobar^</p> -> <p>foobar</p>^
460
+ * ```html
461
+ * <p>foo^bar</p> -> <p>foo</p><p>bar</p>
462
+ * <div><p>foo</p>^<p>bar</p></div> -> <div><p>foo</p></div><div><p>bar</p></div>
463
+ * <p>^foobar</p> -> ^<p>foobar</p>
464
+ * <p>foobar^</p> -> <p>foobar</p>^
465
+ * ```
471
466
  *
472
467
  * **Note:** The difference between {@link module:engine/view/downcastwriter~DowncastWriter#breakAttributes breakAttributes()} and
473
468
  * {@link module:engine/view/downcastwriter~DowncastWriter#breakContainer breakContainer()} is that `breakAttributes()` breaks all
@@ -478,8 +473,8 @@ export default class DowncastWriter {
478
473
  * @see module:engine/view/attributeelement~AttributeElement
479
474
  * @see module:engine/view/containerelement~ContainerElement
480
475
  * @see module:engine/view/downcastwriter~DowncastWriter#breakAttributes
481
- * @param {module:engine/view/position~Position} position The position where to break the element.
482
- * @returns {module:engine/view/position~Position} The position between broken elements. If an element has not been broken,
476
+ * @param position The position where to break the element.
477
+ * @returns The position between broken elements. If an element has not been broken,
483
478
  * the returned position is placed either before or after it.
484
479
  */
485
480
  breakContainer(position) {
@@ -518,14 +513,18 @@ export default class DowncastWriter {
518
513
  *
519
514
  * In following examples `<p>` is a container and `<b>` is an attribute element:
520
515
  *
521
- * <p>foo[]bar</p> -> <p>foo{}bar</p>
522
- * <p><b>foo</b>[]<b>bar</b></p> -> <p><b>foo{}bar</b></p>
523
- * <p><b foo="bar">a</b>[]<b foo="baz">b</b></p> -> <p><b foo="bar">a</b>[]<b foo="baz">b</b></p>
516
+ * ```html
517
+ * <p>foo[]bar</p> -> <p>foo{}bar</p>
518
+ * <p><b>foo</b>[]<b>bar</b></p> -> <p><b>foo{}bar</b></p>
519
+ * <p><b foo="bar">a</b>[]<b foo="baz">b</b></p> -> <p><b foo="bar">a</b>[]<b foo="baz">b</b></p>
520
+ * ```
524
521
  *
525
522
  * It will also take care about empty attributes when merging:
526
523
  *
527
- * <p><b>[]</b></p> -> <p>[]</p>
528
- * <p><b>foo</b><i>[]</i><b>bar</b></p> -> <p><b>foo{}bar</b></p>
524
+ * ```html
525
+ * <p><b>[]</b></p> -> <p>[]</p>
526
+ * <p><b>foo</b><i>[]</i><b>bar</b></p> -> <p><b>foo{}bar</b></p>
527
+ * ```
529
528
  *
530
529
  * **Note:** Difference between {@link module:engine/view/downcastwriter~DowncastWriter#mergeAttributes mergeAttributes} and
531
530
  * {@link module:engine/view/downcastwriter~DowncastWriter#mergeContainers mergeContainers} is that `mergeAttributes` merges two
@@ -535,8 +534,8 @@ export default class DowncastWriter {
535
534
  * @see module:engine/view/attributeelement~AttributeElement
536
535
  * @see module:engine/view/containerelement~ContainerElement
537
536
  * @see module:engine/view/downcastwriter~DowncastWriter#mergeContainers
538
- * @param {module:engine/view/position~Position} position Merge position.
539
- * @returns {module:engine/view/position~Position} Position after merge.
537
+ * @param position Merge position.
538
+ * @returns Position after merge.
540
539
  */
541
540
  mergeAttributes(position) {
542
541
  const positionOffset = position.offset;
@@ -580,8 +579,10 @@ export default class DowncastWriter {
580
579
  * Merges two {@link module:engine/view/containerelement~ContainerElement container elements} that are before and after given position.
581
580
  * Precisely, the element after the position is removed and it's contents are moved to element before the position.
582
581
  *
583
- * <p>foo</p>^<p>bar</p> -> <p>foo^bar</p>
584
- * <div>foo</div>^<p>bar</p> -> <div>foo^bar</div>
582
+ * ```html
583
+ * <p>foo</p>^<p>bar</p> -> <p>foo^bar</p>
584
+ * <div>foo</div>^<p>bar</p> -> <div>foo^bar</div>
585
+ * ```
585
586
  *
586
587
  * **Note:** Difference between {@link module:engine/view/downcastwriter~DowncastWriter#mergeAttributes mergeAttributes} and
587
588
  * {@link module:engine/view/downcastwriter~DowncastWriter#mergeContainers mergeContainers} is that `mergeAttributes` merges two
@@ -591,8 +592,8 @@ export default class DowncastWriter {
591
592
  * @see module:engine/view/attributeelement~AttributeElement
592
593
  * @see module:engine/view/containerelement~ContainerElement
593
594
  * @see module:engine/view/downcastwriter~DowncastWriter#mergeAttributes
594
- * @param {module:engine/view/position~Position} position Merge position.
595
- * @returns {module:engine/view/position~Position} Position after merge.
595
+ * @param position Merge position.
596
+ * @returns Position after merge.
596
597
  */
597
598
  mergeContainers(position) {
598
599
  const prev = position.nodeBefore;
@@ -623,15 +624,9 @@ export default class DowncastWriter {
623
624
  * {@link module:engine/view/rawelement~RawElement RawElements} or
624
625
  * {@link module:engine/view/uielement~UIElement UIElements}.
625
626
  *
626
- * @param {module:engine/view/position~Position} position Insertion position.
627
- * @param {module:engine/view/text~Text|module:engine/view/attributeelement~AttributeElement|
628
- * module:engine/view/containerelement~ContainerElement|module:engine/view/emptyelement~EmptyElement|
629
- * module:engine/view/rawelement~RawElement|module:engine/view/uielement~UIElement|
630
- * Iterable.<module:engine/view/text~Text|
631
- * module:engine/view/attributeelement~AttributeElement|module:engine/view/containerelement~ContainerElement|
632
- * module:engine/view/emptyelement~EmptyElement|module:engine/view/rawelement~RawElement|
633
- * module:engine/view/uielement~UIElement>} nodes Node or nodes to insert.
634
- * @returns {module:engine/view/range~Range} Range around inserted nodes.
627
+ * @param position Insertion position.
628
+ * @param nodes Node or nodes to insert.
629
+ * @returns Range around inserted nodes.
635
630
  */
636
631
  insert(position, nodes) {
637
632
  nodes = isIterable(nodes) ? [...nodes] : [nodes];
@@ -677,10 +672,10 @@ export default class DowncastWriter {
677
672
  * {@link module:engine/view/range~Range#start start} and {@link module:engine/view/range~Range#end end} positions are not placed inside
678
673
  * same parent container.
679
674
  *
680
- * @param {module:engine/view/range~Range|module:engine/view/item~Item} rangeOrItem Range to remove from container
675
+ * @param rangeOrItem Range to remove from container
681
676
  * or an {@link module:engine/view/item~Item item} to remove. If range is provided, after removing, it will be updated
682
677
  * to a collapsed range showing the new position.
683
- * @returns {module:engine/view/documentfragment~DocumentFragment} Document fragment containing removed nodes.
678
+ * @returns Document fragment containing removed nodes.
684
679
  */
685
680
  remove(rangeOrItem) {
686
681
  const range = rangeOrItem instanceof Range ? rangeOrItem : Range._createOn(rangeOrItem);
@@ -712,8 +707,8 @@ export default class DowncastWriter {
712
707
  * {@link module:engine/view/range~Range#start start} and {@link module:engine/view/range~Range#end end} positions are not placed inside
713
708
  * same parent container.
714
709
  *
715
- * @param {module:engine/view/range~Range} range Range to clear.
716
- * @param {module:engine/view/element~Element} element Element to remove.
710
+ * @param range Range to clear.
711
+ * @param element Element to remove.
717
712
  */
718
713
  clear(range, element) {
719
714
  validateRangeContainer(range, this.document);
@@ -764,9 +759,9 @@ export default class DowncastWriter {
764
759
  * {@link module:engine/view/range~Range#start start} and {@link module:engine/view/range~Range#end end} positions are not placed inside
765
760
  * same parent container.
766
761
  *
767
- * @param {module:engine/view/range~Range} sourceRange Range containing nodes to move.
768
- * @param {module:engine/view/position~Position} targetPosition Position to insert.
769
- * @returns {module:engine/view/range~Range} Range in target container. Inserted nodes are placed between
762
+ * @param sourceRange Range containing nodes to move.
763
+ * @param targetPosition Position to insert.
764
+ * @returns Range in target container. Inserted nodes are placed between
770
765
  * {@link module:engine/view/range~Range#start start} and {@link module:engine/view/range~Range#end end} positions.
771
766
  */
772
767
  move(sourceRange, targetPosition) {
@@ -801,9 +796,9 @@ export default class DowncastWriter {
801
796
  * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-nonselection-collapsed-range` when passed range
802
797
  * is collapsed and different than view selection.
803
798
  *
804
- * @param {module:engine/view/range~Range} range Range to wrap.
805
- * @param {module:engine/view/attributeelement~AttributeElement} attribute Attribute element to use as wrapper.
806
- * @returns {module:engine/view/range~Range} range Range after wrapping, spanning over wrapping attribute element.
799
+ * @param range Range to wrap.
800
+ * @param attribute Attribute element to use as wrapper.
801
+ * @returns range Range after wrapping, spanning over wrapping attribute element.
807
802
  */
808
803
  wrap(range, attribute) {
809
804
  if (!(attribute instanceof AttributeElement)) {
@@ -835,9 +830,6 @@ export default class DowncastWriter {
835
830
  * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-invalid-range-container` when
836
831
  * {@link module:engine/view/range~Range#start start} and {@link module:engine/view/range~Range#end end} positions are not placed inside
837
832
  * same parent container.
838
- *
839
- * @param {module:engine/view/range~Range} range
840
- * @param {module:engine/view/attributeelement~AttributeElement} attribute
841
833
  */
842
834
  unwrap(range, attribute) {
843
835
  if (!(attribute instanceof AttributeElement)) {
@@ -877,9 +869,9 @@ export default class DowncastWriter {
877
869
  *
878
870
  * Since this function creates a new element and removes the given one, the new element is returned to keep reference.
879
871
  *
880
- * @param {String} newName New name for element.
881
- * @param {module:engine/view/containerelement~ContainerElement} viewElement Element to be renamed.
882
- * @returns {module:engine/view/containerelement~ContainerElement} Element created due to rename.
872
+ * @param newName New name for element.
873
+ * @param viewElement Element to be renamed.
874
+ * @returns Element created due to rename.
883
875
  */
884
876
  rename(newName, viewElement) {
885
877
  const newElement = new ContainerElement(this.document, newName, viewElement.getAttributes());
@@ -900,7 +892,7 @@ export default class DowncastWriter {
900
892
  *
901
893
  * Keep in mind that group names are equal to the `id` property of the attribute element.
902
894
  *
903
- * @param {String} groupName Name of the group to clear.
895
+ * @param groupName Name of the group to clear.
904
896
  */
905
897
  clearClonedElementsGroup(groupName) {
906
898
  this._cloneGroups.delete(groupName);
@@ -918,10 +910,7 @@ export default class DowncastWriter {
918
910
  * * {@link #createPositionBefore},
919
911
  * * {@link #createPositionAfter},
920
912
  *
921
- * @param {module:engine/view/item~Item|module:engine/model/position~Position} itemOrPosition
922
- * @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
923
- * first parameter is a {@link module:engine/view/item~Item view item}.
924
- * @returns {module:engine/view/position~Position}
913
+ * @param offset Offset or one of the flags. Used only when the first parameter is a {@link module:engine/view/item~Item view item}.
925
914
  */
926
915
  createPositionAt(itemOrPosition, offset) {
927
916
  return Position._createAt(itemOrPosition, offset);
@@ -929,8 +918,7 @@ export default class DowncastWriter {
929
918
  /**
930
919
  * Creates a new position after given view item.
931
920
  *
932
- * @param {module:engine/view/item~Item} item View item after which the position should be located.
933
- * @returns {module:engine/view/position~Position}
921
+ * @param item View item after which the position should be located.
934
922
  */
935
923
  createPositionAfter(item) {
936
924
  return Position._createAfter(item);
@@ -938,8 +926,7 @@ export default class DowncastWriter {
938
926
  /**
939
927
  * Creates a new position before given view item.
940
928
  *
941
- * @param {module:engine/view/item~Item} item View item before which the position should be located.
942
- * @returns {module:engine/view/position~Position}
929
+ * @param item View item before which the position should be located.
943
930
  */
944
931
  createPositionBefore(item) {
945
932
  return Position._createBefore(item);
@@ -949,18 +936,14 @@ export default class DowncastWriter {
949
936
  *
950
937
  * **Note:** This factory method creates its own {@link module:engine/view/position~Position} instances basing on passed values.
951
938
  *
952
- * @param {module:engine/view/position~Position} start Start position.
953
- * @param {module:engine/view/position~Position} [end] End position. If not set, range will be collapsed at `start` position.
954
- * @returns {module:engine/view/range~Range}
939
+ * @param start Start position.
940
+ * @param end End position. If not set, range will be collapsed at `start` position.
955
941
  */
956
- createRange(...args) {
957
- return new Range(...args);
942
+ createRange(start, end) {
943
+ return new Range(start, end);
958
944
  }
959
945
  /**
960
946
  * Creates a range that starts before given {@link module:engine/view/item~Item view item} and ends after it.
961
- *
962
- * @param {module:engine/view/item~Item} item
963
- * @returns {module:engine/view/range~Range}
964
947
  */
965
948
  createRangeOn(item) {
966
949
  return Range._createOn(item);
@@ -969,8 +952,7 @@ export default class DowncastWriter {
969
952
  * Creates a range inside an {@link module:engine/view/element~Element element} which starts before the first child of
970
953
  * that element and ends after the last child of that element.
971
954
  *
972
- * @param {module:engine/view/element~Element} element Element which is a parent for the range.
973
- * @returns {module:engine/view/range~Range}
955
+ * @param element Element which is a parent for the range.
974
956
  */
975
957
  createRangeIn(element) {
976
958
  return Range._createIn(element);
@@ -978,44 +960,48 @@ export default class DowncastWriter {
978
960
  /**
979
961
  * Creates new {@link module:engine/view/selection~Selection} instance.
980
962
  *
981
- * // Creates empty selection without ranges.
982
- * const selection = writer.createSelection();
963
+ * ```ts
964
+ * // Creates empty selection without ranges.
965
+ * const selection = writer.createSelection();
983
966
  *
984
- * // Creates selection at the given range.
985
- * const range = writer.createRange( start, end );
986
- * const selection = writer.createSelection( range );
967
+ * // Creates selection at the given range.
968
+ * const range = writer.createRange( start, end );
969
+ * const selection = writer.createSelection( range );
987
970
  *
988
- * // Creates selection at the given ranges
989
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
990
- * const selection = writer.createSelection( ranges );
971
+ * // Creates selection at the given ranges
972
+ * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
973
+ * const selection = writer.createSelection( ranges );
991
974
  *
992
- * // Creates selection from the other selection.
993
- * const otherSelection = writer.createSelection();
994
- * const selection = writer.createSelection( otherSelection );
975
+ * // Creates selection from the other selection.
976
+ * const otherSelection = writer.createSelection();
977
+ * const selection = writer.createSelection( otherSelection );
995
978
  *
996
- * // Creates selection from the document selection.
997
- * const selection = writer.createSelection( editor.editing.view.document.selection );
979
+ * // Creates selection from the document selection.
980
+ * const selection = writer.createSelection( editor.editing.view.document.selection );
998
981
  *
999
- * // Creates selection at the given position.
1000
- * const position = writer.createPositionFromPath( root, path );
1001
- * const selection = writer.createSelection( position );
982
+ * // Creates selection at the given position.
983
+ * const position = writer.createPositionFromPath( root, path );
984
+ * const selection = writer.createSelection( position );
1002
985
  *
1003
- * // Creates collapsed selection at the position of given item and offset.
1004
- * const paragraph = writer.createContainerElement( 'p' );
1005
- * const selection = writer.createSelection( paragraph, offset );
986
+ * // Creates collapsed selection at the position of given item and offset.
987
+ * const paragraph = writer.createContainerElement( 'p' );
988
+ * const selection = writer.createSelection( paragraph, offset );
1006
989
  *
1007
- * // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
1008
- * // first child of that element and ends after the last child of that element.
1009
- * const selection = writer.createSelection( paragraph, 'in' );
990
+ * // Creates a range inside an {@link module:engine/view/element~Element element} which starts before the
991
+ * // first child of that element and ends after the last child of that element.
992
+ * const selection = writer.createSelection( paragraph, 'in' );
1010
993
  *
1011
- * // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
1012
- * // just after the item.
1013
- * const selection = writer.createSelection( paragraph, 'on' );
994
+ * // Creates a range on an {@link module:engine/view/item~Item item} which starts before the item and ends
995
+ * // just after the item.
996
+ * const selection = writer.createSelection( paragraph, 'on' );
997
+ * ```
1014
998
  *
1015
999
  * `Selection`'s constructor allow passing additional options (`backward`, `fake` and `label`) as the last argument.
1016
1000
  *
1017
- * // Creates backward selection.
1018
- * const selection = writer.createSelection( range, { backward: true } );
1001
+ * ```ts
1002
+ * // Creates backward selection.
1003
+ * const selection = writer.createSelection( range, { backward: true } );
1004
+ * ```
1019
1005
  *
1020
1006
  * Fake selection does not render as browser native selection over selected elements and is hidden to the user.
1021
1007
  * This way, no native selection UI artifacts are displayed to the user and selection over elements can be
@@ -1024,16 +1010,10 @@ export default class DowncastWriter {
1024
1010
  * Additionally fake's selection label can be provided. It will be used to describe fake selection in DOM
1025
1011
  * (and be properly handled by screen readers).
1026
1012
  *
1027
- * // Creates fake selection with label.
1028
- * const selection = writer.createSelection( range, { fake: true, label: 'foo' } );
1029
- *
1030
- * @param {module:engine/view/selection~Selectable} [selectable=null]
1031
- * @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Offset or place when selectable is an `Item`.
1032
- * @param {Object} [options]
1033
- * @param {Boolean} [options.backward] Sets this selection instance to be backward.
1034
- * @param {Boolean} [options.fake] Sets this selection instance to be marked as `fake`.
1035
- * @param {String} [options.label] Label for the fake selection.
1036
- * @returns {module:engine/view/selection~Selection}
1013
+ * ```ts
1014
+ * // Creates fake selection with label.
1015
+ * const selection = writer.createSelection( range, { fake: true, label: 'foo' } );
1016
+ * ```
1037
1017
  */
1038
1018
  createSelection(...args) {
1039
1019
  return new Selection(...args);
@@ -1042,28 +1022,32 @@ export default class DowncastWriter {
1042
1022
  * Creates placeholders for child elements of the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure
1043
1023
  * `elementToStructure()`} conversion helper.
1044
1024
  *
1045
- * const viewSlot = conversionApi.writer.createSlot();
1046
- * const viewPosition = conversionApi.writer.createPositionAt( viewElement, 0 );
1025
+ * ```ts
1026
+ * const viewSlot = conversionApi.writer.createSlot();
1027
+ * const viewPosition = conversionApi.writer.createPositionAt( viewElement, 0 );
1047
1028
  *
1048
- * conversionApi.writer.insert( viewPosition, viewSlot );
1029
+ * conversionApi.writer.insert( viewPosition, viewSlot );
1030
+ * ```
1049
1031
  *
1050
1032
  * It could be filtered down to a specific subset of children (only `<foo>` model elements in this case):
1051
1033
  *
1052
- * const viewSlot = conversionApi.writer.createSlot( node => node.is( 'element', 'foo' ) );
1053
- * const viewPosition = conversionApi.writer.createPositionAt( viewElement, 0 );
1034
+ * ```ts
1035
+ * const viewSlot = conversionApi.writer.createSlot( node => node.is( 'element', 'foo' ) );
1036
+ * const viewPosition = conversionApi.writer.createPositionAt( viewElement, 0 );
1054
1037
  *
1055
- * conversionApi.writer.insert( viewPosition, viewSlot );
1038
+ * conversionApi.writer.insert( viewPosition, viewSlot );
1039
+ * ```
1056
1040
  *
1057
1041
  * While providing a filtered slot, make sure to provide slots for all child nodes. A single node can not be downcasted into
1058
1042
  * multiple slots.
1059
1043
  *
1060
1044
  * **Note**: You should not change the order of nodes. View elements should be in the same order as model nodes.
1061
1045
  *
1062
- * @param {'children'|module:engine/conversion/downcasthelpers~SlotFilter} [modeOrFilter='children'] The filter for child nodes.
1063
- * @returns {module:engine/view/element~Element} The slot element to be placed in to the view structure while processing
1046
+ * @param modeOrFilter The filter for child nodes.
1047
+ * @returns The slot element to be placed in to the view structure while processing
1064
1048
  * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure `elementToStructure()`}.
1065
1049
  */
1066
- createSlot(modeOrFilter) {
1050
+ createSlot(modeOrFilter = 'children') {
1067
1051
  if (!this._slotFactory) {
1068
1052
  /**
1069
1053
  * The `createSlot()` method is only allowed inside the `elementToStructure` downcast helper callback.
@@ -1077,8 +1061,8 @@ export default class DowncastWriter {
1077
1061
  /**
1078
1062
  * Registers a slot factory.
1079
1063
  *
1080
- * @protected
1081
- * @param {Function} slotFactory The slot factory.
1064
+ * @internal
1065
+ * @param slotFactory The slot factory.
1082
1066
  */
1083
1067
  _registerSlotFactory(slotFactory) {
1084
1068
  this._slotFactory = slotFactory;
@@ -1086,7 +1070,7 @@ export default class DowncastWriter {
1086
1070
  /**
1087
1071
  * Clears the registered slot factory.
1088
1072
  *
1089
- * @protected
1073
+ * @internal
1090
1074
  */
1091
1075
  _clearSlotFactory() {
1092
1076
  this._slotFactory = null;
@@ -1095,17 +1079,10 @@ export default class DowncastWriter {
1095
1079
  * Inserts a node or nodes at the specified position. Takes care of breaking attributes before insertion
1096
1080
  * and merging them afterwards if requested by the breakAttributes param.
1097
1081
  *
1098
- * @private
1099
- * @param {module:engine/view/position~Position} position Insertion position.
1100
- * @param {module:engine/view/text~Text|module:engine/view/attributeelement~AttributeElement|
1101
- * module:engine/view/containerelement~ContainerElement|module:engine/view/emptyelement~EmptyElement|
1102
- * module:engine/view/rawelement~RawElement|module:engine/view/uielement~UIElement|
1103
- * Iterable.<module:engine/view/text~Text|
1104
- * module:engine/view/attributeelement~AttributeElement|module:engine/view/containerelement~ContainerElement|
1105
- * module:engine/view/emptyelement~EmptyElement|module:engine/view/rawelement~RawElement|
1106
- * module:engine/view/uielement~UIElement>} nodes Node or nodes to insert.
1107
- * @param {Boolean} breakAttributes Whether attributes should be broken.
1108
- * @returns {module:engine/view/range~Range} Range around inserted nodes.
1082
+ * @param position Insertion position.
1083
+ * @param nodes Node or nodes to insert.
1084
+ * @param breakAttributes Whether attributes should be broken.
1085
+ * @returns Range around inserted nodes.
1109
1086
  */
1110
1087
  _insertNodes(position, nodes, breakAttributes) {
1111
1088
  let parentElement;
@@ -1148,12 +1125,6 @@ export default class DowncastWriter {
1148
1125
  /**
1149
1126
  * Wraps children with provided `wrapElement`. Only children contained in `parent` element between
1150
1127
  * `startOffset` and `endOffset` will be wrapped.
1151
- *
1152
- * @private
1153
- * @param {module:engine/view/element~Element} parent
1154
- * @param {Number} startOffset
1155
- * @param {Number} endOffset
1156
- * @param {module:engine/view/element~Element} wrapElement
1157
1128
  */
1158
1129
  _wrapChildren(parent, startOffset, endOffset, wrapElement) {
1159
1130
  let i = startOffset;
@@ -1219,12 +1190,6 @@ export default class DowncastWriter {
1219
1190
  /**
1220
1191
  * Unwraps children from provided `unwrapElement`. Only children contained in `parent` element between
1221
1192
  * `startOffset` and `endOffset` will be unwrapped.
1222
- *
1223
- * @private
1224
- * @param {module:engine/view/element~Element} parent
1225
- * @param {Number} startOffset
1226
- * @param {Number} endOffset
1227
- * @param {module:engine/view/element~Element} unwrapElement
1228
1193
  */
1229
1194
  _unwrapChildren(parent, startOffset, endOffset, unwrapElement) {
1230
1195
  let i = startOffset;
@@ -1304,10 +1269,7 @@ export default class DowncastWriter {
1304
1269
  * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not
1305
1270
  * an instance of {@link module:engine/view/attributeelement~AttributeElement AttributeElement}.
1306
1271
  *
1307
- * @private
1308
- * @param {module:engine/view/range~Range} range
1309
- * @param {module:engine/view/attributeelement~AttributeElement} attribute
1310
- * @returns {module:engine/view/range~Range} New range after wrapping, spanning over wrapping attribute element.
1272
+ * @returns New range after wrapping, spanning over wrapping attribute element.
1311
1273
  */
1312
1274
  _wrapRange(range, attribute) {
1313
1275
  // Break attributes at range start and end.
@@ -1331,10 +1293,7 @@ export default class DowncastWriter {
1331
1293
  * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not
1332
1294
  * an instance of {@link module:engine/view/attributeelement~AttributeElement AttributeElement}.
1333
1295
  *
1334
- * @private
1335
- * @param {module:engine/view/position~Position} position
1336
- * @param {module:engine/view/attributeelement~AttributeElement} attribute
1337
- * @returns {module:engine/view/position~Position} New position after wrapping.
1296
+ * @returns New position after wrapping.
1338
1297
  */
1339
1298
  _wrapPosition(position, attribute) {
1340
1299
  // Return same position when trying to wrap with attribute similar to position parent.
@@ -1368,14 +1327,13 @@ export default class DowncastWriter {
1368
1327
  return movePositionToTextNode(newPosition);
1369
1328
  }
1370
1329
  /**
1371
- * Wraps one {@link module:engine/view/attributeelement~AttributeElement AttributeElement} into another by
1372
- * merging them if possible. When merging is possible - all attributes, styles and classes are moved from wrapper
1373
- * element to element being wrapped.
1374
- *
1375
- * @private
1376
- * @param {module:engine/view/attributeelement~AttributeElement} wrapper Wrapper AttributeElement.
1377
- * @param {module:engine/view/attributeelement~AttributeElement} toWrap AttributeElement to wrap using wrapper element.
1378
- * @returns {Boolean} Returns `true` if elements are merged.
1330
+ * Wraps one {@link module:engine/view/attributeelement~AttributeElement AttributeElement} into another by
1331
+ * merging them if possible. When merging is possible - all attributes, styles and classes are moved from wrapper
1332
+ * element to element being wrapped.
1333
+ *
1334
+ * @param wrapper Wrapper AttributeElement.
1335
+ * @param toWrap AttributeElement to wrap using wrapper element.
1336
+ * @returns Returns `true` if elements are merged.
1379
1337
  */
1380
1338
  _wrapAttributeElement(wrapper, toWrap) {
1381
1339
  if (!canBeJoined(wrapper, toWrap)) {
@@ -1430,10 +1388,9 @@ export default class DowncastWriter {
1430
1388
  * corresponding attributes, classes and styles. All attributes, classes and styles from wrapper should be present
1431
1389
  * inside element being unwrapped.
1432
1390
  *
1433
- * @private
1434
- * @param {module:engine/view/attributeelement~AttributeElement} wrapper Wrapper AttributeElement.
1435
- * @param {module:engine/view/attributeelement~AttributeElement} toUnwrap AttributeElement to unwrap using wrapper element.
1436
- * @returns {Boolean} Returns `true` if elements are unwrapped.
1391
+ * @param wrapper Wrapper AttributeElement.
1392
+ * @param toUnwrap AttributeElement to unwrap using wrapper element.
1393
+ * @returns Returns `true` if elements are unwrapped.
1437
1394
  **/
1438
1395
  _unwrapAttributeElement(wrapper, toUnwrap) {
1439
1396
  if (!canBeJoined(wrapper, toUnwrap)) {
@@ -1482,11 +1439,10 @@ export default class DowncastWriter {
1482
1439
  /**
1483
1440
  * Helper function used by other `DowncastWriter` methods. Breaks attribute elements at the boundaries of given range.
1484
1441
  *
1485
- * @private
1486
- * @param {module:engine/view/range~Range} range Range which `start` and `end` positions will be used to break attributes.
1487
- * @param {Boolean} [forceSplitText=false] If set to `true`, will break text nodes even if they are directly in container element.
1442
+ * @param range Range which `start` and `end` positions will be used to break attributes.
1443
+ * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.
1488
1444
  * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.
1489
- * @returns {module:engine/view/range~Range} New range with located at break positions.
1445
+ * @returns New range with located at break positions.
1490
1446
  */
1491
1447
  _breakAttributesRange(range, forceSplitText = false) {
1492
1448
  const rangeStart = range.start;
@@ -1513,11 +1469,10 @@ export default class DowncastWriter {
1513
1469
  * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-ui-element` when break position
1514
1470
  * is placed inside {@link module:engine/view/uielement~UIElement UIElement}.
1515
1471
  *
1516
- * @private
1517
- * @param {module:engine/view/position~Position} position Position where to break attributes.
1518
- * @param {Boolean} [forceSplitText=false] If set to `true`, will break text nodes even if they are directly in container element.
1472
+ * @param position Position where to break attributes.
1473
+ * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.
1519
1474
  * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.
1520
- * @returns {module:engine/view/position~Position} New position after breaking the attributes.
1475
+ * @returns New position after breaking the attributes.
1521
1476
  */
1522
1477
  _breakAttributes(position, forceSplitText = false) {
1523
1478
  const positionOffset = position.offset;
@@ -1620,8 +1575,7 @@ export default class DowncastWriter {
1620
1575
  *
1621
1576
  * Does nothing if added element has no {@link module:engine/view/attributeelement~AttributeElement#id id}.
1622
1577
  *
1623
- * @private
1624
- * @param {module:engine/view/attributeelement~AttributeElement} element Attribute element to save.
1578
+ * @param element Attribute element to save.
1625
1579
  */
1626
1580
  _addToClonedElementsGroup(element) {
1627
1581
  // Add only if the element is in document tree.
@@ -1656,8 +1610,7 @@ export default class DowncastWriter {
1656
1610
  *
1657
1611
  * Does nothing if the element has no {@link module:engine/view/attributeelement~AttributeElement#id id}.
1658
1612
  *
1659
- * @private
1660
- * @param {module:engine/view/attributeelement~AttributeElement} element Attribute element to remove.
1613
+ * @param element Attribute element to remove.
1661
1614
  */
1662
1615
  _removeFromClonedElementsGroup(element) {
1663
1616
  // Traverse the element's children recursively to find other attribute elements that also got removed.
@@ -1690,13 +1643,14 @@ function _hasNonUiChildren(parent) {
1690
1643
  *
1691
1644
  * @error view-writer-wrap-invalid-attribute
1692
1645
  */
1693
- // Returns first parent container of specified {@link module:engine/view/position~Position Position}.
1694
- // Position's parent node is checked as first, then next parents are checked.
1695
- // Note that {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment} is treated like a container.
1696
- //
1697
- // @param {module:engine/view/position~Position} position Position used as a start point to locate parent container.
1698
- // @returns {module:engine/view/containerelement~ContainerElement|module:engine/view/documentfragment~DocumentFragment|undefined}
1699
- // Parent container element or `undefined` if container is not found.
1646
+ /**
1647
+ * Returns first parent container of specified {@link module:engine/view/position~Position Position}.
1648
+ * Position's parent node is checked as first, then next parents are checked.
1649
+ * Note that {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment} is treated like a container.
1650
+ *
1651
+ * @param position Position used as a start point to locate parent container.
1652
+ * @returns Parent container element or `undefined` if container is not found.
1653
+ */
1700
1654
  function getParentContainer(position) {
1701
1655
  let parent = position.parent;
1702
1656
  while (!isContainerOrFragment(parent)) {
@@ -1707,14 +1661,12 @@ function getParentContainer(position) {
1707
1661
  }
1708
1662
  return parent;
1709
1663
  }
1710
- // Checks if first {@link module:engine/view/attributeelement~AttributeElement AttributeElement} provided to the function
1711
- // can be wrapped outside second element. It is done by comparing elements'
1712
- // {@link module:engine/view/attributeelement~AttributeElement#priority priorities}, if both have same priority
1713
- // {@link module:engine/view/element~Element#getIdentity identities} are compared.
1714
- //
1715
- // @param {module:engine/view/attributeelement~AttributeElement} a
1716
- // @param {module:engine/view/attributeelement~AttributeElement} b
1717
- // @returns {Boolean}
1664
+ /**
1665
+ * Checks if first {@link module:engine/view/attributeelement~AttributeElement AttributeElement} provided to the function
1666
+ * can be wrapped outside second element. It is done by comparing elements'
1667
+ * {@link module:engine/view/attributeelement~AttributeElement#priority priorities}, if both have same priority
1668
+ * {@link module:engine/view/element~Element#getIdentity identities} are compared.
1669
+ */
1718
1670
  function shouldABeOutsideB(a, b) {
1719
1671
  if (a.priority < b.priority) {
1720
1672
  return true;
@@ -1725,15 +1677,18 @@ function shouldABeOutsideB(a, b) {
1725
1677
  // When priorities are equal and names are different - use identities.
1726
1678
  return a.getIdentity() < b.getIdentity();
1727
1679
  }
1728
- // Returns new position that is moved to near text node. Returns same position if there is no text node before of after
1729
- // specified position.
1730
- //
1731
- // <p>foo[]</p> -> <p>foo{}</p>
1732
- // <p>[]foo</p> -> <p>{}foo</p>
1733
- //
1734
- // @param {module:engine/view/position~Position} position
1735
- // @returns {module:engine/view/position~Position} Position located inside text node or same position if there is no text nodes
1736
- // before or after position location.
1680
+ /**
1681
+ * Returns new position that is moved to near text node. Returns same position if there is no text node before of after
1682
+ * specified position.
1683
+ *
1684
+ * ```html
1685
+ * <p>foo[]</p> -> <p>foo{}</p>
1686
+ * <p>[]foo</p> -> <p>{}foo</p>
1687
+ * ```
1688
+ *
1689
+ * @returns Position located inside text node or same position if there is no text nodes
1690
+ * before or after position location.
1691
+ */
1737
1692
  function movePositionToTextNode(position) {
1738
1693
  const nodeBefore = position.nodeBefore;
1739
1694
  if (nodeBefore && nodeBefore.is('$text')) {
@@ -1745,14 +1700,18 @@ function movePositionToTextNode(position) {
1745
1700
  }
1746
1701
  return position;
1747
1702
  }
1748
- // Breaks text node into two text nodes when possible.
1749
- //
1750
- // <p>foo{}bar</p> -> <p>foo[]bar</p>
1751
- // <p>{}foobar</p> -> <p>[]foobar</p>
1752
- // <p>foobar{}</p> -> <p>foobar[]</p>
1753
- //
1754
- // @param {module:engine/view/position~Position} position Position that need to be placed inside text node.
1755
- // @returns {module:engine/view/position~Position} New position after breaking text node.
1703
+ /**
1704
+ * Breaks text node into two text nodes when possible.
1705
+ *
1706
+ * ```html
1707
+ * <p>foo{}bar</p> -> <p>foo[]bar</p>
1708
+ * <p>{}foobar</p> -> <p>[]foobar</p>
1709
+ * <p>foobar{}</p> -> <p>foobar[]</p>
1710
+ * ```
1711
+ *
1712
+ * @param position Position that need to be placed inside text node.
1713
+ * @returns New position after breaking text node.
1714
+ */
1756
1715
  function breakTextNode(position) {
1757
1716
  if (position.offset == position.parent.data.length) {
1758
1717
  return new Position(position.parent.parent, position.parent.index + 1);
@@ -1769,12 +1728,13 @@ function breakTextNode(position) {
1769
1728
  // Return new position between two newly created text nodes.
1770
1729
  return new Position(position.parent.parent, position.parent.index + 1);
1771
1730
  }
1772
- // Merges two text nodes into first node. Removes second node and returns merge position.
1773
- //
1774
- // @param {module:engine/view/text~Text} t1 First text node to merge. Data from second text node will be moved at the end of
1775
- // this text node.
1776
- // @param {module:engine/view/text~Text} t2 Second text node to merge. This node will be removed after merging.
1777
- // @returns {module:engine/view/position~Position} Position after merging text nodes.
1731
+ /**
1732
+ * Merges two text nodes into first node. Removes second node and returns merge position.
1733
+ *
1734
+ * @param t1 First text node to merge. Data from second text node will be moved at the end of this text node.
1735
+ * @param t2 Second text node to merge. This node will be removed after merging.
1736
+ * @returns Position after merging text nodes.
1737
+ */
1778
1738
  function mergeTextNodes(t1, t2) {
1779
1739
  // Merge text data into first text node and remove second one.
1780
1740
  const nodeBeforeLength = t1.data.length;
@@ -1783,13 +1743,12 @@ function mergeTextNodes(t1, t2) {
1783
1743
  return new Position(t1, nodeBeforeLength);
1784
1744
  }
1785
1745
  const validNodesToInsert = [Text, AttributeElement, ContainerElement, EmptyElement, RawElement, UIElement];
1786
- // Checks if provided nodes are valid to insert.
1787
- //
1788
- // Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert
1789
- // contains instances that are not supported ones (see error description for valid ones.
1790
- //
1791
- // @param Iterable.<module:engine/view/text~Text|module:engine/view/element~Element> nodes
1792
- // @param {Object} errorContext
1746
+ /**
1747
+ * Checks if provided nodes are valid to insert.
1748
+ *
1749
+ * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert
1750
+ * contains instances that are not supported ones (see error description for valid ones.
1751
+ */
1793
1752
  function validateNodesToInsert(nodes, errorContext) {
1794
1753
  for (const node of nodes) {
1795
1754
  if (!validNodesToInsert.some((validNode => node instanceof validNode))) { // eslint-disable-line no-use-before-define
@@ -1815,19 +1774,19 @@ function validateNodesToInsert(nodes, errorContext) {
1815
1774
  }
1816
1775
  }
1817
1776
  }
1818
- // Checks if node is ContainerElement or DocumentFragment, because in most cases they should be treated the same way.
1819
- //
1820
- // @param {module:engine/view/node~Node} node
1821
- // @returns {Boolean} Returns `true` if node is instance of ContainerElement or DocumentFragment.
1777
+ /**
1778
+ * Checks if node is ContainerElement or DocumentFragment, because in most cases they should be treated the same way.
1779
+ *
1780
+ * @returns Returns `true` if node is instance of ContainerElement or DocumentFragment.
1781
+ */
1822
1782
  function isContainerOrFragment(node) {
1823
1783
  return node && (node.is('containerElement') || node.is('documentFragment'));
1824
1784
  }
1825
- // Checks if {@link module:engine/view/range~Range#start range start} and {@link module:engine/view/range~Range#end range end} are placed
1826
- // inside same {@link module:engine/view/containerelement~ContainerElement container element}.
1827
- // Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-invalid-range-container` when validation fails.
1828
- //
1829
- // @param {module:engine/view/range~Range} range
1830
- // @param {Object} errorContext
1785
+ /**
1786
+ * Checks if {@link module:engine/view/range~Range#start range start} and {@link module:engine/view/range~Range#end range end} are placed
1787
+ * inside same {@link module:engine/view/containerelement~ContainerElement container element}.
1788
+ * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-invalid-range-container` when validation fails.
1789
+ */
1831
1790
  function validateRangeContainer(range, errorContext) {
1832
1791
  const startContainer = getParentContainer(range.start);
1833
1792
  const endContainer = getParentContainer(range.end);
@@ -1851,13 +1810,10 @@ function validateRangeContainer(range, errorContext) {
1851
1810
  throw new CKEditorError('view-writer-invalid-range-container', errorContext);
1852
1811
  }
1853
1812
  }
1854
- // Checks if two attribute elements can be joined together. Elements can be joined together if, and only if
1855
- // they do not have ids specified.
1856
- //
1857
- // @private
1858
- // @param {module:engine/view/element~Element} a
1859
- // @param {module:engine/view/element~Element} b
1860
- // @returns {Boolean}
1813
+ /**
1814
+ * Checks if two attribute elements can be joined together. Elements can be joined together if, and only if
1815
+ * they do not have ids specified.
1816
+ */
1861
1817
  function canBeJoined(a, b) {
1862
1818
  return a.id === null && b.id === null;
1863
1819
  }