@ckeditor/ckeditor5-utils 39.0.2 → 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 (131) hide show
  1. package/package.json +1 -1
  2. package/src/areconnectedthroughproperties.d.ts +11 -11
  3. package/src/areconnectedthroughproperties.js +73 -73
  4. package/src/ckeditorerror.d.ts +123 -123
  5. package/src/ckeditorerror.js +176 -176
  6. package/src/collection.d.ts +427 -427
  7. package/src/collection.js +575 -575
  8. package/src/comparearrays.d.ts +30 -30
  9. package/src/comparearrays.js +47 -47
  10. package/src/config.d.ts +163 -163
  11. package/src/config.js +162 -162
  12. package/src/count.d.ts +18 -18
  13. package/src/count.js +24 -24
  14. package/src/delay.d.ts +19 -19
  15. package/src/delay.js +26 -26
  16. package/src/diff.d.ts +31 -31
  17. package/src/diff.js +115 -115
  18. package/src/difftochanges.d.ts +59 -59
  19. package/src/difftochanges.js +79 -79
  20. package/src/dom/createelement.d.ts +57 -57
  21. package/src/dom/createelement.js +40 -40
  22. package/src/dom/emittermixin.d.ts +142 -142
  23. package/src/dom/emittermixin.js +239 -239
  24. package/src/dom/findclosestscrollableancestor.d.ts +11 -11
  25. package/src/dom/findclosestscrollableancestor.js +31 -31
  26. package/src/dom/getancestors.d.ts +17 -17
  27. package/src/dom/getancestors.js +27 -27
  28. package/src/dom/getborderwidths.d.ts +24 -24
  29. package/src/dom/getborderwidths.js +24 -24
  30. package/src/dom/getcommonancestor.d.ts +12 -12
  31. package/src/dom/getcommonancestor.js +25 -25
  32. package/src/dom/getdatafromelement.d.ts +14 -14
  33. package/src/dom/getdatafromelement.js +20 -20
  34. package/src/dom/getpositionedancestor.d.ts +10 -10
  35. package/src/dom/getpositionedancestor.js +22 -22
  36. package/src/dom/global.d.ts +32 -32
  37. package/src/dom/global.js +35 -35
  38. package/src/dom/indexof.d.ts +14 -14
  39. package/src/dom/indexof.js +21 -21
  40. package/src/dom/insertat.d.ts +15 -15
  41. package/src/dom/insertat.js +17 -17
  42. package/src/dom/iscomment.d.ts +11 -11
  43. package/src/dom/iscomment.js +14 -14
  44. package/src/dom/isnode.d.ts +11 -11
  45. package/src/dom/isnode.js +21 -21
  46. package/src/dom/isrange.d.ts +11 -11
  47. package/src/dom/isrange.js +13 -13
  48. package/src/dom/istext.d.ts +11 -11
  49. package/src/dom/istext.js +13 -13
  50. package/src/dom/isvalidattributename.d.ts +10 -10
  51. package/src/dom/isvalidattributename.js +22 -22
  52. package/src/dom/isvisible.d.ts +18 -18
  53. package/src/dom/isvisible.js +20 -20
  54. package/src/dom/iswindow.d.ts +11 -11
  55. package/src/dom/iswindow.js +22 -22
  56. package/src/dom/position.d.ts +211 -208
  57. package/src/dom/position.js +313 -305
  58. package/src/dom/rect.d.ts +195 -191
  59. package/src/dom/rect.js +474 -388
  60. package/src/dom/remove.d.ts +13 -13
  61. package/src/dom/remove.js +18 -18
  62. package/src/dom/resizeobserver.d.ts +74 -74
  63. package/src/dom/resizeobserver.js +126 -126
  64. package/src/dom/scroll.d.ts +73 -73
  65. package/src/dom/scroll.js +383 -383
  66. package/src/dom/setdatainelement.d.ts +14 -14
  67. package/src/dom/setdatainelement.js +20 -20
  68. package/src/dom/tounit.d.ts +22 -22
  69. package/src/dom/tounit.js +16 -16
  70. package/src/elementreplacer.d.ts +31 -31
  71. package/src/elementreplacer.js +43 -43
  72. package/src/emittermixin.d.ts +312 -312
  73. package/src/emittermixin.js +453 -453
  74. package/src/env.d.ts +117 -117
  75. package/src/env.js +122 -122
  76. package/src/eventinfo.d.ts +58 -58
  77. package/src/eventinfo.js +26 -26
  78. package/src/fastdiff.d.ts +112 -112
  79. package/src/fastdiff.js +248 -248
  80. package/src/first.d.ts +11 -11
  81. package/src/first.js +17 -17
  82. package/src/focustracker.d.ts +75 -75
  83. package/src/focustracker.js +95 -95
  84. package/src/index.d.ts +61 -62
  85. package/src/index.js +60 -61
  86. package/src/inserttopriorityarray.d.ts +30 -30
  87. package/src/inserttopriorityarray.js +21 -21
  88. package/src/isiterable.d.ts +14 -14
  89. package/src/isiterable.js +16 -16
  90. package/src/keyboard.d.ts +126 -126
  91. package/src/keyboard.js +221 -221
  92. package/src/keystrokehandler.d.ts +87 -87
  93. package/src/keystrokehandler.js +122 -122
  94. package/src/language.d.ts +17 -17
  95. package/src/language.js +19 -19
  96. package/src/locale.d.ts +120 -120
  97. package/src/locale.js +76 -76
  98. package/src/mapsequal.d.ts +15 -15
  99. package/src/mapsequal.js +27 -27
  100. package/src/mix.d.ts +85 -85
  101. package/src/mix.js +50 -50
  102. package/src/nth.d.ts +16 -16
  103. package/src/nth.js +24 -24
  104. package/src/objecttomap.d.ts +23 -23
  105. package/src/objecttomap.js +27 -27
  106. package/src/observablemixin.d.ts +560 -560
  107. package/src/observablemixin.js +580 -580
  108. package/src/priorities.d.ts +33 -33
  109. package/src/priorities.js +23 -23
  110. package/src/splicearray.d.ts +26 -26
  111. package/src/splicearray.js +40 -40
  112. package/src/spy.d.ts +21 -21
  113. package/src/spy.js +22 -22
  114. package/src/toarray.d.ts +25 -25
  115. package/src/toarray.js +7 -7
  116. package/src/tomap.d.ts +19 -19
  117. package/src/tomap.js +29 -29
  118. package/src/translation-service.d.ts +168 -168
  119. package/src/translation-service.js +198 -198
  120. package/src/uid.d.ts +15 -15
  121. package/src/uid.js +57 -57
  122. package/src/unicode.d.ts +54 -54
  123. package/src/unicode.js +85 -85
  124. package/src/verifylicense.d.ts +15 -15
  125. package/src/verifylicense.js +87 -87
  126. package/src/version.d.ts +10 -10
  127. package/src/version.js +153 -153
  128. package/src/dom/getelementsintersectionrect.d.ts +0 -14
  129. package/src/dom/getelementsintersectionrect.js +0 -43
  130. package/src/dom/getscrollableancestors.d.ts +0 -14
  131. package/src/dom/getscrollableancestors.js +0 -28
