@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
package/src/uid.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
* Returns a unique id. The id starts with an "e" character and a randomly generated string of
|
|
7
|
+
* 32 alphanumeric characters.
|
|
8
|
+
*
|
|
9
|
+
* **Note**: The characters the unique id is built from correspond to the hex number notation
|
|
10
|
+
* (from "0" to "9", from "a" to "f"). In other words, each id corresponds to an "e" followed
|
|
11
|
+
* by 16 8-bit numbers next to each other.
|
|
12
|
+
*
|
|
13
|
+
* @returns An unique id string.
|
|
14
|
+
*/
|
|
15
|
+
export default function uid(): string;
|
package/src/uid.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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/uid
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A hash table of hex numbers to avoid using toString() in uid() which is costly.
|
|
10
|
+
* [ '00', '01', '02', ..., 'fe', 'ff' ]
|
|
11
|
+
*/
|
|
12
|
+
const HEX_NUMBERS = new Array(256).fill('')
|
|
13
|
+
.map((_, index) => ('0' + (index).toString(16)).slice(-2));
|
|
14
|
+
/**
|
|
15
|
+
* Returns a unique id. The id starts with an "e" character and a randomly generated string of
|
|
16
|
+
* 32 alphanumeric characters.
|
|
17
|
+
*
|
|
18
|
+
* **Note**: The characters the unique id is built from correspond to the hex number notation
|
|
19
|
+
* (from "0" to "9", from "a" to "f"). In other words, each id corresponds to an "e" followed
|
|
20
|
+
* by 16 8-bit numbers next to each other.
|
|
21
|
+
*
|
|
22
|
+
* @returns An unique id string.
|
|
23
|
+
*/
|
|
24
|
+
export default function uid() {
|
|
25
|
+
// Let's create some positive random 32bit integers first.
|
|
26
|
+
const [r1, r2, r3, r4] = crypto.getRandomValues(new Uint32Array(4));
|
|
27
|
+
// Make sure that id does not start with number.
|
|
28
|
+
return 'e' +
|
|
29
|
+
HEX_NUMBERS[r1 >> 0 & 0xFF] +
|
|
30
|
+
HEX_NUMBERS[r1 >> 8 & 0xFF] +
|
|
31
|
+
HEX_NUMBERS[r1 >> 16 & 0xFF] +
|
|
32
|
+
HEX_NUMBERS[r1 >> 24 & 0xFF] +
|
|
33
|
+
HEX_NUMBERS[r2 >> 0 & 0xFF] +
|
|
34
|
+
HEX_NUMBERS[r2 >> 8 & 0xFF] +
|
|
35
|
+
HEX_NUMBERS[r2 >> 16 & 0xFF] +
|
|
36
|
+
HEX_NUMBERS[r2 >> 24 & 0xFF] +
|
|
37
|
+
HEX_NUMBERS[r3 >> 0 & 0xFF] +
|
|
38
|
+
HEX_NUMBERS[r3 >> 8 & 0xFF] +
|
|
39
|
+
HEX_NUMBERS[r3 >> 16 & 0xFF] +
|
|
40
|
+
HEX_NUMBERS[r3 >> 24 & 0xFF] +
|
|
41
|
+
HEX_NUMBERS[r4 >> 0 & 0xFF] +
|
|
42
|
+
HEX_NUMBERS[r4 >> 8 & 0xFF] +
|
|
43
|
+
HEX_NUMBERS[r4 >> 16 & 0xFF] +
|
|
44
|
+
HEX_NUMBERS[r4 >> 24 & 0xFF];
|
|
45
|
+
}
|
package/src/unicode.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
* Set of utils to handle unicode characters.
|
|
7
|
+
*
|
|
8
|
+
* @module utils/unicode
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether given `character` is a combining mark.
|
|
12
|
+
*
|
|
13
|
+
* @param character Character to check.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isCombiningMark(character: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether given `character` is a high half of surrogate pair.
|
|
18
|
+
*
|
|
19
|
+
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
20
|
+
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
21
|
+
*
|
|
22
|
+
* @param character Character to check.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isHighSurrogateHalf(character: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether given `character` is a low half of surrogate pair.
|
|
27
|
+
*
|
|
28
|
+
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
29
|
+
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
30
|
+
*
|
|
31
|
+
* @param character Character to check.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isLowSurrogateHalf(character: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Checks whether given offset in a string is inside a surrogate pair (between two surrogate halves).
|
|
36
|
+
*
|
|
37
|
+
* @param string String to check.
|
|
38
|
+
* @param offset Offset to check.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isInsideSurrogatePair(string: string, offset: number): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Checks whether given offset in a string is between base character and combining mark or between two combining marks.
|
|
43
|
+
*
|
|
44
|
+
* @param string String to check.
|
|
45
|
+
* @param offset Offset to check.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isInsideCombinedSymbol(string: string, offset: number): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Checks whether given offset in a string is inside multi-character emoji sequence.
|
|
50
|
+
*
|
|
51
|
+
* @param string String to check.
|
|
52
|
+
* @param offset Offset to check.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isInsideEmojiSequence(string: string, offset: number): boolean;
|
package/src/unicode.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
* Set of utils to handle unicode characters.
|
|
7
|
+
*
|
|
8
|
+
* @module utils/unicode
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether given `character` is a combining mark.
|
|
12
|
+
*
|
|
13
|
+
* @param character Character to check.
|
|
14
|
+
*/
|
|
15
|
+
export function isCombiningMark(character) {
|
|
16
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
17
|
+
return !!character && character.length == 1 && /[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(character);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether given `character` is a high half of surrogate pair.
|
|
21
|
+
*
|
|
22
|
+
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
23
|
+
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
24
|
+
*
|
|
25
|
+
* @param character Character to check.
|
|
26
|
+
*/
|
|
27
|
+
export function isHighSurrogateHalf(character) {
|
|
28
|
+
return !!character && character.length == 1 && /[\ud800-\udbff]/.test(character);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether given `character` is a low half of surrogate pair.
|
|
32
|
+
*
|
|
33
|
+
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
34
|
+
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
35
|
+
*
|
|
36
|
+
* @param character Character to check.
|
|
37
|
+
*/
|
|
38
|
+
export function isLowSurrogateHalf(character) {
|
|
39
|
+
return !!character && character.length == 1 && /[\udc00-\udfff]/.test(character);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks whether given offset in a string is inside a surrogate pair (between two surrogate halves).
|
|
43
|
+
*
|
|
44
|
+
* @param string String to check.
|
|
45
|
+
* @param offset Offset to check.
|
|
46
|
+
*/
|
|
47
|
+
export function isInsideSurrogatePair(string, offset) {
|
|
48
|
+
return isHighSurrogateHalf(string.charAt(offset - 1)) && isLowSurrogateHalf(string.charAt(offset));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether given offset in a string is between base character and combining mark or between two combining marks.
|
|
52
|
+
*
|
|
53
|
+
* @param string String to check.
|
|
54
|
+
* @param offset Offset to check.
|
|
55
|
+
*/
|
|
56
|
+
export function isInsideCombinedSymbol(string, offset) {
|
|
57
|
+
return isCombiningMark(string.charAt(offset));
|
|
58
|
+
}
|
|
59
|
+
const EMOJI_PATTERN = /* #__PURE__ */ buildEmojiRegexp();
|
|
60
|
+
/**
|
|
61
|
+
* Checks whether given offset in a string is inside multi-character emoji sequence.
|
|
62
|
+
*
|
|
63
|
+
* @param string String to check.
|
|
64
|
+
* @param offset Offset to check.
|
|
65
|
+
*/
|
|
66
|
+
export function isInsideEmojiSequence(string, offset) {
|
|
67
|
+
const matches = String(string).matchAll(EMOJI_PATTERN);
|
|
68
|
+
return Array.from(matches).some(match => match.index < offset && offset < match.index + match[0].length);
|
|
69
|
+
}
|
|
70
|
+
function buildEmojiRegexp() {
|
|
71
|
+
const parts = [
|
|
72
|
+
// Emoji Tag Sequence (ETS)
|
|
73
|
+
/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,
|
|
74
|
+
// Emoji Keycap Sequence
|
|
75
|
+
/\p{Emoji}\u{FE0F}?\u{20E3}/u,
|
|
76
|
+
// Emoji Presentation Sequence
|
|
77
|
+
/\p{Emoji}\u{FE0F}/u,
|
|
78
|
+
// Single-Character Emoji / Emoji Modifier Sequence
|
|
79
|
+
/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u
|
|
80
|
+
];
|
|
81
|
+
const flagSequence = /\p{Regional_Indicator}{2}/u.source;
|
|
82
|
+
const emoji = '(?:' + parts.map(part => part.source).join('|') + ')';
|
|
83
|
+
const sequence = `${flagSequence}|${emoji}(?:\u{200D}${emoji})*`;
|
|
84
|
+
return new RegExp(sequence, 'ug');
|
|
85
|
+
}
|
package/src/version.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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 version = "0.0.0-internal-20241017.0";
|
|
6
|
+
export default version;
|
|
7
|
+
export declare const releaseDate: Date;
|
|
8
|
+
declare global {
|
|
9
|
+
var CKEDITOR_VERSION: string;
|
|
10
|
+
}
|
package/src/version.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
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/version
|
|
7
|
+
*/
|
|
8
|
+
import CKEditorError from './ckeditorerror.js';
|
|
9
|
+
const version = '0.0.0-internal-20241017.0';
|
|
10
|
+
export default version;
|
|
11
|
+
// The second argument is not a month. It is `monthIndex` and starts from `0`.
|
|
12
|
+
export const releaseDate = new Date(2024, 9, 17);
|
|
13
|
+
/* istanbul ignore next -- @preserve */
|
|
14
|
+
if (globalThis.CKEDITOR_VERSION) {
|
|
15
|
+
/**
|
|
16
|
+
* This error is thrown when, due to a mistake in the way CKEditor 5 was installed,
|
|
17
|
+
* imported, or initialized, some of its modules were evaluated and executed twice.
|
|
18
|
+
* Duplicate modules inevitably lead to runtime errors and increased bundle size.
|
|
19
|
+
*
|
|
20
|
+
* # Check dependency versions
|
|
21
|
+
*
|
|
22
|
+
* First, make sure that you use the latest version of all CKEditor 5 dependencies.
|
|
23
|
+
* Depending on the installation method, you should check the versions of the `ckeditor5`,
|
|
24
|
+
* `ckeditor5-premium-features`, or `@ckeditor/ckeditor5-<NAME>` packages. If you cannot update
|
|
25
|
+
* to the latest version, ensure that all the CKEditor 5 packages are
|
|
26
|
+
* in the same version.
|
|
27
|
+
*
|
|
28
|
+
* If you use third-party plugins, make sure to update them, too. If they are incompatible
|
|
29
|
+
* with the version of CKEditor 5 you use, you may need to downgrade the CKEditor 5 packages
|
|
30
|
+
* (which we do not recommend). Ask the plugin's author to upgrade the dependencies,
|
|
31
|
+
* or fork their project and update it yourself.
|
|
32
|
+
*
|
|
33
|
+
* # Check imports
|
|
34
|
+
*
|
|
35
|
+
* The next step is to look at how you import CKEditor 5 into your project.
|
|
36
|
+
*
|
|
37
|
+
* **The {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods}
|
|
38
|
+
* are designed to prevent module duplication, so if you are not using them yet, you should consider
|
|
39
|
+
* updating your project**. However, several legacy installation methods are still supported for backward
|
|
40
|
+
* compatibility, and mixing them may result in module duplication.
|
|
41
|
+
*
|
|
42
|
+
* These are the most common import methods of the CKEditor 5 packages.
|
|
43
|
+
*
|
|
44
|
+
* - **New installation methods (NIM)** – Imports from the `ckeditor5` and `ckeditor5-premium-features` packages.
|
|
45
|
+
* - **Optimized build** for the new installation methods – Imports from the `@ckeditor/ckeditor5-<NAME>/dist/index.js`.
|
|
46
|
+
* - **Predefined builds** (legacy) – Imports from the `@ckeditor/ckeditor5-build-<NAME>` packages.
|
|
47
|
+
* - **Default imports** (legacy) – Imports from the `@ckeditor/ckeditor5-<NAME>` packages (default export).
|
|
48
|
+
* - **`src`** (legacy) – Imports from the `@ckeditor/ckeditor5-<NAME>/src/*`.
|
|
49
|
+
* - **DLL builds** (legacy) – Imports from the `ckeditor5/build/<NAME>` and `@ckeditor/ckeditor5-<NAME>/build/*`.
|
|
50
|
+
*
|
|
51
|
+
* The best way to avoid duplicate modules is to avoid mixing these installation methods. For example, if you use imports
|
|
52
|
+
* specific to the optimized build, you should use them for all CKEditor 5 packages. In addition, since
|
|
53
|
+
* the Predefined and DLL builds already include the core of the editor, they cannot be used with other types of imports.
|
|
54
|
+
*
|
|
55
|
+
* Here is a matrix showing which installation methods are compatible with each other:
|
|
56
|
+
*
|
|
57
|
+
* | | NIM | Optimized build | Predefined builds | Default imports | `src` | DLL builds |
|
|
58
|
+
* |------------------|-----|-----------------|-------------------|-----------------|-------|------------|
|
|
59
|
+
* | NIM | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
60
|
+
* | Optimized builds | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
61
|
+
* | Predefined build | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
62
|
+
* | Default imports | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
|
63
|
+
* | `src` | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
|
64
|
+
* | DLL builds | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
65
|
+
*
|
|
66
|
+
* If you use any third-party plugins, make sure the way you import them is compatible with
|
|
67
|
+
* the way you import CKEditor 5.
|
|
68
|
+
*
|
|
69
|
+
* <details>
|
|
70
|
+
* <summary>New installation methods and optimized builds</summary>
|
|
71
|
+
*
|
|
72
|
+
* If you use the {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods},
|
|
73
|
+
* you should only import code from the `ckeditor5` and `ckeditor5-premium-features` packages.
|
|
74
|
+
* Do not import code from the `@ckeditor/ckeditor5-<NAME>` packages unless you follow
|
|
75
|
+
* the {@glink getting-started/setup/optimizing-build-size Optimizing build size} guide and the imports from
|
|
76
|
+
* the `@ckeditor/ckeditor5-<NAME>` packages end with `/dist/index.js`.
|
|
77
|
+
*
|
|
78
|
+
* If you use a CDN, ensure that some files are not included twice in your project.
|
|
79
|
+
*
|
|
80
|
+
* Examples of valid and invalid import paths:
|
|
81
|
+
*
|
|
82
|
+
* ```js
|
|
83
|
+
* import { ClassicEditor, Highlight } from 'ckeditor5'; // ✅
|
|
84
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ✅
|
|
85
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ❌
|
|
86
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
|
|
87
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight.js'; // ❌
|
|
88
|
+
* ```
|
|
89
|
+
* </details>
|
|
90
|
+
*
|
|
91
|
+
* <details>
|
|
92
|
+
* <summary>(Legacy) Predefined builds</summary>
|
|
93
|
+
*
|
|
94
|
+
* If you use the {@glink getting-started/legacy/installation-methods/predefined-builds Predefined builds},
|
|
95
|
+
* you cannot import any additional plugins. These builds already include the editor's core
|
|
96
|
+
* and selected plugins and importing additional ones will cause some modules to be bundled and loaded twice.
|
|
97
|
+
*
|
|
98
|
+
* Examples of valid and invalid import paths:
|
|
99
|
+
*
|
|
100
|
+
* ```js
|
|
101
|
+
* import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; // ✅
|
|
102
|
+
* import { Highlight } from 'ckeditor5'; // ❌
|
|
103
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
|
|
104
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
|
|
105
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight'; // ❌
|
|
106
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight'; // ❌
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* If you are missing some features from the
|
|
110
|
+
* {@glink getting-started/legacy/installation-methods/predefined-builds#plugins-included-in-the-predefined-builds list of plugins},
|
|
111
|
+
* you should switch to the {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods}
|
|
112
|
+
* which do not have this limitation.
|
|
113
|
+
* If you cannot migrate to the new installation methods, try the
|
|
114
|
+
* {@glink getting-started/legacy/installation-methods/predefined-builds#superbuild superbuild} instead.
|
|
115
|
+
* This build contains all the editor features.
|
|
116
|
+
* </details>
|
|
117
|
+
*
|
|
118
|
+
* <details>
|
|
119
|
+
* <summary>(Legacy) Default imports and `src` imports</summary>
|
|
120
|
+
*
|
|
121
|
+
* If you use the {@glink getting-started/legacy/installation-methods/quick-start-other legacy customized installation}
|
|
122
|
+
* method, you should only import code from the `@ckeditor/ckeditor5-<NAME>` packages. While you can import code from
|
|
123
|
+
* the `@ckeditor/ckeditor5-<NAME>/src/*` files, it is not recommended as it can make migration to the new installation
|
|
124
|
+
* methods more difficult.
|
|
125
|
+
*
|
|
126
|
+
* If you use this installation method, you should not import code from the `ckeditor5`, `ckeditor5-premium-features`,
|
|
127
|
+
* or `@ckeditor/ckeditor5-build-<NAME>` packages.
|
|
128
|
+
*
|
|
129
|
+
* Examples of valid and invalid import paths:
|
|
130
|
+
*
|
|
131
|
+
* ```js
|
|
132
|
+
* import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic'; // ✅
|
|
133
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ✅
|
|
134
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ✅ (not recommended)
|
|
135
|
+
* import { Highlight } from 'ckeditor5'; // ❌
|
|
136
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
|
|
137
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight'; // ❌
|
|
138
|
+
* ```
|
|
139
|
+
* </details>
|
|
140
|
+
*
|
|
141
|
+
* <details>
|
|
142
|
+
* <summary>(Legacy) DLL builds</summary>
|
|
143
|
+
*
|
|
144
|
+
* If you are using the {@glink getting-started/legacy/advanced/alternative-setups/dll-builds legacy DLL builds},
|
|
145
|
+
* you should not import any non-DLL modules.
|
|
146
|
+
*
|
|
147
|
+
* Examples of valid and invalid import paths:
|
|
148
|
+
*
|
|
149
|
+
* ```js
|
|
150
|
+
* import 'ckeditor5/build/ckeditor5-dll.js';// ✅
|
|
151
|
+
* import '@ckeditor/ckeditor5-editor-classic/build/editor-classic.js';// ✅
|
|
152
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight.js';// ✅
|
|
153
|
+
* import { Highlight } from 'ckeditor5'; // ❌
|
|
154
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
|
|
155
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
|
|
156
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ❌
|
|
157
|
+
* ```
|
|
158
|
+
* </details>
|
|
159
|
+
*
|
|
160
|
+
* # Reinstall `node_modules`
|
|
161
|
+
*
|
|
162
|
+
* Usually, npm and other package managers deduplicate all packages - for example, `ckeditor5` is only installed once
|
|
163
|
+
* in `node_modules/`. However, it is known to fail to do so occasionally.
|
|
164
|
+
*
|
|
165
|
+
* To rule out this possibility, you can try the following:
|
|
166
|
+
*
|
|
167
|
+
* 1. Remove the `node_modules` directory.
|
|
168
|
+
* 2. Remove the `package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml` files (depending on the package manager used).
|
|
169
|
+
* 3. Run `npm install` to reinstall all packages.
|
|
170
|
+
* 4. Run `npm ls` to check how many times packages like `@ckeditor/ckeditor5-core` are installed.
|
|
171
|
+
* If they are installed more than once, verify which package causes that.
|
|
172
|
+
*
|
|
173
|
+
* @error ckeditor-duplicated-modules
|
|
174
|
+
*/
|
|
175
|
+
throw new CKEditorError('ckeditor-duplicated-modules', null);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
globalThis.CKEDITOR_VERSION = version;
|
|
179
|
+
}
|
package/src/wait.d.ts
ADDED
|
@@ -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/wait
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns a promise that is resolved after the specified time.
|
|
10
|
+
*
|
|
11
|
+
* @param timeout The time in milliseconds to wait.
|
|
12
|
+
* @param options.signal A signal to abort the waiting.
|
|
13
|
+
*/
|
|
14
|
+
export default function wait(timeout: number, options?: {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}): Promise<void>;
|
package/src/wait.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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/wait
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns a promise that is resolved after the specified time.
|
|
10
|
+
*
|
|
11
|
+
* @param timeout The time in milliseconds to wait.
|
|
12
|
+
* @param options.signal A signal to abort the waiting.
|
|
13
|
+
*/
|
|
14
|
+
export default function wait(timeout, options = {}) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const signal = options.signal || (new AbortController()).signal;
|
|
17
|
+
signal.throwIfAborted();
|
|
18
|
+
const timer = setTimeout(timeoutHandler, timeout);
|
|
19
|
+
signal.addEventListener('abort', abortHandler, { once: true });
|
|
20
|
+
function timeoutHandler() {
|
|
21
|
+
signal.removeEventListener('abort', abortHandler);
|
|
22
|
+
resolve();
|
|
23
|
+
}
|
|
24
|
+
function abortHandler() {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
reject(signal.reason);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|