@ckeditor/ckeditor5-utils 39.0.1 → 40.0.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 (134) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/LICENSE.md +1 -1
  3. package/README.md +3 -3
  4. package/package.json +1 -5
  5. package/src/areconnectedthroughproperties.d.ts +11 -11
  6. package/src/areconnectedthroughproperties.js +73 -73
  7. package/src/ckeditorerror.d.ts +123 -123
  8. package/src/ckeditorerror.js +176 -176
  9. package/src/collection.d.ts +427 -427
  10. package/src/collection.js +575 -575
  11. package/src/comparearrays.d.ts +30 -30
  12. package/src/comparearrays.js +47 -47
  13. package/src/config.d.ts +163 -163
  14. package/src/config.js +162 -162
  15. package/src/count.d.ts +18 -18
  16. package/src/count.js +24 -24
  17. package/src/delay.d.ts +19 -19
  18. package/src/delay.js +26 -26
  19. package/src/diff.d.ts +31 -31
  20. package/src/diff.js +115 -115
  21. package/src/difftochanges.d.ts +59 -59
  22. package/src/difftochanges.js +79 -79
  23. package/src/dom/createelement.d.ts +57 -57
  24. package/src/dom/createelement.js +40 -40
  25. package/src/dom/emittermixin.d.ts +142 -142
  26. package/src/dom/emittermixin.js +239 -239
  27. package/src/dom/findclosestscrollableancestor.d.ts +11 -11
  28. package/src/dom/findclosestscrollableancestor.js +31 -31
  29. package/src/dom/getancestors.d.ts +17 -17
  30. package/src/dom/getancestors.js +27 -27
  31. package/src/dom/getborderwidths.d.ts +24 -24
  32. package/src/dom/getborderwidths.js +24 -24
  33. package/src/dom/getcommonancestor.d.ts +12 -12
  34. package/src/dom/getcommonancestor.js +25 -25
  35. package/src/dom/getdatafromelement.d.ts +14 -14
  36. package/src/dom/getdatafromelement.js +20 -20
  37. package/src/dom/getpositionedancestor.d.ts +10 -10
  38. package/src/dom/getpositionedancestor.js +22 -22
  39. package/src/dom/global.d.ts +32 -32
  40. package/src/dom/global.js +35 -35
  41. package/src/dom/indexof.d.ts +14 -14
  42. package/src/dom/indexof.js +21 -21
  43. package/src/dom/insertat.d.ts +15 -15
  44. package/src/dom/insertat.js +17 -17
  45. package/src/dom/iscomment.d.ts +11 -11
  46. package/src/dom/iscomment.js +14 -14
  47. package/src/dom/isnode.d.ts +11 -11
  48. package/src/dom/isnode.js +21 -21
  49. package/src/dom/isrange.d.ts +11 -11
  50. package/src/dom/isrange.js +13 -13
  51. package/src/dom/istext.d.ts +11 -11
  52. package/src/dom/istext.js +13 -13
  53. package/src/dom/isvalidattributename.d.ts +10 -10
  54. package/src/dom/isvalidattributename.js +22 -22
  55. package/src/dom/isvisible.d.ts +18 -18
  56. package/src/dom/isvisible.js +20 -20
  57. package/src/dom/iswindow.d.ts +11 -11
  58. package/src/dom/iswindow.js +22 -22
  59. package/src/dom/position.d.ts +211 -208
  60. package/src/dom/position.js +313 -305
  61. package/src/dom/rect.d.ts +195 -191
  62. package/src/dom/rect.js +474 -388
  63. package/src/dom/remove.d.ts +13 -13
  64. package/src/dom/remove.js +18 -18
  65. package/src/dom/resizeobserver.d.ts +74 -74
  66. package/src/dom/resizeobserver.js +126 -126
  67. package/src/dom/scroll.d.ts +73 -73
  68. package/src/dom/scroll.js +383 -383
  69. package/src/dom/setdatainelement.d.ts +14 -14
  70. package/src/dom/setdatainelement.js +20 -20
  71. package/src/dom/tounit.d.ts +22 -22
  72. package/src/dom/tounit.js +16 -16
  73. package/src/elementreplacer.d.ts +31 -31
  74. package/src/elementreplacer.js +43 -43
  75. package/src/emittermixin.d.ts +312 -312
  76. package/src/emittermixin.js +453 -453
  77. package/src/env.d.ts +117 -117
  78. package/src/env.js +122 -122
  79. package/src/eventinfo.d.ts +58 -58
  80. package/src/eventinfo.js +26 -26
  81. package/src/fastdiff.d.ts +112 -112
  82. package/src/fastdiff.js +248 -248
  83. package/src/first.d.ts +11 -11
  84. package/src/first.js +17 -17
  85. package/src/focustracker.d.ts +75 -75
  86. package/src/focustracker.js +95 -95
  87. package/src/index.d.ts +61 -62
  88. package/src/index.js +60 -61
  89. package/src/inserttopriorityarray.d.ts +30 -30
  90. package/src/inserttopriorityarray.js +21 -21
  91. package/src/isiterable.d.ts +14 -14
  92. package/src/isiterable.js +16 -16
  93. package/src/keyboard.d.ts +126 -126
  94. package/src/keyboard.js +221 -221
  95. package/src/keystrokehandler.d.ts +87 -87
  96. package/src/keystrokehandler.js +122 -122
  97. package/src/language.d.ts +17 -17
  98. package/src/language.js +19 -19
  99. package/src/locale.d.ts +120 -120
  100. package/src/locale.js +76 -76
  101. package/src/mapsequal.d.ts +15 -15
  102. package/src/mapsequal.js +27 -27
  103. package/src/mix.d.ts +85 -85
  104. package/src/mix.js +50 -50
  105. package/src/nth.d.ts +16 -16
  106. package/src/nth.js +24 -24
  107. package/src/objecttomap.d.ts +23 -23
  108. package/src/objecttomap.js +27 -27
  109. package/src/observablemixin.d.ts +560 -560
  110. package/src/observablemixin.js +580 -580
  111. package/src/priorities.d.ts +33 -33
  112. package/src/priorities.js +23 -23
  113. package/src/splicearray.d.ts +26 -26
  114. package/src/splicearray.js +40 -40
  115. package/src/spy.d.ts +21 -21
  116. package/src/spy.js +22 -22
  117. package/src/toarray.d.ts +25 -25
  118. package/src/toarray.js +7 -7
  119. package/src/tomap.d.ts +19 -19
  120. package/src/tomap.js +29 -29
  121. package/src/translation-service.d.ts +168 -168
  122. package/src/translation-service.js +198 -198
  123. package/src/uid.d.ts +15 -15
  124. package/src/uid.js +57 -57
  125. package/src/unicode.d.ts +54 -54
  126. package/src/unicode.js +85 -85
  127. package/src/verifylicense.d.ts +15 -15
  128. package/src/verifylicense.js +87 -87
  129. package/src/version.d.ts +10 -10
  130. package/src/version.js +153 -156
  131. package/src/dom/getelementsintersectionrect.d.ts +0 -17
  132. package/src/dom/getelementsintersectionrect.js +0 -42
  133. package/src/dom/getscrollableancestors.d.ts +0 -14
  134. package/src/dom/getscrollableancestors.js +0 -28
