refactor(client): define context menu shortcuts in separate field

This commit is contained in:
Elian Doran 2024-11-21 20:33:47 +02:00
parent a037f95ff1
commit ea8e98b8ef
No known key found for this signature in database
2 changed files with 12 additions and 4 deletions

View File

@ -103,6 +103,10 @@ class ContextMenu {
.append("   ") // some space between icon and text
.append(item.title);
if (item.shortcut) {
$link.append($("<kbd>").text(item.shortcut));
}
const $item = $("<li>")
.addClass("dropdown-item")
.append($link)

View File

@ -39,7 +39,8 @@ function setupContextMenu() {
if (params.isEditable) {
items.push({
enabled: editFlags.canCut && hasText,
title: `Cut <kbd>${platformModifier}+X`,
title: `Cut`,
shortcut: `${platformModifier}+X`,
uiIcon: "bx bx-cut",
handler: () => webContents.cut()
});
@ -48,7 +49,8 @@ function setupContextMenu() {
if (params.isEditable || hasText) {
items.push({
enabled: editFlags.canCopy && hasText,
title: `Copy <kbd>${platformModifier}+C`,
title: `Copy`,
shortcut: `${platformModifier}+C`,
uiIcon: "bx bx-copy",
handler: () => webContents.copy()
});
@ -70,7 +72,8 @@ function setupContextMenu() {
if (params.isEditable) {
items.push({
enabled: editFlags.canPaste,
title: `Paste <kbd>${platformModifier}+V`,
title: `Paste`,
shortcut: `${platformModifier}+V`,
uiIcon: "bx bx-paste",
handler: () => webContents.paste()
});
@ -79,7 +82,8 @@ function setupContextMenu() {
if (params.isEditable) {
items.push({
enabled: editFlags.canPaste,
title: `Paste as plain text <kbd>${platformModifier}+Shift+V`,
title: `Paste as plain text`,
shortcut: `${platformModifier}+Shift+V`,
uiIcon: "bx bx-paste",
handler: () => webContents.pasteAndMatchStyle()
});