@ckeditor/ckeditor5-engine 36.0.1 → 37.0.0-alpha.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 (200) hide show
  1. package/README.md +1 -1
  2. package/package.json +24 -23
  3. package/src/controller/datacontroller.d.ts +331 -0
  4. package/src/controller/datacontroller.js +62 -109
  5. package/src/controller/editingcontroller.d.ts +98 -0
  6. package/src/controller/editingcontroller.js +22 -46
  7. package/src/conversion/conversion.d.ts +476 -0
  8. package/src/conversion/conversion.js +328 -347
  9. package/src/conversion/conversionhelpers.d.ts +26 -0
  10. package/src/conversion/conversionhelpers.js +1 -5
  11. package/src/conversion/downcastdispatcher.d.ts +547 -0
  12. package/src/conversion/downcastdispatcher.js +74 -152
  13. package/src/conversion/downcasthelpers.d.ts +1226 -0
  14. package/src/conversion/downcasthelpers.js +843 -762
  15. package/src/conversion/mapper.d.ts +499 -0
  16. package/src/conversion/mapper.js +84 -99
  17. package/src/conversion/modelconsumable.d.ts +201 -0
  18. package/src/conversion/modelconsumable.js +96 -99
  19. package/src/conversion/upcastdispatcher.d.ts +492 -0
  20. package/src/conversion/upcastdispatcher.js +73 -100
  21. package/src/conversion/upcasthelpers.d.ts +499 -0
  22. package/src/conversion/upcasthelpers.js +406 -373
  23. package/src/conversion/viewconsumable.d.ts +177 -0
  24. package/src/conversion/viewconsumable.js +157 -162
  25. package/src/dataprocessor/basichtmlwriter.d.ts +18 -0
  26. package/src/dataprocessor/basichtmlwriter.js +0 -9
  27. package/src/dataprocessor/dataprocessor.d.ts +61 -0
  28. package/src/dataprocessor/htmldataprocessor.d.ts +76 -0
  29. package/src/dataprocessor/htmldataprocessor.js +6 -28
  30. package/src/dataprocessor/htmlwriter.d.ts +16 -0
  31. package/src/dataprocessor/xmldataprocessor.d.ts +90 -0
  32. package/src/dataprocessor/xmldataprocessor.js +8 -40
  33. package/src/dev-utils/model.d.ts +124 -0
  34. package/src/dev-utils/model.js +41 -38
  35. package/src/dev-utils/operationreplayer.d.ts +51 -0
  36. package/src/dev-utils/operationreplayer.js +6 -14
  37. package/src/dev-utils/utils.d.ts +37 -0
  38. package/src/dev-utils/utils.js +5 -18
  39. package/src/dev-utils/view.d.ts +319 -0
  40. package/src/dev-utils/view.js +205 -226
  41. package/src/index.d.ts +105 -0
  42. package/src/index.js +1 -0
  43. package/src/model/batch.d.ts +106 -0
  44. package/src/model/differ.d.ts +329 -0
  45. package/src/model/document.d.ts +245 -0
  46. package/src/model/document.js +1 -1
  47. package/src/model/documentfragment.d.ts +196 -0
  48. package/src/model/documentfragment.js +2 -2
  49. package/src/model/documentselection.d.ts +420 -0
  50. package/src/model/element.d.ts +165 -0
  51. package/src/model/history.d.ts +114 -0
  52. package/src/model/item.d.ts +14 -0
  53. package/src/model/liveposition.d.ts +77 -0
  54. package/src/model/liverange.d.ts +102 -0
  55. package/src/model/markercollection.d.ts +335 -0
  56. package/src/model/model.d.ts +812 -0
  57. package/src/model/model.js +59 -30
  58. package/src/model/node.d.ts +256 -0
  59. package/src/model/nodelist.d.ts +91 -0
  60. package/src/model/operation/attributeoperation.d.ts +98 -0
  61. package/src/model/operation/detachoperation.d.ts +55 -0
  62. package/src/model/operation/insertoperation.d.ts +85 -0
  63. package/src/model/operation/markeroperation.d.ts +86 -0
  64. package/src/model/operation/mergeoperation.d.ts +95 -0
  65. package/src/model/operation/moveoperation.d.ts +91 -0
  66. package/src/model/operation/nooperation.d.ts +33 -0
  67. package/src/model/operation/operation.d.ts +89 -0
  68. package/src/model/operation/operationfactory.d.ts +18 -0
  69. package/src/model/operation/renameoperation.d.ts +78 -0
  70. package/src/model/operation/rootattributeoperation.d.ts +97 -0
  71. package/src/model/operation/rootattributeoperation.js +1 -1
  72. package/src/model/operation/splitoperation.d.ts +104 -0
  73. package/src/model/operation/transform.d.ts +100 -0
  74. package/src/model/operation/utils.d.ts +71 -0
  75. package/src/model/position.d.ts +539 -0
  76. package/src/model/position.js +1 -1
  77. package/src/model/range.d.ts +458 -0
  78. package/src/model/range.js +1 -1
  79. package/src/model/rootelement.d.ts +40 -0
  80. package/src/model/schema.d.ts +1176 -0
  81. package/src/model/schema.js +15 -15
  82. package/src/model/selection.d.ts +472 -0
  83. package/src/model/text.d.ts +66 -0
  84. package/src/model/text.js +0 -2
  85. package/src/model/textproxy.d.ts +144 -0
  86. package/src/model/treewalker.d.ts +186 -0
  87. package/src/model/treewalker.js +19 -10
  88. package/src/model/typecheckable.d.ts +255 -0
  89. package/src/model/utils/autoparagraphing.d.ts +37 -0
  90. package/src/model/utils/deletecontent.d.ts +58 -0
  91. package/src/model/utils/findoptimalinsertionrange.d.ts +32 -0
  92. package/src/model/utils/getselectedcontent.d.ts +30 -0
  93. package/src/model/utils/insertcontent.d.ts +46 -0
  94. package/src/model/utils/insertcontent.js +2 -12
  95. package/src/model/utils/insertobject.d.ts +44 -0
  96. package/src/model/utils/insertobject.js +3 -14
  97. package/src/model/utils/modifyselection.d.ts +48 -0
  98. package/src/model/utils/selection-post-fixer.d.ts +65 -0
  99. package/src/model/writer.d.ts +726 -0
  100. package/src/model/writer.js +6 -4
  101. package/src/view/attributeelement.d.ts +108 -0
  102. package/src/view/attributeelement.js +25 -69
  103. package/src/view/containerelement.d.ts +49 -0
  104. package/src/view/containerelement.js +10 -43
  105. package/src/view/datatransfer.d.ts +75 -0
  106. package/src/view/document.d.ts +184 -0
  107. package/src/view/document.js +15 -84
  108. package/src/view/documentfragment.d.ts +150 -0
  109. package/src/view/documentfragment.js +40 -81
  110. package/src/view/documentselection.d.ts +219 -0
  111. package/src/view/documentselection.js +75 -121
  112. package/src/view/domconverter.d.ts +620 -0
  113. package/src/view/domconverter.js +159 -276
  114. package/src/view/downcastwriter.d.ts +804 -0
  115. package/src/view/downcastwriter.js +336 -380
  116. package/src/view/editableelement.d.ts +52 -0
  117. package/src/view/editableelement.js +9 -49
  118. package/src/view/element.d.ts +466 -0
  119. package/src/view/element.js +150 -222
  120. package/src/view/elementdefinition.d.ts +87 -0
  121. package/src/view/emptyelement.d.ts +41 -0
  122. package/src/view/emptyelement.js +11 -44
  123. package/src/view/filler.d.ts +111 -0
  124. package/src/view/filler.js +24 -21
  125. package/src/view/item.d.ts +14 -0
  126. package/src/view/matcher.d.ts +486 -0
  127. package/src/view/matcher.js +247 -218
  128. package/src/view/node.d.ts +160 -0
  129. package/src/view/node.js +26 -100
  130. package/src/view/observer/arrowkeysobserver.d.ts +41 -0
  131. package/src/view/observer/arrowkeysobserver.js +0 -13
  132. package/src/view/observer/bubblingemittermixin.d.ts +166 -0
  133. package/src/view/observer/bubblingemittermixin.js +36 -25
  134. package/src/view/observer/bubblingeventinfo.d.ts +47 -0
  135. package/src/view/observer/bubblingeventinfo.js +3 -29
  136. package/src/view/observer/clickobserver.d.ts +43 -0
  137. package/src/view/observer/clickobserver.js +9 -19
  138. package/src/view/observer/compositionobserver.d.ts +82 -0
  139. package/src/view/observer/compositionobserver.js +13 -42
  140. package/src/view/observer/domeventdata.d.ts +50 -0
  141. package/src/view/observer/domeventdata.js +5 -30
  142. package/src/view/observer/domeventobserver.d.ts +69 -0
  143. package/src/view/observer/domeventobserver.js +19 -21
  144. package/src/view/observer/fakeselectionobserver.d.ts +46 -0
  145. package/src/view/observer/fakeselectionobserver.js +2 -15
  146. package/src/view/observer/focusobserver.d.ts +82 -0
  147. package/src/view/observer/focusobserver.js +14 -40
  148. package/src/view/observer/inputobserver.d.ts +86 -0
  149. package/src/view/observer/inputobserver.js +18 -64
  150. package/src/view/observer/keyobserver.d.ts +67 -0
  151. package/src/view/observer/keyobserver.js +8 -42
  152. package/src/view/observer/mouseobserver.d.ts +89 -0
  153. package/src/view/observer/mouseobserver.js +8 -28
  154. package/src/view/observer/mutationobserver.d.ts +82 -0
  155. package/src/view/observer/mutationobserver.js +7 -37
  156. package/src/view/observer/observer.d.ts +84 -0
  157. package/src/view/observer/observer.js +12 -25
  158. package/src/view/observer/selectionobserver.d.ts +143 -0
  159. package/src/view/observer/selectionobserver.js +9 -99
  160. package/src/view/observer/tabobserver.d.ts +42 -0
  161. package/src/view/observer/tabobserver.js +0 -14
  162. package/src/view/placeholder.d.ts +85 -0
  163. package/src/view/placeholder.js +26 -43
  164. package/src/view/position.d.ts +189 -0
  165. package/src/view/position.js +36 -83
  166. package/src/view/range.d.ts +279 -0
  167. package/src/view/range.js +79 -122
  168. package/src/view/rawelement.d.ts +73 -0
  169. package/src/view/rawelement.js +34 -48
  170. package/src/view/renderer.d.ts +265 -0
  171. package/src/view/renderer.js +105 -193
  172. package/src/view/rooteditableelement.d.ts +41 -0
  173. package/src/view/rooteditableelement.js +12 -40
  174. package/src/view/selection.d.ts +375 -0
  175. package/src/view/selection.js +79 -153
  176. package/src/view/styles/background.d.ts +33 -0
  177. package/src/view/styles/background.js +14 -12
  178. package/src/view/styles/border.d.ts +43 -0
  179. package/src/view/styles/border.js +58 -48
  180. package/src/view/styles/margin.d.ts +29 -0
  181. package/src/view/styles/margin.js +13 -11
  182. package/src/view/styles/padding.d.ts +29 -0
  183. package/src/view/styles/padding.js +13 -11
  184. package/src/view/styles/utils.d.ts +93 -0
  185. package/src/view/styles/utils.js +22 -48
  186. package/src/view/stylesmap.d.ts +675 -0
  187. package/src/view/stylesmap.js +249 -244
  188. package/src/view/text.d.ts +74 -0
  189. package/src/view/text.js +16 -46
  190. package/src/view/textproxy.d.ts +97 -0
  191. package/src/view/textproxy.js +10 -59
  192. package/src/view/treewalker.d.ts +195 -0
  193. package/src/view/treewalker.js +43 -106
  194. package/src/view/typecheckable.d.ts +401 -0
  195. package/src/view/uielement.d.ts +96 -0
  196. package/src/view/uielement.js +28 -62
  197. package/src/view/upcastwriter.d.ts +328 -0
  198. package/src/view/upcastwriter.js +124 -134
  199. package/src/view/view.d.ts +327 -0
  200. package/src/view/view.js +79 -150
