@ckeditor/ckeditor5-utils 47.6.1 → 48.0.0-alpha.1

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.
Files changed (154) hide show
  1. package/LICENSE.md +1 -1
  2. package/{src → dist}/dom/global.d.ts +1 -1
  3. package/{src → dist}/dom/rect.d.ts +8 -0
  4. package/dist/index.css +3 -0
  5. package/dist/index.css.map +1 -0
  6. package/dist/index.js +24 -5
  7. package/dist/index.js.map +1 -1
  8. package/{src → dist}/version.d.ts +1 -1
  9. package/package.json +20 -38
  10. package/src/abortabledebounce.js +0 -22
  11. package/src/areconnectedthroughproperties.js +0 -71
  12. package/src/ckeditorerror.js +0 -187
  13. package/src/collection.js +0 -620
  14. package/src/collectstylesheets.js +0 -52
  15. package/src/comparearrays.js +0 -47
  16. package/src/config.js +0 -167
  17. package/src/count.js +0 -25
  18. package/src/crc32.js +0 -61
  19. package/src/decodelicensekey.js +0 -30
  20. package/src/delay.js +0 -25
  21. package/src/diff.js +0 -115
  22. package/src/difftochanges.js +0 -79
  23. package/src/dom/createelement.js +0 -40
  24. package/src/dom/emittermixin.js +0 -237
  25. package/src/dom/findclosestscrollableancestor.js +0 -31
  26. package/src/dom/getancestors.js +0 -26
  27. package/src/dom/getborderwidths.js +0 -24
  28. package/src/dom/getcommonancestor.js +0 -25
  29. package/src/dom/getdatafromelement.js +0 -19
  30. package/src/dom/getpositionedancestor.js +0 -22
  31. package/src/dom/getrangefrommouseevent.js +0 -33
  32. package/src/dom/getvisualviewportoffset.js +0 -21
  33. package/src/dom/global.js +0 -35
  34. package/src/dom/indexof.js +0 -21
  35. package/src/dom/insertat.js +0 -17
  36. package/src/dom/iscomment.js +0 -13
  37. package/src/dom/isnode.js +0 -21
  38. package/src/dom/isrange.js +0 -13
  39. package/src/dom/istext.js +0 -13
  40. package/src/dom/isvalidattributename.js +0 -22
  41. package/src/dom/isvisible.js +0 -30
  42. package/src/dom/iswindow.js +0 -22
  43. package/src/dom/position.js +0 -322
  44. package/src/dom/rect.js +0 -498
  45. package/src/dom/remove.js +0 -18
  46. package/src/dom/resizeobserver.js +0 -134
  47. package/src/dom/scroll.js +0 -406
  48. package/src/dom/setdatainelement.js +0 -19
  49. package/src/dom/tounit.js +0 -16
  50. package/src/elementreplacer.js +0 -47
  51. package/src/emittermixin.js +0 -443
  52. package/src/env.js +0 -158
  53. package/src/eventinfo.js +0 -63
  54. package/src/fastdiff.js +0 -248
  55. package/src/first.js +0 -17
  56. package/src/focustracker.js +0 -329
  57. package/src/formathtml.js +0 -164
  58. package/src/index.js +0 -78
  59. package/src/inserttopriorityarray.js +0 -28
  60. package/src/isfeatureblockedbylicensekey.js +0 -17
  61. package/src/isiterable.js +0 -16
  62. package/src/keyboard.js +0 -256
  63. package/src/keystrokehandler.js +0 -126
  64. package/src/language.js +0 -21
  65. package/src/legacyerrors.js +0 -18
  66. package/src/locale.js +0 -135
  67. package/src/mapsequal.js +0 -27
  68. package/src/mix.js +0 -5
  69. package/src/nth.js +0 -24
  70. package/src/objecttomap.js +0 -27
  71. package/src/observablemixin.js +0 -575
  72. package/src/parsebase64encodedobject.js +0 -22
  73. package/src/priorities.js +0 -22
  74. package/src/retry.js +0 -48
  75. package/src/splicearray.js +0 -37
  76. package/src/spy.js +0 -21
  77. package/src/toarray.js +0 -7
  78. package/src/tomap.js +0 -29
  79. package/src/translation-service.js +0 -209
  80. package/src/uid.js +0 -45
  81. package/src/unicode.js +0 -85
  82. package/src/version.js +0 -177
  83. package/src/wait.js +0 -29
  84. /package/{src → dist}/abortabledebounce.d.ts +0 -0
  85. /package/{src → dist}/areconnectedthroughproperties.d.ts +0 -0
  86. /package/{src → dist}/ckeditorerror.d.ts +0 -0
  87. /package/{src → dist}/collection.d.ts +0 -0
  88. /package/{src → dist}/collectstylesheets.d.ts +0 -0
  89. /package/{src → dist}/comparearrays.d.ts +0 -0
  90. /package/{src → dist}/config.d.ts +0 -0
  91. /package/{src → dist}/count.d.ts +0 -0
  92. /package/{src → dist}/crc32.d.ts +0 -0
  93. /package/{src → dist}/decodelicensekey.d.ts +0 -0
  94. /package/{src → dist}/delay.d.ts +0 -0
  95. /package/{src → dist}/diff.d.ts +0 -0
  96. /package/{src → dist}/difftochanges.d.ts +0 -0
  97. /package/{src → dist}/dom/createelement.d.ts +0 -0
  98. /package/{src → dist}/dom/emittermixin.d.ts +0 -0
  99. /package/{src → dist}/dom/findclosestscrollableancestor.d.ts +0 -0
  100. /package/{src → dist}/dom/getancestors.d.ts +0 -0
  101. /package/{src → dist}/dom/getborderwidths.d.ts +0 -0
  102. /package/{src → dist}/dom/getcommonancestor.d.ts +0 -0
  103. /package/{src → dist}/dom/getdatafromelement.d.ts +0 -0
  104. /package/{src → dist}/dom/getpositionedancestor.d.ts +0 -0
  105. /package/{src → dist}/dom/getrangefrommouseevent.d.ts +0 -0
  106. /package/{src → dist}/dom/getvisualviewportoffset.d.ts +0 -0
  107. /package/{src → dist}/dom/indexof.d.ts +0 -0
  108. /package/{src → dist}/dom/insertat.d.ts +0 -0
  109. /package/{src → dist}/dom/iscomment.d.ts +0 -0
  110. /package/{src → dist}/dom/isnode.d.ts +0 -0
  111. /package/{src → dist}/dom/isrange.d.ts +0 -0
  112. /package/{src → dist}/dom/istext.d.ts +0 -0
  113. /package/{src → dist}/dom/isvalidattributename.d.ts +0 -0
  114. /package/{src → dist}/dom/isvisible.d.ts +0 -0
  115. /package/{src → dist}/dom/iswindow.d.ts +0 -0
  116. /package/{src → dist}/dom/position.d.ts +0 -0
  117. /package/{src → dist}/dom/remove.d.ts +0 -0
  118. /package/{src → dist}/dom/resizeobserver.d.ts +0 -0
  119. /package/{src → dist}/dom/scroll.d.ts +0 -0
  120. /package/{src → dist}/dom/setdatainelement.d.ts +0 -0
  121. /package/{src → dist}/dom/tounit.d.ts +0 -0
  122. /package/{src → dist}/elementreplacer.d.ts +0 -0
  123. /package/{src → dist}/emittermixin.d.ts +0 -0
  124. /package/{src → dist}/env.d.ts +0 -0
  125. /package/{src → dist}/eventinfo.d.ts +0 -0
  126. /package/{src → dist}/fastdiff.d.ts +0 -0
  127. /package/{src → dist}/first.d.ts +0 -0
  128. /package/{src → dist}/focustracker.d.ts +0 -0
  129. /package/{src → dist}/formathtml.d.ts +0 -0
  130. /package/{src → dist}/index.d.ts +0 -0
  131. /package/{src → dist}/inserttopriorityarray.d.ts +0 -0
  132. /package/{src → dist}/isfeatureblockedbylicensekey.d.ts +0 -0
  133. /package/{src → dist}/isiterable.d.ts +0 -0
  134. /package/{src → dist}/keyboard.d.ts +0 -0
  135. /package/{src → dist}/keystrokehandler.d.ts +0 -0
  136. /package/{src → dist}/language.d.ts +0 -0
  137. /package/{src → dist}/legacyerrors.d.ts +0 -0
  138. /package/{src → dist}/locale.d.ts +0 -0
  139. /package/{src → dist}/mapsequal.d.ts +0 -0
  140. /package/{src → dist}/mix.d.ts +0 -0
  141. /package/{src → dist}/nth.d.ts +0 -0
  142. /package/{src → dist}/objecttomap.d.ts +0 -0
  143. /package/{src → dist}/observablemixin.d.ts +0 -0
  144. /package/{src → dist}/parsebase64encodedobject.d.ts +0 -0
  145. /package/{src → dist}/priorities.d.ts +0 -0
  146. /package/{src → dist}/retry.d.ts +0 -0
  147. /package/{src → dist}/splicearray.d.ts +0 -0
  148. /package/{src → dist}/spy.d.ts +0 -0
  149. /package/{src → dist}/toarray.d.ts +0 -0
  150. /package/{src → dist}/tomap.d.ts +0 -0
  151. /package/{src → dist}/translation-service.d.ts +0 -0
  152. /package/{src → dist}/uid.d.ts +0 -0
  153. /package/{src → dist}/unicode.d.ts +0 -0
  154. /package/{src → dist}/wait.d.ts +0 -0
