@ckeditor/ckeditor5-widget 41.3.0-alpha.4 → 41.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. package/package.json +7 -8
  2. package/src/utils.js +1 -0
  3. package/src/widget.d.ts +8 -0
  4. package/src/widget.js +85 -1
  5. package/dist/content-index.css +0 -4
  6. package/dist/editor-index.css +0 -144
  7. package/dist/index.css +0 -257
  8. package/dist/index.css.map +0 -1
  9. package/dist/translations/ar.d.ts +0 -8
  10. package/dist/translations/ar.js +0 -5
  11. package/dist/translations/az.d.ts +0 -8
  12. package/dist/translations/az.js +0 -5
  13. package/dist/translations/bg.d.ts +0 -8
  14. package/dist/translations/bg.js +0 -5
  15. package/dist/translations/bn.d.ts +0 -8
  16. package/dist/translations/bn.js +0 -5
  17. package/dist/translations/ca.d.ts +0 -8
  18. package/dist/translations/ca.js +0 -5
  19. package/dist/translations/cs.d.ts +0 -8
  20. package/dist/translations/cs.js +0 -5
  21. package/dist/translations/da.d.ts +0 -8
  22. package/dist/translations/da.js +0 -5
  23. package/dist/translations/de-ch.d.ts +0 -8
  24. package/dist/translations/de-ch.js +0 -5
  25. package/dist/translations/de.d.ts +0 -8
  26. package/dist/translations/de.js +0 -5
  27. package/dist/translations/el.d.ts +0 -8
  28. package/dist/translations/el.js +0 -5
  29. package/dist/translations/en-au.d.ts +0 -8
  30. package/dist/translations/en-au.js +0 -5
  31. package/dist/translations/en.d.ts +0 -8
  32. package/dist/translations/en.js +0 -5
  33. package/dist/translations/es.d.ts +0 -8
  34. package/dist/translations/es.js +0 -5
  35. package/dist/translations/et.d.ts +0 -8
  36. package/dist/translations/et.js +0 -5
  37. package/dist/translations/fa.d.ts +0 -8
  38. package/dist/translations/fa.js +0 -5
  39. package/dist/translations/fi.d.ts +0 -8
  40. package/dist/translations/fi.js +0 -5
  41. package/dist/translations/fr.d.ts +0 -8
  42. package/dist/translations/fr.js +0 -5
  43. package/dist/translations/gl.d.ts +0 -8
  44. package/dist/translations/gl.js +0 -5
  45. package/dist/translations/he.d.ts +0 -8
  46. package/dist/translations/he.js +0 -5
  47. package/dist/translations/hi.d.ts +0 -8
  48. package/dist/translations/hi.js +0 -5
  49. package/dist/translations/hr.d.ts +0 -8
  50. package/dist/translations/hr.js +0 -5
  51. package/dist/translations/hu.d.ts +0 -8
  52. package/dist/translations/hu.js +0 -5
  53. package/dist/translations/id.d.ts +0 -8
  54. package/dist/translations/id.js +0 -5
  55. package/dist/translations/it.d.ts +0 -8
  56. package/dist/translations/it.js +0 -5
  57. package/dist/translations/ja.d.ts +0 -8
  58. package/dist/translations/ja.js +0 -5
  59. package/dist/translations/ko.d.ts +0 -8
  60. package/dist/translations/ko.js +0 -5
  61. package/dist/translations/ku.d.ts +0 -8
  62. package/dist/translations/ku.js +0 -5
  63. package/dist/translations/lt.d.ts +0 -8
  64. package/dist/translations/lt.js +0 -5
  65. package/dist/translations/lv.d.ts +0 -8
  66. package/dist/translations/lv.js +0 -5
  67. package/dist/translations/ms.d.ts +0 -8
  68. package/dist/translations/ms.js +0 -5
  69. package/dist/translations/nl.d.ts +0 -8
  70. package/dist/translations/nl.js +0 -5
  71. package/dist/translations/no.d.ts +0 -8
  72. package/dist/translations/no.js +0 -5
  73. package/dist/translations/pl.d.ts +0 -8
  74. package/dist/translations/pl.js +0 -5
  75. package/dist/translations/pt-br.d.ts +0 -8
  76. package/dist/translations/pt-br.js +0 -5
  77. package/dist/translations/pt.d.ts +0 -8
  78. package/dist/translations/pt.js +0 -5
  79. package/dist/translations/ro.d.ts +0 -8
  80. package/dist/translations/ro.js +0 -5
  81. package/dist/translations/ru.d.ts +0 -8
  82. package/dist/translations/ru.js +0 -5
  83. package/dist/translations/sk.d.ts +0 -8
  84. package/dist/translations/sk.js +0 -5
  85. package/dist/translations/sq.d.ts +0 -8
  86. package/dist/translations/sq.js +0 -5
  87. package/dist/translations/sr-latn.d.ts +0 -8
  88. package/dist/translations/sr-latn.js +0 -5
  89. package/dist/translations/sr.d.ts +0 -8
  90. package/dist/translations/sr.js +0 -5
  91. package/dist/translations/sv.d.ts +0 -8
  92. package/dist/translations/sv.js +0 -5
  93. package/dist/translations/th.d.ts +0 -8
  94. package/dist/translations/th.js +0 -5
  95. package/dist/translations/tk.d.ts +0 -8
  96. package/dist/translations/tk.js +0 -5
  97. package/dist/translations/tr.d.ts +0 -8
  98. package/dist/translations/tr.js +0 -5
  99. package/dist/translations/uk.d.ts +0 -8
  100. package/dist/translations/uk.js +0 -5
  101. package/dist/translations/ur.d.ts +0 -8
  102. package/dist/translations/ur.js +0 -5
  103. package/dist/translations/uz.d.ts +0 -8
  104. package/dist/translations/uz.js +0 -5
  105. package/dist/translations/vi.d.ts +0 -8
  106. package/dist/translations/vi.js +0 -5
  107. package/dist/translations/zh-cn.d.ts +0 -8
  108. package/dist/translations/zh-cn.js +0 -5
  109. package/dist/translations/zh.d.ts +0 -8
  110. package/dist/translations/zh.js +0 -5
  111. package/dist/types/augmentation.d.ts +0 -17
  112. package/dist/types/highlightstack.d.ts +0 -78
  113. package/dist/types/index.d.ts +0 -17
  114. package/dist/types/utils.d.ts +0 -202
  115. package/dist/types/verticalnavigation.d.ts +0 -19
  116. package/dist/types/widget.d.ts +0 -99
  117. package/dist/types/widgetresize/resizer.d.ts +0 -181
  118. package/dist/types/widgetresize/resizerstate.d.ts +0 -129
  119. package/dist/types/widgetresize/sizeview.d.ts +0 -59
  120. package/dist/types/widgetresize.d.ts +0 -129
  121. package/dist/types/widgettoolbarrepository.d.ts +0 -98
  122. package/dist/types/widgettypearound/utils.d.ts +0 -42
  123. package/dist/types/widgettypearound/widgettypearound.d.ts +0 -233
