@ckeditor/ckeditor5-widget 48.2.0-alpha.7 → 48.3.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.
@@ -1,101 +1,101 @@
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/widgettoolbarrepository
7
- */
8
- import { Plugin, type ToolbarConfigItem } from '@ckeditor/ckeditor5-core';
9
- import type { ViewDocumentSelection, ViewElement } from '@ckeditor/ckeditor5-engine';
10
- import { ContextualBalloon } from '@ckeditor/ckeditor5-ui';
11
- import { type PositioningFunction } from '@ckeditor/ckeditor5-utils';
6
+ * @module widget/widgettoolbarrepository
7
+ */
8
+ import { Plugin, type ToolbarConfigItem, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
9
+ import type { ViewDocumentSelection, ViewElement } from "@ckeditor/ckeditor5-engine";
10
+ import { ContextualBalloon } from "@ckeditor/ckeditor5-ui";
11
+ import { type PositioningFunction } from "@ckeditor/ckeditor5-utils";
12
12
  /**
13
- * Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole
14
- * toolbar rendering process and exposes a concise API.
15
- *
16
- * To add a toolbar for your widget use the {@link ~WidgetToolbarRepository#register `WidgetToolbarRepository#register()`} method.
17
- *
18
- * The following example comes from the {@link module:image/imagetoolbar~ImageToolbar} plugin:
19
- *
20
- * ```ts
21
- * class ImageToolbar extends Plugin {
22
- * static get requires() {
23
- * return [ WidgetToolbarRepository ];
24
- * }
25
- *
26
- * afterInit() {
27
- * const editor = this.editor;
28
- * const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
29
- *
30
- * widgetToolbarRepository.register( 'image', {
31
- * items: editor.config.get( 'image.toolbar' ),
32
- * getRelatedElement: getClosestSelectedImageWidget
33
- * } );
34
- * }
35
- * }
36
- * ```
37
- */
13
+ * Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole
14
+ * toolbar rendering process and exposes a concise API.
15
+ *
16
+ * To add a toolbar for your widget use the {@link ~WidgetToolbarRepository#register `WidgetToolbarRepository#register()`} method.
17
+ *
18
+ * The following example comes from the {@link module:image/imagetoolbar~ImageToolbar} plugin:
19
+ *
20
+ * ```ts
21
+ * class ImageToolbar extends Plugin {
22
+ * static get requires(): PluginDependenciesOf<[ WidgetToolbarRepository ]> {
23
+ * return [ WidgetToolbarRepository ];
24
+ * }
25
+ *
26
+ * afterInit() {
27
+ * const editor = this.editor;
28
+ * const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
29
+ *
30
+ * widgetToolbarRepository.register( 'image', {
31
+ * items: editor.config.get( 'image.toolbar' ),
32
+ * getRelatedElement: getClosestSelectedImageWidget
33
+ * } );
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
38
  export declare class WidgetToolbarRepository extends Plugin {
39
- /**
40
- * A map of toolbar definitions.
41
- */
42
- private _toolbarDefinitions;
43
- private _balloon;
44
- /**
45
- * @inheritDoc
46
- */
47
- static get requires(): readonly [typeof ContextualBalloon];
48
- /**
49
- * @inheritDoc
50
- */
51
- static get pluginName(): "WidgetToolbarRepository";
52
- /**
53
- * @inheritDoc
54
- */
55
- static get isOfficialPlugin(): true;
56
- /**
57
- * @inheritDoc
58
- */
59
- init(): void;
60
- destroy(): void;
61
- /**
62
- * Registers toolbar in the WidgetToolbarRepository. It renders it in the `ContextualBalloon` based on the value of the invoked
63
- * `getRelatedElement` function. Toolbar items are gathered from `items` array.
64
- * The balloon's CSS class is by default `ck-toolbar-container` and may be override with the `balloonClassName` option.
65
- *
66
- * Note: This method should be called in the {@link module:core/plugin~PluginInterface#afterInit `Plugin#afterInit()`}
67
- * callback (or later) to make sure that the given toolbar items were already registered by other plugins.
68
- *
69
- * @param toolbarId An id for the toolbar. Used to
70
- * @param options Detailed options
71
- * @param options.ariaLabel Label used by assistive technologies to describe this toolbar element.
72
- * @param options.items Array of toolbar items.
73
- * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
74
- * @param options.balloonClassName CSS class for the widget balloon.
75
- */
76
- register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName, positions }: {
77
- ariaLabel?: string;
78
- items: Array<ToolbarConfigItem>;
79
- getRelatedElement: (selection: ViewDocumentSelection) => (ViewElement | null);
80
- balloonClassName?: string;
81
- positions?: ReadonlyArray<PositioningFunction>;
82
- }): void;
83
- /**
84
- * Iterates over stored toolbars and makes them visible or hidden.
85
- */
86
- private _updateToolbarsVisibility;
87
- /**
88
- * Hides the given toolbar.
89
- */
90
- private _hideToolbar;
91
- /**
92
- * Shows up the toolbar if the toolbar is not visible.
93
- * Otherwise, repositions the toolbar's balloon when toolbar's view is the most top view in balloon stack.
94
- *
95
- * It might happen here that the toolbar's view is under another view. Then do nothing as the other toolbar view
96
- * should be still visible after the {@link module:ui/editorui/editorui~EditorUI#event:update}.
97
- */
98
- private _showToolbar;
99
- private _isToolbarVisible;
100
- private _isToolbarInBalloon;
39
+ /**
40
+ * A map of toolbar definitions.
41
+ */
42
+ private _toolbarDefinitions;
43
+ private _balloon;
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ static get requires(): PluginDependenciesOf<[ContextualBalloon]>;
48
+ /**
49
+ * @inheritDoc
50
+ */
51
+ static get pluginName(): "WidgetToolbarRepository";
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ static override get isOfficialPlugin(): true;
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ init(): void;
60
+ override destroy(): void;
61
+ /**
62
+ * Registers toolbar in the WidgetToolbarRepository. It renders it in the `ContextualBalloon` based on the value of the invoked
63
+ * `getRelatedElement` function. Toolbar items are gathered from `items` array.
64
+ * The balloon's CSS class is by default `ck-toolbar-container` and may be override with the `balloonClassName` option.
65
+ *
66
+ * Note: This method should be called in the {@link module:core/plugin~PluginInterface#afterInit `Plugin#afterInit()`}
67
+ * callback (or later) to make sure that the given toolbar items were already registered by other plugins.
68
+ *
69
+ * @param toolbarId An id for the toolbar. Used to
70
+ * @param options Detailed options
71
+ * @param options.ariaLabel Label used by assistive technologies to describe this toolbar element.
72
+ * @param options.items Array of toolbar items.
73
+ * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
74
+ * @param options.balloonClassName CSS class for the widget balloon.
75
+ */
76
+ register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName, positions }: {
77
+ ariaLabel?: string;
78
+ items: Array<ToolbarConfigItem>;
79
+ getRelatedElement: (selection: ViewDocumentSelection) => (ViewElement | null);
80
+ balloonClassName?: string;
81
+ positions?: ReadonlyArray<PositioningFunction>;
82
+ }): void;
83
+ /**
84
+ * Iterates over stored toolbars and makes them visible or hidden.
85
+ */
86
+ private _updateToolbarsVisibility;
87
+ /**
88
+ * Hides the given toolbar.
89
+ */
90
+ private _hideToolbar;
91
+ /**
92
+ * Shows up the toolbar if the toolbar is not visible.
93
+ * Otherwise, repositions the toolbar's balloon when toolbar's view is the most top view in balloon stack.
94
+ *
95
+ * It might happen here that the toolbar's view is under another view. Then do nothing as the other toolbar view
96
+ * should be still visible after the {@link module:ui/editorui/editorui~EditorUI#event:update}.
97
+ */
98
+ private _showToolbar;
99
+ private _isToolbarVisible;
100
+ private _isToolbarInBalloon;
101
101
  }
