@ckeditor/ckeditor5-editor-inline 48.8.1-alpha.3 → 49.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.
package/dist/index.js CHANGED
@@ -2,393 +2,367 @@
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 { ElementApiMixin, Editor, normalizeSingleRootEditorConstructorParams, normalizeRootsConfig, secureSourceElement, registerAndInitializeRootConfigAttributes, attachToForm, verifyRootElements } from '@ckeditor/ckeditor5-core/dist/index.js';
6
- import { ResizeObserver, Rect, toUnit, CKEditorError } from '@ckeditor/ckeditor5-utils/dist/index.js';
7
- import { EditorUI, normalizeToolbarConfig, EditorUIView, ToolbarView, MenuBarView, BalloonPanelView, InlineEditableUIView } from '@ckeditor/ckeditor5-ui/dist/index.js';
8
- import { enableViewPlaceholder } from '@ckeditor/ckeditor5-engine/dist/index.js';
9
- import { isElement as isElement$1 } from 'es-toolkit/compat';
5
+ import { Editor, ElementApiMixin, attachToForm, normalizeRootsConfig, normalizeSingleRootEditorConstructorParams, registerAndInitializeRootConfigAttributes, rootAcceptsBlocks, secureSourceElement, verifyRootElements } from "@ckeditor/ckeditor5-core";
6
+ import { BalloonPanelView, EditorUI, EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView, normalizeToolbarConfig } from "@ckeditor/ckeditor5-ui";
7
+ import { enableViewPlaceholder } from "@ckeditor/ckeditor5-engine";
8
+ import { Rect, ResizeObserver, toUnit } from "@ckeditor/ckeditor5-utils";
9
+ import { isElement } from "es-toolkit/compat";
10
10
 
