@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/index.js CHANGED
@@ -2,25 +2,18 @@
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
8
7
  */
9
-
10
8
  export * from './view/placeholder';
11
-
12
9
  export { default as EditingController } from './controller/editingcontroller';
13
10
  export { default as DataController } from './controller/datacontroller';
14
-
15
11
  export { default as Conversion } from './conversion/conversion';
16
-
17
12
  export { default as HtmlDataProcessor } from './dataprocessor/htmldataprocessor';
18
-
19
13
  export { default as InsertOperation } from './model/operation/insertoperation';
20
14
  export { default as MarkerOperation } from './model/operation/markeroperation';
21
15
  export { default as OperationFactory } from './model/operation/operationfactory';
22
16
  export { transformSets } from './model/operation/transform';
23
-
24
17
  export { default as DocumentSelection } from './model/documentselection';
25
18
  export { default as Range } from './model/range';
26
19
  export { default as LiveRange } from './model/liverange';
@@ -32,7 +25,6 @@ export { default as Position } from './model/position';
32
25
  export { default as DocumentFragment } from './model/documentfragment';
33
26
  export { default as History } from './model/history';
34
27
  export { default as Text } from './model/text';
35
-
36
28
  export { default as DomConverter } from './view/domconverter';
37
29
  export { default as Renderer } from './view/renderer';
38
30
  export { default as ViewDocument } from './view/document';
@@ -44,7 +36,6 @@ export { default as ViewEmptyElement } from './view/emptyelement';
44
36
  export { default as ViewRawElement } from './view/rawelement';
45
37
  export { default as ViewUIElement } from './view/uielement';
46
38
  export { default as ViewDocumentFragment } from './view/documentfragment';
47
-
48
39
  export { getFillerOffset } from './view/containerelement';
49
40
  export { default as Observer } from './view/observer/observer';
50
41
  export { default as ClickObserver } from './view/observer/clickobserver';
@@ -53,9 +44,7 @@ export { default as MouseObserver } from './view/observer/mouseobserver';
53
44
  export { default as DowncastWriter } from './view/downcastwriter';
54
45
  export { default as UpcastWriter } from './view/upcastwriter';
55
46
  export { default as Matcher } from './view/matcher';
56
-
57
47
  export { default as DomEventData } from './view/observer/domeventdata';
58
-
59
48
  export { StylesProcessor } from './view/stylesmap';
60
49
  export * from './view/styles/background';
61
50
  export * from './view/styles/border';
@@ -2,13 +2,10 @@
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/batch
8
7
  */
