@ckeditor/ckeditor5-utils 34.2.0 → 35.1.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/LICENSE.md +1 -1
  3. package/package.json +19 -8
  4. package/src/areconnectedthroughproperties.js +54 -71
  5. package/src/ckeditorerror.js +92 -114
  6. package/src/collection.js +594 -762
  7. package/src/comparearrays.js +22 -28
  8. package/src/config.js +193 -223
  9. package/src/count.js +8 -12
  10. package/src/diff.js +85 -110
  11. package/src/difftochanges.js +47 -57
  12. package/src/dom/createelement.js +17 -25
  13. package/src/dom/emittermixin.js +202 -263
  14. package/src/dom/getancestors.js +9 -13
  15. package/src/dom/getborderwidths.js +10 -13
  16. package/src/dom/getcommonancestor.js +9 -15
  17. package/src/dom/getdatafromelement.js +5 -9
  18. package/src/dom/getpositionedancestor.js +9 -14
  19. package/src/dom/global.js +15 -4
  20. package/src/dom/indexof.js +7 -11
  21. package/src/dom/insertat.js +2 -4
  22. package/src/dom/iscomment.js +2 -5
  23. package/src/dom/isnode.js +10 -12
  24. package/src/dom/isrange.js +2 -4
  25. package/src/dom/istext.js +2 -4
  26. package/src/dom/isvisible.js +2 -4
  27. package/src/dom/iswindow.js +11 -16
  28. package/src/dom/position.js +220 -410
  29. package/src/dom/rect.js +335 -414
  30. package/src/dom/remove.js +5 -8
  31. package/src/dom/resizeobserver.js +109 -342
  32. package/src/dom/scroll.js +151 -183
  33. package/src/dom/setdatainelement.js +5 -9
  34. package/src/dom/tounit.js +10 -12
  35. package/src/elementreplacer.js +30 -44
  36. package/src/emittermixin.js +368 -634
  37. package/src/env.js +109 -116
  38. package/src/eventinfo.js +12 -65
  39. package/src/fastdiff.js +96 -128
  40. package/src/first.js +8 -12
  41. package/src/focustracker.js +77 -133
  42. package/src/index.js +0 -9
  43. package/src/inserttopriorityarray.js +9 -30
  44. package/src/isiterable.js +2 -4
  45. package/src/keyboard.js +117 -196
  46. package/src/keystrokehandler.js +72 -88
  47. package/src/language.js +9 -15
  48. package/src/locale.js +61 -158
  49. package/src/mapsequal.js +12 -17
  50. package/src/mix.js +17 -16
  51. package/src/nth.js +8 -11
  52. package/src/objecttomap.js +7 -11
  53. package/src/observablemixin.js +474 -778
  54. package/src/priorities.js +20 -32
  55. package/src/spy.js +3 -6
  56. package/src/toarray.js +2 -13
  57. package/src/tomap.js +8 -10
  58. package/src/translation-service.js +57 -93
  59. package/src/uid.js +34 -38
  60. package/src/unicode.js +28 -43
  61. package/src/version.js +134 -143
package/src/version.js CHANGED
@@ -2,156 +2,147 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/version
8
7
  */
9
-
10
8
  /* globals window, global */
11
-
12
9
  import CKEditorError from './ckeditorerror';
13
-
14
- const version = '34.2.0';
15
-
10
+ const version = '35.1.0';
16
11
  export default version;
17
-
18
12
  /* istanbul ignore next */
19
13
  const windowOrGlobal = typeof window === 'object' ? window : global;
20
-
21
14
  /* istanbul ignore next */
22
- if ( windowOrGlobal.CKEDITOR_VERSION ) {
23
- /**
24
- * This error is thrown when due to a mistake in how CKEditor 5 was installed or initialized, some
25
- * of its modules were duplicated (evaluated and executed twice). Module duplication leads to inevitable runtime
26
- * errors.
27
- *
28
- * There are many situations in which some modules can be loaded twice. In the worst case scenario,
29
- * you may need to check your project for each of these issues and fix them all.
30
- *
31
- * # Trying to add a plugin to an existing build
32
- *
33
- * If you import an existing CKEditor 5 build and a plugin like this:
34
- *
35
- * import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
36
- * import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight';
37
- *
38
- * Then your project loads some CKEditor 5 packages twice. How does it happen?
39
- *
40
- * The build package contains a file which is already compiled with webpack. This means
41
- * that it contains all the necessary code from e.g. `@ckeditor/ckeditor5-engine` and `@ckeditor/ckeditor5-utils`.
42
- *
43
- * However, the `Highlight` plugin imports some of the modules from these packages, too. If you ask webpack to
44
- * build such a project, you will end up with the modules being included (and run) twice — first, because they are
45
- * included inside the build package, and second, because they are required by the `Highlight` plugin.
46
- *
47
- * Therefore, **you must never add plugins to an existing build** unless your plugin has no dependencies.
48
- *
49
- * Adding plugins to a build is done by taking the source version of this build (so, before it was built with webpack)
50
- * and adding plugins there. In this situation, webpack will know that it only needs to load each plugin once.
51
- *
52
- * Read more in the {@glink installation/getting-started/installing-plugins "Installing plugins"} guide.
53
- *
54
- * # Confused an editor build with an editor implementation
55
- *
56
- * This scenario is very similar to the previous one, but has a different origin.
57
- *
58
- * Let's assume that you wanted to use CKEditor 5 from source, as explained in the
59
- * {@glink installation/advanced/alternative-setups/integrating-from-source "Building from source"} section
60
- * or in the {@glink framework/guides/quick-start "Quick start"} guide of CKEditor 5 Framework.
61
- *
62
- * The correct way to do so is to import an editor and plugins and run them together like this:
63
- *
64
- * import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
65
- * import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
66
- * import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
67
- * import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
68
- * import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
69
- *
70
- * ClassicEditor
71
- * .create( document.querySelector( '#editor' ), {
72
- * plugins: [ Essentials, Paragraph, Bold, Italic ],
73
- * toolbar: [ 'bold', 'italic' ]
74
- * } )
75
- * .then( editor => {
76
- * console.log( 'Editor was initialized', editor );
77
- * } )
78
- * .catch( error => {
79
- * console.error( error.stack );
80
- * } );
81
- *
82
- * However, you might have mistakenly imported a build instead of the source `ClassicEditor`. In this case
83
- * your imports will look like this:
84
- *
85
- * import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
86
- * import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
87
- * import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
88
- * import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
89
- * import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
90
- *
91
- * This creates the same situation as in the previous section because you use a build together with source plugins.
92
- *
93
- * Remember: `@ckeditor/ckeditor5-build-*` packages contain editor builds and `@ckeditor/ckeditor5-editor-*` contain source editors.
94
- *
95
- * # Loading two or more builds on one page
96
- *
97
- * If you use CKEditor 5 builds, you might have loaded two (or more) `ckeditor.js` files on one web page.
98
- * Check your web page for duplicated `<script>` elements or make sure your page builder/bundler includes CKEditor only once.
99
- *
100
- * If you want to use two different types of editors at once, see the
101
- * {@glink installation/advanced/using-two-editors "Using two different editors"}
102
- * section.
103
- *
104
- * # Using outdated packages
105
- *
106
- * Building CKEditor 5 from source requires using multiple npm packages. These packages have their dependencies
107
- * to other packages. If you use the latest version of, for example, `@ckeditor/ckeditor5-editor-classic` with
108
- * an outdated version of `@ckeditor/ckeditor5-image`, npm or yarn will need to install two different versions of
109
- * `@ckeditor/ckeditor5-core` because `@ckeditor/ckeditor5-editor-classic` and `@ckeditor/ckeditor5-image` may require
110
- * different versions of the core package.
111
- *
112
- * The solution to this issue is to update all packages to their latest version. We recommend
113
- * using tools like [`npm-check-updates`](https://www.npmjs.com/package/npm-check-updates) which simplify this process.
114
- *
115
- * # Conflicting version of dependencies
116
- *
117
- * This is a special case of the previous scenario. If you use CKEditor 5 with some third-party plugins,
118
- * it may happen that even if you use the latest versions of the official packages and the latest version of
119
- * these third-party packages, there will be a conflict between some of their dependencies.
120
- *
121
- * Such a problem can be resolved by either downgrading CKEditor 5 packages (which we do not recommend) or
122
- * asking the author of the third-party package to upgrade its depdendencies (or forking their project and doing this yourself).
123
- *
124
- * **Note:** All official CKEditor 5 packages (excluding integrations and `ckeditor5-dev-*` packages) are released in the
125
- * same major version. This is &mdash; in the `x.y.z`, the `x` is the same for all packages. This is the simplest way to check
126
- * whether you use packages coming from the same CKEditor 5 version. You can read more about versioning in the
127
- * {@glink support/versioning-policy Versioning policy} guide.
128
- *
129
- * # Packages were duplicated in `node_modules`
130
- *
131
- * In some situations, especially when calling `npm install` multiple times, it may happen
132
- * that npm will not correctly "deduplicate" packages.
133
- *
134
- * Normally, npm deduplicates all packages so, for example, `@ckeditor/ckeditor5-core` is installed only once in `node_modules/`.
135
- * However, it is known to fail to do so from time to time.
136
- *
137
- * We recommend checking if any of the steps listed below help:
138
- *
139
- * * `rm -rf node_modules && npm install` to make sure you have a clean `node_modules/` directory. This step
140
- * is known to help in most cases.
141
- * * If you use `yarn.lock` or `package-lock.json`, remove it before `npm install`.
142
- * * Check whether all CKEditor 5 packages are up to date and reinstall them
143
- * if you changed anything (`rm -rf node_modules && npm install`).
144
- *
145
- * If all packages are correct and compatible with each other, the steps above are known to help. If not, you may
146
- * try to check with `npm ls` how many times packages like `@ckeditor/ckeditor5-core`, `@ckeditor/ckeditor5-engine` and
147
- *`@ckeditor/ckeditor5-utils` are installed. If more than once, verify which package causes that.
148
- *
149
- * @error ckeditor-duplicated-modules
150
- */
151
- throw new CKEditorError(
152
- 'ckeditor-duplicated-modules',
153
- null
154
- );
155
- } else {
156
- windowOrGlobal.CKEDITOR_VERSION = version;
15
+ if (windowOrGlobal.CKEDITOR_VERSION) {
16
+ /**
17
+ * This error is thrown when due to a mistake in how CKEditor 5 was installed or initialized, some
18
+ * of its modules were duplicated (evaluated and executed twice). Module duplication leads to inevitable runtime
19
+ * errors.
20
+ *
21
+ * There are many situations in which some modules can be loaded twice. In the worst case scenario,
22
+ * you may need to check your project for each of these issues and fix them all.
23
+ *
24
+ * # Trying to add a plugin to an existing build
25
+ *
26
+ * If you import an existing CKEditor 5 build and a plugin like this:
27
+ *
28
+ * import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
29
+ * import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight';
30
+ *
31
+ * Then your project loads some CKEditor 5 packages twice. How does it happen?
32
+ *
33
+ * The build package contains a file which is already compiled with webpack. This means
34
+ * that it contains all the necessary code from e.g. `@ckeditor/ckeditor5-engine` and `@ckeditor/ckeditor5-utils`.
35
+ *
36
+ * However, the `Highlight` plugin imports some of the modules from these packages, too. If you ask webpack to
37
+ * build such a project, you will end up with the modules being included (and run) twice &mdash; first, because they are
38
+ * included inside the build package, and second, because they are required by the `Highlight` plugin.
39
+ *
40
+ * Therefore, **you must never add plugins to an existing build** unless your plugin has no dependencies.
41
+ *
42
+ * Adding plugins to a build is done by taking the source version of this build (so, before it was built with webpack)
43
+ * and adding plugins there. In this situation, webpack will know that it only needs to load each plugin once.
44
+ *
45
+ * Read more in the {@glink installation/getting-started/installing-plugins "Installing plugins"} guide.
46
+ *
47
+ * # Confused an editor build with an editor implementation
48
+ *
49
+ * This scenario is very similar to the previous one, but has a different origin.
50
+ *
51
+ * Let's assume that you wanted to use CKEditor 5 from source, as explained in the
52
+ * {@glink installation/advanced/alternative-setups/integrating-from-source "Building from source"} section
53
+ * or in the {@glink framework/guides/quick-start "Quick start"} guide of CKEditor 5 Framework.
54
+ *
55
+ * The correct way to do so is to import an editor and plugins and run them together like this:
56
+ *
57
+ * import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
58
+ * import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
59
+ * import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
60
+ * import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
61
+ * import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
62
+ *
63
+ * ClassicEditor
64
+ * .create( document.querySelector( '#editor' ), {
65
+ * plugins: [ Essentials, Paragraph, Bold, Italic ],
66
+ * toolbar: [ 'bold', 'italic' ]
67
+ * } )
68
+ * .then( editor => {
69
+ * console.log( 'Editor was initialized', editor );
70
+ * } )
71
+ * .catch( error => {
72
+ * console.error( error.stack );
73
+ * } );
74
+ *
75
+ * However, you might have mistakenly imported a build instead of the source `ClassicEditor`. In this case
76
+ * your imports will look like this:
77
+ *
78
+ * import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
79
+ * import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
80
+ * import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
81
+ * import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
82
+ * import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
83
+ *
84
+ * This creates the same situation as in the previous section because you use a build together with source plugins.
85
+ *
86
+ * Remember: `@ckeditor/ckeditor5-build-*` packages contain editor builds and `@ckeditor/ckeditor5-editor-*` contain source editors.
87
+ *
88
+ * # Loading two or more builds on one page
89
+ *
90
+ * If you use CKEditor 5 builds, you might have loaded two (or more) `ckeditor.js` files on one web page.
91
+ * Check your web page for duplicated `<script>` elements or make sure your page builder/bundler includes CKEditor only once.
92
+ *
93
+ * If you want to use two different types of editors at once, see the
94
+ * {@glink installation/advanced/using-two-editors "Using two different editors"}
95
+ * section.
96
+ *
97
+ * # Using outdated packages
98
+ *
99
+ * Building CKEditor 5 from source requires using multiple npm packages. These packages have their dependencies
100
+ * to other packages. If you use the latest version of, for example, `@ckeditor/ckeditor5-editor-classic` with
101
+ * an outdated version of `@ckeditor/ckeditor5-image`, npm or yarn will need to install two different versions of
102
+ * `@ckeditor/ckeditor5-core` because `@ckeditor/ckeditor5-editor-classic` and `@ckeditor/ckeditor5-image` may require
103
+ * different versions of the core package.
104
+ *
105
+ * The solution to this issue is to update all packages to their latest version. We recommend
106
+ * using tools like [`npm-check-updates`](https://www.npmjs.com/package/npm-check-updates) which simplify this process.
107
+ *
108
+ * # Conflicting version of dependencies
109
+ *
110
+ * This is a special case of the previous scenario. If you use CKEditor 5 with some third-party plugins,
111
+ * it may happen that even if you use the latest versions of the official packages and the latest version of
112
+ * these third-party packages, there will be a conflict between some of their dependencies.
113
+ *
114
+ * Such a problem can be resolved by either downgrading CKEditor 5 packages (which we do not recommend) or
115
+ * asking the author of the third-party package to upgrade its depdendencies (or forking their project and doing this yourself).
116
+ *
117
+ * **Note:** All official CKEditor 5 packages (excluding integrations and `ckeditor5-dev-*` packages) are released in the
118
+ * same major version. This is &mdash; in the `x.y.z`, the `x` is the same for all packages. This is the simplest way to check
119
+ * whether you use packages coming from the same CKEditor 5 version. You can read more about versioning in the
120
+ * {@glink support/versioning-policy Versioning policy} guide.
121
+ *
122
+ * # Packages were duplicated in `node_modules`
123
+ *
124
+ * In some situations, especially when calling `npm install` multiple times, it may happen
125
+ * that npm will not correctly "deduplicate" packages.
126
+ *
127
+ * Normally, npm deduplicates all packages so, for example, `@ckeditor/ckeditor5-core` is installed only once in `node_modules/`.
128
+ * However, it is known to fail to do so from time to time.
129
+ *
130
+ * We recommend checking if any of the steps listed below help:
131
+ *
132
+ * * `rm -rf node_modules && npm install` to make sure you have a clean `node_modules/` directory. This step
133
+ * is known to help in most cases.
134
+ * * If you use `yarn.lock` or `package-lock.json`, remove it before `npm install`.
135
+ * * Check whether all CKEditor 5 packages are up to date and reinstall them
136
+ * if you changed anything (`rm -rf node_modules && npm install`).
137
+ *
138
+ * If all packages are correct and compatible with each other, the steps above are known to help. If not, you may
139
+ * try to check with `npm ls` how many times packages like `@ckeditor/ckeditor5-core`, `@ckeditor/ckeditor5-engine` and
140
+ *`@ckeditor/ckeditor5-utils` are installed. If more than once, verify which package causes that.
141
+ *
142
+ * @error ckeditor-duplicated-modules
143
+ */
144
+ throw new CKEditorError('ckeditor-duplicated-modules', null);
145
+ }
146
+ else {
147
+ windowOrGlobal.CKEDITOR_VERSION = version;
157
148
  }