@ckeditor/ckeditor5-engine 35.4.0 → 36.0.1

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