@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
  /**
@@ -30,23 +30,25 @@ import Range from '../range';
30
30
  * See as an example a selection that starts in a P1 element and ends inside the text of a TD element
31
31
  * (`[` and `]` are range boundaries and `(l)` denotes an element defined as `isLimit=true`):
32
32
  *
33
- * root
34
- * |- element P1
35
- * | |- "foo" root
36
- * |- element TABLE (l) P1 TABLE P2
37
- * | |- element TR (l) f o[o TR TR b a r
38
- * | | |- element TD (l) TD TD
39
- * | | |- "aaa" a]a a b b b
40
- * | |- element TR (l)
41
- * | | |- element TD (l) ||
42
- * | | |- "bbb" ||
43
- * |- element P2 VV
44
- * | |- "bar"
45
- * root
46
- * P1 TABLE] P2
47
- * f o[o TR TR b a r
48
- * TD TD
49
- * a a a b b b
33
+ * ```
34
+ * root
35
+ * |- element P1
36
+ * | |- "foo" root
37
+ * |- element TABLE (l) P1 TABLE P2
38
+ * | |- element TR (l) f o[o TR TR b a r
39
+ * | | |- element TD (l) TD TD
40
+ * | | |- "aaa" a]a a b b b
41
+ * | |- element TR (l)
42
+ * | | |- element TD (l) ||
43
+ * | | |- "bbb" ||
44
+ * |- element P2 VV
45
+ * | |- "bar"
46
+ * root
47
+ * P1 TABLE] P2
48
+ * f o[o TR TR b a r
49
+ * TD TD
50
+ * a a a b b b
51
+ * ```
50
52
  *
51
53
  * In the example above, the TABLE, TR and TD are defined as `isLimit=true` in the schema. The range which is not contained within
52
54
  * a single limit element must be expanded to select the outermost limit element. The range end is inside the text node of the TD element.
@@ -55,16 +57,13 @@ import Range from '../range';
55
57
  *
56
58
  * **Note** If the selection contains multiple ranges, the method returns a minimal set of ranges that are not intersecting after expanding
57
59
  * them to select `isLimit=true` elements.
58
- *
59
- * @param {module:engine/model/model~Model} model
60
60
  */
61
61
  export function injectSelectionPostFixer(model) {
62
62
  model.document.registerPostFixer(writer => selectionPostFixer(writer, model));
63
63
  }
64
- // The selection post-fixer.
65
- //
66
- // @param {module:engine/model/writer~Writer} writer
67
- // @param {module:engine/model/model~Model} model
64
+ /**
65
+ * The selection post-fixer.
66
+ */
68
67
  function selectionPostFixer(writer, model) {
69
68
  const selection = model.document.selection;
70
69
  const schema = model.schema;
@@ -95,24 +94,25 @@ function selectionPostFixer(writer, model) {
95
94
  }
96
95
  return false;
97
96
  }
98
- // Tries fixing a range if it's incorrect.
99
- //
100
- // @param {module:engine/model/range~Range} range
101
- // @param {module:engine/model/schema~Schema} schema
102
- // @returns {module:engine/model/range~Range|null} Returns fixed range or null if range is valid.
97
+ /**
98
+ * Tries fixing a range if it's incorrect.
99
+ *
100
+ * @returns Returns fixed range or null if range is valid.
101
+ */
103
102
  function tryFixingRange(range, schema) {
104
103
  if (range.isCollapsed) {
105
104
  return tryFixingCollapsedRange(range, schema);
106
105
  }
107
106
  return tryFixingNonCollapsedRage(range, schema);
108
107
  }
109
- // Tries to fix collapsed ranges.
110
- //
111
- // * Fixes situation when a range is in a place where $text is not allowed
112
- //
113
- // @param {module:engine/model/range~Range} range Collapsed range to fix.
114
- // @param {module:engine/model/schema~Schema} schema
115
- // @returns {module:engine/model/range~Range|null} Returns fixed range or null if range is valid.
108
+ /**
109
+ * Tries to fix collapsed ranges.
110
+ *
111
+ * * Fixes situation when a range is in a place where $text is not allowed
112
+ *
113
+ * @param range Collapsed range to fix.
114
+ * @returns Returns fixed range or null if range is valid.
115
+ */
116
116
  function tryFixingCollapsedRange(range, schema) {
117
117
  const originalPosition = range.start;
118
118
  const nearestSelectionRange = schema.getNearestSelectionRange(originalPosition);
@@ -137,11 +137,12 @@ function tryFixingCollapsedRange(range, schema) {
137
137
  }
138
138
  return new Range(fixedPosition);
139
139
  }
