@ckeditor/ckeditor5-editor-balloon 48.2.0 → 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.
@@ -2,3 +2,4 @@
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
+
@@ -2,3 +2,4 @@
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
+
package/dist/index.css CHANGED
@@ -3,5 +3,3 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
 
6
-
7
- /*# sourceMappingURL=index.css.map */
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module editor-balloon
7
- */
8
- export { BalloonEditor } from './ballooneditor.js';
9
- export { BalloonEditorUI } from './ballooneditorui.js';
10
- export { BalloonEditorUIView } from './ballooneditoruiview.js';
6
+ * @module editor-balloon
7
+ */
8
+ export { BalloonEditor } from "./ballooneditor.js";
9
+ export { BalloonEditorUI } from "./ballooneditorui.js";
10
+ export { BalloonEditorUIView } from "./ballooneditoruiview.js";
package/dist/index.js CHANGED
@@ -2,212 +2,215 @@
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, EditorUIView, InlineEditableUIView, MenuBarView, BalloonToolbar } from '@ckeditor/ckeditor5-ui/dist/index.js';
7
- import { enableViewPlaceholder } from '@ckeditor/ckeditor5-engine/dist/index.js';
8
- 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 { BalloonToolbar, EditorUI, EditorUIView, InlineEditableUIView, MenuBarView } from "@ckeditor/ckeditor5-ui";
7
+ import { enableViewPlaceholder } from "@ckeditor/ckeditor5-engine";
8
+ import { isElement } from "es-toolkit/compat";
9
9
 
