Add interface languages and improve themes and workspace controls for 0.1.36
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { loadMarks } from "$lib/workspace/marks";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
@@ -20,10 +21,10 @@
|
||||
</script>
|
||||
|
||||
<div class="pane">
|
||||
<div class="pane-label">Bookmarks</div>
|
||||
<div class="pane-label">{$t("Bookmarks")}</div>
|
||||
<BrowserSlot kind="bookmarks" />
|
||||
{#if bookmarks.length === 0}
|
||||
<p class="placeholder">Right-click a file and choose Bookmark.</p>
|
||||
<p class="placeholder">{$t("Right-click a file and choose Bookmark.")}</p>
|
||||
{:else}
|
||||
<ul>
|
||||
{#each bookmarks as rel (rel)}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { tick, untrack } from "svelte";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
@@ -75,12 +76,12 @@
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={keydown} />
|
||||
<div class="browser-window" role="application" aria-label="RuneStone browser">
|
||||
<div class="browser-window" role="application" aria-label={$t("RuneStone browser")}>
|
||||
<header class="header" data-tauri-drag-region>
|
||||
<TabBar {tabs} activePath={active} onSelect={select} onClose={close} onCloseTabs={close}
|
||||
onMove={move} onPin={pinPluginEditor} fileActions={() => []} tabActions={actions}
|
||||
tabDragData={dragData} onDropTab={(data, index) => void receive(data, index)} />
|
||||
<IconButton icon="plus" label="New browser tab (Ctrl T)" disabled={!browser?.newTab || opening} onclick={() => void newTab()} />
|
||||
<IconButton icon="plus" label={$t("New browser tab (Ctrl T)")} disabled={!browser?.newTab || opening} onclick={() => void newTab()} />
|
||||
<div class="window-drag-space" data-tauri-drag-region></div>
|
||||
<WindowControls onError={message => error = message} />
|
||||
</header>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import type { GitLineInfo } from "$lib/git/contracts";
|
||||
import EditorHost from "$lib/editor/EditorHost.svelte";
|
||||
@@ -128,18 +129,18 @@
|
||||
|
||||
{#if !buffer || buffer.kind === "empty"}
|
||||
<div class="empty">
|
||||
{#if onCloseSplit}<IconButton icon="close" label="Close split" onclick={onCloseSplit} />{/if}
|
||||
{#if onCloseSplit}<IconButton icon="close" label={$t("Close split")} onclick={onCloseSplit} />{/if}
|
||||
<div class="welcome-actions">
|
||||
{#if hasWorkspace}
|
||||
<div class="welcome-row">
|
||||
<button onclick={onNewFile}><Icon icon="file-plus" /> New file <kbd>Ctrl N</kbd></button>
|
||||
{#if onNewNote}<button onclick={onNewNote}><Icon icon="pen" /> New note</button>{/if}
|
||||
<button onclick={onQuickOpen}><Icon icon="search" /> Find file <kbd>Ctrl P</kbd></button>
|
||||
<button onclick={onNewFile}><Icon icon="file-plus" /> {$t("New file")} <kbd>Ctrl N</kbd></button>
|
||||
{#if onNewNote}<button onclick={onNewNote}><Icon icon="pen" /> {$t("New note")}</button>{/if}
|
||||
<button onclick={onQuickOpen}><Icon icon="search" /> {$t("Find file")} <kbd>Ctrl P</kbd></button>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="welcome-row">
|
||||
<button onclick={onOpenWorkspace}><Icon icon="folder-open" /> Open folder <kbd>Ctrl O</kbd></button>
|
||||
{#if onOpenBrowser}<button onclick={onOpenBrowser} disabled={browserOpening}><Icon icon="globe" /> {browserOpening ? "Opening browser…" : "Open browser"}</button>{/if}
|
||||
<button onclick={onOpenWorkspace}><Icon icon="folder-open" /> {$t("Open folder")} <kbd>Ctrl O</kbd></button>
|
||||
{#if onOpenBrowser}<button onclick={onOpenBrowser} disabled={browserOpening}><Icon icon="globe" /> {browserOpening ? $t("Opening browser…") : $t("Open browser")}</button>{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -153,25 +154,25 @@
|
||||
</span>
|
||||
{/if}
|
||||
<div class="actions" bind:this={modeControls}>
|
||||
{#if onCloseSplit}<IconButton icon="close" label="Close split" onclick={onCloseSplit} />{/if}
|
||||
{#if onCloseSplit}<IconButton icon="close" label={$t("Close split")} onclick={onCloseSplit} />{/if}
|
||||
{#if canPreview}
|
||||
<ModeSwitcher
|
||||
label="Document view"
|
||||
label={$t("Document view")}
|
||||
value={documentMode}
|
||||
options={[
|
||||
{ value: "edit", label: "Edit", icon: "pen" },
|
||||
{ value: "read", label: "Read", icon: "book-open" },
|
||||
{ value: "split", label: "Split", icon: "split" },
|
||||
{ value: "edit", label: $t("Edit"), icon: "pen" },
|
||||
{ value: "read", label: $t("Read"), icon: "book-open" },
|
||||
{ value: "split", label: $t("Split"), icon: "split" },
|
||||
]}
|
||||
onchange={setDocumentMode}
|
||||
/>
|
||||
{/if}
|
||||
<ModeSwitcher
|
||||
label="Editor layout"
|
||||
label={$t("Editor layout")}
|
||||
value={chrome}
|
||||
options={[
|
||||
{ value: "Ide", label: "IDE", icon: "code" },
|
||||
{ value: "Writing", label: "Writer", icon: "text" },
|
||||
{ value: "Ide", label: $t("IDE"), icon: "code" },
|
||||
{ value: "Writing", label: $t("Writer"), icon: "text" },
|
||||
]}
|
||||
shortcut=" (Ctrl E)"
|
||||
onchange={(mode) => { if (mode !== chrome) onToggleChrome?.(); }}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { onMount, tick, untrack } from "svelte";
|
||||
import { createNote, noteTemplates, type NoteTemplate } from "$lib/workspace/templates";
|
||||
import { confirm } from "@tauri-apps/plugin-dialog";
|
||||
@@ -19,7 +20,6 @@
|
||||
import { moveMarks, replayMoveMarks } from "$lib/workspace/treeMoveHistory";
|
||||
import { actionEntries, selectionRoots, setSelectedMarks, runTreeActions } from "$lib/workspace/treeActions";
|
||||
import {
|
||||
dropHint,
|
||||
dropPlaceAt,
|
||||
joinRel,
|
||||
parentRel,
|
||||
@@ -478,7 +478,7 @@
|
||||
if (workspaceRoot !== operationRoot || error) return;
|
||||
}
|
||||
} else {
|
||||
const typed = await requestText("File name, including any extension", "Untitled");
|
||||
const typed = await requestText($t("File name, including any extension"), "Untitled");
|
||||
if (!typed) {
|
||||
return;
|
||||
}
|
||||
@@ -685,10 +685,10 @@
|
||||
async function deleteEntries(entries: TreeEntry[]) {
|
||||
const roots = selectionRoots(entries);
|
||||
const message = entries.length === 1
|
||||
? `Permanently delete ${entries[0].name}${entries[0].kind === "folder" ? " and everything inside it" : ""}?`
|
||||
: `Permanently delete ${entries.length} selected items${entries.some(entry => entry.kind === "folder") ? " and all contents of selected folders" : ""}?\n\n${roots.map(entry => entry.rel_path).join("\n")}`;
|
||||
? $t(entries[0].kind === "folder" ? "Permanently delete {name} and everything inside it?" : "Permanently delete {name}?", { name: entries[0].name })
|
||||
: $t(entries.some(entry => entry.kind === "folder") ? "Permanently delete {count} selected items and all contents of selected folders?" : "Permanently delete {count} selected items?", { count: entries.length }) + "\n\n" + roots.map(entry => entry.rel_path).join("\n");
|
||||
try {
|
||||
if (!await confirm(message, { title: "Delete from disk", kind: "warning" })) return;
|
||||
if (!await confirm(message, { title: $t("Delete from disk"), kind: "warning" })) return;
|
||||
const result = await runTreeActions(roots, async entry => {
|
||||
await workspaceDelete(entry.rel_path);
|
||||
forgetFolder(entry.rel_path);
|
||||
@@ -696,7 +696,7 @@
|
||||
});
|
||||
for (const parent of new Set(roots.map(entry => parentRel(entry.rel_path)))) await load(parent);
|
||||
error = result.failures.length ? result.failures.join("\n") : null;
|
||||
onStatus?.(`Deleted ${result.completed.length} of ${roots.length} items`);
|
||||
onStatus?.($t("Deleted {count} of {total} items", { count: result.completed.length, total: roots.length }));
|
||||
} catch (err) {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
@@ -713,16 +713,16 @@
|
||||
return [
|
||||
{
|
||||
kind: "action",
|
||||
label: "New file…",
|
||||
label: $t("New file…"),
|
||||
icon: "file-plus",
|
||||
run: () => { void createIn(parent, "file"); },
|
||||
},
|
||||
...(templates.length || onManageTemplates ? [{ kind: "group" as const, label: "New note", icon: "file-plus" as const, run: () => { void fromTemplate(); }, items: [
|
||||
{ kind: "action" as const, label: "Blank note", icon: "file-plus" as const, run: () => { void fromTemplate(); } },
|
||||
...(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: "Manage templates…", icon: "copy" as const, run: onManageTemplates }] : []),
|
||||
] }] : [{ kind: "action" as const, label: "New note", icon: "file-plus" as const, run: () => { void fromTemplate(); } }]),
|
||||
{ kind: "action", label: "New folder", icon: "folder-plus", run: () => { void createIn(parent, "folder"); } },
|
||||
...(onManageTemplates ? [{ kind: "sep" as const }, { kind: "action" as const, label: $t("Manage templates…"), icon: "copy" as const, run: onManageTemplates }] : []),
|
||||
] }] : [{ kind: "action" as const, label: $t("New note"), icon: "file-plus" as const, run: () => { void fromTemplate(); } }]),
|
||||
{ kind: "action", label: $t("New folder"), icon: "folder-plus", run: () => { void createIn(parent, "folder"); } },
|
||||
...$pluginDocumentTypes.filter(item => item.type.create).map(({ owner, type }): MenuItem => ({
|
||||
kind: "action", label: type.create!.label, icon: type.icon === "kanban" ? "kanban" : "file-plus",
|
||||
run: () => { void (async () => {
|
||||
@@ -730,7 +730,7 @@
|
||||
const typed = await requestText(create.label, create.defaultName);
|
||||
if (typed === null) return;
|
||||
const name = typed.trim().replace(new RegExp(`\\.${create.extension}$`, "i"), "");
|
||||
if (!name || name.length > 100 || /[<>:"/\\|?*\x00-\x1f]/.test(name) || /[. ]$/.test(name) || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(name)) { error = "Enter a valid document name."; return; }
|
||||
if (!name || name.length > 100 || /[<>:"/\\|?*\x00-\x1f]/.test(name) || /[. ]$/.test(name) || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(name)) { error = $t("Enter a valid document name."); return; }
|
||||
const fileName = `${name}.${create.extension}`;
|
||||
const path = joinRel(parent, fileName);
|
||||
try {
|
||||
@@ -746,11 +746,11 @@
|
||||
|
||||
function folderActions(parent: string): MenuItem[] {
|
||||
return [
|
||||
{ kind: "action", label: "Open in terminal", icon: "terminal", run: () => { void workspaceOpenTerminal(parent).catch(reason => error = String(reason)); } },
|
||||
{ kind: "action", label: "Paste", icon: "paste", disabled: !clipboard || clipboard.root !== workspaceRoot || moving, run: () => { void pasteEntries(parent); } },
|
||||
{ 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" ? "Undo rename" : "Undo file move", icon: "undo", disabled: !undoMoves.length || moving, run: () => { void replayMoves(); } },
|
||||
{ kind: "action", label: redoMoves.at(-1)?.action === "rename" ? "Redo rename" : "Redo file move", icon: "redo", disabled: !redoMoves.length || moving, run: () => { void replayMoves(true); } },
|
||||
{ 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); } },
|
||||
];
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: "Show in Explorer",
|
||||
label: $t("Show in Explorer"),
|
||||
icon: "folder",
|
||||
run: () => {
|
||||
void workspaceReveal("").catch((err) => {
|
||||
@@ -784,25 +784,25 @@
|
||||
return [
|
||||
...createItems,
|
||||
...(!multiple && entry.kind === "file" && /\.md$/i.test(entry.name) && onSaveTemplate ? [
|
||||
{ kind: "action" as const, label: "Save as template", icon: "copy" as const, run: () => onSaveTemplate?.(entry) },
|
||||
{ kind: "action" as const, label: $t("Save as template"), icon: "copy" as const, run: () => onSaveTemplate?.(entry) },
|
||||
] : []),
|
||||
...(!multiple && entry.kind === "file" ? [
|
||||
{ kind: "action" as const, label: "Open in new tab", icon: "file-plus" as const, run: () => onOpenFile(entry, true) },
|
||||
{ kind: "action" as const, label: "Open in default app", icon: "external" as const, run: () => { void workspaceOpenDefault(entry.rel_path).catch(reason => error = String(reason)); } },
|
||||
{ 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 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)),
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: "Cut", icon: "cut", run: () => { clipboard = { root: workspaceRoot, paths: selectionRoots(entries).map(item => item.rel_path), cut: true }; } },
|
||||
{ kind: "action", label: "Copy", icon: "copy", run: () => { clipboard = { root: workspaceRoot, paths: selectionRoots(entries).map(item => item.rel_path), cut: false }; } },
|
||||
{ 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 ? `Make copies (${entries.length})` : "Make a copy",
|
||||
label: multiple ? $t("Make copies ({count})", { count: entries.length }) : $t("Make a copy"),
|
||||
icon: "copy",
|
||||
run: () => { void copyEntries(entries); },
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: bookmarked ? (multiple ? "Remove bookmarks" : "Remove bookmark") : "Bookmark",
|
||||
label: bookmarked ? (multiple ? $t("Remove bookmarks") : $t("Remove bookmark")) : $t("Bookmark"),
|
||||
icon: "bookmark",
|
||||
run: () => {
|
||||
void persistMarks({
|
||||
@@ -814,7 +814,7 @@
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? "Copy workspace paths" : "Copy workspace path",
|
||||
label: multiple ? $t("Copy workspace paths") : $t("Copy workspace path"),
|
||||
icon: "copy",
|
||||
run: () => {
|
||||
void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? "workspace paths" : "workspace path");
|
||||
@@ -822,7 +822,7 @@
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? "Copy system paths" : "Copy system path",
|
||||
label: multiple ? $t("Copy system paths") : $t("Copy system path"),
|
||||
icon: "copy",
|
||||
run: () => {
|
||||
void (async () => {
|
||||
@@ -837,7 +837,7 @@
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: "Show in Explorer",
|
||||
label: $t("Show in Explorer"),
|
||||
icon: "folder",
|
||||
run: () => {
|
||||
void (async () => {
|
||||
@@ -849,7 +849,7 @@
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: pinned ? "Unpin" : "Pin",
|
||||
label: pinned ? $t("Unpin") : $t("Pin"),
|
||||
icon: "pin",
|
||||
run: () => {
|
||||
void persistMarks({
|
||||
@@ -860,7 +860,7 @@
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: "Rename",
|
||||
label: $t("Rename"),
|
||||
icon: "rename",
|
||||
disabled: multiple,
|
||||
run: () => {
|
||||
@@ -869,7 +869,7 @@
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? `Delete (${entries.length})` : "Delete",
|
||||
label: multiple ? $t("Delete ({count})", { count: entries.length }) : $t("Delete"),
|
||||
icon: "trash",
|
||||
run: () => { void deleteEntries(entries); },
|
||||
},
|
||||
@@ -881,16 +881,16 @@
|
||||
|
||||
<div class="wrap">
|
||||
<div class="ribbon tree-tools">
|
||||
<IconButton icon="file-plus" label="New file" onclick={() => void createIn("", "file")} />
|
||||
<IconButton icon="folder-plus" label="New folder" onclick={() => void createIn("", "folder")} />
|
||||
<IconButton icon="file-plus" label={$t("New file")} onclick={() => void createIn("", "file")} />
|
||||
<IconButton icon="folder-plus" label={$t("New folder")} onclick={() => void createIn("", "folder")} />
|
||||
<IconButton
|
||||
icon="sort"
|
||||
label={sortMode === "custom" ? "Sort: custom" : sortMode === "name" ? "Sort: name" : "Sort: name Z-A"}
|
||||
label={sortMode === "custom" ? $t("Sort: custom") : sortMode === "name" ? $t("Sort: name") : $t("Sort: name Z-A")}
|
||||
onclick={cycleSort}
|
||||
/>
|
||||
<IconButton
|
||||
icon={allCollapsed ? "unfold" : "fold"}
|
||||
label={allCollapsed ? "Expand all" : "Collapse all"}
|
||||
label={allCollapsed ? $t("Expand all") : $t("Collapse all")}
|
||||
onclick={() => {
|
||||
if (allCollapsed) {
|
||||
void expandAll();
|
||||
@@ -905,7 +905,7 @@
|
||||
class="tree"
|
||||
tabindex="-1"
|
||||
role="navigation"
|
||||
aria-label="Workspace files"
|
||||
aria-label={$t("Workspace files")}
|
||||
oncontextmenu={(event) => {
|
||||
event.preventDefault();
|
||||
menu = { x: event.clientX, y: event.clientY, entry: null };
|
||||
@@ -915,10 +915,10 @@
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
{#if loading && !childrenMap[""]}
|
||||
<p class="muted">Loading…</p>
|
||||
<p class="muted">{$t("Loading…")}</p>
|
||||
{/if}
|
||||
{#if childrenMap[""]}
|
||||
<ul role="tree" aria-label="Workspace files" aria-multiselectable="true">
|
||||
<ul role="tree" aria-label={$t("Workspace files")} aria-multiselectable="true">
|
||||
{#each childrenMap[""] as entry (entry.rel_path)}
|
||||
<TreeNode
|
||||
{entry}
|
||||
@@ -952,18 +952,18 @@
|
||||
{#if dragRel && dragPoint}
|
||||
{@const landing = dropTarget ? findEntry(dropTarget.rel) : null}
|
||||
<div class="drag-ghost" style:left="{dragPoint.x + 12}px" style:top="{dragPoint.y + 12}px">
|
||||
<span>{dragEntries.length > 1 ? `${dragEntries.length} items` : dragRel.split("/").pop()}</span>
|
||||
<span>{dragEntries.length > 1 ? $t("{count} items", { count: dragEntries.length }) : dragRel.split("/").pop()}</span>
|
||||
{#if imageLanding}
|
||||
<span class="hint">{isImagePath(dragRel ?? "") ? "Insert image" : "Insert link"}</span>
|
||||
<span class="hint">{isImagePath(dragRel ?? "") ? $t("Insert image") : $t("Insert link")}</span>
|
||||
{:else if landing && dropTarget}
|
||||
<span class="hint">{dropHint(landing.name, dropTarget.place)}</span>
|
||||
<span class="hint">{$t(dropTarget.place === "inside" ? "Into {name}" : dropTarget.place === "before" ? "Before {name}" : "After {name}", { name: landing.name })}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if menu}
|
||||
<ContextMenu
|
||||
label="File actions"
|
||||
label={$t("File actions")}
|
||||
x={menu.x}
|
||||
y={menu.y}
|
||||
items={menuItems(menu.entry)}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import { tick, type Snippet } from "svelte";
|
||||
import { workspaceReadDataUrl } from "$lib/workspace/api";
|
||||
@@ -112,13 +113,13 @@
|
||||
}
|
||||
}
|
||||
button.dataset.copied = "true";
|
||||
button.setAttribute("aria-label", "Copied");
|
||||
button.title = "Copied";
|
||||
button.setAttribute("aria-label", $t("Copied"));
|
||||
button.title = $t("Copied");
|
||||
window.setTimeout(() => {
|
||||
if (button.isConnected) {
|
||||
delete button.dataset.copied;
|
||||
button.setAttribute("aria-label", "Copy code");
|
||||
button.title = "Copy code";
|
||||
button.setAttribute("aria-label", $t("Copy code"));
|
||||
button.title = $t("Copy code");
|
||||
}
|
||||
}, 1200);
|
||||
}
|
||||
@@ -181,12 +182,12 @@
|
||||
<h1 class="document-title">{markdownTitle(noteRel)}</h1>
|
||||
{#if onEditBlock}
|
||||
{#each sections.filter(section => !editing || section.start < editing.start) as section (section.start)}
|
||||
<div class="md-edit-block" role="button" tabindex="0" aria-label="Edit document block" data-start={section.start} data-end={section.end}>{@html section.html}</div>
|
||||
<div class="md-edit-block" role="button" tabindex="0" aria-label={$t("Edit document block")} data-start={section.start} data-end={section.end}>{@html section.html}</div>
|
||||
{/each}
|
||||
{#if editing && blockEditor}
|
||||
{@render blockEditor()}
|
||||
{#each sections.filter(section => section.start >= editing.end && section.end > editing.end) as section (section.start)}
|
||||
<div class="md-edit-block" role="button" tabindex="0" aria-label="Edit document block" data-start={section.start} data-end={section.end}>{@html section.html}</div>
|
||||
<div class="md-edit-block" role="button" tabindex="0" aria-label={$t("Edit document block")} data-start={section.start} data-end={section.end}>{@html section.html}</div>
|
||||
{/each}
|
||||
{/if}
|
||||
{:else}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { tick } from "svelte";
|
||||
import type { OutlineItem } from "$lib/workspace/outline";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
@@ -47,27 +48,27 @@
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions (The outline accepts focus for pane-local search shortcuts.) -->
|
||||
<section class="outline" aria-label="Outline" tabindex="0" bind:this={pane} onkeydown={keydown}>
|
||||
<section class="outline" aria-label={$t("Outline")} tabindex="0" bind:this={pane} onkeydown={keydown}>
|
||||
<div class="pane-label">
|
||||
<span>Outline</span>
|
||||
<IconButton icon="search" label="Find in outline (Ctrl+F)" active={searchOpen} onclick={() => void openSearch()} />
|
||||
<span>{$t("Outline")}</span>
|
||||
<IconButton icon="search" label={$t("Find in outline (Ctrl+F)")} active={searchOpen} onclick={() => void openSearch()} />
|
||||
</div>
|
||||
{#if searchOpen}
|
||||
<div class="rs-find-bar outline-search">
|
||||
<div class="rs-find-row">
|
||||
<div class="rs-find-field">
|
||||
<Icon icon="search" />
|
||||
<input bind:this={searchInput} bind:value={query} aria-label="Find in outline" placeholder="Find in outline" />
|
||||
<input bind:this={searchInput} bind:value={query} aria-label={$t("Find in outline")} placeholder={$t("Find in outline")} />
|
||||
</div>
|
||||
<IconButton icon="close" label="Close outline find (Escape)" onclick={closeSearch} />
|
||||
<IconButton icon="close" label={$t("Close outline find (Escape)")} onclick={closeSearch} />
|
||||
</div>
|
||||
<span class="match-count" role="status">{visibleItems.length} of {items.length} headings or symbols</span>
|
||||
<span class="match-count" role="status">{$t("{visible} of {total} headings or symbols", { visible: visibleItems.length, total: items.length })}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if items.length === 0}
|
||||
<p class="placeholder">No headings or symbols in this file.</p>
|
||||
<p class="placeholder">{$t("No headings or symbols in this file.")}</p>
|
||||
{:else if visibleItems.length === 0}
|
||||
<p class="placeholder">No matching headings or symbols.</p>
|
||||
<p class="placeholder">{$t("No matching headings or symbols.")}</p>
|
||||
{:else}
|
||||
<ul>
|
||||
{#each visibleItems as item (item.line + item.text)}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { workspaceList } from "$lib/workspace/api";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
import { onMount } from "svelte";
|
||||
@@ -33,11 +34,11 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<dialog class="rs-picker" bind:this={dialog} aria-label={purpose} onpointerdown={(event) => {
|
||||
<dialog class="rs-picker" bind:this={dialog} aria-label={$t(purpose)} onpointerdown={(event) => {
|
||||
const bounds = dialog.getBoundingClientRect();
|
||||
if (event.target === dialog && (event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom)) onClose();
|
||||
}} oncancel={onClose}>
|
||||
<input bind:this={input} bind:value={query} oninput={() => selected = 0} aria-label="Find a file" placeholder="Find a note or code file…" onkeydown={(event) => {
|
||||
<input bind:this={input} bind:value={query} oninput={() => selected = 0} aria-label={$t("Find a file")} placeholder={$t("Find a note or code file…")} onkeydown={(event) => {
|
||||
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
||||
event.preventDefault(); selected = Math.max(0, Math.min(matches.length - 1, selected + (event.key === "ArrowDown" ? 1 : -1)));
|
||||
dialog.querySelector(`[data-index="${selected}"]`)?.scrollIntoView({ block: "nearest" });
|
||||
@@ -48,9 +49,9 @@
|
||||
{#each matches as entry, index (entry.rel_path)}
|
||||
<button class="rs-picker-row" data-index={index} aria-current={selected === index ? 'true' : undefined} onclick={() => pick(entry)}><span class="file-detail"><strong>{entry.name}</strong><span class="rs-picker-hint">{entry.rel_path}</span></span></button>
|
||||
{/each}
|
||||
{#if !matches.length}<p>{loading ? "Finding files…" : "No matching files."}</p>{/if}
|
||||
{#if !matches.length}<p>{loading ? $t("Finding files…") : $t("No matching files.")}</p>{/if}
|
||||
</div>
|
||||
<footer>{error || `${files.length} files${loading ? " · indexing…" : ""}`} <span>↑ ↓ select · Enter {actionLabel} · Esc close</span></footer>
|
||||
<footer>{error || `${files.length} files${loading ? $t(" · indexing…") : ""}`} <span>{$t("↑ ↓ select · Enter {action} · Esc close", { action: $t(actionLabel) })}</span></footer>
|
||||
</dialog>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import { workspaceSearch, type SearchHit } from "$lib/workspace/api";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
@@ -36,7 +37,7 @@
|
||||
</script>
|
||||
|
||||
<div class="pane">
|
||||
<div class="pane-label">Search</div>
|
||||
<div class="pane-label">{$t("Search")}</div>
|
||||
<form
|
||||
class="bar"
|
||||
onsubmit={(event) => {
|
||||
@@ -44,8 +45,8 @@
|
||||
void run();
|
||||
}}
|
||||
>
|
||||
<input bind:value={query} placeholder="Search files and notes" />
|
||||
<IconButton icon="search" label="Search workspace" type="submit" />
|
||||
<input bind:value={query} placeholder={$t("Search files and notes")} />
|
||||
<IconButton icon="search" label={$t("Search workspace")} type="submit" />
|
||||
</form>
|
||||
{#if error}
|
||||
<p class="error">{error}</p>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { t, locale, LANGUAGES, setLocale } from "$lib/i18n";
|
||||
import { showActionMenu } from "$lib/ui/managedActionMenu";
|
||||
import { onDestroy } from "svelte";
|
||||
import PluginManager from "$lib/plugins/PluginManager.svelte";
|
||||
import AppearanceSettings from "$lib/theme/AppearanceSettings.svelte";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
@@ -20,13 +23,23 @@
|
||||
onSave: (value: AppSettings) => void;
|
||||
onClose: () => void;
|
||||
} = $props();
|
||||
let closeLanguage = () => {};
|
||||
onDestroy(() => closeLanguage());
|
||||
function languagePicker(event: MouseEvent) {
|
||||
closeLanguage();
|
||||
const anchor = event.currentTarget as HTMLButtonElement;
|
||||
const bounds = anchor.getBoundingClientRect();
|
||||
closeLanguage = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: $t("Language"), parent: dialog,
|
||||
items: LANGUAGES.map(item => ({ label: item.name, radio: true, checked: $locale === item.id,
|
||||
run: () => { try { setLocale(item.id); error = ""; message = $t("Changes saved."); } catch { error = $t("Could not save language settings."); } } })) }).close;
|
||||
}
|
||||
type Section = string;
|
||||
const sections: { id: Section; label: string; icon: IconName; keywords: string }[] = [
|
||||
{ id: "about", label: "Help and about", icon: "help", keywords: "help about version shortcuts keyboard guide" },
|
||||
{ id: "general", label: "General", icon: "settings", keywords: "auto-save autosave save interval seconds files" },
|
||||
{ id: "appearance", label: "Appearance", icon: "sun", keywords: "theme colors light dark Claude Sakura Harvest Moon Crimson Pilot Silver Serpent" },
|
||||
{ id: "plugins", label: "Plug-ins", icon: "puzzle", keywords: "plugins extensions community" },
|
||||
];
|
||||
const sections: { id: Section; label: string; icon: IconName; keywords: string }[] = $derived([
|
||||
{ id: "about", label: $t("Help and about"), icon: "help", keywords: "help about version shortcuts keyboard guide" },
|
||||
{ id: "general", label: $t("General"), icon: "settings", keywords: "auto-save autosave save interval seconds files language français 日本語 简体中文" },
|
||||
{ id: "appearance", label: $t("Appearance"), icon: "sun", keywords: "theme colors light dark Claude Sakura Harvest Moon Crimson Pilot Silver Serpent" },
|
||||
{ id: "plugins", label: $t("Plug-ins"), icon: "puzzle", keywords: "plugins extensions community" },
|
||||
]);
|
||||
let section = $state<Section>(untrack(() => help ? "about" : "general"));
|
||||
let query = $state("");
|
||||
let seconds = $state<number | undefined>(untrack(() => settings.autosaveSeconds));
|
||||
@@ -39,7 +52,7 @@
|
||||
label: tool.title, icon: "settings" as const,
|
||||
keywords: `${$installedPlugins.plugins.find(row => row.manifest.id === tool.owner)?.manifest.name ?? tool.owner} settings configuration`,
|
||||
})));
|
||||
const matches = $derived([...sections, ...(browserEnabled ? [{ id: "browser" as const, label: "Browser", icon: "globe" as const, keywords: "browser profiles search cookies cache web privacy" }] : []), ...pluginSections].filter(item => `${item.label} ${item.keywords}`.toLowerCase().includes(query.trim().toLowerCase())));
|
||||
const matches = $derived([...sections, ...(browserEnabled ? [{ id: "browser" as const, label: $t("Browser"), icon: "globe" as const, keywords: "browser profiles search cookies cache web privacy" }] : []), ...pluginSections].filter(item => `${item.label} ${item.keywords}`.toLowerCase().includes(query.trim().toLowerCase())));
|
||||
const selected = $derived(matches.find(item => item.id === section) ?? matches[0]);
|
||||
const selectedPlugin = $derived(pluginSections.find(item => item.id === selected?.id));
|
||||
|
||||
@@ -52,13 +65,13 @@
|
||||
|
||||
function apply(value: AppSettings) {
|
||||
error = "";
|
||||
try { onSave(value); message = "Changes saved."; }
|
||||
catch { error = "Could not save these settings. Your previous settings still apply. Try again."; message = ""; }
|
||||
try { onSave(value); message = $t("Changes saved."); }
|
||||
catch { error = $t("Could not save these settings. Your previous settings still apply. Try again."); message = ""; }
|
||||
}
|
||||
|
||||
function changeInterval() {
|
||||
if (!validAutosaveSeconds(seconds)) {
|
||||
error = "Choose a whole number from 1 to 300 seconds.";
|
||||
error = $t("Choose a whole number from 1 to 300 seconds.");
|
||||
message = "";
|
||||
return;
|
||||
}
|
||||
@@ -80,52 +93,54 @@
|
||||
|
||||
<dialog bind:this={dialog} class:help class:standalone aria-labelledby="settings-title" onkeydown={trapFocus} oncancel={event => { if (event.target === dialog) { event.preventDefault(); onClose(); } }}>
|
||||
<header class:window-header={!!windowControls} data-tauri-drag-region={windowControls ? true : undefined}>
|
||||
<h1 id="settings-title" data-tauri-drag-region={windowControls ? true : undefined}>{help ? "Help and about" : "Settings"}</h1>
|
||||
<h1 id="settings-title" data-tauri-drag-region={windowControls ? true : undefined}>{help ? $t("Help and about") : $t("Settings")}</h1>
|
||||
{#if windowControls}
|
||||
{@render windowControls()}
|
||||
{:else}
|
||||
<IconButton icon="close" label={help ? "Close help" : "Close settings"} onclick={onClose} />
|
||||
<IconButton icon="close" label={help ? $t("Close help") : $t("Close settings")} onclick={onClose} />
|
||||
{/if}
|
||||
</header>
|
||||
<div class="body">
|
||||
{#if !help}
|
||||
<aside>
|
||||
<label class="search"><Icon icon="search" /><input aria-label="Search settings" placeholder="Search settings…" bind:value={query} /></label>
|
||||
<p class="nav-heading">Preferences</p>
|
||||
<nav aria-label="Settings categories">
|
||||
<label class="search"><Icon icon="search" /><input 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}
|
||||
<button class:active={selected?.id === item.id} aria-current={selected?.id === item.id ? "page" : undefined} onclick={() => select(item.id)}><Icon icon={item.icon} />{item.label}</button>
|
||||
{/each}
|
||||
</nav>
|
||||
<p class="scope">For all workspaces on this device.</p>
|
||||
<p class="scope">{$t("For all workspaces on this device.")}</p>
|
||||
</aside>
|
||||
{/if}
|
||||
<div class="content">
|
||||
{#if windowError}<p class="error" role="alert">{windowError}</p>{/if}
|
||||
{#if !selected}
|
||||
<h2>No settings found</h2>
|
||||
<p>Try “save”, “plug-ins”, or “help”.</p>
|
||||
<button class="text-button" onclick={() => query = ""}>Clear search</button>
|
||||
<h2>{$t("No settings found")}</h2>
|
||||
<p>{$t("Try “save”, “plug-ins”, or “help”.")}</p>
|
||||
<button class="text-button" onclick={() => query = ""}>{$t("Clear search")}</button>
|
||||
{:else if selected.id === "general"}
|
||||
<h2>General</h2>
|
||||
<p class="intro">Choose how RuneStone saves your work.</p>
|
||||
<h3>Files</h3>
|
||||
<h2>{$t("General")}</h2>
|
||||
<p class="intro">{$t("Choose how RuneStone saves your work.")}</p>
|
||||
<h3>{$t('Language')}</h3>
|
||||
<div class="card"><div class="setting-row language-row"><div><label for="language-picker">{$t('Display language')}</label><p>{$t('Choose the language for RuneStone controls.')}</p></div><button id="language-picker" class="text-button language-picker" aria-haspopup="menu" onclick={languagePicker}><Icon icon="globe" />{LANGUAGES.find(item => item.id === $locale)?.name}<Icon icon="chevron-down" /></button></div></div>
|
||||
<h3>{$t("Files")}</h3>
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="show-internal-folder">Show .runestone folder</label><p id="internal-folder-description">Show workspace settings and plugin data in the file tree.</p></div>
|
||||
<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 })} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-enabled">Auto-save</label><p id="autosave-description">Save changed notes and scripts, including background tabs.</p></div>
|
||||
<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; }} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-seconds">Auto-save interval</label><p id="interval-description">Time between saves, even while you type. Choose 1–300 seconds.</p></div>
|
||||
<div class="interval"><input id="autosave-seconds" type="number" min={MIN_AUTOSAVE_SECONDS} max={MAX_AUTOSAVE_SECONDS} step="1" required disabled={!settings.autosaveEnabled} aria-describedby="interval-description" aria-invalid={!!error} bind:value={seconds} onchange={changeInterval} /><span>seconds</span></div>
|
||||
<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>
|
||||
<div class="interval"><input id="autosave-seconds" type="number" min={MIN_AUTOSAVE_SECONDS} max={MAX_AUTOSAVE_SECONDS} step="1" required disabled={!settings.autosaveEnabled} aria-describedby="interval-description" aria-invalid={!!error} bind:value={seconds} onchange={changeInterval} /><span>{$t("seconds")}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="note">{settings.autosaveEnabled ? "Only changed files are saved." : "Auto-save is off. Use Ctrl+S to save your changes."} Disk conflicts keep your edits for review.</p>
|
||||
<div class="section-footer"><button class="text-button" onclick={() => { seconds = DEFAULT_SETTINGS.autosaveSeconds; apply({ ...DEFAULT_SETTINGS }); }}>Restore defaults</button><span>Default: every 5 seconds</span></div>
|
||||
<p class="note">{settings.autosaveEnabled ? $t("Only changed files are saved.") : $t("Auto-save is off. Use Ctrl+S to save your changes.")} {$t("Disk conflicts keep your edits for review.")}</p>
|
||||
<div class="section-footer"><button class="text-button" onclick={() => { seconds = DEFAULT_SETTINGS.autosaveSeconds; apply({ ...DEFAULT_SETTINGS }); }}>{$t("Restore defaults")}</button><span>{$t("Default: every 5 seconds")}</span></div>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<p class="saved" role="status">{message}</p>
|
||||
{:else if selected.id === "appearance"}
|
||||
@@ -137,13 +152,13 @@
|
||||
{:else if selectedPlugin}
|
||||
{#key selectedPlugin.id}<PluginSettings owner={selectedPlugin.owner} id={selectedPlugin.view} />{/key}
|
||||
{:else}
|
||||
<div class="brand"><img src="/runestone.svg" alt="" width="88" height="88" /><h2>RuneStone</h2><p>Version {version}</p></div>
|
||||
<div class="brand"><img src="/runestone.svg" alt="" width="88" height="88" /><h2>RuneStone</h2><p>{$t("Version {version}", { version })}</p></div>
|
||||
<div class="card help-card">
|
||||
<details><summary><Icon icon="book-open" /> Get started</summary><div class="help-copy"><p>Use the folder button to open a workspace or create one. Your notes and scripts stay as ordinary files on disk.</p><p>Use the + beside the tabs for a new tab. Press Ctrl+N to create a file, or Ctrl+P to find one.</p><p>Press Ctrl+E to switch between writing and source editing. Use the terminal button to work with a shell beside your files.</p></div></details>
|
||||
<details><summary><Icon icon="save" /> Save your work</summary><div class="help-copy"><p>Auto-save saves changed files at the interval in Settings → General. Ctrl+S saves the active file immediately.</p><p>If another app changes a file, RuneStone keeps your edits and offers both versions for review.</p></div></details>
|
||||
<details><summary><Icon icon="code" /> Keyboard shortcuts</summary><dl><div><dt>Open a workspace</dt><dd><kbd>Ctrl+O</kbd></dd></div><div><dt>Find a file</dt><dd><kbd>Ctrl+P</kbd></dd></div><div><dt>Save the active file</dt><dd><kbd>Ctrl+S</kbd></dd></div><div><dt>Search the workspace</dt><dd><kbd>Ctrl+Shift+F</kbd></dd></div><div><dt>Open settings</dt><dd><kbd>Ctrl+,</kbd></dd></div><div><dt>Help and about</dt><dd><kbd>F1</kbd></dd></div></dl></details>
|
||||
<details><summary><Icon icon="book-open" /> {$t("Get started")}</summary><div class="help-copy"><p>{$t("Use the folder button to open a workspace or create one. Your notes and scripts stay as ordinary files on disk.")}</p><p>{$t("Use the + beside the tabs for a new tab. Press Ctrl+N to create a file, or Ctrl+P to find one.")}</p><p>{$t("Press Ctrl+E to switch between writing and source editing. Use the terminal button to work with a shell beside your files.")}</p></div></details>
|
||||
<details><summary><Icon icon="save" /> {$t("Save your work")}</summary><div class="help-copy"><p>{$t("Auto-save saves changed files at the interval in Settings → General. Ctrl+S saves the active file immediately.")}</p><p>{$t("If another app changes a file, RuneStone keeps your edits and offers both versions for review.")}</p></div></details>
|
||||
<details><summary><Icon icon="code" /> {$t("Keyboard shortcuts")}</summary><dl><div><dt>{$t("Open a workspace")}</dt><dd><kbd>Ctrl+O</kbd></dd></div><div><dt>{$t("Find a file")}</dt><dd><kbd>Ctrl+P</kbd></dd></div><div><dt>{$t("Save the active file")}</dt><dd><kbd>Ctrl+S</kbd></dd></div><div><dt>{$t("Search the workspace")}</dt><dd><kbd>Ctrl+Shift+F</kbd></dd></div><div><dt>{$t("Open settings")}</dt><dd><kbd>Ctrl+,</kbd></dd></div><div><dt>{$t("Help and about")}</dt><dd><kbd>F1</kbd></dd></div></dl></details>
|
||||
</div>
|
||||
<p class="about-note">RuneStone is under development. Maintained by kwyvern-gh.</p>
|
||||
<p class="about-note">{$t("RuneStone is under development. Maintained by kwyvern-gh.")}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -179,6 +194,8 @@
|
||||
.setting-row + .setting-row { border-top: 1px solid var(--rs-border); }
|
||||
.setting-row label { font-weight: 500; }
|
||||
.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); }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { onDestroy, tick } from "svelte";
|
||||
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
|
||||
import { actionIcons } from "$lib/ui/actionIcons";
|
||||
@@ -122,24 +123,24 @@
|
||||
children: item.children ? wrapActions(item.children) : undefined };
|
||||
});
|
||||
menu = actionMenu(x, y, [
|
||||
closing("Close", "one"),
|
||||
closing("Close others", "others"),
|
||||
closing("Close tabs after", "after"),
|
||||
closing("Close all", "all"),
|
||||
closing($t("Close"), "one"),
|
||||
closing($t("Close others"), "others"),
|
||||
closing($t("Close tabs after"), "after"),
|
||||
closing($t("Close all"), "all"),
|
||||
...(tabs[index].pinned !== undefined ? [
|
||||
{ separator: true as const },
|
||||
{ label: tabs[index].pinned ? "Unpin" : "Pin", icon: "pin" as const, run: run(() => onPin(path)) },
|
||||
{ label: tabs[index].pinned ? $t("Unpin") : $t("Pin"), icon: "pin" as const, run: run(() => onPin(path)) },
|
||||
] : []),
|
||||
...wrapActions(tabActions(tabs[index])),
|
||||
...(path === activePath ? wrapActions(fileActions(tabs[index])) : []),
|
||||
{ separator: true },
|
||||
{ label: "Move tab", icon: "swap", children: [
|
||||
{ label: "Move tab left", icon: "move-left", disabled: index <= 0,
|
||||
{ label: $t("Move tab"), icon: "swap", children: [
|
||||
{ label: $t("Move tab left"), icon: "move-left", disabled: index <= 0,
|
||||
run: run(() => { void move(path, index - 1); }) },
|
||||
{ label: "Move tab right", icon: "move-right", disabled: index === tabs.length - 1,
|
||||
{ label: $t("Move tab right"), icon: "move-right", disabled: index === tabs.length - 1,
|
||||
run: run(() => { void move(path, index + 1); }) },
|
||||
] },
|
||||
], () => closeMenu(true), "Tab actions");
|
||||
], () => closeMenu(true), $t("Tab actions"));
|
||||
menu.classList.add("tab-menu");
|
||||
}
|
||||
|
||||
@@ -255,7 +256,7 @@
|
||||
|
||||
<svelte:window onpointerdown={(event) => { if (menu && !menu.contains(event.target as Node)) closeMenu(); }} onresize={() => closeMenu()} />
|
||||
|
||||
<div bind:this={bar} class="tabs" class:receiving role="tablist" aria-label="Working tabs" tabindex="-1"
|
||||
<div bind:this={bar} class="tabs" class:receiving role="tablist" aria-label={$t("Working tabs")} tabindex="-1"
|
||||
ondragover={dragOver} ondrop={dropTab}
|
||||
ondragleave={(event) => { if (!(event.relatedTarget instanceof Node) || !bar.contains(event.relatedTarget)) { receiving = false; dropBefore = dropAfter = null; } }}>
|
||||
{#each tabs as tab (tab.id)}
|
||||
@@ -270,7 +271,7 @@
|
||||
aria-controls={tab.panelId}
|
||||
aria-describedby={tab.pinned ? `tab-pin-${tab.id}` : undefined}
|
||||
aria-keyshortcuts="Alt+Shift+ArrowLeft Alt+Shift+ArrowRight"
|
||||
title={`${tab.title}\n${tab.draggable ? "Drag to reorder or move to another RuneStone window." : "Drag to reorder."} Right-click for tab actions.`}
|
||||
title={`${tab.title}\n${tab.draggable ? $t("Drag to reorder or move to another RuneStone window.") : $t("Drag to reorder.")} ${$t("Right-click for tab actions.")}`}
|
||||
onclick={() => { if (suppressClick) { suppressClick = false; return; } onSelect(tab.relPath); }}
|
||||
onpointerdown={(event) => { if (!tab.draggable) startDrag(event, tab.relPath); else suppressClick = false; }}
|
||||
draggable={!!tab.draggable}
|
||||
@@ -289,12 +290,12 @@
|
||||
<TabIcon image={tab.iconImage} icon={tab.icon} />
|
||||
<span class="tab-label">{tab.name}{tab.dirty ? " •" : ""}</span>
|
||||
</button>
|
||||
{#if tab.pinned}<span class="sr-only" id={`tab-pin-${tab.id}`}>Pinned tab</span>{/if}
|
||||
{#if tab.pinned}<span class="sr-only" id={`tab-pin-${tab.id}`}>{$t("Pinned tab")}</span>{/if}
|
||||
<button
|
||||
class="close"
|
||||
type="button"
|
||||
aria-label="Close {tab.name}"
|
||||
title="Close {tab.name}"
|
||||
aria-label={$t("Close {name}", { name: tab.name })}
|
||||
title={$t("Close {name}", { name: tab.name })}
|
||||
onclick={() => onClose(tab.relPath)}
|
||||
onmousedown={onMiddleDown}
|
||||
onmouseup={(event) => onMiddleUp(event, tab.relPath)}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { onMount } from "svelte";
|
||||
import { confirm } from "@tauri-apps/plugin-dialog";
|
||||
import { isTauri } from "@tauri-apps/api/core";
|
||||
@@ -18,7 +19,7 @@
|
||||
async function refresh() { templates = await noteTemplates(); window.dispatchEvent(new Event("runestone-templates-changed")); }
|
||||
onMount(() => { dialog.showModal(); void refresh(); });
|
||||
async function create() {
|
||||
const name = await requestText("Template name", "New template");
|
||||
const name = await requestText($t("Template name"), $t("New template"));
|
||||
if (!name) return;
|
||||
busy = true; error = "";
|
||||
try { const path = await saveNoteTemplate(name, ""); await refresh(); edit({ path, name: path.split("/").at(-1)!.replace(/\.md$/i, "") }); }
|
||||
@@ -26,10 +27,10 @@
|
||||
finally { busy = false; }
|
||||
}
|
||||
async function rename(template: NoteTemplate) {
|
||||
const name = await requestText("Template name", template.name);
|
||||
const name = await requestText($t("Template name"), template.name);
|
||||
if (!name) return;
|
||||
const title = name.trim().replace(/\.md$/i, "");
|
||||
if (!title || /[<>:"/\\|?*\x00-\x1f]/.test(title) || /[. ]$/.test(title)) { error = "Enter a valid template name."; return; }
|
||||
if (!title || /[<>:"/\\|?*\x00-\x1f]/.test(title) || /[. ]$/.test(title)) { error = $t("Enter a valid template name."); return; }
|
||||
const path = `${TEMPLATE_FOLDER}/${title}.md`;
|
||||
if (path === template.path) return;
|
||||
busy = true; error = "";
|
||||
@@ -38,8 +39,8 @@
|
||||
finally { busy = false; }
|
||||
}
|
||||
async function remove(template: NoteTemplate) {
|
||||
const message = `Delete the template “${template.name}”? Existing notes stay unchanged.`;
|
||||
const accepted = isTauri() ? await confirm(message, { title: "Delete template", kind: "warning" }) : window.confirm(message);
|
||||
const message = $t("Delete the template “{name}”? Existing notes stay unchanged.", { name: template.name });
|
||||
const accepted = isTauri() ? await confirm(message, { title: $t("Delete template"), kind: "warning" }) : window.confirm(message);
|
||||
if (!accepted) return;
|
||||
busy = true; error = "";
|
||||
try { await workspaceDelete(template.path); onDeleted(template.path); await refresh(); }
|
||||
@@ -49,17 +50,17 @@
|
||||
</script>
|
||||
|
||||
<dialog bind:this={dialog} aria-labelledby="templates-title" oncancel={event => { event.preventDefault(); if (!busy) onClose(); }}>
|
||||
<header><h2 id="templates-title">Document templates</h2><IconButton icon="close" label="Close templates" disabled={busy} onclick={onClose} /></header>
|
||||
<p>Templates belong to this workspace. Edit a template to change future notes.</p>
|
||||
<button class="new" disabled={busy} onclick={() => void create()}><Icon icon="file-plus" /> New template</button>
|
||||
<header><h2 id="templates-title">{$t("Document templates")}</h2><IconButton icon="close" label={$t("Close templates")} disabled={busy} onclick={onClose} /></header>
|
||||
<p>{$t("Templates belong to this workspace. Edit a template to change future notes.")}</p>
|
||||
<button class="new" disabled={busy} onclick={() => void create()}><Icon icon="file-plus" /> {$t("New template")}</button>
|
||||
<div class="list">
|
||||
{#each templates as template (template.path)}
|
||||
<div class="row"><span title={template.name}>{template.name}</span><div class="actions">
|
||||
<IconButton icon="pen" label={`Edit ${template.name}`} disabled={busy} onclick={() => edit(template)} />
|
||||
<button class="rename" aria-label={`Rename ${template.name}`} title={`Rename ${template.name}`} disabled={busy} onclick={() => void rename(template)}><Icon icon="text" /> Rename</button>
|
||||
<IconButton icon="trash" label={`Delete ${template.name}`} disabled={busy} onclick={() => void remove(template)} />
|
||||
<IconButton icon="pen" label={$t("Edit {name}", { name: template.name })} disabled={busy} onclick={() => edit(template)} />
|
||||
<button class="rename" aria-label={$t("Rename {name}", { name: template.name })} title={$t("Rename {name}", { name: template.name })} disabled={busy} onclick={() => void rename(template)}><Icon icon="text" /> {$t("Rename")}</button>
|
||||
<IconButton icon="trash" label={$t("Delete {name}", { name: template.name })} disabled={busy} onclick={() => void remove(template)} />
|
||||
</div></div>
|
||||
{:else}<p>No templates yet. Create one or use Save as template on a note.</p>{/each}
|
||||
{:else}<p>{$t("No templates yet. Create one or use Save as template on a note.")}</p>{/each}
|
||||
</div>
|
||||
{#if error}<p role="alert">{error}</p>{/if}
|
||||
</dialog>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { dialogs, finishText } from "$lib/workspace/dialogs.svelte";
|
||||
let element: HTMLDialogElement | undefined = $state();
|
||||
let input: HTMLInputElement | undefined = $state();
|
||||
@@ -17,7 +18,7 @@
|
||||
<form onsubmit={(event) => { event.preventDefault(); finishText(dialogs.text?.value.trim() || null); }}>
|
||||
<label for="text-request">{dialogs.text.title}</label>
|
||||
<input id="text-request" bind:this={input} bind:value={dialogs.text.value} autocomplete="off" />
|
||||
<div><button type="button" onclick={() => finishText(null)}>Cancel</button><button type="submit" disabled={!dialogs.text.value.trim()}>Continue</button></div>
|
||||
<div><button type="button" onclick={() => finishText(null)}>{$t("Cancel")}</button><button type="submit" disabled={!dialogs.text.value.trim()}>{$t("Continue")}</button></div>
|
||||
</form>
|
||||
</dialog>
|
||||
{/if}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
import type { DropTarget } from "$lib/workspace/treeDrop";
|
||||
import type { SelectionModifiers, TreeSelectionEdges } from "$lib/workspace/treeSelection";
|
||||
@@ -133,7 +134,7 @@
|
||||
{#if isRenaming}
|
||||
<input
|
||||
class="rename"
|
||||
aria-label="File or folder name, including any extension"
|
||||
aria-label={$t("File or folder name, including any extension")}
|
||||
value={renameDraft}
|
||||
use:focusSelect
|
||||
onclick={(event) => event.stopPropagation()}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import TerminalSlot from "$lib/plugins/TerminalSlot.svelte";
|
||||
import PluginTools from "$lib/plugins/PluginTools.svelte";
|
||||
import PluginAccessMenu from "$lib/plugins/PluginAccessMenu.svelte";
|
||||
@@ -75,7 +76,7 @@
|
||||
if (openingSettings) return;
|
||||
openingSettings = true;
|
||||
try { await invoke("settings_open_window"); }
|
||||
catch (reason) { error = `Could not open settings: ${String(reason)}`; }
|
||||
catch (reason) { error = $t("Could not open settings: {error}", { error: String(reason) }); }
|
||||
finally { openingSettings = false; }
|
||||
}
|
||||
let settings = $state<AppSettings>({ ...DEFAULT_SETTINGS });
|
||||
@@ -86,7 +87,7 @@
|
||||
let tabs = $state<OpenBuffer[]>([]);
|
||||
let activePath = $state<string | null>(null);
|
||||
const buffer = $derived(tabs.find((tab) => tab.relPath === activePath) ?? null);
|
||||
let status = $state("Open a workspace folder");
|
||||
let status = $state($t("Open a workspace folder"));
|
||||
let error = $state<string | null>(null);
|
||||
let refreshToken = $state(0);
|
||||
let view = $state<Chrome>("Writing");
|
||||
@@ -277,7 +278,7 @@
|
||||
|
||||
async function terminalAction(action: Exclude<ReturnType<Contributions["terminal"]["shortcut"]>, null | "toggle">) {
|
||||
if (!terminalEnabled) return;
|
||||
if (!workspace) { error = "Open a workspace to start a terminal."; return; }
|
||||
if (!workspace) { error = $t("Open a workspace to start a terminal."); return; }
|
||||
const started = terminalStarted;
|
||||
terminalStarted = true; terminalOpen = true;
|
||||
if (bottomHeight < 220) bottomHeight = 260;
|
||||
@@ -374,7 +375,7 @@
|
||||
focusLine = null;
|
||||
documents?.select(relPath);
|
||||
focusDocumentPane(documentPanes.active, true);
|
||||
status = documents?.active?.kind === "empty" ? "New tab" : relPath;
|
||||
status = documents?.active?.kind === "empty" ? $t("New tab") : relPath;
|
||||
}
|
||||
|
||||
function selectWorkingTab(path: string) {
|
||||
@@ -403,7 +404,7 @@
|
||||
const tab = workingTabs.find(tab => tab.id === item.id);
|
||||
const actions = tab && "plugin" in tab ? pluginTabActions(tab.plugin) : [];
|
||||
if (actions.some(action => "label" in action && /(?:move|open).*new window/i.test(action.label))) return actions;
|
||||
return tab ? [{ label: "Open in new window", icon: "external", disabled: !desktop || !workspace, run: () => { void detachTab(tab); } }, ...actions] : [];
|
||||
return tab ? [{ label: $t("Open in new window"), icon: "external", disabled: !desktop || !workspace, run: () => { void detachTab(tab); } }, ...actions] : [];
|
||||
}
|
||||
async function detachTab(item: WorkbenchTab, keepSource = false) {
|
||||
const tab = workingTabs.find(tab => tab.id === item.id);
|
||||
@@ -451,7 +452,7 @@
|
||||
focusLine = null;
|
||||
documents.newTab();
|
||||
terminalMaximized = false;
|
||||
status = "New tab";
|
||||
status = $t("New tab");
|
||||
error = null;
|
||||
}
|
||||
|
||||
@@ -471,7 +472,7 @@
|
||||
if ("buffer" in target) {
|
||||
if (!tab || (scope !== "one" && tab.pinned)) continue;
|
||||
const contents = tab.contents;
|
||||
if (contents !== tab.saved && !await confirm(`Discard unsaved edits in ${tab.name}?`, { title: "Close document", kind: "warning" })) break;
|
||||
if (contents !== tab.saved && !await confirm($t("Discard unsaved edits in {name}?", { name: tab.name }), { title: $t("Close document"), kind: "warning" })) break;
|
||||
if (documents !== current || switching || tab.contents !== contents) break;
|
||||
if (scope !== "one" && tab.pinned) continue;
|
||||
}
|
||||
@@ -491,7 +492,7 @@
|
||||
try {
|
||||
const text = system ? await workspaceAbsPath(path) : path;
|
||||
await navigator.clipboard.writeText(text);
|
||||
status = system ? "Copied system path" : "Copied workspace path";
|
||||
status = system ? $t("Copied system path") : $t("Copied workspace path");
|
||||
} catch (err) { error = String(err); }
|
||||
}
|
||||
|
||||
@@ -500,21 +501,21 @@
|
||||
const items: ActionMenuItem[] = [];
|
||||
if (tab.kind === "text" && isMarkdownPath(tab.relPath)) {
|
||||
items.push(
|
||||
{ label: "Save as template", icon: "copy", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
|
||||
{ label: reading ? "Editing view" : "Reading view", icon: "book", run: () => activeEditor()?.toggleReadingView() },
|
||||
{ label: isIde ? "Writing mode" : "Source mode", icon: "code", run: toggleChrome },
|
||||
{ label: $t("Save as template"), icon: "copy", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
|
||||
{ label: reading ? $t("Editing view") : $t("Reading view"), icon: "book", run: () => activeEditor()?.toggleReadingView() },
|
||||
{ label: isIde ? $t("Writing mode") : $t("Source mode"), icon: "code", run: toggleChrome },
|
||||
);
|
||||
}
|
||||
items.push({ separator: true },
|
||||
{ label: "Rename…", icon: "rename", run: () => { void renameActive(); } },
|
||||
{ label: $t("Rename…"), icon: "rename", run: () => { void renameActive(); } },
|
||||
);
|
||||
if (tab.kind === "text") items.push({ label: "Save a copy…", icon: "copy", run: () => { void saveCopy(); } });
|
||||
if (tab.kind === "text") items.push({ label: $t("Save a copy…"), icon: "copy", run: () => { void saveCopy(); } });
|
||||
items.push({ separator: true },
|
||||
{ label: "Copy path", icon: "copy", children: [
|
||||
{ label: "Workspace path", icon: "copy", run: () => { void copyTabPath(tab.relPath, false); } },
|
||||
{ label: "System path", icon: "copy", run: () => { void copyTabPath(tab.relPath, 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: "Show in system explorer", icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
|
||||
{ label: $t("Show in system explorer"), icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
|
||||
);
|
||||
return items;
|
||||
}
|
||||
@@ -595,7 +596,7 @@
|
||||
if (!workspace || !current || !note) return null;
|
||||
const folder = note.relPath.slice(0, note.relPath.lastIndexOf("/") + 1);
|
||||
const suggested = label.replace(/[<>:"/\\|?*\r\n]/g, " ").trim().slice(0, 60) || "Extracted selection";
|
||||
const name = await requestText("Extract selection to a new note (workspace relative path)", `${folder}${suggested}.md`);
|
||||
const name = await requestText($t("Extract selection to a new note (workspace relative path)"), `${folder}${suggested}.md`);
|
||||
if (!name || documents !== current || !valid() || saving || switching) return null;
|
||||
const rel = name.replaceAll("\\", "/").replace(/\.md$/i, "") + ".md";
|
||||
saving = true;
|
||||
@@ -603,7 +604,7 @@
|
||||
await workspaceCreate(rel, "file");
|
||||
await workspaceWrite(rel, markdown + "\n", "");
|
||||
refreshToken++;
|
||||
status = `Extracted selection to ${rel}`;
|
||||
status = $t("Extracted selection to {path}", { path: rel });
|
||||
return `/${rel}`;
|
||||
} catch (err) { error = String(err); return null; }
|
||||
finally { saving = false; }
|
||||
@@ -616,7 +617,7 @@
|
||||
saving = true;
|
||||
try {
|
||||
await current.save(tab.id);
|
||||
status = `Saved ${tab.relPath}`;
|
||||
status = $t("Saved {path}", { path: tab.relPath });
|
||||
error = null;
|
||||
} catch (err) {
|
||||
error = String(err);
|
||||
@@ -631,9 +632,9 @@
|
||||
try {
|
||||
const result = await current.autosave();
|
||||
if (documents !== current) return;
|
||||
if (result.saved.length) status = `Autosaved ${result.saved.length} ${result.saved.length === 1 ? "file" : "files"}`;
|
||||
if (result.saved.length) status = result.saved.length === 1 ? $t("Autosaved 1 file") : $t("Autosaved {count} files", { count: result.saved.length });
|
||||
if (result.failed.length) {
|
||||
error = result.failed.map(({ path, error }) => `Could not autosave ${path}: ${String(error)}`).join("\n");
|
||||
error = result.failed.map(({ path, error }) => $t("Could not autosave {path}: {error}", { path, error: String(error) })).join("\n");
|
||||
await current.refresh();
|
||||
}
|
||||
} finally { saving = false; }
|
||||
@@ -641,7 +642,7 @@
|
||||
|
||||
async function saveCopy(tab = buffer) {
|
||||
if (!tab || tab.kind !== "text") return;
|
||||
const name = await requestText("Save a copy as (workspace relative path)", tab.relPath.replace(/(\.[^./]+)?$/, " copy$1"));
|
||||
const name = await requestText($t("Save a copy as (workspace relative path)"), tab.relPath.replace(/(\.[^./]+)?$/, " copy$1"));
|
||||
if (!name) return;
|
||||
try {
|
||||
await workspaceCreate(name, "file");
|
||||
@@ -655,7 +656,7 @@
|
||||
if (!workspace) {
|
||||
return;
|
||||
}
|
||||
const name = await requestText("New file path relative to the workspace", "Untitled.md");
|
||||
const name = await requestText($t("New file path relative to the workspace"), "Untitled.md");
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
@@ -673,12 +674,12 @@
|
||||
}
|
||||
|
||||
async function saveTemplate(entry: TreeEntry) {
|
||||
const name = await requestText("Template name", entry.name.replace(/\.md$/i, ""));
|
||||
const name = await requestText($t("Template name"), entry.name.replace(/\.md$/i, ""));
|
||||
if (!name) return;
|
||||
try {
|
||||
const contents = documents?.buffers.find(tab => tab.relPath === entry.rel_path)?.contents ?? await workspaceRead(entry.rel_path);
|
||||
await saveNoteTemplate(name, contents);
|
||||
status = `Saved template: ${name}`;
|
||||
status = $t("Saved template: {name}", { name });
|
||||
} catch (reason) { error = String(reason); }
|
||||
}
|
||||
|
||||
@@ -697,9 +698,9 @@
|
||||
const close = () => { menu.remove(); window.removeEventListener("pointerdown", outside); anchor?.focus(); };
|
||||
const outside = (event: PointerEvent) => { if (!menu.contains(event.target as Node)) close(); };
|
||||
const menu = actionMenu(event.clientX, event.clientY, [
|
||||
{ label: "Blank note", icon: "file-plus", run: () => { close(); void create(); } },
|
||||
{ label: $t("Blank note"), icon: "file-plus", run: () => { close(); void create(); } },
|
||||
...templates.map(template => ({ label: template.name, icon: "file-plus" as const, run: () => { close(); void create(template); } })),
|
||||
], close, "New note");
|
||||
], close, $t("New note"));
|
||||
window.addEventListener("pointerdown", outside);
|
||||
}
|
||||
|
||||
@@ -806,7 +807,7 @@
|
||||
current.rename(from, plan.to);
|
||||
if (documents !== current) return;
|
||||
refreshToken += 1;
|
||||
status = `Renamed to ${plan.to}`;
|
||||
status = $t("Renamed to {path}", { path: plan.to });
|
||||
error = null;
|
||||
}
|
||||
|
||||
@@ -816,7 +817,7 @@
|
||||
}
|
||||
const current = documents;
|
||||
const from = activePath;
|
||||
const typed = await requestText("Rename to", from.split("/").pop() ?? from);
|
||||
const typed = await requestText($t("Rename to"), from.split("/").pop() ?? from);
|
||||
if (typed == null || documents !== current || switching) {
|
||||
return;
|
||||
}
|
||||
@@ -833,7 +834,7 @@
|
||||
current?.rename(from, plan.to);
|
||||
if (documents !== current) return;
|
||||
refreshToken += 1;
|
||||
status = `Renamed to ${plan.to}`;
|
||||
status = $t("Renamed to {path}", { path: plan.to });
|
||||
error = null;
|
||||
} catch (err) {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
@@ -852,13 +853,13 @@
|
||||
const found = files.find(file => file.rel_path === path && file.kind === "file");
|
||||
if (found) return found;
|
||||
}
|
||||
throw new Error(`Could not find ${link.target} in the workspace.`);
|
||||
throw new Error($t("Could not find {path} in the workspace.", { path: link.target }));
|
||||
};
|
||||
const run = (action: (file: TreeEntry) => void | Promise<void>) => () => {
|
||||
void entry().then(file => { if (valid()) return action(file); }).catch(reason => { error = String(reason); });
|
||||
};
|
||||
async function rename(file: TreeEntry, move = false) {
|
||||
const typed = await requestText(move ? "Move file to (workspace path, including filename)" : "New file name", move ? file.rel_path : file.name);
|
||||
const typed = await requestText(move ? $t("Move file to (workspace path, including filename)") : $t("New file name"), move ? file.rel_path : file.name);
|
||||
if (!typed || !valid()) return;
|
||||
let to = typed.trim().replaceAll("\\", "/");
|
||||
if (move) {
|
||||
@@ -877,31 +878,31 @@
|
||||
applyPathRename(file.rel_path, to);
|
||||
await saveMarks(moveMarks(marks, file.rel_path, to));
|
||||
refreshToken++;
|
||||
status = `Moved to ${to}`;
|
||||
status = $t("Moved to {path}", { path: to });
|
||||
}
|
||||
return [
|
||||
{ label: "Open to the right", icon: "split-right", run: run(file => openToRight(file, sourcePane)) },
|
||||
{ label: "Open in new window", icon: "external", disabled: !desktop, run: run(async file => {
|
||||
{ label: $t("Open to the right"), icon: "split-right", run: run(file => openToRight(file, sourcePane)) },
|
||||
{ label: $t("Open in new window"), icon: "external", disabled: !desktop, run: run(async file => {
|
||||
await openFile(file, undefined, "new");
|
||||
if (!valid()) return;
|
||||
const tab = workingTabs.find(tab => tab.relPath === file.rel_path);
|
||||
if (tab) await detachTab(tab, true);
|
||||
}) },
|
||||
{ label: "Copy path", icon: "copy", children: [
|
||||
{ label: "Workspace path", icon: "copy", run: run(file => copyTabPath(file.rel_path, false)) },
|
||||
{ label: "System path", icon: "copy", run: run(file => copyTabPath(file.rel_path, true)) },
|
||||
{ label: $t("Copy path"), icon: "copy", children: [
|
||||
{ label: $t("Workspace path"), icon: "copy", run: run(file => copyTabPath(file.rel_path, false)) },
|
||||
{ label: $t("System path"), icon: "copy", run: run(file => copyTabPath(file.rel_path, true)) },
|
||||
] },
|
||||
{ label: "Rename…", icon: "rename", run: run(file => rename(file)) },
|
||||
{ label: "Move file to…", icon: "folder", run: run(file => rename(file, true)) },
|
||||
{ label: "Bookmark", icon: "bookmark", run: run(async file => {
|
||||
{ label: $t("Rename…"), icon: "rename", run: run(file => rename(file)) },
|
||||
{ label: $t("Move file to…"), icon: "folder", run: run(file => rename(file, true)) },
|
||||
{ label: $t("Bookmark"), icon: "bookmark", run: run(async file => {
|
||||
const marks = await loadMarks();
|
||||
if (!valid()) return;
|
||||
if (!marks.bookmarks.includes(file.rel_path)) await saveMarks({ ...marks, bookmarks: [...marks.bookmarks, file.rel_path] });
|
||||
refreshToken++; status = `Bookmarked ${file.name}`;
|
||||
refreshToken++; status = $t("Bookmarked {name}", { name: file.name });
|
||||
}) },
|
||||
{ label: "Open in default app", icon: "external", run: run(file => workspaceOpenDefault(file.rel_path)) },
|
||||
{ label: "Show in system explorer", icon: "folder", run: run(file => workspaceReveal(file.rel_path)) },
|
||||
{ label: "Reveal file in navigation", icon: "folder", run: run(async file => { closePluginSidebar(); leftView = "files"; leftOpen = true; await tick(); await fileTree?.revealPath(file.rel_path); }) },
|
||||
{ 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("Reveal file in navigation"), icon: "folder", run: run(async file => { closePluginSidebar(); leftView = "files"; leftOpen = true; await tick(); await fileTree?.revealPath(file.rel_path); }) },
|
||||
];
|
||||
}
|
||||
|
||||
@@ -922,7 +923,7 @@
|
||||
return;
|
||||
} catch { /* Try the workspace-root candidate after the note-relative path. */ }
|
||||
}
|
||||
error = `Could not open ${target}`;
|
||||
error = $t("Could not open {path}", { path: target });
|
||||
}
|
||||
|
||||
function onPointerMove(event: PointerEvent) {
|
||||
@@ -1028,7 +1029,7 @@
|
||||
closing = true;
|
||||
try {
|
||||
const message = [hasDirty ? "Unsaved edits will be discarded." : "", terminalStarted ? "Terminal sessions will end." : ""].filter(Boolean).join("\n");
|
||||
if (await confirm(`${message}\nClose RuneStone?`, { title: "Close workspace", kind: "warning" })) await getCurrentWindow().destroy();
|
||||
if (await confirm(`${message}\n${$t("Close RuneStone?")}`, { title: $t("Close workspace"), kind: "warning" })) await getCurrentWindow().destroy();
|
||||
} finally { closing = false; }
|
||||
}).then(register).catch(err => error = String(err));
|
||||
const focus = () => { void documents?.refresh(); refreshToken++; };
|
||||
@@ -1061,7 +1062,7 @@
|
||||
class:left-open={!transferredWindow && leftOpen}
|
||||
class:right-open={!transferredWindow && rightOpen}
|
||||
role="application"
|
||||
aria-label="RuneStone workbench"
|
||||
aria-label={$t("RuneStone workbench")}
|
||||
style:--left="{leftWidth}px"
|
||||
style:--right="{rightWidth}px"
|
||||
style:--bottom="{bottomHeight}px"
|
||||
@@ -1075,19 +1076,19 @@
|
||||
{#if !transferredWindow}
|
||||
<IconButton
|
||||
icon="files"
|
||||
label="Files"
|
||||
label={$t("Files")}
|
||||
active={leftOpen && !$pluginSidebar && leftView === "files"}
|
||||
onclick={() => selectLeft("files")}
|
||||
/>
|
||||
<IconButton
|
||||
icon="search"
|
||||
label="Search"
|
||||
label={$t("Search")}
|
||||
active={leftOpen && !$pluginSidebar && leftView === "search"}
|
||||
onclick={() => selectLeft("search")}
|
||||
/>
|
||||
<IconButton
|
||||
icon="bookmark"
|
||||
label="Bookmarks"
|
||||
label={$t("Bookmarks")}
|
||||
active={leftOpen && !$pluginSidebar && leftView === "bookmarks"}
|
||||
onclick={() => selectLeft("bookmarks")}
|
||||
/>
|
||||
@@ -1107,19 +1108,19 @@
|
||||
fileActions={workingTabFileActions} tabActions={workingTabActions} onMove={moveWorkingTab}
|
||||
onDetach={(tab) => { void detachTab(tab); }}
|
||||
tabDragData={workingTabDragData} onDropTab={(data, index) => void receiveTab(data, index)} />
|
||||
<IconButton icon="plus" label="New tab (Ctrl T)" onclick={newTab} />
|
||||
<IconButton icon="plus" label={$t("New tab (Ctrl T)")} onclick={newTab} />
|
||||
{#if desktop}<div class="window-drag-space" data-tauri-drag-region></div>{/if}
|
||||
</div>
|
||||
<div class="header-right" data-tauri-drag-region>
|
||||
{#if browserContribution?.newTab}<IconButton icon="globe" label="New browser tab" disabled={browserOpening} onclick={() => void openBrowser()} />{/if}
|
||||
{#if browserContribution?.newTab}<IconButton icon="globe" label={$t("New browser tab")} disabled={browserOpening} onclick={() => void openBrowser()} />{/if}
|
||||
<PluginAccessMenu surface="open" compact />
|
||||
<PluginTools />
|
||||
<PluginAccessMenu surface="commands" compact />
|
||||
<IconButton icon="save" label="Save" disabled={editorPluginVisible || !dirty || saving} onclick={() => void save()} />
|
||||
{#if terminalEnabled}<IconButton icon="terminal" label="Terminal" active={terminalOpen} onclick={toggleTerminal} />{/if}
|
||||
<IconButton icon="save" label={$t("Save")} disabled={editorPluginVisible || !dirty || saving} onclick={() => void save()} />
|
||||
{#if terminalEnabled}<IconButton icon="terminal" label={$t("Terminal")} active={terminalOpen} onclick={toggleTerminal} />{/if}
|
||||
{#if !transferredWindow}<IconButton
|
||||
icon="panel-right"
|
||||
label={rightOpen ? "Hide outline" : "Show outline"}
|
||||
label={rightOpen ? $t("Hide outline") : $t("Show outline")}
|
||||
active={rightOpen}
|
||||
onclick={() => (rightOpen = !rightOpen)}
|
||||
/>{/if}
|
||||
@@ -1127,7 +1128,7 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{#if !transferredWindow}<nav class="plugin-ribbon" aria-label="Plugin shortcuts" hidden={ribbonNavigation.length === 0}>
|
||||
{#if !transferredWindow}<nav class="plugin-ribbon" aria-label={$t("Plugin shortcuts")} hidden={ribbonNavigation.length === 0}>
|
||||
{#each ribbonNavigation as item (`${item.owner}:${item.id}`)}
|
||||
<IconButton
|
||||
icon={item.icon === "list" || item.icon === "kanban" || item.icon === "globe" || item.icon === "git" ? item.icon : "puzzle"}
|
||||
@@ -1147,7 +1148,7 @@
|
||||
{/if}
|
||||
<div class="native-left" class:sidebar-covered={!!$pluginSidebar}>
|
||||
{#if !workspace}
|
||||
{#if leftView === "bookmarks"}<BrowserSlot kind="bookmarks" />{:else}<p class="placeholder">No folder is open.</p>{/if}
|
||||
{#if leftView === "bookmarks"}<BrowserSlot kind="bookmarks" />{:else}<p class="placeholder">{$t("No folder is open.")}</p>{/if}
|
||||
{:else}
|
||||
<div class="left-stack">
|
||||
<div class="left-layer" class:shown={leftView === "files"}>
|
||||
@@ -1183,12 +1184,12 @@
|
||||
</div>
|
||||
<div class="left-footer">
|
||||
<div class="footer-start" bind:this={workspaceAnchor}>
|
||||
<IconButton icon="folder-open" label="Open folder" onclick={chooseWorkspace} />
|
||||
<span class="ws">{workspace ? workspace.name : "No workspace"}</span>
|
||||
<IconButton icon="folder-open" label={$t("Open folder")} onclick={chooseWorkspace} />
|
||||
<span class="ws">{workspace ? workspace.name : $t("No workspace")}</span>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<IconButton icon="help" label="Help and about (F1)" onclick={() => preferences = "help"} />
|
||||
<IconButton icon="settings" label="Settings (Ctrl+,)" onclick={() => void openSettings()} />
|
||||
<IconButton icon="help" label={$t("Help and about (F1)")} onclick={() => preferences = "help"} />
|
||||
<IconButton icon="settings" label={$t("Settings (Ctrl+,)")} onclick={() => void openSettings()} />
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -1231,15 +1232,15 @@
|
||||
onpointerdowncapture={() => focusDocumentPane(pane.id)}
|
||||
onfocusin={() => focusDocumentPane(pane.id)}>
|
||||
{#if pane.buffer?.diskError}
|
||||
<div class="conflict" role="alert"><span>{pane.buffer.diskError}</span><button onclick={() => void saveCopy(pane.buffer)}>Save a copy</button><button onclick={() => void documents?.refresh()}>Retry</button></div>
|
||||
<div class="conflict" role="alert"><span>{pane.buffer.diskError}</span><button onclick={() => void saveCopy(pane.buffer)}>{$t("Save a copy")}</button><button onclick={() => void documents?.refresh()}>{$t("Retry")}</button></div>
|
||||
{:else if pane.buffer?.diskContents != null}
|
||||
<div class="conflict" role="alert">
|
||||
<span>This file changed on disk. Your edits are preserved. Review both versions before saving.</span>
|
||||
<button onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, true); }}>Use disk version</button>
|
||||
<button onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, false); }}>Keep my edits</button>
|
||||
<button onclick={() => void saveCopy(pane.buffer)}>Save a copy</button>
|
||||
<span>{$t("This file changed on disk. Your edits are preserved. Review both versions before saving.")}</span>
|
||||
<button onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, true); }}>{$t("Use disk version")}</button>
|
||||
<button onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, false); }}>{$t("Keep my edits")}</button>
|
||||
<button onclick={() => void saveCopy(pane.buffer)}>{$t("Save a copy")}</button>
|
||||
</div>
|
||||
<details class="disk-review"><summary>View disk version</summary><pre>{pane.buffer.diskContents}</pre></details>
|
||||
<details class="disk-review"><summary>{$t("View disk version")}</summary><pre>{pane.buffer.diskContents}</pre></details>
|
||||
{/if}
|
||||
<EditorPane
|
||||
bind:this={paneComponents[pane.id]}
|
||||
@@ -1290,7 +1291,7 @@
|
||||
getSelection={() => selectedEditorText(buffer?.id)} onConfigureTasks={configureTasks} />
|
||||
{/key}
|
||||
{:else}
|
||||
<p class="placeholder">Open a workspace to start the terminal.</p>
|
||||
<p class="placeholder">{$t("Open a workspace to start the terminal.")}</p>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
@@ -1322,7 +1323,7 @@
|
||||
{#if workspace}
|
||||
<span>{workspace.watch_mode} watch</span>
|
||||
{/if}
|
||||
<span>{isIde ? "IDE" : "Writer"}</span>
|
||||
<span>{isIde ? $t("IDE") : $t("Writer")}</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { t, tr } from "$lib/i18n";
|
||||
import { tick } from "svelte";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import { pickWorkspaceFolder, workspaceRecent } from "$lib/workspace/api";
|
||||
import { attachTooltip } from "$lib/ui/tooltip";
|
||||
import { pickWorkspaceFolder, workspaceRecent, workspaceForget } from "$lib/workspace/api";
|
||||
|
||||
let { currentRoot, anchor, onOpen }: {
|
||||
currentRoot?: string; anchor?: HTMLElement;
|
||||
@@ -19,21 +21,26 @@
|
||||
let parent = $state("");
|
||||
let returnFocus: HTMLElement | null = null;
|
||||
const folderName = (path: string) => path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path;
|
||||
const destination = $derived(parent ? `${parent.replace(/[\\/]+$/, "")}${parent.includes("\\") ? "\\" : "/"}${name.trim()}` : "Choose where to create your workspace.");
|
||||
const removeTooltip = (node: HTMLElement) => ({ destroy: attachTooltip(node, () => tr("Remove from recent workspaces")) });
|
||||
const destination = $derived(parent ? `${parent.replace(/[\\/]+$/, "")}${parent.includes("\\") ? "\\" : "/"}${name.trim()}` : $t("Choose where to create your workspace."));
|
||||
|
||||
export async function show() {
|
||||
if (busy || creating) return;
|
||||
if (menu.matches(":popover-open")) { menu.hidePopover(); return; }
|
||||
returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
error = ""; loading = true;
|
||||
const keyboard = anchor?.matches(":focus-visible") ?? false;
|
||||
menu.showPopover();
|
||||
position();
|
||||
menu.querySelector<HTMLButtonElement>("button")?.focus();
|
||||
menu.focus();
|
||||
try { recent = await workspaceRecent(); }
|
||||
catch (err) { error = `Could not load recent workspaces: ${String(err)}`; }
|
||||
catch (err) { error = tr("Could not load recent workspaces: {error}", { error: String(err) }); }
|
||||
finally { loading = false; }
|
||||
await tick();
|
||||
if (menu.matches(":popover-open")) { position(); menu.querySelector<HTMLButtonElement>("button")?.focus(); }
|
||||
if (menu.matches(":popover-open")) {
|
||||
position();
|
||||
if (keyboard) (menu.querySelector<HTMLButtonElement>('button[aria-current="true"]') ?? menu.querySelector<HTMLButtonElement>("button"))?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function position() {
|
||||
@@ -44,12 +51,25 @@
|
||||
|
||||
function close() { menu.hidePopover(); returnFocus?.focus(); }
|
||||
|
||||
async function forget(path: string) {
|
||||
if (busy) return;
|
||||
busy = true; error = "";
|
||||
const index = recent.indexOf(path);
|
||||
try { recent = await workspaceForget(path); }
|
||||
catch (err) { error = tr("Could not remove workspace from recent workspaces: {error}", { error: String(err) }); }
|
||||
finally { busy = false; }
|
||||
await tick();
|
||||
position();
|
||||
const rows = menu.querySelectorAll<HTMLButtonElement>(".workspace-row");
|
||||
(rows[Math.min(index, rows.length - 1)] ?? menu.querySelector<HTMLButtonElement>("footer button"))?.focus();
|
||||
}
|
||||
|
||||
async function open(path: string) {
|
||||
if (busy) return;
|
||||
if (path === currentRoot) { close(); return; }
|
||||
busy = true; error = "";
|
||||
try { if (await onOpen(path)) close(); }
|
||||
catch (err) { error = `Could not open workspace: ${String(err)}`; }
|
||||
catch (err) { error = tr("Could not open workspace: {error}", { error: String(err) }); }
|
||||
finally { busy = false; }
|
||||
}
|
||||
|
||||
@@ -70,7 +90,7 @@
|
||||
function cancel() { if (!busy) { creating = false; returnFocus?.focus(); } }
|
||||
async function chooseLocation() {
|
||||
busy = true; error = "";
|
||||
try { const path = await pickWorkspaceFolder("Choose a location for the new workspace"); if (path) parent = path; }
|
||||
try { const path = await pickWorkspaceFolder(tr("Choose a location for the new workspace")); if (path) parent = path; }
|
||||
catch (err) { error = String(err); }
|
||||
finally { busy = false; }
|
||||
}
|
||||
@@ -93,38 +113,41 @@
|
||||
</script>
|
||||
|
||||
<svelte:window onresize={() => { if (menu?.matches(":popover-open")) position(); }} />
|
||||
<div bind:this={menu} popover="auto" class="workspace-menu rs-picker" role="dialog" aria-label="Workspaces" tabindex="-1" onkeydown={navigate}>
|
||||
<h2>Recent workspaces</h2>
|
||||
<div bind:this={menu} popover="auto" class="workspace-menu rs-picker" role="dialog" aria-label={$t("Workspaces")} tabindex="-1" onkeydown={navigate}>
|
||||
<h2>{$t("Recent workspaces")}</h2>
|
||||
<div class="recent" aria-busy={loading || busy}>
|
||||
{#if loading}<p>Loading workspaces…</p>
|
||||
{:else if !recent.length}<p>No recent workspaces yet.</p>{/if}
|
||||
{#each recent as path}
|
||||
{#if loading}<p>{$t("Loading workspaces…")}</p>
|
||||
{:else if !recent.length}<p>{$t("No recent workspaces yet.")}</p>{/if}
|
||||
{#each recent as path (path)}
|
||||
<div class="workspace-entry">
|
||||
<button class="workspace-row rs-picker-row" aria-current={path === currentRoot ? "true" : undefined} disabled={busy} onclick={() => open(path)}>
|
||||
<span class="rs-picker-icon"><Icon icon="folder-open" /></span>
|
||||
<span class="details"><span>{folderName(path)}</span><small>{path}</small></span>
|
||||
{#if path === currentRoot}<span class="current-label">Current</span>{/if}
|
||||
{#if path === currentRoot}<span class="current-label">{$t("Current")}</span>{/if}
|
||||
</button>
|
||||
<button class="workspace-remove rs-picker-row" aria-label={$t("Remove {path} from recent workspaces", { path })} use:removeTooltip disabled={busy} onclick={() => forget(path)}><Icon icon="close" /></button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<footer>
|
||||
<button class="rs-picker-row" disabled={busy} onclick={newWorkspace}><span class="rs-picker-icon"><Icon icon="folder-plus" /></span> New workspace…</button>
|
||||
<button class="rs-picker-row" disabled={busy} onclick={browse}><span class="rs-picker-icon"><Icon icon="folder-open" /></span> Open another folder…</button>
|
||||
<button class="rs-picker-row" disabled={busy} onclick={newWorkspace}><span class="rs-picker-icon"><Icon icon="folder-plus" /></span> {$t("New workspace…")}</button>
|
||||
<button class="rs-picker-row" disabled={busy} onclick={browse}><span class="rs-picker-icon"><Icon icon="folder-open" /></span> {$t("Open another folder…")}</button>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
{#if creating}
|
||||
<dialog bind:this={dialog} aria-labelledby="new-workspace-title" oncancel={(event) => { event.preventDefault(); cancel(); }}>
|
||||
<form onsubmit={(event) => { event.preventDefault(); void create(); }}>
|
||||
<h2 id="new-workspace-title"><Icon icon="folder-plus" /> New workspace</h2>
|
||||
<p>Create a folder for your notes and files, then open it in a new window.</p>
|
||||
<label for="workspace-name">Workspace name</label>
|
||||
<input id="workspace-name" bind:this={input} bind:value={name} oninput={() => error = ""} placeholder="My workspace" autocomplete="off" required disabled={busy} />
|
||||
<div class="location-label"><label for="workspace-location">Location</label><button type="button" disabled={busy} onclick={chooseLocation}><Icon icon="folder-open" /> Browse…</button></div>
|
||||
<input id="workspace-location" value={parent} readonly placeholder="Choose a parent folder" />
|
||||
<small class="destination">{parent ? "Will create: " : ""}{destination}</small>
|
||||
<h2 id="new-workspace-title"><Icon icon="folder-plus" /> {$t("New workspace")}</h2>
|
||||
<p>{$t("Create a folder for your notes and files, then open it in a new window.")}</p>
|
||||
<label for="workspace-name">{$t("Workspace name")}</label>
|
||||
<input id="workspace-name" bind:this={input} bind:value={name} oninput={() => error = ""} placeholder={$t("My workspace")} autocomplete="off" required disabled={busy} />
|
||||
<div class="location-label"><label for="workspace-location">{$t("Location")}</label><button type="button" disabled={busy} onclick={chooseLocation}><Icon icon="folder-open" /> {$t("Browse…")}</button></div>
|
||||
<input id="workspace-location" value={parent} readonly placeholder={$t("Choose a parent folder")} />
|
||||
<small class="destination">{parent ? $t("Will create: {path}", { path: destination }) : destination}</small>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<div class="actions"><button type="button" disabled={busy} onclick={cancel}>Cancel</button><button class="primary" type="submit" disabled={busy || !name.trim() || !parent}>{busy ? "Please wait…" : "Create workspace"}</button></div>
|
||||
<div class="actions"><button type="button" disabled={busy} onclick={cancel}>{$t("Cancel")}</button><button class="primary" type="submit" disabled={busy || !name.trim() || !parent}>{busy ? $t("Please wait…") : $t("Create workspace")}</button></div>
|
||||
</form>
|
||||
</dialog>
|
||||
{/if}
|
||||
@@ -140,6 +163,9 @@
|
||||
form button:focus-visible, input:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: -2px; }
|
||||
form button:disabled { opacity: .5; }
|
||||
.workspace-row, footer button { width: 100%; }
|
||||
.workspace-entry { display: flex; align-items: stretch; }
|
||||
.workspace-entry .workspace-row { flex: 1; min-width: 0; }
|
||||
.workspace-entry .workspace-remove { width: 30px; flex: 0 0 30px; justify-content: center; padding-inline: 0; }
|
||||
.details { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 3px; }
|
||||
small { font-size: 11px; color: var(--rs-text-dim); overflow-wrap: anywhere; }
|
||||
.current-label { font-size: 11px; color: var(--rs-accent); }
|
||||
|
||||
Reference in New Issue
Block a user