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:
@@ -2,7 +2,7 @@
|
||||
import { t } from "$lib/i18n";
|
||||
import TerminalSlot from "$lib/plugins/TerminalSlot.svelte";
|
||||
import type PluginEditor from "$lib/plugins/PluginEditor.svelte";
|
||||
import { pluginSplits, pinPluginEditor, pluginTabActions, pluginTabState, restorePluginTab, pluginTabDragData, dropPluginTab, waitForPluginStartup } from "$lib/plugins/external";
|
||||
import { pluginSplits, pinPluginEditor, pluginTabActions, pluginTabState, restorePluginTab, pluginTabDragData, dropPluginTab, waitForPluginStartup, pluginTools, installedPlugins, runPluginCommand } from "$lib/plugins/external";
|
||||
import { containsPane, paneBounds } from "$lib/workspace/splitLayout";
|
||||
import { pluginSidebar, closePluginSidebar, pluginNavigation, openPluginView, pluginView, pluginEditors, pluginEditorActive, selectPluginEditor, closePluginEditor, openPluginDocument, renamePluginDocuments, removePluginDocuments, notifyPluginWorkspace, guardPluginWrites, handlePluginFileOpen, handlePluginDocumentRename, cancelPluginDocumentOpen, type OpenPluginView } from "$lib/plugins/external";
|
||||
import { onMount, onDestroy, tick, untrack } from "svelte";
|
||||
@@ -26,6 +26,7 @@
|
||||
import { requestText } from "$lib/workspace/dialogs.svelte";
|
||||
import TextDialog from "./TextDialog.svelte";
|
||||
import QuickOpen from "./QuickOpen.svelte";
|
||||
import CommandPalette, { type PaletteCommand } from "./CommandPalette.svelte";
|
||||
import TemplateManager from "./TemplateManager.svelte";
|
||||
import WorkspacePicker from "./WorkspacePicker.svelte";
|
||||
import SettingsDialog from "./SettingsDialog.svelte";
|
||||
@@ -35,7 +36,7 @@
|
||||
import { TAB_TRANSFER_ID, cancelTabTransfer, finishTabTransfer, offerTabTransfer, onTabTransferAccepted, parseTabTransfer, takeTabTransfer } from "$lib/workspace/tabTransfer";
|
||||
import { DEFAULT_WORKBENCH_LAYOUT, WORKBENCH_LAYOUT_KEY, parseWorkbenchLayout, saveWorkbenchLayout, type WorkbenchLayout } from "$lib/workspace/workbenchLayout";
|
||||
import type FileTree from "./FileTree.svelte";
|
||||
import { preferenceKeys, workbenchCommand, type WorkbenchCommand } from "./workbenchKeys";
|
||||
import { COMMAND_LABELS, commandShortcut, preferenceKeys, workbenchCommand, type WorkbenchCommand } from "./workbenchKeys";
|
||||
import type EditorPane from "./EditorPane.svelte";
|
||||
import WorkbenchHeader from "./WorkbenchHeader.svelte";
|
||||
import PluginRibbon from "./PluginRibbon.svelte";
|
||||
@@ -147,6 +148,19 @@
|
||||
let documentPanes = $state(initialDocumentPanes());
|
||||
const reading = $derived(documentPanes.panes.find(pane => pane.id === documentPanes.active)?.reading ?? false);
|
||||
let quickOpen = $state(false);
|
||||
let palette = $state(false);
|
||||
/** The commands of the palette: the app commands that apply here, then the plugin commands. */
|
||||
function paletteCommands(): PaletteCommand[] {
|
||||
const hidden = new Set<WorkbenchCommand>(["command-palette", ...(terminalEnabled ? [] : ["toggle-terminal" as const]), ...(workspace ? [] : ["quick-open" as const])]);
|
||||
const app = (Object.keys(COMMAND_LABELS) as WorkbenchCommand[]).filter(command => !hidden.has(command)).map(command => ({
|
||||
id: command, label: $t(COMMAND_LABELS[command]), shortcut: commandShortcut(command) || undefined, run: () => { runCommand(command); },
|
||||
}));
|
||||
const plugins = $pluginTools.filter(tool => tool.kind === "command" && tool.surface === "commands").map(tool => ({
|
||||
id: `plugin:${tool.owner}:${tool.id}`, label: tool.title, detail: $installedPlugins.plugins.find(row => row.manifest.id === tool.owner)?.manifest.name ?? tool.owner,
|
||||
run: () => { void runPluginCommand(tool.owner, tool.id).catch(reason => error = String(reason)); },
|
||||
}));
|
||||
return [...app, ...plugins];
|
||||
}
|
||||
let templateManager = $state(false);
|
||||
let terminalStarted = $state(false);
|
||||
let terminalMaximized = $state(false);
|
||||
@@ -858,6 +872,7 @@
|
||||
selectWorkingTab(workingTabs[next].relPath);
|
||||
return true;
|
||||
}
|
||||
case "command-palette": palette = true; return true;
|
||||
case "settings": void openSettings(); return true;
|
||||
case "help": preferences = "help"; return true;
|
||||
case "quick-open": if (workspace) quickOpen = true; return true;
|
||||
@@ -1162,6 +1177,7 @@
|
||||
<WorkspacePicker bind:this={workspacePicker} currentRoot={workspace?.root} anchor={workspaceAnchor} onOpen={openPath} />
|
||||
{#if preferences}<SettingsDialog {settings} help={preferences === "help"} onSave={updateSettings} onClose={() => preferences = null} />{/if}
|
||||
{#if quickOpen && workspace}<QuickOpen onOpen={(entry) => void openFile(entry)} onClose={() => quickOpen = false} />{/if}
|
||||
{#if palette}<CommandPalette commands={paletteCommands()} onClose={() => palette = false} />{/if}
|
||||
{#if templateManager && workspace}<TemplateManager {session} onClose={() => templateManager = false}
|
||||
onEdit={(entry) => { templateManager = false; void openFile(entry, undefined, "new"); }} />{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user