@ckeditor/ckeditor5-core 48.0.1-alpha.1 → 48.1.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/editor/editor.d.ts +34 -2
- package/dist/editor/editorconfig.d.ts +171 -2
- package/dist/editor/utils/registerandinitializerootconfigattributes.d.ts +16 -0
- package/dist/editor/utils/verifyrootelements.d.ts +11 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +150 -23
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/editor/editor.d.ts
CHANGED
|
@@ -243,6 +243,12 @@ export declare abstract class Editor extends /* #__PURE__ */ Editor_base {
|
|
|
243
243
|
* A set of lock IDs for the {@link #isReadOnly} getter.
|
|
244
244
|
*/
|
|
245
245
|
protected readonly _readOnlyLocks: Set<symbol | string>;
|
|
246
|
+
/**
|
|
247
|
+
* Holds attributes keys that were passed in
|
|
248
|
+
* {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}
|
|
249
|
+
* or {@link module:core/editor/editorconfig~EditorConfig#root `config.root.modelAttributes`}.
|
|
250
|
+
*/
|
|
251
|
+
protected readonly _registeredRootsAttributesKeys: Set<string>;
|
|
246
252
|
/**
|
|
247
253
|
* `Editor` class is commonly put in `config.plugins` array.
|
|
248
254
|
*
|
|
@@ -431,6 +437,26 @@ export declare abstract class Editor extends /* #__PURE__ */ Editor_base {
|
|
|
431
437
|
* of the {@glink framework/deep-dive/ui/focus-tracking Deep dive into focus tracking} guide to learn more.
|
|
432
438
|
*/
|
|
433
439
|
focus(): void;
|
|
440
|
+
/**
|
|
441
|
+
* Registers a given string as a root attribute key. Registered root attributes are added to
|
|
442
|
+
* the {@link module:engine/model/schema~ModelSchema schema}.
|
|
443
|
+
*
|
|
444
|
+
* Note: Attributes passed in the configuration for multi-root editors
|
|
445
|
+
* ({@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}) or
|
|
446
|
+
* single-root editors ({@link module:core/editor/editorconfig~EditorConfig#root `config.root.modelAttributes`})
|
|
447
|
+
* are automatically registered when the editor is initialized. However, registering the same attribute twice
|
|
448
|
+
* does not have any negative impact, so it is recommended to use this method in any feature that uses
|
|
449
|
+
* root attributes.
|
|
450
|
+
*/
|
|
451
|
+
registerRootAttribute(key: string): void;
|
|
452
|
+
/**
|
|
453
|
+
* Returns attributes for the specified root.
|
|
454
|
+
* If no root name is provided, it returns attributes for the 'main' root by default.
|
|
455
|
+
*
|
|
456
|
+
* Note: all and only {@link ~Editor#registerRootAttribute registered} roots attributes will be returned.
|
|
457
|
+
* If a registered root attribute is not set for a given root, `null` will be returned.
|
|
458
|
+
*/
|
|
459
|
+
getRootAttributes(rootName?: string): EditorRootAttributes;
|
|
434
460
|
/**
|
|
435
461
|
* Creates and initializes a new editor instance.
|
|
436
462
|
*
|
|
@@ -522,6 +548,10 @@ export type EditorDestroyEvent = {
|
|
|
522
548
|
name: 'destroy';
|
|
523
549
|
args: [];
|
|
524
550
|
};
|
|
551
|
+
/**
|
|
552
|
+
* Attributes set on a model root element.
|
|
553
|
+
*/
|
|
554
|
+
export type EditorRootAttributes = Record<string, unknown>;
|
|
525
555
|
export {};
|
|
526
556
|
/**
|
|
527
557
|
* This error is thrown when trying to pass a `<textarea>` element to a `create()` function of an editor class.
|
|
@@ -549,8 +579,10 @@ export {};
|
|
|
549
579
|
* In case you intended to use the [LTS Edition](https://ckeditor.com/ckeditor-5-lts/),
|
|
550
580
|
* but have not yet made a purchase, please [contact our sales team](https://ckeditor.com/contact-sales/)
|
|
551
581
|
*
|
|
552
|
-
* If you did not intend to use LTS, please
|
|
553
|
-
*
|
|
582
|
+
* If you did not intend to use LTS, please note that all releases in the v47.7 line are
|
|
583
|
+
* for LTS subscribers only. To use a non-LTS edition, either upgrade to v48 or newer,
|
|
584
|
+
* which is our standard [latest](https://ckeditor.com/docs/ckeditor5/latest/updating/guides/changelog.html)
|
|
585
|
+
* release line, or stay on a version 47.6.2 or earlier.
|
|
554
586
|
*
|
|
555
587
|
* @error license-key-lts-not-allowed
|
|
556
588
|
*/
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { ArrayOrItem, Translations } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
import { type Context } from '../context.js';
|
|
10
10
|
import type { PluginConstructor } from '../plugin.js';
|
|
11
|
-
import {
|
|
11
|
+
import type { EditorRootAttributes, Editor } from './editor.js';
|
|
12
12
|
import type { MenuBarConfig } from '@ckeditor/ckeditor5-ui';
|
|
13
13
|
import type { EngineConfig } from '@ckeditor/ckeditor5-engine';
|
|
14
14
|
/**
|
|
@@ -1215,6 +1215,50 @@ export interface RootConfig {
|
|
|
1215
1215
|
* See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples.
|
|
1216
1216
|
*/
|
|
1217
1217
|
placeholder?: string;
|
|
1218
|
+
/**
|
|
1219
|
+
* The name of the model root element to use for this editor root.
|
|
1220
|
+
*
|
|
1221
|
+
* By default, the editor creates model roots using the generic `$root` element, which allows all standard block
|
|
1222
|
+
* content (paragraphs, headings, lists, tables, etc.). You can set this option to a custom element name if you
|
|
1223
|
+
* need a root with different schema rules — for example, a root that restricts or extends what content is allowed
|
|
1224
|
+
* at the top level.
|
|
1225
|
+
*
|
|
1226
|
+
* The element name must be registered in the {@link module:engine/model/schema~ModelSchema schema} before or during
|
|
1227
|
+
* editor initialization. See the {@glink framework/deep-dive/schema "Schema"} guide for more information about
|
|
1228
|
+
* generic items like `$root` and `$inlineRoot`.
|
|
1229
|
+
*
|
|
1230
|
+
* ```ts
|
|
1231
|
+
* ClassicEditor
|
|
1232
|
+
* .create( {
|
|
1233
|
+
* root: {
|
|
1234
|
+
* modelElement: '$inlineRoot'
|
|
1235
|
+
* }
|
|
1236
|
+
* } )
|
|
1237
|
+
* .then( ... )
|
|
1238
|
+
* .catch( ... );
|
|
1239
|
+
* ```
|
|
1240
|
+
*
|
|
1241
|
+
* If your editor implementation uses multiple roots, you can set a different model element for each root:
|
|
1242
|
+
*
|
|
1243
|
+
* ```ts
|
|
1244
|
+
* MultiRootEditor.create( {
|
|
1245
|
+
* roots: {
|
|
1246
|
+
* header: {
|
|
1247
|
+
* modelElement: '$inlineRoot',
|
|
1248
|
+
* initialData: 'My document title'
|
|
1249
|
+
* },
|
|
1250
|
+
* content: {
|
|
1251
|
+
* initialData: '<p>Main content goes here.</p>'
|
|
1252
|
+
* }
|
|
1253
|
+
* }
|
|
1254
|
+
* } )
|
|
1255
|
+
* .then( ... )
|
|
1256
|
+
* .catch( ... );
|
|
1257
|
+
* ```
|
|
1258
|
+
*
|
|
1259
|
+
* @default '$root'
|
|
1260
|
+
*/
|
|
1261
|
+
modelElement?: string;
|
|
1218
1262
|
/**
|
|
1219
1263
|
* Label which briefly describes this editing area.
|
|
1220
1264
|
*
|
|
@@ -1222,7 +1266,7 @@ export interface RootConfig {
|
|
|
1222
1266
|
* to tell apart multiple editor instances (editing areas) on the page. If not set, a default
|
|
1223
1267
|
* "Rich Text Editor. Editing area [name of the area]" is used instead.
|
|
1224
1268
|
*
|
|
1225
|
-
* It can also be used by other features when referring to this editing area
|
|
1269
|
+
* It can also be used by other features when referring to this editing area.
|
|
1226
1270
|
*
|
|
1227
1271
|
* ```ts
|
|
1228
1272
|
* ClassicEditor
|
|
@@ -1264,6 +1308,131 @@ export interface RootConfig {
|
|
|
1264
1308
|
* ```
|
|
1265
1309
|
*/
|
|
1266
1310
|
label?: string;
|
|
1311
|
+
/**
|
|
1312
|
+
* An optional, longer description of this editing area. It is intended as a stable, human-readable identifier
|
|
1313
|
+
* so features can match a root across sessions, for instance AI features interacting with multiple editor instances
|
|
1314
|
+
* and multi-root editors.
|
|
1315
|
+
*
|
|
1316
|
+
* ```ts
|
|
1317
|
+
* ClassicEditor
|
|
1318
|
+
* .create( {
|
|
1319
|
+
* attachTo: document.querySelector( '#editor' ),
|
|
1320
|
+
* root: {
|
|
1321
|
+
* description: '...'
|
|
1322
|
+
* }
|
|
1323
|
+
* } )
|
|
1324
|
+
* .then( ... )
|
|
1325
|
+
* .catch( ... );
|
|
1326
|
+
* ```
|
|
1327
|
+
*
|
|
1328
|
+
* If your editor implementation uses multiple roots, you should provide config for roots individually:
|
|
1329
|
+
*
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* MultiRootEditor.create( {
|
|
1332
|
+
* roots: {
|
|
1333
|
+
* chapter1: {
|
|
1334
|
+
* element: document.querySelector( '#chapter1' ),
|
|
1335
|
+
* description: 'Editing root for the first chapter.'
|
|
1336
|
+
* },
|
|
1337
|
+
* chapter2: {
|
|
1338
|
+
* element: document.querySelector( '#chapter2' ),
|
|
1339
|
+
* description: 'Editing root for the second chapter.'
|
|
1340
|
+
* },
|
|
1341
|
+
* chapter3: {
|
|
1342
|
+
* element: document.querySelector( '#chapter3' ),
|
|
1343
|
+
* description: 'Editing root for the third chapter.'
|
|
1344
|
+
* }
|
|
1345
|
+
* }
|
|
1346
|
+
* } )
|
|
1347
|
+
* .then( ... )
|
|
1348
|
+
* .catch( ... );
|
|
1349
|
+
* ```
|
|
1350
|
+
*/
|
|
1351
|
+
description?: string;
|
|
1352
|
+
/**
|
|
1353
|
+
* Initial root attributes for a root.
|
|
1354
|
+
*
|
|
1355
|
+
* **Note: You must provide full set of attributes for each root. If an attribute is not set on a root, set the value to `null`.
|
|
1356
|
+
* Only provided attribute keys will be returned by {@link module:core/editor/editor~Editor#getRootAttributes} or
|
|
1357
|
+
* {@link module:editor-multi-root/multirooteditor~MultiRootEditor#getRootsAttributes}.**
|
|
1358
|
+
*
|
|
1359
|
+
* Roots attributes hold additional data related to the document roots, in addition to the regular document data (which usually is
|
|
1360
|
+
* HTML). In roots attributes, for each root, you can store arbitrary key-value pairs with attributes connected with that root.
|
|
1361
|
+
* Use it to store any custom data that is specific to your integration or custom features.
|
|
1362
|
+
*
|
|
1363
|
+
* Currently, any official plugins do not use root attributes. This is a mechanism that is prepared for custom features
|
|
1364
|
+
* and non-standard integrations. If you do not provide any custom feature that would use root attributes, you do not need to
|
|
1365
|
+
* handle (save and load) this property.
|
|
1366
|
+
*
|
|
1367
|
+
* ```ts
|
|
1368
|
+
* ClassicEditor.create( {
|
|
1369
|
+
* root: {
|
|
1370
|
+
* modelAttributes: { customAttribute: true }
|
|
1371
|
+
* }
|
|
1372
|
+
* } )
|
|
1373
|
+
* .then( ... )
|
|
1374
|
+
* .catch( ... );
|
|
1375
|
+
* ```
|
|
1376
|
+
*
|
|
1377
|
+
* If your editor implementation uses multiple roots, you should provide attributes for roots individually:
|
|
1378
|
+
*
|
|
1379
|
+
* ```ts
|
|
1380
|
+
* MultiRootEditor.create(
|
|
1381
|
+
* {
|
|
1382
|
+
* roots: {
|
|
1383
|
+
* uid1: {
|
|
1384
|
+
* // ... other root config
|
|
1385
|
+
* modelAttributes: { order: 20, isLocked: false } // Third, unlocked.
|
|
1386
|
+
* },
|
|
1387
|
+
* uid2: {
|
|
1388
|
+
* // ... other root config
|
|
1389
|
+
* modelAttributes: { order: 10, isLocked: true } // Second, locked.
|
|
1390
|
+
* },
|
|
1391
|
+
* uid3: {
|
|
1392
|
+
* // ... other root config
|
|
1393
|
+
* modelAttributes: { order: 30, isLocked: true } // Fourth, locked.
|
|
1394
|
+
* },
|
|
1395
|
+
* uid4: {
|
|
1396
|
+
* // ... other root config
|
|
1397
|
+
* modelAttributes: { order: 0, isLocked: false } // First, unlocked.
|
|
1398
|
+
* }
|
|
1399
|
+
* }
|
|
1400
|
+
* }
|
|
1401
|
+
* )
|
|
1402
|
+
* .then( ... )
|
|
1403
|
+
* .catch( ... );
|
|
1404
|
+
* ```
|
|
1405
|
+
*
|
|
1406
|
+
* Note, that the above code snippet is only an example. You need to implement your own features that will use these attributes.
|
|
1407
|
+
*
|
|
1408
|
+
* Roots attributes can be changed the same way as attributes set on other model nodes:
|
|
1409
|
+
*
|
|
1410
|
+
* ```ts
|
|
1411
|
+
* editor.model.change( writer => {
|
|
1412
|
+
* const root = editor.model.getRoot( 'uid3' );
|
|
1413
|
+
*
|
|
1414
|
+
* writer.setAttribute( 'order', 40, root );
|
|
1415
|
+
* } );
|
|
1416
|
+
* ```
|
|
1417
|
+
*
|
|
1418
|
+
* You can react to root attributes changes by listening to
|
|
1419
|
+
* {@link module:engine/model/document~ModelDocument#event:change:data document `change:data` event}:
|
|
1420
|
+
*
|
|
1421
|
+
* ```ts
|
|
1422
|
+
* editor.model.document.on( 'change:data', () => {
|
|
1423
|
+
* const changedRoots = editor.model.document.differ.getChangedRoots();
|
|
1424
|
+
*
|
|
1425
|
+
* for ( const change of changedRoots ) {
|
|
1426
|
+
* if ( change.attributes ) {
|
|
1427
|
+
* const root = editor.model.getRoot( change.name );
|
|
1428
|
+
*
|
|
1429
|
+
* // ...
|
|
1430
|
+
* }
|
|
1431
|
+
* }
|
|
1432
|
+
* } );
|
|
1433
|
+
* ```
|
|
1434
|
+
*/
|
|
1435
|
+
modelAttributes?: EditorRootAttributes;
|
|
1267
1436
|
}
|
|
1268
1437
|
/**
|
|
1269
1438
|
* The configuration of the editor language.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module core/editor/utils/registerandinitializerootconfigattributes
|
|
7
|
+
*/
|
|
8
|
+
import type { Editor } from '../editor.js';
|
|
9
|
+
/**
|
|
10
|
+
* Registers and initializes root attributes from
|
|
11
|
+
* {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}
|
|
12
|
+
* and {@link module:core/editor/editorconfig~EditorConfig#roots `config.root.modelAttributes`}.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerAndInitializeRootConfigAttributes(editor: Editor): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
import type { Editor } from '../editor.js';
|
|
6
|
+
/**
|
|
7
|
+
* Verifies that all model root elements are registered in the schema as limit elements.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function verifyRootElements(editor: Editor): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,17 +9,19 @@ export { Plugin, type PluginDependencies, type PluginConstructor, type PluginInt
|
|
|
9
9
|
export { Command, type CommandExecuteEvent } from './command.js';
|
|
10
10
|
export { MultiCommand } from './multicommand.js';
|
|
11
11
|
export { CommandCollection, type CommandsMap } from './commandcollection.js';
|
|
12
|
-
export type
|
|
12
|
+
export { type PluginsMap, PluginCollection, type PluginEntry } from './plugincollection.js';
|
|
13
13
|
export { Context, type ContextConfig } from './context.js';
|
|
14
14
|
export { ContextPlugin, type ContextInterface, type ContextPluginDependencies } from './contextplugin.js';
|
|
15
15
|
export { EditingKeystrokeHandler, type EditingKeystrokeCallback } from './editingkeystrokehandler.js';
|
|
16
16
|
export type { PartialBy, NonEmptyArray, HexColor } from './typings.js';
|
|
17
|
-
export { Editor, type EditorCollectUsageDataEvent, type EditorReadyEvent, type EditorDestroyEvent, type LicenseErrorReason as _LicenseErrorReason } from './editor/editor.js';
|
|
17
|
+
export { Editor, type EditorRootAttributes, type EditorCollectUsageDataEvent, type EditorReadyEvent, type EditorDestroyEvent, type LicenseErrorReason as _LicenseErrorReason } from './editor/editor.js';
|
|
18
18
|
export type { EditorConfig, RootConfig, LanguageConfig, ToolbarConfig, ToolbarConfigItem, UiConfig, ViewportOffsetConfig, PoweredByConfig } from './editor/editorconfig.js';
|
|
19
19
|
export { attachToForm } from './editor/utils/attachtoform.js';
|
|
20
20
|
export { ElementApiMixin, type ElementApi } from './editor/utils/elementapimixin.js';
|
|
21
21
|
export { secureSourceElement } from './editor/utils/securesourceelement.js';
|
|
22
|
+
export { registerAndInitializeRootConfigAttributes } from './editor/utils/registerandinitializerootconfigattributes.js';
|
|
22
23
|
export { normalizeRootsConfig, normalizeSingleRootEditorConstructorParams, normalizeMultiRootEditorConstructorParams } from './editor/utils/normalizerootsconfig.js';
|
|
24
|
+
export { verifyRootElements } from './editor/utils/verifyrootelements.js';
|
|
23
25
|
export { PendingActions, type PendingAction, type PendingActionsAddEvent, type PendingActionsRemoveEvent } from './pendingactions.js';
|
|
24
26
|
export { Accessibility, DEFAULT_GROUP_ID as _DEFAULT_ACCESSIBILITY_GROUP_ID, type AddKeystrokeInfoCategoryData, type AddKeystrokeInfoGroupData, type AddKeystrokeInfosData, type KeystrokeInfoDefinition, type KeystrokeInfoDefinitions, type KeystrokeInfoGroupDefinition, type KeystrokeInfoCategoryDefinition } from './accessibility.js';
|
|
25
27
|
export { getEditorUsageData as _getEditorUsageData, type EditorUsageData as _EditorUsageData } from './editor/utils/editorusagedata.js';
|
package/dist/index.js
CHANGED
|
@@ -2006,6 +2006,11 @@ function getPageSessionID() {
|
|
|
2006
2006
|
/**
|
|
2007
2007
|
* A set of lock IDs for the {@link #isReadOnly} getter.
|
|
2008
2008
|
*/ _readOnlyLocks;
|
|
2009
|
+
/**
|
|
2010
|
+
* Holds attributes keys that were passed in
|
|
2011
|
+
* {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}
|
|
2012
|
+
* or {@link module:core/editor/editorconfig~EditorConfig#root `config.root.modelAttributes`}.
|
|
2013
|
+
*/ _registeredRootsAttributesKeys = new Set();
|
|
2009
2014
|
/**
|
|
2010
2015
|
* `Editor` class is commonly put in `config.plugins` array.
|
|
2011
2016
|
*
|
|
@@ -2445,16 +2450,15 @@ function getPageSessionID() {
|
|
|
2445
2450
|
* Loads and initializes plugins specified in the configuration.
|
|
2446
2451
|
*
|
|
2447
2452
|
* @returns A promise which resolves once the initialization is completed, providing an array of loaded plugins.
|
|
2448
|
-
*/ initPlugins() {
|
|
2453
|
+
*/ async initPlugins() {
|
|
2449
2454
|
const config = this.config;
|
|
2450
2455
|
const plugins = config.get('plugins');
|
|
2451
2456
|
const removePlugins = config.get('removePlugins') || [];
|
|
2452
2457
|
const extraPlugins = config.get('extraPlugins') || [];
|
|
2453
2458
|
const substitutePlugins = config.get('substitutePlugins') || [];
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
});
|
|
2459
|
+
const loadedPlugins = await this.plugins.init(plugins.concat(extraPlugins), removePlugins, substitutePlugins);
|
|
2460
|
+
checkPluginsAllowedByLicenseKey(this);
|
|
2461
|
+
return loadedPlugins;
|
|
2458
2462
|
function checkPluginsAllowedByLicenseKey(editor) {
|
|
2459
2463
|
const licenseKey = editor.config.get('licenseKey');
|
|
2460
2464
|
if (licenseKey === 'GPL') {
|
|
@@ -2489,23 +2493,24 @@ function getPageSessionID() {
|
|
|
2489
2493
|
*
|
|
2490
2494
|
* @fires destroy
|
|
2491
2495
|
* @returns A promise that resolves once the editor instance is fully destroyed.
|
|
2492
|
-
*/ destroy() {
|
|
2493
|
-
let readyPromise = Promise.resolve();
|
|
2496
|
+
*/ async destroy() {
|
|
2494
2497
|
if (this.state == 'initializing') {
|
|
2495
|
-
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
})// Remove the editor from the context.
|
|
2498
|
+
await new Promise((resolve)=>this.once('ready', resolve));
|
|
2499
|
+
}
|
|
2500
|
+
this.fire('destroy');
|
|
2501
|
+
this.stopListening();
|
|
2502
|
+
this.commands.destroy();
|
|
2503
|
+
await this.plugins.destroy();
|
|
2504
|
+
this.model.destroy();
|
|
2505
|
+
this.data.destroy();
|
|
2506
|
+
this.editing.destroy();
|
|
2507
|
+
this.keystrokes.destroy();
|
|
2508
|
+
// Remove the editor from the context.
|
|
2507
2509
|
// When the context was created by this editor, the context will be destroyed.
|
|
2508
|
-
|
|
2510
|
+
await this._context._removeEditor(this);
|
|
2511
|
+
// To satisfy the return type and to keep it backward compatible.
|
|
2512
|
+
// eslint-disable-next-line no-useless-return
|
|
2513
|
+
return;
|
|
2509
2514
|
}
|
|
2510
2515
|
/**
|
|
2511
2516
|
* Executes the specified command with given parameters.
|
|
@@ -2538,6 +2543,49 @@ function getPageSessionID() {
|
|
|
2538
2543
|
*/ focus() {
|
|
2539
2544
|
this.editing.view.focus();
|
|
2540
2545
|
}
|
|
2546
|
+
/**
|
|
2547
|
+
* Registers a given string as a root attribute key. Registered root attributes are added to
|
|
2548
|
+
* the {@link module:engine/model/schema~ModelSchema schema}.
|
|
2549
|
+
*
|
|
2550
|
+
* Note: Attributes passed in the configuration for multi-root editors
|
|
2551
|
+
* ({@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}) or
|
|
2552
|
+
* single-root editors ({@link module:core/editor/editorconfig~EditorConfig#root `config.root.modelAttributes`})
|
|
2553
|
+
* are automatically registered when the editor is initialized. However, registering the same attribute twice
|
|
2554
|
+
* does not have any negative impact, so it is recommended to use this method in any feature that uses
|
|
2555
|
+
* root attributes.
|
|
2556
|
+
*/ registerRootAttribute(key) {
|
|
2557
|
+
if (this._registeredRootsAttributesKeys.has(key)) {
|
|
2558
|
+
return;
|
|
2559
|
+
}
|
|
2560
|
+
this._registeredRootsAttributesKeys.add(key);
|
|
2561
|
+
this.editing.model.schema.extend('$root', {
|
|
2562
|
+
allowAttributes: key
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Returns attributes for the specified root.
|
|
2567
|
+
* If no root name is provided, it returns attributes for the 'main' root by default.
|
|
2568
|
+
*
|
|
2569
|
+
* Note: all and only {@link ~Editor#registerRootAttribute registered} roots attributes will be returned.
|
|
2570
|
+
* If a registered root attribute is not set for a given root, `null` will be returned.
|
|
2571
|
+
*/ getRootAttributes(rootName = 'main') {
|
|
2572
|
+
const root = this.model.document.getRoot(rootName);
|
|
2573
|
+
if (!root) {
|
|
2574
|
+
/**
|
|
2575
|
+
* The requested root does not exist. Please ensure that the provided root name
|
|
2576
|
+
* is correct and that the root has been properly initialized in the document.
|
|
2577
|
+
*
|
|
2578
|
+
* @error get-root-attributes-missing-root
|
|
2579
|
+
*/ throw new CKEditorError('get-root-attributes-missing-root', this, {
|
|
2580
|
+
rootName
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
const rootAttributes = {};
|
|
2584
|
+
for (const key of this._registeredRootsAttributesKeys){
|
|
2585
|
+
rootAttributes[key] = root.hasAttribute(key) ? root.getAttribute(key) : null;
|
|
2586
|
+
}
|
|
2587
|
+
return rootAttributes;
|
|
2588
|
+
}
|
|
2541
2589
|
/* istanbul ignore next -- @preserve */ /**
|
|
2542
2590
|
* Creates and initializes a new editor instance.
|
|
2543
2591
|
*
|
|
@@ -2769,8 +2817,10 @@ function collectUsageData(editor) {
|
|
|
2769
2817
|
* In case you intended to use the [LTS Edition](https://ckeditor.com/ckeditor-5-lts/),
|
|
2770
2818
|
* but have not yet made a purchase, please [contact our sales team](https://ckeditor.com/contact-sales/)
|
|
2771
2819
|
*
|
|
2772
|
-
* If you did not intend to use LTS, please
|
|
2773
|
-
*
|
|
2820
|
+
* If you did not intend to use LTS, please note that all releases in the v47.7 line are
|
|
2821
|
+
* for LTS subscribers only. To use a non-LTS edition, either upgrade to v48 or newer,
|
|
2822
|
+
* which is our standard [latest](https://ckeditor.com/docs/ckeditor5/latest/updating/guides/changelog.html)
|
|
2823
|
+
* release line, or stay on a version 47.6.2 or earlier.
|
|
2774
2824
|
*
|
|
2775
2825
|
* @error license-key-lts-not-allowed
|
|
2776
2826
|
*/
|
|
@@ -2881,6 +2931,48 @@ function isTextArea(sourceElement) {
|
|
|
2881
2931
|
});
|
|
2882
2932
|
}
|
|
2883
2933
|
|
|
2934
|
+
/**
|
|
2935
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2936
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
2937
|
+
*/ /**
|
|
2938
|
+
* @module core/editor/utils/registerandinitializerootconfigattributes
|
|
2939
|
+
*/ /**
|
|
2940
|
+
* Registers and initializes root attributes from
|
|
2941
|
+
* {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}
|
|
2942
|
+
* and {@link module:core/editor/editorconfig~EditorConfig#roots `config.root.modelAttributes`}.
|
|
2943
|
+
*
|
|
2944
|
+
* @internal
|
|
2945
|
+
*/ function registerAndInitializeRootConfigAttributes(editor) {
|
|
2946
|
+
const rootsConfig = editor.config.get('roots');
|
|
2947
|
+
let hasRootAttributes = false;
|
|
2948
|
+
for (const rootConfig of Object.values(rootsConfig)){
|
|
2949
|
+
for (const key of Object.keys(rootConfig.modelAttributes || {})){
|
|
2950
|
+
editor.registerRootAttribute(key);
|
|
2951
|
+
hasRootAttributes = true;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
if (!hasRootAttributes) {
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2957
|
+
editor.data.once('init', ()=>{
|
|
2958
|
+
editor.model.enqueueChange({
|
|
2959
|
+
isUndoable: false
|
|
2960
|
+
}, (writer)=>{
|
|
2961
|
+
for (const [rootName, rootConfig] of Object.entries(rootsConfig)){
|
|
2962
|
+
const root = editor.model.document.getRoot(rootName);
|
|
2963
|
+
if (!root) {
|
|
2964
|
+
continue;
|
|
2965
|
+
}
|
|
2966
|
+
for (const [key, value] of Object.entries(rootConfig.modelAttributes || {})){
|
|
2967
|
+
if (value !== null) {
|
|
2968
|
+
writer.setAttribute(key, value, root);
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
});
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2884
2976
|
/**
|
|
2885
2977
|
* Normalizes the editor roots configuration. It ensures that all root configurations are defined in `config.roots`
|
|
2886
2978
|
* and that they have `initialData` defined.
|
|
@@ -3035,6 +3127,8 @@ function isTextArea(sourceElement) {
|
|
|
3035
3127
|
// Handle legacy `config.placeholder` and `config.label` for the root.
|
|
3036
3128
|
rootConfig.placeholder ??= getLegacyPlainConfigValue(config, 'placeholder', rootName);
|
|
3037
3129
|
rootConfig.label ??= getLegacyPlainConfigValue(config, 'label', rootName);
|
|
3130
|
+
// Default model element to `$root` so all callers can rely on `rootConfig.modelElement` being a string.
|
|
3131
|
+
rootConfig.modelElement ||= '$root';
|
|
3038
3132
|
rootsConfig[rootName] = rootConfig;
|
|
3039
3133
|
}
|
|
3040
3134
|
// The ClassicEditor has a special separate config option `attachTo`.
|
|
@@ -3147,6 +3241,39 @@ function isTextArea(sourceElement) {
|
|
|
3147
3241
|
return isElement$1(value);
|
|
3148
3242
|
}
|
|
3149
3243
|
|
|
3244
|
+
/**
|
|
3245
|
+
* Verifies that all model root elements are registered in the schema as limit elements.
|
|
3246
|
+
*
|
|
3247
|
+
* @internal
|
|
3248
|
+
*/ function verifyRootElements(editor) {
|
|
3249
|
+
const schema = editor.model.schema;
|
|
3250
|
+
const document = editor.model.document;
|
|
3251
|
+
// Iterate `document.roots` directly instead of `document.getRootNames()` because the latter filters out roots
|
|
3252
|
+
// that are not loaded yet (e.g. lazy roots in the multi-root editor), which still need to be verified.
|
|
3253
|
+
// Detached roots are skipped – a detached root is equivalent to being removed, so there is no point in validating it.
|
|
3254
|
+
for (const root of document.roots){
|
|
3255
|
+
if (root === document.graveyard || !root.isAttached()) {
|
|
3256
|
+
continue;
|
|
3257
|
+
}
|
|
3258
|
+
if (!schema.isLimit(root)) {
|
|
3259
|
+
/**
|
|
3260
|
+
* The model root element must be a {@link module:engine/model/schema~ModelSchemaItemDefinition#isLimit limit element}.
|
|
3261
|
+
* The element name specified in
|
|
3262
|
+
* {@link module:core/editor/editorconfig~RootConfig#modelElement `config.root.modelElement`}
|
|
3263
|
+
* (or `config.roots.<rootName>.modelElement`) must be registered in the schema
|
|
3264
|
+
* with `isLimit` set to `true`.
|
|
3265
|
+
*
|
|
3266
|
+
* @error editor-root-element-is-not-limit
|
|
3267
|
+
* @param rootName The name of the root that uses a non-limit element.
|
|
3268
|
+
* @param elementName The name of the model element used for the root.
|
|
3269
|
+
*/ throw new CKEditorError('editor-root-element-is-not-limit', null, {
|
|
3270
|
+
rootName: root.rootName,
|
|
3271
|
+
elementName: root.name
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3150
3277
|
/**
|
|
3151
3278
|
* The list of pending editor actions.
|
|
3152
3279
|
*
|
|
@@ -3258,5 +3385,5 @@ function isTextArea(sourceElement) {
|
|
|
3258
3385
|
}
|
|
3259
3386
|
}
|
|
3260
3387
|
|
|
3261
|
-
export { Accessibility, Command, CommandCollection, Context, ContextPlugin, EditingKeystrokeHandler, Editor, ElementApiMixin, MultiCommand, PendingActions, Plugin, DEFAULT_GROUP_ID as _DEFAULT_ACCESSIBILITY_GROUP_ID, getEditorUsageData as _getEditorUsageData, attachToForm, normalizeMultiRootEditorConstructorParams, normalizeRootsConfig, normalizeSingleRootEditorConstructorParams, secureSourceElement };
|
|
3388
|
+
export { Accessibility, Command, CommandCollection, Context, ContextPlugin, EditingKeystrokeHandler, Editor, ElementApiMixin, MultiCommand, PendingActions, Plugin, PluginCollection, DEFAULT_GROUP_ID as _DEFAULT_ACCESSIBILITY_GROUP_ID, getEditorUsageData as _getEditorUsageData, attachToForm, normalizeMultiRootEditorConstructorParams, normalizeRootsConfig, normalizeSingleRootEditorConstructorParams, registerAndInitializeRootConfigAttributes, secureSourceElement, verifyRootElements };
|
|
3262
3389
|
//# sourceMappingURL=index.js.map
|