@@ -1,46 +1,46 @@
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 { ModelDocumentSelection, ViewDomConverter, ModelElement, ModelSchema, ModelSelection, ViewElement } from '@ckeditor/ckeditor5-engine';
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 { ModelDocumentSelection, ViewDomConverter, ModelElement, ModelSchema, ModelSelection, ViewElement } from "@ckeditor/ckeditor5-engine";
6
6
  /**
7
- * The name of the type around model selection attribute responsible for
8
- * displaying a fake caret next to a selected widget.
9
- *
10
- * @internal
11
- */
7
+ * The name of the type around model selection attribute responsible for
8
+ * displaying a fake caret next to a selected widget.
9
+ *
10
+ * @internal
11
+ */
12
12
  export declare const TYPE_AROUND_SELECTION_ATTRIBUTE = "widget-type-around";
13
13
  /**
14
- * Checks if an element is a widget that qualifies to get the widget type around UI.
15
- */
14
+ * Checks if an element is a widget that qualifies to get the widget type around UI.
15
+ */
16
16
  export declare function isTypeAroundWidget(viewElement: ViewElement | undefined, modelElement: ModelElement, schema: ModelSchema): boolean;
17
17
  /**
18
- * For the passed HTML element, this helper finds the closest widget type around button ancestor.
19
- *
20
- * @internal
21
- */
18
+ * For the passed HTML element, this helper finds the closest widget type around button ancestor.
19
+ *
20
+ * @internal
21
+ */
22
22
  export declare function getClosestTypeAroundDomButton(domElement: HTMLElement): HTMLElement | null;
