@ckeditor/ckeditor5-ui 36.0.0 → 37.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/package.json +23 -22
- package/src/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
- package/src/bindings/addkeyboardhandlingforgrid.js +42 -34
- package/src/bindings/clickoutsidehandler.d.ts +28 -0
- package/src/bindings/clickoutsidehandler.js +5 -6
- package/src/bindings/csstransitiondisablermixin.d.ts +40 -0
- package/src/bindings/csstransitiondisablermixin.js +55 -0
- package/src/bindings/injectcsstransitiondisabler.d.ts +59 -0
- package/src/bindings/injectcsstransitiondisabler.js +23 -20
- package/src/bindings/preventdefault.d.ts +33 -0
- package/src/bindings/preventdefault.js +13 -15
- package/src/bindings/submithandler.d.ts +57 -0
- package/src/bindings/submithandler.js +22 -23
- package/src/button/button.d.ts +154 -0
- package/src/button/buttonview.d.ts +155 -0
- package/src/button/buttonview.js +16 -60
- package/src/button/switchbuttonview.d.ts +45 -0
- package/src/button/switchbuttonview.js +9 -18
- package/src/colorgrid/colorgridview.d.ts +132 -0
- package/src/colorgrid/colorgridview.js +8 -40
- package/src/colorgrid/colortileview.d.ts +28 -0
- package/src/colorgrid/colortileview.js +0 -13
- package/src/colorgrid/utils.d.ts +47 -0
- package/src/colorgrid/utils.js +7 -13
- package/src/componentfactory.d.ts +81 -0
- package/src/componentfactory.js +21 -35
- package/src/dropdown/button/dropdownbutton.d.ts +25 -0
- package/src/dropdown/button/dropdownbuttonview.d.ts +48 -0
- package/src/dropdown/button/dropdownbuttonview.js +11 -21
- package/src/dropdown/button/splitbuttonview.d.ts +145 -0
- package/src/dropdown/button/splitbuttonview.js +10 -51
- package/src/dropdown/dropdownpanelfocusable.d.ts +21 -0
- package/src/dropdown/dropdownpanelview.d.ts +62 -0
- package/src/dropdown/dropdownpanelview.js +2 -30
- package/src/dropdown/dropdownview.d.ts +315 -0
- package/src/dropdown/dropdownview.js +121 -222
- package/src/dropdown/utils.d.ts +219 -0
- package/src/dropdown/utils.js +112 -106
- package/src/editableui/editableuiview.d.ts +71 -0
- package/src/editableui/editableuiview.js +14 -43
- package/src/editableui/inline/inlineeditableuiview.d.ts +40 -0
- package/src/editableui/inline/inlineeditableuiview.js +5 -15
- package/src/editorui/bodycollection.d.ts +51 -0
- package/src/editorui/bodycollection.js +2 -16
- package/src/editorui/boxed/boxededitoruiview.d.ts +40 -0
- package/src/editorui/boxed/boxededitoruiview.js +1 -27
- package/src/editorui/editorui.d.ts +264 -0
- package/src/editorui/editorui.js +21 -128
- package/src/editorui/editoruiview.d.ts +39 -0
- package/src/editorui/editoruiview.js +1 -10
- package/src/focuscycler.d.ts +183 -0
- package/src/focuscycler.js +34 -90
- package/src/formheader/formheaderview.d.ts +53 -0
- package/src/formheader/formheaderview.js +3 -24
- package/src/icon/iconview.d.ts +78 -0
- package/src/icon/iconview.js +0 -50
- package/src/iframe/iframeview.d.ts +50 -0
- package/src/iframe/iframeview.js +2 -2
- package/src/index.d.ts +54 -0
- package/src/index.js +1 -0
- package/src/input/inputview.d.ts +121 -0
- package/src/input/inputview.js +0 -82
- package/src/inputnumber/inputnumberview.d.ts +49 -0
- package/src/inputnumber/inputnumberview.js +5 -28
- package/src/inputtext/inputtextview.d.ts +18 -0
- package/src/inputtext/inputtextview.js +0 -2
- package/src/label/labelview.d.ts +36 -0
- package/src/label/labelview.js +0 -20
- package/src/labeledfield/labeledfieldview.d.ts +182 -0
- package/src/labeledfield/labeledfieldview.js +20 -126
- package/src/labeledfield/utils.d.ts +93 -0
- package/src/labeledfield/utils.js +24 -18
- package/src/labeledinput/labeledinputview.d.ts +125 -0
- package/src/labeledinput/labeledinputview.js +7 -90
- package/src/list/listitemview.d.ts +35 -0
- package/src/list/listitemview.js +0 -16
- package/src/list/listseparatorview.d.ts +18 -0
- package/src/list/listseparatorview.js +0 -2
- package/src/list/listview.d.ts +59 -0
- package/src/list/listview.js +0 -33
- package/src/model.d.ts +22 -0
- package/src/model.js +2 -4
- package/src/notification/notification.d.ts +216 -0
- package/src/notification/notification.js +64 -51
- package/src/panel/balloon/balloonpanelview.d.ts +685 -0
- package/src/panel/balloon/balloonpanelview.js +146 -168
- package/src/panel/balloon/contextualballoon.d.ts +240 -0
- package/src/panel/balloon/contextualballoon.js +41 -171
- package/src/panel/sticky/stickypanelview.d.ts +132 -0
- package/src/panel/sticky/stickypanelview.js +0 -115
- package/src/template.d.ts +940 -0
- package/src/template.js +396 -460
- package/src/toolbar/balloon/balloontoolbar.d.ts +124 -0
- package/src/toolbar/balloon/balloontoolbar.js +15 -81
- package/src/toolbar/block/blockbuttonview.d.ts +35 -0
- package/src/toolbar/block/blockbuttonview.js +1 -13
- package/src/toolbar/block/blocktoolbar.d.ts +159 -0
- package/src/toolbar/block/blocktoolbar.js +32 -69
- package/src/toolbar/normalizetoolbarconfig.d.ts +39 -0
- package/src/toolbar/normalizetoolbarconfig.js +12 -8
- package/src/toolbar/toolbarlinebreakview.d.ts +18 -0
- package/src/toolbar/toolbarlinebreakview.js +0 -2
- package/src/toolbar/toolbarseparatorview.d.ts +18 -0
- package/src/toolbar/toolbarseparatorview.js +0 -2
- package/src/toolbar/toolbarview.d.ts +241 -0
- package/src/toolbar/toolbarview.js +54 -305
- package/src/tooltipmanager.d.ts +180 -0
- package/src/tooltipmanager.js +47 -94
- package/src/uiconfig.d.ts +82 -0
- package/src/uiconfig.js +5 -0
- package/src/view.d.ts +422 -0
- package/src/view.js +182 -251
- package/src/viewcollection.d.ts +139 -0
- package/src/viewcollection.js +62 -56
|
@@ -0,0 +1,180 @@
|
|
|
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 ui/tooltipmanager
|
|
7
|
+
*/
|
|
8
|
+
import View from './view';
|
|
9
|
+
import BalloonPanelView from './panel/balloon/balloonpanelview';
|
|
10
|
+
import { type PositioningFunction } from '@ckeditor/ckeditor5-utils';
|
|
11
|
+
import type { Editor } from '@ckeditor/ckeditor5-core';
|
|
12
|
+
import '../theme/components/tooltip/tooltip.css';
|
|
13
|
+
declare const TooltipManager_base: {
|
|
14
|
+
new (): import("@ckeditor/ckeditor5-utils").DomEmitter;
|
|
15
|
+
prototype: import("@ckeditor/ckeditor5-utils").DomEmitter;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A tooltip manager class for the UI of the editor.
|
|
19
|
+
*
|
|
20
|
+
* **Note**: Most likely you do not have to use the `TooltipManager` API listed below in order to display tooltips. Popular
|
|
21
|
+
* {@glink framework/architecture/ui-library UI components} support tooltips out-of-the-box via observable properties
|
|
22
|
+
* (see {@link module:ui/button/buttonview~ButtonView#tooltip} and {@link module:ui/button/buttonview~ButtonView#tooltipPosition}).
|
|
23
|
+
*
|
|
24
|
+
* # Displaying tooltips
|
|
25
|
+
*
|
|
26
|
+
* To display a tooltip, set `data-cke-tooltip-text` attribute on any DOM element:
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* domElement.dataset.ckeTooltipText = 'My tooltip';
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* The tooltip will show up whenever the user moves the mouse over the element or the element gets focus in DOM.
|
|
33
|
+
*
|
|
34
|
+
* # Positioning tooltips
|
|
35
|
+
*
|
|
36
|
+
* To change the position of the tooltip, use the `data-cke-tooltip-position` attribute (`s`, `se`, `sw`, `n`, `e`, or `w`):
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* domElement.dataset.ckeTooltipText = 'Tooltip to the north';
|
|
40
|
+
* domElement.dataset.ckeTooltipPosition = 'n';
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* # Disabling tooltips
|
|
44
|
+
*
|
|
45
|
+
* In order to disable the tooltip temporarily, use the `data-cke-tooltip-disabled` attribute:
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* domElement.dataset.ckeTooltipText = 'Disabled. For now.';
|
|
49
|
+
* domElement.dataset.ckeTooltipDisabled = 'true';
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* # Styling tooltips
|
|
53
|
+
*
|
|
54
|
+
* By default, the tooltip has `.ck-tooltip` class and its text inner `.ck-tooltip__text`.
|
|
55
|
+
*
|
|
56
|
+
* If your tooltip requires custom styling, using `data-cke-tooltip-class` attribute will add additional class to the balloon
|
|
57
|
+
* displaying the tooltip:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* domElement.dataset.ckeTooltipText = 'Tooltip with a red text';
|
|
61
|
+
* domElement.dataset.ckeTooltipClass = 'my-class';
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* ```css
|
|
65
|
+
* .ck.ck-tooltip.my-class { color: red }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* **Note**: This class is a singleton. All editor instances re-use the same instance loaded by
|
|
69
|
+
* {@link module:core/editor/editorui~EditorUI} of the first editor.
|
|
70
|
+
*/
|
|
71
|
+
export default class TooltipManager extends TooltipManager_base {
|
|
72
|
+
/**
|
|
73
|
+
* The view rendering text of the tooltip.
|
|
74
|
+
*/
|
|
75
|
+
readonly tooltipTextView: View & {
|
|
76
|
+
text: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The instance of the balloon panel that renders and positions the tooltip.
|
|
80
|
+
*/
|
|
81
|
+
readonly balloonPanelView: BalloonPanelView;
|
|
82
|
+
/**
|
|
83
|
+
* A set of default {@link module:utils/dom/position~PositioningFunction positioning functions} used by the `TooltipManager`
|
|
84
|
+
* to pin tooltips in different positions.
|
|
85
|
+
*/
|
|
86
|
+
static defaultBalloonPositions: Record<string, PositioningFunction>;
|
|
87
|
+
/**
|
|
88
|
+
* Stores the reference to the DOM element the tooltip is attached to. `null` when there's no tooltip
|
|
89
|
+
* in the UI.
|
|
90
|
+
*/
|
|
91
|
+
private _currentElementWithTooltip;
|
|
92
|
+
/**
|
|
93
|
+
* Stores the current tooltip position. `null` when there's no tooltip in the UI.
|
|
94
|
+
*/
|
|
95
|
+
private _currentTooltipPosition;
|
|
96
|
+
/**
|
|
97
|
+
* An instance of the resize observer that keeps track on target element visibility,
|
|
98
|
+
* when it hides the tooltip should also disappear.
|
|
99
|
+
*
|
|
100
|
+
* {@link module:core/editor/editorconfig~EditorConfig#balloonToolbar configuration}.
|
|
101
|
+
*/
|
|
102
|
+
private _resizeObserver;
|
|
103
|
+
/**
|
|
104
|
+
* A debounced version of {@link #_pinTooltip}. Tooltips show with a delay to avoid flashing and
|
|
105
|
+
* to improve the UX.
|
|
106
|
+
*/
|
|
107
|
+
private _pinTooltipDebounced;
|
|
108
|
+
private readonly _watchdogExcluded;
|
|
109
|
+
/**
|
|
110
|
+
* A set of editors the single tooltip manager instance must listen to.
|
|
111
|
+
* This is mostly to handle `EditorUI#update` listeners from individual editors.
|
|
112
|
+
*/
|
|
113
|
+
private static _editors;
|
|
114
|
+
/**
|
|
115
|
+
* A reference to the `TooltipManager` instance. The class is a singleton and as such,
|
|
116
|
+
* successive attempts at creating instances should return this instance.
|
|
117
|
+
*/
|
|
118
|
+
private static _instance;
|
|
119
|
+
/**
|
|
120
|
+
* Creates an instance of the tooltip manager.
|
|
121
|
+
*/
|
|
122
|
+
constructor(editor: Editor);
|
|
123
|
+
/**
|
|
124
|
+
* Destroys the tooltip manager.
|
|
125
|
+
*
|
|
126
|
+
* **Note**: The manager singleton cannot be destroyed until all editors that use it are destroyed.
|
|
127
|
+
*
|
|
128
|
+
* @param editor The editor the manager was created for.
|
|
129
|
+
*/
|
|
130
|
+
destroy(editor: Editor): void;
|
|
131
|
+
/**
|
|
132
|
+
* Returns {@link #balloonPanelView} {@link module:utils/dom/position~PositioningFunction positioning functions} for a given position
|
|
133
|
+
* name.
|
|
134
|
+
*
|
|
135
|
+
* @param position Name of the position (`s`, `se`, `sw`, `n`, `e`, or `w`).
|
|
136
|
+
* @returns Positioning functions to be used by the {@link #balloonPanelView}.
|
|
137
|
+
*/
|
|
138
|
+
static getPositioningFunctions(position: TooltipPosition): Array<PositioningFunction>;
|
|
139
|
+
/**
|
|
140
|
+
* Handles displaying tooltips on `mouseenter` and `focus` in DOM.
|
|
141
|
+
*
|
|
142
|
+
* @param evt An object containing information about the fired event.
|
|
143
|
+
* @param domEvent The DOM event.
|
|
144
|
+
*/
|
|
145
|
+
private _onEnterOrFocus;
|
|
146
|
+
/**
|
|
147
|
+
* Handles hiding tooltips on `mouseleave` and `blur` in DOM.
|
|
148
|
+
*
|
|
149
|
+
* @param evt An object containing information about the fired event.
|
|
150
|
+
* @param domEvent The DOM event.
|
|
151
|
+
*/
|
|
152
|
+
private _onLeaveOrBlur;
|
|
153
|
+
/**
|
|
154
|
+
* Handles hiding tooltips on `scroll` in DOM.
|
|
155
|
+
*
|
|
156
|
+
* @param evt An object containing information about the fired event.
|
|
157
|
+
* @param domEvent The DOM event.
|
|
158
|
+
*/
|
|
159
|
+
private _onScroll;
|
|
160
|
+
/**
|
|
161
|
+
* Pins the tooltip to a specific DOM element.
|
|
162
|
+
*
|
|
163
|
+
* @param options.text Text of the tooltip to display.
|
|
164
|
+
* @param options.position The position of the tooltip.
|
|
165
|
+
* @param options.cssClass Additional CSS class of the balloon with the tooltip.
|
|
166
|
+
*/
|
|
167
|
+
private _pinTooltip;
|
|
168
|
+
/**
|
|
169
|
+
* Unpins the tooltip and cancels all queued pinning.
|
|
170
|
+
*/
|
|
171
|
+
private _unpinTooltip;
|
|
172
|
+
/**
|
|
173
|
+
* Updates the position of the tooltip so it stays in sync with the element it is pinned to.
|
|
174
|
+
*
|
|
175
|
+
* Hides the tooltip when the element is no longer visible in DOM.
|
|
176
|
+
*/
|
|
177
|
+
private _updateTooltipPosition;
|
|
178
|
+
}
|
|
179
|
+
export type TooltipPosition = 's' | 'n' | 'e' | 'w' | 'sw' | 'se';
|
|
180
|
+
export {};
|
package/src/tooltipmanager.js
CHANGED
|
@@ -15,14 +15,16 @@ const BALLOON_CLASS = 'ck-tooltip';
|
|
|
15
15
|
* A tooltip manager class for the UI of the editor.
|
|
16
16
|
*
|
|
17
17
|
* **Note**: Most likely you do not have to use the `TooltipManager` API listed below in order to display tooltips. Popular
|
|
18
|
-
* {@glink framework/
|
|
18
|
+
* {@glink framework/architecture/ui-library UI components} support tooltips out-of-the-box via observable properties
|
|
19
19
|
* (see {@link module:ui/button/buttonview~ButtonView#tooltip} and {@link module:ui/button/buttonview~ButtonView#tooltipPosition}).
|
|
20
20
|
*
|
|
21
21
|
* # Displaying tooltips
|
|
22
22
|
*
|
|
23
23
|
* To display a tooltip, set `data-cke-tooltip-text` attribute on any DOM element:
|
|
24
24
|
*
|
|
25
|
-
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* domElement.dataset.ckeTooltipText = 'My tooltip';
|
|
27
|
+
* ```
|
|
26
28
|
*
|
|
27
29
|
* The tooltip will show up whenever the user moves the mouse over the element or the element gets focus in DOM.
|
|
28
30
|
*
|
|
@@ -30,16 +32,19 @@ const BALLOON_CLASS = 'ck-tooltip';
|
|
|
30
32
|
*
|
|
31
33
|
* To change the position of the tooltip, use the `data-cke-tooltip-position` attribute (`s`, `se`, `sw`, `n`, `e`, or `w`):
|
|
32
34
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* domElement.dataset.ckeTooltipText = 'Tooltip to the north';
|
|
37
|
+
* domElement.dataset.ckeTooltipPosition = 'n';
|
|
38
|
+
* ```
|
|
35
39
|
*
|
|
36
40
|
* # Disabling tooltips
|
|
37
41
|
*
|
|
38
42
|
* In order to disable the tooltip temporarily, use the `data-cke-tooltip-disabled` attribute:
|
|
39
43
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* domElement.dataset.ckeTooltipText = 'Disabled. For now.';
|
|
46
|
+
* domElement.dataset.ckeTooltipDisabled = 'true';
|
|
47
|
+
* ```
|
|
43
48
|
*
|
|
44
49
|
* # Styling tooltips
|
|
45
50
|
*
|
|
@@ -48,24 +53,40 @@ const BALLOON_CLASS = 'ck-tooltip';
|
|
|
48
53
|
* If your tooltip requires custom styling, using `data-cke-tooltip-class` attribute will add additional class to the balloon
|
|
49
54
|
* displaying the tooltip:
|
|
50
55
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* domElement.dataset.ckeTooltipText = 'Tooltip with a red text';
|
|
58
|
+
* domElement.dataset.ckeTooltipClass = 'my-class';
|
|
59
|
+
* ```
|
|
53
60
|
*
|
|
54
|
-
*
|
|
61
|
+
* ```css
|
|
62
|
+
* .ck.ck-tooltip.my-class { color: red }
|
|
63
|
+
* ```
|
|
55
64
|
*
|
|
56
65
|
* **Note**: This class is a singleton. All editor instances re-use the same instance loaded by
|
|
57
66
|
* {@link module:core/editor/editorui~EditorUI} of the first editor.
|
|
58
|
-
*
|
|
59
|
-
* @mixes module:utils/domemittermixin~DomEmitterMixin
|
|
60
67
|
*/
|
|
61
68
|
export default class TooltipManager extends DomEmitterMixin() {
|
|
62
69
|
/**
|
|
63
70
|
* Creates an instance of the tooltip manager.
|
|
64
|
-
*
|
|
65
|
-
* @param {module:core/editor/editor~Editor} editor
|
|
66
71
|
*/
|
|
67
72
|
constructor(editor) {
|
|
68
73
|
super();
|
|
74
|
+
/**
|
|
75
|
+
* Stores the reference to the DOM element the tooltip is attached to. `null` when there's no tooltip
|
|
76
|
+
* in the UI.
|
|
77
|
+
*/
|
|
78
|
+
this._currentElementWithTooltip = null;
|
|
79
|
+
/**
|
|
80
|
+
* Stores the current tooltip position. `null` when there's no tooltip in the UI.
|
|
81
|
+
*/
|
|
82
|
+
this._currentTooltipPosition = null;
|
|
83
|
+
/**
|
|
84
|
+
* An instance of the resize observer that keeps track on target element visibility,
|
|
85
|
+
* when it hides the tooltip should also disappear.
|
|
86
|
+
*
|
|
87
|
+
* {@link module:core/editor/editorconfig~EditorConfig#balloonToolbar configuration}.
|
|
88
|
+
*/
|
|
89
|
+
this._resizeObserver = null;
|
|
69
90
|
TooltipManager._editors.add(editor);
|
|
70
91
|
// TooltipManager must be a singleton. Multiple instances would mean multiple tooltips attached
|
|
71
92
|
// to the same DOM element with data-cke-tooltip-* attributes.
|
|
@@ -73,12 +94,6 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
73
94
|
return TooltipManager._instance;
|
|
74
95
|
}
|
|
75
96
|
TooltipManager._instance = this;
|
|
76
|
-
/**
|
|
77
|
-
* The view rendering text of the tooltip.
|
|
78
|
-
*
|
|
79
|
-
* @readonly
|
|
80
|
-
* @member {module:ui/view~View} #tooltipTextView
|
|
81
|
-
*/
|
|
82
97
|
this.tooltipTextView = new View(editor.locale);
|
|
83
98
|
this.tooltipTextView.set('text', '');
|
|
84
99
|
this.tooltipTextView.setTemplate({
|
|
@@ -95,51 +110,9 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
95
110
|
}
|
|
96
111
|
]
|
|
97
112
|
});
|
|
98
|
-
/**
|
|
99
|
-
* The instance of the balloon panel that renders and positions the tooltip.
|
|
100
|
-
*
|
|
101
|
-
* @readonly
|
|
102
|
-
* @member {module:ui/panel/balloon/balloonpanelview~BalloonPanelView} #balloonPanelView
|
|
103
|
-
*/
|
|
104
113
|
this.balloonPanelView = new BalloonPanelView(editor.locale);
|
|
105
114
|
this.balloonPanelView.class = BALLOON_CLASS;
|
|
106
115
|
this.balloonPanelView.content.add(this.tooltipTextView);
|
|
107
|
-
/**
|
|
108
|
-
* An instance of the resize observer that keeps track on target element visibility,
|
|
109
|
-
* when it hides the tooltip should also disappear.
|
|
110
|
-
*
|
|
111
|
-
* {@link module:core/editor/editorconfig~EditorConfig#balloonToolbar configuration}.
|
|
112
|
-
*
|
|
113
|
-
* @protected
|
|
114
|
-
* @member {module:utils/dom/resizeobserver~ResizeObserver|null}
|
|
115
|
-
*
|
|
116
|
-
*/
|
|
117
|
-
this._resizeObserver = null;
|
|
118
|
-
/**
|
|
119
|
-
* Stores the reference to the DOM element the tooltip is attached to. `null` when there's no tooltip
|
|
120
|
-
* in the UI.
|
|
121
|
-
*
|
|
122
|
-
* @private
|
|
123
|
-
* @readonly
|
|
124
|
-
* @member {HTMLElement|null} #_currentElementWithTooltip
|
|
125
|
-
*/
|
|
126
|
-
this._currentElementWithTooltip = null;
|
|
127
|
-
/**
|
|
128
|
-
* Stores the current tooltip position. `null` when there's no tooltip in the UI.
|
|
129
|
-
*
|
|
130
|
-
* @private
|
|
131
|
-
* @readonly
|
|
132
|
-
* @member {String|null} #_currentTooltipPosition
|
|
133
|
-
*/
|
|
134
|
-
this._currentTooltipPosition = null;
|
|
135
|
-
/**
|
|
136
|
-
* A debounced version of {@link #_pinTooltip}. Tooltips show with a delay to avoid flashing and
|
|
137
|
-
* to improve the UX.
|
|
138
|
-
*
|
|
139
|
-
* @private
|
|
140
|
-
* @readonly
|
|
141
|
-
* @member {Function} #_pinTooltipDebounced
|
|
142
|
-
*/
|
|
143
116
|
this._pinTooltipDebounced = debounce(this._pinTooltip, 600);
|
|
144
117
|
this.listenTo(global.document, 'mouseenter', this._onEnterOrFocus.bind(this), { useCapture: true });
|
|
145
118
|
this.listenTo(global.document, 'mouseleave', this._onLeaveOrBlur.bind(this), { useCapture: true });
|
|
@@ -158,7 +131,7 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
158
131
|
*
|
|
159
132
|
* **Note**: The manager singleton cannot be destroyed until all editors that use it are destroyed.
|
|
160
133
|
*
|
|
161
|
-
* @param
|
|
134
|
+
* @param editor The editor the manager was created for.
|
|
162
135
|
*/
|
|
163
136
|
destroy(editor) {
|
|
164
137
|
const editorBodyViewCollection = editor.ui.view && editor.ui.view.body;
|
|
@@ -180,9 +153,8 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
180
153
|
* Returns {@link #balloonPanelView} {@link module:utils/dom/position~PositioningFunction positioning functions} for a given position
|
|
181
154
|
* name.
|
|
182
155
|
*
|
|
183
|
-
* @
|
|
184
|
-
* @
|
|
185
|
-
* @returns {Array.<module:utils/dom/position~PositioningFunction>} Positioning functions to be used by the {@link #balloonPanelView}.
|
|
156
|
+
* @param position Name of the position (`s`, `se`, `sw`, `n`, `e`, or `w`).
|
|
157
|
+
* @returns Positioning functions to be used by the {@link #balloonPanelView}.
|
|
186
158
|
*/
|
|
187
159
|
static getPositioningFunctions(position) {
|
|
188
160
|
const defaultPositions = TooltipManager.defaultBalloonPositions;
|
|
@@ -203,9 +175,8 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
203
175
|
/**
|
|
204
176
|
* Handles displaying tooltips on `mouseenter` and `focus` in DOM.
|
|
205
177
|
*
|
|
206
|
-
* @
|
|
207
|
-
* @param
|
|
208
|
-
* @param {Event} domEvent The DOM event.
|
|
178
|
+
* @param evt An object containing information about the fired event.
|
|
179
|
+
* @param domEvent The DOM event.
|
|
209
180
|
*/
|
|
210
181
|
_onEnterOrFocus(evt, { target }) {
|
|
211
182
|
const elementWithTooltipAttribute = getDescendantWithTooltip(target);
|
|
@@ -225,9 +196,8 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
225
196
|
/**
|
|
226
197
|
* Handles hiding tooltips on `mouseleave` and `blur` in DOM.
|
|
227
198
|
*
|
|
228
|
-
* @
|
|
229
|
-
* @param
|
|
230
|
-
* @param {Event} domEvent The DOM event.
|
|
199
|
+
* @param evt An object containing information about the fired event.
|
|
200
|
+
* @param domEvent The DOM event.
|
|
231
201
|
*/
|
|
232
202
|
_onLeaveOrBlur(evt, { target, relatedTarget }) {
|
|
233
203
|
if (evt.name === 'mouseleave') {
|
|
@@ -264,9 +234,8 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
264
234
|
/**
|
|
265
235
|
* Handles hiding tooltips on `scroll` in DOM.
|
|
266
236
|
*
|
|
267
|
-
* @
|
|
268
|
-
* @param
|
|
269
|
-
* @param {Event} domEvent The DOM event.
|
|
237
|
+
* @param evt An object containing information about the fired event.
|
|
238
|
+
* @param domEvent The DOM event.
|
|
270
239
|
*/
|
|
271
240
|
_onScroll(evt, { target }) {
|
|
272
241
|
// No tooltip, no reason to react on scroll.
|
|
@@ -284,12 +253,9 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
284
253
|
/**
|
|
285
254
|
* Pins the tooltip to a specific DOM element.
|
|
286
255
|
*
|
|
287
|
-
* @
|
|
288
|
-
* @param
|
|
289
|
-
* @param
|
|
290
|
-
* @param {String} options.text Text of the tooltip to display.
|
|
291
|
-
* @param {String} options.position The position of the tooltip.
|
|
292
|
-
* @param {String} options.cssClass Additional CSS class of the balloon with the tooltip.
|
|
256
|
+
* @param options.text Text of the tooltip to display.
|
|
257
|
+
* @param options.position The position of the tooltip.
|
|
258
|
+
* @param options.cssClass Additional CSS class of the balloon with the tooltip.
|
|
293
259
|
*/
|
|
294
260
|
_pinTooltip(targetDomElement, { text, position, cssClass }) {
|
|
295
261
|
// Use the body collection of the first editor.
|
|
@@ -323,8 +289,6 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
323
289
|
}
|
|
324
290
|
/**
|
|
325
291
|
* Unpins the tooltip and cancels all queued pinning.
|
|
326
|
-
*
|
|
327
|
-
* @private
|
|
328
292
|
*/
|
|
329
293
|
_unpinTooltip() {
|
|
330
294
|
this._pinTooltipDebounced.cancel();
|
|
@@ -342,8 +306,6 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
342
306
|
* Updates the position of the tooltip so it stays in sync with the element it is pinned to.
|
|
343
307
|
*
|
|
344
308
|
* Hides the tooltip when the element is no longer visible in DOM.
|
|
345
|
-
*
|
|
346
|
-
* @private
|
|
347
309
|
*/
|
|
348
310
|
_updateTooltipPosition() {
|
|
349
311
|
// This could happen if the tooltip was attached somewhere in a contextual content toolbar and the toolbar
|
|
@@ -361,9 +323,6 @@ export default class TooltipManager extends DomEmitterMixin() {
|
|
|
361
323
|
/**
|
|
362
324
|
* A set of default {@link module:utils/dom/position~PositioningFunction positioning functions} used by the `TooltipManager`
|
|
363
325
|
* to pin tooltips in different positions.
|
|
364
|
-
*
|
|
365
|
-
* @member {Object.<String,module:utils/dom/position~PositioningFunction>}
|
|
366
|
-
* module:ui/tooltipmanager~TooltipManager.defaultBalloonPositions
|
|
367
326
|
*/
|
|
368
327
|
TooltipManager.defaultBalloonPositions = generatePositions({
|
|
369
328
|
heightOffset: 5,
|
|
@@ -372,17 +331,11 @@ TooltipManager.defaultBalloonPositions = generatePositions({
|
|
|
372
331
|
/**
|
|
373
332
|
* A set of editors the single tooltip manager instance must listen to.
|
|
374
333
|
* This is mostly to handle `EditorUI#update` listeners from individual editors.
|
|
375
|
-
*
|
|
376
|
-
* @private
|
|
377
|
-
* @member {Set.<module:core/editor/editor~Editor>} module:ui/tooltipmanager~TooltipManager._editors
|
|
378
334
|
*/
|
|
379
335
|
TooltipManager._editors = new Set();
|
|
380
336
|
/**
|
|
381
337
|
* A reference to the `TooltipManager` instance. The class is a singleton and as such,
|
|
382
338
|
* successive attempts at creating instances should return this instance.
|
|
383
|
-
*
|
|
384
|
-
* @private
|
|
385
|
-
* @member {module:ui/tooltipmanager~TooltipManager} module:ui/tooltipmanager~TooltipManager._instance
|
|
386
339
|
*/
|
|
387
340
|
TooltipManager._instance = null;
|
|
388
341
|
function getDescendantWithTooltip(element) {
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
import type { ToolbarConfig } from '@ckeditor/ckeditor5-core';
|
|
6
|
+
/**
|
|
7
|
+
* @module ui/uiconfig
|
|
8
|
+
*/
|
|
9
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
10
|
+
interface EditorConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Contextual toolbar configuration. Used by the {@link module:ui/toolbar/balloon/balloontoolbar~BalloonToolbar}
|
|
13
|
+
* feature.
|
|
14
|
+
*
|
|
15
|
+
* ## Configuring toolbar items
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const config = {
|
|
19
|
+
* balloonToolbar: [ 'bold', 'italic', 'undo', 'redo' ]
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* You can also use `'|'` to create a separator between groups of items:
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const config = {
|
|
27
|
+
* balloonToolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Read also about configuring the main editor toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
|
|
32
|
+
*
|
|
33
|
+
* ## Configuring items grouping
|
|
34
|
+
*
|
|
35
|
+
* You can prevent automatic items grouping by setting the `shouldNotGroupWhenFull` option:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* const config = {
|
|
39
|
+
* balloonToolbar: {
|
|
40
|
+
* items: [ 'bold', 'italic', 'undo', 'redo' ],
|
|
41
|
+
* shouldNotGroupWhenFull: true
|
|
42
|
+
* },
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
balloonToolbar?: ToolbarConfig;
|
|
47
|
+
/**
|
|
48
|
+
* The block toolbar configuration. Used by the {@link module:ui/toolbar/block/blocktoolbar~BlockToolbar}
|
|
49
|
+
* feature.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const config = {
|
|
53
|
+
* blockToolbar: [ 'paragraph', 'heading1', 'heading2', 'bulletedList', 'numberedList' ]
|
|
54
|
+
* };
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* You can also use `'|'` to create a separator between groups of items:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const config = {
|
|
61
|
+
* blockToolbar: [ 'paragraph', 'heading1', 'heading2', '|', 'bulletedList', 'numberedList' ]
|
|
62
|
+
* };
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* ## Configuring items grouping
|
|
66
|
+
*
|
|
67
|
+
* You can prevent automatic items grouping by setting the `shouldNotGroupWhenFull` option:
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* const config = {
|
|
71
|
+
* blockToolbar: {
|
|
72
|
+
* items: [ 'paragraph', 'heading1', 'heading2', '|', 'bulletedList', 'numberedList' ],
|
|
73
|
+
* shouldNotGroupWhenFull: true
|
|
74
|
+
* },
|
|
75
|
+
* };
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* Read more about configuring the main editor toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
|
|
79
|
+
*/
|
|
80
|
+
blockToolbar?: ToolbarConfig;
|
|
81
|
+
}
|
|
82
|
+
}
|