ckeditor5-elements-core 49.0.0-alpha.2 → 49.0.0-alpha.4
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/README.md +2 -2
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -9
- package/dist/index.js.map +1 -1
- package/dist/singleCopyGuard.js +2 -2
- package/package.json +1 -3
- package/src/index.ts +4 -16
- package/src/singleCopyGuard.ts +2 -2
- package/dist/augmentation.d.ts +0 -7
- package/dist/augmentation.d.ts.map +0 -1
- package/dist/augmentation.js +0 -2
- package/dist/augmentation.js.map +0 -1
- package/dist/elementMenu.d.ts +0 -93
- package/dist/elementMenu.d.ts.map +0 -1
- package/dist/elementMenu.js +0 -163
- package/dist/elementMenu.js.map +0 -1
- package/dist/elementMenuItemButtonView.d.ts +0 -24
- package/dist/elementMenuItemButtonView.d.ts.map +0 -1
- package/dist/elementMenuItemButtonView.js +0 -29
- package/dist/elementMenuItemButtonView.js.map +0 -1
- package/dist/elementMenuView.d.ts +0 -35
- package/dist/elementMenuView.d.ts.map +0 -1
- package/dist/elementMenuView.js +0 -118
- package/dist/elementMenuView.js.map +0 -1
- package/dist/menuSeparatorView.d.ts +0 -8
- package/dist/menuSeparatorView.d.ts.map +0 -1
- package/dist/menuSeparatorView.js +0 -16
- package/dist/menuSeparatorView.js.map +0 -1
- package/dist/submenuView.d.ts +0 -68
- package/dist/submenuView.d.ts.map +0 -1
- package/dist/submenuView.js +0 -159
- package/dist/submenuView.js.map +0 -1
- package/src/augmentation.ts +0 -7
- package/src/elementMenu.ts +0 -275
- package/src/elementMenuView.ts +0 -164
- package/theme/elementMenu.css +0 -14
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# ckeditor5-elements-core
|
|
2
2
|
|
|
3
3
|
The base of CKEditor 5 Elements: commands that act on a position or an element (`ElementOrPositionCommand`,
|
|
4
|
-
`ElementCommand`), their buttons (`ElementOrPositionButtonView`, `ElementButtonView`)
|
|
5
|
-
|
|
4
|
+
`ElementCommand`), and their buttons (`ElementOrPositionButtonView`, `ElementButtonView`). The menus of commands are in
|
|
5
|
+
`ckeditor5-elements-menu`.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The base of the element commands
|
|
3
|
-
*
|
|
4
|
-
* views
|
|
5
|
-
* quick insert).
|
|
2
|
+
* The base of the element commands and their buttons: `ElementOrPositionCommand` (a command for a position or an
|
|
3
|
+
* element, with its title, icon and state for any target), `ElementCommand` (toggles an element), and their button
|
|
4
|
+
* views. The menus of commands are in `ckeditor5-elements-menu`.
|
|
6
5
|
*
|
|
7
6
|
* @module ckeditor5-elements-core
|
|
8
7
|
*/
|
|
9
8
|
import './singleCopyGuard.js';
|
|
10
|
-
export { default as ElementMenu, type ElementMenuConfig, type ElementMenuItem, type ElementMenuShowOptions, type ElementSubmenu } from './elementMenu.js';
|
|
11
9
|
export { default as ElementOrPositionCommand, type ElementOrPosition } from './elementOrPositionCommand.js';
|
|
12
10
|
export { default as ElementCommand } from './elementCommand.js';
|
|
13
|
-
export { default as ElementOrPositionButtonView, type ElementOrPositionButtonViewOptions, type ElementOrPositionTarget } from './elementOrPositionButtonView.js';
|
|
11
|
+
export { default as ElementOrPositionButtonView, bindButtonToCommand, type ElementOrPositionButtonViewOptions, type ElementOrPositionTarget } from './elementOrPositionButtonView.js';
|
|
14
12
|
export { default as ElementButtonView } from './elementButtonView.js';
|
|
15
|
-
export { default as ElementMenuView } from './elementMenuView.js';
|
|
16
13
|
export { getElementAtSelection, isInDocument, isStandalone, selectNewElement } from './utils.js';
|
|
17
14
|
export { findPlugin, getElementsAround, matchesElement, type ElementMatcher } from './matching.js';
|
|
18
|
-
import './augmentation.js';
|
|
19
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,EACN,OAAO,IAAI,2BAA2B,EACtC,mBAAmB,EACnB,KAAK,kCAAkC,EACvC,KAAK,uBAAuB,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The base of the element commands
|
|
3
|
-
*
|
|
4
|
-
* views
|
|
5
|
-
* quick insert).
|
|
2
|
+
* The base of the element commands and their buttons: `ElementOrPositionCommand` (a command for a position or an
|
|
3
|
+
* element, with its title, icon and state for any target), `ElementCommand` (toggles an element), and their button
|
|
4
|
+
* views. The menus of commands are in `ckeditor5-elements-menu`.
|
|
6
5
|
*
|
|
7
6
|
* @module ckeditor5-elements-core
|
|
8
7
|
*/
|
|
9
8
|
import './singleCopyGuard.js';
|
|
10
|
-
// Plugins.
|
|
11
|
-
export { default as ElementMenu } from './elementMenu.js';
|
|
12
9
|
// Commands.
|
|
13
10
|
export { default as ElementOrPositionCommand } from './elementOrPositionCommand.js';
|
|
14
11
|
export { default as ElementCommand } from './elementCommand.js';
|
|
15
12
|
// Views.
|
|
16
|
-
export { default as ElementOrPositionButtonView } from './elementOrPositionButtonView.js';
|
|
13
|
+
export { default as ElementOrPositionButtonView, bindButtonToCommand } from './elementOrPositionButtonView.js';
|
|
17
14
|
export { default as ElementButtonView } from './elementButtonView.js';
|
|
18
|
-
export { default as ElementMenuView } from './elementMenuView.js';
|
|
19
15
|
// Utils.
|
|
20
16
|
export { getElementAtSelection, isInDocument, isStandalone, selectNewElement } from './utils.js';
|
|
21
17
|
export { findPlugin, getElementsAround, matchesElement } from './matching.js';
|
|
22
|
-
import './augmentation.js';
|
|
23
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,sBAAsB,CAAC;AAE9B,YAAY;AACZ,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAA0B,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEhE,SAAS;AACT,OAAO,EACN,OAAO,IAAI,2BAA2B,EACtC,mBAAmB,EAGnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,SAAS;AACT,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAuB,MAAM,eAAe,CAAC"}
|
package/dist/singleCopyGuard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fails when this package is loaded twice, e.g. because two versions of it are installed: `ckeditor5-elements` of one
|
|
3
|
-
* version, and a feature package of another. Two copies would
|
|
4
|
-
*
|
|
3
|
+
* version, and a feature package of another. Two copies would have two different `ElementOrPositionCommand` classes,
|
|
4
|
+
* and the commands of one copy would not be menu items for the menus of the other, which recognize them by class.
|
|
5
5
|
*
|
|
6
6
|
* It is the counterpart of CKEditor's `ckeditor-duplicated-modules` error. Like CKEditor's packages, this package
|
|
7
7
|
* declares no `sideEffects` in its `package.json`, so bundlers keep this module, which exports nothing.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ckeditor5-elements-core",
|
|
3
|
-
"version": "49.0.0-alpha.
|
|
3
|
+
"version": "49.0.0-alpha.4",
|
|
4
4
|
"description": "The base of the element commands, buttons and menus for CKEditor 5: ElementOrPositionCommand, ElementCommand, their button views, and ElementMenu.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -28,13 +28,11 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js"
|
|
30
30
|
},
|
|
31
|
-
"./index.css": "./theme/elementMenu.css",
|
|
32
31
|
"./package.json": "./package.json"
|
|
33
32
|
},
|
|
34
33
|
"files": [
|
|
35
34
|
"dist",
|
|
36
35
|
"src",
|
|
37
|
-
"theme",
|
|
38
36
|
"README.md"
|
|
39
37
|
],
|
|
40
38
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The base of the element commands
|
|
3
|
-
*
|
|
4
|
-
* views
|
|
5
|
-
* quick insert).
|
|
2
|
+
* The base of the element commands and their buttons: `ElementOrPositionCommand` (a command for a position or an
|
|
3
|
+
* element, with its title, icon and state for any target), `ElementCommand` (toggles an element), and their button
|
|
4
|
+
* views. The menus of commands are in `ckeditor5-elements-menu`.
|
|
6
5
|
*
|
|
7
6
|
* @module ckeditor5-elements-core
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
import './singleCopyGuard.js';
|
|
11
10
|
|
|
12
|
-
// Plugins.
|
|
13
|
-
export {
|
|
14
|
-
default as ElementMenu,
|
|
15
|
-
type ElementMenuConfig,
|
|
16
|
-
type ElementMenuItem,
|
|
17
|
-
type ElementMenuShowOptions,
|
|
18
|
-
type ElementSubmenu
|
|
19
|
-
} from './elementMenu.js';
|
|
20
|
-
|
|
21
11
|
// Commands.
|
|
22
12
|
export { default as ElementOrPositionCommand, type ElementOrPosition } from './elementOrPositionCommand.js';
|
|
23
13
|
export { default as ElementCommand } from './elementCommand.js';
|
|
@@ -25,14 +15,12 @@ export { default as ElementCommand } from './elementCommand.js';
|
|
|
25
15
|
// Views.
|
|
26
16
|
export {
|
|
27
17
|
default as ElementOrPositionButtonView,
|
|
18
|
+
bindButtonToCommand,
|
|
28
19
|
type ElementOrPositionButtonViewOptions,
|
|
29
20
|
type ElementOrPositionTarget
|
|
30
21
|
} from './elementOrPositionButtonView.js';
|
|
31
22
|
export { default as ElementButtonView } from './elementButtonView.js';
|
|
32
|
-
export { default as ElementMenuView } from './elementMenuView.js';
|
|
33
23
|
|
|
34
24
|
// Utils.
|
|
35
25
|
export { getElementAtSelection, isInDocument, isStandalone, selectNewElement } from './utils.js';
|
|
36
26
|
export { findPlugin, getElementsAround, matchesElement, type ElementMatcher } from './matching.js';
|
|
37
|
-
|
|
38
|
-
import './augmentation.js';
|
package/src/singleCopyGuard.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fails when this package is loaded twice, e.g. because two versions of it are installed: `ckeditor5-elements` of one
|
|
3
|
-
* version, and a feature package of another. Two copies would
|
|
4
|
-
*
|
|
3
|
+
* version, and a feature package of another. Two copies would have two different `ElementOrPositionCommand` classes,
|
|
4
|
+
* and the commands of one copy would not be menu items for the menus of the other, which recognize them by class.
|
|
5
5
|
*
|
|
6
6
|
* It is the counterpart of CKEditor's `ckeditor-duplicated-modules` error. Like CKEditor's packages, this package
|
|
7
7
|
* declares no `sideEffects` in its `package.json`, so bundlers keep this module, which exports nothing.
|
package/dist/augmentation.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"augmentation.d.ts","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,QAAQ,WAAW,CAAC;IAC1B,UAAU,UAAU;QACnB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;KACtC;CACD"}
|
package/dist/augmentation.js
DELETED
package/dist/augmentation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"augmentation.js","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":""}
|
package/dist/elementMenu.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { ContextualBalloon, Notification, Plugin, type Editor, type FocusableView, type ModelElement, type RectSource } from 'ckeditor5';
|
|
2
|
-
import ElementOrPositionCommand from './elementOrPositionCommand.js';
|
|
3
|
-
/**
|
|
4
|
-
* A submenu of an element menu. Missing items are skipped, as in the menu.
|
|
5
|
-
*/
|
|
6
|
-
export interface ElementSubmenu {
|
|
7
|
-
title: string;
|
|
8
|
-
/**
|
|
9
|
-
* The icon (SVG string) shown next to the title.
|
|
10
|
-
*/
|
|
11
|
-
icon?: string;
|
|
12
|
-
items: (ElementMenuItem | null | undefined)[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* An item of an element menu:
|
|
16
|
-
*
|
|
17
|
-
* * a command, shown as a button with its `title` and `icon`, enabled and "on" according to its
|
|
18
|
-
* {@link ElementOrPositionCommand#getState state} for the element,
|
|
19
|
-
* * a submenu,
|
|
20
|
-
* * `'|'`, a separator. Separators at the start or the end of a menu, and repeated ones, are not shown, so a group of
|
|
21
|
-
* items can start with one.
|
|
22
|
-
*/
|
|
23
|
-
export type ElementMenuItem = ElementOrPositionCommand | ElementSubmenu | '|';
|
|
24
|
-
/**
|
|
25
|
-
* Returns the items of the menu of the given element, e.g. as the `elementContextMenu` or `breadcrumbs.menu` editor
|
|
26
|
-
* config option. Missing items (e.g. commands that are not registered) are skipped. No items means no menu.
|
|
27
|
-
*/
|
|
28
|
-
export type ElementMenuConfig = (element: ModelElement, editor: Editor) => (ElementMenuItem | null | undefined)[];
|
|
29
|
-
/**
|
|
30
|
-
* The options of {@link ElementMenu#open} and {@link ElementMenu#show}.
|
|
31
|
-
*/
|
|
32
|
-
export interface ElementMenuShowOptions {
|
|
33
|
-
/**
|
|
34
|
-
* The accessible name of the menu of an element (see {@link ElementMenu#open}). Defaults to "Element menu".
|
|
35
|
-
*/
|
|
36
|
-
label?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Called when the document data changes while the menu is open. When it returns `true`, the menu closes, e.g.
|
|
39
|
-
* because the element it is for was removed.
|
|
40
|
-
*/
|
|
41
|
-
isObsolete?: () => boolean;
|
|
42
|
-
/**
|
|
43
|
-
* What gets the focus when the menu is closed with Esc, e.g. the button that opened the menu. Defaults to the editor.
|
|
44
|
-
*/
|
|
45
|
-
returnFocusTo?: {
|
|
46
|
-
focus(): void;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Called when the menu closes, for any reason: Esc, a click outside, an executed item, or another menu replacing it.
|
|
50
|
-
*/
|
|
51
|
-
onHide?: () => void;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Shows menus in a balloon: the menu of an element, built from commands, submenus and separators (see {@link open}),
|
|
55
|
-
* or any view, e.g. the quick insert search (see {@link show}).
|
|
56
|
-
*
|
|
57
|
-
* The element context menu, the breadcrumbs and quick insert show their menus with it. The menu of an element is
|
|
58
|
-
* CKEditor's dropdown menu (see {@link ElementMenuView}).
|
|
59
|
-
*
|
|
60
|
-
* Executing an item closes the menu. Esc and clicking outside close it too; Esc returns the focus to the editor, or to
|
|
61
|
-
* {@link ElementMenuShowOptions.returnFocusTo}.
|
|
62
|
-
*/
|
|
63
|
-
export default class ElementMenu extends Plugin {
|
|
64
|
-
/**
|
|
65
|
-
* The view in the open menu, if any.
|
|
66
|
-
*/
|
|
67
|
-
view: FocusableView | null;
|
|
68
|
-
private _keystrokes;
|
|
69
|
-
private _isObsolete;
|
|
70
|
-
private _onHide;
|
|
71
|
-
static get requires(): readonly [typeof ContextualBalloon, typeof Notification];
|
|
72
|
-
static get pluginName(): 'ElementMenu';
|
|
73
|
-
init(): void;
|
|
74
|
-
/**
|
|
75
|
-
* Opens the menu of the element next to the target (e.g. a button, or a `DOMRect` in viewport coordinates), with
|
|
76
|
-
* the items from the config callback. The menu closes when the element is removed.
|
|
77
|
-
*
|
|
78
|
-
* Returns `false` when there are no items.
|
|
79
|
-
*/
|
|
80
|
-
open(element: ModelElement, target: RectSource, config: ElementMenuConfig, { label, isObsolete, ...options }?: ElementMenuShowOptions): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Shows the view (e.g. a menu) next to the target (e.g. a button, or a `DOMRect` in viewport coordinates), and
|
|
83
|
-
* focuses it. The menu closes when the view, or an item of CKEditor's dropdown menu in it, fires `execute`.
|
|
84
|
-
*/
|
|
85
|
-
show(view: FocusableView, target: RectSource, { isObsolete, returnFocusTo, onHide }?: ElementMenuShowOptions): void;
|
|
86
|
-
/**
|
|
87
|
-
* Hides the open menu, if any.
|
|
88
|
-
*/
|
|
89
|
-
hide(): void;
|
|
90
|
-
destroy(): void;
|
|
91
|
-
private get _balloon();
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=elementMenu.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elementMenu.d.ts","sourceRoot":"","sources":["../src/elementMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EAGjB,YAAY,EACZ,MAAM,EAEN,KAAK,MAAM,EAC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V,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,iBAAiB,EACzB,EAAE,KAAqC,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,GAAE,sBAA2B,GAC5F,OAAO;IAmBV;;;OAGG;IACI,IAAI,CACV,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,UAAU,EAClB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,GAAE,sBAA2B,GAChE,IAAI;IAqDP;;OAEG;IACI,IAAI,IAAI,IAAI;IAuBH,OAAO,IAAI,IAAI;IAK/B,OAAO,KAAK,QAAQ,GAEnB;CACD"}
|
package/dist/elementMenu.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { ContextualBalloon, DropdownMenuRootListView, KeystrokeHandler, Notification, Plugin, clickOutsideHandler } from 'ckeditor5';
|
|
2
|
-
import ElementMenuView from './elementMenuView.js';
|
|
3
|
-
import ElementOrPositionCommand from './elementOrPositionCommand.js';
|
|
4
|
-
import { isInDocument } from './utils.js';
|
|
5
|
-
/**
|
|
6
|
-
* Shows menus in a balloon: the menu of an element, built from commands, submenus and separators (see {@link open}),
|
|
7
|
-
* or any view, e.g. the quick insert search (see {@link show}).
|
|
8
|
-
*
|
|
9
|
-
* The element context menu, the breadcrumbs and quick insert show their menus with it. The menu of an element is
|
|
10
|
-
* CKEditor's dropdown menu (see {@link ElementMenuView}).
|
|
11
|
-
*
|
|
12
|
-
* Executing an item closes the menu. Esc and clicking outside close it too; Esc returns the focus to the editor, or to
|
|
13
|
-
* {@link ElementMenuShowOptions.returnFocusTo}.
|
|
14
|
-
*/
|
|
15
|
-
export default class ElementMenu extends Plugin {
|
|
16
|
-
/**
|
|
17
|
-
* The view in the open menu, if any.
|
|
18
|
-
*/
|
|
19
|
-
view = null;
|
|
20
|
-
_keystrokes = null;
|
|
21
|
-
_isObsolete = null;
|
|
22
|
-
_onHide = null;
|
|
23
|
-
static get requires() {
|
|
24
|
-
// The buttons of the menu report failed commands with notifications.
|
|
25
|
-
return [ContextualBalloon, Notification];
|
|
26
|
-
}
|
|
27
|
-
static get pluginName() {
|
|
28
|
-
return 'ElementMenu';
|
|
29
|
-
}
|
|
30
|
-
init() {
|
|
31
|
-
this.listenTo(this.editor.model.document, 'change:data', () => {
|
|
32
|
-
if (this._isObsolete?.()) {
|
|
33
|
-
this.hide();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Opens the menu of the element next to the target (e.g. a button, or a `DOMRect` in viewport coordinates), with
|
|
39
|
-
* the items from the config callback. The menu closes when the element is removed.
|
|
40
|
-
*
|
|
41
|
-
* Returns `false` when there are no items.
|
|
42
|
-
*/
|
|
43
|
-
open(element, target, config, { label = this.editor.t('Element menu'), isObsolete, ...options } = {}) {
|
|
44
|
-
const items = cleanItems(config(element, this.editor));
|
|
45
|
-
if (!items.length) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
const view = new ElementMenuView(this.editor.locale, this.editor.ui.view.body, items, element);
|
|
49
|
-
view.ariaLabel = label;
|
|
50
|
-
this.show(view, target, {
|
|
51
|
-
...options,
|
|
52
|
-
isObsolete: () => !isInDocument(element) || !!isObsolete?.()
|
|
53
|
-
});
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Shows the view (e.g. a menu) next to the target (e.g. a button, or a `DOMRect` in viewport coordinates), and
|
|
58
|
-
* focuses it. The menu closes when the view, or an item of CKEditor's dropdown menu in it, fires `execute`.
|
|
59
|
-
*/
|
|
60
|
-
show(view, target, { isObsolete, returnFocusTo, onHide } = {}) {
|
|
61
|
-
this.hide();
|
|
62
|
-
const close = () => {
|
|
63
|
-
// The item may have opened another menu already (e.g. "Insert before" opens quick insert).
|
|
64
|
-
if (this.view === view) {
|
|
65
|
-
this.hide();
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
this.listenTo(view, 'execute', close);
|
|
69
|
-
this.listenTo(view, 'menu:execute', close);
|
|
70
|
-
clickOutsideHandler({
|
|
71
|
-
emitter: view,
|
|
72
|
-
activator: () => this._balloon.visibleView === view,
|
|
73
|
-
// The open nested menus are in panels outside the balloon.
|
|
74
|
-
contextElements: () => [this._balloon.view.element, ...getOpenPanels(view)].filter(element => !!element),
|
|
75
|
-
callback: () => {
|
|
76
|
-
this.hide();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
this._balloon.add({
|
|
80
|
-
view,
|
|
81
|
-
position: { target },
|
|
82
|
-
withArrow: false,
|
|
83
|
-
singleViewMode: true,
|
|
84
|
-
// Views that other plugins add to the balloon meanwhile (e.g. an element toolbar, when the selection moves
|
|
85
|
-
// into its element) go to their own stack, so they do not cover the menu.
|
|
86
|
-
stackId: 'elementMenu'
|
|
87
|
-
});
|
|
88
|
-
const keystrokes = new KeystrokeHandler();
|
|
89
|
-
// Esc in a nested menu closes only that menu.
|
|
90
|
-
keystrokes.set('Esc', (data, cancel) => {
|
|
91
|
-
this.hide();
|
|
92
|
-
(returnFocusTo ?? this.editor.editing.view).focus();
|
|
93
|
-
cancel();
|
|
94
|
-
});
|
|
95
|
-
if (view.element) {
|
|
96
|
-
keystrokes.listenTo(view.element);
|
|
97
|
-
}
|
|
98
|
-
this.view = view;
|
|
99
|
-
this._keystrokes = keystrokes;
|
|
100
|
-
this._isObsolete = isObsolete ?? null;
|
|
101
|
-
this._onHide = onHide ?? null;
|
|
102
|
-
view.focus();
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Hides the open menu, if any.
|
|
106
|
-
*/
|
|
107
|
-
hide() {
|
|
108
|
-
const view = this.view;
|
|
109
|
-
const onHide = this._onHide;
|
|
110
|
-
if (!view) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
this._keystrokes?.destroy();
|
|
114
|
-
this.view = null;
|
|
115
|
-
this._keystrokes = null;
|
|
116
|
-
this._isObsolete = null;
|
|
117
|
-
this._onHide = null;
|
|
118
|
-
this.stopListening(view);
|
|
119
|
-
if (this._balloon.hasView(view)) {
|
|
120
|
-
this._balloon.remove(view);
|
|
121
|
-
}
|
|
122
|
-
view.destroy();
|
|
123
|
-
onHide?.();
|
|
124
|
-
}
|
|
125
|
-
destroy() {
|
|
126
|
-
this.hide();
|
|
127
|
-
super.destroy();
|
|
128
|
-
}
|
|
129
|
-
get _balloon() {
|
|
130
|
-
return this.editor.plugins.get(ContextualBalloon);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Returns the items without missing ones, submenus without items, and separators at the start or the end, or
|
|
135
|
-
* repeated ones.
|
|
136
|
-
*/
|
|
137
|
-
function cleanItems(items) {
|
|
138
|
-
const result = [];
|
|
139
|
-
for (const item of items) {
|
|
140
|
-
const cleaned = item === '|' || item instanceof ElementOrPositionCommand || !item ? item : cleanSubmenu(item);
|
|
141
|
-
if (!cleaned || (cleaned === '|' && (!result.length || result.at(-1) === '|'))) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
result.push(cleaned);
|
|
145
|
-
}
|
|
146
|
-
if (result.at(-1) === '|') {
|
|
147
|
-
result.pop();
|
|
148
|
-
}
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
function cleanSubmenu(submenu) {
|
|
152
|
-
const items = cleanItems(submenu.items);
|
|
153
|
-
return items.length ? { ...submenu, items } : null;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Returns the panels of the open nested menus of CKEditor's dropdown menu.
|
|
157
|
-
*/
|
|
158
|
-
function getOpenPanels(view) {
|
|
159
|
-
return view instanceof DropdownMenuRootListView
|
|
160
|
-
? view.menus.filter(menu => menu.isOpen).map(menu => menu.panelView.element)
|
|
161
|
-
: [];
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=elementMenu.js.map
|
package/dist/elementMenu.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elementM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tB,CAAC;IAED,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,EAAE,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,OAAuB;IAC5C,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAExC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,IAAmB;IACzC,OAAO,IAAI,YAAY,wBAAwB;QAC9C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAC5E,CAAC,CAAC,EAAE,CAAC;AACP,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ListItemButtonView, type Locale } from 'ckeditor5';
|
|
2
|
-
import type ElementOrPositionCommand from './elementOrPositionCommand.js';
|
|
3
|
-
import { type ElementOrPosition } from './elementOrPositionCommand.js';
|
|
4
|
-
/**
|
|
5
|
-
* A menu item for an {@link ElementOrPositionCommand}: CKEditor's list item button, labelled with the command title and
|
|
6
|
-
* icon, that reflects and executes the command like {@link ElementOrPositionButtonView}.
|
|
7
|
-
*
|
|
8
|
-
* For a {@link ElementOrPositionCommand#isToggleable toggleable} command, it is a `menuitemcheckbox` with a check mark
|
|
9
|
-
* when the command is "on"; otherwise, a `menuitem`.
|
|
10
|
-
*/
|
|
11
|
-
export default class ElementMenuItemButtonView extends ListItemButtonView {
|
|
12
|
-
/**
|
|
13
|
-
* The command this item reflects.
|
|
14
|
-
*/
|
|
15
|
-
readonly command: ElementOrPositionCommand;
|
|
16
|
-
/**
|
|
17
|
-
* The position or element the item acts on, if any.
|
|
18
|
-
*/
|
|
19
|
-
readonly target: ElementOrPosition | undefined;
|
|
20
|
-
constructor(locale: Locale | undefined, command: ElementOrPositionCommand, { target }?: {
|
|
21
|
-
target?: ElementOrPosition;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=elementMenuItemButtonView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elementMenuItemButtonView.d.ts","sourceRoot":"","sources":["../src/elementMenuItemButtonView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,KAAK,wBAAwB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,kBAAkB;IACxE;;OAEG;IACH,SAAgB,OAAO,EAAE,wBAAwB,CAAC;IAElD;;OAEG;IACH,SAAgB,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;gBAGrD,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,wBAAwB,EACjC,EAAE,MAAM,EAAE,GAAE;QAAE,MAAM,CAAC,EAAE,iBAAiB,CAAA;KAAO;CAYhD"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ListItemButtonView } from 'ckeditor5';
|
|
2
|
-
import { bindButtonToCommand } from './elementOrPositionButtonView.js';
|
|
3
|
-
import {} from './elementOrPositionCommand.js';
|
|
4
|
-
/**
|
|
5
|
-
* A menu item for an {@link ElementOrPositionCommand}: CKEditor's list item button, labelled with the command title and
|
|
6
|
-
* icon, that reflects and executes the command like {@link ElementOrPositionButtonView}.
|
|
7
|
-
*
|
|
8
|
-
* For a {@link ElementOrPositionCommand#isToggleable toggleable} command, it is a `menuitemcheckbox` with a check mark
|
|
9
|
-
* when the command is "on"; otherwise, a `menuitem`.
|
|
10
|
-
*/
|
|
11
|
-
export default class ElementMenuItemButtonView extends ListItemButtonView {
|
|
12
|
-
/**
|
|
13
|
-
* The command this item reflects.
|
|
14
|
-
*/
|
|
15
|
-
command;
|
|
16
|
-
/**
|
|
17
|
-
* The position or element the item acts on, if any.
|
|
18
|
-
*/
|
|
19
|
-
target;
|
|
20
|
-
constructor(locale, command, { target } = {}) {
|
|
21
|
-
super(locale);
|
|
22
|
-
this.command = command;
|
|
23
|
-
this.target = target;
|
|
24
|
-
bindButtonToCommand(this, command, { withText: true, target });
|
|
25
|
-
// A toggleable button with a checkable role tells assistive technology whether it is "on" with `aria-checked`.
|
|
26
|
-
this.role = command.isToggleable ? 'menuitemcheckbox' : 'menuitem';
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=elementMenuItemButtonView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elementMenuItemButtonView.js","sourceRoot":"","sources":["../src/elementMenuItemButtonView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAA0B,MAAM,+BAA+B,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,kBAAkB;IACxE;;OAEG;IACa,OAAO,CAA2B;IAElD;;OAEG;IACa,MAAM,CAAgC;IAEtD,YACC,MAA0B,EAC1B,OAAiC,EACjC,EAAE,MAAM,KAAqC,EAAE;QAE/C,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAE/D,+GAA+G;QAC/G,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC;IACpE,CAAC;CACD"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { DropdownMenuRootListView, type BodyCollection, type Locale } from 'ckeditor5';
|
|
2
|
-
import { type ElementMenuItem } from './elementMenu.js';
|
|
3
|
-
import { type ElementOrPosition } from './elementOrPositionCommand.js';
|
|
4
|
-
/**
|
|
5
|
-
* The menu of an element: CKEditor's dropdown menu (`DropdownMenuRootListView`), built from commands, submenus and
|
|
6
|
-
* separators.
|
|
7
|
-
*
|
|
8
|
-
* CKEditor builds the menu and handles it: the nested menus (opened on click, hover, or the right arrow; placed where
|
|
9
|
-
* they fit), the keyboard, and right-to-left languages. This view only connects the buttons to the commands: they
|
|
10
|
-
* reflect the command title, icon and {@link ElementOrPositionCommand#getState state} for the target, and execute the
|
|
11
|
-
* command for it. It also adds the separators, which CKEditor's menu definitions do not have.
|
|
12
|
-
*
|
|
13
|
-
* Submenus are enabled when one of their items is. Right-clicking the menu does not open the native context menu.
|
|
14
|
-
*/
|
|
15
|
-
export default class ElementMenuView extends DropdownMenuRootListView {
|
|
16
|
-
/**
|
|
17
|
-
* The element or position the commands are executed for.
|
|
18
|
-
*/
|
|
19
|
-
readonly target: ElementOrPosition;
|
|
20
|
-
private readonly _commands;
|
|
21
|
-
private readonly _submenus;
|
|
22
|
-
/**
|
|
23
|
-
* The positions of the separators in each list, by the id of the submenu (`''` for the menu itself).
|
|
24
|
-
*/
|
|
25
|
-
private readonly _separators;
|
|
26
|
-
constructor(locale: Locale, bodyCollection: BodyCollection, items: readonly (ElementMenuItem | null | undefined)[], target: ElementOrPosition);
|
|
27
|
-
/**
|
|
28
|
-
* Renders the menu: CKEditor builds it from the definitions; then the buttons are connected to the commands, and the
|
|
29
|
-
* separators are added.
|
|
30
|
-
*/
|
|
31
|
-
render(): void;
|
|
32
|
-
private _addSeparators;
|
|
33
|
-
private _isEnabled;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=elementMenuView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elementMenuView.d.ts","sourceRoot":"","sources":["../src/elementMenuView.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EAExB,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,eAAe,EAAuB,MAAM,kBAAkB,CAAC;AAE7E,OAAiC,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjG;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,wBAAwB;IACpE;;OAEG;IACH,SAAgB,MAAM,EAAE,iBAAiB,CAAC;IAE1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;IAClE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IAExD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;gBAGnD,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,SAAS,CAAC,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACtD,MAAM,EAAE,iBAAiB;IAkB1B;;;OAGG;IACa,MAAM,IAAI,IAAI;IAqC9B,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,UAAU;CASlB"}
|