@ckeditor/ckeditor5-utils 49.0.1 → 49.1.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.
- package/dist/dom/domtargetslistener.d.ts +111 -0
- package/dist/dom/geteventroots.d.ts +18 -0
- package/dist/dom/isprocessinginstruction.d.ts +11 -0
- package/dist/dom/shadowrootregistry.d.ts +68 -27
- package/dist/index.d.ts +4 -1
- package/dist/index.js +248 -55
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -915,8 +915,8 @@ function formatConsoleArguments(errorName, data) {
|
|
|
915
915
|
/**
|
|
916
916
|
* @module utils/version
|
|
917
917
|
*/
|
|
918
|
-
const version = "49.0.
|
|
919
|
-
const releaseDate = new Date(2026, 9,
|
|
918
|
+
const version = "49.1.0-alpha.0";
|
|
919
|
+
const releaseDate = new Date(2026, 9, 28);
|
|
920
920
|
/* v8 ignore next -- @preserve */
|
|
921
921
|
if (globalThis.CKEDITOR_VERSION)
|
|
922
922
|
/**
|
|
@@ -2820,6 +2820,138 @@ function getShadowRoots(node) {
|
|
|
2820
2820
|
return shadowRoots;
|
|
2821
2821
|
}
|
|
2822
2822
|
|
|
2823
|
+
/**
|
|
2824
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2825
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
2826
|
+
*/
|
|
2827
|
+
/**
|
|
2828
|
+
* @module utils/dom/geteventroots
|
|
2829
|
+
*/
|
|
2830
|
+
/**
|
|
2831
|
+
* Returns every event root of the given node: the shadow roots it renders in, innermost first, followed by
|
|
2832
|
+
* the document it is connected to.
|
|
2833
|
+
*
|
|
2834
|
+
* For code that listens to the DOM events of a node, which a listener on `document` alone may miss: events that
|
|
2835
|
+
* are not `composed`, such as `scroll`, never leave the shadow root they started in, and the events that do are
|
|
2836
|
+
* retargeted to the shadow host. Works for open and closed roots alike.
|
|
2837
|
+
*
|
|
2838
|
+
* Like {@link module:utils/dom/getshadowroots~getShadowRoots}, it reports the shadow roots of a detached node too.
|
|
2839
|
+
* The document is only included while the node is connected to it. Empty for `null`.
|
|
2840
|
+
*
|
|
2841
|
+
* @param node The node to collect the event roots of.
|
|
2842
|
+
*/
|
|
2843
|
+
function getEventRoots(node) {
|
|
2844
|
+
if (!node) return [];
|
|
2845
|
+
const roots = getShadowRoots(node);
|
|
2846
|
+
if (node.nodeType == Node.DOCUMENT_NODE) roots.push(node);
|
|
2847
|
+
else if (node.isConnected) roots.push(node.ownerDocument);
|
|
2848
|
+
return roots;
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
/**
|
|
2852
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2853
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
2854
|
+
*/
|
|
2855
|
+
/**
|
|
2856
|
+
* Keeps `emitter`'s callback attached to exactly the DOM event targets returned by `getTargets()`, for code whose
|
|
2857
|
+
* targets are known only later or change over time.
|
|
2858
|
+
*
|
|
2859
|
+
* To listen to the events of the whole editor UI, use {@link module:utils/dom/shadowrootregistry~listenToEventRoots}
|
|
2860
|
+
* instead, which follows the editor's {@link module:utils/dom/shadowrootregistry~ShadowRootRegistry registry} on its own.
|
|
2861
|
+
* Use this listener for particular elements, such as the positioning target of a balloon or the limiter of a sticky
|
|
2862
|
+
* panel: return `document` and their {@link module:utils/dom/geteventroots~getEventRoots event roots} from `getTargets()`.
|
|
2863
|
+
* Unlike the registry listeners, it does not listen to `document` on its own.
|
|
2864
|
+
*
|
|
2865
|
+
* The targets are read once, when the listener is created. Call {@link #refresh} whenever they may have changed:
|
|
2866
|
+
* it calls `getTargets()` again, attaches the callback to the targets that appeared and detaches it from the targets
|
|
2867
|
+
* that disappeared, leaving the others alone. Call {@link #destroy} to detach the callback from every target:
|
|
2868
|
+
*
|
|
2869
|
+
* ```ts
|
|
2870
|
+
* const scrollListener = new DomTargetsListener( () => [ document, ...getEventRoots( limiterElement ) ], {
|
|
2871
|
+
* emitter: view,
|
|
2872
|
+
* event: 'scroll',
|
|
2873
|
+
* listenerOptions: { useCapture: true },
|
|
2874
|
+
* callback: onScroll
|
|
2875
|
+
* } );
|
|
2876
|
+
*
|
|
2877
|
+
* // For example once the limiter was moved to another shadow root.
|
|
2878
|
+
* scrollListener.refresh();
|
|
2879
|
+
*
|
|
2880
|
+
* // For example when the view is destroyed.
|
|
2881
|
+
* scrollListener.destroy();
|
|
2882
|
+
* ```
|
|
2883
|
+
*
|
|
2884
|
+
* Only this callback is ever detached, so other listeners of the same emitter on the same targets are not affected.
|
|
2885
|
+
*/
|
|
2886
|
+
var DomTargetsListener = class {
|
|
2887
|
+
/**
|
|
2888
|
+
* Returns the targets that should be listened to.
|
|
2889
|
+
*/
|
|
2890
|
+
_getTargets;
|
|
2891
|
+
/**
|
|
2892
|
+
* The emitter the callback is attached with.
|
|
2893
|
+
*/
|
|
2894
|
+
_emitter;
|
|
2895
|
+
/**
|
|
2896
|
+
* The DOM event the callback is attached to.
|
|
2897
|
+
*/
|
|
2898
|
+
_event;
|
|
2899
|
+
/**
|
|
2900
|
+
* The callback attached to each target.
|
|
2901
|
+
*/
|
|
2902
|
+
_callback;
|
|
2903
|
+
/**
|
|
2904
|
+
* The options the callback is attached with.
|
|
2905
|
+
*/
|
|
2906
|
+
_listenerOptions;
|
|
2907
|
+
/**
|
|
2908
|
+
* The targets the callback is currently attached to.
|
|
2909
|
+
*/
|
|
2910
|
+
_attachedTargets = /* @__PURE__ */ new Set();
|
|
2911
|
+
/**
|
|
2912
|
+
* Creates the listener and attaches the callback to the targets returned by `getTargets()`.
|
|
2913
|
+
*
|
|
2914
|
+
* @param getTargets Returns the targets that should be listened to. `null` and `undefined` entries are skipped.
|
|
2915
|
+
* @param options Describes the listener to attach to each target.
|
|
2916
|
+
*/
|
|
2917
|
+
constructor(getTargets, { emitter, event, listenerOptions, callback }) {
|
|
2918
|
+
this._getTargets = getTargets;
|
|
2919
|
+
this._emitter = emitter;
|
|
2920
|
+
this._event = event;
|
|
2921
|
+
this._callback = callback;
|
|
2922
|
+
this._listenerOptions = listenerOptions;
|
|
2923
|
+
this.refresh();
|
|
2924
|
+
}
|
|
2925
|
+
/**
|
|
2926
|
+
* Reads the targets again: attaches the callback to the targets that appeared and detaches it from the targets that
|
|
2927
|
+
* disappeared.
|
|
2928
|
+
*/
|
|
2929
|
+
refresh() {
|
|
2930
|
+
const targets = /* @__PURE__ */ new Set();
|
|
2931
|
+
for (const target of this._getTargets()) if (target) targets.add(target);
|
|
2932
|
+
this._attachTo(targets);
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Detaches the callback from every target.
|
|
2936
|
+
*/
|
|
2937
|
+
destroy() {
|
|
2938
|
+
this._attachTo(/* @__PURE__ */ new Set());
|
|
2939
|
+
}
|
|
2940
|
+
/**
|
|
2941
|
+
* Attaches the callback to exactly the given targets.
|
|
2942
|
+
*/
|
|
2943
|
+
_attachTo(targets) {
|
|
2944
|
+
for (const target of this._attachedTargets) if (!targets.has(target)) {
|
|
2945
|
+
this._emitter.stopListening(target, this._event, this._callback);
|
|
2946
|
+
this._attachedTargets.delete(target);
|
|
2947
|
+
}
|
|
2948
|
+
for (const target of targets) if (!this._attachedTargets.has(target)) {
|
|
2949
|
+
this._emitter.listenTo(target, this._event, this._callback, this._listenerOptions);
|
|
2950
|
+
this._attachedTargets.add(target);
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
|
|
2823
2955
|
/**
|
|
2824
2956
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2825
2957
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
@@ -3464,12 +3596,10 @@ var Rect = class Rect {
|
|
|
3464
3596
|
* Recalculates screen coordinates to coordinates relative to the positioned ancestor offset.
|
|
3465
3597
|
*/
|
|
3466
3598
|
toAbsoluteRect() {
|
|
3467
|
-
const
|
|
3468
|
-
const
|
|
3469
|
-
if (
|
|
3470
|
-
|
|
3471
|
-
if (positionedAncestor) shiftRectToCompensatePositionedAncestor(absoluteRect, positionedAncestor);
|
|
3472
|
-
}
|
|
3599
|
+
const absoluteRect = this.clone();
|
|
3600
|
+
const positionedAncestor = isDomElement(this._source) ? getPositionedAncestor(this._source) : null;
|
|
3601
|
+
if (positionedAncestor) shiftRectToCompensatePositionedAncestor(absoluteRect, positionedAncestor);
|
|
3602
|
+
else absoluteRect.moveBy(globalVar.window.scrollX, globalVar.window.scrollY);
|
|
3473
3603
|
return absoluteRect;
|
|
3474
3604
|
}
|
|
3475
3605
|
/**
|
|
@@ -3611,7 +3741,7 @@ function isPositioned(node) {
|
|
|
3611
3741
|
return node instanceof HTMLElement && POSITIONING_VALUES.has(getElementPosition(node));
|
|
3612
3742
|
}
|
|
3613
3743
|
/**
|
|
3614
|
-
* For a given
|
|
3744
|
+
* For a given Rect relative to the viewport and a positioned element ancestor, it updates its
|
|
3615
3745
|
* coordinates that make up for the position and the scroll of the ancestor.
|
|
3616
3746
|
*
|
|
3617
3747
|
* This is necessary because while Rects (and DOMRects) are relative to the browser's viewport, their coordinates
|
|
@@ -3985,6 +4115,20 @@ function insertAt(parentElement, index, nodeToInsert) {
|
|
|
3985
4115
|
parentElement.insertBefore(nodeToInsert, parentElement.childNodes[index] || null);
|
|
3986
4116
|
}
|
|
3987
4117
|
|
|
4118
|
+
/**
|
|
4119
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
4120
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4121
|
+
*/
|
|
4122
|
+
/**
|
|
4123
|
+
* @module utils/dom/isprocessinginstruction
|
|
4124
|
+
*/
|
|
4125
|
+
/**
|
|
4126
|
+
* Checks whether the object is a native DOM Processing Instruction node.
|
|
4127
|
+
*/
|
|
4128
|
+
function isProcessingInstruction(obj) {
|
|
4129
|
+
return obj && obj.nodeType === Node.PROCESSING_INSTRUCTION_NODE;
|
|
4130
|
+
}
|
|
4131
|
+
|
|
3988
4132
|
/**
|
|
3989
4133
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3990
4134
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
@@ -4079,19 +4223,33 @@ const ShadowRootRegistryBase = /* #__PURE__ */ EmitterMixin();
|
|
|
4079
4223
|
* Keeps track of the shadow roots hosting a set of registered DOM nodes (for example an editor UI's editables,
|
|
4080
4224
|
* toolbars and menu bars, or a feature's own UI), so that consumers can, for instance, inject styles or listeners
|
|
4081
4225
|
* into every shadow root those nodes currently live in.
|
|
4226
|
+
*
|
|
4227
|
+
* It also keeps track of the wider set of the {@link #getEventRoots event roots} of those nodes – the shadow roots
|
|
4228
|
+
* plus the documents the nodes are connected to – for consumers that listen to DOM events of those nodes.
|
|
4082
4229
|
*/
|
|
4083
4230
|
var ShadowRootRegistry = class extends ShadowRootRegistryBase {
|
|
4084
4231
|
/**
|
|
4085
|
-
* The
|
|
4086
|
-
*
|
|
4087
|
-
* node that has since been attached, or moved to another tree, is picked up.
|
|
4088
|
-
* {@link #getShadowRoots}.
|
|
4232
|
+
* The event roots of each registered node, as of the last time that node was looked at: the shadow roots hosting
|
|
4233
|
+
* it and the document it is connected to. Empty for a node that was detached then. Re-derived for every node by
|
|
4234
|
+
* each {@link #refresh}, so a node that has since been attached, or moved to another tree, is picked up.
|
|
4235
|
+
* The union of the values is {@link #getEventRoots}, and its shadow roots are {@link #getShadowRoots}.
|
|
4089
4236
|
*/
|
|
4090
4237
|
_rootsByNode = /* @__PURE__ */ new Map();
|
|
4091
4238
|
/**
|
|
4092
4239
|
* Returns the shadow roots currently hosting at least one registered node.
|
|
4093
4240
|
*/
|
|
4094
4241
|
getShadowRoots() {
|
|
4242
|
+
const roots = /* @__PURE__ */ new Set();
|
|
4243
|
+
for (const root of this.getEventRoots()) if (isShadowRoot(root)) roots.add(root);
|
|
4244
|
+
return roots;
|
|
4245
|
+
}
|
|
4246
|
+
/**
|
|
4247
|
+
* Returns the event roots of the currently registered nodes: every shadow root hosting at least one of them,
|
|
4248
|
+
* as in {@link #getShadowRoots}, and every document at least one of them is connected to.
|
|
4249
|
+
*
|
|
4250
|
+
* See {@link module:utils/dom/geteventroots~getEventRoots} for what an event root is.
|
|
4251
|
+
*/
|
|
4252
|
+
getEventRoots() {
|
|
4095
4253
|
const roots = /* @__PURE__ */ new Set();
|
|
4096
4254
|
for (const nodeRoots of this._rootsByNode.values()) for (const root of nodeRoots) roots.add(root);
|
|
4097
4255
|
return roots;
|
|
@@ -4104,7 +4262,7 @@ var ShadowRootRegistry = class extends ShadowRootRegistryBase {
|
|
|
4104
4262
|
*/
|
|
4105
4263
|
registerNode(node) {
|
|
4106
4264
|
if (this._rootsByNode.has(node)) return;
|
|
4107
|
-
const previousRoots = this.
|
|
4265
|
+
const previousRoots = this.getEventRoots();
|
|
4108
4266
|
this._rootsByNode.set(node, deriveRoots(node));
|
|
4109
4267
|
this._fireRootChanges(previousRoots);
|
|
4110
4268
|
}
|
|
@@ -4114,13 +4272,14 @@ var ShadowRootRegistry = class extends ShadowRootRegistryBase {
|
|
|
4114
4272
|
*/
|
|
4115
4273
|
unregisterNode(node) {
|
|
4116
4274
|
if (!this._rootsByNode.has(node)) return;
|
|
4117
|
-
const previousRoots = this.
|
|
4275
|
+
const previousRoots = this.getEventRoots();
|
|
4118
4276
|
this._rootsByNode.delete(node);
|
|
4119
4277
|
this._fireRootChanges(previousRoots);
|
|
4120
4278
|
}
|
|
4121
4279
|
/**
|
|
4122
4280
|
* Re-derives the shadow roots of every registered node, firing {@link #event:add} for the roots that started
|
|
4123
|
-
* hosting one and {@link #event:remove} for those that stopped.
|
|
4281
|
+
* hosting one and {@link #event:remove} for those that stopped. Fires {@link #event:changeEventRoots} if
|
|
4282
|
+
* the {@link #getEventRoots event roots} changed.
|
|
4124
4283
|
*
|
|
4125
4284
|
* Call it whenever a registered node may have been attached, detached, or moved – for example on every editor
|
|
4126
4285
|
* UI update. Nodes are re-derived rather than resolved once, because the tree a node lives in is not fixed:
|
|
@@ -4128,29 +4287,38 @@ var ShadowRootRegistry = class extends ShadowRootRegistryBase {
|
|
|
4128
4287
|
* another tree, ends up somewhere its roots were never derived from.
|
|
4129
4288
|
*/
|
|
4130
4289
|
refresh() {
|
|
4131
|
-
const previousRoots = this.
|
|
4290
|
+
const previousRoots = this.getEventRoots();
|
|
4132
4291
|
for (const node of this._rootsByNode.keys()) this._rootsByNode.set(node, deriveRoots(node));
|
|
4133
4292
|
this._fireRootChanges(previousRoots);
|
|
4134
4293
|
}
|
|
4135
4294
|
/**
|
|
4136
4295
|
* Unregisters every currently registered node at once, firing {@link #event:remove} for every shadow root
|
|
4137
|
-
* that consequently stops being tracked.
|
|
4296
|
+
* that consequently stops being tracked, and {@link #event:changeEventRoots} if any event root was tracked.
|
|
4138
4297
|
*
|
|
4139
4298
|
* @internal
|
|
4140
4299
|
*/
|
|
4141
4300
|
destroy() {
|
|
4142
|
-
const previousRoots = this.
|
|
4301
|
+
const previousRoots = this.getEventRoots();
|
|
4143
4302
|
this._rootsByNode.clear();
|
|
4144
4303
|
this._fireRootChanges(previousRoots);
|
|
4145
4304
|
}
|
|
4146
4305
|
/**
|
|
4147
|
-
* Fires {@link #event:add} and {@link #event:remove} for the difference between the
|
|
4148
|
-
*
|
|
4306
|
+
* Fires {@link #event:add} and {@link #event:remove} for the difference between the shadow roots in the given
|
|
4307
|
+
* set of tracked event roots and the current ones, followed by a single {@link #event:changeEventRoots} if
|
|
4308
|
+
* the event roots differ at all.
|
|
4149
4309
|
*/
|
|
4150
4310
|
_fireRootChanges(previousRoots) {
|
|
4151
|
-
const currentRoots = this.
|
|
4152
|
-
|
|
4153
|
-
for (const root of
|
|
4311
|
+
const currentRoots = this.getEventRoots();
|
|
4312
|
+
let hasChanged = false;
|
|
4313
|
+
for (const root of previousRoots) if (!currentRoots.has(root)) {
|
|
4314
|
+
hasChanged = true;
|
|
4315
|
+
if (isShadowRoot(root)) this.fire("remove", root);
|
|
4316
|
+
}
|
|
4317
|
+
for (const root of currentRoots) if (!previousRoots.has(root)) {
|
|
4318
|
+
hasChanged = true;
|
|
4319
|
+
if (isShadowRoot(root)) this.fire("add", root);
|
|
4320
|
+
}
|
|
4321
|
+
if (hasChanged) this.fire("changeEventRoots");
|
|
4154
4322
|
}
|
|
4155
4323
|
};
|
|
4156
4324
|
/**
|
|
@@ -4170,55 +4338,80 @@ var ShadowRootRegistry = class extends ShadowRootRegistryBase {
|
|
|
4170
4338
|
* const stopListening = listenToShadowRoots( editor.ui.shadowRootRegistry, {
|
|
4171
4339
|
* emitter: view,
|
|
4172
4340
|
* event: 'scroll',
|
|
4173
|
-
*
|
|
4174
|
-
*
|
|
4341
|
+
* listenerOptions: { useCapture: true },
|
|
4342
|
+
* callback: repositionOnScroll
|
|
4175
4343
|
* } );
|
|
4176
4344
|
* ```
|
|
4177
4345
|
*
|
|
4346
|
+
* To cover both with a single call, use {@link ~listenToEventRoots} instead.
|
|
4347
|
+
*
|
|
4178
4348
|
* The `useCapture` above is not incidental. The events this function exists for do not bubble when fired on an
|
|
4179
4349
|
* element, so a listener on a shadow root only sees one that originates inside that root during the capture
|
|
4180
4350
|
* phase. Without it the listener is attached but never fires.
|
|
4181
4351
|
*
|
|
4182
|
-
* Call the returned function to detach.
|
|
4352
|
+
* Call the returned function to detach. There is nothing to refresh, as the listener follows the registry on its own.
|
|
4183
4353
|
*
|
|
4184
4354
|
* @param registry The registry whose shadow roots should be listened to.
|
|
4185
4355
|
* @param options Describes the listener to attach to each shadow root.
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4356
|
+
*/
|
|
4357
|
+
function listenToShadowRoots(registry, options) {
|
|
4358
|
+
return listenToTrackedRoots(registry, ["add", "remove"], () => registry.getShadowRoots(), options);
|
|
4359
|
+
}
|
|
4360
|
+
/**
|
|
4361
|
+
* Attaches `emitter`'s callback to the global `document` and to every {@link ~ShadowRootRegistry#getEventRoots event root}
|
|
4362
|
+
* tracked by `registry`, and keeps that up to date – attaching to roots that appear later, detaching from roots that
|
|
4363
|
+
* disappear – for as long as the returned function is not called.
|
|
4364
|
+
*
|
|
4365
|
+
* It replaces a pair of a `document` listener and {@link ~listenToShadowRoots}:
|
|
4366
|
+
*
|
|
4367
|
+
* ```ts
|
|
4368
|
+
* const stopListening = listenToEventRoots( editor.ui.shadowRootRegistry, {
|
|
4369
|
+
* emitter: view,
|
|
4370
|
+
* event: 'scroll',
|
|
4371
|
+
* listenerOptions: { useCapture: true },
|
|
4372
|
+
* callback: repositionOnScroll
|
|
4373
|
+
* } );
|
|
4374
|
+
* ```
|
|
4375
|
+
*
|
|
4376
|
+
* The global `document` is always listened to, even if no registered node lives in it, so the callback receives
|
|
4377
|
+
* the same events as a listener on `document` would, plus the events of the other event roots. Each root is listened
|
|
4378
|
+
* to once, no matter how many registered nodes it hosts.
|
|
4379
|
+
*
|
|
4380
|
+
* As with {@link ~listenToShadowRoots}, use `useCapture: true` for events that do not bubble, such as `scroll`.
|
|
4381
|
+
*
|
|
4382
|
+
* Call the returned function to detach. There is nothing to refresh, as the listener follows the registry on its own.
|
|
4383
|
+
*
|
|
4384
|
+
* @param registry The registry whose event roots should be listened to.
|
|
4385
|
+
* @param options Describes the listener to attach to each event root.
|
|
4386
|
+
*/
|
|
4387
|
+
function listenToEventRoots(registry, options) {
|
|
4388
|
+
return listenToTrackedRoots(registry, ["changeEventRoots"], () => {
|
|
4389
|
+
const roots = registry.getEventRoots();
|
|
4390
|
+
roots.add(globalVar.document);
|
|
4391
|
+
return roots;
|
|
4392
|
+
}, options);
|
|
4393
|
+
}
|
|
4394
|
+
/**
|
|
4395
|
+
* Keeps `emitter`'s callback attached to exactly the roots returned by `getRoots()`, re-reading them whenever
|
|
4396
|
+
* the registry fires one of `registryEvents`.
|
|
4397
|
+
*/
|
|
4398
|
+
function listenToTrackedRoots(registry, registryEvents, getRoots, options) {
|
|
4399
|
+
const rootsListener = new DomTargetsListener(getRoots, options);
|
|
4400
|
+
const refresh = () => rootsListener.refresh();
|
|
4401
|
+
for (const registryEvent of registryEvents) options.emitter.listenTo(registry, registryEvent, refresh);
|
|
4207
4402
|
return () => {
|
|
4208
|
-
emitter.stopListening(registry,
|
|
4209
|
-
|
|
4210
|
-
for (const root of attachedRoots) emitter.stopListening(root, event, callback);
|
|
4211
|
-
attachedRoots.clear();
|
|
4403
|
+
for (const registryEvent of registryEvents) options.emitter.stopListening(registry, registryEvent, refresh);
|
|
4404
|
+
rootsListener.destroy();
|
|
4212
4405
|
};
|
|
4213
4406
|
}
|
|
4214
4407
|
/**
|
|
4215
|
-
* The
|
|
4408
|
+
* The event roots a node lives in, or none while it is detached.
|
|
4216
4409
|
*
|
|
4217
4410
|
* A detached node still reports the shadow roots of the tree it sits in – those roots exist whether or not their
|
|
4218
4411
|
* host is in a document – but nothing in them is rendered yet, so there is nothing to listen to or inject into.
|
|
4219
4412
|
*/
|
|
4220
4413
|
function deriveRoots(node) {
|
|
4221
|
-
return node.isConnected ?
|
|
4414
|
+
return node.isConnected ? getEventRoots(node) : [];
|
|
4222
4415
|
}
|
|
4223
4416
|
|
|
4224
4417
|
/**
|
|
@@ -7034,5 +7227,5 @@ function tryCastDimensionsToUnit(parentDimensionPx, dimension, targetUnit) {
|
|
|
7034
7227
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
7035
7228
|
*/
|
|
7036
7229
|
|
|
7037
|
-
export { CKEditorError, Collection, Config, DOCUMENTATION_URL, DomEmitterMixin, ElementReplacer, EmitterMixin, EventInfo, FocusTracker, KeystrokeHandler, Locale, ObservableMixin, Rect, ResizeObserver, ShadowRootRegistry, ShadowSelection, _clear as _clearTranslations, _clearTrustedTypesCache, _getEmitterId, _getEmitterListenedTo, getUserAgent as _getUserAgent, isAndroid as _isAndroid, isBlink as _isBlink, isGecko as _isGecko, isMac as _isMac, isMediaForcedColors as _isMediaForcedColors, isMotionReduced as _isMotionReduced, isRegExpUnicodePropertySupported as _isRegExpUnicodePropertySupported, isSafari as _isSafari, isWindows as _isWindows, isiOS as _isiOS, _setEmitterId, _translate, _trustedAttributeValue, tryCastDimensionsToUnit as _tryCastDimensionsToUnit, tryParseDimensionWithUnit as _tryParseDimensionWithUnit, _unifyTranslations, abortableDebounce, add, adoptGlobalStyleSheet, areConnectedThroughProperties, collectStylesheets, compareArrays, containsNode, count, crc32, createElement, decodeLicenseKey, delay, diff, diffToChanges, env, exponentialDelay, fastDiff, findClosestScrollableAncestor, first, formatHtml, getActiveElement, getAncestors, getBorderWidths, getCode, getConstrainedViewportRect, getDataFromElement, getElementFromPoint, getEnvKeystrokeText, getLanguageDirection, getLayoutParentElement, getLayoutParentNode, getLocalizedArrowKeyCodeDirection, getOptimalPosition, getOverlayMountRoot, getParentElement, getParentNode, getPositionedAncestor, getRangeFromMouseEvent, getSelection, getShadowRoots, getVisualViewportOffset, globalVar as global, indexOf, insertAt, insertToPriorityArray, isArrowKeyCode, isCombiningMark, isComment, isDomSelectionBackward, isFeatureBlockedByLicenseKey, isForwardArrowKeyCode, isHighSurrogateHalf, isInsideCombinedSymbol, isInsideEmojiSequence, isInsideSurrogatePair, isIterable, isLowSurrogateHalf, isNode, isOffline, isRange, isShadowHostOf, isShadowRoot, isText, isTrustedTypesEnforced, isValidAttributeName, isViewWithFocusTracker, isVisible, isWindow, keyCodes, listenToShadowRoots, logError, logWarning, mapsEqual, nth, objectToMap, parseBase64EncodedObject, parseKeystroke, priorities, releaseDate, remove, retry, scrollAncestorsToShowTarget, scrollViewportToShowTarget, setDataInElement, spliceArray, spy, toArray, toMap, toUnit, trustedHtml, uid, version, wait, whenElementConnected };
|
|
7230
|
+
export { CKEditorError, Collection, Config, DOCUMENTATION_URL, DomEmitterMixin, DomTargetsListener, ElementReplacer, EmitterMixin, EventInfo, FocusTracker, KeystrokeHandler, Locale, ObservableMixin, Rect, ResizeObserver, ShadowRootRegistry, ShadowSelection, _clear as _clearTranslations, _clearTrustedTypesCache, _getEmitterId, _getEmitterListenedTo, getUserAgent as _getUserAgent, isAndroid as _isAndroid, isBlink as _isBlink, isGecko as _isGecko, isMac as _isMac, isMediaForcedColors as _isMediaForcedColors, isMotionReduced as _isMotionReduced, isRegExpUnicodePropertySupported as _isRegExpUnicodePropertySupported, isSafari as _isSafari, isWindows as _isWindows, isiOS as _isiOS, _setEmitterId, _translate, _trustedAttributeValue, tryCastDimensionsToUnit as _tryCastDimensionsToUnit, tryParseDimensionWithUnit as _tryParseDimensionWithUnit, _unifyTranslations, abortableDebounce, add, adoptGlobalStyleSheet, areConnectedThroughProperties, collectStylesheets, compareArrays, containsNode, count, crc32, createElement, decodeLicenseKey, delay, diff, diffToChanges, env, exponentialDelay, fastDiff, findClosestScrollableAncestor, first, formatHtml, getActiveElement, getAncestors, getBorderWidths, getCode, getConstrainedViewportRect, getDataFromElement, getElementFromPoint, getEnvKeystrokeText, getEventRoots, getLanguageDirection, getLayoutParentElement, getLayoutParentNode, getLocalizedArrowKeyCodeDirection, getOptimalPosition, getOverlayMountRoot, getParentElement, getParentNode, getPositionedAncestor, getRangeFromMouseEvent, getSelection, getShadowRoots, getVisualViewportOffset, globalVar as global, indexOf, insertAt, insertToPriorityArray, isArrowKeyCode, isCombiningMark, isComment, isDomSelectionBackward, isFeatureBlockedByLicenseKey, isForwardArrowKeyCode, isHighSurrogateHalf, isInsideCombinedSymbol, isInsideEmojiSequence, isInsideSurrogatePair, isIterable, isLowSurrogateHalf, isNode, isOffline, isProcessingInstruction, isRange, isShadowHostOf, isShadowRoot, isText, isTrustedTypesEnforced, isValidAttributeName, isViewWithFocusTracker, isVisible, isWindow, keyCodes, listenToEventRoots, listenToShadowRoots, logError, logWarning, mapsEqual, nth, objectToMap, parseBase64EncodedObject, parseKeystroke, priorities, releaseDate, remove, retry, scrollAncestorsToShowTarget, scrollViewportToShowTarget, setDataInElement, spliceArray, spy, toArray, toMap, toUnit, trustedHtml, uid, version, wait, whenElementConnected };
|
|
7038
7231
|
//# sourceMappingURL=index.js.map
|