140
- // Tries to fix an expanded range.
141
- //
142
- // @param {module:engine/model/range~Range} range Expanded range to fix.
143
- // @param {module:engine/model/schema~Schema} schema
144
- // @returns {module:engine/model/range~Range|null} Returns fixed range or null if range is valid.
140
+ /**
141
+ * Tries to fix an expanded range.
142
+ *
143
+ * @param range Expanded range to fix.
144
+ * @returns Returns fixed range or null if range is valid.
145
+ */
145
146
  function tryFixingNonCollapsedRage(range, schema) {
146
147
  const { start, end } = range;
147
148
  const isTextAllowedOnStart = schema.checkChild(start, '$text');
@@ -195,11 +196,9 @@ function tryFixingNonCollapsedRage(range, schema) {
195
196
  // Range was not fixed at this point so it is valid - ie it was placed around limit element already.
196
197
  return null;
197
198
  }
198
- // Finds the outer-most ancestor.
199
- //
200
- // @param {module:engine/model/node~Node} startingNode
201
- // @param {module:engine/model/schema~Schema} schema
202
- // @returns {module:engine/model/node~Node}
199
+ /**
200
+ * Finds the outer-most ancestor.
201
+ */
203
202
  function findOutermostLimitAncestor(startingNode, schema) {
204
203
  let isLimitNode = startingNode;
205
204
  let parent = isLimitNode;
@@ -210,12 +209,9 @@ function findOutermostLimitAncestor(startingNode, schema) {
210
209
  }
211
210
  return isLimitNode;
212
211
  }
213
- // Checks whether any of range boundaries is placed around non-limit elements.
214
- //
215
- // @param {module:engine/model/position~Position} start
216
- // @param {module:engine/model/position~Position} end
217
- // @param {module:engine/model/schema~Schema} schema
218
- // @returns {Boolean}
212
+ /**
213
+ * Checks whether any of range boundaries is placed around non-limit elements.
214
+ */
219
215
  function checkSelectionOnNonLimitElements(start, end, schema) {
220
216
  const startIsOnBlock = (start.nodeAfter && !schema.isLimit(start.nodeAfter)) || schema.checkChild(start, '$text');
221
217
  const endIsOnBlock = (end.nodeBefore && !schema.isLimit(end.nodeBefore)) || schema.checkChild(end, '$text');
@@ -225,8 +221,8 @@ function checkSelectionOnNonLimitElements(start, end, schema) {
225
221
  /**
226
222
  * Returns a minimal non-intersecting array of ranges without duplicates.
227
223
  *
228
- * @param {Array.<module:engine/model/range~Range>} Ranges to merge.
229
- * @returns {Array.<module:engine/model/range~Range>} Array of unique and nonIntersecting ranges.
224
+ * @param ranges Ranges to merge.
225
+ * @returns Array of unique and non-intersecting ranges.
230
226
  */
231
227
  export function mergeIntersectingRanges(ranges) {
232
228
  const rangesToMerge = [...ranges];
@@ -254,11 +250,9 @@ export function mergeIntersectingRanges(ranges) {
254
250
  const nonIntersectingRanges = rangesToMerge.filter((_, index) => !rangeIndexesToRemove.has(index));
255
251
  return nonIntersectingRanges;
256
252
  }
257
- // Checks if node exists and if it's a selectable.
258
- //
259
- // @param {module:engine/model/node~Node} node
260
- // @param {module:engine/model/schema~Schema} schema
261
- // @returns {Boolean}
253
+ /**
254
+ * Checks if node exists and if it's a selectable.
255
+ */
262
256
  function isSelectable(node, schema) {
263
257
  return node && schema.isSelectable(node);
264
258
  }