10
10
  /**
11
- * The balloon editor UI class.
12
- */ class BalloonEditorUI extends EditorUI {
13
- /**
14
- * The main (top–most) view of the editor UI.
15
- */ view;
16
- /**
17
- * Creates an instance of the balloon editor UI class.
18
- *
19
- * @param editor The editor instance.
20
- * @param view The view of the UI.
21
- */ constructor(editor, view){
22
- super(editor);
23
- this.view = view;
24
- }
25
- /**
26
- * @inheritDoc
27
- */ get element() {
28
- return this.view.editable.element;
29
- }
30
- /**
31
- * Initializes the UI.
32
- */ init() {
33
- const editor = this.editor;
34
- const view = this.view;
35
- const editingView = editor.editing.view;
36
- const editable = view.editable;
37
- const editingRoot = editingView.document.getRoot();
38
- // The editable UI and editing root should share the same name. Then name is used
39
- // to recognize the particular editable, for instance in ARIA attributes.
40
- editable.name = editingRoot.rootName;
41
- // Resolved during UI init rather than in the editor constructor: by this point the plugin
42
- // initialization phase has finished, so the schema is fully populated and the check below
43
- // reflects any plugin-registered root types or additional content rules.
44
- editable.isInlineRoot = !rootAcceptsBlocks(editor, editingRoot.rootName);
45
- view.render();
46
- // The editable UI element in DOM is available for sure only after the editor UI view has been rendered.
47
- // But it can be available earlier if a DOM element has been passed to BalloonEditor.create().
48
- const editableElement = editable.element;
49
- // Register the editable UI view in the editor. A single editor instance can aggregate multiple
50
- // editable areas (roots) but the balloon editor has only one.
51
- this.setEditableElement(editable.name, editableElement);
52
- // Let the editable UI element respond to the changes in the global editor focus
53
- // tracker. It has been added to the same tracker a few lines above but, in reality, there are
54
- // many focusable areas in the editor, like balloons, toolbars or dropdowns and as long
55
- // as they have focus, the editable should act like it is focused too (although technically
56
- // it isn't), e.g. by setting the proper CSS class, visually announcing focus to the user.
57
- // Doing otherwise will result in editable focus styles disappearing, once e.g. the
58
- // toolbar gets focused.
59
- editable.bind('isFocused').to(this.focusTracker);
60
- // Bind the editable UI element to the editing view, making it an end– and entry–point
61
- // of the editor's engine. This is where the engine meets the UI.
62
- editingView.attachDomRoot(editableElement);
63
- this._initPlaceholder();
64
- this.initMenuBar(this.view.menuBarView);
65
- this.fire('ready');
66
- }
67
- /**
68
- * @inheritDoc
69
- */ destroy() {
70
- super.destroy();
71
- const view = this.view;
72
- const editingView = this.editor.editing.view;
73
- if (editingView.getDomRoot(view.editable.name)) {
74
- editingView.detachDomRoot(view.editable.name);
75
- }
76
- view.destroy();
77
- }
78
- /**
79
- * Enable the placeholder text on the editing root.
80
- */ _initPlaceholder() {
81
- const editor = this.editor;
82
- const editingView = editor.editing.view;
83
- const editingRoot = editingView.document.getRoot();
84
- const placeholder = editor.config.get('roots')[editingRoot.rootName].placeholder;
85
- if (placeholder) {
86
- editingRoot.placeholder = placeholder;
87
- }
88
- enableViewPlaceholder({
89
- view: editingView,
90
- element: editingRoot,
91
- isDirectHost: this.view.editable.isInlineRoot,
92
- keepOnFocus: true
93
- });
94
- }
95
- }
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-balloon/ballooneditorui
16
+ */
17
+ /**
18
+ * The balloon editor UI class.
19
+ */
20
+ var BalloonEditorUI = class extends EditorUI {
21
+ /**
22
+ * The main (top–most) view of the editor UI.
23
+ */
24
+ view;
25
+ /**
26
+ * Creates an instance of the balloon 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
+ * @inheritDoc
37
+ */
38
+ get element() {
39
+ return this.view.editable.element;
40
+ }
41
+ /**
42
+ * Initializes the UI.
43
+ */
44
+ init() {
45
+ const editor = this.editor;
46
+ const view = this.view;
47
+ const editingView = editor.editing.view;
48
+ const editable = view.editable;
49
+ const editingRoot = editingView.document.getRoot();
50
+ editable.name = editingRoot.rootName;
51
+ editable.isInlineRoot = !rootAcceptsBlocks(editor, editingRoot.rootName);
52
+ view.render();
53
+ const editableElement = editable.element;
54
+ this.setEditableElement(editable.name, editableElement);
55
+ editable.bind("isFocused").to(this.focusTracker);
56
+ editingView.attachDomRoot(editableElement);
57
+ this._initPlaceholder();
58
+ this.initMenuBar(this.view.menuBarView);
59
+ this.fire("ready");
60
+ }
61
+ /**
62
+ * @inheritDoc
63
+ */
64
+ destroy() {
65
+ super.destroy();
66
+ const view = this.view;
67
+ const editingView = this.editor.editing.view;
68
+ if (editingView.getDomRoot(view.editable.name)) editingView.detachDomRoot(view.editable.name);
69
+ view.destroy();
70
+ }
71
+ /**
72
+ * Enable the placeholder text on the editing root.
73
+ */
74
+ _initPlaceholder() {
75
+ const editor = this.editor;
76
+ const editingView = editor.editing.view;
77
+ const editingRoot = editingView.document.getRoot();
78
+ const placeholder = editor.config.get("roots")[editingRoot.rootName].placeholder;
79
+ if (placeholder) editingRoot.placeholder = placeholder;
80
+ enableViewPlaceholder({
81
+ view: editingView,
82
+ element: editingRoot,
83
+ isDirectHost: this.view.editable.isInlineRoot,
84
+ keepOnFocus: true
85
+ });
86
+ }
87
+ };
96
88
 