@@ -1,202 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module widget/utils
11
- */
12
- import { type GetCallback } from '@ckeditor/ckeditor5-utils';
13
- 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';
14
- /**
15
- * CSS class added to each widget element.
16
- */
17
- export declare const WIDGET_CLASS_NAME = "ck-widget";
18
- /**
19
- * CSS class added to currently selected widget element.
20
- */
21
- export declare const WIDGET_SELECTED_CLASS_NAME = "ck-widget_selected";
22
- /**
23
- * Returns `true` if given {@link module:engine/view/node~Node} is an {@link module:engine/view/element~Element} and a widget.
24
- */
25
- export declare function isWidget(node: ViewTypeCheckable): boolean;
26
- /**
27
- * Converts the given {@link module:engine/view/element~Element} to a widget in the following way:
28
- *
29
- * * sets the `contenteditable` attribute to `"false"`,
30
- * * adds the `ck-widget` CSS class,
31
- * * adds a custom {@link module:engine/view/element~Element#getFillerOffset `getFillerOffset()`} method returning `null`,
32
- * * adds a custom property allowing to recognize widget elements by using {@link ~isWidget `isWidget()`},
33
- * * implements the {@link ~setHighlightHandling view highlight on widgets}.
34
- *
35
- * This function needs to be used in conjunction with
36
- * {@link module:engine/conversion/downcasthelpers~DowncastHelpers downcast conversion helpers}
37
- * like {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
38
- * Moreover, typically you will want to use `toWidget()` only for `editingDowncast`, while keeping the `dataDowncast` clean.
39
- *
40
- * For example, in order to convert a `<widget>` model element to `<div class="widget">` in the view, you can define
41
- * such converters:
42
- *
43
- * ```ts
44
- * editor.conversion.for( 'editingDowncast' )
45
- * .elementToElement( {
46
- * model: 'widget',
47
- * view: ( modelItem, { writer } ) => {
48
- * const div = writer.createContainerElement( 'div', { class: 'widget' } );
49
- *
50
- * return toWidget( div, writer, { label: 'some widget' } );
51
- * }
52
- * } );
53
- *
54
- * editor.conversion.for( 'dataDowncast' )
55
- * .elementToElement( {
56
- * model: 'widget',
57
- * view: ( modelItem, { writer } ) => {
58
- * return writer.createContainerElement( 'div', { class: 'widget' } );
59
- * }
60
- * } );
61
- * ```
62
- *
63
- * See the full source code of the widget (with a nested editable) schema definition and converters in
64
- * [this sample](https://github.com/ckeditor/ckeditor5-widget/blob/master/tests/manual/widget-with-nestededitable.js).
65
- *
66
- * @param options Additional options.
67
- * @param options.label Element's label provided to the {@link ~setLabel} function. It can be passed as
68
- * a plain string or a function returning a string. It represents the widget for assistive technologies (like screen readers).
69
- * @param options.hasSelectionHandle If `true`, the widget will have a selection handle added.
70
- * @returns Returns the same element.
71
- */
72
- export declare function toWidget(element: ViewElement, writer: DowncastWriter, options?: {
73
- label?: string | (() => string);
74
- hasSelectionHandle?: boolean;
75
- }): ViewElement;
76
- /**
77
- * Sets highlight handling methods. Uses {@link module:widget/highlightstack~HighlightStack} to
78
- * properly determine which highlight descriptor should be used at given time.
79
- */
80
- 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;
81
- /**
82
- * Sets label for given element.
83
- * It can be passed as a plain string or a function returning a string. Function will be called each time label is retrieved by
84
- * {@link ~getLabel `getLabel()`}.
85
- */
86
- export declare function setLabel(element: ViewElement, labelOrCreator: string | (() => string)): void;
87
- /**
88
- * Returns the label of the provided element.
89
- */
90
- export declare function getLabel(element: ViewElement): string;
91
- /**
92
- * Adds functionality to the provided {@link module:engine/view/editableelement~EditableElement} to act as a widget's editable:
93
- *
94
- * * sets the `contenteditable` attribute to `true` when {@link module:engine/view/editableelement~EditableElement#isReadOnly} is `false`,
95
- * otherwise sets it to `false`,
96
- * * adds the `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
97
- * * adds the `ck-editor__nested-editable_focused` CSS class when the editable is focused and removes it when it is blurred.
98
- * * implements the {@link ~setHighlightHandling view highlight on widget's editable}.
99
- *
100
- * Similarly to {@link ~toWidget `toWidget()`} this function should be used in `editingDowncast` only and it is usually
101
- * used together with {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
102
- *
103
- * For example, in order to convert a `<nested>` model element to `<div class="nested">` in the view, you can define
104
- * such converters:
105
- *
106
- * ```ts
107
- * editor.conversion.for( 'editingDowncast' )
108
- * .elementToElement( {
109
- * model: 'nested',
110
- * view: ( modelItem, { writer } ) => {
111
- * const div = writer.createEditableElement( 'div', { class: 'nested' } );
112
- *
113
- * return toWidgetEditable( nested, writer, { label: 'label for editable' } );
114
- * }
115
- * } );
116
- *
117
- * editor.conversion.for( 'dataDowncast' )
118
- * .elementToElement( {
119
- * model: 'nested',
120
- * view: ( modelItem, { writer } ) => {
121
- * return writer.createContainerElement( 'div', { class: 'nested' } );
122
- * }
123
- * } );
124
- * ```
125
- *
126
- * See the full source code of the widget (with nested editable) schema definition and converters in
127
- * [this sample](https://github.com/ckeditor/ckeditor5-widget/blob/master/tests/manual/widget-with-nestededitable.js).
128
- *
129
- * @param options Additional options.
130
- * @param options.label Editable's label used by assistive technologies (e.g. screen readers).
131
- * @returns Returns the same element that was provided in the `editable` parameter
132
- */
133
- export declare function toWidgetEditable(editable: ViewEditableElement, writer: DowncastWriter, options?: {
134
- label?: string;
135
- }): ViewEditableElement;
136
- /**
137
- * Returns a model range which is optimal (in terms of UX) for inserting a widget block.
138
- *
139
- * For instance, if a selection is in the middle of a paragraph, the collapsed range before this paragraph
140
- * will be returned so that it is not split. If the selection is at the end of a paragraph,
141
- * the collapsed range after this paragraph will be returned.
142
- *
143
- * Note: If the selection is placed in an empty block, the range in that block will be returned. If that range
144
- * is then passed to {@link module:engine/model/model~Model#insertContent}, the block will be fully replaced
145
- * by the inserted widget block.
146
- *
147
- * @param selection The selection based on which the insertion position should be calculated.
148
- * @param model Model instance.
149
- * @returns The optimal range.
150
- */
151
- export declare function findOptimalInsertionRange(selection: Selection | DocumentSelection, model: Model): Range;
152
- /**
153
- * A util to be used in order to map view positions to correct model positions when implementing a widget
154
- * which renders non-empty view element for an empty model element.
155
- *
156
- * For example:
157
- *
158
- * ```
159
- * // Model:
160
- * <placeholder type="name"></placeholder>
161
- *
162
- * // View:
163
- * <span class="placeholder">name</span>
164
- * ```
165
- *
166
- * In such case, view positions inside `<span>` cannot be correctly mapped to the model (because the model element is empty).
167
- * To handle mapping positions inside `<span class="placeholder">` to the model use this util as follows:
168
- *
169
- * ```ts
170
- * editor.editing.mapper.on(
171
- * 'viewToModelPosition',
172
- * viewToModelPositionOutsideModelElement( model, viewElement => viewElement.hasClass( 'placeholder' ) )
173
- * );
174
- * ```
175
- *
176
- * The callback will try to map the view offset of selection to an expected model position.
177
- *
178
- * 1. When the position is at the end (or in the middle) of the inline widget:
179
- *
180
- * ```
181
- * // View:
182
- * <p>foo <span class="placeholder">name|</span> bar</p>
183
- *
184
- * // Model:
185
- * <paragraph>foo <placeholder type="name"></placeholder>| bar</paragraph>
186
- * ```
187
- *
188
- * 2. When the position is at the beginning of the inline widget:
189
- *
190
- * ```
191
- * // View:
192
- * <p>foo <span class="placeholder">|name</span> bar</p>
193
- *
194
- * // Model:
195
- * <paragraph>foo |<placeholder type="name"></placeholder> bar</paragraph>
196
- * ```
197
- *
198
- * @param model Model instance on which the callback operates.
199
- * @param viewElementMatcher Function that is passed a view element and should return `true` if the custom mapping
200
- * should be applied to the given view element.
201
- */
202
- export declare function viewToModelPositionOutsideModelElement(model: Model, viewElementMatcher: (element: ViewElement) => boolean): GetCallback<MapperViewToModelPositionEvent>;
@@ -1,19 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module widget/verticalnavigation
11
- */
12
- import { type GetCallback } from '@ckeditor/ckeditor5-utils';
13
- import type { EditingController, ViewDocumentArrowKeyEvent } from '@ckeditor/ckeditor5-engine';
14
- /**
15
- * Returns 'keydown' handler for up/down arrow keys that modifies the caret movement if it's in a text line next to an object.
16
- *
17
- * @param editing The editing controller.
18
- */
19
- export default function verticalNavigationHandler(editing: EditingController): GetCallback<ViewDocumentArrowKeyEvent>;
@@ -1,99 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module widget/widget
11
- */
12
- import { Plugin } from '@ckeditor/ckeditor5-core';
13
- import { type Element, type Node } from '@ckeditor/ckeditor5-engine';
14
- import { Delete } from '@ckeditor/ckeditor5-typing';
15
- import WidgetTypeAround from './widgettypearound/widgettypearound.js';
16
- import '../theme/widget.css';
17
- /**
18
- * The widget plugin. It enables base support for widgets.
19
- *
20
- * See {@glink api/widget package page} for more details and documentation.
21
- *
22
- * This plugin enables multiple behaviors required by widgets:
23
- *
24
- * * The model to view selection converter for the editing pipeline (it handles widget custom selection rendering).
25
- * If a converted selection wraps around a widget element, that selection is marked as
26
- * {@link module:engine/view/selection~Selection#isFake fake}. Additionally, the `ck-widget_selected` CSS class
27
- * is added to indicate that widget has been selected.
28
- * * The mouse and keyboard events handling on and around widget elements.
29
- */
30
- export default class Widget extends Plugin {
31
- /**
32
- * Holds previously selected widgets.
33
- */
34
- private _previouslySelected;
35
- /**
36
- * @inheritDoc
37
- */
38
- static get pluginName(): "Widget";
39
- /**
40
- * @inheritDoc
41
- */
42
- static get requires(): readonly [typeof WidgetTypeAround, typeof Delete];
43
- /**
44
- * @inheritDoc
45
- */
46
- init(): void;
47
- /**
48
- * Handles {@link module:engine/view/document~Document#event:mousedown mousedown} events on widget elements.
49
- */
50
- private _onMousedown;
51
- /**
52
- * Selects entire block content, e.g. on triple click it selects entire paragraph.
53
- */
54
- private _selectBlockContent;
55
- /**
56
- * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and changes
57
- * the model selection when:
58
- *
59
- * * arrow key is pressed when the widget is selected,
60
- * * the selection is next to a widget and the widget should become selected upon the arrow key press.
61
- *
62
- * See {@link #_preventDefaultOnArrowKeyPress}.
63
- */
64
- private _handleSelectionChangeOnArrowKeyPress;
65
- /**
66
- * Handles {@link module:engine/view/document~Document#event:keydown keydown} events and prevents
67
- * the default browser behavior to make sure the fake selection is not being moved from a fake selection
68
- * container.
69
- *
70
- * See {@link #_handleSelectionChangeOnArrowKeyPress}.
71
- */
72
- private _preventDefaultOnArrowKeyPress;
73
- /**
74
- * Handles delete keys: backspace and delete.
75
- *
76
- * @param isForward Set to true if delete was performed in forward direction.
77
- * @returns Returns `true` if keys were handled correctly.
78
- */
79
- private _handleDelete;
80
- /**
81
- * Sets {@link module:engine/model/selection~Selection document's selection} over given element.
82
- *
83
- * @internal
84
- */
85
- _setSelectionOverElement(element: Node): void;
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`.
90
- *
91
- * @internal
92
- * @param forward Direction of checking.
93
- */
94
- _getObjectElementNextToSelection(forward: boolean): Element | null;
95
- /**
96
- * Removes CSS class from previously selected widgets.
97
- */
98
- private _clearPreviouslySelectedWidgets;
99
- }
@@ -1,181 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- import { Rect, type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils';
10
- import ResizeState from './resizerstate.js';
11
- import type { ResizerOptions } from '../widgetresize.js';
12
- declare const Resizer_base: {
13
- new (): import("@ckeditor/ckeditor5-utils").Observable;
14
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
15
- };
16
- /**
17
- * Represents a resizer for a single resizable object.
18
- */
19
- export default class Resizer extends Resizer_base {
20
- /**
21
- * Flag that indicates whether resizer can be used.
22
- *
23
- * @observable
24
- */
25
- isEnabled: boolean;
26
- /**
27
- * Flag that indicates that resizer is currently focused.
28
- *
29
- * @observable
30
- */
31
- isSelected: boolean;
32
- /**
33
- * Flag that indicates whether resizer is rendered (visible on the screen).
34
- *
35
- * @readonly
36
- * @observable
37
- */
38
- isVisible: boolean;
39
- /**
40
- * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
41
- *
42
- * Note that a new state is created for each resize transaction.
43
- */
44
- private _state;
45
- /**
46
- * A view displaying the proposed new element size during the resizing.
47
- */
48
- private _sizeView;
49
- /**
50
- * Options passed to the {@link #constructor}.
51
- */
52
- private _options;
53
- /**
54
- * A wrapper that is controlled by the resizer. This is usually a widget element.
55
- */
56
- private _viewResizerWrapper;
57
- /**
58
- * The width of the resized {@link module:widget/widgetresize~ResizerOptions#viewElement viewElement} before the resizing started.
59
- */
60
- private _initialViewWidth;
61
- /**
62
- * @param options Resizer options.
63
- */
64
- constructor(options: ResizerOptions);
65
- /**
66
- * Stores the state of the resizable host geometry, such as the original width, the currently proposed height, etc.
67
- *
68
- * Note that a new state is created for each resize transaction.
69
- */
70
- get state(): ResizeState;
71
- /**
72
- * Makes resizer visible in the UI.
73
- */
74
- show(): void;
75
- /**
76
- * Hides resizer in the UI.
77
- */
78
- hide(): void;
79
- /**
80
- * Attaches the resizer to the DOM.
81
- */
82
- attach(): void;
83
- /**
84
- * Starts the resizing process.
85
- *
86
- * Creates a new {@link #state} for the current process.
87
- *
88
- * @fires begin
89
- * @param domResizeHandle Clicked handle.
90
- */
91
- begin(domResizeHandle: HTMLElement): void;
92
- /**
93
- * Updates the proposed size based on `domEventData`.
94
- *
95
- * @fires updateSize
96
- */
97
- updateSize(domEventData: MouseEvent): void;
98
- /**
99
- * Applies the geometry proposed with the resizer.
100
- *
101
- * @fires commit
102
- */
103
- commit(): void;
104
- /**
105
- * Cancels and rejects the proposed resize dimensions, hiding the UI.
106
- *
107
- * @fires cancel
108
- */
109
- cancel(): void;
110
- /**
111
- * Destroys the resizer.
112
- */
113
- destroy(): void;
114
- /**
115
- * Redraws the resizer.
116
- *
117
- * @param handleHostRect Handle host rectangle might be given to improve performance.
118
- */
119
- redraw(handleHostRect?: Rect): void;
120
- containsHandle(domElement: HTMLElement): boolean;
121
- static isResizeHandle(domElement: HTMLElement): boolean;
122
- /**
123
- * Cleans up the context state.
124
- */
125
- private _cleanup;
126
- /**
127
- * Calculates the proposed size as the resize handles are dragged.
128
- *
129
- * @param domEventData Event data that caused the size update request. It should be used to calculate the proposed size.
130
- */
131
- private _proposeNewSize;
132
- /**
133
- * Obtains the resize host.
134
- *
135
- * Resize host is an object that receives dimensions which are the result of resizing.
136
- */
137
- private _getResizeHost;
138
- /**
139
- * Obtains the handle host.
140
- *
141
- * Handle host is an object that the handles are aligned to.
142
- *
143
- * Handle host will not always be an entire widget itself. Take an image as an example. The image widget
144
- * contains an image and a caption. Only the image should be surrounded with handles.
145
- */
146
- private _getHandleHost;
147
- /**
148
- * DOM container of the entire resize UI.
149
- *
150
- * Note that this property will have a value only after the element bound with the resizer is rendered
151
- * (otherwise `null`).
152
- */
153
- private get _domResizerWrapper();
154
- /**
155
- * Renders the resize handles in the DOM.
156
- *
157
- * @param domElement The resizer wrapper.
158
- */
159
- private _appendHandles;
160
- /**
161
- * Sets up the {@link #_sizeView} property and adds it to the passed `domElement`.
162
- */
163
- private _appendSizeUI;
164
- }
165
- /**
166
- * @eventName ~Resizer#begin
167
- */
168
- export type ResizerBeginEvent = DecoratedMethodEvent<Resizer, 'begin'>;
169
- /**
170
- * @eventName ~Resizer#cancel
171
- */
172
- export type ResizerCancelEvent = DecoratedMethodEvent<Resizer, 'cancel'>;
173
- /**
174
- * @eventName ~Resizer#commit
175
- */
176
- export type ResizerCommitEvent = DecoratedMethodEvent<Resizer, 'commit'>;
177
- /**
178
- * @eventName ~Resizer#updateSize
179
- */
180
- export type ResizerUpdateSizeEvent = DecoratedMethodEvent<Resizer, 'updateSize'>;
181
- export {};
@@ -1,129 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- import type { ResizerOptions } from '../widgetresize.js';
10
- declare const ResizeState_base: {
11
- new (): import("@ckeditor/ckeditor5-utils").Observable;
12
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
13
- };
14
- /**
15
- * Stores the internal state of a single resizable object.
16
- */
17
- export default class ResizeState extends ResizeState_base {
18
- /**
19
- * The position of the handle that initiated the resizing. E.g. `"top-left"`, `"bottom-right"` etc. or `null`
20
- * if unknown.
21
- *
22
- * @readonly
23
- * @observable
24
- */
25
- activeHandlePosition: string | null;
26
- /**
27
- * The width (percents) proposed, but not committed yet, in the current resize process.
28
- *
29
- * @readonly
30
- * @observable
31
- */
32
- proposedWidthPercents: number | null;
33
- /**
34
- * The width (pixels) proposed, but not committed yet, in the current resize process.
35
- *
36
- * @readonly
37
- * @observable
38
- */
39
- proposedWidth: number | null;
40
- /**
41
- * The height (pixels) proposed, but not committed yet, in the current resize process.
42
- *
43
- * @readonly
44
- * @observable
45
- */
46
- proposedHeight: number | null;
47
- /**
48
- * @readonly
49
- * @observable
50
- */
51
- proposedHandleHostWidth: number | null;
52
- /**
53
- * @readonly
54
- * @observable
55
- */
56
- proposedHandleHostHeight: number | null;
57
- /**
58
- * The reference point of the resizer where the dragging started. It is used to measure the distance the user cursor
59
- * traveled, so how much the image should be enlarged.
60
- * This information is only known after the DOM was rendered, so it will be updated later.
61
- *
62
- * @internal
63
- */
64
- _referenceCoordinates: {
65
- x: number;
66
- y: number;
67
- } | null;
68
- /**
69
- * Resizer options.
70
- */
71
- private readonly _options;
72
- /**
73
- * The original width (pixels) of the resized object when the resize process was started.
74
- *
75
- * @readonly
76
- */
77
- private _originalWidth?;
78
- /**
79
- * The original height (pixels) of the resized object when the resize process was started.
80
- *
81
- * @readonly
82
- */
83
- private _originalHeight?;
84
- /**
85
- * The original width (percents) of the resized object when the resize process was started.
86
- *
87
- * @readonly
88
- */
89
- private _originalWidthPercents?;
90
- /**
91
- * A width to height ratio of the resized image.
92
- *
93
- * @readonly
94
- */
95
- private _aspectRatio?;
96
- /**
97
- * @param options Resizer options.
98
- */
99
- constructor(options: ResizerOptions);
100
- /**
101
- * The original width (pixels) of the resized object when the resize process was started.
102
- */
103
- get originalWidth(): number | undefined;
104
- /**
105
- * The original height (pixels) of the resized object when the resize process was started.
106
- */
107
- get originalHeight(): number | undefined;
108
- /**
109
- * The original width (percents) of the resized object when the resize process was started.
110
- */
111
- get originalWidthPercents(): number | undefined;
112
- /**
113
- * A width to height ratio of the resized image.
114
- */
115
- get aspectRatio(): number | undefined;
116
- /**
117
- *
118
- * @param domResizeHandle The handle used to calculate the reference point.
119
- */
120
- begin(domResizeHandle: HTMLElement, domHandleHost: HTMLElement, domResizeHost: HTMLElement): void;
121
- update(newSize: {
122
- width: number;
123
- height: number;
124
- widthPercents: number;
125
- handleHostWidth: number;
126
- handleHostHeight: number;
127
- }): void;
128
- }
129
- export {};
@@ -1,59 +0,0 @@
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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module widget/widgetresize/sizeview
11
- */
12
- import { View } from '@ckeditor/ckeditor5-ui';
13
- import type { ResizerOptions } from '../widgetresize.js';
14
- import type ResizeState from './resizerstate.js';
15
- /**
16
- * A view displaying the proposed new element size during the resizing.
17
- */
18
- export default class SizeView extends View {
19
- /**
20
- * The visibility of the view defined based on the existence of the host proposed dimensions.
21
- *
22
- * @internal
23
- * @observable
24
- * @readonly
25
- */
26
- _isVisible: boolean;
27
- /**
28
- * The text that will be displayed in the `SizeView` child.
29
- * It can be formatted as the pixel values (e.g. 10x20) or the percentage value (e.g. 10%).
30
- *
31
- * @internal
32
- * @observable
33
- * @readonly
34
- */
35
- _label: string;
36
- /**
37
- * The position of the view defined based on the host size and active handle position.
38
- *
39
- * @internal
40
- * @observable
41
- * @readonly
42
- */
43
- _viewPosition: string;
44
- constructor();
45
- /**
46
- * A method used for binding the `SizeView` instance properties to the `ResizeState` instance observable properties.
47
- *
48
- * @internal
49
- * @param options An object defining the resizer options, used for setting the proper size label.
50
- * @param resizeState The `ResizeState` class instance, used for keeping the `SizeView` state up to date.
51
- */
52
- _bindToState(options: ResizerOptions, resizeState: ResizeState): void;
53
- /**
54
- * A method used for cleaning up. It removes the bindings and hides the view.
55
- *
56
- * @internal
57
- */
58
- _dismiss(): void;
59
- }