@ckeditor/ckeditor5-utils 40.0.0 → 40.2.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 +26 -26
- package/LICENSE.md +3 -3
- package/package.json +1 -1
- package/src/abortabledebounce.d.ts +17 -0
- package/src/abortabledebounce.js +22 -0
- package/src/areconnectedthroughproperties.d.ts +11 -11
- package/src/areconnectedthroughproperties.js +73 -73
- package/src/ckeditorerror.d.ts +123 -123
- package/src/ckeditorerror.js +176 -176
- package/src/collection.d.ts +433 -427
- package/src/collection.js +583 -575
- package/src/comparearrays.d.ts +30 -30
- package/src/comparearrays.js +47 -47
- package/src/config.d.ts +163 -163
- package/src/config.js +163 -162
- package/src/count.d.ts +18 -18
- package/src/count.js +24 -24
- package/src/delay.d.ts +19 -19
- package/src/delay.js +26 -26
- package/src/diff.d.ts +31 -31
- package/src/diff.js +115 -115
- package/src/difftochanges.d.ts +59 -59
- package/src/difftochanges.js +79 -79
- package/src/dom/createelement.d.ts +57 -57
- package/src/dom/createelement.js +40 -40
- package/src/dom/emittermixin.d.ts +142 -142
- package/src/dom/emittermixin.js +239 -239
- package/src/dom/findclosestscrollableancestor.d.ts +11 -11
- package/src/dom/findclosestscrollableancestor.js +31 -31
- package/src/dom/getancestors.d.ts +17 -17
- package/src/dom/getancestors.js +27 -27
- package/src/dom/getborderwidths.d.ts +24 -24
- package/src/dom/getborderwidths.js +24 -24
- package/src/dom/getcommonancestor.d.ts +12 -12
- package/src/dom/getcommonancestor.js +25 -25
- package/src/dom/getdatafromelement.d.ts +14 -14
- package/src/dom/getdatafromelement.js +20 -20
- package/src/dom/getpositionedancestor.d.ts +10 -10
- package/src/dom/getpositionedancestor.js +22 -22
- package/src/dom/global.d.ts +32 -32
- package/src/dom/global.js +35 -35
- package/src/dom/indexof.d.ts +14 -14
- package/src/dom/indexof.js +21 -21
- package/src/dom/insertat.d.ts +15 -15
- package/src/dom/insertat.js +17 -17
- package/src/dom/iscomment.d.ts +11 -11
- package/src/dom/iscomment.js +14 -14
- package/src/dom/isnode.d.ts +11 -11
- package/src/dom/isnode.js +21 -21
- package/src/dom/isrange.d.ts +11 -11
- package/src/dom/isrange.js +13 -13
- package/src/dom/istext.d.ts +11 -11
- package/src/dom/istext.js +13 -13
- package/src/dom/isvalidattributename.d.ts +10 -10
- package/src/dom/isvalidattributename.js +22 -22
- package/src/dom/isvisible.d.ts +18 -18
- package/src/dom/isvisible.js +20 -20
- package/src/dom/iswindow.d.ts +11 -11
- package/src/dom/iswindow.js +22 -22
- package/src/dom/position.d.ts +211 -211
- package/src/dom/position.js +313 -313
- package/src/dom/rect.d.ts +195 -195
- package/src/dom/rect.js +474 -474
- package/src/dom/remove.d.ts +13 -13
- package/src/dom/remove.js +18 -18
- package/src/dom/resizeobserver.d.ts +74 -74
- package/src/dom/resizeobserver.js +126 -126
- package/src/dom/scroll.d.ts +73 -73
- package/src/dom/scroll.js +383 -383
- package/src/dom/setdatainelement.d.ts +14 -14
- package/src/dom/setdatainelement.js +20 -20
- package/src/dom/tounit.d.ts +22 -22
- package/src/dom/tounit.js +16 -16
- package/src/elementreplacer.d.ts +31 -31
- package/src/elementreplacer.js +43 -43
- package/src/emittermixin.d.ts +312 -312
- package/src/emittermixin.js +453 -453
- package/src/env.d.ts +117 -117
- package/src/env.js +122 -122
- package/src/eventinfo.d.ts +58 -58
- package/src/eventinfo.js +26 -26
- package/src/fastdiff.d.ts +112 -112
- package/src/fastdiff.js +248 -248
- package/src/first.d.ts +11 -11
- package/src/first.js +17 -17
- package/src/focustracker.d.ts +75 -75
- package/src/focustracker.js +95 -95
- package/src/index.d.ts +64 -61
- package/src/index.js +63 -60
- package/src/inserttopriorityarray.d.ts +30 -30
- package/src/inserttopriorityarray.js +21 -21
- package/src/isiterable.d.ts +14 -14
- package/src/isiterable.js +16 -16
- package/src/keyboard.d.ts +126 -126
- package/src/keyboard.js +221 -221
- package/src/keystrokehandler.d.ts +87 -87
- package/src/keystrokehandler.js +122 -122
- package/src/language.d.ts +17 -17
- package/src/language.js +19 -19
- package/src/locale.d.ts +120 -120
- package/src/locale.js +76 -76
- package/src/mapsequal.d.ts +15 -15
- package/src/mapsequal.js +27 -27
- package/src/mix.d.ts +85 -85
- package/src/mix.js +50 -50
- package/src/nth.d.ts +16 -16
- package/src/nth.js +24 -24
- package/src/objecttomap.d.ts +23 -23
- package/src/objecttomap.js +27 -27
- package/src/observablemixin.d.ts +560 -560
- package/src/observablemixin.js +580 -580
- package/src/priorities.d.ts +33 -33
- package/src/priorities.js +23 -23
- package/src/retry.d.ts +33 -0
- package/src/retry.js +47 -0
- package/src/splicearray.d.ts +26 -26
- package/src/splicearray.js +40 -40
- package/src/spy.d.ts +21 -21
- package/src/spy.js +22 -22
- package/src/toarray.d.ts +25 -25
- package/src/toarray.js +7 -7
- package/src/tomap.d.ts +19 -19
- package/src/tomap.js +29 -29
- package/src/translation-service.d.ts +168 -168
- package/src/translation-service.js +198 -198
- package/src/uid.d.ts +15 -15
- package/src/uid.js +57 -57
- package/src/unicode.d.ts +54 -54
- package/src/unicode.js +85 -85
- package/src/verifylicense.d.ts +15 -15
- package/src/verifylicense.js +87 -87
- package/src/version.d.ts +10 -10
- package/src/version.js +153 -153
- package/src/wait.d.ts +16 -0
- package/src/wait.js +29 -0
package/src/env.d.ts
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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/env
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Safely returns `userAgent` from browser's navigator API in a lower case.
|
|
10
|
-
* If navigator API is not available it will return an empty string.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getUserAgent(): string;
|
|
13
|
-
/**
|
|
14
|
-
* A namespace containing environment and browser information.
|
|
15
|
-
*/
|
|
16
|
-
export interface EnvType {
|
|
17
|
-
/**
|
|
18
|
-
* Indicates that the application is running on Macintosh.
|
|
19
|
-
*/
|
|
20
|
-
readonly isMac: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Indicates that the application is running on Windows.
|
|
23
|
-
*/
|
|
24
|
-
readonly isWindows: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Indicates that the application is running in Firefox (Gecko).
|
|
27
|
-
*/
|
|
28
|
-
readonly isGecko: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Indicates that the application is running in Safari.
|
|
31
|
-
*/
|
|
32
|
-
readonly isSafari: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Indicates the the application is running in iOS.
|
|
35
|
-
*/
|
|
36
|
-
readonly isiOS: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Indicates that the application is running on Android mobile device.
|
|
39
|
-
*/
|
|
40
|
-
readonly isAndroid: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Indicates that the application is running in a browser using the Blink engine.
|
|
43
|
-
*/
|
|
44
|
-
readonly isBlink: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Environment features information.
|
|
47
|
-
*/
|
|
48
|
-
readonly features: EnvFeaturesType;
|
|
49
|
-
}
|
|
50
|
-
export interface EnvFeaturesType {
|
|
51
|
-
/**
|
|
52
|
-
* Indicates that the environment supports ES2018 Unicode property escapes — like `\p{P}` or `\p{L}`.
|
|
53
|
-
* More information about unicode properties might be found
|
|
54
|
-
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
55
|
-
*/
|
|
56
|
-
readonly isRegExpUnicodePropertySupported: boolean;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* A namespace containing environment and browser information.
|
|
60
|
-
*/
|
|
61
|
-
declare const env: EnvType;
|
|
62
|
-
export default env;
|
|
63
|
-
/**
|
|
64
|
-
* Checks if User Agent represented by the string is running on Macintosh.
|
|
65
|
-
*
|
|
66
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
67
|
-
* @returns Whether User Agent is running on Macintosh or not.
|
|
68
|
-
*/
|
|
69
|
-
export declare function isMac(userAgent: string): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Checks if User Agent represented by the string is running on Windows.
|
|
72
|
-
*
|
|
73
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
74
|
-
* @returns Whether User Agent is running on Windows or not.
|
|
75
|
-
*/
|
|
76
|
-
export declare function isWindows(userAgent: string): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Checks if User Agent represented by the string is Firefox (Gecko).
|
|
79
|
-
*
|
|
80
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
81
|
-
* @returns Whether User Agent is Firefox or not.
|
|
82
|
-
*/
|
|
83
|
-
export declare function isGecko(userAgent: string): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Checks if User Agent represented by the string is Safari.
|
|
86
|
-
*
|
|
87
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
88
|
-
* @returns Whether User Agent is Safari or not.
|
|
89
|
-
*/
|
|
90
|
-
export declare function isSafari(userAgent: string): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Checks if User Agent represented by the string is running in iOS.
|
|
93
|
-
*
|
|
94
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
95
|
-
* @returns Whether User Agent is running in iOS or not.
|
|
96
|
-
*/
|
|
97
|
-
export declare function isiOS(userAgent: string): boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Checks if User Agent represented by the string is Android mobile device.
|
|
100
|
-
*
|
|
101
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
102
|
-
* @returns Whether User Agent is Safari or not.
|
|
103
|
-
*/
|
|
104
|
-
export declare function isAndroid(userAgent: string): boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Checks if User Agent represented by the string is Blink engine.
|
|
107
|
-
*
|
|
108
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
109
|
-
* @returns Whether User Agent is Blink engine or not.
|
|
110
|
-
*/
|
|
111
|
-
export declare function isBlink(userAgent: string): boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Checks if the current environment supports ES2018 Unicode properties like `\p{P}` or `\p{L}`.
|
|
114
|
-
* More information about unicode properties might be found
|
|
115
|
-
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
116
|
-
*/
|
|
117
|
-
export declare function isRegExpUnicodePropertySupported(): boolean;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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/env
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Safely returns `userAgent` from browser's navigator API in a lower case.
|
|
10
|
+
* If navigator API is not available it will return an empty string.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getUserAgent(): string;
|
|
13
|
+
/**
|
|
14
|
+
* A namespace containing environment and browser information.
|
|
15
|
+
*/
|
|
16
|
+
export interface EnvType {
|
|
17
|
+
/**
|
|
18
|
+
* Indicates that the application is running on Macintosh.
|
|
19
|
+
*/
|
|
20
|
+
readonly isMac: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Indicates that the application is running on Windows.
|
|
23
|
+
*/
|
|
24
|
+
readonly isWindows: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Indicates that the application is running in Firefox (Gecko).
|
|
27
|
+
*/
|
|
28
|
+
readonly isGecko: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Indicates that the application is running in Safari.
|
|
31
|
+
*/
|
|
32
|
+
readonly isSafari: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Indicates the the application is running in iOS.
|
|
35
|
+
*/
|
|
36
|
+
readonly isiOS: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Indicates that the application is running on Android mobile device.
|
|
39
|
+
*/
|
|
40
|
+
readonly isAndroid: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Indicates that the application is running in a browser using the Blink engine.
|
|
43
|
+
*/
|
|
44
|
+
readonly isBlink: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Environment features information.
|
|
47
|
+
*/
|
|
48
|
+
readonly features: EnvFeaturesType;
|
|
49
|
+
}
|
|
50
|
+
export interface EnvFeaturesType {
|
|
51
|
+
/**
|
|
52
|
+
* Indicates that the environment supports ES2018 Unicode property escapes — like `\p{P}` or `\p{L}`.
|
|
53
|
+
* More information about unicode properties might be found
|
|
54
|
+
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
55
|
+
*/
|
|
56
|
+
readonly isRegExpUnicodePropertySupported: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A namespace containing environment and browser information.
|
|
60
|
+
*/
|
|
61
|
+
declare const env: EnvType;
|
|
62
|
+
export default env;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if User Agent represented by the string is running on Macintosh.
|
|
65
|
+
*
|
|
66
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
67
|
+
* @returns Whether User Agent is running on Macintosh or not.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isMac(userAgent: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Checks if User Agent represented by the string is running on Windows.
|
|
72
|
+
*
|
|
73
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
74
|
+
* @returns Whether User Agent is running on Windows or not.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isWindows(userAgent: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Checks if User Agent represented by the string is Firefox (Gecko).
|
|
79
|
+
*
|
|
80
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
81
|
+
* @returns Whether User Agent is Firefox or not.
|
|
82
|
+
*/
|
|
83
|
+
export declare function isGecko(userAgent: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Checks if User Agent represented by the string is Safari.
|
|
86
|
+
*
|
|
87
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
88
|
+
* @returns Whether User Agent is Safari or not.
|
|
89
|
+
*/
|
|
90
|
+
export declare function isSafari(userAgent: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Checks if User Agent represented by the string is running in iOS.
|
|
93
|
+
*
|
|
94
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
95
|
+
* @returns Whether User Agent is running in iOS or not.
|
|
96
|
+
*/
|
|
97
|
+
export declare function isiOS(userAgent: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Checks if User Agent represented by the string is Android mobile device.
|
|
100
|
+
*
|
|
101
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
102
|
+
* @returns Whether User Agent is Safari or not.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isAndroid(userAgent: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Checks if User Agent represented by the string is Blink engine.
|
|
107
|
+
*
|
|
108
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
109
|
+
* @returns Whether User Agent is Blink engine or not.
|
|
110
|
+
*/
|
|
111
|
+
export declare function isBlink(userAgent: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Checks if the current environment supports ES2018 Unicode properties like `\p{P}` or `\p{L}`.
|
|
114
|
+
* More information about unicode properties might be found
|
|
115
|
+
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
116
|
+
*/
|
|
117
|
+
export declare function isRegExpUnicodePropertySupported(): boolean;
|
package/src/env.js
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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
|
-
/* globals navigator:false */
|
|
6
|
-
/**
|
|
7
|
-
* @module utils/env
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Safely returns `userAgent` from browser's navigator API in a lower case.
|
|
11
|
-
* If navigator API is not available it will return an empty string.
|
|
12
|
-
*/
|
|
13
|
-
export function getUserAgent() {
|
|
14
|
-
// In some environments navigator API might not be available.
|
|
15
|
-
try {
|
|
16
|
-
return navigator.userAgent.toLowerCase();
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
return '';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const userAgent = getUserAgent();
|
|
23
|
-
/**
|
|
24
|
-
* A namespace containing environment and browser information.
|
|
25
|
-
*/
|
|
26
|
-
const env = {
|
|
27
|
-
isMac: isMac(userAgent),
|
|
28
|
-
isWindows: isWindows(userAgent),
|
|
29
|
-
isGecko: isGecko(userAgent),
|
|
30
|
-
isSafari: isSafari(userAgent),
|
|
31
|
-
isiOS: isiOS(userAgent),
|
|
32
|
-
isAndroid: isAndroid(userAgent),
|
|
33
|
-
isBlink: isBlink(userAgent),
|
|
34
|
-
features: {
|
|
35
|
-
isRegExpUnicodePropertySupported: isRegExpUnicodePropertySupported()
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
export default env;
|
|
39
|
-
/**
|
|
40
|
-
* Checks if User Agent represented by the string is running on Macintosh.
|
|
41
|
-
*
|
|
42
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
43
|
-
* @returns Whether User Agent is running on Macintosh or not.
|
|
44
|
-
*/
|
|
45
|
-
export function isMac(userAgent) {
|
|
46
|
-
return userAgent.indexOf('macintosh') > -1;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Checks if User Agent represented by the string is running on Windows.
|
|
50
|
-
*
|
|
51
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
52
|
-
* @returns Whether User Agent is running on Windows or not.
|
|
53
|
-
*/
|
|
54
|
-
export function isWindows(userAgent) {
|
|
55
|
-
return userAgent.indexOf('windows') > -1;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Checks if User Agent represented by the string is Firefox (Gecko).
|
|
59
|
-
*
|
|
60
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
61
|
-
* @returns Whether User Agent is Firefox or not.
|
|
62
|
-
*/
|
|
63
|
-
export function isGecko(userAgent) {
|
|
64
|
-
return !!userAgent.match(/gecko\/\d+/);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Checks if User Agent represented by the string is Safari.
|
|
68
|
-
*
|
|
69
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
70
|
-
* @returns Whether User Agent is Safari or not.
|
|
71
|
-
*/
|
|
72
|
-
export function isSafari(userAgent) {
|
|
73
|
-
return userAgent.indexOf(' applewebkit/') > -1 && userAgent.indexOf('chrome') === -1;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Checks if User Agent represented by the string is running in iOS.
|
|
77
|
-
*
|
|
78
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
79
|
-
* @returns Whether User Agent is running in iOS or not.
|
|
80
|
-
*/
|
|
81
|
-
export function isiOS(userAgent) {
|
|
82
|
-
// "Request mobile site" || "Request desktop site".
|
|
83
|
-
return !!userAgent.match(/iphone|ipad/i) || (isMac(userAgent) && navigator.maxTouchPoints > 0);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Checks if User Agent represented by the string is Android mobile device.
|
|
87
|
-
*
|
|
88
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
89
|
-
* @returns Whether User Agent is Safari or not.
|
|
90
|
-
*/
|
|
91
|
-
export function isAndroid(userAgent) {
|
|
92
|
-
return userAgent.indexOf('android') > -1;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Checks if User Agent represented by the string is Blink engine.
|
|
96
|
-
*
|
|
97
|
-
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
98
|
-
* @returns Whether User Agent is Blink engine or not.
|
|
99
|
-
*/
|
|
100
|
-
export function isBlink(userAgent) {
|
|
101
|
-
// The Edge browser before switching to the Blink engine used to report itself as Chrome (and "Edge/")
|
|
102
|
-
// but after switching to the Blink it replaced "Edge/" with "Edg/".
|
|
103
|
-
return userAgent.indexOf('chrome/') > -1 && userAgent.indexOf('edge/') < 0;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Checks if the current environment supports ES2018 Unicode properties like `\p{P}` or `\p{L}`.
|
|
107
|
-
* More information about unicode properties might be found
|
|
108
|
-
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
109
|
-
*/
|
|
110
|
-
export function isRegExpUnicodePropertySupported() {
|
|
111
|
-
let isSupported = false;
|
|
112
|
-
// Feature detection for Unicode properties. Added in ES2018. Currently Firefox does not support it.
|
|
113
|
-
// See https://github.com/ckeditor/ckeditor5-mention/issues/44#issuecomment-487002174.
|
|
114
|
-
try {
|
|
115
|
-
// Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).
|
|
116
|
-
isSupported = 'ć'.search(new RegExp('[\\p{L}]', 'u')) === 0;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
// Firefox throws a SyntaxError when the group is unsupported.
|
|
120
|
-
}
|
|
121
|
-
return isSupported;
|
|
122
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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
|
+
/* globals navigator:false */
|
|
6
|
+
/**
|
|
7
|
+
* @module utils/env
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Safely returns `userAgent` from browser's navigator API in a lower case.
|
|
11
|
+
* If navigator API is not available it will return an empty string.
|
|
12
|
+
*/
|
|
13
|
+
export function getUserAgent() {
|
|
14
|
+
// In some environments navigator API might not be available.
|
|
15
|
+
try {
|
|
16
|
+
return navigator.userAgent.toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const userAgent = getUserAgent();
|
|
23
|
+
/**
|
|
24
|
+
* A namespace containing environment and browser information.
|
|
25
|
+
*/
|
|
26
|
+
const env = {
|
|
27
|
+
isMac: isMac(userAgent),
|
|
28
|
+
isWindows: isWindows(userAgent),
|
|
29
|
+
isGecko: isGecko(userAgent),
|
|
30
|
+
isSafari: isSafari(userAgent),
|
|
31
|
+
isiOS: isiOS(userAgent),
|
|
32
|
+
isAndroid: isAndroid(userAgent),
|
|
33
|
+
isBlink: isBlink(userAgent),
|
|
34
|
+
features: {
|
|
35
|
+
isRegExpUnicodePropertySupported: isRegExpUnicodePropertySupported()
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export default env;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if User Agent represented by the string is running on Macintosh.
|
|
41
|
+
*
|
|
42
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
43
|
+
* @returns Whether User Agent is running on Macintosh or not.
|
|
44
|
+
*/
|
|
45
|
+
export function isMac(userAgent) {
|
|
46
|
+
return userAgent.indexOf('macintosh') > -1;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if User Agent represented by the string is running on Windows.
|
|
50
|
+
*
|
|
51
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
52
|
+
* @returns Whether User Agent is running on Windows or not.
|
|
53
|
+
*/
|
|
54
|
+
export function isWindows(userAgent) {
|
|
55
|
+
return userAgent.indexOf('windows') > -1;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Checks if User Agent represented by the string is Firefox (Gecko).
|
|
59
|
+
*
|
|
60
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
61
|
+
* @returns Whether User Agent is Firefox or not.
|
|
62
|
+
*/
|
|
63
|
+
export function isGecko(userAgent) {
|
|
64
|
+
return !!userAgent.match(/gecko\/\d+/);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Checks if User Agent represented by the string is Safari.
|
|
68
|
+
*
|
|
69
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
70
|
+
* @returns Whether User Agent is Safari or not.
|
|
71
|
+
*/
|
|
72
|
+
export function isSafari(userAgent) {
|
|
73
|
+
return userAgent.indexOf(' applewebkit/') > -1 && userAgent.indexOf('chrome') === -1;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Checks if User Agent represented by the string is running in iOS.
|
|
77
|
+
*
|
|
78
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
79
|
+
* @returns Whether User Agent is running in iOS or not.
|
|
80
|
+
*/
|
|
81
|
+
export function isiOS(userAgent) {
|
|
82
|
+
// "Request mobile site" || "Request desktop site".
|
|
83
|
+
return !!userAgent.match(/iphone|ipad/i) || (isMac(userAgent) && navigator.maxTouchPoints > 0);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Checks if User Agent represented by the string is Android mobile device.
|
|
87
|
+
*
|
|
88
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
89
|
+
* @returns Whether User Agent is Safari or not.
|
|
90
|
+
*/
|
|
91
|
+
export function isAndroid(userAgent) {
|
|
92
|
+
return userAgent.indexOf('android') > -1;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Checks if User Agent represented by the string is Blink engine.
|
|
96
|
+
*
|
|
97
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
98
|
+
* @returns Whether User Agent is Blink engine or not.
|
|
99
|
+
*/
|
|
100
|
+
export function isBlink(userAgent) {
|
|
101
|
+
// The Edge browser before switching to the Blink engine used to report itself as Chrome (and "Edge/")
|
|
102
|
+
// but after switching to the Blink it replaced "Edge/" with "Edg/".
|
|
103
|
+
return userAgent.indexOf('chrome/') > -1 && userAgent.indexOf('edge/') < 0;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Checks if the current environment supports ES2018 Unicode properties like `\p{P}` or `\p{L}`.
|
|
107
|
+
* More information about unicode properties might be found
|
|
108
|
+
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
109
|
+
*/
|
|
110
|
+
export function isRegExpUnicodePropertySupported() {
|
|
111
|
+
let isSupported = false;
|
|
112
|
+
// Feature detection for Unicode properties. Added in ES2018. Currently Firefox does not support it.
|
|
113
|
+
// See https://github.com/ckeditor/ckeditor5-mention/issues/44#issuecomment-487002174.
|
|
114
|
+
try {
|
|
115
|
+
// Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534).
|
|
116
|
+
isSupported = 'ć'.search(new RegExp('[\\p{L}]', 'u')) === 0;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
// Firefox throws a SyntaxError when the group is unsupported.
|
|
120
|
+
}
|
|
121
|
+
return isSupported;
|
|
122
|
+
}
|
package/src/eventinfo.d.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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
|
-
* The event object passed to event callbacks. It is used to provide information about the event as well as a tool to
|
|
7
|
-
* manipulate it.
|
|
8
|
-
*/
|
|
9
|
-
export default class EventInfo<TName extends string = string, TReturn = unknown> {
|
|
10
|
-
/**
|
|
11
|
-
* The object that fired the event.
|
|
12
|
-
*/
|
|
13
|
-
readonly source: object;
|
|
14
|
-
/**
|
|
15
|
-
* The event name.
|
|
16
|
-
*/
|
|
17
|
-
readonly name: TName;
|
|
18
|
-
/**
|
|
19
|
-
* Path this event has followed. See {@link module:utils/emittermixin~Emitter#delegate}.
|
|
20
|
-
*/
|
|
21
|
-
path: Array<object>;
|
|
22
|
-
/**
|
|
23
|
-
* Stops the event emitter to call further callbacks for this event interaction.
|
|
24
|
-
*/
|
|
25
|
-
readonly stop: {
|
|
26
|
-
(): void;
|
|
27
|
-
called?: boolean;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Removes the current callback from future interactions of this event.
|
|
31
|
-
*/
|
|
32
|
-
readonly off: {
|
|
33
|
-
(): void;
|
|
34
|
-
called?: boolean;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* The value which will be returned by {@link module:utils/emittermixin~Emitter#fire}.
|
|
38
|
-
*
|
|
39
|
-
* It's `undefined` by default and can be changed by an event listener:
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* dataController.fire( 'getSelectedContent', ( evt ) => {
|
|
43
|
-
* // This listener will make `dataController.fire( 'getSelectedContent' )`
|
|
44
|
-
* // always return an empty DocumentFragment.
|
|
45
|
-
* evt.return = new DocumentFragment();
|
|
46
|
-
*
|
|
47
|
-
* // Make sure no other listeners are executed.
|
|
48
|
-
* evt.stop();
|
|
49
|
-
* } );
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
return: TReturn | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* @param source The emitter.
|
|
55
|
-
* @param name The event name.
|
|
56
|
-
*/
|
|
57
|
-
constructor(source: object, name: TName);
|
|
58
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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
|
+
* The event object passed to event callbacks. It is used to provide information about the event as well as a tool to
|
|
7
|
+
* manipulate it.
|
|
8
|
+
*/
|
|
9
|
+
export default class EventInfo<TName extends string = string, TReturn = unknown> {
|
|
10
|
+
/**
|
|
11
|
+
* The object that fired the event.
|
|
12
|
+
*/
|
|
13
|
+
readonly source: object;
|
|
14
|
+
/**
|
|
15
|
+
* The event name.
|
|
16
|
+
*/
|
|
17
|
+
readonly name: TName;
|
|
18
|
+
/**
|
|
19
|
+
* Path this event has followed. See {@link module:utils/emittermixin~Emitter#delegate}.
|
|
20
|
+
*/
|
|
21
|
+
path: Array<object>;
|
|
22
|
+
/**
|
|
23
|
+
* Stops the event emitter to call further callbacks for this event interaction.
|
|
24
|
+
*/
|
|
25
|
+
readonly stop: {
|
|
26
|
+
(): void;
|
|
27
|
+
called?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Removes the current callback from future interactions of this event.
|
|
31
|
+
*/
|
|
32
|
+
readonly off: {
|
|
33
|
+
(): void;
|
|
34
|
+
called?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The value which will be returned by {@link module:utils/emittermixin~Emitter#fire}.
|
|
38
|
+
*
|
|
39
|
+
* It's `undefined` by default and can be changed by an event listener:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* dataController.fire( 'getSelectedContent', ( evt ) => {
|
|
43
|
+
* // This listener will make `dataController.fire( 'getSelectedContent' )`
|
|
44
|
+
* // always return an empty DocumentFragment.
|
|
45
|
+
* evt.return = new DocumentFragment();
|
|
46
|
+
*
|
|
47
|
+
* // Make sure no other listeners are executed.
|
|
48
|
+
* evt.stop();
|
|
49
|
+
* } );
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
return: TReturn | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* @param source The emitter.
|
|
55
|
+
* @param name The event name.
|
|
56
|
+
*/
|
|
57
|
+
constructor(source: object, name: TName);
|
|
58
|
+
}
|
package/src/eventinfo.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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/eventinfo
|
|
7
|
-
*/
|
|
8
|
-
import spy from './spy';
|
|
9
|
-
/**
|
|
10
|
-
* The event object passed to event callbacks. It is used to provide information about the event as well as a tool to
|
|
11
|
-
* manipulate it.
|
|
12
|
-
*/
|
|
13
|
-
export default class EventInfo {
|
|
14
|
-
/**
|
|
15
|
-
* @param source The emitter.
|
|
16
|
-
* @param name The event name.
|
|
17
|
-
*/
|
|
18
|
-
constructor(source, name) {
|
|
19
|
-
this.source = source;
|
|
20
|
-
this.name = name;
|
|
21
|
-
this.path = [];
|
|
22
|
-
// The following methods are defined in the constructor because they must be re-created per instance.
|
|
23
|
-
this.stop = spy();
|
|
24
|
-
this.off = spy();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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/eventinfo
|
|
7
|
+
*/
|
|
8
|
+
import spy from './spy';
|
|
9
|
+
/**
|
|
10
|
+
* The event object passed to event callbacks. It is used to provide information about the event as well as a tool to
|
|
11
|
+
* manipulate it.
|
|
12
|
+
*/
|
|
13
|
+
export default class EventInfo {
|
|
14
|
+
/**
|
|
15
|
+
* @param source The emitter.
|
|
16
|
+
* @param name The event name.
|
|
17
|
+
*/
|
|
18
|
+
constructor(source, name) {
|
|
19
|
+
this.source = source;
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.path = [];
|
|
22
|
+
// The following methods are defined in the constructor because they must be re-created per instance.
|
|
23
|
+
this.stop = spy();
|
|
24
|
+
this.off = spy();
|
|
25
|
+
}
|
|
26
|
+
}
|