@ckeditor/ckeditor5-utils 43.1.1 → 43.2.0-alpha.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/dist/index.js +142 -117
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/count.js +2 -1
- package/src/version.d.ts +1 -1
- package/src/version.js +141 -117
package/dist/index.js
CHANGED
|
@@ -953,143 +953,167 @@ diff.fastDiff = fastDiff;
|
|
|
953
953
|
];
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
-
const version = '43.
|
|
956
|
+
const version = '43.2.0-alpha.0';
|
|
957
957
|
// The second argument is not a month. It is `monthIndex` and starts from `0`.
|
|
958
958
|
const releaseDate = new Date(2024, 8, 25);
|
|
959
959
|
/* istanbul ignore next -- @preserve */ if (globalThis.CKEDITOR_VERSION) {
|
|
960
960
|
/**
|
|
961
|
-
*
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
*
|
|
966
|
-
*
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
*
|
|
977
|
-
*
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
* import
|
|
961
|
+
* This error is thrown when, due to a mistake in the way CKEditor 5 was installed,
|
|
962
|
+
* imported, or initialized, some of its modules were evaluated and executed twice.
|
|
963
|
+
* Duplicate modules inevitably lead to runtime errors and increased bundle size.
|
|
964
|
+
*
|
|
965
|
+
* # Check dependency versions
|
|
966
|
+
*
|
|
967
|
+
* First, make sure that you use the latest version of all CKEditor 5 dependencies.
|
|
968
|
+
* Depending on the installation method, you should check the versions of the `ckeditor5`,
|
|
969
|
+
* `ckeditor5-premium-features`, or `@ckeditor/ckeditor5-<NAME>` packages. If you cannot update
|
|
970
|
+
* to the latest version, ensure that all the CKEditor 5 packages are
|
|
971
|
+
* in the same version.
|
|
972
|
+
*
|
|
973
|
+
* If you use third-party plugins, make sure to update them, too. If they are incompatible
|
|
974
|
+
* with the version of CKEditor 5 you use, you may need to downgrade the CKEditor 5 packages
|
|
975
|
+
* (which we do not recommend). Ask the plugin's author to upgrade the dependencies,
|
|
976
|
+
* or fork their project and update it yourself.
|
|
977
|
+
*
|
|
978
|
+
* # Check imports
|
|
979
|
+
*
|
|
980
|
+
* The next step is to look at how you import CKEditor 5 into your project.
|
|
981
|
+
*
|
|
982
|
+
* **The {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods}
|
|
983
|
+
* are designed to prevent module duplication, so if you are not using them yet, you should consider
|
|
984
|
+
* updating your project**. However, several legacy installation methods are still supported for backward
|
|
985
|
+
* compatibility, and mixing them may result in module duplication.
|
|
986
|
+
*
|
|
987
|
+
* These are the most common import methods of the CKEditor 5 packages.
|
|
988
|
+
*
|
|
989
|
+
* - **New installation methods (NIM)** – Imports from the `ckeditor5` and `ckeditor5-premium-features` packages.
|
|
990
|
+
* - **Optimized build** for the new installation methods – Imports from the `@ckeditor/ckeditor5-<NAME>/dist/index.js`.
|
|
991
|
+
* - **Predefined builds** (legacy) – Imports from the `@ckeditor/ckeditor5-build-<NAME>` packages.
|
|
992
|
+
* - **Default imports** (legacy) – Imports from the `@ckeditor/ckeditor5-<NAME>` packages (default export).
|
|
993
|
+
* - **`src`** (legacy) – Imports from the `@ckeditor/ckeditor5-<NAME>/src/*`.
|
|
994
|
+
* - **DLL builds** (legacy) – Imports from the `ckeditor5/build/<NAME>` and `@ckeditor/ckeditor5-<NAME>/build/*`.
|
|
995
|
+
*
|
|
996
|
+
* The best way to avoid duplicate modules is to avoid mixing these installation methods. For example, if you use imports
|
|
997
|
+
* specific to the optimized build, you should use them for all CKEditor 5 packages. In addition, since
|
|
998
|
+
* the Predefined and DLL builds already include the core of the editor, they cannot be used with other types of imports.
|
|
999
|
+
*
|
|
1000
|
+
* Here is a matrix showing which installation methods are compatible with each other:
|
|
1001
|
+
*
|
|
1002
|
+
* | | NIM | Optimized build | Predefined builds | Default imports | `src` | DLL builds |
|
|
1003
|
+
* |------------------|-----|-----------------|-------------------|-----------------|-------|------------|
|
|
1004
|
+
* | NIM | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
1005
|
+
* | Optimized builds | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
1006
|
+
* | Predefined build | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
1007
|
+
* | Default imports | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
|
1008
|
+
* | `src` | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
|
1009
|
+
* | DLL builds | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
1010
|
+
*
|
|
1011
|
+
* If you use any third-party plugins, make sure the way you import them is compatible with
|
|
1012
|
+
* the way you import CKEditor 5.
|
|
1013
|
+
*
|
|
1014
|
+
* <details>
|
|
1015
|
+
* <summary>New installation methods and optimized builds</summary>
|
|
1016
|
+
*
|
|
1017
|
+
* If you use the {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods},
|
|
1018
|
+
* you should only import code from the `ckeditor5` and `ckeditor5-premium-features` packages.
|
|
1019
|
+
* Do not import code from the `@ckeditor/ckeditor5-<NAME>` packages unless you follow
|
|
1020
|
+
* the {@glink getting-started/setup/optimizing-build-size Optimizing build size} guide and the imports from
|
|
1021
|
+
* the `@ckeditor/ckeditor5-<NAME>` packages end with `/dist/index.js`.
|
|
1022
|
+
*
|
|
1023
|
+
* If you use a CDN, ensure that some files are not included twice in your project.
|
|
1024
|
+
*
|
|
1025
|
+
* Examples of valid and invalid import paths:
|
|
1026
|
+
*
|
|
1027
|
+
* ```js
|
|
1028
|
+
* import { ClassicEditor, Highlight } from 'ckeditor5'; // ✅
|
|
1029
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ✅
|
|
1030
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ❌
|
|
1031
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
|
|
1032
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight.js'; // ❌
|
|
981
1033
|
* ```
|
|
1034
|
+
* </details>
|
|
982
1035
|
*
|
|
983
|
-
*
|
|
1036
|
+
* <details>
|
|
1037
|
+
* <summary>(Legacy) Predefined builds</summary>
|
|
984
1038
|
*
|
|
985
|
-
*
|
|
986
|
-
*
|
|
1039
|
+
* If you use the {@glink getting-started/legacy/installation-methods/predefined-builds Predefined builds},
|
|
1040
|
+
* you cannot import any additional plugins. These builds already include the editor's core
|
|
1041
|
+
* and selected plugins and importing additional ones will cause some modules to be bundled and loaded twice.
|
|
987
1042
|
*
|
|
988
|
-
*
|
|
989
|
-
* build such a project, you will end up with the modules being included (and run) twice – first, because they are
|
|
990
|
-
* included inside the build package, and second, because they are required by the `Highlight` plugin.
|
|
1043
|
+
* Examples of valid and invalid import paths:
|
|
991
1044
|
*
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
*
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
-
*
|
|
999
|
-
* This scenario is very similar to the previous one, but has a different origin.
|
|
1000
|
-
*
|
|
1001
|
-
* Let's assume that you wanted to use CKEditor 5 from source.
|
|
1002
|
-
*
|
|
1003
|
-
* The correct way to do so is to import an editor and plugins and run them together like this:
|
|
1004
|
-
*
|
|
1005
|
-
* ```ts
|
|
1006
|
-
* import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
|
|
1007
|
-
* import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
|
|
1008
|
-
* import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
1009
|
-
* import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
|
|
1010
|
-
* import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
|
|
1011
|
-
*
|
|
1012
|
-
* ClassicEditor
|
|
1013
|
-
* .create( document.querySelector( '#editor' ), {
|
|
1014
|
-
* plugins: [ Essentials, Paragraph, Bold, Italic ],
|
|
1015
|
-
* toolbar: [ 'bold', 'italic' ]
|
|
1016
|
-
* } )
|
|
1017
|
-
* .then( editor => {
|
|
1018
|
-
* console.log( 'Editor was initialized', editor );
|
|
1019
|
-
* } )
|
|
1020
|
-
* .catch( error => {
|
|
1021
|
-
* console.error( error.stack );
|
|
1022
|
-
* } );
|
|
1045
|
+
* ```js
|
|
1046
|
+
* import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; // ✅
|
|
1047
|
+
* import { Highlight } from 'ckeditor5'; // ❌
|
|
1048
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
|
|
1049
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
|
|
1050
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight'; // ❌
|
|
1051
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight'; // ❌
|
|
1023
1052
|
* ```
|
|
1024
1053
|
*
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1054
|
+
* If you are missing some features from the
|
|
1055
|
+
* {@glink getting-started/legacy/installation-methods/predefined-builds#plugins-included-in-the-predefined-builds list of plugins},
|
|
1056
|
+
* you should switch to the {@glink updating/nim-migration/migration-to-new-installation-methods new installation methods}
|
|
1057
|
+
* which do not have this limitation.
|
|
1058
|
+
* If you cannot migrate to the new installation methods, try the
|
|
1059
|
+
* {@glink getting-started/legacy/installation-methods/predefined-builds#superbuild superbuild} instead.
|
|
1060
|
+
* This build contains all the editor features.
|
|
1061
|
+
* </details>
|
|
1062
|
+
*
|
|
1063
|
+
* <details>
|
|
1064
|
+
* <summary>(Legacy) Default imports and `src` imports</summary>
|
|
1065
|
+
*
|
|
1066
|
+
* If you use the {@glink getting-started/legacy/installation-methods/quick-start-other legacy customized installation}
|
|
1067
|
+
* method, you should only import code from the `@ckeditor/ckeditor5-<NAME>` packages. While you can import code from
|
|
1068
|
+
* the `@ckeditor/ckeditor5-<NAME>/src/*` files, it is not recommended as it can make migration to the new installation
|
|
1069
|
+
* methods more difficult.
|
|
1070
|
+
*
|
|
1071
|
+
* If you use this installation method, you should not import code from the `ckeditor5`, `ckeditor5-premium-features`,
|
|
1072
|
+
* or `@ckeditor/ckeditor5-build-<NAME>` packages.
|
|
1073
|
+
*
|
|
1074
|
+
* Examples of valid and invalid import paths:
|
|
1075
|
+
*
|
|
1076
|
+
* ```js
|
|
1077
|
+
* import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic'; // ✅
|
|
1078
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ✅
|
|
1079
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ✅ (not recommended)
|
|
1080
|
+
* import { Highlight } from 'ckeditor5'; // ❌
|
|
1081
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
|
|
1082
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight'; // ❌
|
|
1034
1083
|
* ```
|
|
1084
|
+
* </details>
|
|
1035
1085
|
*
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
* Remember: `@ckeditor/ckeditor5-build-*` packages contain editor builds and `@ckeditor/ckeditor5-editor-*` contain source editors.
|
|
1039
|
-
*
|
|
1040
|
-
* # Loading two or more builds on one page
|
|
1041
|
-
*
|
|
1042
|
-
* If you use CKEditor 5 builds, you might have loaded two (or more) `ckeditor.js` files on one web page.
|
|
1043
|
-
* Check your web page for duplicated `<script>` elements or make sure your page builder/bundler includes CKEditor only once.
|
|
1044
|
-
*
|
|
1045
|
-
* If you want to use two different types of editors at once, see the
|
|
1046
|
-
* {@glink getting-started/legacy/advanced/using-two-editors "Using two different editors"}
|
|
1047
|
-
* section.
|
|
1048
|
-
*
|
|
1049
|
-
* # Using outdated packages
|
|
1086
|
+
* <details>
|
|
1087
|
+
* <summary>(Legacy) DLL builds</summary>
|
|
1050
1088
|
*
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
* an outdated version of `@ckeditor/ckeditor5-image`, npm or yarn will need to install two different versions of
|
|
1054
|
-
* `@ckeditor/ckeditor5-core` because `@ckeditor/ckeditor5-editor-classic` and `@ckeditor/ckeditor5-image` may require
|
|
1055
|
-
* different versions of the core package.
|
|
1089
|
+
* If you are using the {@glink getting-started/legacy/advanced/alternative-setups/dll-builds legacy DLL builds},
|
|
1090
|
+
* you should not import any non-DLL modules.
|
|
1056
1091
|
*
|
|
1057
|
-
*
|
|
1058
|
-
* using tools like [`npm-check-updates`](https://www.npmjs.com/package/npm-check-updates) which simplify this process.
|
|
1092
|
+
* Examples of valid and invalid import paths:
|
|
1059
1093
|
*
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1063
|
-
*
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
* same major version. This means that in the `x.y.z` version, the `x` is the same for all packages. This is the simplest way to check
|
|
1071
|
-
* whether you use packages coming from the same CKEditor 5 version. You can read more about versioning in the
|
|
1072
|
-
* {@glink updating/versioning-policy Versioning policy} guide.
|
|
1073
|
-
*
|
|
1074
|
-
* # Packages were duplicated in `node_modules`
|
|
1075
|
-
*
|
|
1076
|
-
* In some situations, especially when calling `npm install` multiple times, it may happen
|
|
1077
|
-
* that npm will not correctly "deduplicate" packages.
|
|
1094
|
+
* ```js
|
|
1095
|
+
* import 'ckeditor5/build/ckeditor5-dll.js';// ✅
|
|
1096
|
+
* import '@ckeditor/ckeditor5-editor-classic/build/editor-classic.js';// ✅
|
|
1097
|
+
* import '@ckeditor/ckeditor5-highlight/build/highlight.js';// ✅
|
|
1098
|
+
* import { Highlight } from 'ckeditor5'; // ❌
|
|
1099
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight/dist/index.js'; // ❌
|
|
1100
|
+
* import { Highlight } from '@ckeditor/ckeditor5-highlight'; // ❌
|
|
1101
|
+
* import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js'; // ❌
|
|
1102
|
+
* ```
|
|
1103
|
+
* </details>
|
|
1078
1104
|
*
|
|
1079
|
-
*
|
|
1080
|
-
* However, it is known to fail to do so from time to time.
|
|
1105
|
+
* # Reinstall `node_modules`
|
|
1081
1106
|
*
|
|
1082
|
-
*
|
|
1107
|
+
* Usually, npm and other package managers deduplicate all packages - for example, `ckeditor5` is only installed once
|
|
1108
|
+
* in `node_modules/`. However, it is known to fail to do so occasionally.
|
|
1083
1109
|
*
|
|
1084
|
-
*
|
|
1085
|
-
* is known to help in most cases.
|
|
1086
|
-
* * If you use `yarn.lock` or `package-lock.json`, remove it before `npm install`.
|
|
1087
|
-
* * Check whether all CKEditor 5 packages are up to date and reinstall them
|
|
1088
|
-
* if you changed anything (`rm -rf node_modules && npm install`).
|
|
1110
|
+
* To rule out this possibility, you can try the following:
|
|
1089
1111
|
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
|
|
1112
|
+
* 1. Remove the `node_modules` directory.
|
|
1113
|
+
* 2. Remove the `package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml` files (depending on the package manager used).
|
|
1114
|
+
* 3. Run `npm install` to reinstall all packages.
|
|
1115
|
+
* 4. Run `npm ls` to check how many times packages like `@ckeditor/ckeditor5-core` are installed.
|
|
1116
|
+
* If they are installed more than once, verify which package causes that.
|
|
1093
1117
|
*
|
|
1094
1118
|
* @error ckeditor-duplicated-modules
|
|
1095
1119
|
*/ throw new CKEditorError('ckeditor-duplicated-modules', null);
|
|
@@ -2181,6 +2205,7 @@ function initObservable(observable) {
|
|
|
2181
2205
|
* @returns Number of items returned by that iterable.
|
|
2182
2206
|
*/ function count(iterable) {
|
|
2183
2207
|
let count = 0;
|
|
2208
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2184
2209
|
for (const _ of iterable){
|
|
2185
2210
|
count++;
|
|
2186
2211
|
}
|