97
89
  /**
98
- * Contextual editor UI view. Uses the {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView}.
99
- */ class BalloonEditorUIView extends EditorUIView {
100
- /**
101
- * Editable UI view.
102
- */ editable;
103
- /**
104
- * Menu bar view instance.
105
- */ menuBarView;
106
- /**
107
- * Creates an instance of the balloon editor UI view.
108
- *
109
- * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
110
- * @param editingView The editing view instance this view is related to.
111
- * @param editableElement The editable element. If not specified, it will be automatically created by
112
- * {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
113
- * @param label When set, this value will be used as an accessible `aria-label` of the
114
- * {@link module:ui/editableui/editableuiview~EditableUIView editable view}.
115
- */ constructor(locale, editingView, editableElement, label){
116
- super(locale);
117
- this.editable = new InlineEditableUIView(locale, editingView, editableElement, {
118
- label
119
- });
120
- this.menuBarView = new MenuBarView(locale);
121
- this.menuBarView.extendTemplate({
122
- attributes: {
123
- class: [
124
- 'ck-reset_all',
125
- 'ck-rounded-corners'
126
- ],
127
- dir: locale.uiLanguageDirection
128
- }
129
- });
130
- }
131
- /**
132
- * @inheritDoc
133
- */ render() {
134
- super.render();
135
- this.registerChild(this.editable);
136
- this.registerChild(this.menuBarView);
137
- }
138
- }
90
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
91
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
92
+ */
93
+ /**
94
+ * @module editor-balloon/ballooneditoruiview
95
+ */
96
+ /**
97
+ * Contextual editor UI view. Uses the {@link module:ui/editableui/inline/inlineeditableuiview~InlineEditableUIView}.
98
+ */
99
+ var BalloonEditorUIView = class extends EditorUIView {
100
+ /**
101
+ * Editable UI view.
102
+ */
103
+ editable;
104
+ /**
105
+ * Menu bar view instance.
106
+ */
107
+ menuBarView;
108
+ /**
109
+ * Creates an instance of the balloon editor UI view.
110
+ *
111
+ * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
112
+ * @param editingView The editing view instance this view is related to.
113
+ * @param editableElement The editable element. If not specified, it will be automatically created by
114
+ * {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
115
+ * @param label When set, this value will be used as an accessible `aria-label` of the
116
+ * {@link module:ui/editableui/editableuiview~EditableUIView editable view}.
117
+ */
118
+ constructor(locale, editingView, editableElement, label) {
119
+ super(locale);
120
+ this.editable = new InlineEditableUIView(locale, editingView, editableElement, { label });
121
+ this.menuBarView = new MenuBarView(locale);
122
+ this.menuBarView.extendTemplate({ attributes: {
123
+ class: ["ck-reset_all", "ck-rounded-corners"],
124
+ dir: locale.uiLanguageDirection
125
+ } });
126
+ }
127
+ /**
128
+ * @inheritDoc
129
+ */
130
+ render() {
131
+ super.render();
132
+ this.registerChild(this.editable);
133
+ this.registerChild(this.menuBarView);
134
+ }
135
+ };
139
136
 
