mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
client/context menus: add support to display badges for menu items
This commit is contained in:
parent
38114bddb9
commit
0a06c60cb7
@ -17,11 +17,17 @@ interface MenuSeparatorItem {
|
|||||||
title: "----";
|
title: "----";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MenuItemBadge {
|
||||||
|
title: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface MenuCommandItem<T> {
|
export interface MenuCommandItem<T> {
|
||||||
title: string;
|
title: string;
|
||||||
command?: T;
|
command?: T;
|
||||||
type?: string;
|
type?: string;
|
||||||
uiIcon?: string;
|
uiIcon?: string;
|
||||||
|
badges?: MenuItemBadge[];
|
||||||
templateNoteId?: string;
|
templateNoteId?: string;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
handler?: MenuHandler<T>;
|
handler?: MenuHandler<T>;
|
||||||
@ -157,6 +163,18 @@ class ContextMenu {
|
|||||||
.append(" ") // some space between icon and text
|
.append(" ") // some space between icon and text
|
||||||
.append(item.title);
|
.append(item.title);
|
||||||
|
|
||||||
|
if ("badges" in item && item.badges) {
|
||||||
|
for (let badge of item.badges) {
|
||||||
|
const badgeElement = $(`<span class="badge">`).text(badge.title);
|
||||||
|
|
||||||
|
if (badge.className) {
|
||||||
|
badgeElement.addClass(badge.className);
|
||||||
|
}
|
||||||
|
|
||||||
|
$link.append(badgeElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ("shortcut" in item && item.shortcut) {
|
if ("shortcut" in item && item.shortcut) {
|
||||||
$link.append($("<kbd>").text(item.shortcut));
|
$link.append($("<kbd>").text(item.shortcut));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user