AI-native design editor. Open-source Figma alternative.
feat: add searchable command palette
Danila Poyarkov0e9c0ee6cf92
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dc2e8a48b..525ae4667 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,7 @@### Added+- Add a searchable command palette for editor and application actions.- Render triangle and line arrow stroke caps on lines and open vector paths, and choose them from the stroke cap picker.- Add a timestamp-faithful pan and zoom benchmark workflow with physical macOS trackpad recording, CDP and DOM replay, Chromium traces, frame-pacing and latency distributions, zoom-anchor drift and viewport-jump detection, retained-backing settlement metrics, and a documented native Instruments acceptance procedure.diff --git a/bun.lock b/bun.lockindex 0c00a1593..03c0db754 100644--- a/bun.lock+++ b/bun.lock@@ -352,6 +352,7 @@"@open-pencil/scene-graph": "workspace:*","@tanstack/vue-table": "^8.21.3","@vueuse/core": "^14.4.0",+ "fuse.js": "^7.5.0","nanostores": "^1.5.0","reka-ui": "^2.10.3",},@@ -2759,6 +2760,8 @@"functions-have-names": ["[email protected]", "", {}, "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ=="],+ "fuse.js": ["[email protected]", "", {}, "sha512-sQtrEfA+ez/3G0cCZecF70oqpCRttCexYUG4mUrtWL49ULUzUyxokt5kyqwtKzj1270RaKih+hcP3qLcumccow=="],+"fzstd": ["[email protected]", "", {}, "sha512-dkuVSOKKwh3eas5VkJy1AW1vFpet8TA/fGmVA5krThl8YcOVE/8ZIoEA1+U1vEn5ckxxhLirSdY837azmbaNHA=="],"gaxios": ["[email protected]", "", { "dependencies": { "extend": "^3.0.2", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2" } }, "sha512-kB3rzJV7d9juLZh8/56QTXCwQfxyhdOMdyYk1HdQKFtF8TJTDTZQJtixWIwXdE9Jji91mC41DUNpjleo4L4eAQ=="],diff --git a/packages/vue/package.json b/packages/vue/package.jsonindex a10ebe115..86f45be72 100644--- a/packages/vue/package.json+++ b/packages/vue/package.json@@ -48,6 +48,7 @@"@open-pencil/scene-graph": "workspace:*","@tanstack/vue-table": "^8.21.3","@vueuse/core": "^14.4.0",+ "fuse.js": "^7.5.0","nanostores": "^1.5.0","reka-ui": "^2.10.3"},diff --git a/packages/vue/src/editor/menu-model/types.ts b/packages/vue/src/editor/menu-model/types.tsindex ce2fdc294..1c2443a71 100644--- a/packages/vue/src/editor/menu-model/types.ts+++ b/packages/vue/src/editor/menu-model/types.ts@@ -5,15 +5,23 @@ import type { TestId } from '#vue/testing/test-id'export interface MenuActionNode {separator?: false+ menuId?: stringid?: EditorCommandIdlabel: stringicon?: Componentshortcut?: string+ paletteShortcut?: stringaction?: () => voiddisabled?: booleantestId?: TestIdchecked?: booleanonCheckedChange?: (checked: boolean) => void+ palette?: {+ icon?: Component+ label?: string+ description?: string+ keywords?: string[]+ }sub?: MenuEntry[]}diff --git a/packages/vue/src/i18n/locales/de/commands.json b/packages/vue/src/i18n/locales/de/commands.jsonindex 46a340669..4ca8bb997 100644--- a/packages/vue/src/i18n/locales/de/commands.json+++ b/packages/vue/src/i18n/locales/de/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "Horizontalen Abstand verteilen","distributeVertical": "Vertikalen Abstand verteilen","selectInverse": "Auswahl umkehren",- "sendBackward": "Nach hinten"+ "sendBackward": "Nach hinten",+ "paletteSearchPlaceholder": "Befehl eingeben oder suchen…",+ "paletteAriaLabel": "Befehlspalette",+ "paletteSearchAriaLabel": "Befehle suchen",+ "paletteDescription": "OpenPencil-Befehle suchen und ausführen.",+ "paletteNoCommands": "Keine Befehle gefunden.",+ "paletteBack": "Zurück"}diff --git a/packages/vue/src/i18n/locales/de/menu.json b/packages/vue/src/i18n/locales/de/menu.jsonindex 33f85a8fb..32e0690ce 100644--- a/packages/vue/src/i18n/locales/de/menu.json+++ b/packages/vue/src/i18n/locales/de/menu.json@@ -66,5 +66,9 @@"splitRight": "Nach rechts teilen","splitDown": "Nach unten teilen","closeView": "Ansicht schließen",- "removeGuide": "Hilfslinie entfernen"+ "removeGuide": "Hilfslinie entfernen",+ "exportSelectionAsPNG": "Auswahl als PNG exportieren",+ "exportSelectionAsSVG": "Auswahl als SVG exportieren",+ "exportSelectionAsPPTX": "Auswahl als PPTX exportieren",+ "exportSelectionAsFig": "Auswahl als .fig exportieren"}diff --git a/packages/vue/src/i18n/locales/es/commands.json b/packages/vue/src/i18n/locales/es/commands.jsonindex dd8d83aa8..6e04f0938 100644--- a/packages/vue/src/i18n/locales/es/commands.json+++ b/packages/vue/src/i18n/locales/es/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "Distribuir espacio horizontal","distributeVertical": "Distribuir espacio vertical","selectInverse": "Invertir selección",- "sendBackward": "Atrasar"+ "sendBackward": "Atrasar",+ "paletteSearchPlaceholder": "Escribe un comando o busca…",+ "paletteAriaLabel": "Paleta de comandos",+ "paletteSearchAriaLabel": "Buscar comandos",+ "paletteDescription": "Busca y ejecuta comandos de OpenPencil.",+ "paletteNoCommands": "No se encontraron comandos.",+ "paletteBack": "Atrás"}diff --git a/packages/vue/src/i18n/locales/es/menu.json b/packages/vue/src/i18n/locales/es/menu.jsonindex 2144fb406..d93958c71 100644--- a/packages/vue/src/i18n/locales/es/menu.json+++ b/packages/vue/src/i18n/locales/es/menu.json@@ -66,5 +66,9 @@"splitRight": "Dividir a la derecha","splitDown": "Dividir hacia abajo","closeView": "Cerrar vista",- "removeGuide": "Eliminar guía"+ "removeGuide": "Eliminar guía",+ "exportSelectionAsPNG": "Exportar selección como PNG",+ "exportSelectionAsSVG": "Exportar selección como SVG",+ "exportSelectionAsPPTX": "Exportar selección como PPTX",+ "exportSelectionAsFig": "Exportar selección como .fig"}diff --git a/packages/vue/src/i18n/locales/fr/commands.json b/packages/vue/src/i18n/locales/fr/commands.jsonindex 3d8dbc893..0ffe13fa4 100644--- a/packages/vue/src/i18n/locales/fr/commands.json+++ b/packages/vue/src/i18n/locales/fr/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "Répartir l’espacement horizontal","distributeVertical": "Répartir l’espacement vertical","selectInverse": "Inverser la sélection",- "sendBackward": "Reculer"+ "sendBackward": "Reculer",+ "paletteSearchPlaceholder": "Saisissez une commande ou recherchez…",+ "paletteAriaLabel": "Palette de commandes",+ "paletteSearchAriaLabel": "Rechercher des commandes",+ "paletteDescription": "Rechercher et exécuter des commandes OpenPencil.",+ "paletteNoCommands": "Aucune commande trouvée.",+ "paletteBack": "Retour"}diff --git a/packages/vue/src/i18n/locales/fr/menu.json b/packages/vue/src/i18n/locales/fr/menu.jsonindex 8c03ee191..6682b71e0 100644--- a/packages/vue/src/i18n/locales/fr/menu.json+++ b/packages/vue/src/i18n/locales/fr/menu.json@@ -66,5 +66,9 @@"splitRight": "Diviser à droite","splitDown": "Diviser vers le bas","closeView": "Fermer la vue",- "removeGuide": "Supprimer le repère"+ "removeGuide": "Supprimer le repère",+ "exportSelectionAsPNG": "Exporter la sélection en PNG",+ "exportSelectionAsSVG": "Exporter la sélection en SVG",+ "exportSelectionAsPPTX": "Exporter la sélection en PPTX",+ "exportSelectionAsFig": "Exporter la sélection en .fig"}diff --git a/packages/vue/src/i18n/locales/it/commands.json b/packages/vue/src/i18n/locales/it/commands.jsonindex b68a1e1ca..2a8f305a4 100644--- a/packages/vue/src/i18n/locales/it/commands.json+++ b/packages/vue/src/i18n/locales/it/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "Distribuisci spaziatura orizzontale","distributeVertical": "Distribuisci spaziatura verticale","selectInverse": "Inverti selezione",- "sendBackward": "Porta indietro"+ "sendBackward": "Porta indietro",+ "paletteSearchPlaceholder": "Digita un comando o cerca…",+ "paletteAriaLabel": "Tavolozza dei comandi",+ "paletteSearchAriaLabel": "Cerca comandi",+ "paletteDescription": "Cerca ed esegui i comandi di OpenPencil.",+ "paletteNoCommands": "Nessun comando trovato.",+ "paletteBack": "Indietro"}diff --git a/packages/vue/src/i18n/locales/it/menu.json b/packages/vue/src/i18n/locales/it/menu.jsonindex de9374e95..7b0ae4b22 100644--- a/packages/vue/src/i18n/locales/it/menu.json+++ b/packages/vue/src/i18n/locales/it/menu.json@@ -66,5 +66,9 @@"splitRight": "Dividi a destra","splitDown": "Dividi in basso","closeView": "Chiudi vista",- "removeGuide": "Rimuovi guida"+ "removeGuide": "Rimuovi guida",+ "exportSelectionAsPNG": "Esporta selezione come PNG",+ "exportSelectionAsSVG": "Esporta selezione come SVG",+ "exportSelectionAsPPTX": "Esporta selezione come PPTX",+ "exportSelectionAsFig": "Esporta selezione come .fig"}diff --git a/packages/vue/src/i18n/locales/ja/commands.json b/packages/vue/src/i18n/locales/ja/commands.jsonindex 3473d4e53..fe3f58c18 100644--- a/packages/vue/src/i18n/locales/ja/commands.json+++ b/packages/vue/src/i18n/locales/ja/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "水平方向の間隔を均等に配置","distributeVertical": "垂直方向の間隔を均等に配置","selectInverse": "選択範囲を反転",- "sendBackward": "背面へ移動"+ "sendBackward": "背面へ移動",+ "paletteSearchPlaceholder": "コマンドを入力または検索…",+ "paletteAriaLabel": "コマンドパレット",+ "paletteSearchAriaLabel": "コマンドを検索",+ "paletteDescription": "OpenPencil のコマンドを検索して実行します。",+ "paletteNoCommands": "コマンドが見つかりません。",+ "paletteBack": "戻る"}diff --git a/packages/vue/src/i18n/locales/ja/menu.json b/packages/vue/src/i18n/locales/ja/menu.jsonindex 01e1eeaad..89e716d65 100644--- a/packages/vue/src/i18n/locales/ja/menu.json+++ b/packages/vue/src/i18n/locales/ja/menu.json@@ -66,5 +66,9 @@"splitRight": "右に分割","splitDown": "下に分割","closeView": "ビューを閉じる",- "removeGuide": "ガイドを削除"+ "removeGuide": "ガイドを削除",+ "exportSelectionAsPNG": "選択範囲を PNG としてエクスポート",+ "exportSelectionAsSVG": "選択範囲を SVG としてエクスポート",+ "exportSelectionAsPPTX": "選択範囲を PPTX としてエクスポート",+ "exportSelectionAsFig": "選択範囲を .fig としてエクスポート"}diff --git a/packages/vue/src/i18n/locales/pl/commands.json b/packages/vue/src/i18n/locales/pl/commands.jsonindex 36ba64e4c..8b9be67bd 100644--- a/packages/vue/src/i18n/locales/pl/commands.json+++ b/packages/vue/src/i18n/locales/pl/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "Rozłóż odstępy w poziomie","distributeVertical": "Rozłóż odstępy w pionie","selectInverse": "Odwróć zaznaczenie",- "sendBackward": "Przesuń do tyłu"+ "sendBackward": "Przesuń do tyłu",+ "paletteSearchPlaceholder": "Wpisz polecenie lub wyszukaj…",+ "paletteAriaLabel": "Paleta poleceń",+ "paletteSearchAriaLabel": "Szukaj poleceń",+ "paletteDescription": "Wyszukuj i uruchamiaj polecenia OpenPencil.",+ "paletteNoCommands": "Nie znaleziono poleceń.",+ "paletteBack": "Wstecz"}diff --git a/packages/vue/src/i18n/locales/pl/menu.json b/packages/vue/src/i18n/locales/pl/menu.jsonindex fba1bad43..12250fd22 100644--- a/packages/vue/src/i18n/locales/pl/menu.json+++ b/packages/vue/src/i18n/locales/pl/menu.json@@ -66,5 +66,9 @@"splitRight": "Podziel w prawo","splitDown": "Podziel w dół","closeView": "Zamknij widok",- "removeGuide": "Usuń prowadnicę"+ "removeGuide": "Usuń prowadnicę",+ "exportSelectionAsPNG": "Eksportuj zaznaczenie jako PNG",+ "exportSelectionAsSVG": "Eksportuj zaznaczenie jako SVG",+ "exportSelectionAsPPTX": "Eksportuj zaznaczenie jako PPTX",+ "exportSelectionAsFig": "Eksportuj zaznaczenie jako .fig"}diff --git a/packages/vue/src/i18n/locales/ru/commands.json b/packages/vue/src/i18n/locales/ru/commands.jsonindex 8ab4a223f..db6dc341b 100644--- a/packages/vue/src/i18n/locales/ru/commands.json+++ b/packages/vue/src/i18n/locales/ru/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "Распределить интервалы по горизонтали","distributeVertical": "Распределить интервалы по вертикали","selectInverse": "Инвертировать выделение",- "sendBackward": "Переместить назад"+ "sendBackward": "Переместить назад",+ "paletteSearchPlaceholder": "Введите команду или выполните поиск…",+ "paletteAriaLabel": "Палитра команд",+ "paletteSearchAriaLabel": "Поиск команд",+ "paletteDescription": "Поиск и выполнение команд OpenPencil.",+ "paletteNoCommands": "Команды не найдены.",+ "paletteBack": "Назад"}diff --git a/packages/vue/src/i18n/locales/ru/menu.json b/packages/vue/src/i18n/locales/ru/menu.jsonindex 4e1a6c8a4..649d63347 100644--- a/packages/vue/src/i18n/locales/ru/menu.json+++ b/packages/vue/src/i18n/locales/ru/menu.json@@ -66,5 +66,9 @@"splitRight": "Разделить вправо","splitDown": "Разделить вниз","closeView": "Закрыть вид",- "removeGuide": "Удалить направляющую"+ "removeGuide": "Удалить направляющую",+ "exportSelectionAsPNG": "Экспортировать выделение как PNG",+ "exportSelectionAsSVG": "Экспортировать выделение как SVG",+ "exportSelectionAsPPTX": "Экспортировать выделение как PPTX",+ "exportSelectionAsFig": "Экспортировать выделение как .fig"}diff --git a/packages/vue/src/i18n/locales/zh-cn/commands.json b/packages/vue/src/i18n/locales/zh-cn/commands.jsonindex 11c8561da..7c3713e7b 100644--- a/packages/vue/src/i18n/locales/zh-cn/commands.json+++ b/packages/vue/src/i18n/locales/zh-cn/commands.json@@ -39,5 +39,11 @@"distributeHorizontal": "水平等距分布","distributeVertical": "垂直等距分布","selectInverse": "反向选择",- "sendBackward": "下移一层"+ "sendBackward": "下移一层",+ "paletteSearchPlaceholder": "输入命令或搜索…",+ "paletteAriaLabel": "命令面板",+ "paletteSearchAriaLabel": "搜索命令",+ "paletteDescription": "搜索并运行 OpenPencil 命令。",+ "paletteNoCommands": "未找到命令。",+ "paletteBack": "返回"}diff --git a/packages/vue/src/i18n/locales/zh-cn/menu.json b/packages/vue/src/i18n/locales/zh-cn/menu.jsonindex 615a73bb6..4c2ae4a71 100644--- a/packages/vue/src/i18n/locales/zh-cn/menu.json+++ b/packages/vue/src/i18n/locales/zh-cn/menu.json@@ -66,5 +66,9 @@"splitRight": "向右拆分","splitDown": "向下拆分","closeView": "关闭视图",- "removeGuide": "移除参考线"+ "removeGuide": "移除参考线",+ "exportSelectionAsPNG": "将所选内容导出为 PNG",+ "exportSelectionAsSVG": "将所选内容导出为 SVG",+ "exportSelectionAsPPTX": "将所选内容导出为 PPTX",+ "exportSelectionAsFig": "将所选内容导出为 .fig"}diff --git a/packages/vue/src/i18n/messages/commands.ts b/packages/vue/src/i18n/messages/commands.tsindex 8d28dabd2..60f4a1e46 100644--- a/packages/vue/src/i18n/messages/commands.ts+++ b/packages/vue/src/i18n/messages/commands.ts@@ -41,7 +41,13 @@ export const commandMessageDefaults = {setOpacity: 'Set opacity',zoomTo100: 'Zoom to 100%',zoomToFit: 'Zoom to fit',- zoomToSelection: 'Zoom to selection'+ zoomToSelection: 'Zoom to selection',+ paletteSearchPlaceholder: 'Type a command or search…',+ paletteAriaLabel: 'Command palette',+ paletteSearchAriaLabel: 'Search commands',+ paletteDescription: 'Search and run OpenPencil commands.',+ paletteNoCommands: 'No commands found.',+ paletteBack: 'Back'} as constexport const commandMessages = i18n('commands', commandMessageDefaults)diff --git a/packages/vue/src/i18n/messages/menu.ts b/packages/vue/src/i18n/messages/menu.tsindex c298e8de3..dcfc91e80 100644--- a/packages/vue/src/i18n/messages/menu.ts+++ b/packages/vue/src/i18n/messages/menu.ts@@ -14,6 +14,10 @@ export const menuMessageDefaults = {save: 'Save',saveAs: 'Save as…',exportSelection: 'Export selection…',+ exportSelectionAsPNG: 'Export selection as PNG',+ exportSelectionAsSVG: 'Export selection as SVG',+ exportSelectionAsPPTX: 'Export selection as PPTX',+ exportSelectionAsFig: 'Export selection as .fig',autosave: 'Auto-save to local file',closeTab: 'Close tab',diff --git a/packages/vue/src/index.ts b/packages/vue/src/index.tsindex 3d973ca1d..cd37d107f 100644--- a/packages/vue/src/index.ts+++ b/packages/vue/src/index.ts@@ -34,7 +34,17 @@ export { useSelectionState } from '#vue/editor/selection-state/use'export { useEditorEvent } from '#vue/editor/events/use'export { useSelectionCapabilities } from '#vue/editor/selection-capabilities/use'-/** Command and menu composition helpers. */+/** Command palette primitives and search state. */+export { CommandPaletteRoot } from '#vue/primitives/CommandPalette'+export type {+ CommandPaletteGroup,+ CommandPaletteItem,+ CommandPaletteShortcut,+ CommandPaletteLabels,+ CommandPaletteUI,+ UseCommandPaletteOptions+} from '#vue/primitives/CommandPalette'+export { useEditorCommands } from '#vue/editor/commands/use'export { EDITOR_COMMAND_METADATA, editorCommandMetadata } from '#vue/editor/commands/registry'export { formatShortcut, shortcutPlatform } from '#vue/editor/commands/shortcut'diff --git a/packages/vue/src/primitives/CommandPalette/CommandPalette.stories.ts b/packages/vue/src/primitives/CommandPalette/CommandPalette.stories.tsnew file mode 100644index 000000000..df31353d1--- /dev/null+++ b/packages/vue/src/primitives/CommandPalette/CommandPalette.stories.ts@@ -0,0 +1,46 @@+import type { Meta, StoryObj } from '@storybook/vue3-vite'+import { expect, userEvent, within } from 'storybook/test'++import CommandPaletteDemo from './CommandPaletteDemo.vue'++const meta = {+ title: 'Vue SDK/Primitives/Command Palette',+ component: CommandPaletteDemo,+ tags: ['autodocs'],+ parameters: {+ docs: {+ description: {+ component: 'Headless searchable command list built on Reka UI Listbox primitives.'+ }+ }+ }+} satisfies Meta<typeof CommandPaletteDemo>++export default meta+type Story = StoryObj<typeof meta>++export const Default: Story = {}++export const Interaction: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement)+ const input = canvas.getByRole('searchbox', { name: 'Search commands' })++ await userEvent.click(input)+ await userEvent.type(input, 'setting')+ await expect(canvas.getByRole('option', { name: /Settings/ })).toBeVisible()+ await expect(canvas.queryByRole('option', { name: 'Undo' })).not.toBeInTheDocument()++ await userEvent.click(canvas.getByRole('option', { name: /Settings/ }))+ await expect(canvas.getByRole('status', { name: 'Last selection' })).toHaveTextContent(+ 'Settings'+ )++ await userEvent.clear(input)+ await userEvent.click(canvas.getByRole('option', { name: 'Export selection' }))+ await expect(canvas.getByText('Export selection as PNG')).toBeVisible()+ await userEvent.click(input)+ await userEvent.keyboard('{Backspace}')+ await expect(canvas.getByRole('option', { name: 'Export selection' })).toBeVisible()+ }+}diff --git a/packages/vue/src/primitives/CommandPalette/CommandPaletteDemo.vue b/packages/vue/src/primitives/CommandPalette/CommandPaletteDemo.vuenew file mode 100644index 000000000..419eb0323--- /dev/null+++ b/packages/vue/src/primitives/CommandPalette/CommandPaletteDemo.vue@@ -0,0 +1,64 @@+<script setup lang="ts">+import { ref } from 'vue'++import CommandPaletteRoot from './CommandPaletteRoot.vue'+import type { CommandPaletteGroup } from './types'++const selected = ref('')+const selectedLabels = ref<string[]>([])+const labels = {+ searchPlaceholder: 'Search commands…',+ searchLabel: 'Search commands',+ paletteLabel: 'Command palette',+ empty: 'No commands found.',+ back: 'Back'+}+const groups: CommandPaletteGroup[] = [+ {+ id: 'file',+ label: 'File',+ items: [+ { id: 'new', label: 'New document', shortcut: { keys: ['⌘', 'N'] } },+ { id: 'settings', label: 'Settings', shortcut: { keys: ['⌘', ','] } },+ {+ id: 'export',+ label: 'Export selection',+ children: [+ { id: 'export-png', label: 'Export selection as PNG' },+ { id: 'export-svg', label: 'Export selection as SVG' }+ ]+ }+ ]+ },+ {+ id: 'edit',+ label: 'Edit',+ items: [{ id: 'undo', label: 'Undo', shortcut: { keys: ['⌘', 'Z'] } }]+ }+]+</script>++<template>+ <div class="space-y-2">+ <CommandPaletteRoot+ v-model="selected"+ :groups="groups"+ :labels="labels"+ :ui="{+ root: 'w-[min(40rem,100%)] overflow-hidden rounded-xl border border-border bg-panel text-surface shadow-xl',+ search: 'h-12 w-full border-b border-border bg-transparent px-4 text-sm outline-none',+ content: 'max-h-96 overflow-y-auto p-2',+ label: 'px-2 py-1 text-[11px] text-muted',+ item: 'flex h-8 cursor-pointer items-center gap-2 rounded-md p-1 text-[13px] data-[highlighted]:bg-hover',+ itemIcon: 'flex size-6 shrink-0 items-center justify-center text-muted',+ itemLabel: 'min-w-0 flex-1 truncate',+ shortcut: 'flex items-center gap-1 text-xs text-muted',+ key: 'rounded border border-border bg-input px-1.5 py-1 font-mono leading-none'+ }"+ @select="selectedLabels.push($event.label)"+ />+ <div v-if="selectedLabels.length" role="status" aria-label="Last selection">+ {{ selectedLabels.at(-1) }}+ </div>+ </div>+</template>diff --git a/packages/vue/src/primitives/CommandPalette/CommandPaletteRoot.vue b/packages/vue/src/primitives/CommandPalette/CommandPaletteRoot.vuenew file mode 100644index 000000000..40059e8aa--- /dev/null+++ b/packages/vue/src/primitives/CommandPalette/CommandPaletteRoot.vue@@ -0,0 +1,110 @@+<script setup lang="ts">+import { provide, toRef } from 'vue'+import {+ ListboxContent,+ ListboxFilter,+ ListboxGroup,+ ListboxGroupLabel,+ ListboxItem,+ ListboxRoot+} from 'reka-ui'++import { COMMAND_PALETTE_KEY } from './context'+import { useCommandPalette } from './useCommandPalette'+import type {+ CommandPaletteGroup,+ CommandPaletteItem,+ CommandPaletteLabels,+ CommandPaletteUI+} from './types'++const {+ groups,+ labels,+ ui,+ placeholder,+ resultLimit = 12+} = defineProps<{+ groups: CommandPaletteGroup[]+ labels: CommandPaletteLabels+ ui?: CommandPaletteUI+ placeholder?: string+ resultLimit?: number+}>()++const emit = defineEmits<{ select: [item: CommandPaletteItem] }>()+const palette = useCommandPalette(() => ({ groups, resultLimit }))++provide(COMMAND_PALETTE_KEY, {+ groups: toRef(() => groups),+ searchTerm: palette.searchTerm,+ isNested: palette.isNested,+ labels: toRef(() => labels),+ ui: toRef(() => ui),+ navigate: palette.navigate,+ navigateBack: palette.navigateBack,+ select: palette.select+})++function select(item: CommandPaletteItem) {+ palette.select(item)+ emit('select', item)+}+</script>++<template>+ <ListboxRoot+ v-model="palette.selectedId.value"+ :class="ui?.root"+ :aria-label="labels.paletteLabel"+ :data-searching="palette.searchTerm.value ? '' : undefined"+ >+ <div v-if="palette.isNested.value" :class="ui?.back">+ <button type="button" @click="palette.navigateBack()">{{ labels.back }}</button>+ </div>+ <div :class="ui?.searchWrapper">+ <slot name="search-leading" />+ <ListboxFilter v-model="palette.searchTerm.value" as-child>+ <input+ type="search"+ :value="palette.searchTerm.value"+ :placeholder="placeholder ?? labels.searchPlaceholder"+ :aria-label="labels.searchLabel"+ :class="ui?.search"+ autocomplete="off"+ @keydown.backspace="palette.searchTerm.value || palette.navigateBack()"+ />+ </ListboxFilter>+ <slot name="search-trailing" />+ </div>+ <ListboxContent :class="ui?.content">+ <template v-if="palette.filteredGroups.value.length">+ <ListboxGroup+ v-for="group in palette.filteredGroups.value"+ :key="group.id"+ :class="ui?.group"+ >+ <ListboxGroupLabel v-if="group.label" :class="ui?.label">{{+ group.label+ }}</ListboxGroupLabel>+ <ListboxItem+ v-for="item in group.items"+ :key="item.id"+ :value="item.id"+ :disabled="item.disabled"+ :class="ui?.item"+ @select="select(item)"+ >+ <span :class="ui?.itemIcon"><slot name="item-icon" :item="item" /></span>+ <span :class="ui?.itemLabel">{{ item.label }}</span>+ <span v-if="item.description" :class="ui?.itemDescription">{{ item.description }}</span>+ <span v-if="item.shortcut" :class="ui?.shortcut">+ <kbd v-for="key in item.shortcut.keys" :key="key" :class="ui?.key">{{ key }}</kbd>+ </span>+ </ListboxItem>+ </ListboxGroup>+ </template>+ <slot v-else name="empty" :search-term="palette.searchTerm.value">{{ labels.empty }}</slot>+ </ListboxContent>+ </ListboxRoot>+</template>diff --git a/packages/vue/src/primitives/CommandPalette/context.ts b/packages/vue/src/primitives/CommandPalette/context.tsnew file mode 100644index 000000000..a0a55d53c--- /dev/null+++ b/packages/vue/src/primitives/CommandPalette/context.ts@@ -0,0 +1,21 @@+import type { InjectionKey, Ref } from 'vue'++import type {+ CommandPaletteGroup,+ CommandPaletteItem,+ CommandPaletteLabels,+ CommandPaletteUI+} from './types'++export interface CommandPaletteContext {+ groups: Ref<CommandPaletteGroup[]>+ searchTerm: Ref<string>+ isNested: Ref<boolean>+ labels: Ref<CommandPaletteLabels>+ ui: Ref<CommandPaletteUI | undefined>+ navigate: (item: CommandPaletteItem) => boolean+ navigateBack: () => boolean+ select: (item: CommandPaletteItem) => void+}++export const COMMAND_PALETTE_KEY: InjectionKey<CommandPaletteContext> = Symbol('command-palette')diff --git a/packages/vue/src/primitives/CommandPalette/index.ts b/packages/vue/src/primitives/CommandPalette/index.tsnew file mode 100644index 000000000..3d2c39d4b--- /dev/null+++ b/packages/vue/src/primitives/CommandPalette/index.ts@@ -0,0 +1,10 @@+export { default as CommandPaletteRoot } from '#vue/primitives/CommandPalette/CommandPaletteRoot.vue'+export { useCommandPalette } from '#vue/primitives/CommandPalette/useCommandPalette'+export type {+ CommandPaletteGroup,+ CommandPaletteItem,+ CommandPaletteShortcut,+ CommandPaletteUI,+ CommandPaletteLabels,+ UseCommandPaletteOptions+} from '#vue/primitives/CommandPalette/types'diff --git a/packages/vue/src/primitives/CommandPalette/types.ts b/packages/vue/src/primitives/CommandPalette/types.tsnew file mode 100644index 000000000..4e6151d5f--- /dev/null+++ b/packages/vue/src/primitives/CommandPalette/types.ts@@ -0,0 +1,54 @@+import type { Component } from 'vue'++export interface CommandPaletteShortcut {+ keys: string[]+}++export interface CommandPaletteItem {+ id: string+ label: string+ description?: string+ keywords?: string[]+ icon?: Component+ shortcut?: CommandPaletteShortcut+ disabled?: boolean+ children?: CommandPaletteItem[]+ onSelect?: () => void+}++export interface CommandPaletteGroup {+ id: string+ label?: string+ items: CommandPaletteItem[]+}++export interface CommandPaletteLabels {+ searchPlaceholder: string+ searchLabel: string+ paletteLabel: string+ empty: string+ back: string+}++export interface CommandPaletteUI {+ root?: string+ searchWrapper?: string+ search?: string+ back?: string+ content?: string+ viewport?: string+ group?: string+ label?: string+ item?: string+ itemIcon?: string+ itemLabel?: string+ itemDescription?: string+ shortcut?: string+ key?: string+ empty?: string+}++export interface UseCommandPaletteOptions {+ groups: CommandPaletteGroup[]+ resultLimit?: number+}diff --git a/packages/vue/src/primitives/CommandPalette/useCommandPalette.ts b/packages/vue/src/primitives/CommandPalette/useCommandPalette.tsnew file mode 100644index 000000000..3b5bd7ead--- /dev/null+++ b/packages/vue/src/primitives/CommandPalette/useCommandPalette.ts@@ -0,0 +1,101 @@+import { groupBy } from 'es-toolkit/array'+import Fuse from 'fuse.js'+import { computed, ref, type MaybeRefOrGetter, toValue } from 'vue'++import type { CommandPaletteGroup, CommandPaletteItem, UseCommandPaletteOptions } from './types'++function searchItems(+ items: CommandPaletteItem[],+ query: string,+ resultLimit: number+): CommandPaletteItem[] {+ if (!query) return items.slice(0, resultLimit)++ return new Fuse(items, {+ keys: ['label', 'description', 'keywords'],+ threshold: 0.2,+ ignoreLocation: true+ })+ .search(query)+ .slice(0, resultLimit)+ .map((result) => result.item)+}++function filterGroups(+ groups: CommandPaletteGroup[],+ results: CommandPaletteItem[]+): CommandPaletteGroup[] {+ const groupByItem = new Map(+ groups.flatMap((group) => group.items.map((item) => [item, group.id] as const))+ )+ const groupedResults = groupBy(results, (item) => groupByItem.get(item) ?? '')++ return groups+ .map((group) => ({ ...group, items: groupedResults[group.id] ?? [] }))+ .filter((group) => group.items.length > 0)+}++export function useCommandPalette(options: MaybeRefOrGetter<UseCommandPaletteOptions>) {+ const searchTerm = ref('')+ const selectedId = ref<string>()+ const navigation = ref<CommandPaletteGroup[]>([])++ const groups = computed(() => toValue(options).groups)+ const resultLimit = computed(() => toValue(options).resultLimit ?? 12)+ const currentGroups = computed(() => {+ const current = navigation.value.at(-1)+ return current ? [current] : groups.value+ })+ const items = computed(() => currentGroups.value.flatMap((group) => group.items))+ const filteredGroups = computed(() =>+ filterGroups(+ currentGroups.value,+ searchItems(items.value, searchTerm.value.trim(), resultLimit.value)+ )+ )+ const isNested = computed(() => navigation.value.length > 0)++ function resetNavigation() {+ navigation.value = []+ searchTerm.value = ''+ selectedId.value = undefined+ }++ function close() {+ resetNavigation()+ }++ function navigate(item: CommandPaletteItem): boolean {+ if (!item.children?.length) return false+ navigation.value.push({ id: item.id, label: item.label, items: item.children })+ searchTerm.value = ''+ selectedId.value = undefined+ return true+ }++ function navigateBack(): boolean {+ if (navigation.value.length === 0) return false+ navigation.value.pop()+ searchTerm.value = ''+ selectedId.value = undefined+ return true+ }++ function select(item: CommandPaletteItem) {+ if (item.disabled || navigate(item)) return+ selectedId.value = item.id+ item.onSelect?.()+ close()+ }++ return {+ searchTerm,+ selectedId,+ filteredGroups,+ isNested,+ close,+ navigate,+ navigateBack,+ select+ }+}diff --git a/src/app/shell/menu/app-menu.ts b/src/app/shell/menu/app-menu.tsindex 05d3454b7..632403a8b 100644--- a/src/app/shell/menu/app-menu.ts+++ b/src/app/shell/menu/app-menu.ts@@ -1,15 +1,34 @@+import type { Component } from 'vue'import { computed } from 'vue'import { useRouter } from 'vue-router'+import IconDownload from '~icons/lucide/download'+import IconEye from '~icons/lucide/eye'+import IconFile from '~icons/lucide/file'+import IconFolderOpen from '~icons/lucide/folder-open'+import IconLayers from '~icons/lucide/layers-2'+import IconPencil from '~icons/lucide/pencil'+import IconRedo from '~icons/lucide/redo-2'+import IconSave from '~icons/lucide/save'+import IconSettings from '~icons/lucide/settings'+import IconType from '~icons/lucide/type'+import IconUndo from '~icons/lucide/undo-2'+import IconZoomIn from '~icons/lucide/zoom-in'+import IconZoomOut from '~icons/lucide/zoom-out'-import type { MenuEntry } from '@open-pencil/vue'-import { useEditorCommands, useI18n } from '@open-pencil/vue'+import type { CommandPaletteGroup, CommandPaletteItem, MenuEntry } from '@open-pencil/vue'+import { shortcutPlatform, useEditorCommands, useI18n } from '@open-pencil/vue'import { useEditorStore } from '@/app/editor/active-store'import { openSettingsDialog } from '@/app/settings/dialog'import { setSnappingPreference } from '@/app/settings/preferences/apply'import { createSharedEditorMenuActions } from '@/app/shell/menu/editor-actions'import { openStorageWorkspace } from '@/app/shell/menu/navigation'-import type { AppMenuActionItem, AppMenuEntry, AppMenuGroupSchema } from '@/app/shell/menu/schema'+import type {+ AppMenuActionItem,+ AppMenuEntry,+ AppMenuGroupSchema,+ AppMenuIcon+} from '@/app/shell/menu/schema'import { APP_MENU_SCHEMA } from '@/app/shell/menu/schema'import { createSelectionMenuActions } from '@/app/shell/menu/selection-actions'import { appMenuShortcutLabel } from '@/app/shell/menu/shortcut'@@ -19,9 +38,37 @@ import { closeTab, activeTab } from '@/app/tabs'export interface AppMenuGroup {label: string+ paletteIcon?: Componentitems: MenuEntry[]}+const APP_MENU_ICONS: Record<AppMenuIcon, Component> = {+ download: IconDownload,+ eye: IconEye,+ file: IconFile,+ 'folder-open': IconFolderOpen,+ layers: IconLayers,+ pencil: IconPencil,+ redo: IconRedo,+ save: IconSave,+ settings: IconSettings,+ type: IconType,+ undo: IconUndo,+ 'zoom-in': IconZoomIn,+ 'zoom-out': IconZoomOut+}++function shortcutKeys(shortcut: string | undefined): string[] | undefined {+ if (!shortcut) return undefined+ const platform = shortcutPlatform()+ return shortcut.split('+').map((key) => {+ if (key === 'MOD') return platform === 'mac' ? '⌘' : 'Ctrl'+ if (key === 'SHIFT') return platform === 'mac' ? '⇧' : 'Shift'+ if (key === 'ALT') return platform === 'mac' ? '⌥' : 'Alt'+ return key+ })+}+function isVisible(entry: { target?: string }): boolean {return entry.target !== 'native'}@@ -200,6 +247,16 @@ export function useAppMenu() {return key ? menu.value[key] : entry.label}+ function resolvePalette(entry: AppMenuActionItem) {+ return entry.palette+ ? {+ ...entry.palette,+ label: entry.palette.label ? menu.value[entry.palette.label] : undefined,+ icon: entry.palette.icon ? APP_MENU_ICONS[entry.palette.icon] : undefined+ }+ : undefined+ }+function buildEntry(entry: AppMenuEntry): MenuEntry | null {if (!isVisible(entry)) return nullif (isSeparator(entry)) return { separator: true }@@ -223,11 +280,19 @@ export function useAppMenu() {}if (entry.command) {- return commandMenuItem(entry.command, appMenuShortcutLabel(entry.id))+ return {+ ...commandMenuItem(entry.command, appMenuShortcutLabel(entry.id)),+ menuId: entry.id,+ palette: resolvePalette(entry),+ paletteShortcut: entry.shortcut+ }}return {+ menuId: entry.id,label: menuLabel(entry),+ palette: resolvePalette(entry),+ paletteShortcut: entry.shortcut,shortcut: appMenuShortcutLabel(entry.id),action: itemAction(entry),disabled: disabled(entry),@@ -246,13 +311,50 @@ export function useAppMenu() {if (!isVisible(group)) return nullreturn {label: groupLabel(group),+ paletteIcon: group.paletteIcon ? APP_MENU_ICONS[group.paletteIcon] : undefined,items: group.items.map(buildEntry).filter((item): item is MenuEntry => item !== null)}}+ function paletteEntries(+ entry: MenuEntry,+ category: string,+ fallbackIcon?: Component+ ): CommandPaletteItem[] {+ if ('separator' in entry) return []+ if (!entry.menuId)+ return entry.sub?.flatMap((child) => paletteEntries(child, category, fallbackIcon)) ?? []++ const item: CommandPaletteItem = {+ id: entry.menuId,+ label: entry.palette?.label ?? entry.label,+ icon: entry.palette?.icon ?? fallbackIcon,+ shortcut: entry.paletteShortcut+ ? { keys: shortcutKeys(entry.paletteShortcut) ?? [] }+ : undefined,+ description: entry.palette?.description,+ keywords: entry.palette?.keywords,+ disabled: entry.disabled,+ onSelect:+ entry.action ??+ (entry.onCheckedChange ? () => entry.onCheckedChange?.(!entry.checked) : undefined)+ }+ const children =+ entry.sub?.flatMap((child) => paletteEntries(child, category, fallbackIcon)) ?? []+ return [item, ...children]+ }+const topMenus = computed<AppMenuGroup[]>(() =>APP_MENU_SCHEMA.map(buildGroup).filter((group): group is AppMenuGroup => group !== null))- return { topMenus }+ const commandGroups = computed<CommandPaletteGroup[]>(() =>+ topMenus.value.map((group) => ({+ id: group.label.toLowerCase(),+ label: group.label,+ items: group.items.flatMap((entry) => paletteEntries(entry, group.label, group.paletteIcon))+ }))+ )++ return { topMenus, commandGroups }}diff --git a/src/app/shell/menu/schema.ts b/src/app/shell/menu/schema.tsindex 31e23861a..9aaffe2b4 100644--- a/src/app/shell/menu/schema.ts+++ b/src/app/shell/menu/schema.ts@@ -1,6 +1,35 @@import type { EditorCommandId } from '@open-pencil/vue'export type AppMenuTarget = 'all' | 'browser' | 'native'++export type AppMenuIcon =+ | 'download'+ | 'eye'+ | 'file'+ | 'folder-open'+ | 'layers'+ | 'pencil'+ | 'redo'+ | 'save'+ | 'settings'+ | 'type'+ | 'undo'+ | 'zoom-in'+ | 'zoom-out'++export type AppMenuPaletteLabel =+ | 'exportSelectionAsPNG'+ | 'exportSelectionAsSVG'+ | 'exportSelectionAsPPTX'+ | 'exportSelectionAsFig'++export interface AppMenuPaletteMetadata {+ icon?: AppMenuIcon+ label?: AppMenuPaletteLabel+ description?: string+ keywords?: string[]+}+export type AppMenuHandler = 'editor' | 'shell'export interface AppMenuActionItem {@@ -13,6 +42,7 @@ export interface AppMenuActionItem {checkbox?: booleantarget?: AppMenuTargethandler?: AppMenuHandler+ palette?: AppMenuPaletteMetadatasub?: AppMenuEntry[]}@@ -26,12 +56,14 @@ export type AppMenuEntry = AppMenuActionItem | AppMenuSeparatorItemexport interface AppMenuGroupSchema {label: stringtarget?: AppMenuTarget+ paletteIcon?: AppMenuIconitems: AppMenuEntry[]}export const APP_MENU_SCHEMA = [{label: 'File',+ paletteIcon: 'file',items: [{ id: 'new', label: 'New', shortcut: 'MOD+N' },{ id: 'open', label: 'Open…', shortcut: 'MOD+O' },@@ -44,12 +76,29 @@ export const APP_MENU_SCHEMA = [{id: 'export-selection',label: 'Export Selection',+ palette: { icon: 'download' },shortcut: 'MOD+SHIFT+E',sub: [- { id: 'export-png', label: 'PNG' },- { id: 'export-svg', label: 'SVG' },- { id: 'export-pptx', label: 'PPTX' },- { id: 'export-fig', label: '.fig' }+ {+ id: 'export-png',+ label: 'PNG',+ palette: { icon: 'download', label: 'exportSelectionAsPNG' }+ },+ {+ id: 'export-svg',+ label: 'SVG',+ palette: { icon: 'download', label: 'exportSelectionAsSVG' }+ },+ {+ id: 'export-pptx',+ label: 'PPTX',+ palette: { icon: 'download', label: 'exportSelectionAsPPTX' }+ },+ {+ id: 'export-fig',+ label: '.fig',+ palette: { icon: 'download', label: 'exportSelectionAsFig' }+ }]},{ type: 'separator' },@@ -59,6 +108,7 @@ export const APP_MENU_SCHEMA = [},{label: 'Edit',+ paletteIcon: 'pencil',items: [{id: 'edit.undo',@@ -101,6 +151,7 @@ export const APP_MENU_SCHEMA = [},{label: 'View',+ paletteIcon: 'eye',items: [{id: 'view.zoom100',@@ -183,6 +234,7 @@ export const APP_MENU_SCHEMA = [},{label: 'Object',+ paletteIcon: 'layers',items: [{id: 'selection.group',@@ -319,6 +371,7 @@ export const APP_MENU_SCHEMA = [},{label: 'Text',+ paletteIcon: 'type',items: [{ id: 'text.bold', label: 'Bold', shortcut: 'MOD+B' },{ id: 'text.italic', label: 'Italic', shortcut: 'MOD+I' },@@ -327,6 +380,7 @@ export const APP_MENU_SCHEMA = [},{label: 'Arrange',+ paletteIcon: 'layers',items: [{id: 'selection.wrapInAutoLayout',diff --git a/src/components/commands/CommandPalette.vue b/src/components/commands/CommandPalette.vuenew file mode 100644index 000000000..6e2345b62--- /dev/null+++ b/src/components/commands/CommandPalette.vue@@ -0,0 +1,88 @@+<script setup lang="ts">+import { computed } from 'vue'+import { useEventListener } from '@vueuse/core'+import {+ CommandPaletteRoot,+ shortcutPlatform,+ useCommandMessages,+ useCommonMessages+} from '@open-pencil/vue'+import { DialogDescription, DialogTitle, VisuallyHidden } from 'reka-ui'++import Search from '~icons/lucide/search'+import X from '~icons/lucide/x'++import { IS_BROWSER } from '@/constants'+import { useAppMenu } from '@/app/shell/menu/app-menu'+import AppDialogRoot from '@/components/ui/dialog/AppDialogRoot.vue'+import { useCommandPaletteUI } from './ui'++const { commandGroups: groups } = useAppMenu()+const commands = useCommandMessages()+const common = useCommonMessages()+const paletteUI = useCommandPaletteUI()+const labels = computed(() => ({+ searchPlaceholder: commands.value.paletteSearchPlaceholder,+ searchLabel: commands.value.paletteSearchAriaLabel,+ paletteLabel: commands.value.paletteAriaLabel,+ empty: commands.value.paletteNoCommands,+ back: commands.value.paletteBack+}))+const open = defineModel<boolean>('open', { default: false })++function close() {+ open.value = false+}++if (IS_BROWSER) {+ const isMac = shortcutPlatform() === 'mac'+ useEventListener(window, 'keydown', (event) => {+ const hasPlatformModifier = isMac+ ? event.metaKey && !event.ctrlKey+ : event.ctrlKey && !event.metaKey+ if (!hasPlatformModifier || event.altKey || event.shiftKey || event.code !== 'KeyK') return+ event.preventDefault()+ open.value = true+ })+}+</script>++<template>+ <AppDialogRoot+ v-model:open="open"+ size="md"+ :ui="{+ content: 'w-[min(40rem,94vw)] p-0',+ overlay: 'bg-black/40'+ }"+ @escape-key-down="close"+ >+ <VisuallyHidden>+ <DialogTitle>{{ commands.paletteAriaLabel }}</DialogTitle>+ <DialogDescription>{{ commands.paletteDescription }}</DialogDescription>+ </VisuallyHidden>+ <CommandPaletteRoot :groups="groups" :labels="labels" :ui="paletteUI" @select="open = false">+ <template #search-leading>+ <Search class="mx-2 size-5 shrink-0 text-muted" />+ </template>+ <template #search-trailing>+ <button+ type="button"+ class="ml-2 inline-flex size-8 shrink-0 items-center justify-center rounded text-muted hover:bg-hover hover:text-surface"+ :aria-label="common.close"+ @click="close"+ >+ <X class="size-5" />+ </button>+ </template>+ <template #empty>+ <p class="px-4 py-8 text-center text-xs text-muted">+ {{ commands.paletteNoCommands }}+ </p>+ </template>+ <template #item-icon="{ item }">+ <component :is="item.icon" v-if="item.icon" class="size-4" />+ </template>+ </CommandPaletteRoot>+ </AppDialogRoot>+</template>diff --git a/src/components/commands/ui.ts b/src/components/commands/ui.tsnew file mode 100644index 000000000..3af08f13d--- /dev/null+++ b/src/components/commands/ui.ts@@ -0,0 +1,23 @@+import { tv } from 'tailwind-variants'++import commandPaletteTheme from '@/theme/command-palette'++export const commandPalette = tv(commandPaletteTheme)++export function useCommandPaletteUI() {+ const ui = commandPalette()+ return {+ root: ui.root(),+ searchWrapper: ui.searchWrapper(),+ search: ui.search(),+ back: ui.back(),+ content: ui.content(),+ label: ui.label(),+ group: ui.group(),+ item: ui.item(),+ itemIcon: ui.itemIcon(),+ itemLabel: ui.itemLabel(),+ shortcut: ui.shortcut(),+ key: ui.key()+ }+}diff --git a/src/theme/command-palette.ts b/src/theme/command-palette.tsnew file mode 100644index 000000000..9f44a4bab--- /dev/null+++ b/src/theme/command-palette.ts@@ -0,0 +1,18 @@+export default {+ slots: {+ root: 'flex h-[min(70vh,32rem)] flex-col overflow-hidden',+ searchWrapper: 'flex h-14 shrink-0 items-center border-b border-border px-3',+ search:+ 'h-8 flex-1 rounded-none border-0 bg-transparent px-0 text-[13px] outline-none placeholder:text-muted',+ back: 'px-2 pt-2 text-xs text-muted',+ content:+ 'min-h-0 flex-1 overflow-y-auto px-2 pb-2 pt-1 [scrollbar-color:theme(colors.muted)_transparent]',+ label: 'px-2 py-1 text-[11px] font-medium text-muted',+ group: 'mb-2 last:mb-0',+ item: 'mx-0 flex h-8 cursor-pointer items-center gap-2 rounded-md p-1 text-[13px] leading-6 text-surface outline-none data-[disabled]:cursor-not-allowed data-[disabled]:text-muted data-[disabled]:opacity-55 data-[highlighted]:bg-hover',+ itemIcon: 'flex size-6 shrink-0 items-center justify-center text-muted',+ itemLabel: 'min-w-0 flex-1 truncate',+ shortcut: 'flex shrink-0 items-center gap-1 text-xs text-muted',+ key: 'inline-flex min-w-5 items-center justify-center rounded border border-border bg-panel px-1 py-0.5 font-mono text-[10px] leading-none'+ }+} as constdiff --git a/src/views/WorkspaceView.vue b/src/views/WorkspaceView.vueindex 7dd0ab1b6..9a5a5975b 100644--- a/src/views/WorkspaceView.vue+++ b/src/views/WorkspaceView.vue@@ -21,9 +21,10 @@ import {} from '@/app/tabs'import { isTauri } from '@/app/tauri/env'import FontStatusBanner from '@/components/font-status/FontStatusBanner.vue'-import RenameSelectionDialog from '@/components/selection/RenameSelectionDialog.vue'+import CommandPalette from '@/components/commands/CommandPalette.vue'import SafariBanner from '@/components/SafariBanner.vue'import TabBar from '@/components/TabBar.vue'+import RenameSelectionDialog from '@/components/selection/RenameSelectionDialog.vue'import EditorWorkspace from '@/components/editor/EditorWorkspace.vue'import HomeWorkspace from '@/components/home/HomeWorkspace.vue'@@ -100,6 +101,7 @@ onUnmounted(() => {<SafariBanner /><FontStatusBanner /><RenameSelectionDialog />+ <CommandPalette /><TabBar /><HomeWorkspace v-show="activeTab?.kind === 'home'" @new-document="createDocumentInCurrentTab" /><EditorWorkspace v-if="activeTab?.kind !== 'home'" />diff --git a/tests/e2e/app/command-palette.spec.ts b/tests/e2e/app/command-palette.spec.tsnew file mode 100644index 000000000..da4255d46--- /dev/null+++ b/tests/e2e/app/command-palette.spec.ts@@ -0,0 +1,34 @@+import { expect, test, useEditorSetup } from '#tests/e2e/fixtures'++const editor = useEditorSetup()++function commandPaletteShortcut() {+ return process.platform === 'darwin' ? 'Meta+KeyK' : 'Control+KeyK'+}++test('command palette opens, searches, and closes', async () => {+ await editor.page.keyboard.press(commandPaletteShortcut())++ const palette = editor.page.getByRole('dialog', { name: 'Command palette' })+ await expect(palette).toBeVisible()++ const search = palette.getByRole('searchbox', { name: 'Search commands' })+ await expect(search).toBeFocused()+ await search.fill('zoom')+ await expect(palette.getByRole('option', { name: /Zoom to fit/ })).toBeVisible()+ await expect(palette.getByRole('option', { name: 'New' })).not.toBeVisible()++ await editor.page.keyboard.press('Escape')+ await expect(palette).not.toBeVisible()+})++test('command palette exposes contextual export labels', async () => {+ await editor.page.keyboard.press(commandPaletteShortcut())++ const palette = editor.page.getByRole('dialog', { name: 'Command palette' })+ await palette.getByRole('searchbox', { name: 'Search commands' }).fill('export')+ await expect(palette.getByText('Export selection as PNG')).toBeVisible()+ await expect(palette.getByText('Export selection as SVG')).toBeVisible()++ await editor.page.keyboard.press('Escape')+})diff --git a/tools/i18n/mixed-script-baseline.txt b/tools/i18n/mixed-script-baseline.txtindex 0aa25ba78..bfa30cb43 100644--- a/tools/i18n/mixed-script-baseline.txt+++ b/tools/i18n/mixed-script-baseline.txt@@ -2,7 +2,6 @@ ja:ai.apiKeyja:ai.apiTypeja:ai.baseURLja:ai.baseURLPlaceholder-ja:ai.connectProviderja:ai.connectionTestAPITypeMismatchja:ai.connectionTestAuthFailedja:ai.connectionTestBrowserNetworkFailed@@ -12,6 +11,7 @@ ja:ai.connectionTestMissingBaseURLja:ai.connectionTestMissingModelja:ai.connectionTestModelNotFoundja:ai.connectionTestNetworkFailed+ja:ai.connectProviderja:ai.customModelIDja:ai.getProviderAPIKeyja:ai.modelID@@ -45,6 +45,7 @@ ja:code.copyJSXReferenceja:collaboration.clickToFollowPeerja:collaboration.followingPeerStopja:collaboration.pasteRoomLinkOrId+ja:commands.paletteDescriptionja:credentials.getAPIKeyja:credentials.storageja:diagnostics.acpFailed@@ -60,9 +61,9 @@ ja:editor.showUIja:editor.toolOptionsja:files.browserFileAPINotSupportedja:files.clipboardImageFetchFailed-ja:files.clipboardImageUnavailableWebja:files.clipboardImagesFetchFailedja:files.clipboardImagesUnavailableWeb+ja:files.clipboardImageUnavailableWebja:files.closeTabja:files.importFailedja:files.importHTMLCSS@@ -79,8 +80,8 @@ ja:fonts.providerEnabledja:fonts.webFontProvidersRequireDesktopAppja:media.getPexelsAPIKeyja:media.getUnsplashAccessKey-ja:media.pexelsAPIKeyja:media.pexelsAlternativeOptional+ja:media.pexelsAPIKeyja:media.stockPhotoToolOptionalja:media.unsplashAccessKeyja:media.vectorizationDescription@@ -89,6 +90,10 @@ ja:menu.copyAsPNGja:menu.copyAsSVGja:menu.copyNodeIdja:menu.copyXPath+ja:menu.exportSelectionAsFig+ja:menu.exportSelectionAsPNG+ja:menu.exportSelectionAsPPTX+ja:menu.exportSelectionAsSVGja:menu.toggleUIja:pages.pageNameja:panels.assetVariantSummary@@ -128,7 +133,6 @@ zh-cn:ai.apiKeyzh-cn:ai.apiTypezh-cn:ai.baseURLPlaceholderzh-cn:ai.chatOutputLimit-zh-cn:ai.connectProviderzh-cn:ai.connectionTestAPITypeMismatchzh-cn:ai.connectionTestAuthFailedzh-cn:ai.connectionTestBrowserNetworkFailed@@ -138,6 +142,7 @@ zh-cn:ai.connectionTestMissingBaseURLzh-cn:ai.connectionTestMissingModelzh-cn:ai.connectionTestModelNotFoundzh-cn:ai.connectionTestNetworkFailed+zh-cn:ai.connectProviderzh-cn:ai.customModelIDzh-cn:ai.getProviderAPIKeyzh-cn:ai.maxOutputTokens@@ -172,6 +177,7 @@ zh-cn:code.copyJSXReferencezh-cn:collaboration.clickToFollowPeerzh-cn:collaboration.followingPeerStopzh-cn:collaboration.pasteRoomLinkOrId+zh-cn:commands.paletteDescriptionzh-cn:credentials.getAPIKeyzh-cn:credentials.storagezh-cn:diagnostics.acpFailed@@ -203,8 +209,8 @@ zh-cn:fonts.providerDisabledzh-cn:fonts.providerEnabledzh-cn:media.getPexelsAPIKeyzh-cn:media.getUnsplashAccessKey-zh-cn:media.pexelsAPIKeyzh-cn:media.pexelsAlternativeOptional+zh-cn:media.pexelsAPIKeyzh-cn:media.stockPhotoToolOptionalzh-cn:media.unsplashAccessKeyzh-cn:media.vectorizationDescription@@ -213,6 +219,10 @@ zh-cn:menu.copyAsPNGzh-cn:menu.copyAsSVGzh-cn:menu.copyNodeIdzh-cn:menu.copyXPath+zh-cn:menu.exportSelectionAsFig+zh-cn:menu.exportSelectionAsPNG+zh-cn:menu.exportSelectionAsPPTX+zh-cn:menu.exportSelectionAsSVGzh-cn:pages.pageNamezh-cn:panels.assetVariantSummaryzh-cn:panels.colorHintHsb