ckeditor5-elements-menu 0.0.0-stage → 49.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 +21 -0
- package/README.md +50 -2
- package/dist/augmentation.d.ts +30 -0
- package/dist/augmentation.d.ts.map +1 -0
- package/dist/augmentation.js +2 -0
- package/dist/augmentation.js.map +1 -0
- package/dist/breadcrumbs/breadcrumbItemView.d.ts +47 -0
- package/dist/breadcrumbs/breadcrumbItemView.d.ts.map +1 -0
- package/dist/breadcrumbs/breadcrumbItemView.js +30 -0
- package/dist/breadcrumbs/breadcrumbItemView.js.map +1 -0
- package/dist/breadcrumbs/breadcrumbLabelView.d.ts +29 -0
- package/dist/breadcrumbs/breadcrumbLabelView.d.ts.map +1 -0
- package/dist/breadcrumbs/breadcrumbLabelView.js +39 -0
- package/dist/breadcrumbs/breadcrumbLabelView.js.map +1 -0
- package/dist/breadcrumbs/breadcrumbsView.d.ts +68 -0
- package/dist/breadcrumbs/breadcrumbsView.d.ts.map +1 -0
- package/dist/breadcrumbs/breadcrumbsView.js +134 -0
- package/dist/breadcrumbs/breadcrumbsView.js.map +1 -0
- package/dist/breadcrumbs/elementBreadcrumbs.d.ts +73 -0
- package/dist/breadcrumbs/elementBreadcrumbs.d.ts.map +1 -0
- package/dist/breadcrumbs/elementBreadcrumbs.js +225 -0
- package/dist/breadcrumbs/elementBreadcrumbs.js.map +1 -0
- package/dist/contextMenu/contextMenuObserver.d.ts +19 -0
- package/dist/contextMenu/contextMenuObserver.d.ts.map +1 -0
- package/dist/contextMenu/contextMenuObserver.js +18 -0
- package/dist/contextMenu/contextMenuObserver.js.map +1 -0
- package/dist/contextMenu/elementContextMenu.d.ts +34 -0
- package/dist/contextMenu/elementContextMenu.d.ts.map +1 -0
- package/dist/contextMenu/elementContextMenu.js +88 -0
- package/dist/contextMenu/elementContextMenu.js.map +1 -0
- package/dist/domTarget.d.ts +8 -0
- package/dist/domTarget.d.ts.map +1 -0
- package/dist/domTarget.js +20 -0
- package/dist/domTarget.js.map +1 -0
- package/dist/elementMenu.d.ts +93 -0
- package/dist/elementMenu.d.ts.map +1 -0
- package/dist/elementMenu.js +140 -0
- package/dist/elementMenu.js.map +1 -0
- package/dist/elementMenuView.d.ts +40 -0
- package/dist/elementMenuView.d.ts.map +1 -0
- package/dist/elementMenuView.js +143 -0
- package/dist/elementMenuView.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/quickInsert/elementQuickInsert.d.ts +57 -0
- package/dist/quickInsert/elementQuickInsert.d.ts.map +1 -0
- package/dist/quickInsert/elementQuickInsert.js +96 -0
- package/dist/quickInsert/elementQuickInsert.js.map +1 -0
- package/dist/quickInsert/icons.d.ts +16 -0
- package/dist/quickInsert/icons.d.ts.map +1 -0
- package/dist/quickInsert/icons.js +21 -0
- package/dist/quickInsert/icons.js.map +1 -0
- package/dist/quickInsert/quickInsertCommand.d.ts +47 -0
- package/dist/quickInsert/quickInsertCommand.d.ts.map +1 -0
- package/dist/quickInsert/quickInsertCommand.js +81 -0
- package/dist/quickInsert/quickInsertCommand.js.map +1 -0
- package/dist/quickInsert/quickInsertListView.d.ts +29 -0
- package/dist/quickInsert/quickInsertListView.d.ts.map +1 -0
- package/dist/quickInsert/quickInsertListView.js +44 -0
- package/dist/quickInsert/quickInsertListView.js.map +1 -0
- package/dist/quickInsert/quickInsertPositionCommand.d.ts +33 -0
- package/dist/quickInsert/quickInsertPositionCommand.d.ts.map +1 -0
- package/dist/quickInsert/quickInsertPositionCommand.js +52 -0
- package/dist/quickInsert/quickInsertPositionCommand.js.map +1 -0
- package/dist/quickInsert/quickInsertView.d.ts +20 -0
- package/dist/quickInsert/quickInsertView.d.ts.map +1 -0
- package/dist/quickInsert/quickInsertView.js +52 -0
- package/dist/quickInsert/quickInsertView.js.map +1 -0
- package/package.json +52 -3
- package/src/augmentation.ts +44 -0
- package/src/breadcrumbs/breadcrumbItemView.ts +74 -0
- package/src/breadcrumbs/breadcrumbLabelView.ts +55 -0
- package/src/breadcrumbs/breadcrumbsView.ts +176 -0
- package/src/breadcrumbs/elementBreadcrumbs.ts +323 -0
- package/src/contextMenu/contextMenuObserver.ts +27 -0
- package/src/contextMenu/elementContextMenu.ts +104 -0
- package/src/domTarget.ts +27 -0
- package/src/elementMenu.ts +249 -0
- package/src/elementMenuView.ts +202 -0
- package/src/index.ts +54 -0
- package/src/quickInsert/elementQuickInsert.ts +135 -0
- package/src/quickInsert/icons.ts +26 -0
- package/src/quickInsert/quickInsertCommand.ts +96 -0
- package/src/quickInsert/quickInsertListView.ts +71 -0
- package/src/quickInsert/quickInsertPositionCommand.ts +68 -0
- package/src/quickInsert/quickInsertView.ts +64 -0
- package/theme/menu.css +131 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ivan Kildyushov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ckeditor5-elements-menu
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Element menus for CKEditor 5 Elements: `ElementMenu` shows the menu of an element, built from commands, submenus and
|
|
4
|
+
separators, in a balloon. The features that open it are in this package too:
|
|
5
|
+
|
|
6
|
+
- `ElementContextMenu`: right-clicking an element (or Shift+F10, or the menu key) opens its menu, configured by the
|
|
7
|
+
`elementContextMenu` option.
|
|
8
|
+
- `ElementBreadcrumbs`: the element path at the selection, e.g. `aside.note › p`, as labels, or as buttons that open the menu of
|
|
9
|
+
their element with the `elementBreadcrumbs.menu` option.
|
|
10
|
+
- `ElementQuickInsert`: Alt+Enter opens a searchable list of the elements allowed at the cursor, and the `quickInsertBefore`
|
|
11
|
+
and `quickInsertAfter` commands are menu items that insert next to an element.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
This package is part of `ckeditor5-elements`. Install the whole package to use it:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install ckeditor5 ckeditor5-elements
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Import the stylesheet of the package (`ckeditor5-elements/index.css` has the styles of all the features).
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { ElementBreadcrumbs, ElementClipboard, ElementContextMenu, ElementQuickInsert } from 'ckeditor5-elements';
|
|
27
|
+
import 'ckeditor5-elements/index.css';
|
|
28
|
+
|
|
29
|
+
// One menu for both: right-clicking an element, and clicking its breadcrumb.
|
|
30
|
+
const menu = (element, editor) => [
|
|
31
|
+
{ title: 'Insert', items: [editor.commands.get('quickInsertBefore'), editor.commands.get('quickInsertAfter')] },
|
|
32
|
+
'|',
|
|
33
|
+
editor.commands.get('copyElement'),
|
|
34
|
+
editor.commands.get('cutElement')
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
// In the editor config:
|
|
38
|
+
plugins: [..., ElementContextMenu, ElementBreadcrumbs, ElementQuickInsert, ElementClipboard],
|
|
39
|
+
toolbar: ['bold', 'italic', '|', 'breadcrumbs'],
|
|
40
|
+
elementContextMenu: menu,
|
|
41
|
+
elementBreadcrumbs: { menu },
|
|
42
|
+
elementQuickInsert: { labels: { paragraph: 'Paragraph', heading1: 'Heading 1' } }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
See the [Context menu](https://ivankild.github.io/ckeditor5-elements/guide/context-menu),
|
|
46
|
+
[Breadcrumbs](https://ivankild.github.io/ckeditor5-elements/guide/breadcrumbs) and
|
|
47
|
+
[Quick insert](https://ivankild.github.io/ckeditor5-elements/guide/quick-insert) guides of the documentation.
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ElementBreadcrumbs, ElementBreadcrumbsConfig, ElementContextMenu, ElementMenu, ElementMenuConfig, ElementQuickInsert, QuickInsertCommand, ElementQuickInsertConfig, QuickInsertPositionCommand } from './index.js';
|
|
2
|
+
declare module 'ckeditor5' {
|
|
3
|
+
interface PluginsMap {
|
|
4
|
+
[ElementMenu.pluginName]: ElementMenu;
|
|
5
|
+
[ElementContextMenu.pluginName]: ElementContextMenu;
|
|
6
|
+
[ElementBreadcrumbs.pluginName]: ElementBreadcrumbs;
|
|
7
|
+
[ElementQuickInsert.pluginName]: ElementQuickInsert;
|
|
8
|
+
}
|
|
9
|
+
interface CommandsMap {
|
|
10
|
+
quickInsert: QuickInsertCommand;
|
|
11
|
+
quickInsertBefore: QuickInsertPositionCommand;
|
|
12
|
+
quickInsertAfter: QuickInsertPositionCommand;
|
|
13
|
+
}
|
|
14
|
+
interface EditorConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Returns the items (commands, submenus and `'|'` separators) of the context menu of the right-clicked element.
|
|
17
|
+
* See {@link ElementContextMenu}.
|
|
18
|
+
*/
|
|
19
|
+
elementContextMenu?: ElementMenuConfig;
|
|
20
|
+
/**
|
|
21
|
+
* The configuration of the {@link ElementBreadcrumbs} plugin.
|
|
22
|
+
*/
|
|
23
|
+
elementBreadcrumbs?: ElementBreadcrumbsConfig;
|
|
24
|
+
/**
|
|
25
|
+
* The configuration of the {@link ElementQuickInsert} plugin.
|
|
26
|
+
*/
|
|
27
|
+
elementQuickInsert?: ElementQuickInsertConfig;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=augmentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augmentation.d.ts","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,YAAY,CAAC;AAEpB,OAAO,QAAQ,WAAW,CAAC;IAC1B,UAAU,UAAU;QACnB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;QACtC,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;QACpD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;QACpD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;KACpD;IAED,UAAU,WAAW;QACpB,WAAW,EAAE,kBAAkB,CAAC;QAChC,iBAAiB,EAAE,0BAA0B,CAAC;QAC9C,gBAAgB,EAAE,0BAA0B,CAAC;KAC7C;IAED,UAAU,YAAY;QACrB;;;WAGG;QACH,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;QAEvC;;WAEG;QACH,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;QAE9C;;WAEG;QACH,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;KAC9C;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augmentation.js","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ButtonView, type Locale, type ModelElement, type ViewElement } from 'ckeditor5';
|
|
2
|
+
/**
|
|
3
|
+
* A single breadcrumb that can be clicked: a button labelled with one element of the data view, e.g. `section.title`.
|
|
4
|
+
* It opens the menu of its element (`aria-haspopup`), and is `aria-expanded` while the menu is open.
|
|
5
|
+
*/
|
|
6
|
+
export default class BreadcrumbItemView extends ButtonView {
|
|
7
|
+
/**
|
|
8
|
+
* The data view element this item stands for.
|
|
9
|
+
*/
|
|
10
|
+
readonly viewElement: ViewElement;
|
|
11
|
+
/**
|
|
12
|
+
* The model element the menu of this item is for.
|
|
13
|
+
*/
|
|
14
|
+
readonly modelElement: ModelElement | null;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the menu of this item is open.
|
|
17
|
+
*
|
|
18
|
+
* @observable
|
|
19
|
+
*/
|
|
20
|
+
isExpanded: boolean;
|
|
21
|
+
constructor(locale: Locale | undefined, { label, viewElement, modelElement }: BreadcrumbItem, { isCurrent }?: BreadcrumbItemViewOptions);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The options of {@link BreadcrumbItemView} and {@link BreadcrumbLabelView}.
|
|
25
|
+
*/
|
|
26
|
+
export interface BreadcrumbItemViewOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Whether the item is the innermost element (where the cursor is). It is marked with `aria-current="location"`.
|
|
29
|
+
*/
|
|
30
|
+
isCurrent?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A breadcrumb: an element of the data view, its label, and the model element it belongs to.
|
|
34
|
+
*/
|
|
35
|
+
export interface BreadcrumbItem {
|
|
36
|
+
label: string;
|
|
37
|
+
/**
|
|
38
|
+
* The data view element (as in the editor data, e.g. `getData()`).
|
|
39
|
+
*/
|
|
40
|
+
viewElement: ViewElement;
|
|
41
|
+
/**
|
|
42
|
+
* The model element of the view element: the mapped one, or for a part of a structure (e.g. a `tbody`), the closest
|
|
43
|
+
* mapped ancestor (the table). `null` for list items (`ul`, `li`), which come from block attributes.
|
|
44
|
+
*/
|
|
45
|
+
modelElement: ModelElement | null;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=breadcrumbItemView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumbItemView.d.ts","sourceRoot":"","sources":["../../src/breadcrumbs/breadcrumbItemView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAEzF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACzD;;OAEG;IACH,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;OAEG;IACH,SAAgB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAElD;;;;OAIG;IACY,UAAU,EAAE,OAAO,CAAC;gBAGlC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,cAAc,EACpD,EAAE,SAAiB,EAAE,GAAE,yBAA8B;CAkBtD;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;;OAGG;IACH,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;CAClC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ButtonView } from 'ckeditor5';
|
|
2
|
+
/**
|
|
3
|
+
* A single breadcrumb that can be clicked: a button labelled with one element of the data view, e.g. `section.title`.
|
|
4
|
+
* It opens the menu of its element (`aria-haspopup`), and is `aria-expanded` while the menu is open.
|
|
5
|
+
*/
|
|
6
|
+
export default class BreadcrumbItemView extends ButtonView {
|
|
7
|
+
/**
|
|
8
|
+
* The data view element this item stands for.
|
|
9
|
+
*/
|
|
10
|
+
viewElement;
|
|
11
|
+
/**
|
|
12
|
+
* The model element the menu of this item is for.
|
|
13
|
+
*/
|
|
14
|
+
modelElement;
|
|
15
|
+
constructor(locale, { label, viewElement, modelElement }, { isCurrent = false } = {}) {
|
|
16
|
+
super(locale);
|
|
17
|
+
this.viewElement = viewElement;
|
|
18
|
+
this.modelElement = modelElement;
|
|
19
|
+
this.set({ label, withText: true, isExpanded: false });
|
|
20
|
+
this.extendTemplate({
|
|
21
|
+
attributes: {
|
|
22
|
+
class: 'ck-elements-breadcrumbs__item',
|
|
23
|
+
'aria-haspopup': 'menu',
|
|
24
|
+
'aria-expanded': this.bindTemplate.to('isExpanded', value => String(value)),
|
|
25
|
+
...(isCurrent ? { 'aria-current': 'location' } : {})
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=breadcrumbItemView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumbItemView.js","sourceRoot":"","sources":["../../src/breadcrumbs/breadcrumbItemView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoD,MAAM,WAAW,CAAC;AAEzF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACzD;;OAEG;IACa,WAAW,CAAc;IAEzC;;OAEG;IACa,YAAY,CAAsB;IASlD,YACC,MAA0B,EAC1B,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAkB,EACpD,EAAE,SAAS,GAAG,KAAK,KAAgC,EAAE;QAErD,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QAEjC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAEvD,IAAI,CAAC,cAAc,CAAC;YACnB,UAAU,EAAE;gBACX,KAAK,EAAE,+BAA+B;gBACtC,eAAe,EAAE,MAAM;gBACvB,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3E,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpD;SACD,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { View, type Locale, type ModelElement, type ViewElement } from 'ckeditor5';
|
|
2
|
+
import { type BreadcrumbItem, type BreadcrumbItemViewOptions } from './breadcrumbItemView.js';
|
|
3
|
+
/**
|
|
4
|
+
* A single breadcrumb that cannot be clicked: the label of one element of the data view, e.g. `section.title`.
|
|
5
|
+
*
|
|
6
|
+
* It can be focused (but is not in the Tab order), so keyboard users can reach it in a toolbar.
|
|
7
|
+
*/
|
|
8
|
+
export default class BreadcrumbLabelView extends View {
|
|
9
|
+
/**
|
|
10
|
+
* The data view element this item stands for.
|
|
11
|
+
*/
|
|
12
|
+
readonly viewElement: ViewElement;
|
|
13
|
+
/**
|
|
14
|
+
* The model element of the view element, if any.
|
|
15
|
+
*/
|
|
16
|
+
readonly modelElement: ModelElement | null;
|
|
17
|
+
/**
|
|
18
|
+
* The label of the element.
|
|
19
|
+
*
|
|
20
|
+
* @observable
|
|
21
|
+
*/
|
|
22
|
+
label: string;
|
|
23
|
+
constructor(locale: Locale | undefined, { label, viewElement, modelElement }: BreadcrumbItem, { isCurrent }?: BreadcrumbItemViewOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Focuses the label.
|
|
26
|
+
*/
|
|
27
|
+
focus(): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=breadcrumbLabelView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumbLabelView.d.ts","sourceRoot":"","sources":["../../src/breadcrumbs/breadcrumbLabelView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAE9F;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,IAAI;IACpD;;OAEG;IACH,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;OAEG;IACH,SAAgB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAElD;;;;OAIG;IACY,KAAK,EAAE,MAAM,CAAC;gBAG5B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,cAAc,EACpD,EAAE,SAAiB,EAAE,GAAE,yBAA8B;IAmBtD;;OAEG;IACI,KAAK,IAAI,IAAI;CAGpB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { View } from 'ckeditor5';
|
|
2
|
+
import {} from './breadcrumbItemView.js';
|
|
3
|
+
/**
|
|
4
|
+
* A single breadcrumb that cannot be clicked: the label of one element of the data view, e.g. `section.title`.
|
|
5
|
+
*
|
|
6
|
+
* It can be focused (but is not in the Tab order), so keyboard users can reach it in a toolbar.
|
|
7
|
+
*/
|
|
8
|
+
export default class BreadcrumbLabelView extends View {
|
|
9
|
+
/**
|
|
10
|
+
* The data view element this item stands for.
|
|
11
|
+
*/
|
|
12
|
+
viewElement;
|
|
13
|
+
/**
|
|
14
|
+
* The model element of the view element, if any.
|
|
15
|
+
*/
|
|
16
|
+
modelElement;
|
|
17
|
+
constructor(locale, { label, viewElement, modelElement }, { isCurrent = false } = {}) {
|
|
18
|
+
super(locale);
|
|
19
|
+
this.viewElement = viewElement;
|
|
20
|
+
this.modelElement = modelElement;
|
|
21
|
+
this.set('label', label);
|
|
22
|
+
this.setTemplate({
|
|
23
|
+
tag: 'span',
|
|
24
|
+
attributes: {
|
|
25
|
+
class: ['ck', 'ck-elements-breadcrumbs__item', 'ck-elements-breadcrumbs__label'],
|
|
26
|
+
tabindex: '-1',
|
|
27
|
+
...(isCurrent ? { 'aria-current': 'location' } : {})
|
|
28
|
+
},
|
|
29
|
+
children: [{ text: this.bindTemplate.to('label') }]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Focuses the label.
|
|
34
|
+
*/
|
|
35
|
+
focus() {
|
|
36
|
+
this.element?.focus();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=breadcrumbLabelView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumbLabelView.js","sourceRoot":"","sources":["../../src/breadcrumbs/breadcrumbLabelView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoD,MAAM,WAAW,CAAC;AACnF,OAAO,EAAuD,MAAM,yBAAyB,CAAC;AAE9F;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,IAAI;IACpD;;OAEG;IACa,WAAW,CAAc;IAEzC;;OAEG;IACa,YAAY,CAAsB;IASlD,YACC,MAA0B,EAC1B,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAkB,EACpD,EAAE,SAAS,GAAG,KAAK,KAAgC,EAAE;QAErD,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAEzB,IAAI,CAAC,WAAW,CAAC;YAChB,GAAG,EAAE,MAAM;YACX,UAAU,EAAE;gBACX,KAAK,EAAE,CAAC,IAAI,EAAE,+BAA+B,EAAE,gCAAgC,CAAC;gBAChF,QAAQ,EAAE,IAAI;gBACd,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpD;YACD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;SACnD,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { KeystrokeHandler, View, ViewCollection, type Locale } from 'ckeditor5';
|
|
2
|
+
import BreadcrumbItemView, { type BreadcrumbItem } from './breadcrumbItemView.js';
|
|
3
|
+
import BreadcrumbLabelView from './breadcrumbLabelView.js';
|
|
4
|
+
/**
|
|
5
|
+
* The options of {@link BreadcrumbsView}.
|
|
6
|
+
*/
|
|
7
|
+
export interface BreadcrumbsViewOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the items are buttons that can be clicked, or labels. Defaults to `false`.
|
|
10
|
+
*/
|
|
11
|
+
isClickable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Shows a path of elements, from the outermost to the innermost one, as a list (`<ol>`) in a `<nav>` landmark: buttons
|
|
15
|
+
* when the items can be clicked, labels otherwise. Items without a model element (list items) are labels too. The
|
|
16
|
+
* innermost item is marked with `aria-current="location"`.
|
|
17
|
+
*
|
|
18
|
+
* The left and right arrows move the focus between the items; past the first or the last one, they are left to the
|
|
19
|
+
* toolbar the view is in. Fires `execute` with the item when one of the buttons is clicked.
|
|
20
|
+
*/
|
|
21
|
+
export default class BreadcrumbsView extends View {
|
|
22
|
+
/**
|
|
23
|
+
* The breadcrumb items: the buttons or labels, from the outermost to the innermost one.
|
|
24
|
+
*/
|
|
25
|
+
readonly items: ViewCollection<BreadcrumbItemView | BreadcrumbLabelView>;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the items are buttons that can be clicked, or labels.
|
|
28
|
+
*/
|
|
29
|
+
readonly isClickable: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Handles the keystrokes within the breadcrumbs.
|
|
32
|
+
*/
|
|
33
|
+
readonly keystrokes: KeystrokeHandler;
|
|
34
|
+
/**
|
|
35
|
+
* The list items (`<li>`) that hold the {@link items}.
|
|
36
|
+
*/
|
|
37
|
+
private readonly _listItems;
|
|
38
|
+
constructor(locale?: Locale, { isClickable }?: BreadcrumbsViewOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Replaces the items.
|
|
41
|
+
*/
|
|
42
|
+
setItems(items: readonly BreadcrumbItem[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Renders the view and starts handling the keystrokes.
|
|
45
|
+
*/
|
|
46
|
+
render(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Focuses an item: the first one when the focus moves forward (`1`, e.g. from the previous toolbar item), the
|
|
49
|
+
* innermost one otherwise.
|
|
50
|
+
*/
|
|
51
|
+
focus(direction?: 1 | -1): void;
|
|
52
|
+
/**
|
|
53
|
+
* Destroys the view and its keystroke handler.
|
|
54
|
+
*/
|
|
55
|
+
destroy(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Focuses the item before (`-1`) or after (`1`) the focused one. Returns `false` when there is none.
|
|
58
|
+
*/
|
|
59
|
+
private _focusSibling;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fired by {@link BreadcrumbsView} when one of its buttons is clicked.
|
|
63
|
+
*/
|
|
64
|
+
export interface BreadcrumbsViewExecuteEvent {
|
|
65
|
+
name: 'execute';
|
|
66
|
+
args: [item: BreadcrumbItemView];
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=breadcrumbsView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumbsView.d.ts","sourceRoot":"","sources":["../../src/breadcrumbs/breadcrumbsView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,kBAAkB,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,IAAI;IAChD;;OAEG;IACH,SAAgB,KAAK,2DAAkE;IAEvF;;OAEG;IACH,SAAgB,WAAW,EAAE,OAAO,CAAC;IAErC;;OAEG;IACH,SAAgB,UAAU,mBAA0B;IAEpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0C;gBAEzD,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,WAAmB,EAAE,GAAE,sBAA2B;IAsCjF;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,IAAI;IA0BvD;;OAEG;IACa,MAAM,IAAI,IAAI;IAQ9B;;;OAGG;IACI,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI;IAItC;;OAEG;IACa,OAAO,IAAI,IAAI;IAK/B;;OAEG;IACH,OAAO,CAAC,aAAa;CASrB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { KeystrokeHandler, View, ViewCollection } from 'ckeditor5';
|
|
2
|
+
import BreadcrumbItemView, {} from './breadcrumbItemView.js';
|
|
3
|
+
import BreadcrumbLabelView from './breadcrumbLabelView.js';
|
|
4
|
+
/**
|
|
5
|
+
* Shows a path of elements, from the outermost to the innermost one, as a list (`<ol>`) in a `<nav>` landmark: buttons
|
|
6
|
+
* when the items can be clicked, labels otherwise. Items without a model element (list items) are labels too. The
|
|
7
|
+
* innermost item is marked with `aria-current="location"`.
|
|
8
|
+
*
|
|
9
|
+
* The left and right arrows move the focus between the items; past the first or the last one, they are left to the
|
|
10
|
+
* toolbar the view is in. Fires `execute` with the item when one of the buttons is clicked.
|
|
11
|
+
*/
|
|
12
|
+
export default class BreadcrumbsView extends View {
|
|
13
|
+
/**
|
|
14
|
+
* The breadcrumb items: the buttons or labels, from the outermost to the innermost one.
|
|
15
|
+
*/
|
|
16
|
+
items = new ViewCollection();
|
|
17
|
+
/**
|
|
18
|
+
* Whether the items are buttons that can be clicked, or labels.
|
|
19
|
+
*/
|
|
20
|
+
isClickable;
|
|
21
|
+
/**
|
|
22
|
+
* Handles the keystrokes within the breadcrumbs.
|
|
23
|
+
*/
|
|
24
|
+
keystrokes = new KeystrokeHandler();
|
|
25
|
+
/**
|
|
26
|
+
* The list items (`<li>`) that hold the {@link items}.
|
|
27
|
+
*/
|
|
28
|
+
_listItems;
|
|
29
|
+
constructor(locale, { isClickable = false } = {}) {
|
|
30
|
+
super(locale);
|
|
31
|
+
this._listItems = this.createCollection();
|
|
32
|
+
this.isClickable = isClickable;
|
|
33
|
+
const isRtl = locale?.uiLanguageDirection === 'rtl';
|
|
34
|
+
this.keystrokes.set(isRtl ? 'arrowright' : 'arrowleft', (data, cancel) => {
|
|
35
|
+
if (this._focusSibling(-1)) {
|
|
36
|
+
cancel();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
this.keystrokes.set(isRtl ? 'arrowleft' : 'arrowright', (data, cancel) => {
|
|
40
|
+
if (this._focusSibling(1)) {
|
|
41
|
+
cancel();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.setTemplate({
|
|
45
|
+
tag: 'nav',
|
|
46
|
+
attributes: {
|
|
47
|
+
class: ['ck', 'ck-elements-breadcrumbs'],
|
|
48
|
+
'aria-label': locale?.t('Element path') ?? 'Element path'
|
|
49
|
+
},
|
|
50
|
+
children: [
|
|
51
|
+
{
|
|
52
|
+
tag: 'ol',
|
|
53
|
+
attributes: {
|
|
54
|
+
class: ['ck', 'ck-elements-breadcrumbs__list']
|
|
55
|
+
},
|
|
56
|
+
children: this._listItems
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Replaces the items.
|
|
63
|
+
*/
|
|
64
|
+
setItems(items) {
|
|
65
|
+
for (const listItem of this._listItems) {
|
|
66
|
+
listItem.destroy();
|
|
67
|
+
}
|
|
68
|
+
this._listItems.clear();
|
|
69
|
+
this.items.clear();
|
|
70
|
+
items.forEach((item, index) => {
|
|
71
|
+
const isCurrent = index === items.length - 1;
|
|
72
|
+
const view = this.isClickable && item.modelElement
|
|
73
|
+
? new BreadcrumbItemView(this.locale, item, { isCurrent })
|
|
74
|
+
: new BreadcrumbLabelView(this.locale, item, { isCurrent });
|
|
75
|
+
if (view instanceof BreadcrumbItemView) {
|
|
76
|
+
view.on('execute', () => {
|
|
77
|
+
this.fire('execute', view);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
this.items.add(view);
|
|
81
|
+
this._listItems.add(new BreadcrumbsListItemView(this.locale, view));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Renders the view and starts handling the keystrokes.
|
|
86
|
+
*/
|
|
87
|
+
render() {
|
|
88
|
+
super.render();
|
|
89
|
+
if (this.element) {
|
|
90
|
+
this.keystrokes.listenTo(this.element);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Focuses an item: the first one when the focus moves forward (`1`, e.g. from the previous toolbar item), the
|
|
95
|
+
* innermost one otherwise.
|
|
96
|
+
*/
|
|
97
|
+
focus(direction) {
|
|
98
|
+
(direction === 1 ? this.items.first : this.items.last)?.focus();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Destroys the view and its keystroke handler.
|
|
102
|
+
*/
|
|
103
|
+
destroy() {
|
|
104
|
+
super.destroy();
|
|
105
|
+
this.keystrokes.destroy();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Focuses the item before (`-1`) or after (`1`) the focused one. Returns `false` when there is none.
|
|
109
|
+
*/
|
|
110
|
+
_focusSibling(step) {
|
|
111
|
+
const items = Array.from(this.items);
|
|
112
|
+
const index = items.findIndex(item => item.element === document.activeElement);
|
|
113
|
+
const sibling = index === -1 ? undefined : items[index + step];
|
|
114
|
+
sibling?.focus();
|
|
115
|
+
return !!sibling;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A list item (`<li>`) of the breadcrumbs, holding a button or a label.
|
|
120
|
+
*/
|
|
121
|
+
class BreadcrumbsListItemView extends View {
|
|
122
|
+
constructor(locale, item) {
|
|
123
|
+
super(locale);
|
|
124
|
+
// Rendering registers the item as a child, so it is destroyed with the list item.
|
|
125
|
+
this.setTemplate({
|
|
126
|
+
tag: 'li',
|
|
127
|
+
attributes: {
|
|
128
|
+
class: ['ck', 'ck-elements-breadcrumbs__list-item']
|
|
129
|
+
},
|
|
130
|
+
children: [item]
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=breadcrumbsView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumbsView.js","sourceRoot":"","sources":["../../src/breadcrumbs/breadcrumbsView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAe,MAAM,WAAW,CAAC;AAChF,OAAO,kBAAkB,EAAE,EAAuB,MAAM,yBAAyB,CAAC;AAClF,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAY3D;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,IAAI;IAChD;;OAEG;IACa,KAAK,GAAG,IAAI,cAAc,EAA4C,CAAC;IAEvF;;OAEG;IACa,WAAW,CAAU;IAErC;;OAEG;IACa,UAAU,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAEpD;;OAEG;IACc,UAAU,CAA0C;IAErE,YAAY,MAAe,EAAE,EAAE,WAAW,GAAG,KAAK,KAA6B,EAAE;QAChF,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,MAAM,KAAK,GAAG,MAAM,EAAE,mBAAmB,KAAK,KAAK,CAAC;QAEpD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACxE,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5B,MAAM,EAAE,CAAC;YACV,CAAC;QACF,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACxE,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,EAAE,CAAC;YACV,CAAC;QACF,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC;YAChB,GAAG,EAAE,KAAK;YACV,UAAU,EAAE;gBACX,KAAK,EAAE,CAAC,IAAI,EAAE,yBAAyB,CAAC;gBACxC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,cAAc;aACzD;YACD,QAAQ,EAAE;gBACT;oBACC,GAAG,EAAE,IAAI;oBACT,UAAU,EAAE;wBACX,KAAK,EAAE,CAAC,IAAI,EAAE,+BAA+B,CAAC;qBAC9C;oBACD,QAAQ,EAAE,IAAI,CAAC,UAAU;iBACzB;aACD;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,KAAgC;QAC/C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAEnB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC7B,MAAM,SAAS,GAAG,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC7C,MAAM,IAAI,GACT,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,YAAY;gBACpC,CAAC,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC;gBAC1D,CAAC,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAE9D,IAAI,IAAI,YAAY,kBAAkB,EAAE,CAAC;gBACxC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;oBACvB,IAAI,CAAC,IAAI,CAA8B,SAAS,EAAE,IAAI,CAAC,CAAC;gBACzD,CAAC,CAAC,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACa,MAAM;QACrB,KAAK,CAAC,MAAM,EAAE,CAAC;QAEf,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,SAAkB;QAC9B,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;IACjE,CAAC;IAED;;OAEG;IACa,OAAO;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,IAAY;QACjC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;QAE/D,OAAO,EAAE,KAAK,EAAE,CAAC;QAEjB,OAAO,CAAC,CAAC,OAAO,CAAC;IAClB,CAAC;CACD;AAUD;;GAEG;AACH,MAAM,uBAAwB,SAAQ,IAAI;IACzC,YAAY,MAA0B,EAAE,IAA8C;QACrF,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,kFAAkF;QAClF,IAAI,CAAC,WAAW,CAAC;YAChB,GAAG,EAAE,IAAI;YACT,UAAU,EAAE;gBACX,KAAK,EAAE,CAAC,IAAI,EAAE,oCAAoC,CAAC;aACnD;YACD,QAAQ,EAAE,CAAC,IAAI,CAAC;SAChB,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Plugin, type Editor, type Locale } from 'ckeditor5';
|
|
2
|
+
import ElementMenu, { type ElementMenuConfig } from '../elementMenu.js';
|
|
3
|
+
import { type BreadcrumbItem } from './breadcrumbItemView.js';
|
|
4
|
+
import BreadcrumbsView from './breadcrumbsView.js';
|
|
5
|
+
/**
|
|
6
|
+
* The configuration of the {@link ElementBreadcrumbs} plugin.
|
|
7
|
+
*/
|
|
8
|
+
export interface ElementBreadcrumbsConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the items of the menu that opens when a breadcrumb is clicked, for the element of the breadcrumb: the
|
|
11
|
+
* same items as in the `elementContextMenu` option (commands, submenus and `'|'` separators), so one callback can
|
|
12
|
+
* serve both. Without this option, breadcrumbs are labels, and cannot be clicked.
|
|
13
|
+
*/
|
|
14
|
+
menu?: ElementMenuConfig;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Shows the data view structure at the current selection (the elements of the editor data, as in `getData()`), e.g.
|
|
18
|
+
* `aside.note › p`, `ul › li` or `figure.table › table › tbody › tr › td`.
|
|
19
|
+
*
|
|
20
|
+
* Inline elements are items, as any element. CKEditor's text attributes, marks on the text such as its `<strong>`, are
|
|
21
|
+
* skipped. The selected element, e.g. an image, is the innermost item.
|
|
22
|
+
*
|
|
23
|
+
* Place them in a toolbar as the `breadcrumbs` component, or anywhere else using a view from {@link createView}.
|
|
24
|
+
*
|
|
25
|
+
* Clicking is configured only by the `elementBreadcrumbs.menu` editor config option (see {@link ElementBreadcrumbsConfig}): with it,
|
|
26
|
+
* the items are buttons that open the menu of their element, with `ElementMenu`, as the context menu does; without it,
|
|
27
|
+
* they are labels.
|
|
28
|
+
*
|
|
29
|
+
* The data view is converted again only when elements change, not when typing or moving the cursor. For a large
|
|
30
|
+
* document, that happens at most every 250 ms.
|
|
31
|
+
*/
|
|
32
|
+
export default class ElementBreadcrumbs extends Plugin {
|
|
33
|
+
/**
|
|
34
|
+
* The elements at the current selection, from the outermost to the innermost one.
|
|
35
|
+
*
|
|
36
|
+
* @observable
|
|
37
|
+
*/
|
|
38
|
+
items: readonly BreadcrumbItem[];
|
|
39
|
+
private _dataView;
|
|
40
|
+
private _isDataViewOutdated;
|
|
41
|
+
private _isConversionSlow;
|
|
42
|
+
private _conversionTimeout;
|
|
43
|
+
static get pluginName(): 'ElementBreadcrumbs';
|
|
44
|
+
static get requires(): readonly [typeof ElementMenu];
|
|
45
|
+
constructor(editor: Editor);
|
|
46
|
+
init(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a breadcrumbs view that follows {@link items}.
|
|
49
|
+
*/
|
|
50
|
+
createView(locale?: Locale): BreadcrumbsView;
|
|
51
|
+
/**
|
|
52
|
+
* Updates {@link items} from the current selection, converting the data view first when elements changed.
|
|
53
|
+
*/
|
|
54
|
+
refresh(): void;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Refreshes the items after a change. When converting is slow, the data view is converted later, and the items
|
|
58
|
+
* follow the outdated data view until then.
|
|
59
|
+
*/
|
|
60
|
+
private _update;
|
|
61
|
+
/**
|
|
62
|
+
* Converts the root to the data view, and maps its model elements to their view elements.
|
|
63
|
+
*/
|
|
64
|
+
private _convert;
|
|
65
|
+
private _cancelConversion;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the data view elements at the selection: the view element of the selected element, or of the innermost
|
|
68
|
+
* element with the selection, and its ancestors.
|
|
69
|
+
*/
|
|
70
|
+
private _getItems;
|
|
71
|
+
private _openMenu;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=elementBreadcrumbs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementBreadcrumbs.d.ts","sourceRoot":"","sources":["../../src/breadcrumbs/elementBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EAEN,KAAK,MAAM,EACX,KAAK,MAAM,EAQX,MAAM,WAAW,CAAC;AAEnB,OAAO,WAAW,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,KAAK,cAAc,EAAsC,MAAM,yBAAyB,CAAC;AAClG,OAAO,eAAqD,MAAM,sBAAsB,CAAC;AASzF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;OAIG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;CACzB;AAWD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,MAAM;IACrD;;;;OAIG;IACY,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAEhD,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,mBAAmB,CAAQ;IACnC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,kBAAkB,CAA8C;IAExE,WAAkB,UAAU,IAAI,oBAAoB,CAEnD;IAED,WAAkB,QAAQ,IAAI,SAAS,CAAC,OAAO,WAAW,CAAC,CAE1D;gBAEW,MAAM,EAAE,MAAM;IAMnB,IAAI,IAAI,IAAI;IAmBnB;;OAEG;IACI,UAAU,CAAC,MAAM,GAAE,MAA2B,GAAG,eAAe;IAgBvE;;OAEG;IACI,OAAO,IAAI,IAAI;IAcN,OAAO,IAAI,IAAI;IAK/B;;;OAGG;IACH,OAAO,CAAC,OAAO;IAqBf;;OAEG;IACH,OAAO,CAAC,QAAQ;IAwBhB,OAAO,CAAC,iBAAiB;IAOzB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,SAAS;CAwBjB"}
|