@ckeditor/ckeditor5-engine 45.2.1 → 46.0.0-alpha.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 (241) hide show
  1. package/dist/index.js +2563 -2257
  2. package/dist/index.js.map +1 -1
  3. package/package.json +3 -3
  4. package/src/controller/datacontroller.d.ts +33 -32
  5. package/src/controller/datacontroller.js +29 -28
  6. package/src/controller/editingcontroller.d.ts +8 -8
  7. package/src/controller/editingcontroller.js +10 -10
  8. package/src/conversion/conversion.d.ts +18 -19
  9. package/src/conversion/conversion.js +4 -4
  10. package/src/conversion/conversionhelpers.d.ts +1 -1
  11. package/src/conversion/conversionhelpers.js +1 -1
  12. package/src/conversion/downcastdispatcher.d.ts +63 -69
  13. package/src/conversion/downcastdispatcher.js +16 -16
  14. package/src/conversion/downcasthelpers.d.ts +94 -83
  15. package/src/conversion/downcasthelpers.js +63 -53
  16. package/src/conversion/mapper.d.ts +27 -27
  17. package/src/conversion/mapper.js +15 -15
  18. package/src/conversion/modelconsumable.d.ts +26 -26
  19. package/src/conversion/modelconsumable.js +23 -23
  20. package/src/conversion/upcastdispatcher.d.ts +33 -32
  21. package/src/conversion/upcastdispatcher.js +19 -19
  22. package/src/conversion/upcasthelpers.d.ts +46 -38
  23. package/src/conversion/upcasthelpers.js +33 -24
  24. package/src/conversion/viewconsumable.d.ts +50 -45
  25. package/src/conversion/viewconsumable.js +32 -27
  26. package/src/dataprocessor/basichtmlwriter.d.ts +4 -2
  27. package/src/dataprocessor/basichtmlwriter.js +3 -1
  28. package/src/dataprocessor/dataprocessor.d.ts +7 -6
  29. package/src/dataprocessor/htmldataprocessor.d.ts +10 -10
  30. package/src/dataprocessor/htmldataprocessor.js +6 -6
  31. package/src/dataprocessor/htmlwriter.d.ts +1 -1
  32. package/src/dataprocessor/xmldataprocessor.d.ts +10 -10
  33. package/src/dataprocessor/xmldataprocessor.js +6 -6
  34. package/src/dev-utils/model.d.ts +25 -26
  35. package/src/dev-utils/model.js +35 -36
  36. package/src/dev-utils/operationreplayer.d.ts +5 -3
  37. package/src/dev-utils/operationreplayer.js +4 -2
  38. package/src/dev-utils/utils.d.ts +8 -0
  39. package/src/dev-utils/utils.js +8 -0
  40. package/src/dev-utils/view.d.ts +66 -63
  41. package/src/dev-utils/view.js +144 -134
  42. package/src/index.d.ts +135 -106
  43. package/src/index.js +120 -71
  44. package/src/legacyerrors.d.ts +5 -0
  45. package/src/legacyerrors.js +17 -0
  46. package/src/model/batch.d.ts +2 -15
  47. package/src/model/batch.js +1 -23
  48. package/src/model/differ.d.ts +54 -31
  49. package/src/model/differ.js +15 -15
  50. package/src/model/document.d.ts +31 -31
  51. package/src/model/document.js +13 -13
  52. package/src/model/documentfragment.d.ts +45 -45
  53. package/src/model/documentfragment.js +40 -40
  54. package/src/model/documentselection.d.ts +92 -92
  55. package/src/model/documentselection.js +71 -70
  56. package/src/model/element.d.ts +31 -31
  57. package/src/model/element.js +29 -29
  58. package/src/model/history.d.ts +3 -3
  59. package/src/model/history.js +2 -2
  60. package/src/model/item.d.ts +4 -5
  61. package/src/model/liveposition.d.ts +31 -31
  62. package/src/model/liveposition.js +18 -18
  63. package/src/model/liverange.d.ts +42 -38
  64. package/src/model/liverange.js +17 -16
  65. package/src/model/markercollection.d.ts +41 -40
  66. package/src/model/markercollection.js +22 -20
  67. package/src/model/model.d.ts +82 -81
  68. package/src/model/model.js +54 -54
  69. package/src/model/node.d.ts +48 -48
  70. package/src/model/node.js +31 -31
  71. package/src/model/nodelist.d.ts +17 -17
  72. package/src/model/nodelist.js +11 -11
  73. package/src/model/operation/attributeoperation.d.ts +10 -10
  74. package/src/model/operation/attributeoperation.js +7 -7
  75. package/src/model/operation/detachoperation.d.ts +11 -9
  76. package/src/model/operation/detachoperation.js +8 -6
  77. package/src/model/operation/insertoperation.d.ts +13 -13
  78. package/src/model/operation/insertoperation.js +15 -15
  79. package/src/model/operation/markeroperation.d.ts +12 -12
  80. package/src/model/operation/markeroperation.js +5 -5
  81. package/src/model/operation/mergeoperation.d.ts +16 -16
  82. package/src/model/operation/mergeoperation.js +18 -18
  83. package/src/model/operation/moveoperation.d.ts +16 -16
  84. package/src/model/operation/moveoperation.js +18 -15
  85. package/src/model/operation/nooperation.d.ts +4 -4
  86. package/src/model/operation/nooperation.js +2 -2
  87. package/src/model/operation/operation.d.ts +10 -10
  88. package/src/model/operation/operation.js +5 -5
  89. package/src/model/operation/operationfactory.d.ts +4 -4
  90. package/src/model/operation/operationfactory.js +12 -12
  91. package/src/model/operation/renameoperation.d.ts +10 -10
  92. package/src/model/operation/renameoperation.js +7 -7
  93. package/src/model/operation/rootattributeoperation.d.ts +12 -12
  94. package/src/model/operation/rootattributeoperation.js +8 -8
  95. package/src/model/operation/rootoperation.d.ts +8 -8
  96. package/src/model/operation/rootoperation.js +3 -3
  97. package/src/model/operation/splitoperation.d.ts +17 -17
  98. package/src/model/operation/splitoperation.js +19 -19
  99. package/src/model/operation/transform.d.ts +11 -8
  100. package/src/model/operation/transform.js +66 -49
  101. package/src/model/operation/utils.d.ts +24 -23
  102. package/src/model/operation/utils.js +20 -20
  103. package/src/model/position.d.ts +101 -97
  104. package/src/model/position.js +69 -64
  105. package/src/model/range.d.ts +90 -90
  106. package/src/model/range.js +87 -87
  107. package/src/model/rootelement.d.ts +11 -11
  108. package/src/model/rootelement.js +9 -9
  109. package/src/model/schema.d.ts +158 -154
  110. package/src/model/schema.js +93 -90
  111. package/src/model/selection.d.ts +73 -73
  112. package/src/model/selection.js +62 -62
  113. package/src/model/text.d.ts +11 -10
  114. package/src/model/text.js +11 -10
  115. package/src/model/textproxy.d.ts +39 -38
  116. package/src/model/textproxy.js +31 -30
  117. package/src/model/treewalker.d.ts +37 -37
  118. package/src/model/treewalker.js +14 -14
  119. package/src/model/typecheckable.d.ts +45 -45
  120. package/src/model/typecheckable.js +1 -1
  121. package/src/model/utils/autoparagraphing.d.ts +7 -7
  122. package/src/model/utils/deletecontent.d.ts +7 -5
  123. package/src/model/utils/deletecontent.js +13 -11
  124. package/src/model/utils/getselectedcontent.d.ts +6 -5
  125. package/src/model/utils/getselectedcontent.js +2 -1
  126. package/src/model/utils/insertcontent.d.ts +9 -8
  127. package/src/model/utils/insertcontent.js +41 -40
  128. package/src/model/utils/insertobject.d.ts +9 -9
  129. package/src/model/utils/insertobject.js +4 -4
  130. package/src/model/utils/modifyselection.d.ts +5 -4
  131. package/src/model/utils/modifyselection.js +12 -11
  132. package/src/model/utils/selection-post-fixer.d.ts +12 -8
  133. package/src/model/utils/selection-post-fixer.js +15 -11
  134. package/src/model/writer.d.ts +102 -101
  135. package/src/model/writer.js +99 -98
  136. package/src/view/attributeelement.d.ts +29 -29
  137. package/src/view/attributeelement.js +25 -25
  138. package/src/view/containerelement.d.ts +16 -15
  139. package/src/view/containerelement.js +15 -14
  140. package/src/view/datatransfer.d.ts +7 -7
  141. package/src/view/datatransfer.js +1 -1
  142. package/src/view/document.d.ts +25 -25
  143. package/src/view/document.js +15 -15
  144. package/src/view/documentfragment.d.ts +21 -21
  145. package/src/view/documentfragment.js +14 -14
  146. package/src/view/documentselection.d.ts +65 -63
  147. package/src/view/documentselection.js +27 -25
  148. package/src/view/domconverter.d.ts +96 -91
  149. package/src/view/domconverter.js +78 -73
  150. package/src/view/downcastwriter.d.ts +185 -181
  151. package/src/view/downcastwriter.js +222 -210
  152. package/src/view/editableelement.d.ts +13 -13
  153. package/src/view/editableelement.js +8 -8
  154. package/src/view/element.d.ts +75 -74
  155. package/src/view/element.js +58 -58
  156. package/src/view/elementdefinition.d.ts +3 -4
  157. package/src/view/emptyelement.d.ts +13 -13
  158. package/src/view/emptyelement.js +13 -13
  159. package/src/view/filler.d.ts +14 -3
  160. package/src/view/filler.js +12 -1
  161. package/src/view/item.d.ts +4 -5
  162. package/src/view/matcher.d.ts +22 -19
  163. package/src/view/matcher.js +6 -6
  164. package/src/view/node.d.ts +33 -33
  165. package/src/view/node.js +9 -9
  166. package/src/view/observer/arrowkeysobserver.d.ts +10 -10
  167. package/src/view/observer/arrowkeysobserver.js +5 -5
  168. package/src/view/observer/bubblingemittermixin.d.ts +5 -5
  169. package/src/view/observer/bubblingemittermixin.js +2 -9
  170. package/src/view/observer/bubblingeventinfo.d.ts +9 -9
  171. package/src/view/observer/bubblingeventinfo.js +1 -1
  172. package/src/view/observer/clickobserver.d.ts +8 -8
  173. package/src/view/observer/clickobserver.js +4 -4
  174. package/src/view/observer/compositionobserver.d.ts +19 -19
  175. package/src/view/observer/compositionobserver.js +6 -6
  176. package/src/view/observer/domeventdata.d.ts +9 -9
  177. package/src/view/observer/domeventdata.js +2 -2
  178. package/src/view/observer/domeventobserver.d.ts +3 -3
  179. package/src/view/observer/domeventobserver.js +5 -5
  180. package/src/view/observer/fakeselectionobserver.d.ts +9 -9
  181. package/src/view/observer/fakeselectionobserver.js +8 -8
  182. package/src/view/observer/focusobserver.d.ts +16 -16
  183. package/src/view/observer/focusobserver.js +7 -7
  184. package/src/view/observer/inputobserver.d.ts +18 -18
  185. package/src/view/observer/inputobserver.js +5 -5
  186. package/src/view/observer/keyobserver.d.ts +11 -11
  187. package/src/view/observer/keyobserver.js +3 -3
  188. package/src/view/observer/mouseobserver.d.ts +16 -16
  189. package/src/view/observer/mouseobserver.js +3 -3
  190. package/src/view/observer/mutationobserver.d.ts +21 -21
  191. package/src/view/observer/mutationobserver.js +7 -7
  192. package/src/view/observer/observer.d.ts +12 -12
  193. package/src/view/observer/observer.js +6 -6
  194. package/src/view/observer/selectionobserver.d.ts +33 -33
  195. package/src/view/observer/selectionobserver.js +14 -14
  196. package/src/view/observer/tabobserver.d.ts +10 -10
  197. package/src/view/observer/tabobserver.js +5 -5
  198. package/src/view/observer/touchobserver.d.ts +13 -13
  199. package/src/view/observer/touchobserver.js +3 -3
  200. package/src/view/placeholder.d.ts +21 -21
  201. package/src/view/placeholder.js +23 -23
  202. package/src/view/position.d.ts +49 -49
  203. package/src/view/position.js +42 -42
  204. package/src/view/range.d.ts +76 -74
  205. package/src/view/range.js +67 -65
  206. package/src/view/rawelement.d.ts +19 -19
  207. package/src/view/rawelement.js +16 -16
  208. package/src/view/renderer.d.ts +14 -14
  209. package/src/view/renderer.js +7 -7
  210. package/src/view/rooteditableelement.d.ts +8 -7
  211. package/src/view/rooteditableelement.js +7 -6
  212. package/src/view/selection.d.ts +66 -64
  213. package/src/view/selection.js +50 -48
  214. package/src/view/styles/background.d.ts +2 -2
  215. package/src/view/styles/background.js +9 -9
  216. package/src/view/styles/border.d.ts +2 -2
  217. package/src/view/styles/border.js +13 -13
  218. package/src/view/styles/margin.d.ts +2 -2
  219. package/src/view/styles/margin.js +5 -5
  220. package/src/view/styles/padding.d.ts +2 -2
  221. package/src/view/styles/padding.js +5 -5
  222. package/src/view/styles/utils.d.ts +24 -24
  223. package/src/view/styles/utils.js +25 -25
  224. package/src/view/stylesmap.d.ts +28 -32
  225. package/src/view/stylesmap.js +52 -39
  226. package/src/view/text.d.ts +11 -11
  227. package/src/view/text.js +10 -10
  228. package/src/view/textproxy.d.ts +33 -32
  229. package/src/view/textproxy.js +23 -22
  230. package/src/view/tokenlist.d.ts +14 -14
  231. package/src/view/tokenlist.js +10 -10
  232. package/src/view/treewalker.d.ts +42 -40
  233. package/src/view/treewalker.js +36 -35
  234. package/src/view/typecheckable.d.ts +76 -75
  235. package/src/view/typecheckable.js +1 -1
  236. package/src/view/uielement.d.ts +22 -21
  237. package/src/view/uielement.js +17 -16
  238. package/src/view/upcastwriter.d.ts +70 -70
  239. package/src/view/upcastwriter.js +42 -42
  240. package/src/view/view.d.ts +70 -69
  241. package/src/view/view.js +56 -55