@@ -1,40 +1,40 @@
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 utils/dom/createelement
7
- */
8
- import isIterable from '../isiterable';
9
- import { isString } from 'lodash-es';
10
- /**
11
- * Creates an HTML or SVG element with attributes and children elements.
12
- *
13
- * ```ts
14
- * createElement( document, 'p' ); // <p>
15
- * createElement( document, 'mask', { xmlns: 'http://www.w3.org/2000/svg' } ); // <mask>
16
- * ```
17
- *
18
- * @param doc Document used to create the element.
19
- * @param name Name of the element.
20
- * @param attributes Object where keys represent attribute keys and values represent attribute values.
21
- * @param children Child or any iterable of children. Strings will be automatically turned into Text nodes.
22
- * @returns HTML or SVG element.
23
- */
24
- export default function createElement(doc, name, attributes = {}, children = []) {
25
- const namespace = attributes && attributes.xmlns;
26
- const element = namespace ? doc.createElementNS(namespace, name) : doc.createElement(name);
27
- for (const key in attributes) {
28
- element.setAttribute(key, attributes[key]);
29
- }
30
- if (isString(children) || !isIterable(children)) {
31
- children = [children];
32
- }
33
- for (let child of children) {
34
- if (isString(child)) {
35
- child = doc.createTextNode(child);
36
- }
37
- element.appendChild(child);
38
- }
39
- return element;
40
- }
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 utils/dom/createelement
7
+ */
8
+ import isIterable from '../isiterable';
9
+ import { isString } from 'lodash-es';
10
+ /**
11
+ * Creates an HTML or SVG element with attributes and children elements.
12
+ *
13
+ * ```ts
14
+ * createElement( document, 'p' ); // <p>
15
+ * createElement( document, 'mask', { xmlns: 'http://www.w3.org/2000/svg' } ); // <mask>
16
+ * ```
17
+ *
18
+ * @param doc Document used to create the element.
19
+ * @param name Name of the element.
20
+ * @param attributes Object where keys represent attribute keys and values represent attribute values.
21
+ * @param children Child or any iterable of children. Strings will be automatically turned into Text nodes.
22
+ * @returns HTML or SVG element.
23
+ */
24
+ export default function createElement(doc, name, attributes = {}, children = []) {
25
+ const namespace = attributes && attributes.xmlns;
26
+ const element = namespace ? doc.createElementNS(namespace, name) : doc.createElement(name);
27
+ for (const key in attributes) {
28
+ element.setAttribute(key, attributes[key]);
29
+ }
30
+ if (isString(children) || !isIterable(children)) {
31
+ children = [children];
32
+ }
33
+ for (let child of children) {
34
+ if (isString(child)) {
35
+ child = doc.createTextNode(child);
36
+ }
37
+ element.appendChild(child);
38
+ }
39
+ return element;
40
+ }
@@ -1,142 +1,142 @@
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 utils/dom/emittermixin
7
- */
8
- import { type Emitter, type CallbackOptions, type BaseEvent, type GetCallback } from '../emittermixin';
9
- import type EventInfo from '../eventinfo';
10
- import type { Constructor, Mixed } from '../mix';
11
- /**
12
- * Mixin that injects the DOM events API into its host. It provides the API
13
- * compatible with {@link module:utils/emittermixin~Emitter}.
14
- *
15
- * This function creates a class that inherits from the provided `base` and implements `Emitter` interface.
16
- *
17
- * DOM emitter mixin is by default available in the {@link module:ui/view~View} class,
18
- * but it can also be mixed into any other class:
19
- *
20
- * ```ts
21
- * import DomEmitterMixin from '../utils/dom/emittermixin.js';
22
- *
23
- * class BaseClass { ... }
24
- *
25
- * class SomeView extends DomEmitterMixin( BaseClass ) {}
26
- *
27
- * const view = new SomeView();
28
- * view.listenTo( domElement, ( evt, domEvt ) => {
29
- * console.log( evt, domEvt );
30
- * } );
31
- * ```
32
- *
33
- * @label EXTENDS
34
- */
35
- export default function DomEmitterMixin<Base extends Constructor<Emitter>>(base: Base): Mixed<Base, DomEmitter>;
36
- /**
37
- * Mixin that injects the DOM events API into its host. It provides the API
38
- * compatible with {@link module:utils/emittermixin~Emitter}.
39
- *
40
- * This function creates a class that implements `Emitter` interface.
41
- *
42
- * DOM emitter mixin is by default available in the {@link module:ui/view~View} class,
43
- * but it can also be mixed into any other class:
44
- *
45
- * ```ts
46
- * import DomEmitterMixin from '../utils/dom/emittermixin.js';
47
- *
48
- * class SomeView extends DomEmitterMixin() {}
49
- *
50
- * const view = new SomeView();
51
- * view.listenTo( domElement, ( evt, domEvt ) => {
52
- * console.log( evt, domEvt );
53
- * } );
54
- * ```
55
- *
56
- * @label NO_ARGUMENTS
57
- */
58
- export default function DomEmitterMixin(): {
59
- new (): DomEmitter;
60
- prototype: DomEmitter;
61
- };
62
- export interface DomEventMap extends HTMLElementEventMap, WindowEventMap {
63
- }
64
- /**
65
- * Interface representing classes which mix in {@link module:utils/dom/emittermixin~DomEmitterMixin}.
66
- *
67
- * Can be easily implemented by a class by mixing the {@link module:utils/dom/emittermixin~DomEmitterMixin} mixin.
68
- *
69
- * ```ts
70
- * class MyClass extends DomEmitterMixin( OtherBaseClass ) {
71
- * // This class now implements the `Emitter` interface.
72
- * }
73
- * ```
74
- */
75
- export interface DomEmitter extends Emitter {
76
- /**
77
- * Registers a callback function to be executed when an event is fired in a specific Emitter or DOM Node.
78
- * It is backwards compatible with {@link module:utils/emittermixin~Emitter#listenTo}.
79
- *
80
- * @label HTML_EMITTER
81
- * @param emitter The object that fires the event.
82
- * @param event The name of the event.
83
- * @param callback The function to be called on event.
84
- * @param options Additional options.
85
- * @param options.useCapture Indicates that events of this type will be dispatched to the registered
86
- * listener before being dispatched to any EventTarget beneath it in the DOM tree.
87
- * @param options.usePassive Indicates that the function specified by listener will never call preventDefault()
88
- * and prevents blocking browser's main thread by this event handler.
89
- */
90
- listenTo<K extends keyof DomEventMap>(emitter: Node | Window, event: K, callback: (this: this, ev: EventInfo, event: DomEventMap[K]) => void, options?: CallbackOptions & {
91
- readonly useCapture?: boolean;
92
- readonly usePassive?: boolean;
93
- }): void;
94
- /**
95
- * Registers a callback function to be executed when an event is fired in a specific (emitter) object.
96
- *
97
- * Events can be grouped in namespaces using `:`.
98
- * When namespaced event is fired, it additionally fires all callbacks for that namespace.
99
- *
100
- * ```ts
101
- * // myEmitter.on( ... ) is a shorthand for myEmitter.listenTo( myEmitter, ... ).
102
- * myEmitter.on( 'myGroup', genericCallback );
103
- * myEmitter.on( 'myGroup:myEvent', specificCallback );
104
- *
105
- * // genericCallback is fired.
106
- * myEmitter.fire( 'myGroup' );
107
- * // both genericCallback and specificCallback are fired.
108
- * myEmitter.fire( 'myGroup:myEvent' );
109
- * // genericCallback is fired even though there are no callbacks for "foo".
110
- * myEmitter.fire( 'myGroup:foo' );
111
- * ```
112
- *
113
- * An event callback can {@link module:utils/eventinfo~EventInfo#stop stop the event} and
114
- * set the {@link module:utils/eventinfo~EventInfo#return return value} of the {@link #fire} method.
115
- *
116
- * @label DOM_EMITTER
117
- * @typeParam TEvent The type describing the event. See {@link module:utils/emittermixin~BaseEvent}.
118
- * @param emitter The object that fires the event.
119
- * @param event The name of the event.
120
- * @param callback The function to be called on event.
121
- * @param options Additional options.
122
- */
123
- listenTo<TEvent extends BaseEvent>(emitter: Emitter, event: TEvent['name'], callback: GetCallback<TEvent>, options?: CallbackOptions): void;
124
- /**
125
- * Stops listening for events. It can be used at different levels:
126
- * It is backwards compatible with {@link module:utils/emittermixin~Emitter#listenTo}.
127
- *
128
- * * To stop listening to a specific callback.
129
- * * To stop listening to a specific event.
130
- * * To stop listening to all events fired by a specific object.
131
- * * To stop listening to all events fired by all objects.
132
- *
133
- * @label DOM_STOP
134
- * @param emitter The object to stop listening to.
135
- * If omitted, stops it for all objects.
136
- * @param event (Requires the `emitter`) The name of the event to stop listening to. If omitted, stops it
137
- * for all events from `emitter`.
138
- * @param callback (Requires the `event`) The function to be removed from the call list for the given
139
- * `event`.
140
- */
141
- stopListening(emitter?: Emitter | Node | Window, event?: string, callback?: Function): void;
142
- }
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 utils/dom/emittermixin
7
+ */
8
+ import { type Emitter, type CallbackOptions, type BaseEvent, type GetCallback } from '../emittermixin';
9
+ import type EventInfo from '../eventinfo';
10
+ import type { Constructor, Mixed } from '../mix';
11
+ /**
12
+ * Mixin that injects the DOM events API into its host. It provides the API
13
+ * compatible with {@link module:utils/emittermixin~Emitter}.
14
+ *
15
+ * This function creates a class that inherits from the provided `base` and implements `Emitter` interface.
16
+ *
17
+ * DOM emitter mixin is by default available in the {@link module:ui/view~View} class,
18
+ * but it can also be mixed into any other class:
19
+ *
20
+ * ```ts
21
+ * import DomEmitterMixin from '../utils/dom/emittermixin.js';
22
+ *
23
+ * class BaseClass { ... }
24
+ *
25
+ * class SomeView extends DomEmitterMixin( BaseClass ) {}
26
+ *
27
+ * const view = new SomeView();
28
+ * view.listenTo( domElement, ( evt, domEvt ) => {
29
+ * console.log( evt, domEvt );
30
+ * } );
31
+ * ```
32
+ *
33
+ * @label EXTENDS
34
+ */
35
+ export default function DomEmitterMixin<Base extends Constructor<Emitter>>(base: Base): Mixed<Base, DomEmitter>;
36
+ /**
37
+ * Mixin that injects the DOM events API into its host. It provides the API
38
+ * compatible with {@link module:utils/emittermixin~Emitter}.
39
+ *
40
+ * This function creates a class that implements `Emitter` interface.
41
+ *
42
+ * DOM emitter mixin is by default available in the {@link module:ui/view~View} class,
43
+ * but it can also be mixed into any other class:
44
+ *
45
+ * ```ts
46
+ * import DomEmitterMixin from '../utils/dom/emittermixin.js';
47
+ *
48
+ * class SomeView extends DomEmitterMixin() {}
49
+ *
50
+ * const view = new SomeView();
51
+ * view.listenTo( domElement, ( evt, domEvt ) => {
52
+ * console.log( evt, domEvt );
53
+ * } );
54
+ * ```
55
+ *
56
+ * @label NO_ARGUMENTS
57
+ */
58
+ export default function DomEmitterMixin(): {
59
+ new (): DomEmitter;
60
+ prototype: DomEmitter;
61
+ };
62
+ export interface DomEventMap extends HTMLElementEventMap, WindowEventMap {
63
+ }
64
+ /**
65
+ * Interface representing classes which mix in {@link module:utils/dom/emittermixin~DomEmitterMixin}.
66
+ *
67
+ * Can be easily implemented by a class by mixing the {@link module:utils/dom/emittermixin~DomEmitterMixin} mixin.
68
+ *
69
+ * ```ts
70
+ * class MyClass extends DomEmitterMixin( OtherBaseClass ) {
71
+ * // This class now implements the `Emitter` interface.
72
+ * }
73
+ * ```
74
+ */
75
+ export interface DomEmitter extends Emitter {
76
+ /**
77
+ * Registers a callback function to be executed when an event is fired in a specific Emitter or DOM Node.
78
+ * It is backwards compatible with {@link module:utils/emittermixin~Emitter#listenTo}.
79
+ *
80
+ * @label HTML_EMITTER
81
+ * @param emitter The object that fires the event.
82
+ * @param event The name of the event.
83
+ * @param callback The function to be called on event.
84
+ * @param options Additional options.
85
+ * @param options.useCapture Indicates that events of this type will be dispatched to the registered
86
+ * listener before being dispatched to any EventTarget beneath it in the DOM tree.
87
+ * @param options.usePassive Indicates that the function specified by listener will never call preventDefault()
88
+ * and prevents blocking browser's main thread by this event handler.
89
+ */
90
+ listenTo<K extends keyof DomEventMap>(emitter: Node | Window, event: K, callback: (this: this, ev: EventInfo, event: DomEventMap[K]) => void, options?: CallbackOptions & {
91
+ readonly useCapture?: boolean;
92
+ readonly usePassive?: boolean;
93
+ }): void;
94
+ /**
95
+ * Registers a callback function to be executed when an event is fired in a specific (emitter) object.
96
+ *
97
+ * Events can be grouped in namespaces using `:`.
98
+ * When namespaced event is fired, it additionally fires all callbacks for that namespace.
99
+ *
100
+ * ```ts
101
+ * // myEmitter.on( ... ) is a shorthand for myEmitter.listenTo( myEmitter, ... ).
102
+ * myEmitter.on( 'myGroup', genericCallback );
103
+ * myEmitter.on( 'myGroup:myEvent', specificCallback );
104
+ *
105
+ * // genericCallback is fired.
106
+ * myEmitter.fire( 'myGroup' );
107
+ * // both genericCallback and specificCallback are fired.
108
+ * myEmitter.fire( 'myGroup:myEvent' );
109
+ * // genericCallback is fired even though there are no callbacks for "foo".
110
+ * myEmitter.fire( 'myGroup:foo' );
111
+ * ```
112
+ *
113
+ * An event callback can {@link module:utils/eventinfo~EventInfo#stop stop the event} and
114
+ * set the {@link module:utils/eventinfo~EventInfo#return return value} of the {@link #fire} method.
115
+ *
116
+ * @label DOM_EMITTER
117
+ * @typeParam TEvent The type describing the event. See {@link module:utils/emittermixin~BaseEvent}.
118
+ * @param emitter The object that fires the event.
119
+ * @param event The name of the event.
120
+ * @param callback The function to be called on event.
121
+ * @param options Additional options.
122
+ */
123
+ listenTo<TEvent extends BaseEvent>(emitter: Emitter, event: TEvent['name'], callback: GetCallback<TEvent>, options?: CallbackOptions): void;
124
+ /**
125
+ * Stops listening for events. It can be used at different levels:
126
+ * It is backwards compatible with {@link module:utils/emittermixin~Emitter#listenTo}.
127
+ *
128
+ * * To stop listening to a specific callback.
129
+ * * To stop listening to a specific event.
130
+ * * To stop listening to all events fired by a specific object.
131
+ * * To stop listening to all events fired by all objects.
132
+ *
133
+ * @label DOM_STOP
134
+ * @param emitter The object to stop listening to.
135
+ * If omitted, stops it for all objects.
136
+ * @param event (Requires the `emitter`) The name of the event to stop listening to. If omitted, stops it
137
+ * for all events from `emitter`.
138
+ * @param callback (Requires the `event`) The function to be removed from the call list for the given
139
+ * `event`.
140
+ */
141
+ stopListening(emitter?: Emitter | Node | Window, event?: string, callback?: Function): void;
142
+ }