@ckeditor/ckeditor5-widget 38.1.1 → 38.2.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,177 +1,177 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- import { Rect, type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils';
6
- import ResizeState from './resizerstate';
7
- import type { ResizerOptions } from '../widgetresize';
8
- declare const Resizer_base: {
9
- new (): import("@ckeditor/ckeditor5-utils").Observable;
10
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
11
- };
12
- /**
13
- * Represents a resizer for a single resizable object.
14
- */
15
- export default class Resizer extends Resizer_base {
16
- /**
17
- * Flag that indicates whether resizer can be used.
18
- *
19
- * @observable
20
- */
21
- isEnabled: boolean;
22
- /**
23
- * Flag that indicates that resizer is currently focused.
24
- *
25
- * @observable
26
- */
27
- isSelected: boolean;
28
- /**
29
- * Flag that indicates whether resizer is rendered (visible on the screen).
30
- *
31
- * @readonly
32
- * @observable
33
- */
34
- isVisible: boolean;
35
- /**
36
- * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
37
- *
38
- * Note that a new state is created for each resize transaction.
39
- */
40
- private _state;
41
- /**
42
- * A view displaying the proposed new element size during the resizing.
43
- */
44
- private _sizeView;
45
- /**
46
- * Options passed to the {@link #constructor}.
47
- */
48
- private _options;
49
- /**
50
- * A wrapper that is controlled by the resizer. This is usually a widget element.
51
- */
52
- private _viewResizerWrapper;
53
- /**
54
- * The width of the resized {@link module:widget/widgetresize~ResizerOptions#viewElement viewElement} before the resizing started.
55
- */
56
- private _initialViewWidth;
57
- /**
58
- * @param options Resizer options.
59
- */
60
- constructor(options: ResizerOptions);
61
- /**
62
- * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
63
- *
64
- * Note that a new state is created for each resize transaction.
65
- */
66
- get state(): ResizeState;
67
- /**
68
- * Makes resizer visible in the UI.
69
- */
70
- show(): void;
71
- /**
72
- * Hides resizer in the UI.
73
- */
74
- hide(): void;
75
- /**
76
- * Attaches the resizer to the DOM.
77
- */
78
- attach(): void;
79
- /**
80
- * Starts the resizing process.
81
- *
82
- * Creates a new {@link #state} for the current process.
83
- *
84
- * @fires begin
85
- * @param domResizeHandle Clicked handle.
86
- */
87
- begin(domResizeHandle: HTMLElement): void;
88
- /**
89
- * Updates the proposed size based on `domEventData`.
90
- *
91
- * @fires updateSize
92
- */
93
- updateSize(domEventData: MouseEvent): void;
94
- /**
95
- * Applies the geometry proposed with the resizer.
96
- *
97
- * @fires commit
98
- */
99
- commit(): void;
100
- /**
101
- * Cancels and rejects the proposed resize dimensions, hiding the UI.
102
- *
103
- * @fires cancel
104
- */
105
- cancel(): void;
106
- /**
107
- * Destroys the resizer.
108
- */
109
- destroy(): void;
110
- /**
111
- * Redraws the resizer.
112
- *
113
- * @param handleHostRect Handle host rectangle might be given to improve performance.
114
- */
115
- redraw(handleHostRect?: Rect): void;
116
- containsHandle(domElement: HTMLElement): boolean;
117
- static isResizeHandle(domElement: HTMLElement): boolean;
118
- /**
119
- * Cleans up the context state.
120
- */
121
- private _cleanup;
122
- /**
123
- * Calculates the proposed size as the resize handles are dragged.
124
- *
125
- * @param domEventData Event data that caused the size update request. It should be used to calculate the proposed size.
126
- */
127
- private _proposeNewSize;
128
- /**
129
- * Obtains the resize host.
130
- *
131
- * Resize host is an object that receives dimensions which are the result of resizing.
132
- */
133
- private _getResizeHost;
134
- /**
135
- * Obtains the handle host.
136
- *
137
- * Handle host is an object that the handles are aligned to.
138
- *
139
- * Handle host will not always be an entire widget itself. Take an image as an example. The image widget
140
- * contains an image and a caption. Only the image should be surrounded with handles.
141
- */
142
- private _getHandleHost;
143
- /**
144
- * DOM container of the entire resize UI.
145
- *
146
- * Note that this property will have a value only after the element bound with the resizer is rendered
147
- * (otherwise `null`).
148
- */
149
- private get _domResizerWrapper();
150
- /**
151
- * Renders the resize handles in the DOM.
152
- *
153
- * @param domElement The resizer wrapper.
154
- */
155
- private _appendHandles;
156
- /**
157
- * Sets up the {@link #_sizeView} property and adds it to the passed `domElement`.
158
- */
159
- private _appendSizeUI;
160
- }
161
- /**
162
- * @eventName ~Resizer#begin
163
- */
164
- export type ResizerBeginEvent = DecoratedMethodEvent<Resizer, 'begin'>;
165
- /**
166
- * @eventName ~Resizer#cancel
167
- */
168
- export type ResizerCancelEvent = DecoratedMethodEvent<Resizer, 'cancel'>;
169
- /**
170
- * @eventName ~Resizer#commit
171
- */
172
- export type ResizerCommitEvent = DecoratedMethodEvent<Resizer, 'commit'>;
173
- /**
174
- * @eventName ~Resizer#updateSize
175
- */
176
- export type ResizerUpdateSizeEvent = DecoratedMethodEvent<Resizer, 'updateSize'>;
177
- export {};
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
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: {
9
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
10
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
11
+ };
12
+ /**
13
+ * Represents a resizer for a single resizable object.
14
+ */
15
+ export default class Resizer extends Resizer_base {
16
+ /**
17
+ * Flag that indicates whether resizer can be used.
18
+ *
19
+ * @observable
20
+ */
21
+ isEnabled: boolean;
22
+ /**
23
+ * Flag that indicates that resizer is currently focused.
24
+ *
25
+ * @observable
26
+ */
27
+ isSelected: boolean;
28
+ /**
29
+ * Flag that indicates whether resizer is rendered (visible on the screen).
30
+ *
31
+ * @readonly
32
+ * @observable
33
+ */
34
+ isVisible: boolean;
35
+ /**
36
+ * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
37
+ *
38
+ * Note that a new state is created for each resize transaction.
39
+ */
40
+ private _state;
41
+ /**
42
+ * A view displaying the proposed new element size during the resizing.
43
+ */
44
+ private _sizeView;
45
+ /**
46
+ * Options passed to the {@link #constructor}.
47
+ */
48
+ private _options;
49
+ /**
50
+ * A wrapper that is controlled by the resizer. This is usually a widget element.
51
+ */
52
+ private _viewResizerWrapper;
53
+ /**
54
+ * The width of the resized {@link module:widget/widgetresize~ResizerOptions#viewElement viewElement} before the resizing started.
55
+ */
56
+ private _initialViewWidth;
57
+ /**
58
+ * @param options Resizer options.
59
+ */
60
+ constructor(options: ResizerOptions);
61
+ /**
62
+ * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
63
+ *
64
+ * Note that a new state is created for each resize transaction.
65
+ */
66
+ get state(): ResizeState;
67
+ /**
68
+ * Makes resizer visible in the UI.
69
+ */
70
+ show(): void;
71
+ /**
72
+ * Hides resizer in the UI.
73
+ */
74
+ hide(): void;
75
+ /**
76
+ * Attaches the resizer to the DOM.
77
+ */
78
+ attach(): void;
79
+ /**
80
+ * Starts the resizing process.
81
+ *
82
+ * Creates a new {@link #state} for the current process.
83
+ *
84
+ * @fires begin
85
+ * @param domResizeHandle Clicked handle.
86
+ */
87
+ begin(domResizeHandle: HTMLElement): void;
88
+ /**
89
+ * Updates the proposed size based on `domEventData`.
90
+ *
91
+ * @fires updateSize
92
+ */
93
+ updateSize(domEventData: MouseEvent): void;
94
+ /**
95
+ * Applies the geometry proposed with the resizer.
96
+ *
97
+ * @fires commit
98
+ */
99
+ commit(): void;
100
+ /**
101
+ * Cancels and rejects the proposed resize dimensions, hiding the UI.
102
+ *
103
+ * @fires cancel
104
+ */
105
+ cancel(): void;
106
+ /**
107
+ * Destroys the resizer.
108
+ */
109
+ destroy(): void;
110
+ /**
111
+ * Redraws the resizer.
112
+ *
113
+ * @param handleHostRect Handle host rectangle might be given to improve performance.
114
+ */
115
+ redraw(handleHostRect?: Rect): void;
116
+ containsHandle(domElement: HTMLElement): boolean;
117
+ static isResizeHandle(domElement: HTMLElement): boolean;
118
+ /**
119
+ * Cleans up the context state.
120
+ */
121
+ private _cleanup;
122
+ /**
123
+ * Calculates the proposed size as the resize handles are dragged.
124
+ *
125
+ * @param domEventData Event data that caused the size update request. It should be used to calculate the proposed size.
126
+ */
127
+ private _proposeNewSize;
128
+ /**
129
+ * Obtains the resize host.
130
+ *
131
+ * Resize host is an object that receives dimensions which are the result of resizing.
132
+ */
133
+ private _getResizeHost;
134
+ /**
135
+ * Obtains the handle host.
136
+ *
137
+ * Handle host is an object that the handles are aligned to.
138
+ *
139
+ * Handle host will not always be an entire widget itself. Take an image as an example. The image widget
140
+ * contains an image and a caption. Only the image should be surrounded with handles.
141
+ */
142
+ private _getHandleHost;
143
+ /**
144
+ * DOM container of the entire resize UI.
145
+ *
146
+ * Note that this property will have a value only after the element bound with the resizer is rendered
147
+ * (otherwise `null`).
148
+ */
149
+ private get _domResizerWrapper();
150
+ /**
151
+ * Renders the resize handles in the DOM.
152
+ *
153
+ * @param domElement The resizer wrapper.
154
+ */
155
+ private _appendHandles;
156
+ /**
157
+ * Sets up the {@link #_sizeView} property and adds it to the passed `domElement`.
158
+ */
159
+ private _appendSizeUI;
160
+ }
161
+ /**
162
+ * @eventName ~Resizer#begin
163
+ */
164
+ export type ResizerBeginEvent = DecoratedMethodEvent<Resizer, 'begin'>;
165
+ /**
166
+ * @eventName ~Resizer#cancel
167
+ */
168
+ export type ResizerCancelEvent = DecoratedMethodEvent<Resizer, 'cancel'>;
169
+ /**
170
+ * @eventName ~Resizer#commit
171
+ */
172
+ export type ResizerCommitEvent = DecoratedMethodEvent<Resizer, 'commit'>;
173
+ /**
174
+ * @eventName ~Resizer#updateSize
175
+ */
176
+ export type ResizerUpdateSizeEvent = DecoratedMethodEvent<Resizer, 'updateSize'>;
177
+ export {};