11
11
  /**
12
- * The inline editor UI class.
13
- *
14
- * @extends module:ui/editorui/editorui~EditorUI
15
- */ class InlineEditorUI extends EditorUI {
16
- /**
17
- * The main (top–most) view of the editor UI.
18
- */ view;
19
- /**
20
- * A normalized `config.toolbar` object.
21
- */ _toolbarConfig;
22
- /**
23
- * Creates an instance of the inline editor UI class.
24
- *
25
- * @param editor The editor instance.
26
- * @param view The view of the UI.
27
- */ constructor(editor, view){
28
- super(editor);
29
- this.view = view;
30
- this._toolbarConfig = normalizeToolbarConfig(editor.config.get('toolbar'));
31
- }
32
- /**
33
- * @inheritDoc
34
- */ get element() {
35
- return this.view.editable.element;
36
- }
37
- /**
38
- * Initializes the UI.
39
- */ init() {
40
- const editor = this.editor;
41
- const view = this.view;
42
- const editingView = editor.editing.view;
43
- const editable = view.editable;
44
- const editingRoot = editingView.document.getRoot();
45
- // The editable UI and editing root should share the same name. Then name is used
46
- // to recognize the particular editable, for instance in ARIA attributes.
47
- editable.name = editingRoot.rootName;
48
- view.render();
49
- // The editable UI element in DOM is available for sure only after the editor UI view has been rendered.
50
- // But it can be available earlier if a DOM element has been passed to InlineEditor.create().
51
- const editableElement = editable.element;
52
- // Register the editable UI view in the editor. A single editor instance can aggregate multiple
53
- // editable areas (roots) but the inline editor has only one.
54
- this.setEditableElement(editable.name, editableElement);
55
- // Let the editable UI element respond to the changes in the global editor focus
56
- // tracker. It has been added to the same tracker a few lines above but, in reality, there are
57
- // many focusable areas in the editor, like balloons, toolbars or dropdowns and as long
58
- // as they have focus, the editable should act like it is focused too (although technically
59
- // it isn't), e.g. by setting the proper CSS class, visually announcing focus to the user.
60
- // Doing otherwise will result in editable focus styles disappearing, once e.g. the
61
- // toolbar gets focused.
62
- editable.bind('isFocused').to(this.focusTracker);
63
- // Bind the editable UI element to the editing view, making it an end– and entry–point
64
- // of the editor's engine. This is where the engine meets the UI.
65
- editingView.attachDomRoot(editableElement);
66
- this._initPlaceholder();
67
- this._initToolbar();
68
- if (view.menuBarView) {
69
- this.initMenuBar(view.menuBarView);
70
- }
71
- this.fire('ready');
72
- }
73
- /**
74
- * @inheritDoc
75
- */ destroy() {
76
- super.destroy();
77
- const view = this.view;
78
- const editingView = this.editor.editing.view;
79
- if (editingView.getDomRoot(view.editable.name)) {
80
- editingView.detachDomRoot(view.editable.name);
81
- }
82
- view.destroy();
83
- }
84
- /**
85
- * Initializes the inline editor toolbar and its panel.
86
- */ _initToolbar() {
87
- const editor = this.editor;
88
- const view = this.view;
89
- const editableElement = view.editable.element;
90
- const toolbar = view.toolbar;
91
- // Set–up the view#panel.
92
- view.panel.bind('isVisible').to(this.focusTracker, 'isFocused');
93
- view.bind('viewportTopOffset').to(this, 'viewportOffset', ({ visualTop })=>visualTop || 0);
94
- // https://github.com/ckeditor/ckeditor5-editor-inline/issues/4
95
- view.listenTo(editor.ui, 'update', ()=>{
96
- // Don't pin if the panel is not already visible. It prevents the panel
97
- // showing up when there's no focus in the UI.
98
- if (view.panel.isVisible) {
99
- view.panel.pin({
100
- target: editableElement,
101
- positions: view.panelPositions
102
- });
103
- }
104
- });
105
- toolbar.fillFromConfig(this._toolbarConfig, this.componentFactory);
106
- // Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
107
- this.addToolbar(toolbar);
108
- }
109
- /**
110
- * Enable the placeholder text on the editing root.
111
- */ _initPlaceholder() {
112
- const editor = this.editor;
113
- const editingView = editor.editing.view;
114
- const editingRoot = editingView.document.getRoot();
115
- const placeholder = editor.config.get('roots')[editingRoot.rootName].placeholder;
116
- if (placeholder) {
117
- editingRoot.placeholder = placeholder;
118
- }
119
- enableViewPlaceholder({
120
- view: editingView,
121
- element: editingRoot,
122
- isDirectHost: false,
123
- keepOnFocus: true
124
- });
125
- }
126
- }
12
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
13
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
14
+ */
15
+ /**
16
+ * @module editor-inline/inlineeditorui
17
+ */
18
+ /**
19
+ * The inline editor UI class.
20
+ *
21
+ * @extends module:ui/editorui/editorui~EditorUI
22
+ */
23
+ var InlineEditorUI = class extends EditorUI {
24
+ /**
25
+ * The main (top–most) view of the editor UI.
26
+ */
27
+ view;
28
+ /**
29
+ * A normalized `config.toolbar` object.
30
+ */
31
+ _toolbarConfig;
32
+ /**
33
+ * Creates an instance of the inline editor UI class.
34
+ *
35
+ * @param editor The editor instance.
36
+ * @param view The view of the UI.
37
+ */
38
+ constructor(editor, view) {
39
+ super(editor);
40
+ this.view = view;
41
+ this._toolbarConfig = normalizeToolbarConfig(editor.config.get("toolbar"));
42
+ }
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ get element() {
47
+ return this.view.editable.element;
48
+ }
49
+ /**
50
+ * Initializes the UI.
51
+ */
52
+ init() {
53
+ const editor = this.editor;
54
+ const view = this.view;
55
+ const editingView = editor.editing.view;
56
+ const editable = view.editable;
57
+ const editingRoot = editingView.document.getRoot();
58
+ editable.name = editingRoot.rootName;
59
+ editable.isInlineRoot = !rootAcceptsBlocks(editor, editingRoot.rootName);
60
+ view.render();
61
+ const editableElement = editable.element;
62
+ this.setEditableElement(editable.name, editableElement);
63
+ editable.bind("isFocused").to(this.focusTracker);
64
+ editingView.attachDomRoot(editableElement);
65
+ this._initPlaceholder();
66
+ this._initToolbar();
67
+ if (view.menuBarView) this.initMenuBar(view.menuBarView);
68
+ this.fire("ready");
69
+ }
70
+ /**
71
+ * @inheritDoc
72
+ */
73
+ destroy() {
74
+ super.destroy();
75
+ const view = this.view;
76
+ const editingView = this.editor.editing.view;
77
+ if (editingView.getDomRoot(view.editable.name)) editingView.detachDomRoot(view.editable.name);
78
+ view.destroy();
79
+ }
80
+ /**
81
+ * Initializes the inline editor toolbar and its panel.
82
+ */
83
+ _initToolbar() {
84
+ const editor = this.editor;
85
+ const view = this.view;
86
+ const editableElement = view.editable.element;
87
+ const toolbar = view.toolbar;
88
+ view.panel.bind("isVisible").to(this.focusTracker, "isFocused");
89
+ view.bind("viewportTopOffset").to(this, "viewportOffset", ({ visualTop }) => visualTop || 0);
90
+ view.listenTo(editor.ui, "update", () => {
91
+ if (view.panel.isVisible) view.panel.pin({
92
+ target: editableElement,
93
+ positions: view.panelPositions
94
+ });
95
+ });
96
+ toolbar.fillFromConfig(this._toolbarConfig, this.componentFactory);
97
+ this.addToolbar(toolbar);
98
+ }
99
+ /**
100
+ * Enable the placeholder text on the editing root.
101
+ */
102
+ _initPlaceholder() {
103
+ const editor = this.editor;
104
+ const editingView = editor.editing.view;
105
+ const editingRoot = editingView.document.getRoot();
106
+ const placeholder = editor.config.get("roots")[editingRoot.rootName].placeholder;
107
+ if (placeholder) editingRoot.placeholder = placeholder;
108
+ enableViewPlaceholder({
109
+ view: editingView,
110
+ element: editingRoot,
111
+ isDirectHost: this.view.editable.isInlineRoot,
112
+ keepOnFocus: true
113
+ });
114
+ }
115
+ };
127
116
 
