@ckeditor/ckeditor5-editor-multi-root 47.6.1 → 48.0.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.
@@ -5,10 +5,10 @@
5
5
  /**
6
6
  * @module editor-multi-root/multirooteditor
7
7
  */
8
- import { Editor, type EditorConfig } from 'ckeditor5/src/core.js';
9
- import { type DecoratedMethodEvent } from 'ckeditor5/src/utils.js';
8
+ import { Editor, type EditorConfig, type RootConfig } from '@ckeditor/ckeditor5-core';
9
+ import { type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils';
10
10
  import { MultiRootEditorUI } from './multirooteditorui.js';
11
- import { type ModelRootElement } from 'ckeditor5/src/engine.js';
11
+ import { type ModelRootElement } from '@ckeditor/ckeditor5-engine';
12
12
  /**
13
13
  * The multi-root editor implementation.
14
14
  *
@@ -37,8 +37,9 @@ export declare class MultiRootEditor extends Editor {
37
37
  */
38
38
  readonly sourceElements: Record<string, HTMLElement>;
39
39
  /**
40
- * Holds attributes keys that were passed in {@link module:core/editor/editorconfig~EditorConfig#rootsAttributes `rootsAttributes`}
41
- * config property and should be returned by {@link #getRootsAttributes}.
40
+ * Holds attributes keys that were passed in
41
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}
42
+ * and should be returned by {@link #getRootsAttributes}.
42
43
  */
43
44
  private readonly _registeredRootsAttributesKeys;
44
45
  /**
@@ -51,12 +52,24 @@ export declare class MultiRootEditor extends Editor {
51
52
  * **Note:** Do not use the constructor to create editor instances. Use the static
52
53
  * {@link module:editor-multi-root/multirooteditor~MultiRootEditor.create `MultiRootEditor.create()`} method instead.
53
54
  *
55
+ * @param config The editor configuration.
56
+ */
57
+ protected constructor(config: EditorConfig);
58
+ /**
59
+ * Creates an instance of the multi-root editor.
60
+ *
61
+ * **Note:** Do not use the constructor to create editor instances. Use the static
62
+ * {@link module:editor-multi-root/multirooteditor~MultiRootEditor.create `MultiRootEditor.create()`} method instead.
63
+ *
64
+ * **Note**: This constructor signature is deprecated and will be removed in the future release.
65
+ *
66
+ * @deprecated
54
67
  * @param sourceElementsOrData The DOM elements that will be the source for the created editor
55
68
  * or the editor's initial data. The editor will initialize multiple roots with names according to the keys in the passed object.
56
69
  * For more information see {@link module:editor-multi-root/multirooteditor~MultiRootEditor.create `MultiRootEditor.create()`}.
57
70
  * @param config The editor configuration.
58
71
  */
59
- protected constructor(sourceElementsOrData: Record<string, HTMLElement> | Record<string, string>, config?: EditorConfig);
72
+ protected constructor(sourceElementsOrData: Record<string, HTMLElement> | Record<string, string>, config: EditorConfig);
60
73
  /**
61
74
  * Destroys the editor instance, releasing all resources used by it.
62
75
  *
@@ -86,7 +99,7 @@ export declare class MultiRootEditor extends Editor {
86
99
  * Adds a new root to the editor.
87
100
  *
88
101
  * ```ts
89
- * editor.addRoot( 'myRoot', { data: '<p>Initial root data.</p>' } );
102
+ * editor.addRoot( 'myRoot', { initialData: '<p>Initial root data.</p>' } );
90
103
  * ```
91
104
  *
92
105
  * After a root is added, you will be able to modify and retrieve its data.
@@ -127,13 +140,13 @@ export declare class MultiRootEditor extends Editor {
127
140
  * ```ts
128
141
  * // Add a collapsed root at fourth position from top.
129
142
  * // Keep in mind that these are just examples of attributes. You need to provide your own features that will handle the attributes.
130
- * editor.addRoot( 'myRoot', { attributes: { isCollapsed: true, index: 4 } } );
143
+ * editor.addRoot( 'myRoot', { modelAttributes: { isCollapsed: true, index: 4 } } );
131
144
  * ```
132
145
  *
133
146
  * Note that attributes added together with a root are automatically registered.
134
147
  *
135
148
  * See also {@link ~MultiRootEditor#registerRootAttribute `MultiRootEditor#registerRootAttribute()`} and
136
- * {@link module:core/editor/editorconfig~EditorConfig#rootsAttributes `config.rootsAttributes` configuration option}.
149
+ * {@link module:core/editor/editorconfig~RootConfig#modelAttributes `config.roots.<rootName>.modelAttributes` configuration option}.
137
150
  *
138
151
  * By setting `isUndoable` flag to `true`, you can allow for detaching the root using the undo feature.
139
152
  *
@@ -152,10 +165,27 @@ export declare class MultiRootEditor extends Editor {
152
165
  * } );
153
166
  * ```
154
167
  *
168
+ * @label ROOT_CONFIG
169
+ * @param rootName Name of the root to add.
170
+ * @param options Additional options for the added root.
171
+ */
172
+ addRoot(rootName: string, options?: AddRootRootConfig): void;
173
+ /**
174
+ * Adds a new root to the editor.
175
+ *
176
+ * ```ts
177
+ * editor.addRoot( 'myRoot', { data: '<p>Initial root data.</p>' } );
178
+ * ```
179
+ *
180
+ * **Note**: This method signature is deprecated and will be removed in one of the next releases.
181
+ * Use the signature with root options object instead {@link #addRoot:ROOT_CONFIG `addRoot( rootName, options )`}.
182
+ *
183
+ * @deprecated
184
+ * @label LEGACY_ADD_ROOT_OPTIONS
155
185
  * @param rootName Name of the root to add.
156
186
  * @param options Additional options for the added root.
157
187
  */
158
- addRoot(rootName: string, { data, attributes, elementName, isUndoable }?: AddRootOptions): void;
188
+ addRoot(rootName: string, options?: AddRootOptions): void;
159
189
  /**
160
190
  * Detaches a root from the editor.
161
191
  *
@@ -216,9 +246,27 @@ export declare class MultiRootEditor extends Editor {
216
246
  *
217
247
  * The new DOM editable is attached to the model root and can be used to modify the root content.
218
248
  *
249
+ * @label OPTIONS
250
+ * @param root Root for which the editable element should be created.
251
+ * @param options.placeholder Placeholder for the editable element. If not set, placeholder value from the
252
+ * {@link module:core/editor/editorconfig~RootConfig#placeholder root configuration} will be used (if it was provided).
253
+ * @param options.label The accessible label text describing the editable to the assistive technologies.
254
+ * @returns The created DOM element. Append it in a desired place in your application.
255
+ */
256
+ createEditable(root: ModelRootElement, options?: RootEditableOptions): HTMLElement;
257
+ /**
258
+ * Creates and returns a new DOM editable element for the given root element.
259
+ *
260
+ * The new DOM editable is attached to the model root and can be used to modify the root content.
261
+ *
262
+ * **Note**: this method signature is deprecated and will be removed in one of the next releases.
263
+ * Use the signature with options object instead {@link #createEditable:OPTIONS `createEditable( root, options )`}.
264
+ *
265
+ * @deprecated
266
+ * @label LEGACY
219
267
  * @param root Root for which the editable element should be created.
220
268
  * @param placeholder Placeholder for the editable element. If not set, placeholder value from the
221
- * {@link module:core/editor/editorconfig~EditorConfig#placeholder editor configuration} will be used (if it was provided).
269
+ * {@link module:core/editor/editorconfig~RootConfig#placeholder root configuration} will be used (if it was provided).
222
270
  * @param label The accessible label text describing the editable to the assistive technologies.
223
271
  * @returns The created DOM element. Append it in a desired place in your application.
224
272
  */
@@ -231,8 +279,8 @@ export declare class MultiRootEditor extends Editor {
231
279
  */
232
280
  detachEditable(root: ModelRootElement): HTMLElement;
233
281
  /**
234
- * Loads a root that has previously been declared in {@link module:core/editor/editorconfig~EditorConfig#lazyRoots `lazyRoots`}
235
- * configuration option.
282
+ * Loads a root that has previously been declared in
283
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.lazyLoad`} configuration option.
236
284
  *
237
285
  * **Important! Lazy roots loading is an experimental feature, and may become deprecated. Be advised of the following
238
286
  * known limitations:**
@@ -261,7 +309,7 @@ export declare class MultiRootEditor extends Editor {
261
309
  * Note that attributes loaded together with a root are automatically registered.
262
310
  *
263
311
  * See also {@link ~MultiRootEditor#registerRootAttribute `MultiRootEditor#registerRootAttribute()`} and
264
- * {@link module:core/editor/editorconfig~EditorConfig#rootsAttributes `config.rootsAttributes` configuration option}.
312
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes` configuration option}.
265
313
  *
266
314
  * When this method is used in real-time collaboration environment, its effects become asynchronous as the editor will first synchronize
267
315
  * with the remote editing session, before the root is added to the editor.
@@ -306,9 +354,10 @@ export declare class MultiRootEditor extends Editor {
306
354
  * {@link ~MultiRootEditor#getRootAttributes `getRootAttributes()`} and
307
355
  * {@link ~MultiRootEditor#getRootsAttributes `getRootsAttributes()`}.
308
356
  *
309
- * Note: attributes passed in {@link module:core/editor/editorconfig~EditorConfig#rootsAttributes `config.rootsAttributes`} are
310
- * automatically registered as the editor is initialized. However, registering the same attribute twice does not have any negative
311
- * impact, so it is recommended to use this method in any feature that uses roots attributes.
357
+ * Note: attributes passed in
358
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.modelAttributes`}
359
+ * are automatically registered as the editor is initialized. However, registering the same attribute twice does not have any
360
+ * negative impact, so it is recommended to use this method in any feature that uses roots attributes.
312
361
  */
313
362
  registerRootAttribute(key: string): void;
314
363
  /**
@@ -368,6 +417,150 @@ export declare class MultiRootEditor extends Editor {
368
417
  *
369
418
  * ```ts
370
419
  * MultiRootEditor.create( {
420
+ * roots: {
421
+ * intro: {
422
+ * element: document.querySelector( '#editor-intro' )
423
+ * },
424
+ * content: {
425
+ * element: document.querySelector( '#editor-content' )
426
+ * },
427
+ * sidePanelLeft: {
428
+ * element: document.querySelector( '#editor-side-left' )
429
+ * },
430
+ * sidePanelRight: {
431
+ * element: document.querySelector( '#editor-side-right' )
432
+ * },
433
+ * outro: {
434
+ * element: document.querySelector( '#editor-outro' )
435
+ * }
436
+ * }
437
+ * } )
438
+ * .then( editor => {
439
+ * console.log( 'Editor was initialized', editor );
440
+ *
441
+ * // Append the toolbar inside a provided DOM element.
442
+ * document.querySelector( '#toolbar-container' ).appendChild( editor.ui.view.toolbar.element );
443
+ * } )
444
+ * .catch( err => {
445
+ * console.error( err.stack );
446
+ * } );
447
+ * ```
448
+ *
449
+ * The elements' content will be used as the editor data and elements will become editable elements.
450
+ *
451
+ * # Creating a detached editor
452
+ *
453
+ * Alternatively, you can initialize the editor by passing the initial data directly as strings.
454
+ * In this case, you will have to manually append both the toolbar element and the editable elements to your web page.
455
+ *
456
+ * ```ts
457
+ * MultiRootEditor.create( {
458
+ * roots: {
459
+ * intro: {
460
+ * initialData: '<p><strong>Exciting</strong> intro text to an article.</p>'
461
+ * },
462
+ * content: {
463
+ * initialData: '<p>Lorem ipsum dolor sit amet.</p>'
464
+ * },
465
+ * sidePanelLeft: {
466
+ * initialData: '<blockquote>Strong quotation from article.</blockquote>'
467
+ * },
468
+ * sidePanelRight: {
469
+ * initialData: '<p>List of similar articles...</p>'
470
+ * },
471
+ * outro: {
472
+ * initialData: '<p>Closing text.</p>'
473
+ * }
474
+ * }
475
+ * } )
476
+ * .then( editor => {
477
+ * console.log( 'Editor was initialized', editor );
478
+ *
479
+ * // Append the toolbar inside a provided DOM element.
480
+ * document.querySelector( '#toolbar-container' ).appendChild( editor.ui.view.toolbar.element );
481
+ *
482
+ * // Append DOM editable elements created by the editor.
483
+ * const editables = editor.ui.view.editables;
484
+ * const container = document.querySelector( '#editable-container' );
485
+ *
486
+ * container.appendChild( editables.intro.element );
487
+ * container.appendChild( editables.content.element );
488
+ * container.appendChild( editables.outro.element );
489
+ * } )
490
+ * .catch( err => {
491
+ * console.error( err.stack );
492
+ * } );
493
+ * ```
494
+ *
495
+ * This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
496
+ * web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
497
+ *
498
+ * # Using an existing DOM element (and data provided in `config.roots.<rootName>.initialData`)
499
+ *
500
+ * You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
501
+ *
502
+ * ```ts
503
+ * MultiRootEditor.create( {
504
+ * roots: {
505
+ * intro: {
506
+ * element: document.querySelector( '#editor-intro' ),
507
+ * initialData: '<p><strong>Exciting</strong> intro text to an article.</p>'
508
+ * },
509
+ * content: {
510
+ * element: document.querySelector( '#editor-content' ),
511
+ * initialData: '<p>Lorem ipsum dolor sit amet.</p>'
512
+ * },
513
+ * sidePanelLeft: {
514
+ * element: document.querySelector( '#editor-side-left' ),
515
+ * initialData: '<blockquote>Strong quotation from article.</blockquote>'
516
+ * },
517
+ * sidePanelRight: {
518
+ * element: document.querySelector( '#editor-side-right' ),
519
+ * initialData: '<p>List of similar articles...</p>'
520
+ * },
521
+ * outro: {
522
+ * element: document.querySelector( '#editor-outro' ),
523
+ * initialData: '<p>Closing text.</p>'
524
+ * }
525
+ * }
526
+ * } )
527
+ * .then( editor => {
528
+ * console.log( 'Editor was initialized', editor );
529
+ *
530
+ * // Append the toolbar inside a provided DOM element.
531
+ * document.querySelector( '#toolbar-container' ).appendChild( editor.ui.view.toolbar.element );
532
+ * } )
533
+ * .catch( err => {
534
+ * console.error( err.stack );
535
+ * } );
536
+ * ```
537
+ *
538
+ * This method can be used to initialize the editor on an existing element with the specified content in case if your integration
539
+ * makes it difficult to set the content of the source element.
540
+ *
541
+ * # Configuring the editor
542
+ *
543
+ * See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
544
+ * customizing plugins, toolbar and more.
545
+ *
546
+ * @param config The editor configuration.
547
+ * @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
548
+ */
549
+ static create(config: EditorConfig): Promise<MultiRootEditor>;
550
+ /**
551
+ * Creates a new multi-root editor instance.
552
+ *
553
+ * **Note**: This method signature is deprecated and will be removed in the future release.
554
+ *
555
+ * **Note:** remember that `MultiRootEditor` does not append the toolbar element to your web page, so you have to do it manually
556
+ * after the editor has been initialized.
557
+ *
558
+ * There are a few different ways to initialize the multi-root editor.
559
+ *
560
+ * # Using existing DOM elements:
561
+ *
562
+ * ```ts
563
+ * MultiRootEditor.create( {
371
564
  * intro: document.querySelector( '#editor-intro' ),
372
565
  * content: document.querySelector( '#editor-content' ),
373
566
  * sidePanelLeft: document.querySelector( '#editor-side-left' ),
@@ -422,7 +615,7 @@ export declare class MultiRootEditor extends Editor {
422
615
  * This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
423
616
  * web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
424
617
  *
425
- * # Using an existing DOM element (and data provided in `config.initialData`)
618
+ * # Using an existing DOM element (and data provided in `config.roots.<rootName>.initialData`)
426
619
  *
427
620
  * You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
428
621
  *
@@ -434,12 +627,22 @@ export declare class MultiRootEditor extends Editor {
434
627
  * sidePanelRight: document.querySelector( '#editor-side-right' ),
435
628
  * outro: document.querySelector( '#editor-outro' )
436
629
  * }, {
437
- * initialData: {
438
- * intro: '<p><strong>Exciting</strong> intro text to an article.</p>',
439
- * content: '<p>Lorem ipsum dolor sit amet.</p>',
440
- * sidePanelLeft '<blockquote>Strong quotation from article.</blockquote>':
441
- * sidePanelRight '<p>List of similar articles...</p>':
442
- * outro: '<p>Closing text.</p>'
630
+ * roots: {
631
+ * intro: {
632
+ * initialData: '<p><strong>Exciting</strong> intro text to an article.</p>'
633
+ * },
634
+ * content: {
635
+ * initialData: '<p>Lorem ipsum dolor sit amet.</p>'
636
+ * },
637
+ * sidePanelLeft: {
638
+ * initialData: '<blockquote>Strong quotation from article.</blockquote>'
639
+ * },
640
+ * sidePanelRight: {
641
+ * initialData: '<p>List of similar articles...</p>'
642
+ * },
643
+ * outro: {
644
+ * initialData: '<p>Closing text.</p>'
645
+ * }
443
646
  * }
444
647
  * } )
445
648
  * .then( editor => {
@@ -463,6 +666,7 @@ export declare class MultiRootEditor extends Editor {
463
666
  * See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
464
667
  * customizing plugins, toolbar and more.
465
668
  *
669
+ * @deprecated
466
670
  * @param sourceElementsOrData The DOM elements that will be the source for the created editor
467
671
  * or the editor's initial data. The editor will initialize multiple roots with names according to the keys in the passed object.
468
672
  *
@@ -478,7 +682,7 @@ export declare class MultiRootEditor extends Editor {
478
682
  * @param config The editor configuration.
479
683
  * @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
480
684
  */
481
- static create(sourceElementsOrData: Record<string, HTMLElement> | Record<string, string>, config?: EditorConfig): Promise<MultiRootEditor>;
685
+ static create(sourceElementsOrData: Record<string, HTMLElement> | Record<string, string>, config: EditorConfig): Promise<MultiRootEditor>;
482
686
  /**
483
687
  * @internal
484
688
  */
@@ -528,6 +732,8 @@ export type DetachRootEvent = {
528
732
  export type LoadRootEvent = DecoratedMethodEvent<MultiRootEditor, 'loadRoot'>;
529
733
  /**
530
734
  * Additional options available when adding a root.
735
+ *
736
+ * @deprecated
531
737
  */
532
738
  export type AddRootOptions = {
533
739
  /**
@@ -547,6 +753,19 @@ export type AddRootOptions = {
547
753
  */
548
754
  isUndoable?: boolean;
549
755
  };
756
+ /**
757
+ * Declares an additional options available when adding a root.
758
+ */
759
+ export interface AddRootRootConfig extends RootConfig {
760
+ /**
761
+ * Passing a DOM element to {@link ~MultiRootEditor#addRoot:ROOT_CONFIG `addRoot( rootName, options )`} is not supported.
762
+ */
763
+ element?: undefined;
764
+ /**
765
+ * Whether creating the root can be undone (using the undo feature) or not.
766
+ */
767
+ isUndoable?: boolean;
768
+ }
550
769
  /**
551
770
  * Additional options available when loading a root.
552
771
  */
@@ -555,3 +774,17 @@ export type LoadRootOptions = Omit<AddRootOptions, 'elementName' | 'isUndoable'>
555
774
  * Attributes set on a model root element.
556
775
  */
557
776
  export type RootAttributes = Record<string, unknown>;
777
+ /**
778
+ * Additional options for the created editable element.
779
+ */
780
+ export interface RootEditableOptions {
781
+ /**
782
+ * Placeholder for the editable element. If not set, placeholder value from the
783
+ * {@link module:core/editor/editorconfig~RootConfig#placeholder editor configuration} will be used (if it was provided).
784
+ */
785
+ placeholder?: string;
786
+ /**
787
+ * The accessible label text describing the editable to the assistive technologies.
788
+ */
789
+ label?: string;
790
+ }
@@ -5,8 +5,8 @@
5
5
  /**
6
6
  * @module editor-multi-root/multirooteditorui
7
7
  */
8
- import { type Editor } from 'ckeditor5/src/core.js';
9
- import { EditorUI, type InlineEditableUIView } from 'ckeditor5/src/ui.js';
8
+ import { type Editor } from '@ckeditor/ckeditor5-core';
9
+ import { EditorUI, type InlineEditableUIView } from '@ckeditor/ckeditor5-ui';
10
10
  import { type MultiRootEditorUIView } from './multirooteditoruiview.js';
11
11
  /**
12
12
  * The multi-root editor UI class.
@@ -5,9 +5,9 @@
5
5
  /**
6
6
  * @module editor-multi-root/multirooteditoruiview
7
7
  */
8
- import { EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from 'ckeditor5/src/ui.js';
9
- import type { Locale } from 'ckeditor5/src/utils.js';
10
- import type { EditingView } from 'ckeditor5/src/engine.js';
8
+ import { EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from '@ckeditor/ckeditor5-ui';
9
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
10
+ import type { EditingView } from '@ckeditor/ckeditor5-engine';
11
11
  /**
12
12
  * The multi-root editor UI view. It is a virtual view providing an inline
13
13
  * {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#editable} and a
package/package.json CHANGED
@@ -1,26 +1,9 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-editor-multi-root",
3
- "version": "47.6.1",
3
+ "version": "48.0.0-alpha.0",
4
4
  "description": "Multi-root editor implementation for CKEditor 5.",
5
- "keywords": [
6
- "ckeditor",
7
- "ckeditor5",
8
- "ckeditor 5",
9
- "ckeditor5-editor",
10
- "ckeditor5-dll"
11
- ],
12
- "type": "module",
13
- "main": "src/index.js",
14
- "dependencies": {
15
- "@ckeditor/ckeditor5-core": "47.6.1",
16
- "@ckeditor/ckeditor5-engine": "47.6.1",
17
- "@ckeditor/ckeditor5-ui": "47.6.1",
18
- "@ckeditor/ckeditor5-utils": "47.6.1",
19
- "ckeditor5": "47.6.1",
20
- "es-toolkit": "1.39.5"
21
- },
22
- "author": "CKSource (http://cksource.com/)",
23
5
  "license": "SEE LICENSE IN LICENSE.md",
6
+ "author": "CKSource (http://cksource.com/)",
24
7
  "homepage": "https://ckeditor.com/ckeditor-5",
25
8
  "bugs": "https://github.com/ckeditor/ckeditor5/issues",
26
9
  "repository": {
@@ -28,33 +11,29 @@
28
11
  "url": "https://github.com/ckeditor/ckeditor5.git",
29
12
  "directory": "packages/ckeditor5-editor-multi-root"
30
13
  },
14
+ "keywords": [
15
+ "ckeditor",
16
+ "ckeditor5",
17
+ "ckeditor 5",
18
+ "ckeditor5-editor"
19
+ ],
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "exports": {
23
+ ".": "./dist/index.js",
24
+ "./dist/*": "./dist/*",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "dependencies": {
28
+ "@ckeditor/ckeditor5-core": "48.0.0-alpha.0",
29
+ "@ckeditor/ckeditor5-engine": "48.0.0-alpha.0",
30
+ "@ckeditor/ckeditor5-ui": "48.0.0-alpha.0",
31
+ "@ckeditor/ckeditor5-utils": "48.0.0-alpha.0",
32
+ "es-toolkit": "1.45.1"
33
+ },
31
34
  "files": [
32
35
  "dist",
33
- "lang",
34
- "src/**/*.js",
35
- "src/**/*.d.ts",
36
- "theme",
37
- "build",
38
36
  "CHANGELOG.md"
39
37
  ],
40
- "types": "src/index.d.ts",
41
- "exports": {
42
- ".": {
43
- "types": "./src/index.d.ts",
44
- "import": "./src/index.js",
45
- "default": "./src/index.js"
46
- },
47
- "./dist/*": {
48
- "types": "./src/index.d.ts",
49
- "import": "./dist/*",
50
- "default": "./dist/*"
51
- },
52
- "./src/*": {
53
- "types": "./src/*.d.ts",
54
- "import": "./src/*",
55
- "default": "./src/*"
56
- },
57
- "./build/*": "./build/*",
58
- "./package.json": "./package.json"
59
- }
38
+ "types": "./dist/index.d.ts"
60
39
  }
@@ -1,4 +0,0 @@
1
- /*!
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md.
4
- */(()=>{var t={237:t=>{"use strict";t.exports=CKEditor5.dll},311:(t,e,o)=>{t.exports=o(237)("./src/ui.js")},584:(t,e,o)=>{t.exports=o(237)("./src/utils.js")},782:(t,e,o)=>{t.exports=o(237)("./src/core.js")},783:(t,e,o)=>{t.exports=o(237)("./src/engine.js")}},e={};function o(i){var s=e[i];if(void 0!==s)return s.exports;var r=e[i]={exports:{}};return t[i](r,r.exports,o),r.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";o.r(i),o.d(i,{MultiRootEditor:()=>l,MultiRootEditorUI:()=>n,MultiRootEditorUIView:()=>a});var t=o(782),e=o(584),s=o(311),r=o(783);class n extends s.EditorUI{view;_lastFocusedEditableElement;constructor(t,e){super(t),this.view=e,this._lastFocusedEditableElement=null}init(){this.view.render(),this.focusTracker.on("change:focusedElement",(t,e,o)=>{for(const t of Object.values(this.view.editables))o===t.element&&(this._lastFocusedEditableElement=t.element)}),this.focusTracker.on("change:isFocused",(t,e,o)=>{o||(this._lastFocusedEditableElement=null)});for(const t of Object.values(this.view.editables))this.addEditable(t);this._initToolbar(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}addEditable(t,e){const o=t.element;this.editor.editing.view.attachDomRoot(o,t.name),this.setEditableElement(t.name,o),t.bind("isFocused").to(this.focusTracker,"isFocused",this.focusTracker,"focusedElement",(t,e)=>!!t&&(e===o||this._lastFocusedEditableElement===o)),this._initPlaceholder(t,e)}removeEditable(t){const e=this.editor.editing.view;e.getDomRoot(t.name)&&e.detachDomRoot(t.name),t.unbind("isFocused"),this.removeEditableElement(t.name)}destroy(){super.destroy();for(const t of Object.values(this.view.editables))this.removeEditable(t);this.view.destroy()}_initToolbar(){const t=this.editor,e=this.view;e.toolbar.fillFromConfig(t.config.get("toolbar"),this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(t,e){if(!e){const o=this.editor.config.get("placeholder");o&&(e="string"==typeof o?o:o[t.name])}const o=this.editor.editing.view,i=o.document.getRoot(t.name);e&&(i.placeholder=e),(0,r.enableViewPlaceholder)({view:o,element:i,isDirectHost:!1,keepOnFocus:!0})}}class a extends s.EditorUIView{toolbar;editables;editable;menuBarView;_editingView;constructor(t,e,o,i={}){super(t),this._editingView=e,this.toolbar=new s.ToolbarView(t,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.menuBarView=new s.MenuBarView(t),this.editables={};for(const t of o){const e=i.editableElements?i.editableElements[t]:void 0;let{label:o}=i;"object"==typeof o&&(o=o[t]),this.createEditable(t,e,o)}this.editable=Object.values(this.editables)[0],this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}}),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}createEditable(t,e,o){const i=new s.InlineEditableUIView(this.locale,this._editingView,e,{label:o});return this.editables[t]=i,i.name=t,this.isRendered&&this.registerChild(i),i}removeEditable(t){const e=this.editables[t];this.isRendered&&this.deregisterChild(e),delete this.editables[t],e.destroy()}render(){super.render(),this.registerChild(Object.values(this.editables)),this.registerChild(this.toolbar),this.registerChild(this.menuBarView)}}function d(t){return function(t){return"object"==typeof t&&null!==t}(t)&&1===t.nodeType&&!function(t){if("object"!=typeof t)return!1;if(null==t)return!1;if(null===Object.getPrototypeOf(t))return!0;if("[object Object]"!==Object.prototype.toString.call(t)){const e=t[Symbol.toStringTag];return null!=e&&(!!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable&&t.toString()===`[object ${e}]`)}let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}(t)}class l extends t.Editor{static get editorName(){return"MultiRootEditor"}ui;sourceElements;_registeredRootsAttributesKeys=new Set;_readOnlyRootLocks=new Map;constructor(o,i={}){const s=Object.keys(o),r=0===s.length||"string"==typeof o[s[0]];if(r&&void 0!==i.initialData&&Object.keys(i.initialData).length>0)throw new e.CKEditorError("editor-create-initial-data",null);if(super(i),this.sourceElements=r?{}:o,void 0===this.config.get("initialData")){const t={};for(const e of s)t[e]=c(o[e]);this.config.set("initialData",t)}if(!r)for(const e of s)(0,t.secureSourceElement)(this,o[e]);this.editing.view.document.roots.on("add",(t,e)=>{e.unbind("isReadOnly"),e.bind("isReadOnly").to(this.editing.view.document,"isReadOnly",t=>t||this._readOnlyRootLocks.has(e.rootName)),e.on("change:isReadOnly",(t,o,i)=>{const s=this.editing.view.createRangeIn(e);for(const t of s.getItems())t.is("editableElement")&&(t.unbind("isReadOnly"),t.isReadOnly=i)})});for(const t of s)this.model.document.createRoot("$root",t);if(this.config.get("lazyRoots"))for(const t of this.config.get("lazyRoots")){this.model.document.createRoot("$root",t)._isLoaded=!1}if(this.config.get("rootsAttributes")){const t=this.config.get("rootsAttributes");for(const[o,i]of Object.entries(t)){if(!this.model.document.getRoot(o))throw new e.CKEditorError("multi-root-editor-root-attributes-no-root",null);for(const t of Object.keys(i))this.registerRootAttribute(t)}this.data.on("init",()=>{this.model.enqueueChange({isUndoable:!1},e=>{for(const[o,i]of Object.entries(t)){const t=this.model.document.getRoot(o);for(const[o,s]of Object.entries(i))null!==s&&e.setAttribute(o,s,t)}})})}const d={shouldToolbarGroupWhenFull:!this.config.get("toolbar.shouldNotGroupWhenFull"),editableElements:r?void 0:o,label:this.config.get("label")},l=new a(this.locale,this.editing.view,s,d);this.ui=new n(this,l),this.model.document.on("change:data",()=>{const t=this.model.document.differ.getChangedRoots();for(const e of t){const t=this.model.document.getRoot(e.name);"detached"==e.state&&this.fire("detachRoot",t)}for(const e of t){const t=this.model.document.getRoot(e.name);"attached"==e.state&&this.fire("addRoot",t)}}),this.listenTo(this.model,"canEditAt",(t,[e])=>{if(!e)return;let o=!1;for(const t of e.getRanges()){const e=t.root;if(this._readOnlyRootLocks.has(e.rootName)){o=!0;break}}o&&(t.return=!1,t.stop())},{priority:"high"}),this.decorate("loadRoot"),this.on("loadRoot",(t,[o])=>{const i=this.model.document.getRoot(o);if(!i)throw new e.CKEditorError("multi-root-editor-load-root-no-root",this,{rootName:o});i._isLoaded&&((0,e.logWarning)("multi-root-editor-load-root-already-loaded"),t.stop())},{priority:"highest"}),function(t){const o=t.config.get("licenseKey"),i=(0,e.decodeLicenseKey)(o);if(!i)return;(0,e.isFeatureBlockedByLicenseKey)(i,"MRE")&&(t.enableReadOnlyMode(Symbol("invalidLicense")),t._showLicenseError("featureNotAllowed","Multi-root editor"))}(this)}destroy(){const t=this.config.get("updateSourceElementOnDestroy"),o={};for(const e of Object.keys(this.sourceElements))o[e]=t?this.getData({rootName:e}):"";return this.ui.destroy(),super.destroy().then(()=>{for(const t of Object.keys(this.sourceElements))(0,e.setDataInElement)(this.sourceElements[t],o[t])})}addRoot(t,{data:e="",attributes:o={},elementName:i="$root",isUndoable:s=!1}={}){const r=s=>{const r=s.addRoot(t,i);e&&s.insert(this.data.parse(e,r),r,0);for(const t of Object.keys(o))this.registerRootAttribute(t),s.setAttribute(t,o[t],r)};s?this.model.change(r):this.model.enqueueChange({isUndoable:!1},r)}detachRoot(t,e=!1){e?this.model.change(e=>e.detachRoot(t)):this.model.enqueueChange({isUndoable:!1},e=>e.detachRoot(t))}createEditable(t,e,o){const i=this.ui.view.createEditable(t.rootName,void 0,o);return this.ui.addEditable(i,e),this.editing.view.forceRender(),i.element}detachEditable(t){const e=t.rootName,o=this.ui.view.editables[e];return this.ui.removeEditable(o),this.ui.view.removeEditable(e),o.element}loadRoot(t,{data:e="",attributes:o={}}={}){const i=this.model.document.getRoot(t);this.model.enqueueChange({isUndoable:!1},t=>{e&&t.insert(this.data.parse(e,i),i,0);for(const e of Object.keys(o))this.registerRootAttribute(e),t.setAttribute(e,o[e],i);i._isLoaded=!0,this.model.document.differ._bufferRootLoad(i)})}getFullData(t){const e={};for(const o of this.model.document.getRootNames())e[o]=this.data.get({...t,rootName:o});return e}getRootsAttributes(){const t={};for(const e of this.model.document.getRootNames())t[e]=this.getRootAttributes(e);return t}getRootAttributes(t){const e={},o=this.model.document.getRoot(t);for(const t of this._registeredRootsAttributesKeys)e[t]=o.hasAttribute(t)?o.getAttribute(t):null;return e}registerRootAttribute(t){this._registeredRootsAttributesKeys.has(t)||(this._registeredRootsAttributesKeys.add(t),this.editing.model.schema.extend("$root",{allowAttributes:t}))}disableRoot(t,o){if("$graveyard"==t)throw new e.CKEditorError("multi-root-editor-cannot-disable-graveyard-root",this);const i=this._readOnlyRootLocks.get(t);if(i)i.add(o);else{this._readOnlyRootLocks.set(t,new Set([o]));this.editing.view.document.getRoot(t).isReadOnly=!0,Array.from(this.commands.commands()).forEach(t=>t.affectsData&&t.refresh())}}enableRoot(t,e){const o=this._readOnlyRootLocks.get(t);if(o&&o.has(e))if(1===o.size){this._readOnlyRootLocks.delete(t);this.editing.view.document.getRoot(t).isReadOnly=this.isReadOnly,Array.from(this.commands.commands()).forEach(t=>t.affectsData&&t.refresh())}else o.delete(e)}static create(t,o={}){return new Promise(i=>{for(const o of Object.values(t))if(h(o)&&"TEXTAREA"===o.tagName)throw new e.CKEditorError("editor-wrong-element",null);const s=new this(t,o);i(s.initPlugins().then(()=>s.ui.init()).then(()=>(s._verifyRootsWithInitialData(),s.data.init(s.config.get("initialData")))).then(()=>s.fire("ready")).then(()=>s))})}_verifyRootsWithInitialData(){const t=this.config.get("initialData");for(const o of this.model.document.getRootNames())if(!(o in t))throw new e.CKEditorError("multi-root-editor-root-initial-data-mismatch",null);for(const o of Object.keys(t)){const t=this.model.document.getRoot(o);if(!t||!t.isAttached())throw new e.CKEditorError("multi-root-editor-root-initial-data-mismatch",null)}}}function c(t){return h(t)?(0,e.getDataFromElement)(t):t}function h(t){return d(t)}})(),(window.CKEditor5=window.CKEditor5||{}).editorMultiRoot=i})();
package/src/index.js DELETED
@@ -1,11 +0,0 @@
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 editor-multi-root
7
- */
8
- export { MultiRootEditor } from './multirooteditor.js';
9
- export { MultiRootEditorUI } from './multirooteditorui.js';
10
- export { MultiRootEditorUIView } from './multirooteditoruiview.js';
11
- import './augmentation.js';