@ckeditor/ckeditor5-engine 31.0.0 → 33.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 (117) hide show
  1. package/LICENSE.md +2 -2
  2. package/package.json +25 -25
  3. package/src/controller/datacontroller.js +71 -80
  4. package/src/controller/editingcontroller.js +83 -6
  5. package/src/conversion/conversion.js +15 -14
  6. package/src/conversion/conversionhelpers.js +1 -1
  7. package/src/conversion/downcastdispatcher.js +298 -367
  8. package/src/conversion/downcasthelpers.js +771 -63
  9. package/src/conversion/mapper.js +105 -60
  10. package/src/conversion/modelconsumable.js +85 -35
  11. package/src/conversion/upcastdispatcher.js +3 -6
  12. package/src/conversion/upcasthelpers.js +4 -2
  13. package/src/conversion/viewconsumable.js +1 -1
  14. package/src/dataprocessor/basichtmlwriter.js +1 -1
  15. package/src/dataprocessor/dataprocessor.jsdoc +1 -1
  16. package/src/dataprocessor/htmldataprocessor.js +9 -31
  17. package/src/dataprocessor/htmlwriter.js +1 -1
  18. package/src/dataprocessor/xmldataprocessor.js +1 -1
  19. package/src/dev-utils/model.js +16 -14
  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 +7 -7
  23. package/src/index.js +2 -1
  24. package/src/model/batch.js +77 -10
  25. package/src/model/differ.js +87 -59
  26. package/src/model/document.js +13 -4
  27. package/src/model/documentfragment.js +1 -1
  28. package/src/model/documentselection.js +1 -1
  29. package/src/model/element.js +1 -1
  30. package/src/model/history.js +1 -1
  31. package/src/model/item.jsdoc +1 -1
  32. package/src/model/liveposition.js +1 -1
  33. package/src/model/liverange.js +1 -1
  34. package/src/model/markercollection.js +29 -5
  35. package/src/model/model.js +18 -9
  36. package/src/model/node.js +1 -1
  37. package/src/model/nodelist.js +1 -1
  38. package/src/model/operation/attributeoperation.js +1 -1
  39. package/src/model/operation/detachoperation.js +1 -1
  40. package/src/model/operation/insertoperation.js +1 -1
  41. package/src/model/operation/markeroperation.js +1 -1
  42. package/src/model/operation/mergeoperation.js +1 -1
  43. package/src/model/operation/moveoperation.js +1 -1
  44. package/src/model/operation/nooperation.js +1 -1
  45. package/src/model/operation/operation.js +1 -1
  46. package/src/model/operation/operationfactory.js +1 -1
  47. package/src/model/operation/renameoperation.js +1 -1
  48. package/src/model/operation/rootattributeoperation.js +1 -1
  49. package/src/model/operation/splitoperation.js +1 -1
  50. package/src/model/operation/transform.js +1 -1
  51. package/src/model/operation/utils.js +1 -1
  52. package/src/model/position.js +1 -1
  53. package/src/model/range.js +1 -1
  54. package/src/model/rootelement.js +1 -1
  55. package/src/model/schema.js +1 -1
  56. package/src/model/selection.js +1 -1
  57. package/src/model/text.js +1 -1
  58. package/src/model/textproxy.js +1 -1
  59. package/src/model/treewalker.js +1 -1
  60. package/src/model/utils/autoparagraphing.js +1 -1
  61. package/src/model/utils/deletecontent.js +1 -1
  62. package/src/model/utils/getselectedcontent.js +1 -1
  63. package/src/model/utils/insertcontent.js +1 -1
  64. package/src/model/utils/modifyselection.js +15 -8
  65. package/src/model/utils/selection-post-fixer.js +37 -30
  66. package/src/model/writer.js +17 -27
  67. package/src/view/attributeelement.js +1 -1
  68. package/src/view/containerelement.js +1 -1
  69. package/src/view/document.js +3 -2
  70. package/src/view/documentfragment.js +1 -1
  71. package/src/view/documentselection.js +1 -1
  72. package/src/view/domconverter.js +169 -47
  73. package/src/view/downcastwriter.js +121 -5
  74. package/src/view/editableelement.js +1 -1
  75. package/src/view/element.js +29 -1
  76. package/src/view/elementdefinition.jsdoc +1 -1
  77. package/src/view/emptyelement.js +1 -1
  78. package/src/view/filler.js +1 -1
  79. package/src/view/item.jsdoc +1 -1
  80. package/src/view/matcher.js +15 -14
  81. package/src/view/node.js +1 -1
  82. package/src/view/observer/arrowkeysobserver.js +1 -1
  83. package/src/view/observer/bubblingemittermixin.js +1 -1
  84. package/src/view/observer/bubblingeventinfo.js +1 -1
  85. package/src/view/observer/clickobserver.js +1 -1
  86. package/src/view/observer/compositionobserver.js +1 -1
  87. package/src/view/observer/domeventdata.js +1 -1
  88. package/src/view/observer/domeventobserver.js +1 -1
  89. package/src/view/observer/fakeselectionobserver.js +1 -1
  90. package/src/view/observer/focusobserver.js +1 -1
  91. package/src/view/observer/inputobserver.js +1 -1
  92. package/src/view/observer/keyobserver.js +1 -1
  93. package/src/view/observer/mouseobserver.js +1 -1
  94. package/src/view/observer/mutationobserver.js +1 -1
  95. package/src/view/observer/observer.js +1 -1
  96. package/src/view/observer/selectionobserver.js +3 -3
  97. package/src/view/placeholder.js +1 -1
  98. package/src/view/position.js +1 -1
  99. package/src/view/range.js +1 -1
  100. package/src/view/rawelement.js +1 -1
  101. package/src/view/renderer.js +7 -17
  102. package/src/view/rooteditableelement.js +1 -1
  103. package/src/view/selection.js +1 -1
  104. package/src/view/styles/background.js +1 -1
  105. package/src/view/styles/border.js +1 -1
  106. package/src/view/styles/margin.js +1 -1
  107. package/src/view/styles/padding.js +1 -1
  108. package/src/view/styles/utils.js +1 -1
  109. package/src/view/stylesmap.js +1 -1
  110. package/src/view/text.js +1 -1
  111. package/src/view/textproxy.js +1 -1
  112. package/src/view/treewalker.js +1 -1
  113. package/src/view/uielement.js +1 -1
  114. package/src/view/upcastwriter.js +1 -1
  115. package/src/view/view.js +1 -1
  116. package/theme/placeholder.css +10 -1
  117. package/theme/renderer.css +2 -2
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -58,6 +58,14 @@ export default class DowncastWriter {
58
58
  * @type {Map.<String,Set>}
59
59
  */
60
60
  this._cloneGroups = new Map();
61
+
62
+ /**
63
+ * The slot factory used by the `elementToStructure` downcast helper.
64
+ *
65
+ * @private
66
+ * @type {Function|null}
67
+ */
68
+ this._slotFactory = null;
61
69
  }
