@ckeditor/ckeditor5-widget 44.3.0 → 45.0.0-alpha.1

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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, 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
+
6
+ import type { Translations } from '@ckeditor/ckeditor5-utils';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, 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
+ export default {"be":{"dictionary":{"Widget toolbar":"Панель інструментаў віджэта","Insert paragraph before block":"Уставіць параграф перад блокам","Insert paragraph after block":"Уставіць параграф пасля блока","Press Enter to type after or press Shift + Enter to type before the widget":"Націсніце Enter для ўводу тэксту пасля віджэта або націсніце Shift + Enter для ўводу тэксту перад віджэтам","Keystrokes that can be used when a widget is selected (for example: image, table, etc.)":"Націскі клавіш, якія можна выкарыстоўваць пры выбару віджэта (напрыклад: відарыс, табліца і г. д.)","Insert a new paragraph directly after a widget":"Уставіць новы абзац пасля віджэта.","Insert a new paragraph directly before a widget":"Уставіць новы абзац напярэдзе віджэта.","Move the caret to allow typing directly before a widget":"Перамясціце курсор, каб можна было ўводзіць тэкст напярэдзе віджэта.","Move the caret to allow typing directly after a widget":"Перамясціце курсор, каб можна было ўводзіць тэкст пасля віджэта.","Move focus from an editable area back to the parent widget":"Перамясціце фокус з рэдагававальнай вобласці назад на бацькоўскі віджэт"},getPluralForm(n){return (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);}}}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, 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
+
6
+ ( e => {
7
+ const { [ 'be' ]: { dictionary, getPluralForm } } = {"be":{"dictionary":{"Widget toolbar":"Панель інструментаў віджэта","Insert paragraph before block":"Уставіць параграф перад блокам","Insert paragraph after block":"Уставіць параграф пасля блока","Press Enter to type after or press Shift + Enter to type before the widget":"Націсніце Enter для ўводу тэксту пасля віджэта або націсніце Shift + Enter для ўводу тэксту перад віджэтам","Keystrokes that can be used when a widget is selected (for example: image, table, etc.)":"Націскі клавіш, якія можна выкарыстоўваць пры выбару віджэта (напрыклад: відарыс, табліца і г. д.)","Insert a new paragraph directly after a widget":"Уставіць новы абзац пасля віджэта.","Insert a new paragraph directly before a widget":"Уставіць новы абзац напярэдзе віджэта.","Move the caret to allow typing directly before a widget":"Перамясціце курсор, каб можна было ўводзіць тэкст напярэдзе віджэта.","Move the caret to allow typing directly after a widget":"Перамясціце курсор, каб можна было ўводзіць тэкст пасля віджэта.","Move focus from an editable area back to the parent widget":"Перамясціце фокус з рэдагававальнай вобласці назад на бацькоўскі віджэт"},getPluralForm(n){return (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);}}};
8
+ e[ 'be' ] ||= { dictionary: {}, getPluralForm: null };
9
+ e[ 'be' ].dictionary = Object.assign( e[ 'be' ].dictionary, dictionary );
10
+ e[ 'be' ].getPluralForm = getPluralForm;
11
+ } )( window.CKEDITOR_TRANSLATIONS ||= {} );
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
+ #
5
+ # Check out the official contributor's guide:
6
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
+ #
8
+ msgid ""
9
+ msgstr ""
10
+ "Language: be\n"
11
+ "Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+
14
+ msgctxt "The label used by assistive technologies describing a toolbar attached to a widget."
15
+ msgid "Widget toolbar"
16
+ msgstr "Панель інструментаў віджэта"
17
+
18
+ msgctxt "The title displayed when a mouse is over a button that inserts a paragraph before a block."
19
+ msgid "Insert paragraph before block"
20
+ msgstr "Уставіць параграф перад блокам"
21
+
22
+ msgctxt "The title displayed when a mouse is over a button that inserts a paragraph after a block."
23
+ msgid "Insert paragraph after block"
24
+ msgstr "Уставіць параграф пасля блока"
25
+
26
+ msgctxt "Information to be read by screen reader about shortcuts to type around a widget."
27
+ msgid "Press Enter to type after or press Shift + Enter to type before the widget"
28
+ msgstr "Націсніце Enter для ўводу тэксту пасля віджэта або націсніце Shift + Enter для ўводу тэксту перад віджэтам"
29
+
30
+ msgctxt "Accessibility help dialog section title for widget plugin keystrokes."
31
+ msgid "Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"
32
+ msgstr "Націскі клавіш, якія можна выкарыстоўваць пры выбару віджэта (напрыклад: відарыс, табліца і г. д.)"
33
+
34
+ msgctxt "Accessibility help dialog entry explaining the meaning of the keystroke that inserts a paragraph after a widget."
35
+ msgid "Insert a new paragraph directly after a widget"
36
+ msgstr "Уставіць новы абзац пасля віджэта."
37
+
38
+ msgctxt "Accessibility help dialog entry explaining the meaning of the keystroke that inserts a paragraph before a widget."
39
+ msgid "Insert a new paragraph directly before a widget"
40
+ msgstr "Уставіць новы абзац напярэдзе віджэта."
41
+
42
+ msgctxt "Accessibility help dialog entry explaining the meaning of the keystroke that moves the caret before a widget."
43
+ msgid "Move the caret to allow typing directly before a widget"
44
+ msgstr "Перамясціце курсор, каб можна было ўводзіць тэкст напярэдзе віджэта."
45
+
46
+ msgctxt "Accessibility help dialog entry explaining the meaning of the keystroke that moves the caret after a widget."
47
+ msgid "Move the caret to allow typing directly after a widget"
48
+ msgstr "Перамясціце курсор, каб можна было ўводзіць тэкст пасля віджэта."
49
+
50
+ msgctxt "Accessibility help dialog entry explaining the meaning of the keystroke that moves selection from a nested editable area back to the parent widget."
51
+ msgid "Move focus from an editable area back to the parent widget"
52
+ msgstr "Перамясціце фокус з рэдагававальнай вобласці назад на бацькоўскі віджэт"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-widget",
3
- "version": "44.3.0",
3
+ "version": "45.0.0-alpha.1",
4
4
  "description": "Widget API for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,13 +12,14 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "44.3.0",
16
- "@ckeditor/ckeditor5-engine": "44.3.0",
17
- "@ckeditor/ckeditor5-enter": "44.3.0",
18
- "@ckeditor/ckeditor5-ui": "44.3.0",
19
- "@ckeditor/ckeditor5-utils": "44.3.0",
20
- "@ckeditor/ckeditor5-typing": "44.3.0",
21
- "lodash-es": "4.17.21"
15
+ "@ckeditor/ckeditor5-core": "45.0.0-alpha.1",
16
+ "@ckeditor/ckeditor5-engine": "45.0.0-alpha.1",
17
+ "@ckeditor/ckeditor5-enter": "45.0.0-alpha.1",
18
+ "@ckeditor/ckeditor5-icons": "45.0.0-alpha.1",
19
+ "@ckeditor/ckeditor5-ui": "45.0.0-alpha.1",
20
+ "@ckeditor/ckeditor5-utils": "45.0.0-alpha.1",
21
+ "@ckeditor/ckeditor5-typing": "45.0.0-alpha.1",
22
+ "es-toolkit": "1.32.0"
22
23
  },
23
24
  "author": "CKSource (http://cksource.com/)",
24
25
  "license": "SEE LICENSE IN LICENSE.md",
@@ -18,10 +18,7 @@ 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
- constructor() {
22
- super(...arguments);
23
- this._stack = [];
24
- }
21
+ _stack = [];
25
22
  /**
26
23
  * Adds highlight descriptor to the stack.
27
24
  *
package/src/utils.d.ts CHANGED
@@ -2,9 +2,6 @@
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
- */
8
5
  import { Rect, type GetCallback } from '@ckeditor/ckeditor5-utils';
9
6
  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';
10
7
  /**
@@ -92,6 +89,7 @@ export declare function getLabel(element: ViewElement): string;
92
89
  * * adds the `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
93
90
  * * adds the `ck-editor__nested-editable_focused` CSS class when the editable is focused and removes it when it is blurred.
94
91
  * * implements the {@link ~setHighlightHandling view highlight on widget's editable}.
92
+ * * sets the `role` attribute to `textbox` for accessibility purposes.
95
93
  *
96
94
  * Similarly to {@link ~toWidget `toWidget()`} this function should be used in `editingDowncast` only and it is usually
97
95
  * used together with {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
@@ -124,10 +122,12 @@ export declare function getLabel(element: ViewElement): string;
124
122
  *
125
123
  * @param options Additional options.
126
124
  * @param options.label Editable's label used by assistive technologies (e.g. screen readers).
125
+ * @param options.withAriaRole Whether to add the role="textbox" attribute on the editable. Defaults to `true`.
127
126
  * @returns Returns the same element that was provided in the `editable` parameter
128
127
  */
129
128
  export declare function toWidgetEditable(editable: ViewEditableElement, writer: DowncastWriter, options?: {
130
129
  label?: string;
130
+ withAriaRole?: boolean;
131
131
  }): ViewEditableElement;
132
132
  /**
133
133
  * Returns a model range which is optimal (in terms of UX) for inserting a widget block.
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';
8
9
  import { Rect, CKEditorError, toArray } from '@ckeditor/ckeditor5-utils';
9
10
  import { IconView } from '@ckeditor/ckeditor5-ui';
10
11
  import HighlightStack from './highlightstack.js';
11
12
  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
  */
@@ -176,6 +176,7 @@ export function getLabel(element) {
176
176
  * * adds the `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
177
177
  * * adds the `ck-editor__nested-editable_focused` CSS class when the editable is focused and removes it when it is blurred.
178
178
  * * implements the {@link ~setHighlightHandling view highlight on widget's editable}.
179
+ * * sets the `role` attribute to `textbox` for accessibility purposes.
179
180
  *
180
181
  * Similarly to {@link ~toWidget `toWidget()`} this function should be used in `editingDowncast` only and it is usually
181
182
  * used together with {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
@@ -208,11 +209,15 @@ export function getLabel(element) {
208
209
  *
209
210
  * @param options Additional options.
210
211
  * @param options.label Editable's label used by assistive technologies (e.g. screen readers).
212
+ * @param options.withAriaRole Whether to add the role="textbox" attribute on the editable. Defaults to `true`.
211
213
  * @returns Returns the same element that was provided in the `editable` parameter
212
214
  */
213
215
  export function toWidgetEditable(editable, writer, options = {}) {
214
216
  writer.addClass(['ck-editor__editable', 'ck-editor__nested-editable'], editable);
215
- writer.setAttribute('role', 'textbox', editable);
217
+ // Set role="textbox" only if explicitly requested (defaults to true for backward compatibility).
218
+ if (options.withAriaRole !== false) {
219
+ writer.setAttribute('role', 'textbox', editable);
220
+ }
216
221
  writer.setAttribute('tabindex', '-1', editable);
217
222
  if (options.label) {
218
223
  writer.setAttribute('aria-label', options.label, editable);
@@ -336,7 +341,7 @@ function addSelectionHandle(widgetElement, writer) {
336
341
  const domElement = this.toDomElement(domDocument);
337
342
  // Use the IconView from the ui library.
338
343
  const icon = new IconView();
339
- icon.set('content', dragHandleIcon);
344
+ icon.set('content', IconDragHandle);
340
345
  // Render the icon view right away to append its #element to the selectionHandle DOM element.
341
346
  icon.render();
342
347
  domElement.appendChild(icon.element);
package/src/widget.js CHANGED
@@ -27,13 +27,10 @@ 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
- constructor() {
31
- super(...arguments);
32
- /**
33
- * Holds previously selected widgets.
34
- */
35
- this._previouslySelected = new Set();
36
- }
30
+ /**
31
+ * Holds previously selected widgets.
32
+ */
33
+ _previouslySelected = new Set();
37
34
  /**
38
35
  * @inheritDoc
39
36
  */
@@ -13,15 +13,33 @@ 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;
16
38
  /**
17
39
  * @param options Resizer options.
18
40
  */
19
41
  constructor(options) {
20
42
  super();
21
- /**
22
- * A wrapper that is controlled by the resizer. This is usually a widget element.
23
- */
24
- this._viewResizerWrapper = null;
25
43
  this._options = options;
26
44
  this.set('isEnabled', true);
27
45
  this.set('isSelected', false);
@@ -11,6 +11,42 @@ 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;
14
50
  /**
15
51
  * @param options Resizer options.
16
52
  */
@@ -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 'lodash-es';
12
+ import { throttle } from 'es-toolkit/compat';
13
13
  import '../theme/widgetresize.css';
14
14
  /**
15
15
  * The widget resize feature plugin.
@@ -17,13 +17,12 @@ 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
- constructor() {
21
- super(...arguments);
22
- /**
23
- * A map of resizers created using this plugin instance.
24
- */
25
- this._resizers = new Map();
26
- }
20
+ /**
21
+ * A map of resizers created using this plugin instance.
22
+ */
23
+ _resizers = new Map();
24
+ _observer;
25
+ _redrawSelectedResizerThrottled;
27
26
  /**
28
27
  * @inheritDoc
29
28
  */
@@ -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.
@@ -36,13 +36,11 @@ import { isWidget } from './utils.js';
36
36
  * ```
37
37
  */
38
38
  export default class WidgetToolbarRepository extends Plugin {
39
- constructor() {
40
- super(...arguments);
41
- /**
42
- * A map of toolbar definitions.
43
- */
44
- this._toolbarDefinitions = new Map();
45
- }
39
+ /**
40
+ * A map of toolbar definitions.
41
+ */
42
+ _toolbarDefinitions = new Map();
43
+ _balloon;
46
44
  /**
47
45
  * @inheritDoc
48
46
  */
@@ -107,7 +105,7 @@ export default class WidgetToolbarRepository extends Plugin {
107
105
  * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
108
106
  * @param options.balloonClassName CSS class for the widget balloon.
109
107
  */
110
- register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container' }) {
108
+ register(toolbarId, { ariaLabel, items, getRelatedElement, balloonClassName = 'ck-toolbar-container', positions }) {
111
109
  // Trying to register a toolbar without any item.
112
110
  if (!items.length) {
113
111
  /**
@@ -145,6 +143,7 @@ export default class WidgetToolbarRepository extends Plugin {
145
143
  getRelatedElement,
146
144
  balloonClassName,
147
145
  itemsConfig: items,
146
+ positions,
148
147
  initialized: false
149
148
  };
150
149
  // Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
@@ -214,7 +213,7 @@ export default class WidgetToolbarRepository extends Plugin {
214
213
  */
215
214
  _showToolbar(toolbarDefinition, relatedElement) {
216
215
  if (this._isToolbarVisible(toolbarDefinition)) {
217
- repositionContextualBalloon(this.editor, relatedElement);
216
+ repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
218
217
  }
219
218
  else if (!this._isToolbarInBalloon(toolbarDefinition)) {
220
219
  if (!toolbarDefinition.initialized) {
@@ -223,7 +222,7 @@ export default class WidgetToolbarRepository extends Plugin {
223
222
  }
224
223
  this._balloon.add({
225
224
  view: toolbarDefinition.view,
226
- position: getBalloonPositionData(this.editor, relatedElement),
225
+ position: getBalloonPositionData(this.editor, relatedElement, toolbarDefinition.positions),
227
226
  balloonClassName: toolbarDefinition.balloonClassName
228
227
  });
229
228
  // Update toolbar position each time stack with toolbar view is switched to visible.
@@ -234,7 +233,7 @@ export default class WidgetToolbarRepository extends Plugin {
234
233
  for (const definition of this._toolbarDefinitions.values()) {
235
234
  if (this._isToolbarVisible(definition)) {
236
235
  const relatedElement = definition.getRelatedElement(this.editor.editing.view.document.selection);
237
- repositionContextualBalloon(this.editor, relatedElement);
236
+ repositionContextualBalloon(this.editor, relatedElement, toolbarDefinition.positions);
238
237
  }
239
238
  }
240
239
  });
@@ -247,17 +246,17 @@ export default class WidgetToolbarRepository extends Plugin {
247
246
  return this._balloon.hasView(toolbar.view);
248
247
  }
249
248
  }
250
- function repositionContextualBalloon(editor, relatedElement) {
249
+ function repositionContextualBalloon(editor, relatedElement, positions) {
251
250
  const balloon = editor.plugins.get('ContextualBalloon');
252
- const position = getBalloonPositionData(editor, relatedElement);
251
+ const position = getBalloonPositionData(editor, relatedElement, positions);
253
252
  balloon.updatePosition(position);
254
253
  }
255
- function getBalloonPositionData(editor, relatedElement) {
254
+ function getBalloonPositionData(editor, relatedElement, positions) {
256
255
  const editingView = editor.editing.view;
257
256
  const defaultPositions = BalloonPanelView.defaultPositions;
258
257
  return {
259
258
  target: editingView.domConverter.mapViewToDom(relatedElement),
260
- positions: [
259
+ positions: positions || [
261
260
  defaultPositions.northArrowSouth,
262
261
  defaultPositions.northArrowSouthWest,
263
262
  defaultPositions.northArrowSouthEast,
@@ -7,17 +7,18 @@
7
7
  * @module widget/widgettypearound/widgettypearound
8
8
  */
9
9
  import { Plugin } from '@ckeditor/ckeditor5-core';
10
+ import { IconReturnArrow } from '@ckeditor/ckeditor5-icons';
10
11
  import { Template } from '@ckeditor/ckeditor5-ui';
11
12
  import { Enter } from '@ckeditor/ckeditor5-enter';
12
13
  import { Delete } from '@ckeditor/ckeditor5-typing';
13
14
  import { env, isForwardArrowKeyCode } from '@ckeditor/ckeditor5-utils';
14
15
  import { isTypeAroundWidget, getClosestTypeAroundDomButton, getTypeAroundButtonPosition, getClosestWidgetViewElement, getTypeAroundFakeCaretPosition, TYPE_AROUND_SELECTION_ATTRIBUTE } from './utils.js';
15
16
  import { isWidget } from '../utils.js';
16
- import returnIcon from '../../theme/icons/return-arrow.svg';
17
+ // @if CK_DEBUG_TYPING // const { _buildLogMessage } = require( '@ckeditor/ckeditor5-engine/src/dev-utils/utils.js' );
17
18
  import '../../theme/widgettypearound.css';
18
19
  const POSSIBLE_INSERTION_POSITIONS = ['before', 'after'];
19
20
  // 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(returnIcon, 'image/svg+xml').firstChild;
21
+ const RETURN_ARROW_ICON_ELEMENT = new DOMParser().parseFromString(IconReturnArrow, 'image/svg+xml').firstChild;
21
22
  const PLUGIN_DISABLED_EDITING_ROOT_CLASS = 'ck-widget__type-around_disabled';
22
23
  /**
23
24
  * A plugin that allows users to type around widgets where normally it is impossible to place the caret due
@@ -30,15 +31,12 @@ const PLUGIN_DISABLED_EDITING_ROOT_CLASS = 'ck-widget__type-around_disabled';
30
31
  * in it so that users can type (or insert content, paste, etc.) straight away.
31
32
  */
32
33
  export default class WidgetTypeAround extends Plugin {
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
- }
34
+ /**
35
+ * A reference to the model widget element that has the fake caret active
36
+ * on either side of it. It is later used to remove CSS classes associated with the fake caret
37
+ * when the widget no longer needs it.
38
+ */
39
+ _currentFakeCaretModelElement = null;
42
40
  /**
43
41
  * @inheritDoc
44
42
  */
@@ -158,9 +156,9 @@ export default class WidgetTypeAround extends Plugin {
158
156
  return false;
159
157
  }
160
158
  // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {
161
- // @if CK_DEBUG_TYPING // console.info( '%c[WidgetTypeAround]%c Fake caret -> insert paragraph',
162
- // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green', ''
163
- // @if CK_DEBUG_TYPING // );
159
+ // @if CK_DEBUG_TYPING // console.info( ..._buildLogMessage( this, 'WidgetTypeAround',
160
+ // @if CK_DEBUG_TYPING // 'Fake caret -> insert paragraph',
161
+ // @if CK_DEBUG_TYPING // ) );
164
162
  // @if CK_DEBUG_TYPING // }
165
163
  const selectedModelElement = modelSelection.getSelectedElement();
166
164
  this._insertParagraph(selectedModelElement, typeAroundFakeCaretPosition);
@@ -1 +0,0 @@
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>
@@ -1 +0,0 @@
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>