@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
  /**
@@ -10,8 +10,7 @@ import Position from './position';
10
10
  import Range from './range';
11
11
  import Text from './text';
12
12
  import TreeWalker from './treewalker';
13
- import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
14
- import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
13
+ import { CKEditorError, ObservableMixin } from '@ckeditor/ckeditor5-utils';
15
14
  /**
16
15
  * The model's schema. It defines the allowed and disallowed structures of nodes as well as nodes' attributes.
17
16
  * The schema is usually defined by the features and based on them, the editing framework and features
@@ -23,11 +22,9 @@ import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
23
22
  *
24
23
  * * The {@glink framework/guides/architecture/editing-engine#schema schema section} of the
25
24
  * {@glink framework/guides/architecture/editing-engine Introduction to the Editing engine architecture} guide.
26
- * * The {@glink framework/guides/deep-dive/schema Schema deep dive} guide.
27
- *
28
- * @mixes module:utils/observablemixin~ObservableMixin
25
+ * * The {@glink framework/guides/deep-dive/schema Schema deep-dive guide}.
29
26
  */
30
- export default class Schema extends Observable {
27
+ export default class Schema extends ObservableMixin() {
31
28
  /**
32
29
  * Creates a schema instance.
33
30
  */
@@ -36,9 +33,6 @@ export default class Schema extends Observable {
36
33
  this._sourceDefinitions = {};
37
34
  /**
38
35
  * A dictionary containing attribute properties.
39
- *
40
- * @private
41
- * @member {Object.<String,AttributeProperties>}
42
36
  */
43
37
  this._attributeProperties = {};
44
38
  this.decorate('checkChild');
@@ -54,12 +48,11 @@ export default class Schema extends Observable {
54
48
  /**
55
49
  * Registers a schema item. Can only be called once for every item name.
56
50
  *
57
- * schema.register( 'paragraph', {
58
- * inheritAllFrom: '$block'
59
- * } );
60
- *
61
- * @param {String} itemName
62
- * @param {module:engine/model/schema~SchemaItemDefinition} definition
51
+ * ```ts
52
+ * schema.register( 'paragraph', {
53
+ * inheritAllFrom: '$block'
54
+ * } );
55
+ * ```
63
56
  */
64
57
  register(itemName, definition) {
65
58
  if (this._sourceDefinitions[itemName]) {
@@ -97,23 +90,22 @@ export default class Schema extends Observable {
97
90
  * Extending properties such as `allowIn` will add more items to the existing properties,
98
91
  * while redefining properties such as `isBlock` will override the previously defined ones.
99
92
  *
100
- * schema.register( 'foo', {
101
- * allowIn: '$root',
102
- * isBlock: true;
103
- * } );
104
- * schema.extend( 'foo', {
105
- * allowIn: 'blockQuote',
106
- * isBlock: false
107
- * } );
108
- *
109
- * schema.getDefinition( 'foo' );
110
- * // {
111
- * // allowIn: [ '$root', 'blockQuote' ],
112
- * // isBlock: false
113
- * // }
114
- *
115
- * @param {String} itemName
116
- * @param {module:engine/model/schema~SchemaItemDefinition} definition
93
+ * ```ts
94
+ * schema.register( 'foo', {
95
+ * allowIn: '$root',
96
+ * isBlock: true;
97
+ * } );
98
+ * schema.extend( 'foo', {
99
+ * allowIn: 'blockQuote',
100
+ * isBlock: false
101
+ * } );
102
+ *
103
+ * schema.getDefinition( 'foo' );
104
+ * // {
105
+ * // allowIn: [ '$root', 'blockQuote' ],
106
+ * // isBlock: false
107
+ * // }
108
+ * ```
117
109
  */
118
110
  extend(itemName, definition) {
119
111
  if (!this._sourceDefinitions[itemName]) {
@@ -140,8 +132,6 @@ export default class Schema extends Observable {
140
132
  * checking a list of all block elements, etc).
141
133
  * Use specific methods (such as {@link #checkChild `checkChild()`} or {@link #isLimit `isLimit()`})
142
134
  * in other cases.
143
- *
144
- * @returns {Object.<String,module:engine/model/schema~SchemaCompiledItemDefinition>}
145
135
  */
146
136
  getDefinitions() {
147
137
  if (!this._compiledDefinitions) {
@@ -156,9 +146,6 @@ export default class Schema extends Observable {
156
146
  * checking a list of all block elements, etc).
157
147
  * Use specific methods (such as {@link #checkChild `checkChild()`} or {@link #isLimit `isLimit()`})
158
148
  * in other cases.
159
- *
160
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
161
- * @returns {module:engine/model/schema~SchemaCompiledItemDefinition}
162
149
  */
163
150
  getDefinition(item) {
164
151
  let itemName;
@@ -177,12 +164,11 @@ export default class Schema extends Observable {
177
164
  /**
178
165
  * Returns `true` if the given item is registered in the schema.
179
166
  *
180
- * schema.isRegistered( 'paragraph' ); // -> true
181
- * schema.isRegistered( editor.model.document.getRoot() ); // -> true
182
- * schema.isRegistered( 'foo' ); // -> false
183
- *
184
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
185
- * @returns {Boolean}
167
+ * ```ts
168
+ * schema.isRegistered( 'paragraph' ); // -> true
169
+ * schema.isRegistered( editor.model.document.getRoot() ); // -> true
170
+ * schema.isRegistered( 'foo' ); // -> false
171
+ * ```
186
172
  */
187
173
  isRegistered(item) {
188
174
  return !!this.getDefinition(item);
@@ -191,17 +177,16 @@ export default class Schema extends Observable {
191
177
  * Returns `true` if the given item is defined to be
192
178
  * a block by the {@link module:engine/model/schema~SchemaItemDefinition}'s `isBlock` property.
193
179
  *
194
- * schema.isBlock( 'paragraph' ); // -> true
195
- * schema.isBlock( '$root' ); // -> false
180
+ * ```ts
181
+ * schema.isBlock( 'paragraph' ); // -> true
182
+ * schema.isBlock( '$root' ); // -> false
196
183
  *
197
- * const paragraphElement = writer.createElement( 'paragraph' );
198
- * schema.isBlock( paragraphElement ); // -> true
184
+ * const paragraphElement = writer.createElement( 'paragraph' );
185
+ * schema.isBlock( paragraphElement ); // -> true
186
+ * ```
199
187
  *
200
188
  * See the {@glink framework/guides/deep-dive/schema#block-elements Block elements} section of
201
- * the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
202
- *
203
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
204
- * @returns {Boolean}
189
+ * the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
205
190
  */
206
191
  isBlock(item) {
207
192
  const def = this.getDefinition(item);
@@ -216,16 +201,15 @@ export default class Schema extends Observable {
216
201
  * {@link module:engine/model/schema~SchemaItemDefinition#isObject `isObject`} property
217
202
  * was set to `true`.
218
203
  *
219
- * schema.isLimit( 'paragraph' ); // -> false
220
- * schema.isLimit( '$root' ); // -> true
221
- * schema.isLimit( editor.model.document.getRoot() ); // -> true
222
- * schema.isLimit( 'imageBlock' ); // -> true
204
+ * ```ts
205
+ * schema.isLimit( 'paragraph' ); // -> false
206
+ * schema.isLimit( '$root' ); // -> true
207
+ * schema.isLimit( editor.model.document.getRoot() ); // -> true
208
+ * schema.isLimit( 'imageBlock' ); // -> true
209
+ * ```
223
210
  *
224
211
  * See the {@glink framework/guides/deep-dive/schema#limit-elements Limit elements} section of
225
- * the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
226
- *
227
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
228
- * @returns {Boolean}
212
+ * the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
229
213
  */
230
214
  isLimit(item) {
231
215
  const def = this.getDefinition(item);
@@ -242,17 +226,16 @@ export default class Schema extends Observable {
242
226
  * {@link module:engine/model/schema~SchemaItemDefinition#isObject `isObject`} property
243
227
  * was set to `true`.
244
228
  *
245
- * schema.isObject( 'paragraph' ); // -> false
246
- * schema.isObject( 'imageBlock' ); // -> true
229
+ * ```ts
230
+ * schema.isObject( 'paragraph' ); // -> false
231
+ * schema.isObject( 'imageBlock' ); // -> true
247
232
  *
248
- * const imageElement = writer.createElement( 'imageBlock' );
249
- * schema.isObject( imageElement ); // -> true
233
+ * const imageElement = writer.createElement( 'imageBlock' );
234
+ * schema.isObject( imageElement ); // -> true
235
+ * ```
250
236
  *
251
237
  * See the {@glink framework/guides/deep-dive/schema#object-elements Object elements} section of
252
- * the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
253
- *
254
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
255
- * @returns {Boolean}
238
+ * the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
256
239
  */
257
240
  isObject(item) {
258
241
  const def = this.getDefinition(item);
@@ -267,17 +250,16 @@ export default class Schema extends Observable {
267
250
  * Returns `true` if the given item is defined to be
268
251
  * an inline element by the {@link module:engine/model/schema~SchemaItemDefinition}'s `isInline` property.
269
252
  *
270
- * schema.isInline( 'paragraph' ); // -> false
271
- * schema.isInline( 'softBreak' ); // -> true
253
+ * ```ts
254
+ * schema.isInline( 'paragraph' ); // -> false
255
+ * schema.isInline( 'softBreak' ); // -> true
272
256
  *
273
- * const text = writer.createText( 'foo' );
274
- * schema.isInline( text ); // -> true
257
+ * const text = writer.createText( 'foo' );
258
+ * schema.isInline( text ); // -> true
259
+ * ```
275
260
  *
276
261
  * See the {@glink framework/guides/deep-dive/schema#inline-elements Inline elements} section of
277
- * the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
278
- *
279
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
280
- * @returns {Boolean}
262
+ * the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
281
263
  */
282
264
  isInline(item) {
283
265
  const def = this.getDefinition(item);
@@ -287,19 +269,18 @@ export default class Schema extends Observable {
287
269
  * Returns `true` if the given item is defined to be
288
270
  * a selectable element by the {@link module:engine/model/schema~SchemaItemDefinition}'s `isSelectable` property.
289
271
  *
290
- * schema.isSelectable( 'paragraph' ); // -> false
291
- * schema.isSelectable( 'heading1' ); // -> false
292
- * schema.isSelectable( 'imageBlock' ); // -> true
293
- * schema.isSelectable( 'tableCell' ); // -> true
272
+ * ```ts
273
+ * schema.isSelectable( 'paragraph' ); // -> false
274
+ * schema.isSelectable( 'heading1' ); // -> false
275
+ * schema.isSelectable( 'imageBlock' ); // -> true
276
+ * schema.isSelectable( 'tableCell' ); // -> true
294
277
  *
295
- * const text = writer.createText( 'foo' );
296
- * schema.isSelectable( text ); // -> false
278
+ * const text = writer.createText( 'foo' );
279
+ * schema.isSelectable( text ); // -> false
280
+ * ```
297
281
  *
298
282
  * See the {@glink framework/guides/deep-dive/schema#selectable-elements Selectable elements section} of
299
- * the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
300
- *
301
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
302
- * @returns {Boolean}
283
+ * the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
303
284
  */
304
285
  isSelectable(item) {
305
286
  const def = this.getDefinition(item);
@@ -312,19 +293,18 @@ export default class Schema extends Observable {
312
293
  * Returns `true` if the given item is defined to be
313
294
  * a content by the {@link module:engine/model/schema~SchemaItemDefinition}'s `isContent` property.
314
295
  *
315
- * schema.isContent( 'paragraph' ); // -> false
316
- * schema.isContent( 'heading1' ); // -> false
317
- * schema.isContent( 'imageBlock' ); // -> true
318
- * schema.isContent( 'horizontalLine' ); // -> true
296
+ * ```ts
297
+ * schema.isContent( 'paragraph' ); // -> false
298
+ * schema.isContent( 'heading1' ); // -> false
299
+ * schema.isContent( 'imageBlock' ); // -> true
300
+ * schema.isContent( 'horizontalLine' ); // -> true
319
301
  *
320
- * const text = writer.createText( 'foo' );
321
- * schema.isContent( text ); // -> true
302
+ * const text = writer.createText( 'foo' );
303
+ * schema.isContent( text ); // -> true
304
+ * ```
322
305
  *
323
306
  * See the {@glink framework/guides/deep-dive/schema#content-elements Content elements section} of
324
- * the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
325
- *
326
- * @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
327
- * @returns {Boolean}
307
+ * the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
328
308
  */
329
309
  isContent(item) {
330
310
  const def = this.getDefinition(item);
@@ -336,12 +316,14 @@ export default class Schema extends Observable {
336
316
  /**
337
317
  * Checks whether the given node (`child`) can be a child of the given context.
338
318
  *
339
- * schema.checkChild( model.document.getRoot(), paragraph ); // -> false
319
+ * ```ts
320
+ * schema.checkChild( model.document.getRoot(), paragraph ); // -> false
340
321
  *
341
- * schema.register( 'paragraph', {
342
- * allowIn: '$root'
343
- * } );
344
- * schema.checkChild( model.document.getRoot(), paragraph ); // -> true
322
+ * schema.register( 'paragraph', {
323
+ * allowIn: '$root'
324
+ * } );
325
+ * schema.checkChild( model.document.getRoot(), paragraph ); // -> true
326
+ * ```
345
327
  *
346
328
  * Note: When verifying whether the given node can be a child of the given context, the
347
329
  * schema also verifies the entire context &mdash; from its root to its last element. Therefore, it is possible
@@ -349,9 +331,8 @@ export default class Schema extends Observable {
349
331
  * It happens if one of the context's elements does not allow its child.
350
332
  *
351
333
  * @fires checkChild
352
- * @param {module:engine/model/schema~SchemaContextDefinition} context The context in which the child will be checked.
353
- * @param {module:engine/model/node~Node|String} def The child to check.
354
- * @returns {Boolean}
334
+ * @param context The context in which the child will be checked.
335
+ * @param def The child to check.
355
336
  */
356
337
  checkChild(context, def) {
357
338
  // Note: context and child are already normalized here to a SchemaContext and SchemaCompiledItemDefinition.
@@ -364,17 +345,17 @@ export default class Schema extends Observable {
364
345
  * Checks whether the given attribute can be applied in the given context (on the last
365
346
  * item of the context).
366
347
  *
367
- * schema.checkAttribute( textNode, 'bold' ); // -> false
348
+ * ```ts
349
+ * schema.checkAttribute( textNode, 'bold' ); // -> false
368
350
  *
369
- * schema.extend( '$text', {
370
- * allowAttributes: 'bold'
371
- * } );
372
- * schema.checkAttribute( textNode, 'bold' ); // -> true
351
+ * schema.extend( '$text', {
352
+ * allowAttributes: 'bold'
353
+ * } );
354
+ * schema.checkAttribute( textNode, 'bold' ); // -> true
355
+ * ```
373
356
  *
374
357
  * @fires checkAttribute
375
- * @param {module:engine/model/schema~SchemaContextDefinition} context The context in which the attribute will be checked.
376
- * @param {String} attributeName
377
- * @returns {Boolean}
358
+ * @param context The context in which the attribute will be checked.
378
359
  */
379
360
  checkAttribute(context, attributeName) {
380
361
  const def = this.getDefinition(context.last);
@@ -394,10 +375,8 @@ export default class Schema extends Observable {
394
375
  * Instead of elements, you can pass the instance of the {@link module:engine/model/position~Position} class as the
395
376
  * `positionOrBaseElement`. It means that the elements before and after the position will be checked whether they can be merged.
396
377
  *
397
- * @param {module:engine/model/position~Position|module:engine/model/element~Element} positionOrBaseElement The position or base
398
- * element to which the `elementToMerge` will be merged.
399
- * @param {module:engine/model/element~Element} elementToMerge The element to merge. Required if `positionOrBaseElement` is an element.
400
- * @returns {Boolean}
378
+ * @param positionOrBaseElement The position or base element to which the `elementToMerge` will be merged.
379
+ * @param elementToMerge The element to merge. Required if `positionOrBaseElement` is an element.
401
380
  */
402
381
  checkMerge(positionOrBaseElement, elementToMerge) {
403
382
  if (positionOrBaseElement instanceof Position) {
@@ -440,28 +419,32 @@ export default class Schema extends Observable {
440
419
  *
441
420
  * Example:
442
421
  *
443
- * // Disallow heading1 directly inside a blockQuote.
444
- * schema.addChildCheck( ( context, childDefinition ) => {
445
- * if ( context.endsWith( 'blockQuote' ) && childDefinition.name == 'heading1' ) {
446
- * return false;
447
- * }
448
- * } );
422
+ * ```ts
423
+ * // Disallow heading1 directly inside a blockQuote.
424
+ * schema.addChildCheck( ( context, childDefinition ) => {
425
+ * if ( context.endsWith( 'blockQuote' ) && childDefinition.name == 'heading1' ) {
426
+ * return false;
427
+ * }
428
+ * } );
429
+ * ```
449
430
  *
450
431
  * Which translates to:
451
432
  *
452
- * schema.on( 'checkChild', ( evt, args ) => {
453
- * const context = args[ 0 ];
454
- * const childDefinition = args[ 1 ];
455
- *
456
- * if ( context.endsWith( 'blockQuote' ) && childDefinition && childDefinition.name == 'heading1' ) {
457
- * // Prevent next listeners from being called.
458
- * evt.stop();
459
- * // Set the checkChild()'s return value.
460
- * evt.return = false;
461
- * }
462
- * }, { priority: 'high' } );
463
- *
464
- * @param {Function} callback The callback to be called. It is called with two parameters:
433
+ * ```ts
434
+ * schema.on( 'checkChild', ( evt, args ) => {
435
+ * const context = args[ 0 ];
436
+ * const childDefinition = args[ 1 ];
437
+ *
438
+ * if ( context.endsWith( 'blockQuote' ) && childDefinition && childDefinition.name == 'heading1' ) {
439
+ * // Prevent next listeners from being called.
440
+ * evt.stop();
441
+ * // Set the checkChild()'s return value.
442
+ * evt.return = false;
443
+ * }
444
+ * }, { priority: 'high' } );
445
+ * ```
446
+ *
447
+ * @param callback The callback to be called. It is called with two parameters:
465
448
  * {@link module:engine/model/schema~SchemaContext} (context) instance and
466
449
  * {@link module:engine/model/schema~SchemaCompiledItemDefinition} (child-to-check definition).
467
450
  * The callback may return `true/false` to override `checkChild()`'s return value. If it does not return
@@ -495,28 +478,32 @@ export default class Schema extends Observable {
495
478
  *
496
479
  * Example:
497
480
  *
498
- * // Disallow bold on $text inside heading1.
499
- * schema.addAttributeCheck( ( context, attributeName ) => {
500
- * if ( context.endsWith( 'heading1 $text' ) && attributeName == 'bold' ) {
501
- * return false;
502
- * }
503
- * } );
481
+ * ```ts
482
+ * // Disallow bold on $text inside heading1.
483
+ * schema.addAttributeCheck( ( context, attributeName ) => {
484
+ * if ( context.endsWith( 'heading1 $text' ) && attributeName == 'bold' ) {
485
+ * return false;
486
+ * }
487
+ * } );
488
+ * ```
504
489
  *
505
490
  * Which translates to:
506
491
  *
507
- * schema.on( 'checkAttribute', ( evt, args ) => {
508
- * const context = args[ 0 ];
509
- * const attributeName = args[ 1 ];
510
- *
511
- * if ( context.endsWith( 'heading1 $text' ) && attributeName == 'bold' ) {
512
- * // Prevent next listeners from being called.
513
- * evt.stop();
514
- * // Set the checkAttribute()'s return value.
515
- * evt.return = false;
516
- * }
517
- * }, { priority: 'high' } );
518
- *
519
- * @param {Function} callback The callback to be called. It is called with two parameters:
492
+ * ```ts
493
+ * schema.on( 'checkAttribute', ( evt, args ) => {
494
+ * const context = args[ 0 ];
495
+ * const attributeName = args[ 1 ];
496
+ *
497
+ * if ( context.endsWith( 'heading1 $text' ) && attributeName == 'bold' ) {
498
+ * // Prevent next listeners from being called.
499
+ * evt.stop();
500
+ * // Set the checkAttribute()'s return value.
501
+ * evt.return = false;
502
+ * }
503
+ * }, { priority: 'high' } );
504
+ * ```
505
+ *
506
+ * @param callback The callback to be called. It is called with two parameters:
520
507
  * {@link module:engine/model/schema~SchemaContext} (context) instance and attribute name.
521
508
  * The callback may return `true/false` to override `checkAttribute()`'s return value. If it does not return
522
509
  * a boolean value, the default algorithm (or other callbacks) will define `checkAttribute()`'s return value.
@@ -535,38 +522,44 @@ export default class Schema extends Observable {
535
522
  * {@link module:engine/model/schema~AttributeProperties `AttributeProperties#isFormatting` property} is
536
523
  * used to mark formatting attributes (like `bold` or `italic`).
537
524
  *
538
- * // Mark bold as a formatting attribute.
539
- * schema.setAttributeProperties( 'bold', {
540
- * isFormatting: true
541
- * } );
525
+ * ```ts
526
+ * // Mark bold as a formatting attribute.
527
+ * schema.setAttributeProperties( 'bold', {
528
+ * isFormatting: true
529
+ * } );
542
530
  *
543
- * // Override code not to be considered a formatting markup.
544
- * schema.setAttributeProperties( 'code', {
545
- * isFormatting: false
546
- * } );
531
+ * // Override code not to be considered a formatting markup.
532
+ * schema.setAttributeProperties( 'code', {
533
+ * isFormatting: false
534
+ * } );
535
+ * ```
547
536
  *
548
537
  * Properties are not limited to members defined in the
549
538
  * {@link module:engine/model/schema~AttributeProperties `AttributeProperties` type} and you can also use custom properties:
550
539
  *
551
- * schema.setAttributeProperties( 'blockQuote', {
552
- * customProperty: 'value'
553
- * } );
540
+ * ```ts
541
+ * schema.setAttributeProperties( 'blockQuote', {
542
+ * customProperty: 'value'
543
+ * } );
544
+ * ```
554
545
  *
555
546
  * Subsequent calls with the same attribute will extend its custom properties:
556
547
  *
557
- * schema.setAttributeProperties( 'blockQuote', {
558
- * one: 1
559
- * } );
548
+ * ```ts
549
+ * schema.setAttributeProperties( 'blockQuote', {
550
+ * one: 1
551
+ * } );
560
552
  *
561
- * schema.setAttributeProperties( 'blockQuote', {
562
- * two: 2
563
- * } );
553
+ * schema.setAttributeProperties( 'blockQuote', {
554
+ * two: 2
555
+ * } );
564
556
  *
565
- * console.log( schema.getAttributeProperties( 'blockQuote' ) );
566
- * // Logs: { one: 1, two: 2 }
557
+ * console.log( schema.getAttributeProperties( 'blockQuote' ) );
558
+ * // Logs: { one: 1, two: 2 }
559
+ * ```
567
560
  *
568
- * @param {String} attributeName A name of the attribute to receive the properties.
569
- * @param {module:engine/model/schema~AttributeProperties} properties A dictionary of properties.
561
+ * @param attributeName A name of the attribute to receive the properties.
562
+ * @param properties A dictionary of properties.
570
563
  */
571
564
  setAttributeProperties(attributeName, properties) {
572
565
  this._attributeProperties[attributeName] = Object.assign(this.getAttributeProperties(attributeName), properties);
@@ -574,8 +567,7 @@ export default class Schema extends Observable {
574
567
  /**
575
568
  * Returns properties associated with a given model attribute. See {@link #setAttributeProperties `setAttributeProperties()`}.
576
569
  *
577
- * @param {String} attributeName A name of the attribute.
578
- * @returns {module:engine/model/schema~AttributeProperties}
570
+ * @param attributeName A name of the attribute.
579
571
  */
580
572
  getAttributeProperties(attributeName) {
581
573
  return this._attributeProperties[attributeName] || {};
@@ -584,11 +576,8 @@ export default class Schema extends Observable {
584
576
  * Returns the lowest {@link module:engine/model/schema~Schema#isLimit limit element} containing the entire
585
577
  * selection/range/position or the root otherwise.
586
578
  *
587
- * @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection|
588
- * module:engine/model/range~Range|module:engine/model/position~Position} selectionOrRangeOrPosition
589
- * The selection/range/position to check.
590
- * @returns {module:engine/model/element~Element} The lowest limit element containing
591
- * the entire `selectionOrRangeOrPosition`.
579
+ * @param selectionOrRangeOrPosition The selection/range/position to check.
580
+ * @returns The lowest limit element containing the entire `selectionOrRangeOrPosition`.
592
581
  */
593
582
  getLimitElement(selectionOrRangeOrPosition) {
594
583
  let element;
@@ -626,10 +615,8 @@ export default class Schema extends Observable {
626
615
  * * if the selection is collapsed, then checks if on the selection position there's a text with the
627
616
  * specified attribute allowed.
628
617
  *
629
- * @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection} selection
630
- * Selection which will be checked.
631
- * @param {String} attribute The name of the attribute to check.
632
- * @returns {Boolean}
618
+ * @param selection Selection which will be checked.
619
+ * @param attribute The name of the attribute to check.
633
620
  */
634
621
  checkAttributeInSelection(selection, attribute) {
635
622
  if (selection.isCollapsed) {
@@ -659,9 +646,9 @@ export default class Schema extends Observable {
659
646
  /**
660
647
  * Transforms the given set of ranges into a set of ranges where the given attribute is allowed (and can be applied).
661
648
  *
662
- * @param {Iterable.<module:engine/model/range~Range>} ranges Ranges to be validated.
663
- * @param {String} attribute The name of the attribute to check.
664
- * @returns {Iterable.<module:engine/model/range~Range>} Ranges in which the attribute is allowed.
649
+ * @param ranges Ranges to be validated.
650
+ * @param attribute The name of the attribute to check.
651
+ * @returns Ranges in which the attribute is allowed.
665
652
  */
666
653
  *getValidRanges(ranges, attribute) {
667
654
  ranges = convertToMinimalFlatRanges(ranges);
@@ -685,9 +672,9 @@ export default class Schema extends Observable {
685
672
  *
686
673
  * When valid selection range cannot be found, `null` is returned.
687
674
  *
688
- * @param {module:engine/model/position~Position} position Reference position where new selection range should be looked for.
689
- * @param {'both'|'forward'|'backward'} [direction='both'] Search direction.
690
- * @returns {module:engine/model/range~Range|null} Nearest selection range or `null` if one cannot be found.
675
+ * @param position Reference position where new selection range should be looked for.
676
+ * @param direction Search direction.
677
+ * @returns Nearest selection range or `null` if one cannot be found.
691
678
  */
692
679
  getNearestSelectionRange(position, direction = 'both') {
693
680
  // Return collapsed range if provided position is valid.
@@ -729,9 +716,9 @@ export default class Schema extends Observable {
729
716
  * as long as a {@link module:engine/model/schema~Schema#isLimit limit element}, an
730
717
  * {@link module:engine/model/schema~Schema#isObject object element} or a topmost ancestor is not reached.
731
718
  *
732
- * @param {module:engine/model/position~Position} position The position that the search will start from.
733
- * @param {module:engine/model/node~Node|String} node The node for which an allowed parent should be found or its name.
734
- * @returns {module:engine/model/element~Element|null} element Allowed parent or null if nothing was found.
719
+ * @param position The position that the search will start from.
720
+ * @param node The node for which an allowed parent should be found or its name.
721
+ * @returns Allowed parent or null if nothing was found.
735
722
  */
736
723
  findAllowedParent(position, node) {
737
724
  let parent = position.parent;
@@ -750,9 +737,9 @@ export default class Schema extends Observable {
750
737
  /**
751
738
  * Sets attributes allowed by the schema on a given node.
752
739
  *
753
- * @param {module:engine/model/node~Node} node A node to set attributes on.
754
- * @param {Object} attributes Attributes keys and values.
755
- * @param {module:engine/model/writer~Writer} writer An instance of the model writer.
740
+ * @param node A node to set attributes on.
741
+ * @param attributes Attributes keys and values.
742
+ * @param writer An instance of the model writer.
756
743
  */
757
744
  setAllowedAttributes(node, attributes, writer) {
758
745
  const model = writer.model;
@@ -765,8 +752,7 @@ export default class Schema extends Observable {
765
752
  /**
766
753
  * Removes attributes disallowed by the schema.
767
754
  *
768
- * @param {Iterable.<module:engine/model/node~Node>} nodes Nodes that will be filtered.
769
- * @param {module:engine/model/writer~Writer} writer
755
+ * @param nodes Nodes that will be filtered.
770
756
  */
771
757
  removeDisallowedAttributes(nodes, writer) {
772
758
  for (const node of nodes) {
@@ -791,12 +777,12 @@ export default class Schema extends Observable {
791
777
  /**
792
778
  * Gets attributes of a node that have a given property.
793
779
  *
794
- * @param {module:engine/model/node~Node} node Node to get attributes from.
795
- * @param {String} propertyName Name of the property that attribute must have to return it.
796
- * @param {Boolean|Symbol|String|Number|Object|null|undefined} propertyValue Desired value of the property that we want to check.
780
+ * @param node Node to get attributes from.
781
+ * @param propertyName Name of the property that attribute must have to return it.
782
+ * @param propertyValue Desired value of the property that we want to check.
797
783
  * When `undefined` attributes will be returned if they have set a given property no matter what the value is. If specified it will
798
784
  * return attributes which given property's value is equal to this parameter.
799
- * @returns {Object} Object with attributes' names as key and attributes' values as value.
785
+ * @returns Object with attributes' names as key and attributes' values as value.
800
786
  */
801
787
  getAttributesWithProperty(node, propertyName, propertyValue) {
802
788
  const attributes = {};
@@ -813,22 +799,13 @@ export default class Schema extends Observable {
813
799
  }
814
800
  /**
815
801
  * Creates an instance of the schema context.
816
- *
817
- * @param {module:engine/model/schema~SchemaContextDefinition} context
818
- * @returns {module:engine/model/schema~SchemaContext}
819
802
  */
820
803
  createContext(context) {
821
804
  return new SchemaContext(context);
822
805
  }
823
- /**
824
- * @private
825
- */
826
806
  _clearCache() {
827
807
  this._compiledDefinitions = null;
828
808
  }
829
- /**
830
- * @private
831
- */
832
809
  _compile() {
833
810
  const compiledDefinitions = {};
834
811
  const sourceRules = this._sourceDefinitions;
@@ -856,12 +833,6 @@ export default class Schema extends Observable {
856
833
  }
857
834
  this._compiledDefinitions = compiledDefinitions;
858
835
  }
859
- /**
860
- * @private
861
- * @param {module:engine/model/schema~SchemaCompiledItemDefinition} def
862
- * @param {module:engine/model/schema~SchemaContext} context
863
- * @param {Number} contextItemIndex
864
- */
865
836
  _checkContextMatch(def, context, contextItemIndex = context.length - 1) {
866
837
  const contextItem = context.getItem(contextItemIndex);
867
838
  if (def.allowIn.includes(contextItem.name)) {
@@ -883,10 +854,9 @@ export default class Schema extends Observable {
883
854
  *
884
855
  * This is a helper function for {@link ~Schema#getValidRanges}.
885
856
  *
886
- * @private
887
- * @param {module:engine/model/range~Range} range The range to process.
888
- * @param {String} attribute The name of the attribute to check.
889
- * @returns {Iterable.<module:engine/model/range~Range>} Ranges in which the attribute is allowed.
857
+ * @param range The range to process.
858
+ * @param attribute The name of the attribute to check.
859
+ * @returns Ranges in which the attribute is allowed.
890
860
  */
891
861
  *_getValidRangesForRange(range, attribute) {
892
862
  let start = range.start;
@@ -913,13 +883,15 @@ export default class Schema extends Observable {
913
883
  *
914
884
  * Considering such position:
915
885
  *
916
- * <$root>
917
- * <blockQuote>
918
- * <paragraph>
919
- * ^
920
- * </paragraph>
921
- * </blockQuote>
922
- * </$root>
886
+ * ```xml
887
+ * <$root>
888
+ * <blockQuote>
889
+ * <paragraph>
890
+ * ^
891
+ * </paragraph>
892
+ * </blockQuote>
893
+ * </$root>
894
+ * ```
923
895
  *
924
896
  * The context of this position is its {@link module:engine/model/position~Position#getAncestors lists of ancestors}:
925
897
  *
@@ -935,8 +907,6 @@ export default class Schema extends Observable {
935
907
  export class SchemaContext {
936
908
  /**
937
909
  * Creates an instance of the context.
938
- *
939
- * @param {module:engine/model/schema~SchemaContextDefinition} context
940
910
  */
941
911
  constructor(context) {
942
912
  if (context instanceof SchemaContext) {
@@ -958,16 +928,12 @@ export class SchemaContext {
958
928
  }
959
929
  /**
960
930
  * The number of items.
961
- *
962
- * @type {Number}
963
931
  */
964
932
  get length() {
965
933
  return this._items.length;
966
934
  }
967
935
  /**
968
936
  * The last item (the lowest node).
969
- *
970
- * @type {module:engine/model/schema~SchemaContextItem}
971
937
  */
972
938
  get last() {
973
939
  return this._items[this._items.length - 1];
@@ -976,8 +942,6 @@ export class SchemaContext {
976
942
  * Iterable interface.
977
943
  *
978
944
  * Iterates over all context items.
979
- *
980
- * @returns {Iterable.<module:engine/model/schema~SchemaContextItem>}
981
945
  */
982
946
  [Symbol.iterator]() {
983
947
  return this._items[Symbol.iterator]();
@@ -987,25 +951,26 @@ export class SchemaContext {
987
951
  *
988
952
  * Item can be added as:
989
953
  *
990
- * const context = new SchemaContext( [ '$root' ] );
954
+ * ```ts
955
+ * const context = new SchemaContext( [ '$root' ] );
991
956
  *
992
- * // An element.
993
- * const fooElement = writer.createElement( 'fooElement' );
994
- * const newContext = context.push( fooElement ); // [ '$root', 'fooElement' ]
957
+ * // An element.
958
+ * const fooElement = writer.createElement( 'fooElement' );
959
+ * const newContext = context.push( fooElement ); // [ '$root', 'fooElement' ]
995
960
  *
996
- * // A text node.
997
- * const text = writer.createText( 'foobar' );
998
- * const newContext = context.push( text ); // [ '$root', '$text' ]
961
+ * // A text node.
962
+ * const text = writer.createText( 'foobar' );
963
+ * const newContext = context.push( text ); // [ '$root', '$text' ]
999
964
  *
1000
- * // A string (element name).
1001
- * const newContext = context.push( 'barElement' ); // [ '$root', 'barElement' ]
965
+ * // A string (element name).
966
+ * const newContext = context.push( 'barElement' ); // [ '$root', 'barElement' ]
967
+ * ```
1002
968
  *
1003
969
  * **Note** {@link module:engine/model/node~Node} that is already in the model tree will be added as the only item
1004
970
  * (without ancestors).
1005
971
  *
1006
- * @param {String|module:engine/model/node~Node} item An item that will be added
1007
- * to the current context.
1008
- * @returns {module:engine/model/schema~SchemaContext} A new schema context instance with an additional item.
972
+ * @param item An item that will be added to the current context.
973
+ * @returns A new schema context instance with an additional item.
1009
974
  */
1010
975
  push(item) {
1011
976
  const ctx = new SchemaContext([item]);
@@ -1014,16 +979,12 @@ export class SchemaContext {
1014
979
  }
1015
980
  /**
1016
981
  * Gets an item on the given index.
1017
- *
1018
- * @returns {module:engine/model/schema~SchemaContextItem}
1019
982
  */
1020
983
  getItem(index) {
1021
984
  return this._items[index];
1022
985
  }
1023
986
  /**
1024
987
  * Returns the names of items.
1025
- *
1026
- * @returns {Iterable.<String>}
1027
988
  */
1028
989
  *getNames() {
1029
990
  yield* this._items.map(item => item.name);
@@ -1031,15 +992,14 @@ export class SchemaContext {
1031
992
  /**
1032
993
  * Checks whether the context ends with the given nodes.
1033
994
  *
1034
- * const ctx = new SchemaContext( [ rootElement, paragraphElement, textNode ] );
1035
- *
1036
- * ctx.endsWith( '$text' ); // -> true
1037
- * ctx.endsWith( 'paragraph $text' ); // -> true
1038
- * ctx.endsWith( '$root' ); // -> false
1039
- * ctx.endsWith( 'paragraph' ); // -> false
995
+ * ```ts
996
+ * const ctx = new SchemaContext( [ rootElement, paragraphElement, textNode ] );
1040
997
  *
1041
- * @param {String} query
1042
- * @returns {Boolean}
998
+ * ctx.endsWith( '$text' ); // -> true
999
+ * ctx.endsWith( 'paragraph $text' ); // -> true
1000
+ * ctx.endsWith( '$root' ); // -> false
1001
+ * ctx.endsWith( 'paragraph' ); // -> false
1002
+ * ```
1043
1003
  */
1044
1004
  endsWith(query) {
1045
1005
  return Array.from(this.getNames()).join(' ').endsWith(query);
@@ -1047,15 +1007,14 @@ export class SchemaContext {
1047
1007
  /**
1048
1008
  * Checks whether the context starts with the given nodes.
1049
1009
  *
1050
- * const ctx = new SchemaContext( [ rootElement, paragraphElement, textNode ] );
1051
- *
1052
- * ctx.endsWith( '$root' ); // -> true
1053
- * ctx.endsWith( '$root paragraph' ); // -> true
1054
- * ctx.endsWith( '$text' ); // -> false
1055
- * ctx.endsWith( 'paragraph' ); // -> false
1010
+ * ```ts
1011
+ * const ctx = new SchemaContext( [ rootElement, paragraphElement, textNode ] );
1056
1012
  *
1057
- * @param {String} query
1058
- * @returns {Boolean}
1013
+ * ctx.endsWith( '$root' ); // -> true
1014
+ * ctx.endsWith( '$root paragraph' ); // -> true
1015
+ * ctx.endsWith( '$text' ); // -> false
1016
+ * ctx.endsWith( 'paragraph' ); // -> false
1017
+ * ```
1059
1018
  */
1060
1019
  startsWith(query) {
1061
1020
  return Array.from(this.getNames()).join(' ').startsWith(query);
@@ -1222,13 +1181,15 @@ function mapContextItem(ctxItem) {
1222
1181
  };
1223
1182
  }
1224
1183
  }
1225
- // Generator function returning values from provided walkers, switching between them at each iteration. If only one walker
1226
- // is provided it will return data only from that walker.
1227
- //
1228
- // @param {module:engine/module/treewalker~TreeWalker} [backward] Walker iterating in backward direction.
1229
- // @param {module:engine/module/treewalker~TreeWalker} [forward] Walker iterating in forward direction.
1230
- // @returns {Iterable.<Object>} Object returned at each iteration contains `value` and `walker` (informing which walker returned
1231
- // given value) fields.
1184
+ /**
1185
+ * Generator function returning values from provided walkers, switching between them at each iteration. If only one walker
1186
+ * is provided it will return data only from that walker.
1187
+ *
1188
+ * @param backward Walker iterating in backward direction.
1189
+ * @param forward Walker iterating in forward direction.
1190
+ * @returns Object returned at each iteration contains `value` and `walker` (informing which walker returned
1191
+ * given value) fields.
1192
+ */
1232
1193
  function* combineWalkers(backward, forward) {
1233
1194
  let done = false;
1234
1195
  while (!done) {
@@ -1255,11 +1216,13 @@ function* combineWalkers(backward, forward) {
1255
1216
  }
1256
1217
  }
1257
1218
  }
1258
- // Takes an array of non-intersecting ranges. For each of them gets minimal flat ranges covering that range and returns
1259
- // all those minimal flat ranges.
1260
- //
1261
- // @param {Array.<module:engine/model/range~Range>} ranges Ranges to process.
1262
- // @returns {Iterable.<module:engine/model/range~Range>} Minimal flat ranges of given `ranges`.
1219
+ /**
1220
+ * Takes an array of non-intersecting ranges. For each of them gets minimal flat ranges covering that range and returns
1221
+ * all those minimal flat ranges.
1222
+ *
1223
+ * @param ranges Ranges to process.
1224
+ * @returns Minimal flat ranges of given `ranges`.
1225
+ */
1263
1226
  function* convertToMinimalFlatRanges(ranges) {
1264
1227
  for (const range of ranges) {
1265
1228
  yield* range.getMinimalFlatRanges();