Skip to content

Build your personal knowledge base with Trilium Notes

feat(options): add a "show conflicts only" shortcut filter

Elian Doran31293e478a27
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 0e351bd4a2..83acbacec5 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1738,7 +1738,10 @@
"make_global": "Make this a system-wide (global) shortcut",
"make_local": "Make this an in-app shortcut",
"global_shortcut": "System-wide (global) shortcut, only active on the desktop app",
- "conflict_chip": "This combination is also assigned to: {{actions}}"
+ "conflict_chip": "This combination is also assigned to: {{actions}}",
+ "show_conflicts_only": "Show conflicts only",
+ "show_conflicts_only_count": "Show conflicts only ({{count}})",
+ "no_conflicts": "No conflicting shortcuts."
},
"spellcheck": {
"title": "Spell Check",
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.css b/apps/client/src/widgets/type_widgets/options/shortcuts.css
index 7050a667e5..ee54b4d741 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.css
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.css
@@ -8,6 +8,18 @@
padding-block: 0.5em;
border-bottom: 1px solid var(--main-border-color);
margin-bottom: 1em;
+ display: flex;
+ align-items: center;
+ gap: 1em;
+
+ > :first-child {
+ flex: 1;
+ }
+
+ .form-checkbox {
+ flex: 0 0 auto;
+ white-space: nowrap;
+ }
}
> footer {
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
index af3c370cd5..4eb70b76bb 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
@@ -12,6 +12,7 @@ import toast from "../../../services/toast";
import { arrayEqual, isElectron, reloadFrontendApp } from "../../../services/utils";
import ActionButton from "../../react/ActionButton";
import Button from "../../react/Button";
+import FormCheckbox from "../../react/FormCheckbox";
import FormText from "../../react/FormText";
import FormTextBox from "../../react/FormTextBox";
import { useTriliumEvent } from "../../react/hooks";
@@ -23,6 +24,7 @@ import OptionsSection from "./components/OptionsSection";
export default function ShortcutSettings() {
const [ keyboardShortcuts, setKeyboardShortcuts ] = useState<KeyboardShortcut[]>([]);
const [ filter, setFilter ] = useState<string>();
+ const [ conflictsOnly, setConflictsOnly ] = useState(false);
useEffect(() => {
server.get<KeyboardShortcut[]>("keyboard-actions").then(setKeyboardShortcuts);
@@ -83,7 +85,9 @@ export default function ShortcutSettings() {
const filteredGroups = groups
.map((group) => ({
...group,
- actions: filter ? group.actions.filter((action) => filterKeyboardAction(action, filterLowerCase)) : group.actions
+ actions: group.actions.filter((action) =>
+ (!conflictsOnly || conflicts.has(action.actionName)) &&
+ (!filter || filterKeyboardAction(action, filterLowerCase)))
}))
.filter((group) => group.actions.length > 0);
@@ -99,6 +103,13 @@ export default function ShortcutSettings() {
placeholder={t("shortcuts.type_text_to_filter")}
currentValue={filter} onChange={(value) => setFilter(value)}
/>
+ <FormCheckbox
+ label={conflicts.size > 0
+ ? t("shortcuts.show_conflicts_only_count", { count: conflicts.size })
+ : t("shortcuts.show_conflicts_only")}
+ currentValue={conflictsOnly}
+ onChange={setConflictsOnly}
+ />
</header>
{filteredGroups.length > 0
@@ -109,12 +120,19 @@ export default function ShortcutSettings() {
))}
</OptionsSection>
))
- : (
- <NoItems
- icon="bx bx-filter-alt"
- text={t("shortcuts.no_results", { filter })}
- />
- )}
+ : conflictsOnly && conflicts.size === 0
+ ? (
+ <NoItems
+ icon="bx bx-check-circle"
+ text={t("shortcuts.no_conflicts")}
+ />
+ )
+ : (
+ <NoItems
+ icon="bx bx-filter-alt"
+ text={t("shortcuts.no_results", { filter })}
+ />
+ )}
<footer>
<Button