23
23
  /**
24
- * For the passed widget type around button element, this helper determines at which position
25
- * the paragraph would be inserted into the content if, for instance, the button was
26
- * clicked by the user.
27
- *
28
- * @internal
29
- * @returns The position of the button.
30
- */
31
- export declare function getTypeAroundButtonPosition(domElement: HTMLElement): 'before' | 'after';
24
+ * For the passed widget type around button element, this helper determines at which position
25
+ * the paragraph would be inserted into the content if, for instance, the button was
26
+ * clicked by the user.
27
+ *
28
+ * @internal
29
+ * @returns The position of the button.
30
+ */
31
+ export declare function getTypeAroundButtonPosition(domElement: HTMLElement): "before" | "after";
32
32
  /**
33
- * For the passed HTML element, this helper returns the closest view widget ancestor.
34
- *
35
- * @internal
36
- */
33
+ * For the passed HTML element, this helper returns the closest view widget ancestor.
34
+ *
35
+ * @internal
36
+ */
37
37
  export declare function getClosestWidgetViewElement(domElement: HTMLElement, domConverter: ViewDomConverter): ViewElement;
38
38
  /**
39
- * For the passed selection instance, it returns the position of the fake caret displayed next to a widget.
40
- *
41
- * **Note**: If the fake caret is not currently displayed, `null` is returned.
42
- *
43
- * @internal
44
- * @returns The position of the fake caret or `null` when none is present.
45
- */
46
- export declare function getTypeAroundFakeCaretPosition(selection: ModelSelection | ModelDocumentSelection): 'before' | 'after' | null;
39
+ * For the passed selection instance, it returns the position of the fake caret displayed next to a widget.
40
+ *
41
+ * **Note**: If the fake caret is not currently displayed, `null` is returned.
42
+ *
43
+ * @internal
44
+ * @returns The position of the fake caret or `null` when none is present.
45
+ */
46
+ export declare function getTypeAroundFakeCaretPosition(selection: ModelSelection | ModelDocumentSelection): "before" | "after" | null;