Update editor, workspace, Git services, appearance, and project guides
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
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";
|
||||
@@ -25,6 +27,7 @@
|
||||
onOpenLink?: (kind: "md" | "wiki", target: string) => void;
|
||||
onOpenWorkspace: () => void;
|
||||
onNewFile: () => void;
|
||||
onNewNote?: (event: MouseEvent) => void;
|
||||
onQuickOpen: () => void;
|
||||
onOpenBrowser?: () => void;
|
||||
browserOpening?: boolean;
|
||||
@@ -32,7 +35,28 @@
|
||||
tableActions?: TableContextActions;
|
||||
};
|
||||
|
||||
let { buffer, tabs, chrome, reading, focusLine, onChange, onRenameTitle, onInsertImage, onToggleReading, onToggleChrome, onOpenLink, onOpenWorkspace, onNewFile, 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 }: Props = $props();
|
||||
let selectedLine = $state(1);
|
||||
let lineInfo = $state<GitLineInfo | null>(null);
|
||||
const git = $derived.by(() => { void $pluginHost; return pluginHost.get("git"); });
|
||||
$effect(() => { void buffer?.id; selectedLine = 1; });
|
||||
$effect(() => {
|
||||
void buffer?.id;
|
||||
const path = buffer?.relPath, line = selectedLine, provider = git;
|
||||
const dirty = buffer?.contents !== buffer?.saved;
|
||||
const available = buffer?.kind === "text" && !reading;
|
||||
lineInfo = null;
|
||||
if (!path || !provider || !available || dirty) return;
|
||||
let cancelled = false;
|
||||
const timer = setTimeout(() => {
|
||||
void provider.blame(path, line).then(info => { if (!cancelled) lineInfo = info; }).catch(() => {});
|
||||
}, 250);
|
||||
return () => { cancelled = true; clearTimeout(timer); };
|
||||
});
|
||||
function lineDate(value: string, detailed = false) {
|
||||
const date = new Date(/^\d+$/.test(value) ? Number(value) * 1000 : value);
|
||||
return Number.isNaN(date.getTime()) ? value : detailed ? date.toLocaleString() : date.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
||||
}
|
||||
let previewMode = $state<"split" | "preview">("split");
|
||||
let modeControls = $state<HTMLDivElement>();
|
||||
let titleFocusId = $state<string | null>(null);
|
||||
@@ -100,6 +124,7 @@
|
||||
<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>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -109,6 +134,11 @@
|
||||
<div class="editor">
|
||||
<div class="chrome-bar">
|
||||
<span class="breadcrumb" title={buffer.relPath}>{buffer.relPath}</span>
|
||||
{#if lineInfo}
|
||||
<span class="line-history" title={`Line ${selectedLine} · ${lineInfo.author} · ${lineDate(lineInfo.date, true)}\n${lineInfo.summary} (${lineInfo.commit.slice(0, 8)})`}>
|
||||
<Icon icon="git" /><span>Ln {selectedLine} · {lineDate(lineInfo.date)}</span>
|
||||
</span>
|
||||
{/if}
|
||||
<div class="actions" bind:this={modeControls}>
|
||||
{#if canPreview}
|
||||
<ModeSwitcher
|
||||
@@ -141,10 +171,10 @@
|
||||
<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}
|
||||
<LiveWriter {buffer} {onChange} {onRenameTitle} {onInsertImage} {onOpenLink} {focusLine} {tableActions} {shouldFocusOnMount} onSelectionLine={(line) => selectedLine = line}
|
||||
focusTitle={titleFocusId === buffer.id} onTitleFocused={() => { titleFocusId = null; }} />
|
||||
{:else}
|
||||
<EditorHost {buffer} {chrome} {onChange} {onInsertImage} {focusLine} {tableActions} {shouldFocusOnMount} />
|
||||
<EditorHost {buffer} {chrome} {onChange} {onInsertImage} {onOpenLink} {focusLine} {tableActions} {shouldFocusOnMount} onSelectionLine={(line) => selectedLine = line} />
|
||||
{/if}
|
||||
{/key}
|
||||
</div>
|
||||
@@ -161,6 +191,9 @@
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.line-history { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 40%; color: var(--rs-text-dim); font-size: 11px; white-space: nowrap; }
|
||||
.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; }
|
||||
@@ -193,9 +226,10 @@
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
height: 42px;
|
||||
min-height: 34px;
|
||||
flex-shrink: 0;
|
||||
padding: 0 10px;
|
||||
background: var(--rs-bg-elevated);
|
||||
background: var(--rs-bg);
|
||||
border-bottom: 1px solid var(--rs-border);
|
||||
color: var(--rs-text-dim);
|
||||
flex: 0 0 auto;
|
||||
|
||||
+185
-31
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from "svelte";
|
||||
import { onMount, tick, untrack } from "svelte";
|
||||
import { createNote, noteTemplates, type NoteTemplate } from "$lib/workspace/templates";
|
||||
import { confirm } from "@tauri-apps/plugin-dialog";
|
||||
import { requestText } from "$lib/workspace/dialogs.svelte";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
@@ -11,8 +12,11 @@
|
||||
workspaceList,
|
||||
workspaceRename,
|
||||
workspaceReveal,
|
||||
workspaceOpenDefault,
|
||||
workspaceOpenTerminal,
|
||||
} from "$lib/workspace/api";
|
||||
import { loadMarks, saveMarks, type Marks } from "$lib/workspace/marks";
|
||||
import { moveMarks, replayMoveMarks } from "$lib/workspace/treeMoveHistory";
|
||||
import { actionEntries, selectionRoots, setSelectedMarks, runTreeActions } from "$lib/workspace/treeActions";
|
||||
import {
|
||||
dropHint,
|
||||
@@ -24,7 +28,7 @@
|
||||
type DropPlace,
|
||||
type DropTarget,
|
||||
} from "$lib/workspace/treeDrop";
|
||||
import { planRename, planDocumentTitleRename } from "$lib/workspace/renamePath";
|
||||
import { planRename } from "$lib/workspace/renamePath";
|
||||
import { selectTreePath, treeSelectionEdges, visibleTreePaths, type SelectionModifiers, type TreeSelection } from "$lib/workspace/treeSelection";
|
||||
import ContextMenu from "./ContextMenu.svelte";
|
||||
import type { MenuItem } from "./menuTypes";
|
||||
@@ -43,6 +47,8 @@
|
||||
onEntryRenamed?: (from: string, to: string) => void;
|
||||
onCreated?: (entry: TreeEntry) => void;
|
||||
keysActive?: boolean;
|
||||
showInternal?: boolean;
|
||||
onSaveTemplate?: (entry: TreeEntry) => void;
|
||||
};
|
||||
|
||||
let {
|
||||
@@ -55,6 +61,8 @@
|
||||
onEntryRenamed,
|
||||
onCreated,
|
||||
keysActive = true,
|
||||
showInternal = false,
|
||||
onSaveTemplate,
|
||||
}: Props = $props();
|
||||
|
||||
let expanded = $state<Set<string>>(new Set([""]));
|
||||
@@ -73,10 +81,21 @@
|
||||
const selectionEdges = $derived(treeSelectionEdges(visiblePaths, selection.paths));
|
||||
let renameRel = $state<string | null>(null);
|
||||
let renameDraft = $state("");
|
||||
let renameDocument = false;
|
||||
let skipClick = false;
|
||||
let imageLanding = $state(false);
|
||||
let cancelDrag: (() => void) | undefined;
|
||||
let treeElement: HTMLDivElement;
|
||||
let clipboard = $state<{ root: string; paths: string[]; cut: boolean } | null>(null);
|
||||
type MoveBatch = { moves: { from: string; to: string }[]; before: Marks; after: Marks };
|
||||
let undoMoves = $state<MoveBatch[]>([]);
|
||||
let redoMoves = $state<MoveBatch[]>([]);
|
||||
let moving = $state(false);
|
||||
let templates = $state<NoteTemplate[]>([]);
|
||||
onMount(() => {
|
||||
const read = () => { void noteTemplates().then(value => templates = value); };
|
||||
read(); window.addEventListener("runestone-templates-changed", read);
|
||||
return () => window.removeEventListener("runestone-templates-changed", read);
|
||||
});
|
||||
$effect(() => () => cancelDrag?.());
|
||||
|
||||
const pins = $derived(new Set(marks.pins));
|
||||
@@ -117,7 +136,7 @@
|
||||
async function load(rel: string) {
|
||||
loading = true;
|
||||
try {
|
||||
const entries = await workspaceList(rel);
|
||||
const entries = await workspaceList(rel, showInternal);
|
||||
childrenMap = { ...childrenMap, [rel]: sortEntries(rel, entries) };
|
||||
void inspectPluginDocuments(entries);
|
||||
error = null;
|
||||
@@ -130,6 +149,7 @@
|
||||
|
||||
$effect(() => {
|
||||
void workspaceRoot;
|
||||
undoMoves = []; redoMoves = []; clipboard = null;
|
||||
expanded = new Set([""]);
|
||||
selection = { paths: new Set(), anchor: null };
|
||||
childrenMap = {};
|
||||
@@ -142,6 +162,7 @@
|
||||
|
||||
$effect(() => {
|
||||
void refreshToken;
|
||||
void showInternal;
|
||||
void $pluginDocumentTypes;
|
||||
const keys = untrack(() => Object.keys(childrenMap));
|
||||
for (const key of keys) {
|
||||
@@ -352,8 +373,7 @@
|
||||
function startRename(entry: TreeEntry) {
|
||||
selectOnly(entry.rel_path);
|
||||
renameRel = entry.rel_path;
|
||||
renameDocument = entry.kind === "file" && (!!$pluginDocuments[entry.rel_path] || /\.(md|markdown|mdown)$/i.test(entry.name));
|
||||
renameDraft = renameDocument ? entry.name.replace(/\.[^.]+$/, "") : entry.name;
|
||||
renameDraft = entry.name;
|
||||
}
|
||||
|
||||
function cancelRename() {
|
||||
@@ -366,7 +386,7 @@
|
||||
if (!from) {
|
||||
return;
|
||||
}
|
||||
const plan = renameDocument ? planDocumentTitleRename(from, renameDraft) : planRename(from, renameDraft);
|
||||
const plan = planRename(from, renameDraft);
|
||||
cancelRename();
|
||||
if (plan.action === "noop") {
|
||||
return;
|
||||
@@ -390,6 +410,26 @@
|
||||
if (!keysActive) {
|
||||
return;
|
||||
}
|
||||
if (event.target instanceof Element && treeElement?.contains(event.target)
|
||||
&& !event.target.closest('input, textarea, [contenteditable="true"]')
|
||||
&& (event.ctrlKey || event.metaKey) && !event.altKey) {
|
||||
const key = event.key.toLowerCase();
|
||||
if (key === "z" || key === "y") {
|
||||
event.preventDefault(); event.stopPropagation();
|
||||
void replayMoves(key === "y" || event.shiftKey);
|
||||
return;
|
||||
}
|
||||
const entries = selectionRoots([...selection.paths].map(findEntry).filter((entry): entry is TreeEntry => !!entry));
|
||||
if ((key === "c" || key === "x") && entries.length) {
|
||||
event.preventDefault(); clipboard = { root: workspaceRoot, paths: entries.map(entry => entry.rel_path), cut: key === "x" }; return;
|
||||
}
|
||||
if (key === "v") {
|
||||
event.preventDefault();
|
||||
const selected = entries[0];
|
||||
void pasteEntries(selected?.kind === "folder" ? selected.rel_path : selected ? parentRel(selected.rel_path) : "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.key !== "F2" || event.ctrlKey || event.metaKey || event.altKey) {
|
||||
return;
|
||||
}
|
||||
@@ -409,22 +449,23 @@
|
||||
startRename(entry);
|
||||
}
|
||||
|
||||
async function createIn(parent: string, kind: "folder" | "note") {
|
||||
async function createIn(parent: string, kind: "folder" | "note" | "file") {
|
||||
let name: string;
|
||||
if (kind === "note") {
|
||||
name = "untitled.md";
|
||||
} else {
|
||||
const typed = await requestText("Folder name", "folder");
|
||||
const typed = await requestText(kind === "folder" ? "Folder name" : "File name, including any extension", kind === "folder" ? "folder" : "Untitled");
|
||||
if (!typed) {
|
||||
return;
|
||||
}
|
||||
if (typed.includes("/") || typed.includes("\\")) {
|
||||
error = "Name cannot contain a path separator";
|
||||
const plan = planRename("", typed);
|
||||
if (plan.action === "error") {
|
||||
error = plan.message;
|
||||
return;
|
||||
}
|
||||
name = typed;
|
||||
name = typed.trim();
|
||||
}
|
||||
const finalName = uniqueName(namesIn(parent), name);
|
||||
const finalName = kind === "file" ? name : uniqueName(namesIn(parent), name);
|
||||
const rel = joinRel(parent, finalName);
|
||||
try {
|
||||
await workspaceCreate(rel, kind === "folder" ? "folder" : "file");
|
||||
@@ -438,7 +479,7 @@
|
||||
}
|
||||
await load(parent);
|
||||
onStatus?.(`Created ${rel}`);
|
||||
if (kind === "note") {
|
||||
if (kind !== "folder") {
|
||||
onCreated?.({ name: finalName, rel_path: rel, kind: "file" });
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -452,16 +493,22 @@
|
||||
}
|
||||
|
||||
async function handleDrop(target: TreeEntry, entries: TreeEntry[], place: DropPlace) {
|
||||
if (moving) return;
|
||||
const operationRoot = workspaceRoot;
|
||||
const before = structuredClone($state.snapshot(marks));
|
||||
const moves: MoveBatch["moves"] = [];
|
||||
const destination = place === "inside" ? target.rel_path : parentRel(target.rel_path);
|
||||
// Load collapsed folders before checking for name conflicts.
|
||||
try {
|
||||
childrenMap = { ...childrenMap, [destination]: sortEntries(destination, await workspaceList(destination)) };
|
||||
childrenMap = { ...childrenMap, [destination]: sortEntries(destination, await workspaceList(destination, showInternal)) };
|
||||
} catch (err) {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
return;
|
||||
}
|
||||
const paths = new Map(entries.map(entry => [entry.rel_path, entry.rel_path]));
|
||||
moving = true;
|
||||
const result = await runTreeActions(place === "after" ? [...entries].reverse() : entries, async entry => {
|
||||
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
|
||||
const plan = planDrop(entry.rel_path, target, place, namesIn);
|
||||
if (plan.action === "noop") return;
|
||||
if (plan.action === "reorder") {
|
||||
@@ -471,14 +518,17 @@
|
||||
await load(plan.parent);
|
||||
return;
|
||||
}
|
||||
await workspaceRename(plan.from, plan.to);
|
||||
await workspaceRename(plan.from, plan.to, operationRoot);
|
||||
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
|
||||
moves.push({ from: plan.from, to: plan.to });
|
||||
paths.set(plan.from, plan.to);
|
||||
forgetFolder(plan.from);
|
||||
onEntryRenamed?.(plan.from, plan.to);
|
||||
const order = { ...marks.order };
|
||||
const next = moveMarks(marks, plan.from, plan.to);
|
||||
const order = { ...next.order };
|
||||
order[plan.fromParent] = plan.orderFrom;
|
||||
order[plan.toParent] = plan.orderTo;
|
||||
await persistMarks({ ...marks, order });
|
||||
await persistMarks({ ...next, order });
|
||||
await load(plan.fromParent);
|
||||
if (plan.toParent !== plan.fromParent) {
|
||||
await load(plan.toParent);
|
||||
@@ -488,6 +538,82 @@
|
||||
selection = { paths: new Set(paths.values()), anchor: paths.values().next().value ?? null };
|
||||
error = result.failures.length ? result.failures.join("\n") : null;
|
||||
onStatus?.(`Moved ${result.completed.length} of ${entries.length} items`);
|
||||
if (moves.length || JSON.stringify(before.order) !== JSON.stringify(marks.order)) {
|
||||
undoMoves = [...undoMoves, { moves, before, after: structuredClone($state.snapshot(marks)) }];
|
||||
redoMoves = [];
|
||||
}
|
||||
moving = false;
|
||||
await focusTreePath(paths.values().next().value);
|
||||
}
|
||||
|
||||
async function focusTreePath(path?: string) {
|
||||
await tick();
|
||||
const target = [...treeElement.querySelectorAll<HTMLElement>("[data-tree-rel]")].find(node => node.dataset.treeRel === path);
|
||||
(target ?? treeElement).focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
async function replayMoves(redo = false) {
|
||||
if (moving) return;
|
||||
const stack = redo ? redoMoves : undoMoves;
|
||||
const batch = stack.at(-1);
|
||||
if (!batch) return;
|
||||
const operationRoot = workspaceRoot;
|
||||
moving = true;
|
||||
const applied: { from: string; to: string }[] = [];
|
||||
try {
|
||||
for (const move of redo ? batch.moves : [...batch.moves].reverse()) {
|
||||
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
|
||||
const from = redo ? move.from : move.to, to = redo ? move.to : move.from;
|
||||
await workspaceRename(from, to, operationRoot);
|
||||
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
|
||||
applied.push({ from, to });
|
||||
onEntryRenamed?.(from, to);
|
||||
}
|
||||
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
|
||||
await persistMarks(replayMoveMarks(marks, batch.before, batch.after, batch.moves, redo));
|
||||
if (redo) { redoMoves = redoMoves.slice(0, -1); undoMoves = [...undoMoves, batch]; }
|
||||
else { undoMoves = undoMoves.slice(0, -1); redoMoves = [...redoMoves, batch]; }
|
||||
childrenMap = {}; expanded = new Set([""]);
|
||||
await load("");
|
||||
selection = { paths: new Set(applied.map(move => move.to)), anchor: applied.at(-1)?.to ?? null };
|
||||
await focusTreePath(applied.at(-1)?.to);
|
||||
onStatus?.(redo ? "File move restored." : "File move undone.");
|
||||
} catch (reason) {
|
||||
const rollbackErrors: string[] = [];
|
||||
for (const move of applied.reverse()) {
|
||||
if (workspaceRoot !== operationRoot) { rollbackErrors.push("The original workspace is unavailable."); break; }
|
||||
try { await workspaceRename(move.to, move.from, operationRoot); onEntryRenamed?.(move.to, move.from); }
|
||||
catch (failure) { rollbackErrors.push(String(failure)); }
|
||||
}
|
||||
if (rollbackErrors.length) { undoMoves = []; redoMoves = []; }
|
||||
error = [String(reason), ...rollbackErrors].join("\n");
|
||||
} finally { moving = false; }
|
||||
}
|
||||
|
||||
async function pasteEntries(parent: string) {
|
||||
if (!clipboard || clipboard.root !== workspaceRoot || moving) return;
|
||||
const source = clipboard;
|
||||
const operationRoot = workspaceRoot;
|
||||
const before = structuredClone($state.snapshot(marks));
|
||||
const moves: MoveBatch["moves"] = [];
|
||||
moving = true;
|
||||
const result = await runTreeActions(source.paths.map(rel_path => ({ rel_path, name: rel_path.split("/").pop()!, kind: "file" as const })), async entry => {
|
||||
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. Paste stopped.");
|
||||
if (source.cut) {
|
||||
const to = joinRel(parent, entry.name);
|
||||
if (to === entry.rel_path) return;
|
||||
await workspaceRename(entry.rel_path, to, operationRoot);
|
||||
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. Paste stopped.");
|
||||
moves.push({ from: entry.rel_path, to });
|
||||
onEntryRenamed?.(entry.rel_path, to);
|
||||
await persistMarks(moveMarks(marks, entry.rel_path, to));
|
||||
} else await workspaceCopy(entry.rel_path, parent, operationRoot);
|
||||
});
|
||||
if (moves.length) { undoMoves = [...undoMoves, { moves, before, after: structuredClone($state.snapshot(marks)) }]; redoMoves = []; }
|
||||
if (source.cut) clipboard = result.failures.length ? { ...source, paths: source.paths.filter(path => !moves.some(move => move.from === path)) } : null;
|
||||
for (const folder of new Set([parent, ...source.paths.map(parentRel)])) await load(folder);
|
||||
error = result.failures.length ? result.failures.join("\n") : null;
|
||||
moving = false;
|
||||
}
|
||||
|
||||
async function copyEntries(entries: TreeEntry[]) {
|
||||
@@ -519,23 +645,25 @@
|
||||
}
|
||||
|
||||
function paneMenuItems(parent: string): MenuItem[] {
|
||||
const fromTemplate = async (template?: NoteTemplate) => {
|
||||
try {
|
||||
const path = await createNote(parent, template);
|
||||
await load(parent);
|
||||
onCreated?.({ name: path.split("/").pop()!, rel_path: path, kind: "file" });
|
||||
} catch (reason) { error = String(reason); }
|
||||
};
|
||||
return [
|
||||
{
|
||||
kind: "action",
|
||||
label: "Create folder",
|
||||
icon: "folder-plus",
|
||||
run: () => {
|
||||
void createIn(parent, "folder");
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: "Create new note",
|
||||
label: "New file…",
|
||||
icon: "file-plus",
|
||||
run: () => {
|
||||
void createIn(parent, "note");
|
||||
},
|
||||
run: () => { void createIn(parent, "file"); },
|
||||
},
|
||||
...(templates.length ? [{ kind: "group" as const, label: "New note", icon: "file-plus" as const, items: [
|
||||
{ kind: "action" as const, label: "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); } })),
|
||||
] }] : [{ 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"); } },
|
||||
...$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 () => {
|
||||
@@ -557,11 +685,24 @@
|
||||
];
|
||||
}
|
||||
|
||||
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: "Copy path", icon: "copy", run: () => { void workspaceAbsPath(parent).then(path => copyText(path, "path")).catch(reason => error = String(reason)); } },
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: "Undo file move", icon: "undo", disabled: !undoMoves.length || moving, run: () => { void replayMoves(); } },
|
||||
{ kind: "action", label: "Redo file move", icon: "redo", disabled: !redoMoves.length || moving, run: () => { void replayMoves(true); } },
|
||||
];
|
||||
}
|
||||
|
||||
function menuItems(entry: TreeEntry | null): MenuItem[] {
|
||||
if (!entry) {
|
||||
return [
|
||||
...paneMenuItems(""),
|
||||
{ kind: "sep" },
|
||||
...folderActions(""),
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: "Show in Explorer",
|
||||
@@ -584,6 +725,17 @@
|
||||
: [];
|
||||
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) },
|
||||
] : []),
|
||||
...(!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)); } },
|
||||
] : []),
|
||||
...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: multiple ? `Make copies (${entries.length})` : "Make a copy",
|
||||
@@ -671,7 +823,7 @@
|
||||
|
||||
<div class="wrap">
|
||||
<div class="ribbon tree-tools">
|
||||
<IconButton icon="file-plus" label="New file" onclick={() => void createIn("", "note")} />
|
||||
<IconButton icon="file-plus" label="New file" onclick={() => void createIn("", "file")} />
|
||||
<IconButton icon="folder-plus" label="New folder" onclick={() => void createIn("", "folder")} />
|
||||
<IconButton
|
||||
icon="sort"
|
||||
@@ -691,7 +843,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
bind:this={treeElement}
|
||||
class="tree"
|
||||
tabindex="-1"
|
||||
role="navigation"
|
||||
aria-label="Workspace files"
|
||||
oncontextmenu={(event) => {
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
<script lang="ts">
|
||||
import PluginManager from "$lib/plugins/PluginManager.svelte";
|
||||
import AppearanceSettings from "$lib/theme/AppearanceSettings.svelte";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
import PluginSettings from "$lib/plugins/PluginSettings.svelte";
|
||||
import { installedPlugins, pluginTools } from "$lib/plugins/external";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import { onMount, untrack } from "svelte";
|
||||
import { onMount, untrack, type Snippet } from "svelte";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import IconButton, { type IconName } from "$lib/ui/IconButton.svelte";
|
||||
import { DEFAULT_SETTINGS, MIN_AUTOSAVE_SECONDS, MAX_AUTOSAVE_SECONDS, validAutosaveSeconds, type AppSettings } from "$lib/workspace/settings";
|
||||
import { version, license } from "../../../package.json";
|
||||
|
||||
let { settings, help = false, standalone = false, windowError = "", onSave, onClose }: {
|
||||
let { settings, help = false, standalone = false, windowError = "", windowControls, onSave, onClose }: {
|
||||
settings: AppSettings;
|
||||
help?: boolean;
|
||||
standalone?: boolean;
|
||||
windowError?: string;
|
||||
windowControls?: Snippet;
|
||||
onSave: (value: AppSettings) => void;
|
||||
onClose: () => void;
|
||||
} = $props();
|
||||
@@ -22,6 +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: "plugins", label: "Plug-ins", icon: "puzzle", keywords: "plugins extensions community" },
|
||||
];
|
||||
let section = $state<Section>(untrack(() => help ? "about" : "general"));
|
||||
@@ -76,9 +79,13 @@
|
||||
</script>
|
||||
|
||||
<dialog bind:this={dialog} class:help class:standalone aria-labelledby="settings-title" onkeydown={trapFocus} oncancel={event => { if (event.target === dialog) { event.preventDefault(); onClose(); } }}>
|
||||
<header>
|
||||
<h1 id="settings-title">{help ? "Help and about" : "Settings"}</h1>
|
||||
<IconButton icon="close" label={help ? "Close help" : "Close settings"} onclick={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>
|
||||
{#if windowControls}
|
||||
{@render windowControls()}
|
||||
{:else}
|
||||
<IconButton icon="close" label={help ? "Close help" : "Close settings"} onclick={onClose} />
|
||||
{/if}
|
||||
</header>
|
||||
<div class="body">
|
||||
{#if !help}
|
||||
@@ -104,6 +111,10 @@
|
||||
<p class="intro">Choose how RuneStone saves your work.</p>
|
||||
<h3>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>
|
||||
<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>
|
||||
<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; }} />
|
||||
@@ -117,6 +128,8 @@
|
||||
<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>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<p class="saved" role="status">{message}</p>
|
||||
{:else if selected.id === "appearance"}
|
||||
<AppearanceSettings />
|
||||
{:else if selected.id === "plugins"}
|
||||
<PluginManager />
|
||||
{:else if selected.id === "browser"}
|
||||
@@ -141,40 +154,42 @@
|
||||
dialog::backdrop { background: #0008; }
|
||||
dialog.standalone { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
|
||||
dialog.help { width: min(650px, calc(100vw - 32px)); }
|
||||
header { height: 48px; padding: 0 14px 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rs-border); background: var(--rs-bg-elevated); }
|
||||
h1 { font-size: 14px; font-weight: 600; margin: 0; }
|
||||
.body { display: flex; height: calc(100% - 48px); }
|
||||
aside { width: 220px; flex-shrink: 0; padding: 18px 12px; background: var(--rs-bg-elevated); border-right: 1px solid var(--rs-border); display: flex; flex-direction: column; overflow: auto; }
|
||||
.search { display: flex; gap: 7px; align-items: center; background: var(--rs-bg-active); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); padding: 8px; color: var(--rs-text-dim); }
|
||||
header { height: var(--rs-titlebar-height); padding: 0 4px 0 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rs-border); background: var(--rs-bg-elevated); }
|
||||
header.window-header { padding-right: 0; user-select: none; }
|
||||
h1 { font-size: 13px; font-weight: 600; margin: 0; }
|
||||
.body { display: flex; height: calc(100% - var(--rs-titlebar-height)); min-height: 0; }
|
||||
aside { width: 220px; flex-shrink: 0; padding: 12px 8px; background: var(--rs-bg-elevated); border-right: 1px solid var(--rs-border); display: flex; flex-direction: column; overflow: auto; }
|
||||
.search { display: flex; gap: var(--rs-settings-gap); align-items: center; min-height: var(--rs-settings-control-height); background: var(--rs-bg-active); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); padding: 4px 8px; color: var(--rs-text-dim); }
|
||||
.search:focus-within { outline: 2px solid var(--rs-accent); }
|
||||
.search input { width: 100%; min-width: 0; border: 0; padding: 0; outline: none; background: transparent; color: var(--rs-text); }
|
||||
.nav-heading { margin: 24px 10px 8px; font-size: 11px; color: var(--rs-text-dim); }
|
||||
nav { display: flex; flex-direction: column; gap: 4px; }
|
||||
nav button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: var(--rs-control-radius); background: transparent; text-align: left; }
|
||||
.nav-heading { margin: 16px 8px 6px; font-size: 11px; color: var(--rs-text-dim); }
|
||||
nav { display: flex; flex-direction: column; gap: 2px; }
|
||||
nav button { display: flex; align-items: center; gap: var(--rs-settings-gap); width: 100%; min-height: var(--rs-settings-control-height); padding: 5px 8px; border: 0; border-radius: var(--rs-control-radius); background: transparent; text-align: left; }
|
||||
nav button:hover { background: var(--rs-bg-active); }
|
||||
nav button.active { 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); }
|
||||
.scope { margin: auto 10px 0; padding-top: 24px; color: var(--rs-text-dim); font-size: 12px; }
|
||||
.content { padding: 30px 32px; flex: 1; min-width: 0; overflow-y: auto; }
|
||||
h2 { margin: 0; font-size: 23px; font-weight: 600; color: var(--rs-text-strong); }
|
||||
h3 { margin: 28px 0 12px; font-size: 14px; font-weight: 600; }
|
||||
p { color: var(--rs-text-dim); line-height: 1.6; }
|
||||
.intro { margin: 7px 0 24px; }
|
||||
.card { padding: 0 20px; background: var(--rs-bg-elevated); border: 1px solid var(--rs-border); border-radius: 10px; }
|
||||
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 0; }
|
||||
.content { padding: 20px 24px; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; }
|
||||
h2 { margin: 0; font-size: var(--rs-settings-heading-size); font-weight: 600; color: var(--rs-text-strong); }
|
||||
h3 { margin: var(--rs-settings-section-gap) 0 8px; font-size: 13px; font-weight: 600; }
|
||||
p { color: var(--rs-text-dim); line-height: 1.45; }
|
||||
.intro { margin: 6px 0 var(--rs-settings-section-gap); }
|
||||
.card { padding: 0 12px; background: var(--rs-bg-elevated); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); }
|
||||
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: var(--rs-settings-row-padding) 0; }
|
||||
.setting-row > div:first-child { min-width: 0; }
|
||||
.setting-row + .setting-row { border-top: 1px solid var(--rs-border); }
|
||||
.setting-row label { font-weight: 500; }
|
||||
.setting-row p { margin: 5px 0 0; font-size: 12px; }
|
||||
.setting-row p { margin: 3px 0 0; font-size: var(--rs-settings-description-size); }
|
||||
.switch { appearance: none; width: 38px; height: 22px; flex: 0 0 38px; margin: 0; border-radius: 20px; background: var(--rs-bg-active); border: 1px solid var(--rs-text-dim); cursor: pointer; }
|
||||
.switch::before { content: ""; display: block; width: 16px; height: 16px; margin: 2px; background: var(--rs-text); border-radius: 50%; transition: transform .12s; }
|
||||
.switch:checked { background: var(--rs-accent); border-color: var(--rs-accent); }
|
||||
.switch:checked::before { transform: translateX(16px); background: var(--rs-bg); }
|
||||
.interval { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11px; color: var(--rs-text-dim); }
|
||||
.interval input { width: 84px; padding: 9px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font-size: 14px; }
|
||||
.interval input { width: 72px; min-height: var(--rs-settings-control-height); padding: 4px 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font-size: 13px; }
|
||||
.interval input:disabled { opacity: .45; }
|
||||
.note, .section-footer, .about-note { font-size: 12px; }
|
||||
.note { margin: 16px 0 24px; }
|
||||
.note { margin: 10px 0 var(--rs-settings-section-gap); }
|
||||
.section-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--rs-text-dim); }
|
||||
.text-button { border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg-elevated); padding: 8px 12px; color: var(--rs-text); }
|
||||
.text-button { min-height: var(--rs-settings-control-height); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg-elevated); padding: 4px 8px; color: var(--rs-text); }
|
||||
.text-button:hover { background: var(--rs-bg-active); }
|
||||
.saved { font-size: 12px; color: var(--rs-ok); min-height: 20px; }
|
||||
.error { color: var(--rs-error); }
|
||||
@@ -193,11 +208,11 @@
|
||||
.about-note { text-align: center; margin: 20px 0 0; }
|
||||
@media (max-width: 660px) {
|
||||
.body { flex-direction: column; }
|
||||
aside { width: 100%; padding: 12px; border-right: 0; border-bottom: 1px solid var(--rs-border); flex-shrink: 0; }
|
||||
nav { flex-direction: row; margin-top: 10px; }
|
||||
nav button { width: auto; flex: 1; padding: 8px; gap: 6px; }
|
||||
aside { width: 100%; max-height: 40%; padding: 8px; border-right: 0; border-bottom: 1px solid var(--rs-border); flex-shrink: 0; }
|
||||
nav { flex-direction: row; flex-wrap: wrap; margin-top: 6px; }
|
||||
nav button { width: auto; flex: 1 1 auto; padding: 5px 8px; gap: 6px; }
|
||||
.nav-heading, .scope { display: none; }
|
||||
.content { padding: 24px 18px; }
|
||||
.content { padding: 16px 12px; }
|
||||
.setting-row { gap: 14px; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { isTauri } from "@tauri-apps/api/core";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import SettingsDialog from "./SettingsDialog.svelte";
|
||||
import WindowControls from "$lib/ui/WindowControls.svelte";
|
||||
import { DEFAULT_SETTINGS, SETTINGS_KEY, parseSettings, saveSettings, type AppSettings } from "$lib/workspace/settings";
|
||||
|
||||
let settings = $state<AppSettings>({ ...DEFAULT_SETTINGS });
|
||||
@@ -32,4 +33,5 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<SettingsDialog {settings} standalone windowError={error} onSave={save} onClose={() => void close()} />
|
||||
{#snippet controls()}<WindowControls onError={message => error = message} />{/snippet}
|
||||
<SettingsDialog {settings} standalone windowError={error} windowControls={isTauri() ? controls : undefined} onSave={save} onClose={() => void close()} />
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
tabActions?: (tab: WorkbenchTab) => ActionMenuItem[];
|
||||
tabDragData?: (tab: WorkbenchTab) => string | undefined;
|
||||
onDropTab?: (data: string, index: number) => void;
|
||||
onDetach?: (tab: WorkbenchTab) => void;
|
||||
};
|
||||
|
||||
let { tabs, activePath, onSelect, onClose, onMove, onCloseTabs, onPin, fileActions, tabActions = () => [], tabDragData = () => undefined, onDropTab }: Props = $props();
|
||||
let { tabs, activePath, onSelect, onClose, onMove, onCloseTabs, onPin, fileActions, tabActions = () => [], tabDragData = () => undefined, onDropTab, onDetach }: Props = $props();
|
||||
const transferType = "application/x-runestone-tab";
|
||||
let bar: HTMLDivElement;
|
||||
let dragged = $state<string | null>(null);
|
||||
@@ -168,6 +169,8 @@
|
||||
cancelDrag();
|
||||
closeMenu();
|
||||
suppressClick = false;
|
||||
const pointerTarget = event.currentTarget as HTMLElement;
|
||||
pointerTarget.setPointerCapture(event.pointerId);
|
||||
const startX = event.clientX, startY = event.clientY, pointerId = event.pointerId;
|
||||
let x = startX, y = startY, started = false, destination: number | null = null, frame = 0;
|
||||
const update = () => {
|
||||
@@ -192,6 +195,7 @@
|
||||
frame = requestAnimationFrame(scroll);
|
||||
};
|
||||
const clean = () => {
|
||||
if (pointerTarget.hasPointerCapture(pointerId)) pointerTarget.releasePointerCapture(pointerId);
|
||||
cancelAnimationFrame(frame);
|
||||
dragged = dropBefore = dropAfter = null;
|
||||
window.removeEventListener("pointermove", onMovePointer);
|
||||
@@ -216,6 +220,10 @@
|
||||
const target = destination;
|
||||
clean();
|
||||
if (started && target !== null) void move(path, target);
|
||||
else if (started && (x < 0 || y < 0 || x > window.innerWidth || y > window.innerHeight)) {
|
||||
const tab = tabs.find(tab => tab.relPath === path);
|
||||
if (tab) onDetach?.(tab);
|
||||
}
|
||||
};
|
||||
const onEscape = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); clean(); }
|
||||
@@ -267,7 +275,11 @@
|
||||
onpointerdown={(event) => { if (!tab.draggable) startDrag(event, tab.relPath); else suppressClick = false; }}
|
||||
draggable={!!tab.draggable}
|
||||
ondragstart={(event) => startTabTransfer(event, tab)}
|
||||
ondragend={finishTabTransfer}
|
||||
ondragend={(event) => {
|
||||
const outside = event.clientX < 0 || event.clientY < 0 || event.clientX > window.innerWidth || event.clientY > window.innerHeight;
|
||||
if (dragged && event.dataTransfer?.dropEffect === "none" && outside) onDetach?.(tab);
|
||||
finishTabTransfer();
|
||||
}}
|
||||
onkeydown={(event) => onKey(event, tab.relPath)}
|
||||
oncontextmenu={(event) => { event.preventDefault(); event.stopPropagation(); showMenu(event.currentTarget, tab.relPath, event.clientX, event.clientY); }}
|
||||
onmousedown={onMiddleDown}
|
||||
@@ -300,7 +312,7 @@
|
||||
min-height: 32px;
|
||||
overflow-x: auto;
|
||||
background: var(--rs-bg-elevated);
|
||||
border-bottom: 1px solid var(--rs-border);
|
||||
box-shadow: inset 0 -1px var(--rs-border);
|
||||
}
|
||||
.tabs:empty { min-width: 80px; }
|
||||
.tabs.receiving { box-shadow: inset 0 -2px var(--rs-accent); }
|
||||
@@ -311,17 +323,19 @@
|
||||
align-items: center;
|
||||
max-width: 220px;
|
||||
flex-shrink: 0;
|
||||
border-radius: var(--rs-item-selection-radius);
|
||||
border-radius: var(--rs-item-selection-radius) var(--rs-item-selection-radius) 0 0;
|
||||
border-right: 1px solid var(--rs-border);
|
||||
background: var(--rs-bg);
|
||||
background: transparent;
|
||||
border-bottom: 1px solid var(--rs-border);
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
background: var(--rs-item-selection-bg);
|
||||
box-shadow: inset 0 0 0 var(--rs-item-selection-width) var(--rs-item-selection-border);
|
||||
background: var(--rs-bg);
|
||||
border-bottom-color: transparent;
|
||||
}
|
||||
|
||||
.tab:hover { background: var(--rs-bg-active); }
|
||||
.tab:focus-within { box-shadow: inset 0 0 0 var(--rs-item-selection-width) var(--rs-item-selection-border); }
|
||||
.tab:not(.active):hover { background: var(--rs-bg-active); }
|
||||
.tab.dragging { opacity: 0.5; }
|
||||
.tabs:has(.dragging) .tab > button:first-child { cursor: grabbing; }
|
||||
.tab.drop-before::before, .tab.drop-after::after {
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
{#if isRenaming}
|
||||
<input
|
||||
class="rename"
|
||||
aria-label="File or folder name, including any extension"
|
||||
value={renameDraft}
|
||||
use:focusSelect
|
||||
onclick={(event) => event.stopPropagation()}
|
||||
@@ -155,7 +156,7 @@
|
||||
{:else}
|
||||
<span class="name">{label}</span>
|
||||
{/if}
|
||||
{#if ext}
|
||||
{#if ext && !isRenaming}
|
||||
<span class="mark ext">{ext}</span>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -220,7 +221,7 @@
|
||||
}
|
||||
|
||||
.row.active {
|
||||
background: var(--rs-bg-active);
|
||||
background: var(--rs-item-selection-bg);
|
||||
color: var(--rs-text-strong);
|
||||
}
|
||||
|
||||
@@ -236,12 +237,15 @@
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
border: var(--rs-item-selection-width) solid var(--rs-item-selection-border);
|
||||
border-top: 0;
|
||||
border-bottom: 0;
|
||||
border-radius: inherit;
|
||||
}
|
||||
|
||||
:global(.tree:focus-within) .selection-outline { visibility: visible; }
|
||||
|
||||
.selection-outline.full-top { border-top: var(--rs-item-selection-width) solid var(--rs-item-selection-border); }
|
||||
.selection-outline.full-bottom { border-bottom: var(--rs-item-selection-width) solid var(--rs-item-selection-border); }
|
||||
|
||||
|
||||
+187
-42
@@ -3,10 +3,10 @@
|
||||
import PluginTools from "$lib/plugins/PluginTools.svelte";
|
||||
import PluginAccessMenu from "$lib/plugins/PluginAccessMenu.svelte";
|
||||
import PluginEditor from "$lib/plugins/PluginEditor.svelte";
|
||||
import { pluginSplits, pinPluginEditor, pluginTabActions, pluginTabDragData, dropPluginTab, findPluginEditor } from "$lib/plugins/external";
|
||||
import { pluginSplits, pinPluginEditor, pluginTabActions, pluginTabState, restorePluginTab, pluginTabDragData, dropPluginTab, findPluginEditor } from "$lib/plugins/external";
|
||||
import { containsPane, paneBounds } from "$lib/workspace/splitLayout";
|
||||
import { pluginNavigation, openPluginView, pluginView, pluginEditors, pluginEditorActive, selectPluginEditor, closePluginEditor, openPluginDocument, renamePluginDocuments, removePluginDocuments, notifyPluginWorkspace, guardPluginWrites, handlePluginDocumentRename, cancelPluginDocumentOpen, type OpenPluginView } from "$lib/plugins/external";
|
||||
import { onMount, tick } from "svelte";
|
||||
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 { selectedEditorText } from "$lib/editor/selection";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import type { Contributions } from "$lib/plugins/contracts";
|
||||
@@ -17,7 +17,8 @@
|
||||
import { Documents } from "$lib/workspace/documents";
|
||||
import { tabsToClose, type TabCloseScope } from "$lib/workspace/tabActions";
|
||||
import { orderWorkbenchTabs, type WorkbenchTab } from "$lib/workspace/workbenchTabs";
|
||||
import type { ActionMenuItem } from "$lib/ui/actionMenu";
|
||||
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
|
||||
import { createNote, noteTemplates, saveNoteTemplate, type NoteTemplate } from "$lib/workspace/templates";
|
||||
import { requestText } from "$lib/workspace/dialogs.svelte";
|
||||
import TextDialog from "./TextDialog.svelte";
|
||||
import QuickOpen from "./QuickOpen.svelte";
|
||||
@@ -25,6 +26,7 @@
|
||||
import SettingsDialog from "./SettingsDialog.svelte";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
import { DEFAULT_SETTINGS, SETTINGS_KEY, parseSettings, saveSettings, type AppSettings } from "$lib/workspace/settings";
|
||||
import { DEFAULT_WORKBENCH_LAYOUT, WORKBENCH_LAYOUT_KEY, parseWorkbenchLayout, saveWorkbenchLayout, type WorkbenchLayout } from "$lib/workspace/workbenchLayout";
|
||||
import FileTree from "./FileTree.svelte";
|
||||
import EditorPane from "./EditorPane.svelte";
|
||||
import TabBar from "./TabBar.svelte";
|
||||
@@ -79,13 +81,15 @@
|
||||
let error = $state<string | null>(null);
|
||||
let refreshToken = $state(0);
|
||||
let view = $state<Chrome>("Writing");
|
||||
let leftWidth = $state(260);
|
||||
let rightWidth = $state(240);
|
||||
let layoutReady = $state(false);
|
||||
let leftWidth = $state(DEFAULT_WORKBENCH_LAYOUT.leftWidth);
|
||||
let rightWidth = $state(DEFAULT_WORKBENCH_LAYOUT.rightWidth);
|
||||
let bottomHeight = $state(180);
|
||||
let leftView = $state<"files" | "search" | "bookmarks">("files");
|
||||
let leftView = $state<WorkbenchLayout["leftView"]>(DEFAULT_WORKBENCH_LAYOUT.leftView);
|
||||
let searchRequest = $state<{ text: string; id: number } | null>(null);
|
||||
let leftOpen = $state(true);
|
||||
let rightOpen = $state(true);
|
||||
let leftOpen = $state(DEFAULT_WORKBENCH_LAYOUT.leftOpen);
|
||||
let rightOpen = $state(DEFAULT_WORKBENCH_LAYOUT.rightOpen);
|
||||
$effect(() => { if ($pluginSidebar) leftOpen = true; });
|
||||
let terminalOpen = $state(false);
|
||||
let reading = $state(false);
|
||||
let quickOpen = $state(false);
|
||||
@@ -94,6 +98,8 @@
|
||||
let terminalDock: TerminalSlot | undefined = $state();
|
||||
const terminalContribution = $derived.by(() => { void $pluginHost; return pluginHost.get("terminal"); });
|
||||
const terminalEnabled = $derived(!!terminalContribution);
|
||||
const sidebarNavigation = $derived($pluginNavigation.filter(item => item.placement === "sidebar" && !item.toolbar));
|
||||
const ribbonNavigation = $derived($pluginNavigation.filter(item => item.placement !== "sidebar" && !item.toolbar));
|
||||
const browserContribution = $derived.by(() => { void $pluginHost; return pluginHost.get("browser"); });
|
||||
let browserOpening = $state(false);
|
||||
async function openBrowser() {
|
||||
@@ -125,6 +131,7 @@
|
||||
|
||||
let saving = $state(false);
|
||||
let switching = false;
|
||||
let workbenchReady = $state(false);
|
||||
let documents: Documents | null = null;
|
||||
let editorPane: EditorPane | undefined = $state();
|
||||
let closingTabs = false;
|
||||
@@ -165,6 +172,13 @@
|
||||
})),
|
||||
]);
|
||||
const workingTabs = $derived(orderWorkbenchTabs(availableTabs, tabOrder));
|
||||
$effect(() => {
|
||||
if (workbenchReady && !availableTabs.length) untrack(() => {
|
||||
const previousError = error;
|
||||
newTab();
|
||||
error = previousError;
|
||||
});
|
||||
});
|
||||
function workingTabDragData(tab: WorkbenchTab) {
|
||||
const view = $pluginEditors.find(view => view.key === tab.id);
|
||||
return view ? pluginTabDragData(view) : undefined;
|
||||
@@ -241,7 +255,9 @@
|
||||
}
|
||||
|
||||
function selectLeft(next: "files" | "search" | "bookmarks") {
|
||||
if (leftOpen && leftView === next) {
|
||||
const hadSidebar = !!$pluginSidebar;
|
||||
closePluginSidebar();
|
||||
if (!hadSidebar && leftOpen && leftView === next) {
|
||||
leftOpen = false;
|
||||
return;
|
||||
}
|
||||
@@ -270,9 +286,31 @@
|
||||
documents = createDocuments();
|
||||
status = workspace.root;
|
||||
refreshToken += 1;
|
||||
const token = new URLSearchParams(location.search).get("tabTransfer");
|
||||
if (token && /^[0-9a-f-]{36}$/i.test(token)) {
|
||||
const key = `runestone.tab-transfer.${token}`;
|
||||
const raw = localStorage.getItem(key);
|
||||
if (raw) {
|
||||
const transfer = JSON.parse(raw);
|
||||
if (transfer.root === workspace.root && transfer.created > Date.now() - 120000
|
||||
&& (transfer.buffer || transfer.plugin)) {
|
||||
if (transfer.buffer && typeof transfer.buffer.relPath === "string" && typeof transfer.buffer.contents === "string") documents.importTab(transfer.buffer);
|
||||
else if (transfer.plugin) {
|
||||
const deadline = Date.now() + 15000;
|
||||
while (!await restorePluginTab(transfer.plugin)) {
|
||||
if (Date.now() > deadline) throw new Error("Enable the plugin before moving this tab.");
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
} else throw new Error("Invalid tab transfer.");
|
||||
reading = transfer.reading === true;
|
||||
localStorage.setItem(key + ".accepted", "true");
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) { error = String(err); }
|
||||
finally { switching = false; }
|
||||
finally { switching = false; workbenchReady = true; }
|
||||
}
|
||||
|
||||
function selectTab(relPath: string) {
|
||||
@@ -307,7 +345,40 @@
|
||||
}
|
||||
function workingTabActions(item: WorkbenchTab): ActionMenuItem[] {
|
||||
const tab = workingTabs.find(tab => tab.id === item.id);
|
||||
return tab && "plugin" in tab ? pluginTabActions(tab.plugin) : [];
|
||||
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] : [];
|
||||
}
|
||||
async function detachTab(item: WorkbenchTab) {
|
||||
const tab = workingTabs.find(tab => tab.id === item.id);
|
||||
if (!tab || !workspace || !desktop) return;
|
||||
if ("plugin" in tab) {
|
||||
const action = pluginTabActions(tab.plugin).find(action => "label" in action && /(?:move|open).*new window/i.test(action.label));
|
||||
if (action && "run" in action && !action.disabled) { action.run?.(); return; }
|
||||
}
|
||||
const current = documents;
|
||||
const snapshot = JSON.stringify("buffer" in tab ? tab.buffer : pluginTabState(tab.plugin));
|
||||
const token = crypto.randomUUID(), key = `runestone.tab-transfer.${token}`;
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
const finish = () => {
|
||||
window.removeEventListener("storage", accepted);
|
||||
clearTimeout(timer);
|
||||
localStorage.removeItem(key);
|
||||
localStorage.removeItem(key + ".accepted");
|
||||
};
|
||||
const accepted = (event: StorageEvent) => {
|
||||
if (event.key !== key + ".accepted" || event.newValue !== "true") return;
|
||||
if ("buffer" in tab) {
|
||||
if (documents === current && JSON.stringify(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);
|
||||
finish();
|
||||
};
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify({ root: workspace.root, created: Date.now(), ...("buffer" in tab ? { buffer: tab.buffer } : { plugin: pluginTabState(tab.plugin) }), reading }));
|
||||
window.addEventListener("storage", accepted);
|
||||
timer = setTimeout(() => { finish(); error = "The new window did not accept the tab. The source tab remains open."; }, 30000);
|
||||
await workspaceOpenWindow(workspace.root, token);
|
||||
} catch (reason) { finish(); error = String(reason); }
|
||||
}
|
||||
function pinWorkingTab(path: string) {
|
||||
const tab = workingTabs.find(tab => tab.relPath === path);
|
||||
@@ -372,6 +443,7 @@
|
||||
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: () => editorPane?.toggleReadingView() },
|
||||
{ label: isIde ? "Writing mode" : "Source mode", icon: "code", run: toggleChrome },
|
||||
);
|
||||
@@ -544,8 +616,47 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function saveTemplate(entry: TreeEntry) {
|
||||
const name = await requestText("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}`;
|
||||
} catch (reason) { error = String(reason); }
|
||||
}
|
||||
|
||||
async function newNote(event?: MouseEvent) {
|
||||
if (!workspace) return;
|
||||
const create = async (template?: NoteTemplate) => {
|
||||
try {
|
||||
const path = await createNote("", template);
|
||||
refreshToken++;
|
||||
await openCreatedFile({ name: path.split("/").pop()!, rel_path: path, kind: "file" });
|
||||
} catch (reason) { error = String(reason); }
|
||||
};
|
||||
const templates = await noteTemplates();
|
||||
if (!templates.length || !event) { await create(); return; }
|
||||
const anchor = event.currentTarget instanceof HTMLElement ? event.currentTarget : document.activeElement as HTMLElement;
|
||||
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(); } },
|
||||
...templates.map(template => ({ label: template.name, icon: "file-plus" as const, run: () => { close(); void create(template); } })),
|
||||
], close, "New note");
|
||||
window.addEventListener("pointerdown", outside);
|
||||
}
|
||||
|
||||
function onPreferencesKeydown(event: KeyboardEvent) {
|
||||
if (event.target instanceof Element && event.target.closest("dialog, [role=dialog], [role=menu]")) return;
|
||||
if (event.ctrlKey && !event.altKey && !event.metaKey && event.key === "Tab" && workingTabs.length) {
|
||||
event.preventDefault(); event.stopPropagation();
|
||||
const index = workingTabs.findIndex(tab => tab.relPath === activeTabPath);
|
||||
const next = (index + (event.shiftKey ? -1 : 1) + workingTabs.length) % workingTabs.length;
|
||||
selectWorkingTab(workingTabs[next].relPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey && event.key === ",") {
|
||||
event.preventDefault(); event.stopPropagation(); void openSettings();
|
||||
}
|
||||
@@ -699,7 +810,7 @@
|
||||
const shell = event.currentTarget as HTMLElement;
|
||||
const rect = shell.getBoundingClientRect();
|
||||
if (dragging === "left") {
|
||||
leftWidth = Math.min(480, Math.max(160, event.clientX - rect.left - ($pluginNavigation.length ? 44 : 0)));
|
||||
leftWidth = Math.min(480, Math.max(160, event.clientX - rect.left - (ribbonNavigation.length ? 44 : 0)));
|
||||
}
|
||||
if (dragging === "right") {
|
||||
rightWidth = Math.min(480, Math.max(160, rect.right - event.clientX));
|
||||
@@ -715,6 +826,20 @@
|
||||
settings = { ...next };
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
try {
|
||||
const layout = parseWorkbenchLayout(localStorage.getItem(WORKBENCH_LAYOUT_KEY));
|
||||
({ leftOpen, rightOpen, leftWidth, rightWidth, leftView } = layout);
|
||||
layoutReady = true;
|
||||
} catch { error = "Could not read your layout. Default layout applies for this window."; }
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!layoutReady) return;
|
||||
try { saveWorkbenchLayout(localStorage, { leftOpen, rightOpen, leftWidth, rightWidth, leftView }); }
|
||||
catch { error = "Could not save your layout. Layout changes apply for this window only."; }
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
try { settings = parseSettings(localStorage.getItem(SETTINGS_KEY)); }
|
||||
catch { error = "Could not read your settings. Default settings apply until you save new settings."; }
|
||||
@@ -741,6 +866,9 @@
|
||||
void restoreLast();
|
||||
let disposed = false;
|
||||
const unlisteners: (() => void)[] = [];
|
||||
unlisteners.push(handlePluginFileOpen(async path => {
|
||||
await openFile({ name: path.split("/").pop() ?? path, rel_path: path, kind: "file" });
|
||||
}));
|
||||
unlisteners.push(handlePluginDocumentRename(async (from, name) => {
|
||||
const current = documents;
|
||||
if (!current || switching) throw new Error("Open a workspace before renaming a document.");
|
||||
@@ -801,7 +929,7 @@
|
||||
|
||||
<div
|
||||
class="shell"
|
||||
class:has-ribbon={$pluginNavigation.length > 0}
|
||||
class:has-ribbon={ribbonNavigation.length > 0}
|
||||
class:left-open={leftOpen}
|
||||
class:right-open={rightOpen}
|
||||
role="application"
|
||||
@@ -818,34 +946,48 @@
|
||||
<IconButton
|
||||
icon="files"
|
||||
label="Files"
|
||||
active={leftOpen && leftView === "files"}
|
||||
active={leftOpen && !$pluginSidebar && leftView === "files"}
|
||||
onclick={() => selectLeft("files")}
|
||||
/>
|
||||
<IconButton
|
||||
icon="search"
|
||||
label="Search"
|
||||
active={leftOpen && leftView === "search"}
|
||||
active={leftOpen && !$pluginSidebar && leftView === "search"}
|
||||
onclick={() => selectLeft("search")}
|
||||
/>
|
||||
<IconButton
|
||||
icon="bookmark"
|
||||
label="Bookmarks"
|
||||
active={leftOpen && leftView === "bookmarks"}
|
||||
active={leftOpen && !$pluginSidebar && leftView === "bookmarks"}
|
||||
onclick={() => selectLeft("bookmarks")}
|
||||
/>
|
||||
{#each sidebarNavigation as item (`${item.owner}:${item.id}`)}
|
||||
<IconButton
|
||||
icon={item.icon === "list" || item.icon === "kanban" || item.icon === "globe" || item.icon === "git" ? item.icon : "puzzle"}
|
||||
label={item.title}
|
||||
active={leftOpen && $pluginSidebar?.owner === item.owner && $pluginSidebar?.id === item.id}
|
||||
onclick={() => openPluginView(item.owner, item.id)}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="header-center" data-tauri-drag-region>
|
||||
<TabBar tabs={workingTabs} activePath={activeTabPath} onSelect={selectWorkingTab} onClose={closeTab}
|
||||
onCloseTabs={(path, scope) => void closeTabs(path, scope)} onPin={pinWorkingTab}
|
||||
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} />
|
||||
<PluginAccessMenu surface="open" />
|
||||
<PluginAccessMenu surface="open" compact />
|
||||
{#if desktop}<div class="window-drag-space" data-tauri-drag-region></div>{/if}
|
||||
</div>
|
||||
<div class="header-right" data-tauri-drag-region>
|
||||
{#each $pluginNavigation.filter(item => item.toolbar) as item (item.owner + ":" + item.id)}
|
||||
<IconButton icon={item.icon ?? "puzzle"} label={item.title}
|
||||
active={$pluginView?.owner === item.owner && $pluginView?.id === item.id && $pluginEditorActive}
|
||||
onclick={() => openPluginView(item.owner, item.id)} />
|
||||
{/each}
|
||||
<PluginTools />
|
||||
<PluginAccessMenu surface="commands" />
|
||||
<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
|
||||
@@ -858,13 +1000,13 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav class="plugin-ribbon" aria-label="Plugin shortcuts" hidden={$pluginNavigation.length === 0}>
|
||||
{#each $pluginNavigation as item (`${item.owner}:${item.id}`)}
|
||||
<nav class="plugin-ribbon" aria-label="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 : "puzzle"}
|
||||
icon={item.icon === "list" || item.icon === "kanban" || item.icon === "globe" || item.icon === "git" ? item.icon : "puzzle"}
|
||||
label={item.title}
|
||||
side="right"
|
||||
active={$pluginView?.owner === item.owner && $pluginView?.id === item.id && !$pluginView?.document && ($pluginView?.placement === "dialog" || $pluginEditorActive)}
|
||||
active={($pluginSidebar?.owner === item.owner && $pluginSidebar?.id === item.id) || $pluginView?.owner === item.owner && $pluginView?.id === item.id && !$pluginView?.document && ($pluginView?.placement === "dialog" || $pluginEditorActive)}
|
||||
onclick={() => openPluginView(item.owner, item.id)}
|
||||
/>
|
||||
{/each}
|
||||
@@ -873,6 +1015,10 @@
|
||||
{#if leftOpen}
|
||||
<aside class="left">
|
||||
<div class="left-body">
|
||||
{#if $pluginSidebar}
|
||||
{#key $pluginSidebar.key}<PluginEditor view={$pluginSidebar} />{/key}
|
||||
{/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}
|
||||
{:else}
|
||||
@@ -880,10 +1026,12 @@
|
||||
<div class="left-layer" class:shown={leftView === "files"}>
|
||||
<FileTree
|
||||
workspaceRoot={workspace.root}
|
||||
showInternal={settings.showInternalFolder}
|
||||
onSaveTemplate={(entry) => { void saveTemplate(entry); }}
|
||||
activePath={editorPluginVisible ? $pluginView?.document?.path ?? null : activePath}
|
||||
onOpenFile={(entry, newTab) => void openFile(entry, undefined, newTab ? "new" : "current")}
|
||||
{refreshToken}
|
||||
keysActive={leftView === "files"}
|
||||
keysActive={leftOpen && !$pluginSidebar && leftView === "files"}
|
||||
onCreated={(entry) => {
|
||||
void openCreatedFile(entry);
|
||||
}}
|
||||
@@ -902,6 +1050,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="left-footer">
|
||||
<div class="footer-start" bind:this={workspaceAnchor}>
|
||||
@@ -961,6 +1110,7 @@
|
||||
hasWorkspace={!!workspace}
|
||||
onOpenWorkspace={() => void chooseWorkspace()}
|
||||
onNewFile={() => void newFile()}
|
||||
onNewNote={(event) => { void newNote(event); }}
|
||||
onQuickOpen={() => quickOpen = true}
|
||||
onOpenBrowser={browserContribution?.newTab ? () => void openBrowser() : undefined}
|
||||
{browserOpening}
|
||||
@@ -1043,7 +1193,7 @@
|
||||
display: grid;
|
||||
--ribbon-width: 0px;
|
||||
grid-template-columns: var(--ribbon-width) minmax(0, 1fr);
|
||||
grid-template-rows: 36px minmax(0, 1fr) 22px;
|
||||
grid-template-rows: var(--rs-titlebar-height) minmax(0, 1fr) 22px;
|
||||
background: var(--rs-bg);
|
||||
}
|
||||
|
||||
@@ -1086,22 +1236,10 @@
|
||||
gap: 0;
|
||||
padding: 0;
|
||||
background: var(--rs-bg-elevated);
|
||||
border-bottom: 1px solid var(--rs-border);
|
||||
box-shadow: inset 0 -1px var(--rs-border);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.shell.left-open .header {
|
||||
grid-template-columns: calc(var(--left) + var(--ribbon-width)) minmax(0, 1fr) auto;
|
||||
}
|
||||
|
||||
.shell.right-open .header {
|
||||
grid-template-columns: auto minmax(0, 1fr) minmax(max-content, var(--right));
|
||||
}
|
||||
|
||||
.shell.left-open.right-open .header {
|
||||
grid-template-columns: calc(var(--left) + var(--ribbon-width)) minmax(0, 1fr) minmax(max-content, var(--right));
|
||||
}
|
||||
|
||||
.header-left,
|
||||
.header-right {
|
||||
display: flex;
|
||||
@@ -1109,6 +1247,7 @@
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.header-center {
|
||||
@@ -1117,12 +1256,14 @@
|
||||
justify-content: flex-start;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 0 8px;
|
||||
padding: 0;
|
||||
border-left: 1px solid var(--rs-border);
|
||||
border-right: 1px solid var(--rs-border);
|
||||
}
|
||||
|
||||
.header-left, .header-center, .header-right { height: 100%; }
|
||||
.shell.left-open .header-left { width: calc(var(--ribbon-width) + var(--left) + 1px); padding-left: calc(var(--ribbon-width) + 4px); }
|
||||
.header-left :global(.icon-btn), .header-right :global(.icon-btn) { flex-shrink: 0; }
|
||||
.header-right { justify-content: flex-end; }
|
||||
.window-drag-space { flex: 0 0 40px; align-self: stretch; }
|
||||
|
||||
@@ -1134,15 +1275,16 @@
|
||||
background: transparent;
|
||||
border-bottom: 0;
|
||||
}
|
||||
.header-center :global(.tabs:empty) { min-width: 80px; }
|
||||
|
||||
.header-center :global(.tab) {
|
||||
flex: 0 1 180px;
|
||||
width: 180px;
|
||||
min-width: 96px;
|
||||
max-width: 180px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.header-center :global(.tab.active) {
|
||||
background: var(--rs-item-selection-bg);
|
||||
background: var(--rs-bg);
|
||||
}
|
||||
|
||||
.ws {
|
||||
@@ -1215,6 +1357,9 @@
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.native-left { display: flex; flex-direction: column; min-height: 0; }
|
||||
.native-left.sidebar-covered { display: none; }
|
||||
|
||||
.left-stack {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
Reference in New Issue
Block a user