@@ -5,13 +5,13 @@
5
5
  /**
6
6
  * @module engine/view/matcher
7
7
  */
8
- import type Element from './element.js';
8
+ import { type ViewElement } from './element.js';
9
9
  import { type Consumables } from '../conversion/viewconsumable.js';
10
10
  /**
11
11
  * View matcher class.
12
- * Instance of this class can be used to find {@link module:engine/view/element~Element elements} that match given pattern.
12
+ * Instance of this class can be used to find {@link module:engine/view/element~ViewElement elements} that match given pattern.
13
13
  */
14
- export default class Matcher {
14
+ export declare class Matcher {
15
15
  private readonly _patterns;
16
16
  /**
17
17
  * Creates new instance of Matcher.
@@ -45,14 +45,14 @@ export default class Matcher {
45
45
  *
46
46
  * @param pattern Object describing pattern details. If string or regular expression
47
47
  * is provided it will be used to match element's name. Pattern can be also provided in a form
48
- * of a function - then this function will be called with each {@link module:engine/view/element~Element element} as a parameter.
48
+ * of a function - then this function will be called with each {@link module:engine/view/element~ViewElement element} as a parameter.
49
49
  * Function's return value will be stored under `match` key of the object returned from
50
50
  * {@link module:engine/view/matcher~Matcher#match match} or {@link module:engine/view/matcher~Matcher#matchAll matchAll} methods.
51
51
  */
52
52
  add(...pattern: Array<MatcherPattern>): void;
53
53
  /**
54
54
  * Matches elements for currently stored patterns. Returns match information about first found
55
- * {@link module:engine/view/element~Element element}, otherwise returns `null`.
55
+ * {@link module:engine/view/element~ViewElement element}, otherwise returns `null`.
56
56
  *
57
57
  * Example of returned object:
58
58
  *
@@ -82,10 +82,10 @@ export default class Matcher {
82
82
  * @param element View element to match against stored patterns.
83
83
  * @returns The match information about found element or `null`.
84
84
  */
85
- match(...element: Array<Element>): MatchResult | null;
85
+ match(...element: Array<ViewElement>): MatchResult | null;
86
86
  /**
87
87
  * Matches elements for currently stored patterns. Returns array of match information with all found
88
- * {@link module:engine/view/element~Element elements}. If no element is found - returns `null`.
88
+ * {@link module:engine/view/element~ViewElement elements}. If no element is found - returns `null`.
89
89
  *
90
90
  * @see module:engine/view/matcher~Matcher#add
91
91
  * @see module:engine/view/matcher~Matcher#match
@@ -93,7 +93,7 @@ export default class Matcher {
93
93
  * @returns Array with match information about found elements or `null`. For more information
94
94
  * see {@link module:engine/view/matcher~Matcher#match match method} description.
95
95
  */
96
- matchAll(...element: Array<Element>): Array<MatchResult> | null;
96
+ matchAll(...element: Array<ViewElement>): Array<MatchResult> | null;
97
97
  /**
98
98
  * Returns the name of the element to match if there is exactly one pattern added to the matcher instance
99
99
  * and it matches element name defined by `string` (not `RegExp`). Otherwise, returns `null`.
@@ -102,7 +102,7 @@ export default class Matcher {
102
102
  */
103
103
  getElementName(): string | null;
104
104
  /**
105
- * Returns match information if {@link module:engine/view/element~Element element} is matching provided pattern.
105
+ * Returns match information if {@link module:engine/view/element~ViewElement element} is matching provided pattern.
106
106
  * If element cannot be matched to provided pattern - returns `null`.
107
107
  *
108
108
  * @returns Returns object with match information or null if element is not matching.
@@ -365,14 +365,14 @@ export declare function isPatternMatched(pattern: true | string | RegExp, item:
365
365
  * };
366
366
  * ```
367
367
  *
368
- * `MatcherPattern` is defined in a way that it is a superset of {@link module:engine/view/elementdefinition~ElementDefinition},
368
+ * `MatcherPattern` is defined in a way that it is a superset of {@link module:engine/view/elementdefinition~ViewElementDefinition},
369
369
  * that is, every `ElementDefinition` also can be used as a `MatcherPattern`.
370
370
  */
371
371
  export type MatcherPattern = string | RegExp | MatcherFunctionPattern | MatcherObjectPattern;
372
372
  /**
373
373
  * A function describing `MatcherPattern`. See {@link ~MatcherPattern} for examples and other options.
374
374
  */
375
- export type MatcherFunctionPattern = (element: Element) => Match | Consumables | null;
375
+ export type MatcherFunctionPattern = (element: ViewElement) => Match | Consumables | null;
376
376
  /**
377
377
  * An object describing `MatcherPattern`. See {@link ~MatcherPattern} for examples and other options.
378
378
  */
@@ -384,15 +384,15 @@ export interface MatcherObjectPattern {
384
384
  /**
385
385
  * View element's classes to match.
386
386
  */
387
- classes?: ClassPatterns;
387
+ classes?: MatchClassPatterns;
388
388
  /**
389
389
  * View element's styles to match.
390
390
  */
391
- styles?: StylePatterns;
391
+ styles?: MatchStylePatterns;
392
392
  /**
393
393
  * View element's attributes to match.
394
394
  */
395
- attributes?: AttributePatterns;
395
+ attributes?: MatchAttributePatterns;
396
396
  }
397
397
  /**
398
398
  * An object representing matched element parts.
@@ -415,7 +415,7 @@ export interface MatchResult {
415
415
  /**
416
416
  * Matched view element.
417
417
  */
418
- element: Element;
418
+ element: ViewElement;
419
419
  /**
420
420
  * Pattern that was used to find matched element.
421
421
  */
@@ -425,13 +425,16 @@ export interface MatchResult {
425
425
  */
426
426
  match: Match;
427
427
  }
428
- export type PropertyPatterns<ValuePattern = string | RegExp> = true | string | RegExp | Record<string, true | ValuePattern> | Array<string | RegExp | {
428
+ export type MatchPropertyPatterns<ValuePattern = string | RegExp> = true | string | RegExp | Record<string, true | ValuePattern> | Array<string | RegExp | {
429
429
  key: string | RegExp;
430
430
  value: true | ValuePattern;
431
431
  }>;
432
- export type AttributePatterns = PropertyPatterns;
433
- export type StylePatterns = PropertyPatterns;
434
- export type ClassPatterns = PropertyPatterns<never>;
432
+ export type MatchAttributePatterns = MatchPropertyPatterns;
433
+ export type MatchStylePatterns = MatchPropertyPatterns;
434
+ export type MatchClassPatterns = MatchPropertyPatterns<never>;
435
+ /**
436
+ * @internal
437
+ */
435
438
  export type NormalizedPropertyPattern = [
436
439
  true | string | RegExp,
437
440
  true | string | RegExp,
@@ -6,9 +6,9 @@ import { logWarning } from '@ckeditor/ckeditor5-utils';
6
6
  import { normalizeConsumables } from '../conversion/viewconsumable.js';
7
7
  /**
8
8
  * View matcher class.
9
- * Instance of this class can be used to find {@link module:engine/view/element~Element elements} that match given pattern.
9
+ * Instance of this class can be used to find {@link module:engine/view/element~ViewElement elements} that match given pattern.
10
10
  */
11
- export default class Matcher {
11
+ export class Matcher {
12
12
  _patterns = [];
13
13
  /**
14
14
  * Creates new instance of Matcher.
@@ -44,7 +44,7 @@ export default class Matcher {
44
44
  *
45
45
  * @param pattern Object describing pattern details. If string or regular expression
46
46
  * is provided it will be used to match element's name. Pattern can be also provided in a form
47
- * of a function - then this function will be called with each {@link module:engine/view/element~Element element} as a parameter.
47
+ * of a function - then this function will be called with each {@link module:engine/view/element~ViewElement element} as a parameter.
48
48
  * Function's return value will be stored under `match` key of the object returned from
49
49
  * {@link module:engine/view/matcher~Matcher#match match} or {@link module:engine/view/matcher~Matcher#matchAll matchAll} methods.
50
50
  */
@@ -59,7 +59,7 @@ export default class Matcher {
59
59
  }
60
60
  /**
61
61
  * Matches elements for currently stored patterns. Returns match information about first found
62
- * {@link module:engine/view/element~Element element}, otherwise returns `null`.
62
+ * {@link module:engine/view/element~ViewElement element}, otherwise returns `null`.
63
63
  *
64
64
  * Example of returned object:
65
65
  *
@@ -106,7 +106,7 @@ export default class Matcher {
106
106
  }
107
107
  /**
108
108
  * Matches elements for currently stored patterns. Returns array of match information with all found
109
- * {@link module:engine/view/element~Element elements}. If no element is found - returns `null`.
109
+ * {@link module:engine/view/element~ViewElement elements}. If no element is found - returns `null`.
110
110
  *
111
111
  * @see module:engine/view/matcher~Matcher#add
112
112
  * @see module:engine/view/matcher~Matcher#match
@@ -145,7 +145,7 @@ export default class Matcher {
145
145
  return (typeof pattern != 'function' && name && !(name instanceof RegExp)) ? name : null;
146
146
  }
147
147
  /**
148
- * Returns match information if {@link module:engine/view/element~Element element} is matching provided pattern.
148
+ * Returns match information if {@link module:engine/view/element~ViewElement element} is matching provided pattern.
149
149
  * If element cannot be matched to provided pattern - returns `null`.
150
150
  *
151
151
  * @returns Returns object with match information or null if element is not matching.
@@ -5,33 +5,33 @@
5
5
  /**
6
6
  * @module engine/view/node
7
7
  */
8
- import TypeCheckable from './typecheckable.js';
9
- import type { default as Document, ChangeType } from './document.js';
10
- import type DocumentFragment from './documentfragment.js';
11
- import type Element from './element.js';
12
- declare const Node_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof TypeCheckable, import("@ckeditor/ckeditor5-utils").Emitter>;
8
+ import { ViewTypeCheckable } from './typecheckable.js';
9
+ import type { ViewDocument, ViewDocumentChangeType } from './document.js';
10
+ import { type ViewDocumentFragment } from './documentfragment.js';
11
+ import { type ViewElement } from './element.js';
12
+ declare const ViewNode_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof ViewTypeCheckable, import("@ckeditor/ckeditor5-utils").Emitter>;
13
13
  /**
14
14
  * Abstract view node class.
15
15
  *
16
16
  * This is an abstract class. Its constructor should not be used directly.
17
- * Use the {@link module:engine/view/downcastwriter~DowncastWriter} or {@link module:engine/view/upcastwriter~UpcastWriter}
17
+ * Use the {@link module:engine/view/downcastwriter~ViewDowncastWriter} or {@link module:engine/view/upcastwriter~ViewUpcastWriter}
18
18
  * to create new instances of view nodes.
19
19
  */
20
- export default abstract class Node extends /* #__PURE__ */ Node_base {
20
+ export declare abstract class ViewNode extends /* #__PURE__ */ ViewNode_base {
21
21
  /**
22
22
  * The document instance to which this node belongs.
23
23
  */
24
- readonly document: Document;
24
+ readonly document: ViewDocument;
25
25
  /**
26
- * Parent element. Null by default. Set by {@link module:engine/view/element~Element#_insertChild}.
26
+ * Parent element. Null by default. Set by {@link module:engine/view/element~ViewElement#_insertChild}.
27
27
  */
28
- readonly parent: Element | DocumentFragment | null;
28
+ readonly parent: ViewElement | ViewDocumentFragment | null;
29
29
  /**
30
30
  * Creates a tree view node.
31
31
  *
32
32
  * @param document The document instance to which this node belongs.
33
33
  */
34
- protected constructor(document: Document);
34
+ protected constructor(document: ViewDocument);
35
35
  /**
36
36
  * Index of the node in the parent element or null if the node has no parent.
37
37
  *
@@ -42,22 +42,22 @@ export default abstract class Node extends /* #__PURE__ */ Node_base {
42
42
  /**
43
43
  * Node's next sibling, or `null` if it is the last child.
44
44
  */
45
- get nextSibling(): Node | null;
45
+ get nextSibling(): ViewNode | null;
46
46
  /**
47
47
  * Node's previous sibling, or `null` if it is the first child.
48
48
  */
49
- get previousSibling(): Node | null;
49
+ get previousSibling(): ViewNode | null;
50
50
  /**
51
51
  * Top-most ancestor of the node. If the node has no parent it is the root itself.
52
52
  */
53
- get root(): Element | DocumentFragment;
53
+ get root(): ViewElement | ViewDocumentFragment;
54
54
  /**
55
55
  * Returns true if the node is in a tree rooted in the document (is a descendant of one of its roots).
56
56
  */
57
57
  isAttached(): boolean;
58
58
  /**
59
59
  * Gets a path to the node. The path is an array containing indices of consecutive ancestors of this node,
60
- * beginning from {@link module:engine/view/node~Node#root root}, down to this node's index.
60
+ * beginning from {@link module:engine/view/node~ViewNode#root root}, down to this node's index.
61
61
  *
62
62
  * ```ts
63
63
  * const abc = downcastWriter.createText( 'abc' );
@@ -85,9 +85,9 @@ export default abstract class Node extends /* #__PURE__ */ Node_base {
85
85
  getAncestors(options?: {
86
86
  includeSelf?: boolean;
87
87
  parentFirst?: boolean;
88
- }): Array<Node | DocumentFragment>;
88
+ }): Array<ViewNode | ViewDocumentFragment>;
89
89
  /**
90
- * Returns a {@link module:engine/view/element~Element} or {@link module:engine/view/documentfragment~DocumentFragment}
90
+ * Returns a {@link module:engine/view/element~ViewElement} or {@link module:engine/view/documentfragment~ViewDocumentFragment}
91
91
  * which is a common ancestor of both nodes.
92
92
  *
93
93
  * @param node The second node.
@@ -95,23 +95,23 @@ export default abstract class Node extends /* #__PURE__ */ Node_base {
95
95
  * @param options.includeSelf When set to `true` both nodes will be considered "ancestors" too.
96
96
  * Which means that if e.g. node A is inside B, then their common ancestor will be B.
97
97
  */
98
- getCommonAncestor(node: Node, options?: {
98
+ getCommonAncestor(node: ViewNode, options?: {
99
99
  includeSelf?: boolean;
100
- }): Element | DocumentFragment | null;
100
+ }): ViewElement | ViewDocumentFragment | null;
101
101
  /**
102
102
  * Returns whether this node is before given node. `false` is returned if nodes are in different trees (for example,
103
- * in different {@link module:engine/view/documentfragment~DocumentFragment}s).
103
+ * in different {@link module:engine/view/documentfragment~ViewDocumentFragment}s).
104
104
  *
105
105
  * @param node Node to compare with.
106
106
  */
107
- isBefore(node: Node): boolean;
107
+ isBefore(node: ViewNode): boolean;
108
108
  /**
109
109
  * Returns whether this node is after given node. `false` is returned if nodes are in different trees (for example,
110
- * in different {@link module:engine/view/documentfragment~DocumentFragment}s).
110
+ * in different {@link module:engine/view/documentfragment~ViewDocumentFragment}s).
111
111
  *
112
112
  * @param node Node to compare with.
113
113
  */
114
- isAfter(node: Node): boolean;
114
+ isAfter(node: ViewNode): boolean;
115
115
  /**
116
116
  * Removes node from parent.
117
117
  *
@@ -125,7 +125,7 @@ export default abstract class Node extends /* #__PURE__ */ Node_base {
125
125
  * @param data Additional data.
126
126
  * @fires change
127
127
  */
128
- _fireChange(type: ChangeType, node: Node, data?: {
128
+ _fireChange(type: ViewDocumentChangeType, node: ViewNode, data?: {
129
129
  index: number;
130
130
  }): void;
131
131
  /**
@@ -140,16 +140,16 @@ export default abstract class Node extends /* #__PURE__ */ Node_base {
140
140
  * @internal
141
141
  * @returns Clone of this node.
142
142
  */
143
- abstract _clone(deep?: boolean): Node;
143
+ abstract _clone(deep?: boolean): ViewNode;
144
144
  /**
145
145
  * Checks if provided node is similar to this node.
146
146
  *
147
147
  * @returns True if nodes are similar.
148
148
  */
149
- abstract isSimilar(other: Node): boolean;
149
+ abstract isSimilar(other: ViewNode): boolean;
150
150
  }
151
151
  /**
152
- * Fired when list of {@link module:engine/view/element~Element elements} children, attributes or text changes.
152
+ * Fired when list of {@link module:engine/view/element~ViewElement elements} children, attributes or text changes.
153
153
  *
154
154
  * Change event is bubbled – it is fired on all ancestors.
155
155
  *
@@ -157,14 +157,14 @@ export default abstract class Node extends /* #__PURE__ */ Node_base {
157
157
  *
158
158
  * If `change:children` event is fired, there is an additional second parameter, which is an object with additional data related to change.
159
159
  *
160
- * @eventName ~Node#change
161
- * @eventName ~Node#change:children
162
- * @eventName ~Node#change:attributes
163
- * @eventName ~Node#change:text
160
+ * @eventName ~ViewNode#change
161
+ * @eventName ~ViewNode#change:children
162
+ * @eventName ~ViewNode#change:attributes
163
+ * @eventName ~ViewNode#change:text
164
164
  */
165
165
  export type ViewNodeChangeEvent = {
166
- name: 'change' | `change:${ChangeType}`;
167
- args: [changedNode: Node, data?: {
166
+ name: 'change' | `change:${ViewDocumentChangeType}`;
167
+ args: [changedNode: ViewNode, data?: {
168
168
  index: number;
169
169
  }];
170
170
  };
package/src/view/node.js CHANGED
@@ -5,23 +5,23 @@
5
5
  /**
6
6
  * @module engine/view/node
7
7
  */
8
- import TypeCheckable from './typecheckable.js';
8
+ import { ViewTypeCheckable } from './typecheckable.js';
9
9
  import { CKEditorError, EmitterMixin, compareArrays } from '@ckeditor/ckeditor5-utils';
10
10
  import { clone } from 'es-toolkit/compat';
11
11
  /**
12
12
  * Abstract view node class.
13
13
  *
14
14
  * This is an abstract class. Its constructor should not be used directly.
15
- * Use the {@link module:engine/view/downcastwriter~DowncastWriter} or {@link module:engine/view/upcastwriter~UpcastWriter}
15
+ * Use the {@link module:engine/view/downcastwriter~ViewDowncastWriter} or {@link module:engine/view/upcastwriter~ViewUpcastWriter}
16
16
  * to create new instances of view nodes.
17
17
  */
18
- export default class Node extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
18
+ export class ViewNode extends /* #__PURE__ */ EmitterMixin(ViewTypeCheckable) {
19
19
  /**
20
20
  * The document instance to which this node belongs.
21
21
  */
22
22
  document;
23
23
  /**
24
- * Parent element. Null by default. Set by {@link module:engine/view/element~Element#_insertChild}.
24
+ * Parent element. Null by default. Set by {@link module:engine/view/element~ViewElement#_insertChild}.
25
25
  */
26
26
  parent;
27
27
  /**
@@ -89,7 +89,7 @@ export default class Node extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
89
89
  }
90
90
  /**
91
91
  * Gets a path to the node. The path is an array containing indices of consecutive ancestors of this node,
92
- * beginning from {@link module:engine/view/node~Node#root root}, down to this node's index.
92
+ * beginning from {@link module:engine/view/node~ViewNode#root root}, down to this node's index.
93
93
  *
94
94
  * ```ts
95
95
  * const abc = downcastWriter.createText( 'abc' );
@@ -133,7 +133,7 @@ export default class Node extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
133
133
  return ancestors;
134
134
  }
135
135
  /**
136
- * Returns a {@link module:engine/view/element~Element} or {@link module:engine/view/documentfragment~DocumentFragment}
136
+ * Returns a {@link module:engine/view/element~ViewElement} or {@link module:engine/view/documentfragment~ViewDocumentFragment}
137
137
  * which is a common ancestor of both nodes.
138
138
  *
139
139
  * @param node The second node.
@@ -152,7 +152,7 @@ export default class Node extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
152
152
  }
153
153
  /**
154
154
  * Returns whether this node is before given node. `false` is returned if nodes are in different trees (for example,
155
- * in different {@link module:engine/view/documentfragment~DocumentFragment}s).
155
+ * in different {@link module:engine/view/documentfragment~ViewDocumentFragment}s).
156
156
  *
157
157
  * @param node Node to compare with.
158
158
  */
@@ -179,7 +179,7 @@ export default class Node extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
179
179
  }
180
180
  /**
181
181
  * Returns whether this node is after given node. `false` is returned if nodes are in different trees (for example,
182
- * in different {@link module:engine/view/documentfragment~DocumentFragment}s).
182
+ * in different {@link module:engine/view/documentfragment~ViewDocumentFragment}s).
183
183
  *
184
184
  * @param node Node to compare with.
185
185
  */
@@ -230,6 +230,6 @@ export default class Node extends /* #__PURE__ */ EmitterMixin(TypeCheckable) {
230
230
  }
231
231
  // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
232
232
  // Proper overload would interfere with that.
233
- Node.prototype.is = function (type) {
233
+ ViewNode.prototype.is = function (type) {
234
234
  return type === 'node' || type === 'view:node';
235
235
  };
@@ -5,20 +5,20 @@
5
5
  /**
6
6
  * @module engine/view/observer/arrowkeysobserver
7
7
  */
8
- import Observer from './observer.js';
9
- import type View from '../view.js';
10
- import type { KeyEventData } from './keyobserver.js';
8
+ import { Observer } from './observer.js';
9
+ import { type EditingView } from '../view.js';
10
+ import type { ViewDocumentKeyEventData } from './keyobserver.js';
11
11
  import type { BubblingEvent } from './bubblingemittermixin.js';
12
12
  /**
13
- * Arrow keys observer introduces the {@link module:engine/view/document~Document#event:arrowKey `Document#arrowKey`} event.
13
+ * Arrow keys observer introduces the {@link module:engine/view/document~ViewDocument#event:arrowKey `Document#arrowKey`} event.
14
14
  *
15
- * Note that this observer is attached by the {@link module:engine/view/view~View} and is available by default.
15
+ * Note that this observer is attached by the {@link module:engine/view/view~EditingView} and is available by default.
16
16
  */
17
- export default class ArrowKeysObserver extends Observer {
17
+ export declare class ArrowKeysObserver extends Observer {
18
18
  /**
19
19
  * @inheritDoc
20
20
  */
21
- constructor(view: View);
21
+ constructor(view: EditingView);
22
22
  /**
23
23
  * @inheritDoc
24
24
  */
@@ -34,12 +34,12 @@ export default class ArrowKeysObserver extends Observer {
34
34
  * Introduced by {@link module:engine/view/observer/arrowkeysobserver~ArrowKeysObserver}.
35
35
  *
36
36
  * Note that because {@link module:engine/view/observer/arrowkeysobserver~ArrowKeysObserver} is attached by the
37
- * {@link module:engine/view/view~View} this event is available by default.
37
+ * {@link module:engine/view/view~EditingView} this event is available by default.
38
38
  *
39
- * @eventName module:engine/view/document~Document#arrowKey
39
+ * @eventName module:engine/view/document~ViewDocument#arrowKey
40
40
  * @param data
41
41
  */
42
42
  export type ViewDocumentArrowKeyEvent = BubblingEvent<{
43
43
  name: 'arrowKey';
44
- args: [data: KeyEventData];
44
+ args: [data: ViewDocumentKeyEventData];
45
45
  }>;
@@ -5,15 +5,15 @@
5
5
  /**
6
6
  * @module engine/view/observer/arrowkeysobserver
7
7
  */
8
- import Observer from './observer.js';
9
- import BubblingEventInfo from './bubblingeventinfo.js';
8
+ import { Observer } from './observer.js';
9
+ import { BubblingEventInfo } from './bubblingeventinfo.js';
10
10
  import { isArrowKeyCode } from '@ckeditor/ckeditor5-utils';
11
11
  /**
12
- * Arrow keys observer introduces the {@link module:engine/view/document~Document#event:arrowKey `Document#arrowKey`} event.
12
+ * Arrow keys observer introduces the {@link module:engine/view/document~ViewDocument#event:arrowKey `Document#arrowKey`} event.
13
13
  *
14
- * Note that this observer is attached by the {@link module:engine/view/view~View} and is available by default.
14
+ * Note that this observer is attached by the {@link module:engine/view/view~EditingView} and is available by default.
15
15
  */
16
- export default class ArrowKeysObserver extends Observer {
16
+ export class ArrowKeysObserver extends Observer {
17
17
  /**
18
18
  * @inheritDoc
19
19
  */
@@ -6,8 +6,8 @@
6
6
  * @module engine/view/observer/bubblingemittermixin
7
7
  */
8
8
  import { type ArrayOrItem, type Emitter, type BaseEvent, type CallbackOptions, type Constructor, type Mixed } from '@ckeditor/ckeditor5-utils';
9
- import BubblingEventInfo from './bubblingeventinfo.js';
10
- import type Node from '../node.js';
9
+ import { BubblingEventInfo } from './bubblingeventinfo.js';
10
+ import { type ViewNode } from '../node.js';
11
11
  /**
12
12
  * Bubbling emitter mixin for the view document as described in the {@link ~BubblingEmitter} interface.
13
13
  *
@@ -24,11 +24,11 @@ import type Node from '../node.js';
24
24
  * }
25
25
  * ```
26
26
  */
27
- export default function BubblingEmitterMixin<Base extends Constructor<Emitter>>(base: Base): Mixed<Base, BubblingEmitter>;
27
+ export declare function BubblingEmitterMixin<Base extends Constructor<Emitter>>(base: Base): Mixed<Base, BubblingEmitter>;
28
28
  /**
29
29
  * Bubbling emitter for the view document.
30
30
  *
31
- * Bubbling emitter is triggering events in the context of specified {@link module:engine/view/element~Element view element} name,
31
+ * Bubbling emitter is triggering events in the context of specified {@link module:engine/view/element~ViewElement view element} name,
32
32
  * predefined `'$text'`, `'$root'`, `'$document'` and `'$capture'` contexts, and context matchers provided as a function.
33
33
  *
34
34
  * Before bubbling starts, listeners for `'$capture'` context are triggered. Then the bubbling starts from the deeper selection
@@ -137,7 +137,7 @@ export type BubblingEmitter = Emitter;
137
137
  *
138
138
  * Should return true for nodes that that match the custom context.
139
139
  */
140
- export type BubblingEventContextFunction = (node: Node) => boolean;
140
+ export type BubblingEventContextFunction = (node: ViewNode) => boolean;
141
141
  /**
142
142
  * Helper type that allows describing bubbling event. Extends `TEvent` so that:
143
143
  *
@@ -6,7 +6,7 @@
6
6
  * @module engine/view/observer/bubblingemittermixin
7
7
  */
8
8
  import { CKEditorError, EmitterMixin, EventInfo, toArray } from '@ckeditor/ckeditor5-utils';
9
- import BubblingEventInfo from './bubblingeventinfo.js';
9
+ import { BubblingEventInfo } from './bubblingeventinfo.js';
10
10
  const contextsSymbol = Symbol('bubbling contexts');
11
11
  /**
12
12
  * Bubbling emitter mixin for the view document as described in the {@link ~BubblingEmitter} interface.
@@ -24,7 +24,7 @@ const contextsSymbol = Symbol('bubbling contexts');
24
24
  * }
25
25
  * ```
26
26
  */
27
- export default function BubblingEmitterMixin(base) {
27
+ export function BubblingEmitterMixin(base) {
28
28
  class Mixin extends base {
29
29
  fire(eventOrInfo, ...eventArgs) {
30
30
  try {
@@ -102,13 +102,6 @@ export default function BubblingEmitterMixin(base) {
102
102
  }
103
103
  return Mixin;
104
104
  }
105
- // Backward compatibility with `mix`.
106
- {
107
- const mixin = BubblingEmitterMixin(Object);
108
- ['fire', '_addEventListener', '_removeEventListener'].forEach(key => {
109
- BubblingEmitterMixin[key] = mixin.prototype[key];
110
- });
111
- }
112
105
  /**
113
106
  * Update the event info bubbling fields.
114
107
  *
@@ -6,18 +6,18 @@
6
6
  * @module engine/view/observer/bubblingeventinfo
7
7
  */
8
8
  import { EventInfo } from '@ckeditor/ckeditor5-utils';
9
- import type Document from '../document.js';
10
- import type Node from '../node.js';
11
- import type Range from '../range.js';
9
+ import { type ViewDocument } from '../document.js';
10
+ import { type ViewNode } from '../node.js';
11
+ import { type ViewRange } from '../range.js';
12
12
  /**
13
13
  * The event object passed to bubbling event callbacks. It is used to provide information about the event as well as a tool to
14
14
  * manipulate it.
15
15
  */
16
- export default class BubblingEventInfo<TName extends string = string, TReturn = unknown> extends EventInfo<TName, TReturn> {
16
+ export declare class BubblingEventInfo<TName extends string = string, TReturn = unknown> extends EventInfo<TName, TReturn> {
17
17
  /**
18
18
  * The view range that the bubbling should start from.
19
19
  */
20
- readonly startRange: Range;
20
+ readonly startRange: ViewRange;
21
21
  /**
22
22
  * The current event phase.
23
23
  */
@@ -31,17 +31,17 @@ export default class BubblingEventInfo<TName extends string = string, TReturn =
31
31
  * @param name The event name.
32
32
  * @param startRange The view range that the bubbling should start from.
33
33
  */
34
- constructor(source: object, name: TName, startRange: Range);
34
+ constructor(source: object, name: TName, startRange: ViewRange);
35
35
  /**
36
36
  * The current event phase.
37
37
  */
38
- get eventPhase(): EventPhase;
38
+ get eventPhase(): BubblingEventPhase;
39
39
  /**
40
40
  * The current bubbling target.
41
41
  */
42
- get currentTarget(): Document | Node | null;
42
+ get currentTarget(): ViewDocument | ViewNode | null;
43
43
  }
44
44
  /**
45
45
  * The phase the event is in.
46
46
  */
47
- export type EventPhase = 'none' | 'capturing' | 'atTarget' | 'bubbling';
47
+ export type BubblingEventPhase = 'none' | 'capturing' | 'atTarget' | 'bubbling';
@@ -10,7 +10,7 @@ import { EventInfo } from '@ckeditor/ckeditor5-utils';
10
10
  * The event object passed to bubbling event callbacks. It is used to provide information about the event as well as a tool to
11
11
  * manipulate it.
12
12
  */
13
- export default class BubblingEventInfo extends EventInfo {
13
+ export class BubblingEventInfo extends EventInfo {
14
14
  /**
15
15
  * The view range that the bubbling should start from.
16
16
  */
@@ -5,16 +5,16 @@
5
5
  /**
6
6
  * @module engine/view/observer/clickobserver
7
7
  */
8
- import DomEventObserver from './domeventobserver.js';
9
- import type DomEventData from './domeventdata.js';
8
+ import { DomEventObserver } from './domeventobserver.js';
9
+ import { type ViewDocumentDomEventData } from './domeventdata.js';
10
10
  import type { BubblingEvent } from './bubblingemittermixin.js';
11
11
  /**
12
- * {@link module:engine/view/document~Document#event:click Click} event observer.
12
+ * {@link module:engine/view/document~ViewDocument#event:click Click} event observer.
13
13
  *
14
14
  * Note that this observer is not available by default. To make it available it needs to be added to
15
- * {@link module:engine/view/view~View view controller} by a {@link module:engine/view/view~View#addObserver} method.
15
+ * {@link module:engine/view/view~EditingView view controller} by a {@link module:engine/view/view~EditingView#addObserver} method.
16
16
  */
17
- export default class ClickObserver extends DomEventObserver<'click'> {
17
+ export declare class ClickObserver extends DomEventObserver<'click'> {
18
18
  /**
19
19
  * @inheritDoc
20
20
  */
@@ -31,13 +31,13 @@ export default class ClickObserver extends DomEventObserver<'click'> {
31
31
  *
32
32
  * Note that this event is not available by default. To make it available
33
33
  * {@link module:engine/view/observer/clickobserver~ClickObserver} needs to be added
34
- * to {@link module:engine/view/view~View} by a {@link module:engine/view/view~View#addObserver} method.
34
+ * to {@link module:engine/view/view~EditingView} by a {@link module:engine/view/view~EditingView#addObserver} method.
35
35
  *
36
36
  * @see module:engine/view/observer/clickobserver~ClickObserver
37
- * @eventName module:engine/view/document~Document#click
37
+ * @eventName module:engine/view/document~ViewDocument#click
38
38
  * @param data Event data.
39
39
  */
40
40
  export type ViewDocumentClickEvent = BubblingEvent<{
41
41
  name: 'click';
42
- args: [data: DomEventData<MouseEvent>];
42
+ args: [data: ViewDocumentDomEventData<MouseEvent>];
43
43
  }>;