128
- const toPx = /* #__PURE__ */ toUnit('px');
129
117
  /**
130
- * Inline editor UI view. Uses an nline editable and a floating toolbar.
131
- */ class InlineEditorUIView extends EditorUIView {
132
- /**
133
- * A floating toolbar view instance.
134
- */ toolbar;
135
- /**
136
- * A balloon panel view instance.
137
- */ panel;
138
- /**
139
- * A set of positioning functions used by the {@link #panel} to float around
140
- * {@link #element editableElement}.
141
- *
142
- * The positioning functions are as follows:
143
- *
144
- * * West:
145
- *
146
- * ```
147
- * [ Panel ]
148
- * +------------------+
149
- * | #editableElement |
150
- * +------------------+
151
- *
152
- * +------------------+
153
- * | #editableElement |
154
- * |[ Panel ] |
155
- * | |
156
- * +------------------+
157
- *
158
- * +------------------+
159
- * | #editableElement |
160
- * +------------------+
161
- * [ Panel ]
162
- * ```
163
- *
164
- * * East:
165
- *
166
- * ```
167
- * [ Panel ]
168
- * +------------------+
169
- * | #editableElement |
170
- * +------------------+
171
- *
172
- * +------------------+
173
- * | #editableElement |
174
- * | [ Panel ]|
175
- * | |
176
- * +------------------+
177
- *
178
- * +------------------+
179
- * | #editableElement |
180
- * +------------------+
181
- * [ Panel ]
182
- * ```
183
- *
184
- * See: {@link module:utils/dom/position~DomOptimalPositionOptions#positions}.
185
- */ panelPositions;
186
- /**
187
- * Editable UI view.
188
- */ editable;
189
- /**
190
- * An instance of the resize observer that helps dynamically determine the geometry of the toolbar
191
- * and manage items that do not fit into a single row.
192
- *
193
- * **Note:** Created in {@link #render}.
194
- */ _resizeObserver;
195
- /**
196
- * Creates an instance of the inline editor UI view.
197
- *
198
- * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
199
- * @param editingView The editing view instance this view is related to.
200
- * @param editableElement The editable element. If not specified, it will be automatically created by
201
- * {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
202
- * @param options Configuration options for the view instance.
203
- * @param options.shouldToolbarGroupWhenFull When set `true` enables automatic items grouping
204
- * in the main {@link module:editor-inline/inlineeditoruiview~InlineEditorUIView#toolbar toolbar}.
205
- * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
206
- * @param options.label When set, this value will be used as an accessible `aria-label` of the
207
- * {@link module:ui/editableui/editableuiview~EditableUIView editable view}.
208
- */ constructor(locale, editingView, editableElement, options = {}){
209
- super(locale);
210
- this.toolbar = new ToolbarView(locale, {
211
- shouldGroupWhenFull: options.shouldToolbarGroupWhenFull,
212
- isFloating: true
213
- });
214
- if (options.useMenuBar) {
215
- this.menuBarView = new MenuBarView(locale);
216
- }
217
- this.set('viewportTopOffset', 0);
218
- this.panel = new BalloonPanelView(locale);
219
- this.panelPositions = this._getPanelPositions();
220
- this.panel.extendTemplate({
221
- attributes: {
222
- class: 'ck-toolbar-container'
223
- }
224
- });
225
- this.editable = new InlineEditableUIView(locale, editingView, editableElement, {
226
- label: options.label
227
- });
228
- this._resizeObserver = null;
229
- }
230
- /**
231
- * @inheritDoc
232
- */ render() {
233
- super.render();
234
- this.body.add(this.panel);
235
- this.registerChild(this.editable);
236
- if (this.menuBarView) {
237
- // Set toolbar as a child of a stickyPanel and makes toolbar sticky.
238
- this.panel.content.addMany([
239
- this.menuBarView,
240
- this.toolbar
241
- ]);
242
- } else {
243
- this.panel.content.add(this.toolbar);
244
- }
245
- const options = this.toolbar.options;
246
- // Set toolbar's max-width on the initialization and update it on the editable resize,
247
- // if 'shouldToolbarGroupWhenFull' in config is set to 'true'.
248
- if (options.shouldGroupWhenFull) {
249
- const editableElement = this.editable.element;
250
- this._resizeObserver = new ResizeObserver(editableElement, ()=>{
251
- this.toolbar.maxWidth = toPx(new Rect(editableElement).width);
252
- });
253
- }
254
- }
255
- /**
256
- * @inheritDoc
257
- */ destroy() {
258
- super.destroy();
259
- if (this._resizeObserver) {
260
- this._resizeObserver.destroy();
261
- }
262
- }
263
- /**
264
- * Determines the panel top position of the {@link #panel} in {@link #panelPositions}.
265
- *
266
- * @param editableRect Rect of the {@link #element}.
267
- * @param panelRect Rect of the {@link #panel}.
268
- */ _getPanelPositionTop(editableRect, panelRect) {
269
- let top;
270
- if (editableRect.top > panelRect.height + this.viewportTopOffset) {
271
- top = editableRect.top - panelRect.height;
272
- } else if (editableRect.bottom > panelRect.height + this.viewportTopOffset + 50) {
273
- top = this.viewportTopOffset;
274
- } else {
275
- top = editableRect.bottom;
276
- }
277
- return top;
278
- }
279
- /**
280
- * Returns the positions for {@link #panelPositions}.
281
- *
282
- * See: {@link module:utils/dom/position~DomOptimalPositionOptions#positions}.
283
- */ _getPanelPositions() {
284
- const positions = [
285
- (editableRect, panelRect)=>{
286
- return {
287
- top: this._getPanelPositionTop(editableRect, panelRect),
288
- left: editableRect.left,
289
- name: 'toolbar_west',
290
- config: {
291
- withArrow: false
292
- }
293
- };
294
- },
295
- (editableRect, panelRect)=>{
296
- return {
297
- top: this._getPanelPositionTop(editableRect, panelRect),
298
- left: editableRect.left + editableRect.width - panelRect.width,
299
- name: 'toolbar_east',
300
- config: {
301
- withArrow: false
302
- }
303
- };
304
- }
305
- ];
306
- if (this.locale.uiLanguageDirection === 'ltr') {
307
- return positions;
308
- } else {
309
- return positions.reverse();
310
- }
311
- }
312
- }
118
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
119
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
120
+ */
121
+ /**
122
+ * @module editor-inline/inlineeditoruiview
123
+ */
124
+ const toPx = /* #__PURE__ */ toUnit("px");
125
+ /**
126
+ * Inline editor UI view. Uses an nline editable and a floating toolbar.
127
+ */
128
+ var InlineEditorUIView = class extends EditorUIView {
129
+ /**
130
+ * A floating toolbar view instance.
131
+ */
132
+ toolbar;
133
+ /**
134
+ * A balloon panel view instance.
135
+ */
136
+ panel;
137
+ /**
138
+ * A set of positioning functions used by the {@link #panel} to float around
139
+ * {@link #element editableElement}.
140
+ *
141
+ * The positioning functions are as follows:
142
+ *
143
+ * * West:
144
+ *
145
+ * ```
146
+ * [ Panel ]
147
+ * +------------------+
148
+ * | #editableElement |
149
+ * +------------------+
150
+ *
151
+ * +------------------+
152
+ * | #editableElement |
153
+ * |[ Panel ] |
154
+ * | |
155
+ * +------------------+
156
+ *
157
+ * +------------------+
158
+ * | #editableElement |
159
+ * +------------------+
160
+ * [ Panel ]
161
+ * ```
162
+ *
163
+ * * East:
164
+ *
165
+ * ```
166
+ * [ Panel ]
167
+ * +------------------+
168
+ * | #editableElement |
169
+ * +------------------+
170
+ *
171
+ * +------------------+
172
+ * | #editableElement |
173
+ * | [ Panel ]|
174
+ * | |
175
+ * +------------------+
176
+ *
177
+ * +------------------+
178
+ * | #editableElement |
179
+ * +------------------+
180
+ * [ Panel ]
181
+ * ```
182
+ *
183
+ * See: {@link module:utils/dom/position~DomOptimalPositionOptions#positions}.
184
+ */
185
+ panelPositions;
186
+ /**
187
+ * Editable UI view.
188
+ */
189
+ editable;
190
+ /**
191
+ * An instance of the resize observer that helps dynamically determine the geometry of the toolbar
192
+ * and manage items that do not fit into a single row.
193
+ *
194
+ * **Note:** Created in {@link #render}.
195
+ */
196
+ _resizeObserver;
197
+ /**
198
+ * Creates an instance of the inline editor UI view.
199
+ *
200
+ * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
201
+ * @param editingView The editing view instance this view is related to.
202
+ * @param editableElement The editable element. If not specified, it will be automatically created by
203
+ * {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
204
+ * @param options Configuration options for the view instance.
205
+ * @param options.shouldToolbarGroupWhenFull When set `true` enables automatic items grouping
206
+ * in the main {@link module:editor-inline/inlineeditoruiview~InlineEditorUIView#toolbar toolbar}.
207
+ * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
208
+ * @param options.label When set, this value will be used as an accessible `aria-label` of the
209
+ * {@link module:ui/editableui/editableuiview~EditableUIView editable view}.
210
+ */
211
+ constructor(locale, editingView, editableElement, options = {}) {
212
+ super(locale);
213
+ this.toolbar = new ToolbarView(locale, {
214
+ shouldGroupWhenFull: options.shouldToolbarGroupWhenFull,
215
+ isFloating: true
216
+ });
217
+ if (options.useMenuBar) this.menuBarView = new MenuBarView(locale);
218
+ this.set("viewportTopOffset", 0);
219
+ this.panel = new BalloonPanelView(locale);
220
+ this.panelPositions = this._getPanelPositions();
221
+ this.panel.extendTemplate({ attributes: { class: "ck-toolbar-container" } });
222
+ this.editable = new InlineEditableUIView(locale, editingView, editableElement, { label: options.label });
223
+ this._resizeObserver = null;
224
+ }
225
+ /**
226
+ * @inheritDoc
227
+ */
228
+ render() {
229
+ super.render();
230
+ this.body.add(this.panel);
231
+ this.registerChild(this.editable);
232
+ if (this.menuBarView) this.panel.content.addMany([this.menuBarView, this.toolbar]);
233
+ else this.panel.content.add(this.toolbar);
234
+ if (this.toolbar.options.shouldGroupWhenFull) {
235
+ const editableElement = this.editable.element;
236
+ this._resizeObserver = new ResizeObserver(editableElement, () => {
237
+ this.toolbar.maxWidth = toPx(new Rect(editableElement).width);
238
+ });
239
+ }
240
+ }
241
+ /**
242
+ * @inheritDoc
243
+ */
244
+ destroy() {
245
+ super.destroy();
246
+ if (this._resizeObserver) this._resizeObserver.destroy();
247
+ }
248
+ /**
249
+ * Determines the panel top position of the {@link #panel} in {@link #panelPositions}.
250
+ *
251
+ * @param editableRect Rect of the {@link #element}.
252
+ * @param panelRect Rect of the {@link #panel}.
253
+ */
254
+ _getPanelPositionTop(editableRect, panelRect) {
255
+ let top;
256
+ if (editableRect.top > panelRect.height + this.viewportTopOffset) top = editableRect.top - panelRect.height;
257
+ else if (editableRect.bottom > panelRect.height + this.viewportTopOffset + 50) top = this.viewportTopOffset;
258
+ else top = editableRect.bottom;
259
+ return top;
260
+ }
261
+ /**
262
+ * Returns the positions for {@link #panelPositions}.
263
+ *
264
+ * See: {@link module:utils/dom/position~DomOptimalPositionOptions#positions}.
265
+ */
266
+ _getPanelPositions() {
267
+ const positions = [(editableRect, panelRect) => {
268
+ return {
269
+ top: this._getPanelPositionTop(editableRect, panelRect),
270
+ left: editableRect.left,
271
+ name: "toolbar_west",
272
+ config: { withArrow: false }
273
+ };
274
+ }, (editableRect, panelRect) => {
275
+ return {
276
+ top: this._getPanelPositionTop(editableRect, panelRect),
277
+ left: editableRect.left + editableRect.width - panelRect.width,
278
+ name: "toolbar_east",
279
+ config: { withArrow: false }
280
+ };
281
+ }];
282
+ if (this.locale.uiLanguageDirection === "ltr") return positions;
283
+ else return positions.reverse();
284
+ }
285
+ };
313
286
 