62
70
 
63
71
  /**
@@ -186,6 +194,8 @@ export default class DowncastWriter {
186
194
  * @param {Object} [options] Element's options.
187
195
  * @param {Number} [options.priority] Element's {@link module:engine/view/attributeelement~AttributeElement#priority priority}.
188
196
  * @param {Number|String} [options.id] Element's {@link module:engine/view/attributeelement~AttributeElement#id id}.
197
+ * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
198
+ * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
189
199
  * @returns {module:engine/view/attributeelement~AttributeElement} Created element.
190
200
  */
191
201
  createAttributeElement( name, attributes, options = {} ) {
@@ -199,6 +209,10 @@ export default class DowncastWriter {
199
209
  attributeElement._id = options.id;
200
210
  }
201
211
 
212
+ if ( options.renderUnsafeAttributes ) {
213
+ attributeElement._unsafeAttributesToRender.push( ...options.renderUnsafeAttributes );
214
+ }
215
+
202
216
  return attributeElement;
203
217
  }
204
218
 
@@ -216,21 +230,47 @@ export default class DowncastWriter {
216
230
  * // Create element with custom classes.
217
231
  * writer.createContainerElement( 'p', { class: 'foo bar baz' } );
218
232
  *
233
+ * // Create element with children.
234
+ * writer.createContainerElement( 'figure', { class: 'image' }, [
235
+ * writer.createEmptyElement( 'img' ),
236
+ * writer.createContainerElement( 'figcaption' )
237
+ * ] );
238
+ *
239
+ * // Create element with specific options.
240
+ * writer.createContainerElement( 'span', { class: 'placeholder' }, { isAllowedInsideAttributeElement: true } );
241
+ *
219
242
  * @param {String} name Name of the element.
220
243
  * @param {Object} [attributes] Elements attributes.
244
+ * @param {module:engine/view/node~Node|Iterable.<module:engine/view/node~Node>|Object} [childrenOrOptions]
245
+ * A node or a list of nodes to be inserted into the created element. If no children were specified, element's `options`
246
+ * can be passed in this argument.
221
247
  * @param {Object} [options] Element's options.
222
248
  * @param {Boolean} [options.isAllowedInsideAttributeElement=false] Whether an element is
223
249
  * {@link module:engine/view/element~Element#isAllowedInsideAttributeElement allowed inside an AttributeElement} and can be wrapped
224
250
  * with {@link module:engine/view/attributeelement~AttributeElement} by {@link module:engine/view/downcastwriter~DowncastWriter}.
251
+ * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
252
+ * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
225
253
  * @returns {module:engine/view/containerelement~ContainerElement} Created element.
226
254
  */
227
- createContainerElement( name, attributes, options = {} ) {
228
- const containerElement = new ContainerElement( this.document, name, attributes );
255
+ createContainerElement( name, attributes, childrenOrOptions = {}, options = {} ) {
256
+ let children = null;
257
+
258
+ if ( isPlainObject( childrenOrOptions ) ) {
259
+ options = childrenOrOptions;
260
+ } else {
261
+ children = childrenOrOptions;
262
+ }
263
+
264
+ const containerElement = new ContainerElement( this.document, name, attributes, children );
229
265
 
230
266
  if ( options.isAllowedInsideAttributeElement !== undefined ) {
231
267
  containerElement._isAllowedInsideAttributeElement = options.isAllowedInsideAttributeElement;
232
268
  }
233
269
 
270
+ if ( options.renderUnsafeAttributes ) {
271
+ containerElement._unsafeAttributesToRender.push( ...options.renderUnsafeAttributes );
272
+ }
273
+
234
274
  return containerElement;
235
275
  }
236
276
 
@@ -245,12 +285,19 @@ export default class DowncastWriter {
245
285
  *
246
286
  * @param {String} name Name of the element.
247
287
  * @param {Object} [attributes] Elements attributes.
288
+ * @param {Object} [options] Element's options.
289
+ * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
290
+ * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
248
291
  * @returns {module:engine/view/editableelement~EditableElement} Created element.
249
292
  */
250
- createEditableElement( name, attributes ) {
293
+ createEditableElement( name, attributes, options = {} ) {
251
294
  const editableElement = new EditableElement( this.document, name, attributes );
252
295
  editableElement._document = this.document;
253
296
 
297
+ if ( options.renderUnsafeAttributes ) {
298
+ editableElement._unsafeAttributesToRender.push( ...options.renderUnsafeAttributes );
299
+ }
300
+
254
301
  return editableElement;
255
302
  }
256
303
 
@@ -266,6 +313,8 @@ export default class DowncastWriter {
266
313
  * @param {Boolean} [options.isAllowedInsideAttributeElement=true] Whether an element is
267
314
  * {@link module:engine/view/element~Element#isAllowedInsideAttributeElement allowed inside an AttributeElement} and can be wrapped
268
315
  * with {@link module:engine/view/attributeelement~AttributeElement} by {@link module:engine/view/downcastwriter~DowncastWriter}.
316
+ * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
317
+ * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
269
318
  * @returns {module:engine/view/emptyelement~EmptyElement} Created element.
270
319
  */
271
320
  createEmptyElement( name, attributes, options = {} ) {
@@ -275,6 +324,10 @@ export default class DowncastWriter {
275
324
  emptyElement._isAllowedInsideAttributeElement = options.isAllowedInsideAttributeElement;
276
325
  }
277
326
 
327
+ if ( options.renderUnsafeAttributes ) {
328
+ emptyElement._unsafeAttributesToRender.push( ...options.renderUnsafeAttributes );
329
+ }
330
+
278
331
  return emptyElement;
279
332
  }
280
333
 
@@ -347,6 +400,8 @@ export default class DowncastWriter {
347
400
  * @param {Boolean} [options.isAllowedInsideAttributeElement=true] Whether an element is
348
401
  * {@link module:engine/view/element~Element#isAllowedInsideAttributeElement allowed inside an AttributeElement} and can be wrapped
349
402
  * with {@link module:engine/view/attributeelement~AttributeElement} by {@link module:engine/view/downcastwriter~DowncastWriter}.
403
+ * @param {Array.<String>} [options.renderUnsafeAttributes] A list of attribute names that should be rendered in the editing
404
+ * pipeline even though they would normally be filtered out by unsafe attribute detection mechanisms.
350
405
  * @returns {module:engine/view/rawelement~RawElement} The created element.
351
406
  */
352
407
  createRawElement( name, attributes, renderFunction, options = {} ) {
@@ -358,6 +413,10 @@ export default class DowncastWriter {
358
413
  rawElement._isAllowedInsideAttributeElement = options.isAllowedInsideAttributeElement;
359
414
  }
360
415
 
416
+ if ( options.renderUnsafeAttributes ) {
417
+ rawElement._unsafeAttributesToRender.push( ...options.renderUnsafeAttributes );
418
+ }
419
+
361
420
  return rawElement;
362
421
  }
363
422
 
@@ -1136,7 +1195,7 @@ export default class DowncastWriter {
1136
1195
  }
1137
1196
 
1138
1197
  /**
1139
- Creates new {@link module:engine/view/selection~Selection} instance.
1198
+ * Creates new {@link module:engine/view/selection~Selection} instance.
1140
1199
  *
1141
1200
  * // Creates empty selection without ranges.
1142
1201
  * const selection = writer.createSelection();
@@ -1199,6 +1258,63 @@ export default class DowncastWriter {
1199
1258
  return new Selection( selectable, placeOrOffset, options );
1200
1259
  }
1201
1260
 
1261
+ /**
1262
+ * Creates placeholders for child elements of the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure
1263
+ * `elementToStructure()`} conversion helper.
1264
+ *
1265
+ * const viewSlot = conversionApi.writer.createSlot();
1266
+ * const viewPosition = conversionApi.writer.createPositionAt( viewElement, 0 );
1267
+ *
1268
+ * conversionApi.writer.insert( viewPosition, viewSlot );
1269
+ *
1270
+ * It could be filtered down to a specific subset of children (only `<foo>` model elements in this case):
1271
+ *
1272
+ * const viewSlot = conversionApi.writer.createSlot( node => node.is( 'element', 'foo' ) );
1273
+ * const viewPosition = conversionApi.writer.createPositionAt( viewElement, 0 );
1274
+ *
1275
+ * conversionApi.writer.insert( viewPosition, viewSlot );
1276
+ *
1277
+ * While providing a filtered slot, make sure to provide slots for all child nodes. A single node can not be downcasted into
1278
+ * multiple slots.
1279
+ *
1280
+ * **Note**: You should not change the order of nodes. View elements should be in the same order as model nodes.
1281
+ *
1282
+ * @param {'children'|module:engine/conversion/downcasthelpers~SlotFilter} [modeOrFilter='children'] The filter for child nodes.
1283
+ * @returns {module:engine/view/element~Element} The slot element to be placed in to the view structure while processing
1284
+ * {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure `elementToStructure()`}.
1285
+ */
1286
+ createSlot( modeOrFilter ) {
1287
+ if ( !this._slotFactory ) {
1288
+ /**
1289
+ * The `createSlot()` method is only allowed inside the `elementToStructure` downcast helper callback.
1290
+ *
1291
+ * @error view-writer-invalid-create-slot-context
1292
+ */
1293
+ throw new CKEditorError( 'view-writer-invalid-create-slot-context', this.document );
1294
+ }
1295
+
1296
+ return this._slotFactory( this, modeOrFilter );
1297
+ }
1298
+
1299
+ /**
1300
+ * Registers a slot factory.
1301
+ *
1302
+ * @protected
1303
+ * @param {Function} slotFactory The slot factory.
1304
+ */
1305
+ _registerSlotFactory( slotFactory ) {
1306
+ this._slotFactory = slotFactory;
1307
+ }
1308
+
1309
+ /**
1310
+ * Clears the registered slot factory.
1311
+ *
1312
+ * @protected
1313
+ */
1314
+ _clearSlotFactory() {
1315
+ this._slotFactory = null;
1316
+ }
1317
+
1202
1318
  /**
1203
1319
  * Inserts a node or nodes at the specified position. Takes care of breaking attributes before insertion
1204
1320
  * and merging them afterwards if requested by the breakAttributes param.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -138,6 +138,21 @@ export default class Element extends Node {
138
138
  * @member {Boolean}
139
139
  */
140
140
  this._isAllowedInsideAttributeElement = false;
141
+
142
+ /**
143
+ * A list of attribute names that should be rendered in the editing pipeline even though filtering mechanisms
144
+ * implemented in the {@link module:engine/view/domconverter~DomConverter} (for instance,
145
+ * {@link module:engine/view/domconverter~DomConverter#shouldRenderAttribute}) would filter them out.
146
+ *
147
+ * These attributes can be specified as an option when the element is created by
148
+ * the {@link module:engine/view/downcastwriter~DowncastWriter}. To check whether an unsafe an attribute should
149
+ * be permitted, use the {@link #shouldRenderUnsafeAttribute} method.
150
+ *
151
+ * @private
152
+ * @readonly
153
+ * @member {Array.<String>}
154
+ */
155
+ this._unsafeAttributesToRender = [];
141
156
  }
142
157
 
143
158
  /**
@@ -572,6 +587,19 @@ export default class Element extends Node {
572
587
  ( attributes == '' ? '' : ` ${ attributes }` );
573
588
  }
574
589
 
590
+ /**
591
+ * Decides whether an unsafe attribute is whitelisted and should be rendered in the editing pipeline even though filtering mechanisms
592
+ * like {@link module:engine/view/domconverter~DomConverter#shouldRenderAttribute} say it should not.
593
+ *
594
+ * Unsafe attribute names can be specified when creating an element via {@link module:engine/view/downcastwriter~DowncastWriter}.
595
+ *
596
+ * @param {String} attributeName The name of the attribute to be checked.
597
+ * @returns {Boolean}
598
+ */
599
+ shouldRenderUnsafeAttribute( attributeName ) {
600
+ return this._unsafeAttributesToRender.includes( attributeName );
601
+ }
602
+
575
603
  /**
576
604
  * Clones provided element.
577
605
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -531,7 +531,7 @@ function matchStyles( patterns, element ) {
531
531
  * name: 'figure',
532
532
  * attributes: [
533
533
  * 'title', // Match `title` attribute (can be empty).
534
- * /^data-*$/, // Match attributes starting with `data-` e.g. `data-foo` with any value (can be empty).
534
+ * /^data-*$/ // Match attributes starting with `data-` e.g. `data-foo` with any value (can be empty).
535
535
  * ]
536
536
  * };
537
537
  *
@@ -541,7 +541,8 @@ function matchStyles( patterns, element ) {
541
541
  * attributes: [
542
542
  * {
543
543
  * key: 'type', // Match `type` as an attribute key.
544
- * value: /^(text|number|date)$/ }, // Match `text`, `number` or `date` values.
544
+ * value: /^(text|number|date)$/ // Match `text`, `number` or `date` values.
545
+ * },
545
546
  * {
546
547
  * key: /^data-.*$/, // Match attributes starting with `data-` e.g. `data-foo`.
547
548
  * value: true // Match any value (can be empty).
@@ -572,7 +573,7 @@ function matchStyles( patterns, element ) {
572
573
  * // Match view element which has matching styles (Object).
573
574
  * const pattern = {
574
575
  * name: 'p',
575
- * attributes: {
576
+ * styles: {
576
577
  * color: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/, // Match `color` in RGB format only.
577
578
  * 'font-weight': 600, // Match `font-weight` only if it's `600`.
578
579
  * 'text-decoration': true // Match any text decoration.
@@ -582,19 +583,20 @@ function matchStyles( patterns, element ) {
582
583
  * // Match view element which has matching styles (Array).
583
584
  * const pattern = {
584
585
  * name: 'p',
585
- * attributes: [
586
+ * styles: [
586
587
  * 'color', // Match `color` with any value.
587
- * /^border.*$/, // Match all border properties.
588
+ * /^border.*$/ // Match all border properties.
588
589
  * ]
589
590
  * };
590
591
  *
591
592
  * // Match view element which has matching styles (key-value pairs).
592
593
  * const pattern = {
593
594
  * name: 'p',
594
- * attributes: [
595
+ * styles: [
595
596
  * {
596
- * key: 'color', // Match `color` as an property key.
597
- * value: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/, // Match RGB format only.
597
+ * key: 'color', // Match `color` as an property key.
598
+ * value: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/ // Match RGB format only.
599
+ * },
598
600
  * {
599
601
  * key: /^border.*$/, // Match any border style.
600
602
  * value: true // Match any value.
@@ -647,6 +649,7 @@ function matchStyles( patterns, element ) {
647
649
  * {
648
650
  * key: 'image', // Match `image` class.
649
651
  * value: true
652
+ * },
650
653
  * {
651
654
  * key: /^image-side-(left|right)$/, // Match `image-side-left` or `image-side-right` class.
652
655
  * value: true
@@ -700,11 +703,9 @@ function matchStyles( patterns, element ) {
700
703
  * @typedef {String|RegExp|Object|Function} module:engine/view/matcher~MatcherPattern
701
704
  *
702
705
  * @property {String|RegExp} [name] View element name to match.
703
- * @property {String|RegExp|Array.<String|RegExp>} [classes] View element's class name(s) to match.
704
- * @property {Object} [styles] Object with key-value pairs representing styles to match.
705
- * Each object key represents style name. Value can be given as `String` or `RegExp`.
706
- * @property {Object} [attributes] Object with key-value pairs representing attributes to match.
707
- * Each object key represents attribute name. Value can be given as `String` or `RegExp`.
706
+ * @property {Boolean|String|RegExp|Object|Array.<String|RegExp|Object>} [classes] View element's classes to match.
707
+ * @property {Boolean|String|RegExp|Object|Array.<String|RegExp|Object>} [styles] View element's styles to match.
708
+ * @property {Boolean|String|RegExp|Object|Array.<String|RegExp|Object>} [attributes] View element's attributes to match.
708
709
  */
709
710
 
710
711
  /**
package/src/view/node.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
4
4
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
5
5
  */
6
6
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -81,7 +81,7 @@ export default class SelectionObserver extends Observer {
81
81
  this._fireSelectionChangeDoneDebounced = debounce( data => this.document.fire( 'selectionChangeDone', data ), 200 );
82
82
 
83
83
  /**
84
- * When called, starts clearing the {@link #_loopbackCounter} counter in intervals of time. When the number of selection
84
+ * When called, starts clearing the {@link #_loopbackCounter} counter in time intervals. When the number of selection
85
85
  * changes exceeds a certain limit within the interval of time, the observer will not fire `selectionChange` but warn about
86
86
  * possible infinite selection loop.
87
87
  *
@@ -92,7 +92,7 @@ export default class SelectionObserver extends Observer {
92
92
 
93
93
  /**
94
94
  * Unlocks the `isSelecting` state of the view document in case the selection observer did not record this fact
95
- * correctly (for whatever the reason). It is a safeguard (paranoid check) that returns document to the normal state
95
+ * correctly (for whatever reason). It is a safeguard (paranoid check), that returns document to the normal state
96
96
  * after a certain period of time (debounced, postponed by each selectionchange event).
97
97
  *
98
98
  * @private
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
package/src/view/range.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, 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
 
@@ -20,6 +20,7 @@ import remove from '@ckeditor/ckeditor5-utils/src/dom/remove';
20
20
  import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
21
21
  import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
22
22
  import isText from '@ckeditor/ckeditor5-utils/src/dom/istext';
23
+ import isComment from '@ckeditor/ckeditor5-utils/src/dom/iscomment';
23
24
  import isNode from '@ckeditor/ckeditor5-utils/src/dom/isnode';
24
25
  import fastDiff from '@ckeditor/ckeditor5-utils/src/fastdiff';
25
26
  import env from '@ckeditor/ckeditor5-utils/src/env';
@@ -120,7 +121,7 @@ export default class Renderer {
120
121
  // Rendering the selection and inline filler manipulation should be postponed in (non-Android) Blink until the user finishes
121
122
  // creating the selection in DOM to avoid accidental selection collapsing
122
123
  // (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).
123
- // When the user stops, selecting, all pending changes should be rendered ASAP, though.
124
+ // When the user stops selecting, all pending changes should be rendered ASAP, though.
124
125
  if ( env.isBlink && !env.isAndroid ) {
125
126
  this.on( 'change:isSelecting', () => {
126
127
  if ( !this.isSelecting ) {
@@ -555,25 +556,14 @@ export default class Renderer {
555
556
 
556
557
  // Add or overwrite attributes.
557
558
  for ( const key of viewAttrKeys ) {
558
- const value = viewElement.getAttribute( key );
559
-
560
- if ( !this.domConverter.shouldRenderAttribute( key, value ) ) {
561
- domElement.removeAttribute( key );
562
- } else {
563
- domElement.setAttribute( key, value );
564
- }
559
+ this.domConverter.setDomElementAttribute( domElement, key, viewElement.getAttribute( key ), viewElement );
565
560
  }
566
561
 
567
562
  // Remove from DOM attributes which do not exists in the view.
568
563
  for ( const key of domAttrKeys ) {
569
- // Do not remove attributes on `script` elements with special data attributes `data-ck-hidden`.
570
- if ( viewElement.name === 'script' && key === 'data-ck-hidden' ) {
571
- continue;
572
- }
573
-
574
564
  // All other attributes not present in the DOM should be removed.
575
565
  if ( !viewElement.hasAttribute( key ) ) {
576
- domElement.removeAttribute( key );
566
+ this.domConverter.removeDomElementAttribute( domElement, key );
577
567
  }
578
568
  }
579
569
  }
@@ -742,7 +732,7 @@ export default class Renderer {
742
732
  _updateSelection() {
743
733
  // Block updating DOM selection in (non-Android) Blink while the user is selecting to prevent accidental selection collapsing.
744
734
  // Note: Structural changes in DOM must trigger selection rendering, though. Nodes the selection was anchored
745
- // to may disappear in DOM which would break the selection (e.g. in real-time collaboration scenarios).
735
+ // to, may disappear in DOM which would break the selection (e.g. in real-time collaboration scenarios).
746
736
  // https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723
747
737
  if ( env.isBlink && !env.isAndroid && this.isSelecting && !this.markedChildren.size ) {
748
738
  return;
@@ -1000,7 +990,7 @@ function addInlineFiller( domDocument, domParentOrArray, offset ) {
1000
990
  function areSimilar( node1, node2 ) {
1001
991
  return isNode( node1 ) && isNode( node2 ) &&
1002
992
  !isText( node1 ) && !isText( node2 ) &&
1003
- node1.nodeType !== Node.COMMENT_NODE && node2.nodeType !== Node.COMMENT_NODE &&
993
+ !isComment( node1 ) && !isComment( node2 ) &&
1004
994
  node1.tagName.toLowerCase() === node2.tagName.toLowerCase();
1005
995
  }
1006
996