@ckeditor/ckeditor5-editor-multi-root 0.0.0-internal-20241017.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/CHANGELOG.md +4 -0
- package/LICENSE.md +21 -0
- package/README.md +26 -0
- package/build/editor-multi-root.js +4 -0
- package/dist/augmentation.d.ts +94 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +4 -0
- package/dist/index.css +4 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1079 -0
- package/dist/index.js.map +1 -0
- package/dist/multirooteditor.d.ts +548 -0
- package/dist/multirooteditorui.d.ts +78 -0
- package/dist/multirooteditoruiview.d.ts +86 -0
- package/package.json +42 -0
- package/src/augmentation.d.ts +90 -0
- package/src/augmentation.js +5 -0
- package/src/index.d.ts +10 -0
- package/src/index.js +9 -0
- package/src/multirooteditor.d.ts +544 -0
- package/src/multirooteditor.js +806 -0
- package/src/multirooteditorui.d.ts +74 -0
- package/src/multirooteditorui.js +169 -0
- package/src/multirooteditoruiview.d.ts +82 -0
- package/src/multirooteditoruiview.js +121 -0
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module editor-multi-root/multirooteditoruiview
|
|
11
|
+
*/
|
|
12
|
+
import { EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from 'ckeditor5/src/ui.js';
|
|
13
|
+
import type { Locale } from 'ckeditor5/src/utils.js';
|
|
14
|
+
import type { EditingView } from 'ckeditor5/src/engine.js';
|
|
15
|
+
/**
|
|
16
|
+
* The multi-root editor UI view. It is a virtual view providing an inline
|
|
17
|
+
* {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#editable} and a
|
|
18
|
+
* {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar}, but without any
|
|
19
|
+
* specific arrangement of the components in the DOM.
|
|
20
|
+
*
|
|
21
|
+
* See {@link module:editor-multi-root/multirooteditor~MultiRootEditor.create `MultiRootEditor.create()`}
|
|
22
|
+
* to learn more about this view.
|
|
23
|
+
*/
|
|
24
|
+
export default class MultiRootEditorUIView extends EditorUIView {
|
|
25
|
+
/**
|
|
26
|
+
* The main toolbar of the multi-root editor UI.
|
|
27
|
+
*/
|
|
28
|
+
readonly toolbar: ToolbarView;
|
|
29
|
+
/**
|
|
30
|
+
* Editable elements used by the multi-root editor UI.
|
|
31
|
+
*/
|
|
32
|
+
readonly editables: Record<string, InlineEditableUIView>;
|
|
33
|
+
readonly editable: InlineEditableUIView;
|
|
34
|
+
/**
|
|
35
|
+
* Menu bar view instance.
|
|
36
|
+
*/
|
|
37
|
+
menuBarView: MenuBarView;
|
|
38
|
+
/**
|
|
39
|
+
* The editing view instance this view is related to.
|
|
40
|
+
*/
|
|
41
|
+
private readonly _editingView;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an instance of the multi-root editor UI view.
|
|
44
|
+
*
|
|
45
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
46
|
+
* @param editingView The editing view instance this view is related to.
|
|
47
|
+
* @param editableNames Names for all editable views. For each name, one
|
|
48
|
+
* {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView `InlineEditableUIView`} instance will be initialized.
|
|
49
|
+
* @param options Configuration options for the view instance.
|
|
50
|
+
* @param options.editableElements The editable elements to be used, assigned to their names. If not specified, they will be
|
|
51
|
+
* automatically created by {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView `InlineEditableUIView`}
|
|
52
|
+
* instances.
|
|
53
|
+
* @param options.shouldToolbarGroupWhenFull When set to `true` enables automatic items grouping
|
|
54
|
+
* in the main {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar toolbar}.
|
|
55
|
+
* See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
|
|
56
|
+
* @param options.label When set, this value will be used as an accessible `aria-label` of the
|
|
57
|
+
* {@link module:ui/editableui/editableuiview~EditableUIView editable view} elements.
|
|
58
|
+
*/
|
|
59
|
+
constructor(locale: Locale, editingView: EditingView, editableNames: Array<string>, options?: {
|
|
60
|
+
editableElements?: Record<string, HTMLElement>;
|
|
61
|
+
shouldToolbarGroupWhenFull?: boolean;
|
|
62
|
+
label?: string | Record<string, string>;
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Creates an editable instance with given name and registers it in the editor UI view.
|
|
66
|
+
*
|
|
67
|
+
* If `editableElement` is provided, the editable instance will be created on top of it. Otherwise, the editor will create a new
|
|
68
|
+
* DOM element and use it instead.
|
|
69
|
+
*
|
|
70
|
+
* @param editableName The name for the editable.
|
|
71
|
+
* @param editableElement DOM element for which the editable should be created.
|
|
72
|
+
* @param label The accessible editable label used by assistive technologies.
|
|
73
|
+
* @returns The created editable instance.
|
|
74
|
+
*/
|
|
75
|
+
createEditable(editableName: string, editableElement?: HTMLElement, label?: string): InlineEditableUIView;
|
|
76
|
+
/**
|
|
77
|
+
* Destroys and removes the editable from the editor UI view.
|
|
78
|
+
*
|
|
79
|
+
* @param editableName The name of the editable that should be removed.
|
|
80
|
+
*/
|
|
81
|
+
removeEditable(editableName: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* @inheritDoc
|
|
84
|
+
*/
|
|
85
|
+
render(): void;
|
|
86
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ckeditor/ckeditor5-editor-multi-root",
|
|
3
|
+
"version": "0.0.0-internal-20241017.0",
|
|
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": "0.0.0-internal-20241017.0",
|
|
16
|
+
"@ckeditor/ckeditor5-engine": "0.0.0-internal-20241017.0",
|
|
17
|
+
"@ckeditor/ckeditor5-ui": "0.0.0-internal-20241017.0",
|
|
18
|
+
"@ckeditor/ckeditor5-utils": "0.0.0-internal-20241017.0",
|
|
19
|
+
"ckeditor5": "0.0.0-internal-20241017.0",
|
|
20
|
+
"lodash-es": "4.17.21"
|
|
21
|
+
},
|
|
22
|
+
"author": "CKSource (http://cksource.com/)",
|
|
23
|
+
"license": "GPL-2.0-or-later",
|
|
24
|
+
"homepage": "https://ckeditor.com/ckeditor-5",
|
|
25
|
+
"bugs": "https://github.com/ckeditor/ckeditor5/issues",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/ckeditor/ckeditor5.git",
|
|
29
|
+
"directory": "packages/ckeditor5-editor-multi-root"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"lang",
|
|
34
|
+
"src/**/*.js",
|
|
35
|
+
"src/**/*.d.ts",
|
|
36
|
+
"theme",
|
|
37
|
+
"build",
|
|
38
|
+
"ckeditor5-metadata.json",
|
|
39
|
+
"CHANGELOG.md"
|
|
40
|
+
],
|
|
41
|
+
"types": "src/index.d.ts"
|
|
42
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
import { type RootAttributes } from './multirooteditor.js';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface EditorConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Initial roots attributes for the document roots.
|
|
10
|
+
*
|
|
11
|
+
* **Note: This configuration option is supported only by the
|
|
12
|
+
* {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root} editor type.**
|
|
13
|
+
*
|
|
14
|
+
* **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`.
|
|
15
|
+
* Only provided attribute keys will be returned by
|
|
16
|
+
* {@link module:editor-multi-root/multirooteditor~MultiRootEditor#getRootsAttributes}.**
|
|
17
|
+
*
|
|
18
|
+
* Roots attributes hold additional data related to the document roots, in addition to the regular document data (which usually is
|
|
19
|
+
* HTML). In roots attributes, for each root, you can store arbitrary key-value pairs with attributes connected with that root.
|
|
20
|
+
* Use it to store any custom data that is specific to your integration or custom features.
|
|
21
|
+
*
|
|
22
|
+
* Currently, roots attributes are not used only by any official plugins. This is a mechanism that is prepared for custom features
|
|
23
|
+
* and non-standard integrations. If you do not provide any custom feature that would use root attributes, you do not need to
|
|
24
|
+
* handle (save and load) this property.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* MultiRootEditor.create(
|
|
28
|
+
* // Roots for the editor:
|
|
29
|
+
* {
|
|
30
|
+
* uid1: document.querySelector( '#uid1' ),
|
|
31
|
+
* uid2: document.querySelector( '#uid2' ),
|
|
32
|
+
* uid3: document.querySelector( '#uid3' ),
|
|
33
|
+
* uid4: document.querySelector( '#uid4' )
|
|
34
|
+
* },
|
|
35
|
+
* // Config:
|
|
36
|
+
* {
|
|
37
|
+
* rootsAttributes: {
|
|
38
|
+
* uid1: { order: 20, isLocked: false }, // Third, unlocked.
|
|
39
|
+
* uid2: { order: 10, isLocked: true }, // Second, locked.
|
|
40
|
+
* uid3: { order: 30, isLocked: true }, // Fourth, locked.
|
|
41
|
+
* uid4: { order: 0, isLocked: false } // First, unlocked.
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* )
|
|
45
|
+
* .then( ... )
|
|
46
|
+
* .catch( ... );
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* Note, that the above code snippet is only an example. You need to implement your own features that will use these attributes.
|
|
50
|
+
*
|
|
51
|
+
* Roots attributes can be changed the same way as attributes set on other model nodes:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* editor.model.change( writer => {
|
|
55
|
+
* const root = editor.model.getRoot( 'uid3' );
|
|
56
|
+
*
|
|
57
|
+
* writer.setAttribute( 'order', 40, root );
|
|
58
|
+
* } );
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* You can react to root attributes changes by listening to
|
|
62
|
+
* {@link module:engine/model/document~Document#event:change:data document `change:data` event}:
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* editor.model.document.on( 'change:data', () => {
|
|
66
|
+
* const changedRoots = editor.model.document.differ.getChangedRoots();
|
|
67
|
+
*
|
|
68
|
+
* for ( const change of changedRoots ) {
|
|
69
|
+
* if ( change.attributes ) {
|
|
70
|
+
* const root = editor.model.getRoot( change.name );
|
|
71
|
+
*
|
|
72
|
+
* // ...
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* } );
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
rootsAttributes?: Record<string, RootAttributes>;
|
|
79
|
+
/**
|
|
80
|
+
* A list of names of all the roots that exist in the document but are not initially loaded by the editor.
|
|
81
|
+
*
|
|
82
|
+
* These roots can be loaded at any time after the editor has been initialized, using
|
|
83
|
+
* {@link module:editor-multi-root/multirooteditor~MultiRootEditor#loadRoot `MultiRootEditor#lazyRoot()`}.
|
|
84
|
+
*
|
|
85
|
+
* This is useful for handling big documents that contain hundreds of roots, or contain very large roots, which may have
|
|
86
|
+
* impact editor performance if loaded all at once.
|
|
87
|
+
*/
|
|
88
|
+
lazyRoots?: Array<string>;
|
|
89
|
+
}
|
|
90
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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 editor-multi-root
|
|
7
|
+
*/
|
|
8
|
+
export { default as MultiRootEditor } from './multirooteditor.js';
|
|
9
|
+
export type { RootAttributes, AddRootEvent, DetachRootEvent } from './multirooteditor.js';
|
|
10
|
+
import './augmentation.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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 editor-multi-root
|
|
7
|
+
*/
|
|
8
|
+
export { default as MultiRootEditor } from './multirooteditor.js';
|
|
9
|
+
import './augmentation.js';
|