@ckeditor/ckeditor5-widget 41.1.0 → 41.3.0-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. package/dist/content-index.css +4 -0
  2. package/dist/editor-index.css +144 -0
  3. package/dist/index.css +257 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.js +2979 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/types/augmentation.d.ts +13 -0
  8. package/dist/types/highlightstack.d.ts +74 -0
  9. package/dist/types/index.d.ts +13 -0
  10. package/dist/types/utils.d.ts +198 -0
  11. package/dist/types/verticalnavigation.d.ts +15 -0
  12. package/dist/types/widget.d.ts +95 -0
  13. package/dist/types/widgetresize/resizer.d.ts +177 -0
  14. package/dist/types/widgetresize/resizerstate.d.ts +125 -0
  15. package/dist/types/widgetresize/sizeview.d.ts +55 -0
  16. package/dist/types/widgetresize.d.ts +125 -0
  17. package/dist/types/widgettoolbarrepository.d.ts +94 -0
  18. package/dist/types/widgettypearound/utils.d.ts +38 -0
  19. package/dist/types/widgettypearound/widgettypearound.d.ts +229 -0
  20. package/lang/contexts.json +6 -1
  21. package/lang/translations/ar.po +21 -1
  22. package/lang/translations/az.po +21 -1
  23. package/lang/translations/bg.po +21 -1
  24. package/lang/translations/bn.po +21 -1
  25. package/lang/translations/ca.po +21 -1
  26. package/lang/translations/cs.po +21 -1
  27. package/lang/translations/da.po +21 -1
  28. package/lang/translations/de-ch.po +21 -1
  29. package/lang/translations/de.po +21 -1
  30. package/lang/translations/el.po +21 -1
  31. package/lang/translations/en-au.po +21 -1
  32. package/lang/translations/en.po +21 -1
  33. package/lang/translations/es.po +21 -1
  34. package/lang/translations/et.po +21 -1
  35. package/lang/translations/fa.po +21 -1
  36. package/lang/translations/fi.po +21 -1
  37. package/lang/translations/fr.po +21 -1
  38. package/lang/translations/gl.po +21 -1
  39. package/lang/translations/he.po +22 -2
  40. package/lang/translations/hi.po +21 -1
  41. package/lang/translations/hr.po +21 -1
  42. package/lang/translations/hu.po +21 -1
  43. package/lang/translations/id.po +21 -1
  44. package/lang/translations/it.po +21 -1
  45. package/lang/translations/ja.po +21 -1
  46. package/lang/translations/ko.po +21 -1
  47. package/lang/translations/ku.po +21 -1
  48. package/lang/translations/lt.po +21 -1
  49. package/lang/translations/lv.po +21 -1
  50. package/lang/translations/ms.po +21 -1
  51. package/lang/translations/nl.po +21 -1
  52. package/lang/translations/no.po +21 -1
  53. package/lang/translations/pl.po +21 -1
  54. package/lang/translations/pt-br.po +21 -1
  55. package/lang/translations/pt.po +21 -1
  56. package/lang/translations/ro.po +21 -1
  57. package/lang/translations/ru.po +21 -1
  58. package/lang/translations/sk.po +21 -1
  59. package/lang/translations/sq.po +21 -1
  60. package/lang/translations/sr-latn.po +21 -1
  61. package/lang/translations/sr.po +21 -1
  62. package/lang/translations/sv.po +21 -1
  63. package/lang/translations/th.po +21 -1
  64. package/lang/translations/tk.po +21 -1
  65. package/lang/translations/tr.po +21 -1
  66. package/lang/translations/uk.po +21 -1
  67. package/lang/translations/ur.po +21 -1
  68. package/lang/translations/uz.po +21 -1
  69. package/lang/translations/vi.po +21 -1
  70. package/lang/translations/zh-cn.po +21 -1
  71. package/lang/translations/zh.po +21 -1
  72. package/package.json +8 -7
  73. package/src/widget.js +24 -0
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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 type { Widget, WidgetResize, WidgetToolbarRepository, WidgetTypeAround } from './index.js';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface PluginsMap {
8
+ [Widget.pluginName]: Widget;
9
+ [WidgetResize.pluginName]: WidgetResize;
10
+ [WidgetToolbarRepository.pluginName]: WidgetToolbarRepository;
11
+ [WidgetTypeAround.pluginName]: WidgetTypeAround;
12
+ }
13
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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 type { DowncastWriter, HighlightDescriptor } from '@ckeditor/ckeditor5-engine';
6
+ declare const HighlightStack_base: {
7
+ new (): import("@ckeditor/ckeditor5-utils").Emitter;
8
+ prototype: import("@ckeditor/ckeditor5-utils").Emitter;
9
+ };
10
+ /**
11
+ * Class used to handle the correct order of highlights on elements.
12
+ *
13
+ * When different highlights are applied to same element the correct order should be preserved:
14
+ *
15
+ * * highlight with highest priority should be applied,
16
+ * * if two highlights have same priority - sort by CSS class provided in
17
+ * {@link module:engine/conversion/downcasthelpers~HighlightDescriptor}.
18
+ *
19
+ * This way, highlight will be applied with the same rules it is applied on texts.
20
+ */
21
+ export default class HighlightStack extends HighlightStack_base {
22
+ private readonly _stack;
23
+ /**
24
+ * Adds highlight descriptor to the stack.
25
+ *
26
+ * @fires change:top
27
+ */
28
+ add(descriptor: HighlightDescriptor, writer: DowncastWriter): void;
29
+ /**
30
+ * Removes highlight descriptor from the stack.
31
+ *
32
+ * @fires change:top
33
+ * @param id Id of the descriptor to remove.
34
+ */
35
+ remove(id: string, writer: DowncastWriter): void;
36
+ /**
37
+ * Inserts a given descriptor in correct place in the stack. It also takes care about updating information
38
+ * when descriptor with same id is already present.
39
+ */
40
+ private _insertDescriptor;
41
+ /**
42
+ * Removes descriptor with given id from the stack.
43
+ *
44
+ * @param id Descriptor's id.
45
+ */
46
+ private _removeDescriptor;
47
+ }
48
+ /**
49
+ * Fired when top element on {@link module:widget/highlightstack~HighlightStack} has been changed
50
+ *
51
+ * @eventName ~HighlightStack#change:top
52
+ */
53
+ export type HighlightStackChangeEvent = {
54
+ name: 'change' | 'change:top';
55
+ args: [HighlightStackChangeEventData];
56
+ };
57
+ /**
58
+ * Additional information about the change.
59
+ */
60
+ export type HighlightStackChangeEventData = {
61
+ /**
62
+ * Old highlight descriptor. It will be `undefined` when first descriptor is added to the stack.
63
+ */
64
+ oldDescriptor: HighlightDescriptor;
65
+ /**
66
+ * New highlight descriptor. It will be `undefined` when last descriptor is removed from the stack.
67
+ */
68
+ newDescriptor: HighlightDescriptor;
69
+ /**
70
+ * View writer that can be used to modify element.
71
+ */
72
+ writer: DowncastWriter;
73
+ };
74
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ /**
6
+ * @module widget
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';
13
+ import './augmentation.js';
@@ -0,0 +1,198 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ /**
6
+ * @module widget/utils
7
+ */
8
+ import { type GetCallback } from '@ckeditor/ckeditor5-utils';
9
+ import { type HighlightDescriptor, type MapperViewToModelPositionEvent, type DocumentSelection, type DowncastWriter, type Model, type Range, type Selection, type ViewEditableElement, type ViewElement, type ViewTypeCheckable } from '@ckeditor/ckeditor5-engine';
10
+ /**
11
+ * CSS class added to each widget element.
12
+ */
13
+ export declare const WIDGET_CLASS_NAME = "ck-widget";
14
+ /**
15
+ * CSS class added to currently selected widget element.
16
+ */
17
+ export declare const WIDGET_SELECTED_CLASS_NAME = "ck-widget_selected";
18
+ /**
19
+ * Returns `true` if given {@link module:engine/view/node~Node} is an {@link module:engine/view/element~Element} and a widget.
20
+ */
21
+ export declare function isWidget(node: ViewTypeCheckable): boolean;
22
+ /**
23
+ * Converts the given {@link module:engine/view/element~Element} to a widget in the following way:
24
+ *
25
+ * * sets the `contenteditable` attribute to `"false"`,
26
+ * * adds the `ck-widget` CSS class,
27
+ * * adds a custom {@link module:engine/view/element~Element#getFillerOffset `getFillerOffset()`} method returning `null`,
28
+ * * adds a custom property allowing to recognize widget elements by using {@link ~isWidget `isWidget()`},
29
+ * * implements the {@link ~setHighlightHandling view highlight on widgets}.
30
+ *
31
+ * This function needs to be used in conjunction with
32
+ * {@link module:engine/conversion/downcasthelpers~DowncastHelpers downcast conversion helpers}
33
+ * like {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
34
+ * Moreover, typically you will want to use `toWidget()` only for `editingDowncast`, while keeping the `dataDowncast` clean.
35
+ *
36
+ * For example, in order to convert a `<widget>` model element to `<div class="widget">` in the view, you can define
37
+ * such converters:
38
+ *
39
+ * ```ts
40
+ * editor.conversion.for( 'editingDowncast' )
41
+ * .elementToElement( {
42
+ * model: 'widget',
43
+ * view: ( modelItem, { writer } ) => {
44
+ * const div = writer.createContainerElement( 'div', { class: 'widget' } );
45
+ *
46
+ * return toWidget( div, writer, { label: 'some widget' } );
47
+ * }
48
+ * } );
49
+ *
50
+ * editor.conversion.for( 'dataDowncast' )
51
+ * .elementToElement( {
52
+ * model: 'widget',
53
+ * view: ( modelItem, { writer } ) => {
54
+ * return writer.createContainerElement( 'div', { class: 'widget' } );
55
+ * }
56
+ * } );
57
+ * ```
58
+ *
59
+ * See the full source code of the widget (with a nested editable) schema definition and converters in
60
+ * [this sample](https://github.com/ckeditor/ckeditor5-widget/blob/master/tests/manual/widget-with-nestededitable.js).
61
+ *
62
+ * @param options Additional options.
63
+ * @param options.label Element's label provided to the {@link ~setLabel} function. It can be passed as
64
+ * a plain string or a function returning a string. It represents the widget for assistive technologies (like screen readers).
65
+ * @param options.hasSelectionHandle If `true`, the widget will have a selection handle added.
66
+ * @returns Returns the same element.
67
+ */
68
+ export declare function toWidget(element: ViewElement, writer: DowncastWriter, options?: {
69
+ label?: string | (() => string);
70
+ hasSelectionHandle?: boolean;
71
+ }): ViewElement;
72
+ /**
73
+ * Sets highlight handling methods. Uses {@link module:widget/highlightstack~HighlightStack} to
74
+ * properly determine which highlight descriptor should be used at given time.
75
+ */
76
+ 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;
77
+ /**
78
+ * Sets label for given element.
79
+ * It can be passed as a plain string or a function returning a string. Function will be called each time label is retrieved by
80
+ * {@link ~getLabel `getLabel()`}.
81
+ */
82
+ export declare function setLabel(element: ViewElement, labelOrCreator: string | (() => string)): void;
83
+ /**
84
+ * Returns the label of the provided element.
85
+ */
86
+ export declare function getLabel(element: ViewElement): string;
87
+ /**
88
+ * Adds functionality to the provided {@link module:engine/view/editableelement~EditableElement} to act as a widget's editable:
89
+ *
90
+ * * sets the `contenteditable` attribute to `true` when {@link module:engine/view/editableelement~EditableElement#isReadOnly} is `false`,
91
+ * otherwise sets it to `false`,
92
+ * * adds the `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
93
+ * * adds the `ck-editor__nested-editable_focused` CSS class when the editable is focused and removes it when it is blurred.
94
+ * * implements the {@link ~setHighlightHandling view highlight on widget's editable}.
95
+ *
96
+ * Similarly to {@link ~toWidget `toWidget()`} this function should be used in `editingDowncast` only and it is usually
97
+ * used together with {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
98
+ *
99
+ * For example, in order to convert a `<nested>` model element to `<div class="nested">` in the view, you can define
100
+ * such converters:
101
+ *
102
+ * ```ts
103
+ * editor.conversion.for( 'editingDowncast' )
104
+ * .elementToElement( {
105
+ * model: 'nested',
106
+ * view: ( modelItem, { writer } ) => {
107
+ * const div = writer.createEditableElement( 'div', { class: 'nested' } );
108
+ *
109
+ * return toWidgetEditable( nested, writer, { label: 'label for editable' } );
110
+ * }
111
+ * } );
112
+ *
113
+ * editor.conversion.for( 'dataDowncast' )
114
+ * .elementToElement( {
115
+ * model: 'nested',
116
+ * view: ( modelItem, { writer } ) => {
117
+ * return writer.createContainerElement( 'div', { class: 'nested' } );
118
+ * }
119
+ * } );
120
+ * ```
121
+ *
122
+ * See the full source code of the widget (with nested editable) schema definition and converters in
123
+ * [this sample](https://github.com/ckeditor/ckeditor5-widget/blob/master/tests/manual/widget-with-nestededitable.js).
124
+ *
125
+ * @param options Additional options.
126
+ * @param options.label Editable's label used by assistive technologies (e.g. screen readers).
127
+ * @returns Returns the same element that was provided in the `editable` parameter
128
+ */
129
+ export declare function toWidgetEditable(editable: ViewEditableElement, writer: DowncastWriter, options?: {
130
+ label?: string;
131
+ }): ViewEditableElement;
132
+ /**
133
+ * Returns a model range which is optimal (in terms of UX) for inserting a widget block.
134
+ *
135
+ * For instance, if a selection is in the middle of a paragraph, the collapsed range before this paragraph
136
+ * will be returned so that it is not split. If the selection is at the end of a paragraph,
137
+ * the collapsed range after this paragraph will be returned.
138
+ *
139
+ * Note: If the selection is placed in an empty block, the range in that block will be returned. If that range
140
+ * is then passed to {@link module:engine/model/model~Model#insertContent}, the block will be fully replaced
141
+ * by the inserted widget block.
142
+ *
143
+ * @param selection The selection based on which the insertion position should be calculated.
144
+ * @param model Model instance.
145
+ * @returns The optimal range.
146
+ */
147
+ export declare function findOptimalInsertionRange(selection: Selection | DocumentSelection, model: Model): Range;
148
+ /**
149
+ * A util to be used in order to map view positions to correct model positions when implementing a widget
150
+ * which renders non-empty view element for an empty model element.
151
+ *
152
+ * For example:
153
+ *
154
+ * ```
155
+ * // Model:
156
+ * <placeholder type="name"></placeholder>
157
+ *
158
+ * // View:
159
+ * <span class="placeholder">name</span>
160
+ * ```
161
+ *
162
+ * In such case, view positions inside `<span>` cannot be correctly mapped to the model (because the model element is empty).
163
+ * To handle mapping positions inside `<span class="placeholder">` to the model use this util as follows:
164
+ *
165
+ * ```ts
166
+ * editor.editing.mapper.on(
167
+ * 'viewToModelPosition',
168
+ * viewToModelPositionOutsideModelElement( model, viewElement => viewElement.hasClass( 'placeholder' ) )
169
+ * );
170
+ * ```
171
+ *
172
+ * The callback will try to map the view offset of selection to an expected model position.
173
+ *
174
+ * 1. When the position is at the end (or in the middle) of the inline widget:
175
+ *
176
+ * ```
177
+ * // View:
178
+ * <p>foo <span class="placeholder">name|</span> bar</p>
179
+ *
180
+ * // Model:
181
+ * <paragraph>foo <placeholder type="name"></placeholder>| bar</paragraph>
182
+ * ```
183
+ *
184
+ * 2. When the position is at the beginning of the inline widget:
185
+ *
186
+ * ```
187
+ * // View:
188
+ * <p>foo <span class="placeholder">|name</span> bar</p>
189
+ *
190
+ * // Model:
191
+ * <paragraph>foo |<placeholder type="name"></placeholder> bar</paragraph>
192
+ * ```
193
+ *
194
+ * @param model Model instance on which the callback operates.
195
+ * @param viewElementMatcher Function that is passed a view element and should return `true` if the custom mapping
196
+ * should be applied to the given view element.
197
+ */
198
+ export declare function viewToModelPositionOutsideModelElement(model: Model, viewElementMatcher: (element: ViewElement) => boolean): GetCallback<MapperViewToModelPositionEvent>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ /**
6
+ * @module widget/verticalnavigation
7
+ */
8
+ import { type GetCallback } from '@ckeditor/ckeditor5-utils';
9
+ import type { EditingController, ViewDocumentArrowKeyEvent } from '@ckeditor/ckeditor5-engine';
10
+ /**
11
+ * Returns 'keydown' handler for up/down arrow keys that modifies the caret movement if it's in a text line next to an object.
12
+ *
13
+ * @param editing The editing controller.
14
+ */
15
+ export default function verticalNavigationHandler(editing: EditingController): GetCallback<ViewDocumentArrowKeyEvent>;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ /**
6
+ * @module widget/widget
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import { type Element, type Node } from '@ckeditor/ckeditor5-engine';
10
+ import { Delete } from '@ckeditor/ckeditor5-typing';
11
+ import WidgetTypeAround from './widgettypearound/widgettypearound.js';
12
+ import '../theme/widget.css';
13
+ /**
14
+ * The widget plugin. It enables base support for widgets.
15
+ *
16
+ * See {@glink api/widget package page} for more details and documentation.
17
+ *
18
+ * This plugin enables multiple behaviors required by widgets:
19
+ *
20
+ * * The model to view selection converter for the editing pipeline (it handles widget custom selection rendering).
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
23
+ * is added to indicate that widget has been selected.
24
+ * * The mouse and keyboard events handling on and around widget elements.
25
+ */
26
+ export default class Widget extends Plugin {
27
+ /**
28
+ * Holds previously selected widgets.
29
+ */
30
+ private _previouslySelected;
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ static get pluginName(): "Widget";
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ static get requires(): readonly [typeof WidgetTypeAround, typeof Delete];
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ init(): void;
43
+ /**
44
+ * Handles {@link module:engine/view/document~Document#event:mousedown mousedown} events on widget elements.
45
+ */
46
+ private _onMousedown;
47
+ /**
48
+ * Selects entire block content, e.g. on triple click it selects entire paragraph.
49
+ */
50
+ private _selectBlockContent;
51
+ /**
52
+ * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and changes
53
+ * the model selection when:
54
+ *
55
+ * * arrow key is pressed when the widget is selected,
56
+ * * the selection is next to a widget and the widget should become selected upon the arrow key press.
57
+ *
58
+ * See {@link #_preventDefaultOnArrowKeyPress}.
59
+ */
60
+ private _handleSelectionChangeOnArrowKeyPress;
61
+ /**
62
+ * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and prevents
63
+ * the default browser behavior to make sure the fake selection is not being moved from a fake selection
64
+ * container.
65
+ *
66
+ * See {@link #_handleSelectionChangeOnArrowKeyPress}.
67
+ */
68
+ private _preventDefaultOnArrowKeyPress;
69
+ /**
70
+ * Handles delete keys: backspace and delete.
71
+ *
72
+ * @param isForward Set to true if delete was performed in forward direction.
73
+ * @returns Returns `true` if keys were handled correctly.
74
+ */
75
+ private _handleDelete;
76
+ /**
77
+ * Sets {@link module:engine/model/selection~Selection document's selection} over given element.
78
+ *
79
+ * @internal
80
+ */
81
+ _setSelectionOverElement(element: Node): void;
82
+ /**
83
+ * Checks if {@link module:engine/model/element~Element element} placed next to the current
84
+ * {@link module:engine/model/selection~Selection model selection} exists and is marked in
85
+ * {@link module:engine/model/schema~Schema schema} as `object`.
86
+ *
87
+ * @internal
88
+ * @param forward Direction of checking.
89
+ */
90
+ _getObjectElementNextToSelection(forward: boolean): Element | null;
91
+ /**
92
+ * Removes CSS class from previously selected widgets.
93
+ */
94
+ private _clearPreviouslySelectedWidgets;
95
+ }
@@ -0,0 +1,177 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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 {};