@ckeditor/ckeditor5-widget 0.0.0-nightly-next-20250226.0 → 0.0.0-nightly-20250227.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-20250226.0",
3
+ "version": "0.0.0-nightly-20250227.0",
4
4
  "description": "Widget API for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,14 +12,13 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
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
- "es-toolkit": "1.32.0"
15
+ "@ckeditor/ckeditor5-core": "0.0.0-nightly-20250227.0",
16
+ "@ckeditor/ckeditor5-engine": "0.0.0-nightly-20250227.0",
17
+ "@ckeditor/ckeditor5-enter": "0.0.0-nightly-20250227.0",
18
+ "@ckeditor/ckeditor5-ui": "0.0.0-nightly-20250227.0",
19
+ "@ckeditor/ckeditor5-utils": "0.0.0-nightly-20250227.0",
20
+ "@ckeditor/ckeditor5-typing": "0.0.0-nightly-20250227.0",
21
+ "lodash-es": "4.17.21"
23
22
  },
24
23
  "author": "CKSource (http://cksource.com/)",
25
24
  "license": "SEE LICENSE IN LICENSE.md",
@@ -18,7 +18,10 @@ import { EmitterMixin } from '@ckeditor/ckeditor5-utils';
18
18
  * This way, highlight will be applied with the same rules it is applied on texts.
19
19
  */
