@ckeditor/ckeditor5-utils 44.1.0 → 44.2.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 (213) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/index-content.css +2 -2
  3. package/dist/index-editor.css +2 -2
  4. package/dist/index.css +2 -2
  5. package/dist/index.js +194 -47
  6. package/dist/index.js.map +1 -1
  7. package/package.json +24 -4
  8. package/src/abortabledebounce.d.ts +1 -1
  9. package/src/abortabledebounce.js +1 -1
  10. package/src/areconnectedthroughproperties.d.ts +1 -1
  11. package/src/areconnectedthroughproperties.js +1 -1
  12. package/src/ckeditorerror.d.ts +1 -1
  13. package/src/ckeditorerror.js +1 -1
  14. package/src/collection.d.ts +1 -1
  15. package/src/collection.js +1 -1
  16. package/src/collectstylesheets.d.ts +13 -0
  17. package/src/collectstylesheets.js +52 -0
  18. package/src/comparearrays.d.ts +1 -1
  19. package/src/comparearrays.js +1 -1
  20. package/src/config.d.ts +1 -1
  21. package/src/config.js +1 -1
  22. package/src/count.d.ts +1 -1
  23. package/src/count.js +1 -1
  24. package/src/crc32.d.ts +1 -1
  25. package/src/crc32.js +1 -1
  26. package/src/delay.d.ts +1 -1
  27. package/src/delay.js +1 -1
  28. package/src/diff.d.ts +1 -1
  29. package/src/diff.js +1 -1
  30. package/src/difftochanges.d.ts +1 -1
  31. package/src/difftochanges.js +1 -1
  32. package/src/dom/createelement.d.ts +1 -1
  33. package/src/dom/createelement.js +1 -1
  34. package/src/dom/emittermixin.d.ts +1 -1
  35. package/src/dom/emittermixin.js +1 -1
  36. package/src/dom/findclosestscrollableancestor.d.ts +1 -1
  37. package/src/dom/findclosestscrollableancestor.js +1 -1
  38. package/src/dom/getancestors.d.ts +1 -1
  39. package/src/dom/getancestors.js +1 -1
  40. package/src/dom/getborderwidths.d.ts +1 -1
  41. package/src/dom/getborderwidths.js +1 -1
  42. package/src/dom/getcommonancestor.d.ts +1 -1
  43. package/src/dom/getcommonancestor.js +1 -1
  44. package/src/dom/getdatafromelement.d.ts +1 -1
  45. package/src/dom/getdatafromelement.js +1 -1
  46. package/src/dom/getpositionedancestor.d.ts +1 -1
  47. package/src/dom/getpositionedancestor.js +1 -1
  48. package/src/dom/getrangefrommouseevent.d.ts +1 -1
  49. package/src/dom/getrangefrommouseevent.js +1 -1
  50. package/src/dom/global.d.ts +1 -1
  51. package/src/dom/global.js +1 -1
  52. package/src/dom/indexof.d.ts +1 -1
  53. package/src/dom/indexof.js +1 -1
  54. package/src/dom/insertat.d.ts +1 -1
  55. package/src/dom/insertat.js +1 -1
  56. package/src/dom/iscomment.d.ts +1 -1
  57. package/src/dom/iscomment.js +1 -1
  58. package/src/dom/isnode.d.ts +1 -1
  59. package/src/dom/isnode.js +1 -1
  60. package/src/dom/isrange.d.ts +1 -1
  61. package/src/dom/isrange.js +1 -1
  62. package/src/dom/istext.d.ts +1 -1
  63. package/src/dom/istext.js +1 -1
  64. package/src/dom/isvalidattributename.d.ts +1 -1
  65. package/src/dom/isvalidattributename.js +1 -1
  66. package/src/dom/isvisible.d.ts +1 -1
  67. package/src/dom/isvisible.js +1 -1
  68. package/src/dom/iswindow.d.ts +1 -1
  69. package/src/dom/iswindow.js +1 -1
  70. package/src/dom/position.d.ts +1 -1
  71. package/src/dom/position.js +1 -1
  72. package/src/dom/rect.d.ts +1 -1
  73. package/src/dom/rect.js +1 -1
  74. package/src/dom/remove.d.ts +1 -1
  75. package/src/dom/remove.js +1 -1
  76. package/src/dom/resizeobserver.d.ts +1 -1
  77. package/src/dom/resizeobserver.js +1 -1
  78. package/src/dom/scroll.d.ts +1 -1
  79. package/src/dom/scroll.js +1 -1
  80. package/src/dom/setdatainelement.d.ts +1 -1
  81. package/src/dom/setdatainelement.js +1 -1
  82. package/src/dom/tounit.d.ts +1 -1
  83. package/src/dom/tounit.js +1 -1
  84. package/src/elementreplacer.d.ts +1 -1
  85. package/src/elementreplacer.js +1 -1
  86. package/src/emittermixin.d.ts +1 -1
  87. package/src/emittermixin.js +1 -1
  88. package/src/env.d.ts +1 -1
  89. package/src/env.js +1 -1
  90. package/src/eventinfo.d.ts +1 -1
  91. package/src/eventinfo.js +1 -1
  92. package/src/fastdiff.d.ts +1 -1
  93. package/src/fastdiff.js +1 -1
  94. package/src/first.d.ts +1 -1
  95. package/src/first.js +1 -1
  96. package/src/focustracker.d.ts +1 -1
  97. package/src/focustracker.js +1 -1
  98. package/src/index.d.ts +3 -1
  99. package/src/index.js +3 -1
  100. package/src/inserttopriorityarray.d.ts +1 -1
  101. package/src/inserttopriorityarray.js +1 -1
  102. package/src/isiterable.d.ts +1 -1
  103. package/src/isiterable.js +1 -1
  104. package/src/keyboard.d.ts +4 -3
  105. package/src/keyboard.js +8 -4
  106. package/src/keystrokehandler.d.ts +1 -1
  107. package/src/keystrokehandler.js +1 -1
  108. package/src/language.d.ts +1 -1
  109. package/src/language.js +1 -1
  110. package/src/locale.d.ts +1 -1
  111. package/src/locale.js +1 -1
  112. package/src/mapsequal.d.ts +1 -1
  113. package/src/mapsequal.js +1 -1
  114. package/src/mix.d.ts +1 -1
  115. package/src/mix.js +1 -1
  116. package/src/nth.d.ts +1 -1
  117. package/src/nth.js +1 -1
  118. package/src/objecttomap.d.ts +1 -1
  119. package/src/objecttomap.js +1 -1
  120. package/src/observablemixin.d.ts +1 -1
  121. package/src/observablemixin.js +1 -1
  122. package/src/parsebase64encodedobject.d.ts +1 -1
  123. package/src/parsebase64encodedobject.js +1 -1
  124. package/src/priorities.d.ts +1 -1
  125. package/src/priorities.js +1 -1
  126. package/src/retry.d.ts +1 -1
  127. package/src/retry.js +1 -1
  128. package/src/splicearray.d.ts +1 -1
  129. package/src/splicearray.js +1 -1
  130. package/src/spy.d.ts +1 -1
  131. package/src/spy.js +1 -1
  132. package/src/toarray.d.ts +1 -1
  133. package/src/toarray.js +1 -1
  134. package/src/tomap.d.ts +1 -1
  135. package/src/tomap.js +1 -1
  136. package/src/translation-service.d.ts +1 -1
  137. package/src/translation-service.js +1 -1
  138. package/src/uid.d.ts +1 -1
  139. package/src/uid.js +1 -1
  140. package/src/unicode.d.ts +1 -1
  141. package/src/unicode.js +1 -1
  142. package/src/version.d.ts +2 -2
  143. package/src/version.js +3 -3
  144. package/src/wait.d.ts +1 -1
  145. package/src/wait.js +1 -1
  146. package/dist/abortabledebounce.d.ts +0 -21
  147. package/dist/areconnectedthroughproperties.d.ts +0 -15
  148. package/dist/ckeditorerror.d.ts +0 -127
  149. package/dist/collection.d.ts +0 -437
  150. package/dist/comparearrays.d.ts +0 -34
  151. package/dist/config.d.ts +0 -167
  152. package/dist/count.d.ts +0 -22
  153. package/dist/crc32.d.ts +0 -30
  154. package/dist/delay.d.ts +0 -23
  155. package/dist/diff.d.ts +0 -35
  156. package/dist/difftochanges.d.ts +0 -63
  157. package/dist/dom/createelement.d.ts +0 -61
  158. package/dist/dom/emittermixin.d.ts +0 -146
  159. package/dist/dom/findclosestscrollableancestor.d.ts +0 -15
  160. package/dist/dom/getancestors.d.ts +0 -21
  161. package/dist/dom/getborderwidths.d.ts +0 -28
  162. package/dist/dom/getcommonancestor.d.ts +0 -16
  163. package/dist/dom/getdatafromelement.d.ts +0 -18
  164. package/dist/dom/getpositionedancestor.d.ts +0 -14
  165. package/dist/dom/getrangefrommouseevent.d.ts +0 -21
  166. package/dist/dom/global.d.ts +0 -36
  167. package/dist/dom/indexof.d.ts +0 -18
  168. package/dist/dom/insertat.d.ts +0 -19
  169. package/dist/dom/iscomment.d.ts +0 -15
  170. package/dist/dom/isnode.d.ts +0 -15
  171. package/dist/dom/isrange.d.ts +0 -15
  172. package/dist/dom/istext.d.ts +0 -15
  173. package/dist/dom/isvalidattributename.d.ts +0 -14
  174. package/dist/dom/isvisible.d.ts +0 -19
  175. package/dist/dom/iswindow.d.ts +0 -15
  176. package/dist/dom/position.d.ts +0 -215
  177. package/dist/dom/rect.d.ts +0 -199
  178. package/dist/dom/remove.d.ts +0 -17
  179. package/dist/dom/resizeobserver.d.ts +0 -78
  180. package/dist/dom/scroll.d.ts +0 -77
  181. package/dist/dom/setdatainelement.d.ts +0 -18
  182. package/dist/dom/tounit.d.ts +0 -26
  183. package/dist/elementreplacer.d.ts +0 -35
  184. package/dist/emittermixin.d.ts +0 -316
  185. package/dist/env.d.ts +0 -144
  186. package/dist/eventinfo.d.ts +0 -62
  187. package/dist/fastdiff.d.ts +0 -116
  188. package/dist/first.d.ts +0 -15
  189. package/dist/focustracker.d.ts +0 -144
  190. package/dist/index.d.ts +0 -70
  191. package/dist/inserttopriorityarray.d.ts +0 -34
  192. package/dist/isiterable.d.ts +0 -18
  193. package/dist/keyboard.d.ts +0 -130
  194. package/dist/keystrokehandler.d.ts +0 -101
  195. package/dist/language.d.ts +0 -21
  196. package/dist/locale.d.ts +0 -145
  197. package/dist/mapsequal.d.ts +0 -19
  198. package/dist/mix.d.ts +0 -89
  199. package/dist/nth.d.ts +0 -20
  200. package/dist/objecttomap.d.ts +0 -27
  201. package/dist/observablemixin.d.ts +0 -564
  202. package/dist/parsebase64encodedobject.d.ts +0 -15
  203. package/dist/priorities.d.ts +0 -37
  204. package/dist/retry.d.ts +0 -37
  205. package/dist/splicearray.d.ts +0 -31
  206. package/dist/spy.d.ts +0 -25
  207. package/dist/toarray.d.ts +0 -29
  208. package/dist/tomap.d.ts +0 -23
  209. package/dist/translation-service.d.ts +0 -178
  210. package/dist/uid.d.ts +0 -19
  211. package/dist/unicode.d.ts +0 -58
  212. package/dist/version.d.ts +0 -14
  213. package/dist/wait.d.ts +0 -20