140
137
  /**
141
- * The balloon editor implementation (Medium-like editor).
142
- * It uses an inline editable and a toolbar based on the {@link module:ui/toolbar/balloon/balloontoolbar~BalloonToolbar}.
143
- * See the {@glink examples/builds/balloon-editor demo}.
144
- *
145
- * In order to create a balloon editor instance, use the static
146
- * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`} method.
147
- */ class BalloonEditor extends /* #__PURE__ */ ElementApiMixin(Editor) {
148
- /**
149
- * @inheritDoc
150
- */ static get editorName() {
151
- return 'BalloonEditor';
152
- }
153
- /**
154
- * @inheritDoc
155
- */ ui;
156
- constructor(sourceElementOrDataOrConfig, config = {}){
157
- const { sourceElementOrData, editorConfig } = normalizeSingleRootEditorConstructorParams(sourceElementOrDataOrConfig, config);
158
- super(editorConfig);
159
- normalizeRootsConfig(sourceElementOrData, this.config);
160
- // `normalizeRootsConfig()` reshaped this into a canonical form (HTMLElement or ViewRootElementDefinition).
161
- const editableElement = this.config.get('roots').main.element;
162
- if (isElement(editableElement)) {
163
- this.sourceElement = editableElement;
164
- secureSourceElement(this, editableElement);
165
- }
166
- const plugins = this.config.get('plugins');
167
- plugins.push(BalloonToolbar);
168
- this.config.set('plugins', plugins);
169
- this.config.define('balloonToolbar', this.config.get('toolbar'));
170
- this.model.document.createRoot(this.config.get('roots').main.modelElement);
171
- registerAndInitializeRootConfigAttributes(this);
172
- const view = new BalloonEditorUIView(this.locale, this.editing.view, editableElement, this.config.get('roots').main.label);
173
- this.ui = new BalloonEditorUI(this, view);
174
- attachToForm(this);
175
- }
176
- /**
177
- * Destroys the editor instance, releasing all resources used by it.
178
- *
179
- * Updates the original editor element with the data if the
180
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
181
- * configuration option is set to `true`.
182
- */ async destroy() {
183
- // Cache the data, then destroy.
184
- // It's safe to assume that the model->view conversion will not work after super.destroy().
185
- const data = this.getData();
186
- this.ui.destroy();
187
- await super.destroy();
188
- if (this.sourceElement) {
189
- this.updateSourceElement(data);
190
- }
191
- // To satisfy the return type and to keep it backward compatible.
192
- // eslint-disable-next-line no-useless-return
193
- return;
194
- }
195
- static async create(sourceElementOrDataOrConfig, config = {}) {
196
- const editor = new this(sourceElementOrDataOrConfig, config);
197
- await editor.initPlugins();
198
- // Roots are created in the editor constructor (before plugins are loaded), but the schema is only fully
199
- // built after plugins register their items during init(). Custom root element names (e.g. registered by a
200
- // plugin) may not exist in the schema at construction time, so we defer this check until here.
201
- verifyRootElements(editor);
202
- await editor.ui.init();
203
- await editor.data.init(editor.config.get('roots').main.initialData);
204
- editor.fire('ready');
205
- return editor;
206
- }
207
- }
208
- function isElement(value) {
209
- return isElement$1(value);
138
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
139
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
140
+ */
141
+ /**
142
+ * @module editor-balloon/ballooneditor
143
+ */
144
+ const BalloonEditorBase = /* #__PURE__ */ ElementApiMixin(Editor);
145
+ /**
146
+ * The balloon editor implementation (Medium-like editor).
147
+ * It uses an inline editable and a toolbar based on the {@link module:ui/toolbar/balloon/balloontoolbar~BalloonToolbar}.
148
+ * See the {@glink examples/builds/balloon-editor demo}.
149
+ *
150
+ * In order to create a balloon editor instance, use the static
151
+ * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`} method.
152
+ */
153
+ var BalloonEditor = class extends BalloonEditorBase {
154
+ /**
155
+ * @inheritDoc
156
+ */
157
+ static get editorName() {
158
+ return "BalloonEditor";
159
+ }
160
+ /**
161
+ * @inheritDoc
162
+ */
163
+ ui;
164
+ constructor(sourceElementOrDataOrConfig, config = {}) {
165
+ const { sourceElementOrData, editorConfig } = normalizeSingleRootEditorConstructorParams(sourceElementOrDataOrConfig, config);
166
+ super(editorConfig);
167
+ normalizeRootsConfig(sourceElementOrData, this.config);
168
+ const editableElement = this.config.get("roots").main.element;
169
+ if (isElement$1(editableElement)) {
170
+ this.sourceElement = editableElement;
171
+ secureSourceElement(this, editableElement);
172
+ }
173
+ const plugins = this.config.get("plugins");
174
+ plugins.push(BalloonToolbar);
175
+ this.config.set("plugins", plugins);
176
+ this.config.define("balloonToolbar", this.config.get("toolbar"));
177
+ this.model.document.createRoot(this.config.get("roots").main.modelElement);
178
+ registerAndInitializeRootConfigAttributes(this);
179
+ const view = new BalloonEditorUIView(this.locale, this.editing.view, editableElement, this.config.get("roots").main.label);
180
+ this.ui = new BalloonEditorUI(this, view);
181
+ attachToForm(this);
182
+ }
183
+ /**
184
+ * Destroys the editor instance, releasing all resources used by it.
185
+ *
186
+ * Updates the original editor element with the data if the
187
+ * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
188
+ * configuration option is set to `true`.
189
+ */
190
+ async destroy() {
191
+ const data = this.getData();
192
+ this.ui.destroy();
193
+ await super.destroy();
194
+ if (this.sourceElement) this.updateSourceElement(data);
195
+ }
196
+ static async create(sourceElementOrDataOrConfig, config = {}) {
197
+ const editor = new this(sourceElementOrDataOrConfig, config);
198
+ await editor.initPlugins();
199
+ verifyRootElements(editor);
200
+ await editor.ui.init();
201
+ await editor.data.init(editor.config.get("roots").main.initialData);
202
+ editor.fire("ready");
203
+ return editor;
204
+ }
205
+ };
206
+ function isElement$1(value) {
207
+ return isElement(value);
210
208
  }
211
209
 
210
+ /**
211
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
212
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
213
+ */
214
+
212
215
  export { BalloonEditor, BalloonEditorUI, BalloonEditorUIView };
213
- //# sourceMappingURL=index.js.map
216
+ //# sourceMappingURL=index.js.map