@ckeditor/ckeditor5-editor-decoupled 48.2.0-alpha.7 → 48.3.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/decouplededitor.d.ts +280 -280
- package/dist/decouplededitorui.d.ts +37 -37
- package/dist/decouplededitoruiview.d.ts +53 -53
- package/dist/index-content.css +1 -0
- package/dist/index-editor.css +1 -0
- package/dist/index.css +0 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.js +254 -263
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/index.css.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,275 +2,266 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { EditorUI, EditorUIView,
|
|
7
|
-
import { enableViewPlaceholder } from
|
|
8
|
-
import { isElement
|
|
5
|
+
import { Editor, ElementApiMixin, normalizeRootsConfig, normalizeSingleRootEditorConstructorParams, registerAndInitializeRootConfigAttributes, rootAcceptsBlocks, secureSourceElement, verifyRootElements } from "@ckeditor/ckeditor5-core";
|
|
6
|
+
import { EditorUI, EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from "@ckeditor/ckeditor5-ui";
|
|
7
|
+
import { enableViewPlaceholder } from "@ckeditor/ckeditor5-engine";
|
|
8
|
+
import { isElement } from "es-toolkit/compat";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
editingRoot.placeholder = placeholder;
|
|
93
|
-
}
|
|
94
|
-
enableViewPlaceholder({
|
|
95
|
-
view: editingView,
|
|
96
|
-
element: editingRoot,
|
|
97
|
-
isDirectHost: this.view.editable.isInlineRoot,
|
|
98
|
-
keepOnFocus: true
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
11
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
12
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @module editor-decoupled/decouplededitorui
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The decoupled editor UI class.
|
|
19
|
+
*/
|
|
20
|
+
var DecoupledEditorUI = class extends EditorUI {
|
|
21
|
+
/**
|
|
22
|
+
* The main (top–most) view of the editor UI.
|
|
23
|
+
*/
|
|
24
|
+
view;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of the decoupled editor UI class.
|
|
27
|
+
*
|
|
28
|
+
* @param editor The editor instance.
|
|
29
|
+
* @param view The view of the UI.
|
|
30
|
+
*/
|
|
31
|
+
constructor(editor, view) {
|
|
32
|
+
super(editor);
|
|
33
|
+
this.view = view;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Initializes the UI.
|
|
37
|
+
*/
|
|
38
|
+
init() {
|
|
39
|
+
const editor = this.editor;
|
|
40
|
+
const view = this.view;
|
|
41
|
+
const editingView = editor.editing.view;
|
|
42
|
+
const editable = view.editable;
|
|
43
|
+
const editingRoot = editingView.document.getRoot();
|
|
44
|
+
editable.name = editingRoot.rootName;
|
|
45
|
+
editable.isInlineRoot = !rootAcceptsBlocks(editor, editingRoot.rootName);
|
|
46
|
+
view.render();
|
|
47
|
+
const editableElement = editable.element;
|
|
48
|
+
this.setEditableElement(editable.name, editableElement);
|
|
49
|
+
view.editable.bind("isFocused").to(this.focusTracker);
|
|
50
|
+
editingView.attachDomRoot(editableElement);
|
|
51
|
+
this._initPlaceholder();
|
|
52
|
+
this._initToolbar();
|
|
53
|
+
this.initMenuBar(this.view.menuBarView);
|
|
54
|
+
this.fire("ready");
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
destroy() {
|
|
60
|
+
super.destroy();
|
|
61
|
+
const view = this.view;
|
|
62
|
+
const editingView = this.editor.editing.view;
|
|
63
|
+
if (editingView.getDomRoot(view.editable.name)) editingView.detachDomRoot(view.editable.name);
|
|
64
|
+
view.destroy();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Initializes the inline editor toolbar and its panel.
|
|
68
|
+
*/
|
|
69
|
+
_initToolbar() {
|
|
70
|
+
const editor = this.editor;
|
|
71
|
+
const view = this.view;
|
|
72
|
+
view.toolbar.fillFromConfig(editor.config.get("toolbar"), this.componentFactory);
|
|
73
|
+
this.addToolbar(view.toolbar);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Enable the placeholder text on the editing root.
|
|
77
|
+
*/
|
|
78
|
+
_initPlaceholder() {
|
|
79
|
+
const editor = this.editor;
|
|
80
|
+
const editingView = editor.editing.view;
|
|
81
|
+
const editingRoot = editingView.document.getRoot();
|
|
82
|
+
const placeholder = editor.config.get("roots")[editingRoot.rootName].placeholder;
|
|
83
|
+
if (placeholder) editingRoot.placeholder = placeholder;
|
|
84
|
+
enableViewPlaceholder({
|
|
85
|
+
view: editingView,
|
|
86
|
+
element: editingRoot,
|
|
87
|
+
isDirectHost: this.view.editable.isInlineRoot,
|
|
88
|
+
keepOnFocus: true
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
102
92
|
|
|
103
93
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.toolbar,
|
|
174
|
-
this.editable
|
|
175
|
-
]);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
94
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
95
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* @module editor-decoupled/decouplededitoruiview
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* The decoupled editor UI view. It is a virtual view providing an inline
|
|
102
|
+
* {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#editable},
|
|
103
|
+
* {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar}, and a
|
|
104
|
+
* {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#menuBarView} but without any
|
|
105
|
+
* specific arrangement of the components in the DOM.
|
|
106
|
+
*
|
|
107
|
+
* See {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
|
|
108
|
+
* to learn more about this view.
|
|
109
|
+
*/
|
|
110
|
+
var DecoupledEditorUIView = class extends EditorUIView {
|
|
111
|
+
/**
|
|
112
|
+
* The main toolbar of the decoupled editor UI.
|
|
113
|
+
*/
|
|
114
|
+
toolbar;
|
|
115
|
+
/**
|
|
116
|
+
* The editable of the decoupled editor UI.
|
|
117
|
+
*/
|
|
118
|
+
editable;
|
|
119
|
+
/**
|
|
120
|
+
* Menu bar view instance.
|
|
121
|
+
*/
|
|
122
|
+
menuBarView;
|
|
123
|
+
/**
|
|
124
|
+
* Creates an instance of the decoupled editor UI view.
|
|
125
|
+
*
|
|
126
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
127
|
+
* @param editingView The editing view instance this view is related to.
|
|
128
|
+
* @param options Configuration options for the view instance.
|
|
129
|
+
* @param options.editableElement The editable element. If not specified, it will be automatically created by
|
|
130
|
+
* {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
|
|
131
|
+
* @param options.shouldToolbarGroupWhenFull When set `true` enables automatic items grouping
|
|
132
|
+
* in the main {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar toolbar}.
|
|
133
|
+
* See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
|
|
134
|
+
* @param options.label When set, this value will be used as an accessible `aria-label` of the
|
|
135
|
+
* {@link module:ui/editableui/editableuiview~EditableUIView editable view}.
|
|
136
|
+
*/
|
|
137
|
+
constructor(locale, editingView, options = {}) {
|
|
138
|
+
super(locale);
|
|
139
|
+
this.toolbar = new ToolbarView(locale, { shouldGroupWhenFull: options.shouldToolbarGroupWhenFull });
|
|
140
|
+
this.menuBarView = new MenuBarView(locale);
|
|
141
|
+
this.editable = new InlineEditableUIView(locale, editingView, options.editableElement, { label: options.label });
|
|
142
|
+
this.toolbar.extendTemplate({ attributes: {
|
|
143
|
+
class: ["ck-reset_all", "ck-rounded-corners"],
|
|
144
|
+
dir: locale.uiLanguageDirection
|
|
145
|
+
} });
|
|
146
|
+
this.menuBarView.extendTemplate({ attributes: {
|
|
147
|
+
class: ["ck-reset_all", "ck-rounded-corners"],
|
|
148
|
+
dir: locale.uiLanguageDirection
|
|
149
|
+
} });
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @inheritDoc
|
|
153
|
+
*/
|
|
154
|
+
render() {
|
|
155
|
+
super.render();
|
|
156
|
+
this.registerChild([
|
|
157
|
+
this.menuBarView,
|
|
158
|
+
this.toolbar,
|
|
159
|
+
this.editable
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
178
163
|
|
|
179
164
|
/**
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
165
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
166
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* @module editor-decoupled/decouplededitor
|
|
170
|
+
*/
|
|
171
|
+
const DecoupledEditorBase = /* #__PURE__ */ ElementApiMixin(Editor);
|
|
172
|
+
/**
|
|
173
|
+
* The decoupled editor implementation. It provides an inline editable and a toolbar. However, unlike other editors,
|
|
174
|
+
* it does not render these components anywhere in the DOM unless configured.
|
|
175
|
+
*
|
|
176
|
+
* This type of an editor is dedicated to integrations which require a customized UI with an open
|
|
177
|
+
* structure, allowing developers to specify the exact location of the interface.
|
|
178
|
+
*
|
|
179
|
+
* See the document editor {@glink examples/builds/document-editor demo} to learn about possible use cases
|
|
180
|
+
* for the decoupled editor.
|
|
181
|
+
*
|
|
182
|
+
* In order to create a decoupled editor instance, use the static
|
|
183
|
+
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
|
|
184
|
+
*
|
|
185
|
+
* Note that you will need to attach the editor toolbar and menu bar to your web page manually, in a desired place,
|
|
186
|
+
* after the editor is initialized.
|
|
187
|
+
*/
|
|
188
|
+
var DecoupledEditor = class extends DecoupledEditorBase {
|
|
189
|
+
/**
|
|
190
|
+
* @inheritDoc
|
|
191
|
+
*/
|
|
192
|
+
static get editorName() {
|
|
193
|
+
return "DecoupledEditor";
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @inheritDoc
|
|
197
|
+
*/
|
|
198
|
+
ui;
|
|
199
|
+
constructor(sourceElementOrDataOrConfig, config = {}) {
|
|
200
|
+
const { sourceElementOrData, editorConfig } = normalizeSingleRootEditorConstructorParams(sourceElementOrDataOrConfig, config);
|
|
201
|
+
super(editorConfig);
|
|
202
|
+
normalizeRootsConfig(sourceElementOrData, this.config);
|
|
203
|
+
const editableElement = this.config.get("roots").main.element;
|
|
204
|
+
if (isElement$1(editableElement)) {
|
|
205
|
+
this.sourceElement = editableElement;
|
|
206
|
+
secureSourceElement(this, editableElement);
|
|
207
|
+
}
|
|
208
|
+
this.model.document.createRoot(this.config.get("roots").main.modelElement);
|
|
209
|
+
registerAndInitializeRootConfigAttributes(this);
|
|
210
|
+
const shouldToolbarGroupWhenFull = !this.config.get("toolbar.shouldNotGroupWhenFull");
|
|
211
|
+
const view = new DecoupledEditorUIView(this.locale, this.editing.view, {
|
|
212
|
+
editableElement,
|
|
213
|
+
shouldToolbarGroupWhenFull,
|
|
214
|
+
label: this.config.get("roots").main.label
|
|
215
|
+
});
|
|
216
|
+
this.ui = new DecoupledEditorUI(this, view);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Destroys the editor instance, releasing all resources used by it.
|
|
220
|
+
*
|
|
221
|
+
* Updates the original editor element with the data if the
|
|
222
|
+
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
|
|
223
|
+
* configuration option is set to `true`.
|
|
224
|
+
*
|
|
225
|
+
* **Note**: The decoupled editor does not remove the toolbar and editable when destroyed. You can
|
|
226
|
+
* do that yourself in the destruction chain:
|
|
227
|
+
*
|
|
228
|
+
* ```ts
|
|
229
|
+
* editor.destroy()
|
|
230
|
+
* .then( () => {
|
|
231
|
+
* // Remove the toolbar from DOM.
|
|
232
|
+
* editor.ui.view.toolbar.element.remove();
|
|
233
|
+
*
|
|
234
|
+
* // Remove the editable from DOM.
|
|
235
|
+
* editor.ui.view.editable.element.remove();
|
|
236
|
+
*
|
|
237
|
+
* console.log( 'Editor was destroyed' );
|
|
238
|
+
* } );
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
async destroy() {
|
|
242
|
+
const data = this.getData();
|
|
243
|
+
this.ui.destroy();
|
|
244
|
+
await super.destroy();
|
|
245
|
+
if (this.sourceElement) this.updateSourceElement(data);
|
|
246
|
+
}
|
|
247
|
+
static async create(sourceElementOrDataOrConfig, config = {}) {
|
|
248
|
+
const editor = new this(sourceElementOrDataOrConfig, config);
|
|
249
|
+
await editor.initPlugins();
|
|
250
|
+
verifyRootElements(editor);
|
|
251
|
+
await editor.ui.init();
|
|
252
|
+
await editor.data.init(editor.config.get("roots").main.initialData);
|
|
253
|
+
editor.fire("ready");
|
|
254
|
+
return editor;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
function isElement$1(value) {
|
|
258
|
+
return isElement(value);
|
|
273
259
|
}
|
|
274
260
|
|
|
261
|
+
/**
|
|
262
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
263
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
264
|
+
*/
|
|
265
|
+
|
|
275
266
|
export { DecoupledEditor, DecoupledEditorUI, DecoupledEditorUIView };
|
|
276
|
-
//# sourceMappingURL=index.js.map
|
|
267
|
+
//# sourceMappingURL=index.js.map
|