@@ -1,15 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module utils/dom/iswindow
11
- */
12
- /**
13
- * Checks if the object is a native DOM Window.
14
- */
15
- export default function isWindow(obj: unknown): obj is Window;
@@ -1,215 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- import Rect, { type RectSource } from './rect.js';
10
- /**
11
- * Calculates the `position: absolute` coordinates of a given element so it can be positioned with respect to the
12
- * target in the visually most efficient way, taking various restrictions like viewport or limiter geometry
13
- * into consideration.
14
- *
15
- * **Note**: If there are no position coordinates found that meet the requirements (arguments of this helper),
16
- * `null` is returned.
17
- *
18
- * ```ts
19
- * // The element which is to be positioned.
20
- * const element = document.body.querySelector( '#toolbar' );
21
- *
22
- * // A target to which the element is positioned relatively.
23
- * const target = document.body.querySelector( '#container' );
24
- *
25
- * // Finding the optimal coordinates for the positioning.
26
- * const { left, top, name } = getOptimalPosition( {
27
- * element: element,
28
- * target: target,
29
- *
30
- * // The algorithm will chose among these positions to meet the requirements such
31
- * // as "limiter" element or "fitInViewport", set below. The positions are considered
32
- * // in the order of the array.
33
- * positions: [
34
- * //
35
- * // [ Target ]
36
- * // +-----------------+
37
- * // | Element |
38
- * // +-----------------+
39
- * //
40
- * targetRect => ( {
41
- * top: targetRect.bottom,
42
- * left: targetRect.left,
43
- * name: 'mySouthEastPosition'
44
- * } ),
45
- *
46
- * //
47
- * // +-----------------+
48
- * // | Element |
49
- * // +-----------------+
50
- * // [ Target ]
51
- * //
52
- * ( targetRect, elementRect ) => ( {
53
- * top: targetRect.top - elementRect.height,
54
- * left: targetRect.left,
55
- * name: 'myNorthEastPosition'
56
- * } )
57
- * ],
58
- *
59
- * // Find a position such guarantees the element remains within visible boundaries of <body>.
60
- * limiter: document.body,
61
- *
62
- * // Find a position such guarantees the element remains within visible boundaries of the browser viewport.
63
- * fitInViewport: true
64
- * } );
65
- *
66
- * // The best position which fits into document.body and the viewport. May be useful
67
- * // to set proper class on the `element`.
68
- * console.log( name ); // -> "myNorthEastPosition"
69
- *
70
- * // Using the absolute coordinates which has been found to position the element
71
- * // as in the diagram depicting the "myNorthEastPosition" position.
72
- * element.style.top = top;
73
- * element.style.left = left;
74
- * ```
75
- *
76
- * @param options The input data and configuration of the helper.
77
- */
78
- export declare function getOptimalPosition({ element, target, positions, limiter, fitInViewport, viewportOffsetConfig }: Options): DomPoint | null;
79
- /**
80
- * A position object which instances are created and used by the {@link module:utils/dom/position~getOptimalPosition} helper.
81
- *
82
- * {@link module:utils/dom/position~DomPoint#top} and {@link module:utils/dom/position~DomPoint#left} properties of the position instance
83
- * translate directly to the `top` and `left` properties in CSS "`position: absolute` coordinate system". If set on the positioned element
84
- * in DOM, they will make it display it in the right place in the viewport.
85
- */
86
- export interface DomPoint {
87
- /**
88
- * Position name.
89
- */
90
- readonly name?: string;
91
- /**
92
- * Additional position configuration, as passed from the {@link module:utils/dom/position~PositioningFunction positioning function}.
93
- *
94
- * This object can be use, for instance, to pass through presentation options used by the consumer of the
95
- * {@link module:utils/dom/position~getOptimalPosition} helper.
96
- */
97
- readonly config?: object;
98
- /**
99
- * The left value in pixels in the CSS `position: absolute` coordinate system.
100
- * Set it on the positioned element in DOM to move it to the position.
101
- */
102
- readonly left: number;
103
- /**
104
- * The top value in pixels in the CSS `position: absolute` coordinate system.
105
- * Set it on the positioned element in DOM to move it to the position.
106
- */
107
- readonly top: number;
108
- }
109
- /**
110
- * The `getOptimalPosition()` helper options.
111
- */
112
- export interface Options {
113
- /**
114
- * Element that is to be positioned.
115
- */
116
- readonly element: HTMLElement;
117
- /**
118
- * Target with respect to which the `element` is to be positioned.
119
- */
120
- readonly target: RectSource | (() => RectSource);
121
- /**
122
- * An array of positioning functions.
123
- *
124
- * **Note**: Positioning functions are processed in the order of preference. The first function that works
125
- * in the current environment (e.g. offers the complete fit in the viewport geometry) will be picked by
126
- * `getOptimalPosition()`.
127
- *
128
- * **Note**: Any positioning function returning `null` is ignored.
129
- */
130
- readonly positions: ReadonlyArray<PositioningFunction>;
131
- /**
132
- * When set, the algorithm will chose position which fits the most in the
133
- * limiter's bounding rect.
134
- */
135
- readonly limiter?: RectSource | (() => (RectSource | null)) | null;
136
- /**
137
- * When set, the algorithm will chose such a position which fits `element`
138
- * the most inside visible viewport.
139
- */
140
- readonly fitInViewport?: boolean;
141
- /**
142
- * Viewport offset config object. It restricts the visible viewport available to the `getOptimalPosition()` from each side.
143
- *
144
- * ```ts
145
- * {
146
- * top: 50,
147
- * right: 50,
148
- * bottom: 50,
149
- * left: 50
150
- * }
151
- * ```
152
- */
153
- readonly viewportOffsetConfig?: {
154
- readonly top?: number;
155
- readonly right?: number;
156
- readonly bottom?: number;
157
- readonly left?: number;
158
- };
159
- }
160
- /**
161
- * A positioning function which, based on positioned element and target {@link module:utils/dom/rect~Rect Rects}, returns rect coordinates
162
- * representing the geometrical relation between them. Used by the {@link module:utils/dom/position~getOptimalPosition} helper.
163
- *
164
- * ```ts
165
- * // This simple position will place the element directly under the target, in the middle:
166
- * //
167
- * // [ Target ]
168
- * // +-----------------+
169
- * // | Element |
170
- * // +-----------------+
171
- * //
172
- * const position = ( targetRect, elementRect, [ viewportRect ] ) => ( {
173
- * top: targetRect.bottom,
174
- * left: targetRect.left + targetRect.width / 2 - elementRect.width / 2,
175
- * name: 'bottomMiddle',
176
- *
177
- * // Note: The config is optional.
178
- * config: {
179
- * zIndex: '999'
180
- * }
181
- * } );
182
- * ```
183
- *
184
- * @param elementRect The rect of the element to be positioned.
185
- * @param targetRect The rect of the target the element (its rect) is relatively positioned to.
186
- * @param viewportRect The rect of the visual browser viewport.
187
- * @returns When the function returns `null`, it will not be considered by {@link module:utils/dom/position~getOptimalPosition}.
188
- */
189
- export type PositioningFunction = (elementRect: Rect, targetRect: Rect, viewportRect: Rect, limiterRect?: Rect) => PositioningFunctionResult | null;
190
- /**
191
- * The result of {@link module:utils/dom/position~PositioningFunction}.
192
- */
193
- export interface PositioningFunctionResult {
194
- /**
195
- * The `top` value of the element rect that would represent the position.
196
- */
197
- top: number;
198
- /**
199
- * The `left` value of the element rect that would represent the position.
200
- */
201
- left: number;
202
- /**
203
- * The name of the position. It helps the user of the {@link module:utils/dom/position~getOptimalPosition}
204
- * helper to recognize different positioning function results. It will pass through to the {@link module:utils/dom/position~DomPoint}
205
- * returned by the helper.
206
- */
207
- name?: string;
208
- /**
209
- * An optional configuration that will pass-through the {@link module:utils/dom/position~getOptimalPosition} helper
210
- * to the {@link module:utils/dom/position~DomPoint} returned by this helper.
211
- * This configuration may, for instance, let the user of {@link module:utils/dom/position~getOptimalPosition} know that this particular
212
- * position comes with a certain presentation.
213
- */
214
- config?: object;
215
- }
@@ -1,199 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * A helper class representing a `ClientRect` object, e.g. value returned by
11
- * the native `object.getBoundingClientRect()` method. Provides a set of methods
12
- * to manipulate the rect and compare it against other rect instances.
13
- */
14
- export default class Rect {
15
- /**
16
- * The "top" value of the rect.
17
- *
18
- * @readonly
19
- */
20
- top: number;
21
- /**
22
- * The "right" value of the rect.
23
- *
24
- * @readonly
25
- */
26
- right: number;
27
- /**
28
- * The "bottom" value of the rect.
29
- *
30
- * @readonly
31
- */
32
- bottom: number;
33
- /**
34
- * The "left" value of the rect.
35
- *
36
- * @readonly
37
- */
38
- left: number;
39
- /**
40
- * The "width" value of the rect.
41
- *
42
- * @readonly
43
- */
44
- width: number;
45
- /**
46
- * The "height" value of the rect.
47
- *
48
- * @readonly
49
- */
50
- height: number;
51
- /**
52
- * The object this rect is for.
53
- *
54
- * @readonly
55
- */
56
- private _source;
57
- /**
58
- * Creates an instance of rect.
59
- *
60
- * ```ts
61
- * // Rect of an HTMLElement.
62
- * const rectA = new Rect( document.body );
63
- *
64
- * // Rect of a DOM Range.
65
- * const rectB = new Rect( document.getSelection().getRangeAt( 0 ) );
66
- *
67
- * // Rect of a window (web browser viewport).
68
- * const rectC = new Rect( window );
69
- *
70
- * // Rect out of an object.
71
- * const rectD = new Rect( { top: 0, right: 10, bottom: 10, left: 0, width: 10, height: 10 } );
72
- *
73
- * // Rect out of another Rect instance.
74
- * const rectE = new Rect( rectD );
75
- *
76
- * // Rect out of a ClientRect.
77
- * const rectF = new Rect( document.body.getClientRects().item( 0 ) );
78
- * ```
79
- *
80
- * **Note**: By default a rect of an HTML element includes its CSS borders and scrollbars (if any)
81
- * ant the rect of a `window` includes scrollbars too. Use {@link #excludeScrollbarsAndBorders}
82
- * to get the inner part of the rect.
83
- *
84
- * @param source A source object to create the rect.
85
- */
86
- constructor(source: RectSource);
87
- /**
88
- * Returns a clone of the rect.
89
- *
90
- * @returns A cloned rect.
91
- */
92
- clone(): Rect;
93
- /**
94
- * Moves the rect so that its upper–left corner lands in desired `[ x, y ]` location.
95
- *
96
- * @param x Desired horizontal location.
97
- * @param y Desired vertical location.
98
- * @returns A rect which has been moved.
99
- */
100
- moveTo(x: number, y: number): this;
101
- /**
102
- * Moves the rect in–place by a dedicated offset.
103
- *
104
- * @param x A horizontal offset.
105
- * @param y A vertical offset
106
- * @returns A rect which has been moved.
107
- */
108
- moveBy(x: number, y: number): this;
109
- /**
110
- * Returns a new rect a a result of intersection with another rect.
111
- */
112
- getIntersection(anotherRect: Rect): Rect | null;
113
- /**
114
- * Returns the area of intersection with another rect.
115
- *
116
- * @returns Area of intersection.
117
- */
118
- getIntersectionArea(anotherRect: Rect): number;
119
- /**
120
- * Returns the area of the rect.
121
- */
122
- getArea(): number;
123
- /**
124
- * Returns a new rect, a part of the original rect, which is actually visible to the user and is relative to the,`body`,
125
- * e.g. an original rect cropped by parent element rects which have `overflow` set in CSS
126
- * other than `"visible"`.
127
- *
128
- * If there's no such visible rect, which is when the rect is limited by one or many of
129
- * the ancestors, `null` is returned.
130
- *
131
- * **Note**: This method does not consider the boundaries of the viewport (window).
132
- * To get a rect cropped by all ancestors and the viewport, use an intersection such as:
133
- *
134
- * ```ts
135
- * const visibleInViewportRect = new Rect( window ).getIntersection( new Rect( source ).getVisible() );
136
- * ```
137
- *
138
- * @returns A visible rect instance or `null`, if there's none.
139
- */
140
- getVisible(): Rect | null;
141
- /**
142
- * Checks if all property values ({@link #top}, {@link #left}, {@link #right},
143
- * {@link #bottom}, {@link #width} and {@link #height}) are the equal in both rect
144
- * instances.
145
- *
146
- * @param anotherRect A rect instance to compare with.
147
- * @returns `true` when Rects are equal. `false` otherwise.
148
- */
149
- isEqual(anotherRect: Rect): boolean;
150
- /**
151
- * Checks whether a rect fully contains another rect instance.
152
- *
153
- * @param anotherRect
154
- * @returns `true` if contains, `false` otherwise.
155
- */
156
- contains(anotherRect: Rect): boolean;
157
- /**
158
- * Recalculates screen coordinates to coordinates relative to the positioned ancestor offset.
159
- */
160
- toAbsoluteRect(): Rect;
161
- /**
162
- * Excludes scrollbars and CSS borders from the rect.
163
- *
164
- * * Borders are removed when {@link #_source} is an HTML element.
165
- * * Scrollbars are excluded from HTML elements and the `window`.
166
- *
167
- * @returns A rect which has been updated.
168
- */
169
- excludeScrollbarsAndBorders(): this;
170
- /**
171
- * Returns an array of rects of the given native DOM Range.
172
- *
173
- * @param range A native DOM range.
174
- * @returns DOM Range rects.
175
- */
176
- static getDomRangeRects(range: Range): Array<Rect>;
177
- /**
178
- * Returns a bounding rectangle that contains all the given `rects`.
179
- *
180
- * @param rects A list of rectangles that should be contained in the result rectangle.
181
- * @returns Bounding rectangle or `null` if no `rects` were given.
182
- */
183
- static getBoundingRect(rects: Iterable<Rect>): Rect | null;
184
- }
185
- /**
186
- * A source of {@link module:utils/dom/rect~Rect}.
187
- */
188
- export type RectSource = HTMLElement | Range | Window | RectLike;
189
- /**
190
- * An object that describes properties of `ClientRect` object.
191
- */
192
- export interface RectLike {
193
- readonly top: number;
194
- readonly right: number;
195
- readonly bottom: number;
196
- readonly left: number;
197
- readonly width: number;
198
- readonly height: number;
199
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module utils/dom/remove
11
- */
12
- /**
13
- * Removes given node from parent.
14
- *
15
- * @param node Node to remove.
16
- */
17
- export default function remove(node: Node): void;
@@ -1,78 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * A helper class which instances allow performing custom actions when native DOM elements are resized.
11
- *
12
- * ```ts
13
- * const editableElement = editor.editing.view.getDomRoot();
14
- *
15
- * const observer = new ResizeObserver( editableElement, entry => {
16
- * console.log( 'The editable element has been resized in DOM.' );
17
- * console.log( entry.target ); // -> editableElement
18
- * console.log( entry.contentRect.width ); // -> e.g. '423px'
19
- * } );
20
- * ```
21
- *
22
- * It uses the [native DOM resize observer](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
23
- * under the hood.
24
- */
25
- export default class ResizeObserver {
26
- /**
27
- * The element observed by this observer.
28
- */
29
- private readonly _element;
30
- /**
31
- * The callback executed each time {@link #_element} is resized.
32
- */
33
- private readonly _callback;
34
- /**
35
- * The single native observer instance shared across all {@link module:utils/dom/resizeobserver~ResizeObserver} instances.
36
- */
37
- private static _observerInstance;
38
- /**
39
- * A mapping of native DOM elements and their callbacks shared across all
40
- * {@link module:utils/dom/resizeobserver~ResizeObserver} instances.
41
- */
42
- private static _elementCallbacks;
43
- /**
44
- * Creates an instance of the `ResizeObserver` class.
45
- *
46
- * @param element A DOM element that is to be observed for resizing. Note that
47
- * the element must be visible (i.e. not detached from DOM) for the observer to work.
48
- * @param callback A function called when the observed element was resized. It passes
49
- * the [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)
50
- * object with information about the resize event.
51
- */
52
- constructor(element: Element, callback: (entry: ResizeObserverEntry) => void);
53
- /**
54
- * The element observed by this observer.
55
- */
56
- get element(): Element;
57
- /**
58
- * Destroys the observer which disables the `callback` passed to the {@link #constructor}.
59
- */
60
- destroy(): void;
61
- /**
62
- * Registers a new resize callback for the DOM element.
63
- */
64
- private static _addElementCallback;
65
- /**
66
- * Removes a resize callback from the DOM element. If no callbacks are left
67
- * for the element, it removes the element from the native observer.
68
- */
69
- private static _deleteElementCallback;
70
- /**
71
- * Returns are registered resize callbacks for the DOM element.
72
- */
73
- private static _getElementCallbacks;
74
- /**
75
- * Creates the single native observer shared across all `ResizeObserver` instances.
76
- */
77
- private static _createObserver;
78
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- type IfTrue<T> = T extends true ? true : never;
10
- /**
11
- * Makes any page `HTMLElement` or `Range` (`target`) visible inside the browser viewport.
12
- * This helper will scroll all `target` ancestors and the web browser viewport to reveal the target to
13
- * the user. If the `target` is already visible, nothing will happen.
14
- *
15
- * @param options Additional configuration of the scrolling behavior.
16
- * @param options.target A target, which supposed to become visible to the user.
17
- * @param options.viewportOffset An offset from the edge of the viewport (in pixels)
18
- * the `target` will be moved by if the viewport is scrolled. It enhances the user experience
19
- * by keeping the `target` some distance from the edge of the viewport and thus making it easier to
20
- * read or edit by the user.
21
- * @param options.ancestorOffset An offset from the boundary of scrollable ancestors (if any)
22
- * the `target` will be moved by if the viewport is scrolled. It enhances the user experience
23
- * by keeping the `target` some distance from the edge of the ancestors and thus making it easier to
24
- * read or edit by the user.
25
- * @param options.alignToTop When set `true`, the helper will make sure the `target` is scrolled up
26
- * to the top boundary of the viewport and/or scrollable ancestors if scrolled up. When not set
27
- * (default), the `target` will be revealed by scrolling as little as possible. This option will
28
- * not affect `targets` that must be scrolled down because they will appear at the top of the boundary
29
- * anyway.
30
- *
31
- * ```
32
- * scrollViewportToShowTarget() with scrollViewportToShowTarget() with
33
- * Initial state alignToTop unset (default) alignToTop = true
34
- *
35
- * ┌────────────────────────────────┬─┐ ┌────────────────────────────────┬─┐ ┌────────────────────────────────┬─┐
36
- * │ │▲│ │ │▲│ │ [ Target to be revealed ] │▲│
37
- * │ │ │ │ │ │ │ │ │
38
- * │ │█│ │ │ │ │ │ │
39
- * │ │█│ │ │ │ │ │ │
40
- * │ │ │ │ │█│ │ │ │
41
- * │ │ │ │ │█│ │ │█│
42
- * │ │ │ │ │ │ │ │█│
43
- * │ │▼│ │ [ Target to be revealed ] │▼│ │ │▼│
44
- * └────────────────────────────────┴─┘ └────────────────────────────────┴─┘ └────────────────────────────────┴─┘
45
- *
46
- *
47
- * [ Target to be revealed ]
48
- *```
49
- *
50
- * @param options.forceScroll When set `true`, the `target` will be aligned to the top of the viewport
51
- * and scrollable ancestors whether it is already visible or not. This option will only work when `alignToTop`
52
- * is `true`
53
- */
54
- export declare function scrollViewportToShowTarget<T extends boolean, U extends IfTrue<T>>({ target, viewportOffset, ancestorOffset, alignToTop, forceScroll }: {
55
- readonly target: HTMLElement | Range;
56
- readonly viewportOffset?: number | {
57
- top: number;
58
- bottom: number;
59
- left: number;
60
- right: number;
61
- };
62
- readonly ancestorOffset?: number;
63
- readonly alignToTop?: T;
64
- readonly forceScroll?: U;
65
- }): void;
66
- /**
67
- * Makes any page `HTMLElement` or `Range` (target) visible within its scrollable ancestors,
68
- * e.g. if they have `overflow: scroll` CSS style.
69
- *
70
- * @param target A target, which supposed to become visible to the user.
71
- * @param ancestorOffset An offset between the target and the boundary of scrollable ancestors
72
- * to be maintained while scrolling.
73
- * @param limiterElement The outermost ancestor that should be scrolled. If specified, it can prevent
74
- * scrolling the whole page.
75
- */
76
- export declare function scrollAncestorsToShowTarget(target: HTMLElement | Range, ancestorOffset?: number, limiterElement?: HTMLElement): void;
77
- export {};
@@ -1,18 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module utils/dom/setdatainelement
11
- */
12
- /**
13
- * Sets data in a given element.
14
- *
15
- * @param el The element in which the data will be set.
16
- * @param data The data string.
17
- */
18
- export default function setDataInElement(el: HTMLElement, data: string): void;
@@ -1,26 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module utils/dom/tounit
11
- */
12
- /**
13
- * Returns a helper function, which adds a desired trailing
14
- * `unit` to the passed value.
15
- *
16
- * @param unit An unit like "px" or "em".
17
- */
18
- export default function toUnit(unit: string): ToUnitHelper;
19
- /**
20
- * A function, which adds a pre–defined trailing `unit`
21
- * to the passed `value`.
22
- *
23
- * @param value A value to be given the unit.
24
- * @returns A value with the trailing unit.
25
- */
26
- export type ToUnitHelper = (value: string | number) => string;
@@ -1,35 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module utils/elementreplacer
11
- */
12
- /**
13
- * Utility class allowing to hide existing HTML elements or replace them with given ones in a way that doesn't remove
14
- * the original elements from the DOM.
15
- */
16
- export default class ElementReplacer {
17
- /**
18
- * The elements replaced by {@link #replace} and their replacements.
19
- */
20
- private _replacedElements;
21
- constructor();
22
- /**
23
- * Hides the `element` and, if specified, inserts the the given element next to it.
24
- *
25
- * The effect of this method can be reverted by {@link #restore}.
26
- *
27
- * @param element The element to replace.
28
- * @param newElement The replacement element. If not passed, then the `element` will just be hidden.
29
- */
30
- replace(element: HTMLElement, newElement?: HTMLElement): void;
31
- /**
32
- * Restores what {@link #replace} did.
33
- */
34
- restore(): void;
35
- }