diff --git a/docs/design-decisions.md b/docs/design-decisions.md index 7891898..955853f 100644 --- a/docs/design-decisions.md +++ b/docs/design-decisions.md @@ -965,3 +965,18 @@ Native shell, background image, and desktop acceptance remain open. - Evidence: `tests/smoke/layout/keyboardFocus.smoke.mjs`. - Replaces / replaced by: The radio rule of [UI-003](#ui-003--quiet-menu-choices). Other parts of UI-003 remain. - Limits: The check mark replaces the icon of a radio row. The list of all tabs names pinned tabs in text. Browser checks use desktop service mocks. + +### UI-052 — Panes that give way, one icon per action, and consistent Settings + +- Type: Rule change +- Date: 2026-10-28 +- Status: Implemented for user review +- Decision source: Owner decisions 6 (menu separator and danger color) and 13 (layout and icons, Settings) of 2026-10-27 (interface review issues 9, 11, 13, 19, and 21), stage 5-6. +- Previous rule: Side panes kept 260 and 240 pixels in every window, so a 900-pixel window gave the document 44% of its width. The copy icon stood for 7 functions, and one action had two labels ("Show in Explorer" and "Show in system explorer"). Delete sat after Rename with no separator or color. The tree used CSS triangles. Search showed a flat list of paths. Bookmarks were bare paths. Settings had three switch designs, a Save button only for the browser, and the first focus on "Minimize window". Some targets were 22 pixels. +- New rule: The outline gives way below 1100 pixels and the side pane below 800 pixels, when the window becomes narrow. They come back when it grows, and a pane that the user opens in a narrow window stays open. One function has one icon (`copy`, `duplicate`, `template`, and `tab`, added to the SDK icon set), and the reveal action has one label for each platform. The file menu follows one order and ends with Delete in the error color after a separator. The tree uses the shared chevron. Search hits come in groups by file, with counts and marked matches. Bookmarks show the name, the folder, and a remove button. All boolean settings use the `rs-switch` design, every setting applies at once, and the Settings window opens with the focus on its search. The tab close button, outline rows, switches, and the settings search are at least 24 pixels. +- Reason: A narrow window must leave room for the document. A user must recognize an action by its icon and its label. Settings must behave the same on every page. +- Scope: The workbench layout, the file and tab menus, the image and table menus, the left pane views, the outline, and Settings. +- Shared implementation: `Workbench.svelte` (the narrow layout), `FileTree.svelte`, `menuTypes.ts` and `actionMenu.ts` (`danger`), `menuItems.ts` (`revealLabel`), `packages/plugin-sdk/src/icons.ts`, `SearchPane.svelte`, `BookmarksPane.svelte`, `TreeNode.svelte`, and `src/lib/ui/switch.css`. +- Evidence: `tests/smoke/layout/panesAndSettings.smoke.mjs`. +- Replaces / replaced by: The fixed side panes of narrow windows, and the Save button of the browser settings. +- Limits: At startup, the saved layout applies as it is, also in a narrow window. Panes give way only when the window becomes narrower. Browser checks use desktop service mocks. The SDK release that publishes the new icon names is a separate step. diff --git a/docs/ui-design.md b/docs/ui-design.md index 328aa78..1b6637d 100644 --- a/docs/ui-design.md +++ b/docs/ui-design.md @@ -69,7 +69,7 @@ Do not copy feature-specific colors into a shared control. ## Controls, corners, and focus - Controls, menu rows, and navigation highlights use `--rs-control-radius`. This includes hover, active, and selected states. -- Keep readable labels, visible focus indicators, and comfortable click targets in compact layouts. +- Keep readable labels, visible focus indicators, and comfortable click targets in compact layouts. A target is at least 24 by 24 pixels. - Keyboard focus shows a 2-pixel `--rs-focus` ring outside the control. Menu rows draw the ring inside the row. Hover never shows the ring. - Hover gets a neutral fill. An active toggle also gets the accent color, the selection fill, and a 2-pixel accent bar, so it differs from hover. - A disabled control uses `--rs-text-dim` at full opacity. Do not fade a control with opacity. @@ -110,6 +110,8 @@ 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`. +- One function has one icon: `copy` puts content on the clipboard, `duplicate` makes a second file or row, `template` marks template actions, and `tab` opens in a new tab. The action that shows a file in the file manager takes its label from `revealLabel()`. +- A file menu follows one order: open, clipboard, organize, show and copy path, history, then Delete. Delete and Delete permanently use `danger`, which gives them the error color. - 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. Keyboard focus adds a 2-pixel ring inside the row. @@ -154,6 +156,7 @@ Decisions: [UI-002](design-decisions.md#ui-002--share-the-requested-dropdown-des - Document and plugin tabs share the tab bar. The new-tab button follows the tabs. Tabs keep their order and pin state when a plugin replaces its view. - The main window keeps an empty New tab after its last tab closes. A secondary window closes with its last tab. The unsaved-edit and active-terminal confirmations still apply, and Cancel keeps the tab open. - Sidebar widths and visibility persist across window sessions. A different editor does not restore a hidden outline. +- Side panes give way when the window becomes narrow: the outline below 1100 pixels, and the side pane below 800 pixels. They come back when the window grows again. A pane that the user opens in a narrow window stays open, and the saved layout keeps the choice of a wide window. - A detached tab window holds the tab work area and window controls only. It has no side panes, plugin ribbon, or pane switches, and it does not change the main window layout. Decisions: [UI-004](design-decisions.md#ui-004--detached-tab-work-area), [UI-039](design-decisions.md#ui-039--close-secondary-windows-after-the-last-tab). @@ -162,6 +165,9 @@ Decisions: [UI-004](design-decisions.md#ui-004--detached-tab-work-area), [UI-039 - Follow the Obsidian settings pattern. Navigation pairs icons with labels. Each page uses readable text and ordinary controls. - Use the `--rs-settings-*` tokens for spacing, control height, headings, and descriptions. +- Every boolean setting uses the one switch design: `` (`src/lib/ui/switch.css`). +- Settings apply at once: a switch or a choice on change, and a text field when it loses focus. No page has a Save button. +- The Settings window opens with the focus on its search field. - Put related plugin metadata and actions in compact rows. - Controls wrap at narrow widths, and the content area scrolls. Long navigation must leave room for the selected page. - General offers the interface language through the shared action menu. diff --git a/docs/user-guide.md b/docs/user-guide.md index b7ebac5..1a01d4b 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -40,15 +40,15 @@ To show workspace settings and plugin data in the navigator, turn on **Settings | New file | Press Ctrl+N and type the full name with its extension, such as `notes/meeting.md` or `scripts/check.py`. RuneStone does not add an extension. | | New note | Select **New note** in an empty tab, or right-click the navigator and choose **New note**. RuneStone creates a Markdown file. Rename it from the note title. | | Find a file by path | Press Ctrl+P. | -| Search all files | Press Ctrl+Shift+F. | +| Search all files | Press Ctrl+Shift+F. The results come in groups by file, with the count and the matches marked. | | Find in the document | Press Ctrl+F. | | 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. | +| Bookmark | Right-click a file and choose **Bookmark**. The Bookmarks pane lists it with its folder. Select × beside a bookmark to remove it. | -Right-click a file or folder for more actions, such as **Make a copy**, **Copy workspace path**, and **Open in default app**. +Right-click a file or folder for more actions, such as **Make a copy**, **Copy path**, and **Open in default app**. **Delete** is last in the menu, in the error color. With the navigator focused, Ctrl+X, Ctrl+C, and Ctrl+V cut, copy, and paste files. The navigator is one Tab stop. Up and Down move between items, and Shift+Up or Shift+Down extends the selection. Right opens a folder or enters it. Left closes a folder or goes to its parent. Home and End go to the first and last item. Type the start of a name to go to it. Ctrl+Z undoes a file move or rename, and Ctrl+Shift+Z or Ctrl+Y repeats it. @@ -190,7 +190,7 @@ If a write fails, your edits stay in the tab. RuneStone does not lock files, so ## Change settings Select the gear at the bottom of the left ribbon, or press Ctrl+,. Use the search field to find a setting. -Settings apply to all workspaces on this computer and update all open windows. +Settings apply at once to all workspaces on this computer and update all open windows. A text field applies when you leave it. | Category | Settings | | --- | --- | diff --git a/packages/plugin-sdk/src/icons.ts b/packages/plugin-sdk/src/icons.ts index 9fa1469..43d1a63 100644 --- a/packages/plugin-sdk/src/icons.ts +++ b/packages/plugin-sdk/src/icons.ts @@ -45,6 +45,9 @@ export const actionIcons = { footnote: '', cut: '', copy: '', + duplicate: '', + template: '', + tab: '', paste: '', 'paste-text': '', format: '', diff --git a/src/app.css b/src/app.css index 457b4bb..aa395b7 100644 --- a/src/app.css +++ b/src/app.css @@ -1,6 +1,7 @@ /* Global styles. Each file lives beside the code that uses it. The order of the imports is the cascade order. */ @import "./lib/theme/tokens.css"; @import "./lib/ui/menu.css"; +@import "./lib/ui/switch.css"; @import "./lib/theme/base.css"; @import "./lib/ui/tooltip.css"; @import "./lib/layout/reading.css"; diff --git a/src/lib/browser/Settings.svelte b/src/lib/browser/Settings.svelte index ef6f130..def1d65 100644 --- a/src/lib/browser/Settings.svelte +++ b/src/lib/browser/Settings.svelte @@ -1,89 +1,88 @@ - -
-

{$t("Browser")}

{$t("Choose how you browse within RuneStone.")}

-

{$t("General")}

-
{ event.preventDefault(); if (ready && !busy) void save(); }}> -
-
- - -
{$t("Search engine")}
- - -
- - -
-
-

