@ckeditor/ckeditor5-editor-multi-root 38.1.0 → 38.1.1
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/package.json +2 -2
- package/src/augmentation.d.ts +80 -80
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +10 -10
- package/src/index.js +9 -9
- package/src/multirooteditor.d.ts +522 -522
- package/src/multirooteditor.js +747 -747
- package/src/multirooteditorui.d.ts +74 -74
- package/src/multirooteditorui.js +169 -169
- package/src/multirooteditoruiview.d.ts +74 -74
- package/src/multirooteditoruiview.js +106 -106
@@ -1,106 +1,106 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, 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/multirooteditoruiview
|
7
|
-
*/
|
8
|
-
import { EditorUIView, InlineEditableUIView, ToolbarView } from 'ckeditor5/src/ui';
|
9
|
-
/**
|
10
|
-
* The multi-root editor UI view. It is a virtual view providing an inline
|
11
|
-
* {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#editable} and a
|
12
|
-
* {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar}, but without any
|
13
|
-
* specific arrangement of the components in the DOM.
|
14
|
-
*
|
15
|
-
* See {@link module:editor-multi-root/multirooteditor~MultiRootEditor.create `MultiRootEditor.create()`}
|
16
|
-
* to learn more about this view.
|
17
|
-
*/
|
18
|
-
export default class MultiRootEditorUIView extends EditorUIView {
|
19
|
-
/**
|
20
|
-
* Creates an instance of the multi-root editor UI view.
|
21
|
-
*
|
22
|
-
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
23
|
-
* @param editingView The editing view instance this view is related to.
|
24
|
-
* @param editableNames Names for all editable views. For each name, one
|
25
|
-
* {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView `InlineEditableUIView`} instance will be initialized.
|
26
|
-
* @param options Configuration options for the view instance.
|
27
|
-
* @param options.editableElements The editable elements to be used, assigned to their names. If not specified, they will be
|
28
|
-
* automatically created by {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView `InlineEditableUIView`}
|
29
|
-
* instances.
|
30
|
-
* @param options.shouldToolbarGroupWhenFull When set to `true` enables automatic items grouping
|
31
|
-
* in the main {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar toolbar}.
|
32
|
-
* See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
|
33
|
-
*/
|
34
|
-
constructor(locale, editingView, editableNames, options = {}) {
|
35
|
-
super(locale);
|
36
|
-
this._editingView = editingView;
|
37
|
-
this.toolbar = new ToolbarView(locale, {
|
38
|
-
shouldGroupWhenFull: options.shouldToolbarGroupWhenFull
|
39
|
-
});
|
40
|
-
this.editables = {};
|
41
|
-
// Create `InlineEditableUIView` instance for each editable.
|
42
|
-
for (const editableName of editableNames) {
|
43
|
-
const editableElement = options.editableElements ? options.editableElements[editableName] : undefined;
|
44
|
-
this.createEditable(editableName, editableElement);
|
45
|
-
}
|
46
|
-
this.editable = Object.values(this.editables)[0];
|
47
|
-
// This toolbar may be placed anywhere in the page so things like font size need to be reset in it.
|
48
|
-
// Because of the above, make sure the toolbar supports rounded corners.
|
49
|
-
// Also, make sure the toolbar has the proper dir attribute because its ancestor may not have one
|
50
|
-
// and some toolbar item styles depend on this attribute.
|
51
|
-
this.toolbar.extendTemplate({
|
52
|
-
attributes: {
|
53
|
-
class: [
|
54
|
-
'ck-reset_all',
|
55
|
-
'ck-rounded-corners'
|
56
|
-
],
|
57
|
-
dir: locale.uiLanguageDirection
|
58
|
-
}
|
59
|
-
});
|
60
|
-
}
|
61
|
-
/**
|
62
|
-
* Creates an editable instance with given name and registers it in the editor UI view.
|
63
|
-
*
|
64
|
-
* If `editableElement` is provided, the editable instance will be created on top of it. Otherwise, the editor will create a new
|
65
|
-
* DOM element and use it instead.
|
66
|
-
*
|
67
|
-
* @param editableName The name for the editable.
|
68
|
-
* @param editableElement DOM element for which the editable should be created.
|
69
|
-
* @returns The created editable instance.
|
70
|
-
*/
|
71
|
-
createEditable(editableName, editableElement) {
|
72
|
-
const t = this.locale.t;
|
73
|
-
const editable = new InlineEditableUIView(this.locale, this._editingView, editableElement, {
|
74
|
-
label: editable => {
|
75
|
-
return t('Rich Text Editor. Editing area: %0', editable.name);
|
76
|
-
}
|
77
|
-
});
|
78
|
-
this.editables[editableName] = editable;
|
79
|
-
editable.name = editableName;
|
80
|
-
if (this.isRendered) {
|
81
|
-
this.registerChild(editable);
|
82
|
-
}
|
83
|
-
return editable;
|
84
|
-
}
|
85
|
-
/**
|
86
|
-
* Destroys and removes the editable from the editor UI view.
|
87
|
-
*
|
88
|
-
* @param editableName The name of the editable that should be removed.
|
89
|
-
*/
|
90
|
-
removeEditable(editableName) {
|
91
|
-
const editable = this.editables[editableName];
|
92
|
-
if (this.isRendered) {
|
93
|
-
this.deregisterChild(editable);
|
94
|
-
}
|
95
|
-
delete this.editables[editableName];
|
96
|
-
editable.destroy();
|
97
|
-
}
|
98
|
-
/**
|
99
|
-
* @inheritDoc
|
100
|
-
*/
|
101
|
-
render() {
|
102
|
-
super.render();
|
103
|
-
this.registerChild(Object.values(this.editables));
|
104
|
-
this.registerChild(this.toolbar);
|
105
|
-
}
|
106
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, 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/multirooteditoruiview
|
7
|
+
*/
|
8
|
+
import { EditorUIView, InlineEditableUIView, ToolbarView } from 'ckeditor5/src/ui';
|
9
|
+
/**
|
10
|
+
* The multi-root editor UI view. It is a virtual view providing an inline
|
11
|
+
* {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#editable} and a
|
12
|
+
* {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar}, but without any
|
13
|
+
* specific arrangement of the components in the DOM.
|
14
|
+
*
|
15
|
+
* See {@link module:editor-multi-root/multirooteditor~MultiRootEditor.create `MultiRootEditor.create()`}
|
16
|
+
* to learn more about this view.
|
17
|
+
*/
|
18
|
+
export default class MultiRootEditorUIView extends EditorUIView {
|
19
|
+
/**
|
20
|
+
* Creates an instance of the multi-root editor UI view.
|
21
|
+
*
|
22
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
23
|
+
* @param editingView The editing view instance this view is related to.
|
24
|
+
* @param editableNames Names for all editable views. For each name, one
|
25
|
+
* {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView `InlineEditableUIView`} instance will be initialized.
|
26
|
+
* @param options Configuration options for the view instance.
|
27
|
+
* @param options.editableElements The editable elements to be used, assigned to their names. If not specified, they will be
|
28
|
+
* automatically created by {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView `InlineEditableUIView`}
|
29
|
+
* instances.
|
30
|
+
* @param options.shouldToolbarGroupWhenFull When set to `true` enables automatic items grouping
|
31
|
+
* in the main {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar toolbar}.
|
32
|
+
* See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
|
33
|
+
*/
|
34
|
+
constructor(locale, editingView, editableNames, options = {}) {
|
35
|
+
super(locale);
|
36
|
+
this._editingView = editingView;
|
37
|
+
this.toolbar = new ToolbarView(locale, {
|
38
|
+
shouldGroupWhenFull: options.shouldToolbarGroupWhenFull
|
39
|
+
});
|
40
|
+
this.editables = {};
|
41
|
+
// Create `InlineEditableUIView` instance for each editable.
|
42
|
+
for (const editableName of editableNames) {
|
43
|
+
const editableElement = options.editableElements ? options.editableElements[editableName] : undefined;
|
44
|
+
this.createEditable(editableName, editableElement);
|
45
|
+
}
|
46
|
+
this.editable = Object.values(this.editables)[0];
|
47
|
+
// This toolbar may be placed anywhere in the page so things like font size need to be reset in it.
|
48
|
+
// Because of the above, make sure the toolbar supports rounded corners.
|
49
|
+
// Also, make sure the toolbar has the proper dir attribute because its ancestor may not have one
|
50
|
+
// and some toolbar item styles depend on this attribute.
|
51
|
+
this.toolbar.extendTemplate({
|
52
|
+
attributes: {
|
53
|
+
class: [
|
54
|
+
'ck-reset_all',
|
55
|
+
'ck-rounded-corners'
|
56
|
+
],
|
57
|
+
dir: locale.uiLanguageDirection
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Creates an editable instance with given name and registers it in the editor UI view.
|
63
|
+
*
|
64
|
+
* If `editableElement` is provided, the editable instance will be created on top of it. Otherwise, the editor will create a new
|
65
|
+
* DOM element and use it instead.
|
66
|
+
*
|
67
|
+
* @param editableName The name for the editable.
|
68
|
+
* @param editableElement DOM element for which the editable should be created.
|
69
|
+
* @returns The created editable instance.
|
70
|
+
*/
|
71
|
+
createEditable(editableName, editableElement) {
|
72
|
+
const t = this.locale.t;
|
73
|
+
const editable = new InlineEditableUIView(this.locale, this._editingView, editableElement, {
|
74
|
+
label: editable => {
|
75
|
+
return t('Rich Text Editor. Editing area: %0', editable.name);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
this.editables[editableName] = editable;
|
79
|
+
editable.name = editableName;
|
80
|
+
if (this.isRendered) {
|
81
|
+
this.registerChild(editable);
|
82
|
+
}
|
83
|
+
return editable;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Destroys and removes the editable from the editor UI view.
|
87
|
+
*
|
88
|
+
* @param editableName The name of the editable that should be removed.
|
89
|
+
*/
|
90
|
+
removeEditable(editableName) {
|
91
|
+
const editable = this.editables[editableName];
|
92
|
+
if (this.isRendered) {
|
93
|
+
this.deregisterChild(editable);
|
94
|
+
}
|
95
|
+
delete this.editables[editableName];
|
96
|
+
editable.destroy();
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* @inheritDoc
|
100
|
+
*/
|
101
|
+
render() {
|
102
|
+
super.render();
|
103
|
+
this.registerChild(Object.values(this.editables));
|
104
|
+
this.registerChild(this.toolbar);
|
105
|
+
}
|
106
|
+
}
|