Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
import type { GitLineInfo } from "$lib/git/contracts";
|
||||
import EditorHost from "$lib/editor/EditorHost.svelte";
|
||||
import LiveWriter from "$lib/editor/LiveWriter.svelte";
|
||||
import { onDestroy, tick } from "svelte";
|
||||
import { retainEditorSessions } from "$lib/editor/sessions";
|
||||
import { tick } from "svelte";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import ImageViewer from "./ImageViewer.svelte";
|
||||
import MarkdownView from "./MarkdownView.svelte";
|
||||
import ModeSwitcher from "$lib/ui/ModeSwitcher.svelte";
|
||||
@@ -13,6 +13,8 @@
|
||||
import type { Chrome, OpenBuffer } from "$lib/workspace/types";
|
||||
import type { TableContextActions } from "$lib/editor/tableCellActions";
|
||||
|
||||
import type { DocumentLinkActions } from "$lib/editor/linkMenu";
|
||||
|
||||
type Props = {
|
||||
buffer: OpenBuffer | null;
|
||||
tabs: OpenBuffer[];
|
||||
@@ -33,9 +35,12 @@
|
||||
browserOpening?: boolean;
|
||||
hasWorkspace: boolean;
|
||||
tableActions?: TableContextActions;
|
||||
linkActions?: DocumentLinkActions;
|
||||
active?: boolean;
|
||||
onCloseSplit?: () => void;
|
||||
};
|
||||
|
||||
let { buffer, tabs, chrome, reading, focusLine, onChange, onRenameTitle, onInsertImage, onToggleReading, onToggleChrome, onOpenLink, onOpenWorkspace, onNewFile, onNewNote, onQuickOpen, onOpenBrowser, browserOpening = false, hasWorkspace, tableActions }: Props = $props();
|
||||
let { buffer, tabs, chrome, reading, focusLine, onChange, onRenameTitle, onInsertImage, onToggleReading, onToggleChrome, onOpenLink, onOpenWorkspace, onNewFile, onNewNote, onQuickOpen, onOpenBrowser, browserOpening = false, hasWorkspace, tableActions, linkActions, active = true, onCloseSplit }: Props = $props();
|
||||
let selectedLine = $state(1);
|
||||
let lineInfo = $state<GitLineInfo | null>(null);
|
||||
const git = $derived.by(() => { void $pluginHost; return pluginHost.get("git"); });
|
||||
@@ -60,7 +65,15 @@
|
||||
let previewMode = $state<"split" | "preview">("split");
|
||||
let modeControls = $state<HTMLDivElement>();
|
||||
let titleFocusId = $state<string | null>(null);
|
||||
const shouldFocusOnMount = () => !modeControls?.contains(document.activeElement);
|
||||
let element: HTMLDivElement | undefined = $state();
|
||||
let writerEditor: LiveWriter | undefined = $state();
|
||||
let sourceEditor: EditorHost | undefined = $state();
|
||||
const shouldFocusOnMount = () => active && !modeControls?.contains(document.activeElement);
|
||||
export function focusEditor() {
|
||||
if (reading) element?.querySelector<HTMLElement>(".reading")?.focus({ preventScroll: true });
|
||||
else if (writerEditor) writerEditor.focus();
|
||||
else sourceEditor?.focus();
|
||||
}
|
||||
export function focusTitle(id: string) {
|
||||
titleFocusId = id;
|
||||
}
|
||||
@@ -70,10 +83,8 @@
|
||||
const previewScroll = new Map<string, { top: number; left: number }>();
|
||||
$effect(() => {
|
||||
const ids = tabs.map(tab => tab.id);
|
||||
retainEditorSessions(ids);
|
||||
for (const id of previewScroll.keys()) if (!ids.includes(id)) previewScroll.delete(id);
|
||||
});
|
||||
onDestroy(() => retainEditorSessions([]));
|
||||
|
||||
function rememberPreviewScroll(node: HTMLDivElement, id: string) {
|
||||
const saved = previewScroll.get(id);
|
||||
@@ -117,21 +128,23 @@
|
||||
|
||||
{#if !buffer || buffer.kind === "empty"}
|
||||
<div class="empty">
|
||||
<h1>{buffer?.kind === "empty" ? "New tab" : "One project. Notes, code, terminal."}</h1>
|
||||
<p>{hasWorkspace ? "Open a file to get started, or create a note or script." : "Open a folder to work with your own files."}</p>
|
||||
{#if onCloseSplit}<IconButton icon="close" label="Close split" onclick={onCloseSplit} />{/if}
|
||||
<div class="welcome-actions">
|
||||
{#if onOpenBrowser}<button onclick={onOpenBrowser} disabled={browserOpening}><Icon icon="globe" /> {browserOpening ? "Opening browser…" : "Open browser"}</button>{/if}
|
||||
<button onclick={onOpenWorkspace}><Icon icon="folder-open" /> Open folder <kbd>Ctrl O</kbd></button>
|
||||
{#if hasWorkspace}
|
||||
<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 a file <kbd>Ctrl P</kbd></button>
|
||||
<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>
|
||||
</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}
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint">Save · Ctrl S Terminal · Ctrl ` Find in file · Ctrl F</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="editor">
|
||||
<div class="editor" class:pane-active={active} bind:this={element}>
|
||||
<div class="chrome-bar">
|
||||
<span class="breadcrumb" title={buffer.relPath}>{buffer.relPath}</span>
|
||||
{#if lineInfo}
|
||||
@@ -140,6 +153,7 @@
|
||||
</span>
|
||||
{/if}
|
||||
<div class="actions" bind:this={modeControls}>
|
||||
{#if onCloseSplit}<IconButton icon="close" label="Close split" onclick={onCloseSplit} />{/if}
|
||||
{#if canPreview}
|
||||
<ModeSwitcher
|
||||
label="Document view"
|
||||
@@ -171,17 +185,17 @@
|
||||
<div class="editor-wrap" class:hidden={reading && canPreview && previewMode === "preview"}>
|
||||
{#key buffer.id}
|
||||
{#if !isIde && canPreview && !reading}
|
||||
<LiveWriter {buffer} {onChange} {onRenameTitle} {onInsertImage} {onOpenLink} {focusLine} {tableActions} {shouldFocusOnMount} onSelectionLine={(line) => selectedLine = line}
|
||||
<LiveWriter bind:this={writerEditor} {buffer} {onChange} {onRenameTitle} {onInsertImage} {onOpenLink} {linkActions} {focusLine} {tableActions} {shouldFocusOnMount} onSelectionLine={(line) => selectedLine = line}
|
||||
focusTitle={titleFocusId === buffer.id} onTitleFocused={() => { titleFocusId = null; }} />
|
||||
{:else}
|
||||
<EditorHost {buffer} {chrome} {onChange} {onInsertImage} {onOpenLink} {focusLine} {tableActions} {shouldFocusOnMount} onSelectionLine={(line) => selectedLine = line} />
|
||||
<EditorHost bind:this={sourceEditor} {buffer} {chrome} {onChange} {onInsertImage} {onOpenLink} {linkActions} {focusLine} {tableActions} {shouldFocusOnMount} onSelectionLine={(line) => selectedLine = line} />
|
||||
{/if}
|
||||
{/key}
|
||||
</div>
|
||||
{#if reading && canPreview}
|
||||
{#key buffer.id}
|
||||
<div class="md-page" use:rememberPreviewScroll={buffer.id}>
|
||||
<MarkdownView noteRel={buffer.relPath} contents={buffer.contents} {onOpenLink} />
|
||||
<MarkdownView noteRel={buffer.relPath} contents={buffer.contents} {onOpenLink} {linkActions} onSearch={tableActions?.onSearch} />
|
||||
</div>
|
||||
{/key}
|
||||
{/if}
|
||||
@@ -195,11 +209,12 @@
|
||||
.line-history span { overflow: hidden; text-overflow: ellipsis; }
|
||||
.line-history :global(svg) { width: 14px; height: 14px; flex-shrink: 0; }
|
||||
.breadcrumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; }
|
||||
.welcome-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
|
||||
.welcome-actions button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); padding: 10px 14px; }
|
||||
.welcome-actions { display: flex; flex-direction: column; gap: 12px; max-width: 100%; }
|
||||
.welcome-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 100%; }
|
||||
.welcome-actions button { flex-wrap: wrap; justify-content: center; max-width: 100%; }
|
||||
.welcome-actions button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-image-control-bg); padding: 10px 14px; }
|
||||
.welcome-actions button:hover { background: var(--rs-image-control-hover-bg); }
|
||||
kbd { margin-left: 12px; color: var(--rs-text-dim); font-size: 11px; }
|
||||
h1 { color: var(--rs-text-strong); font-size: 24px; font-weight: 500; }
|
||||
.hint { margin-top: 32px; font-size: 12px; }
|
||||
.hidden { display: none; }
|
||||
.split .md-page { border-left: 1px solid var(--rs-border); }
|
||||
.editor { container-type: inline-size; }
|
||||
@@ -214,11 +229,6 @@
|
||||
}
|
||||
|
||||
.empty {
|
||||
background-color: var(--rs-new-tab-bg, var(--rs-bg));
|
||||
background-image: var(--rs-background-image, var(--rs-new-tab-image, none));
|
||||
background-size: 100% 100%, var(--rs-background-size, cover);
|
||||
background-position: center, var(--rs-background-position, center);
|
||||
background-repeat: no-repeat;
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
@@ -227,7 +237,6 @@
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
.empty h1,.empty>p{background:color-mix(in srgb,var(--rs-bg) 92%,transparent);padding:8px 14px;border-radius:var(--rs-control-radius)}
|
||||
|
||||
.chrome-bar {
|
||||
display: flex;
|
||||
@@ -251,6 +260,7 @@
|
||||
}
|
||||
|
||||
.body {
|
||||
background: var(--rs-workarea-editor-bg);
|
||||
flex: 1;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
|
||||
@@ -469,11 +469,16 @@
|
||||
}
|
||||
|
||||
async function createIn(parent: string, kind: "folder" | "note" | "file") {
|
||||
const operationRoot = workspaceRoot;
|
||||
let name: string;
|
||||
if (kind === "note") {
|
||||
name = "untitled.md";
|
||||
if (kind === "note" || kind === "folder") {
|
||||
name = kind === "folder" ? "untitled" : "untitled.md";
|
||||
if (kind === "folder") {
|
||||
await load(parent);
|
||||
if (workspaceRoot !== operationRoot || error) return;
|
||||
}
|
||||
} else {
|
||||
const typed = await requestText(kind === "folder" ? "Folder name" : "File name, including any extension", kind === "folder" ? "folder" : "Untitled");
|
||||
const typed = await requestText("File name, including any extension", "Untitled");
|
||||
if (!typed) {
|
||||
return;
|
||||
}
|
||||
@@ -484,21 +489,26 @@
|
||||
}
|
||||
name = typed.trim();
|
||||
}
|
||||
const finalName = kind === "file" ? name : uniqueName(namesIn(parent), name);
|
||||
if (workspaceRoot !== operationRoot) return;
|
||||
const finalName = kind === "file" ? name : uniqueName(kind === "folder" ? namesIn(parent).map(value => value.toLowerCase()) : namesIn(parent), name);
|
||||
const rel = joinRel(parent, finalName);
|
||||
try {
|
||||
await workspaceCreate(rel, kind === "folder" ? "folder" : "file");
|
||||
if (workspaceRoot !== operationRoot) return;
|
||||
const order = { ...marks.order };
|
||||
order[parent] = [...(order[parent] ?? []), finalName];
|
||||
await persistMarks({ ...marks, order });
|
||||
if (!childrenMap[parent] && parent !== "") {
|
||||
if (kind === "folder" || (!childrenMap[parent] && parent !== "")) {
|
||||
const next = new Set(expanded);
|
||||
next.add(parent);
|
||||
expanded = next;
|
||||
}
|
||||
await load(parent);
|
||||
if (workspaceRoot !== operationRoot) return;
|
||||
onStatus?.(`Created ${rel}`);
|
||||
if (kind !== "folder") {
|
||||
if (kind === "folder") {
|
||||
startRename({ name: finalName, rel_path: rel, kind: "folder" });
|
||||
} else {
|
||||
onCreated?.({ name: finalName, rel_path: rel, kind: "file" });
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -575,6 +585,24 @@
|
||||
await focusTreePath(paths.values().next().value);
|
||||
}
|
||||
|
||||
export async function revealPath(path: string) {
|
||||
const operationRoot = workspaceRoot;
|
||||
const folders = path.split("/").slice(0, -1);
|
||||
await load("");
|
||||
let parent = "";
|
||||
for (const folder of folders) {
|
||||
if (workspaceRoot !== operationRoot) return;
|
||||
parent = parent ? `${parent}/${folder}` : folder;
|
||||
expanded = new Set([...expanded, parent]);
|
||||
await load(parent);
|
||||
}
|
||||
if (workspaceRoot !== operationRoot) return;
|
||||
selectOnly(path);
|
||||
await focusTreePath(path);
|
||||
const target = [...treeElement.querySelectorAll<HTMLElement>("[data-tree-rel]")].find(node => node.dataset.treeRel === path);
|
||||
target?.scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
|
||||
async function focusTreePath(path?: string) {
|
||||
await tick();
|
||||
const target = [...treeElement.querySelectorAll<HTMLElement>("[data-tree-rel]")].find(node => node.dataset.treeRel === path);
|
||||
|
||||
@@ -9,23 +9,34 @@
|
||||
import { readerHeadingFolding } from "$lib/editor/headingFolding";
|
||||
import "$lib/editor/headingFolding.css";
|
||||
|
||||
import { readingMenu } from "$lib/editor/readingMenu";
|
||||
import type { DocumentLinkActions } from "$lib/editor/linkMenu";
|
||||
|
||||
type Props = {
|
||||
noteRel: string;
|
||||
contents: string;
|
||||
linkActions?: DocumentLinkActions;
|
||||
onSearch?: (text: string) => void;
|
||||
onOpenLink?: (kind: "md" | "wiki", target: string) => void;
|
||||
onEditBlock?: (start: number, end: number) => void;
|
||||
editing?: { start: number; end: number } | null;
|
||||
blockEditor?: Snippet;
|
||||
};
|
||||
|
||||
let { noteRel, contents, onOpenLink, onEditBlock, editing = null, blockEditor }: Props = $props();
|
||||
let { noteRel, contents, onOpenLink, linkActions = {}, onSearch, onEditBlock, editing = null, blockEditor }: Props = $props();
|
||||
let html = $state("");
|
||||
let menuError = $state("");
|
||||
let sections = $state<MarkdownSection[]>([]);
|
||||
let root: HTMLDivElement | undefined = $state();
|
||||
const collapsedHeadings = new Set<string>();
|
||||
let foldingNote = "";
|
||||
let headingControls: ReturnType<typeof readerHeadingFolding> | undefined;
|
||||
|
||||
$effect(() => {
|
||||
if (!root) return;
|
||||
return readingMenu(root, { ...linkActions, open: link => onOpenLink?.(link.kind, link.target) }, onSearch, message => { menuError = message; });
|
||||
});
|
||||
|
||||
async function loadUrls(noteRel: string, contents: string): Promise<Map<string, string>> {
|
||||
const urls = new Map<string, string>();
|
||||
await Promise.all(markdownImages(contents).map(async source => {
|
||||
@@ -117,6 +128,7 @@
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="reading"
|
||||
tabindex="-1"
|
||||
bind:this={root}
|
||||
onkeydown={(event) => {
|
||||
if (event.target instanceof HTMLElement && event.target.classList.contains("md-edit-block") && (event.key === "Enter" || event.key === " ")) {
|
||||
@@ -165,6 +177,7 @@
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#if menuError}<p role="alert">{menuError}</p>{/if}
|
||||
<h1 class="document-title">{markdownTitle(noteRel)}</h1>
|
||||
{#if onEditBlock}
|
||||
{#each sections.filter(section => !editing || section.start < editing.start) as section (section.start)}
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
let error = $state("");
|
||||
let dialog: HTMLDialogElement;
|
||||
let input: HTMLInputElement;
|
||||
let picked = false;
|
||||
const matches = $derived(files.filter(file => query.toLowerCase().split(/\s+/).every(part => file.rel_path.toLowerCase().includes(part))).slice(0, 80));
|
||||
function pick(entry?: TreeEntry) { if (entry) { onOpen(entry); onClose(); } }
|
||||
function pick(entry?: TreeEntry) { if (entry) { picked = true; onOpen(entry); onClose(); } }
|
||||
onMount(() => {
|
||||
const origin = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
dialog.showModal(); input.focus();
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
@@ -27,11 +29,11 @@
|
||||
} catch (err) { if (!cancelled) error = String(err); }
|
||||
finally { if (!cancelled) loading = false; }
|
||||
})();
|
||||
return () => { cancelled = true; };
|
||||
return () => { cancelled = true; if (!picked && origin?.isConnected) origin.focus({ preventScroll: true }); };
|
||||
});
|
||||
</script>
|
||||
|
||||
<dialog bind:this={dialog} aria-label={purpose} onpointerdown={(event) => {
|
||||
<dialog class="rs-picker" bind:this={dialog} aria-label={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}>
|
||||
@@ -44,7 +46,7 @@
|
||||
}} />
|
||||
<div class="results">
|
||||
{#each matches as entry, index (entry.rel_path)}
|
||||
<button data-index={index} class:selected={selected === index} onclick={() => pick(entry)}><strong>{entry.name}</strong><span>{entry.rel_path}</span></button>
|
||||
<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}
|
||||
</div>
|
||||
@@ -52,12 +54,11 @@
|
||||
</dialog>
|
||||
|
||||
<style>
|
||||
dialog { margin-top: 12vh; padding: 0; width: min(640px, 85vw); background: var(--rs-bg-elevated); color: var(--rs-text); border: 1px solid var(--rs-border); }
|
||||
dialog { margin-top: 12vh; width: min(640px, 85vw); }
|
||||
dialog::backdrop { background: #0008; }
|
||||
input { width: 100%; padding: 16px; border: 0; background: var(--rs-bg); color: var(--rs-text-strong); }
|
||||
.results { max-height: 50vh; overflow: auto; padding: 6px; }
|
||||
button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px 10px; border: 0; background: transparent; text-align: left; }
|
||||
button.selected, button:hover { background: var(--rs-bg-active); }
|
||||
button span, footer { color: var(--rs-text-dim); font-size: 12px; }
|
||||
.results { max-height: 50vh; overflow: auto; }
|
||||
.file-detail { min-width: 0; overflow-wrap: anywhere; }
|
||||
footer { color: var(--rs-text-dim); font-size: var(--rs-settings-description-size); }
|
||||
footer { padding: 10px 14px; display: flex; justify-content: space-between; border-top: 1px solid var(--rs-border); }
|
||||
</style>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
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 GPT Claude Terminal Sakura" },
|
||||
{ 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" },
|
||||
];
|
||||
let section = $state<Section>(untrack(() => help ? "about" : "general"));
|
||||
|
||||
+241
-59
@@ -6,7 +6,12 @@
|
||||
import { pluginSplits, pinPluginEditor, pluginTabActions, pluginTabState, restorePluginTab, pluginTabDragData, dropPluginTab, findPluginEditor } from "$lib/plugins/external";
|
||||
import { containsPane, paneBounds } from "$lib/workspace/splitLayout";
|
||||
import { pluginSidebar, closePluginSidebar, pluginNavigation, openPluginView, pluginView, pluginEditors, pluginEditorActive, selectPluginEditor, closePluginEditor, openPluginDocument, renamePluginDocuments, removePluginDocuments, notifyPluginWorkspace, guardPluginWrites, handlePluginFileOpen, handlePluginDocumentRename, cancelPluginDocumentOpen, type OpenPluginView } from "$lib/plugins/external";
|
||||
import { onMount, tick, untrack } from "svelte";
|
||||
import { onMount, onDestroy, tick, untrack } from "svelte";
|
||||
import type { MenuLink } from "$lib/editor/linkMenu";
|
||||
import { loadMarks, saveMarks } from "$lib/workspace/marks";
|
||||
import { moveMarks } from "$lib/workspace/treeMoveHistory";
|
||||
import { retainEditorSessions } from "$lib/editor/sessions";
|
||||
import { initialDocumentPanes, syncDocumentPanes, splitDocumentPane, closeDocumentPane, selectPane, readDocumentPane } from "$lib/workspace/documentPanes";
|
||||
import { selectedEditorText } from "$lib/editor/selection";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import type { Contributions } from "$lib/plugins/contracts";
|
||||
@@ -41,6 +46,8 @@
|
||||
import {
|
||||
onWorkspaceEvent,
|
||||
workspaceNew,
|
||||
workspaceList,
|
||||
workspaceOpenDefault,
|
||||
workspaceCreate,
|
||||
workspaceAbsPath,
|
||||
workspaceLastPath,
|
||||
@@ -93,7 +100,8 @@
|
||||
let rightOpen = $state(!transferredWindow && DEFAULT_WORKBENCH_LAYOUT.rightOpen);
|
||||
$effect(() => { if ($pluginSidebar && !transferredWindow) leftOpen = true; });
|
||||
let terminalOpen = $state(false);
|
||||
let reading = $state(false);
|
||||
let documentPanes = $state(initialDocumentPanes());
|
||||
const reading = $derived(documentPanes.panes.find(pane => pane.id === documentPanes.active)?.reading ?? false);
|
||||
let quickOpen = $state(false);
|
||||
let templateManager = $state(false);
|
||||
let terminalStarted = $state(false);
|
||||
@@ -136,11 +144,14 @@
|
||||
let switching = false;
|
||||
let workbenchReady = $state(false);
|
||||
let documents: Documents | null = null;
|
||||
let editorPane: EditorPane | undefined = $state();
|
||||
let paneComponents = $state<Record<string, EditorPane | undefined>>({});
|
||||
function activeEditor() { return paneComponents[documentPanes.active]; }
|
||||
let fileTree: FileTree | undefined = $state();
|
||||
let closingTabs = false;
|
||||
const hasDirty = $derived(tabs.some(tab => tab.contents !== tab.saved));
|
||||
|
||||
function createDocuments() {
|
||||
documentPanes = initialDocumentPanes();
|
||||
const next = new Documents({
|
||||
read: workspaceRead, write: workspaceWrite, image: workspaceReadDataUrl,
|
||||
kind: path => isImagePath(path) ? "image" : "text", chrome: detectChrome,
|
||||
@@ -149,10 +160,50 @@
|
||||
tabs = next.buffers.map(tab => ({ ...tab }));
|
||||
activePath = next.activePath;
|
||||
const selected = next.active;
|
||||
documentPanes = syncDocumentPanes(documentPanes, next.buffers.map(tab => tab.id), selected?.id ?? null);
|
||||
if (selected) view = selected.chromeOverride ?? selected.chrome;
|
||||
});
|
||||
return next;
|
||||
}
|
||||
$effect(() => retainEditorSessions(tabs.map(tab => tab.id)));
|
||||
onDestroy(() => retainEditorSessions([]));
|
||||
const documentViews = $derived.by(() => {
|
||||
const bounds = paneBounds(documentPanes.layout);
|
||||
return documentPanes.panes.map(pane => ({ ...pane, buffer: tabs.find(tab => tab.id === pane.documentId) ?? null, bounds: bounds[pane.id] }))
|
||||
.sort((a, b) => a.bounds.left - b.bounds.left);
|
||||
});
|
||||
function setReading(next: boolean, paneId = documentPanes.active) {
|
||||
documentPanes = readDocumentPane(documentPanes, paneId, next);
|
||||
}
|
||||
function focusDocumentPane(paneId: string, focusEditor = false) {
|
||||
const pane = documentPanes.panes.find(pane => pane.id === paneId);
|
||||
if (!pane) return;
|
||||
const tab = tabs.find(tab => tab.id === pane.documentId);
|
||||
documentPanes = selectPane(documentPanes, paneId);
|
||||
pluginEditorActive.set(false);
|
||||
if (tab && documents?.active?.id !== tab.id) { focusLine = null; documents?.select(tab.relPath); }
|
||||
if (focusEditor) void tick().then(() => {
|
||||
if (documentPanes.active !== paneId) return;
|
||||
paneComponents[paneId]?.focusEditor();
|
||||
document.querySelector<HTMLElement>(`[data-document-pane="${paneId}"]`)?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
||||
});
|
||||
}
|
||||
function closeSplit(paneId: string) {
|
||||
documentPanes = closeDocumentPane(documentPanes, paneId);
|
||||
focusDocumentPane(documentPanes.active, true);
|
||||
}
|
||||
async function openToRight(file: TreeEntry, sourcePane: string) {
|
||||
const current = documents;
|
||||
const source = documentPanes.panes.find(pane => pane.id === sourcePane);
|
||||
if (!current || switching || !source) return;
|
||||
await current.open(file, "background");
|
||||
if (documents !== current || switching || documentPanes.active !== sourcePane
|
||||
|| documentPanes.panes.find(pane => pane.id === sourcePane)?.documentId !== source.documentId) return;
|
||||
const target = current.buffers.find(tab => tab.relPath === file.rel_path);
|
||||
if (!target) return;
|
||||
documentPanes = splitDocumentPane(documentPanes, sourcePane, target.id, crypto.randomUUID());
|
||||
focusDocumentPane(documentPanes.active, true);
|
||||
}
|
||||
let focusLine = $state<number | null>(null);
|
||||
let dragging = $state<"left" | "right" | "bottom" | null>(null);
|
||||
let centerStack: HTMLElement | undefined = $state();
|
||||
@@ -212,7 +263,7 @@
|
||||
|
||||
function toggleChrome() {
|
||||
const next = view === "Writing" ? "Ide" : "Writing";
|
||||
reading = false;
|
||||
setReading(false);
|
||||
applyChrome(next);
|
||||
documents?.setChrome(next);
|
||||
}
|
||||
@@ -306,7 +357,7 @@
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
} else throw new Error("Invalid tab transfer.");
|
||||
reading = transfer.reading === true;
|
||||
setReading(transfer.reading === true);
|
||||
localStorage.setItem(key + ".accepted", "true");
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
@@ -322,6 +373,7 @@
|
||||
pluginEditorActive.set(false);
|
||||
focusLine = null;
|
||||
documents?.select(relPath);
|
||||
focusDocumentPane(documentPanes.active, true);
|
||||
status = documents?.active?.kind === "empty" ? "New tab" : relPath;
|
||||
}
|
||||
|
||||
@@ -353,7 +405,7 @@
|
||||
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] : [];
|
||||
}
|
||||
async function detachTab(item: WorkbenchTab) {
|
||||
async function detachTab(item: WorkbenchTab, keepSource = false) {
|
||||
const tab = workingTabs.find(tab => tab.id === item.id);
|
||||
if (!tab || !workspace || !desktop) return;
|
||||
if ("plugin" in tab) {
|
||||
@@ -373,9 +425,9 @@
|
||||
};
|
||||
const accepted = (event: StorageEvent) => {
|
||||
if (event.key !== key + ".accepted" || event.newValue !== "true") return;
|
||||
if ("buffer" in tab) {
|
||||
if (!keepSource && "buffer" in tab) {
|
||||
if (documents === current && bufferSnapshot(current?.buffers.find(buffer => buffer.id === tab.buffer.id)) === snapshot) current?.close(tab.relPath);
|
||||
} else if (JSON.stringify(pluginTabState(tab.plugin)) === snapshot) closePluginEditor(tab.plugin.key);
|
||||
} else if (!keepSource && "plugin" in tab && JSON.stringify(pluginTabState(tab.plugin)) === snapshot) closePluginEditor(tab.plugin.key);
|
||||
finish();
|
||||
};
|
||||
try {
|
||||
@@ -449,7 +501,7 @@
|
||||
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: () => editorPane?.toggleReadingView() },
|
||||
{ label: reading ? "Editing view" : "Reading view", icon: "book", run: () => activeEditor()?.toggleReadingView() },
|
||||
{ label: isIde ? "Writing mode" : "Source mode", icon: "code", run: toggleChrome },
|
||||
);
|
||||
}
|
||||
@@ -482,7 +534,7 @@
|
||||
error = null;
|
||||
focusLine = null;
|
||||
if (line) {
|
||||
reading = false;
|
||||
setReading(false);
|
||||
queueMicrotask(() => { focusLine = line; });
|
||||
}
|
||||
} catch (err) { if (documents === current) error = String(err); }
|
||||
@@ -492,8 +544,8 @@
|
||||
const current = documents;
|
||||
await openFile(entry);
|
||||
if (documents !== current || current?.active?.relPath !== entry.rel_path || !isMarkdownPath(entry.rel_path)) return;
|
||||
reading = false;
|
||||
editorPane?.focusTitle(current.active.id);
|
||||
setReading(false);
|
||||
activeEditor()?.focusTitle(current.active.id);
|
||||
}
|
||||
|
||||
function readFileDataUrl(file: File): Promise<string> {
|
||||
@@ -505,11 +557,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
async function insertImage(file: File): Promise<string | null> {
|
||||
if (!buffer || buffer.kind !== "text" || !isMarkdownPath(buffer.relPath)) {
|
||||
async function insertImage(file: File, note = buffer): Promise<string | null> {
|
||||
if (!note || note.kind !== "text" || !isMarkdownPath(note.relPath)) {
|
||||
return null;
|
||||
}
|
||||
const noteRel = buffer.relPath;
|
||||
const noteRel = note.relPath;
|
||||
const current = documents;
|
||||
try {
|
||||
const rel = attachmentRel(file.name);
|
||||
@@ -538,8 +590,8 @@
|
||||
searchRequest = { text, id: (searchRequest?.id || 0) + 1 };
|
||||
}
|
||||
|
||||
async function extractSelection(markdown: string, label: string, valid: () => boolean): Promise<string | null> {
|
||||
const current = documents, note = buffer;
|
||||
async function extractSelection(markdown: string, label: string, valid: () => boolean, note = buffer): Promise<string | null> {
|
||||
const current = documents;
|
||||
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";
|
||||
@@ -587,8 +639,7 @@
|
||||
} finally { saving = false; }
|
||||
}
|
||||
|
||||
async function saveCopy() {
|
||||
const tab = buffer;
|
||||
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"));
|
||||
if (!name) return;
|
||||
@@ -789,7 +840,72 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function openLink(kind: "md" | "wiki", target: string) {
|
||||
function workspaceLinkItems(link: MenuLink, origin = activePath ?? "", sourcePane = documentPanes.active): ActionMenuItem[] {
|
||||
const current = documents, currentWorkspace = workspace;
|
||||
const valid = () => documents === current && workspace === currentWorkspace && !!currentWorkspace;
|
||||
const entry = async () => {
|
||||
for (const path of linkCandidates(origin, link.target, link.kind)) {
|
||||
if (!valid()) throw new Error("The workspace changed. Open the link menu again.");
|
||||
const parent = path.split("/").slice(0, -1).join("/");
|
||||
let files: TreeEntry[];
|
||||
try { files = await workspaceList(parent); } catch { continue; }
|
||||
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.`);
|
||||
};
|
||||
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);
|
||||
if (!typed || !valid()) return;
|
||||
let to = typed.trim().replaceAll("\\", "/");
|
||||
if (move) {
|
||||
if (!to || to.startsWith("/") || to.split("/").some(part => !part || part === "." || part === "..") || /[<>:"|?*\u0000-\u001f]/.test(to)) throw new Error("Enter a relative workspace path without reserved characters.");
|
||||
} else {
|
||||
const plan = planRename(file.rel_path, to);
|
||||
if (plan.action === "noop") return;
|
||||
if (plan.action === "error") throw new Error(plan.message);
|
||||
to = plan.to;
|
||||
}
|
||||
if (to === file.rel_path) return;
|
||||
const marks = await loadMarks();
|
||||
if (!valid()) return;
|
||||
await workspaceRename(file.rel_path, to, currentWorkspace!.root);
|
||||
if (!valid()) return;
|
||||
applyPathRename(file.rel_path, to);
|
||||
await saveMarks(moveMarks(marks, file.rel_path, to));
|
||||
refreshToken++;
|
||||
status = `Moved to ${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 => {
|
||||
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: "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 => {
|
||||
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}`;
|
||||
}) },
|
||||
{ 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); }) },
|
||||
];
|
||||
}
|
||||
|
||||
async function openLink(kind: "md" | "wiki", target: string, origin = activePath ?? "", paneId = documentPanes.active) {
|
||||
if (/^(https?:\/\/|mailto:)/i.test(target)) {
|
||||
try {
|
||||
if (/^https?:\/\//i.test(target) && await pluginHost.get("browser")?.open(target)) return;
|
||||
@@ -797,7 +913,8 @@
|
||||
} catch (err) { error = String(err); }
|
||||
return;
|
||||
}
|
||||
const rels = linkCandidates(activePath ?? "", target, kind);
|
||||
const rels = linkCandidates(origin, target, kind);
|
||||
focusDocumentPane(paneId);
|
||||
for (const rel of rels) {
|
||||
try {
|
||||
await documents?.open({ name: rel.split("/").pop() ?? rel, rel_path: rel, kind: "file" });
|
||||
@@ -952,6 +1069,7 @@
|
||||
onpointerup={() => (dragging = null)}
|
||||
onpointerleave={() => (dragging = null)}
|
||||
>
|
||||
<div class="workarea-background" aria-hidden="true"></div>
|
||||
<header class="header" data-tauri-drag-region>
|
||||
<div class="header-left" data-tauri-drag-region>
|
||||
{#if !transferredWindow}
|
||||
@@ -1034,6 +1152,7 @@
|
||||
<div class="left-stack">
|
||||
<div class="left-layer" class:shown={leftView === "files"}>
|
||||
<FileTree
|
||||
bind:this={fileTree}
|
||||
workspaceRoot={workspace.root}
|
||||
showInternal={settings.showInternalFolder}
|
||||
onSaveTemplate={(entry) => { void saveTemplate(entry); }}
|
||||
@@ -1103,39 +1222,57 @@
|
||||
{/each}
|
||||
</div>
|
||||
<div class="editor-host" class:plugin-covered={editorPluginVisible}>
|
||||
{#if buffer?.diskError}
|
||||
<div class="conflict" role="alert"><span>{buffer.diskError}</span><button onclick={() => void saveCopy()}>Save a copy</button><button onclick={() => void documents?.refresh()}>Retry</button></div>
|
||||
{:else if 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 (buffer) documents?.resolve(buffer.id, true); }}>Use disk version</button>
|
||||
<button onclick={() => { if (buffer) documents?.resolve(buffer.id, false); }}>Keep my edits</button>
|
||||
<button onclick={() => void saveCopy()}>Save a copy</button>
|
||||
</div>
|
||||
<details class="disk-review"><summary>View disk version</summary><pre>{buffer.diskContents}</pre></details>
|
||||
{/if}
|
||||
<EditorPane
|
||||
bind:this={editorPane}
|
||||
{tabs}
|
||||
hasWorkspace={!!workspace}
|
||||
onOpenWorkspace={() => void chooseWorkspace()}
|
||||
onNewFile={() => void newFile()}
|
||||
onNewNote={(event) => { void newNote(event); }}
|
||||
onQuickOpen={() => quickOpen = true}
|
||||
onOpenBrowser={browserContribution?.newTab ? () => void openBrowser() : undefined}
|
||||
{browserOpening}
|
||||
{buffer}
|
||||
chrome={view}
|
||||
{reading}
|
||||
{focusLine}
|
||||
{onChange}
|
||||
onInsertImage={insertImage}
|
||||
onRenameTitle={renameNoteTitle}
|
||||
tableActions={{ onSearch: searchSelection, onExtract: extractSelection }}
|
||||
onToggleReading={() => (reading = !reading)}
|
||||
onToggleChrome={toggleChrome}
|
||||
onOpenLink={(kind, target) => void openLink(kind, target)}
|
||||
/>
|
||||
<div class="document-panes" class:split={documentViews.length > 1}>
|
||||
{#each documentViews as pane (pane.id)}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions (Focus identifies the document for shared commands.) -->
|
||||
<div class="document-pane" class:focused={documentPanes.active === pane.id}
|
||||
data-document-pane={pane.id} data-document-path={pane.buffer?.relPath ?? ""}
|
||||
style:--pane-weight={pane.bounds.width}
|
||||
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>
|
||||
{: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>
|
||||
</div>
|
||||
<details class="disk-review"><summary>View disk version</summary><pre>{pane.buffer.diskContents}</pre></details>
|
||||
{/if}
|
||||
<EditorPane
|
||||
bind:this={paneComponents[pane.id]}
|
||||
{tabs}
|
||||
active={documentPanes.active === pane.id}
|
||||
onCloseSplit={documentViews.length > 1 ? () => closeSplit(pane.id) : undefined}
|
||||
hasWorkspace={!!workspace}
|
||||
onOpenWorkspace={() => void chooseWorkspace()}
|
||||
onNewFile={() => void newFile()}
|
||||
onNewNote={(event) => { void newNote(event); }}
|
||||
onQuickOpen={() => quickOpen = true}
|
||||
onOpenBrowser={browserContribution?.newTab ? () => void openBrowser() : undefined}
|
||||
{browserOpening}
|
||||
buffer={pane.buffer}
|
||||
chrome={pane.buffer?.chromeOverride ?? pane.buffer?.chrome ?? "Writing"}
|
||||
reading={pane.reading}
|
||||
focusLine={documentPanes.active === pane.id ? focusLine : null}
|
||||
{onChange}
|
||||
onInsertImage={file => insertImage(file, pane.buffer)}
|
||||
onRenameTitle={renameNoteTitle}
|
||||
tableActions={{ onSearch: searchSelection, onExtract: (markdown, label, valid) => extractSelection(markdown, label, valid, pane.buffer) }}
|
||||
linkActions={{
|
||||
browser: browserContribution ? async target => { if (!await browserContribution?.open(target)) throw new Error("Could not open the app browser."); } : undefined,
|
||||
defaultBrowser: target => openUrl(target),
|
||||
workspaceItems: link => workspaceLinkItems(link, pane.buffer?.relPath ?? "", pane.id),
|
||||
}}
|
||||
onToggleReading={() => setReading(!pane.reading, pane.id)}
|
||||
onToggleChrome={() => { focusDocumentPane(pane.id); toggleChrome(); }}
|
||||
onOpenLink={(kind, target) => void openLink(kind, target, pane.buffer?.relPath ?? "", pane.id)}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{#if terminalContribution && terminalStarted}
|
||||
@@ -1170,7 +1307,7 @@
|
||||
items={outlineItems}
|
||||
onJump={(line) => {
|
||||
pluginEditorActive.set(false);
|
||||
reading = false;
|
||||
setReading(false);
|
||||
focusLine = null;
|
||||
queueMicrotask(() => {
|
||||
focusLine = line;
|
||||
@@ -1199,6 +1336,8 @@
|
||||
.disk-review { padding: 8px 12px; max-height: 35vh; overflow: auto; flex: 0 0 auto; }
|
||||
.disk-review pre { white-space: pre-wrap; user-select: text; }
|
||||
.shell {
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
--ribbon-width: 0px;
|
||||
@@ -1207,6 +1346,39 @@
|
||||
background: var(--rs-bg);
|
||||
}
|
||||
|
||||
.workarea-background {
|
||||
position: absolute;
|
||||
inset: var(--rs-titlebar-height) 0 22px;
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
background-color: var(--rs-new-tab-bg, var(--rs-bg));
|
||||
background-image: var(--rs-background-image, var(--rs-new-tab-image, none));
|
||||
background-size: var(--rs-background-layer-sizes, 100% 100%, var(--rs-background-size, cover));
|
||||
background-position: var(--rs-background-layer-positions, center, var(--rs-background-position, center));
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.workarea-background::before,
|
||||
.workarea-background::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.workarea-background::before {
|
||||
background-image: var(--rs-background-previous-image, none);
|
||||
background-size: var(--rs-background-previous-layer-sizes, 100% 100%, var(--rs-background-previous-size, cover));
|
||||
background-position: var(--rs-background-previous-layer-positions, center, var(--rs-background-previous-position, center));
|
||||
}
|
||||
|
||||
.workarea-background::after {
|
||||
background-image: var(--rs-background-transition-image, none);
|
||||
background-size: var(--rs-background-layer-sizes, 100% 100%, var(--rs-background-size, cover));
|
||||
background-position: var(--rs-background-layer-positions, center, var(--rs-background-position, center));
|
||||
}
|
||||
|
||||
.shell.left-open {
|
||||
grid-template-columns: var(--ribbon-width) var(--left) 1px minmax(0, 1fr);
|
||||
}
|
||||
@@ -1232,7 +1404,7 @@
|
||||
min-height: 0;
|
||||
padding: 6px 5px;
|
||||
overflow-y: auto;
|
||||
background: var(--rs-bg-elevated);
|
||||
background: var(--rs-workarea-sidebar-bg);
|
||||
border-right: 1px solid var(--rs-border);
|
||||
}
|
||||
|
||||
@@ -1315,7 +1487,7 @@
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: var(--rs-bg);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.center-stack {
|
||||
@@ -1337,6 +1509,16 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.editor-host { container-type: inline-size; }
|
||||
.document-panes { flex: 1; min-height: 0; display: flex; overflow: hidden; }
|
||||
.document-pane { flex: var(--pane-weight) 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
||||
.document-pane + .document-pane { border-left: 1px solid var(--rs-border); }
|
||||
.document-panes.split .document-pane.focused :global(.chrome-bar) { background: var(--rs-bg-active); }
|
||||
@container (max-width: 640px) {
|
||||
.document-panes.split { flex-direction: column; overflow-y: auto; }
|
||||
.document-panes.split .document-pane { flex: 1 0 320px; }
|
||||
.document-pane + .document-pane { border-left: 0; border-top: 1px solid var(--rs-border); }
|
||||
}
|
||||
.editor-host.plugin-covered { display: none; }
|
||||
.center { position: relative; }
|
||||
.plugin-panes { position: relative; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
|
||||
@@ -1347,7 +1529,7 @@
|
||||
|
||||
.left,
|
||||
.right {
|
||||
background: var(--rs-bg-elevated);
|
||||
background: var(--rs-workarea-sidebar-bg);
|
||||
}
|
||||
|
||||
.left {
|
||||
@@ -1487,7 +1669,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
background: var(--rs-bg-elevated);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.bottom > :global(*) {
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
finally { busy = false; }
|
||||
}
|
||||
function navigate(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") { event.preventDefault(); close(); return; }
|
||||
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
|
||||
event.preventDefault();
|
||||
const buttons = [...menu.querySelectorAll<HTMLButtonElement>("button:not(:disabled)")];
|
||||
@@ -92,14 +93,14 @@
|
||||
</script>
|
||||
|
||||
<svelte:window onresize={() => { if (menu?.matches(":popover-open")) position(); }} />
|
||||
<div bind:this={menu} popover="auto" class="workspace-menu" role="dialog" aria-label="Workspaces" tabindex="-1" onkeydown={navigate}>
|
||||
<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 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}
|
||||
<button class="workspace-row" class:current={path === currentRoot} aria-current={path === currentRoot ? "true" : undefined} disabled={busy} onclick={() => open(path)}>
|
||||
<Icon icon="folder-open" />
|
||||
<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}
|
||||
</button>
|
||||
@@ -107,8 +108,8 @@
|
||||
</div>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<footer>
|
||||
<button disabled={busy} onclick={newWorkspace}><Icon icon="folder-plus" /> New workspace…</button>
|
||||
<button disabled={busy} onclick={browse}><Icon icon="folder-open" /> Open another folder…</button>
|
||||
<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>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -129,17 +130,16 @@
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.workspace-menu, dialog { background: var(--rs-bg-elevated); color: var(--rs-text); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); box-shadow: 0 12px 36px #0006; }
|
||||
.workspace-menu { position: fixed; inset: auto; margin: 0; padding: 6px; width: min(380px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow: auto; }
|
||||
dialog { background: var(--rs-bg-elevated); color: var(--rs-text); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); box-shadow: 0 12px 36px #0006; }
|
||||
.workspace-menu { position: fixed; inset: auto; margin: 0; width: min(380px, calc(100vw - 16px)); }
|
||||
h2 { font-size: 14px; font-weight: 600; margin: 0; padding: 9px 10px; display: flex; align-items: center; gap: 8px; }
|
||||
p { font-size: 13px; color: var(--rs-text-dim); margin: 8px 10px; }
|
||||
.recent { max-height: min(360px, 45vh); overflow: auto; padding: 2px; }
|
||||
button { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: var(--rs-control-radius); padding: 9px 10px; color: var(--rs-text); text-align: left; }
|
||||
button:hover { background: var(--rs-bg-active); }
|
||||
button:focus-visible, input:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: -2px; }
|
||||
button:disabled { opacity: .5; }
|
||||
.recent { max-height: min(360px, 45vh); overflow: auto; }
|
||||
form button { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: var(--rs-control-radius); padding: 9px 10px; color: var(--rs-text); text-align: left; }
|
||||
form button:hover { background: var(--rs-bg-active); }
|
||||
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-row.current { background: var(--rs-item-selection-bg); box-shadow: inset 0 0 0 var(--rs-item-selection-width) var(--rs-item-selection-border); border-radius: var(--rs-item-selection-radius); }
|
||||
.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