@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/dist/index.js +42 -31
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/highlightstack.d.ts +14 -14
- package/src/highlightstack.js +3 -3
- package/src/index.d.ts +11 -5
- package/src/index.js +11 -5
- package/src/utils.d.ts +12 -11
- package/src/utils.js +10 -9
- package/src/verticalnavigation.d.ts +1 -1
- package/src/verticalnavigation.js +1 -1
- package/src/widget.d.ts +13 -13
- package/src/widget.js +14 -14
- package/src/widgetresize/resizer.d.ts +15 -15
- package/src/widgetresize/resizer.js +5 -5
- package/src/widgetresize/resizerstate.d.ts +4 -4
- package/src/widgetresize/resizerstate.js +1 -1
- package/src/widgetresize/sizeview.d.ts +6 -4
- package/src/widgetresize/sizeview.js +3 -1
- package/src/widgetresize.d.ts +11 -11
- package/src/widgetresize.js +4 -4
- package/src/widgettoolbarrepository.d.ts +1 -1
- package/src/widgettoolbarrepository.js +1 -1
- package/src/widgettypearound/utils.d.ts +12 -4
- package/src/widgettypearound/utils.js +8 -0
- package/src/widgettypearound/widgettypearound.d.ts +2 -2
- package/src/widgettypearound/widgettypearound.js +2 -2
@@ -2,15 +2,15 @@
|
|
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 {
|
6
|
-
declare const
|
5
|
+
import type { WidgetResizerOptions } from '../widgetresize.js';
|
6
|
+
declare const WidgetResizeState_base: {
|
7
7
|
new (): import("@ckeditor/ckeditor5-utils").Observable;
|
8
8
|
prototype: import("@ckeditor/ckeditor5-utils").Observable;
|
9
9
|
};
|
10
10
|
/**
|
11
11
|
* Stores the internal state of a single resizable object.
|
12
12
|
*/
|
13
|
-
export
|
13
|
+
export declare class WidgetResizeState extends /* #__PURE__ */ WidgetResizeState_base {
|
14
14
|
/**
|
15
15
|
* The position of the handle that initiated the resizing. E.g. `"top-left"`, `"bottom-right"` etc. or `null`
|
16
16
|
* if unknown.
|
@@ -92,7 +92,7 @@ export default class ResizeState extends /* #__PURE__ */ ResizeState_base {
|
|
92
92
|
/**
|
93
93
|
* @param options Resizer options.
|
94
94
|
*/
|
95
|
-
constructor(options:
|
95
|
+
constructor(options: WidgetResizerOptions);
|
96
96
|
/**
|
97
97
|
* The original width (pixels) of the resized object when the resize process was started.
|
98
98
|
*/
|
@@ -10,7 +10,7 @@ import { calculateResizeHostPercentageWidth } from '../utils.js';
|
|
10
10
|
/**
|
11
11
|
* Stores the internal state of a single resizable object.
|
12
12
|
*/
|
13
|
-
export
|
13
|
+
export class WidgetResizeState extends /* #__PURE__ */ ObservableMixin() {
|
14
14
|
/**
|
15
15
|
* The reference point of the resizer where the dragging started. It is used to measure the distance the user cursor
|
16
16
|
* traveled, so how much the image should be enlarged.
|
@@ -6,12 +6,14 @@
|
|
6
6
|
* @module widget/widgetresize/sizeview
|
7
7
|
*/
|
8
8
|
import { View } from '@ckeditor/ckeditor5-ui';
|
9
|
-
import type {
|
10
|
-
import type
|
9
|
+
import type { WidgetResizerOptions } from '../widgetresize.js';
|
10
|
+
import { type WidgetResizeState } from './resizerstate.js';
|
11
11
|
/**
|
12
12
|
* A view displaying the proposed new element size during the resizing.
|
13
|
+
*
|
14
|
+
* @internal
|
13
15
|
*/
|
14
|
-
export
|
16
|
+
export declare class SizeView extends View {
|
15
17
|
/**
|
16
18
|
* The visibility of the view defined based on the existence of the host proposed dimensions.
|
17
19
|
*
|
@@ -45,7 +47,7 @@ export default class SizeView extends View {
|
|
45
47
|
* @param options An object defining the resizer options, used for setting the proper size label.
|
46
48
|
* @param resizeState The `ResizeState` class instance, used for keeping the `SizeView` state up to date.
|
47
49
|
*/
|
48
|
-
_bindToState(options:
|
50
|
+
_bindToState(options: WidgetResizerOptions, resizeState: WidgetResizeState): void;
|
49
51
|
/**
|
50
52
|
* A method used for cleaning up. It removes the bindings and hides the view.
|
51
53
|
*
|
@@ -8,8 +8,10 @@
|
|
8
8
|
import { View } from '@ckeditor/ckeditor5-ui';
|
9
9
|
/**
|
10
10
|
* A view displaying the proposed new element size during the resizing.
|
11
|
+
*
|
12
|
+
* @internal
|
11
13
|
*/
|
12
|
-
export
|
14
|
+
export class SizeView extends View {
|
13
15
|
constructor() {
|
14
16
|
super();
|
15
17
|
const bind = this.bindTemplate;
|
package/src/widgetresize.d.ts
CHANGED
@@ -5,22 +5,22 @@
|
|
5
5
|
/**
|
6
6
|
* @module widget/widgetresize
|
7
7
|
*/
|
8
|
-
import
|
8
|
+
import { WidgetResizer } from './widgetresize/resizer.js';
|
9
9
|
import { Plugin, type Editor } from '@ckeditor/ckeditor5-core';
|
10
|
-
import { type
|
10
|
+
import { type ModelElement, type ViewContainerElement } from '@ckeditor/ckeditor5-engine';
|
11
11
|
import '../theme/widgetresize.css';
|
12
12
|
/**
|
13
13
|
* The widget resize feature plugin.
|
14
14
|
*
|
15
15
|
* Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
|
16
16
|
*/
|
17
|
-
export
|
17
|
+
export declare class WidgetResize extends Plugin {
|
18
18
|
/**
|
19
19
|
* The currently selected resizer.
|
20
20
|
*
|
21
21
|
* @observable
|
22
22
|
*/
|
23
|
-
selectedResizer:
|
23
|
+
selectedResizer: WidgetResizer | null;
|
24
24
|
/**
|
25
25
|
* References an active resizer.
|
26
26
|
*
|
@@ -29,7 +29,7 @@ export default class WidgetResize extends Plugin {
|
|
29
29
|
* @internal
|
30
30
|
* @observable
|
31
31
|
*/
|
32
|
-
_activeResizer:
|
32
|
+
_activeResizer: WidgetResizer | null;
|
33
33
|
/**
|
34
34
|
* A map of resizers created using this plugin instance.
|
35
35
|
*/
|
@@ -59,7 +59,7 @@ export default class WidgetResize extends Plugin {
|
|
59
59
|
/**
|
60
60
|
* Marks resizer as selected.
|
61
61
|
*/
|
62
|
-
select(resizer:
|
62
|
+
select(resizer: WidgetResizer): void;
|
63
63
|
/**
|
64
64
|
* Deselects currently set resizer.
|
65
65
|
*/
|
@@ -67,13 +67,13 @@ export default class WidgetResize extends Plugin {
|
|
67
67
|
/**
|
68
68
|
* @param options Resizer options.
|
69
69
|
*/
|
70
|
-
attachTo(options:
|
70
|
+
attachTo(options: WidgetResizerOptions): WidgetResizer;
|
71
71
|
/**
|
72
72
|
* Returns a resizer created for a given view element (widget element).
|
73
73
|
*
|
74
74
|
* @param viewElement View element associated with the resizer.
|
75
75
|
*/
|
76
|
-
getResizerByViewElement(viewElement: ViewContainerElement):
|
76
|
+
getResizerByViewElement(viewElement: ViewContainerElement): WidgetResizer | undefined;
|
77
77
|
/**
|
78
78
|
* Returns a resizer that contains a given resize handle.
|
79
79
|
*/
|
@@ -91,12 +91,12 @@ export default class WidgetResize extends Plugin {
|
|
91
91
|
/**
|
92
92
|
* Interface describing a resizer. It allows to specify the resizing host, custom logic for calculating aspect ratio, etc.
|
93
93
|
*/
|
94
|
-
export interface
|
94
|
+
export interface WidgetResizerOptions {
|
95
95
|
/**
|
96
96
|
* Editor instance associated with the resizer.
|
97
97
|
*/
|
98
98
|
editor: Editor;
|
99
|
-
modelElement:
|
99
|
+
modelElement: ModelElement;
|
100
100
|
/**
|
101
101
|
* A view of an element to be resized. Typically it's the main widget's view instance.
|
102
102
|
*/
|
@@ -125,5 +125,5 @@ export interface ResizerOptions {
|
|
125
125
|
onCommit: (newValue: string) => void;
|
126
126
|
getResizeHost: (widgetWrapper: HTMLElement) => HTMLElement;
|
127
127
|
getHandleHost: (widgetWrapper: HTMLElement) => HTMLElement;
|
128
|
-
isCentered?: (resizer:
|
128
|
+
isCentered?: (resizer: WidgetResizer) => boolean;
|
129
129
|
}
|
package/src/widgetresize.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/**
|
6
6
|
* @module widget/widgetresize
|
7
7
|
*/
|
8
|
-
import
|
8
|
+
import { WidgetResizer } from './widgetresize/resizer.js';
|
9
9
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
10
10
|
import { MouseObserver } from '@ckeditor/ckeditor5-engine';
|
11
11
|
import { DomEmitterMixin, global } from '@ckeditor/ckeditor5-utils';
|
@@ -16,7 +16,7 @@ import '../theme/widgetresize.css';
|
|
16
16
|
*
|
17
17
|
* Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
|
18
18
|
*/
|
19
|
-
export
|
19
|
+
export class WidgetResize extends Plugin {
|
20
20
|
/**
|
21
21
|
* A map of resizers created using this plugin instance.
|
22
22
|
*/
|
@@ -116,7 +116,7 @@ export default class WidgetResize extends Plugin {
|
|
116
116
|
* @param options Resizer options.
|
117
117
|
*/
|
118
118
|
attachTo(options) {
|
119
|
-
const resizer = new
|
119
|
+
const resizer = new WidgetResizer(options);
|
120
120
|
const plugins = this.editor.plugins;
|
121
121
|
resizer.attach();
|
122
122
|
if (plugins.has('WidgetToolbarRepository')) {
|
@@ -165,7 +165,7 @@ export default class WidgetResize extends Plugin {
|
|
165
165
|
*/
|
166
166
|
_mouseDownListener(event, domEventData) {
|
167
167
|
const resizeHandle = domEventData.domTarget;
|
168
|
-
if (!
|
168
|
+
if (!WidgetResizer.isResizeHandle(resizeHandle)) {
|
169
169
|
return;
|
170
170
|
}
|
171
171
|
this._activeResizer = this._getResizerByHandle(resizeHandle) || null;
|
@@ -35,7 +35,7 @@ import { type PositioningFunction } from '@ckeditor/ckeditor5-utils';
|
|
35
35
|
* }
|
36
36
|
* ```
|
37
37
|
*/
|
38
|
-
export
|
38
|
+
export declare class WidgetToolbarRepository extends Plugin {
|
39
39
|
/**
|
40
40
|
* A map of toolbar definitions.
|
41
41
|
*/
|
@@ -2,18 +2,22 @@
|
|
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 {
|
5
|
+
import type { ModelDocumentSelection, ViewDomConverter, ModelElement, ModelSchema, ModelSelection, ViewElement } from '@ckeditor/ckeditor5-engine';
|
6
6
|
/**
|
7
7
|
* The name of the type around model selection attribute responsible for
|
8
8
|
* displaying a fake caret next to a selected widget.
|
9
|
+
*
|
10
|
+
* @internal
|
9
11
|
*/
|
10
12
|
export declare const TYPE_AROUND_SELECTION_ATTRIBUTE = "widget-type-around";
|
11
13
|
/**
|
12
14
|
* Checks if an element is a widget that qualifies to get the widget type around UI.
|
13
15
|
*/
|
14
|
-
export declare function isTypeAroundWidget(viewElement: ViewElement | undefined, modelElement:
|
16
|
+
export declare function isTypeAroundWidget(viewElement: ViewElement | undefined, modelElement: ModelElement, schema: ModelSchema): boolean;
|
15
17
|
/**
|
16
18
|
* For the passed HTML element, this helper finds the closest widget type around button ancestor.
|
19
|
+
*
|
20
|
+
* @internal
|
17
21
|
*/
|
18
22
|
export declare function getClosestTypeAroundDomButton(domElement: HTMLElement): HTMLElement | null;
|
19
23
|
/**
|
@@ -21,18 +25,22 @@ export declare function getClosestTypeAroundDomButton(domElement: HTMLElement):
|
|
21
25
|
* the paragraph would be inserted into the content if, for instance, the button was
|
22
26
|
* clicked by the user.
|
23
27
|
*
|
28
|
+
* @internal
|
24
29
|
* @returns The position of the button.
|
25
30
|
*/
|
26
31
|
export declare function getTypeAroundButtonPosition(domElement: HTMLElement): 'before' | 'after';
|
27
32
|
/**
|
28
33
|
* For the passed HTML element, this helper returns the closest view widget ancestor.
|
34
|
+
*
|
35
|
+
* @internal
|
29
36
|
*/
|
30
|
-
export declare function getClosestWidgetViewElement(domElement: HTMLElement, domConverter:
|
37
|
+
export declare function getClosestWidgetViewElement(domElement: HTMLElement, domConverter: ViewDomConverter): ViewElement;
|
31
38
|
/**
|
32
39
|
* For the passed selection instance, it returns the position of the fake caret displayed next to a widget.
|
33
40
|
*
|
34
41
|
* **Note**: If the fake caret is not currently displayed, `null` is returned.
|
35
42
|
*
|
43
|
+
* @internal
|
36
44
|
* @returns The position of the fake caret or `null` when none is present.
|
37
45
|
*/
|
38
|
-
export declare function getTypeAroundFakeCaretPosition(selection:
|
46
|
+
export declare function getTypeAroundFakeCaretPosition(selection: ModelSelection | ModelDocumentSelection): 'before' | 'after' | null;
|
@@ -9,6 +9,8 @@ import { isWidget } from '../utils.js';
|
|
9
9
|
/**
|
10
10
|
* The name of the type around model selection attribute responsible for
|
11
11
|
* displaying a fake caret next to a selected widget.
|
12
|
+
*
|
13
|
+
* @internal
|
12
14
|
*/
|
13
15
|
export const TYPE_AROUND_SELECTION_ATTRIBUTE = 'widget-type-around';
|
14
16
|
/**
|
@@ -19,6 +21,8 @@ export function isTypeAroundWidget(viewElement, modelElement, schema) {
|
|
19
21
|
}
|
20
22
|
/**
|
21
23
|
* For the passed HTML element, this helper finds the closest widget type around button ancestor.
|
24
|
+
*
|
25
|
+
* @internal
|
22
26
|
*/
|
23
27
|
export function getClosestTypeAroundDomButton(domElement) {
|
24
28
|
return domElement.closest('.ck-widget__type-around__button');
|
@@ -28,6 +32,7 @@ export function getClosestTypeAroundDomButton(domElement) {
|
|
28
32
|
* the paragraph would be inserted into the content if, for instance, the button was
|
29
33
|
* clicked by the user.
|
30
34
|
*
|
35
|
+
* @internal
|
31
36
|
* @returns The position of the button.
|
32
37
|
*/
|
33
38
|
export function getTypeAroundButtonPosition(domElement) {
|
@@ -35,6 +40,8 @@ export function getTypeAroundButtonPosition(domElement) {
|
|
35
40
|
}
|
36
41
|
/**
|
37
42
|
* For the passed HTML element, this helper returns the closest view widget ancestor.
|
43
|
+
*
|
44
|
+
* @internal
|
38
45
|
*/
|
39
46
|
export function getClosestWidgetViewElement(domElement, domConverter) {
|
40
47
|
const widgetDomElement = domElement.closest('.ck-widget');
|
@@ -45,6 +52,7 @@ export function getClosestWidgetViewElement(domElement, domConverter) {
|
|
45
52
|
*
|
46
53
|
* **Note**: If the fake caret is not currently displayed, `null` is returned.
|
47
54
|
*
|
55
|
+
* @internal
|
48
56
|
* @returns The position of the fake caret or `null` when none is present.
|
49
57
|
*/
|
50
58
|
export function getTypeAroundFakeCaretPosition(selection) {
|
@@ -19,7 +19,7 @@ import '../../theme/widgettypearound.css';
|
|
19
19
|
* user if the widget is next to the "tight spot". Once clicked, a paragraph is created with the selection anchored
|
20
20
|
* in it so that users can type (or insert content, paste, etc.) straight away.
|
21
21
|
*/
|
22
|
-
export
|
22
|
+
export declare class WidgetTypeAround extends Plugin {
|
23
23
|
/**
|
24
24
|
* A reference to the model widget element that has the fake caret active
|
25
25
|
* on either side of it. It is later used to remove CSS classes associated with the fake caret
|
@@ -82,7 +82,7 @@ export default class WidgetTypeAround extends Plugin {
|
|
82
82
|
* Creates a listener in the editing conversion pipeline that injects the widget type around
|
83
83
|
* UI into every single widget instance created in the editor.
|
84
84
|
*
|
85
|
-
* The UI is delivered as a {@link module:engine/view/uielement~
|
85
|
+
* The UI is delivered as a {@link module:engine/view/uielement~ViewUIElement}
|
86
86
|
* wrapper which renders DOM buttons that users can use to insert paragraphs.
|
87
87
|
*/
|
88
88
|
private _enableTypeAroundUIInjection;
|
@@ -29,7 +29,7 @@ const PLUGIN_DISABLED_EDITING_ROOT_CLASS = 'ck-widget__type-around_disabled';
|
|
29
29
|
* user if the widget is next to the "tight spot". Once clicked, a paragraph is created with the selection anchored
|
30
30
|
* in it so that users can type (or insert content, paste, etc.) straight away.
|
31
31
|
*/
|
32
|
-
export
|
32
|
+
export class WidgetTypeAround extends Plugin {
|
33
33
|
/**
|
34
34
|
* A reference to the model widget element that has the fake caret active
|
35
35
|
* on either side of it. It is later used to remove CSS classes associated with the fake caret
|
@@ -165,7 +165,7 @@ export default class WidgetTypeAround extends Plugin {
|
|
165
165
|
* Creates a listener in the editing conversion pipeline that injects the widget type around
|
166
166
|
* UI into every single widget instance created in the editor.
|
167
167
|
*
|
168
|
-
* The UI is delivered as a {@link module:engine/view/uielement~
|
168
|
+
* The UI is delivered as a {@link module:engine/view/uielement~ViewUIElement}
|
169
169
|
* wrapper which renders DOM buttons that users can use to insert paragraphs.
|
170
170
|
*/
|
171
171
|
_enableTypeAroundUIInjection() {
|