314
287
  /**
315
- * The inline editor implementation. It uses an inline editable and a floating toolbar.
316
- * See the {@glink examples/builds/inline-editor demo}.
317
- *
318
- * In order to create a inline editor instance, use the static
319
- * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`} method.
320
- */ class InlineEditor extends /* #__PURE__ */ ElementApiMixin(Editor) {
321
- /**
322
- * @inheritDoc
323
- */ static get editorName() {
324
- return 'InlineEditor';
325
- }
326
- /**
327
- * @inheritDoc
328
- */ ui;
329
- constructor(sourceElementOrDataOrConfig, config = {}){
330
- const { sourceElementOrData, editorConfig } = normalizeSingleRootEditorConstructorParams(sourceElementOrDataOrConfig, config);
331
- super(editorConfig);
332
- normalizeRootsConfig(sourceElementOrData, this.config);
333
- // From this point use only normalized `roots.main.element`.
334
- const sourceElement = this.config.get('roots').main.element;
335
- if (isElement(sourceElement)) {
336
- if (sourceElement.tagName === 'TEXTAREA') {
337
- // Documented in core/editor/editor.js
338
- // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
339
- throw new CKEditorError('editor-wrong-element', null);
340
- }
341
- this.sourceElement = sourceElement;
342
- secureSourceElement(this, sourceElement);
343
- }
344
- this.config.define('menuBar.isVisible', false);
345
- this.model.document.createRoot(this.config.get('roots').main.modelElement);
346
- registerAndInitializeRootConfigAttributes(this);
347
- const shouldToolbarGroupWhenFull = !this.config.get('toolbar.shouldNotGroupWhenFull');
348
- const menuBarConfig = this.config.get('menuBar');
349
- const view = new InlineEditorUIView(this.locale, this.editing.view, this.sourceElement, {
350
- shouldToolbarGroupWhenFull,
351
- useMenuBar: menuBarConfig.isVisible,
352
- label: this.config.get('roots').main.label
353
- });
354
- this.ui = new InlineEditorUI(this, view);
355
- attachToForm(this);
356
- }
357
- /**
358
- * Destroys the editor instance, releasing all resources used by it.
359
- *
360
- * Updates the original editor element with the data if the
361
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
362
- * configuration option is set to `true`.
363
- */ async destroy() {
364
- // Cache the data, then destroy.
365
- // It's safe to assume that the model->view conversion will not work after super.destroy().
366
- const data = this.getData();
367
- this.ui.destroy();
368
- await super.destroy();
369
- if (this.sourceElement) {
370
- this.updateSourceElement(data);
371
- }
372
- // To satisfy the return type and to keep it backward compatible.
373
- // eslint-disable-next-line no-useless-return
374
- return;
375
- }
376
- static async create(sourceElementOrDataOrConfig, config = {}) {
377
- const editor = new this(sourceElementOrDataOrConfig, config);
378
- await editor.initPlugins();
379
- // Roots are created in the editor constructor (before plugins are loaded), but the schema is only fully
380
- // built after plugins register their items during init(). Custom root element names (e.g. registered by a
381
- // plugin) may not exist in the schema at construction time, so we defer this check until here.
382
- verifyRootElements(editor);
383
- await editor.ui.init();
384
- await editor.data.init(editor.config.get('roots').main.initialData);
385
- editor.fire('ready');
386
- return editor;
387
- }
388
- }
389
- function isElement(value) {
390
- return isElement$1(value);
288
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
289
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
290
+ */
291
+ /**
292
+ * @module editor-inline/inlineeditor
293
+ */
294
+ const InlineEditorBase = /* #__PURE__ */ ElementApiMixin(Editor);
295
+ /**
296
+ * The inline editor implementation. It uses an inline editable and a floating toolbar.
297
+ * See the {@glink examples/builds/inline-editor demo}.
298
+ *
299
+ * In order to create a inline editor instance, use the static
300
+ * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`} method.
301
+ */
302
+ var InlineEditor = class extends InlineEditorBase {
303
+ /**
304
+ * @inheritDoc
305
+ */
306
+ static get editorName() {
307
+ return "InlineEditor";
308
+ }
309
+ /**
310
+ * @inheritDoc
311
+ */
312
+ ui;
313
+ constructor(sourceElementOrDataOrConfig, config = {}) {
314
+ const { sourceElementOrData, editorConfig } = normalizeSingleRootEditorConstructorParams(sourceElementOrDataOrConfig, config);
315
+ super(editorConfig);
316
+ normalizeRootsConfig(sourceElementOrData, this.config);
317
+ const editableElement = this.config.get("roots").main.element;
318
+ if (isElement$1(editableElement)) {
319
+ this.sourceElement = editableElement;
320
+ secureSourceElement(this, editableElement);
321
+ }
322
+ this.config.define("menuBar.isVisible", false);
323
+ this.model.document.createRoot(this.config.get("roots").main.modelElement);
324
+ registerAndInitializeRootConfigAttributes(this);
325
+ const shouldToolbarGroupWhenFull = !this.config.get("toolbar.shouldNotGroupWhenFull");
326
+ const menuBarConfig = this.config.get("menuBar");
327
+ const view = new InlineEditorUIView(this.locale, this.editing.view, editableElement, {
328
+ shouldToolbarGroupWhenFull,
329
+ useMenuBar: menuBarConfig.isVisible,
330
+ label: this.config.get("roots").main.label
331
+ });
332
+ this.ui = new InlineEditorUI(this, view);
333
+ attachToForm(this);
334
+ }
335
+ /**
336
+ * Destroys the editor instance, releasing all resources used by it.
337
+ *
338
+ * Updates the original editor element with the data if the
339
+ * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
340
+ * configuration option is set to `true`.
341
+ */
342
+ async destroy() {
343
+ const data = this.getData();
344
+ this.ui.destroy();
345
+ await super.destroy();
346
+ if (this.sourceElement) this.updateSourceElement(data);
347
+ }
348
+ static async create(sourceElementOrDataOrConfig, config = {}) {
349
+ const editor = new this(sourceElementOrDataOrConfig, config);
350
+ await editor.initPlugins();
351
+ verifyRootElements(editor);
352
+ await editor.ui.init();
353
+ await editor.data.init(editor.config.get("roots").main.initialData);
354
+ editor.fire("ready");
355
+ return editor;
356
+ }
357
+ };
358
+ function isElement$1(value) {
359
+ return isElement(value);
391
360
  }
392
361
 
362
+ /**
363
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
364
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
365
+ */
366
+
393
367
  export { InlineEditor, InlineEditorUI, InlineEditorUIView };
394
- //# sourceMappingURL=index.js.map
368
+ //# sourceMappingURL=index.js.map