@@ -1,37 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module utils/splicearray
7
- */
8
- /**
9
- * Splices one array into another. To be used instead of `Array.prototype.splice` for better
10
- * performance and because the latter may throw "Maximum call stack size exceeded" error when
11
- * passing huge number of items to insert.
12
- *
13
- * ```ts
14
- * spliceArray( [ 1, 2 ], [ 3, 4 ], 0 ); // [ 3, 4, 1, 2 ]
15
- * spliceArray( [ 1, 2 ], [ 3, 4 ], 1 ); // [ 1, 3, 4, 2 ]
16
- * spliceArray( [ 1, 2 ], [ 3, 4 ], 2 ); // [ 1, 2, 3, 4 ]
17
- * spliceArray( [ 1, 2 ], [], 0 ); // [ 1, 2 ]
18
- * ```
19
- *
20
- * @param targetArray Array to be spliced.
21
- * @param insertArray Array of elements to be inserted to target.
22
- * @param index Index at which nodes should be inserted.
23
- *
24
- * @returns New spliced array.
25
- */
26
- export function spliceArray(targetArray, insertArray, index) {
27
- const originalLength = targetArray.length;
28
- const insertLength = insertArray.length;
29
- // Shift elements in the target array to make space for insertArray
30
- for (let i = originalLength - 1; i >= index; i--) {
31
- targetArray[i + insertLength] = targetArray[i];
32
- }
33
- // Copy elements from insertArray into the target array
34
- for (let i = 0; i < insertLength; i++) {
35
- targetArray[index + i] = insertArray[i];
36
- }
37
- }
package/src/spy.js DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module utils/spy
7
- */
8
- /**
9
- * Creates a spy function (ala Sinon.js) that can be used to inspect call to it.
10
- *
11
- * The following are the present features:
12
- *
13
- * * spy.called: property set to `true` if the function has been called at least once.
14
- *
15
- * @returns The spy function.
16
- */
17
- export function spy() {
18
- return function spy() {
19
- spy.called = true;
20
- };
21
- }
package/src/toarray.js DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- export function toArray(data) {
6
- return Array.isArray(data) ? data : [data];
7
- }
package/src/tomap.js DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module utils/tomap
7
- */
8
- import { objectToMap } from './objecttomap.js';
9
- import { isIterable } from './isiterable.js';
10
- /**
11
- * Transforms object or iterable to map. Iterable needs to be in the format acceptable by the `Map` constructor.
12
- *
13
- * ```ts
14
- * map = toMap( { 'foo': 1, 'bar': 2 } );
15
- * map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
16
- * map = toMap( anotherMap );
17
- * ```
18
- *
19
- * @param data Object or iterable to transform.
20
- * @returns Map created from data.
21
- */
22
- export function toMap(data) {
23
- if (isIterable(data)) {
24
- return new Map(data);
25
- }
26
- else {
27
- return objectToMap(data);
28
- }
29
- }
@@ -1,209 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- import { CKEditorError } from './ckeditorerror.js';
6
- import { global } from './dom/global.js';
7
- import { merge } from 'es-toolkit/compat';
8
- /* istanbul ignore else -- @preserve */
9
- if (!global.window.CKEDITOR_TRANSLATIONS) {
10
- global.window.CKEDITOR_TRANSLATIONS = {};
11
- }
12
- /**
13
- * Adds translations to existing ones or overrides the existing translations. These translations will later
14
- * be available for the {@link module:utils/locale~Locale#t `t()`} function.
15
- *
16
- * The `translations` is an object which consists of `messageId: translation` pairs. Note that the message ID can be
17
- * either constructed from the message string or from the message ID if it was passed
18
- * (this happens rarely and mostly for short messages or messages with placeholders).
19
- * Since the editor displays only the message string, the message ID can be found either in the source code or in the
20
- * built translations for another language.
21
- *
22
- * ```ts
23
- * add( 'pl', {
24
- * 'Cancel': 'Anuluj',
25
- * 'IMAGE': 'obraz', // Note that the `IMAGE` comes from the message ID, while the string can be `image`.
26
- * } );
27
- * ```
28
- *
29
- * If the message is supposed to support various plural forms, make sure to provide an array with the singular form and all plural forms:
30
- *
31
- * ```ts
32
- * add( 'pl', {
33
- * 'Add space': [ 'Dodaj spację', 'Dodaj %0 spacje', 'Dodaj %0 spacji' ]
34
- * } );
35
- * ```
36
- *
37
- * You should also specify the third argument (the `getPluralForm()` function) that will be used to determine the plural form if no
38
- * language file was loaded for that language. All language files coming from CKEditor 5 sources will have this option set, so
39
- * these plural form rules will be reused by other translations added to the registered languages. The `getPluralForm()` function
40
- * can return either a Boolean or a number.
41
- *
42
- * ```ts
43
- * add( 'en', {
44
- * // ... Translations.
45
- * }, n => n !== 1 );
46
- * add( 'pl', {
47
- * // ... Translations.
48
- * }, n => n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 ) ? 1 : 2 );
49
- * ```
50
- *
51
- * All translations extend the global `window.CKEDITOR_TRANSLATIONS` object. An example of this object can be found below:
52
- *
53
- * ```ts
54
- * {
55
- * pl: {
56
- * dictionary: {
57
- * 'Cancel': 'Anuluj',
58
- * 'Add space': [ 'Dodaj spację', 'Dodaj %0 spacje', 'Dodaj %0 spacji' ]
59
- * },
60
- * // A function that returns the plural form index.
61
- * getPluralForm: n => n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 ) ? 1 : 2 );
62
- * }
63
- * // Other languages.
64
- * }
65
- * ```
66
- *
67
- * If you cannot import { this function } from this module (e.g. because you use a CKEditor 5 build), you can
68
- * still add translations by extending the global `window.CKEDITOR_TRANSLATIONS` object by using a function like
69
- * the one below:
70
- *
71
- * ```ts
72
- * function addTranslations( language, translations, getPluralForm ) {
73
- * if ( !global.window.CKEDITOR_TRANSLATIONS ) {
74
- * global.window.CKEDITOR_TRANSLATIONS = {};
75
- * }
76
-
77
- * if ( !global.window.CKEDITOR_TRANSLATIONS[ language ] ) {
78
- * global.window.CKEDITOR_TRANSLATIONS[ language ] = {};
79
- * }
80
- *
81
- * const languageTranslations = global.window.CKEDITOR_TRANSLATIONS[ language ];
82
- *
83
- * languageTranslations.dictionary = languageTranslations.dictionary || {};
84
- * languageTranslations.getPluralForm = getPluralForm || languageTranslations.getPluralForm;
85
- *
86
- * // Extend the dictionary for the given language.
87
- * Object.assign( languageTranslations.dictionary, translations );
88
- * }
89
- * ```
90
- *
91
- * @param language Target language.
92
- * @param translations An object with translations which will be added to the dictionary.
93
- * For each message ID the value should be either a translation or an array of translations if the message
94
- * should support plural forms.
95
- * @param getPluralForm A function that returns the plural form index (a number).
96
- */
97
- export function add(language, translations, getPluralForm) {
98
- if (!global.window.CKEDITOR_TRANSLATIONS[language]) {
99
- global.window.CKEDITOR_TRANSLATIONS[language] = {};
100
- }
101
- const languageTranslations = global.window.CKEDITOR_TRANSLATIONS[language];
102
- languageTranslations.dictionary = languageTranslations.dictionary || {};
103
- languageTranslations.getPluralForm = getPluralForm || languageTranslations.getPluralForm;
104
- Object.assign(languageTranslations.dictionary, translations);
105
- }
106
- /**
107
- * **Note:** This method is internal, use {@link module:utils/locale~Locale#t the `t()` function} instead to translate
108
- * the editor UI parts.
109
- *
110
- * This function is responsible for translating messages to the specified language. It uses translations added perviously
111
- * by {@link module:utils/translation-service~add} (a translations dictionary and the `getPluralForm()` function
112
- * to provide accurate translations of plural forms).
113
- *
114
- * When no translation is defined in the dictionary or the dictionary does not exist, this function returns
115
- * the original message string or the message plural depending on the number of elements.
116
- *
117
- * ```ts
118
- * translate( 'pl', { string: 'Cancel' } ); // 'Cancel'
119
- * ```
120
- *
121
- * The third optional argument is the number of elements, based on which the single form or one of the plural forms
122
- * should be picked when the message is supposed to support various plural forms.
123
- *
124
- * ```ts
125
- * translate( 'en', { string: 'Add a space', plural: 'Add %0 spaces' }, 1 ); // 'Add a space'
126
- * translate( 'en', { string: 'Add a space', plural: 'Add %0 spaces' }, 3 ); // 'Add %0 spaces'
127
- * ```
128
- *
129
- * The message should provide an ID using the `id` property when the message strings are not unique and their
130
- * translations should be different.
131
- *
132
- * ```ts
133
- * translate( 'en', { string: 'image', id: 'ADD_IMAGE' } );
134
- * translate( 'en', { string: 'image', id: 'AN_IMAGE' } );
135
- * ```
136
- *
137
- * @internal
138
- * @param language Target language.
139
- * @param message A message that will be translated.
140
- * @param quantity The number of elements for which a plural form should be picked from the target language dictionary.
141
- * @param translations Translations passed in editor config, if not provided use the global `window.CKEDITOR_TRANSLATIONS`.
142
- * @returns Translated sentence.
143
- */
144
- export function _translate(language, message, quantity = 1, translations) {
145
- if (typeof quantity !== 'number') {
146
- /**
147
- * An incorrect value was passed to the translation function. This was probably caused
148
- * by an incorrect message interpolation of a plural form. Note that for messages supporting plural forms
149
- * the second argument of the `t()` function should always be a number or an array with a number as the first element.
150
- *
151
- * @error translation-service-quantity-not-a-number
152
- */
153
- throw new CKEditorError('translation-service-quantity-not-a-number', null, { quantity });
154
- }
155
- const normalizedTranslations = translations || global.window.CKEDITOR_TRANSLATIONS;
156
- const numberOfLanguages = getNumberOfLanguages(normalizedTranslations);
157
- if (numberOfLanguages === 1) {
158
- // Override the language to the only supported one.
159
- // This can't be done in the `Locale` class, because the translations comes after the `Locale` class initialization.
160
- language = Object.keys(normalizedTranslations)[0];
161
- }
162
- const messageId = message.id || message.string;
163
- if (numberOfLanguages === 0 || !hasTranslation(language, messageId, normalizedTranslations)) {
164
- if (quantity !== 1) {
165
- // Return the default plural form that was passed in the `message.plural` parameter.
166
- return message.plural;
167
- }
168
- return message.string;
169
- }
170
- const dictionary = normalizedTranslations[language].dictionary;
171
- const getPluralForm = normalizedTranslations[language].getPluralForm || (n => n === 1 ? 0 : 1);
172
- const translation = dictionary[messageId];
173
- if (typeof translation === 'string') {
174
- return translation;
175
- }
176
- const pluralFormIndex = Number(getPluralForm(quantity));
177
- // Note: The `translate` function is not responsible for replacing `%0, %1, ...` with values.
178
- return translation[pluralFormIndex];
179
- }
180
- /**
181
- * Clears dictionaries for test purposes.
182
- *
183
- * @internal
184
- */
185
- export function _clear() {
186
- if (global.window.CKEDITOR_TRANSLATIONS) {
187
- global.window.CKEDITOR_TRANSLATIONS = {};
188
- }
189
- }
190
- /**
191
- * If array then merge objects which are inside otherwise return given object.
192
- *
193
- * @internal
194
- * @param translations Translations passed in editor config.
195
- */
196
- export function _unifyTranslations(translations) {
197
- return Array.isArray(translations) ?
198
- translations.reduce((acc, translation) => merge(acc, translation)) :
199
- translations;
200
- }
201
- /**
202
- * Checks whether the dictionary exists and translation in that dictionary exists.
203
- */
204
- function hasTranslation(language, messageId, translations) {
205
- return !!translations[language] && !!translations[language].dictionary[messageId];
206
- }
207
- function getNumberOfLanguages(translations) {
208
- return Object.keys(translations).length;
209
- }
package/src/uid.js DELETED
@@ -1,45 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
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 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.js DELETED
@@ -1,85 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
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.js DELETED
@@ -1,177 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module utils/version
7
- */
8
- import { CKEditorError } from './ckeditorerror.js';
9
- export const version = '47.6.1';
10
- // The second argument is not a month. It is `monthIndex` and starts from `0`.
11
- export const releaseDate = new Date(2026, 2, 11);
12
- /* istanbul ignore next -- @preserve */
13
- if (globalThis.CKEDITOR_VERSION) {
14
- /**
15
- * This error is thrown when, due to a mistake in the way CKEditor&nbsp;5 was installed,
16
- * imported, or initialized, some of its modules were evaluated and executed twice.
17
- * Duplicate modules inevitably lead to runtime errors and increased bundle size.
18
- *
19
- * # Check dependency versions
20
- *
21
- * First, make sure that you use the latest version of all CKEditor&nbsp;5 dependencies.
22
- * Depending on the installation method, you should check the versions of the `ckeditor5`,
23
- * `ckeditor5-premium-features`, or `@ckeditor/ckeditor5-<NAME>` packages. If you cannot update
24
- * to the latest version, ensure that all the CKEditor&nbsp;5 packages are
25
- * in the same version.
26
- *
27
- * If you use third-party plugins, make sure to update them, too. If they are incompatible
28
- * with the version of CKEditor&nbsp;5 you use, you may need to downgrade the CKEditor&nbsp;5 packages
29
- * (which we do not recommend). Ask the plugin's author to upgrade the dependencies,
30
- * or fork their project and update it yourself.
31
- *
32
- * # Check imports
33
- *
34
- * The next step is to look at how you import CKEditor&nbsp;5 into your project.
35
- *
36
- * **The {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods}
37
- * are designed to prevent module duplication, so if you are not using them yet, you should consider
38
- * updating your project**. However, several legacy installation methods are still supported for backward
39
- * compatibility, and mixing them may result in module duplication.
40
- *
41
- * These are the most common import methods of the CKEditor&nbsp;5 packages.
42
- *
43
- * - **New installation methods (NIM)** &ndash; Imports from the `ckeditor5` and `ckeditor5-premium-features` packages.
44
- * - **Optimized build** for the new installation methods &ndash; Imports from the `@ckeditor/ckeditor5-<NAME>/dist/index.js`.
45
- * - **Predefined builds** (no longer supported) &ndash; Imports from the `@ckeditor/ckeditor5-build-<NAME>` packages.
46
- * - **Default imports** (legacy) &ndash; Imports from the `@ckeditor/ckeditor5-<NAME>` packages (default export).
47
- * - **`src`** (legacy) &ndash; Imports from the `@ckeditor/ckeditor5-<NAME>/src/*`.
48
- * - **DLL builds** (legacy) &ndash; Imports from the `ckeditor5/build/<NAME>` and `@ckeditor/ckeditor5-<NAME>/build/*`.
49
- *
50
- * The best way to avoid duplicate modules is to avoid mixing these installation methods. For example, if you use imports
51
- * specific to the optimized build, you should use them for all CKEditor&nbsp;5 packages. In addition, since
52
- * the DLL builds already include the core of the editor, they cannot be used with other types of imports.
53
- *
54
- * Here is a matrix showing which installation methods are compatible with each other:
55
- *
56
- * | | NIM | Optimized build | Predefined builds | Default imports | `src` | DLL builds |
57
- * |------------------|-----|-----------------|-------------------|-----------------|-------|------------|
58
- * | NIM | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
59
- * | Optimized builds | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
60
- * | Predefined build | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
61
- * | Default imports | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
62
- * | `src` | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
63
- * | DLL builds | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
64
- *
65
- * If you use any third-party plugins, make sure the way you import them is compatible with
66
- * the way you import CKEditor&nbsp;5.
67
- *
68
- * <details>
69
- * <summary>New installation methods and optimized builds</summary>
70
- *
71
- * If you use the {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods},
72
- * you should only import { code } from the `ckeditor5` and `ckeditor5-premium-features` packages.
73
- * Do not import { code } from the `@ckeditor/ckeditor5-<NAME>` packages unless you follow
74
- * the {@glink getting-started/setup/optimizing-build-size Optimizing build size} guide and the imports from
75
- * the `@ckeditor/ckeditor5-<NAME>` packages end with `/dist/index.js`.
76
- *
77
- * If you use a CDN, ensure that some files are not included twice in your project.
78
- *
79
- * Examples of valid and invalid import paths:
80
- *
81
- * ```js
82
- * import { ClassicEditor, Highlight } from 'ckeditor5'; // ✅
83
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ✅
84
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ❌
85
- * import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
86
- * import '@ckeditor/ckeditor5-highlight/build/highlight.js'; // ❌
87
- * ```
88
- * </details>
89
- *
90
- * <details>
91
- * <summary>(Deprecated) Predefined builds</summary>
92
- *
93
- * **As of April, 2025 predefined build are no longer supported. Please refer to the
94
- * {@glink getting-started/index Quick Start} guide
95
- * to choose one of the modern installation and integration methods available**.
96
- *
97
- * If you use the predefined builds, you cannot import any additional plugins.
98
- * These builds already include the editor's core and selected plugins and importing additional
99
- * ones will cause some modules to be bundled and loaded twice.
100
- *
101
- * Examples of valid and invalid import paths:
102
- *
103
- * ```js
104
- * import { ClassicEditor } from '@ckeditor/ckeditor5-build-classic'; // ✅
105
- * import { Highlight } from 'ckeditor5'; // ❌
106
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
107
- * import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
108
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/src/highlight'; // ❌
109
- * import '@ckeditor/ckeditor5-highlight/build/highlight'; // ❌
110
- * ```
111
- *
112
- * If you are missing some features from the list of plugins, you should switch to the
113
- * {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods}
114
- * which do not have this limitation.
115
- * </details>
116
- *
117
- * <details>
118
- * <summary>(Legacy) Default imports and `src` imports</summary>
119
- *
120
- * If you use the {@glink getting-started/legacy/installation-methods/quick-start-other legacy customized installation}
121
- * method, you should only import { code from the `@ckeditor/ckeditor5-<NAME>` packages. While you can import code } from
122
- * the `@ckeditor/ckeditor5-<NAME>/src/*` files, it is not recommended as it can make migration to the new installation
123
- * methods more difficult.
124
- *
125
- * If you use this installation method, you should not import { code } from the `ckeditor5` or `ckeditor5-premium-features` packages.
126
- *
127
- * Examples of valid and invalid import paths:
128
- *
129
- * ```js
130
- * import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic'; // ✅
131
- * import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ✅
132
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ✅ (not recommended)
133
- * import { Highlight } from 'ckeditor5'; // ❌
134
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
135
- * import '@ckeditor/ckeditor5-highlight/build/highlight'; // ❌
136
- * ```
137
- * </details>
138
- *
139
- * <details>
140
- * <summary>(Legacy) DLL builds</summary>
141
- *
142
- * If you are using the {@glink getting-started/legacy/advanced/alternative-setups/dll-builds legacy DLL builds},
143
- * you should not import any non-DLL modules.
144
- *
145
- * Examples of valid and invalid import paths:
146
- *
147
- * ```js
148
- * import 'ckeditor5/build/ckeditor5-dll.js';// ✅
149
- * import '@ckeditor/ckeditor5-editor-classic/build/editor-classic.js';// ✅
150
- * import '@ckeditor/ckeditor5-highlight/build/highlight.js';// ✅
151
- * import { Highlight } from 'ckeditor5'; // ❌
152
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
153
- * import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
154
- * import { Highlight } from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ❌
155
- * ```
156
- * </details>
157
- *
158
- * # Reinstall `node_modules`
159
- *
160
- * Usually, npm and other package managers deduplicate all packages - for example, `ckeditor5` is only installed once
161
- * in `node_modules/`. However, it is known to fail to do so occasionally.
162
- *
163
- * To rule out this possibility, you can try the following:
164
- *
165
- * 1. Remove the `node_modules` directory.
166
- * 2. Remove the `package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml` files (depending on the package manager used).
167
- * 3. Run `npm install` to reinstall all packages.
168
- * 4. Run `npm ls` to check how many times packages like `@ckeditor/ckeditor5-core` are installed.
169
- * If they are installed more than once, verify which package causes that.
170
- *
171
- * @error ckeditor-duplicated-modules
172
- */
173
- throw new CKEditorError('ckeditor-duplicated-modules', null);
174
- }
175
- else {
176
- globalThis.CKEDITOR_VERSION = version;
177
- }
package/src/wait.js DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
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 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
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes