@ckeditor/ckeditor5-widget 45.2.1-alpha.9 → 46.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-widget",
3
- "version": "45.2.1-alpha.9",
3
+ "version": "46.0.0-alpha.0",
4
4
  "description": "Widget API for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,14 +12,14 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "45.2.1-alpha.9",
16
- "@ckeditor/ckeditor5-engine": "45.2.1-alpha.9",
17
- "@ckeditor/ckeditor5-enter": "45.2.1-alpha.9",
18
- "@ckeditor/ckeditor5-icons": "45.2.1-alpha.9",
19
- "@ckeditor/ckeditor5-ui": "45.2.1-alpha.9",
20
- "@ckeditor/ckeditor5-utils": "45.2.1-alpha.9",
21
- "@ckeditor/ckeditor5-typing": "45.2.1-alpha.9",
22
- "es-toolkit": "1.32.0"
15
+ "@ckeditor/ckeditor5-core": "46.0.0-alpha.0",
16
+ "@ckeditor/ckeditor5-engine": "46.0.0-alpha.0",
17
+ "@ckeditor/ckeditor5-enter": "46.0.0-alpha.0",
18
+ "@ckeditor/ckeditor5-icons": "46.0.0-alpha.0",
19
+ "@ckeditor/ckeditor5-ui": "46.0.0-alpha.0",
20
+ "@ckeditor/ckeditor5-utils": "46.0.0-alpha.0",
21
+ "@ckeditor/ckeditor5-typing": "46.0.0-alpha.0",
22
+ "es-toolkit": "1.39.5"
23
23
  },
24
24
  "author": "CKSource (http://cksource.com/)",
25
25
  "license": "SEE LICENSE IN LICENSE.md",
