From a080b627e0a97fbbc7ac0c6d6bb7a00bbaa2a317 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Mon, 14 Apr 2025 16:19:43 +0200 Subject: [PATCH] Add descriptions and categories to commands Use the descriptions and categories in the Command palette and Settings dialog --- src/components/BufferSelector.vue | 17 ++- src/components/settings/KeyBindRow.vue | 25 ++-- src/components/settings/KeyboardBindings.vue | 2 +- src/editor/commands.js | 132 ++++++++++++------- src/editor/editor.js | 2 +- src/editor/keymap.js | 2 +- 6 files changed, 115 insertions(+), 65 deletions(-) diff --git a/src/components/BufferSelector.vue b/src/components/BufferSelector.vue index 246c1d7..1a9b24a 100644 --- a/src/components/BufferSelector.vue +++ b/src/components/BufferSelector.vue @@ -52,9 +52,20 @@ ]), commands() { - return Object.keys(HEYNOTE_COMMANDS).map(cmd => ({ - name: cmd, - cmd: cmd, + const commands = Object.entries(HEYNOTE_COMMANDS) + // sort array first by category, then by description + commands.sort((a, b) => { + const aCategory = a[1].category || "" + const bCategory = b[1].category || "" + if (aCategory === bCategory) { + return a[1].description.localeCompare(b[1].description) + } else { + return aCategory.localeCompare(bCategory) + } + }) + return commands.map(([cmdKey, cmd]) => ({ + name: `${cmd.category}: ${cmd.description}`, + cmd: cmdKey, isCommand: true, })) }, diff --git a/src/components/settings/KeyBindRow.vue b/src/components/settings/KeyBindRow.vue index f4e304d..c436e43 100644 --- a/src/components/settings/KeyBindRow.vue +++ b/src/components/settings/KeyBindRow.vue @@ -1,4 +1,6 @@ @@ -29,8 +39,7 @@ - Unbound - {{ command }} + {{ commandLabel }}