@ckeditor/ckeditor5-widget 48.2.0 → 48.3.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.
@@ -1,125 +1,126 @@
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
- */
5
- import type { WidgetResizerOptions } from '../widgetresize.js';
6
- declare const WidgetResizeState_base: {
7
- new (): import("@ckeditor/ckeditor5-utils").Observable;
8
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
9
- };
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
+ */
10
5
  /**
11
- * Stores the internal state of a single resizable object.
12
- */
13
- export declare class WidgetResizeState extends /* #__PURE__ */ WidgetResizeState_base {
14
- /**
15
- * The position of the handle that initiated the resizing. E.g. `"top-left"`, `"bottom-right"` etc. or `null`
16
- * if unknown.
17
- *
18
- * @readonly
19
- * @observable
20
- */
21
- activeHandlePosition: string | null;
22
- /**
23
- * The width (percents) proposed, but not committed yet, in the current resize process.
24
- *
25
- * @readonly
26
- * @observable
27
- */
28
- proposedWidthPercents: number | null;
29
- /**
30
- * The width (pixels) proposed, but not committed yet, in the current resize process.
31
- *
32
- * @readonly
33
- * @observable
34
- */
35
- proposedWidth: number | null;
36
- /**
37
- * The height (pixels) proposed, but not committed yet, in the current resize process.
38
- *
39
- * @readonly
40
- * @observable
41
- */
42
- proposedHeight: number | null;
43
- /**
44
- * @readonly
45
- * @observable
46
- */
47
- proposedHandleHostWidth: number | null;
48
- /**
49
- * @readonly
50
- * @observable
51
- */
52
- proposedHandleHostHeight: number | null;
53
- /**
54
- * The reference point of the resizer where the dragging started. It is used to measure the distance the user cursor
55
- * traveled, so how much the image should be enlarged.
56
- * This information is only known after the DOM was rendered, so it will be updated later.
57
- *
58
- * @internal
59
- */
60
- _referenceCoordinates: {
61
- x: number;
62
- y: number;
63
- } | null;
64
- /**
65
- * Resizer options.
66
- */
67
- private readonly _options;
68
- /**
69
- * The original width (pixels) of the resized object when the resize process was started.
70
- *
71
- * @readonly
72
- */
73
- private _originalWidth?;
74
- /**
75
- * The original height (pixels) of the resized object when the resize process was started.
76
- *
77
- * @readonly
78
- */
79
- private _originalHeight?;
80
- /**
81
- * The original width (percents) of the resized object when the resize process was started.
82
- *
83
- * @readonly
84
- */
85
- private _originalWidthPercents?;
86
- /**
87
- * A width to height ratio of the resized image.
88
- *
89
- * @readonly
90
- */
91
- private _aspectRatio?;
92
- /**
93
- * @param options Resizer options.
94
- */
95
- constructor(options: WidgetResizerOptions);
96
- /**
97
- * The original width (pixels) of the resized object when the resize process was started.
98
- */
99
- get originalWidth(): number | undefined;
100
- /**
101
- * The original height (pixels) of the resized object when the resize process was started.
102
- */
103
- get originalHeight(): number | undefined;
104
- /**
105
- * The original width (percents) of the resized object when the resize process was started.
106
- */
107
- get originalWidthPercents(): number | undefined;
108
- /**
109
- * A width to height ratio of the resized image.
110
- */
111
- get aspectRatio(): number | undefined;
112
- /**
113
- *
114
- * @param domResizeHandle The handle used to calculate the reference point.
115
- */
116
- begin(domResizeHandle: HTMLElement, domHandleHost: HTMLElement, domResizeHost: HTMLElement): void;
117
- update(newSize: {
118
- width: number;
119
- height: number;
120
- widthPercents: number;
121
- handleHostWidth: number;
122
- handleHostHeight: number;
123
- }): void;
6
+ * @module widget/widgetresize/resizerstate
7
+ */
8
+ import { type ObservableMixinConstructor } from "@ckeditor/ckeditor5-utils";
9
+ import type { WidgetResizerOptions } from "../widgetresize.js";
10
+ declare const WidgetResizeStateBase: ObservableMixinConstructor;
11
+ /**
12
+ * Stores the internal state of a single resizable object.
13
+ */
14
+ export declare class WidgetResizeState extends WidgetResizeStateBase {
15
+ /**
16
+ * The position of the handle that initiated the resizing. E.g. `"top-left"`, `"bottom-right"` etc. or `null`
17
+ * if unknown.
18
+ *
19
+ * @readonly
20
+ * @observable
21
+ */
22
+ activeHandlePosition: string | null;
23
+ /**
24
+ * The width (percents) proposed, but not committed yet, in the current resize process.
25
+ *
26
+ * @readonly
27
+ * @observable
28
+ */
29
+ proposedWidthPercents: number | null;
30
+ /**
31
+ * The width (pixels) proposed, but not committed yet, in the current resize process.
32
+ *
33
+ * @readonly
34
+ * @observable
35
+ */
36
+ proposedWidth: number | null;
37
+ /**
38
+ * The height (pixels) proposed, but not committed yet, in the current resize process.
39
+ *
40
+ * @readonly
41
+ * @observable
42
+ */
43
+ proposedHeight: number | null;
44
+ /**
45
+ * @readonly
46
+ * @observable
47
+ */
48
+ proposedHandleHostWidth: number | null;
49
+ /**
50
+ * @readonly
51
+ * @observable
52
+ */
53
+ proposedHandleHostHeight: number | null;
54
+ /**
55
+ * The reference point of the resizer where the dragging started. It is used to measure the distance the user cursor
56
+ * traveled, so how much the image should be enlarged.
57
+ * This information is only known after the DOM was rendered, so it will be updated later.
58
+ *
59
+ * @internal
60
+ */
61
+ _referenceCoordinates: {
62
+ x: number;
63
+ y: number;
64
+ } | null;
65
+ /**
66
+ * Resizer options.
67
+ */
68
+ private readonly _options;
69
+ /**
70
+ * The original width (pixels) of the resized object when the resize process was started.
71
+ *
72
+ * @readonly
73
+ */
74
+ private _originalWidth?;
75
+ /**
76
+ * The original height (pixels) of the resized object when the resize process was started.
77
+ *
78
+ * @readonly
79
+ */
80
+ private _originalHeight?;
81
+ /**
82
+ * The original width (percents) of the resized object when the resize process was started.
83
+ *
84
+ * @readonly
85
+ */
86
+ private _originalWidthPercents?;
87
+ /**
88
+ * A width to height ratio of the resized image.
89
+ *
90
+ * @readonly
91
+ */
92
+ private _aspectRatio?;
93
+ /**
94
+ * @param options Resizer options.
95
+ */
96
+ constructor(options: WidgetResizerOptions);
97
+ /**
98
+ * The original width (pixels) of the resized object when the resize process was started.
99
+ */
100
+ get originalWidth(): number | undefined;
101
+ /**
102
+ * The original height (pixels) of the resized object when the resize process was started.
103
+ */
104
+ get originalHeight(): number | undefined;
105
+ /**
106
+ * The original width (percents) of the resized object when the resize process was started.
107
+ */
108
+ get originalWidthPercents(): number | undefined;
109
+ /**
110
+ * A width to height ratio of the resized image.
111
+ */
112
+ get aspectRatio(): number | undefined;
113
+ /**
114
+ *
115
+ * @param domResizeHandle The handle used to calculate the reference point.
116
+ */
117
+ begin(domResizeHandle: HTMLElement, domHandleHost: HTMLElement, domResizeHost: HTMLElement): void;
118
+ update(newSize: {
119
+ width: number;
120
+ height: number;
121
+ widthPercents: number;
122
+ handleHostWidth: number;
123
+ handleHostHeight: number;
124
+ }): void;
124
125
  }
125
126
  export {};
@@ -1,57 +1,57 @@
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 widget/widgetresize/sizeview
7
- */
8
- import { View } from '@ckeditor/ckeditor5-ui';
9
- import type { WidgetResizerOptions } from '../widgetresize.js';
10
- import { type WidgetResizeState } from './resizerstate.js';
6
+ * @module widget/widgetresize/sizeview
7
+ */
8
+ import { View } from "@ckeditor/ckeditor5-ui";
9
+ import type { WidgetResizerOptions } from "../widgetresize.js";
10
+ import { type WidgetResizeState } from "./resizerstate.js";
11
11
  /**
12
- * A view displaying the proposed new element size during the resizing.
13
- *
14
- * @internal
15
- */
12
+ * A view displaying the proposed new element size during the resizing.
13
+ *
14
+ * @internal
15
+ */
16
16
  export declare class SizeView extends View {
17
- /**
18
- * The visibility of the view defined based on the existence of the host proposed dimensions.
19
- *
20
- * @internal
21
- * @observable
22
- * @readonly
23
- */
24
- _isVisible: boolean;
25
- /**
26
- * The text that will be displayed in the `SizeView` child.
27
- * It can be formatted as the pixel values (e.g. 10x20) or the percentage value (e.g. 10%).
28
- *
29
- * @internal
30
- * @observable
31
- * @readonly
32
- */
33
- _label: string;
34
- /**
35
- * The position of the view defined based on the host size and active handle position.
36
- *
37
- * @internal
38
- * @observable
39
- * @readonly
40
- */
41
- _viewPosition: string;
42
- constructor();
43
- /**
44
- * A method used for binding the `SizeView` instance properties to the `ResizeState` instance observable properties.
45
- *
46
- * @internal
47
- * @param options An object defining the resizer options, used for setting the proper size label.
48
- * @param resizeState The `ResizeState` class instance, used for keeping the `SizeView` state up to date.
49
- */
50
- _bindToState(options: WidgetResizerOptions, resizeState: WidgetResizeState): void;
51
- /**
52
- * A method used for cleaning up. It removes the bindings and hides the view.
53
- *
54
- * @internal
55
- */
56
- _dismiss(): void;
17
+ /**
18
+ * The visibility of the view defined based on the existence of the host proposed dimensions.
19
+ *
20
+ * @internal
21
+ * @observable
22
+ * @readonly
23
+ */
24
+ _isVisible: boolean;
25
+ /**
26
+ * The text that will be displayed in the `SizeView` child.
27
+ * It can be formatted as the pixel values (e.g. 10x20) or the percentage value (e.g. 10%).
28
+ *
29
+ * @internal
30
+ * @observable
31
+ * @readonly
32
+ */
33
+ _label: string;
34
+ /**
35
+ * The position of the view defined based on the host size and active handle position.
36
+ *
37
+ * @internal
38
+ * @observable
39
+ * @readonly
40
+ */
41
+ _viewPosition: string;
42
+ constructor();
43
+ /**
44
+ * A method used for binding the `SizeView` instance properties to the `ResizeState` instance observable properties.
45
+ *
46
+ * @internal
47
+ * @param options An object defining the resizer options, used for setting the proper size label.
48
+ * @param resizeState The `ResizeState` class instance, used for keeping the `SizeView` state up to date.
49
+ */
50
+ _bindToState(options: WidgetResizerOptions, resizeState: WidgetResizeState): void;
51
+ /**
52
+ * A method used for cleaning up. It removes the bindings and hides the view.
53
+ *
54
+ * @internal
55
+ */
56
+ _dismiss(): void;
57
57
  }
@@ -1,129 +1,129 @@
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 widget/widgetresize
7
- */
8
- import { WidgetResizer } from './widgetresize/resizer.js';
9
- import { Plugin, type Editor } from '@ckeditor/ckeditor5-core';
10
- import { type ModelElement, type ViewContainerElement } from '@ckeditor/ckeditor5-engine';
11
- import '../theme/widgetresize.css';
6
+ * @module widget/widgetresize
7
+ */
8
+ import { WidgetResizer } from "./widgetresize/resizer.js";
9
+ import { Plugin, type Editor } from "@ckeditor/ckeditor5-core";
10
+ import { type ModelElement, type ViewContainerElement } from "@ckeditor/ckeditor5-engine";
11
+ import "../theme/widgetresize.css";
12
12
  /**
13
- * The widget resize feature plugin.
14
- *
15
- * Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
16
- */
13
+ * The widget resize feature plugin.
14
+ *
15
+ * Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
16
+ */
17
17
  export declare class WidgetResize extends Plugin {
18
- /**
19
- * The currently selected resizer.
20
- *
21
- * @observable
22
- */
23
- selectedResizer: WidgetResizer | null;
24
- /**
25
- * References an active resizer.
26
- *
27
- * Active resizer means a resizer which handle is actively used by the end user.
28
- *
29
- * @internal
30
- * @observable
31
- */
32
- _activeResizer: WidgetResizer | null;
33
- /**
34
- * A map of resizers created using this plugin instance.
35
- */
36
- private _resizers;
37
- private _observer;
38
- private _redrawSelectedResizerThrottled;
39
- /**
40
- * @inheritDoc
41
- */
42
- static get pluginName(): "WidgetResize";
43
- /**
44
- * @inheritDoc
45
- */
46
- static get isOfficialPlugin(): true;
47
- /**
48
- * @inheritDoc
49
- */
50
- init(): void;
51
- /**
52
- * Redraws the selected resizer if there is any selected resizer and if it is visible.
53
- */
54
- redrawSelectedResizer(): void;
55
- /**
56
- * @inheritDoc
57
- */
58
- destroy(): void;
59
- /**
60
- * Marks resizer as selected.
61
- */
62
- select(resizer: WidgetResizer): void;
63
- /**
64
- * Deselects currently set resizer.
65
- */
66
- deselect(): void;
67
- /**
68
- * @param options Resizer options.
69
- */
70
- attachTo(options: WidgetResizerOptions): WidgetResizer;
71
- /**
72
- * Returns a resizer created for a given view element (widget element).
73
- *
74
- * @param viewElement View element associated with the resizer.
75
- */
76
- getResizerByViewElement(viewElement: ViewContainerElement): WidgetResizer | undefined;
77
- /**
78
- * Returns a resizer that contains a given resize handle.
79
- */
80
- private _getResizerByHandle;
81
- /**
82
- * @param domEventData Native DOM event.
83
- */
84
- private _mouseDownListener;
85
- /**
86
- * @param domEventData Native DOM event.
87
- */
88
- private _mouseMoveListener;
89
- private _mouseUpListener;
18
+ /**
19
+ * The currently selected resizer.
20
+ *
21
+ * @observable
22
+ */
23
+ selectedResizer: WidgetResizer | null;
24
+ /**
25
+ * References an active resizer.
26
+ *
27
+ * Active resizer means a resizer which handle is actively used by the end user.
28
+ *
29
+ * @internal
30
+ * @observable
31
+ */
32
+ _activeResizer: WidgetResizer | null;
33
+ /**
34
+ * A map of resizers created using this plugin instance.
35
+ */
36
+ private _resizers;
37
+ private _observer;
38
+ private _redrawSelectedResizerThrottled;
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ static get pluginName(): "WidgetResize";
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ static override get isOfficialPlugin(): true;
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ init(): void;
51
+ /**
52
+ * Redraws the selected resizer if there is any selected resizer and if it is visible.
53
+ */
54
+ redrawSelectedResizer(): void;
55
+ /**
56
+ * @inheritDoc
57
+ */
58
+ override destroy(): void;
59
+ /**
60
+ * Marks resizer as selected.
61
+ */
62
+ select(resizer: WidgetResizer): void;
63
+ /**
64
+ * Deselects currently set resizer.
65
+ */
66
+ deselect(): void;
67
+ /**
68
+ * @param options Resizer options.
69
+ */
70
+ attachTo(options: WidgetResizerOptions): WidgetResizer;
71
+ /**
72
+ * Returns a resizer created for a given view element (widget element).
73
+ *
74
+ * @param viewElement View element associated with the resizer.
75
+ */
76
+ getResizerByViewElement(viewElement: ViewContainerElement): WidgetResizer | undefined;
77
+ /**
78
+ * Returns a resizer that contains a given resize handle.
79
+ */
80
+ private _getResizerByHandle;
81
+ /**
82
+ * @param domEventData Native DOM event.
83
+ */
84
+ private _mouseDownListener;
85
+ /**
86
+ * @param domEventData Native DOM event.
87
+ */
88
+ private _mouseMoveListener;
89
+ private _mouseUpListener;
90
90
  }
91
91
  /**
92
- * Interface describing a resizer. It allows to specify the resizing host, custom logic for calculating aspect ratio, etc.
93
- */
92
+ * Interface describing a resizer. It allows to specify the resizing host, custom logic for calculating aspect ratio, etc.
93
+ */
94
94
  export interface WidgetResizerOptions {
95
- /**
96
- * Editor instance associated with the resizer.
97
- */
98
- editor: Editor;
99
- modelElement: ModelElement;
100
- /**
101
- * A view of an element to be resized. Typically it's the main widget's view instance.
102
- */
103
- viewElement: ViewContainerElement;
104
- unit?: 'px' | '%';
105
- /**
106
- * A callback to be executed once the resizing process is done.
107
- *
108
- * It receives a `Number` (`newValue`) as a parameter.
109
- *
110
- * For example, {@link module:image/imageresize~ImageResize} uses it to execute the resize image command
111
- * which puts the new value into the model.
112
- *
113
- * ```ts
114
- * {
115
- * editor,
116
- * modelElement: data.item,
117
- * viewElement: widget,
118
- *
119
- * onCommit( newValue ) {
120
- * editor.execute( 'resizeImage', { width: newValue } );
121
- * }
122
- * };
123
- * ```
124
- */
125
- onCommit: (newValue: string) => void;
126
- getResizeHost: (widgetWrapper: HTMLElement) => HTMLElement;
127
- getHandleHost: (widgetWrapper: HTMLElement) => HTMLElement;
128
- isCentered?: (resizer: WidgetResizer) => boolean;
95
+ /**
96
+ * Editor instance associated with the resizer.
97
+ */
98
+ editor: Editor;
99
+ modelElement: ModelElement;
100
+ /**
101
+ * A view of an element to be resized. Typically it's the main widget's view instance.
102
+ */
103
+ viewElement: ViewContainerElement;
104
+ unit?: "px" | "%";
105
+ /**
106
+ * A callback to be executed once the resizing process is done.
107
+ *
108
+ * It receives a `Number` (`newValue`) as a parameter.
109
+ *
110
+ * For example, {@link module:image/imageresize~ImageResize} uses it to execute the resize image command
111
+ * which puts the new value into the model.
112
+ *
113
+ * ```ts
114
+ * {
115
+ * editor,
116
+ * modelElement: data.item,
117
+ * viewElement: widget,
118
+ *
119
+ * onCommit( newValue ) {
120
+ * editor.execute( 'resizeImage', { width: newValue } );
121
+ * }
122
+ * };
123
+ * ```
124
+ */
125
+ onCommit: (newValue: string) => void;
126
+ getResizeHost: (widgetWrapper: HTMLElement) => HTMLElement;
127
+ getHandleHost: (widgetWrapper: HTMLElement) => HTMLElement;
128
+ isCentered?: (resizer: WidgetResizer) => boolean;
129
129
  }