@ckeditor/ckeditor5-utils 41.4.0 → 41.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +47 -46
- package/dist/index.js.map +1 -1
- package/dist/types/env.d.ts +13 -6
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/env.d.ts +13 -6
- package/src/env.js +11 -4
- package/src/version.d.ts +1 -1
- package/src/version.js +2 -2
package/dist/index.js
CHANGED
|
@@ -7,9 +7,42 @@ import { isObject, isString, isPlainObject, cloneDeepWith, isElement, isFunction
|
|
|
7
7
|
/**
|
|
8
8
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
9
9
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
10
|
-
*/ /* globals navigator:false */ /**
|
|
11
|
-
* @module utils/env
|
|
12
10
|
*/ /**
|
|
11
|
+
* A helper (module) giving an access to the global DOM objects such as `window` and
|
|
12
|
+
* `document`. Accessing these objects using this helper allows easy and bulletproof
|
|
13
|
+
* testing, i.e. stubbing native properties:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { global } from 'ckeditor5/utils';
|
|
17
|
+
*
|
|
18
|
+
* // This stub will work for any code using global module.
|
|
19
|
+
* testUtils.sinon.stub( global, 'window', {
|
|
20
|
+
* innerWidth: 10000
|
|
21
|
+
* } );
|
|
22
|
+
*
|
|
23
|
+
* console.log( global.window.innerWidth );
|
|
24
|
+
* ```
|
|
25
|
+
*/ let globalVar; // named globalVar instead of global: https://github.com/ckeditor/ckeditor5/issues/12971
|
|
26
|
+
// In some environments window and document API might not be available.
|
|
27
|
+
try {
|
|
28
|
+
globalVar = {
|
|
29
|
+
window,
|
|
30
|
+
document
|
|
31
|
+
};
|
|
32
|
+
} catch (e) {
|
|
33
|
+
// It's not possible to mock a window object to simulate lack of a window object without writing extremely convoluted code.
|
|
34
|
+
/* istanbul ignore next -- @preserve */ // Let's cast it to not change module's API.
|
|
35
|
+
// We only handle this so loading editor in environments without window and document doesn't fail.
|
|
36
|
+
// For better DX we shouldn't introduce mixed types and require developers to check the type manually.
|
|
37
|
+
// This module should not be used on purpose in any environment outside browser.
|
|
38
|
+
globalVar = {
|
|
39
|
+
window: {},
|
|
40
|
+
document: {}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var global = globalVar;
|
|
44
|
+
|
|
45
|
+
/**
|
|
13
46
|
* Safely returns `userAgent` from browser's navigator API in a lower case.
|
|
14
47
|
* If navigator API is not available it will return an empty string.
|
|
15
48
|
*/ function getUserAgent() {
|
|
@@ -31,7 +64,9 @@ const userAgent = getUserAgent();
|
|
|
31
64
|
isiOS: isiOS(userAgent),
|
|
32
65
|
isAndroid: isAndroid(userAgent),
|
|
33
66
|
isBlink: isBlink(userAgent),
|
|
34
|
-
isMediaForcedColors
|
|
67
|
+
get isMediaForcedColors () {
|
|
68
|
+
return isMediaForcedColors();
|
|
69
|
+
},
|
|
35
70
|
get isMotionReduced () {
|
|
36
71
|
return isMotionReduced();
|
|
37
72
|
},
|
|
@@ -116,13 +151,17 @@ const userAgent = getUserAgent();
|
|
|
116
151
|
}
|
|
117
152
|
/**
|
|
118
153
|
* Checks if the user agent has enabled a forced colors mode (e.g. Windows High Contrast mode).
|
|
154
|
+
*
|
|
155
|
+
* Returns `false` in environments where `window` global object is not available.
|
|
119
156
|
*/ function isMediaForcedColors() {
|
|
120
|
-
return window.matchMedia('(forced-colors: active)').matches;
|
|
157
|
+
return global.window.matchMedia ? global.window.matchMedia('(forced-colors: active)').matches : false;
|
|
121
158
|
}
|
|
122
159
|
/**
|
|
123
|
-
* Checks if user enabled "prefers reduced motion" setting in browser.
|
|
160
|
+
* Checks if the user enabled "prefers reduced motion" setting in browser.
|
|
161
|
+
*
|
|
162
|
+
* Returns `false` in environments where `window` global object is not available.
|
|
124
163
|
*/ function isMotionReduced() {
|
|
125
|
-
return window.matchMedia('(prefers-reduced-motion)').matches;
|
|
164
|
+
return global.window.matchMedia ? global.window.matchMedia('(prefers-reduced-motion)').matches : false;
|
|
126
165
|
}
|
|
127
166
|
|
|
128
167
|
/**
|
|
@@ -850,9 +889,9 @@ class CKEditorError extends Error {
|
|
|
850
889
|
];
|
|
851
890
|
}
|
|
852
891
|
|
|
853
|
-
const version = '41.4.
|
|
892
|
+
const version = '41.4.2';
|
|
854
893
|
// The second argument is not a month. It is `monthIndex` and starts from `0`.
|
|
855
|
-
const releaseDate = new Date(2024, 4,
|
|
894
|
+
const releaseDate = new Date(2024, 4, 17);
|
|
856
895
|
/* istanbul ignore next -- @preserve */ if (globalThis.CKEDITOR_VERSION) {
|
|
857
896
|
/**
|
|
858
897
|
* This error is thrown when due to a mistake in how CKEditor 5 was installed or initialized, some
|
|
@@ -2582,44 +2621,6 @@ function DomEmitterMixin(base) {
|
|
|
2582
2621
|
return id;
|
|
2583
2622
|
}
|
|
2584
2623
|
|
|
2585
|
-
/**
|
|
2586
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
2587
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
2588
|
-
*/ /**
|
|
2589
|
-
* A helper (module) giving an access to the global DOM objects such as `window` and
|
|
2590
|
-
* `document`. Accessing these objects using this helper allows easy and bulletproof
|
|
2591
|
-
* testing, i.e. stubbing native properties:
|
|
2592
|
-
*
|
|
2593
|
-
* ```ts
|
|
2594
|
-
* import { global } from 'ckeditor5/utils';
|
|
2595
|
-
*
|
|
2596
|
-
* // This stub will work for any code using global module.
|
|
2597
|
-
* testUtils.sinon.stub( global, 'window', {
|
|
2598
|
-
* innerWidth: 10000
|
|
2599
|
-
* } );
|
|
2600
|
-
*
|
|
2601
|
-
* console.log( global.window.innerWidth );
|
|
2602
|
-
* ```
|
|
2603
|
-
*/ let globalVar; // named globalVar instead of global: https://github.com/ckeditor/ckeditor5/issues/12971
|
|
2604
|
-
// In some environments window and document API might not be available.
|
|
2605
|
-
try {
|
|
2606
|
-
globalVar = {
|
|
2607
|
-
window,
|
|
2608
|
-
document
|
|
2609
|
-
};
|
|
2610
|
-
} catch (e) {
|
|
2611
|
-
// It's not possible to mock a window object to simulate lack of a window object without writing extremely convoluted code.
|
|
2612
|
-
/* istanbul ignore next -- @preserve */ // Let's cast it to not change module's API.
|
|
2613
|
-
// We only handle this so loading editor in environments without window and document doesn't fail.
|
|
2614
|
-
// For better DX we shouldn't introduce mixed types and require developers to check the type manually.
|
|
2615
|
-
// This module should not be used on purpose in any environment outside browser.
|
|
2616
|
-
globalVar = {
|
|
2617
|
-
window: {},
|
|
2618
|
-
document: {}
|
|
2619
|
-
};
|
|
2620
|
-
}
|
|
2621
|
-
var global = globalVar;
|
|
2622
|
-
|
|
2623
2624
|
/**
|
|
2624
2625
|
* Returns the closest scrollable ancestor of a DOM element.
|
|
2625
2626
|
*
|