@ckeditor/ckeditor5-utils
Advanced tools
Comparing version 43.2.0 to 43.3.0-alpha.0
@@ -9,2 +9,3 @@ /** | ||
*/ | ||
import { type View } from '@ckeditor/ckeditor5-ui'; | ||
declare const FocusTracker_base: import("./mix.js").Mixed<{ | ||
@@ -15,3 +16,4 @@ new (): import("./observablemixin.js").Observable; | ||
/** | ||
* Allows observing a group of `Element`s whether at least one of them is focused. | ||
* Allows observing a group of DOM `Element`s or {@link module:ui/view~View view instances} whether at least one of them (or their child) | ||
* is focused. | ||
* | ||
@@ -29,3 +31,3 @@ * Used by the {@link module:core/editor/editor~Editor} in order to track whether the focus is still within the application, | ||
/** | ||
* True when one of the registered elements is focused. | ||
* True when one of the registered {@link #elements} or {@link #externalViews} is focused. | ||
* | ||
@@ -39,6 +41,8 @@ * @readonly | ||
* | ||
* While {@link #isFocused `isFocused`} remains `true`, the focus can | ||
* move between different UI elements. This property tracks those | ||
* While {@link #isFocused `isFocused`} remains `true`, the focus can move between different UI elements. This property tracks those | ||
* elements and tells which one is currently focused. | ||
* | ||
* **Note**: The values of this property are restricted to {@link #elements} or {@link module:ui/view~View#element elements} | ||
* registered in {@link #externalViews}. | ||
* | ||
* @readonly | ||
@@ -49,3 +53,3 @@ * @observable | ||
/** | ||
* List of registered elements. | ||
* List of registered DOM elements. | ||
* | ||
@@ -56,34 +60,91 @@ * @internal | ||
/** | ||
* Event loop timeout. | ||
* List of views with external focus trackers that contribute to the state of this focus tracker. | ||
* | ||
* @internal | ||
*/ | ||
private _nextEventLoopTimeout; | ||
_externalViews: Set<ViewWithFocusTracker>; | ||
/** | ||
* Asynchronous blur event timeout. | ||
*/ | ||
private _blurTimeout; | ||
constructor(); | ||
/** | ||
* List of registered elements. | ||
* List of registered DOM elements. | ||
* | ||
* **Note**: The list does do not include elements from {@link #externalViews}. | ||
*/ | ||
get elements(): Array<Element>; | ||
/** | ||
* Starts tracking the specified element. | ||
* List of external focusable views that contribute to the state of this focus tracker. See {@link #add} to learn more. | ||
*/ | ||
add(element: Element): void; | ||
get externalViews(): Array<ViewWithFocusTracker>; | ||
/** | ||
* Stops tracking the specified element and stops listening on this element. | ||
* Starts tracking a specified DOM element or a {@link module:ui/view~View} instance. | ||
* | ||
* * If a DOM element is passed, the focus tracker listens to the `focus` and `blur` events on this element. | ||
* Tracked elements are listed in {@link #elements}. | ||
* * If a {@link module:ui/view~View} instance is passed that has a `FocusTracker` instance ({@link ~ViewWithFocusTracker}), | ||
* the external focus tracker's state ({@link #isFocused}, {@link #focusedElement}) starts contributing to the current tracker instance. | ||
* This allows for increasing the "reach" of a focus tracker instance, by connecting two or more focus trackers together when DOM | ||
* elements they track are located in different subtrees in DOM. External focus trackers are listed in {@link #externalViews}. | ||
* * If a {@link module:ui/view~View} instance is passed that has no `FocusTracker` (**not** a {@link ~ViewWithFocusTracker}), | ||
* its {@link module:ui/view~View#element} is used to track focus like any other DOM element. | ||
*/ | ||
remove(element: Element): void; | ||
add(elementOrView: Element | View): void; | ||
/** | ||
* Stops tracking focus in the specified DOM element or a {@link module:ui/view~View view instance}. See {@link #add} to learn more. | ||
*/ | ||
remove(elementOrView: Element | View): void; | ||
/** | ||
* Adds a DOM element to the focus tracker and starts listening to the `focus` and `blur` events on it. | ||
*/ | ||
private _addElement; | ||
/** | ||
* Removes a DOM element from the focus tracker. | ||
*/ | ||
private _removeElement; | ||
/** | ||
* Adds an external {@link module:ui/view~View view instance} to this focus tracker and makes it contribute to this focus tracker's | ||
* state either by its `View#element` or by its `View#focusTracker` instance. | ||
*/ | ||
private _addView; | ||
/** | ||
* Removes an external {@link module:ui/view~View view instance} from this focus tracker. | ||
*/ | ||
private _removeView; | ||
/** | ||
* Destroys the focus tracker by: | ||
* - Disabling all event listeners attached to tracked elements. | ||
* - Removing all tracked elements that were previously added. | ||
* - Disabling all event listeners attached to tracked elements or external views. | ||
* - Removing all tracked elements and views that were previously added. | ||
*/ | ||
destroy(): void; | ||
/** | ||
* Stores currently focused element and set {@link #isFocused} as `true`. | ||
* Stores currently focused element as {@link #focusedElement} and sets {@link #isFocused} `true`. | ||
*/ | ||
private _focus; | ||
/** | ||
* Clears currently focused element and set {@link #isFocused} as `false`. | ||
* This method uses `setTimeout` to change order of fires `blur` and `focus` events. | ||
* Clears currently {@link #focusedElement} and sets {@link #isFocused} `false`. | ||
* | ||
* This method uses `setTimeout()` to change order of `blur` and `focus` events calls, ensuring that moving focus between | ||
* two elements within a single focus tracker's scope, will not cause `[ blurA, focusB ]` sequence but just `[ focusB ]`. | ||
* The former would cause a momentary change of `#isFocused` to `false` which is not desired because any logic listening to | ||
* a focus tracker state would experience UI flashes and glitches as the user focus travels across the UI. | ||
*/ | ||
private _blur; | ||
/** | ||
* Clears the asynchronous blur event timeout on demand. See {@link #_blur} to learn more. | ||
*/ | ||
private _clearBlurTimeout; | ||
} | ||
/** | ||
* A {@link module:ui/view~View} instance with a {@link module:utils/focustracker~FocusTracker} instance exposed | ||
* at the `#focusTracker` property. | ||
*/ | ||
export type ViewWithFocusTracker = View & { | ||
focusTracker: FocusTracker; | ||
}; | ||
/** | ||
* Checks whether a view is an instance of {@link ~ViewWithFocusTracker}. | ||
*/ | ||
export declare function isViewWithFocusTracker(view: any): view is ViewWithFocusTracker; | ||
export {}; |
@@ -56,3 +56,3 @@ /** | ||
export { default as first } from './first.js'; | ||
export { default as FocusTracker } from './focustracker.js'; | ||
export { default as FocusTracker, type ViewWithFocusTracker, isViewWithFocusTracker } from './focustracker.js'; | ||
export { default as KeystrokeHandler, type KeystrokeHandlerOptions } from './keystrokehandler.js'; | ||
@@ -59,0 +59,0 @@ export { default as toArray, type ArrayOrItem, type ReadonlyArrayOrItem } from './toarray.js'; |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
declare const version = "43.2.0"; | ||
declare const version = "43.3.0-alpha.0"; | ||
export default version; | ||
@@ -12,0 +12,0 @@ export declare const releaseDate: Date; |
{ | ||
"name": "@ckeditor/ckeditor5-utils", | ||
"version": "43.2.0", | ||
"version": "43.3.0-alpha.0", | ||
"description": "Miscellaneous utilities used by CKEditor 5.", | ||
@@ -15,3 +15,4 @@ "keywords": [ | ||
"dependencies": { | ||
"lodash-es": "4.17.21" | ||
"lodash-es": "4.17.21", | ||
"@ckeditor/ckeditor5-ui": "43.3.0-alpha.0" | ||
}, | ||
@@ -18,0 +19,0 @@ "author": "CKSource (http://cksource.com/)", |
@@ -5,2 +5,3 @@ /** | ||
*/ | ||
import { type View } from '@ckeditor/ckeditor5-ui'; | ||
declare const FocusTracker_base: import("./mix.js").Mixed<{ | ||
@@ -11,3 +12,4 @@ new (): import("./observablemixin.js").Observable; | ||
/** | ||
* Allows observing a group of `Element`s whether at least one of them is focused. | ||
* Allows observing a group of DOM `Element`s or {@link module:ui/view~View view instances} whether at least one of them (or their child) | ||
* is focused. | ||
* | ||
@@ -25,3 +27,3 @@ * Used by the {@link module:core/editor/editor~Editor} in order to track whether the focus is still within the application, | ||
/** | ||
* True when one of the registered elements is focused. | ||
* True when one of the registered {@link #elements} or {@link #externalViews} is focused. | ||
* | ||
@@ -35,6 +37,8 @@ * @readonly | ||
* | ||
* While {@link #isFocused `isFocused`} remains `true`, the focus can | ||
* move between different UI elements. This property tracks those | ||
* While {@link #isFocused `isFocused`} remains `true`, the focus can move between different UI elements. This property tracks those | ||
* elements and tells which one is currently focused. | ||
* | ||
* **Note**: The values of this property are restricted to {@link #elements} or {@link module:ui/view~View#element elements} | ||
* registered in {@link #externalViews}. | ||
* | ||
* @readonly | ||
@@ -45,3 +49,3 @@ * @observable | ||
/** | ||
* List of registered elements. | ||
* List of registered DOM elements. | ||
* | ||
@@ -52,34 +56,91 @@ * @internal | ||
/** | ||
* Event loop timeout. | ||
* List of views with external focus trackers that contribute to the state of this focus tracker. | ||
* | ||
* @internal | ||
*/ | ||
private _nextEventLoopTimeout; | ||
_externalViews: Set<ViewWithFocusTracker>; | ||
/** | ||
* Asynchronous blur event timeout. | ||
*/ | ||
private _blurTimeout; | ||
constructor(); | ||
/** | ||
* List of registered elements. | ||
* List of registered DOM elements. | ||
* | ||
* **Note**: The list does do not include elements from {@link #externalViews}. | ||
*/ | ||
get elements(): Array<Element>; | ||
/** | ||
* Starts tracking the specified element. | ||
* List of external focusable views that contribute to the state of this focus tracker. See {@link #add} to learn more. | ||
*/ | ||
add(element: Element): void; | ||
get externalViews(): Array<ViewWithFocusTracker>; | ||
/** | ||
* Stops tracking the specified element and stops listening on this element. | ||
* Starts tracking a specified DOM element or a {@link module:ui/view~View} instance. | ||
* | ||
* * If a DOM element is passed, the focus tracker listens to the `focus` and `blur` events on this element. | ||
* Tracked elements are listed in {@link #elements}. | ||
* * If a {@link module:ui/view~View} instance is passed that has a `FocusTracker` instance ({@link ~ViewWithFocusTracker}), | ||
* the external focus tracker's state ({@link #isFocused}, {@link #focusedElement}) starts contributing to the current tracker instance. | ||
* This allows for increasing the "reach" of a focus tracker instance, by connecting two or more focus trackers together when DOM | ||
* elements they track are located in different subtrees in DOM. External focus trackers are listed in {@link #externalViews}. | ||
* * If a {@link module:ui/view~View} instance is passed that has no `FocusTracker` (**not** a {@link ~ViewWithFocusTracker}), | ||
* its {@link module:ui/view~View#element} is used to track focus like any other DOM element. | ||
*/ | ||
remove(element: Element): void; | ||
add(elementOrView: Element | View): void; | ||
/** | ||
* Stops tracking focus in the specified DOM element or a {@link module:ui/view~View view instance}. See {@link #add} to learn more. | ||
*/ | ||
remove(elementOrView: Element | View): void; | ||
/** | ||
* Adds a DOM element to the focus tracker and starts listening to the `focus` and `blur` events on it. | ||
*/ | ||
private _addElement; | ||
/** | ||
* Removes a DOM element from the focus tracker. | ||
*/ | ||
private _removeElement; | ||
/** | ||
* Adds an external {@link module:ui/view~View view instance} to this focus tracker and makes it contribute to this focus tracker's | ||
* state either by its `View#element` or by its `View#focusTracker` instance. | ||
*/ | ||
private _addView; | ||
/** | ||
* Removes an external {@link module:ui/view~View view instance} from this focus tracker. | ||
*/ | ||
private _removeView; | ||
/** | ||
* Destroys the focus tracker by: | ||
* - Disabling all event listeners attached to tracked elements. | ||
* - Removing all tracked elements that were previously added. | ||
* - Disabling all event listeners attached to tracked elements or external views. | ||
* - Removing all tracked elements and views that were previously added. | ||
*/ | ||
destroy(): void; | ||
/** | ||
* Stores currently focused element and set {@link #isFocused} as `true`. | ||
* Stores currently focused element as {@link #focusedElement} and sets {@link #isFocused} `true`. | ||
*/ | ||
private _focus; | ||
/** | ||
* Clears currently focused element and set {@link #isFocused} as `false`. | ||
* This method uses `setTimeout` to change order of fires `blur` and `focus` events. | ||
* Clears currently {@link #focusedElement} and sets {@link #isFocused} `false`. | ||
* | ||
* This method uses `setTimeout()` to change order of `blur` and `focus` events calls, ensuring that moving focus between | ||
* two elements within a single focus tracker's scope, will not cause `[ blurA, focusB ]` sequence but just `[ focusB ]`. | ||
* The former would cause a momentary change of `#isFocused` to `false` which is not desired because any logic listening to | ||
* a focus tracker state would experience UI flashes and glitches as the user focus travels across the UI. | ||
*/ | ||
private _blur; | ||
/** | ||
* Clears the asynchronous blur event timeout on demand. See {@link #_blur} to learn more. | ||
*/ | ||
private _clearBlurTimeout; | ||
} | ||
/** | ||
* A {@link module:ui/view~View} instance with a {@link module:utils/focustracker~FocusTracker} instance exposed | ||
* at the `#focusTracker` property. | ||
*/ | ||
export type ViewWithFocusTracker = View & { | ||
focusTracker: FocusTracker; | ||
}; | ||
/** | ||
* Checks whether a view is an instance of {@link ~ViewWithFocusTracker}. | ||
*/ | ||
export declare function isViewWithFocusTracker(view: any): view is ViewWithFocusTracker; | ||
export {}; |
@@ -12,4 +12,6 @@ /** | ||
import CKEditorError from './ckeditorerror.js'; | ||
import { isElement as _isElement } from 'lodash-es'; | ||
/** | ||
* Allows observing a group of `Element`s whether at least one of them is focused. | ||
* Allows observing a group of DOM `Element`s or {@link module:ui/view~View view instances} whether at least one of them (or their child) | ||
* is focused. | ||
* | ||
@@ -26,6 +28,7 @@ * Used by the {@link module:core/editor/editor~Editor} in order to track whether the focus is still within the application, | ||
export default class FocusTracker extends /* #__PURE__ */ DomEmitterMixin(/* #__PURE__ */ ObservableMixin()) { | ||
// @if CK_DEBUG_FOCUSTRACKER // public _label?: string; | ||
constructor() { | ||
super(); | ||
/** | ||
* List of registered elements. | ||
* List of registered DOM elements. | ||
* | ||
@@ -36,10 +39,19 @@ * @internal | ||
/** | ||
* Event loop timeout. | ||
* List of views with external focus trackers that contribute to the state of this focus tracker. | ||
* | ||
* @internal | ||
*/ | ||
this._nextEventLoopTimeout = null; | ||
this._externalViews = new Set(); | ||
/** | ||
* Asynchronous blur event timeout. | ||
*/ | ||
this._blurTimeout = null; | ||
this.set('isFocused', false); | ||
this.set('focusedElement', null); | ||
// @if CK_DEBUG_FOCUSTRACKER // FocusTracker._instances.push( this ); | ||
} | ||
/** | ||
* List of registered elements. | ||
* List of registered DOM elements. | ||
* | ||
* **Note**: The list does do not include elements from {@link #externalViews}. | ||
*/ | ||
@@ -50,5 +62,66 @@ get elements() { | ||
/** | ||
* Starts tracking the specified element. | ||
* List of external focusable views that contribute to the state of this focus tracker. See {@link #add} to learn more. | ||
*/ | ||
add(element) { | ||
get externalViews() { | ||
return Array.from(this._externalViews.values()); | ||
} | ||
/** | ||
* Starts tracking a specified DOM element or a {@link module:ui/view~View} instance. | ||
* | ||
* * If a DOM element is passed, the focus tracker listens to the `focus` and `blur` events on this element. | ||
* Tracked elements are listed in {@link #elements}. | ||
* * If a {@link module:ui/view~View} instance is passed that has a `FocusTracker` instance ({@link ~ViewWithFocusTracker}), | ||
* the external focus tracker's state ({@link #isFocused}, {@link #focusedElement}) starts contributing to the current tracker instance. | ||
* This allows for increasing the "reach" of a focus tracker instance, by connecting two or more focus trackers together when DOM | ||
* elements they track are located in different subtrees in DOM. External focus trackers are listed in {@link #externalViews}. | ||
* * If a {@link module:ui/view~View} instance is passed that has no `FocusTracker` (**not** a {@link ~ViewWithFocusTracker}), | ||
* its {@link module:ui/view~View#element} is used to track focus like any other DOM element. | ||
*/ | ||
add(elementOrView) { | ||
if (isElement(elementOrView)) { | ||
this._addElement(elementOrView); | ||
} | ||
else { | ||
if (isViewWithFocusTracker(elementOrView)) { | ||
this._addView(elementOrView); | ||
} | ||
else { | ||
if (!elementOrView.element) { | ||
/** | ||
* The {@link module:ui/view~View} added to the {@link module:utils/focustracker~FocusTracker} does not have an | ||
* {@link module:ui/view~View#element}. Make sure the view is {@link module:ui/view~View#render} before adding | ||
* it to the focus tracker. | ||
* | ||
* @error focustracker-add-view-missing-element | ||
*/ | ||
throw new CKEditorError('focustracker-add-view-missing-element', { | ||
focusTracker: this, | ||
view: elementOrView | ||
}); | ||
} | ||
this._addElement(elementOrView.element); | ||
} | ||
} | ||
} | ||
/** | ||
* Stops tracking focus in the specified DOM element or a {@link module:ui/view~View view instance}. See {@link #add} to learn more. | ||
*/ | ||
remove(elementOrView) { | ||
if (isElement(elementOrView)) { | ||
this._removeElement(elementOrView); | ||
} | ||
else { | ||
if (isViewWithFocusTracker(elementOrView)) { | ||
this._removeView(elementOrView); | ||
} | ||
else { | ||
// Assuming that if the view was successfully added, it must have come with an existing #element. | ||
this._removeElement(elementOrView.element); | ||
} | ||
} | ||
} | ||
/** | ||
* Adds a DOM element to the focus tracker and starts listening to the `focus` and `blur` events on it. | ||
*/ | ||
_addElement(element) { | ||
if (this._elements.has(element)) { | ||
@@ -62,13 +135,22 @@ /** | ||
} | ||
this.listenTo(element, 'focus', () => this._focus(element), { useCapture: true }); | ||
this.listenTo(element, 'blur', () => this._blur(), { useCapture: true }); | ||
this.listenTo(element, 'focus', () => { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.log( `"${ getName( this ) }": Focus with useCapture on DOM element` ); | ||
const externalFocusedViewInSubtree = this.externalViews.find(view => isExternalViewSubtreeFocused(element, view)); | ||
if (externalFocusedViewInSubtree) { | ||
this._focus(externalFocusedViewInSubtree.element); | ||
} | ||
else { | ||
this._focus(element); | ||
} | ||
}, { useCapture: true }); | ||
this.listenTo(element, 'blur', () => { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.log( `"${ getName( this ) }": Blur with useCapture on DOM element` ); | ||
this._blur(); | ||
}, { useCapture: true }); | ||
this._elements.add(element); | ||
} | ||
/** | ||
* Stops tracking the specified element and stops listening on this element. | ||
* Removes a DOM element from the focus tracker. | ||
*/ | ||
remove(element) { | ||
if (element === this.focusedElement) { | ||
this._blur(); | ||
} | ||
_removeElement(element) { | ||
if (this._elements.has(element)) { | ||
@@ -78,16 +160,58 @@ this.stopListening(element); | ||
} | ||
if (element === this.focusedElement) { | ||
this._blur(); | ||
} | ||
} | ||
/** | ||
* Adds an external {@link module:ui/view~View view instance} to this focus tracker and makes it contribute to this focus tracker's | ||
* state either by its `View#element` or by its `View#focusTracker` instance. | ||
*/ | ||
_addView(view) { | ||
if (view.element) { | ||
this._addElement(view.element); | ||
} | ||
this.listenTo(view.focusTracker, 'change:focusedElement', () => { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.log( | ||
// @if CK_DEBUG_FOCUSTRACKER // `"${ getName( this ) }": Related "${ getName( view.focusTracker ) }"#focusedElement = `, | ||
// @if CK_DEBUG_FOCUSTRACKER // view.focusTracker.focusedElement | ||
// @if CK_DEBUG_FOCUSTRACKER // ); | ||
if (view.focusTracker.focusedElement) { | ||
if (view.element) { | ||
this._focus(view.element); | ||
} | ||
} | ||
else { | ||
this._blur(); | ||
} | ||
}); | ||
this._externalViews.add(view); | ||
} | ||
/** | ||
* Removes an external {@link module:ui/view~View view instance} from this focus tracker. | ||
*/ | ||
_removeView(view) { | ||
if (view.element) { | ||
this._removeElement(view.element); | ||
} | ||
this.stopListening(view.focusTracker); | ||
this._externalViews.delete(view); | ||
} | ||
/** | ||
* Destroys the focus tracker by: | ||
* - Disabling all event listeners attached to tracked elements. | ||
* - Removing all tracked elements that were previously added. | ||
* - Disabling all event listeners attached to tracked elements or external views. | ||
* - Removing all tracked elements and views that were previously added. | ||
*/ | ||
destroy() { | ||
this.stopListening(); | ||
this._elements.clear(); | ||
this._externalViews.clear(); | ||
this.isFocused = false; | ||
this.focusedElement = null; | ||
} | ||
/** | ||
* Stores currently focused element and set {@link #isFocused} as `true`. | ||
* Stores currently focused element as {@link #focusedElement} and sets {@link #isFocused} `true`. | ||
*/ | ||
_focus(element) { | ||
clearTimeout(this._nextEventLoopTimeout); | ||
// @if CK_DEBUG_FOCUSTRACKER // console.log( `"${ getName( this ) }": _focus() on element`, element ); | ||
this._clearBlurTimeout(); | ||
this.focusedElement = element; | ||
@@ -97,8 +221,26 @@ this.isFocused = true; | ||
/** | ||
* Clears currently focused element and set {@link #isFocused} as `false`. | ||
* This method uses `setTimeout` to change order of fires `blur` and `focus` events. | ||
* Clears currently {@link #focusedElement} and sets {@link #isFocused} `false`. | ||
* | ||
* This method uses `setTimeout()` to change order of `blur` and `focus` events calls, ensuring that moving focus between | ||
* two elements within a single focus tracker's scope, will not cause `[ blurA, focusB ]` sequence but just `[ focusB ]`. | ||
* The former would cause a momentary change of `#isFocused` to `false` which is not desired because any logic listening to | ||
* a focus tracker state would experience UI flashes and glitches as the user focus travels across the UI. | ||
*/ | ||
_blur() { | ||
clearTimeout(this._nextEventLoopTimeout); | ||
this._nextEventLoopTimeout = setTimeout(() => { | ||
const isAnyElementFocused = this.elements.find(element => element.contains(document.activeElement)); | ||
// Avoid blurs originating from external FTs when the focus still remains in one of the #elements. | ||
if (isAnyElementFocused) { | ||
return; | ||
} | ||
const isAnyExternalViewFocused = this.externalViews.find(view => { | ||
// Do not consider external views's focus trackers as focused if there's a blur timeout pending. | ||
return view.focusTracker.isFocused && !view.focusTracker._blurTimeout; | ||
}); | ||
// Avoid unnecessary DOM blurs coming from #elements when the focus still remains in one of #externalViews. | ||
if (isAnyExternalViewFocused) { | ||
return; | ||
} | ||
this._clearBlurTimeout(); | ||
this._blurTimeout = setTimeout(() => { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.log( `"${ getName( this ) }": Blur.` ); | ||
this.focusedElement = null; | ||
@@ -108,2 +250,89 @@ this.isFocused = false; | ||
} | ||
/** | ||
* Clears the asynchronous blur event timeout on demand. See {@link #_blur} to learn more. | ||
*/ | ||
_clearBlurTimeout() { | ||
clearTimeout(this._blurTimeout); | ||
this._blurTimeout = null; | ||
} | ||
} | ||
/** | ||
* Checks whether a view is an instance of {@link ~ViewWithFocusTracker}. | ||
*/ | ||
export function isViewWithFocusTracker(view) { | ||
return 'focusTracker' in view && view.focusTracker instanceof FocusTracker; | ||
} | ||
function isElement(value) { | ||
return _isElement(value); | ||
} | ||
function isExternalViewSubtreeFocused(subTreeRoot, view) { | ||
if (isFocusedView(subTreeRoot, view)) { | ||
return true; | ||
} | ||
return !!view.focusTracker.externalViews.find(view => isFocusedView(subTreeRoot, view)); | ||
} | ||
function isFocusedView(subTreeRoot, view) { | ||
// Note: You cannot depend on externalView.focusTracker.focusedElement because blurs are asynchronous and the value may | ||
// be outdated when moving focus between two elements. Using document.activeElement instead. | ||
return !!view.element && view.element.contains(document.activeElement) && subTreeRoot.contains(view.element); | ||
} | ||
// @if CK_DEBUG_FOCUSTRACKER // declare global { | ||
// @if CK_DEBUG_FOCUSTRACKER // interface Window { | ||
// @if CK_DEBUG_FOCUSTRACKER // logFocusTrackers: Function; | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // function getName( focusTracker: FocusTracker ): string { | ||
// @if CK_DEBUG_FOCUSTRACKER // return focusTracker._label || 'Unknown'; | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // function logState( | ||
// @if CK_DEBUG_FOCUSTRACKER // focusTracker: FocusTracker, | ||
// @if CK_DEBUG_FOCUSTRACKER // keysToLog: Array<string> = [ 'isFocused', 'focusedElement' ] | ||
// @if CK_DEBUG_FOCUSTRACKER // ): string { | ||
// @if CK_DEBUG_FOCUSTRACKER // keysToLog.forEach( key => { console.log( `${ key }=`, focusTracker[ key ] ) } ); | ||
// @if CK_DEBUG_FOCUSTRACKER // console.log( 'elements', focusTracker.elements ); | ||
// @if CK_DEBUG_FOCUSTRACKER // console.log( 'externalViews', focusTracker.externalViews ); | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // window.logFocusTrackers = ( | ||
// @if CK_DEBUG_FOCUSTRACKER // filter = () => true, | ||
// @if CK_DEBUG_FOCUSTRACKER // keysToLog: Array<string> | ||
// @if CK_DEBUG_FOCUSTRACKER // ): void => { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.group( 'FocusTrackers' ); | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // for ( const focusTracker of FocusTracker._instances ) { | ||
// @if CK_DEBUG_FOCUSTRACKER // if ( filter( focusTracker ) ) { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.group( `"${ getName( focusTracker ) }"` ); | ||
// @if CK_DEBUG_FOCUSTRACKER // logState( focusTracker, keysToLog ); | ||
// @if CK_DEBUG_FOCUSTRACKER // console.groupEnd(); | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // console.groupEnd(); | ||
// @if CK_DEBUG_FOCUSTRACKER // }; | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // window.logFocusTrackerTree = ( | ||
// @if CK_DEBUG_FOCUSTRACKER // rootFocusTracker: FocusTracker, | ||
// @if CK_DEBUG_FOCUSTRACKER // filter = () => true, | ||
// @if CK_DEBUG_FOCUSTRACKER // keysToLog: Array<string> | ||
// @if CK_DEBUG_FOCUSTRACKER // ): void => { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.group( 'FocusTrackers tree' ); | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // logBranch( rootFocusTracker, filter ); | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // function logBranch( focusTracker, filter ) { | ||
// @if CK_DEBUG_FOCUSTRACKER // console.group( `"${ getName( focusTracker ) }"` ); | ||
// @if CK_DEBUG_FOCUSTRACKER // logState( focusTracker, keysToLog ); | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // for ( const externalView of focusTracker.externalViews ) { | ||
// @if CK_DEBUG_FOCUSTRACKER // if ( filter( externalView.focusTracker ) ) { | ||
// @if CK_DEBUG_FOCUSTRACKER // logBranch( externalView.focusTracker, filter ); | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // console.groupEnd(); | ||
// @if CK_DEBUG_FOCUSTRACKER // } | ||
// @if CK_DEBUG_FOCUSTRACKER // | ||
// @if CK_DEBUG_FOCUSTRACKER // console.groupEnd(); | ||
// @if CK_DEBUG_FOCUSTRACKER // }; |
@@ -52,3 +52,3 @@ /** | ||
export { default as first } from './first.js'; | ||
export { default as FocusTracker } from './focustracker.js'; | ||
export { default as FocusTracker, type ViewWithFocusTracker, isViewWithFocusTracker } from './focustracker.js'; | ||
export { default as KeystrokeHandler, type KeystrokeHandlerOptions } from './keystrokehandler.js'; | ||
@@ -55,0 +55,0 @@ export { default as toArray, type ArrayOrItem, type ReadonlyArrayOrItem } from './toarray.js'; |
@@ -51,3 +51,3 @@ /** | ||
export { default as first } from './first.js'; | ||
export { default as FocusTracker } from './focustracker.js'; | ||
export { default as FocusTracker, isViewWithFocusTracker } from './focustracker.js'; | ||
export { default as KeystrokeHandler } from './keystrokehandler.js'; | ||
@@ -54,0 +54,0 @@ export { default as toArray } from './toarray.js'; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
declare const version = "43.2.0"; | ||
declare const version = "43.3.0-alpha.0"; | ||
export default version; | ||
@@ -8,0 +8,0 @@ export declare const releaseDate: Date; |
@@ -9,6 +9,6 @@ /** | ||
import CKEditorError from './ckeditorerror.js'; | ||
const version = '43.2.0'; | ||
const version = '43.3.0-alpha.0'; | ||
export default version; | ||
// The second argument is not a month. It is `monthIndex` and starts from `0`. | ||
export const releaseDate = new Date(2024, 9, 2); | ||
export const releaseDate = new Date(2024, 9, 24); | ||
/* istanbul ignore next -- @preserve */ | ||
@@ -15,0 +15,0 @@ if (globalThis.CKEDITOR_VERSION) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2106199
21757
2
1
+ Added@ckeditor/ckeditor5-core@43.3.0-alpha.0(transitive)
+ Added@ckeditor/ckeditor5-engine@43.3.0-alpha.0(transitive)
+ Added@ckeditor/ckeditor5-ui@43.3.0-alpha.0(transitive)
+ Added@ckeditor/ckeditor5-watchdog@43.3.0-alpha.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcolor-parse@1.4.2(transitive)
+ Addedvanilla-colorful@0.7.2(transitive)