@ckeditor/ckeditor5-utils 48.8.1-alpha.4 → 49.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 (101) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/abortabledebounce.d.ts +19 -13
  3. package/dist/areconnectedthroughproperties.d.ts +7 -7
  4. package/dist/ckeditorerror.d.ts +114 -113
  5. package/dist/collection.d.ts +419 -415
  6. package/dist/collectstylesheets.d.ts +9 -9
  7. package/dist/comparearrays.d.ts +25 -25
  8. package/dist/config.d.ts +159 -156
  9. package/dist/count.d.ts +14 -14
  10. package/dist/crc32.d.ts +19 -19
  11. package/dist/decodelicensekey.d.ts +7 -7
  12. package/dist/delay.d.ts +13 -13
  13. package/dist/diff.d.ts +32 -27
  14. package/dist/difftochanges.d.ts +47 -47
  15. package/dist/dom/adoptglobalstylesheet.d.ts +19 -0
  16. package/dist/dom/containsnode.d.ts +18 -0
  17. package/dist/dom/createelement.d.ts +43 -43
  18. package/dist/dom/emittermixin.d.ts +141 -135
  19. package/dist/dom/findclosestscrollableancestor.d.ts +13 -8
  20. package/dist/dom/getactiveelement.d.ts +17 -0
  21. package/dist/dom/getancestors.d.ts +13 -13
  22. package/dist/dom/getborderwidths.d.ts +16 -16
  23. package/dist/dom/getdatafromelement.d.ts +10 -10
  24. package/dist/dom/getelementfrompoint.d.ts +23 -0
  25. package/dist/dom/getlayoutparentelement.d.ts +18 -0
  26. package/dist/dom/getlayoutparentnode.d.ts +24 -0
  27. package/dist/dom/getoverlaymountroot.d.ts +24 -0
  28. package/dist/dom/getparentelement.d.ts +13 -0
  29. package/dist/dom/getparentnode.d.ts +15 -0
  30. package/dist/dom/getpositionedancestor.d.ts +18 -7
  31. package/dist/dom/getrangefrommouseevent.d.ts +15 -13
  32. package/dist/dom/getselection.d.ts +106 -0
  33. package/dist/dom/getshadowroots.d.ts +19 -0
  34. package/dist/dom/getvisualviewportoffset.d.ts +7 -7
  35. package/dist/dom/global.d.ts +24 -24
  36. package/dist/dom/indexof.d.ts +10 -10
  37. package/dist/dom/insertat.d.ts +11 -11
  38. package/dist/dom/iscomment.d.ts +7 -7
  39. package/dist/dom/isdomselectionbackward.d.ts +18 -0
  40. package/dist/dom/isnode.d.ts +7 -7
  41. package/dist/dom/isoffline.d.ts +8 -0
  42. package/dist/dom/isrange.d.ts +7 -7
  43. package/dist/dom/isshadowhostof.d.ts +18 -0
  44. package/dist/dom/isshadowroot.d.ts +41 -0
  45. package/dist/dom/istext.d.ts +7 -7
  46. package/dist/dom/isvalidattributename.d.ts +7 -7
  47. package/dist/dom/isvisible.d.ts +16 -12
  48. package/dist/dom/iswindow.d.ts +7 -7
  49. package/dist/dom/position.d.ts +200 -200
  50. package/dist/dom/rect.d.ts +198 -194
  51. package/dist/dom/remove.d.ts +7 -10
  52. package/dist/dom/resizeobserver.d.ts +70 -70
  53. package/dist/dom/scroll.d.ts +83 -72
  54. package/dist/dom/setdatainelement.d.ts +8 -11
  55. package/dist/dom/shadowrootregistry.d.ts +125 -0
  56. package/dist/dom/tounit.d.ts +16 -16
  57. package/dist/dom/trustedtypes.d.ts +65 -0
  58. package/dist/dom/whenelementconnected.d.ts +26 -0
  59. package/dist/elementreplacer.d.ts +24 -27
  60. package/dist/emittermixin.d.ts +287 -280
  61. package/dist/env.d.ts +124 -124
  62. package/dist/eventinfo.d.ts +58 -55
  63. package/dist/fastdiff.d.ts +112 -109
  64. package/dist/first.d.ts +7 -7
  65. package/dist/focustracker.d.ts +133 -131
  66. package/dist/formathtml.d.ts +15 -15
  67. package/dist/index-content.css +3 -0
  68. package/dist/index-content.css.map +1 -0
  69. package/dist/index-editor.css +3 -0
  70. package/dist/index-editor.css.map +1 -0
  71. package/dist/index.d.ts +95 -77
  72. package/dist/index.js +6788 -6360
  73. package/dist/index.js.map +1 -1
  74. package/dist/inserttopriorityarray.d.ts +23 -23
  75. package/dist/isfeatureblockedbylicensekey.d.ts +10 -10
  76. package/dist/isiterable.d.ts +10 -10
  77. package/dist/keyboard.d.ts +107 -109
  78. package/dist/keystrokehandler.d.ts +90 -90
  79. package/dist/language.d.ts +12 -12
  80. package/dist/legacyerrors.d.ts +0 -4
  81. package/dist/locale.d.ts +122 -122
  82. package/dist/mapsequal.d.ts +11 -11
  83. package/dist/mix.d.ts +54 -53
  84. package/dist/nth.d.ts +12 -12
  85. package/dist/objecttomap.d.ts +18 -18
  86. package/dist/observablemixin.d.ts +618 -539
  87. package/dist/parsebase64encodedobject.d.ts +7 -7
  88. package/dist/parsedimensionwithunit.d.ts +40 -0
  89. package/dist/priorities.d.ts +24 -24
  90. package/dist/retry.d.ts +27 -27
  91. package/dist/splicearray.d.ts +22 -22
  92. package/dist/spy.d.ts +15 -15
  93. package/dist/toarray.d.ts +17 -17
  94. package/dist/tomap.d.ts +15 -15
  95. package/dist/translation-service.d.ts +157 -157
  96. package/dist/uid.d.ts +12 -12
  97. package/dist/unicode.d.ts +42 -42
  98. package/dist/version.d.ts +5 -5
  99. package/dist/wait.d.ts +11 -11
  100. package/package.json +3 -3
  101. package/dist/dom/getcommonancestor.d.ts +0 -12
