@ckeditor/ckeditor5-widget 0.0.0-nightly-next-20250225.0 → 0.0.0-nightly-next-20250226.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.

Potentially problematic release.


This version of @ckeditor/ckeditor5-widget might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-widget",
3
- "version": "0.0.0-nightly-next-20250225.0",
3
+ "version": "0.0.0-nightly-next-20250226.0",
4
4
  "description": "Widget API for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,13 +12,13 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "0.0.0-nightly-next-20250225.0",
16
- "@ckeditor/ckeditor5-engine": "0.0.0-nightly-next-20250225.0",
17
- "@ckeditor/ckeditor5-enter": "0.0.0-nightly-next-20250225.0",
18
- "@ckeditor/ckeditor5-icons": "0.0.0-nightly-next-20250225.0",
19
- "@ckeditor/ckeditor5-ui": "0.0.0-nightly-next-20250225.0",
20
- "@ckeditor/ckeditor5-utils": "0.0.0-nightly-next-20250225.0",
21
- "@ckeditor/ckeditor5-typing": "0.0.0-nightly-next-20250225.0",
15
+ "@ckeditor/ckeditor5-core": "0.0.0-nightly-next-20250226.0",
16
+ "@ckeditor/ckeditor5-engine": "0.0.0-nightly-next-20250226.0",
17
+ "@ckeditor/ckeditor5-enter": "0.0.0-nightly-next-20250226.0",
18
+ "@ckeditor/ckeditor5-icons": "0.0.0-nightly-next-20250226.0",
19
+ "@ckeditor/ckeditor5-ui": "0.0.0-nightly-next-20250226.0",
20
+ "@ckeditor/ckeditor5-utils": "0.0.0-nightly-next-20250226.0",
21
+ "@ckeditor/ckeditor5-typing": "0.0.0-nightly-next-20250226.0",
22
22
  "es-toolkit": "1.32.0"
23
23
  },
24
24
  "author": "CKSource (http://cksource.com/)",
@@ -8,6 +8,7 @@
8
8
  import { Plugin, type ToolbarConfigItem } from '@ckeditor/ckeditor5-core';
9
9
  import type { ViewDocumentSelection, ViewElement } from '@ckeditor/ckeditor5-engine';
10
10
  import { ContextualBalloon } from '@ckeditor/ckeditor5-ui';
11
+ import { type PositioningFunction } from '@ckeditor/ckeditor5-utils';
11
12
  /**
12
13
  * Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole
13
14
  * toolbar rendering process and exposes a concise API.
@@ -71,11 +72,12 @@ export default class WidgetToolbarRepository extends Plugin {
71
72
  * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
72
73
  * @param options.balloonClassName CSS class for the widget balloon.
73
74
  */
74
- register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName }: {
75
+ register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName, positions }: {
75
76
  ariaLabel?: string;
76
77
  items: Array<ToolbarConfigItem>;
77
78
  getRelatedElement: (selection: ViewDocumentSelection) => (ViewElement | null);
78
79
  balloonClassName?: string;
80
+ positions?: ReadonlyArray<PositioningFunction>;
79
81
  }): void;
80
82
  /**
81
83
  * Iterates over stored toolbars and makes them visible or hidden.
@@ -105,7 +105,7 @@ export default class WidgetToolbarRepository extends Plugin {
105
105
  * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
106
106
  * @param options.balloonClassName CSS class for the widget balloon.
107
107
  */
108
- register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container' }) {
108
+ register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container', positions }) {
109
109
  // Trying to register a toolbar without any item.
110
110
  if (!items.length) {
111
111
  /**
@@ -143,6 +143,7 @@ export default class WidgetToolbarRepository extends Plugin {
143
143
  getRelatedElement,
144
144
  balloonClassName,
145
145
  itemsConfig: items,
146
+ positions,
146
147
  initialized: false
147
148
  };
148
149
  // Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
@@ -212,7 +213,7 @@ export default class WidgetToolbarRepository extends Plugin {
212
213
  */
213
214
  _showToolbar(toolbarDefinition, relatedElement) {
214
215
  if (this._isToolbarVisible(toolbarDefinition)) {
215
- repositionContextualBalloon(this.editor, relatedElement);
216
+ repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
216
217
  }
217
218
  else if (!this._isToolbarInBalloon(toolbarDefinition)) {
218
219
  if (!toolbarDefinition.initialized) {
@@ -221,7 +222,7 @@ export default class WidgetToolbarRepository extends Plugin {
221
222
  }
222
223
  this._balloon.add({
223
224
  view: toolbarDefinition.view,
224
- position: getBalloonPositionData(this.editor, relatedElement),
225
+ position: getBalloonPositionData(this.editor, relatedElement, toolbarDefinition.positions),
225
226
  balloonClassName: toolbarDefinition.balloonClassName
226
227
  });
227
228
  // Update toolbar position each time stack with toolbar view is switched to visible.
@@ -232,7 +233,7 @@ export default class WidgetToolbarRepository extends Plugin {
232
233
  for (const definition of this._toolbarDefinitions.values()) {
233
234
  if (this._isToolbarVisible(definition)) {
234
235
  const relatedElement = definition.getRelatedElement(this.editor.editing.view.document.selection);
235
- repositionContextualBalloon(this.editor, relatedElement);
236
+ repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
236
237
  }
237
238
  }
238
239
  });
@@ -245,17 +246,17 @@ export default class WidgetToolbarRepository extends Plugin {
245
246
  return this._balloon.hasView(toolbar.view);
246
247
  }
247
248
  }
248
- function repositionContextualBalloon(editor, relatedElement) {
249
+ function repositionContextualBalloon(editor, relatedElement, positions) {
249
250
  const balloon = editor.plugins.get('ContextualBalloon');
250
- const position = getBalloonPositionData(editor, relatedElement);
251
+ const position = getBalloonPositionData(editor, relatedElement, positions);
251
252
  balloon.updatePosition(position);
252
253
  }
253
- function getBalloonPositionData(editor, relatedElement) {
254
+ function getBalloonPositionData(editor, relatedElement, positions) {
254
255
  const editingView = editor.editing.view;
255
256
  const defaultPositions = BalloonPanelView.defaultPositions;
256
257
  return {
257
258
  target: editingView.domConverter.mapViewToDom(relatedElement),
258
- positions: [
259
+ positions: positions || [
259
260
  defaultPositions.northArrowSouth,
260
261
  defaultPositions.northArrowSouthWest,
261
262
  defaultPositions.northArrowSouthEast,