@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
|
@@ -2,43 +2,42 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module ui/bindings/submithandler
|
|
7
|
-
*/
|
|
8
5
|
/**
|
|
9
6
|
* A handler useful for {@link module:ui/view~View views} working as HTML forms. It intercepts a native DOM
|
|
10
7
|
* `submit` event, prevents the default web browser behavior (navigation and page reload) and
|
|
11
8
|
* fires the `submit` event on a view instead. Such a custom event can be then used by any
|
|
12
9
|
* {@link module:utils/dom/emittermixin~Emitter emitter}, e.g. to serialize the form data.
|
|
13
10
|
*
|
|
14
|
-
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import submitHandler from '@ckeditor/ckeditor5-ui/src/bindings/submithandler';
|
|
15
13
|
*
|
|
16
|
-
*
|
|
14
|
+
* // ...
|
|
17
15
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* class AnyFormView extends View {
|
|
17
|
+
* constructor() {
|
|
18
|
+
* super();
|
|
21
19
|
*
|
|
22
|
-
*
|
|
20
|
+
* // ...
|
|
23
21
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
22
|
+
* submitHandler( {
|
|
23
|
+
* view: this
|
|
24
|
+
* } );
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
29
27
|
*
|
|
30
|
-
*
|
|
28
|
+
* // ...
|
|
31
29
|
*
|
|
32
|
-
*
|
|
30
|
+
* const view = new AnyFormView();
|
|
33
31
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
32
|
+
* // A sample listener attached by an emitter working with the view.
|
|
33
|
+
* this.listenTo( view, 'submit', () => {
|
|
34
|
+
* saveTheFormData();
|
|
35
|
+
* hideTheForm();
|
|
36
|
+
* } );
|
|
37
|
+
* ```
|
|
39
38
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
39
|
+
* @param options Configuration options.
|
|
40
|
+
* @param options.view The view which DOM `submit` events should be handled.
|
|
42
41
|
*/
|
|
43
42
|
export default function submitHandler({ view }) {
|
|
44
43
|
view.listenTo(view.element, 'submit', (evt, domEvt) => {
|
|
@@ -0,0 +1,154 @@
|
|
|
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/button/button
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The button interface. Implemented by, among others, {@link module:ui/button/buttonview~ButtonView},
|
|
10
|
+
* {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} and
|
|
11
|
+
* {@link module:ui/dropdown/button/dropdownbuttonview~DropdownButtonView}.
|
|
12
|
+
*/
|
|
13
|
+
export default interface Button {
|
|
14
|
+
/**
|
|
15
|
+
* The label of the button view visible to the user when {@link #withText} is `true`.
|
|
16
|
+
* It can also be used to create a {@link #tooltip}.
|
|
17
|
+
*
|
|
18
|
+
* @observable
|
|
19
|
+
*/
|
|
20
|
+
label: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* (Optional) The keystroke associated with the button, i.e. <kbd>CTRL+B</kbd>,
|
|
23
|
+
* in the string format compatible with {@link module:utils/keyboard}.
|
|
24
|
+
*
|
|
25
|
+
* **Note**: Use {@link module:ui/button/button~Button#withKeystroke} if you want to display
|
|
26
|
+
* the keystroke information next to the {@link module:ui/button/button~Button#label label}.
|
|
27
|
+
*
|
|
28
|
+
* @observable
|
|
29
|
+
*/
|
|
30
|
+
keystroke: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* (Optional) Tooltip of the button, i.e. displayed when hovering the button with the mouse cursor.
|
|
33
|
+
*
|
|
34
|
+
* * If defined as a `Boolean` (e.g. `true`), then combination of `label` and `keystroke` will be set as a tooltip.
|
|
35
|
+
* * If defined as a `String`, tooltip will equal the exact text of that `String`.
|
|
36
|
+
* * If defined as a `Function`, `label` and `keystroke` will be passed to that function, which is to return
|
|
37
|
+
* a string with the tooltip text.
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* const view = new ButtonView( locale );
|
|
41
|
+
* view.tooltip = ( label, keystroke ) => `A tooltip for ${ label } and ${ keystroke }.`
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @observable
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
tooltip: boolean | string | ((label: string, keystroke: string | undefined) => string);
|
|
48
|
+
/**
|
|
49
|
+
* (Optional) The position of the tooltip. See {@link module:ui/tooltipmanager~TooltipManager}
|
|
50
|
+
* to learn more about the tooltip system.
|
|
51
|
+
*
|
|
52
|
+
* **Note:** It makes sense only when the {@link #tooltip `tooltip` attribute} is defined.
|
|
53
|
+
*
|
|
54
|
+
* @observable
|
|
55
|
+
* @default 's'
|
|
56
|
+
*/
|
|
57
|
+
tooltipPosition: 's' | 'n' | 'e' | 'w' | 'sw' | 'se';
|
|
58
|
+
/**
|
|
59
|
+
* The HTML type of the button.
|
|
60
|
+
*
|
|
61
|
+
* @observable
|
|
62
|
+
* @default 'button'
|
|
63
|
+
*/
|
|
64
|
+
type: 'button' | 'submit' | 'reset' | 'menu';
|
|
65
|
+
/**
|
|
66
|
+
* Controls whether the button view is "on". It makes sense when a feature it represents
|
|
67
|
+
* is currently active, e.g. a bold button is "on" when the selection is in the bold text.
|
|
68
|
+
*
|
|
69
|
+
* To disable the button, use {@link #isEnabled} instead.
|
|
70
|
+
*
|
|
71
|
+
* @observable
|
|
72
|
+
* @default true
|
|
73
|
+
*/
|
|
74
|
+
isOn: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Controls whether the button view is enabled, i.e. it can be clicked and execute an action.
|
|
77
|
+
*
|
|
78
|
+
* To change the "on" state of the button, use {@link #isOn} instead.
|
|
79
|
+
*
|
|
80
|
+
* @observable
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
isEnabled: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Controls whether the button view is visible. Visible by default, buttons are hidden
|
|
86
|
+
* using a CSS class.
|
|
87
|
+
*
|
|
88
|
+
* @observable
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
isVisible: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Controls whether the button view is a toggle button (two–state) for assistive technologies.
|
|
94
|
+
*
|
|
95
|
+
* @observable
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
isToggleable: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* (Optional) Controls whether the label of the button is hidden (e.g. an icon–only button).
|
|
101
|
+
*
|
|
102
|
+
* @observable
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
withText: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* (Optional) Controls whether the keystroke of the button is displayed next to its
|
|
108
|
+
* {@link module:ui/button/button~Button#label label}.
|
|
109
|
+
*
|
|
110
|
+
* **Note**: This property requires a {@link module:ui/button/button~Button#keystroke keystroke}
|
|
111
|
+
* to be defined in the first place.
|
|
112
|
+
*
|
|
113
|
+
* @observable
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
withKeystroke: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* (Optional) An XML {@link module:ui/icon/iconview~IconView#content content} of the icon.
|
|
119
|
+
* When defined, an `iconView` should be added to the button.
|
|
120
|
+
*
|
|
121
|
+
* @observable
|
|
122
|
+
*/
|
|
123
|
+
icon: string | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* (Optional) Controls the `tabindex` HTML attribute of the button. By default, the button is focusable
|
|
126
|
+
* but does not included in the <kbd>Tab</kbd> order.
|
|
127
|
+
*
|
|
128
|
+
* @observable
|
|
129
|
+
* @default -1
|
|
130
|
+
*/
|
|
131
|
+
tabindex: number;
|
|
132
|
+
/**
|
|
133
|
+
* (Optional) The additional CSS class set on the button.
|
|
134
|
+
*
|
|
135
|
+
* @observable
|
|
136
|
+
*/
|
|
137
|
+
class: string | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* (Optional) The value of the `style` attribute of the label.
|
|
140
|
+
*
|
|
141
|
+
* @observable
|
|
142
|
+
*/
|
|
143
|
+
labelStyle: string | undefined;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Fired when the button view is clicked. It won't be fired when the button {@link #isEnabled}
|
|
147
|
+
* is `false`.
|
|
148
|
+
*
|
|
149
|
+
* @eventName execute
|
|
150
|
+
*/
|
|
151
|
+
export type ButtonExecuteEvent = {
|
|
152
|
+
name: 'execute';
|
|
153
|
+
args: [];
|
|
154
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
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/button/buttonview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import IconView from '../icon/iconview';
|
|
10
|
+
import type ViewCollection from '../viewcollection';
|
|
11
|
+
import type { default as Button } from './button';
|
|
12
|
+
import { type Locale } from '@ckeditor/ckeditor5-utils';
|
|
13
|
+
import '../../theme/components/button/button.css';
|
|
14
|
+
/**
|
|
15
|
+
* The button view class.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const view = new ButtonView();
|
|
19
|
+
*
|
|
20
|
+
* view.set( {
|
|
21
|
+
* label: 'A button',
|
|
22
|
+
* keystroke: 'Ctrl+B',
|
|
23
|
+
* tooltip: true,
|
|
24
|
+
* withText: true
|
|
25
|
+
* } );
|
|
26
|
+
*
|
|
27
|
+
* view.render();
|
|
28
|
+
*
|
|
29
|
+
* document.body.append( view.element );
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export default class ButtonView extends View<HTMLButtonElement> implements Button {
|
|
33
|
+
/**
|
|
34
|
+
* Collection of the child views inside of the button {@link #element}.
|
|
35
|
+
*/
|
|
36
|
+
readonly children: ViewCollection;
|
|
37
|
+
/**
|
|
38
|
+
* Label of the button view. It is configurable using the {@link #label label attribute}.
|
|
39
|
+
*/
|
|
40
|
+
readonly labelView: View;
|
|
41
|
+
/**
|
|
42
|
+
* The icon view of the button. Will be added to {@link #children} when the
|
|
43
|
+
* {@link #icon icon attribute} is defined.
|
|
44
|
+
*/
|
|
45
|
+
readonly iconView: IconView;
|
|
46
|
+
/**
|
|
47
|
+
* A view displaying the keystroke of the button next to the {@link #labelView label}.
|
|
48
|
+
* Added to {@link #children} when the {@link #withKeystroke `withKeystroke` attribute}
|
|
49
|
+
* is defined.
|
|
50
|
+
*/
|
|
51
|
+
readonly keystrokeView: View;
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
*/
|
|
55
|
+
class: string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
labelStyle: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
icon: string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* @inheritDoc
|
|
66
|
+
*/
|
|
67
|
+
isEnabled: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @inheritDoc
|
|
70
|
+
*/
|
|
71
|
+
isOn: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* @inheritDoc
|
|
74
|
+
*/
|
|
75
|
+
isVisible: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @inheritDoc
|
|
78
|
+
*/
|
|
79
|
+
isToggleable: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* @inheritDoc
|
|
82
|
+
*/
|
|
83
|
+
keystroke: string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* @inheritDoc
|
|
86
|
+
*/
|
|
87
|
+
label: string | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* @inheritDoc
|
|
90
|
+
*/
|
|
91
|
+
tabindex: number;
|
|
92
|
+
/**
|
|
93
|
+
* @inheritDoc
|
|
94
|
+
*/
|
|
95
|
+
tooltip: Button['tooltip'];
|
|
96
|
+
/**
|
|
97
|
+
* @inheritDoc
|
|
98
|
+
*/
|
|
99
|
+
tooltipPosition: Button['tooltipPosition'];
|
|
100
|
+
/**
|
|
101
|
+
* @inheritDoc
|
|
102
|
+
*/
|
|
103
|
+
type: Button['type'];
|
|
104
|
+
/**
|
|
105
|
+
* @inheritDoc
|
|
106
|
+
*/
|
|
107
|
+
withText: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* @inheritDoc
|
|
110
|
+
*/
|
|
111
|
+
withKeystroke: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Tooltip of the button bound to the template.
|
|
114
|
+
*
|
|
115
|
+
* @see #tooltip
|
|
116
|
+
* @see #_getTooltipString
|
|
117
|
+
* @internal
|
|
118
|
+
* @observable
|
|
119
|
+
*/
|
|
120
|
+
_tooltipString: string;
|
|
121
|
+
/**
|
|
122
|
+
* @inheritDoc
|
|
123
|
+
*/
|
|
124
|
+
constructor(locale?: Locale);
|
|
125
|
+
/**
|
|
126
|
+
* @inheritDoc
|
|
127
|
+
*/
|
|
128
|
+
render(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Focuses the {@link #element} of the button.
|
|
131
|
+
*/
|
|
132
|
+
focus(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Creates a label view instance and binds it with button attributes.
|
|
135
|
+
*
|
|
136
|
+
* @param ariaLabelUid The aria label UID.
|
|
137
|
+
*/
|
|
138
|
+
private _createLabelView;
|
|
139
|
+
/**
|
|
140
|
+
* Creates a view that displays a keystroke next to a {@link #labelView label }
|
|
141
|
+
* and binds it with button attributes.
|
|
142
|
+
*/
|
|
143
|
+
private _createKeystrokeView;
|
|
144
|
+
/**
|
|
145
|
+
* Gets the text for the tooltip from the combination of
|
|
146
|
+
* {@link #tooltip}, {@link #label} and {@link #keystroke} attributes.
|
|
147
|
+
*
|
|
148
|
+
* @see #tooltip
|
|
149
|
+
* @see #_tooltipString
|
|
150
|
+
* @param tooltip Button tooltip.
|
|
151
|
+
* @param label Button label.
|
|
152
|
+
* @param keystroke Button keystroke.
|
|
153
|
+
*/
|
|
154
|
+
private _getTooltipString;
|
|
155
|
+
}
|
package/src/button/buttonview.js
CHANGED
|
@@ -12,21 +12,20 @@ import '../../theme/components/button/button.css';
|
|
|
12
12
|
/**
|
|
13
13
|
* The button view class.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const view = new ButtonView();
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
18
|
+
* view.set( {
|
|
19
|
+
* label: 'A button',
|
|
20
|
+
* keystroke: 'Ctrl+B',
|
|
21
|
+
* tooltip: true,
|
|
22
|
+
* withText: true
|
|
23
|
+
* } );
|
|
23
24
|
*
|
|
24
|
-
*
|
|
25
|
+
* view.render();
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @extends module:ui/view~View
|
|
29
|
-
* @implements module:ui/button/button~Button
|
|
27
|
+
* document.body.append( view.element );
|
|
28
|
+
* ```
|
|
30
29
|
*/
|
|
31
30
|
export default class ButtonView extends View {
|
|
32
31
|
/**
|
|
@@ -52,51 +51,15 @@ export default class ButtonView extends View {
|
|
|
52
51
|
this.set('type', 'button');
|
|
53
52
|
this.set('withText', false);
|
|
54
53
|
this.set('withKeystroke', false);
|
|
55
|
-
/**
|
|
56
|
-
* Collection of the child views inside of the button {@link #element}.
|
|
57
|
-
*
|
|
58
|
-
* @readonly
|
|
59
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
60
|
-
*/
|
|
61
54
|
this.children = this.createCollection();
|
|
62
|
-
/**
|
|
63
|
-
* Label of the button view. It is configurable using the {@link #label label attribute}.
|
|
64
|
-
*
|
|
65
|
-
* @readonly
|
|
66
|
-
* @member {module:ui/view~View} #labelView
|
|
67
|
-
*/
|
|
68
55
|
this.labelView = this._createLabelView(ariaLabelUid);
|
|
69
|
-
/**
|
|
70
|
-
* The icon view of the button. Will be added to {@link #children} when the
|
|
71
|
-
* {@link #icon icon attribute} is defined.
|
|
72
|
-
*
|
|
73
|
-
* @readonly
|
|
74
|
-
* @member {module:ui/icon/iconview~IconView} #iconView
|
|
75
|
-
*/
|
|
76
56
|
this.iconView = new IconView();
|
|
77
57
|
this.iconView.extendTemplate({
|
|
78
58
|
attributes: {
|
|
79
59
|
class: 'ck-button__icon'
|
|
80
60
|
}
|
|
81
61
|
});
|
|
82
|
-
/**
|
|
83
|
-
* A view displaying the keystroke of the button next to the {@link #labelView label}.
|
|
84
|
-
* Added to {@link #children} when the {@link #withKeystroke `withKeystroke` attribute}
|
|
85
|
-
* is defined.
|
|
86
|
-
*
|
|
87
|
-
* @readonly
|
|
88
|
-
* @member {module:ui/view/view~View} #keystrokeView
|
|
89
|
-
*/
|
|
90
62
|
this.keystrokeView = this._createKeystrokeView();
|
|
91
|
-
/**
|
|
92
|
-
* Tooltip of the button bound to the template.
|
|
93
|
-
*
|
|
94
|
-
* @see #tooltip
|
|
95
|
-
* @see #_getTooltipString
|
|
96
|
-
* @private
|
|
97
|
-
* @observable
|
|
98
|
-
* @member {String|undefined} #_tooltipString
|
|
99
|
-
*/
|
|
100
63
|
this.bind('_tooltipString').to(this, 'tooltip', this, 'label', this, 'keystroke', this._getTooltipString.bind(this));
|
|
101
64
|
const template = {
|
|
102
65
|
tag: 'button',
|
|
@@ -168,9 +131,7 @@ export default class ButtonView extends View {
|
|
|
168
131
|
/**
|
|
169
132
|
* Creates a label view instance and binds it with button attributes.
|
|
170
133
|
*
|
|
171
|
-
* @
|
|
172
|
-
* @param {String} ariaLabelUid The aria label UID.
|
|
173
|
-
* @returns {module:ui/view~View}
|
|
134
|
+
* @param ariaLabelUid The aria label UID.
|
|
174
135
|
*/
|
|
175
136
|
_createLabelView(ariaLabelUid) {
|
|
176
137
|
const labelView = new View();
|
|
@@ -187,7 +148,7 @@ export default class ButtonView extends View {
|
|
|
187
148
|
},
|
|
188
149
|
children: [
|
|
189
150
|
{
|
|
190
|
-
text:
|
|
151
|
+
text: bind.to('label')
|
|
191
152
|
}
|
|
192
153
|
]
|
|
193
154
|
});
|
|
@@ -196,9 +157,6 @@ export default class ButtonView extends View {
|
|
|
196
157
|
/**
|
|
197
158
|
* Creates a view that displays a keystroke next to a {@link #labelView label }
|
|
198
159
|
* and binds it with button attributes.
|
|
199
|
-
*
|
|
200
|
-
* @private
|
|
201
|
-
* @returns {module:ui/view~View}
|
|
202
160
|
*/
|
|
203
161
|
_createKeystrokeView() {
|
|
204
162
|
const keystrokeView = new View();
|
|
@@ -222,13 +180,11 @@ export default class ButtonView extends View {
|
|
|
222
180
|
* Gets the text for the tooltip from the combination of
|
|
223
181
|
* {@link #tooltip}, {@link #label} and {@link #keystroke} attributes.
|
|
224
182
|
*
|
|
225
|
-
* @private
|
|
226
183
|
* @see #tooltip
|
|
227
184
|
* @see #_tooltipString
|
|
228
|
-
* @param
|
|
229
|
-
* @param
|
|
230
|
-
* @param
|
|
231
|
-
* @returns {String}
|
|
185
|
+
* @param tooltip Button tooltip.
|
|
186
|
+
* @param label Button label.
|
|
187
|
+
* @param keystroke Button keystroke.
|
|
232
188
|
*/
|
|
233
189
|
_getTooltipString(tooltip, label, keystroke) {
|
|
234
190
|
if (tooltip) {
|
|
@@ -0,0 +1,45 @@
|
|
|
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/button/switchbuttonview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import ButtonView from './buttonview';
|
|
10
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
11
|
+
import '../../theme/components/button/switchbutton.css';
|
|
12
|
+
/**
|
|
13
|
+
* The switch button view class.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const view = new SwitchButtonView();
|
|
17
|
+
*
|
|
18
|
+
* view.set( {
|
|
19
|
+
* withText: true,
|
|
20
|
+
* label: 'Switch me!'
|
|
21
|
+
* } );
|
|
22
|
+
*
|
|
23
|
+
* view.render();
|
|
24
|
+
*
|
|
25
|
+
* document.body.append( view.element );
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export default class SwitchButtonView extends ButtonView {
|
|
29
|
+
/**
|
|
30
|
+
* The toggle switch of the button.
|
|
31
|
+
*/
|
|
32
|
+
readonly toggleSwitchView: View;
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
constructor(locale?: Locale);
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
render(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a toggle child view.
|
|
43
|
+
*/
|
|
44
|
+
private _createToggleView;
|
|
45
|
+
}
|
|
@@ -11,18 +11,18 @@ import '../../theme/components/button/switchbutton.css';
|
|
|
11
11
|
/**
|
|
12
12
|
* The switch button view class.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const view = new SwitchButtonView();
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* view.set( {
|
|
18
|
+
* withText: true,
|
|
19
|
+
* label: 'Switch me!'
|
|
20
|
+
* } );
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
+
* view.render();
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @extends module:ui/button/buttonview~ButtonView
|
|
24
|
+
* document.body.append( view.element );
|
|
25
|
+
* ```
|
|
26
26
|
*/
|
|
27
27
|
export default class SwitchButtonView extends ButtonView {
|
|
28
28
|
/**
|
|
@@ -31,12 +31,6 @@ export default class SwitchButtonView extends ButtonView {
|
|
|
31
31
|
constructor(locale) {
|
|
32
32
|
super(locale);
|
|
33
33
|
this.isToggleable = true;
|
|
34
|
-
/**
|
|
35
|
-
* The toggle switch of the button.
|
|
36
|
-
*
|
|
37
|
-
* @readonly
|
|
38
|
-
* @member {module:ui/view~View} #toggleSwitchView
|
|
39
|
-
*/
|
|
40
34
|
this.toggleSwitchView = this._createToggleView();
|
|
41
35
|
this.extendTemplate({
|
|
42
36
|
attributes: {
|
|
@@ -53,9 +47,6 @@ export default class SwitchButtonView extends ButtonView {
|
|
|
53
47
|
}
|
|
54
48
|
/**
|
|
55
49
|
* Creates a toggle child view.
|
|
56
|
-
*
|
|
57
|
-
* @private
|
|
58
|
-
* @returns {module:ui/view~View}
|
|
59
50
|
*/
|
|
60
51
|
_createToggleView() {
|
|
61
52
|
const toggleSwitchView = new View();
|