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