@ckeditor/ckeditor5-core 41.0.0 → 41.2.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/lang/contexts.json +13 -1
- package/lang/translations/af.po +48 -0
- package/lang/translations/ar.po +48 -0
- package/lang/translations/ast.po +48 -0
- package/lang/translations/az.po +48 -0
- package/lang/translations/bg.po +48 -0
- package/lang/translations/bn.po +48 -0
- package/lang/translations/bs.po +48 -0
- package/lang/translations/ca.po +48 -0
- package/lang/translations/cs.po +48 -0
- package/lang/translations/da.po +48 -0
- package/lang/translations/de-ch.po +48 -0
- package/lang/translations/de.po +48 -0
- package/lang/translations/el.po +48 -0
- package/lang/translations/en-au.po +48 -0
- package/lang/translations/en-gb.po +48 -0
- package/lang/translations/en.po +48 -0
- package/lang/translations/eo.po +48 -0
- package/lang/translations/es-co.po +48 -0
- package/lang/translations/es.po +48 -0
- package/lang/translations/et.po +48 -0
- package/lang/translations/eu.po +48 -0
- package/lang/translations/fa.po +48 -0
- package/lang/translations/fi.po +48 -0
- package/lang/translations/fr.po +48 -0
- package/lang/translations/gl.po +48 -0
- package/lang/translations/gu.po +48 -0
- package/lang/translations/he.po +49 -1
- package/lang/translations/hi.po +48 -0
- package/lang/translations/hr.po +48 -0
- package/lang/translations/hu.po +48 -0
- package/lang/translations/hy.po +48 -0
- package/lang/translations/id.po +48 -0
- package/lang/translations/it.po +48 -0
- package/lang/translations/ja.po +48 -0
- package/lang/translations/jv.po +48 -0
- package/lang/translations/km.po +48 -0
- package/lang/translations/kn.po +48 -0
- package/lang/translations/ko.po +48 -0
- package/lang/translations/ku.po +48 -0
- package/lang/translations/lt.po +48 -0
- package/lang/translations/lv.po +48 -0
- package/lang/translations/ms.po +48 -0
- package/lang/translations/nb.po +48 -0
- package/lang/translations/ne.po +48 -0
- package/lang/translations/nl.po +48 -0
- package/lang/translations/no.po +48 -0
- package/lang/translations/oc.po +48 -0
- package/lang/translations/pl.po +48 -0
- package/lang/translations/pt-br.po +48 -0
- package/lang/translations/pt.po +48 -0
- package/lang/translations/ro.po +48 -0
- package/lang/translations/ru.po +48 -0
- package/lang/translations/si.po +48 -0
- package/lang/translations/sk.po +48 -0
- package/lang/translations/sl.po +48 -0
- package/lang/translations/sq.po +48 -0
- package/lang/translations/sr-latn.po +48 -0
- package/lang/translations/sr.po +48 -0
- package/lang/translations/sv.po +48 -0
- package/lang/translations/th.po +48 -0
- package/lang/translations/tk.po +48 -0
- package/lang/translations/tr.po +48 -0
- package/lang/translations/tt.po +48 -0
- package/lang/translations/ug.po +48 -0
- package/lang/translations/uk.po +48 -0
- package/lang/translations/ur.po +48 -0
- package/lang/translations/uz.po +48 -0
- package/lang/translations/vi.po +48 -0
- package/lang/translations/zh-cn.po +48 -0
- package/lang/translations/zh.po +48 -0
- package/package.json +3 -3
- package/src/accessibility.d.ts +361 -0
- package/src/accessibility.js +315 -0
- package/src/context.js +6 -2
- package/src/editor/editor.d.ts +61 -0
- package/src/editor/editor.js +65 -3
- package/src/editor/editorconfig.d.ts +5 -0
- package/src/editor/utils/dataapimixin.d.ts +6 -2
- package/src/editor/utils/dataapimixin.js +3 -15
- package/src/index.d.ts +2 -0
- package/src/typings.d.ts +8 -0
- package/src/typings.js +5 -0
package/src/editor/editor.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import Context from '../context.js';
|
|
|
12
12
|
import PluginCollection from '../plugincollection.js';
|
|
13
13
|
import CommandCollection, { type CommandsMap } from '../commandcollection.js';
|
|
14
14
|
import EditingKeystrokeHandler from '../editingkeystrokehandler.js';
|
|
15
|
+
import Accessibility from '../accessibility.js';
|
|
15
16
|
import type { LoadedPlugins, PluginConstructor } from '../plugin.js';
|
|
16
17
|
import type { EditorConfig } from './editorconfig.js';
|
|
17
18
|
declare const Editor_base: {
|
|
@@ -37,6 +38,10 @@ declare const Editor_base: {
|
|
|
37
38
|
* (as most editor implementations do).
|
|
38
39
|
*/
|
|
39
40
|
export default abstract class Editor extends Editor_base {
|
|
41
|
+
/**
|
|
42
|
+
* A namespace for the accessibility features of the editor.
|
|
43
|
+
*/
|
|
44
|
+
readonly accessibility: Accessibility;
|
|
40
45
|
/**
|
|
41
46
|
* Commands registered to the editor.
|
|
42
47
|
*
|
|
@@ -314,6 +319,62 @@ export default abstract class Editor extends Editor_base {
|
|
|
314
319
|
* @param lockId The lock ID for setting the editor to the read-only state.
|
|
315
320
|
*/
|
|
316
321
|
disableReadOnlyMode(lockId: string | symbol): void;
|
|
322
|
+
/**
|
|
323
|
+
* Sets the data in the editor.
|
|
324
|
+
*
|
|
325
|
+
* ```ts
|
|
326
|
+
* editor.setData( '<p>This is editor!</p>' );
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* If your editor implementation uses multiple roots, you should pass an object with keys corresponding
|
|
330
|
+
* to the editor root names and values equal to the data that should be set in each root:
|
|
331
|
+
*
|
|
332
|
+
* ```ts
|
|
333
|
+
* editor.setData( {
|
|
334
|
+
* header: '<p>Content for header part.</p>',
|
|
335
|
+
* content: '<p>Content for main part.</p>',
|
|
336
|
+
* footer: '<p>Content for footer part.</p>'
|
|
337
|
+
* } );
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* By default the editor accepts HTML. This can be controlled by injecting a different data processor.
|
|
341
|
+
* See the {@glink features/markdown Markdown output} guide for more details.
|
|
342
|
+
*
|
|
343
|
+
* @param data Input data.
|
|
344
|
+
*/
|
|
345
|
+
setData(data: string | Record<string, string>): void;
|
|
346
|
+
/**
|
|
347
|
+
* Gets the data from the editor.
|
|
348
|
+
*
|
|
349
|
+
* ```ts
|
|
350
|
+
* editor.getData(); // -> '<p>This is editor!</p>'
|
|
351
|
+
* ```
|
|
352
|
+
*
|
|
353
|
+
* If your editor implementation uses multiple roots, you should pass root name as one of the options:
|
|
354
|
+
*
|
|
355
|
+
* ```ts
|
|
356
|
+
* editor.getData( { rootName: 'header' } ); // -> '<p>Content for header part.</p>'
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* By default, the editor outputs HTML. This can be controlled by injecting a different data processor.
|
|
360
|
+
* See the {@glink features/markdown Markdown output} guide for more details.
|
|
361
|
+
*
|
|
362
|
+
* A warning is logged when you try to retrieve data for a detached root, as most probably this is a mistake. A detached root should
|
|
363
|
+
* be treated like it is removed, and you should not save its data. Note, that the detached root data is always an empty string.
|
|
364
|
+
*
|
|
365
|
+
* @param options Additional configuration for the retrieved data.
|
|
366
|
+
* Editor features may introduce more configuration options that can be set through this parameter.
|
|
367
|
+
* @param options.rootName Root name. Defaults to `'main'`.
|
|
368
|
+
* @param options.trim Whether returned data should be trimmed. This option is set to `'empty'` by default,
|
|
369
|
+
* which means that whenever editor content is considered empty, an empty string is returned. To turn off trimming
|
|
370
|
+
* use `'none'`. In such cases exact content will be returned (for example `'<p> </p>'` for an empty editor).
|
|
371
|
+
* @returns Output data.
|
|
372
|
+
*/
|
|
373
|
+
getData(options?: {
|
|
374
|
+
rootName?: string;
|
|
375
|
+
trim?: 'empty' | 'none';
|
|
376
|
+
[key: string]: unknown;
|
|
377
|
+
}): string;
|
|
317
378
|
/**
|
|
318
379
|
* Loads and initializes plugins specified in the configuration.
|
|
319
380
|
*
|
package/src/editor/editor.js
CHANGED
|
@@ -11,6 +11,7 @@ import Context from '../context.js';
|
|
|
11
11
|
import PluginCollection from '../plugincollection.js';
|
|
12
12
|
import CommandCollection from '../commandcollection.js';
|
|
13
13
|
import EditingKeystrokeHandler from '../editingkeystrokehandler.js';
|
|
14
|
+
import Accessibility from '../accessibility.js';
|
|
14
15
|
/**
|
|
15
16
|
* The class representing a basic, generic editor.
|
|
16
17
|
*
|
|
@@ -40,14 +41,18 @@ export default class Editor extends ObservableMixin() {
|
|
|
40
41
|
constructor(config = {}) {
|
|
41
42
|
super();
|
|
42
43
|
const constructor = this.constructor;
|
|
44
|
+
// We don't pass translations to the config, because its behavior of splitting keys
|
|
45
|
+
// with dots (e.g. `resize.width` => `resize: { width }`) breaks the translations.
|
|
46
|
+
const { translations: defaultTranslations, ...defaultConfig } = constructor.defaultConfig || {};
|
|
47
|
+
const { translations = defaultTranslations, ...rest } = config;
|
|
43
48
|
// Prefer the language passed as the argument to the constructor instead of the constructor's `defaultConfig`, if both are set.
|
|
44
|
-
const language = config.language ||
|
|
45
|
-
this._context = config.context || new Context({ language });
|
|
49
|
+
const language = config.language || defaultConfig.language;
|
|
50
|
+
this._context = config.context || new Context({ language, translations });
|
|
46
51
|
this._context._addEditor(this, !config.context);
|
|
47
52
|
// Clone the plugins to make sure that the plugin array will not be shared
|
|
48
53
|
// between editors and make the watchdog feature work correctly.
|
|
49
54
|
const availablePlugins = Array.from(constructor.builtinPlugins || []);
|
|
50
|
-
this.config = new Config(
|
|
55
|
+
this.config = new Config(rest, defaultConfig);
|
|
51
56
|
this.config.define('plugins', availablePlugins);
|
|
52
57
|
this.config.define(this._context._getEditorConfig());
|
|
53
58
|
this.plugins = new PluginCollection(this, availablePlugins, this._context.plugins);
|
|
@@ -71,6 +76,7 @@ export default class Editor extends ObservableMixin() {
|
|
|
71
76
|
this.conversion.addAlias('editingDowncast', this.editing.downcastDispatcher);
|
|
72
77
|
this.keystrokes = new EditingKeystrokeHandler(this);
|
|
73
78
|
this.keystrokes.listenTo(this.editing.view.document);
|
|
79
|
+
this.accessibility = new Accessibility(this);
|
|
74
80
|
}
|
|
75
81
|
/**
|
|
76
82
|
* Defines whether the editor is in the read-only mode.
|
|
@@ -202,6 +208,62 @@ export default class Editor extends ObservableMixin() {
|
|
|
202
208
|
this.fire('change:isReadOnly', 'isReadOnly', false, true);
|
|
203
209
|
}
|
|
204
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Sets the data in the editor.
|
|
213
|
+
*
|
|
214
|
+
* ```ts
|
|
215
|
+
* editor.setData( '<p>This is editor!</p>' );
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* If your editor implementation uses multiple roots, you should pass an object with keys corresponding
|
|
219
|
+
* to the editor root names and values equal to the data that should be set in each root:
|
|
220
|
+
*
|
|
221
|
+
* ```ts
|
|
222
|
+
* editor.setData( {
|
|
223
|
+
* header: '<p>Content for header part.</p>',
|
|
224
|
+
* content: '<p>Content for main part.</p>',
|
|
225
|
+
* footer: '<p>Content for footer part.</p>'
|
|
226
|
+
* } );
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* By default the editor accepts HTML. This can be controlled by injecting a different data processor.
|
|
230
|
+
* See the {@glink features/markdown Markdown output} guide for more details.
|
|
231
|
+
*
|
|
232
|
+
* @param data Input data.
|
|
233
|
+
*/
|
|
234
|
+
setData(data) {
|
|
235
|
+
this.data.set(data);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Gets the data from the editor.
|
|
239
|
+
*
|
|
240
|
+
* ```ts
|
|
241
|
+
* editor.getData(); // -> '<p>This is editor!</p>'
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* If your editor implementation uses multiple roots, you should pass root name as one of the options:
|
|
245
|
+
*
|
|
246
|
+
* ```ts
|
|
247
|
+
* editor.getData( { rootName: 'header' } ); // -> '<p>Content for header part.</p>'
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* By default, the editor outputs HTML. This can be controlled by injecting a different data processor.
|
|
251
|
+
* See the {@glink features/markdown Markdown output} guide for more details.
|
|
252
|
+
*
|
|
253
|
+
* A warning is logged when you try to retrieve data for a detached root, as most probably this is a mistake. A detached root should
|
|
254
|
+
* be treated like it is removed, and you should not save its data. Note, that the detached root data is always an empty string.
|
|
255
|
+
*
|
|
256
|
+
* @param options Additional configuration for the retrieved data.
|
|
257
|
+
* Editor features may introduce more configuration options that can be set through this parameter.
|
|
258
|
+
* @param options.rootName Root name. Defaults to `'main'`.
|
|
259
|
+
* @param options.trim Whether returned data should be trimmed. This option is set to `'empty'` by default,
|
|
260
|
+
* which means that whenever editor content is considered empty, an empty string is returned. To turn off trimming
|
|
261
|
+
* use `'none'`. In such cases exact content will be returned (for example `'<p> </p>'` for an empty editor).
|
|
262
|
+
* @returns Output data.
|
|
263
|
+
*/
|
|
264
|
+
getData(options) {
|
|
265
|
+
return this.data.get(options);
|
|
266
|
+
}
|
|
205
267
|
/**
|
|
206
268
|
* Loads and initializes plugins specified in the configuration.
|
|
207
269
|
*
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module core/editor/editorconfig
|
|
7
7
|
*/
|
|
8
|
+
import type { ArrayOrItem, Translations } from '@ckeditor/ckeditor5-utils';
|
|
8
9
|
import type Context from '../context.js';
|
|
9
10
|
import type { PluginConstructor } from '../plugin.js';
|
|
10
11
|
import type Editor from './editor.js';
|
|
@@ -519,6 +520,10 @@ export interface EditorConfig {
|
|
|
519
520
|
* [order a trial](https://orders.ckeditor.com/trial/premium-features).
|
|
520
521
|
*/
|
|
521
522
|
licenseKey?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Translations to be used in the editor.
|
|
525
|
+
*/
|
|
526
|
+
translations?: ArrayOrItem<Translations>;
|
|
522
527
|
}
|
|
523
528
|
/**
|
|
524
529
|
* The `config.initialData` option cannot be used together with the initial data passed as the first parameter of
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
* @module core/editor/utils/dataapimixin
|
|
7
7
|
*/
|
|
8
8
|
import type Editor from '../editor.js';
|
|
9
|
-
import type { Constructor
|
|
9
|
+
import type { Constructor } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
/**
|
|
11
11
|
* Implementation of the {@link module:core/editor/utils/dataapimixin~DataApi}.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated This functionality is already implemented by the `Editor` class.
|
|
12
14
|
*/
|
|
13
|
-
export default function DataApiMixin<Base extends Constructor<Editor>>(base: Base):
|
|
15
|
+
export default function DataApiMixin<Base extends Constructor<Editor>>(base: Base): Base;
|
|
14
16
|
/**
|
|
15
17
|
* Interface defining editor methods for setting and getting data to and from the editor's main root element
|
|
16
18
|
* using the {@link module:core/editor/editor~Editor#data data pipeline}.
|
|
@@ -18,6 +20,8 @@ export default function DataApiMixin<Base extends Constructor<Editor>>(base: Bas
|
|
|
18
20
|
* This interface is not a part of the {@link module:core/editor/editor~Editor} class because one may want to implement
|
|
19
21
|
* an editor with multiple root elements, in which case the methods for setting and getting data will need to be implemented
|
|
20
22
|
* differently.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated This interface is implemented by all `Editor` instances by default.
|
|
21
25
|
*/
|
|
22
26
|
export interface DataApi {
|
|
23
27
|
/**
|
|
@@ -4,21 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Implementation of the {@link module:core/editor/utils/dataapimixin~DataApi}.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated This functionality is already implemented by the `Editor` class.
|
|
7
9
|
*/
|
|
8
10
|
export default function DataApiMixin(base) {
|
|
9
|
-
|
|
10
|
-
setData(data) {
|
|
11
|
-
this.data.set(data);
|
|
12
|
-
}
|
|
13
|
-
getData(options) {
|
|
14
|
-
return this.data.get(options);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return Mixin;
|
|
18
|
-
}
|
|
19
|
-
// Backward compatibility with `mix`.
|
|
20
|
-
{
|
|
21
|
-
const mixin = DataApiMixin(Object);
|
|
22
|
-
DataApiMixin.setData = mixin.prototype.setData;
|
|
23
|
-
DataApiMixin.getData = mixin.prototype.getData;
|
|
11
|
+
return base;
|
|
24
12
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type { PluginsMap, default as PluginCollection } from './plugincollection
|
|
|
13
13
|
export { default as Context, type ContextConfig } from './context.js';
|
|
14
14
|
export { default as ContextPlugin, type ContextPluginDependencies } from './contextplugin.js';
|
|
15
15
|
export { type EditingKeystrokeCallback } from './editingkeystrokehandler.js';
|
|
16
|
+
export type { PartialBy } from './typings.js';
|
|
16
17
|
export { default as Editor, type EditorReadyEvent, type EditorDestroyEvent } from './editor/editor.js';
|
|
17
18
|
export type { EditorConfig, LanguageConfig, ToolbarConfig, ToolbarConfigItem, UiConfig } from './editor/editorconfig.js';
|
|
18
19
|
export { default as attachToForm } from './editor/utils/attachtoform.js';
|
|
@@ -20,6 +21,7 @@ export { default as DataApiMixin, type DataApi } from './editor/utils/dataapimix
|
|
|
20
21
|
export { default as ElementApiMixin, type ElementApi } from './editor/utils/elementapimixin.js';
|
|
21
22
|
export { default as secureSourceElement } from './editor/utils/securesourceelement.js';
|
|
22
23
|
export { default as PendingActions, type PendingAction } from './pendingactions.js';
|
|
24
|
+
export type { KeystrokeInfos as KeystrokeInfoDefinitions, KeystrokeInfoGroup as KeystrokeInfoGroupDefinition, KeystrokeInfoCategory as KeystrokeInfoCategoryDefinition, KeystrokeInfoDefinition as KeystrokeInfoDefinition } from './accessibility.js';
|
|
23
25
|
export declare const icons: {
|
|
24
26
|
bold: string;
|
|
25
27
|
cancel: string;
|
package/src/typings.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
+
* @module core/typings
|
|
7
|
+
*/
|
|
8
|
+
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|