{$t("Profiles")}

{$t("New profiles start blank. Duplicate a profile to copy its stored browsing data and bookmarks.")}

-
-
{$t("Profile")}
- -
-

{$t("Duplication briefly restarts browser tabs. The copies remain separate. Agent permissions are not copied.")}

-
-

{$t("Web data")}

{$t("Clear data for the selected profile. Its browser tabs will close. Bookmarks remain.")}

-
-

{message}

- {#if ready}{/if} -
- + +
+

{$t("Browser")}

{$t("Choose how you browse within RuneStone.")}

+

{$t("General")}

+
void save()}> +
+ + +
{$t("Search engine")}
+ + +
+ +
+

{$t("Profiles")}

{$t("New profiles start blank. Duplicate a profile to copy its stored browsing data and bookmarks.")}

+
+
{$t("Profile")}
+ +
+

{$t("Duplication briefly restarts browser tabs. The copies remain separate. Agent permissions are not copied.")}

+
+

{$t("Web data")}

{$t("Clear data for the selected profile. Its browser tabs will close. Bookmarks remain.")}

+
+

{message}

+ {#if ready}{/if} +
+ diff --git a/src/lib/editor/imageControls.ts b/src/lib/editor/imageControls.ts index c43e9f3..0100ff7 100644 --- a/src/lib/editor/imageControls.ts +++ b/src/lib/editor/imageControls.ts @@ -1,4 +1,5 @@ import { tr } from '../i18n/index.ts'; +import { revealLabel } from '../ui/menuItems.ts'; import { actionIcon, type ActionIcon } from "../ui/actionIcons"; import { attachTooltip } from "../ui/tooltip"; const tooltipCleanups = new WeakMap void>(); @@ -137,7 +138,7 @@ export function imageControls(root: HTMLElement, actions: ImageActions = {}, mea ...(actions.edit ? [{ label: tr("Edit image source"), icon: "code" as const, run: () => void run(actions.edit!) }] : []), ...(actions.open ? [{ label: tr("Open in new tab"), icon: "external" as const, run: () => void run(() => actions.open!(image)) }] : []), { label: tr("Copy path"), icon: "link", run: () => void run(() => navigator.clipboard.writeText(image.dataset.mdSrc || "")) }, - ...(actions.reveal && !/^https?:/i.test(image.dataset.mdSrc || "") ? [{ label: tr("Show in Explorer"), icon: "external" as const, run: () => void run(() => actions.reveal!(image)) }] : []), + ...(actions.reveal && !/^https?:/i.test(image.dataset.mdSrc || "") ? [{ label: tr(revealLabel()), icon: "folder" as const, run: () => void run(() => actions.reveal!(image)) }] : []), ]; openingMenu = true; try { menu = showActionMenu({ x, y, items, label: tr("Image actions") }, undefined, restore); } diff --git a/src/lib/editor/tableSelectionControls.ts b/src/lib/editor/tableSelectionControls.ts index c424707..634d193 100644 --- a/src/lib/editor/tableSelectionControls.ts +++ b/src/lib/editor/tableSelectionControls.ts @@ -136,7 +136,7 @@ export function tableSelectionControls(root: HTMLElement, wrapper: HTMLElement, { label: tr("Add row below"), icon: "row-after", run: () => structural("row", "after") }, sep, { label: tr("Move row up"), icon: "up", disabled: row <= 1, run: () => structural("row", "previous") }, { label: tr("Move row down"), icon: "down", disabled: row === 0 || row === lastRow, run: () => structural("row", "next") }, sep, - { label: tr("Duplicate row"), icon: "copy", run: () => structural("row", "duplicate") }, + { label: tr("Duplicate row"), icon: "duplicate", run: () => structural("row", "duplicate") }, { label: tr("Delete row"), icon: "trash", run: () => structural("row", "delete") }, ] }, { label: tr("Column"), icon: "column", children: [ @@ -145,7 +145,7 @@ export function tableSelectionControls(root: HTMLElement, wrapper: HTMLElement, { label: tr("Move column left"), icon: "move-left", disabled: column === 0, run: () => structural("column", "previous") }, { label: tr("Move column right"), icon: "move-right", disabled: column === lastColumn, run: () => structural("column", "next") }, sep, ...alignmentItems, sep, - { label: tr("Duplicate column"), icon: "copy", run: () => structural("column", "duplicate") }, + { label: tr("Duplicate column"), icon: "duplicate", run: () => structural("column", "duplicate") }, { label: tr("Delete column"), icon: "trash", run: () => structural("column", "delete") }, ] }, sep, { label: tr("Sort by column (A to Z)"), icon: "sort-asc", disabled: lastRow < 2, run: () => { range ??= cellRange; apply(text => sortTableColumn(text, column)); } }, diff --git a/src/lib/i18n/messages.ts b/src/lib/i18n/messages.ts index e26a25a..0ef6ec6 100644 --- a/src/lib/i18n/messages.ts +++ b/src/lib/i18n/messages.ts @@ -1109,12 +1109,6 @@ export const messageRows: [string, string, string, string][] = [ "システムのパス", "系统路径" ], - [ - "Show in system explorer", - "Afficher dans l’explorateur système", - "システムのエクスプローラーで表示", - "在系统文件管理器中显示" - ], [ "Blank note", "Note vide", @@ -1325,30 +1319,6 @@ export const messageRows: [string, string, string, string][] = [ "ブックマークを削除", "删除书签" ], - [ - "Copy workspace paths", - "Copier les chemins de travail", - "ワークスペース内のパスをコピー", - "复制工作区路径" - ], - [ - "Copy workspace path", - "Copier le chemin de travail", - "ワークスペース内のパスをコピー", - "复制工作区路径" - ], - [ - "Copy system paths", - "Copier les chemins système", - "システムのパスをコピー", - "复制系统路径" - ], - [ - "Copy system path", - "Copier le chemin système", - "システムのパスをコピー", - "复制系统路径" - ], [ "Rename", "Renommer", @@ -1847,12 +1817,6 @@ export const messageRows: [string, string, string, string][] = [ "広告ブロックリスト", "广告屏蔽列表" ], - [ - "One HTTPS filter list URL per line, up to eight lists. New lists download when you save.", - "Une URL HTTPS par ligne, huit listes maximum. Les nouvelles listes sont téléchargées lors de l’enregistrement.", - "1行に1つのHTTPSフィルターリストURLを入力します。最大8件。保存時に新しいリストをダウンロードします。", - "每行一个 HTTPS 过滤列表网址,最多八个。保存时下载新列表。" - ], [ "Personal filter rules", "Règles de filtrage personnelles", @@ -1949,18 +1913,6 @@ export const messageRows: [string, string, string, string][] = [ "ブラウザー設定を保存中…", "正在保存浏览器设置…" ], - [ - "Saving…", - "Enregistrement…", - "保存中…", - "正在保存…" - ], - [ - "Save browser settings", - "Enregistrer les paramètres du navigateur", - "ブラウザー設定を保存", - "保存浏览器设置" - ], [ "Individual web data", "Données web individuelles", @@ -3466,6 +3418,12 @@ export const messageRows: [string, string, string, string][] = [ ["Resize the outline", "Redimensionner le plan", "アウトラインのサイズを変更", "调整大纲大小"], ["Resize the terminal", "Redimensionner le terminal", "ターミナルのサイズを変更", "调整终端大小"], ["Leave the text, then press Tab", "Quitter le texte, puis appuyer sur Tab", "テキストから出て、Tab キーを押す", "离开文本,然后按 Tab"], + ["One HTTPS filter list URL per line, up to eight lists. New lists download when you leave the field.", "Une URL HTTPS par ligne, huit listes maximum. Les nouvelles listes sont téléchargées quand vous quittez le champ.", "1行に1つのHTTPSフィルターリストURLを入力します。最大8件。欄から移動すると新しいリストをダウンロードします。", "每行一个 HTTPS 过滤列表网址,最多八个。离开此字段时下载新列表。"], + ["1 result", "1 résultat", "1 件の結果", "1 个结果"], + ["{count} results in {files} files", "{count} résultats dans {files} fichiers", "{files} 個のファイルに {count} 件の結果", "{files} 个文件中有 {count} 个结果"], + ["Remove bookmark: {name}", "Retirer le signet : {name}", "ブックマークを削除: {name}", "移除书签:{name}"], + ["Show in Finder", "Afficher dans le Finder", "Finder で表示", "在访达中显示"], + ["Show in file manager", "Afficher dans le gestionnaire de fichiers", "ファイルマネージャーで表示", "在文件管理器中显示"], ]; export const catalogs: Record, Record> = { fr: Object.fromEntries(messageRows.map(row => [row[0], row[1]])), diff --git a/src/lib/layout/BookmarksPane.svelte b/src/lib/layout/BookmarksPane.svelte index f8f4d93..5ed5f7d 100644 --- a/src/lib/layout/BookmarksPane.svelte +++ b/src/lib/layout/BookmarksPane.svelte @@ -1,6 +1,7 @@
@@ -21,22 +29,17 @@ {:else}
    {#each bookmarks as rel (rel)} + {@const item = parts(rel)}
  • - + void remove(rel)} />
  • {/each}
{/if} + {#if error}{/if}
diff --git a/src/lib/layout/ContextMenu.svelte b/src/lib/layout/ContextMenu.svelte index fc53b8a..ed5337f 100644 --- a/src/lib/layout/ContextMenu.svelte +++ b/src/lib/layout/ContextMenu.svelte @@ -27,7 +27,7 @@ if (item.kind === "sep") return { separator: true }; if (item.kind === "group") return { label: item.label, icon: item.icon, children: convert(item.items), ...(item.run ? { run: () => { close(true); item.run?.(); } } : {}) }; - return { label: item.label, icon: item.icon, disabled: item.disabled, run: () => { + return { label: item.label, icon: item.icon, disabled: item.disabled, danger: item.danger, run: () => { close(true); item.run(); } }; diff --git a/src/lib/layout/FileTree.svelte b/src/lib/layout/FileTree.svelte index 2c4189b..a6ca98b 100644 --- a/src/lib/layout/FileTree.svelte +++ b/src/lib/layout/FileTree.svelte @@ -35,6 +35,7 @@ import type { MenuItem } from "./menuTypes"; import TreeNode from "./TreeNode.svelte"; import IconButton from "$lib/ui/IconButton.svelte"; + import { revealLabel } from "$lib/ui/menuItems"; import { dropWorkspaceImage, highlightImageDrop } from "$lib/editor/workspaceImageDrop"; import { pluginDocuments, pluginDocumentTypes, inspectPluginDocuments, createPluginDocument } from "$lib/plugins/external"; @@ -785,7 +786,7 @@ ...(templates.length || onManageTemplates ? [{ kind: "group" as const, label: $t("New note"), icon: "file-plus" as const, run: () => { void fromTemplate(); }, items: [ { kind: "action" as const, label: $t("Blank note"), icon: "file-plus" as const, run: () => { void fromTemplate(); } }, ...templates.map(template => ({ kind: "action" as const, label: template.name, icon: "file-plus" as const, run: () => { void fromTemplate(template); } })), - ...(onManageTemplates ? [{ kind: "sep" as const }, { kind: "action" as const, label: $t("Manage templates…"), icon: "copy" as const, run: onManageTemplates }] : []), + ...(onManageTemplates ? [{ kind: "sep" as const }, { kind: "action" as const, label: $t("Manage templates…"), icon: "template" as const, run: onManageTemplates }] : []), ] }] : [{ kind: "action" as const, label: $t("New note"), icon: "file-plus" as const, run: () => { void fromTemplate(); } }]), { kind: "action", @@ -815,141 +816,104 @@ ]; } - function folderActions(parent: string): MenuItem[] { + // The file menu has one order: open, clipboard, organize, show and copy path, history, then Delete in the error color. + function terminalItem(parent: string): MenuItem { + return { kind: "action", label: $t("Open in terminal"), icon: "terminal", run: () => { void workspaceOpenTerminal(parent).catch(reason => error = String(reason)); } }; + } + + function pasteItem(parent: string): MenuItem { + return { kind: "action", label: $t("Paste"), icon: "paste", disabled: !clipboard || clipboard.root !== workspaceRoot || moving, run: () => { void pasteEntries(parent); } }; + } + + function moveHistoryItems(): MenuItem[] { return [ - { kind: "action", label: $t("Open in terminal"), icon: "terminal", run: () => { void workspaceOpenTerminal(parent).catch(reason => error = String(reason)); } }, - { kind: "action", label: $t("Paste"), icon: "paste", disabled: !clipboard || clipboard.root !== workspaceRoot || moving, run: () => { void pasteEntries(parent); } }, - { kind: "sep" }, { kind: "action", label: undoMoves.at(-1)?.action === "rename" ? $t("Undo rename") : $t("Undo file move"), icon: "undo", disabled: !undoMoves.length || moving, run: () => { void replayMoves(); } }, { kind: "action", label: redoMoves.at(-1)?.action === "rename" ? $t("Redo rename") : $t("Redo file move"), icon: "redo", disabled: !redoMoves.length || moving, run: () => { void replayMoves(true); } }, ]; } + function revealItem(entries: TreeEntry[] | null): MenuItem { + return { + kind: "action", + label: $t(revealLabel()), + icon: "folder", + run: () => { + void (async () => { + if (!entries) { await workspaceReveal("").catch((err) => { error = err instanceof Error ? err.message : String(err); }); return; } + const result = await runTreeActions(entries, item => workspaceReveal(item.rel_path)); + error = result.failures.length ? result.failures.join("\n") : null; + })(); + }, + }; + } + function menuItems(entry: TreeEntry | null): MenuItem[] { if (!entry) { return [ ...paneMenuItems(""), { kind: "sep" }, - ...folderActions(""), + terminalItem(""), { kind: "sep" }, - { - kind: "action", - label: $t("Show in Explorer"), - icon: "folder", - run: () => { - void workspaceReveal("").catch((err) => { - error = err instanceof Error ? err.message : String(err); - }); - }, - }, + pasteItem(""), + { kind: "sep" }, + revealItem(null), + { kind: "sep" }, + ...moveHistoryItems(), ]; } const entries = actionEntries(entry, selection.paths, visiblePaths, findEntry); const multiple = entries.length > 1; const pinned = entries.every(item => pins.has(item.rel_path)); const bookmarked = entries.every(item => bookmarks.has(item.rel_path)); - const createItems = - !multiple && entry.kind === "folder" - ? [...paneMenuItems(entry.rel_path), { kind: "sep" as const }] - : []; + const parent = entry.kind === "folder" ? entry.rel_path : parentRel(entry.rel_path); + const copySystemPaths = async () => { + try { + const paths = await Promise.all(entries.map(item => workspaceAbsPath(item.rel_path))); + await copyText(paths.join("\n"), multiple ? $t("Copied system paths") : $t("Copied system path")); + } catch (err) { + error = err instanceof Error ? err.message : String(err); + } + }; return [ - ...createItems, - ...(!multiple && entry.kind === "file" && /\.md$/i.test(entry.name) && onSaveTemplate ? [ - { kind: "action" as const, label: $t("Save as template"), icon: "copy" as const, run: () => onSaveTemplate?.(entry) }, - ] : []), + ...(!multiple && entry.kind === "folder" ? [...paneMenuItems(entry.rel_path), { kind: "sep" as const }] : []), ...(!multiple && entry.kind === "file" ? [ - { kind: "action" as const, label: $t("Open in new tab"), icon: "file-plus" as const, run: () => onOpenFile(entry, true) }, + { kind: "action" as const, label: $t("Open in new tab"), icon: "tab" as const, run: () => onOpenFile(entry, true) }, { kind: "action" as const, label: $t("Open in default app"), icon: "external" as const, run: () => { void workspaceOpenDefault(entry.rel_path).catch(reason => error = String(reason)); } }, ] : []), - ...folderActions(entry.kind === "folder" ? entry.rel_path : parentRel(entry.rel_path)), + terminalItem(parent), { kind: "sep" }, { kind: "action", label: $t("Cut"), icon: "cut", run: () => { clipboard = { root: workspaceRoot, paths: selectionRoots(entries).map(item => item.rel_path), cut: true }; } }, { kind: "action", label: $t("Copy"), icon: "copy", run: () => { clipboard = { root: workspaceRoot, paths: selectionRoots(entries).map(item => item.rel_path), cut: false }; } }, - { - kind: "action", - label: multiple ? $t("Make copies ({count})", { count: entries.length }) : $t("Make a copy"), - icon: "copy", - run: () => { void copyEntries(entries); }, - }, + pasteItem(parent), + { kind: "action", label: multiple ? $t("Make copies ({count})", { count: entries.length }) : $t("Make a copy"), icon: "duplicate", run: () => { void copyEntries(entries); } }, + { kind: "sep" }, + { kind: "action", label: $t("Rename"), icon: "rename", disabled: multiple, run: () => { startRename(entry); } }, { kind: "action", label: bookmarked ? (multiple ? $t("Remove bookmarks") : $t("Remove bookmark")) : $t("Bookmark"), icon: "bookmark", - run: () => { - void persistMarks(current => ({ - ...current, - bookmarks: setSelectedMarks(current.bookmarks, entries, !bookmarked), - })); - }, + run: () => { void persistMarks(current => ({ ...current, bookmarks: setSelectedMarks(current.bookmarks, entries, !bookmarked) })); }, }, - { kind: "sep" }, - { - kind: "action", - label: multiple ? $t("Copy workspace paths") : $t("Copy workspace path"), - icon: "copy", - run: () => { - void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? $t("Copied workspace paths") : $t("Copied workspace path")); - }, - }, - { - kind: "action", - label: multiple ? $t("Copy system paths") : $t("Copy system path"), - icon: "copy", - run: () => { - void (async () => { - try { - const paths = await Promise.all(entries.map(item => workspaceAbsPath(item.rel_path))); - await copyText(paths.join("\n"), multiple ? $t("Copied system paths") : $t("Copied system path")); - } catch (err) { - error = err instanceof Error ? err.message : String(err); - } - })(); - }, - }, - { - kind: "action", - label: $t("Show in Explorer"), - icon: "folder", - run: () => { - void (async () => { - const result = await runTreeActions(entries, item => workspaceReveal(item.rel_path)); - error = result.failures.length ? result.failures.join("\n") : null; - })(); - }, - }, - { kind: "sep" }, { kind: "action", label: pinned ? $t("Unpin") : $t("Pin"), icon: "pin", - run: () => { - void persistMarks(current => ({ - ...current, - pins: setSelectedMarks(current.pins, entries, !pinned), - })); - }, - }, - { - kind: "action", - label: $t("Rename"), - icon: "rename", - disabled: multiple, - run: () => { - startRename(entry); - }, - }, - { - kind: "action", - label: multiple ? $t("Delete ({count})", { count: entries.length }) : $t("Delete"), - icon: "trash", - run: () => { void deleteEntries(entries); }, - }, - { - kind: "action", - label: multiple ? $t("Delete permanently ({count})", { count: entries.length }) : $t("Delete permanently"), - icon: "trash", - run: () => { void deleteEntries(entries, true); }, + run: () => { void persistMarks(current => ({ ...current, pins: setSelectedMarks(current.pins, entries, !pinned) })); }, }, + ...(!multiple && entry.kind === "file" && /\.md$/i.test(entry.name) && onSaveTemplate ? [ + { kind: "action" as const, label: $t("Save as template"), icon: "template" as const, run: () => onSaveTemplate?.(entry) }, + ] : []), + { kind: "sep" }, + revealItem(entries), + { kind: "group", label: $t("Copy path"), icon: "copy", items: [ + { kind: "action", label: $t("Workspace path"), icon: "copy", run: () => { void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? $t("Copied workspace paths") : $t("Copied workspace path")); } }, + { kind: "action", label: $t("System path"), icon: "copy", run: () => { void copySystemPaths(); } }, + ] }, + { kind: "sep" }, + ...moveHistoryItems(), + { kind: "sep" }, + { kind: "action", label: multiple ? $t("Delete ({count})", { count: entries.length }) : $t("Delete"), icon: "trash", danger: true, run: () => { void deleteEntries(entries); } }, + { kind: "action", label: multiple ? $t("Delete permanently ({count})", { count: entries.length }) : $t("Delete permanently"), icon: "trash", danger: true, run: () => { void deleteEntries(entries, true); } }, ]; } diff --git a/src/lib/layout/OutlinePane.svelte b/src/lib/layout/OutlinePane.svelte index 7041cd2..b2577df 100644 --- a/src/lib/layout/OutlinePane.svelte +++ b/src/lib/layout/OutlinePane.svelte @@ -126,6 +126,7 @@ background: transparent; color: var(--rs-text); text-align: left; + min-height: 24px; padding: 3px 8px; overflow: hidden; text-overflow: ellipsis; diff --git a/src/lib/layout/SearchPane.svelte b/src/lib/layout/SearchPane.svelte index dafc7c2..db7a482 100644 --- a/src/lib/layout/SearchPane.svelte +++ b/src/lib/layout/SearchPane.svelte @@ -12,8 +12,31 @@ let { onOpen, searchRequest }: Props = $props(); let query = $state(""); let hits = $state([]); + let searched = $state(""); let error = $state(null); + // Hits in groups by file, in the order of the first hit of each file. + const groups = $derived.by(() => { + const files = new Map(); + for (const hit of hits) files.set(hit.rel_path, [...files.get(hit.rel_path) ?? [], hit]); + return [...files].map(([path, items]) => ({ path, name: path.split("/").pop() ?? path, folder: path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "", items })); + }); + + /** The parts of a hit line, with the parts that match the query marked. */ + function parts(text: string, term: string) { + const lower = text.toLowerCase(), needle = term.toLowerCase(); + if (!needle) return [{ text, match: false }]; + const result: { text: string; match: boolean }[] = []; + let from = 0; + for (let index = lower.indexOf(needle); index >= 0; index = lower.indexOf(needle, index + needle.length)) { + if (index > from) result.push({ text: text.slice(from, index), match: false }); + result.push({ text: text.slice(index, index + needle.length), match: true }); + from = index + needle.length; + } + if (from < text.length) result.push({ text: text.slice(from), match: false }); + return result; + } + let generation = 0; $effect(() => { if (searchRequest) { query = searchRequest.text; void run(searchRequest.text); } }); @@ -28,6 +51,7 @@ const results = await workspaceSearch(q); if (version !== generation) return; hits = results; + searched = q; error = null; } catch (err) { if (version !== generation) return; @@ -51,24 +75,23 @@ {#if error}

{error}

{/if} -
    - {#each hits as hit (hit.rel_path + hit.line + hit.text)} -
  • - + {#if searched} +

    {hits.length === 1 ? $t("1 result") : $t("{count} results in {files} files", { count: hits.length, files: groups.length })}

    + {/if} +
      + {#each groups as group (group.path)} +
    • +
      {group.name}{#if group.folder}{group.folder}{/if}{group.items.length}
      +
        + {#each group.items as hit (hit.line + hit.text)} +
      • + +
      • + {/each} +
    • {/each}
    @@ -110,37 +133,75 @@ ul { list-style: none; margin: 0; + padding: 0; + } + + .results { padding: 0 0 12px; overflow: auto; } + .summary { + margin: 0 10px 6px; + color: var(--rs-text-dim); + font-size: 12px; + } + + .file + .file { margin-top: 6px; } + + .file-name { + display: flex; + align-items: baseline; + gap: 6px; + min-width: 0; + padding: 4px 10px; + } + + .name { color: var(--rs-text-strong); font-weight: 600; white-space: nowrap; } + .folder { min-width: 0; overflow: hidden; color: var(--rs-text-dim); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; } + .count { margin-left: auto; padding: 0 6px; border-radius: 9px; background: var(--rs-bg-active); color: var(--rs-text); font-size: 11px; } + button { + display: flex; + align-items: baseline; + gap: 8px; width: 100%; + min-height: 24px; border-radius: var(--rs-control-radius); border: 0; background: transparent; text-align: left; - padding: 6px 10px; + padding: 3px 10px 3px 18px; } button:hover { background: var(--rs-bg-active); } - .path { - display: block; - color: var(--rs-accent); - font-size: 12px; + .line { + flex: 0 0 auto; + min-width: 2ch; + color: var(--rs-text-dim); + font-size: 11px; + text-align: right; } .text { - display: block; - color: var(--rs-text-dim); + min-width: 0; + color: var(--rs-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + /* A match uses the search match fill of the theme, so the text keeps its contrast. */ + mark { + border-radius: 2px; + background: var(--rs-item-selection-bg); + box-shadow: inset 0 -2px 0 var(--rs-accent); + color: var(--rs-text-strong); + } + .error { margin: 8px 10px; color: var(--rs-error); diff --git a/src/lib/layout/SettingsDialog.svelte b/src/lib/layout/SettingsDialog.svelte index 1397cd3..c81fda7 100644 --- a/src/lib/layout/SettingsDialog.svelte +++ b/src/lib/layout/SettingsDialog.svelte @@ -70,9 +70,12 @@ const selectedPlugin = $derived(pluginSections.find(item => item.id === selected?.id)); $effect(() => { seconds = settings.autosaveSeconds; }); + let searchInput: HTMLInputElement | undefined = $state(); onMount(() => { const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null; dialog.showModal(); + // The first focus goes to the settings search, not to the first window control. + searchInput?.focus(); return () => { dialog.close(); previous?.focus(); }; }); @@ -117,7 +120,7 @@
    {#if !help}