@@ -1,78 +1,89 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  export type IfTrue<T> = T extends true ? true : never;
6
6
  /**
7
- * Makes any page `HTMLElement` or `Range` (`target`) visible inside the browser viewport.
8
- * This helper will scroll all `target` ancestors and the web browser viewport to reveal the target to
9
- * the user. If the `target` is already visible, nothing will happen.
10
- *
11
- * @param options Additional configuration of the scrolling behavior.
12
- * @param options.target A target, which supposed to become visible to the user.
13
- * @param options.viewportOffset An offset from the edge of the viewport (in pixels)
14
- * the `target` will be moved by if the viewport is scrolled. It enhances the user experience
15
- * by keeping the `target` some distance from the edge of the viewport and thus making it easier to
16
- * read or edit by the user.
17
- * @param options.ancestorOffset An offset from the boundary of scrollable ancestors (if any)
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 ancestors and thus making it easier to
20
- * read or edit by the user.
21
- * @param options.alignToTop When set `true`, the helper will make sure the `target` is scrolled up
22
- * to the top boundary of the viewport and/or scrollable ancestors if scrolled up. When not set
23
- * (default), the `target` will be revealed by scrolling as little as possible. This option will
24
- * not affect `targets` that must be scrolled down because they will appear at the top of the boundary
25
- * anyway.
26
- *
27
- * ```
28
- * scrollViewportToShowTarget() with scrollViewportToShowTarget() with
29
- * Initial state alignToTop unset (default) alignToTop = true
30
- *
31
- * ┌────────────────────────────────┬─┐ ┌────────────────────────────────┬─┐ ┌────────────────────────────────┬─┐
32
- * │ │▲│ │ │▲│ │ [ Target to be revealed ] │▲│
33
- * │ │ │ │ │ │ │ │ │
34
- * │ │█│ │ │ │ │ │ │
35
- * │ │█│ │ │ │ │ │ │
36
- * │ │ │ │ │█│ │ │ │
37
- * │ │ │ │ │█│ │ │█│
38
- * │ │ │ │ │ │ │ │█│
39
- * │ │▼│ │ [ Target to be revealed ] │▼│ │ │▼│
40
- * └────────────────────────────────┴─┘ └────────────────────────────────┴─┘ └────────────────────────────────┴─┘
41
- *
42
- *
43
- * [ Target to be revealed ]
44
- *```
45
- *
46
- * @param options.forceScroll When set `true`, the `target` will be aligned to the top of the viewport
47
- * and scrollable ancestors whether it is already visible or not. This option will only work when `alignToTop`
48
- * is `true`
49
- */
50
- export declare function scrollViewportToShowTarget<T extends boolean, U extends IfTrue<T>>({ target, viewportOffset, ancestorOffset, alignToTop, forceScroll }: {
51
- readonly target: HTMLElement | Range;
52
- readonly viewportOffset?: number | {
53
- top: number;
54
- bottom: number;
55
- left: number;
56
- right: number;
57
- };
58
- readonly ancestorOffset?: number;
59
- readonly alignToTop?: T;
60
- readonly forceScroll?: U;
7
+ * Makes any page `HTMLElement` or `Range` (`target`) visible inside the browser viewport.
8
+ * This helper will scroll all `target` ancestors and the web browser viewport to reveal the target to
9
+ * the user. If the `target` is already visible, nothing will happen.
10
+ *
11
+ * **Note**: The ancestor walk crosses shadow DOM boundaries, continuing from the host element of a shadow root
12
+ * instead of stopping at it, so scrollable ancestors in the surrounding document are scrolled too. Works for open
13
+ * and closed shadow roots alike.
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<
55
+ T extends boolean,
56
+ U extends IfTrue<T>
57
+ >({ target, viewportOffset, ancestorOffset, alignToTop, forceScroll }: {
58
+ readonly target: HTMLElement | Range;
59
+ readonly viewportOffset?: number | {
60
+ top: number;
61
+ bottom: number;
62
+ left: number;
63
+ right: number;
64
+ };
65
+ readonly ancestorOffset?: number;
66
+ readonly alignToTop?: T;
67
+ readonly forceScroll?: U;
61
68
  }): void;
62
69
  /**
63
- * Makes any page `HTMLElement` or `Range` (target) visible within its scrollable ancestors,
64
- * e.g. if they have `overflow: scroll` CSS style.
65
- *
66
- * @param target A target, which supposed to become visible to the user.
67
- * @param ancestorOffset An offset between the target and the boundary of scrollable ancestors
68
- * to be maintained while scrolling.
69
- * @param limiterElement The outermost ancestor that should be scrolled. If specified, it can prevent
70
- * scrolling the whole page.
71
- * @param alignToTop When set `true`, the function will make sure the `target` is scrolled up
72
- * to the top boundary of the scrollable ancestors if scrolled up. When not set (default), the `target`
73
- * will be revealed by scrolling as little as possible. This option will not affect target elements that must be
74
- * scrolled down because they will appear at the top of the boundary anyway.
75
- * @param forceScroll When set `true`, the `target` will be aligned to the top of scrollable ancestors
76
- * whether it is already visible or not. This option will only work when `alignToTop` is `true`
77
- */
70
+ * Makes any page `HTMLElement` or `Range` (target) visible within its scrollable ancestors,
71
+ * e.g. if they have `overflow: scroll` CSS style.
72
+ *
73
+ * **Note**: The ancestor walk crosses shadow DOM boundaries, continuing from the host element of a shadow root
74
+ * instead of stopping at it, so scrollable ancestors in the surrounding document are scrolled too. Works for open
75
+ * and closed shadow roots alike.
76
+ *
77
+ * @param target A target, which supposed to become visible to the user.
78
+ * @param ancestorOffset An offset between the target and the boundary of scrollable ancestors
79
+ * to be maintained while scrolling.
80
+ * @param limiterElement The outermost ancestor that should be scrolled. If specified, it can prevent
81
+ * scrolling the whole page.
82
+ * @param alignToTop When set `true`, the function will make sure the `target` is scrolled up
83
+ * to the top boundary of the scrollable ancestors if scrolled up. When not set (default), the `target`
84
+ * will be revealed by scrolling as little as possible. This option will not affect target elements that must be
85
+ * scrolled down because they will appear at the top of the boundary anyway.
86
+ * @param forceScroll When set `true`, the `target` will be aligned to the top of scrollable ancestors
87
+ * whether it is already visible or not. This option will only work when `alignToTop` is `true`
88
+ */
78
89
  export declare function scrollAncestorsToShowTarget(target: HTMLElement | Range, ancestorOffset?: number, limiterElement?: HTMLElement, alignToTop?: boolean, forceScroll?: true): void;
@@ -1,14 +1,11 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module utils/dom/setdatainelement
7
- */
8
- /**
9
- * Sets data in a given element.
10
- *
11
- * @param el The element in which the data will be set.
12
- * @param data The data string.
13
- */
6
+ * Sets data in a given element.
7
+ *
8
+ * @param el The element in which the data will be set.
9
+ * @param data The data string.
10
+ */
14
11
  export declare function setDataInElement(el: HTMLElement, data: string): void;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ import { type CallbackOptions, type EmitterMixinConstructor } from "../emittermixin.js";
6
+ import { type DomEmitter, type DomEventMap } from "./emittermixin.js";
7
+ import { type EventInfo } from "../eventinfo.js";
8
+ declare const ShadowRootRegistryBase: EmitterMixinConstructor;
9
+ /**
10
+ * Keeps track of the shadow roots hosting a set of registered DOM nodes (for example an editor UI's editables,
11
+ * toolbars and menu bars, or a feature's own UI), so that consumers can, for instance, inject styles or listeners
12
+ * into every shadow root those nodes currently live in.
13
+ */
14
+ export declare class ShadowRootRegistry extends ShadowRootRegistryBase {
15
+ /**
16
+ * The shadow roots hosting each registered node, as of the last time that node was looked at. Empty for a node
17
+ * that was detached or lived in the light DOM then. Re-derived for every node by each {@link #refresh}, so a
18
+ * node that has since been attached, or moved to another tree, is picked up. The union of the values is
19
+ * {@link #getShadowRoots}.
20
+ */
21
+ private _rootsByNode;
22
+ /**
23
+ * Returns the shadow roots currently hosting at least one registered node.
24
+ */
25
+ getShadowRoots(): Set<ShadowRoot>;
26
+ /**
27
+ * Registers a node, so the shadow roots hosting it become a part of {@link #getShadowRoots}.
28
+ *
29
+ * The node does not have to be attached to the DOM yet; while it is not, it simply contributes no shadow root.
30
+ * The next {@link #refresh} picks it up once it is attached.
31
+ */
32
+ registerNode(node: Node): void;
33
+ /**
34
+ * Unregisters a previously {@link #registerNode registered} node. Shadow roots that no longer host any
35
+ * registered node stop being a part of {@link #getShadowRoots}.
36
+ */
37
+ unregisterNode(node: Node): void;
38
+ /**
39
+ * Re-derives the shadow roots of every registered node, firing {@link #event:add} for the roots that started
40
+ * hosting one and {@link #event:remove} for those that stopped.
41
+ *
42
+ * Call it whenever a registered node may have been attached, detached, or moved – for example on every editor
43
+ * UI update. Nodes are re-derived rather than resolved once, because the tree a node lives in is not fixed:
44
+ * an editable mounted by the integrator after the editor was created, or moved into a fullscreen container in
45
+ * another tree, ends up somewhere its roots were never derived from.
46
+ */
47
+ refresh(): void;
48
+ /**
49
+ * Unregisters every currently registered node at once, firing {@link #event:remove} for every shadow root
50
+ * that consequently stops being tracked.
51
+ *
52
+ * @internal
53
+ */
54
+ destroy(): void;
55
+ /**
56
+ * Fires {@link #event:add} and {@link #event:remove} for the difference between the given set of tracked
57
+ * shadow roots and the current one.
58
+ */
59
+ private _fireRootChanges;
60
+ }
61
+ /**
62
+ * Some DOM events never reach a listener on `document` if they originate inside a shadow root — `scroll` and
63
+ * `mouseenter`/`mouseleave`, for instance, do not cross a shadow boundary at all. This function is how code that
64
+ * needs those events anyway reacts to them for every shadow root a registry is currently tracking: it attaches
65
+ * `emitter`'s callback directly to each one tracked by `registry`, and keeps that up to date — attaching to
66
+ * roots that appear later, detaching from roots that disappear — for as long as the returned function is not
67
+ * called.
68
+ *
69
+ * Attach it alongside the `document` listener rather than instead of it — one covers the light DOM, the other
70
+ * each shadow root:
71
+ *
72
+ * ```ts
73
+ * view.listenTo( global.document, 'scroll', repositionOnScroll, { useCapture: true } );
74
+ *
75
+ * const stopListening = listenToShadowRoots( editor.ui.shadowRootRegistry, {
76
+ * emitter: view,
77
+ * event: 'scroll',
78
+ * callback: repositionOnScroll,
79
+ * listenerOptions: { useCapture: true }
80
+ * } );
81
+ * ```
82
+ *
83
+ * The `useCapture` above is not incidental. The events this function exists for do not bubble when fired on an
84
+ * element, so a listener on a shadow root only sees one that originates inside that root during the capture
85
+ * phase. Without it the listener is attached but never fires.
86
+ *
87
+ * Call the returned function to detach.
88
+ *
89
+ * @param registry The registry whose shadow roots should be listened to.
90
+ * @param options Describes the listener to attach to each shadow root.
91
+ * @param options.emitter The emitter to which this behavior should be added.
92
+ * @param options.event The DOM event to listen to.
93
+ * @param options.callback The event handler.
94
+ * @param options.listenerOptions Listener options, passed through to `DomEmitter#listenTo()`.
95
+ */
96
+ export declare function listenToShadowRoots(registry: ShadowRootRegistry, { emitter, event, callback, listenerOptions }: {
97
+ emitter: DomEmitter;
98
+ event: keyof DomEventMap;
99
+ callback: (evt: EventInfo, domEvent: any) => void;
100
+ listenerOptions?: CallbackOptions & {
101
+ useCapture?: boolean;
102
+ usePassive?: boolean;
103
+ };
104
+ }): () => void;
105
+ /**
106
+ * Fired when a shadow root starts hosting a registered node.
107
+ *
108
+ * @eventName ~ShadowRootRegistry#add
109
+ * @param root The shadow root that started being tracked.
110
+ */
111
+ export type ShadowRootRegistryAddEvent = {
112
+ name: "add";
113
+ args: [root: ShadowRoot];
114
+ };
115
+ /**
116
+ * Fired when a shadow root no longer hosts any registered node.
117
+ *
118
+ * @eventName ~ShadowRootRegistry#remove
119
+ * @param root The shadow root that stopped being tracked.
120
+ */
121
+ export type ShadowRootRegistryRemoveEvent = {
122
+ name: "remove";
123
+ args: [root: ShadowRoot];
124
+ };
125
+ export {};
@@ -1,22 +1,22 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module utils/dom/tounit
7
- */
6
+ * @module utils/dom/tounit
7
+ */
8
8
  /**
9
- * Returns a helper function, which adds a desired trailing
10
- * `unit` to the passed value.
11
- *
12
- * @param unit An unit like "px" or "em".
13
- */
9
+ * Returns a helper function, which adds a desired trailing
10
+ * `unit` to the passed value.
11
+ *
12
+ * @param unit An unit like "px" or "em".
13
+ */
14
14
  export declare function toUnit(unit: string): ToUnitHelper;
15
15
  /**
16
- * A function, which adds a pre–defined trailing `unit`
17
- * to the passed `value`.
18
- *
19
- * @param value A value to be given the unit.
20
- * @returns A value with the trailing unit.
21
- */
16
+ * A function, which adds a pre–defined trailing `unit`
17
+ * to the passed `value`.
18
+ *
19
+ * @param value A value to be given the unit.
20
+ * @returns A value with the trailing unit.
21
+ */
22
22
  export type ToUnitHelper = (value: string | number) => string;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * Prepares an HTML string for a DOM injection sink, which means any place that turns a string into HTML, for example
7
+ * `innerHTML` or `DOMParser#parseFromString()`:
8
+ *
9
+ * ```ts
10
+ * element.innerHTML = trustedHtml( '<p>Hello world!</p>' );
11
+ * ```
12
+ *
13
+ * An application can tell the browser to reject plain strings in those places, using the `require-trusted-types-for 'script'`
14
+ * CSP directive. A sink then accepts only a `TrustedHTML` object. This function returns such an object when the browser
15
+ * supports Trusted Types, and the string it was given when it does not. TypeScript types every sink as taking a
16
+ * `string`, so the result is typed that way too, whichever it is. That keeps type casts out of the call sites, but it
17
+ * also means the result is not always a real string: pass it to a sink, and do not call string methods on it. For the
18
+ * same reason `+=` never works on a sink: it reads the property, joins the strings and assigns a plain one.
19
+ *
20
+ * An application that enforces Trusted Types must also allow the name of the editor's policy, plus `lit-html` when it
21
+ * loads the premium features, whichever of them it uses:
22
+ *
23
+ * ```
24
+ * Content-Security-Policy: require-trusted-types-for 'script'; trusted-types ckeditor5 lit-html;
25
+ * ```
26
+ *
27
+ * The policy returns the string unchanged, because the editor writes markup that it created itself. It makes the browser
28
+ * accept the assignment, but it cleans nothing, so pass this function only markup that the calling code produced, and
29
+ * never content that came from a user or from a server response. Making sure that the data loaded into the editor is
30
+ * safe stays the job of the application, exactly as before.
31
+ *
32
+ * See the {@glink getting-started/setup/csp#trusted-types Content Security Policy} guide for more information.
33
+ *
34
+ * @param html The HTML string to prepare.
35
+ * @returns A value that can be assigned to a DOM injection sink.
36
+ */
37
+ export declare function trustedHtml(html: string): string;
38
+ /**
39
+ * Returns `true` if the application enforces Trusted Types with the `require-trusted-types-for 'script'` CSP directive.
40
+ * That is the only case where a DOM injection sink rejects a plain string, so it is also the only case where a feature
41
+ * that writes HTML in code the editor cannot reach, for example inside a third-party library, stops working.
42
+ */
43
+ export declare function isTrustedTypesEnforced(): boolean;
44
+ /**
45
+ * Prepares the value of an attribute for `setAttribute()`. Under Trusted Types, some attributes accept only the object of
46
+ * a Trusted Type, even in a document that is not displayed: an event handler such as `onclick` takes a `TrustedScript`,
47
+ * `src` of a `<script>` takes a `TrustedScriptURL`, and `srcdoc` of an `<iframe>` takes a `TrustedHTML`. For such an
48
+ * attribute, the editor's policy creates that object from the unchanged value. Any other attribute gets the given string.
49
+ * The browser tells which attribute is which, because the list differs between browsers.
50
+ *
51
+ * Like {@link ~trustedHtml}, it cleans nothing, and its result is typed as a string whichever it is.
52
+ *
53
+ * @internal
54
+ * @param element The element that the attribute is set on.
55
+ * @param attributeName The name of the attribute.
56
+ * @param value The value of the attribute.
57
+ */
58
+ export declare function _trustedAttributeValue(element: Element, attributeName: string, value: string): string;
59
+ /**
60
+ * Forgets the policy that was created and whether the application enforces Trusted Types, so that both are worked out
61
+ * again. Only tests need it, because a document never changes either answer.
62
+ *
63
+ * @internal
64
+ */
65
+ export declare function _clearTrustedTypesCache(): void;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * Calls the callback once the given element is connected to a document, and at most once.
7
+ *
8
+ * For code that has to act on the tree an element lives in – injecting styles, resolving a mount target – but is
9
+ * handed the element before it is mounted. The editable of a `DecoupledEditor`, or of any editor created from a
10
+ * data string, is put in the DOM by the integrator at an arbitrary point in time. An element that is already
11
+ * connected is reported synchronously, so the caller needs no second path for that case.
12
+ *
13
+ * "Connected" means connected to a document: an element in a shadow tree qualifies once that tree's host does,
14
+ * and one in a detached tree never does. It is not a visibility check – the element may be connected while
15
+ * having no box of its own, or while an ancestor is not rendered.
16
+ *
17
+ * The waiting is backed by a {@link module:utils/dom/resizeobserver~ResizeObserver}, so the notification is
18
+ * asynchronous and arrives once the element is rendered. For an element mounted into a `display: none` subtree
19
+ * the callback may therefore run on the mount or only once that subtree is shown, depending on the engine. It
20
+ * runs exactly once either way.
21
+ *
22
+ * @param element The element to wait for.
23
+ * @param callback Called once `element` is connected, or immediately if it already is.
24
+ * @returns Cancels the waiting. Safe to call any number of times, and does nothing once the callback has run.
25
+ */
26
+ export declare function whenElementConnected(element: HTMLElement, callback: () => void): () => void;
@@ -1,31 +1,28 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module utils/elementreplacer
7
- */
8
- /**
9
- * Utility class allowing to hide existing HTML elements or replace them with given ones in a way that doesn't remove
10
- * the original elements from the DOM.
11
- */
6
+ * Utility class allowing to hide existing HTML elements or replace them with given ones in a way that doesn't remove
7
+ * the original elements from the DOM.
8
+ */
12
9
  export declare class ElementReplacer {
13
- /**
14
- * The elements replaced by {@link #replace} and their replacements.
15
- */
16
- private _replacedElements;
17
- constructor();
18
- /**
19
- * Hides the `element` and, if specified, inserts the the given element next to it.
20
- *
21
- * The effect of this method can be reverted by {@link #restore}.
22
- *
23
- * @param element The element to replace.
24
- * @param newElement The replacement element. If not passed, then the `element` will just be hidden.
25
- */
26
- replace(element: HTMLElement, newElement?: HTMLElement): void;
27
- /**
28
- * Restores what {@link #replace} did.
29
- */
30
- restore(): void;
10
+ /**
11
+ * The elements replaced by {@link #replace} and their replacements.
12
+ */
13
+ private _replacedElements;
14
+ constructor();
15
+ /**
16
+ * Hides the `element` and, if specified, inserts the the given element next to it.
17
+ *
18
+ * The effect of this method can be reverted by {@link #restore}.
19
+ *
20
+ * @param element The element to replace.
21
+ * @param newElement The replacement element. If not passed, then the `element` will just be hidden.
22
+ */
23
+ replace(element: HTMLElement, newElement?: HTMLElement): void;
24
+ /**
25
+ * Restores what {@link #replace} did.
26
+ */
27
+ restore(): void;
31
28
  }