@@ -1,208 +1,211 @@
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
- import Rect, { type RectSource } from './rect';
6
- /**
7
- * Calculates the `position: absolute` coordinates of a given element so it can be positioned with respect to the
8
- * target in the visually most efficient way, taking various restrictions like viewport or limiter geometry
9
- * into consideration.
10
- *
11
- * ```ts
12
- * // The element which is to be positioned.
13
- * const element = document.body.querySelector( '#toolbar' );
14
- *
15
- * // A target to which the element is positioned relatively.
16
- * const target = document.body.querySelector( '#container' );
17
- *
18
- * // Finding the optimal coordinates for the positioning.
19
- * const { left, top, name } = getOptimalPosition( {
20
- * element: element,
21
- * target: target,
22
- *
23
- * // The algorithm will chose among these positions to meet the requirements such
24
- * // as "limiter" element or "fitInViewport", set below. The positions are considered
25
- * // in the order of the array.
26
- * positions: [
27
- * //
28
- * // [ Target ]
29
- * // +-----------------+
30
- * // | Element |
31
- * // +-----------------+
32
- * //
33
- * targetRect => ( {
34
- * top: targetRect.bottom,
35
- * left: targetRect.left,
36
- * name: 'mySouthEastPosition'
37
- * } ),
38
- *
39
- * //
40
- * // +-----------------+
41
- * // | Element |
42
- * // +-----------------+
43
- * // [ Target ]
44
- * //
45
- * ( targetRect, elementRect ) => ( {
46
- * top: targetRect.top - elementRect.height,
47
- * left: targetRect.left,
48
- * name: 'myNorthEastPosition'
49
- * } )
50
- * ],
51
- *
52
- * // Find a position such guarantees the element remains within visible boundaries of <body>.
53
- * limiter: document.body,
54
- *
55
- * // Find a position such guarantees the element remains within visible boundaries of the browser viewport.
56
- * fitInViewport: true
57
- * } );
58
- *
59
- * // The best position which fits into document.body and the viewport. May be useful
60
- * // to set proper class on the `element`.
61
- * console.log( name ); // -> "myNorthEastPosition"
62
- *
63
- * // Using the absolute coordinates which has been found to position the element
64
- * // as in the diagram depicting the "myNorthEastPosition" position.
65
- * element.style.top = top;
66
- * element.style.left = left;
67
- * ```
68
- *
69
- * @param options The input data and configuration of the helper.
70
- */
71
- export declare function getOptimalPosition({ element, target, positions, limiter, fitInViewport, viewportOffsetConfig }: Options): Position;
72
- /**
73
- * A position object which instances are created and used by the {@link module:utils/dom/position~getOptimalPosition} helper.
74
- *
75
- * {@link module:utils/dom/position~Position#top} and {@link module:utils/dom/position~Position#left} properties of the position instance
76
- * translate directly to the `top` and `left` properties in CSS "`position: absolute` coordinate system". If set on the positioned element
77
- * in DOM, they will make it display it in the right place in the viewport.
78
- */
79
- export interface Position {
80
- /**
81
- * Position name.
82
- */
83
- readonly name?: string;
84
- /**
85
- * Additional position configuration, as passed from the {@link module:utils/dom/position~PositioningFunction positioning function}.
86
- *
87
- * This object can be use, for instance, to pass through presentation options used by the consumer of the
88
- * {@link module:utils/dom/position~getOptimalPosition} helper.
89
- */
90
- readonly config?: object;
91
- /**
92
- * The left value in pixels in the CSS `position: absolute` coordinate system.
93
- * Set it on the positioned element in DOM to move it to the position.
94
- */
95
- readonly left: number;
96
- /**
97
- * The top value in pixels in the CSS `position: absolute` coordinate system.
98
- * Set it on the positioned element in DOM to move it to the position.
99
- */
100
- readonly top: number;
101
- }
102
- /**
103
- * The `getOptimalPosition()` helper options.
104
- */
105
- export interface Options {
106
- /**
107
- * Element that is to be positioned.
108
- */
109
- readonly element: HTMLElement;
110
- /**
111
- * Target with respect to which the `element` is to be positioned.
112
- */
113
- readonly target: RectSource | (() => RectSource);
114
- /**
115
- * An array of positioning functions.
116
- *
117
- * **Note**: Positioning functions are processed in the order of preference. The first function that works
118
- * in the current environment (e.g. offers the complete fit in the viewport geometry) will be picked by
119
- * `getOptimalPosition()`.
120
- *
121
- * **Note**: Any positioning function returning `null` is ignored.
122
- */
123
- readonly positions: ReadonlyArray<PositioningFunction>;
124
- /**
125
- * When set, the algorithm will chose position which fits the most in the
126
- * limiter's bounding rect.
127
- */
128
- readonly limiter?: RectSource | (() => (RectSource | null)) | null;
129
- /**
130
- * When set, the algorithm will chose such a position which fits `element`
131
- * the most inside visible viewport.
132
- */
133
- readonly fitInViewport?: boolean;
134
- /**
135
- * Viewport offset config object. It restricts the visible viewport available to the `getOptimalPosition()` from each side.
136
- *
137
- * ```ts
138
- * {
139
- * top: 50,
140
- * right: 50,
141
- * bottom: 50,
142
- * left: 50
143
- * }
144
- * ```
145
- */
146
- readonly viewportOffsetConfig?: {
147
- readonly top?: number;
148
- readonly right?: number;
149
- readonly bottom?: number;
150
- readonly left?: number;
151
- };
152
- }
153
- /**
154
- * A positioning function which, based on positioned element and target {@link module:utils/dom/rect~Rect Rects}, returns rect coordinates
155
- * representing the geometrical relation between them. Used by the {@link module:utils/dom/position~getOptimalPosition} helper.
156
- *
157
- * ```ts
158
- * // This simple position will place the element directly under the target, in the middle:
159
- * //
160
- * // [ Target ]
161
- * // +-----------------+
162
- * // | Element |
163
- * // +-----------------+
164
- * //
165
- * const position = ( targetRect, elementRect, [ viewportRect ] ) => ( {
166
- * top: targetRect.bottom,
167
- * left: targetRect.left + targetRect.width / 2 - elementRect.width / 2,
168
- * name: 'bottomMiddle',
169
- *
170
- * // Note: The config is optional.
171
- * config: {
172
- * zIndex: '999'
173
- * }
174
- * } );
175
- * ```
176
- *
177
- * @param elementRect The rect of the element to be positioned.
178
- * @param targetRect The rect of the target the element (its rect) is relatively positioned to.
179
- * @param viewportRect The rect of the visual browser viewport.
180
- * @returns When the function returns `null`, it will not be considered by {@link module:utils/dom/position~getOptimalPosition}.
181
- */
182
- export type PositioningFunction = (elementRect: Rect, targetRect: Rect, viewportRect: Rect | null) => PositioningFunctionResult | null;
183
- /**
184
- * The result of {@link module:utils/dom/position~PositioningFunction}.
185
- */
186
- export interface PositioningFunctionResult {
187
- /**
188
- * The `top` value of the element rect that would represent the position.
189
- */
190
- top: number;
191
- /**
192
- * The `left` value of the element rect that would represent the position.
193
- */
194
- left: number;
195
- /**
196
- * The name of the position. It helps the user of the {@link module:utils/dom/position~getOptimalPosition}
197
- * helper to recognize different positioning function results. It will pass through to the {@link module:utils/dom/position~Position}
198
- * returned by the helper.
199
- */
200
- name?: string;
201
- /**
202
- * An optional configuration that will pass-through the {@link module:utils/dom/position~getOptimalPosition} helper
203
- * to the {@link module:utils/dom/position~Position} returned by this helper.
204
- * This configuration may, for instance, let the user of {@link module:utils/dom/position~getOptimalPosition} know that this particular
205
- * position comes with a certain presentation.
206
- */
207
- config?: object;
208
- }
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
+ import Rect, { type RectSource } from './rect';
6
+ /**
7
+ * Calculates the `position: absolute` coordinates of a given element so it can be positioned with respect to the
8
+ * target in the visually most efficient way, taking various restrictions like viewport or limiter geometry
9
+ * into consideration.
10
+ *
11
+ * **Note**: If there are no position coordinates found that meet the requirements (arguments of this helper),
12
+ * `null` is returned.
13
+ *
14
+ * ```ts
15
+ * // The element which is to be positioned.
16
+ * const element = document.body.querySelector( '#toolbar' );
17
+ *
18
+ * // A target to which the element is positioned relatively.
19
+ * const target = document.body.querySelector( '#container' );
20
+ *
21
+ * // Finding the optimal coordinates for the positioning.
22
+ * const { left, top, name } = getOptimalPosition( {
23
+ * element: element,
24
+ * target: target,
25
+ *
26
+ * // The algorithm will chose among these positions to meet the requirements such
27
+ * // as "limiter" element or "fitInViewport", set below. The positions are considered
28
+ * // in the order of the array.
29
+ * positions: [
30
+ * //
31
+ * // [ Target ]
32
+ * // +-----------------+
33
+ * // | Element |
34
+ * // +-----------------+
35
+ * //
36
+ * targetRect => ( {
37
+ * top: targetRect.bottom,
38
+ * left: targetRect.left,
39
+ * name: 'mySouthEastPosition'
40
+ * } ),
41
+ *
42
+ * //
43
+ * // +-----------------+
44
+ * // | Element |
45
+ * // +-----------------+
46
+ * // [ Target ]
47
+ * //
48
+ * ( targetRect, elementRect ) => ( {
49
+ * top: targetRect.top - elementRect.height,
50
+ * left: targetRect.left,
51
+ * name: 'myNorthEastPosition'
52
+ * } )
53
+ * ],
54
+ *
55
+ * // Find a position such guarantees the element remains within visible boundaries of <body>.
56
+ * limiter: document.body,
57
+ *
58
+ * // Find a position such guarantees the element remains within visible boundaries of the browser viewport.
59
+ * fitInViewport: true
60
+ * } );
61
+ *
62
+ * // The best position which fits into document.body and the viewport. May be useful
63
+ * // to set proper class on the `element`.
64
+ * console.log( name ); // -> "myNorthEastPosition"
65
+ *
66
+ * // Using the absolute coordinates which has been found to position the element
67
+ * // as in the diagram depicting the "myNorthEastPosition" position.
68
+ * element.style.top = top;
69
+ * element.style.left = left;
70
+ * ```
71
+ *
72
+ * @param options The input data and configuration of the helper.
73
+ */
74
+ export declare function getOptimalPosition({ element, target, positions, limiter, fitInViewport, viewportOffsetConfig }: Options): Position | null;
75
+ /**
76
+ * A position object which instances are created and used by the {@link module:utils/dom/position~getOptimalPosition} helper.
77
+ *
78
+ * {@link module:utils/dom/position~Position#top} and {@link module:utils/dom/position~Position#left} properties of the position instance
79
+ * translate directly to the `top` and `left` properties in CSS "`position: absolute` coordinate system". If set on the positioned element
80
+ * in DOM, they will make it display it in the right place in the viewport.
81
+ */
82
+ export interface Position {
83
+ /**
84
+ * Position name.
85
+ */
86
+ readonly name?: string;
87
+ /**
88
+ * Additional position configuration, as passed from the {@link module:utils/dom/position~PositioningFunction positioning function}.
89
+ *
90
+ * This object can be use, for instance, to pass through presentation options used by the consumer of the
91
+ * {@link module:utils/dom/position~getOptimalPosition} helper.
92
+ */
93
+ readonly config?: object;
94
+ /**
95
+ * The left value in pixels in the CSS `position: absolute` coordinate system.
96
+ * Set it on the positioned element in DOM to move it to the position.
97
+ */
98
+ readonly left: number;
99
+ /**
100
+ * The top value in pixels in the CSS `position: absolute` coordinate system.
101
+ * Set it on the positioned element in DOM to move it to the position.
102
+ */
103
+ readonly top: number;
104
+ }
105
+ /**
106
+ * The `getOptimalPosition()` helper options.
107
+ */
108
+ export interface Options {
109
+ /**
110
+ * Element that is to be positioned.
111
+ */
112
+ readonly element: HTMLElement;
113
+ /**
114
+ * Target with respect to which the `element` is to be positioned.
115
+ */
116
+ readonly target: RectSource | (() => RectSource);
117
+ /**
118
+ * An array of positioning functions.
119
+ *
120
+ * **Note**: Positioning functions are processed in the order of preference. The first function that works
121
+ * in the current environment (e.g. offers the complete fit in the viewport geometry) will be picked by
122
+ * `getOptimalPosition()`.
123
+ *
124
+ * **Note**: Any positioning function returning `null` is ignored.
125
+ */
126
+ readonly positions: ReadonlyArray<PositioningFunction>;
127
+ /**
128
+ * When set, the algorithm will chose position which fits the most in the
129
+ * limiter's bounding rect.
130
+ */
131
+ readonly limiter?: RectSource | (() => (RectSource | null)) | null;
132
+ /**
133
+ * When set, the algorithm will chose such a position which fits `element`
134
+ * the most inside visible viewport.
135
+ */
136
+ readonly fitInViewport?: boolean;
137
+ /**
138
+ * Viewport offset config object. It restricts the visible viewport available to the `getOptimalPosition()` from each side.
139
+ *
140
+ * ```ts
141
+ * {
142
+ * top: 50,
143
+ * right: 50,
144
+ * bottom: 50,
145
+ * left: 50
146
+ * }
147
+ * ```
148
+ */
149
+ readonly viewportOffsetConfig?: {
150
+ readonly top?: number;
151
+ readonly right?: number;
152
+ readonly bottom?: number;
153
+ readonly left?: number;
154
+ };
155
+ }
156
+ /**
157
+ * A positioning function which, based on positioned element and target {@link module:utils/dom/rect~Rect Rects}, returns rect coordinates
158
+ * representing the geometrical relation between them. Used by the {@link module:utils/dom/position~getOptimalPosition} helper.
159
+ *
160
+ * ```ts
161
+ * // This simple position will place the element directly under the target, in the middle:
162
+ * //
163
+ * // [ Target ]
164
+ * // +-----------------+
165
+ * // | Element |
166
+ * // +-----------------+
167
+ * //
168
+ * const position = ( targetRect, elementRect, [ viewportRect ] ) => ( {
169
+ * top: targetRect.bottom,
170
+ * left: targetRect.left + targetRect.width / 2 - elementRect.width / 2,
171
+ * name: 'bottomMiddle',
172
+ *
173
+ * // Note: The config is optional.
174
+ * config: {
175
+ * zIndex: '999'
176
+ * }
177
+ * } );
178
+ * ```
179
+ *
180
+ * @param elementRect The rect of the element to be positioned.
181
+ * @param targetRect The rect of the target the element (its rect) is relatively positioned to.
182
+ * @param viewportRect The rect of the visual browser viewport.
183
+ * @returns When the function returns `null`, it will not be considered by {@link module:utils/dom/position~getOptimalPosition}.
184
+ */
185
+ export type PositioningFunction = (elementRect: Rect, targetRect: Rect, viewportRect: Rect, limiterRect?: Rect) => PositioningFunctionResult | null;
186
+ /**
187
+ * The result of {@link module:utils/dom/position~PositioningFunction}.
188
+ */
189
+ export interface PositioningFunctionResult {
190
+ /**
191
+ * The `top` value of the element rect that would represent the position.
192
+ */
193
+ top: number;
194
+ /**
195
+ * The `left` value of the element rect that would represent the position.
196
+ */
197
+ left: number;
198
+ /**
199
+ * The name of the position. It helps the user of the {@link module:utils/dom/position~getOptimalPosition}
200
+ * helper to recognize different positioning function results. It will pass through to the {@link module:utils/dom/position~Position}
201
+ * returned by the helper.
202
+ */
203
+ name?: string;
204
+ /**
205
+ * An optional configuration that will pass-through the {@link module:utils/dom/position~getOptimalPosition} helper
206
+ * to the {@link module:utils/dom/position~Position} returned by this helper.
207
+ * This configuration may, for instance, let the user of {@link module:utils/dom/position~getOptimalPosition} know that this particular
208
+ * position comes with a certain presentation.
209
+ */
210
+ config?: object;
211
+ }