@ckeditor/ckeditor5-utils 34.0.0 → 35.0.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 +3 -3
  3. package/package.json +19 -8
  4. package/src/areconnectedthroughproperties.js +0 -92
  5. package/src/ckeditorerror.js +0 -218
  6. package/src/collection.js +0 -785
  7. package/src/comparearrays.js +0 -51
  8. package/src/config.js +0 -246
  9. package/src/count.js +0 -26
  10. package/src/diff.js +0 -138
  11. package/src/difftochanges.js +0 -86
  12. package/src/dom/createelement.js +0 -49
  13. package/src/dom/emittermixin.js +0 -341
  14. package/src/dom/getancestors.js +0 -31
  15. package/src/dom/getborderwidths.js +0 -27
  16. package/src/dom/getcommonancestor.js +0 -31
  17. package/src/dom/getdatafromelement.js +0 -24
  18. package/src/dom/getpositionedancestor.js +0 -28
  19. package/src/dom/global.js +0 -26
  20. package/src/dom/indexof.js +0 -25
  21. package/src/dom/insertat.js +0 -19
  22. package/src/dom/iscomment.js +0 -20
  23. package/src/dom/isnode.js +0 -26
  24. package/src/dom/isrange.js +0 -18
  25. package/src/dom/istext.js +0 -18
  26. package/src/dom/isvisible.js +0 -25
  27. package/src/dom/iswindow.js +0 -30
  28. package/src/dom/position.js +0 -518
  29. package/src/dom/rect.js +0 -443
  30. package/src/dom/remove.js +0 -21
  31. package/src/dom/resizeobserver.js +0 -378
  32. package/src/dom/scroll.js +0 -302
  33. package/src/dom/setdatainelement.js +0 -24
  34. package/src/dom/tounit.js +0 -27
  35. package/src/elementreplacer.js +0 -57
  36. package/src/emittermixin.js +0 -719
  37. package/src/env.js +0 -190
  38. package/src/eventinfo.js +0 -79
  39. package/src/fastdiff.js +0 -261
  40. package/src/first.js +0 -24
  41. package/src/focustracker.js +0 -157
  42. package/src/index.js +0 -45
  43. package/src/inserttopriorityarray.js +0 -42
  44. package/src/isiterable.js +0 -18
  45. package/src/keyboard.js +0 -301
  46. package/src/keystrokehandler.js +0 -130
  47. package/src/language.js +0 -26
  48. package/src/locale.js +0 -176
  49. package/src/mapsequal.js +0 -32
  50. package/src/mix.js +0 -47
  51. package/src/nth.js +0 -31
  52. package/src/objecttomap.js +0 -29
  53. package/src/observablemixin.js +0 -908
  54. package/src/priorities.js +0 -44
  55. package/src/spy.js +0 -25
  56. package/src/toarray.js +0 -18
  57. package/src/tomap.js +0 -29
  58. package/src/translation-service.js +0 -216
  59. package/src/uid.js +0 -59
  60. package/src/unicode.js +0 -106
  61. package/src/version.js +0 -157
