@ckeditor/ckeditor5-engine 35.3.2 → 36.0.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 (123) hide show
  1. package/LICENSE.md +1 -1
  2. package/package.json +22 -22
  3. package/src/controller/datacontroller.js +10 -8
  4. package/src/controller/editingcontroller.js +3 -4
  5. package/src/conversion/conversion.js +2 -3
  6. package/src/conversion/conversionhelpers.js +1 -1
  7. package/src/conversion/downcastdispatcher.js +3 -3
  8. package/src/conversion/downcasthelpers.js +2 -3
  9. package/src/conversion/mapper.js +3 -4
  10. package/src/conversion/modelconsumable.js +2 -2
  11. package/src/conversion/upcastdispatcher.js +3 -4
  12. package/src/conversion/upcasthelpers.js +10 -3
  13. package/src/conversion/viewconsumable.js +2 -2
  14. package/src/dataprocessor/basichtmlwriter.js +1 -1
  15. package/src/dataprocessor/dataprocessor.js +1 -1
  16. package/src/dataprocessor/htmldataprocessor.js +3 -3
  17. package/src/dataprocessor/htmlwriter.js +1 -1
  18. package/src/dataprocessor/xmldataprocessor.js +6 -2
  19. package/src/dev-utils/model.js +3 -3
  20. package/src/dev-utils/operationreplayer.js +1 -1
  21. package/src/dev-utils/utils.js +1 -1
  22. package/src/dev-utils/view.js +1 -1
  23. package/src/index.js +13 -3
  24. package/src/model/batch.js +10 -47
  25. package/src/model/differ.js +81 -174
  26. package/src/model/document.js +38 -97
  27. package/src/model/documentfragment.js +44 -97
  28. package/src/model/documentselection.js +152 -251
  29. package/src/model/element.js +48 -101
  30. package/src/model/history.js +15 -46
  31. package/src/model/item.js +1 -1
  32. package/src/model/liveposition.js +11 -39
  33. package/src/model/liverange.js +14 -38
  34. package/src/model/markercollection.js +42 -115
  35. package/src/model/model.js +214 -292
  36. package/src/model/node.js +36 -128
  37. package/src/model/nodelist.js +12 -41
  38. package/src/model/operation/attributeoperation.js +14 -45
  39. package/src/model/operation/detachoperation.js +4 -17
  40. package/src/model/operation/insertoperation.js +7 -35
  41. package/src/model/operation/markeroperation.js +9 -48
  42. package/src/model/operation/mergeoperation.js +9 -42
  43. package/src/model/operation/moveoperation.js +15 -39
  44. package/src/model/operation/nooperation.js +1 -7
  45. package/src/model/operation/operation.js +5 -63
  46. package/src/model/operation/operationfactory.js +3 -6
  47. package/src/model/operation/renameoperation.js +9 -29
  48. package/src/model/operation/rootattributeoperation.js +19 -48
  49. package/src/model/operation/splitoperation.js +10 -48
  50. package/src/model/operation/transform.js +110 -151
  51. package/src/model/operation/utils.js +37 -52
  52. package/src/model/position.js +118 -230
  53. package/src/model/range.js +146 -202
  54. package/src/model/rootelement.js +8 -47
  55. package/src/model/schema.js +245 -282
  56. package/src/model/selection.js +135 -196
  57. package/src/model/text.js +10 -37
  58. package/src/model/textproxy.js +16 -70
  59. package/src/model/treewalker.js +11 -102
  60. package/src/model/typecheckable.js +1 -1
  61. package/src/model/utils/autoparagraphing.js +11 -12
  62. package/src/model/utils/deletecontent.js +93 -62
  63. package/src/model/utils/findoptimalinsertionrange.js +25 -25
  64. package/src/model/utils/getselectedcontent.js +3 -6
  65. package/src/model/utils/insertcontent.js +37 -130
  66. package/src/model/utils/insertobject.js +40 -40
  67. package/src/model/utils/modifyselection.js +24 -34
  68. package/src/model/utils/selection-post-fixer.js +53 -59
  69. package/src/model/writer.js +209 -316
  70. package/src/view/attributeelement.js +2 -2
  71. package/src/view/containerelement.js +1 -1
  72. package/src/view/datatransfer.js +1 -1
  73. package/src/view/document.js +3 -5
  74. package/src/view/documentfragment.js +50 -4
  75. package/src/view/documentselection.js +2 -3
  76. package/src/view/domconverter.js +4 -8
  77. package/src/view/downcastwriter.js +2 -3
  78. package/src/view/editableelement.js +2 -3
  79. package/src/view/element.js +6 -8
  80. package/src/view/elementdefinition.js +1 -1
  81. package/src/view/emptyelement.js +2 -2
  82. package/src/view/filler.js +2 -3
  83. package/src/view/item.js +1 -1
  84. package/src/view/matcher.js +2 -2
  85. package/src/view/node.js +2 -5
  86. package/src/view/observer/arrowkeysobserver.js +1 -1
  87. package/src/view/observer/bubblingemittermixin.js +3 -6
  88. package/src/view/observer/bubblingeventinfo.js +2 -2
  89. package/src/view/observer/clickobserver.js +1 -1
  90. package/src/view/observer/compositionobserver.js +1 -1
  91. package/src/view/observer/domeventdata.js +1 -1
  92. package/src/view/observer/domeventobserver.js +1 -1
  93. package/src/view/observer/fakeselectionobserver.js +2 -2
  94. package/src/view/observer/focusobserver.js +25 -3
  95. package/src/view/observer/inputobserver.js +2 -2
  96. package/src/view/observer/keyobserver.js +2 -2
  97. package/src/view/observer/mouseobserver.js +1 -1
  98. package/src/view/observer/mutationobserver.js +1 -1
  99. package/src/view/observer/observer.js +3 -3
  100. package/src/view/observer/selectionobserver.js +21 -3
  101. package/src/view/observer/tabobserver.js +2 -2
  102. package/src/view/placeholder.js +1 -1
  103. package/src/view/position.js +2 -3
  104. package/src/view/range.js +1 -1
  105. package/src/view/rawelement.js +2 -2
  106. package/src/view/renderer.js +3 -12
  107. package/src/view/rooteditableelement.js +1 -1
  108. package/src/view/selection.js +2 -6
  109. package/src/view/styles/background.js +1 -1
  110. package/src/view/styles/border.js +1 -1
  111. package/src/view/styles/margin.js +1 -1
  112. package/src/view/styles/padding.js +1 -1
  113. package/src/view/styles/utils.js +1 -1
  114. package/src/view/stylesmap.js +1 -1
  115. package/src/view/text.js +1 -1
  116. package/src/view/textproxy.js +2 -2
  117. package/src/view/treewalker.js +2 -2
  118. package/src/view/typecheckable.js +1 -1
  119. package/src/view/uielement.js +2 -3
  120. package/src/view/upcastwriter.js +1 -1
  121. package/src/view/view.js +7 -7
  122. package/theme/placeholder.css +1 -1
  123. package/theme/renderer.css +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