@@ -2,8 +2,8 @@
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
- import type { DowncastWriter, HighlightDescriptor } from '@ckeditor/ckeditor5-engine';
6
- declare const HighlightStack_base: {
5
+ import type { ViewDowncastWriter, DowncastHighlightDescriptor } from '@ckeditor/ckeditor5-engine';
6
+ declare const WidgetHighlightStack_base: {
7
7
  new (): import("@ckeditor/ckeditor5-utils").Emitter;
8
8
  prototype: import("@ckeditor/ckeditor5-utils").Emitter;
9
9
  };
@@ -14,25 +14,25 @@ declare const HighlightStack_base: {
14
14
  *
15
15
  * * highlight with highest priority should be applied,
16
16
  * * if two highlights have same priority - sort by CSS class provided in
17
- * {@link module:engine/conversion/downcasthelpers~HighlightDescriptor}.
17
+ * {@link module:engine/conversion/downcasthelpers~DowncastHighlightDescriptor}.
18
18
  *
19
19
  * This way, highlight will be applied with the same rules it is applied on texts.
20
20
  */
21
- export default class HighlightStack extends /* #__PURE__ */ HighlightStack_base {
21
+ export declare class WidgetHighlightStack extends /* #__PURE__ */ WidgetHighlightStack_base {
22
22
  private readonly _stack;
23
23
  /**
24
24
  * Adds highlight descriptor to the stack.
25
25
  *
26
26
  * @fires change:top
27
27
  */
28
- add(descriptor: HighlightDescriptor, writer: DowncastWriter): void;
28
+ add(descriptor: DowncastHighlightDescriptor, writer: ViewDowncastWriter): void;
29
29
  /**
30
30
  * Removes highlight descriptor from the stack.
31
31
  *
32
32
  * @fires change:top
33
33
  * @param id Id of the descriptor to remove.
34
34
  */
35
- remove(id: string, writer: DowncastWriter): void;
35
+ remove(id: string, writer: ViewDowncastWriter): void;
36
36
  /**
37
37
  * Inserts a given descriptor in correct place in the stack. It also takes care about updating information
38
38
  * when descriptor with same id is already present.
@@ -46,29 +46,29 @@ export default class HighlightStack extends /* #__PURE__ */ HighlightStack_base
46
46
  private _removeDescriptor;
47
47
  }
48
48
  /**
49
- * Fired when top element on {@link module:widget/highlightstack~HighlightStack} has been changed
49
+ * Fired when top element on {@link module:widget/highlightstack~WidgetHighlightStack} has been changed
50
50
  *
51
- * @eventName ~HighlightStack#change:top
51
+ * @eventName ~WidgetHighlightStack#change:top
52
52
  */
53
- export type HighlightStackChangeEvent = {
53
+ export type WidgetHighlightStackChangeEvent = {
54
54
  name: 'change' | 'change:top';
55
- args: [HighlightStackChangeEventData];
55
+ args: [WidgetHighlightStackChangeEventData];
56
56
  };
57
57
  /**
58
58
  * Additional information about the change.
59
59
  */
60
- export type HighlightStackChangeEventData = {
60
+ export type WidgetHighlightStackChangeEventData = {
61
61
  /**
62
62
  * Old highlight descriptor. It will be `undefined` when first descriptor is added to the stack.
63
63
  */
64
- oldDescriptor: HighlightDescriptor;
64
+ oldDescriptor: DowncastHighlightDescriptor;
65
65
  /**
66
66
  * New highlight descriptor. It will be `undefined` when last descriptor is removed from the stack.
67
67
  */
68
- newDescriptor: HighlightDescriptor;
68
+ newDescriptor: DowncastHighlightDescriptor;
69
69
  /**
70
70
  * View writer that can be used to modify element.
71
71
  */
72
- writer: DowncastWriter;
72
+ writer: ViewDowncastWriter;
73
73
  };
74
74
  export {};
@@ -13,11 +13,11 @@ import { EmitterMixin } from '@ckeditor/ckeditor5-utils';
13
13
  *
14
14
  * * highlight with highest priority should be applied,
15
15
  * * if two highlights have same priority - sort by CSS class provided in
16
- * {@link module:engine/conversion/downcasthelpers~HighlightDescriptor}.
16
+ * {@link module:engine/conversion/downcasthelpers~DowncastHighlightDescriptor}.
17
17
  *
18
18
  * This way, highlight will be applied with the same rules it is applied on texts.
19
19
  */
20
- export default class HighlightStack extends /* #__PURE__ */ EmitterMixin() {
20
+ export class WidgetHighlightStack extends /* #__PURE__ */ EmitterMixin() {
21
21
  _stack = [];
22
22
  /**
23
23
  * Adds highlight descriptor to the stack.
@@ -118,7 +118,7 @@ function shouldABeBeforeB(a, b) {
118
118
  return classesToString(a.classes) > classesToString(b.classes);
119
119
  }
120
120
  /**
121
- * Converts CSS classes passed with {@link module:engine/conversion/downcasthelpers~HighlightDescriptor} to
121
+ * Converts CSS classes passed with {@link module:engine/conversion/downcasthelpers~DowncastHighlightDescriptor} to
122
122
  * sorted string.
123
123
  */
124
124
  function classesToString(classes) {
package/src/index.d.ts CHANGED
@@ -5,9 +5,15 @@
5
5
  /**
6
6
  * @module widget
7
7
  */
8
- export { default as Widget } from './widget.js';
9
- export { default as WidgetToolbarRepository } from './widgettoolbarrepository.js';
10
- export { default as WidgetResize } from './widgetresize.js';
11
- export { default as WidgetTypeAround } from './widgettypearound/widgettypearound.js';
12
- export * from './utils.js';
8
+ export { Widget } from './widget.js';
9
+ export { WidgetToolbarRepository } from './widgettoolbarrepository.js';
10
+ export { WidgetResize, type WidgetResizerOptions } from './widgetresize.js';
11
+ export { WidgetTypeAround } from './widgettypearound/widgettypearound.js';
12
+ export { WIDGET_CLASS_NAME, WIDGET_SELECTED_CLASS_NAME, isWidget, toWidget, setHighlightHandling, setLabel, getLabel, toWidgetEditable, findOptimalInsertionRange, viewToModelPositionOutsideModelElement, calculateResizeHostAncestorWidth, calculateResizeHostPercentageWidth } from './utils.js';
13
+ export { WidgetHighlightStack, type WidgetHighlightStackChangeEvent, type WidgetHighlightStackChangeEventData } from './highlightstack.js';
14
+ export { verticalWidgetNavigationHandler } from './verticalnavigation.js';
15
+ export { WidgetResizeState } from './widgetresize/resizerstate.js';
16
+ export { WidgetResizer, type WidgetResizerBeginEvent, type WidgetResizerCancelEvent, type WidgetResizerCommitEvent, type WidgetResizerUpdateSizeEvent } from './widgetresize/resizer.js';
17
+ export { SizeView as _WidgetSizeView } from './widgetresize/sizeview.js';
18
+ export { TYPE_AROUND_SELECTION_ATTRIBUTE as _WIDGET_TYPE_AROUND_SELECTION_ATTRIBUTE, getClosestTypeAroundDomButton as _getClosestWidgetTypeAroundDomButton, getTypeAroundButtonPosition as _getWidgetTypeAroundButtonPosition, getClosestWidgetViewElement as _getClosestWidgetViewElement, getTypeAroundFakeCaretPosition as _getWidgetTypeAroundFakeCaretPosition, isTypeAroundWidget } from './widgettypearound/utils.js';
13
19
  import './augmentation.js';
package/src/index.js CHANGED
@@ -5,9 +5,15 @@
5
5
  /**
6
6
  * @module widget
7
7
  */
8
- export { default as Widget } from './widget.js';
9
- export { default as WidgetToolbarRepository } from './widgettoolbarrepository.js';
10
- export { default as WidgetResize } from './widgetresize.js';
11
- export { default as WidgetTypeAround } from './widgettypearound/widgettypearound.js';
12
- export * from './utils.js';
8
+ export { Widget } from './widget.js';
9
+ export { WidgetToolbarRepository } from './widgettoolbarrepository.js';
10
+ export { WidgetResize } from './widgetresize.js';
11
+ export { WidgetTypeAround } from './widgettypearound/widgettypearound.js';
12
+ export { WIDGET_CLASS_NAME, WIDGET_SELECTED_CLASS_NAME, isWidget, toWidget, setHighlightHandling, setLabel, getLabel, toWidgetEditable, findOptimalInsertionRange, viewToModelPositionOutsideModelElement, calculateResizeHostAncestorWidth, calculateResizeHostPercentageWidth } from './utils.js';
13
+ export { WidgetHighlightStack } from './highlightstack.js';
14
+ export { verticalWidgetNavigationHandler } from './verticalnavigation.js';
15
+ export { WidgetResizeState } from './widgetresize/resizerstate.js';
16
+ export { WidgetResizer } from './widgetresize/resizer.js';
17
+ export { SizeView as _WidgetSizeView } from './widgetresize/sizeview.js';
18
+ export { TYPE_AROUND_SELECTION_ATTRIBUTE as _WIDGET_TYPE_AROUND_SELECTION_ATTRIBUTE, getClosestTypeAroundDomButton as _getClosestWidgetTypeAroundDomButton, getTypeAroundButtonPosition as _getWidgetTypeAroundButtonPosition, getClosestWidgetViewElement as _getClosestWidgetViewElement, getTypeAroundFakeCaretPosition as _getWidgetTypeAroundFakeCaretPosition, isTypeAroundWidget } from './widgettypearound/utils.js';
13
19
  import './augmentation.js';
package/src/utils.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  import { Rect, type GetCallback } from '@ckeditor/ckeditor5-utils';
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';
6
+ import { type DowncastHighlightDescriptor, type MapperViewToModelPositionEvent, type ModelDocumentSelection, type ViewDowncastWriter, type Model, type ModelRange, type ModelSelection, type ViewEditableElement, type ViewElement, type ViewTypeCheckable } from '@ckeditor/ckeditor5-engine';
7
7
  /**
8
8
  * CSS class added to each widget element.
9
9
  */
@@ -13,15 +13,15 @@ export declare const WIDGET_CLASS_NAME = "ck-widget";
13
13
  */
14
14
  export declare const WIDGET_SELECTED_CLASS_NAME = "ck-widget_selected";
15
15
  /**
16
- * Returns `true` if given {@link module:engine/view/node~Node} is an {@link module:engine/view/element~Element} and a widget.
16
+ * Returns `true` if given {@link module:engine/view/node~ViewNode} is an {@link module:engine/view/element~ViewElement} and a widget.
17
17
  */
18
18
  export declare function isWidget(node: ViewTypeCheckable): boolean;
19
19
  /**
20
- * Converts the given {@link module:engine/view/element~Element} to a widget in the following way:
20
+ * Converts the given {@link module:engine/view/element~ViewElement} to a widget in the following way:
21
21
  *
22
22
  * * sets the `contenteditable` attribute to `"false"`,
23
23
  * * adds the `ck-widget` CSS class,
24
- * * adds a custom {@link module:engine/view/element~Element#getFillerOffset `getFillerOffset()`} method returning `null`,
24
+ * * adds a custom {@link module:engine/view/element~ViewElement#getFillerOffset `getFillerOffset()`} method returning `null`,
25
25
  * * adds a custom property allowing to recognize widget elements by using {@link ~isWidget `isWidget()`},
26
26
  * * implements the {@link ~setHighlightHandling view highlight on widgets}.
27
27
  *
@@ -62,15 +62,15 @@ export declare function isWidget(node: ViewTypeCheckable): boolean;
62
62
  * @param options.hasSelectionHandle If `true`, the widget will have a selection handle added.
63
63
  * @returns Returns the same element.
64
64
  */
65
- export declare function toWidget(element: ViewElement, writer: DowncastWriter, options?: {
65
+ export declare function toWidget(element: ViewElement, writer: ViewDowncastWriter, options?: {
66
66
  label?: string | (() => string);
67
67
  hasSelectionHandle?: boolean;
68
68
  }): ViewElement;
69
69
  /**
70
- * Sets highlight handling methods. Uses {@link module:widget/highlightstack~HighlightStack} to
70
+ * Sets highlight handling methods. Uses {@link module:widget/highlightstack~WidgetHighlightStack} to
71
71
  * properly determine which highlight descriptor should be used at given time.
72
72
  */
73
- export declare function setHighlightHandling(element: ViewElement, writer: DowncastWriter, add?: (element: ViewElement, descriptor: HighlightDescriptor, writer: DowncastWriter) => void, remove?: (element: ViewElement, descriptor: HighlightDescriptor, writer: DowncastWriter) => void): void;
73
+ export declare function setHighlightHandling(element: ViewElement, writer: ViewDowncastWriter, add?: (element: ViewElement, descriptor: DowncastHighlightDescriptor, writer: ViewDowncastWriter) => void, remove?: (element: ViewElement, descriptor: DowncastHighlightDescriptor, writer: ViewDowncastWriter) => void): void;
74
74
  /**
75
75
  * Sets label for given element.
76
76
  * It can be passed as a plain string or a function returning a string. Function will be called each time label is retrieved by
@@ -82,9 +82,10 @@ export declare function setLabel(element: ViewElement, labelOrCreator: string |
82
82
  */
83
83
  export declare function getLabel(element: ViewElement): string;
84
84
  /**
85
- * Adds functionality to the provided {@link module:engine/view/editableelement~EditableElement} to act as a widget's editable:
85
+ * Adds functionality to the provided {@link module:engine/view/editableelement~ViewEditableElement} to act as a widget's editable:
86
86
  *
87
- * * sets the `contenteditable` attribute to `true` when {@link module:engine/view/editableelement~EditableElement#isReadOnly} is `false`,
87
+ * * sets the `contenteditable` attribute to `true` when
88
+ * {@link module:engine/view/editableelement~ViewEditableElement#isReadOnly} is `false`,
88
89
  * otherwise sets it to `false`,
89
90
  * * adds the `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
90
91
  * * adds the `ck-editor__nested-editable_focused` CSS class when the editable is focused and removes it when it is blurred.
@@ -125,7 +126,7 @@ export declare function getLabel(element: ViewElement): string;
125
126
  * @param options.withAriaRole Whether to add the role="textbox" attribute on the editable. Defaults to `true`.
126
127
  * @returns Returns the same element that was provided in the `editable` parameter
127
128
  */
128
- export declare function toWidgetEditable(editable: ViewEditableElement, writer: DowncastWriter, options?: {
129
+ export declare function toWidgetEditable(editable: ViewEditableElement, writer: ViewDowncastWriter, options?: {
129
130
  label?: string;
130
131
  withAriaRole?: boolean;
131
132
  }): ViewEditableElement;
@@ -144,7 +145,7 @@ export declare function toWidgetEditable(editable: ViewEditableElement, writer:
144
145
  * @param model Model instance.
145
146
  * @returns The optimal range.
146
147
  */
147
- export declare function findOptimalInsertionRange(selection: Selection | DocumentSelection, model: Model): Range;
148
+ export declare function findOptimalInsertionRange(selection: ModelSelection | ModelDocumentSelection, model: Model): ModelRange;
148
149
  /**
149
150
  * A util to be used in order to map view positions to correct model positions when implementing a widget
150
151
  * which renders non-empty view element for an empty model element.
package/src/utils.js CHANGED
@@ -8,7 +8,7 @@
8
8
  import { IconDragHandle } from '@ckeditor/ckeditor5-icons';
9
9
  import { Rect, CKEditorError, toArray } from '@ckeditor/ckeditor5-utils';
10
10
  import { IconView } from '@ckeditor/ckeditor5-ui';
11
- import HighlightStack from './highlightstack.js';
11
+ import { WidgetHighlightStack } from './highlightstack.js';
12
12
  import { getTypeAroundFakeCaretPosition } from './widgettypearound/utils.js';
13
13
  /**
14
14
  * CSS class added to each widget element.
@@ -19,7 +19,7 @@ export const WIDGET_CLASS_NAME = 'ck-widget';
19
19
  */
20
20
  export const WIDGET_SELECTED_CLASS_NAME = 'ck-widget_selected';
21
21
  /**
22
- * Returns `true` if given {@link module:engine/view/node~Node} is an {@link module:engine/view/element~Element} and a widget.
22
+ * Returns `true` if given {@link module:engine/view/node~ViewNode} is an {@link module:engine/view/element~ViewElement} and a widget.
23
23
  */
24
24
  export function isWidget(node) {
25
25
  if (!node.is('element')) {
@@ -28,11 +28,11 @@ export function isWidget(node) {
28
28
  return !!node.getCustomProperty('widget');
29
29
  }
30
30
  /**
31
- * Converts the given {@link module:engine/view/element~Element} to a widget in the following way:
31
+ * Converts the given {@link module:engine/view/element~ViewElement} to a widget in the following way:
32
32
  *
33
33
  * * sets the `contenteditable` attribute to `"false"`,
34
34
  * * adds the `ck-widget` CSS class,
35
- * * adds a custom {@link module:engine/view/element~Element#getFillerOffset `getFillerOffset()`} method returning `null`,
35
+ * * adds a custom {@link module:engine/view/element~ViewElement#getFillerOffset `getFillerOffset()`} method returning `null`,
36
36
  * * adds a custom property allowing to recognize widget elements by using {@link ~isWidget `isWidget()`},
37
37
  * * implements the {@link ~setHighlightHandling view highlight on widgets}.
38
38
  *
@@ -76,7 +76,7 @@ export function isWidget(node) {
76
76
  export function toWidget(element, writer, options = {}) {
77
77
  if (!element.is('containerElement')) {
78
78
  /**
79
- * The element passed to `toWidget()` must be a {@link module:engine/view/containerelement~ContainerElement}
79
+ * The element passed to `toWidget()` must be a {@link module:engine/view/containerelement~ViewContainerElement}
80
80
  * instance.
81
81
  *
82
82
  * @error widget-to-widget-wrong-element-type
@@ -127,11 +127,11 @@ function removeHighlight(element, descriptor, writer) {
127
127
  }
128
128
  }
129
129
  /**
130
- * Sets highlight handling methods. Uses {@link module:widget/highlightstack~HighlightStack} to
130
+ * Sets highlight handling methods. Uses {@link module:widget/highlightstack~WidgetHighlightStack} to
131
131
  * properly determine which highlight descriptor should be used at given time.
132
132
  */
133
133
  export function setHighlightHandling(element, writer, add = addHighlight, remove = removeHighlight) {
134
- const stack = new HighlightStack();
134
+ const stack = new WidgetHighlightStack();
135
135
  stack.on('change:top', (evt, data) => {
136
136
  if (data.oldDescriptor) {
137
137
  remove(element, data.oldDescriptor, data.writer);
@@ -169,9 +169,10 @@ export function getLabel(element) {
169
169
  }, '');
170
170
  }
171
171
  /**
172
- * Adds functionality to the provided {@link module:engine/view/editableelement~EditableElement} to act as a widget's editable:
172
+ * Adds functionality to the provided {@link module:engine/view/editableelement~ViewEditableElement} to act as a widget's editable:
173
173
  *
174
- * * sets the `contenteditable` attribute to `true` when {@link module:engine/view/editableelement~EditableElement#isReadOnly} is `false`,
174
+ * * sets the `contenteditable` attribute to `true` when
175
+ * {@link module:engine/view/editableelement~ViewEditableElement#isReadOnly} is `false`,
175
176
  * otherwise sets it to `false`,
176
177
  * * adds the `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
177
178
  * * adds the `ck-editor__nested-editable_focused` CSS class when the editable is focused and removes it when it is blurred.
@@ -12,4 +12,4 @@ import type { EditingController, ViewDocumentArrowKeyEvent } from '@ckeditor/cke
12
12
  *
13
13
  * @param editing The editing controller.
14
14
  */
15
- export default function verticalNavigationHandler(editing: EditingController): GetCallback<ViewDocumentArrowKeyEvent>;
15
+ export declare function verticalWidgetNavigationHandler(editing: EditingController): GetCallback<ViewDocumentArrowKeyEvent>;
@@ -11,7 +11,7 @@ import { keyCodes, Rect } from '@ckeditor/ckeditor5-utils';
11
11
  *
12
12
  * @param editing The editing controller.
13
13
  */
14
- export default function verticalNavigationHandler(editing) {
14
+ export function verticalWidgetNavigationHandler(editing) {
15
15
  const model = editing.model;
16
16
  return (evt, data) => {
17
17
  const arrowUpPressed = data.keyCode == keyCodes.arrowup;
package/src/widget.d.ts CHANGED
@@ -6,9 +6,9 @@
6
6
  * @module widget/widget
7
7
  */
8
8
  import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import { type Element, type Node } from '@ckeditor/ckeditor5-engine';
9
+ import { type ModelElement, type ModelNode } from '@ckeditor/ckeditor5-engine';
10
10
  import { Delete } from '@ckeditor/ckeditor5-typing';
11
- import WidgetTypeAround from './widgettypearound/widgettypearound.js';
11
+ import { WidgetTypeAround } from './widgettypearound/widgettypearound.js';
12
12
  import '../theme/widget.css';
13
13
  /**
14
14
  * The widget plugin. It enables base support for widgets.
@@ -19,11 +19,11 @@ import '../theme/widget.css';
19
19
  *
20
20
  * * The model to view selection converter for the editing pipeline (it handles widget custom selection rendering).
21
21
  * If a converted selection wraps around a widget element, that selection is marked as
22
- * {@link module:engine/view/selection~Selection#isFake fake}. Additionally, the `ck-widget_selected` CSS class
22
+ * {@link module:engine/view/selection~ViewSelection#isFake fake}. Additionally, the `ck-widget_selected` CSS class
23
23
  * is added to indicate that widget has been selected.
24
24
  * * The mouse and keyboard events handling on and around widget elements.
25
25
  */
26
- export default class Widget extends Plugin {
26
+ export declare class Widget extends Plugin {
27
27
  /**
28
28
  * Holds previously selected widgets.
29
29
  */
@@ -45,7 +45,7 @@ export default class Widget extends Plugin {
45
45
  */
46
46
  init(): void;
47
47
  /**
48
- * Handles {@link module:engine/view/document~Document#event:mousedown mousedown} events on widget elements.
48
+ * Handles {@link module:engine/view/document~ViewDocument#event:mousedown mousedown} events on widget elements.
49
49
  */
50
50
  private _onMousedown;
51
51
  /**
@@ -53,7 +53,7 @@ export default class Widget extends Plugin {
53
53
  */
54
54
  private _selectBlockContent;
55
55
  /**
56
- * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and changes
56
+ * Handles {@link module:engine/view/document~ViewDocument#event:keydown keydown} events and changes
57
57
  * the model selection when:
58
58
  *
59
59
  * * arrow key is pressed when the widget is selected,
@@ -63,7 +63,7 @@ export default class Widget extends Plugin {
63
63
  */
64
64
  private _handleSelectionChangeOnArrowKeyPress;
65
65
  /**
66
- * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and prevents
66
+ * Handles {@link module:engine/view/document~ViewDocument#event:keydown keydown} events and prevents
67
67
  * the default browser behavior to make sure the fake selection is not being moved from a fake selection
68
68
  * container.
69
69
  *
@@ -78,20 +78,20 @@ export default class Widget extends Plugin {
78
78
  */
79
79
  private _handleDelete;
80
80
  /**
81
- * Sets {@link module:engine/model/selection~Selection document's selection} over given element.
81
+ * Sets {@link module:engine/model/selection~ModelSelection document's selection} over given element.
82
82
  *
83
83
  * @internal
84
84
  */
85
- _setSelectionOverElement(element: Node): void;
85
+ _setSelectionOverElement(element: ModelNode): void;
86
86
  /**
87
- * Checks if {@link module:engine/model/element~Element element} placed next to the current
88
- * {@link module:engine/model/selection~Selection model selection} exists and is marked in
89
- * {@link module:engine/model/schema~Schema schema} as `object`.
87
+ * Checks if {@link module:engine/model/element~ModelElement element} placed next to the current
88
+ * {@link module:engine/model/selection~ModelSelection model selection} exists and is marked in
89
+ * {@link module:engine/model/schema~ModelSchema schema} as `object`.
90
90
  *
91
91
  * @internal
92
92
  * @param forward Direction of checking.
93
93
  */
94
- _getObjectElementNextToSelection(forward: boolean): Element | null;
94
+ _getObjectElementNextToSelection(forward: boolean): ModelElement | null;
95
95
  /**
96
96
  * Removes CSS class from previously selected widgets.
97
97
  */
package/src/widget.js CHANGED
@@ -6,11 +6,11 @@
6
6
  * @module widget/widget
7
7
  */
8
8
  import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import { MouseObserver, TreeWalker } from '@ckeditor/ckeditor5-engine';
9
+ import { MouseObserver, ModelTreeWalker } from '@ckeditor/ckeditor5-engine';
10
10
  import { Delete } from '@ckeditor/ckeditor5-typing';
11
11
  import { env, keyCodes, getLocalizedArrowKeyCodeDirection, getRangeFromMouseEvent } from '@ckeditor/ckeditor5-utils';
12
- import WidgetTypeAround from './widgettypearound/widgettypearound.js';
13
- import verticalNavigationHandler from './verticalnavigation.js';
12
+ import { WidgetTypeAround } from './widgettypearound/widgettypearound.js';
13
+ import { verticalWidgetNavigationHandler } from './verticalnavigation.js';
14
14
  import { getLabel, isWidget, WIDGET_SELECTED_CLASS_NAME } from './utils.js';
15
15
  import '../theme/widget.css';
16
16
  /**
@@ -22,11 +22,11 @@ import '../theme/widget.css';
22
22
  *
23
23
  * * The model to view selection converter for the editing pipeline (it handles widget custom selection rendering).
24
24
  * If a converted selection wraps around a widget element, that selection is marked as
25
- * {@link module:engine/view/selection~Selection#isFake fake}. Additionally, the `ck-widget_selected` CSS class
25
+ * {@link module:engine/view/selection~ViewSelection#isFake fake}. Additionally, the `ck-widget_selected` CSS class
26
26
  * is added to indicate that widget has been selected.
27
27
  * * The mouse and keyboard events handling on and around widget elements.
28
28
  */
29
- export default class Widget extends Plugin {
29
+ export class Widget extends Plugin {
30
30
  /**
31
31
  * Holds previously selected widgets.
32
32
  */
@@ -141,7 +141,7 @@ export default class Widget extends Plugin {
141
141
  this.listenTo(viewDocument, 'arrowKey', (...args) => {
142
142
  this._preventDefaultOnArrowKeyPress(...args);
143
143
  }, { context: '$root' });
144
- this.listenTo(viewDocument, 'arrowKey', verticalNavigationHandler(this.editor.editing), { context: '$text' });
144
+ this.listenTo(viewDocument, 'arrowKey', verticalWidgetNavigationHandler(this.editor.editing), { context: '$text' });
145
145
  // Handle custom delete behaviour.
146
146
  this.listenTo(viewDocument, 'delete', (evt, data) => {
147
147
  if (this._handleDelete(data.direction == 'forward')) {
@@ -213,7 +213,7 @@ export default class Widget extends Plugin {
213
213
  });
214
214
  }
215
215
  /**
216
- * Handles {@link module:engine/view/document~Document#event:mousedown mousedown} events on widget elements.
216
+ * Handles {@link module:engine/view/document~ViewDocument#event:mousedown mousedown} events on widget elements.
217
217
  */
218
218
  _onMousedown(eventInfo, domEventData) {
219
219
  const editor = this.editor;
@@ -290,7 +290,7 @@ export default class Widget extends Plugin {
290
290
  return true;
291
291
  }
292
292
  /**
293
- * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and changes
293
+ * Handles {@link module:engine/view/document~ViewDocument#event:keydown keydown} events and changes
294
294
  * the model selection when:
295
295
  *
296
296
  * * arrow key is pressed when the widget is selected,
@@ -353,7 +353,7 @@ export default class Widget extends Plugin {
353
353
  }
354
354
  }
355
355
  /**
356
- * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and prevents
356
+ * Handles {@link module:engine/view/document~ViewDocument#event:keydown keydown} events and prevents
357
357
  * the default browser behavior to make sure the fake selection is not being moved from a fake selection
358
358
  * container.
359
359
  *
@@ -402,7 +402,7 @@ export default class Widget extends Plugin {
402
402
  }
403
403
  }
404
404
  /**
405
- * Sets {@link module:engine/model/selection~Selection document's selection} over given element.
405
+ * Sets {@link module:engine/model/selection~ModelSelection document's selection} over given element.
406
406
  *
407
407
  * @internal
408
408
  */
@@ -412,9 +412,9 @@ export default class Widget extends Plugin {
412
412
  });
413
413
  }
414
414
  /**
415
- * Checks if {@link module:engine/model/element~Element element} placed next to the current
416
- * {@link module:engine/model/selection~Selection model selection} exists and is marked in
417
- * {@link module:engine/model/schema~Schema schema} as `object`.
415
+ * Checks if {@link module:engine/model/element~ModelElement element} placed next to the current
416
+ * {@link module:engine/model/selection~ModelSelection model selection} exists and is marked in
417
+ * {@link module:engine/model/schema~ModelSchema schema} as `object`.
418
418
  *
419
419
  * @internal
420
420
  * @param forward Direction of checking.
@@ -587,7 +587,7 @@ function findTextBlockAncestor(modelElement, schema) {
587
587
  * Returns next text block where could put selection.
588
588
  */
589
589
  function findNextTextBlock(position, schema) {
590
- const treeWalker = new TreeWalker({ startPosition: position });
590
+ const treeWalker = new ModelTreeWalker({ startPosition: position });
591
591
  for (const { item } of treeWalker) {
592
592
  if (schema.isLimit(item) || !item.is('element')) {
593
593
  return null;
@@ -3,16 +3,16 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  import { Rect, type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils';
6
- import ResizeState from './resizerstate.js';
7
- import type { ResizerOptions } from '../widgetresize.js';
8
- declare const Resizer_base: {
6
+ import { WidgetResizeState } from './resizerstate.js';
7
+ import type { WidgetResizerOptions } from '../widgetresize.js';
8
+ declare const WidgetResizer_base: {
9
9
  new (): import("@ckeditor/ckeditor5-utils").Observable;
10
10
  prototype: import("@ckeditor/ckeditor5-utils").Observable;
11
11
  };
12
12
  /**
13
13
  * Represents a resizer for a single resizable object.
14
14
  */
15
- export default class Resizer extends /* #__PURE__ */ Resizer_base {
15
+ export declare class WidgetResizer extends /* #__PURE__ */ WidgetResizer_base {
16
16
  /**
17
17
  * Flag that indicates whether resizer can be used.
18
18
  *
@@ -51,19 +51,19 @@ export default class Resizer extends /* #__PURE__ */ Resizer_base {
51
51
  */
52
52
  private _viewResizerWrapper;
53
53
  /**
54
- * The width of the resized {@link module:widget/widgetresize~ResizerOptions#viewElement viewElement} before the resizing started.
54
+ * The width of the resized {@link module:widget/widgetresize~WidgetResizerOptions#viewElement viewElement} before the resizing started.
55
55
  */
56
56
  private _initialViewWidth;
57
57
  /**
58
58
  * @param options Resizer options.
59
59
  */
60
- constructor(options: ResizerOptions);
60
+ constructor(options: WidgetResizerOptions);
61
61
  /**
62
62
  * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
63
63
  *
64
64
  * Note that a new state is created for each resize transaction.
65
65
  */
66
- get state(): ResizeState;
66
+ get state(): WidgetResizeState;
67
67
  /**
68
68
  * Makes resizer visible in the UI.
69
69
  */
@@ -159,19 +159,19 @@ export default class Resizer extends /* #__PURE__ */ Resizer_base {
159
159
  private _appendSizeUI;
160
160
  }
161
161
  /**
162
- * @eventName ~Resizer#begin
162
+ * @eventName ~WidgetResizer#begin
163
163
  */
164
- export type ResizerBeginEvent = DecoratedMethodEvent<Resizer, 'begin'>;
164
+ export type WidgetResizerBeginEvent = DecoratedMethodEvent<WidgetResizer, 'begin'>;
165
165
  /**
166
- * @eventName ~Resizer#cancel
166
+ * @eventName ~WidgetResizer#cancel
167
167
  */
168
- export type ResizerCancelEvent = DecoratedMethodEvent<Resizer, 'cancel'>;
168
+ export type WidgetResizerCancelEvent = DecoratedMethodEvent<WidgetResizer, 'cancel'>;
169
169
  /**
170
- * @eventName ~Resizer#commit
170
+ * @eventName ~WidgetResizer#commit
171
171
  */
172
- export type ResizerCommitEvent = DecoratedMethodEvent<Resizer, 'commit'>;
172
+ export type WidgetResizerCommitEvent = DecoratedMethodEvent<WidgetResizer, 'commit'>;
173
173
  /**
174
- * @eventName ~Resizer#updateSize
174
+ * @eventName ~WidgetResizer#updateSize
175
175
  */
176
- export type ResizerUpdateSizeEvent = DecoratedMethodEvent<Resizer, 'updateSize'>;
176
+ export type WidgetResizerUpdateSizeEvent = DecoratedMethodEvent<WidgetResizer, 'updateSize'>;
177
177
  export {};
@@ -7,12 +7,12 @@
7
7
  */
8
8
  import { Template } from '@ckeditor/ckeditor5-ui';
9
9
  import { Rect, ObservableMixin, compareArrays } from '@ckeditor/ckeditor5-utils';
10
- import ResizeState from './resizerstate.js';
11
- import SizeView from './sizeview.js';
10
+ import { WidgetResizeState } from './resizerstate.js';
11
+ import { SizeView } from './sizeview.js';
12
12
  /**
13
13
  * Represents a resizer for a single resizable object.
14
14
  */
15
- export default class Resizer extends /* #__PURE__ */ ObservableMixin() {
15
+ export class WidgetResizer extends /* #__PURE__ */ ObservableMixin() {
16
16
  /**
17
17
  * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
18
18
  *
@@ -32,7 +32,7 @@ export default class Resizer extends /* #__PURE__ */ ObservableMixin() {
32
32
  */
33
33
  _viewResizerWrapper = null;
34
34
  /**
35
- * The width of the resized {@link module:widget/widgetresize~ResizerOptions#viewElement viewElement} before the resizing started.
35
+ * The width of the resized {@link module:widget/widgetresize~WidgetResizerOptions#viewElement viewElement} before the resizing started.
36
36
  */
37
37
  _initialViewWidth;
38
38
  /**
@@ -127,7 +127,7 @@ export default class Resizer extends /* #__PURE__ */ ObservableMixin() {
127
127
  * @param domResizeHandle Clicked handle.
128
128
  */
129
129
  begin(domResizeHandle) {
130
- this._state = new ResizeState(this._options);
130
+ this._state = new WidgetResizeState(this._options);
131
131
  this._sizeView._bindToState(this._options, this.state);
132
132
  this._initialViewWidth = this._options.viewElement.getStyle('width');
133
133
  this.state.begin(domResizeHandle, this._getHandleHost(), this._getResizeHost());