@ckeditor/ckeditor5-engine 35.0.1 → 35.2.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 (124) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/package.json +30 -24
  3. package/src/controller/datacontroller.js +467 -561
  4. package/src/controller/editingcontroller.js +168 -204
  5. package/src/conversion/conversion.js +541 -565
  6. package/src/conversion/conversionhelpers.js +24 -28
  7. package/src/conversion/downcastdispatcher.js +457 -686
  8. package/src/conversion/downcasthelpers.js +1583 -1965
  9. package/src/conversion/mapper.js +518 -707
  10. package/src/conversion/modelconsumable.js +240 -283
  11. package/src/conversion/upcastdispatcher.js +372 -718
  12. package/src/conversion/upcasthelpers.js +707 -818
  13. package/src/conversion/viewconsumable.js +524 -581
  14. package/src/dataprocessor/basichtmlwriter.js +12 -16
  15. package/src/dataprocessor/dataprocessor.js +5 -0
  16. package/src/dataprocessor/htmldataprocessor.js +100 -116
  17. package/src/dataprocessor/htmlwriter.js +1 -18
  18. package/src/dataprocessor/xmldataprocessor.js +116 -137
  19. package/src/dev-utils/model.js +260 -352
  20. package/src/dev-utils/operationreplayer.js +106 -126
  21. package/src/dev-utils/utils.js +34 -51
  22. package/src/dev-utils/view.js +632 -753
  23. package/src/index.js +0 -11
  24. package/src/model/batch.js +111 -127
  25. package/src/model/differ.js +988 -1233
  26. package/src/model/document.js +340 -449
  27. package/src/model/documentfragment.js +327 -364
  28. package/src/model/documentselection.js +996 -1189
  29. package/src/model/element.js +306 -410
  30. package/src/model/history.js +224 -262
  31. package/src/model/item.js +5 -0
  32. package/src/model/liveposition.js +84 -145
  33. package/src/model/liverange.js +108 -185
  34. package/src/model/markercollection.js +379 -480
  35. package/src/model/model.js +883 -1034
  36. package/src/model/node.js +419 -463
  37. package/src/model/nodelist.js +176 -201
  38. package/src/model/operation/attributeoperation.js +153 -182
  39. package/src/model/operation/detachoperation.js +64 -83
  40. package/src/model/operation/insertoperation.js +135 -166
  41. package/src/model/operation/markeroperation.js +114 -140
  42. package/src/model/operation/mergeoperation.js +163 -191
  43. package/src/model/operation/moveoperation.js +157 -187
  44. package/src/model/operation/nooperation.js +28 -38
  45. package/src/model/operation/operation.js +106 -125
  46. package/src/model/operation/operationfactory.js +30 -34
  47. package/src/model/operation/renameoperation.js +109 -135
  48. package/src/model/operation/rootattributeoperation.js +155 -188
  49. package/src/model/operation/splitoperation.js +196 -232
  50. package/src/model/operation/transform.js +1833 -2204
  51. package/src/model/operation/utils.js +140 -204
  52. package/src/model/position.js +980 -1053
  53. package/src/model/range.js +910 -1028
  54. package/src/model/rootelement.js +77 -97
  55. package/src/model/schema.js +1189 -1835
  56. package/src/model/selection.js +745 -862
  57. package/src/model/text.js +90 -114
  58. package/src/model/textproxy.js +204 -240
  59. package/src/model/treewalker.js +316 -397
  60. package/src/model/typecheckable.js +16 -0
  61. package/src/model/utils/autoparagraphing.js +32 -44
  62. package/src/model/utils/deletecontent.js +334 -418
  63. package/src/model/utils/findoptimalinsertionrange.js +25 -36
  64. package/src/model/utils/getselectedcontent.js +96 -118
  65. package/src/model/utils/insertcontent.js +757 -773
  66. package/src/model/utils/insertobject.js +96 -119
  67. package/src/model/utils/modifyselection.js +120 -158
  68. package/src/model/utils/selection-post-fixer.js +153 -201
  69. package/src/model/writer.js +1305 -1474
  70. package/src/view/attributeelement.js +189 -225
  71. package/src/view/containerelement.js +75 -85
  72. package/src/view/document.js +172 -215
  73. package/src/view/documentfragment.js +200 -249
  74. package/src/view/documentselection.js +338 -367
  75. package/src/view/domconverter.js +1370 -1617
  76. package/src/view/downcastwriter.js +1747 -2076
  77. package/src/view/editableelement.js +81 -97
  78. package/src/view/element.js +739 -890
  79. package/src/view/elementdefinition.js +5 -0
  80. package/src/view/emptyelement.js +82 -92
  81. package/src/view/filler.js +35 -50
  82. package/src/view/item.js +5 -0
  83. package/src/view/matcher.js +260 -559
  84. package/src/view/node.js +274 -360
  85. package/src/view/observer/arrowkeysobserver.js +19 -28
  86. package/src/view/observer/bubblingemittermixin.js +120 -263
  87. package/src/view/observer/bubblingeventinfo.js +47 -55
  88. package/src/view/observer/clickobserver.js +7 -13
  89. package/src/view/observer/compositionobserver.js +14 -24
  90. package/src/view/observer/domeventdata.js +57 -67
  91. package/src/view/observer/domeventobserver.js +40 -64
  92. package/src/view/observer/fakeselectionobserver.js +81 -96
  93. package/src/view/observer/focusobserver.js +45 -61
  94. package/src/view/observer/inputobserver.js +7 -13
  95. package/src/view/observer/keyobserver.js +17 -27
  96. package/src/view/observer/mouseobserver.js +7 -14
  97. package/src/view/observer/mutationobserver.js +220 -315
  98. package/src/view/observer/observer.js +81 -102
  99. package/src/view/observer/selectionobserver.js +199 -246
  100. package/src/view/observer/tabobserver.js +23 -36
  101. package/src/view/placeholder.js +128 -173
  102. package/src/view/position.js +350 -401
  103. package/src/view/range.js +453 -513
  104. package/src/view/rawelement.js +85 -112
  105. package/src/view/renderer.js +874 -1018
  106. package/src/view/rooteditableelement.js +80 -90
  107. package/src/view/selection.js +608 -689
  108. package/src/view/styles/background.js +43 -44
  109. package/src/view/styles/border.js +220 -276
  110. package/src/view/styles/margin.js +8 -17
  111. package/src/view/styles/padding.js +8 -16
  112. package/src/view/styles/utils.js +127 -160
  113. package/src/view/stylesmap.js +728 -905
  114. package/src/view/text.js +102 -126
  115. package/src/view/textproxy.js +144 -170
  116. package/src/view/treewalker.js +383 -479
  117. package/src/view/typecheckable.js +19 -0
  118. package/src/view/uielement.js +166 -187
  119. package/src/view/upcastwriter.js +395 -449
  120. package/src/view/view.js +569 -664
  121. package/src/dataprocessor/dataprocessor.jsdoc +0 -64
  122. package/src/model/item.jsdoc +0 -14
  123. package/src/view/elementdefinition.jsdoc +0 -59
  124. package/src/view/item.jsdoc +0 -14