@@ -29,16 +29,18 @@ import { CKEditorError, logWarning, toMap } from '@ckeditor/ckeditor5-utils';
29
29
  * The instance of the writer is only available in the {@link module:engine/model/model~Model#change `change()`} or
30
30
  * {@link module:engine/model/model~Model#enqueueChange `enqueueChange()`}.
31
31
  *
32
- * model.change( writer => {
33
- * writer.insertText( 'foo', paragraph, 'end' );
34
- * } );
32
+ * ```ts
33
+ * model.change( writer => {
34
+ * writer.insertText( 'foo', paragraph, 'end' );
35
+ * } );
36
+ * ```
35
37
  *
36
38
  * Note that the writer should never be stored and used outside of the `change()` and
37
39
  * `enqueueChange()` blocks.
38
40
  *
39
41
  * Note that writer's methods do not check the {@link module:engine/model/schema~Schema}. It is possible
40
42
  * to create incorrect model structures by using the writer. Read more about in
41
- * {@glink framework/guides/deep-dive/schema#who-checks-the-schema "Who checks the schema?"}.
43
+ * {@glink framework/deep-dive/schema#who-checks-the-schema "Who checks the schema?"}.
42
44
  *
43
45
  * @see module:engine/model/model~Model#change
44
46
  * @see module:engine/model/model~Model#enqueueChange
@@ -0,0 +1,108 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module engine/view/attributeelement
7
+ */
8
+ import Element, { type ElementAttributes } from './element';
9
+ import type Document from './document';
10
+ import type Node from './node';
11
+ /**
12
+ * Attribute elements are used to represent formatting elements in the view (think – `<b>`, `<span style="font-size: 2em">`, etc.).
13
+ * Most often they are created when downcasting model text attributes.
14
+ *
15
+ * Editing engine does not define a fixed HTML DTD. This is why a feature developer needs to choose between various
16
+ * types (container element, {@link module:engine/view/attributeelement~AttributeElement attribute element},
17
+ * {@link module:engine/view/emptyelement~EmptyElement empty element}, etc) when developing a feature.
18
+ *
19
+ * To create a new attribute element instance use the
20
+ * {@link module:engine/view/downcastwriter~DowncastWriter#createAttributeElement `DowncastWriter#createAttributeElement()`} method.
21
+ */
22
+ export default class AttributeElement extends Element {
23
+ static readonly DEFAULT_PRIORITY: number;
24
+ /**
25
+ * Element priority. Decides in what order elements are wrapped by {@link module:engine/view/downcastwriter~DowncastWriter}.
26
+ *
27
+ * @internal
28
+ * @readonly
29
+ */
30
+ _priority: number;
31
+ /**
32
+ * Element identifier. If set, it is used by {@link module:engine/view/element~Element#isSimilar},
33
+ * and then two elements are considered similar if, and only if they have the same `_id`.
34
+ *
35
+ * @internal
36
+ * @readonly
37
+ */
38
+ _id: string | number | null;
39
+ /**
40
+ * Keeps all the attribute elements that have the same {@link module:engine/view/attributeelement~AttributeElement#id ids}
41
+ * and still exist in the view tree.
42
+ *
43
+ * This property is managed by {@link module:engine/view/downcastwriter~DowncastWriter}.
44
+ */
45
+ private readonly _clonesGroup;
46
+ /**
47
+ * Creates an attribute element.
48
+ *
49
+ * @see module:engine/view/downcastwriter~DowncastWriter#createAttributeElement
50
+ * @see module:engine/view/element~Element
51
+ * @protected
52
+ * @param document The document instance to which this element belongs.
53
+ * @param name Node name.
54
+ * @param attrs Collection of attributes.
55
+ * @param children A list of nodes to be inserted into created element.
56
+ */
57
+ constructor(document: Document, name: string, attrs?: ElementAttributes, children?: Node | Iterable<Node>);
58
+ /**
59
+ * Element priority. Decides in what order elements are wrapped by {@link module:engine/view/downcastwriter~DowncastWriter}.
60
+ */
61
+ get priority(): number;
62
+ /**
63
+ * Element identifier. If set, it is used by {@link module:engine/view/element~Element#isSimilar},
64
+ * and then two elements are considered similar if, and only if they have the same `id`.
65
+ */
66
+ get id(): string | number | null;
67
+ /**
68
+ * Returns all {@link module:engine/view/attributeelement~AttributeElement attribute elements} that has the
69
+ * same {@link module:engine/view/attributeelement~AttributeElement#id id} and are in the view tree (were not removed).
70
+ *
71
+ * Note: If this element has been removed from the tree, returned set will not include it.
72
+ *
73
+ * Throws {@link module:utils/ckeditorerror~CKEditorError attribute-element-get-elements-with-same-id-no-id}
74
+ * if this element has no `id`.
75
+ *
76
+ * @returns Set containing all the attribute elements
77
+ * with the same `id` that were added and not removed from the view tree.
78
+ */
79
+ getElementsWithSameId(): Set<AttributeElement>;
80
+ /**
81
+ * Checks if this element is similar to other element.
82
+ *
83
+ * If none of elements has set {@link module:engine/view/attributeelement~AttributeElement#id}, then both elements
84
+ * should have the same name, attributes and priority to be considered as similar. Two similar elements can contain
85
+ * different set of children nodes.
86
+ *
87
+ * If at least one element has {@link module:engine/view/attributeelement~AttributeElement#id} set, then both
88
+ * elements have to have the same {@link module:engine/view/attributeelement~AttributeElement#id} value to be
89
+ * considered similar.
90
+ *
91
+ * Similarity is important for {@link module:engine/view/downcastwriter~DowncastWriter}. For example:
92
+ *
93
+ * * two following similar elements can be merged together into one, longer element,
94
+ * * {@link module:engine/view/downcastwriter~DowncastWriter#unwrap} checks similarity of passed element and processed element to
95
+ * decide whether processed element should be unwrapped,
96
+ * * etc.
97
+ */
98
+ isSimilar(otherElement: Element): boolean;
99
+ /**
100
+ * Clones provided element with priority.
101
+ *
102
+ * @internal
103
+ * @param deep If set to `true` clones element and all its children recursively. When set to `false`,
104
+ * element will be cloned without any children.
105
+ * @returns Clone of this element.
106
+ */
107
+ _clone(deep?: boolean): this;
108
+ }
@@ -19,8 +19,6 @@ const DEFAULT_PRIORITY = 10;
19
19
  *
20
20
  * To create a new attribute element instance use the
21
21
  * {@link module:engine/view/downcastwriter~DowncastWriter#createAttributeElement `DowncastWriter#createAttributeElement()`} method.
22
- *
23
- * @extends module:engine/view/element~Element
24
22
  */
25
23
  export default class AttributeElement extends Element {
26
24
  /**
@@ -29,34 +27,26 @@ export default class AttributeElement extends Element {
29
27
  * @see module:engine/view/downcastwriter~DowncastWriter#createAttributeElement
30
28
  * @see module:engine/view/element~Element
31
29
  * @protected
32
- * @param {module:engine/view/document~Document} document The document instance to which this element belongs.
33
- * @param {String} name Node name.
34
- * @param {Object|Iterable} [attrs] Collection of attributes.
35
- * @param {module:engine/view/node~Node|Iterable.<module:engine/view/node~Node>} [children]
36
- * A list of nodes to be inserted into created element.
30
+ * @param document The document instance to which this element belongs.
31
+ * @param name Node name.
32
+ * @param attrs Collection of attributes.
33
+ * @param children A list of nodes to be inserted into created element.
37
34
  */
38
- constructor(...args) {
39
- super(...args);
40
- /**
41
- * Returns block {@link module:engine/view/filler filler} offset or `null` if block filler is not needed.
42
- *
43
- * @method #getFillerOffset
44
- * @returns {Number|null} Block filler offset or `null` if block filler is not needed.
45
- */
46
- this.getFillerOffset = getFillerOffset;
35
+ constructor(document, name, attrs, children) {
36
+ super(document, name, attrs, children);
47
37
  /**
48
38
  * Element priority. Decides in what order elements are wrapped by {@link module:engine/view/downcastwriter~DowncastWriter}.
49
39
  *
50
- * @protected
51
- * @member {Number}
40
+ * @internal
41
+ * @readonly
52
42
  */
53
43
  this._priority = DEFAULT_PRIORITY;
54
44
  /**
55
45
  * Element identifier. If set, it is used by {@link module:engine/view/element~Element#isSimilar},
56
46
  * and then two elements are considered similar if, and only if they have the same `_id`.
57
47
  *
58
- * @protected
59
- * @member {String|Number}
48
+ * @internal
49
+ * @readonly
60
50
  */
61
51
  this._id = null;
62
52
  /**
@@ -64,17 +54,12 @@ export default class AttributeElement extends Element {
64
54
  * and still exist in the view tree.
65
55
  *
66
56
  * This property is managed by {@link module:engine/view/downcastwriter~DowncastWriter}.
67
- *
68
- * @protected
69
- * @member {Set.<module:engine/view/attributeelement~AttributeElement>|null}
70
57
  */
71
58
  this._clonesGroup = null;
59
+ this.getFillerOffset = getFillerOffset;
72
60
  }
73
61
  /**
74
62
  * Element priority. Decides in what order elements are wrapped by {@link module:engine/view/downcastwriter~DowncastWriter}.
75
- *
76
- * @readonly
77
- * @type {Number}
78
63
  */
79
64
  get priority() {
80
65
  return this._priority;
@@ -82,9 +67,6 @@ export default class AttributeElement extends Element {
82
67
  /**
83
68
  * Element identifier. If set, it is used by {@link module:engine/view/element~Element#isSimilar},
84
69
  * and then two elements are considered similar if, and only if they have the same `id`.
85
- *
86
- * @readonly
87
- * @type {String|Number}
88
70
  */
89
71
  get id() {
90
72
  return this._id;
@@ -98,7 +80,7 @@ export default class AttributeElement extends Element {
98
80
  * Throws {@link module:utils/ckeditorerror~CKEditorError attribute-element-get-elements-with-same-id-no-id}
99
81
  * if this element has no `id`.
100
82
  *
101
- * @returns {Set.<module:engine/view/attributeelement~AttributeElement>} Set containing all the attribute elements
83
+ * @returns Set containing all the attribute elements
102
84
  * with the same `id` that were added and not removed from the view tree.
103
85
  */
104
86
  getElementsWithSameId() {
@@ -129,9 +111,6 @@ export default class AttributeElement extends Element {
129
111
  * * {@link module:engine/view/downcastwriter~DowncastWriter#unwrap} checks similarity of passed element and processed element to
130
112
  * decide whether processed element should be unwrapped,
131
113
  * * etc.
132
- *
133
- * @param {module:engine/view/element~Element} otherElement
134
- * @returns {Boolean}
135
114
  */
136
115
  isSimilar(otherElement) {
137
116
  // If any element has an `id` set, just compare the ids.
@@ -143,10 +122,10 @@ export default class AttributeElement extends Element {
143
122
  /**
144
123
  * Clones provided element with priority.
145
124
  *
146
- * @protected
147
- * @param {Boolean} deep If set to `true` clones element and all its children recursively. When set to `false`,
125
+ * @internal
126
+ * @param deep If set to `true` clones element and all its children recursively. When set to `false`,
148
127
  * element will be cloned without any children.
149
- * @returns {module:engine/view/attributeelement~AttributeElement} Clone of this element.
128
+ * @returns Clone of this element.
150
129
  */
151
130
  _clone(deep = false) {
152
131
  const cloned = super._clone(deep);
@@ -158,32 +137,8 @@ export default class AttributeElement extends Element {
158
137
  }
159
138
  }
160
139
  AttributeElement.DEFAULT_PRIORITY = DEFAULT_PRIORITY;
161
- /**
162
- * Checks whether this object is of the given.
163
- *
164
- * attributeElement.is( 'attributeElement' ); // -> true
165
- * attributeElement.is( 'element' ); // -> true
166
- * attributeElement.is( 'node' ); // -> true
167
- * attributeElement.is( 'view:attributeElement' ); // -> true
168
- * attributeElement.is( 'view:element' ); // -> true
169
- * attributeElement.is( 'view:node' ); // -> true
170
- *
171
- * attributeElement.is( 'model:element' ); // -> false
172
- * attributeElement.is( 'documentFragment' ); // -> false
173
- *
174
- * Assuming that the object being checked is an attribute element, you can also check its
175
- * {@link module:engine/view/attributeelement~AttributeElement#name name}:
176
- *
177
- * attributeElement.is( 'element', 'b' ); // -> true if this is a bold element
178
- * attributeElement.is( 'attributeElement', 'b' ); // -> same as above
179
- * text.is( 'element', 'b' ); -> false
180
- *
181
- * {@link module:engine/view/node~Node#is Check the entire list of view objects} which implement the `is()` method.
182
- *
183
- * @param {String} type Type to check.
184
- * @param {String} [name] Element name.
185
- * @returns {Boolean}
186
- */
140
+ // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
141
+ // Proper overload would interfere with that.
187
142
  AttributeElement.prototype.is = function (type, name) {
188
143
  if (!name) {
189
144
  return type === 'attributeElement' || type === 'view:attributeElement' ||
@@ -197,9 +152,11 @@ AttributeElement.prototype.is = function (type, name) {
197
152
  type === 'element' || type === 'view:element');
198
153
  }
199
154
  };
200
- // Returns block {@link module:engine/view/filler~Filler filler} offset or `null` if block filler is not needed.
201
- //
202
- // @returns {Number|null} Block filler offset or `null` if block filler is not needed.
155
+ /**
156
+ * Returns block {@link module:engine/view/filler~Filler filler} offset or `null` if block filler is not needed.
157
+ *
158
+ * @returns Block filler offset or `null` if block filler is not needed.
159
+ */
203
160
  function getFillerOffset() {
204
161
  // <b>foo</b> does not need filler.
205
162
  if (nonUiChildrenCount(this)) {
@@ -219,10 +176,9 @@ function getFillerOffset() {
219
176
  // Render block filler at the end of element (after all ui elements).
220
177
  return this.childCount;
221
178
  }
222
- // Returns total count of children that are not {@link module:engine/view/uielement~UIElement UIElements}.
223
- //
224
- // @param {module:engine/view/element~Element} element
225
- // @returns {Number}
179
+ /**
180
+ * Returns total count of children that are not {@link module:engine/view/uielement~UIElement UIElements}.
181
+ */
226
182
  function nonUiChildrenCount(element) {
227
183
  return Array.from(element.getChildren()).filter(element => !element.is('uiElement')).length;
228
184
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module engine/view/containerelement
7
+ */
8
+ import Element, { type ElementAttributes } from './element';
9
+ import type Document from './document';
10
+ import type Node from './node';
11
+ /**
12
+ * Containers are elements which define document structure. They define boundaries for
13
+ * {@link module:engine/view/attributeelement~AttributeElement attributes}. They are mostly used for block elements like `<p>` or `<div>`.
14
+ *
15
+ * Editing engine does not define a fixed HTML DTD. This is why a feature developer needs to choose between various
16
+ * types (container element, {@link module:engine/view/attributeelement~AttributeElement attribute element},
17
+ * {@link module:engine/view/emptyelement~EmptyElement empty element}, etc) when developing a feature.
18
+ *
19
+ * The container element should be your default choice when writing a converter, unless:
20
+ *
21
+ * * this element represents a model text attribute (then use {@link module:engine/view/attributeelement~AttributeElement}),
22
+ * * this is an empty element like `<img>` (then use {@link module:engine/view/emptyelement~EmptyElement}),
23
+ * * this is a root element,
24
+ * * this is a nested editable element (then use {@link module:engine/view/editableelement~EditableElement}).
25
+ *
26
+ * To create a new container element instance use the
27
+ * {@link module:engine/view/downcastwriter~DowncastWriter#createContainerElement `DowncastWriter#createContainerElement()`}
28
+ * method.
29
+ */
30
+ export default class ContainerElement extends Element {
31
+ /**
32
+ * Creates a container element.
33
+ *
34
+ * @see module:engine/view/downcastwriter~DowncastWriter#createContainerElement
35
+ * @see module:engine/view/element~Element
36
+ * @internal
37
+ * @param document The document instance to which this element belongs.
38
+ * @param name Node name.
39
+ * @param attrs Collection of attributes.
40
+ * @param children A list of nodes to be inserted into created element.
41
+ */
42
+ constructor(document: Document, name: string, attrs?: ElementAttributes, children?: Node | Iterable<Node>);
43
+ }
44
+ /**
45
+ * Returns block {@link module:engine/view/filler filler} offset or `null` if block filler is not needed.
46
+ *
47
+ * @returns Block filler offset or `null` if block filler is not needed.
48
+ */
49
+ export declare function getFillerOffset(this: ContainerElement): number | null;
@@ -24,8 +24,6 @@ import Element from './element';
24
24
  * To create a new container element instance use the
25
25
  * {@link module:engine/view/downcastwriter~DowncastWriter#createContainerElement `DowncastWriter#createContainerElement()`}
26
26
  * method.
27
- *
28
- * @extends module:engine/view/element~Element
29
27
  */
30
28
  export default class ContainerElement extends Element {
31
29
  /**
@@ -33,50 +31,19 @@ export default class ContainerElement extends Element {
33
31
  *
34
32
  * @see module:engine/view/downcastwriter~DowncastWriter#createContainerElement
35
33
  * @see module:engine/view/element~Element
36
- * @protected
37
- * @param {module:engine/view/document~Document} document The document instance to which this element belongs.
38
- * @param {String} name Node name.
39
- * @param {Object|Iterable} [attrs] Collection of attributes.
40
- * @param {module:engine/view/node~Node|Iterable.<module:engine/view/node~Node>} [children]
41
- * A list of nodes to be inserted into created element.
34
+ * @internal
35
+ * @param document The document instance to which this element belongs.
36
+ * @param name Node name.
37
+ * @param attrs Collection of attributes.
38
+ * @param children A list of nodes to be inserted into created element.
42
39
  */
43
- constructor(...args) {
44
- super(...args);
45
- /**
46
- * Returns block {@link module:engine/view/filler filler} offset or `null` if block filler is not needed.
47
- *
48
- * @method #getFillerOffset
49
- * @returns {Number|null} Block filler offset or `null` if block filler is not needed.
50
- */
40
+ constructor(document, name, attrs, children) {
41
+ super(document, name, attrs, children);
51
42
  this.getFillerOffset = getFillerOffset;
52
43
  }
53
44
  }
54
- /**
55
- * Checks whether this object is of the given.
56
- *
57
- * containerElement.is( 'containerElement' ); // -> true
58
- * containerElement.is( 'element' ); // -> true
59
- * containerElement.is( 'node' ); // -> true
60
- * containerElement.is( 'view:containerElement' ); // -> true
61
- * containerElement.is( 'view:element' ); // -> true
62
- * containerElement.is( 'view:node' ); // -> true
63
- *
64
- * containerElement.is( 'model:element' ); // -> false
65
- * containerElement.is( 'documentFragment' ); // -> false
66
- *
67
- * Assuming that the object being checked is a container element, you can also check its
68
- * {@link module:engine/view/containerelement~ContainerElement#name name}:
69
- *
70
- * containerElement.is( 'element', 'div' ); // -> true if this is a div container element
71
- * containerElement.is( 'contaienrElement', 'div' ); // -> same as above
72
- * text.is( 'element', 'div' ); -> false
73
- *
74
- * {@link module:engine/view/node~Node#is Check the entire list of view objects} which implement the `is()` method.
75
- *
76
- * @param {String} type Type to check.
77
- * @param {String} [name] Element name.
78
- * @returns {Boolean}
79
- */
45
+ // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
46
+ // Proper overload would interfere with that.
80
47
  ContainerElement.prototype.is = function (type, name) {
81
48
  if (!name) {
82
49
  return type === 'containerElement' || type === 'view:containerElement' ||
@@ -93,7 +60,7 @@ ContainerElement.prototype.is = function (type, name) {
93
60
  /**
94
61
  * Returns block {@link module:engine/view/filler filler} offset or `null` if block filler is not needed.
95
62
  *
96
- * @returns {Number|null} Block filler offset or `null` if block filler is not needed.
63
+ * @returns Block filler offset or `null` if block filler is not needed.
97
64
  */
98
65
  export function getFillerOffset() {
99
66
  const children = [...this.getChildren()];
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module engine/view/datatransfer
7
+ */
8
+ type DomDataTransfer = globalThis.DataTransfer;
9
+ /**
10
+ * A facade over the native [`DataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) object.
11
+ */
12
+ export default class DataTransfer {
13
+ /**
14
+ * The array of files created from the native `DataTransfer#files` or `DataTransfer#items`.
15
+ */
16
+ private _files;
17
+ /**
18
+ * The native DataTransfer object.
19
+ */
20
+ private _native;
21
+ /**
22
+ * @param nativeDataTransfer The native [`DataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) object.
23
+ * @param options.cacheFiles Whether `files` list should be initialized in the constructor.
24
+ */
25
+ constructor(nativeDataTransfer: DomDataTransfer, options?: {
26
+ cacheFiles?: boolean;
27
+ });
28
+ /**
29
+ * The array of files created from the native `DataTransfer#files` or `DataTransfer#items`.
30
+ */
31
+ get files(): Array<File>;
32
+ /**
33
+ * Returns an array of available native content types.
34
+ */
35
+ get types(): ReadonlyArray<string>;
36
+ /**
37
+ * Gets the data from the data transfer by its MIME type.
38
+ *
39
+ * ```ts
40
+ * dataTransfer.getData( 'text/plain' );
41
+ * ```
42
+ *
43
+ * @param type The MIME type. E.g. `text/html` or `text/plain`.
44
+ */
45
+ getData(type: string): string;
46
+ /**
47
+ * Sets the data in the data transfer.
48
+ *
49
+ * @param type The MIME type. E.g. `text/html` or `text/plain`.
50
+ */
51
+ setData(type: string, data: string): void;
52
+ /**
53
+ * The effect that is allowed for a drag operation.
54
+ */
55
+ set effectAllowed(value: EffectAllowed);
56
+ get effectAllowed(): EffectAllowed;
57
+ /**
58
+ * The actual drop effect.
59
+ */
60
+ set dropEffect(value: DropEffect);
61
+ get dropEffect(): DropEffect;
62
+ /**
63
+ * Whether the dragging operation was canceled.
64
+ */
65
+ get isCanceled(): boolean;
66
+ }
67
+ /**
68
+ * The effect that is allowed for a drag operation.
69
+ */
70
+ export type EffectAllowed = DomDataTransfer['effectAllowed'];
71
+ /**
72
+ * The actual drop effect.
73
+ */
74
+ export type DropEffect = DomDataTransfer['dropEffect'];
75
+ export {};