9
-
10
8
  import { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
11
-
12
9
  /**
13
10
  * A batch instance groups model changes ({@link module:engine/model/operation/operation~Operation operations}). All operations
14
11
  * grouped in a single batch can be reverted together, so you can also think about a batch as of a single undo step. If you want
@@ -22,128 +19,115 @@ import { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
22
19
  * @see module:engine/model/model~Model#change
23
20
  */
24
21
  export default class Batch {
25
- /**
26
- * Creates a batch instance.
27
- *
28
- * @see module:engine/model/model~Model#enqueueChange
29
- * @see module:engine/model/model~Model#change
30
- * @param {Object} [type] A set of flags that specify the type of the batch. Batch type can alter how some of the features work
31
- * when encountering a given `Batch` instance (for example, when a feature listens to applied operations).
32
- * @param {Boolean} [type.isUndoable=true] Whether a batch can be undone through undo feature.
33
- * @param {Boolean} [type.isLocal=true] Whether a batch includes operations created locally (`true`) or operations created on
34
- * other, remote editors (`false`).
35
- * @param {Boolean} [type.isUndo=false] Whether a batch was created by the undo feature and undoes other operations.
36
- * @param {Boolean} [type.isTyping=false] Whether a batch includes operations connected with a typing action.
37
- */
38
- constructor( type = {} ) {
39
- if ( typeof type === 'string' ) {
40
- type = type === 'transparent' ? { isUndoable: false } : {};
41
-
42
- /**
43
- * The string value for a `type` property of the `Batch` constructor has been deprecated and will be removed in the near future.
44
- * Please refer to the {@link module:engine/model/batch~Batch#constructor `Batch` constructor API documentation} for more
45
- * information.
46
- *
47
- * @error batch-constructor-deprecated-string-type
48
- */
49
- logWarning( 'batch-constructor-deprecated-string-type' );
50
- }
51
-
52
- const { isUndoable = true, isLocal = true, isUndo = false, isTyping = false } = type;
53
-
54
- /**
55
- * An array of operations that compose this batch.
56
- *
57
- * @readonly
58
- * @type {Array.<module:engine/model/operation/operation~Operation>}
59
- */
60
- this.operations = [];
61
-
62
- /**
63
- * Whether the batch can be undone through the undo feature.
64
- *
65
- * @readonly
66
- * @type {Boolean}
67
- */
68
- this.isUndoable = isUndoable;
69
-
70
- /**
71
- * Whether the batch includes operations created locally (`true`) or operations created on other, remote editors (`false`).
72
- *
73
- * @readonly
74
- * @type {Boolean}
75
- */
76
- this.isLocal = isLocal;
77
-
78
- /**
79
- * Whether the batch was created by the undo feature and undoes other operations.
80
- *
81
- * @readonly
82
- * @type {Boolean}
83
- */
84
- this.isUndo = isUndo;
85
-
86
- /**
87
- * Whether the batch includes operations connected with typing.
88
- *
89
- * @readonly
90
- * @type {Boolean}
91
- */
92
- this.isTyping = isTyping;
93
- }
94
-
95
- /**
96
- * The type of the batch.
97
- *
98
- * **This property has been deprecated and is always set to the `'default'` value.**
99
- *
100
- * It can be one of the following values:
101
- * * `'default'` &ndash; All "normal" batches. This is the most commonly used type.
102
- * * `'transparent'` &ndash; A batch that should be ignored by other features, i.e. an initial batch or collaborative editing
103
- * changes.
104
- *
105
- * @deprecated
106
- * @type {'default'}
107
- */
108
- get type() {
109
- /**
110
- * The {@link module:engine/model/batch~Batch#type `Batch#type` } property has been deprecated and will be removed in the near
111
- * future. Use `Batch#isLocal`, `Batch#isUndoable`, `Batch#isUndo` and `Batch#isTyping` instead.
112
- *
113
- * @error batch-type-deprecated
114
- */
115
- logWarning( 'batch-type-deprecated' );
116
-
117
- return 'default';
118
- }
119
-
120
- /**
121
- * Returns the base version of this batch, which is equal to the base version of the first operation in the batch.
122
- * If there are no operations in the batch or neither operation has the base version set, it returns `null`.
123
- *
124
- * @readonly
125
- * @type {Number|null}
126
- */
127
- get baseVersion() {
128
- for ( const op of this.operations ) {
129
- if ( op.baseVersion !== null ) {
130
- return op.baseVersion;
131
- }
132
- }
133
-
134
- return null;
135
- }
136
-
137
- /**
138
- * Adds an operation to the batch instance.
139
- *
140
- * @param {module:engine/model/operation/operation~Operation} operation An operation to add.
141
- * @returns {module:engine/model/operation/operation~Operation} The added operation.
142
- */
143
- addOperation( operation ) {
144
- operation.batch = this;
145
- this.operations.push( operation );
146
-
147
- return operation;
148
- }
22
+ /**
23
+ * Creates a batch instance.
24
+ *
25
+ * @see module:engine/model/model~Model#enqueueChange
26
+ * @see module:engine/model/model~Model#change
27
+ * @param {Object} [type] A set of flags that specify the type of the batch. Batch type can alter how some of the features work
28
+ * when encountering a given `Batch` instance (for example, when a feature listens to applied operations).
29
+ * @param {Boolean} [type.isUndoable=true] Whether a batch can be undone through undo feature.
30
+ * @param {Boolean} [type.isLocal=true] Whether a batch includes operations created locally (`true`) or operations created on
31
+ * other, remote editors (`false`).
32
+ * @param {Boolean} [type.isUndo=false] Whether a batch was created by the undo feature and undoes other operations.
33
+ * @param {Boolean} [type.isTyping=false] Whether a batch includes operations connected with a typing action.
34
+ */
35
+ constructor(type = {}) {
36
+ if (typeof type === 'string') {
37
+ type = type === 'transparent' ? { isUndoable: false } : {};
38
+ /**
39
+ * The string value for a `type` property of the `Batch` constructor has been deprecated and will be removed in the near future.
40
+ * Please refer to the {@link module:engine/model/batch~Batch#constructor `Batch` constructor API documentation} for more
41
+ * information.
42
+ *
43
+ * @error batch-constructor-deprecated-string-type
44
+ */
45
+ logWarning('batch-constructor-deprecated-string-type');
46
+ }
47
+ const { isUndoable = true, isLocal = true, isUndo = false, isTyping = false } = type;
48
+ /**
49
+ * An array of operations that compose this batch.
50
+ *
51
+ * @readonly
52
+ * @type {Array.<module:engine/model/operation/operation~Operation>}
53
+ */
54
+ this.operations = [];
55
+ /**
56
+ * Whether the batch can be undone through the undo feature.
57
+ *
58
+ * @readonly
59
+ * @type {Boolean}
60
+ */
61
+ this.isUndoable = isUndoable;
62
+ /**
63
+ * Whether the batch includes operations created locally (`true`) or operations created on other, remote editors (`false`).
64
+ *
65
+ * @readonly
66
+ * @type {Boolean}
67
+ */
68
+ this.isLocal = isLocal;
69
+ /**
70
+ * Whether the batch was created by the undo feature and undoes other operations.
71
+ *
72
+ * @readonly
73
+ * @type {Boolean}
74
+ */
75
+ this.isUndo = isUndo;
76
+ /**
77
+ * Whether the batch includes operations connected with typing.
78
+ *
79
+ * @readonly
80
+ * @type {Boolean}
81
+ */
82
+ this.isTyping = isTyping;
83
+ }
84
+ /**
85
+ * The type of the batch.
86
+ *
87
+ * **This property has been deprecated and is always set to the `'default'` value.**
88
+ *
89
+ * It can be one of the following values:
90
+ * * `'default'` &ndash; All "normal" batches. This is the most commonly used type.
91
+ * * `'transparent'` &ndash; A batch that should be ignored by other features, i.e. an initial batch or collaborative editing
92
+ * changes.
93
+ *
94
+ * @deprecated
95
+ * @type {'default'}
96
+ */
97
+ get type() {
98
+ /**
99
+ * The {@link module:engine/model/batch~Batch#type `Batch#type` } property has been deprecated and will be removed in the near
100
+ * future. Use `Batch#isLocal`, `Batch#isUndoable`, `Batch#isUndo` and `Batch#isTyping` instead.
101
+ *
102
+ * @error batch-type-deprecated
103
+ */
104
+ logWarning('batch-type-deprecated');
105
+ return 'default';
106
+ }
107
+ /**
108
+ * Returns the base version of this batch, which is equal to the base version of the first operation in the batch.
109
+ * If there are no operations in the batch or neither operation has the base version set, it returns `null`.
110
+ *
111
+ * @readonly
112
+ * @type {Number|null}
113
+ */
114
+ get baseVersion() {
115
+ for (const op of this.operations) {
116
+ if (op.baseVersion !== null) {
117
+ return op.baseVersion;
118
+ }
119
+ }
120
+ return null;
121
+ }
122
+ /**
123
+ * Adds an operation to the batch instance.
124
+ *
125
+ * @param {module:engine/model/operation/operation~Operation} operation An operation to add.
126
+ * @returns {module:engine/model/operation/operation~Operation} The added operation.
127
+ */
128
+ addOperation(operation) {
129
+ operation.batch = this;
130
+ this.operations.push(operation);
131
+ return operation;
132
+ }
149
133
  }