package/src/model/text.js CHANGED
@@ -2,15 +2,11 @@
2
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
-
6
5
  /**
7
6
  * @module engine/model/text
8
7
  */
9
-
10
8
  import Node from './node';
11
-
12
9
  // @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-utils/utils' );
13
-
14
10
  /**
15
11
  * Model text node. Type of {@link module:engine/model/node~Node node} that contains {@link module:engine/model/text~Text#data text data}.
16
12
  *
@@ -25,114 +21,94 @@ import Node from './node';
25
21
  * @extends module:engine/model/node~Node
26
22
  */
27
23
  export default class Text extends Node {
28
- /**
29
- * Creates a text node.
30
- *
31
- * **Note:** Constructor of this class shouldn't be used directly in the code.
32
- * Use the {@link module:engine/model/writer~Writer#createText} method instead.
33
- *
34
- * @protected
35
- * @param {String} data Node's text.
36
- * @param {Object} [attrs] Node's attributes. See {@link module:utils/tomap~toMap} for a list of accepted values.
37
- */
38
- constructor( data, attrs ) {
39
- super( attrs );
40
-
41
- /**
42
- * Text data contained in this text node.
43
- *
44
- * @protected
45
- * @type {String}
46
- */
47
- this._data = data || '';
48
- }
49
-
50
- /**
51
- * @inheritDoc
52
- */
53
- get offsetSize() {
54
- return this.data.length;
55
- }
56
-
57
- /**
58
- * Returns a text data contained in the node.
59
- *
60
- * @readonly
61
- * @type {String}
62
- */
63
- get data() {
64
- return this._data;
65
- }
66
-
67
- /**
68
- * Checks whether this object is of the given.
69
- *
70
- * text.is( '$text' ); // -> true
71
- * text.is( 'node' ); // -> true
72
- * text.is( 'model:$text' ); // -> true
73
- * text.is( 'model:node' ); // -> true
74
- *
75
- * text.is( 'view:$text' ); // -> false
76
- * text.is( 'documentSelection' ); // -> false
77
- *
78
- * {@link module:engine/model/node~Node#is Check the entire list of model objects} which implement the `is()` method.
79
- *
80
- * **Note:** Until version 20.0.0 this method wasn't accepting `'$text'` type. The legacy `'text'` type is still
81
- * accepted for backward compatibility.
82
- *
83
- * @param {String} type Type to check.
84
- * @returns {Boolean}
85
- */
86
- is( type ) {
87
- return type === '$text' || type === 'model:$text' ||
88
- // This are legacy values kept for backward compatibility.
89
- type === 'text' || type === 'model:text' ||
90
- // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
91
- type === 'node' || type === 'model:node';
92
- }
93
-
94
- /**
95
- * Converts `Text` instance to plain object and returns it.
96
- *
97
- * @returns {Object} `Text` instance converted to plain object.
98
- */
99
- toJSON() {
100
- const json = super.toJSON();
101
-
102
- json.data = this.data;
103
-
104
- return json;
105
- }
106
-
107
- /**
108
- * Creates a copy of this text node and returns it. Created text node has same text data and attributes as original text node.
109
- *
110
- * @protected
111
- * @returns {module:engine/model/text~Text} `Text` instance created using given plain object.
112
- */
113
- _clone() {
114
- return new Text( this.data, this.getAttributes() );
115
- }
116
-
117
- /**
118
- * Creates a `Text` instance from given plain object (i.e. parsed JSON string).
119
- *
120
- * @param {Object} json Plain object to be converted to `Text`.
121
- * @returns {module:engine/model/text~Text} `Text` instance created using given plain object.
122
- */
123
- static fromJSON( json ) {
124
- return new Text( json.data, json.attributes );
125
- }
126
-
127
- // @if CK_DEBUG_ENGINE // toString() {
128
- // @if CK_DEBUG_ENGINE // return `#${ this.data }`;
129
- // @if CK_DEBUG_ENGINE // }
130
-
131
- // @if CK_DEBUG_ENGINE // logExtended() {
132
- // @if CK_DEBUG_ENGINE // console.log( `ModelText: ${ this }, attrs: ${ convertMapToStringifiedObject( this.getAttributes() ) }` );
133
- // @if CK_DEBUG_ENGINE // }
134
-
135
- // @if CK_DEBUG_ENGINE // log() {
136
- // @if CK_DEBUG_ENGINE // console.log( 'ModelText: ' + this );
137
- // @if CK_DEBUG_ENGINE // }
24
+ /**
25
+ * Creates a text node.
26
+ *
27
+ * **Note:** Constructor of this class shouldn't be used directly in the code.
28
+ * Use the {@link module:engine/model/writer~Writer#createText} method instead.
29
+ *
30
+ * @protected
31
+ * @param {String} [data] Node's text.
32
+ * @param {Object} [attrs] Node's attributes. See {@link module:utils/tomap~toMap} for a list of accepted values.
33
+ */
34
+ constructor(data, attrs) {
35
+ super(attrs);
36
+ /**
37
+ * Text data contained in this text node.
38
+ *
39
+ * @protected
40
+ * @type {String}
41
+ */
42
+ this._data = data || '';
43
+ }
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ get offsetSize() {
48
+ return this.data.length;
49
+ }
50
+ /**
51
+ * Returns a text data contained in the node.
52
+ *
53
+ * @readonly
54
+ * @type {String}
55
+ */
56
+ get data() {
57
+ return this._data;
58
+ }
59
+ /**
60
+ * Converts `Text` instance to plain object and returns it.
61
+ *
62
+ * @returns {Object} `Text` instance converted to plain object.
63
+ */
64
+ toJSON() {
65
+ const json = super.toJSON();
66
+ json.data = this.data;
67
+ return json;
68
+ }
69
+ /**
70
+ * Creates a copy of this text node and returns it. Created text node has same text data and attributes as original text node.
71
+ *
72
+ * @internal
73
+ * @protected
74
+ * @returns {module:engine/model/text~Text} `Text` instance created using given plain object.
75
+ */
76
+ _clone() {
77
+ return new Text(this.data, this.getAttributes());
78
+ }
79
+ /**
80
+ * Creates a `Text` instance from given plain object (i.e. parsed JSON string).
81
+ *
82
+ * @param {Object} json Plain object to be converted to `Text`.
83
+ * @returns {module:engine/model/text~Text} `Text` instance created using given plain object.
84
+ */
85
+ static fromJSON(json) {
86
+ return new Text(json.data, json.attributes);
87
+ }
138
88
  }
89
+ /**
90
+ * Checks whether this object is of the given.
91
+ *
92
+ * text.is( '$text' ); // -> true
93
+ * text.is( 'node' ); // -> true
94
+ * text.is( 'model:$text' ); // -> true
95
+ * text.is( 'model:node' ); // -> true
96
+ *
97
+ * text.is( 'view:$text' ); // -> false
98
+ * text.is( 'documentSelection' ); // -> false
99
+ *
100
+ * {@link module:engine/model/node~Node#is Check the entire list of model objects} which implement the `is()` method.
101
+ *
102
+ * **Note:** Until version 20.0.0 this method wasn't accepting `'$text'` type. The legacy `'text'` type is still
103
+ * accepted for backward compatibility.
104
+ *
105
+ * @param {String} type Type to check.
106
+ * @returns {Boolean}
107
+ */
108
+ Text.prototype.is = function (type) {
109
+ return type === '$text' || type === 'model:$text' ||
110
+ // This are legacy values kept for backward compatibility.
111
+ type === 'text' || type === 'model:text' ||
112
+ // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
113
+ type === 'node' || type === 'model:node';
114
+ };