@ckeditor/ckeditor5-ui 35.3.2 → 36.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/package.json +21 -21
- package/src/bindings/addkeyboardhandlingforgrid.js +49 -14
- package/src/bindings/clickoutsidehandler.js +5 -7
- package/src/bindings/injectcsstransitiondisabler.js +1 -1
- package/src/bindings/preventdefault.js +1 -1
- package/src/bindings/submithandler.js +1 -1
- package/src/button/button.js +1 -1
- package/src/button/buttonview.js +2 -4
- package/src/button/switchbuttonview.js +1 -1
- package/src/colorgrid/colorgridview.js +4 -3
- package/src/colorgrid/colortileview.js +1 -1
- package/src/colorgrid/utils.js +1 -1
- package/src/componentfactory.js +3 -3
- package/src/dropdown/button/dropdownbutton.js +1 -1
- package/src/dropdown/button/dropdownbuttonview.js +1 -1
- package/src/dropdown/button/splitbuttonview.js +2 -3
- package/src/dropdown/dropdownpanelfocusable.js +1 -1
- package/src/dropdown/dropdownpanelview.js +2 -2
- package/src/dropdown/dropdownview.js +2 -4
- package/src/dropdown/utils.js +84 -27
- package/src/editableui/editableuiview.js +1 -1
- package/src/editableui/inline/inlineeditableuiview.js +1 -1
- package/src/editorui/bodycollection.js +2 -2
- package/src/editorui/boxed/boxededitoruiview.js +1 -1
- package/src/editorui/editorui.js +476 -0
- package/src/editorui/editoruiview.js +1 -1
- package/src/focuscycler.js +2 -2
- package/src/formheader/formheaderview.js +2 -2
- package/src/icon/iconview.js +1 -1
- package/src/iframe/iframeview.js +10 -10
- package/src/index.js +4 -1
- package/src/input/inputview.js +2 -2
- package/src/inputnumber/inputnumberview.js +1 -1
- package/src/inputtext/inputtextview.js +1 -1
- package/src/label/labelview.js +2 -2
- package/src/labeledfield/labeledfieldview.js +2 -2
- package/src/labeledfield/utils.js +1 -1
- package/src/labeledinput/labeledinputview.js +2 -2
- package/src/list/listitemview.js +1 -1
- package/src/list/listseparatorview.js +1 -1
- package/src/list/listview.js +11 -4
- package/src/model.js +3 -3
- package/src/notification/notification.js +2 -2
- package/src/panel/balloon/balloonpanelview.js +2 -5
- package/src/panel/balloon/contextualballoon.js +39 -20
- package/src/panel/sticky/stickypanelview.js +2 -3
- package/src/template.js +3 -6
- package/src/toolbar/balloon/balloontoolbar.js +5 -9
- package/src/toolbar/block/blockbuttonview.js +2 -2
- package/src/toolbar/block/blocktoolbar.js +4 -8
- package/src/toolbar/normalizetoolbarconfig.js +1 -1
- package/src/toolbar/toolbarlinebreakview.js +1 -1
- package/src/toolbar/toolbarseparatorview.js +1 -1
- package/src/toolbar/toolbarview.js +19 -19
- package/src/tooltipmanager.js +3 -4
- package/src/view.js +4 -8
- package/src/viewcollection.js +2 -3
- package/theme/components/button/button.css +1 -1
- package/theme/components/button/switchbutton.css +1 -1
- package/theme/components/colorgrid/colorgrid.css +1 -1
- package/theme/components/dropdown/dropdown.css +1 -1
- package/theme/components/dropdown/listdropdown.css +1 -1
- package/theme/components/dropdown/splitbutton.css +1 -1
- package/theme/components/dropdown/toolbardropdown.css +1 -1
- package/theme/components/editorui/editorui.css +1 -1
- package/theme/components/formheader/formheader.css +1 -1
- package/theme/components/icon/icon.css +1 -1
- package/theme/components/input/input.css +1 -1
- package/theme/components/label/label.css +1 -1
- package/theme/components/labeledfield/labeledfieldview.css +1 -1
- package/theme/components/labeledinput/labeledinput.css +1 -1
- package/theme/components/list/list.css +1 -1
- package/theme/components/panel/balloonpanel.css +1 -1
- package/theme/components/panel/balloonrotator.css +1 -1
- package/theme/components/panel/fakepanel.css +1 -1
- package/theme/components/panel/stickypanel.css +1 -1
- package/theme/components/responsive-form/responsiveform.css +1 -1
- package/theme/components/toolbar/blocktoolbar.css +1 -1
- package/theme/components/toolbar/toolbar.css +1 -1
- package/theme/components/tooltip/tooltip.css +1 -1
- package/theme/globals/_hidden.css +1 -1
- package/theme/globals/_reset.css +1 -1
- package/theme/globals/_transition.css +1 -1
- package/theme/globals/_zindex.css +1 -1
- package/theme/globals/globals.css +1 -1
- package/theme/mixins/_dir.css +1 -1
- package/theme/mixins/_rwd.css +1 -1
- package/theme/mixins/_unselectable.css +1 -1
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 UI framework** – https://github.com/ckeditor/ckeditor5-ui <br>
|
|
5
|
-
Copyright (c) 2003-
|
|
5
|
+
Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
|
6
6
|
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "36.0.0",
|
|
4
4
|
"description": "The UI framework and standard UI library of CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -11,29 +11,29 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "src/index.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
15
|
-
"@ckeditor/ckeditor5-core": "^
|
|
14
|
+
"@ckeditor/ckeditor5-utils": "^36.0.0",
|
|
15
|
+
"@ckeditor/ckeditor5-core": "^36.0.0",
|
|
16
16
|
"lodash-es": "^4.17.15"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
20
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
21
|
-
"@ckeditor/ckeditor5-editor-balloon": "^
|
|
22
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
23
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
24
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
25
|
-
"@ckeditor/ckeditor5-essentials": "^
|
|
26
|
-
"@ckeditor/ckeditor5-font": "^
|
|
27
|
-
"@ckeditor/ckeditor5-find-and-replace": "^
|
|
28
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
29
|
-
"@ckeditor/ckeditor5-image": "^
|
|
30
|
-
"@ckeditor/ckeditor5-link": "^
|
|
31
|
-
"@ckeditor/ckeditor5-list": "^
|
|
32
|
-
"@ckeditor/ckeditor5-mention": "^
|
|
33
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
34
|
-
"@ckeditor/ckeditor5-horizontal-line": "^
|
|
35
|
-
"@ckeditor/ckeditor5-table": "^
|
|
36
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
19
|
+
"@ckeditor/ckeditor5-basic-styles": "^36.0.0",
|
|
20
|
+
"@ckeditor/ckeditor5-block-quote": "^36.0.0",
|
|
21
|
+
"@ckeditor/ckeditor5-editor-balloon": "^36.0.0",
|
|
22
|
+
"@ckeditor/ckeditor5-editor-classic": "^36.0.0",
|
|
23
|
+
"@ckeditor/ckeditor5-engine": "^36.0.0",
|
|
24
|
+
"@ckeditor/ckeditor5-enter": "^36.0.0",
|
|
25
|
+
"@ckeditor/ckeditor5-essentials": "^36.0.0",
|
|
26
|
+
"@ckeditor/ckeditor5-font": "^36.0.0",
|
|
27
|
+
"@ckeditor/ckeditor5-find-and-replace": "^36.0.0",
|
|
28
|
+
"@ckeditor/ckeditor5-heading": "^36.0.0",
|
|
29
|
+
"@ckeditor/ckeditor5-image": "^36.0.0",
|
|
30
|
+
"@ckeditor/ckeditor5-link": "^36.0.0",
|
|
31
|
+
"@ckeditor/ckeditor5-list": "^36.0.0",
|
|
32
|
+
"@ckeditor/ckeditor5-mention": "^36.0.0",
|
|
33
|
+
"@ckeditor/ckeditor5-paragraph": "^36.0.0",
|
|
34
|
+
"@ckeditor/ckeditor5-horizontal-line": "^36.0.0",
|
|
35
|
+
"@ckeditor/ckeditor5-table": "^36.0.0",
|
|
36
|
+
"@ckeditor/ckeditor5-typing": "^36.0.0",
|
|
37
37
|
"typescript": "^4.8.4",
|
|
38
38
|
"webpack": "^5.58.1",
|
|
39
39
|
"webpack-cli": "^4.9.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -15,24 +15,19 @@
|
|
|
15
15
|
* @param {module:ui/viewcollection~ViewCollection} options.gridItems A collection of grid items.
|
|
16
16
|
* @param {Number|Function} options.numberOfColumns Number of columns in the grid. Can be specified as a function that returns
|
|
17
17
|
* the number (e.g. for responsive grids).
|
|
18
|
+
* @param {String|undefined} options.uiLanguageDirection String of ui language direction.
|
|
18
19
|
*/
|
|
19
|
-
export default function addKeyboardHandlingForGrid({ keystrokeHandler, focusTracker, gridItems, numberOfColumns }) {
|
|
20
|
+
export default function addKeyboardHandlingForGrid({ keystrokeHandler, focusTracker, gridItems, numberOfColumns, uiLanguageDirection }) {
|
|
20
21
|
const getNumberOfColumns = typeof numberOfColumns === 'number' ? () => numberOfColumns : numberOfColumns;
|
|
21
22
|
keystrokeHandler.set('arrowright', getGridItemFocuser((focusedElementIndex, gridItems) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
else {
|
|
26
|
-
return focusedElementIndex + 1;
|
|
27
|
-
}
|
|
23
|
+
return uiLanguageDirection === 'rtl' ?
|
|
24
|
+
getLeftElementIndex(focusedElementIndex, gridItems.length) :
|
|
25
|
+
getRightElementIndex(focusedElementIndex, gridItems.length);
|
|
28
26
|
}));
|
|
29
27
|
keystrokeHandler.set('arrowleft', getGridItemFocuser((focusedElementIndex, gridItems) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else {
|
|
34
|
-
return focusedElementIndex - 1;
|
|
35
|
-
}
|
|
28
|
+
return uiLanguageDirection === 'rtl' ?
|
|
29
|
+
getRightElementIndex(focusedElementIndex, gridItems.length) :
|
|
30
|
+
getLeftElementIndex(focusedElementIndex, gridItems.length);
|
|
36
31
|
}));
|
|
37
32
|
keystrokeHandler.set('arrowup', getGridItemFocuser((focusedElementIndex, gridItems) => {
|
|
38
33
|
let nextIndex = focusedElementIndex - getNumberOfColumns();
|
|
@@ -61,4 +56,44 @@ export default function addKeyboardHandlingForGrid({ keystrokeHandler, focusTrac
|
|
|
61
56
|
evt.preventDefault();
|
|
62
57
|
};
|
|
63
58
|
}
|
|
59
|
+
// Function returning the next index.
|
|
60
|
+
//
|
|
61
|
+
// before: [ ][x][ ] after: [ ][ ][x]
|
|
62
|
+
// index = 1 index = 2
|
|
63
|
+
//
|
|
64
|
+
// If current index is last, function returns first index.
|
|
65
|
+
//
|
|
66
|
+
// before: [ ][ ][x] after: [x][ ][ ]
|
|
67
|
+
// index = 2 index = 0
|
|
68
|
+
//
|
|
69
|
+
// @param {number} [elementIndex] Number of current index.
|
|
70
|
+
// @param {number} [collectionLength] A count of collection items.
|
|
71
|
+
function getRightElementIndex(elementIndex, collectionLength) {
|
|
72
|
+
if (elementIndex === collectionLength - 1) {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return elementIndex + 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Function returning the previous index.
|
|
80
|
+
//
|
|
81
|
+
// before: [ ][x][ ] after: [x][ ][ ]
|
|
82
|
+
// index = 1 index = 0
|
|
83
|
+
//
|
|
84
|
+
// If current index is first, function returns last index.
|
|
85
|
+
//
|
|
86
|
+
// before: [x][ ][ ] after: [ ][ ][x]
|
|
87
|
+
// index = 0 index = 2
|
|
88
|
+
//
|
|
89
|
+
// @param {number} [elementIndex] Number of current index.
|
|
90
|
+
// @param {number} [collectionLength] A count of collection items.
|
|
91
|
+
function getLeftElementIndex(elementIndex, collectionLength) {
|
|
92
|
+
if (elementIndex === 0) {
|
|
93
|
+
return collectionLength - 1;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return elementIndex - 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
64
99
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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/clickoutsidehandler
|
|
7
|
-
*/
|
|
8
5
|
/* global document */
|
|
9
6
|
/**
|
|
10
7
|
* Handles clicking **outside** of a specified set of elements, then fires an action.
|
|
@@ -17,8 +14,8 @@
|
|
|
17
14
|
* @param {module:utils/dom/emittermixin~Emitter} options.emitter The emitter to which this behavior
|
|
18
15
|
* should be added.
|
|
19
16
|
* @param {Function} options.activator Function returning a `Boolean`, to determine whether the handler is active.
|
|
20
|
-
* @param {Array.<HTMLElement>} options.contextElements HTML elements
|
|
21
|
-
* handler. Clicking any of them or their descendants will **not** fire the callback.
|
|
17
|
+
* @param {Array.<HTMLElement>} options.contextElements Array of HTML elements or a callback returning an array of HTML elements
|
|
18
|
+
* that determine the scope of the handler. Clicking any of them or their descendants will **not** fire the callback.
|
|
22
19
|
* @param {Function} options.callback An action executed by the handler.
|
|
23
20
|
*/
|
|
24
21
|
export default function clickOutsideHandler({ emitter, activator, callback, contextElements }) {
|
|
@@ -29,7 +26,8 @@ export default function clickOutsideHandler({ emitter, activator, callback, cont
|
|
|
29
26
|
// Check if `composedPath` is `undefined` in case the browser does not support native shadow DOM.
|
|
30
27
|
// Can be removed when all supported browsers support native shadow DOM.
|
|
31
28
|
const path = typeof domEvt.composedPath == 'function' ? domEvt.composedPath() : [];
|
|
32
|
-
|
|
29
|
+
const contextElementsList = typeof contextElements == 'function' ? contextElements() : contextElements;
|
|
30
|
+
for (const contextElement of contextElementsList) {
|
|
33
31
|
if (contextElement.contains(domEvt.target) || path.includes(contextElement)) {
|
|
34
32
|
return;
|
|
35
33
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
package/src/button/button.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
export {};
|
package/src/button/buttonview.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import View from '../view';
|
|
9
9
|
import IconView from '../icon/iconview';
|
|
10
|
-
import uid from '@ckeditor/ckeditor5-utils
|
|
11
|
-
import { getEnvKeystrokeText } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
12
|
-
import env from '@ckeditor/ckeditor5-utils/src/env';
|
|
10
|
+
import { env, getEnvKeystrokeText, uid } from '@ckeditor/ckeditor5-utils';
|
|
13
11
|
import '../../theme/components/button/button.css';
|
|
14
12
|
/**
|
|
15
13
|
* The button view class.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import View from '../view';
|
|
9
9
|
import ColorTileView from './colortileview';
|
|
10
|
-
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
|
|
11
10
|
import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
|
|
12
11
|
import addKeyboardHandlingForGrid from '../bindings/addkeyboardhandlingforgrid';
|
|
12
|
+
import { FocusTracker } from '@ckeditor/ckeditor5-utils';
|
|
13
13
|
import '../../theme/components/colorgrid/colorgrid.css';
|
|
14
14
|
/**
|
|
15
15
|
* A grid of {@link module:ui/colorgrid/colortile~ColorTileView color tiles}.
|
|
@@ -141,7 +141,8 @@ export default class ColorGridView extends View {
|
|
|
141
141
|
keystrokeHandler: this.keystrokes,
|
|
142
142
|
focusTracker: this.focusTracker,
|
|
143
143
|
gridItems: this.items,
|
|
144
|
-
numberOfColumns: this.columns
|
|
144
|
+
numberOfColumns: this.columns,
|
|
145
|
+
uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
148
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
package/src/colorgrid/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
package/src/componentfactory.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
6
6
|
* @module ui/componentfactory
|
|
7
7
|
*/
|
|
8
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
8
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
/**
|
|
10
10
|
* A helper class implementing the UI component ({@link module:ui/view~View view}) factory.
|
|
11
11
|
*
|
|
12
12
|
* It allows functions producing specific UI components to be registered under their unique names
|
|
13
13
|
* in the factory. A registered component can be then instantiated by providing its name.
|
|
14
|
-
* Note that names are case insensitive.
|
|
14
|
+
* Note that the names are case insensitive.
|
|
15
15
|
*
|
|
16
16
|
* // The editor provides localization tools for the factory.
|
|
17
17
|
* const factory = new ComponentFactory( editor );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import View from '../../view';
|
|
9
9
|
import ButtonView from '../../button/buttonview';
|
|
10
|
-
import KeystrokeHandler from '@ckeditor/ckeditor5-utils
|
|
11
|
-
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
|
|
10
|
+
import { KeystrokeHandler, FocusTracker } from '@ckeditor/ckeditor5-utils';
|
|
12
11
|
import dropdownArrowIcon from '../../../theme/icons/dropdown-arrow.svg';
|
|
13
12
|
import '../../../theme/components/dropdown/splitbutton.css';
|
|
14
13
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
6
6
|
* @module ui/dropdown/dropdownpanelview
|
|
7
7
|
*/
|
|
8
8
|
import View from '../view';
|
|
9
|
-
import { logWarning } from '@ckeditor/ckeditor5-utils
|
|
9
|
+
import { logWarning } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
/**
|
|
11
11
|
* The dropdown panel view class.
|
|
12
12
|
*
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
6
6
|
* @module ui/dropdown/dropdownview
|
|
7
7
|
*/
|
|
8
8
|
import View from '../view';
|
|
9
|
-
import KeystrokeHandler from '@ckeditor/ckeditor5-utils
|
|
10
|
-
import { FocusTracker } from '@ckeditor/ckeditor5-utils';
|
|
11
|
-
import { getOptimalPosition } from '@ckeditor/ckeditor5-utils/src/dom/position';
|
|
9
|
+
import { KeystrokeHandler, FocusTracker, getOptimalPosition } from '@ckeditor/ckeditor5-utils';
|
|
12
10
|
import '../../theme/components/dropdown/dropdown.css';
|
|
13
11
|
/**
|
|
14
12
|
* The dropdown view class. It manages the dropdown button and dropdown panel.
|
package/src/dropdown/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -15,6 +15,7 @@ import ListSeparatorView from '../list/listseparatorview';
|
|
|
15
15
|
import ButtonView from '../button/buttonview';
|
|
16
16
|
import SplitButtonView from './button/splitbuttonview';
|
|
17
17
|
import SwitchButtonView from '../button/switchbuttonview';
|
|
18
|
+
import ViewCollection from '../viewcollection';
|
|
18
19
|
import clickOutsideHandler from '../bindings/clickoutsidehandler';
|
|
19
20
|
import { global, priorities, logWarning } from '@ckeditor/ckeditor5-utils';
|
|
20
21
|
import '../../theme/components/dropdown/toolbardropdown.css';
|
|
@@ -98,30 +99,33 @@ export function createDropdown(locale, ButtonClass = DropdownButtonView) {
|
|
|
98
99
|
/**
|
|
99
100
|
* Adds an instance of {@link module:ui/toolbar/toolbarview~ToolbarView} to a dropdown.
|
|
100
101
|
*
|
|
101
|
-
* const
|
|
102
|
+
* const buttonsCreator = () => {
|
|
103
|
+
* const buttons = [];
|
|
102
104
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
105
|
+
* // Either create a new ButtonView instance or create existing.
|
|
106
|
+
* buttons.push( new ButtonView() );
|
|
107
|
+
* buttons.push( editor.ui.componentFactory.create( 'someButton' ) );
|
|
108
|
+
* };
|
|
106
109
|
*
|
|
107
110
|
* const dropdown = createDropdown( locale );
|
|
108
111
|
*
|
|
109
|
-
* addToolbarToDropdown( dropdown,
|
|
110
|
-
*
|
|
111
|
-
* dropdown.toolbarView.isVertical = true;
|
|
112
|
+
* addToolbarToDropdown( dropdown, buttonsCreator, { isVertical: true } );
|
|
112
113
|
*
|
|
113
114
|
* // Will render a vertical button dropdown labeled "A button dropdown"
|
|
114
115
|
* // with a button group in the panel containing two buttons.
|
|
116
|
+
* // Buttons inside the dropdown will be created on first dropdown panel open.
|
|
115
117
|
* dropdown.render()
|
|
116
118
|
* document.body.appendChild( dropdown.element );
|
|
117
119
|
*
|
|
118
120
|
* **Note:** To improve the accessibility, you can tell the dropdown to focus the first active button of the toolbar when the dropdown
|
|
119
121
|
* {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}. See the documentation of `options` to learn more.
|
|
120
122
|
*
|
|
123
|
+
* **Note:** Toolbar view will be created on first open of the dropdown.
|
|
124
|
+
*
|
|
121
125
|
* See {@link module:ui/dropdown/utils~createDropdown} and {@link module:ui/toolbar/toolbarview~ToolbarView}.
|
|
122
126
|
*
|
|
123
127
|
* @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView A dropdown instance to which `ToolbarView` will be added.
|
|
124
|
-
* @param {Iterable.<module:ui/button/buttonview~ButtonView
|
|
128
|
+
* @param {Iterable.<module:ui/button/buttonview~ButtonView>|Function} buttonsOrCallback
|
|
125
129
|
* @param {Object} [options]
|
|
126
130
|
* @param {Boolean} [options.enableActiveItemFocusOnDropdownOpen=false] When set `true`, the focus will automatically move to the first
|
|
127
131
|
* active {@link module:ui/toolbar/toolbarview~ToolbarView#items item} of the toolbar upon
|
|
@@ -129,21 +133,56 @@ export function createDropdown(locale, ButtonClass = DropdownButtonView) {
|
|
|
129
133
|
* `true` (for instance {@link module:ui/button/buttonview~ButtonView buttons}). If no active items is found, the toolbar will be focused
|
|
130
134
|
* as a whole resulting in the focus moving to its first focusable item (default behavior of
|
|
131
135
|
* {@link module:ui/dropdown/dropdownview~DropdownView}).
|
|
136
|
+
* @param {String} [options.ariaLabel] Label used by assistive technologies to describe toolbar element.
|
|
137
|
+
* @param {String} [options.maxWidth] The maximum width of the toolbar element.
|
|
138
|
+
* Details: {@link module:ui/toolbar/toolbarview~ToolbarView#maxWidth}.
|
|
139
|
+
* @param {String} [options.class] An additional CSS class added to the toolbar element.
|
|
140
|
+
* @param {Boolean} [options.isCompact] When set true, makes the toolbar look compact with toolbar element.
|
|
141
|
+
* @param {Boolean} [options.isVertical] Controls the orientation of toolbar items.
|
|
132
142
|
*/
|
|
133
|
-
export function addToolbarToDropdown(dropdownView,
|
|
134
|
-
const locale = dropdownView.locale;
|
|
135
|
-
const t = locale.t;
|
|
136
|
-
const toolbarView = dropdownView.toolbarView = new ToolbarView(locale);
|
|
137
|
-
toolbarView.set('ariaLabel', t('Dropdown toolbar'));
|
|
143
|
+
export function addToolbarToDropdown(dropdownView, buttonsOrCallback, options = {}) {
|
|
138
144
|
dropdownView.extendTemplate({
|
|
139
145
|
attributes: {
|
|
140
146
|
class: ['ck-toolbar-dropdown']
|
|
141
147
|
}
|
|
142
148
|
});
|
|
143
|
-
|
|
149
|
+
if (dropdownView.isOpen) {
|
|
150
|
+
addToolbarToOpenDropdown(dropdownView, buttonsOrCallback, options);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
dropdownView.once('change:isOpen', () => addToolbarToOpenDropdown(dropdownView, buttonsOrCallback, options), { priority: 'highest' });
|
|
154
|
+
}
|
|
144
155
|
if (options.enableActiveItemFocusOnDropdownOpen) {
|
|
145
156
|
// Accessibility: Focus the first active button in the toolbar when the dropdown gets open.
|
|
146
|
-
focusChildOnDropdownOpen(dropdownView, () => toolbarView.items.find((item) => item.isOn));
|
|
157
|
+
focusChildOnDropdownOpen(dropdownView, () => dropdownView.toolbarView.items.find((item) => item.isOn));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Adds an instance of {@link module:ui/toolbar/toolbarview~ToolbarView} to a dropdown.
|
|
162
|
+
*/
|
|
163
|
+
function addToolbarToOpenDropdown(dropdownView, buttonsOrCallback, options) {
|
|
164
|
+
const locale = dropdownView.locale;
|
|
165
|
+
const t = locale.t;
|
|
166
|
+
const toolbarView = dropdownView.toolbarView = new ToolbarView(locale);
|
|
167
|
+
const buttons = typeof buttonsOrCallback == 'function' ? buttonsOrCallback() : buttonsOrCallback;
|
|
168
|
+
toolbarView.ariaLabel = options.ariaLabel || t('Dropdown toolbar');
|
|
169
|
+
if (options.maxWidth) {
|
|
170
|
+
toolbarView.maxWidth = options.maxWidth;
|
|
171
|
+
}
|
|
172
|
+
if (options.class) {
|
|
173
|
+
toolbarView.class = options.class;
|
|
174
|
+
}
|
|
175
|
+
if (options.isCompact) {
|
|
176
|
+
toolbarView.isCompact = options.isCompact;
|
|
177
|
+
}
|
|
178
|
+
if (options.isVertical) {
|
|
179
|
+
toolbarView.isVertical = true;
|
|
180
|
+
}
|
|
181
|
+
if (buttons instanceof ViewCollection) {
|
|
182
|
+
toolbarView.items.bindTo(buttons).using(item => item);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
toolbarView.items.addMany(buttons);
|
|
147
186
|
}
|
|
148
187
|
dropdownView.panelView.children.add(toolbarView);
|
|
149
188
|
toolbarView.items.delegate('execute').to(dropdownView);
|
|
@@ -187,15 +226,39 @@ export function addToolbarToDropdown(dropdownView, buttons, options = {}) {
|
|
|
187
226
|
* to focus the first active item (a host to a {@link module:ui/button/buttonview~ButtonView} with
|
|
188
227
|
* {@link module:ui/button/buttonview~ButtonView#isOn} set `true`) or the very first item when none are active.
|
|
189
228
|
*
|
|
229
|
+
* **Note:** List view will be created on first open of the dropdown.
|
|
230
|
+
*
|
|
190
231
|
* See {@link module:ui/dropdown/utils~createDropdown} and {@link module:list/list~List}.
|
|
191
232
|
*
|
|
192
233
|
* @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView A dropdown instance to which `ListVIew` will be added.
|
|
193
|
-
* @param {Iterable.<module:ui/dropdown/utils~ListDropdownItemDefinition
|
|
194
|
-
*
|
|
234
|
+
* @param {Iterable.<module:ui/dropdown/utils~ListDropdownItemDefinition>|Function} itemsOrCallback A collection of the list item
|
|
235
|
+
* definitions or a callback returning a list item definitions to populate the list.
|
|
236
|
+
* @param {Object} [options]
|
|
237
|
+
* @param {String} [options.ariaLabel] Label used by assistive technologies to describe list element.
|
|
195
238
|
*/
|
|
196
|
-
export function addListToDropdown(dropdownView,
|
|
239
|
+
export function addListToDropdown(dropdownView, itemsOrCallback, options = {}) {
|
|
240
|
+
if (dropdownView.isOpen) {
|
|
241
|
+
addListToOpenDropdown(dropdownView, itemsOrCallback, options);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
dropdownView.once('change:isOpen', () => addListToOpenDropdown(dropdownView, itemsOrCallback, options), { priority: 'highest' });
|
|
245
|
+
}
|
|
246
|
+
// Accessibility: Focus the first active button in the list when the dropdown gets open.
|
|
247
|
+
focusChildOnDropdownOpen(dropdownView, () => dropdownView.listView.items.find(item => {
|
|
248
|
+
if (item instanceof ListItemView) {
|
|
249
|
+
return item.children.first.isOn;
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Adds an instance of {@link module:ui/list/listview~ListView} to a dropdown.
|
|
256
|
+
*/
|
|
257
|
+
function addListToOpenDropdown(dropdownView, itemsOrCallback, options) {
|
|
197
258
|
const locale = dropdownView.locale;
|
|
198
259
|
const listView = dropdownView.listView = new ListView(locale);
|
|
260
|
+
const items = typeof itemsOrCallback == 'function' ? itemsOrCallback() : itemsOrCallback;
|
|
261
|
+
listView.ariaLabel = options.ariaLabel;
|
|
199
262
|
listView.items.bindTo(items).using(def => {
|
|
200
263
|
if (def.type === 'separator') {
|
|
201
264
|
return new ListSeparatorView(locale);
|
|
@@ -219,13 +282,6 @@ export function addListToDropdown(dropdownView, items) {
|
|
|
219
282
|
});
|
|
220
283
|
dropdownView.panelView.children.add(listView);
|
|
221
284
|
listView.items.delegate('execute').to(dropdownView);
|
|
222
|
-
// Accessibility: Focus the first active button in the list when the dropdown gets open.
|
|
223
|
-
focusChildOnDropdownOpen(dropdownView, () => listView.items.find(item => {
|
|
224
|
-
if (item instanceof ListItemView) {
|
|
225
|
-
return item.children.first.isOn;
|
|
226
|
-
}
|
|
227
|
-
return false;
|
|
228
|
-
}));
|
|
229
285
|
}
|
|
230
286
|
/**
|
|
231
287
|
* A helper to be used on an existing {@link module:ui/dropdown/dropdownview~DropdownView} that focuses
|
|
@@ -344,10 +400,11 @@ function focusDropdownButtonOnClose(dropdownView) {
|
|
|
344
400
|
if (isOpen) {
|
|
345
401
|
return;
|
|
346
402
|
}
|
|
403
|
+
const element = dropdownView.panelView.element;
|
|
347
404
|
// If the dropdown was closed, move the focus back to the button (#12125).
|
|
348
405
|
// Don't touch the focus, if it moved somewhere else (e.g. moved to the editing root on #execute) (#12178).
|
|
349
406
|
// Note: Don't use the state of the DropdownView#focusTracker here. It fires #blur with the timeout.
|
|
350
|
-
if (
|
|
407
|
+
if (element && element.contains(global.document.activeElement)) {
|
|
351
408
|
dropdownView.buttonView.focus();
|
|
352
409
|
}
|
|
353
410
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/* globals document */
|
|
9
9
|
import Template from '../template';
|
|
10
10
|
import ViewCollection from '../viewcollection';
|
|
11
|
-
import createElement from '@ckeditor/ckeditor5-utils
|
|
11
|
+
import { createElement } from '@ckeditor/ckeditor5-utils';
|
|
12
12
|
/**
|
|
13
13
|
* This is a special {@link module:ui/viewcollection~ViewCollection} dedicated to elements that are detached
|
|
14
14
|
* from the DOM structure of the editor, like panels, icons, etc.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
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
5
|
/**
|