From ebacdb8164f3cd0b5723e874bf09381f149bff78 Mon Sep 17 00:00:00 2001 From: Knotty Wyvern Date: Wed, 28 Oct 2026 19:10:25 -0700 Subject: [PATCH] Add the command palette, Write formatting keys, and platform labels Phase 5-2. - Ctrl+Shift+P opens the command palette: every workbench command with its shortcut, then the plugin commands (UI-048). - In Write, Ctrl+B, Ctrl+I, Ctrl+Shift+X, and Ctrl+Shift+H format the selection, and Ctrl+K inserts a Markdown link. The Format menu shows these shortcuts. - Ctrl+\ toggles the side pane. It matches the physical key on every keyboard layout. Ctrl+B now belongs to Write. - Help lists every shortcut in groups, open by default. The list comes from the command table. - src/lib/ui/shortcuts.ts writes shortcut labels for the platform: Ctrl+Shift+P on Windows and Linux, and the macOS symbols on a Mac. The catalog uses placeholders, so no translation contains "Ctrl". - 19 new catalog rows, and 10 rows converted to placeholders, in French, Japanese, and Simplified Chinese. - Docs: UI-048, the user guide keyboard tables, and a label rule in ui-design.md. New tests: layout/commands, tests/unit/ui/shortcuts.spec.ts, and new cases in workbenchKeys.spec.ts. Tests that read the old labels or pressed Ctrl+B for the side pane now use the new names and Ctrl+\. The smoke harness raises the resource timing buffer to 5000 entries. The new modules pushed the CodeMirror language module past the default 250 entries, so editor/markdownPaste could not find its URL. --- docs/design-decisions.md | 15 +++ docs/ui-design.md | 1 + docs/user-guide.md | 20 +++- src/lib/browser/Browser.svelte | 17 +-- src/lib/browser/index.ts | 3 +- src/lib/editor/DocumentEditor.svelte | 3 +- src/lib/editor/codeMenu.ts | 3 +- src/lib/editor/formatKeys.ts | 25 +++++ src/lib/editor/liveMarkdown.ts | 8 +- src/lib/editor/markdownMenu.ts | 6 +- src/lib/editor/readingMenu.ts | 3 +- src/lib/editor/tableControls.ts | 2 +- src/lib/editor/tableSelectionControls.ts | 3 +- src/lib/i18n/messages.ts | 101 +++++++++++------- src/lib/layout/BrowserWindow.svelte | 3 +- src/lib/layout/CommandPalette.svelte | 69 ++++++++++++ src/lib/layout/EditorPane.svelte | 9 +- src/lib/layout/LeftPane.svelte | 5 +- src/lib/layout/OutlinePane.svelte | 3 +- src/lib/layout/SettingsDialog.svelte | 23 +++- src/lib/layout/Workbench.svelte | 20 +++- src/lib/layout/WorkbenchHeader.svelte | 3 +- src/lib/layout/workbenchKeys.ts | 58 +++++++++- src/lib/ui/menuItems.ts | 13 +-- src/lib/ui/shortcuts.ts | 31 ++++++ tests/smoke/_harness/index.mjs | 3 +- .../appearance/backgroundImages.smoke.mjs | 5 +- .../smoke/appearance/colorThemeMenu.smoke.mjs | 2 +- .../appearance/newTabBackground.smoke.mjs | 2 +- .../appearance/tooltipsAndSelection.smoke.mjs | 2 +- tests/smoke/editor/emptyMenu.smoke.mjs | 10 +- tests/smoke/editor/markdownMenu.smoke.mjs | 8 +- tests/smoke/editor/surfaces.smoke.mjs | 4 +- .../smoke/editor/templatesAndTasks.smoke.mjs | 2 +- tests/smoke/layout/commands.smoke.mjs | 73 +++++++++++++ tests/smoke/layout/outline.smoke.mjs | 2 +- tests/smoke/settings/general.smoke.mjs | 2 +- .../smoke/tabs/lastTabAndSiteIcons.smoke.mjs | 6 +- tests/smoke/tabs/menus.smoke.mjs | 2 +- tests/smoke/tabs/order.smoke.mjs | 2 +- tests/smoke/tabs/ribbonDrop.smoke.mjs | 2 +- tests/smoke/tree/navigation.smoke.mjs | 4 +- tests/smoke/tree/renameUndo.smoke.mjs | 2 +- .../smoke/workspace/dialogDismissal.smoke.mjs | 4 +- tests/smoke/workspace/openAndCreate.smoke.mjs | 2 +- .../smoke/workspace/saveAsTemplate.smoke.mjs | 2 +- tests/unit/layout/workbenchKeys.spec.ts | 21 +++- tests/unit/ui/shortcuts.spec.ts | 22 ++++ 48 files changed, 506 insertions(+), 125 deletions(-) create mode 100644 src/lib/editor/formatKeys.ts create mode 100644 src/lib/layout/CommandPalette.svelte create mode 100644 src/lib/ui/shortcuts.ts create mode 100644 tests/smoke/layout/commands.smoke.mjs create mode 100644 tests/unit/ui/shortcuts.spec.ts diff --git a/docs/design-decisions.md b/docs/design-decisions.md index e906475..a55e432 100644 --- a/docs/design-decisions.md +++ b/docs/design-decisions.md @@ -903,3 +903,18 @@ Native shell, background image, and desktop acceptance remain open. - Evidence: `tests/smoke/appearance/themeEditor.smoke.mjs` and `tests/unit/theme/themeEditor.spec.ts`. Screenshots are in `output/phase-5a/5a-5/` in the main checkout. - Replaces / replaced by: The theme choice in the action menu rule of "Choice lists and pickers". Other short choices stay in the action menu. - Limits: The editor changes colors, not fonts. Browser checks use desktop service mocks. Native desktop acceptance remains open. + +### UI-048 — Command palette, formatting shortcuts, and platform labels + +- Type: Rule change +- Date: 2026-10-28 +- Status: Implemented for user review +- Decision source: Owner decisions 2, 7 (shortcut labels), and 10 of 2026-10-27 (interface review issues 2, 15, and 22), stage 5-2. +- Previous rule: Ctrl+B toggled the sidebar, so Writer had no Ctrl+B, Ctrl+I, or Ctrl+K. Formatting needed the context menu. Interface text wrote "Ctrl" in three styles ("Ctrl T", "Ctrl+T", "Ctrl N"). Help listed 6 shortcuts in a closed section, and no command list existed. +- New rule: In Writer, Ctrl+B, Ctrl+I, Ctrl+Shift+X, and Ctrl+Shift+H format the selection, and Ctrl+K inserts a Markdown link. The Format menu shows these shortcuts. Ctrl+\ (the physical key on every layout) toggles the sidebar. Ctrl+Shift+P opens the command palette: every workbench command with its shortcut, then the plugin commands. Help lists every shortcut in groups, open by default. `src/lib/ui/shortcuts.ts` writes each shortcut label for the platform, and the catalog uses placeholders. +- Reason: A writing app needs the common formatting keys. A shortcut that a user cannot find does not help. +- Scope: The workbench, Writer, Help, the menus, the tooltips, and the catalog. +- Shared implementation: `workbenchKeys.ts` (labels, `commandShortcut`, and the Help list), `shortcuts.ts`, `CommandPalette.svelte`, `formatKeys.ts`, and `SettingsDialog.svelte`. +- Evidence: `tests/smoke/layout/commands.smoke.mjs`, `tests/unit/ui/shortcuts.spec.ts`, and `tests/unit/layout/workbenchKeys.spec.ts`. +- Replaces / replaced by: The Ctrl+B sidebar shortcut in the user guide. +- Limits: The macOS labels are tested as unit cases, not on a Mac. Browser checks use desktop service mocks. diff --git a/docs/ui-design.md b/docs/ui-design.md index 1d39887..e780a63 100644 --- a/docs/ui-design.md +++ b/docs/ui-design.md @@ -105,6 +105,7 @@ Use one menu design for context menus, action menus, and their submenus in the h - A menu with only text choices omits the icon column. A mixed menu reserves the icon column on every row. - Shortcut text and submenu arrows use separate trailing columns. - A common text action has the same label, icon, and shortcut in every menu. Build Undo, Redo, the clipboard rows, and the search row with `menuItems.ts`. +- Write shortcut labels with `src/lib/ui/shortcuts.ts`: `keys("Mod+Shift+P")` gives Ctrl+Shift+P on Windows and Linux and ⇧⌘P on macOS. A workbench command takes its label from `commandShortcut()` in `workbenchKeys.ts`. Do not write "Ctrl" in interface text or in the catalog. Use a placeholder. - Use inset separators between related groups. - Enabled rows share one hover fill and one keyboard focus fill. - Disabled rows stay readable. Keyboard navigation skips them, and they do not run. diff --git a/docs/user-guide.md b/docs/user-guide.md index dced578..3a00254 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -42,7 +42,8 @@ To show workspace settings and plugin data in the navigator, turn on **Settings | Find a file by path | Press Ctrl+P. | | Search all files | Press Ctrl+Shift+F. | | Find in the document | Press Ctrl+F. | -| Show or hide the sidebar | Press Ctrl+B. | +| Show or hide the sidebar | Press Ctrl+\. | +| Find a command | Press Ctrl+Shift+P, type part of the command name, and press Enter. The list also shows each shortcut and the plugin commands. | | Rename | Select an item in the navigator and press F2. RuneStone selects the name without the extension. | | Move | Drag files between folders. | | Bookmark | Right-click a file and choose **Bookmark**. The Bookmarks pane lists it. | @@ -103,6 +104,14 @@ Right-click Markdown text, or press Shift+F10, to open the context menu. Use the | Menu | Actions | | --- | --- | | Format | Bold, italic, strikethrough, highlight, code, math, comment, and clear formatting | + +In Writer, these shortcuts format the selected text: + +| Format | Shortcut | +| --- | --- | +| Bold / Italic | Ctrl+B / Ctrl+I | +| Strikethrough / Highlight | Ctrl+Shift+X / Ctrl+Shift+H | +| Link (`[text]()`, with the cursor in the address) | Ctrl+K | | Paragraph | Bulleted and numbered lists, tasks, headings 1–6, body text, and quotes | | Insert | Footnotes, tables, callouts, horizontal rules, code blocks, and math blocks | @@ -200,10 +209,11 @@ To open web links from your documents in your system browser instead, turn off * ## Keyboard reference -This table lists the Windows and Linux keys. +This table lists the Windows and Linux keys. On macOS, Cmd replaces Ctrl, and RuneStone shows the macOS symbols, such as ⇧⌘P. Help lists every shortcut. | Action | Shortcut | | --- | --- | +| Find a command | Ctrl+Shift+P | | Open a workspace | Ctrl+O | | Find a file / New file | Ctrl+P / Ctrl+N | | New tab / Close tab | Ctrl+T / Ctrl+W | @@ -213,7 +223,9 @@ This table lists the Windows and Linux keys. | Find in document / Search workspace | Ctrl+F / Ctrl+Shift+F | | Switch Writer and IDE | Ctrl+E | | Nest a list item / Move it up | Tab / Shift+Tab | -| Show or hide the sidebar | Ctrl+B | +| Bold / Italic / Link (Writer) | Ctrl+B / Ctrl+I / Ctrl+K | +| Strikethrough / Highlight (Writer) | Ctrl+Shift+X / Ctrl+Shift+H | +| Show or hide the sidebar | Ctrl+\ | | Rename | F2 | | Delete to the trash / Delete permanently | Delete / Shift+Delete | | Context menu | Shift+F10 | @@ -230,6 +242,6 @@ The [Terminal guide](guides/terminal.md) lists the terminal shortcuts. ## Get help -Press F1, or select the question mark at the bottom of the sidebar, for **Help and about**. It shows the app version, basic steps, and shortcuts. +Press F1, or select the question mark at the bottom of the sidebar, for **Help and about**. It shows the app version, basic steps, and every shortcut. When you report a problem, include the app version, operating system, steps, expected result, and error text. diff --git a/src/lib/browser/Browser.svelte b/src/lib/browser/Browser.svelte index 2acecdb..2a864e1 100644 --- a/src/lib/browser/Browser.svelte +++ b/src/lib/browser/Browser.svelte @@ -1,5 +1,6 @@ + + + + { + const bounds = dialog.getBoundingClientRect(); + if (event.target === dialog && (event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom)) onClose(); +}} oncancel={onClose}> + selected = 0} aria-label={$t("Find a command")} placeholder={$t("Find a command…")} + aria-controls="command-results" aria-activedescendant={matches.length ? `command-${selected}` : undefined} onkeydown={(event) => { + if (event.key === "ArrowDown" || event.key === "ArrowUp") { + event.preventDefault(); selected = Math.max(0, Math.min(matches.length - 1, selected + (event.key === "ArrowDown" ? 1 : -1))); + dialog.querySelector(`[data-index="${selected}"]`)?.scrollIntoView({ block: "nearest" }); + } + if (event.key === "Enter") { event.preventDefault(); pick(matches[selected]); } + }} /> +
+ {#each matches as command, index (command.id)} + + {/each} + {#if !matches.length}

{$t("No matching commands.")}

{/if} +
+
{$t("{count} commands", { count: commands.length })} {$t("↑ ↓ select · Enter {action} · Esc close", { action: $t("run") })}
+
+ + diff --git a/src/lib/layout/EditorPane.svelte b/src/lib/layout/EditorPane.svelte index 04150aa..b2a9302 100644 --- a/src/lib/layout/EditorPane.svelte +++ b/src/lib/layout/EditorPane.svelte @@ -1,5 +1,6 @@