M3.9: hamburger app menu
A slim header bar in MainLayout with a menu button (Lucide menu) whose dropdown lists every command with a menuPath, grouped File, Edit, View, Go, Help, with shortcuts and dimmed disabled entries. Keyboard: arrows, Home/End, Enter/Space, Escape/Tab, type-ahead. menu.open (Alt+M) opens it, also over uiCommand. It is an exclusive modal and a launcher under the one-modal rule. Menu paths for the user-facing engine and UI commands (buffer.close as File/Close Tab). Catalog strings, Vitest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
78709dd76b
commit
27ad30369c
14 changed files with 1004 additions and 25 deletions
|
|
@ -15,7 +15,8 @@
|
|||
* commands run with empty params.
|
||||
* - **Errors:** a failed command raises an error toast (M1.12).
|
||||
* - **Palette:** running any command but `palette.open` closes the palette
|
||||
* first (the modal rule, `modals.ts`).
|
||||
* first (the modal rule, `modals.ts`); likewise any command but
|
||||
* `menu.open` closes the app menu (M3.9).
|
||||
*/
|
||||
import { defineStore } from "pinia";
|
||||
import { computed, ref, shallowReactive } from "vue";
|
||||
|
|
@ -49,11 +50,18 @@ export interface PaletteEntry {
|
|||
shortcut: string | null;
|
||||
/** Whether it can run now. */
|
||||
enabled: boolean;
|
||||
/** Menu path with `/` separators, or null if the command is in no menu (M3.9). */
|
||||
menuPath: string | null;
|
||||
/** Whether the frontend runs it (a UI command, label from the catalog). */
|
||||
ui: boolean;
|
||||
}
|
||||
|
||||
/** Most recently run commands remembered. */
|
||||
export const MAX_RECENT = 20;
|
||||
|
||||
/** The UI command that opens the app menu, which therefore keeps it open. */
|
||||
const MENU_OPEN = "menu.open";
|
||||
|
||||
/** The UI commands that open the go-to popup, which therefore keep it open. */
|
||||
const GOTO_OPEN = new Set(["goto.fileOpen", "goto.classOpen", "goto.symbolOpen"]);
|
||||
|
||||
|
|
@ -151,6 +159,8 @@ export const useCommandsStore = defineStore("commands", () => {
|
|||
label: labelOf(info),
|
||||
shortcut: typeof info.defaultShortcut === "string" ? formatShortcut(info.defaultShortcut, mac) : null,
|
||||
enabled: isEnabled(info.id),
|
||||
menuPath: typeof info.menuPath === "string" && info.menuPath !== "" ? info.menuPath : null,
|
||||
ui: info.ui === true,
|
||||
})),
|
||||
);
|
||||
|
||||
|
|
@ -187,8 +197,9 @@ export const useCommandsStore = defineStore("commands", () => {
|
|||
* Runs a command the user chose (keyboard or palette): through its
|
||||
* handler if a component supplied one, else through the engine. A
|
||||
* disabled command does nothing. A failure raises an error toast. Any
|
||||
* command but `palette.open` closes the palette before it runs, and any
|
||||
* command but the go-to open commands closes the go-to popup.
|
||||
* command but `palette.open` closes the palette before it runs, any
|
||||
* command but the go-to open commands closes the go-to popup, and any
|
||||
* command but `menu.open` closes the app menu.
|
||||
*
|
||||
* @param id - the command id.
|
||||
* @param params - the params.
|
||||
|
|
@ -204,6 +215,9 @@ export const useCommandsStore = defineStore("commands", () => {
|
|||
if (!GOTO_OPEN.has(id)) {
|
||||
modals.dismiss("goto");
|
||||
}
|
||||
if (id !== MENU_OPEN) {
|
||||
modals.dismiss("menu");
|
||||
}
|
||||
const handler = handlers.get(id);
|
||||
if (handler) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue