@ckeditor/ckeditor5-editor-multi-root 48.1.1 → 48.2.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,7 +5,7 @@
5
5
  /**
6
6
  * @module editor-multi-root/multirooteditor
7
7
  */
8
- import { Editor, type EditorConfig, type RootConfig, type EditorRootAttributes } from '@ckeditor/ckeditor5-core';
8
+ import { Editor, type EditorConfig, type RootConfig, type EditorRootAttributes, type ViewRootElementDefinition } from '@ckeditor/ckeditor5-core';
9
9
  import { type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils';
10
10
  import { MultiRootEditorUI } from './multirooteditorui.js';
11
11
  import { type ModelRootElement } from '@ckeditor/ckeditor5-engine';
@@ -236,16 +236,23 @@ export declare class MultiRootEditor extends Editor {
236
236
  */
237
237
  detachRoot(rootName: string, isUndoable?: boolean): void;
238
238
  /**
239
- * Creates and returns a new DOM editable element for the given root element.
239
+ * Creates and returns a DOM editable element for the given root element.
240
240
  *
241
- * The new DOM editable is attached to the model root and can be used to modify the root content.
241
+ * The DOM editable is attached to the model root and can be used to modify the root content.
242
+ *
243
+ * When `options.element` is an existing `HTMLElement`, the method uses it as-is and returns
244
+ * the same element. Otherwise a fresh DOM element is created from `options.element`
245
+ * (descriptor or tag name) — or a default `<div>` when the option is omitted — and the caller
246
+ * is expected to append the returned element to the DOM.
242
247
  *
243
248
  * @label OPTIONS
244
249
  * @param root Root for which the editable element should be created.
245
250
  * @param options.placeholder Placeholder for the editable element. If not set, placeholder value from the
246
251
  * {@link module:core/editor/editorconfig~RootConfig#placeholder root configuration} will be used (if it was provided).
247
252
  * @param options.label The accessible label text describing the editable to the assistive technologies.
248
- * @returns The created DOM element. Append it in a desired place in your application.
253
+ * @param options.element Description of the editable element to create, or an existing `HTMLElement` to use as-is.
254
+ * See {@link ~RootEditableOptions#element} for accepted forms and the real-time collaboration caveat.
255
+ * @returns The DOM element for the editable.
249
256
  */
250
257
  createEditable(root: ModelRootElement, options?: RootEditableOptions): HTMLElement;
251
258
  /**
@@ -733,9 +740,13 @@ export type AddRootOptions = {
733
740
  */
734
741
  export interface AddRootRootConfig extends RootConfig {
735
742
  /**
736
- * Passing a DOM element to {@link ~MultiRootEditor#addRoot:ROOT_CONFIG `addRoot( rootName, options )`} is not supported.
743
+ * A description of the editable root element to create. May be a tag name string (e.g. `'h1'`) or a
744
+ * {@link module:core/editor/editorconfig~ViewRootElementDefinition} object.
745
+ *
746
+ * Passing an existing DOM element is not supported - `addRoot()` only registers the model root;
747
+ * the DOM editable is created later by {@link ~MultiRootEditor#createEditable `createEditable()`}.
737
748
  */
738
- element?: undefined;
749
+ element?: string | ViewRootElementDefinition;
739
750
  /**
740
751
  * Whether creating the root can be undone (using the undo feature) or not.
741
752
  */
@@ -758,4 +769,22 @@ export interface RootEditableOptions {
758
769
  * The accessible label text describing the editable to the assistive technologies.
759
770
  */
760
771
  label?: string;
772
+ /**
773
+ * A description of the editable root element to create, or an existing DOM element to use.
774
+ *
775
+ * Accepted forms:
776
+ *
777
+ * * A tag name string (e.g. `'h1'`).
778
+ * * A {@link module:core/editor/editorconfig~ViewRootElementDefinition} object.
779
+ * * An existing `HTMLElement`. The element is used as-is — `createEditable()` returns the same
780
+ * element instead of creating a new one, so callers do not need to append it to the DOM.
781
+ *
782
+ * When omitted, a default `<div>` is created.
783
+ *
784
+ * **Note**: an `HTMLElement` value is local to this client. It cannot be replicated through
785
+ * real-time collaboration, so it is not persisted with the root. Other clients calling
786
+ * `createEditable()` for the same root receive a fresh element built from the canonical
787
+ * descriptor (or the default `<div>`), unless they pass their own `HTMLElement` as well.
788
+ */
789
+ element?: string | ViewRootElementDefinition | HTMLElement;
761
790
  }
@@ -8,6 +8,7 @@
8
8
  import { EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from '@ckeditor/ckeditor5-ui';
9
9
  import type { Locale } from '@ckeditor/ckeditor5-utils';
10
10
  import type { EditingView } from '@ckeditor/ckeditor5-engine';
11
+ import type { ViewRootElementDefinition } from '@ckeditor/ckeditor5-core';
11
12
  /**
12
13
  * The multi-root editor UI view. It is a virtual view providing an inline
13
14
  * {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#editable} and a
@@ -53,7 +54,7 @@ export declare class MultiRootEditorUIView extends EditorUIView {
53
54
  * {@link module:ui/editableui/editableuiview~EditableUIView editable view} elements.
54
55
  */
55
56
  constructor(locale: Locale, editingView: EditingView, editableNames: Array<string>, options?: {
56
- editableElements?: Record<string, HTMLElement>;
57
+ editableElements?: Record<string, HTMLElement | ViewRootElementDefinition>;
57
58
  shouldToolbarGroupWhenFull?: boolean;
58
59
  label?: string | Record<string, string>;
59
60
  });
@@ -68,7 +69,7 @@ export declare class MultiRootEditorUIView extends EditorUIView {
68
69
  * @param label The accessible editable label used by assistive technologies.
69
70
  * @returns The created editable instance.
70
71
  */
71
- createEditable(editableName: string, editableElement?: HTMLElement, label?: string): InlineEditableUIView;
72
+ createEditable(editableName: string, editableElement?: HTMLElement | ViewRootElementDefinition, label?: string): InlineEditableUIView;
72
73
  /**
73
74
  * Destroys and removes the editable from the editor UI view.
74
75
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-editor-multi-root",
3
- "version": "48.1.1",
3
+ "version": "48.2.0-alpha.0",
4
4
  "description": "Multi-root editor implementation for CKEditor 5.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -25,10 +25,10 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@ckeditor/ckeditor5-core": "48.1.1",
29
- "@ckeditor/ckeditor5-engine": "48.1.1",
30
- "@ckeditor/ckeditor5-ui": "48.1.1",
31
- "@ckeditor/ckeditor5-utils": "48.1.1",
28
+ "@ckeditor/ckeditor5-core": "48.2.0-alpha.0",
29
+ "@ckeditor/ckeditor5-engine": "48.2.0-alpha.0",
30
+ "@ckeditor/ckeditor5-ui": "48.2.0-alpha.0",
31
+ "@ckeditor/ckeditor5-utils": "48.2.0-alpha.0",
32
32
  "es-toolkit": "1.45.1"
33
33
  },
34
34
  "files": [