@ckeditor/ckeditor5-ui 41.0.0 → 41.1.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 +3 -3
- package/src/bindings/draggableviewmixin.d.ts +4 -4
- package/src/bindings/draggableviewmixin.js +5 -5
- package/src/button/button.d.ts +3 -0
- package/src/colorpicker/colorpickerview.d.ts +8 -3
- package/src/colorpicker/colorpickerview.js +8 -5
- package/src/colorpicker/utils.d.ts +5 -0
- package/src/colorpicker/utils.js +9 -0
- package/src/colorselector/colorgridsfragmentview.js +0 -1
- package/src/dialog/dialog.d.ts +23 -23
- package/src/dialog/dialog.js +12 -12
- package/src/dialog/dialogactionsview.d.ts +3 -3
- package/src/dialog/dialogactionsview.js +2 -2
- package/src/dialog/dialogview.d.ts +24 -24
- package/src/dialog/dialogview.js +17 -17
- package/src/focuscycler.d.ts +2 -2
- package/src/focuscycler.js +2 -2
- package/src/icon/iconview.d.ts +3 -0
- package/src/list/listview.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-ui",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.1.0",
|
|
4
4
|
"description": "The UI framework and standard UI library of CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ckeditor/ckeditor5-core": "41.
|
|
16
|
-
"@ckeditor/ckeditor5-utils": "41.
|
|
15
|
+
"@ckeditor/ckeditor5-core": "41.1.0",
|
|
16
|
+
"@ckeditor/ckeditor5-utils": "41.1.0",
|
|
17
17
|
"color-convert": "2.0.1",
|
|
18
18
|
"color-parse": "1.4.2",
|
|
19
19
|
"lodash-es": "4.17.21",
|
|
@@ -18,12 +18,12 @@ import { type Constructor, type Mixed } from '@ckeditor/ckeditor5-utils';
|
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
20
|
* Creating a class extending it attaches a set of mouse and touch listeners allowing to observe dragging of the view element:
|
|
21
|
-
* * `mousedown` and `touchstart` on the view element - starting the dragging
|
|
22
|
-
* * `mousemove` and `touchmove` on the document - updating the view coordinates
|
|
21
|
+
* * `mousedown` and `touchstart` on the view element - starting the dragging.
|
|
22
|
+
* * `mousemove` and `touchmove` on the document - updating the view coordinates.
|
|
23
23
|
* * `mouseup` and `touchend` on the document - stopping the dragging.
|
|
24
24
|
*
|
|
25
|
-
* The mixin itself
|
|
26
|
-
* it
|
|
25
|
+
* The mixin itself does not provide a visual feedback (that is, the dragged element does not change its position) -
|
|
26
|
+
* it is up to the developer to implement it.
|
|
27
27
|
*/
|
|
28
28
|
export default function DraggableViewMixin<Base extends Constructor<View>>(view: Base): Mixed<Base, DraggableView>;
|
|
29
29
|
/**
|
|
@@ -14,12 +14,12 @@ import { global } from '@ckeditor/ckeditor5-utils';
|
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* Creating a class extending it attaches a set of mouse and touch listeners allowing to observe dragging of the view element:
|
|
17
|
-
* * `mousedown` and `touchstart` on the view element - starting the dragging
|
|
18
|
-
* * `mousemove` and `touchmove` on the document - updating the view coordinates
|
|
17
|
+
* * `mousedown` and `touchstart` on the view element - starting the dragging.
|
|
18
|
+
* * `mousemove` and `touchmove` on the document - updating the view coordinates.
|
|
19
19
|
* * `mouseup` and `touchend` on the document - stopping the dragging.
|
|
20
20
|
*
|
|
21
|
-
* The mixin itself
|
|
22
|
-
* it
|
|
21
|
+
* The mixin itself does not provide a visual feedback (that is, the dragged element does not change its position) -
|
|
22
|
+
* it is up to the developer to implement it.
|
|
23
23
|
*/
|
|
24
24
|
export default function DraggableViewMixin(view) {
|
|
25
25
|
class DraggableMixin extends view {
|
|
@@ -37,7 +37,7 @@ export default function DraggableViewMixin(view) {
|
|
|
37
37
|
*/
|
|
38
38
|
this._onDragEndBound = this._onDragEnd.bind(this);
|
|
39
39
|
/**
|
|
40
|
-
* The last coordinates of the view. It
|
|
40
|
+
* The last coordinates of the view. It is updated on every mouse move.
|
|
41
41
|
*/
|
|
42
42
|
this._lastDraggingCoordinates = { x: 0, y: 0 };
|
|
43
43
|
this.on('render', () => {
|
package/src/button/button.d.ts
CHANGED
|
@@ -118,6 +118,9 @@ export default interface Button {
|
|
|
118
118
|
* (Optional) An XML {@link module:ui/icon/iconview~IconView#content content} of the icon.
|
|
119
119
|
* When defined, an `iconView` should be added to the button.
|
|
120
120
|
*
|
|
121
|
+
* The user must provide the entire XML string, not just the path. See the
|
|
122
|
+
* {@glink framework/architecture/ui-library#setting-label-icon-and-tooltip UI library} guide for details.
|
|
123
|
+
*
|
|
121
124
|
* @observable
|
|
122
125
|
*/
|
|
123
126
|
icon: string | undefined;
|
|
@@ -9,8 +9,13 @@ import { type ColorPickerViewConfig } from './utils.js';
|
|
|
9
9
|
import { type Locale } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
import View from '../view.js';
|
|
11
11
|
import type ViewCollection from '../viewcollection.js';
|
|
12
|
-
import 'vanilla-colorful/hex
|
|
12
|
+
import { HexBase } from 'vanilla-colorful/lib/entrypoints/hex';
|
|
13
13
|
import '../../theme/components/colorpicker/colorpicker.css';
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'hex-color-picker': HexBase;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
14
19
|
/**
|
|
15
20
|
* A class which represents a color picker with an input field for defining custom colors.
|
|
16
21
|
*/
|
|
@@ -18,7 +23,7 @@ export default class ColorPickerView extends View {
|
|
|
18
23
|
/**
|
|
19
24
|
* Element with saturation and hue sliders.
|
|
20
25
|
*/
|
|
21
|
-
picker:
|
|
26
|
+
picker: HexBase;
|
|
22
27
|
/**
|
|
23
28
|
* Container for a `#` sign prefix and an input for displaying and defining custom colors
|
|
24
29
|
* in HEX format.
|
|
@@ -96,7 +101,7 @@ export default class ColorPickerView extends View {
|
|
|
96
101
|
}
|
|
97
102
|
declare class SliderView extends View {
|
|
98
103
|
/**
|
|
99
|
-
* @param element HTML
|
|
104
|
+
* @param element HTML element of slider in color picker.
|
|
100
105
|
*/
|
|
101
106
|
constructor(element: HTMLElement);
|
|
102
107
|
/**
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module ui/colorpicker/colorpickerview
|
|
7
7
|
*/
|
|
8
|
-
import { convertColor, convertToHex } from './utils.js';
|
|
8
|
+
import { convertColor, convertToHex, registerCustomElement } from './utils.js';
|
|
9
9
|
import { global, env } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
import { debounce } from 'lodash-es';
|
|
11
11
|
import View from '../view.js';
|
|
12
12
|
import LabeledFieldView from '../labeledfield/labeledfieldview.js';
|
|
13
13
|
import { createLabeledInputText } from '../labeledfield/utils.js';
|
|
14
|
-
|
|
14
|
+
// Custom export due to https://github.com/ckeditor/ckeditor5/issues/15698.
|
|
15
|
+
// eslint-disable-next-line ckeditor5-rules/require-file-extensions-in-imports
|
|
16
|
+
import { HexBase } from 'vanilla-colorful/lib/entrypoints/hex';
|
|
15
17
|
import '../../theme/components/colorpicker/colorpicker.css';
|
|
16
18
|
const waitingTime = 150;
|
|
17
19
|
/**
|
|
@@ -79,6 +81,8 @@ export default class ColorPickerView extends View {
|
|
|
79
81
|
*/
|
|
80
82
|
render() {
|
|
81
83
|
super.render();
|
|
84
|
+
// Extracted to the helper to make it testable.
|
|
85
|
+
registerCustomElement('hex-color-picker', HexBase);
|
|
82
86
|
this.picker = global.document.createElement('hex-color-picker');
|
|
83
87
|
this.picker.setAttribute('class', 'hex-color-picker');
|
|
84
88
|
this.picker.setAttribute('tabindex', '-1');
|
|
@@ -100,8 +104,7 @@ export default class ColorPickerView extends View {
|
|
|
100
104
|
this.picker.shadowRoot.appendChild(styleSheetForFocusedColorPicker);
|
|
101
105
|
}
|
|
102
106
|
this.picker.addEventListener('color-changed', event => {
|
|
103
|
-
const
|
|
104
|
-
const color = customEvent.detail.value;
|
|
107
|
+
const color = event.detail.value;
|
|
105
108
|
this._debounceColorPickerEvent(color);
|
|
106
109
|
});
|
|
107
110
|
}
|
|
@@ -213,7 +216,7 @@ function convertColorToCommonHexFormat(inputColor) {
|
|
|
213
216
|
// View abstraction over pointer in color picker.
|
|
214
217
|
class SliderView extends View {
|
|
215
218
|
/**
|
|
216
|
-
* @param element HTML
|
|
219
|
+
* @param element HTML element of slider in color picker.
|
|
217
220
|
*/
|
|
218
221
|
constructor(element) {
|
|
219
222
|
super();
|
|
@@ -41,3 +41,8 @@ export declare function convertColor(color: string, outputFormat: ColorPickerOut
|
|
|
41
41
|
* @returns A color string.
|
|
42
42
|
*/
|
|
43
43
|
export declare function convertToHex(color: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Registers the custom element in the
|
|
46
|
+
* [CustomElementsRegistry](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry).
|
|
47
|
+
*/
|
|
48
|
+
export declare function registerCustomElement(elementName: string, constructor: CustomElementConstructor): void;
|
package/src/colorpicker/utils.js
CHANGED
|
@@ -58,6 +58,15 @@ export function convertToHex(color) {
|
|
|
58
58
|
}
|
|
59
59
|
return convertColor(color, 'hex');
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Registers the custom element in the
|
|
63
|
+
* [CustomElementsRegistry](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry).
|
|
64
|
+
*/
|
|
65
|
+
export function registerCustomElement(elementName, constructor) {
|
|
66
|
+
if (customElements.get(elementName) === undefined) {
|
|
67
|
+
customElements.define(elementName, constructor);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
61
70
|
/**
|
|
62
71
|
* Formats the passed color channels according to the requested format.
|
|
63
72
|
*
|
package/src/dialog/dialog.d.ts
CHANGED
|
@@ -54,15 +54,15 @@ export default class Dialog extends Plugin {
|
|
|
54
54
|
/**
|
|
55
55
|
* Initiates listeners for the `show` and `hide` events emitted by this plugin.
|
|
56
56
|
*
|
|
57
|
-
* We
|
|
58
|
-
* because they would be fired in the wrong order
|
|
57
|
+
* We could not simply decorate the {@link #show} and {@link #hide} methods to fire events,
|
|
58
|
+
* because they would be fired in the wrong order – first would be `show` and then `hide`
|
|
59
59
|
* (because showing the dialog actually starts with hiding the previously visible one).
|
|
60
60
|
* Hence, we added private methods {@link #_show} and {@link #_hide} which are called on events
|
|
61
61
|
* in the desired sequence.
|
|
62
62
|
*/
|
|
63
63
|
private _initShowHideListeners;
|
|
64
64
|
/**
|
|
65
|
-
* Initiates keystroke handler for toggling the focus between the editor and dialog view.
|
|
65
|
+
* Initiates keystroke handler for toggling the focus between the editor and the dialog view.
|
|
66
66
|
*/
|
|
67
67
|
private _initFocusToggler;
|
|
68
68
|
/**
|
|
@@ -72,12 +72,12 @@ export default class Dialog extends Plugin {
|
|
|
72
72
|
/**
|
|
73
73
|
* Displays a dialog window.
|
|
74
74
|
*
|
|
75
|
-
* This method requires a {@link ~DialogDefinition} that defines dialog's content, title, icon, action buttons, etc.
|
|
75
|
+
* This method requires a {@link ~DialogDefinition} that defines the dialog's content, title, icon, action buttons, etc.
|
|
76
76
|
*
|
|
77
77
|
* For example, the following definition will create a dialog with:
|
|
78
|
-
* *
|
|
79
|
-
* *
|
|
80
|
-
* *
|
|
78
|
+
* * A header consisting of an icon, a title, and a "Close" button (it is added by default).
|
|
79
|
+
* * A content consisting of a view with a single paragraph.
|
|
80
|
+
* * A footer consisting of two buttons: "Yes" and "No".
|
|
81
81
|
*
|
|
82
82
|
* ```js
|
|
83
83
|
* // Create the view that will be used as the dialog's content.
|
|
@@ -102,7 +102,7 @@ export default class Dialog extends Plugin {
|
|
|
102
102
|
* // Show the dialog.
|
|
103
103
|
* editor.plugins.get( 'Dialog' ).show( {
|
|
104
104
|
* id: 'myDialog',
|
|
105
|
-
* icon: 'myIcon', //
|
|
105
|
+
* icon: 'myIcon', // This should be an SVG string.
|
|
106
106
|
* title: 'My dialog',
|
|
107
107
|
* content: textView,
|
|
108
108
|
* actionButtons: [
|
|
@@ -122,18 +122,18 @@ export default class Dialog extends Plugin {
|
|
|
122
122
|
* ```
|
|
123
123
|
*
|
|
124
124
|
* By specifying the {@link ~DialogDefinition#onShow} and {@link ~DialogDefinition#onHide} callbacks
|
|
125
|
-
* it
|
|
125
|
+
* it is also possible to add callbacks that will be called when the dialog is shown or hidden.
|
|
126
126
|
*
|
|
127
127
|
* For example, the callbacks in the following definition:
|
|
128
|
-
* *
|
|
129
|
-
* *
|
|
128
|
+
* * Disable the default behavior of the <kbd>Esc</kbd> key.
|
|
129
|
+
* * Fire a custom event when the dialog gets hidden.
|
|
130
130
|
*
|
|
131
131
|
* ```js
|
|
132
132
|
* editor.plugins.get( 'Dialog' ).show( {
|
|
133
133
|
* // ...
|
|
134
134
|
* onShow: dialog => {
|
|
135
135
|
* dialog.view.on( 'close', ( evt, data ) => {
|
|
136
|
-
* // Only prevent the event from
|
|
136
|
+
* // Only prevent the event from the "Esc" key - do not affect the other ways of closing the dialog.
|
|
137
137
|
* if ( data.source === 'escKeyPress' ) {
|
|
138
138
|
* evt.stop();
|
|
139
139
|
* }
|
|
@@ -173,8 +173,8 @@ export default class Dialog extends Plugin {
|
|
|
173
173
|
*/
|
|
174
174
|
export interface DialogDefinition {
|
|
175
175
|
/**
|
|
176
|
-
* A unique identifier of the dialog.
|
|
177
|
-
* For instance, when open, the
|
|
176
|
+
* A unique identifier of the dialog. It allows for distinguishing between different dialogs and their visibility.
|
|
177
|
+
* For instance, when open, the ID of the currently visible dialog is stored in {@link module:ui/dialog/dialog~Dialog#id}.
|
|
178
178
|
*
|
|
179
179
|
* The `id` is also passed along the {@link module:ui/dialog/dialog~DialogShowEvent} and {@link module:ui/dialog/dialog~DialogHideEvent}
|
|
180
180
|
* events.
|
|
@@ -188,7 +188,7 @@ export interface DialogDefinition {
|
|
|
188
188
|
*/
|
|
189
189
|
icon?: string;
|
|
190
190
|
/**
|
|
191
|
-
* A title displayed in dialogs's header.
|
|
191
|
+
* A title displayed in the dialogs's header. It also works as an accessible name of the dialog used by assistive technologies.
|
|
192
192
|
*
|
|
193
193
|
* When not set, the header is not displayed. Affects {@link #icon} and {@link #hasCloseButton}.
|
|
194
194
|
*/
|
|
@@ -213,7 +213,7 @@ export interface DialogDefinition {
|
|
|
213
213
|
*/
|
|
214
214
|
className?: string;
|
|
215
215
|
/**
|
|
216
|
-
* When set `true`, the dialog will become a modal,
|
|
216
|
+
* When set to `true`, the dialog will become a modal, that is, it will block the UI until it is closed.
|
|
217
217
|
*/
|
|
218
218
|
isModal?: boolean;
|
|
219
219
|
/**
|
|
@@ -224,18 +224,18 @@ export interface DialogDefinition {
|
|
|
224
224
|
*/
|
|
225
225
|
position?: typeof DialogViewPosition[keyof typeof DialogViewPosition];
|
|
226
226
|
/**
|
|
227
|
-
* A callback called when the dialog shows up with `low` priority. It allows for setting up the dialog's {@link #content}.
|
|
227
|
+
* A callback called when the dialog shows up with a `low` priority. It allows for setting up the dialog's {@link #content}.
|
|
228
228
|
*/
|
|
229
229
|
onShow?: (dialog: Dialog) => void;
|
|
230
230
|
/**
|
|
231
|
-
* A callback called when the dialog hides with `low` priority.
|
|
232
|
-
* It allows for cleaning up (
|
|
231
|
+
* A callback called when the dialog hides with a `low` priority.
|
|
232
|
+
* It allows for cleaning up (for example, resetting) the dialog's {@link #content}.
|
|
233
233
|
*/
|
|
234
234
|
onHide?: (dialog: Dialog) => void;
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
237
|
-
* An event fired after {@link module:ui/dialog/dialog~Dialog#show} is called. You can use it to customize behavior
|
|
238
|
-
* any dialog.
|
|
237
|
+
* An event fired after {@link module:ui/dialog/dialog~Dialog#show} is called. You can use it to customize the behavior
|
|
238
|
+
* of any dialog.
|
|
239
239
|
*
|
|
240
240
|
* ```js
|
|
241
241
|
* import { DialogViewPosition } from 'ckeditor5/src/ui.js';
|
|
@@ -255,8 +255,8 @@ export type DialogShowEvent = {
|
|
|
255
255
|
args: [dialogDefinition: DialogDefinition];
|
|
256
256
|
};
|
|
257
257
|
/**
|
|
258
|
-
* An event fired after {@link module:ui/dialog/dialog~Dialog#hide} is called. You can use it to customize behavior
|
|
259
|
-
* any dialog.
|
|
258
|
+
* An event fired after {@link module:ui/dialog/dialog~Dialog#hide} is called. You can use it to customize the behavior
|
|
259
|
+
* of any dialog.
|
|
260
260
|
*
|
|
261
261
|
* ```js
|
|
262
262
|
* // Logs after the "Find and Replace" dialog gets hidden
|
package/src/dialog/dialog.js
CHANGED
|
@@ -27,8 +27,8 @@ export default class Dialog extends Plugin {
|
|
|
27
27
|
/**
|
|
28
28
|
* Initiates listeners for the `show` and `hide` events emitted by this plugin.
|
|
29
29
|
*
|
|
30
|
-
* We
|
|
31
|
-
* because they would be fired in the wrong order
|
|
30
|
+
* We could not simply decorate the {@link #show} and {@link #hide} methods to fire events,
|
|
31
|
+
* because they would be fired in the wrong order – first would be `show` and then `hide`
|
|
32
32
|
* (because showing the dialog actually starts with hiding the previously visible one).
|
|
33
33
|
* Hence, we added private methods {@link #_show} and {@link #_hide} which are called on events
|
|
34
34
|
* in the desired sequence.
|
|
@@ -57,7 +57,7 @@ export default class Dialog extends Plugin {
|
|
|
57
57
|
}, { priority: 'low' });
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* Initiates keystroke handler for toggling the focus between the editor and dialog view.
|
|
60
|
+
* Initiates keystroke handler for toggling the focus between the editor and the dialog view.
|
|
61
61
|
*/
|
|
62
62
|
_initFocusToggler() {
|
|
63
63
|
const editor = this.editor;
|
|
@@ -94,12 +94,12 @@ export default class Dialog extends Plugin {
|
|
|
94
94
|
/**
|
|
95
95
|
* Displays a dialog window.
|
|
96
96
|
*
|
|
97
|
-
* This method requires a {@link ~DialogDefinition} that defines dialog's content, title, icon, action buttons, etc.
|
|
97
|
+
* This method requires a {@link ~DialogDefinition} that defines the dialog's content, title, icon, action buttons, etc.
|
|
98
98
|
*
|
|
99
99
|
* For example, the following definition will create a dialog with:
|
|
100
|
-
* *
|
|
101
|
-
* *
|
|
102
|
-
* *
|
|
100
|
+
* * A header consisting of an icon, a title, and a "Close" button (it is added by default).
|
|
101
|
+
* * A content consisting of a view with a single paragraph.
|
|
102
|
+
* * A footer consisting of two buttons: "Yes" and "No".
|
|
103
103
|
*
|
|
104
104
|
* ```js
|
|
105
105
|
* // Create the view that will be used as the dialog's content.
|
|
@@ -124,7 +124,7 @@ export default class Dialog extends Plugin {
|
|
|
124
124
|
* // Show the dialog.
|
|
125
125
|
* editor.plugins.get( 'Dialog' ).show( {
|
|
126
126
|
* id: 'myDialog',
|
|
127
|
-
* icon: 'myIcon', //
|
|
127
|
+
* icon: 'myIcon', // This should be an SVG string.
|
|
128
128
|
* title: 'My dialog',
|
|
129
129
|
* content: textView,
|
|
130
130
|
* actionButtons: [
|
|
@@ -144,18 +144,18 @@ export default class Dialog extends Plugin {
|
|
|
144
144
|
* ```
|
|
145
145
|
*
|
|
146
146
|
* By specifying the {@link ~DialogDefinition#onShow} and {@link ~DialogDefinition#onHide} callbacks
|
|
147
|
-
* it
|
|
147
|
+
* it is also possible to add callbacks that will be called when the dialog is shown or hidden.
|
|
148
148
|
*
|
|
149
149
|
* For example, the callbacks in the following definition:
|
|
150
|
-
* *
|
|
151
|
-
* *
|
|
150
|
+
* * Disable the default behavior of the <kbd>Esc</kbd> key.
|
|
151
|
+
* * Fire a custom event when the dialog gets hidden.
|
|
152
152
|
*
|
|
153
153
|
* ```js
|
|
154
154
|
* editor.plugins.get( 'Dialog' ).show( {
|
|
155
155
|
* // ...
|
|
156
156
|
* onShow: dialog => {
|
|
157
157
|
* dialog.view.on( 'close', ( evt, data ) => {
|
|
158
|
-
* // Only prevent the event from
|
|
158
|
+
* // Only prevent the event from the "Esc" key - do not affect the other ways of closing the dialog.
|
|
159
159
|
* if ( data.source === 'escKeyPress' ) {
|
|
160
160
|
* evt.stop();
|
|
161
161
|
* }
|
|
@@ -13,7 +13,7 @@ import ViewCollection from '../viewcollection.js';
|
|
|
13
13
|
import FocusCycler, { type FocusableView } from '../focuscycler.js';
|
|
14
14
|
import '../../theme/components/dialog/dialogactions.css';
|
|
15
15
|
/**
|
|
16
|
-
* A dialog actions view class.
|
|
16
|
+
* A dialog actions view class. It contains button views which are used to execute dialog actions.
|
|
17
17
|
*/
|
|
18
18
|
export default class DialogActionsView extends View {
|
|
19
19
|
/**
|
|
@@ -54,13 +54,13 @@ export default class DialogActionsView extends View {
|
|
|
54
54
|
*/
|
|
55
55
|
focus(direction?: 1 | -1): void;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Adds all elements from the {@link #children} collection to the {@link #_focusables} collection
|
|
58
58
|
* and to the {@link #_focusTracker} instance.
|
|
59
59
|
*/
|
|
60
60
|
private _updateFocusCyclableItems;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* A dialog action button definition. It
|
|
63
|
+
* A dialog action button definition. It is a slightly modified version
|
|
64
64
|
* of the {@link module:ui/button/button~Button} definition.
|
|
65
65
|
*/
|
|
66
66
|
export type DialogActionButtonDefinition = Pick<Button, 'label'> & Partial<Pick<Button, 'withText' | 'class' | 'icon'>> & {
|
|
@@ -12,7 +12,7 @@ import ViewCollection from '../viewcollection.js';
|
|
|
12
12
|
import FocusCycler from '../focuscycler.js';
|
|
13
13
|
import '../../theme/components/dialog/dialogactions.css';
|
|
14
14
|
/**
|
|
15
|
-
* A dialog actions view class.
|
|
15
|
+
* A dialog actions view class. It contains button views which are used to execute dialog actions.
|
|
16
16
|
*/
|
|
17
17
|
export default class DialogActionsView extends View {
|
|
18
18
|
/**
|
|
@@ -86,7 +86,7 @@ export default class DialogActionsView extends View {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* Adds all elements from the {@link #children} collection to the {@link #_focusables} collection
|
|
90
90
|
* and to the {@link #_focusTracker} instance.
|
|
91
91
|
*/
|
|
92
92
|
_updateFocusCyclableItems() {
|
|
@@ -18,17 +18,17 @@ import '../../theme/components/dialog/dialog.css';
|
|
|
18
18
|
/**
|
|
19
19
|
* Available dialog view positions:
|
|
20
20
|
*
|
|
21
|
-
* * `DialogViewPosition.SCREEN_CENTER`
|
|
22
|
-
* * `DialogViewPosition.EDITOR_CENTER`
|
|
23
|
-
* * `DialogViewPosition.EDITOR_TOP_SIDE`
|
|
24
|
-
* or top-left (for right-to-left languages) corner of the editor editable area
|
|
25
|
-
* * `DialogViewPosition.EDITOR_TOP_CENTER`
|
|
26
|
-
* * `DialogViewPosition.EDITOR_BOTTOM_CENTER`
|
|
27
|
-
* * `DialogViewPosition.EDITOR_ABOVE_CENTER`
|
|
28
|
-
* * `DialogViewPosition.EDITOR_BELOW_CENTER`
|
|
21
|
+
* * `DialogViewPosition.SCREEN_CENTER` – A fixed position in the center of the screen.
|
|
22
|
+
* * `DialogViewPosition.EDITOR_CENTER` – A dynamic position in the center of the editor editable area.
|
|
23
|
+
* * `DialogViewPosition.EDITOR_TOP_SIDE` – A dynamic position at the top-right (for the left-to-right languages)
|
|
24
|
+
* or top-left (for right-to-left languages) corner of the editor editable area.
|
|
25
|
+
* * `DialogViewPosition.EDITOR_TOP_CENTER` – A dynamic position at the top-center of the editor editable area.
|
|
26
|
+
* * `DialogViewPosition.EDITOR_BOTTOM_CENTER` – A dynamic position at the bottom-center of the editor editable area.
|
|
27
|
+
* * `DialogViewPosition.EDITOR_ABOVE_CENTER` – A dynamic position centered above the editor editable area.
|
|
28
|
+
* * `DialogViewPosition.EDITOR_BELOW_CENTER` – A dynamic position centered below the editor editable area.
|
|
29
29
|
*
|
|
30
30
|
* The position of a dialog is specified by a {@link module:ui/dialog/dialog~DialogDefinition#position `position` property} of a
|
|
31
|
-
* definition passed to {@link module:ui/dialog/dialog~Dialog#show} method.
|
|
31
|
+
* definition passed to the {@link module:ui/dialog/dialog~Dialog#show} method.
|
|
32
32
|
*/
|
|
33
33
|
export declare const DialogViewPosition: {
|
|
34
34
|
readonly SCREEN_CENTER: "screen-center";
|
|
@@ -46,15 +46,15 @@ declare const DialogView_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof
|
|
|
46
46
|
export default class DialogView extends DialogView_base implements DraggableView {
|
|
47
47
|
/**
|
|
48
48
|
* A collection of the child views inside of the dialog.
|
|
49
|
-
*
|
|
49
|
+
* A dialog can have 3 optional parts: header, content, and actions.
|
|
50
50
|
*/
|
|
51
51
|
readonly parts: ViewCollection;
|
|
52
52
|
/**
|
|
53
|
-
* A header view of the dialog. It
|
|
53
|
+
* A header view of the dialog. It is also a drag handle of the dialog.
|
|
54
54
|
*/
|
|
55
55
|
headerView?: FormHeaderView;
|
|
56
56
|
/**
|
|
57
|
-
* A close button view. It
|
|
57
|
+
* A close button view. It is automatically added to the header view if present.
|
|
58
58
|
*/
|
|
59
59
|
closeButtonView?: ButtonView;
|
|
60
60
|
/**
|
|
@@ -79,11 +79,11 @@ export default class DialogView extends DialogView_base implements DraggableView
|
|
|
79
79
|
readonly focusTracker: FocusTracker;
|
|
80
80
|
/**
|
|
81
81
|
* A flag indicating if the dialog was moved manually. If so, its position
|
|
82
|
-
*
|
|
82
|
+
* will not be updated automatically upon window resize or document scroll.
|
|
83
83
|
*/
|
|
84
84
|
wasMoved: boolean;
|
|
85
85
|
/**
|
|
86
|
-
* A flag indicating if this
|
|
86
|
+
* A flag indicating if this dialog view is a modal.
|
|
87
87
|
*
|
|
88
88
|
* @observable
|
|
89
89
|
*/
|
|
@@ -117,7 +117,7 @@ export default class DialogView extends DialogView_base implements DraggableView
|
|
|
117
117
|
*/
|
|
118
118
|
_isVisible: boolean;
|
|
119
119
|
/**
|
|
120
|
-
* A flag indicating if dialog is transparent. It is used to prevent the dialog from being visible
|
|
120
|
+
* A flag indicating if a dialog is transparent. It is used to prevent the dialog from being visible
|
|
121
121
|
* before its position is calculated.
|
|
122
122
|
*
|
|
123
123
|
* @observable
|
|
@@ -125,25 +125,25 @@ export default class DialogView extends DialogView_base implements DraggableView
|
|
|
125
125
|
*/
|
|
126
126
|
_isTransparent: boolean;
|
|
127
127
|
/**
|
|
128
|
-
* The calculated `top` CSS
|
|
128
|
+
* The calculated dialog `top` CSS property used for positioning.
|
|
129
129
|
*
|
|
130
130
|
* @observable
|
|
131
131
|
* @internal
|
|
132
132
|
*/
|
|
133
133
|
_top: number;
|
|
134
134
|
/**
|
|
135
|
-
* The calculated `left` CSS
|
|
135
|
+
* The calculated dialog `left` CSS property used for positioning.
|
|
136
136
|
*
|
|
137
137
|
* @observable
|
|
138
138
|
* @internal
|
|
139
139
|
*/
|
|
140
140
|
_left: number;
|
|
141
141
|
/**
|
|
142
|
-
*
|
|
142
|
+
* A callback returning the DOM root that requested the dialog.
|
|
143
143
|
*/
|
|
144
144
|
private _getCurrentDomRoot;
|
|
145
145
|
/**
|
|
146
|
-
*
|
|
146
|
+
* A callback returning the configured editor viewport offset.
|
|
147
147
|
*/
|
|
148
148
|
private _getViewportOffset;
|
|
149
149
|
/**
|
|
@@ -171,7 +171,7 @@ export default class DialogView extends DialogView_base implements DraggableView
|
|
|
171
171
|
get dragHandleElement(): HTMLElement | null;
|
|
172
172
|
/**
|
|
173
173
|
* Creates the dialog parts. Which of them are created depends on the arguments passed to the method.
|
|
174
|
-
* There are no rules regarding the dialog construction,
|
|
174
|
+
* There are no rules regarding the dialog construction, that is, no part is mandatory.
|
|
175
175
|
* Each part can only be created once.
|
|
176
176
|
*
|
|
177
177
|
* @internal
|
|
@@ -188,7 +188,7 @@ export default class DialogView extends DialogView_base implements DraggableView
|
|
|
188
188
|
*/
|
|
189
189
|
focus(): void;
|
|
190
190
|
/**
|
|
191
|
-
*
|
|
191
|
+
* Normalizes the passed coordinates to make sure the dialog view
|
|
192
192
|
* is displayed within the visible viewport and moves it there.
|
|
193
193
|
*
|
|
194
194
|
* @internal
|
|
@@ -206,11 +206,11 @@ export default class DialogView extends DialogView_base implements DraggableView
|
|
|
206
206
|
moveBy(left: number, top: number): void;
|
|
207
207
|
/**
|
|
208
208
|
* Moves the dialog view to the off-screen position.
|
|
209
|
-
* Used when there
|
|
209
|
+
* Used when there is no space to display the dialog.
|
|
210
210
|
*/
|
|
211
211
|
private _moveOffScreen;
|
|
212
212
|
/**
|
|
213
|
-
* Recalculates the dialog according to the set position and viewport
|
|
213
|
+
* Recalculates the dialog according to the set position and viewport,
|
|
214
214
|
* and moves it to the new position.
|
|
215
215
|
*/
|
|
216
216
|
updatePosition(): void;
|
|
@@ -232,7 +232,7 @@ export default class DialogView extends DialogView_base implements DraggableView
|
|
|
232
232
|
*/
|
|
233
233
|
private _updateFocusCyclableItems;
|
|
234
234
|
/**
|
|
235
|
-
* Creates
|
|
235
|
+
* Creates the close button view that is displayed in the header view corner.
|
|
236
236
|
*/
|
|
237
237
|
private _createCloseButton;
|
|
238
238
|
}
|
package/src/dialog/dialogview.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @module ui/dialog/dialogview
|
|
7
7
|
*/
|
|
8
8
|
import { KeystrokeHandler, FocusTracker, Rect, global, toUnit } from '@ckeditor/ckeditor5-utils';
|
|
9
|
+
import { icons } from '@ckeditor/ckeditor5-core';
|
|
9
10
|
import ViewCollection from '../viewcollection.js';
|
|
10
11
|
import View from '../view.js';
|
|
11
12
|
import FormHeaderView from '../formheader/formheaderview.js';
|
|
@@ -16,21 +17,20 @@ import DialogActionsView from './dialogactionsview.js';
|
|
|
16
17
|
import DialogContentView from './dialogcontentview.js';
|
|
17
18
|
import '../../theme/components/dialog/dialog.css';
|
|
18
19
|
// @if CK_DEBUG_DIALOG // const RectDrawer = require( '@ckeditor/ckeditor5-utils/tests/_utils/rectdrawer' ).default;
|
|
19
|
-
import cancelIcon from '@ckeditor/ckeditor5-core/theme/icons/cancel.svg';
|
|
20
20
|
/**
|
|
21
21
|
* Available dialog view positions:
|
|
22
22
|
*
|
|
23
|
-
* * `DialogViewPosition.SCREEN_CENTER`
|
|
24
|
-
* * `DialogViewPosition.EDITOR_CENTER`
|
|
25
|
-
* * `DialogViewPosition.EDITOR_TOP_SIDE`
|
|
26
|
-
* or top-left (for right-to-left languages) corner of the editor editable area
|
|
27
|
-
* * `DialogViewPosition.EDITOR_TOP_CENTER`
|
|
28
|
-
* * `DialogViewPosition.EDITOR_BOTTOM_CENTER`
|
|
29
|
-
* * `DialogViewPosition.EDITOR_ABOVE_CENTER`
|
|
30
|
-
* * `DialogViewPosition.EDITOR_BELOW_CENTER`
|
|
23
|
+
* * `DialogViewPosition.SCREEN_CENTER` – A fixed position in the center of the screen.
|
|
24
|
+
* * `DialogViewPosition.EDITOR_CENTER` – A dynamic position in the center of the editor editable area.
|
|
25
|
+
* * `DialogViewPosition.EDITOR_TOP_SIDE` – A dynamic position at the top-right (for the left-to-right languages)
|
|
26
|
+
* or top-left (for right-to-left languages) corner of the editor editable area.
|
|
27
|
+
* * `DialogViewPosition.EDITOR_TOP_CENTER` – A dynamic position at the top-center of the editor editable area.
|
|
28
|
+
* * `DialogViewPosition.EDITOR_BOTTOM_CENTER` – A dynamic position at the bottom-center of the editor editable area.
|
|
29
|
+
* * `DialogViewPosition.EDITOR_ABOVE_CENTER` – A dynamic position centered above the editor editable area.
|
|
30
|
+
* * `DialogViewPosition.EDITOR_BELOW_CENTER` – A dynamic position centered below the editor editable area.
|
|
31
31
|
*
|
|
32
32
|
* The position of a dialog is specified by a {@link module:ui/dialog/dialog~DialogDefinition#position `position` property} of a
|
|
33
|
-
* definition passed to {@link module:ui/dialog/dialog~Dialog#show} method.
|
|
33
|
+
* definition passed to the {@link module:ui/dialog/dialog~Dialog#show} method.
|
|
34
34
|
*/
|
|
35
35
|
export const DialogViewPosition = {
|
|
36
36
|
SCREEN_CENTER: 'screen-center',
|
|
@@ -53,7 +53,7 @@ class DialogView extends DraggableViewMixin(View) {
|
|
|
53
53
|
super(locale);
|
|
54
54
|
/**
|
|
55
55
|
* A flag indicating if the dialog was moved manually. If so, its position
|
|
56
|
-
*
|
|
56
|
+
* will not be updated automatically upon window resize or document scroll.
|
|
57
57
|
*/
|
|
58
58
|
this.wasMoved = false;
|
|
59
59
|
const bind = this.bindTemplate;
|
|
@@ -176,7 +176,7 @@ class DialogView extends DraggableViewMixin(View) {
|
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Creates the dialog parts. Which of them are created depends on the arguments passed to the method.
|
|
179
|
-
* There are no rules regarding the dialog construction,
|
|
179
|
+
* There are no rules regarding the dialog construction, that is, no part is mandatory.
|
|
180
180
|
* Each part can only be created once.
|
|
181
181
|
*
|
|
182
182
|
* @internal
|
|
@@ -215,7 +215,7 @@ class DialogView extends DraggableViewMixin(View) {
|
|
|
215
215
|
this._focusCycler.focusFirst();
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
218
|
+
* Normalizes the passed coordinates to make sure the dialog view
|
|
219
219
|
* is displayed within the visible viewport and moves it there.
|
|
220
220
|
*
|
|
221
221
|
* @internal
|
|
@@ -256,13 +256,13 @@ class DialogView extends DraggableViewMixin(View) {
|
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* Moves the dialog view to the off-screen position.
|
|
259
|
-
* Used when there
|
|
259
|
+
* Used when there is no space to display the dialog.
|
|
260
260
|
*/
|
|
261
261
|
_moveOffScreen() {
|
|
262
262
|
this._moveTo(-9999, -9999);
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
|
-
* Recalculates the dialog according to the set position and viewport
|
|
265
|
+
* Recalculates the dialog according to the set position and viewport,
|
|
266
266
|
* and moves it to the new position.
|
|
267
267
|
*/
|
|
268
268
|
updatePosition() {
|
|
@@ -431,7 +431,7 @@ class DialogView extends DraggableViewMixin(View) {
|
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
/**
|
|
434
|
-
* Creates
|
|
434
|
+
* Creates the close button view that is displayed in the header view corner.
|
|
435
435
|
*/
|
|
436
436
|
_createCloseButton() {
|
|
437
437
|
const buttonView = new ButtonView(this.locale);
|
|
@@ -439,7 +439,7 @@ class DialogView extends DraggableViewMixin(View) {
|
|
|
439
439
|
buttonView.set({
|
|
440
440
|
label: t('Close'),
|
|
441
441
|
tooltip: true,
|
|
442
|
-
icon:
|
|
442
|
+
icon: icons.cancel
|
|
443
443
|
});
|
|
444
444
|
buttonView.on('execute', () => this.fire('close', { source: 'closeButton' }));
|
|
445
445
|
return buttonView;
|
package/src/focuscycler.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare const FocusCycler_base: {
|
|
|
13
13
|
prototype: import("@ckeditor/ckeditor5-utils").Emitter;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* A utility class that helps cycling over
|
|
16
|
+
* A utility class that helps cycling over {@link module:ui/focuscycler~FocusableView focusable views} in a
|
|
17
17
|
* {@link module:ui/viewcollection~ViewCollection} when the focus is tracked by the
|
|
18
18
|
* {@link module:utils/focustracker~FocusTracker} instance. It helps implementing keyboard
|
|
19
19
|
* navigation in HTML forms, toolbars, lists and the like.
|
|
@@ -25,7 +25,7 @@ declare const FocusCycler_base: {
|
|
|
25
25
|
* A simple cycler setup can look like this:
|
|
26
26
|
*
|
|
27
27
|
* ```ts
|
|
28
|
-
* const focusables = new ViewCollection();
|
|
28
|
+
* const focusables = new ViewCollection<FocusableView>();
|
|
29
29
|
* const focusTracker = new FocusTracker();
|
|
30
30
|
*
|
|
31
31
|
* // Add focusable views to the focus tracker.
|
package/src/focuscycler.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { isVisible, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
/**
|
|
10
|
-
* A utility class that helps cycling over
|
|
10
|
+
* A utility class that helps cycling over {@link module:ui/focuscycler~FocusableView focusable views} in a
|
|
11
11
|
* {@link module:ui/viewcollection~ViewCollection} when the focus is tracked by the
|
|
12
12
|
* {@link module:utils/focustracker~FocusTracker} instance. It helps implementing keyboard
|
|
13
13
|
* navigation in HTML forms, toolbars, lists and the like.
|
|
@@ -19,7 +19,7 @@ import { isVisible, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
|
19
19
|
* A simple cycler setup can look like this:
|
|
20
20
|
*
|
|
21
21
|
* ```ts
|
|
22
|
-
* const focusables = new ViewCollection();
|
|
22
|
+
* const focusables = new ViewCollection<FocusableView>();
|
|
23
23
|
* const focusTracker = new FocusTracker();
|
|
24
24
|
*
|
|
25
25
|
* // Add focusable views to the focus tracker.
|
package/src/icon/iconview.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export default class IconView extends View {
|
|
|
14
14
|
/**
|
|
15
15
|
* The SVG source of the icon.
|
|
16
16
|
*
|
|
17
|
+
* The user must provide the entire XML string, not just the path. See the
|
|
18
|
+
* {@glink framework/architecture/ui-library#setting-label-icon-and-tooltip UI library} guide for details.
|
|
19
|
+
*
|
|
17
20
|
* @observable
|
|
18
21
|
*/
|
|
19
22
|
content: string | undefined;
|
package/src/list/listview.js
CHANGED