@@ -1,218 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/ckeditorerror
8
- */
9
-
10
- /* globals console */
11
-
12
- /**
13
- * URL to the documentation with error codes.
14
- */
15
- export const DOCUMENTATION_URL =
16
- 'https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html';
17
-
18
- /**
19
- * The CKEditor error class.
20
- *
21
- * You should throw `CKEditorError` when:
22
- *
23
- * * An unexpected situation occurred and the editor (most probably) will not work properly. Such exception will be handled
24
- * by the {@link module:watchdog/watchdog~Watchdog watchdog} (if it is integrated),
25
- * * If the editor is incorrectly integrated or the editor API is used in the wrong way. This way you will give
26
- * feedback to the developer as soon as possible. Keep in mind that for common integration issues which should not
27
- * stop editor initialization (like missing upload adapter, wrong name of a toolbar component) we use
28
- * {@link module:utils/ckeditorerror~logWarning `logWarning()`} and
29
- * {@link module:utils/ckeditorerror~logError `logError()`}
30
- * to improve developers experience and let them see the a working editor as soon as possible.
31
- *
32
- * /**
33
- * * Error thrown when a plugin cannot be loaded due to JavaScript errors, lack of plugins with a given name, etc.
34
- * *
35
- * * @error plugin-load
36
- * * @param pluginName The name of the plugin that could not be loaded.
37
- * * @param moduleName The name of the module which tried to load this plugin.
38
- * * /
39
- * throw new CKEditorError( 'plugin-load', {
40
- * pluginName: 'foo',
41
- * moduleName: 'bar'
42
- * } );
43
- *
44
- * @extends Error
45
- */
46
- export default class CKEditorError extends Error {
47
- /**
48
- * Creates an instance of the CKEditorError class.
49
- *
50
- * @param {String} errorName The error id in an `error-name` format. A link to this error documentation page will be added
51
- * to the thrown error's `message`.
52
- * @param {Object|null} context A context of the error by which the {@link module:watchdog/watchdog~Watchdog watchdog}
53
- * is able to determine which editor crashed. It should be an editor instance or a property connected to it. It can be also
54
- * a `null` value if the editor should not be restarted in case of the error (e.g. during the editor initialization).
55
- * The error context should be checked using the `areConnectedThroughProperties( editor, context )` utility
56
- * to check if the object works as the context.
57
- * @param {Object} [data] Additional data describing the error. A stringified version of this object
58
- * will be appended to the error message, so the data are quickly visible in the console. The original
59
- * data object will also be later available under the {@link #data} property.
60
- */
61
- constructor( errorName, context, data ) {
62
- super( getErrorMessage( errorName, data ) );
63
-
64
- /**
65
- * @type {String}
66
- */
67
- this.name = 'CKEditorError';
68
-
69
- /**
70
- * A context of the error by which the Watchdog is able to determine which editor crashed.
71
- *
72
- * @type {Object|null}
73
- */
74
- this.context = context;
75
-
76
- /**
77
- * The additional error data passed to the constructor. Undefined if none was passed.
78
- *
79
- * @type {Object|undefined}
80
- */
81
- this.data = data;
82
- }
83
-
84
- /**
85
- * Checks if the error is of the `CKEditorError` type.
86
- * @returns {Boolean}
87
- */
88
- is( type ) {
89
- return type === 'CKEditorError';
90
- }
91
-
92
- /**
93
- * A utility that ensures that the thrown error is a {@link module:utils/ckeditorerror~CKEditorError} one.
94
- * It is useful when combined with the {@link module:watchdog/watchdog~Watchdog} feature, which can restart the editor in case
95
- * of a {@link module:utils/ckeditorerror~CKEditorError} error.
96
- *
97
- * @static
98
- * @param {Error} err The error to rethrow.
99
- * @param {Object} context An object connected through properties with the editor instance. This context will be used
100
- * by the watchdog to verify which editor should be restarted.
101
- */
102
- static rethrowUnexpectedError( err, context ) {
103
- if ( err.is && err.is( 'CKEditorError' ) ) {
104
- throw err;
105
- }
106
-
107
- /**
108
- * An unexpected error occurred inside the CKEditor 5 codebase. This error will look like the original one
109
- * to make the debugging easier.
110
- *
111
- * This error is only useful when the editor is initialized using the {@link module:watchdog/watchdog~Watchdog} feature.
112
- * In case of such error (or any {@link module:utils/ckeditorerror~CKEditorError} error) the watchdog should restart the editor.
113
- *
114
- * @error unexpected-error
115
- */
116
- const error = new CKEditorError( err.message, context );
117
-
118
- // Restore the original stack trace to make the error look like the original one.
119
- // See https://github.com/ckeditor/ckeditor5/issues/5595 for more details.
120
- error.stack = err.stack;
121
-
122
- throw error;
123
- }
124
- }
125
-
126
- /**
127
- * Logs a warning to the console with a properly formatted message and adds a link to the documentation.
128
- * Use whenever you want to log a warning to the console.
129
- *
130
- * /**
131
- * * There was a problem processing the configuration of the toolbar. The item with the given
132
- * * name does not exist, so it was omitted when rendering the toolbar.
133
- * *
134
- * * @error toolbarview-item-unavailable
135
- * * @param {String} name The name of the component.
136
- * * /
137
- * logWarning( 'toolbarview-item-unavailable', { name } );
138
- *
139
- * See also {@link module:utils/ckeditorerror~CKEditorError} for an explanation when to throw an error and when to log
140
- * a warning or an error to the console.
141
- *
142
- * @param {String} errorName The error name to be logged.
143
- * @param {Object} [data] Additional data to be logged.
144
- */
145
- export function logWarning( errorName, data ) {
146
- console.warn( ...formatConsoleArguments( errorName, data ) );
147
- }
148
-
149
- /**
150
- * Logs an error to the console with a properly formatted message and adds a link to the documentation.
151
- * Use whenever you want to log an error to the console.
152
- *
153
- * /**
154
- * * There was a problem processing the configuration of the toolbar. The item with the given
155
- * * name does not exist, so it was omitted when rendering the toolbar.
156
- * *
157
- * * @error toolbarview-item-unavailable
158
- * * @param {String} name The name of the component.
159
- * * /
160
- * logError( 'toolbarview-item-unavailable', { name } );
161
- *
162
- * **Note**: In most cases logging a warning using {@link module:utils/ckeditorerror~logWarning} is enough.
163
- *
164
- * See also {@link module:utils/ckeditorerror~CKEditorError} for an explanation when to use each method.
165
- *
166
- * @param {String} errorName The error name to be logged.
167
- * @param {Object} [data] Additional data to be logged.
168
- */
169
- export function logError( errorName, data ) {
170
- console.error( ...formatConsoleArguments( errorName, data ) );
171
- }
172
-
173
- // Returns formatted link to documentation message.
174
- //
175
- // @private
176
- // @param {String} errorName
177
- // @returns {string}
178
- function getLinkToDocumentationMessage( errorName ) {
179
- return `\nRead more: ${ DOCUMENTATION_URL }#error-${ errorName }`;
180
- }
181
-
182
- // Returns formatted error message.
183
- //
184
- // @private
185
- // @param {String} errorName
186
- // @param {Object} [data]
187
- // @returns {string}
188
- function getErrorMessage( errorName, data ) {
189
- const processedObjects = new WeakSet();
190
- const circularReferencesReplacer = ( key, value ) => {
191
- if ( typeof value === 'object' && value !== null ) {
192
- if ( processedObjects.has( value ) ) {
193
- return `[object ${ value.constructor.name }]`;
194
- }
195
-
196
- processedObjects.add( value );
197
- }
198
-
199
- return value;
200
- };
201
-
202
- const stringifiedData = data ? ` ${ JSON.stringify( data, circularReferencesReplacer ) }` : '';
203
- const documentationLink = getLinkToDocumentationMessage( errorName );
204
-
205
- return errorName + stringifiedData + documentationLink;
206
- }
207
-
208
- // Returns formatted console error arguments.
209
- //
210
- // @private
211
- // @param {String} errorName
212
- // @param {Object} [data]
213
- // @returns {Array}
214
- function formatConsoleArguments( errorName, data ) {
215
- const documentationMessage = getLinkToDocumentationMessage( errorName );
216
-
217
- return data ? [ errorName, data, documentationMessage ] : [ errorName, documentationMessage ];
218
- }