@ckeditor/ckeditor5-core 33.0.0 → 34.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.
package/README.md CHANGED
@@ -3,7 +3,8 @@ CKEditor 5 core editor architecture
3
3
 
4
4
  [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-core.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-core)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
6
- [![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://travis-ci.com/ckeditor/ckeditor5)
6
+ [![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://app.travis-ci.com/github/ckeditor/ckeditor5)
7
+ ![Dependency Status](https://img.shields.io/librariesio/release/npm/@ckeditor/ckeditor5-core)
7
8
 
8
9
  This package implements CKEditor 5's core editor architecture — a set of classes and interfaces which glue everything together.
9
10
 
@@ -26,7 +26,7 @@ msgstr "Remove colour"
26
26
 
27
27
  msgctxt "The label used by a button next to the color palette in the color picker that restores the default value if the default table properties are specified."
28
28
  msgid "Restore default"
29
- msgstr ""
29
+ msgstr "Restore default"
30
30
 
31
31
  msgctxt "Label for the Save button."
32
32
  msgid "Save"
@@ -26,7 +26,7 @@ msgstr "Ukloni boju"
26
26
 
27
27
  msgctxt "The label used by a button next to the color palette in the color picker that restores the default value if the default table properties are specified."
28
28
  msgid "Restore default"
29
- msgstr ""
29
+ msgstr "Vrati tvorničke postavke"
30
30
 
31
31
  msgctxt "Label for the Save button."
32
32
  msgid "Save"
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Javanese (https://www.transifex.com/ckeditor/teams/11143/jv/)\n"
16
+ "Language: jv\n"
17
+ "Plural-Forms: nplurals=1; plural=0;\n"
18
+
19
+ msgctxt "Label for the Cancel button."
20
+ msgid "Cancel"
21
+ msgstr "Batal"
22
+
23
+ msgctxt "The label used by a button next to the color palette in the color picker that removes the color (resets it to an empty value, example usages in font color or table properties)."
24
+ msgid "Remove color"
25
+ msgstr "Busek warni"
26
+
27
+ msgctxt "The label used by a button next to the color palette in the color picker that restores the default value if the default table properties are specified."
28
+ msgid "Restore default"
29
+ msgstr "Mangsulaken default"
30
+
31
+ msgctxt "Label for the Save button."
32
+ msgid "Save"
33
+ msgstr "Rimat"
34
+
35
+ msgctxt "Label of a toolbar button which reveals more toolbar items."
36
+ msgid "Show more items"
37
+ msgstr "Tampilaken langkung kathah"
38
+
39
+ msgctxt "Label for an ‘X of Y’ status of a typical next/previous navigation. For instance, ‘Page 5 of 20’ or 'Search result 5 of 20'."
40
+ msgid "%0 of %1"
41
+ msgstr "%0 saking %1"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-core",
3
- "version": "33.0.0",
3
+ "version": "34.0.0",
4
4
  "description": "The core architecture of CKEditor 5 – the best browser-based rich text editor.",
5
5
  "keywords": [
6
6
  "wysiwyg",
@@ -23,25 +23,25 @@
23
23
  ],
24
24
  "main": "src/index.js",
25
25
  "dependencies": {
26
- "@ckeditor/ckeditor5-engine": "^33.0.0",
27
- "@ckeditor/ckeditor5-ui": "^33.0.0",
28
- "@ckeditor/ckeditor5-utils": "^33.0.0",
26
+ "@ckeditor/ckeditor5-engine": "^34.0.0",
27
+ "@ckeditor/ckeditor5-ui": "^34.0.0",
28
+ "@ckeditor/ckeditor5-utils": "^34.0.0",
29
29
  "lodash-es": "^4.17.15"
30
30
  },
31
31
  "devDependencies": {
32
- "@ckeditor/ckeditor5-autoformat": "^33.0.0",
33
- "@ckeditor/ckeditor5-basic-styles": "^33.0.0",
34
- "@ckeditor/ckeditor5-block-quote": "^33.0.0",
35
- "@ckeditor/ckeditor5-editor-classic": "^33.0.0",
36
- "@ckeditor/ckeditor5-essentials": "^33.0.0",
37
- "@ckeditor/ckeditor5-heading": "^33.0.0",
38
- "@ckeditor/ckeditor5-image": "^33.0.0",
39
- "@ckeditor/ckeditor5-indent": "^33.0.0",
40
- "@ckeditor/ckeditor5-link": "^33.0.0",
41
- "@ckeditor/ckeditor5-list": "^33.0.0",
42
- "@ckeditor/ckeditor5-media-embed": "^33.0.0",
43
- "@ckeditor/ckeditor5-paragraph": "^33.0.0",
44
- "@ckeditor/ckeditor5-table": "^33.0.0"
32
+ "@ckeditor/ckeditor5-autoformat": "^34.0.0",
33
+ "@ckeditor/ckeditor5-basic-styles": "^34.0.0",
34
+ "@ckeditor/ckeditor5-block-quote": "^34.0.0",
35
+ "@ckeditor/ckeditor5-editor-classic": "^34.0.0",
36
+ "@ckeditor/ckeditor5-essentials": "^34.0.0",
37
+ "@ckeditor/ckeditor5-heading": "^34.0.0",
38
+ "@ckeditor/ckeditor5-image": "^34.0.0",
39
+ "@ckeditor/ckeditor5-indent": "^34.0.0",
40
+ "@ckeditor/ckeditor5-link": "^34.0.0",
41
+ "@ckeditor/ckeditor5-list": "^34.0.0",
42
+ "@ckeditor/ckeditor5-media-embed": "^34.0.0",
43
+ "@ckeditor/ckeditor5-paragraph": "^34.0.0",
44
+ "@ckeditor/ckeditor5-table": "^34.0.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=14.0.0",
@@ -108,6 +108,14 @@ export default class Editor {
108
108
  */
109
109
  this.t = this.locale.t;
110
110
 
111
+ /**
112
+ * A set of lock IDs for the {@link #isReadOnly} getter.
113
+ *
114
+ * @private
115
+ * @type {Set.<String|Symbol>}
116
+ */
117
+ this._readOnlyLocks = new Set();
118
+
111
119
  /**
112
120
  * Commands registered to the editor.
113
121
  *
@@ -142,21 +150,6 @@ export default class Editor {
142
150
  this.once( 'ready', () => ( this.state = 'ready' ), { priority: 'high' } );
143
151
  this.once( 'destroy', () => ( this.state = 'destroyed' ), { priority: 'high' } );
144
152
 
145
- /**
146
- * Defines whether this editor is in read-only mode.
147
- *
148
- * In read-only mode the editor {@link #commands commands} are disabled so it is not possible
149
- * to modify the document by using them. Also, the editable element(s) become non-editable.
150
- *
151
- * In order to make the editor read-only, you can set this value directly:
152
- *
153
- * editor.isReadOnly = true;
154
- *
155
- * @observable
156
- * @member {Boolean} #isReadOnly
157
- */
158
- this.set( 'isReadOnly', false );
159
-
160
153
  /**
161
154
  * The editor's model.
162
155
  *
@@ -229,6 +222,122 @@ export default class Editor {
229
222
  this.keystrokes.listenTo( this.editing.view.document );
230
223
  }
231
224
 
225
+ /**
226
+ * Defines whether the editor is in the read-only mode.
227
+ *
228
+ * In read-only mode the editor {@link #commands commands} are disabled so it is not possible
229
+ * to modify the document by using them. Also, the editable element(s) become non-editable.
230
+ *
231
+ * In order to make the editor read-only, you need to call the {@link #enableReadOnlyMode} method:
232
+ *
233
+ * editor.enableReadOnlyMode( 'feature-id' );
234
+ *
235
+ * Later, to turn off the read-only mode, call {@link #disableReadOnlyMode}:
236
+ *
237
+ * editor.disableReadOnlyMode( 'feature-id' );
238
+ *
239
+ * @readonly
240
+ * @observable
241
+ * @member {Boolean} #isReadOnly
242
+ */
243
+ get isReadOnly() {
244
+ return this._readOnlyLocks.size > 0;
245
+ }
246
+
247
+ set isReadOnly( value ) {
248
+ /**
249
+ * `Editor#isReadOnly` does not have a setter and should be set using `Editor#enableReadOnlyMode( lockId )` and
250
+ * `Editor#disableReadOnlyMode( lockId )`.
251
+ *
252
+ * @error editor-isreadonly-has-no-setter
253
+ */
254
+ throw new CKEditorError( 'editor-isreadonly-has-no-setter' );
255
+ }
256
+
257
+ /**
258
+ * Turns on the read-only mode in the editor.
259
+ *
260
+ * Editor can be switched to or out of the read-only mode by many features, under various circumstances. The editor supports locking
261
+ * mechanism for the read-only mode. It enables easy control over the read-only mode when many features wants to turn it on or off at
262
+ * the same time, without conflicting with each other. It guarantees that you will not make the editor editable accidentally (which
263
+ * could lead to errors).
264
+ *
265
+ * Each read-only mode request is identified by a unique id (also called "lock"). If multiple plugins requested to turn on the
266
+ * read-only mode, then, the editor will become editable only after all these plugins turn the read-only mode off (using the same ids).
267
+ *
268
+ * Note, that you cannot force the editor to disable the read-only mode if other plugins set it.
269
+ *
270
+ * After the first `enableReadOnlyMode()` call, the {@link #isReadOnly `isReadOnly` property} will be set to `true`:
271
+ *
272
+ * editor.isReadOnly; // `false`.
273
+ * editor.enableReadOnlyMode( 'my-feature-id' );
274
+ * editor.isReadOnly; // `true`.
275
+ *
276
+ * You can turn off the read-only mode ("clear the lock") using the {@link #disableReadOnlyMode `disableReadOnlyMode()`} method:
277
+ *
278
+ * editor.enableReadOnlyMode( 'my-feature-id' );
279
+ * // ...
280
+ * editor.disableReadOnlyMode( 'my-feature-id' );
281
+ * editor.isReadOnly; // `false`.
282
+ *
283
+ * All "locks" need to be removed to enable editing:
284
+ *
285
+ * editor.enableReadOnlyMode( 'my-feature-id' );
286
+ * editor.enableReadOnlyMode( 'my-other-feature-id' );
287
+ * // ...
288
+ * editor.disableReadOnlyMode( 'my-feature-id' );
289
+ * editor.isReadOnly; // `true`.
290
+ * editor.disableReadOnlyMode( 'my-other-feature-id' );
291
+ * editor.isReadOnly; // `false`.
292
+ *
293
+ * @param {String|Symbol} lockId A unique ID for setting the editor to the read-only state.
294
+ */
295
+ enableReadOnlyMode( lockId ) {
296
+ if ( typeof lockId !== 'string' && typeof lockId !== 'symbol' ) {
297
+ /**
298
+ * The lock ID is missing or it is not a string or symbol.
299
+ *
300
+ * @error editor-read-only-lock-id-invalid
301
+ */
302
+ throw new CKEditorError( 'editor-read-only-lock-id-invalid', null, { lockId } );
303
+ }
304
+
305
+ if ( this._readOnlyLocks.has( lockId ) ) {
306
+ return;
307
+ }
308
+
309
+ this._readOnlyLocks.add( lockId );
310
+
311
+ if ( this._readOnlyLocks.size === 1 ) {
312
+ // Manually fire the `change:isReadOnly` event as only getter is provided.
313
+ this.fire( 'change:isReadOnly', 'isReadOnly', true, false );
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Removes the read-only lock from the editor with given lock ID.
319
+ *
320
+ * When no lock is present on the editor anymore, then the {@link #isReadOnly `isReadOnly` property} will be set to `false`.
321
+ *
322
+ * @param {String|Symbol} lockId The lock ID for setting the editor to the read-only state.
323
+ */
324
+ disableReadOnlyMode( lockId ) {
325
+ if ( typeof lockId !== 'string' && typeof lockId !== 'symbol' ) {
326
+ throw new CKEditorError( 'editor-read-only-lock-id-invalid', null, { lockId } );
327
+ }
328
+
329
+ if ( !this._readOnlyLocks.has( lockId ) ) {
330
+ return;
331
+ }
332
+
333
+ this._readOnlyLocks.delete( lockId );
334
+
335
+ if ( this._readOnlyLocks.size === 0 ) {
336
+ // Manually fire the `change:isReadOnly` event as only getter is provided.
337
+ this.fire( 'change:isReadOnly', 'isReadOnly', false, true );
338
+ }
339
+ }
340
+
232
341
  /**
233
342
  * Loads and initializes plugins specified in the configuration.
234
343
  *
@@ -361,7 +470,7 @@ mix( Editor, ObservableMixin );
361
470
  * This error is thrown when trying to pass a `<textarea>` element to a `create()` function of an editor class.
362
471
  *
363
472
  * The only editor type which can be initialized on `<textarea>` elements is
364
- * the {@glink builds/guides/predefined-builds/overview#classic-editor classic editor}.
473
+ * the {@glink installation/advanced/alternative-setups/predefined-builds#classic-editor classic editor}.
365
474
  * This editor hides the passed element and inserts its own UI next to it. Other types of editors reuse the passed element as their root
366
475
  * editable element and therefore `<textarea>` is not appropriate for them. Use a `<div>` or another text container instead:
367
476
  *
@@ -24,7 +24,7 @@
24
24
  * .then( ... )
25
25
  * .catch( ... );
26
26
  *
27
- * Check the {@glink builds/guides/integration/configuration Configuration guide} for more information
27
+ * Check the {@glink installation/advanced/alternative-setups/predefined-builds Configuration guide} for more information
28
28
  * about setting configuration options.
29
29
  *
30
30
  * @interface EditorConfig
@@ -66,7 +66,7 @@
66
66
  /**
67
67
  * The list of plugins to load.
68
68
  *
69
- * If you use an {@glink builds/guides/predefined-builds/overview editor build} you can define the list of plugins to load
69
+ * If you use an {@glink installation/advanced/alternative-setups/predefined-builds editor build} you can define the list of plugins to load
70
70
  * using the names of plugins that are available:
71
71
  *
72
72
  * const config = {
@@ -98,7 +98,7 @@
98
98
 
99
99
  /**
100
100
  * The list of additional plugins to load along those already available in the
101
- * {@glink builds/guides/predefined-builds/overview editor build}. It extends the {@link #plugins `plugins`} configuration.
101
+ * {@glink installation/advanced/alternative-setups/predefined-builds editor build}. It extends the {@link #plugins `plugins`} configuration.
102
102
  *
103
103
  * function MyPlugin( editor ) {
104
104
  * // ...
@@ -110,7 +110,7 @@
110
110
  *
111
111
  * **Note:** This configuration works only for simple plugins which utilize the
112
112
  * {@link module:core/plugin~PluginInterface plugin interface} and have no dependencies. To extend a
113
- * build with complex features, create a {@glink builds/guides/development/custom-builds custom build}.
113
+ * build with complex features, create a {@glink installation/getting-started/quick-start#creating-custom-builds-with-online-builder custom build}.
114
114
  *
115
115
  * **Note:** Make sure you include the new features in you toolbar configuration. Learn more
116
116
  * about the {@glink features/toolbar/toolbar toolbar setup}.
@@ -119,7 +119,7 @@
119
119
  */
120
120
 
121
121
  /**
122
- * The list of plugins which should not be loaded despite being available in an {@glink builds/guides/predefined-builds/overview editor build}.
122
+ * The list of plugins which should not be loaded despite being available in an {@glink installation/advanced/alternative-setups/predefined-builds editor build}.
123
123
  *
124
124
  * const config = {
125
125
  * removePlugins: [ 'Bold', 'Italic' ]
@@ -5,6 +5,8 @@
5
5
 
6
6
  import Command from './command';
7
7
 
8
+ import insertToPriorityArray from '@ckeditor/ckeditor5-utils/src/inserttopriorityarray';
9
+
8
10
  /**
9
11
  * @module core/multicommand
10
12
  */
@@ -14,16 +16,17 @@ import Command from './command';
14
16
  *
15
17
  * This command is used to proxy multiple commands. The multi-command is enabled when
16
18
  * at least one of its registered child commands is enabled.
17
- * When executing a multi-command the first command that is enabled will be executed.
19
+ * When executing a multi-command the first enabled command with highest priority will be executed.
18
20
  *
19
21
  * const multiCommand = new MultiCommand( editor );
20
22
  *
21
23
  * const commandFoo = new Command( editor );
22
24
  * const commandBar = new Command( editor );
23
25
  *
24
- * // Register child commands.
26
+ * // Register a child command.
25
27
  * multiCommand.registerChildCommand( commandFoo );
26
- * multiCommand.registerChildCommand( commandBar );
28
+ * // Register a child command with a low priority.
29
+ * multiCommand.registerChildCommand( commandBar, { priority: 'low' } );
27
30
  *
28
31
  * // Enable one of the commands.
29
32
  * commandBar.isEnabled = true;
@@ -40,12 +43,12 @@ export default class MultiCommand extends Command {
40
43
  super( editor );
41
44
 
42
45
  /**
43
- * Registered child commands.
46
+ * Registered child commands definitions.
44
47
  *
45
- * @type {Array.<module:core/command~Command>}
48
+ * @type {Array.<Object>}
46
49
  * @private
47
50
  */
48
- this._childCommands = [];
51
+ this._childCommandsDefinitions = [];
49
52
  }
50
53
 
51
54
  /**
@@ -56,23 +59,25 @@ export default class MultiCommand extends Command {
56
59
  }
57
60
 
58
61
  /**
59
- * Executes the first of it registered child commands.
62
+ * Executes the first enabled command which has the highest priority of all registered child commands.
60
63
  *
61
64
  * @returns {*} The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
62
65
  */
63
66
  execute( ...args ) {
64
67
  const command = this._getFirstEnabledCommand();
65
68
 
66
- return command != null && command.execute( args );
69
+ return !!command && command.execute( args );
67
70
  }
68
71
 
69
72
  /**
70
73
  * Registers a child command.
71
74
  *
72
75
  * @param {module:core/command~Command} command
76
+ * @param {Object} options An object with configuration options.
77
+ * @param {module:utils/priorities~PriorityString} [options.priority='normal'] Priority of a command to register.
73
78
  */
74
- registerChildCommand( command ) {
75
- this._childCommands.push( command );
79
+ registerChildCommand( command, options = { priority: 'normal' } ) {
80
+ insertToPriorityArray( this._childCommandsDefinitions, { command, priority: options.priority } );
76
81
 
77
82
  // Change multi command enabled state when one of registered commands changes state.
78
83
  command.on( 'change:isEnabled', () => this._checkEnabled() );
@@ -90,12 +95,14 @@ export default class MultiCommand extends Command {
90
95
  }
91
96
 
92
97
  /**
93
- * Returns a first enabled command or undefined if none of them is enabled.
98
+ * Returns a first enabled command with the highest priority or `undefined` if none of them is enabled.
94
99
  *
95
100
  * @returns {module:core/command~Command|undefined}
96
101
  * @private
97
102
  */
98
103
  _getFirstEnabledCommand() {
99
- return this._childCommands.find( command => command.isEnabled );
104
+ const commandDefinition = this._childCommandsDefinitions.find( ( { command } ) => command.isEnabled );
105
+
106
+ return commandDefinition && commandDefinition.command;
100
107
  }
101
108
  }
@@ -48,7 +48,7 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
48
48
  *
49
49
  * This plugin is used by features like {@link module:upload/filerepository~FileRepository} to register their ongoing actions
50
50
  * and by features like {@link module:autosave/autosave~Autosave} to detect whether there are any ongoing actions.
51
- * Read more about saving the data in the {@glink builds/guides/integration/saving-data Saving and getting data} guide.
51
+ * Read more about saving the data in the {@glink installation/advanced/saving-data Saving and getting data} guide.
52
52
  *
53
53
  * @extends module:core/contextplugin~ContextPlugin
54
54
  */
@@ -324,7 +324,7 @@ export default class PluginCollection {
324
324
  *
325
325
  * Soft requirements were introduced in version 26.0.0. If you happen to stumble upon this error
326
326
  * when upgrading to version 26.0.0, read also the
327
- * {@glink builds/guides/migration/migration-to-26 Migration to 26.0.0} guide.
327
+ * {@glink updating/migration-to-26 Migration to 26.0.0} guide.
328
328
  *
329
329
  * @error plugincollection-soft-required
330
330
  * @param {String} missingPlugin The name of the required plugin.
@@ -344,16 +344,17 @@ export default class PluginCollection {
344
344
  * This is usually done in CKEditor 5 builds by setting the {@link module:core/editor/editor~Editor.builtinPlugins}
345
345
  * property.
346
346
  *
347
- * **If you see this warning when using one of the {@glink builds/index CKEditor 5 Builds}**, it means
348
- * that you try to enable a plugin which was not included in that build. This may be due to a typo
347
+ * **If you see this warning when using one of the {@glink installation/advanced/alternative-setups/predefined-builds
348
+ * CKEditor 5 Builds}**,
349
+ * it means that you try to enable a plugin which was not included in that build. This may be due to a typo
349
350
  * in the plugin name or simply because that plugin is not a part of this build. In the latter scenario,
350
- * read more about {@glink builds/guides/development/custom-builds custom builds}.
351
+ * read more about {@glink installation/getting-started/quick-start custom builds}.
351
352
  *
352
353
  * **If you see this warning when using one of the editor creators directly** (not a build), then it means
353
354
  * that you tried loading plugins by name. However, unlike CKEditor 4, CKEditor 5 does not implement a "plugin loader".
354
355
  * This means that CKEditor 5 does not know where to load the plugin modules from. Therefore, you need to
355
356
  * provide each plugin through a reference (as a constructor function). Check out the examples in
356
- * {@glink builds/guides/integration/advanced-setup#scenario-2-building-from-source "Building from source"}.
357
+ * {@glink installation/advanced/alternative-setups/integrating-from-source "Building from source"}.
357
358
  *
358
359
  * @error plugincollection-plugin-not-found
359
360
  * @param {String} plugin The name of the plugin which could not be loaded.
@@ -576,7 +577,7 @@ export default class PluginCollection {
576
577
  * They are already built into that editor build and now get added for the second time as dependencies
577
578
  * of the plugin you are installing.
578
579
  *
579
- * Read more about {@glink builds/guides/integration/installing-plugins installing plugins}.
580
+ * Read more about {@glink installation/getting-started/installing-plugins installing plugins}.
580
581
  *
581
582
  * @error plugincollection-plugin-name-conflict
582
583
  * @param {String} pluginName The duplicated plugin name.