Give way in narrow windows and use one icon for each action
Phase 5-6. - Side panes give way when the window becomes narrow: the outline below 1100 pixels, the side pane below 800 pixels. They come back when the window grows. A pane that the user opens in a narrow window stays open, and the saved layout keeps the wide-window choice. - One function has one icon. The SDK icon set gets duplicate, template, and tab. The reveal action has one label for each platform (Show in Explorer, Show in Finder, Show in file manager). - The file menu follows one order: open, clipboard, organize, show and copy path, history, then Delete and Delete permanently in the error color after a separator. The tree copies paths through a Copy path submenu, as the tab menu does. - 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 one switch design (src/lib/ui/switch.css). Browser settings apply at once, and the Save button is gone. The Settings window opens with the focus on its search. - Targets of at least 24 pixels: the tab close button, outline rows, switches, and the settings search. - Catalog rows in French, Japanese, and Simplified Chinese. - Docs: UI-052, ui-design.md, and the user guide. Tests: the new layout/panesAndSettings. Tests that closed or opened panes by hand around narrow windows now rely on the new behavior, or wait for the panes to give way before they reopen one. Tests that read the old menu labels or the browser Save button use the new ones.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import type { WorkspaceSession } from "$lib/workspace/session.svelte";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
|
||||
@@ -11,6 +12,13 @@
|
||||
|
||||
let { session, onOpen }: Props = $props();
|
||||
const bookmarks = $derived(session.marks.current.bookmarks);
|
||||
let error = $state("");
|
||||
const parts = (rel: string) => ({ name: rel.split("/").pop() ?? rel, folder: rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "" });
|
||||
|
||||
async function remove(rel: string) {
|
||||
try { await session.marks.update(marks => ({ ...marks, bookmarks: marks.bookmarks.filter(path => path !== rel) })); error = ""; }
|
||||
catch (reason) { error = String(reason); }
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="pane">
|
||||
@@ -21,22 +29,17 @@
|
||||
{:else}
|
||||
<ul>
|
||||
{#each bookmarks as rel (rel)}
|
||||
{@const item = parts(rel)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() =>
|
||||
onOpen({
|
||||
name: rel.split("/").pop() ?? rel,
|
||||
rel_path: rel,
|
||||
kind: "file",
|
||||
})}
|
||||
>
|
||||
{rel}
|
||||
<button type="button" title={rel} onclick={() => onOpen({ name: item.name, rel_path: rel, kind: "file" })}>
|
||||
<span class="name">{item.name}</span>{#if item.folder}<span class="folder">{item.folder}</span>{/if}
|
||||
</button>
|
||||
<IconButton icon="close" label={$t("Remove bookmark: {name}", { name: item.name })} onclick={() => void remove(rel)} />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@@ -69,18 +72,33 @@
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
li > button {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 24px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--rs-text);
|
||||
text-align: left;
|
||||
padding: 6px 10px;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
li > button:hover {
|
||||
background: var(--rs-bg-active);
|
||||
color: var(--rs-text-strong);
|
||||
}
|
||||
|
||||
.name, .folder { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.folder { color: var(--rs-text-dim); font-size: 12px; }
|
||||
.error { margin: 8px 10px; color: var(--rs-error); }
|
||||
</style>
|
||||
|
||||
@@ -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();
|
||||
} };
|
||||
|
||||
+65
-101
@@ -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); } },
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -126,6 +126,7 @@
|
||||
background: transparent;
|
||||
color: var(--rs-text);
|
||||
text-align: left;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@@ -12,8 +12,31 @@
|
||||
let { onOpen, searchRequest }: Props = $props();
|
||||
let query = $state("");
|
||||
let hits = $state<SearchHit[]>([]);
|
||||
let searched = $state("");
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
// Hits in groups by file, in the order of the first hit of each file.
|
||||
const groups = $derived.by(() => {
|
||||
const files = new Map<string, SearchHit[]>();
|
||||
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}
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
<ul>
|
||||
{#each hits as hit (hit.rel_path + hit.line + hit.text)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() =>
|
||||
onOpen(
|
||||
{
|
||||
name: hit.rel_path.split("/").pop() ?? hit.rel_path,
|
||||
rel_path: hit.rel_path,
|
||||
kind: "file",
|
||||
},
|
||||
hit.line,
|
||||
)}
|
||||
>
|
||||
<span class="path">{hit.rel_path}:{hit.line}</span>
|
||||
<span class="text">{hit.text}</span>
|
||||
</button>
|
||||
{#if searched}
|
||||
<p class="summary" role="status">{hits.length === 1 ? $t("1 result") : $t("{count} results in {files} files", { count: hits.length, files: groups.length })}</p>
|
||||
{/if}
|
||||
<ul class="results">
|
||||
{#each groups as group (group.path)}
|
||||
<li class="file">
|
||||
<div class="file-name" title={group.path}><span class="name">{group.name}</span>{#if group.folder}<span class="folder">{group.folder}</span>{/if}<span class="count">{group.items.length}</span></div>
|
||||
<ul>
|
||||
{#each group.items as hit (hit.line + hit.text)}
|
||||
<li>
|
||||
<button type="button" onclick={() => onOpen({ name: group.name, rel_path: hit.rel_path, kind: "file" }, hit.line)}>
|
||||
<span class="line">{hit.line}</span>
|
||||
<span class="text">{#each parts(hit.text, searched) as part}{#if part.match}<mark>{part.text}</mark>{:else}{part.text}{/if}{/each}</span>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
@@ -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);
|
||||
|
||||
@@ -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 @@
|
||||
<div class="body">
|
||||
{#if !help}
|
||||
<aside>
|
||||
<label class="search"><Icon icon="search" /><input aria-label={$t("Search settings")} placeholder={$t("Search settings…")} bind:value={query} /></label>
|
||||
<label class="search"><Icon icon="search" /><input bind:this={searchInput} aria-label={$t("Search settings")} placeholder={$t("Search settings…")} bind:value={query} /></label>
|
||||
<p class="nav-heading">{$t("Preferences")}</p>
|
||||
<nav aria-label={$t("Settings categories")}>
|
||||
{#each matches as item}
|
||||
@@ -142,25 +145,25 @@
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="show-file-title">{$t("File name title")}</label><p id="file-title-description">{$t("Show the file name above each Markdown note in Write and Read.")}</p></div>
|
||||
<input id="show-file-title" class="switch" type="checkbox" role="switch" aria-describedby="file-title-description" checked={settings.showFileTitle} onchange={event => apply({ ...settings, showFileTitle: event.currentTarget.checked })} />
|
||||
<input id="show-file-title" class="rs-switch" type="checkbox" role="switch" aria-describedby="file-title-description" checked={settings.showFileTitle} onchange={event => apply({ ...settings, showFileTitle: event.currentTarget.checked })} />
|
||||
</div>
|
||||
</div>
|
||||
<h3>{$t("Tables")}</h3>
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="table-formulas">{$t("Table formulas")}</label><p id="table-formulas-description">{$t("Calculate table cells that start with =. When this is off, formulas show as text.")}</p></div>
|
||||
<input id="table-formulas" class="switch" type="checkbox" role="switch" aria-describedby="table-formulas-description" checked={settings.tableFormulas} onchange={event => apply({ ...settings, tableFormulas: event.currentTarget.checked })} />
|
||||
<input id="table-formulas" class="rs-switch" type="checkbox" role="switch" aria-describedby="table-formulas-description" checked={settings.tableFormulas} onchange={event => apply({ ...settings, tableFormulas: event.currentTarget.checked })} />
|
||||
</div>
|
||||
</div>
|
||||
<h3>{$t("Files")}</h3>
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="show-internal-folder">{$t("Show .runestone folder")}</label><p id="internal-folder-description">{$t("Show workspace settings and plugin data in the file tree.")}</p></div>
|
||||
<input id="show-internal-folder" class="switch" type="checkbox" role="switch" aria-describedby="internal-folder-description" checked={settings.showInternalFolder} onchange={event => apply({ ...settings, showInternalFolder: event.currentTarget.checked })} />
|
||||
<input id="show-internal-folder" class="rs-switch" type="checkbox" role="switch" aria-describedby="internal-folder-description" checked={settings.showInternalFolder} onchange={event => apply({ ...settings, showInternalFolder: event.currentTarget.checked })} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-enabled">{$t("Auto-save")}</label><p id="autosave-description">{$t("Save changed notes and scripts, including background tabs.")}</p></div>
|
||||
<input id="autosave-enabled" class="switch" type="checkbox" role="switch" aria-describedby="autosave-description" checked={settings.autosaveEnabled} onchange={event => { apply({ ...settings, autosaveEnabled: event.currentTarget.checked }); event.currentTarget.checked = settings.autosaveEnabled; }} />
|
||||
<input id="autosave-enabled" class="rs-switch" type="checkbox" role="switch" aria-describedby="autosave-description" checked={settings.autosaveEnabled} onchange={event => { apply({ ...settings, autosaveEnabled: event.currentTarget.checked }); event.currentTarget.checked = settings.autosaveEnabled; }} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-seconds">{$t("Auto-save interval")}</label><p id="interval-description">{$t("Time between saves, even while you type. Choose 1–300 seconds.")}</p></div>
|
||||
@@ -209,7 +212,7 @@
|
||||
aside { width: 220px; flex-shrink: 0; padding: 12px 8px; background: var(--rs-bg-elevated); border-right: 1px solid var(--rs-border); display: flex; flex-direction: column; overflow: auto; }
|
||||
.search { display: flex; gap: var(--rs-settings-gap); align-items: center; min-height: var(--rs-settings-control-height); background: var(--rs-bg-active); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); padding: 4px 8px; color: var(--rs-text-dim); }
|
||||
.search:focus-within { outline: 2px solid var(--rs-focus); }
|
||||
.search input { width: 100%; min-width: 0; border: 0; padding: 0; outline: none; background: transparent; color: var(--rs-text); }
|
||||
.search input { align-self: stretch; width: 100%; min-width: 0; min-height: 24px; border: 0; padding: 0; outline: none; background: transparent; color: var(--rs-text); }
|
||||
.nav-heading { margin: 16px 8px 6px; font-size: 11px; color: var(--rs-text-dim); }
|
||||
nav { display: flex; flex-direction: column; gap: 2px; }
|
||||
nav button { display: flex; align-items: center; gap: var(--rs-settings-gap); width: 100%; min-height: var(--rs-settings-control-height); padding: 5px 8px; border: 0; border-radius: var(--rs-control-radius); background: transparent; text-align: left; }
|
||||
@@ -229,10 +232,6 @@
|
||||
.setting-row p { margin: 3px 0 0; font-size: var(--rs-settings-description-size); }
|
||||
.language-row { flex-wrap: wrap; }
|
||||
.language-picker { display:flex; align-items:center; gap:var(--rs-settings-gap); max-width:100%; }
|
||||
.switch { appearance: none; width: 38px; height: 22px; flex: 0 0 38px; margin: 0; border-radius: 20px; background: var(--rs-bg-active); border: 1px solid var(--rs-text-dim); cursor: pointer; }
|
||||
.switch::before { content: ""; display: block; width: 16px; height: 16px; margin: 2px; background: var(--rs-text); border-radius: 50%; transition: transform .12s; }
|
||||
.switch:checked { background: var(--rs-accent); border-color: var(--rs-accent); }
|
||||
.switch:checked::before { transform: translateX(16px); background: var(--rs-bg); }
|
||||
.interval { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11px; color: var(--rs-text-dim); }
|
||||
.interval input { width: 72px; min-height: var(--rs-settings-control-height); padding: 4px 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font-size: 13px; }
|
||||
.interval input:disabled { color: var(--rs-text-dim); }
|
||||
|
||||
@@ -497,10 +497,10 @@
|
||||
border-radius: var(--rs-control-radius);
|
||||
background: transparent;
|
||||
color: var(--rs-text-dim);
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-right: 4px;
|
||||
flex: 0 0 22px;
|
||||
flex: 0 0 24px;
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import { renameSelection } from "$lib/workspace/renamePath";
|
||||
import TreeNode from "./TreeNode.svelte";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import { actionIcons } from "$lib/ui/actionIcons";
|
||||
import { pluginDocuments } from "$lib/plugins/external";
|
||||
|
||||
type Props = {
|
||||
@@ -134,7 +135,8 @@
|
||||
{#if edges?.bottom != null && edges.bottom > 0}<span class="selection-step bottom"></span>{/if}
|
||||
</span>
|
||||
{/if}
|
||||
<span class="twist" class:open={isOpen} class:folder={entry.kind === "folder"}></span>
|
||||
<!-- Folders use the shared chevron, as headings and menus do. -->
|
||||
<span class="twist" class:open={isOpen} class:folder={entry.kind === "folder"}>{#if entry.kind === "folder"}<svg viewBox="0 0 24 24" aria-hidden="true">{@html actionIcons.chevron}</svg>{/if}</span>
|
||||
{#if $pluginDocuments[entry.rel_path]}
|
||||
<span class="document-icon" title={$pluginDocuments[entry.rel_path].title}><Icon icon={$pluginDocuments[entry.rel_path].icon === "kanban" ? "kanban" : "files"} /></span>
|
||||
{/if}
|
||||
@@ -316,18 +318,21 @@
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.twist.folder::before {
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 5px 0 5px 8px;
|
||||
border-color: transparent transparent transparent currentColor;
|
||||
transform: rotate(0deg);
|
||||
.twist svg {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
transition: transform .12s;
|
||||
}
|
||||
|
||||
.twist.folder.open::before {
|
||||
transform: rotate(90deg);
|
||||
.twist.open svg { transform: rotate(90deg); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.twist svg { transition: none; }
|
||||
}
|
||||
|
||||
.name {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
import { tabsToClose, type TabCloseScope } from "$lib/workspace/tabActions";
|
||||
import { orderWorkbenchTabs, type WorkbenchTab } from "$lib/workspace/workbenchTabs";
|
||||
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
|
||||
import { revealLabel } from "$lib/ui/menuItems";
|
||||
import { createNote, noteTemplates, saveNoteTemplate, type NoteTemplate } from "$lib/workspace/templates";
|
||||
import { requestText } from "$lib/workspace/dialogs.svelte";
|
||||
import TextDialog from "./TextDialog.svelte";
|
||||
@@ -678,7 +679,7 @@
|
||||
const items: ActionMenuItem[] = [];
|
||||
if (tab.kind === "text" && isMarkdownPath(tab.relPath)) {
|
||||
items.push(
|
||||
{ label: $t("Save as template"), icon: "copy", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
|
||||
{ label: $t("Save as template"), icon: "template", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
|
||||
{ label: $t("View"), icon: "book", children: [
|
||||
{ label: $t("Write"), icon: "paragraph", radio: true, checked: viewMode === "write", run: () => setDocumentView(documentPanes.active, "write") },
|
||||
{ label: $t("Source"), icon: "code", radio: true, checked: viewMode === "source", run: () => setDocumentView(documentPanes.active, "source") },
|
||||
@@ -691,13 +692,13 @@
|
||||
items.push({ separator: true },
|
||||
{ label: $t("Rename…"), icon: "rename", run: () => { void renameActive(); } },
|
||||
);
|
||||
if (tab.kind === "text") items.push({ label: $t("Save a copy…"), icon: "copy", run: () => { void saveCopy(); } });
|
||||
if (tab.kind === "text") items.push({ label: $t("Save a copy…"), icon: "duplicate", run: () => { void saveCopy(); } });
|
||||
items.push({ separator: true },
|
||||
{ label: $t("Copy path"), icon: "copy", children: [
|
||||
{ label: $t("Workspace path"), icon: "copy", run: () => { void copyTabPath(tab.relPath, false); } },
|
||||
{ label: $t("System path"), icon: "copy", run: () => { void copyTabPath(tab.relPath, true); } },
|
||||
] },
|
||||
{ label: $t("Show in system explorer"), icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
|
||||
{ label: $t(revealLabel()), icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
|
||||
);
|
||||
return items;
|
||||
}
|
||||
@@ -1041,7 +1042,7 @@
|
||||
if (valid()) status = $t("Bookmarked {name}", { name: file.name });
|
||||
}) },
|
||||
{ label: $t("Open in default app"), icon: "external", run: run(file => workspaceOpenDefault(file.rel_path)) },
|
||||
{ label: $t("Show in system explorer"), icon: "folder", run: run(file => workspaceReveal(file.rel_path)) },
|
||||
{ label: $t(revealLabel()), icon: "folder", run: run(file => workspaceReveal(file.rel_path)) },
|
||||
{ label: $t("Reveal file in navigation"), icon: "folder", run: run(async file => { closePluginSidebar(); leftView = "files"; leftOpen = true; await tick(); await fileTree?.revealPath(file.rel_path); }) },
|
||||
];
|
||||
}
|
||||
@@ -1132,9 +1133,34 @@
|
||||
} catch { error = $t("Could not read your layout. Default layout applies for this window."); }
|
||||
});
|
||||
|
||||
// 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.
|
||||
// At startup the saved layout applies as it is.
|
||||
let windowWidth = $state(window.innerWidth);
|
||||
let measured = false;
|
||||
const narrow = { left: false, right: false };
|
||||
const wide = { left: true, right: true };
|
||||
$effect(() => {
|
||||
if (!layoutReady || transferredWindow) return;
|
||||
try { saveWorkbenchLayout(localStorage, { leftOpen, rightOpen, leftWidth, rightWidth, leftView }); }
|
||||
const left = windowWidth < 800, right = windowWidth < 1100;
|
||||
untrack(() => {
|
||||
if (!measured) { measured = true; Object.assign(narrow, { left, right }); Object.assign(wide, { left: leftOpen, right: rightOpen }); return; }
|
||||
if (right !== narrow.right) {
|
||||
if (right) { wide.right = rightOpen; rightOpen = false; } else rightOpen = wide.right;
|
||||
narrow.right = right;
|
||||
}
|
||||
if (left !== narrow.left) {
|
||||
if (left) { wide.left = leftOpen; leftOpen = false; } else leftOpen = wide.left;
|
||||
narrow.left = left;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// The saved layout keeps the choice of a wide window.
|
||||
$effect(() => {
|
||||
if (!layoutReady || transferredWindow) return;
|
||||
const saved = { leftOpen: narrow.left ? wide.left : leftOpen, rightOpen: narrow.right ? wide.right : rightOpen };
|
||||
try { saveWorkbenchLayout(localStorage, { ...saved, leftWidth, rightWidth, leftView }); }
|
||||
catch { error = $t("Could not save your layout. Layout changes apply for this window only."); }
|
||||
});
|
||||
|
||||
@@ -1209,7 +1235,7 @@
|
||||
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeydown} onbeforeunload={(event) => { if (hasDirty) { event.preventDefault(); event.returnValue = ""; } }} />
|
||||
<svelte:window bind:innerWidth={windowWidth} onkeydown={onKeydown} onbeforeunload={(event) => { if (hasDirty) { event.preventDefault(); event.returnValue = ""; } }} />
|
||||
<TextDialog />
|
||||
<WorkspacePicker bind:this={workspacePicker} currentRoot={workspace?.root} anchor={workspaceAnchor} onOpen={openPath} />
|
||||
{#if preferences}<SettingsDialog {settings} help={preferences === "help"} onSave={updateSettings} onClose={() => preferences = null} />{/if}
|
||||
|
||||
@@ -6,6 +6,8 @@ export type MenuAction = {
|
||||
run: () => void;
|
||||
disabled?: boolean;
|
||||
icon?: ActionIcon;
|
||||
/** The action removes data. The menu shows it in the error color. */
|
||||
danger?: boolean;
|
||||
};
|
||||
|
||||
export type MenuSep = { kind: "sep" };
|
||||
|
||||
Reference in New Issue
Block a user