20
20
  export default class HighlightStack extends /* #__PURE__ */ EmitterMixin() {
21
- _stack = [];
21
+ constructor() {
22
+ super(...arguments);
23
+ this._stack = [];
24
+ }
22
25
  /**
23
26
  * Adds highlight descriptor to the stack.
24
27
  *
package/src/utils.d.ts CHANGED
@@ -2,6 +2,9 @@
2
2
  * @license Copyright (c) 2003-2025, 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
+ /**
6
+ * @module widget/utils
7
+ */
5
8
  import { Rect, type GetCallback } from '@ckeditor/ckeditor5-utils';
6
9
  import { type HighlightDescriptor, type MapperViewToModelPositionEvent, type DocumentSelection, type DowncastWriter, type Model, type Range, type Selection, type ViewEditableElement, type ViewElement, type ViewTypeCheckable } from '@ckeditor/ckeditor5-engine';
7
10
  /**
package/src/utils.js CHANGED
@@ -5,11 +5,11 @@
5
5
  /**
6
6
  * @module widget/utils
7
7
  */
8
- import { IconDragHandle } from '@ckeditor/ckeditor5-icons';
9
8
  import { Rect, CKEditorError, toArray } from '@ckeditor/ckeditor5-utils';
10
9
  import { IconView } from '@ckeditor/ckeditor5-ui';
11
10
  import HighlightStack from './highlightstack.js';
12
11
  import { getTypeAroundFakeCaretPosition } from './widgettypearound/utils.js';
12
+ import dragHandleIcon from '../theme/icons/drag-handle.svg';
13
13
  /**
14
14
  * CSS class added to each widget element.
15
15
  */
@@ -336,7 +336,7 @@ function addSelectionHandle(widgetElement, writer) {
336
336
  const domElement = this.toDomElement(domDocument);
337
337
  // Use the IconView from the ui library.
338
338
  const icon = new IconView();
339
- icon.set('content', IconDragHandle);
339
+ icon.set('content', dragHandleIcon);
340
340
  // Render the icon view right away to append its #element to the selectionHandle DOM element.
341
341
  icon.render();
342
342
  domElement.appendChild(icon.element);
package/src/widget.js CHANGED
@@ -27,10 +27,13 @@ import '../theme/widget.css';
27
27
  * * The mouse and keyboard events handling on and around widget elements.
28
28
  */
29
29
  export default class Widget extends Plugin {
30
- /**
31
- * Holds previously selected widgets.
32
- */
33
- _previouslySelected = new Set();
30
+ constructor() {
31
+ super(...arguments);
32
+ /**
33
+ * Holds previously selected widgets.
34
+ */
35
+ this._previouslySelected = new Set();
36
+ }
34
37
  /**
35
38
  * @inheritDoc
36
39
  */
@@ -13,33 +13,15 @@ import SizeView from './sizeview.js';
13
13
  * Represents a resizer for a single resizable object.
14
14
  */
15
15
  export default class Resizer extends /* #__PURE__ */ ObservableMixin() {
16
- /**
17
- * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
18
- *
19
- * Note that a new state is created for each resize transaction.
20
- */
21
- _state;
22
- /**
23
- * A view displaying the proposed new element size during the resizing.
24
- */
25
- _sizeView;
26
- /**
27
- * Options passed to the {@link #constructor}.
28
- */
29
- _options;
30
- /**
31
- * A wrapper that is controlled by the resizer. This is usually a widget element.
32
- */
33
- _viewResizerWrapper = null;
34
- /**
35
- * The width of the resized {@link module:widget/widgetresize~ResizerOptions#viewElement viewElement} before the resizing started.
36
- */
37
- _initialViewWidth;
38
16
  /**
39
17
  * @param options Resizer options.
40
18
  */
41
19
  constructor(options) {
42
20
  super();
21
+ /**
22
+ * A wrapper that is controlled by the resizer. This is usually a widget element.
23
+ */
24
+ this._viewResizerWrapper = null;
43
25
  this._options = options;
44
26
  this.set('isEnabled', true);
45
27
  this.set('isSelected', false);
@@ -11,42 +11,6 @@ import { calculateResizeHostPercentageWidth } from '../utils.js';
11
11
  * Stores the internal state of a single resizable object.
12
12
  */
13
13
  export default class ResizeState extends /* #__PURE__ */ ObservableMixin() {
14
- /**
15
- * The reference point of the resizer where the dragging started. It is used to measure the distance the user cursor
16
- * traveled, so how much the image should be enlarged.
17
- * This information is only known after the DOM was rendered, so it will be updated later.
18
- *
19
- * @internal
20
- */
21
- _referenceCoordinates;
22
- /**
23
- * Resizer options.
24
- */
25
- _options;
26
- /**
27
- * The original width (pixels) of the resized object when the resize process was started.
28
- *
29
- * @readonly
30
- */
31
- _originalWidth;
32
- /**
33
- * The original height (pixels) of the resized object when the resize process was started.
34
- *
35
- * @readonly
36
- */
37
- _originalHeight;
38
- /**
39
- * The original width (percents) of the resized object when the resize process was started.
40
- *
41
- * @readonly
42
- */
43
- _originalWidthPercents;
44
- /**
45
- * A width to height ratio of the resized image.
46
- *
47
- * @readonly
48
- */
49
- _aspectRatio;
50
14
  /**
51
15
  * @param options Resizer options.
52
16
  */
@@ -9,7 +9,7 @@ import Resizer from './widgetresize/resizer.js';
9
9
  import { Plugin } from '@ckeditor/ckeditor5-core';
10
10
  import { MouseObserver } from '@ckeditor/ckeditor5-engine';
11
11
  import { DomEmitterMixin, global } from '@ckeditor/ckeditor5-utils';
12
- import { throttle } from 'es-toolkit/compat';
12
+ import { throttle } from 'lodash-es';
13
13
  import '../theme/widgetresize.css';
14
14
  /**
15
15
  * The widget resize feature plugin.
@@ -17,12 +17,13 @@ import '../theme/widgetresize.css';
17
17
  * Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
18
18
  */
19
19
  export default class WidgetResize extends Plugin {
20
- /**
21
- * A map of resizers created using this plugin instance.
22
- */
23
- _resizers = new Map();
24
- _observer;
25
- _redrawSelectedResizerThrottled;
20
+ constructor() {
21
+ super(...arguments);
22
+ /**
23
+ * A map of resizers created using this plugin instance.
24
+ */
25
+ this._resizers = new Map();
26
+ }
26
27
  /**
27
28
  * @inheritDoc
28
29
  */
@@ -8,7 +8,6 @@
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';
12
11
  /**
13
12
  * Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole
14
13
  * toolbar rendering process and exposes a concise API.
@@ -72,12 +71,11 @@ export default class WidgetToolbarRepository extends Plugin {
72
71
  * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
73
72
  * @param options.balloonClassName CSS class for the widget balloon.
74
73
  */
75
- register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName, positions }: {
74
+ register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName }: {
76
75
  ariaLabel?: string;
77
76
  items: Array<ToolbarConfigItem>;
78
77
  getRelatedElement: (selection: ViewDocumentSelection) => (ViewElement | null);
79
78
  balloonClassName?: string;
80
- positions?: ReadonlyArray<PositioningFunction>;
81
79
  }): void;
82
80
  /**
83
81
  * Iterates over stored toolbars and makes them visible or hidden.
@@ -36,11 +36,13 @@ import { isWidget } from './utils.js';
36
36
  * ```
37
37
  */
38
38
  export default class WidgetToolbarRepository extends Plugin {
39
- /**
40
- * A map of toolbar definitions.
41
- */
42
- _toolbarDefinitions = new Map();
43
- _balloon;
39
+ constructor() {
40
+ super(...arguments);
41
+ /**
42
+ * A map of toolbar definitions.
43
+ */
44
+ this._toolbarDefinitions = new Map();
45
+ }
44
46
  /**
45
47
  * @inheritDoc
46
48
  */
@@ -105,7 +107,7 @@ export default class WidgetToolbarRepository extends Plugin {
105
107
  * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
106
108
  * @param options.balloonClassName CSS class for the widget balloon.
107
109
  */
108
- register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container', positions }) {
110
+ register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container' }) {
109
111
  // Trying to register a toolbar without any item.
110
112
  if (!items.length) {
111
113
  /**
@@ -143,7 +145,6 @@ export default class WidgetToolbarRepository extends Plugin {
143
145
  getRelatedElement,
144
146
  balloonClassName,
145
147
  itemsConfig: items,
146
- positions,
147
148
  initialized: false
148
149
  };
149
150
  // Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
@@ -213,7 +214,7 @@ export default class WidgetToolbarRepository extends Plugin {
213
214
  */
214
215
  _showToolbar(toolbarDefinition, relatedElement) {
215
216
  if (this._isToolbarVisible(toolbarDefinition)) {
216
- repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
217
+ repositionContextualBalloon(this.editor, relatedElement);
217
218
  }
218
219
  else if (!this._isToolbarInBalloon(toolbarDefinition)) {
219
220
  if (!toolbarDefinition.initialized) {
@@ -222,7 +223,7 @@ export default class WidgetToolbarRepository extends Plugin {
222
223
  }
223
224
  this._balloon.add({
224
225
  view: toolbarDefinition.view,
225
- position: getBalloonPositionData(this.editor, relatedElement, toolbarDefinition.positions),
226
+ position: getBalloonPositionData(this.editor, relatedElement),
226
227
  balloonClassName: toolbarDefinition.balloonClassName
227
228
  });
228
229
  // Update toolbar position each time stack with toolbar view is switched to visible.
@@ -233,7 +234,7 @@ export default class WidgetToolbarRepository extends Plugin {
233
234
  for (const definition of this._toolbarDefinitions.values()) {
234
235
  if (this._isToolbarVisible(definition)) {
235
236
  const relatedElement = definition.getRelatedElement(this.editor.editing.view.document.selection);
236
- repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
237
+ repositionContextualBalloon(this.editor, relatedElement);
237
238
  }
238
239
  }
239
240
  });
@@ -246,17 +247,17 @@ export default class WidgetToolbarRepository extends Plugin {
246
247
  return this._balloon.hasView(toolbar.view);
247
248
  }
248
249
  }
249
- function repositionContextualBalloon(editor, relatedElement, positions) {
250
+ function repositionContextualBalloon(editor, relatedElement) {
250
251
  const balloon = editor.plugins.get('ContextualBalloon');
251
- const position = getBalloonPositionData(editor, relatedElement, positions);
252
+ const position = getBalloonPositionData(editor, relatedElement);
252
253
  balloon.updatePosition(position);
253
254
  }
254
- function getBalloonPositionData(editor, relatedElement, positions) {
255
+ function getBalloonPositionData(editor, relatedElement) {
255
256
  const editingView = editor.editing.view;
256
257
  const defaultPositions = BalloonPanelView.defaultPositions;
257
258
  return {
258
259
  target: editingView.domConverter.mapViewToDom(relatedElement),
259
- positions: positions || [
260
+ positions: [
260
261
  defaultPositions.northArrowSouth,
261
262
  defaultPositions.northArrowSouthWest,
262
263
  defaultPositions.northArrowSouthEast,
@@ -7,17 +7,17 @@
7
7
  * @module widget/widgettypearound/widgettypearound
8
8
  */
9
9
  import { Plugin } from '@ckeditor/ckeditor5-core';
10
- import { IconReturnArrow } from '@ckeditor/ckeditor5-icons';
11
10
  import { Template } from '@ckeditor/ckeditor5-ui';
12
11
  import { Enter } from '@ckeditor/ckeditor5-enter';
13
12
  import { Delete } from '@ckeditor/ckeditor5-typing';
14
13
  import { env, isForwardArrowKeyCode } from '@ckeditor/ckeditor5-utils';
15
14
  import { isTypeAroundWidget, getClosestTypeAroundDomButton, getTypeAroundButtonPosition, getClosestWidgetViewElement, getTypeAroundFakeCaretPosition, TYPE_AROUND_SELECTION_ATTRIBUTE } from './utils.js';
16
15
  import { isWidget } from '../utils.js';
16
+ import returnIcon from '../../theme/icons/return-arrow.svg';
17
17
  import '../../theme/widgettypearound.css';
18
18
  const POSSIBLE_INSERTION_POSITIONS = ['before', 'after'];
19
19
  // Do the SVG parsing once and then clone the result <svg> DOM element for each new button.
20
- const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString(IconReturnArrow, 'image/svg+xml').firstChild;
20
+ const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString(returnIcon, 'image/svg+xml').firstChild;
21
21
  const PLUGIN_DISABLED_EDITING_ROOT_CLASS = 'ck-widget__type-around_disabled';
22
22
  /**
23
23
  * A plugin that allows users to type around widgets where normally it is impossible to place the caret due
@@ -30,12 +30,15 @@ const PLUGIN_DISABLED_EDITING_ROOT_CLASS = 'ck-widget__type-around_disabled';
30
30
  * in it so that users can type (or insert content, paste, etc.) straight away.
31
31
  */
32
32
  export default class WidgetTypeAround extends Plugin {
33
- /**
34
- * A reference to the model widget element that has the fake caret active
35
- * on either side of it. It is later used to remove CSS classes associated with the fake caret
36
- * when the widget no longer needs it.
37
- */
38
- _currentFakeCaretModelElement = null;
33
+ constructor() {
34
+ super(...arguments);
35
+ /**
36
+ * A reference to the model widget element that has the fake caret active
37
+ * on either side of it. It is later used to remove CSS classes associated with the fake caret
38
+ * when the widget no longer needs it.
39
+ */
40
+ this._currentFakeCaretModelElement = null;
41
+ }
39
42
  /**
40
43
  * @inheritDoc
41
44
  */
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0H4zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3V0zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3v1zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5H12z"/><path fill-opacity=".256" d="M1 1h14v14H1z"/><g class="ck-icon__selected-indicator"><path d="M7 0h2v1H7V0zM0 7h1v2H0V7zm15 0h1v2h-1V7zm-8 8h2v1H7v-1z"/><path fill-opacity=".254" d="M1 1h14v14H1z"/></g></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 10 8" xmlns="http://www.w3.org/2000/svg"><path d="M9.055.263v3.972h-6.77M1 4.216l2-2.038m-2 2 2 2.038"/></svg>