Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(options): show the shortcut revert as a default-preview chip
Elian Doran00303e63d2dd
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.css b/apps/client/src/widgets/type_widgets/options/shortcuts.cssindex d214ba9e17..264280ceb2 100644--- a/apps/client/src/widgets/type_widgets/options/shortcuts.css+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.css@@ -84,6 +84,26 @@box-shadow: inset 0 0 0 1px var(--icon-button-danger-color, #d9534f);}+ /* Revert chip: previews the default the row reverts to. A plain gray chip; the whole chip is the+ button, with muted text to keep it quieter than the real (active) shortcut chips. */+ .shortcut-chip.shortcut-chip-revert {+ padding: 0.1em 0.5em;+ border: none;+ background: var(--input-background-color);+ color: var(--muted-text-color);+ cursor: pointer;+ transition: background 0.15s ease, color 0.15s ease;+ }++ .shortcut-chip.shortcut-chip-revert:hover {+ color: var(--main-text-color);+ background: var(--hover-item-background-color);+ }++ .shortcut-chip.shortcut-chip-revert kbd {+ color: inherit;+ }+.shortcut-chip-conflict {color: var(--icon-button-danger-color, #d9534f);}diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx b/apps/client/src/widgets/type_widgets/options/shortcuts.tsxindex 159c2e1c86..32f49ca36c 100644--- a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx@@ -444,18 +444,29 @@ function ShortcutEditor({ keyboardShortcut: action, conflicts }: { keyboardShort);})}- {isShortcutModified(action) &&- <ActionButton- icon="bx bx-reset"- text={t("shortcuts.revert_to_default", { shortcuts: formatDefaultShortcuts(action) })}- tooltipClass="tooltip-top"- onClick={() => revertShortcut(action)}- />}+ {isShortcutModified(action) && <RevertChip action={action} />}<ShortcutRecorder onCapture={addShortcut} /></div>);}+/**+ * Revert affordance styled like a shortcut chip: instead of an opaque reset icon, it previews the+ * default combination the row will return to, so the user sees the target before clicking.+ */+function RevertChip({ action }: { action: ActionKeyboardShortcut }) {+ return (+ <TooltipButton+ className="shortcut-chip shortcut-chip-revert"+ title={t("shortcuts.revert_to_default", { shortcuts: formatDefaultShortcuts(action) })}+ onClick={() => revertShortcut(action)}+ >+ <span class="bx bx-reset" />+ <kbd>{formatDefaultShortcuts(action)}</kbd>+ </TooltipButton>+ );+}+const RECORDING_TOAST_ID = "shortcut-recorder-recording";function ShortcutRecorder({ onCapture }: { onCapture: (shortcut: string) => void }) {@@ -516,8 +527,8 @@ function ShortcutRecorder({ onCapture }: { onCapture: (shortcut: string) => void/*** Attaches a Bootstrap tooltip to an element on the shortcuts page. Uses the `tooltip-top` popup- * class so the tooltip renders above the options modal (matching the revert ActionButton), and a- * focus trigger on mobile where hover is unavailable.+ * class so the tooltip renders above the options modal, and a focus trigger on mobile where hover+ * is unavailable.*/function useShortcutTooltip(elRef: RefObject<Element>, title: string) {useStaticTooltip(elRef, {