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.
This commit is contained in:
Knotty Wyvern
2026-10-28 19:10:25 -07:00
parent b2348d0fe8
commit ebacdb8164
48 changed files with 506 additions and 125 deletions
+9 -8
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import { t } from "$lib/i18n";
import { keys } from '$lib/ui/shortcuts';
import { onMount, untrack, tick } from 'svelte';
import IconButton from '$lib/ui/IconButton.svelte';
import Icon from '$lib/ui/Icon.svelte';
@@ -118,18 +119,18 @@
{ label: $t('Copy image'), icon: 'copy', run: action('copyImage') },
{ label: $t('Copy image address'), icon: 'copy', disabled: !context.srcURL, run: action('copyImageAddress') }, { separator: true });
if (context.isEditable) items.push(
{ label: $t('Undo'), icon: 'undo', shortcut: 'Ctrl+Z', disabled: !context.editFlags.canUndo, run: edit('undo') },
{ label: $t('Redo'), icon: 'redo', shortcut: 'Ctrl+Shift+Z', disabled: !context.editFlags.canRedo, run: edit('redo') }, { separator: true },
{ label: $t('Cut'), icon: 'cut', shortcut: 'Ctrl+X', disabled: !context.editFlags.canCut, run: edit('cut') });
if (context.isEditable || context.selectionText) items.push({ label: $t('Copy'), icon: 'copy', shortcut: 'Ctrl+C', disabled: !context.editFlags.canCopy, run: edit('copy') });
{ label: $t('Undo'), icon: 'undo', shortcut: keys('Mod+Z'), disabled: !context.editFlags.canUndo, run: edit('undo') },
{ label: $t('Redo'), icon: 'redo', shortcut: keys('Mod+Shift+Z'), disabled: !context.editFlags.canRedo, run: edit('redo') }, { separator: true },
{ label: $t('Cut'), icon: 'cut', shortcut: keys('Mod+X'), disabled: !context.editFlags.canCut, run: edit('cut') });
if (context.isEditable || context.selectionText) items.push({ label: $t('Copy'), icon: 'copy', shortcut: keys('Mod+C'), disabled: !context.editFlags.canCopy, run: edit('copy') });
if (context.isEditable) items.push(
{ label: $t('Paste'), icon: 'paste', shortcut: 'Ctrl+V', disabled: !context.editFlags.canPaste, run: edit('paste') },
{ label: $t('Paste as plain text'), icon: 'paste-text', shortcut: 'Ctrl+Shift+V', disabled: !context.editFlags.canPaste, run: edit('pasteAndMatchStyle') },
{ label: $t('Select all'), icon: 'task', shortcut: 'Ctrl+A', run: edit('selectAll') }, { separator: true });
{ label: $t('Paste'), icon: 'paste', shortcut: keys('Mod+V'), disabled: !context.editFlags.canPaste, run: edit('paste') },
{ label: $t('Paste as plain text'), icon: 'paste-text', shortcut: keys('Mod+Shift+V'), disabled: !context.editFlags.canPaste, run: edit('pasteAndMatchStyle') },
{ label: $t('Select all'), icon: 'task', shortcut: keys('Mod+A'), run: edit('selectAll') }, { separator: true });
items.push({ label: $t('Back'), icon: 'arrow-left', disabled: !current?.canBack, run: () => void send('back') },
{ label: $t('Forward'), icon: 'arrow-right', disabled: !current?.canForward, run: () => void send('forward') },
{ label: $t('Reload'), icon: 'refresh', run: () => void send('reload') },
{ label: $t('Find in page'), icon: 'search', shortcut: 'Ctrl+F', run: () => void find() });
{ label: $t('Find in page'), icon: 'search', shortcut: keys('Mod+F'), run: () => void find() });
const rect = surface.getBoundingClientRect();
const menu = showActionMenu({ x: rect.left + imageBox.x + context.x, y: rect.top + imageBox.y + context.y,
items, label: $t('Browser page actions') });
+2 -1
View File
@@ -1,4 +1,5 @@
import { tr } from "../i18n/index.ts";
import { keys } from '../ui/shortcuts.ts';
import { mount, unmount } from 'svelte';
import { get } from 'svelte/store';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
@@ -65,7 +66,7 @@ export async function activate(api: PluginApi) {
{ label: tr("Split right"), icon: 'split-right', disabled: !ready, run: () => split('right') },
{ label: tr("Split down"), icon: 'split-down', disabled: !ready, run: () => split('down') },
{ separator: true },
{ label: tr("Find…"), icon: 'search', shortcut: 'Ctrl+F', disabled: !ready, run: () => { api.openView(id); void saved.control?.find(); } },
{ label: tr("Find…"), icon: 'search', shortcut: keys('Mod+F'), disabled: !ready, run: () => { api.openView(id); void saved.control?.find(); } },
{ label: tr("Open in default browser"), icon: 'external', disabled: !web, run: () => run('openExternal') },
{ label: tr("Bookmark"), icon: 'bookmark', disabled: !web, run: () => run('bookmark') },
];