@ckeditor/ckeditor5-utils 0.0.0-internal-20241017.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/CHANGELOG.md +4 -0
- package/LICENSE.md +21 -0
- package/README.md +22 -0
- package/dist/abortabledebounce.d.ts +21 -0
- package/dist/areconnectedthroughproperties.d.ts +15 -0
- package/dist/ckeditorerror.d.ts +127 -0
- package/dist/collection.d.ts +437 -0
- package/dist/comparearrays.d.ts +34 -0
- package/dist/config.d.ts +167 -0
- package/dist/count.d.ts +22 -0
- package/dist/crc32.d.ts +30 -0
- package/dist/delay.d.ts +23 -0
- package/dist/diff.d.ts +35 -0
- package/dist/difftochanges.d.ts +63 -0
- package/dist/dom/createelement.d.ts +61 -0
- package/dist/dom/emittermixin.d.ts +146 -0
- package/dist/dom/findclosestscrollableancestor.d.ts +15 -0
- package/dist/dom/getancestors.d.ts +21 -0
- package/dist/dom/getborderwidths.d.ts +28 -0
- package/dist/dom/getcommonancestor.d.ts +16 -0
- package/dist/dom/getdatafromelement.d.ts +18 -0
- package/dist/dom/getpositionedancestor.d.ts +14 -0
- package/dist/dom/getrangefrommouseevent.d.ts +21 -0
- package/dist/dom/global.d.ts +36 -0
- package/dist/dom/indexof.d.ts +18 -0
- package/dist/dom/insertat.d.ts +19 -0
- package/dist/dom/iscomment.d.ts +15 -0
- package/dist/dom/isnode.d.ts +15 -0
- package/dist/dom/isrange.d.ts +15 -0
- package/dist/dom/istext.d.ts +15 -0
- package/dist/dom/isvalidattributename.d.ts +14 -0
- package/dist/dom/isvisible.d.ts +19 -0
- package/dist/dom/iswindow.d.ts +15 -0
- package/dist/dom/position.d.ts +215 -0
- package/dist/dom/rect.d.ts +199 -0
- package/dist/dom/remove.d.ts +17 -0
- package/dist/dom/resizeobserver.d.ts +78 -0
- package/dist/dom/scroll.d.ts +77 -0
- package/dist/dom/setdatainelement.d.ts +18 -0
- package/dist/dom/tounit.d.ts +26 -0
- package/dist/elementreplacer.d.ts +35 -0
- package/dist/emittermixin.d.ts +316 -0
- package/dist/env.d.ts +144 -0
- package/dist/eventinfo.d.ts +62 -0
- package/dist/fastdiff.d.ts +116 -0
- package/dist/first.d.ts +15 -0
- package/dist/focustracker.d.ts +83 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +4 -0
- package/dist/index.css +4 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +5871 -0
- package/dist/index.js.map +1 -0
- package/dist/inserttopriorityarray.d.ts +34 -0
- package/dist/isiterable.d.ts +18 -0
- package/dist/keyboard.d.ts +130 -0
- package/dist/keystrokehandler.d.ts +101 -0
- package/dist/language.d.ts +21 -0
- package/dist/locale.d.ts +145 -0
- package/dist/mapsequal.d.ts +19 -0
- package/dist/mix.d.ts +89 -0
- package/dist/nth.d.ts +20 -0
- package/dist/objecttomap.d.ts +27 -0
- package/dist/observablemixin.d.ts +564 -0
- package/dist/parsebase64encodedobject.d.ts +15 -0
- package/dist/priorities.d.ts +37 -0
- package/dist/retry.d.ts +37 -0
- package/dist/splicearray.d.ts +30 -0
- package/dist/spy.d.ts +25 -0
- package/dist/toarray.d.ts +29 -0
- package/dist/tomap.d.ts +23 -0
- package/dist/translation-service.d.ts +178 -0
- package/dist/uid.d.ts +19 -0
- package/dist/unicode.d.ts +58 -0
- package/dist/version.d.ts +14 -0
- package/dist/wait.d.ts +20 -0
- package/package.json +36 -0
- package/src/abortabledebounce.d.ts +17 -0
- package/src/abortabledebounce.js +22 -0
- package/src/areconnectedthroughproperties.d.ts +11 -0
- package/src/areconnectedthroughproperties.js +73 -0
- package/src/ckeditorerror.d.ts +123 -0
- package/src/ckeditorerror.js +176 -0
- package/src/collection.d.ts +433 -0
- package/src/collection.js +583 -0
- package/src/comparearrays.d.ts +30 -0
- package/src/comparearrays.js +47 -0
- package/src/config.d.ts +163 -0
- package/src/config.js +163 -0
- package/src/count.d.ts +18 -0
- package/src/count.js +25 -0
- package/src/crc32.d.ts +26 -0
- package/src/crc32.js +61 -0
- package/src/delay.d.ts +19 -0
- package/src/delay.js +26 -0
- package/src/diff.d.ts +31 -0
- package/src/diff.js +115 -0
- package/src/difftochanges.d.ts +59 -0
- package/src/difftochanges.js +79 -0
- package/src/dom/createelement.d.ts +57 -0
- package/src/dom/createelement.js +40 -0
- package/src/dom/emittermixin.d.ts +142 -0
- package/src/dom/emittermixin.js +239 -0
- package/src/dom/findclosestscrollableancestor.d.ts +11 -0
- package/src/dom/findclosestscrollableancestor.js +31 -0
- package/src/dom/getancestors.d.ts +17 -0
- package/src/dom/getancestors.js +27 -0
- package/src/dom/getborderwidths.d.ts +24 -0
- package/src/dom/getborderwidths.js +24 -0
- package/src/dom/getcommonancestor.d.ts +12 -0
- package/src/dom/getcommonancestor.js +25 -0
- package/src/dom/getdatafromelement.d.ts +14 -0
- package/src/dom/getdatafromelement.js +20 -0
- package/src/dom/getpositionedancestor.d.ts +10 -0
- package/src/dom/getpositionedancestor.js +22 -0
- package/src/dom/getrangefrommouseevent.d.ts +17 -0
- package/src/dom/getrangefrommouseevent.js +33 -0
- package/src/dom/global.d.ts +32 -0
- package/src/dom/global.js +35 -0
- package/src/dom/indexof.d.ts +14 -0
- package/src/dom/indexof.js +21 -0
- package/src/dom/insertat.d.ts +15 -0
- package/src/dom/insertat.js +17 -0
- package/src/dom/iscomment.d.ts +11 -0
- package/src/dom/iscomment.js +14 -0
- package/src/dom/isnode.d.ts +11 -0
- package/src/dom/isnode.js +21 -0
- package/src/dom/isrange.d.ts +11 -0
- package/src/dom/isrange.js +13 -0
- package/src/dom/istext.d.ts +11 -0
- package/src/dom/istext.js +13 -0
- package/src/dom/isvalidattributename.d.ts +10 -0
- package/src/dom/isvalidattributename.js +22 -0
- package/src/dom/isvisible.d.ts +15 -0
- package/src/dom/isvisible.js +30 -0
- package/src/dom/iswindow.d.ts +11 -0
- package/src/dom/iswindow.js +22 -0
- package/src/dom/position.d.ts +211 -0
- package/src/dom/position.js +313 -0
- package/src/dom/rect.d.ts +195 -0
- package/src/dom/rect.js +474 -0
- package/src/dom/remove.d.ts +13 -0
- package/src/dom/remove.js +18 -0
- package/src/dom/resizeobserver.d.ts +74 -0
- package/src/dom/resizeobserver.js +127 -0
- package/src/dom/scroll.d.ts +73 -0
- package/src/dom/scroll.js +383 -0
- package/src/dom/setdatainelement.d.ts +14 -0
- package/src/dom/setdatainelement.js +20 -0
- package/src/dom/tounit.d.ts +22 -0
- package/src/dom/tounit.js +16 -0
- package/src/elementreplacer.d.ts +31 -0
- package/src/elementreplacer.js +43 -0
- package/src/emittermixin.d.ts +312 -0
- package/src/emittermixin.js +453 -0
- package/src/env.d.ts +140 -0
- package/src/env.js +145 -0
- package/src/eventinfo.d.ts +58 -0
- package/src/eventinfo.js +26 -0
- package/src/fastdiff.d.ts +112 -0
- package/src/fastdiff.js +248 -0
- package/src/first.d.ts +11 -0
- package/src/first.js +17 -0
- package/src/focustracker.d.ts +79 -0
- package/src/focustracker.js +101 -0
- package/src/index.d.ts +66 -0
- package/src/index.js +65 -0
- package/src/inserttopriorityarray.d.ts +30 -0
- package/src/inserttopriorityarray.js +21 -0
- package/src/isiterable.d.ts +14 -0
- package/src/isiterable.js +16 -0
- package/src/keyboard.d.ts +126 -0
- package/src/keyboard.js +252 -0
- package/src/keystrokehandler.d.ts +97 -0
- package/src/keystrokehandler.js +122 -0
- package/src/language.d.ts +17 -0
- package/src/language.js +20 -0
- package/src/locale.d.ts +141 -0
- package/src/locale.js +78 -0
- package/src/mapsequal.d.ts +15 -0
- package/src/mapsequal.js +27 -0
- package/src/mix.d.ts +85 -0
- package/src/mix.js +50 -0
- package/src/nth.d.ts +16 -0
- package/src/nth.js +24 -0
- package/src/objecttomap.d.ts +23 -0
- package/src/objecttomap.js +27 -0
- package/src/observablemixin.d.ts +560 -0
- package/src/observablemixin.js +580 -0
- package/src/parsebase64encodedobject.d.ts +11 -0
- package/src/parsebase64encodedobject.js +22 -0
- package/src/priorities.d.ts +33 -0
- package/src/priorities.js +23 -0
- package/src/retry.d.ts +33 -0
- package/src/retry.js +47 -0
- package/src/splicearray.d.ts +26 -0
- package/src/splicearray.js +40 -0
- package/src/spy.d.ts +21 -0
- package/src/spy.js +22 -0
- package/src/toarray.d.ts +25 -0
- package/src/toarray.js +7 -0
- package/src/tomap.d.ts +19 -0
- package/src/tomap.js +29 -0
- package/src/translation-service.d.ts +174 -0
- package/src/translation-service.js +209 -0
- package/src/uid.d.ts +15 -0
- package/src/uid.js +45 -0
- package/src/unicode.d.ts +54 -0
- package/src/unicode.js +85 -0
- package/src/version.d.ts +10 -0
- package/src/version.js +179 -0
- package/src/wait.d.ts +16 -0
- package/src/wait.js +29 -0
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
declare const FocusTracker_base: import("./mix.js").Mixed<{
|
|
6
|
+
new (): import("./observablemixin.js").Observable;
|
|
7
|
+
prototype: import("./observablemixin.js").Observable;
|
|
8
|
+
}, import("./dom/emittermixin.js").DomEmitter>;
|
|
9
|
+
/**
|
|
10
|
+
* Allows observing a group of `Element`s whether at least one of them is focused.
|
|
11
|
+
*
|
|
12
|
+
* Used by the {@link module:core/editor/editor~Editor} in order to track whether the focus is still within the application,
|
|
13
|
+
* or were used outside of its UI.
|
|
14
|
+
*
|
|
15
|
+
* **Note** `focus` and `blur` listeners use event capturing, so it is only needed to register wrapper `Element`
|
|
16
|
+
* which contain other `focusable` elements. But note that this wrapper element has to be focusable too
|
|
17
|
+
* (have e.g. `tabindex="-1"`).
|
|
18
|
+
*
|
|
19
|
+
* Check out the {@glink framework/deep-dive/ui/focus-tracking "Deep dive into focus tracking"} guide to learn more.
|
|
20
|
+
*/
|
|
21
|
+
export default class FocusTracker extends /* #__PURE__ */ FocusTracker_base {
|
|
22
|
+
/**
|
|
23
|
+
* True when one of the registered elements is focused.
|
|
24
|
+
*
|
|
25
|
+
* @readonly
|
|
26
|
+
* @observable
|
|
27
|
+
*/
|
|
28
|
+
isFocused: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The currently focused element.
|
|
31
|
+
*
|
|
32
|
+
* While {@link #isFocused `isFocused`} remains `true`, the focus can
|
|
33
|
+
* move between different UI elements. This property tracks those
|
|
34
|
+
* elements and tells which one is currently focused.
|
|
35
|
+
*
|
|
36
|
+
* @readonly
|
|
37
|
+
* @observable
|
|
38
|
+
*/
|
|
39
|
+
focusedElement: Element | null;
|
|
40
|
+
/**
|
|
41
|
+
* List of registered elements.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
_elements: Set<Element>;
|
|
46
|
+
/**
|
|
47
|
+
* Event loop timeout.
|
|
48
|
+
*/
|
|
49
|
+
private _nextEventLoopTimeout;
|
|
50
|
+
constructor();
|
|
51
|
+
/**
|
|
52
|
+
* List of registered elements.
|
|
53
|
+
*/
|
|
54
|
+
get elements(): Array<Element>;
|
|
55
|
+
/**
|
|
56
|
+
* Starts tracking the specified element.
|
|
57
|
+
*/
|
|
58
|
+
add(element: Element): void;
|
|
59
|
+
/**
|
|
60
|
+
* Stops tracking the specified element and stops listening on this element.
|
|
61
|
+
*/
|
|
62
|
+
remove(element: Element): void;
|
|
63
|
+
/**
|
|
64
|
+
* Destroys the focus tracker by:
|
|
65
|
+
* - Disabling all event listeners attached to tracked elements.
|
|
66
|
+
* - Removing all tracked elements that were previously added.
|
|
67
|
+
*/
|
|
68
|
+
destroy(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Stores currently focused element and set {@link #isFocused} as `true`.
|
|
71
|
+
*/
|
|
72
|
+
private _focus;
|
|
73
|
+
/**
|
|
74
|
+
* Clears currently focused element and set {@link #isFocused} as `false`.
|
|
75
|
+
* This method uses `setTimeout` to change order of fires `blur` and `focus` events.
|
|
76
|
+
*/
|
|
77
|
+
private _blur;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
/* global setTimeout, clearTimeout */
|
|
6
|
+
/**
|
|
7
|
+
* @module utils/focustracker
|
|
8
|
+
*/
|
|
9
|
+
import DomEmitterMixin from './dom/emittermixin.js';
|
|
10
|
+
import ObservableMixin from './observablemixin.js';
|
|
11
|
+
import CKEditorError from './ckeditorerror.js';
|
|
12
|
+
/**
|
|
13
|
+
* Allows observing a group of `Element`s whether at least one of them is focused.
|
|
14
|
+
*
|
|
15
|
+
* Used by the {@link module:core/editor/editor~Editor} in order to track whether the focus is still within the application,
|
|
16
|
+
* or were used outside of its UI.
|
|
17
|
+
*
|
|
18
|
+
* **Note** `focus` and `blur` listeners use event capturing, so it is only needed to register wrapper `Element`
|
|
19
|
+
* which contain other `focusable` elements. But note that this wrapper element has to be focusable too
|
|
20
|
+
* (have e.g. `tabindex="-1"`).
|
|
21
|
+
*
|
|
22
|
+
* Check out the {@glink framework/deep-dive/ui/focus-tracking "Deep dive into focus tracking"} guide to learn more.
|
|
23
|
+
*/
|
|
24
|
+
export default class FocusTracker extends /* #__PURE__ */ DomEmitterMixin(/* #__PURE__ */ ObservableMixin()) {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
/**
|
|
28
|
+
* List of registered elements.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
this._elements = new Set();
|
|
33
|
+
/**
|
|
34
|
+
* Event loop timeout.
|
|
35
|
+
*/
|
|
36
|
+
this._nextEventLoopTimeout = null;
|
|
37
|
+
this.set('isFocused', false);
|
|
38
|
+
this.set('focusedElement', null);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* List of registered elements.
|
|
42
|
+
*/
|
|
43
|
+
get elements() {
|
|
44
|
+
return Array.from(this._elements.values());
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Starts tracking the specified element.
|
|
48
|
+
*/
|
|
49
|
+
add(element) {
|
|
50
|
+
if (this._elements.has(element)) {
|
|
51
|
+
/**
|
|
52
|
+
* This element is already tracked by {@link module:utils/focustracker~FocusTracker}.
|
|
53
|
+
*
|
|
54
|
+
* @error focustracker-add-element-already-exist
|
|
55
|
+
*/
|
|
56
|
+
throw new CKEditorError('focustracker-add-element-already-exist', this);
|
|
57
|
+
}
|
|
58
|
+
this.listenTo(element, 'focus', () => this._focus(element), { useCapture: true });
|
|
59
|
+
this.listenTo(element, 'blur', () => this._blur(), { useCapture: true });
|
|
60
|
+
this._elements.add(element);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Stops tracking the specified element and stops listening on this element.
|
|
64
|
+
*/
|
|
65
|
+
remove(element) {
|
|
66
|
+
if (element === this.focusedElement) {
|
|
67
|
+
this._blur();
|
|
68
|
+
}
|
|
69
|
+
if (this._elements.has(element)) {
|
|
70
|
+
this.stopListening(element);
|
|
71
|
+
this._elements.delete(element);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Destroys the focus tracker by:
|
|
76
|
+
* - Disabling all event listeners attached to tracked elements.
|
|
77
|
+
* - Removing all tracked elements that were previously added.
|
|
78
|
+
*/
|
|
79
|
+
destroy() {
|
|
80
|
+
this.stopListening();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Stores currently focused element and set {@link #isFocused} as `true`.
|
|
84
|
+
*/
|
|
85
|
+
_focus(element) {
|
|
86
|
+
clearTimeout(this._nextEventLoopTimeout);
|
|
87
|
+
this.focusedElement = element;
|
|
88
|
+
this.isFocused = true;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clears currently focused element and set {@link #isFocused} as `false`.
|
|
92
|
+
* This method uses `setTimeout` to change order of fires `blur` and `focus` events.
|
|
93
|
+
*/
|
|
94
|
+
_blur() {
|
|
95
|
+
clearTimeout(this._nextEventLoopTimeout);
|
|
96
|
+
this._nextEventLoopTimeout = setTimeout(() => {
|
|
97
|
+
this.focusedElement = null;
|
|
98
|
+
this.isFocused = false;
|
|
99
|
+
}, 0);
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
* @module utils
|
|
7
|
+
*/
|
|
8
|
+
export { default as env } from './env.js';
|
|
9
|
+
export { default as diff, type DiffResult } from './diff.js';
|
|
10
|
+
export { default as fastDiff } from './fastdiff.js';
|
|
11
|
+
export { default as diffToChanges } from './difftochanges.js';
|
|
12
|
+
export { default as mix } from './mix.js';
|
|
13
|
+
export type { Constructor, Mixed } from './mix.js';
|
|
14
|
+
export { default as EmitterMixin, type Emitter, type BaseEvent, type CallbackOptions, type EmitterMixinDelegateChain, type GetCallback, type GetCallbackOptions, type GetEventInfo, type GetNameOrEventInfo } from './emittermixin.js';
|
|
15
|
+
export { default as EventInfo } from './eventinfo.js';
|
|
16
|
+
export { default as ObservableMixin, type Observable, type DecoratedMethodEvent, type ObservableChangeEvent, type ObservableSetEvent } from './observablemixin.js';
|
|
17
|
+
export { default as CKEditorError, logError, logWarning } from './ckeditorerror.js';
|
|
18
|
+
export { default as ElementReplacer } from './elementreplacer.js';
|
|
19
|
+
export { default as abortableDebounce, type AbortableFunc } from './abortabledebounce.js';
|
|
20
|
+
export { default as count } from './count.js';
|
|
21
|
+
export { default as compareArrays } from './comparearrays.js';
|
|
22
|
+
export { default as createElement } from './dom/createelement.js';
|
|
23
|
+
export { default as Config } from './config.js';
|
|
24
|
+
export { default as isIterable } from './isiterable.js';
|
|
25
|
+
export { default as DomEmitterMixin, type DomEmitter } from './dom/emittermixin.js';
|
|
26
|
+
export { default as findClosestScrollableAncestor } from './dom/findclosestscrollableancestor.js';
|
|
27
|
+
export { default as global } from './dom/global.js';
|
|
28
|
+
export { default as getAncestors } from './dom/getancestors.js';
|
|
29
|
+
export { default as getDataFromElement } from './dom/getdatafromelement.js';
|
|
30
|
+
export { default as getBorderWidths } from './dom/getborderwidths.js';
|
|
31
|
+
export { default as getRangeFromMouseEvent } from './dom/getrangefrommouseevent.js';
|
|
32
|
+
export { default as isText } from './dom/istext.js';
|
|
33
|
+
export { default as Rect, type RectSource } from './dom/rect.js';
|
|
34
|
+
export { default as ResizeObserver } from './dom/resizeobserver.js';
|
|
35
|
+
export { default as setDataInElement } from './dom/setdatainelement.js';
|
|
36
|
+
export { default as toUnit } from './dom/tounit.js';
|
|
37
|
+
export { default as indexOf } from './dom/indexof.js';
|
|
38
|
+
export { default as insertAt } from './dom/insertat.js';
|
|
39
|
+
export { default as isComment } from './dom/iscomment.js';
|
|
40
|
+
export { default as isNode } from './dom/isnode.js';
|
|
41
|
+
export { default as isRange } from './dom/isrange.js';
|
|
42
|
+
export { default as isValidAttributeName } from './dom/isvalidattributename.js';
|
|
43
|
+
export { default as isVisible } from './dom/isvisible.js';
|
|
44
|
+
export { getOptimalPosition, type Options as PositionOptions, type PositioningFunction, type DomPoint } from './dom/position.js';
|
|
45
|
+
export { default as remove } from './dom/remove.js';
|
|
46
|
+
export * from './dom/scroll.js';
|
|
47
|
+
export * from './keyboard.js';
|
|
48
|
+
export * from './language.js';
|
|
49
|
+
export { default as Locale, type LocaleTranslate, type Translations } from './locale.js';
|
|
50
|
+
export { default as Collection, type CollectionAddEvent, type CollectionChangeEvent, type CollectionRemoveEvent } from './collection.js';
|
|
51
|
+
export { default as first } from './first.js';
|
|
52
|
+
export { default as FocusTracker } from './focustracker.js';
|
|
53
|
+
export { default as KeystrokeHandler, type KeystrokeHandlerOptions } from './keystrokehandler.js';
|
|
54
|
+
export { default as toArray, type ArrayOrItem, type ReadonlyArrayOrItem } from './toarray.js';
|
|
55
|
+
export { default as toMap } from './tomap.js';
|
|
56
|
+
export { default as priorities, type PriorityString } from './priorities.js';
|
|
57
|
+
export { default as retry, exponentialDelay } from './retry.js';
|
|
58
|
+
export { default as insertToPriorityArray } from './inserttopriorityarray.js';
|
|
59
|
+
export { default as spliceArray } from './splicearray.js';
|
|
60
|
+
export { default as uid } from './uid.js';
|
|
61
|
+
export { default as delay, type DelayedFunc } from './delay.js';
|
|
62
|
+
export { default as wait } from './wait.js';
|
|
63
|
+
export { default as parseBase64EncodedObject } from './parsebase64encodedobject.js';
|
|
64
|
+
export { default as crc32, type CRCData } from './crc32.js';
|
|
65
|
+
export * from './unicode.js';
|
|
66
|
+
export { default as version, releaseDate } from './version.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
* @module utils
|
|
7
|
+
*/
|
|
8
|
+
export { default as env } from './env.js';
|
|
9
|
+
export { default as diff } from './diff.js';
|
|
10
|
+
export { default as fastDiff } from './fastdiff.js';
|
|
11
|
+
export { default as diffToChanges } from './difftochanges.js';
|
|
12
|
+
export { default as mix } from './mix.js';
|
|
13
|
+
export { default as EmitterMixin } from './emittermixin.js';
|
|
14
|
+
export { default as EventInfo } from './eventinfo.js';
|
|
15
|
+
export { default as ObservableMixin } from './observablemixin.js';
|
|
16
|
+
export { default as CKEditorError, logError, logWarning } from './ckeditorerror.js';
|
|
17
|
+
export { default as ElementReplacer } from './elementreplacer.js';
|
|
18
|
+
export { default as abortableDebounce } from './abortabledebounce.js';
|
|
19
|
+
export { default as count } from './count.js';
|
|
20
|
+
export { default as compareArrays } from './comparearrays.js';
|
|
21
|
+
export { default as createElement } from './dom/createelement.js';
|
|
22
|
+
export { default as Config } from './config.js';
|
|
23
|
+
export { default as isIterable } from './isiterable.js';
|
|
24
|
+
export { default as DomEmitterMixin } from './dom/emittermixin.js';
|
|
25
|
+
export { default as findClosestScrollableAncestor } from './dom/findclosestscrollableancestor.js';
|
|
26
|
+
export { default as global } from './dom/global.js';
|
|
27
|
+
export { default as getAncestors } from './dom/getancestors.js';
|
|
28
|
+
export { default as getDataFromElement } from './dom/getdatafromelement.js';
|
|
29
|
+
export { default as getBorderWidths } from './dom/getborderwidths.js';
|
|
30
|
+
export { default as getRangeFromMouseEvent } from './dom/getrangefrommouseevent.js';
|
|
31
|
+
export { default as isText } from './dom/istext.js';
|
|
32
|
+
export { default as Rect } from './dom/rect.js';
|
|
33
|
+
export { default as ResizeObserver } from './dom/resizeobserver.js';
|
|
34
|
+
export { default as setDataInElement } from './dom/setdatainelement.js';
|
|
35
|
+
export { default as toUnit } from './dom/tounit.js';
|
|
36
|
+
export { default as indexOf } from './dom/indexof.js';
|
|
37
|
+
export { default as insertAt } from './dom/insertat.js';
|
|
38
|
+
export { default as isComment } from './dom/iscomment.js';
|
|
39
|
+
export { default as isNode } from './dom/isnode.js';
|
|
40
|
+
export { default as isRange } from './dom/isrange.js';
|
|
41
|
+
export { default as isValidAttributeName } from './dom/isvalidattributename.js';
|
|
42
|
+
export { default as isVisible } from './dom/isvisible.js';
|
|
43
|
+
export { getOptimalPosition } from './dom/position.js';
|
|
44
|
+
export { default as remove } from './dom/remove.js';
|
|
45
|
+
export * from './dom/scroll.js';
|
|
46
|
+
export * from './keyboard.js';
|
|
47
|
+
export * from './language.js';
|
|
48
|
+
export { default as Locale } from './locale.js';
|
|
49
|
+
export { default as Collection } from './collection.js';
|
|
50
|
+
export { default as first } from './first.js';
|
|
51
|
+
export { default as FocusTracker } from './focustracker.js';
|
|
52
|
+
export { default as KeystrokeHandler } from './keystrokehandler.js';
|
|
53
|
+
export { default as toArray } from './toarray.js';
|
|
54
|
+
export { default as toMap } from './tomap.js';
|
|
55
|
+
export { default as priorities } from './priorities.js';
|
|
56
|
+
export { default as retry, exponentialDelay } from './retry.js';
|
|
57
|
+
export { default as insertToPriorityArray } from './inserttopriorityarray.js';
|
|
58
|
+
export { default as spliceArray } from './splicearray.js';
|
|
59
|
+
export { default as uid } from './uid.js';
|
|
60
|
+
export { default as delay } from './delay.js';
|
|
61
|
+
export { default as wait } from './wait.js';
|
|
62
|
+
export { default as parseBase64EncodedObject } from './parsebase64encodedobject.js';
|
|
63
|
+
export { default as crc32 } from './crc32.js';
|
|
64
|
+
export * from './unicode.js';
|
|
65
|
+
export { default as version, releaseDate } from './version.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
import { type PriorityString } from './priorities.js';
|
|
6
|
+
/**
|
|
7
|
+
* @module utils/inserttopriorityarray
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The priority object descriptor.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const objectWithPriority = {
|
|
14
|
+
* priority: 'high'
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface ObjectWithPriority {
|
|
19
|
+
/**
|
|
20
|
+
* Priority of the object.
|
|
21
|
+
*/
|
|
22
|
+
priority: PriorityString;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Inserts any object with priority at correct index by priority so registered objects are always sorted from highest to lowest priority.
|
|
26
|
+
*
|
|
27
|
+
* @param objects Array of objects with priority to insert object to.
|
|
28
|
+
* @param objectToInsert Object with `priority` property.
|
|
29
|
+
*/
|
|
30
|
+
export default function insertToPriorityArray<T extends ObjectWithPriority>(objects: Array<T>, objectToInsert: T): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
import priorities from './priorities.js';
|
|
6
|
+
/**
|
|
7
|
+
* Inserts any object with priority at correct index by priority so registered objects are always sorted from highest to lowest priority.
|
|
8
|
+
*
|
|
9
|
+
* @param objects Array of objects with priority to insert object to.
|
|
10
|
+
* @param objectToInsert Object with `priority` property.
|
|
11
|
+
*/
|
|
12
|
+
export default function insertToPriorityArray(objects, objectToInsert) {
|
|
13
|
+
const priority = priorities.get(objectToInsert.priority);
|
|
14
|
+
for (let i = 0; i < objects.length; i++) {
|
|
15
|
+
if (priorities.get(objects[i].priority) < priority) {
|
|
16
|
+
objects.splice(i, 0, objectToInsert);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
objects.push(objectToInsert);
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
* @module utils/isiterable
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Checks if value implements iterator interface.
|
|
10
|
+
*
|
|
11
|
+
* @param value The value to check.
|
|
12
|
+
* @returns True if value implements iterator interface.
|
|
13
|
+
*/
|
|
14
|
+
export default function isIterable(value: any): value is Iterable<any>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
* @module utils/isiterable
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Checks if value implements iterator interface.
|
|
10
|
+
*
|
|
11
|
+
* @param value The value to check.
|
|
12
|
+
* @returns True if value implements iterator interface.
|
|
13
|
+
*/
|
|
14
|
+
export default function isIterable(value) {
|
|
15
|
+
return !!(value && value[Symbol.iterator]);
|
|
16
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
* A set of utilities related to keyboard support.
|
|
7
|
+
*
|
|
8
|
+
* @module utils/keyboard
|
|
9
|
+
*/
|
|
10
|
+
import type { LanguageDirection } from './language.js';
|
|
11
|
+
/**
|
|
12
|
+
* An object with `keyName => keyCode` pairs for a set of known keys.
|
|
13
|
+
*
|
|
14
|
+
* Contains:
|
|
15
|
+
*
|
|
16
|
+
* * `a-z`,
|
|
17
|
+
* * `0-9`,
|
|
18
|
+
* * `f1-f12`,
|
|
19
|
+
* * `` ` ``, `-`, `=`, `[`, `]`, `;`, `'`, `,`, `.`, `/`, `\`,
|
|
20
|
+
* * `arrow(left|up|right|bottom)`,
|
|
21
|
+
* * `backspace`, `delete`, `enter`, `esc`, `tab`,
|
|
22
|
+
* * `ctrl`, `cmd`, `shift`, `alt`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const keyCodes: {
|
|
25
|
+
readonly [keyCode: string]: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Converts a key name or {@link module:utils/keyboard~KeystrokeInfo keystroke info} into a key code.
|
|
29
|
+
*
|
|
30
|
+
* Note: Key names are matched with {@link module:utils/keyboard#keyCodes} in a case-insensitive way.
|
|
31
|
+
*
|
|
32
|
+
* @param key A key name (see {@link module:utils/keyboard#keyCodes}) or a keystroke data object.
|
|
33
|
+
* @returns Key or keystroke code.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCode(key: string | Readonly<KeystrokeInfo>): number;
|
|
36
|
+
/**
|
|
37
|
+
* Parses the keystroke and returns a keystroke code that will match the code returned by
|
|
38
|
+
* {@link module:utils/keyboard~getCode} for the corresponding {@link module:utils/keyboard~KeystrokeInfo keystroke info}.
|
|
39
|
+
*
|
|
40
|
+
* The keystroke can be passed in two formats:
|
|
41
|
+
*
|
|
42
|
+
* * as a single string – e.g. `ctrl + A`,
|
|
43
|
+
* * as an array of {@link module:utils/keyboard~keyCodes known key names} and key codes – e.g.:
|
|
44
|
+
* * `[ 'ctrl', 32 ]` (ctrl + space),
|
|
45
|
+
* * `[ 'ctrl', 'a' ]` (ctrl + A).
|
|
46
|
+
*
|
|
47
|
+
* Note: Key names are matched with {@link module:utils/keyboard#keyCodes} in a case-insensitive way.
|
|
48
|
+
*
|
|
49
|
+
* Note: Only keystrokes with a single non-modifier key are supported (e.g. `ctrl+A` is OK, but `ctrl+A+B` is not).
|
|
50
|
+
*
|
|
51
|
+
* Note: On macOS, keystroke handling is translating the `Ctrl` key to the `Cmd` key and handling only that keystroke.
|
|
52
|
+
* For example, a registered keystroke `Ctrl+A` will be translated to `Cmd+A` on macOS. To disable the translation of some keystroke,
|
|
53
|
+
* use the forced modifier: `Ctrl!+A` (note the exclamation mark).
|
|
54
|
+
*
|
|
55
|
+
* @param keystroke The keystroke definition.
|
|
56
|
+
* @returns Keystroke code.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseKeystroke(keystroke: string | ReadonlyArray<number | string>): number;
|
|
59
|
+
/**
|
|
60
|
+
* Translates any keystroke string text like `"Ctrl+A"` to an
|
|
61
|
+
* environment–specific keystroke, i.e. `"⌘A"` on macOS.
|
|
62
|
+
*
|
|
63
|
+
* @param keystroke The keystroke text.
|
|
64
|
+
* @returns The keystroke text specific for the environment.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getEnvKeystrokeText(keystroke: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Returns `true` if the provided key code represents one of the arrow keys.
|
|
69
|
+
*
|
|
70
|
+
* @param keyCode A key code as in {@link module:utils/keyboard~KeystrokeInfo#keyCode}.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isArrowKeyCode(keyCode: number): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* String representing a direction of an arrow key kode.
|
|
75
|
+
*/
|
|
76
|
+
export type ArrowKeyCodeDirection = 'left' | 'up' | 'right' | 'down';
|
|
77
|
+
/**
|
|
78
|
+
* Returns the direction in which the {@link module:engine/model/documentselection~DocumentSelection selection}
|
|
79
|
+
* will move when the provided arrow key code is pressed considering the language direction of the editor content.
|
|
80
|
+
*
|
|
81
|
+
* For instance, in right–to–left (RTL) content languages, pressing the left arrow means moving the selection right (forward)
|
|
82
|
+
* in the model structure. Similarly, pressing the right arrow moves the selection left (backward).
|
|
83
|
+
*
|
|
84
|
+
* @param keyCode A key code as in {@link module:utils/keyboard~KeystrokeInfo#keyCode}.
|
|
85
|
+
* @param contentLanguageDirection The content language direction, corresponding to
|
|
86
|
+
* {@link module:utils/locale~Locale#contentLanguageDirection}.
|
|
87
|
+
* @returns Localized arrow direction or `undefined` for non-arrow key codes.
|
|
88
|
+
*/
|
|
89
|
+
export declare function getLocalizedArrowKeyCodeDirection(keyCode: number, contentLanguageDirection: LanguageDirection): ArrowKeyCodeDirection | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Determines if the provided key code moves the {@link module:engine/model/documentselection~DocumentSelection selection}
|
|
92
|
+
* forward or backward considering the language direction of the editor content.
|
|
93
|
+
*
|
|
94
|
+
* For instance, in right–to–left (RTL) languages, pressing the left arrow means moving forward
|
|
95
|
+
* in the model structure. Similarly, pressing the right arrow moves the selection backward.
|
|
96
|
+
*
|
|
97
|
+
* @param keyCode A key code as in {@link module:utils/keyboard~KeystrokeInfo#keyCode}.
|
|
98
|
+
* @param contentLanguageDirection The content language direction, corresponding to
|
|
99
|
+
* {@link module:utils/locale~Locale#contentLanguageDirection}.
|
|
100
|
+
*/
|
|
101
|
+
export declare function isForwardArrowKeyCode(keyCode: number, contentLanguageDirection: LanguageDirection): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Information about the keystroke.
|
|
104
|
+
*/
|
|
105
|
+
export interface KeystrokeInfo {
|
|
106
|
+
/**
|
|
107
|
+
* The [key code](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode).
|
|
108
|
+
*/
|
|
109
|
+
keyCode: number;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the <kbd>Alt</kbd> modifier was pressed.
|
|
112
|
+
*/
|
|
113
|
+
altKey: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the <kbd>Cmd</kbd> modifier was pressed.
|
|
116
|
+
*/
|
|
117
|
+
metaKey: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Whether the <kbd>Ctrl</kbd> modifier was pressed.
|
|
120
|
+
*/
|
|
121
|
+
ctrlKey: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the <kbd>Shift</kbd> modifier was pressed.
|
|
124
|
+
*/
|
|
125
|
+
shiftKey: boolean;
|
|
126
|
+
}
|