@ckeditor/ckeditor5-widget 39.0.1 → 40.0.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +3 -3
  4. package/lang/translations/ar.po +1 -0
  5. package/lang/translations/az.po +1 -0
  6. package/lang/translations/bg.po +1 -0
  7. package/lang/translations/bn.po +1 -0
  8. package/lang/translations/ca.po +1 -0
  9. package/lang/translations/cs.po +1 -0
  10. package/lang/translations/da.po +1 -0
  11. package/lang/translations/de-ch.po +1 -0
  12. package/lang/translations/de.po +1 -0
  13. package/lang/translations/el.po +1 -0
  14. package/lang/translations/en-au.po +1 -0
  15. package/lang/translations/en.po +1 -0
  16. package/lang/translations/es.po +1 -0
  17. package/lang/translations/et.po +1 -0
  18. package/lang/translations/fa.po +1 -0
  19. package/lang/translations/fi.po +1 -0
  20. package/lang/translations/fr.po +1 -0
  21. package/lang/translations/gl.po +1 -0
  22. package/lang/translations/he.po +1 -0
  23. package/lang/translations/hi.po +1 -0
  24. package/lang/translations/hr.po +1 -0
  25. package/lang/translations/hu.po +1 -0
  26. package/lang/translations/id.po +1 -0
  27. package/lang/translations/it.po +1 -0
  28. package/lang/translations/ja.po +1 -0
  29. package/lang/translations/ko.po +1 -0
  30. package/lang/translations/ku.po +1 -0
  31. package/lang/translations/lt.po +1 -0
  32. package/lang/translations/lv.po +1 -0
  33. package/lang/translations/ms.po +1 -0
  34. package/lang/translations/nl.po +1 -0
  35. package/lang/translations/no.po +1 -0
  36. package/lang/translations/pl.po +1 -0
  37. package/lang/translations/pt-br.po +1 -0
  38. package/lang/translations/pt.po +1 -0
  39. package/lang/translations/ro.po +1 -0
  40. package/lang/translations/ru.po +1 -0
  41. package/lang/translations/sk.po +1 -0
  42. package/lang/translations/sq.po +1 -0
  43. package/lang/translations/sr-latn.po +1 -0
  44. package/lang/translations/sr.po +1 -0
  45. package/lang/translations/sv.po +1 -0
  46. package/lang/translations/th.po +1 -0
  47. package/lang/translations/tk.po +1 -0
  48. package/lang/translations/tr.po +1 -0
  49. package/lang/translations/uk.po +1 -0
  50. package/lang/translations/ur.po +1 -0
  51. package/lang/translations/uz.po +1 -0
  52. package/lang/translations/vi.po +1 -0
  53. package/lang/translations/zh-cn.po +1 -0
  54. package/lang/translations/zh.po +1 -0
  55. package/package.json +7 -11
  56. package/src/augmentation.d.ts +13 -13
  57. package/src/augmentation.js +5 -5
  58. package/src/highlightstack.d.ts +74 -74
  59. package/src/highlightstack.js +129 -129
  60. package/src/index.d.ts +13 -13
  61. package/src/index.js +13 -13
  62. package/src/utils.d.ts +198 -198
  63. package/src/utils.js +348 -348
  64. package/src/verticalnavigation.d.ts +15 -15
  65. package/src/verticalnavigation.js +196 -196
  66. package/src/widget.d.ts +91 -91
  67. package/src/widget.js +380 -380
  68. package/src/widgetresize/resizer.d.ts +177 -177
  69. package/src/widgetresize/resizer.js +372 -372
  70. package/src/widgetresize/resizerstate.d.ts +125 -125
  71. package/src/widgetresize/resizerstate.js +150 -150
  72. package/src/widgetresize/sizeview.d.ts +55 -55
  73. package/src/widgetresize/sizeview.js +63 -63
  74. package/src/widgetresize.d.ts +125 -125
  75. package/src/widgetresize.js +188 -188
  76. package/src/widgettoolbarrepository.d.ts +94 -94
  77. package/src/widgettoolbarrepository.js +268 -268
  78. package/src/widgettypearound/utils.d.ts +38 -38
  79. package/src/widgettypearound/utils.js +52 -52
  80. package/src/widgettypearound/widgettypearound.d.ts +229 -229
  81. package/src/widgettypearound/widgettypearound.js +773 -773
@@ -1,188 +1,188 @@
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
- /**
6
- * @module widget/widgetresize
7
- */
8
- import Resizer from './widgetresize/resizer';
9
- import { Plugin } from '@ckeditor/ckeditor5-core';
10
- import { MouseObserver } from '@ckeditor/ckeditor5-engine';
11
- import { DomEmitterMixin, global } from '@ckeditor/ckeditor5-utils';
12
- import { throttle } from 'lodash-es';
13
- import '../theme/widgetresize.css';
14
- /**
15
- * The widget resize feature plugin.
16
- *
17
- * Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
18
- */
19
- export default class WidgetResize extends Plugin {
20
- constructor() {
21
- super(...arguments);
22
- /**
23
- * A map of resizers created using this plugin instance.
24
- */
25
- this._resizers = new Map();
26
- }
27
- /**
28
- * @inheritDoc
29
- */
30
- static get pluginName() {
31
- return 'WidgetResize';
32
- }
33
- /**
34
- * @inheritDoc
35
- */
36
- init() {
37
- const editing = this.editor.editing;
38
- const domDocument = global.window.document;
39
- this.set('selectedResizer', null);
40
- this.set('_activeResizer', null);
41
- editing.view.addObserver(MouseObserver);
42
- this._observer = new (DomEmitterMixin())();
43
- this.listenTo(editing.view.document, 'mousedown', this._mouseDownListener.bind(this), { priority: 'high' });
44
- this._observer.listenTo(domDocument, 'mousemove', this._mouseMoveListener.bind(this));
45
- this._observer.listenTo(domDocument, 'mouseup', this._mouseUpListener.bind(this));
46
- this._redrawSelectedResizerThrottled = throttle(() => this.redrawSelectedResizer(), 200);
47
- // Redrawing on any change of the UI of the editor (including content changes).
48
- this.editor.ui.on('update', this._redrawSelectedResizerThrottled);
49
- // Remove view widget-resizer mappings for widgets that have been removed from the document.
50
- // https://github.com/ckeditor/ckeditor5/issues/10156
51
- // https://github.com/ckeditor/ckeditor5/issues/10266
52
- this.editor.model.document.on('change', () => {
53
- for (const [viewElement, resizer] of this._resizers) {
54
- if (!viewElement.isAttached()) {
55
- this._resizers.delete(viewElement);
56
- resizer.destroy();
57
- }
58
- }
59
- }, { priority: 'lowest' });
60
- // Resizers need to be redrawn upon window resize, because new window might shrink resize host.
61
- this._observer.listenTo(global.window, 'resize', this._redrawSelectedResizerThrottled);
62
- const viewSelection = this.editor.editing.view.document.selection;
63
- viewSelection.on('change', () => {
64
- const selectedElement = viewSelection.getSelectedElement();
65
- const resizer = this.getResizerByViewElement(selectedElement) || null;
66
- if (resizer) {
67
- this.select(resizer);
68
- }
69
- else {
70
- this.deselect();
71
- }
72
- });
73
- }
74
- /**
75
- * Redraws the selected resizer if there is any selected resizer and if it is visible.
76
- */
77
- redrawSelectedResizer() {
78
- if (this.selectedResizer && this.selectedResizer.isVisible) {
79
- this.selectedResizer.redraw();
80
- }
81
- }
82
- /**
83
- * @inheritDoc
84
- */
85
- destroy() {
86
- super.destroy();
87
- this._observer.stopListening();
88
- for (const resizer of this._resizers.values()) {
89
- resizer.destroy();
90
- }
91
- this._redrawSelectedResizerThrottled.cancel();
92
- }
93
- /**
94
- * Marks resizer as selected.
95
- */
96
- select(resizer) {
97
- this.deselect();
98
- this.selectedResizer = resizer;
99
- this.selectedResizer.isSelected = true;
100
- }
101
- /**
102
- * Deselects currently set resizer.
103
- */
104
- deselect() {
105
- if (this.selectedResizer) {
106
- this.selectedResizer.isSelected = false;
107
- }
108
- this.selectedResizer = null;
109
- }
110
- /**
111
- * @param options Resizer options.
112
- */
113
- attachTo(options) {
114
- const resizer = new Resizer(options);
115
- const plugins = this.editor.plugins;
116
- resizer.attach();
117
- if (plugins.has('WidgetToolbarRepository')) {
118
- // Hiding widget toolbar to improve the performance
119
- // (https://github.com/ckeditor/ckeditor5-widget/pull/112#issuecomment-564528765).
120
- const widgetToolbarRepository = plugins.get('WidgetToolbarRepository');
121
- resizer.on('begin', () => {
122
- widgetToolbarRepository.forceDisabled('resize');
123
- }, { priority: 'lowest' });
124
- resizer.on('cancel', () => {
125
- widgetToolbarRepository.clearForceDisabled('resize');
126
- }, { priority: 'highest' });
127
- resizer.on('commit', () => {
128
- widgetToolbarRepository.clearForceDisabled('resize');
129
- }, { priority: 'highest' });
130
- }
131
- this._resizers.set(options.viewElement, resizer);
132
- const viewSelection = this.editor.editing.view.document.selection;
133
- const selectedElement = viewSelection.getSelectedElement();
134
- // If the element the resizer is created for is currently focused, it should become visible.
135
- if (this.getResizerByViewElement(selectedElement) == resizer) {
136
- this.select(resizer);
137
- }
138
- return resizer;
139
- }
140
- /**
141
- * Returns a resizer created for a given view element (widget element).
142
- *
143
- * @param viewElement View element associated with the resizer.
144
- */
145
- getResizerByViewElement(viewElement) {
146
- return this._resizers.get(viewElement);
147
- }
148
- /**
149
- * Returns a resizer that contains a given resize handle.
150
- */
151
- _getResizerByHandle(domResizeHandle) {
152
- for (const resizer of this._resizers.values()) {
153
- if (resizer.containsHandle(domResizeHandle)) {
154
- return resizer;
155
- }
156
- }
157
- }
158
- /**
159
- * @param domEventData Native DOM event.
160
- */
161
- _mouseDownListener(event, domEventData) {
162
- const resizeHandle = domEventData.domTarget;
163
- if (!Resizer.isResizeHandle(resizeHandle)) {
164
- return;
165
- }
166
- this._activeResizer = this._getResizerByHandle(resizeHandle) || null;
167
- if (this._activeResizer) {
168
- this._activeResizer.begin(resizeHandle);
169
- // Do not call other events when resizing. See: #6755.
170
- event.stop();
171
- domEventData.preventDefault();
172
- }
173
- }
174
- /**
175
- * @param domEventData Native DOM event.
176
- */
177
- _mouseMoveListener(event, domEventData) {
178
- if (this._activeResizer) {
179
- this._activeResizer.updateSize(domEventData);
180
- }
181
- }
182
- _mouseUpListener() {
183
- if (this._activeResizer) {
184
- this._activeResizer.commit();
185
- this._activeResizer = null;
186
- }
187
- }
188
- }
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
+ /**
6
+ * @module widget/widgetresize
7
+ */
8
+ import Resizer from './widgetresize/resizer';
9
+ import { Plugin } from '@ckeditor/ckeditor5-core';
10
+ import { MouseObserver } from '@ckeditor/ckeditor5-engine';
11
+ import { DomEmitterMixin, global } from '@ckeditor/ckeditor5-utils';
12
+ import { throttle } from 'lodash-es';
13
+ import '../theme/widgetresize.css';
14
+ /**
15
+ * The widget resize feature plugin.
16
+ *
17
+ * Use the {@link module:widget/widgetresize~WidgetResize#attachTo} method to create a resizer for the specified widget.
18
+ */
19
+ export default class WidgetResize extends Plugin {
20
+ constructor() {
21
+ super(...arguments);
22
+ /**
23
+ * A map of resizers created using this plugin instance.
24
+ */
25
+ this._resizers = new Map();
26
+ }
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get pluginName() {
31
+ return 'WidgetResize';
32
+ }
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ init() {
37
+ const editing = this.editor.editing;
38
+ const domDocument = global.window.document;
39
+ this.set('selectedResizer', null);
40
+ this.set('_activeResizer', null);
41
+ editing.view.addObserver(MouseObserver);
42
+ this._observer = new (DomEmitterMixin())();
43
+ this.listenTo(editing.view.document, 'mousedown', this._mouseDownListener.bind(this), { priority: 'high' });
44
+ this._observer.listenTo(domDocument, 'mousemove', this._mouseMoveListener.bind(this));
45
+ this._observer.listenTo(domDocument, 'mouseup', this._mouseUpListener.bind(this));
46
+ this._redrawSelectedResizerThrottled = throttle(() => this.redrawSelectedResizer(), 200);
47
+ // Redrawing on any change of the UI of the editor (including content changes).
48
+ this.editor.ui.on('update', this._redrawSelectedResizerThrottled);
49
+ // Remove view widget-resizer mappings for widgets that have been removed from the document.
50
+ // https://github.com/ckeditor/ckeditor5/issues/10156
51
+ // https://github.com/ckeditor/ckeditor5/issues/10266
52
+ this.editor.model.document.on('change', () => {
53
+ for (const [viewElement, resizer] of this._resizers) {
54
+ if (!viewElement.isAttached()) {
55
+ this._resizers.delete(viewElement);
56
+ resizer.destroy();
57
+ }
58
+ }
59
+ }, { priority: 'lowest' });
60
+ // Resizers need to be redrawn upon window resize, because new window might shrink resize host.
61
+ this._observer.listenTo(global.window, 'resize', this._redrawSelectedResizerThrottled);
62
+ const viewSelection = this.editor.editing.view.document.selection;
63
+ viewSelection.on('change', () => {
64
+ const selectedElement = viewSelection.getSelectedElement();
65
+ const resizer = this.getResizerByViewElement(selectedElement) || null;
66
+ if (resizer) {
67
+ this.select(resizer);
68
+ }
69
+ else {
70
+ this.deselect();
71
+ }
72
+ });
73
+ }
74
+ /**
75
+ * Redraws the selected resizer if there is any selected resizer and if it is visible.
76
+ */
77
+ redrawSelectedResizer() {
78
+ if (this.selectedResizer && this.selectedResizer.isVisible) {
79
+ this.selectedResizer.redraw();
80
+ }
81
+ }
82
+ /**
83
+ * @inheritDoc
84
+ */
85
+ destroy() {
86
+ super.destroy();
87
+ this._observer.stopListening();
88
+ for (const resizer of this._resizers.values()) {
89
+ resizer.destroy();
90
+ }
91
+ this._redrawSelectedResizerThrottled.cancel();
92
+ }
93
+ /**
94
+ * Marks resizer as selected.
95
+ */
96
+ select(resizer) {
97
+ this.deselect();
98
+ this.selectedResizer = resizer;
99
+ this.selectedResizer.isSelected = true;
100
+ }
101
+ /**
102
+ * Deselects currently set resizer.
103
+ */
104
+ deselect() {
105
+ if (this.selectedResizer) {
106
+ this.selectedResizer.isSelected = false;
107
+ }
108
+ this.selectedResizer = null;
109
+ }
110
+ /**
111
+ * @param options Resizer options.
112
+ */
113
+ attachTo(options) {
114
+ const resizer = new Resizer(options);
115
+ const plugins = this.editor.plugins;
116
+ resizer.attach();
117
+ if (plugins.has('WidgetToolbarRepository')) {
118
+ // Hiding widget toolbar to improve the performance
119
+ // (https://github.com/ckeditor/ckeditor5-widget/pull/112#issuecomment-564528765).
120
+ const widgetToolbarRepository = plugins.get('WidgetToolbarRepository');
121
+ resizer.on('begin', () => {
122
+ widgetToolbarRepository.forceDisabled('resize');
123
+ }, { priority: 'lowest' });
124
+ resizer.on('cancel', () => {
125
+ widgetToolbarRepository.clearForceDisabled('resize');
126
+ }, { priority: 'highest' });
127
+ resizer.on('commit', () => {
128
+ widgetToolbarRepository.clearForceDisabled('resize');
129
+ }, { priority: 'highest' });
130
+ }
131
+ this._resizers.set(options.viewElement, resizer);
132
+ const viewSelection = this.editor.editing.view.document.selection;
133
+ const selectedElement = viewSelection.getSelectedElement();
134
+ // If the element the resizer is created for is currently focused, it should become visible.
135
+ if (this.getResizerByViewElement(selectedElement) == resizer) {
136
+ this.select(resizer);
137
+ }
138
+ return resizer;
139
+ }
140
+ /**
141
+ * Returns a resizer created for a given view element (widget element).
142
+ *
143
+ * @param viewElement View element associated with the resizer.
144
+ */
145
+ getResizerByViewElement(viewElement) {
146
+ return this._resizers.get(viewElement);
147
+ }
148
+ /**
149
+ * Returns a resizer that contains a given resize handle.
150
+ */
151
+ _getResizerByHandle(domResizeHandle) {
152
+ for (const resizer of this._resizers.values()) {
153
+ if (resizer.containsHandle(domResizeHandle)) {
154
+ return resizer;
155
+ }
156
+ }
157
+ }
158
+ /**
159
+ * @param domEventData Native DOM event.
160
+ */
161
+ _mouseDownListener(event, domEventData) {
162
+ const resizeHandle = domEventData.domTarget;
163
+ if (!Resizer.isResizeHandle(resizeHandle)) {
164
+ return;
165
+ }
166
+ this._activeResizer = this._getResizerByHandle(resizeHandle) || null;
167
+ if (this._activeResizer) {
168
+ this._activeResizer.begin(resizeHandle);
169
+ // Do not call other events when resizing. See: #6755.
170
+ event.stop();
171
+ domEventData.preventDefault();
172
+ }
173
+ }
174
+ /**
175
+ * @param domEventData Native DOM event.
176
+ */
177
+ _mouseMoveListener(event, domEventData) {
178
+ if (this._activeResizer) {
179
+ this._activeResizer.updateSize(domEventData);
180
+ }
181
+ }
182
+ _mouseUpListener() {
183
+ if (this._activeResizer) {
184
+ this._activeResizer.commit();
185
+ this._activeResizer = null;
186
+ }
187
+ }
188
+ }
@@ -1,94 +1,94 @@
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
- /**
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
- /**
12
- * Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole
13
- * toolbar rendering process and exposes a concise API.
14
- *
15
- * To add a toolbar for your widget use the {@link ~WidgetToolbarRepository#register `WidgetToolbarRepository#register()`} method.
16
- *
17
- * The following example comes from the {@link module:image/imagetoolbar~ImageToolbar} plugin:
18
- *
19
- * ```ts
20
- * class ImageToolbar extends Plugin {
21
- * static get requires() {
22
- * return [ WidgetToolbarRepository ];
23
- * }
24
- *
25
- * afterInit() {
26
- * const editor = this.editor;
27
- * const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
28
- *
29
- * widgetToolbarRepository.register( 'image', {
30
- * items: editor.config.get( 'image.toolbar' ),
31
- * getRelatedElement: getClosestSelectedImageWidget
32
- * } );
33
- * }
34
- * }
35
- * ```
36
- */
37
- export default class WidgetToolbarRepository extends Plugin {
38
- /**
39
- * A map of toolbar definitions.
40
- */
41
- private _toolbarDefinitions;
42
- private _balloon;
43
- /**
44
- * @inheritDoc
45
- */
46
- static get requires(): readonly [typeof ContextualBalloon];
47
- /**
48
- * @inheritDoc
49
- */
50
- static get pluginName(): "WidgetToolbarRepository";
51
- /**
52
- * @inheritDoc
53
- */
54
- init(): void;
55
- destroy(): void;
56
- /**
57
- * Registers toolbar in the WidgetToolbarRepository. It renders it in the `ContextualBalloon` based on the value of the invoked
58
- * `getRelatedElement` function. Toolbar items are gathered from `items` array.
59
- * The balloon's CSS class is by default `ck-toolbar-container` and may be override with the `balloonClassName` option.
60
- *
61
- * Note: This method should be called in the {@link module:core/plugin~PluginInterface#afterInit `Plugin#afterInit()`}
62
- * callback (or later) to make sure that the given toolbar items were already registered by other plugins.
63
- *
64
- * @param toolbarId An id for the toolbar. Used to
65
- * @param options.ariaLabel Label used by assistive technologies to describe this toolbar element.
66
- * @param options.items Array of toolbar items.
67
- * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
68
- * @param options.balloonClassName CSS class for the widget balloon.
69
- */
70
- register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName }: {
71
- ariaLabel?: string;
72
- items: Array<ToolbarConfigItem>;
73
- getRelatedElement: (selection: ViewDocumentSelection) => (ViewElement | null);
74
- balloonClassName?: string;
75
- }): void;
76
- /**
77
- * Iterates over stored toolbars and makes them visible or hidden.
78
- */
79
- private _updateToolbarsVisibility;
80
- /**
81
- * Hides the given toolbar.
82
- */
83
- private _hideToolbar;
84
- /**
85
- * Shows up the toolbar if the toolbar is not visible.
86
- * Otherwise, repositions the toolbar's balloon when toolbar's view is the most top view in balloon stack.
87
- *
88
- * It might happen here that the toolbar's view is under another view. Then do nothing as the other toolbar view
89
- * should be still visible after the {@link module:ui/editorui/editorui~EditorUI#event:update}.
90
- */
91
- private _showToolbar;
92
- private _isToolbarVisible;
93
- private _isToolbarInBalloon;
94
- }
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
+ /**
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
+ /**
12
+ * Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole
13
+ * toolbar rendering process and exposes a concise API.
14
+ *
15
+ * To add a toolbar for your widget use the {@link ~WidgetToolbarRepository#register `WidgetToolbarRepository#register()`} method.
16
+ *
17
+ * The following example comes from the {@link module:image/imagetoolbar~ImageToolbar} plugin:
18
+ *
19
+ * ```ts
20
+ * class ImageToolbar extends Plugin {
21
+ * static get requires() {
22
+ * return [ WidgetToolbarRepository ];
23
+ * }
24
+ *
25
+ * afterInit() {
26
+ * const editor = this.editor;
27
+ * const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
28
+ *
29
+ * widgetToolbarRepository.register( 'image', {
30
+ * items: editor.config.get( 'image.toolbar' ),
31
+ * getRelatedElement: getClosestSelectedImageWidget
32
+ * } );
33
+ * }
34
+ * }
35
+ * ```
36
+ */
37
+ export default class WidgetToolbarRepository extends Plugin {
38
+ /**
39
+ * A map of toolbar definitions.
40
+ */
41
+ private _toolbarDefinitions;
42
+ private _balloon;
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ static get requires(): readonly [typeof ContextualBalloon];
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ static get pluginName(): "WidgetToolbarRepository";
51
+ /**
52
+ * @inheritDoc
53
+ */
54
+ init(): void;
55
+ destroy(): void;
56
+ /**
57
+ * Registers toolbar in the WidgetToolbarRepository. It renders it in the `ContextualBalloon` based on the value of the invoked
58
+ * `getRelatedElement` function. Toolbar items are gathered from `items` array.
59
+ * The balloon's CSS class is by default `ck-toolbar-container` and may be override with the `balloonClassName` option.
60
+ *
61
+ * Note: This method should be called in the {@link module:core/plugin~PluginInterface#afterInit `Plugin#afterInit()`}
62
+ * callback (or later) to make sure that the given toolbar items were already registered by other plugins.
63
+ *
64
+ * @param toolbarId An id for the toolbar. Used to
65
+ * @param options.ariaLabel Label used by assistive technologies to describe this toolbar element.
66
+ * @param options.items Array of toolbar items.
67
+ * @param options.getRelatedElement Callback which returns an element the toolbar should be attached to.
68
+ * @param options.balloonClassName CSS class for the widget balloon.
69
+ */
70
+ register(toolbarId: string, { ariaLabel, items, getRelatedElement, balloonClassName }: {
71
+ ariaLabel?: string;
72
+ items: Array<ToolbarConfigItem>;
73
+ getRelatedElement: (selection: ViewDocumentSelection) => (ViewElement | null);
74
+ balloonClassName?: string;
75
+ }): void;
76
+ /**
77
+ * Iterates over stored toolbars and makes them visible or hidden.
78
+ */
79
+ private _updateToolbarsVisibility;
80
+ /**
81
+ * Hides the given toolbar.
82
+ */
83
+ private _hideToolbar;
84
+ /**
85
+ * Shows up the toolbar if the toolbar is not visible.
86
+ * Otherwise, repositions the toolbar's balloon when toolbar's view is the most top view in balloon stack.
87
+ *
88
+ * It might happen here that the toolbar's view is under another view. Then do nothing as the other toolbar view
89
+ * should be still visible after the {@link module:ui/editorui/editorui~EditorUI#event:update}.
90
+ */
91
+ private _showToolbar;
92
+ private _isToolbarVisible;
93
+ private _isToolbarInBalloon;
94
+ }