@@ -21,8 +21,7 @@ import Position from './position';
21
21
  import Range from './range';
22
22
  import RootElement from './rootelement';
23
23
  import Text from './text';
24
- import toMap from '@ckeditor/ckeditor5-utils/src/tomap';
25
- import CKEditorError, { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
24
+ import { CKEditorError, logWarning, toMap } from '@ckeditor/ckeditor5-utils';
26
25
  /**
27
26
  * The model can only be modified by using the writer. It should be used whenever you want to create a node, modify
28
27
  * child nodes, attributes or text, set the selection's position and its attributes.
@@ -51,34 +50,22 @@ export default class Writer {
51
50
  * **Note:** It is not recommended to use it directly. Use {@link module:engine/model/model~Model#change `Model#change()`} or
52
51
  * {@link module:engine/model/model~Model#enqueueChange `Model#enqueueChange()`} instead.
53
52
  *
54
- * @protected
55
- * @param {module:engine/model/model~Model} model
56
- * @param {module:engine/model/batch~Batch} batch
53
+ * @internal
57
54
  */
58
55
  constructor(model, batch) {
59
- /**
60
- * Instance of the model on which this writer operates.
61
- *
62
- * @readonly
63
- * @type {module:engine/model/model~Model}
64
- */
65
56
  this.model = model;
66
- /**
67
- * The batch to which this writer will add changes.
68
- *
69
- * @readonly
70
- * @type {module:engine/model/batch~Batch}
71
- */
72
57
  this.batch = batch;
73
58
  }
74
59
  /**
75
60
  * Creates a new {@link module:engine/model/text~Text text node}.
76
61
  *
77
- * writer.createText( 'foo' );
78
- * writer.createText( 'foo', { bold: true } );
62
+ * ```ts
63
+ * writer.createText( 'foo' );
64
+ * writer.createText( 'foo', { bold: true } );
65
+ * ```
79
66
  *
80
- * @param {String} data Text data.
81
- * @param {Object} [attributes] Text attributes.
67
+ * @param data Text data.
68
+ * @param attributes Text attributes.
82
69
  * @returns {module:engine/model/text~Text} Created text node.
83
70
  */
84
71
  createText(data, attributes) {
@@ -87,12 +74,14 @@ export default class Writer {
87
74
  /**
88
75
  * Creates a new {@link module:engine/model/element~Element element}.
89
76
  *
90
- * writer.createElement( 'paragraph' );
91
- * writer.createElement( 'paragraph', { alignment: 'center' } );
77
+ * ```ts
78
+ * writer.createElement( 'paragraph' );
79
+ * writer.createElement( 'paragraph', { alignment: 'center' } );
80
+ * ```
92
81
  *
93
- * @param {String} name Name of the element.
94
- * @param {Object} [attributes] Elements attributes.
95
- * @returns {module:engine/model/element~Element} Created element.
82
+ * @param name Name of the element.
83
+ * @param attributes Elements attributes.
84
+ * @returns Created element.
96
85
  */
97
86
  createElement(name, attributes) {
98
87
  return new Element(name, attributes);
@@ -100,7 +89,7 @@ export default class Writer {
100
89
  /**
101
90
  * Creates a new {@link module:engine/model/documentfragment~DocumentFragment document fragment}.
102
91
  *
103
- * @returns {module:engine/model/documentfragment~DocumentFragment} Created document fragment.
92
+ * @returns Created document fragment.
104
93
  */
105
94
  createDocumentFragment() {
106
95
  return new DocumentFragment();
@@ -109,8 +98,8 @@ export default class Writer {
109
98
  * Creates a copy of the element and returns it. Created element has the same name and attributes as the original element.
110
99
  * If clone is deep, the original element's children are also cloned. If not, then empty element is returned.
111
100
  *
112
- * @param {module:engine/model/element~Element} element The element to clone.
113
- * @param {Boolean} [deep=true] If set to `true` clones element and all its children recursively. When set to `false`,
101
+ * @param element The element to clone.
102
+ * @param deep If set to `true` clones element and all its children recursively. When set to `false`,
114
103
  * element will be cloned without any child.
115
104
  */
116
105
  cloneElement(element, deep = true) {
@@ -119,23 +108,31 @@ export default class Writer {
119
108
  /**
120
109
  * Inserts item on given position.
121
110
  *
122
- * const paragraph = writer.createElement( 'paragraph' );
123
- * writer.insert( paragraph, position );
111
+ * ```ts
112
+ * const paragraph = writer.createElement( 'paragraph' );
113
+ * writer.insert( paragraph, position );
114
+ * ```
124
115
  *
125
116
  * Instead of using position you can use parent and offset:
126
117
  *
127
- * const text = writer.createText( 'foo' );
128
- * writer.insert( text, paragraph, 5 );
118
+ * ```ts
119
+ * const text = writer.createText( 'foo' );
120
+ * writer.insert( text, paragraph, 5 );
121
+ * ```
129
122
  *
130
123
  * You can also use `end` instead of the offset to insert at the end:
131
124
  *
132
- * const text = writer.createText( 'foo' );
133
- * writer.insert( text, paragraph, 'end' );
125
+ * ```ts
126
+ * const text = writer.createText( 'foo' );
127
+ * writer.insert( text, paragraph, 'end' );
128
+ * ```
134
129
  *
135
130
  * Or insert before or after another element:
136
131
  *
137
- * const paragraph = writer.createElement( 'paragraph' );
138
- * writer.insert( paragraph, anotherParagraph, 'after' );
132
+ * ```ts
133
+ * const paragraph = writer.createElement( 'paragraph' );
134
+ * writer.insert( paragraph, anotherParagraph, 'after' );
135
+ * ```
139
136
  *
140
137
  * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
141
138
  *
@@ -150,11 +147,8 @@ export default class Writer {
150
147
  * **Note:** For a paste-like content insertion mechanism see
151
148
  * {@link module:engine/model/model~Model#insertContent `model.insertContent()`}.
152
149
  *
153
- * @param {module:engine/model/item~Item|module:engine/model/documentfragment~DocumentFragment} item Item or document
154
- * fragment to insert.
155
- * @param {module:engine/model/item~Item|module:engine/model/position~Position} itemOrPosition
156
- * @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
157
- * second parameter is a {@link module:engine/model/item~Item model item}.
150
+ * @param item Item or document fragment to insert.
151
+ * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
158
152
  */
159
153
  insert(item, itemOrPosition, offset = 0) {
160
154
  this._assertWriterUsedCorrectly();
@@ -211,30 +205,6 @@ export default class Writer {
211
205
  }
212
206
  }
213
207
  }
214
- /**
215
- * Creates and inserts text on given position. You can optionally set text attributes:
216
- *
217
- * writer.insertText( 'foo', position );
218
- * writer.insertText( 'foo', { bold: true }, position );
219
- *
220
- * Instead of using position you can use parent and offset or define that text should be inserted at the end
221
- * or before or after other node:
222
- *
223
- * // Inserts 'foo' in paragraph, at offset 5:
224
- * writer.insertText( 'foo', paragraph, 5 );
225
- * // Inserts 'foo' at the end of a paragraph:
226
- * writer.insertText( 'foo', paragraph, 'end' );
227
- * // Inserts 'foo' after an image:
228
- * writer.insertText( 'foo', image, 'after' );
229
- *
230
- * These parameters work in the same way as {@link #createPositionAt `writer.createPositionAt()`}.
231
- *
232
- * @param {String} dattexta Text data.
233
- * @param {Object} [attributes] Text attributes.
234
- * @param {module:engine/model/item~Item|module:engine/model/position~Position} itemOrPosition
235
- * @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
236
- * third parameter is a {@link module:engine/model/item~Item model item}.
237
- */
238
208
  insertText(text, attributes, // Too complicated when not using `any`.
239
209
  itemOrPosition, // Too complicated when not using `any`.
240
210
  offset // Too complicated when not using `any`.
@@ -246,30 +216,6 @@ export default class Writer {
246
216
  this.insert(this.createText(text, attributes), itemOrPosition, offset);
247
217
  }
248
218
  }
249
- /**
250
- * Creates and inserts element on given position. You can optionally set attributes:
251
- *
252
- * writer.insertElement( 'paragraph', position );
253
- * writer.insertElement( 'paragraph', { alignment: 'center' }, position );
254
- *
255
- * Instead of using position you can use parent and offset or define that text should be inserted at the end
256
- * or before or after other node:
257
- *
258
- * // Inserts paragraph in the root at offset 5:
259
- * writer.insertElement( 'paragraph', root, 5 );
260
- * // Inserts paragraph at the end of a blockquote:
261
- * writer.insertElement( 'paragraph', blockquote, 'end' );
262
- * // Inserts after an image:
263
- * writer.insertElement( 'paragraph', image, 'after' );
264
- *
265
- * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
266
- *
267
- * @param {String} name Name of the element.
268
- * @param {Object} [attributes] Elements attributes.
269
- * @param {module:engine/model/item~Item|module:engine/model/position~Position} itemOrPosition
270
- * @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
271
- * third parameter is a {@link module:engine/model/item~Item model item}.
272
- */
273
219
  insertElement(name, attributes, // Too complicated when not using `any`.
274
220
  itemOrPositionOrOffset, // Too complicated when not using `any`.
275
221
  offset // Too complicated when not using `any`.
@@ -284,31 +230,21 @@ export default class Writer {
284
230
  /**
285
231
  * Inserts item at the end of the given parent.
286
232
  *
287
- * const paragraph = writer.createElement( 'paragraph' );
288
- * writer.append( paragraph, root );
233
+ * ```ts
234
+ * const paragraph = writer.createElement( 'paragraph' );
235
+ * writer.append( paragraph, root );
236
+ * ```
289
237
  *
290
238
  * Note that if the item already has parent it will be removed from the previous parent.
291
239
  *
292
240
  * If you want to move {@link module:engine/model/range~Range range} instead of an
293
241
  * {@link module:engine/model/item~Item item} use {@link module:engine/model/writer~Writer#move `Writer#move()`}.
294
242
  *
295
- * @param {module:engine/model/item~Item|module:engine/model/documentfragment~DocumentFragment}
296
- * item Item or document fragment to insert.
297
- * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} parent
243
+ * @param item Item or document fragment to insert.
298
244
  */
299
245
  append(item, parent) {
300
246
  this.insert(item, parent, 'end');
301
247
  }
302
- /**
303
- * Creates text node and inserts it at the end of the parent. You can optionally set text attributes:
304
- *
305
- * writer.appendText( 'foo', paragraph );
306
- * writer.appendText( 'foo', { bold: true }, paragraph );
307
- *
308
- * @param {String} text Text data.
309
- * @param {Object} [attributes] Text attributes.
310
- * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} parent
311
- */
312
248
  appendText(text, attributes, parent) {
313
249
  if (attributes instanceof DocumentFragment || attributes instanceof Element) {
314
250
  this.insert(this.createText(text), attributes, 'end');
@@ -317,16 +253,6 @@ export default class Writer {
317
253
  this.insert(this.createText(text, attributes), parent, 'end');
318
254
  }
319
255
  }
320
- /**
321
- * Creates element and inserts it at the end of the parent. You can optionally set attributes:
322
- *
323
- * writer.appendElement( 'paragraph', root );
324
- * writer.appendElement( 'paragraph', { alignment: 'center' }, root );
325
- *
326
- * @param {String} name Name of the element.
327
- * @param {Object} [attributes] Elements attributes.
328
- * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} parent
329
- */
330
256
  appendElement(name, attributes, parent) {
331
257
  if (attributes instanceof DocumentFragment || attributes instanceof Element) {
332
258
  this.insert(this.createElement(name), attributes, 'end');
@@ -339,10 +265,9 @@ export default class Writer {
339
265
  * Sets value of the attribute with given key on a {@link module:engine/model/item~Item model item}
340
266
  * or on a {@link module:engine/model/range~Range range}.
341
267
  *
342
- * @param {String} key Attribute key.
343
- * @param {*} value Attribute new value.
344
- * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
345
- * Model item or range on which the attribute will be set.
268
+ * @param key Attribute key.
269
+ * @param value Attribute new value.
270
+ * @param itemOrRange Model item or range on which the attribute will be set.
346
271
  */
347
272
  setAttribute(key, value, itemOrRange) {
348
273
  this._assertWriterUsedCorrectly();
@@ -360,14 +285,15 @@ export default class Writer {
360
285
  * Sets values of attributes on a {@link module:engine/model/item~Item model item}
361
286
  * or on a {@link module:engine/model/range~Range range}.
362
287
  *
363
- * writer.setAttributes( {
364
- * bold: true,
365
- * italic: true
366
- * }, range );
288
+ * ```ts
289
+ * writer.setAttributes( {
290
+ * bold: true,
291
+ * italic: true
292
+ * }, range );
293
+ * ```
367
294
  *
368
- * @param {Object} attributes Attributes keys and values.
369
- * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
370
- * Model item or range on which the attributes will be set.
295
+ * @param attributes Attributes keys and values.
296
+ * @param itemOrRange Model item or range on which the attributes will be set.
371
297
  */
372
298
  setAttributes(attributes, itemOrRange) {
373
299
  for (const [key, val] of toMap(attributes)) {
@@ -378,9 +304,8 @@ export default class Writer {
378
304
  * Removes an attribute with given key from a {@link module:engine/model/item~Item model item}
379
305
  * or from a {@link module:engine/model/range~Range range}.
380
306
  *
381
- * @param {String} key Attribute key.
382
- * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
383
- * Model item or range from which the attribute will be removed.
307
+ * @param key Attribute key.
308
+ * @param itemOrRange Model item or range from which the attribute will be removed.
384
309
  */
385
310
  removeAttribute(key, itemOrRange) {
386
311
  this._assertWriterUsedCorrectly();
@@ -397,8 +322,7 @@ export default class Writer {
397
322
  /**
398
323
  * Removes all attributes from all elements in the range or from the given item.
399
324
  *
400
- * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
401
- * Model item or range from which all attributes will be removed.
325
+ * @param itemOrRange Model item or range from which all attributes will be removed.
402
326
  */
403
327
  clearAttributes(itemOrRange) {
404
328
  this._assertWriterUsedCorrectly();
@@ -419,17 +343,21 @@ export default class Writer {
419
343
  /**
420
344
  * Moves all items in the source range to the target position.
421
345
  *
422
- * writer.move( sourceRange, targetPosition );
346
+ * ```ts
347
+ * writer.move( sourceRange, targetPosition );
348
+ * ```
423
349
  *
424
350
  * Instead of the target position you can use parent and offset or define that range should be moved to the end
425
351
  * or before or after chosen item:
426
352
  *
427
- * // Moves all items in the range to the paragraph at offset 5:
428
- * writer.move( sourceRange, paragraph, 5 );
429
- * // Moves all items in the range to the end of a blockquote:
430
- * writer.move( sourceRange, blockquote, 'end' );
431
- * // Moves all items in the range to a position after an image:
432
- * writer.move( sourceRange, image, 'after' );
353
+ * ```ts
354
+ * // Moves all items in the range to the paragraph at offset 5:
355
+ * writer.move( sourceRange, paragraph, 5 );
356
+ * // Moves all items in the range to the end of a blockquote:
357
+ * writer.move( sourceRange, blockquote, 'end' );
358
+ * // Moves all items in the range to a position after an image:
359
+ * writer.move( sourceRange, image, 'after' );
360
+ * ```
433
361
  *
434
362
  * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
435
363
  *
@@ -438,10 +366,8 @@ export default class Writer {
438
366
  * but you can not move items from document fragment to the document or from one detached element to another. Use
439
367
  * {@link module:engine/model/writer~Writer#insert} in such cases.
440
368
  *
441
- * @param {module:engine/model/range~Range} range Source range.
442
- * @param {module:engine/model/item~Item|module:engine/model/position~Position} itemOrPosition
443
- * @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
444
- * second parameter is a {@link module:engine/model/item~Item model item}.
369
+ * @param range Source range.
370
+ * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
445
371
  */
446
372
  move(range, itemOrPosition, offset) {
447
373
  this._assertWriterUsedCorrectly();
@@ -485,7 +411,7 @@ export default class Writer {
485
411
  /**
486
412
  * Removes given model {@link module:engine/model/item~Item item} or {@link module:engine/model/range~Range range}.
487
413
  *
488
- * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange Model item or range to remove.
414
+ * @param itemOrRange Model item or range to remove.
489
415
  */
490
416
  remove(itemOrRange) {
491
417
  this._assertWriterUsedCorrectly();
@@ -503,7 +429,7 @@ export default class Writer {
503
429
  * Node before and after the position have to be an element. Otherwise `writer-merge-no-element-before` or
504
430
  * `writer-merge-no-element-after` error will be thrown.
505
431
  *
506
- * @param {module:engine/model/position~Position} position Position between merged elements.
432
+ * @param position Position between merged elements.
507
433
  */
508
434
  merge(position) {
509
435
  this._assertWriterUsedCorrectly();
@@ -537,11 +463,9 @@ export default class Writer {
537
463
  /**
538
464
  * Shortcut for {@link module:engine/model/model~Model#createPositionFromPath `Model#createPositionFromPath()`}.
539
465
  *
540
- * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} root Root of the position.
541
- * @param {Array.<Number>} path Position path. See {@link module:engine/model/position~Position#path}.
542
- * @param {module:engine/model/position~PositionStickiness} [stickiness='toNone'] Position stickiness.
543
- * See {@link module:engine/model/position~PositionStickiness}.
544
- * @returns {module:engine/model/position~Position}
466
+ * @param root Root of the position.
467
+ * @param path Position path. See {@link module:engine/model/position~Position#path}.
468
+ * @param stickiness Position stickiness. See {@link module:engine/model/position~PositionStickiness}.
545
469
  */
546
470
  createPositionFromPath(root, path, stickiness) {
547
471
  return this.model.createPositionFromPath(root, path, stickiness);
@@ -549,10 +473,7 @@ export default class Writer {
549
473
  /**
550
474
  * Shortcut for {@link module:engine/model/model~Model#createPositionAt `Model#createPositionAt()`}.
551
475
  *
552
- * @param {module:engine/model/item~Item|module:engine/model/position~Position} itemOrPosition
553
- * @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
554
- * first parameter is a {@link module:engine/model/item~Item model item}.
555
- * @returns {module:engine/model/position~Position}
476
+ * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~Item model item}.
556
477
  */
557
478
  createPositionAt(itemOrPosition, offset) {
558
479
  return this.model.createPositionAt(itemOrPosition, offset);
@@ -560,8 +481,7 @@ export default class Writer {
560
481
  /**
561
482
  * Shortcut for {@link module:engine/model/model~Model#createPositionAfter `Model#createPositionAfter()`}.
562
483
  *
563
- * @param {module:engine/model/item~Item} item Item after which the position should be placed.
564
- * @returns {module:engine/model/position~Position}
484
+ * @param item Item after which the position should be placed.
565
485
  */
566
486
  createPositionAfter(item) {
567
487
  return this.model.createPositionAfter(item);
@@ -569,8 +489,7 @@ export default class Writer {
569
489
  /**
570
490
  * Shortcut for {@link module:engine/model/model~Model#createPositionBefore `Model#createPositionBefore()`}.
571
491
  *
572
- * @param {module:engine/model/item~Item} item Item after which the position should be placed.
573
- * @returns {module:engine/model/position~Position}
492
+ * @param item Item after which the position should be placed.
574
493
  */
575
494
  createPositionBefore(item) {
576
495
  return this.model.createPositionBefore(item);
@@ -578,9 +497,8 @@ export default class Writer {
578
497
  /**
579
498
  * Shortcut for {@link module:engine/model/model~Model#createRange `Model#createRange()`}.
580
499
  *
581
- * @param {module:engine/model/position~Position} start Start position.
582
- * @param {module:engine/model/position~Position} [end] End position. If not set, range will be collapsed at `start` position.
583
- * @returns {module:engine/model/range~Range}
500
+ * @param start Start position.
501
+ * @param end End position. If not set, range will be collapsed at `start` position.
584
502
  */
585
503
  createRange(start, end) {
586
504
  return this.model.createRange(start, end);
@@ -588,8 +506,7 @@ export default class Writer {
588
506
  /**
589
507
  * Shortcut for {@link module:engine/model/model~Model#createRangeIn `Model#createRangeIn()`}.
590
508
  *
591
- * @param {module:engine/model/element~Element} element Element which is a parent for the range.
592
- * @returns {module:engine/model/range~Range}
509
+ * @param element Element which is a parent for the range.
593
510
  */
594
511
  createRangeIn(element) {
595
512
  return this.model.createRangeIn(element);
@@ -597,20 +514,13 @@ export default class Writer {
597
514
  /**
598
515
  * Shortcut for {@link module:engine/model/model~Model#createRangeOn `Model#createRangeOn()`}.
599
516
  *
600
- * @param {module:engine/model/element~Element} element Element which is a parent for the range.
601
- * @returns {module:engine/model/range~Range}
517
+ * @param element Element which is a parent for the range.
602
518
  */
603
519
  createRangeOn(element) {
604
520
  return this.model.createRangeOn(element);
605
521
  }
606
522
  /**
607
523
  * Shortcut for {@link module:engine/model/model~Model#createSelection `Model#createSelection()`}.
608
- *
609
- * @param {module:engine/model/selection~Selectable} selectable
610
- * @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Sets place or offset of the selection.
611
- * @param {Object} [options]
612
- * @param {Boolean} [options.backward] Sets this selection instance to be backward.
613
- * @returns {module:engine/model/selection~Selection}
614
524
  */
615
525
  createSelection(...args) {
616
526
  return this.model.createSelection(...args);
@@ -618,8 +528,7 @@ export default class Writer {
618
528
  /**
619
529
  * Performs merge action in a detached tree.
620
530
  *
621
- * @private
622
- * @param {module:engine/model/position~Position} position Position between merged elements.
531
+ * @param position Position between merged elements.
623
532
  */
624
533
  _mergeDetached(position) {
625
534
  const nodeBefore = position.nodeBefore;
@@ -630,8 +539,7 @@ export default class Writer {
630
539
  /**
631
540
  * Performs merge action in a non-detached tree.
632
541
  *
633
- * @private
634
- * @param {module:engine/model/position~Position} position Position between merged elements.
542
+ * @param position Position between merged elements.
635
543
  */
636
544
  _merge(position) {
637
545
  const targetPosition = Position._createAt(position.nodeBefore, 'end');
@@ -646,8 +554,8 @@ export default class Writer {
646
554
  /**
647
555
  * Renames the given element.
648
556
  *
649
- * @param {module:engine/model/element~Element} element The element to rename.
650
- * @param {String} newName New element name.
557
+ * @param element The element to rename.
558
+ * @param newName New element name.
651
559
  */
652
560
  rename(element, newName) {
653
561
  this._assertWriterUsedCorrectly();
@@ -671,12 +579,11 @@ export default class Writer {
671
579
  * The element needs to have a parent. It cannot be a root element nor a document fragment.
672
580
  * The `writer-split-element-no-parent` error will be thrown if you try to split an element with no parent.
673
581
  *
674
- * @param {module:engine/model/position~Position} position Position of split.
675
- * @param {module:engine/model/node~Node} [limitElement] Stop splitting when this element will be reached.
676
- * @returns {Object} result Split result.
677
- * @returns {module:engine/model/position~Position} result.position Position between split elements.
678
- * @returns {module:engine/model/range~Range} result.range Range that stars from the end of the first split element and ends
679
- * at the beginning of the first copy element.
582
+ * @param position Position of split.
583
+ * @param limitElement Stop splitting when this element will be reached.
584
+ * @returns Split result with properties:
585
+ * * `position` - Position between split elements.
586
+ * * `range` - Range that stars from the end of the first split element and ends at the beginning of the first copy element.
680
587
  */
681
588
  split(position, limitElement) {
682
589
  this._assertWriterUsedCorrectly();
@@ -732,8 +639,8 @@ export default class Writer {
732
639
  * **Note:** range to wrap should be a "flat range" (see {@link module:engine/model/range~Range#isFlat `Range#isFlat`}).
733
640
  * If not, an error will be thrown.
734
641
  *
735
- * @param {module:engine/model/range~Range} range Range to wrap.
736
- * @param {module:engine/model/element~Element|String} elementOrString Element or name of element to wrap the range with.
642
+ * @param range Range to wrap.
643
+ * @param elementOrString Element or name of element to wrap the range with.
737
644
  */
738
645
  wrap(range, elementOrString) {
739
646
  this._assertWriterUsedCorrectly();
@@ -771,7 +678,7 @@ export default class Writer {
771
678
  * Unwraps children of the given element – all its children are moved before it and then the element is removed.
772
679
  * Throws error if you try to unwrap an element which does not have a parent.
773
680
  *
774
- * @param {module:engine/model/element~Element} element Element to unwrap.
681
+ * @param element Element to unwrap.
775
682
  */
776
683
  unwrap(element) {
777
684
  this._assertWriterUsedCorrectly();
@@ -804,26 +711,31 @@ export default class Writer {
804
711
  *
805
712
  * Create marker directly base on marker's name:
806
713
  *
807
- * addMarker( markerName, { range, usingOperation: false } );
714
+ * ```ts
715
+ * addMarker( markerName, { range, usingOperation: false } );
716
+ * ```
808
717
  *
809
718
  * Create marker using operation:
810
719
  *
811
- * addMarker( markerName, { range, usingOperation: true } );
720
+ * ```ts
721
+ * addMarker( markerName, { range, usingOperation: true } );
722
+ * ```
812
723
  *
813
724
  * Create marker that affects the editor data:
814
725
  *
815
- * addMarker( markerName, { range, usingOperation: false, affectsData: true } );
726
+ * ```ts
727
+ * addMarker( markerName, { range, usingOperation: false, affectsData: true } );
728
+ * ```
816
729
  *
817
730
  * Note: For efficiency reasons, it's best to create and keep as little markers as possible.
818
731
  *
819
732
  * @see module:engine/model/markercollection~Marker
820
- * @param {String} name Name of a marker to create - must be unique.
821
- * @param {Object} options
822
- * @param {Boolean} options.usingOperation Flag indicating that the marker should be added by MarkerOperation.
733
+ * @param name Name of a marker to create - must be unique.
734
+ * @param options.usingOperation Flag indicating that the marker should be added by MarkerOperation.
823
735
  * See {@link module:engine/model/markercollection~Marker#managedUsingOperations}.
824
- * @param {module:engine/model/range~Range} options.range Marker range.
825
- * @param {Boolean} [options.affectsData=false] Flag indicating that the marker changes the editor data.
826
- * @returns {module:engine/model/markercollection~Marker} Marker that was set.
736
+ * @param options.range Marker range.
737
+ * @param options.affectsData Flag indicating that the marker changes the editor data.
738
+ * @returns Marker that was set.
827
739
  */
828
740
  addMarker(name, options) {
829
741
  this._assertWriterUsedCorrectly();
@@ -883,29 +795,37 @@ export default class Writer {
883
795
  *
884
796
  * Update marker directly base on marker's name:
885
797
  *
886
- * updateMarker( markerName, { range } );
798
+ * ```ts
799
+ * updateMarker( markerName, { range } );
800
+ * ```
887
801
  *
888
802
  * Update marker using operation:
889
803
  *
890
- * updateMarker( marker, { range, usingOperation: true } );
891
- * updateMarker( markerName, { range, usingOperation: true } );
804
+ * ```ts
805
+ * updateMarker( marker, { range, usingOperation: true } );
806
+ * updateMarker( markerName, { range, usingOperation: true } );
807
+ * ```
892
808
  *
893
809
  * Change marker's option (start using operations to manage it):
894
810
  *
895
- * updateMarker( marker, { usingOperation: true } );
811
+ * ```ts
812
+ * updateMarker( marker, { usingOperation: true } );
813
+ * ```
896
814
  *
897
815
  * Change marker's option (inform the engine, that the marker does not affect the data anymore):
898
816
  *
899
- * updateMarker( markerName, { affectsData: false } );
817
+ * ```ts
818
+ * updateMarker( markerName, { affectsData: false } );
819
+ * ```
900
820
  *
901
821
  * @see module:engine/model/markercollection~Marker
902
- * @param {String|module:engine/model/markercollection~Marker} markerOrName Name of a marker to update, or a marker instance.
903
- * @param {Object} [options] If options object is not defined then marker will be refreshed by triggering
822
+ * @param markerOrName Name of a marker to update, or a marker instance.
823
+ * @param options If options object is not defined then marker will be refreshed by triggering
904
824
  * downcast conversion for this marker with the same data.
905
- * @param {module:engine/model/range~Range} [options.range] Marker range to update.
906
- * @param {Boolean} [options.usingOperation] Flag indicated whether the marker should be added by MarkerOperation.
825
+ * @param options.range Marker range to update.
826
+ * @param options.usingOperation Flag indicated whether the marker should be added by MarkerOperation.
907
827
  * See {@link module:engine/model/markercollection~Marker#managedUsingOperations}.
908
- * @param {Boolean} [options.affectsData] Flag indicating that the marker changes the editor data.
828
+ * @param options.affectsData Flag indicating that the marker changes the editor data.
909
829
  */
910
830
  updateMarker(markerOrName, options) {
911
831
  this._assertWriterUsedCorrectly();
@@ -928,7 +848,7 @@ export default class Writer {
928
848
  * instead.
929
849
  *
930
850
  * @error writer-updatemarker-reconvert-using-editingcontroller
931
- * @param {String} markerName The name of the updated marker.
851
+ * @param markerName The name of the updated marker.
932
852
  */
933
853
  logWarning('writer-updatemarker-reconvert-using-editingcontroller', { markerName });
934
854
  this.model.markers._refresh(currentMarker);
@@ -977,7 +897,7 @@ export default class Writer {
977
897
  * The marker is removed accordingly to how it has been created, so if the marker was created using operation,
978
898
  * it will be destroyed using operation.
979
899
  *
980
- * @param {module:engine/model/markercollection~Marker|String} markerOrName Marker or marker name to remove.
900
+ * @param markerOrName Marker or marker name to remove.
981
901
  */
982
902
  removeMarker(markerOrName) {
983
903
  this._assertWriterUsedCorrectly();
@@ -1002,52 +922,55 @@ export default class Writer {
1002
922
  * Sets the document's selection (ranges and direction) to the specified location based on the given
1003
923
  * {@link module:engine/model/selection~Selectable selectable} or creates an empty selection if no arguments were passed.
1004
924
  *
1005
- * // Sets selection to the given range.
1006
- * const range = writer.createRange( start, end );
1007
- * writer.setSelection( range );
925
+ * ```ts
926
+ * // Sets selection to the given range.
927
+ * const range = writer.createRange( start, end );
928
+ * writer.setSelection( range );
1008
929
  *
1009
- * // Sets selection to given ranges.
1010
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
1011
- * writer.setSelection( ranges );
930
+ * // Sets selection to given ranges.
931
+ * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
932
+ * writer.setSelection( ranges );
1012
933
  *
1013
- * // Sets selection to other selection.
1014
- * const otherSelection = writer.createSelection();
1015
- * writer.setSelection( otherSelection );
934
+ * // Sets selection to other selection.
935
+ * const otherSelection = writer.createSelection();
936
+ * writer.setSelection( otherSelection );
1016
937
  *
1017
- * // Sets selection to the given document selection.
1018
- * const documentSelection = model.document.selection;
1019
- * writer.setSelection( documentSelection );
938
+ * // Sets selection to the given document selection.
939
+ * const documentSelection = model.document.selection;
940
+ * writer.setSelection( documentSelection );
1020
941
  *
1021
- * // Sets collapsed selection at the given position.
1022
- * const position = writer.createPosition( root, path );
1023
- * writer.setSelection( position );
942
+ * // Sets collapsed selection at the given position.
943
+ * const position = writer.createPosition( root, path );
944
+ * writer.setSelection( position );
1024
945
  *
1025
- * // Sets collapsed selection at the position of the given node and an offset.
1026
- * writer.setSelection( paragraph, offset );
946
+ * // Sets collapsed selection at the position of the given node and an offset.
947
+ * writer.setSelection( paragraph, offset );
948
+ * ```
1027
949
  *
1028
950
  * Creates a range inside an {@link module:engine/model/element~Element element} which starts before the first child of
1029
951
  * that element and ends after the last child of that element.
1030
952
  *
1031
- * writer.setSelection( paragraph, 'in' );
953
+ * ```ts
954
+ * writer.setSelection( paragraph, 'in' );
955
+ * ```
1032
956
  *
1033
957
  * Creates a range on an {@link module:engine/model/item~Item item} which starts before the item and ends just after the item.
1034
958
  *
1035
- * writer.setSelection( paragraph, 'on' );
959
+ * ```ts
960
+ * writer.setSelection( paragraph, 'on' );
1036
961
  *
1037
- * // Removes all selection's ranges.
1038
- * writer.setSelection( null );
962
+ * // Removes all selection's ranges.
963
+ * writer.setSelection( null );
964
+ * ```
1039
965
  *
1040
966
  * `Writer#setSelection()` allow passing additional options (`backward`) as the last argument.
1041
967
  *
1042
- * // Sets selection as backward.
1043
- * writer.setSelection( range, { backward: true } );
968
+ * ```ts
969
+ * // Sets selection as backward.
970
+ * writer.setSelection( range, { backward: true } );
971
+ * ```
1044
972
  *
1045
973
  * Throws `writer-incorrect-use` error when the writer is used outside the `change()` block.
1046
- *
1047
- * @param {module:engine/model/selection~Selectable} selectable
1048
- * @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Sets place or offset of the selection.
1049
- * @param {Object} [options]
1050
- * @param {Boolean} [options.backward] Sets this selection instance to be backward.
1051
974
  */
1052
975
  setSelection(...args) {
1053
976
  this._assertWriterUsedCorrectly();
@@ -1059,33 +982,13 @@ export default class Writer {
1059
982
  * The location can be specified in the same form as
1060
983
  * {@link #createPositionAt `writer.createPositionAt()`} parameters.
1061
984
  *
1062
- * @param {module:engine/model/item~Item|module:engine/model/position~Position} itemOrPosition
1063
- * @param {Number|'end'|'before'|'after'} [offset=0] Offset or one of the flags. Used only when
1064
- * first parameter is a {@link module:engine/model/item~Item model item}.
985
+ * @param itemOrPosition
986
+ * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~Item model item}.
1065
987
  */
1066
988
  setSelectionFocus(itemOrPosition, offset) {
1067
989
  this._assertWriterUsedCorrectly();
1068
990
  this.model.document.selection._setFocus(itemOrPosition, offset);
1069
991
  }
1070
- /**
1071
- * Sets attribute(s) on the selection. If attribute with the same key already is set, it's value is overwritten.
1072
- *
1073
- * Using key and value pair:
1074
- *
1075
- * writer.setSelectionAttribute( 'italic', true );
1076
- *
1077
- * Using key-value object:
1078
- *
1079
- * writer.setSelectionAttribute( { italic: true, bold: false } );
1080
- *
1081
- * Using iterable object:
1082
- *
1083
- * writer.setSelectionAttribute( new Map( [ [ 'italic', true ] ] ) );
1084
- *
1085
- * @param {String|Object|Iterable.<*>} keyOrObjectOrIterable Key of the attribute to set
1086
- * or object / iterable of key => value attribute pairs.
1087
- * @param {*} [value] Attribute value.
1088
- */
1089
992
  setSelectionAttribute(keyOrObjectOrIterable, value) {
1090
993
  this._assertWriterUsedCorrectly();
1091
994
  if (typeof keyOrObjectOrIterable === 'string') {
@@ -1102,13 +1005,17 @@ export default class Writer {
1102
1005
  *
1103
1006
  * Remove one attribute:
1104
1007
  *
1105
- * writer.removeSelectionAttribute( 'italic' );
1008
+ * ```ts
1009
+ * writer.removeSelectionAttribute( 'italic' );
1010
+ * ```
1106
1011
  *
1107
1012
  * Remove multiple attributes:
1108
1013
  *
1109
- * writer.removeSelectionAttribute( [ 'italic', 'bold' ] );
1014
+ * ```ts
1015
+ * writer.removeSelectionAttribute( [ 'italic', 'bold' ] );
1016
+ * ```
1110
1017
  *
1111
- * @param {String|Iterable.<String>} keyOrIterableOfKeys Key of the attribute to remove or an iterable of attribute keys to remove.
1018
+ * @param keyOrIterableOfKeys Key of the attribute to remove or an iterable of attribute keys to remove.
1112
1019
  */
1113
1020
  removeSelectionAttribute(keyOrIterableOfKeys) {
1114
1021
  this._assertWriterUsedCorrectly();
@@ -1131,7 +1038,9 @@ export default class Writer {
1131
1038
  *
1132
1039
  * For the following model fragment:
1133
1040
  *
1134
- * <$text bold="true" linkHref="url">bar[]</$text><$text bold="true">biz</$text>
1041
+ * ```xml
1042
+ * <$text bold="true" linkHref="url">bar[]</$text><$text bold="true">biz</$text>
1043
+ * ```
1135
1044
  *
1136
1045
  * * Default gravity: selection will have the `bold` and `linkHref` attributes.
1137
1046
  * * Overridden gravity: selection will have `bold` attribute.
@@ -1139,7 +1048,7 @@ export default class Writer {
1139
1048
  * **Note**: It returns an unique identifier which is required to restore the gravity. It guarantees the symmetry
1140
1049
  * of the process.
1141
1050
  *
1142
- * @returns {String} The unique id which allows restoring the gravity.
1051
+ * @returns The unique id which allows restoring the gravity.
1143
1052
  */
1144
1053
  overrideSelectionGravity() {
1145
1054
  return this.model.document.selection._overrideGravity();
@@ -1151,15 +1060,14 @@ export default class Writer {
1151
1060
  * {@link ~Writer#overrideSelectionGravity}. Note that the gravity remains overridden as long as won't be restored
1152
1061
  * the same number of times it was overridden.
1153
1062
  *
1154
- * @param {String} uid The unique id returned by {@link ~Writer#overrideSelectionGravity}.
1063
+ * @param uid The unique id returned by {@link ~Writer#overrideSelectionGravity}.
1155
1064
  */
1156
1065
  restoreSelectionGravity(uid) {
1157
1066
  this.model.document.selection._restoreGravity(uid);
1158
1067
  }
1159
1068
  /**
1160
- * @private
1161
- * @param {String} key Key of the attribute to remove.
1162
- * @param {*} value Attribute value.
1069
+ * @param key Key of the attribute to remove.
1070
+ * @param value Attribute value.
1163
1071
  */
1164
1072
  _setSelectionAttribute(key, value) {
1165
1073
  const selection = this.model.document.selection;
@@ -1171,8 +1079,7 @@ export default class Writer {
1171
1079
  selection._setAttribute(key, value);
1172
1080
  }
1173
1081
  /**
1174
- * @private
1175
- * @param {String} key Key of the attribute to remove.
1082
+ * @param key Key of the attribute to remove.
1176
1083
  */
1177
1084
  _removeSelectionAttribute(key) {
1178
1085
  const selection = this.model.document.selection;
@@ -1185,8 +1092,6 @@ export default class Writer {
1185
1092
  }
1186
1093
  /**
1187
1094
  * Throws `writer-detached-writer-tries-to-modify-model` error when the writer is used outside of the `change()` block.
1188
- *
1189
- * @private
1190
1095
  */
1191
1096
  _assertWriterUsedCorrectly() {
1192
1097
  /**
@@ -1207,10 +1112,8 @@ export default class Writer {
1207
1112
  * and applies a marker operation with the new marker range equal to the current range. Thanks to this, the marker range
1208
1113
  * can be later correctly processed during undo.
1209
1114
  *
1210
- * @private
1211
- * @param {'move'|'merge'} type Writer action type.
1212
- * @param {module:engine/model/position~Position|module:engine/model/range~Range} positionOrRange Position or range
1213
- * where the writer action happens.
1115
+ * @param type Writer action type.
1116
+ * @param positionOrRange Position or range where the writer action happens.
1214
1117
  */
1215
1118
  _addOperationForAffectedMarkers(type, positionOrRange) {
1216
1119
  for (const marker of this.model.markers) {
@@ -1260,18 +1163,14 @@ export default class Writer {
1260
1163
  }
1261
1164
  }
1262
1165
  }
1263
- // Sets given attribute to each node in given range. When attribute value is null then attribute will be removed.
1264
- //
1265
- // Because attribute operation needs to have the same attribute value on the whole range, this function splits
1266
- // the range into smaller parts.
1267
- //
1268
- // Given `range` must be flat.
1269
- //
1270
- // @private
1271
- // @param {module:engine/model/writer~Writer} writer
1272
- // @param {String} key Attribute key.
1273
- // @param {*} value Attribute new value.
1274
- // @param {module:engine/model/range~Range} range Model range on which the attribute will be set.
1166
+ /**
1167
+ * Sets given attribute to each node in given range. When attribute value is null then attribute will be removed.
1168
+ *
1169
+ * Because attribute operation needs to have the same attribute value on the whole range, this function splits
1170
+ * the range into smaller parts.
1171
+ *
1172
+ * Given `range` must be flat.
1173
+ */
1275
1174
  function setAttributeOnRange(writer, key, value, range) {
1276
1175
  const model = writer.model;
1277
1176
  const doc = model.document;
@@ -1311,13 +1210,9 @@ function setAttributeOnRange(writer, key, value, range) {
1311
1210
  model.applyOperation(operation);
1312
1211
  }
1313
1212
  }
1314
- // Sets given attribute to the given node. When attribute value is null then attribute will be removed.
1315
- //
1316
- // @private
1317
- // @param {module:engine/model/writer~Writer} writer
1318
- // @param {String} key Attribute key.
1319
- // @param {*} value Attribute new value.
1320
- // @param {module:engine/model/item~Item} item Model item on which the attribute will be set.
1213
+ /**
1214
+ * Sets given attribute to the given node. When attribute value is null then attribute will be removed.
1215
+ */
1321
1216
  function setAttributeOnItem(writer, key, value, item) {
1322
1217
  const model = writer.model;
1323
1218
  const doc = model.document;
@@ -1339,14 +1234,9 @@ function setAttributeOnItem(writer, key, value, item) {
1339
1234
  model.applyOperation(operation);
1340
1235
  }
1341
1236
  }
1342
- // Creates and applies marker operation to {@link module:engine/model/operation/operation~Operation operation}.
1343
- //
1344
- // @private
1345
- // @param {module:engine/model/writer~Writer} writer
1346
- // @param {String} name Marker name.
1347
- // @param {module:engine/model/range~Range} oldRange Marker range before the change.
1348
- // @param {module:engine/model/range~Range} newRange Marker range after the change.
1349
- // @param {Boolean} affectsData
1237
+ /**
1238
+ * Creates and applies marker operation to {@link module:engine/model/operation/operation~Operation operation}.
1239
+ */
1350
1240
  function applyMarkerOperation(writer, name, oldRange, newRange, affectsData) {
1351
1241
  const model = writer.model;
1352
1242
  const doc = model.document;
@@ -1354,14 +1244,15 @@ function applyMarkerOperation(writer, name, oldRange, newRange, affectsData) {
1354
1244
  writer.batch.addOperation(operation);
1355
1245
  model.applyOperation(operation);
1356
1246
  }
1357
- // Creates `MoveOperation` or `DetachOperation` that removes `howMany` nodes starting from `position`.
1358
- // The operation will be applied on given model instance and added to given operation instance.
1359
- //
1360
- // @private
1361
- // @param {module:engine/model/position~Position} position Position from which nodes are removed.
1362
- // @param {Number} howMany Number of nodes to remove.
1363
- // @param {Batch} batch Batch to which the operation will be added.
1364
- // @param {module:engine/model/model~Model} model Model instance on which operation will be applied.
1247
+ /**
1248
+ * Creates `MoveOperation` or `DetachOperation` that removes `howMany` nodes starting from `position`.
1249
+ * The operation will be applied on given model instance and added to given operation instance.
1250
+ *
1251
+ * @param position Position from which nodes are removed.
1252
+ * @param howMany Number of nodes to remove.
1253
+ * @param batch Batch to which the operation will be added.
1254
+ * @param model Model instance on which operation will be applied.
1255
+ */
1365
1256
  function applyRemoveOperation(position, howMany, batch, model) {
1366
1257
  let operation;
1367
1258
  if (position.root.document) {
@@ -1375,13 +1266,15 @@ function applyRemoveOperation(position, howMany, batch, model) {
1375
1266
  batch.addOperation(operation);
1376
1267
  model.applyOperation(operation);
1377
1268
  }
1378
- // Returns `true` if both root elements are the same element or both are documents root elements.
1379
- //
1380
- // Elements in the same tree can be moved (for instance you can move element form one documents root to another, or
1381
- // within the same document fragment), but when element supposed to be moved from document fragment to the document, or
1382
- // to another document it should be removed and inserted to avoid problems with OT. This is because features like undo or
1383
- // collaboration may track changes on the document but ignore changes on detached fragments and should not get
1384
- // unexpected `move` operation.
1269
+ /**
1270
+ * Returns `true` if both root elements are the same element or both are documents root elements.
1271
+ *
1272
+ * Elements in the same tree can be moved (for instance you can move element form one documents root to another, or
1273
+ * within the same document fragment), but when element supposed to be moved from document fragment to the document, or
1274
+ * to another document it should be removed and inserted to avoid problems with OT. This is because features like undo or
1275
+ * collaboration may track changes on the document but ignore changes on detached fragments and should not get
1276
+ * unexpected `move` operation.
1277
+ */
1385
1278
  function isSameTree(rootA, rootB) {
1386
1279
  // If it is the same root this is the same tree.
1387
1280
  if (rootA === rootB) {