Add completion, browser integration, and workspace improvements
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { loadMarks } from "$lib/workspace/marks";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
|
||||
type Props = {
|
||||
@@ -20,6 +21,7 @@
|
||||
|
||||
<div class="pane">
|
||||
<div class="pane-label">Bookmarks</div>
|
||||
<BrowserSlot kind="bookmarks" />
|
||||
{#if bookmarks.length === 0}
|
||||
<p class="placeholder">Right-click a file and choose Bookmark.</p>
|
||||
{:else}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<script lang="ts">
|
||||
import { tick, untrack } from "svelte";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import { pluginEditors, pluginView, pluginSplits, externalErrors, pluginServiceError, selectPluginEditor, closePluginEditor, pinPluginEditor, pluginTabActions, pluginTabDragData, dropPluginTab, findPluginEditor } from "$lib/plugins/external";
|
||||
import PluginEditor from "$lib/plugins/PluginEditor.svelte";
|
||||
import { containsPane, paneBounds } from "$lib/workspace/splitLayout";
|
||||
import { tabsToClose, type TabCloseScope } from "$lib/workspace/tabActions";
|
||||
import type { WorkbenchTab } from "$lib/workspace/workbenchTabs";
|
||||
import TabBar from "./TabBar.svelte";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import WindowControls from "$lib/ui/WindowControls.svelte";
|
||||
|
||||
let error = $state("");
|
||||
let opening = $state(false);
|
||||
let hadTabs = false;
|
||||
const browser = $derived.by(() => { void $pluginHost; return pluginHost.get("browser"); });
|
||||
const tabs = $derived<WorkbenchTab[]>($pluginEditors.map(view => ({
|
||||
id: view.key, relPath: view.key, name: view.title, title: view.title,
|
||||
pinned: !!view.pinned, draggable: view.draggable, icon: "globe", iconImage: view.iconImage, panelId: `plugin-editor-${view.key}`,
|
||||
})));
|
||||
const active = $derived($pluginView?.key ?? null);
|
||||
const split = $derived($pluginSplits.find(tree => active && containsPane(tree, active)));
|
||||
const bounds = $derived(split ? paneBounds(split) : active ? paneBounds(active) : {});
|
||||
const message = $derived(error || $externalErrors["runestone.browser"] || $pluginServiceError);
|
||||
|
||||
$effect(() => {
|
||||
if (tabs.length) hadTabs = true;
|
||||
else if (hadTabs) void tick().then(() => {
|
||||
if (!untrack(() => $pluginEditors.length)) void getCurrentWindow().destroy().catch(reason => error = String(reason));
|
||||
});
|
||||
});
|
||||
|
||||
function select(path: string) {
|
||||
const view = $pluginEditors.find(view => view.key === path);
|
||||
if (view) selectPluginEditor(view);
|
||||
}
|
||||
function move(path: string, index: number) {
|
||||
pluginEditors.update(views => {
|
||||
const from = views.findIndex(view => view.key === path);
|
||||
if (from < 0) return views;
|
||||
const ordered = [...views], [view] = ordered.splice(from, 1);
|
||||
ordered.splice(Math.max(0, Math.min(index, ordered.length)), 0, view);
|
||||
return ordered;
|
||||
});
|
||||
}
|
||||
function close(path: string, scope: TabCloseScope = "one") {
|
||||
for (const tab of tabsToClose(tabs, path, scope)) closePluginEditor(tab.id);
|
||||
}
|
||||
function actions(tab: WorkbenchTab) {
|
||||
const view = $pluginEditors.find(view => view.key === tab.id);
|
||||
return view ? pluginTabActions(view) : [];
|
||||
}
|
||||
function dragData(tab: WorkbenchTab) {
|
||||
const view = $pluginEditors.find(view => view.key === tab.id);
|
||||
return view ? pluginTabDragData(view) : undefined;
|
||||
}
|
||||
async function receive(data: string, index: number) {
|
||||
try { await dropPluginTab(data); if ($pluginView) move($pluginView.key, index); error = ""; }
|
||||
catch (reason) { error = String(reason); }
|
||||
}
|
||||
async function newTab() {
|
||||
if (opening || !browser?.newTab) return;
|
||||
opening = true;
|
||||
try { await browser.newTab(); error = ""; } catch (reason) { error = String(reason); }
|
||||
finally { opening = false; }
|
||||
}
|
||||
function keydown(event: KeyboardEvent) {
|
||||
if (event.defaultPrevented || !(event.ctrlKey || event.metaKey) || event.shiftKey || event.altKey) return;
|
||||
if (event.target instanceof Element && event.target.closest("dialog, [role=menu]")) return;
|
||||
if (event.key.toLowerCase() === "t") { event.preventDefault(); void newTab(); }
|
||||
if (event.key.toLowerCase() === "w" && active) { event.preventDefault(); close(active); }
|
||||
if (event.key.toLowerCase() === "f" && $pluginView && findPluginEditor($pluginView)) event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={keydown} />
|
||||
<div class="browser-window" role="application" aria-label="RuneStone browser">
|
||||
<header class="header" data-tauri-drag-region>
|
||||
<TabBar {tabs} activePath={active} onSelect={select} onClose={close} onCloseTabs={close}
|
||||
onMove={move} onPin={pinPluginEditor} fileActions={() => []} tabActions={actions}
|
||||
tabDragData={dragData} onDropTab={(data, index) => void receive(data, index)} />
|
||||
<IconButton icon="plus" label="New browser tab (Ctrl T)" disabled={!browser?.newTab || opening} onclick={() => void newTab()} />
|
||||
<div class="window-drag-space" data-tauri-drag-region></div>
|
||||
<WindowControls onError={message => error = message} />
|
||||
</header>
|
||||
{#if message}<p class="error" role="alert">{message}</p>{/if}
|
||||
<main class="pages">
|
||||
{#each $pluginEditors as view (view.key)}
|
||||
{@const position = bounds[view.key]}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions (Input selects its browser pane.) -->
|
||||
<div class="pane" class:inactive={!position} class:split={!!split} class:focused={active === view.key}
|
||||
style:left={`${position?.left ?? 0}%`} style:top={`${position?.top ?? 0}%`}
|
||||
style:width={`${position?.width ?? 100}%`} style:height={`${position?.height ?? 100}%`}
|
||||
onfocusin={() => { if (active !== view.key) select(view.key); }}
|
||||
onpointerdown={() => { if (active !== view.key) select(view.key); }}>
|
||||
{#if split && position}
|
||||
<TabBar tabs={tabs.filter(tab => tab.id === view.key)} activePath={active}
|
||||
onSelect={select} onClose={close} onCloseTabs={close} onMove={move} onPin={pinPluginEditor}
|
||||
fileActions={() => []} tabActions={actions} tabDragData={dragData} onDropTab={(data, index) => void receive(data, index)} />
|
||||
{/if}
|
||||
<PluginEditor {view} />
|
||||
</div>
|
||||
{/each}
|
||||
{#if !tabs.length}<p class="placeholder">{browser ? "Open a browser tab with the + button." : "Loading browser…"}</p>{/if}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.browser-window { height: 100vh; display: flex; flex-direction: column; background: var(--rs-bg); }
|
||||
.header { display: flex; align-items: center; height: 36px; flex-shrink: 0; background: var(--rs-bg-elevated); border-bottom: 1px solid var(--rs-border); }
|
||||
.header :global(.tabs) { flex: 0 1 auto; min-width: 80px; height: 100%; border-bottom: 0; }
|
||||
.window-drag-space { flex: 1; min-width: 40px; align-self: stretch; }
|
||||
.pages { position: relative; flex: 1; min-height: 0; overflow: hidden; }
|
||||
.pane { position: absolute; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
|
||||
.pane.inactive { display: none; }
|
||||
.pane.split { border: 1px solid var(--rs-border); }
|
||||
.pane.split.focused { border-color: var(--rs-accent); }
|
||||
.placeholder { padding: 24px; color: var(--rs-text-dim); }
|
||||
.error { margin: 0; padding: 8px; color: var(--rs-error); }
|
||||
</style>
|
||||
@@ -26,11 +26,13 @@
|
||||
onOpenWorkspace: () => void;
|
||||
onNewFile: () => void;
|
||||
onQuickOpen: () => void;
|
||||
onOpenBrowser?: () => void;
|
||||
browserOpening?: boolean;
|
||||
hasWorkspace: boolean;
|
||||
tableActions?: TableContextActions;
|
||||
};
|
||||
|
||||
let { buffer, tabs, chrome, reading, focusLine, onChange, onRenameTitle, onInsertImage, onToggleReading, onToggleChrome, onOpenLink, onOpenWorkspace, onNewFile, onQuickOpen, hasWorkspace, tableActions }: Props = $props();
|
||||
let { buffer, tabs, chrome, reading, focusLine, onChange, onRenameTitle, onInsertImage, onToggleReading, onToggleChrome, onOpenLink, onOpenWorkspace, onNewFile, onQuickOpen, onOpenBrowser, browserOpening = false, hasWorkspace, tableActions }: Props = $props();
|
||||
let previewMode = $state<"split" | "preview">("split");
|
||||
let modeControls = $state<HTMLDivElement>();
|
||||
let titleFocusId = $state<string | null>(null);
|
||||
@@ -94,6 +96,7 @@
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@@ -559,7 +559,20 @@
|
||||
|
||||
function menuItems(entry: TreeEntry | null): MenuItem[] {
|
||||
if (!entry) {
|
||||
return paneMenuItems("");
|
||||
return [
|
||||
...paneMenuItems(""),
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: "Show in Explorer",
|
||||
icon: "folder",
|
||||
run: () => {
|
||||
void workspaceReveal("").catch((err) => {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
const entries = actionEntries(entry, selection.paths, visiblePaths, findEntry);
|
||||
const multiple = entries.length > 1;
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
<script lang="ts">
|
||||
import PluginManager from "$lib/plugins/PluginManager.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 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, onSave, onClose }: {
|
||||
let { settings, help = false, standalone = false, windowError = "", onSave, onClose }: {
|
||||
settings: AppSettings;
|
||||
help?: boolean;
|
||||
standalone?: boolean;
|
||||
windowError?: string;
|
||||
onSave: (value: AppSettings) => void;
|
||||
onClose: () => void;
|
||||
} = $props();
|
||||
type Section = "general" | "plugins" | "about";
|
||||
type Section = string;
|
||||
const sections: { id: Section; label: string; icon: IconName; keywords: string }[] = [
|
||||
{ id: "about", label: "Help and about", icon: "help", keywords: "help about version shortcuts keyboard guide" },
|
||||
{ id: "general", label: "General", icon: "settings", keywords: "auto-save autosave save interval seconds files" },
|
||||
{ id: "plugins", label: "Plug-ins", icon: "puzzle", keywords: "plugins extensions community" },
|
||||
{ id: "about", label: "Help and about", icon: "help", keywords: "help about version shortcuts keyboard guide" },
|
||||
];
|
||||
let section = $state<Section>(untrack(() => help ? "about" : "general"));
|
||||
let query = $state("");
|
||||
@@ -24,8 +30,15 @@
|
||||
let message = $state("");
|
||||
let error = $state("");
|
||||
let dialog: HTMLDialogElement;
|
||||
const matches = $derived(sections.filter(item => `${item.label} ${item.keywords}`.toLowerCase().includes(query.trim().toLowerCase())));
|
||||
const browserEnabled = $derived.by(() => { void $pluginHost; return !!pluginHost.get("browser"); });
|
||||
const pluginSections = $derived($pluginTools.filter(tool => tool.surface === "settings").map(tool => ({
|
||||
id: `plugin:${tool.owner}:${tool.id}`, owner: tool.owner, view: tool.id,
|
||||
label: tool.title, icon: "settings" as const,
|
||||
keywords: `${$installedPlugins.plugins.find(row => row.manifest.id === tool.owner)?.manifest.name ?? tool.owner} settings configuration`,
|
||||
})));
|
||||
const matches = $derived([...sections, ...(browserEnabled ? [{ id: "browser" as const, label: "Browser", icon: "globe" as const, keywords: "browser profiles search cookies cache web privacy" }] : []), ...pluginSections].filter(item => `${item.label} ${item.keywords}`.toLowerCase().includes(query.trim().toLowerCase())));
|
||||
const selected = $derived(matches.find(item => item.id === section) ?? matches[0]);
|
||||
const selectedPlugin = $derived(pluginSections.find(item => item.id === selected?.id));
|
||||
|
||||
$effect(() => { seconds = settings.autosaveSeconds; });
|
||||
onMount(() => {
|
||||
@@ -54,7 +67,7 @@
|
||||
function trapFocus(event: KeyboardEvent) {
|
||||
if (event.target instanceof Element && event.target.closest("dialog") !== dialog) return;
|
||||
if (event.key !== "Tab") return;
|
||||
const controls = [...dialog.querySelectorAll<HTMLElement>("button:not(:disabled), input:not(:disabled), summary")]
|
||||
const controls = [...dialog.querySelectorAll<HTMLElement>("button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), a[href], summary, [tabindex]:not([tabindex='-1'])")]
|
||||
.filter(element => element.getClientRects().length > 0);
|
||||
const first = controls[0], last = controls.at(-1);
|
||||
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last?.focus(); }
|
||||
@@ -62,7 +75,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<dialog bind:this={dialog} class:help aria-labelledby="settings-title" onkeydown={trapFocus} oncancel={event => { if (event.target === dialog) { event.preventDefault(); onClose(); } }}>
|
||||
<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} />
|
||||
@@ -81,6 +94,7 @@
|
||||
</aside>
|
||||
{/if}
|
||||
<div class="content">
|
||||
{#if windowError}<p class="error" role="alert">{windowError}</p>{/if}
|
||||
{#if !selected}
|
||||
<h2>No settings found</h2>
|
||||
<p>Try “save”, “plug-ins”, or “help”.</p>
|
||||
@@ -105,6 +119,10 @@
|
||||
<p class="saved" role="status">{message}</p>
|
||||
{:else if selected.id === "plugins"}
|
||||
<PluginManager />
|
||||
{:else if selected.id === "browser"}
|
||||
<BrowserSlot kind="settings" />
|
||||
{:else if selectedPlugin}
|
||||
{#key selectedPlugin.id}<PluginSettings owner={selectedPlugin.owner} id={selectedPlugin.view} />{/key}
|
||||
{:else}
|
||||
<div class="brand"><img src="/runestone.svg" alt="" width="88" height="88" /><h2>RuneStone</h2><p>Version {version}</p></div>
|
||||
<div class="card help-card">
|
||||
@@ -121,6 +139,7 @@
|
||||
<style>
|
||||
dialog { width: min(920px, calc(100vw - 32px)); height: min(650px, calc(100dvh - 32px)); max-width: none; max-height: none; padding: 0; background: var(--rs-bg); color: var(--rs-text); border: 1px solid var(--rs-border); border-radius: 12px; box-shadow: 0 24px 80px #0008; overflow: hidden; }
|
||||
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; }
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { isTauri } from "@tauri-apps/api/core";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import SettingsDialog from "./SettingsDialog.svelte";
|
||||
import { DEFAULT_SETTINGS, SETTINGS_KEY, parseSettings, saveSettings, type AppSettings } from "$lib/workspace/settings";
|
||||
|
||||
let settings = $state<AppSettings>({ ...DEFAULT_SETTINGS });
|
||||
let error = $state("");
|
||||
function read() {
|
||||
try { settings = parseSettings(localStorage.getItem(SETTINGS_KEY)); }
|
||||
catch { error = "Could not read your settings. Default settings apply until you save new settings."; }
|
||||
}
|
||||
onMount(() => {
|
||||
read();
|
||||
const sync = (event: StorageEvent) => {
|
||||
if (event.storageArea === localStorage && (event.key === SETTINGS_KEY || event.key === null)) read();
|
||||
};
|
||||
window.addEventListener("storage", sync);
|
||||
window.addEventListener("focus", read);
|
||||
return () => { window.removeEventListener("storage", sync); window.removeEventListener("focus", read); };
|
||||
});
|
||||
function save(next: AppSettings) {
|
||||
saveSettings(localStorage, next);
|
||||
settings = { ...next };
|
||||
error = "";
|
||||
}
|
||||
async function close() {
|
||||
if (!isTauri()) { window.location.assign("/"); return; }
|
||||
try { await getCurrentWindow().close(); }
|
||||
catch (reason) { error = `Could not close settings: ${String(reason)}`; }
|
||||
}
|
||||
</script>
|
||||
|
||||
<SettingsDialog {settings} standalone windowError={error} onSave={save} onClose={() => void close()} />
|
||||
@@ -2,21 +2,26 @@
|
||||
import { onDestroy, tick } from "svelte";
|
||||
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
|
||||
import { actionIcons } from "$lib/ui/actionIcons";
|
||||
import TabIcon from "$lib/ui/TabIcon.svelte";
|
||||
import { tabsToClose, type TabCloseScope } from "$lib/workspace/tabActions";
|
||||
import type { OpenBuffer } from "$lib/workspace/types";
|
||||
import type { WorkbenchTab } from "$lib/workspace/workbenchTabs";
|
||||
|
||||
type Props = {
|
||||
tabs: OpenBuffer[];
|
||||
tabs: WorkbenchTab[];
|
||||
activePath: string | null;
|
||||
onSelect: (relPath: string) => void;
|
||||
onClose: (relPath: string) => void;
|
||||
onMove: (relPath: string, index: number) => void;
|
||||
onCloseTabs: (relPath: string, scope: TabCloseScope) => void;
|
||||
onPin: (relPath: string) => void;
|
||||
fileActions: (tab: OpenBuffer) => ActionMenuItem[];
|
||||
fileActions: (tab: WorkbenchTab) => ActionMenuItem[];
|
||||
tabActions?: (tab: WorkbenchTab) => ActionMenuItem[];
|
||||
tabDragData?: (tab: WorkbenchTab) => string | undefined;
|
||||
onDropTab?: (data: string, index: number) => void;
|
||||
};
|
||||
|
||||
let { tabs, activePath, onSelect, onClose, onMove, onCloseTabs, onPin, fileActions }: Props = $props();
|
||||
let { tabs, activePath, onSelect, onClose, onMove, onCloseTabs, onPin, fileActions, tabActions = () => [], tabDragData = () => undefined, onDropTab }: Props = $props();
|
||||
const transferType = "application/x-runestone-tab";
|
||||
let bar: HTMLDivElement;
|
||||
let dragged = $state<string | null>(null);
|
||||
let dropBefore = $state<string | null>(null);
|
||||
@@ -27,6 +32,48 @@
|
||||
let menu: HTMLElement | undefined;
|
||||
let menuAnchor: HTMLButtonElement | undefined;
|
||||
let menuPath = $state<string | null>(null);
|
||||
let receiving = $state(false);
|
||||
|
||||
function startTabTransfer(event: DragEvent, tab: WorkbenchTab) {
|
||||
const data = tabDragData(tab);
|
||||
if (!data || !event.dataTransfer) { event.preventDefault(); return; }
|
||||
cancelDrag(); closeMenu();
|
||||
dragged = tab.relPath;
|
||||
suppressClick = true;
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
event.dataTransfer.setData(transferType, data);
|
||||
}
|
||||
|
||||
function transferIndex(x: number) {
|
||||
const others = [...bar.querySelectorAll<HTMLElement>(".tab")].filter(row => row.dataset.path !== dragged);
|
||||
const before = others.findIndex(row => { const bounds = row.getBoundingClientRect(); return x < bounds.left + bounds.width / 2; });
|
||||
dropBefore = before < 0 ? null : others[before].dataset.path!;
|
||||
dropAfter = before < 0 ? others.at(-1)?.dataset.path ?? null : null;
|
||||
return before < 0 ? others.length : before;
|
||||
}
|
||||
|
||||
function dragOver(event: DragEvent) {
|
||||
if (!event.dataTransfer?.types.includes(transferType) || (!dragged && !onDropTab)) return;
|
||||
event.preventDefault();
|
||||
event.dataTransfer.dropEffect = "move";
|
||||
receiving = true;
|
||||
const bounds = bar.getBoundingClientRect();
|
||||
if (event.clientX < bounds.left + 28) bar.scrollLeft -= 10;
|
||||
else if (event.clientX > bounds.right - 28) bar.scrollLeft += 10;
|
||||
transferIndex(event.clientX);
|
||||
}
|
||||
|
||||
function finishTabTransfer() { dragged = dropBefore = dropAfter = null; receiving = false; suppressClick = false; }
|
||||
|
||||
function dropTab(event: DragEvent) {
|
||||
const data = event.dataTransfer?.getData(transferType);
|
||||
if (!data) return;
|
||||
event.preventDefault(); event.stopPropagation();
|
||||
const path = dragged, index = transferIndex(event.clientX);
|
||||
finishTabTransfer();
|
||||
if (path) void move(path, index);
|
||||
else onDropTab?.(data, index);
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (menuPath && !tabs.some(tab => tab.relPath === menuPath)) closeMenu();
|
||||
@@ -78,8 +125,11 @@
|
||||
closing("Close others", "others"),
|
||||
closing("Close tabs after", "after"),
|
||||
closing("Close all", "all"),
|
||||
{ separator: true },
|
||||
{ label: tabs[index].pinned ? "Unpin" : "Pin", icon: "pin", run: run(() => onPin(path)) },
|
||||
...(tabs[index].pinned !== undefined ? [
|
||||
{ separator: true as const },
|
||||
{ label: tabs[index].pinned ? "Unpin" : "Pin", icon: "pin" as const, run: run(() => onPin(path)) },
|
||||
] : []),
|
||||
...wrapActions(tabActions(tabs[index])),
|
||||
...(path === activePath ? wrapActions(fileActions(tabs[index])) : []),
|
||||
{ separator: true },
|
||||
{ label: "Move tab", icon: "swap", children: [
|
||||
@@ -197,8 +247,10 @@
|
||||
|
||||
<svelte:window onpointerdown={(event) => { if (menu && !menu.contains(event.target as Node)) closeMenu(); }} onresize={() => closeMenu()} />
|
||||
|
||||
<div bind:this={bar} class="tabs" role="tablist" aria-label="Open files">
|
||||
{#each tabs as tab (tab.relPath)}
|
||||
<div bind:this={bar} class="tabs" class:receiving role="tablist" aria-label="Working tabs" tabindex="-1"
|
||||
ondragover={dragOver} ondrop={dropTab}
|
||||
ondragleave={(event) => { if (!(event.relatedTarget instanceof Node) || !bar.contains(event.relatedTarget)) { receiving = false; dropBefore = dropAfter = null; } }}>
|
||||
{#each tabs as tab (tab.id)}
|
||||
<div class="tab" data-path={tab.relPath} class:active={tab.relPath === activePath} class:dragging={dragged === tab.relPath}
|
||||
class:drop-before={dropBefore === tab.relPath} class:drop-after={dropAfter === tab.relPath}>
|
||||
<button
|
||||
@@ -207,19 +259,23 @@
|
||||
data-path={tab.relPath}
|
||||
tabindex={tab.relPath === activePath ? 0 : -1}
|
||||
aria-selected={tab.relPath === activePath}
|
||||
aria-controls={tab.panelId}
|
||||
aria-describedby={tab.pinned ? `tab-pin-${tab.id}` : undefined}
|
||||
aria-keyshortcuts="Alt+Shift+ArrowLeft Alt+Shift+ArrowRight"
|
||||
title={`${tab.kind === "empty" ? tab.name : tab.relPath}\nDrag to reorder. Right-click for tab actions.`}
|
||||
title={`${tab.title}\n${tab.draggable ? "Drag to reorder or move to another RuneStone window." : "Drag to reorder."} Right-click for tab actions.`}
|
||||
onclick={() => { if (suppressClick) { suppressClick = false; return; } onSelect(tab.relPath); }}
|
||||
onpointerdown={(event) => startDrag(event, tab.relPath)}
|
||||
ondragstart={(event) => event.preventDefault()}
|
||||
onpointerdown={(event) => { if (!tab.draggable) startDrag(event, tab.relPath); else suppressClick = false; }}
|
||||
draggable={!!tab.draggable}
|
||||
ondragstart={(event) => startTabTransfer(event, tab)}
|
||||
ondragend={finishTabTransfer}
|
||||
onkeydown={(event) => onKey(event, tab.relPath)}
|
||||
oncontextmenu={(event) => { event.preventDefault(); event.stopPropagation(); showMenu(event.currentTarget, tab.relPath, event.clientX, event.clientY); }}
|
||||
onmousedown={onMiddleDown}
|
||||
onmouseup={(event) => onMiddleUp(event, tab.relPath)}
|
||||
>
|
||||
{#if tab.pinned}<svg class="pin" viewBox="0 0 24 24" aria-hidden="true">{@html actionIcons.pin}</svg>{/if}
|
||||
{tab.name}{tab.contents !== tab.saved ? " •" : ""}
|
||||
<TabIcon image={tab.iconImage} icon={tab.icon} />
|
||||
<span class="tab-label">{tab.name}{tab.dirty ? " •" : ""}</span>
|
||||
</button>
|
||||
{#if tab.pinned}<span class="sr-only" id={`tab-pin-${tab.id}`}>Pinned tab</span>{/if}
|
||||
<button
|
||||
@@ -246,6 +302,8 @@
|
||||
background: var(--rs-bg-elevated);
|
||||
border-bottom: 1px solid var(--rs-border);
|
||||
}
|
||||
.tabs:empty { min-width: 80px; }
|
||||
.tabs.receiving { box-shadow: inset 0 -2px var(--rs-accent); }
|
||||
|
||||
.tab {
|
||||
position: relative;
|
||||
@@ -281,6 +339,9 @@
|
||||
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
||||
|
||||
.tab > button:first-child {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
@@ -302,7 +363,9 @@
|
||||
color: var(--rs-text-strong);
|
||||
}
|
||||
|
||||
.pin { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
|
||||
.tab-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.tab :global(svg) { width: 16px; height: 16px; flex-shrink: 0; }
|
||||
.pin { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
|
||||
|
||||
.close {
|
||||
border: 0;
|
||||
|
||||
+169
-25
@@ -1,25 +1,29 @@
|
||||
<script lang="ts">
|
||||
import TerminalSlot from "$lib/plugins/TerminalSlot.svelte";
|
||||
import PluginTools from "$lib/plugins/PluginTools.svelte";
|
||||
import PluginAccessMenu from "$lib/plugins/PluginAccessMenu.svelte";
|
||||
import PluginEditor from "$lib/plugins/PluginEditor.svelte";
|
||||
import PluginEditorTab from "$lib/plugins/PluginEditorTab.svelte";
|
||||
import { pluginNavigation, openPluginView, pluginView, pluginEditors, pluginEditorActive, closePluginEditor, openPluginDocument, renamePluginDocuments, removePluginDocuments, notifyPluginWorkspace, guardPluginWrites, handlePluginDocumentRename, cancelPluginDocumentOpen } from "$lib/plugins/external";
|
||||
import { pluginSplits, pinPluginEditor, pluginTabActions, 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 { selectedEditorText } from "$lib/editor/selection";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import type { Contributions } from "$lib/plugins/contracts";
|
||||
import { isTauri } from "@tauri-apps/api/core";
|
||||
import { invoke, isTauri } from "@tauri-apps/api/core";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { confirm } from "@tauri-apps/plugin-dialog";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
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 { requestText } from "$lib/workspace/dialogs.svelte";
|
||||
import TextDialog from "./TextDialog.svelte";
|
||||
import QuickOpen from "./QuickOpen.svelte";
|
||||
import WorkspacePicker from "./WorkspacePicker.svelte";
|
||||
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 FileTree from "./FileTree.svelte";
|
||||
import EditorPane from "./EditorPane.svelte";
|
||||
@@ -55,6 +59,15 @@
|
||||
let workspace = $state<WorkspaceInfo | null>(null);
|
||||
let workspacePicker: WorkspacePicker;
|
||||
let preferences = $state<"settings" | "help" | null>(null);
|
||||
let openingSettings = false;
|
||||
async function openSettings() {
|
||||
if (!desktop) { preferences = "settings"; return; }
|
||||
if (openingSettings) return;
|
||||
openingSettings = true;
|
||||
try { await invoke("settings_open_window"); }
|
||||
catch (reason) { error = `Could not open settings: ${String(reason)}`; }
|
||||
finally { openingSettings = false; }
|
||||
}
|
||||
let settings = $state<AppSettings>({ ...DEFAULT_SETTINGS });
|
||||
let settingsReady = $state(false);
|
||||
let workspaceAnchor: HTMLDivElement | undefined = $state();
|
||||
@@ -81,6 +94,28 @@
|
||||
let terminalDock: TerminalSlot | undefined = $state();
|
||||
const terminalContribution = $derived.by(() => { void $pluginHost; return pluginHost.get("terminal"); });
|
||||
const terminalEnabled = $derived(!!terminalContribution);
|
||||
const browserContribution = $derived.by(() => { void $pluginHost; return pluginHost.get("browser"); });
|
||||
let browserOpening = $state(false);
|
||||
async function openBrowser() {
|
||||
if (browserOpening || !browserContribution?.newTab) return;
|
||||
browserOpening = true;
|
||||
const current = documents;
|
||||
const empty = !editorPluginVisible && buffer?.kind === "empty" ? buffer : null;
|
||||
const existing = new Set($pluginEditors.map(view => view.key));
|
||||
try {
|
||||
await browserContribution.newTab();
|
||||
const opened = $pluginView;
|
||||
if (empty && documents === current && current?.buffers.some(tab => tab.id === empty.id && tab.kind === "empty")
|
||||
&& opened?.placement === "editor" && !existing.has(opened.key)) {
|
||||
tabOrder = workingTabs.map(tab => tab.id === (empty.tabId ?? empty.id) ? opened.key : tab.id).filter((id, index, order) => order.indexOf(id) === index);
|
||||
if (empty.pinned && !opened.pinned) pinPluginEditor(opened.key);
|
||||
current.close(empty.relPath);
|
||||
}
|
||||
error = null;
|
||||
}
|
||||
catch (reason) { error = String(reason); }
|
||||
finally { browserOpening = false; }
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (!terminalEnabled) {
|
||||
@@ -113,6 +148,41 @@
|
||||
let centerStack: HTMLElement | undefined = $state();
|
||||
|
||||
const editorPluginVisible = $derived($pluginView?.placement === "editor" && $pluginEditorActive);
|
||||
type EditorTab = WorkbenchTab & ({ buffer: OpenBuffer } | { plugin: OpenPluginView });
|
||||
let tabOrder = $state<string[]>([]);
|
||||
const availableTabs = $derived<EditorTab[]>([
|
||||
...tabs.map(tab => ({
|
||||
id: tab.tabId ?? tab.id, relPath: tab.relPath, name: tab.name,
|
||||
title: tab.kind === "empty" ? tab.name : tab.relPath,
|
||||
dirty: tab.contents !== tab.saved, pinned: !!tab.pinned, buffer: tab,
|
||||
})),
|
||||
...$pluginEditors.map(plugin => ({
|
||||
id: plugin.key, relPath: `plugin:${plugin.key}`, name: plugin.title,
|
||||
title: plugin.document?.path ?? plugin.title,
|
||||
icon: plugin.icon === "file" ? "files" as const : plugin.icon ?? "puzzle" as const,
|
||||
iconImage: plugin.iconImage,
|
||||
panelId: `plugin-editor-${plugin.key}`, pinned: !!plugin.pinned, draggable: plugin.draggable, plugin,
|
||||
})),
|
||||
]);
|
||||
const workingTabs = $derived(orderWorkbenchTabs(availableTabs, tabOrder));
|
||||
function workingTabDragData(tab: WorkbenchTab) {
|
||||
const view = $pluginEditors.find(view => view.key === tab.id);
|
||||
return view ? pluginTabDragData(view) : undefined;
|
||||
}
|
||||
async function receiveTab(data: string, index: number) {
|
||||
try {
|
||||
await dropPluginTab(data);
|
||||
if ($pluginView?.placement === "editor") moveWorkingTab(`plugin:${$pluginView.key}`, index);
|
||||
error = null;
|
||||
} catch (reason) { error = String(reason); }
|
||||
}
|
||||
const activeTabPath = $derived(editorPluginVisible && $pluginView ? `plugin:${$pluginView.key}` : activePath);
|
||||
const activeSplit = $derived($pluginSplits.find(tree => $pluginView && containsPane(tree, $pluginView.key)));
|
||||
const pluginBounds = $derived(activeSplit ? paneBounds(activeSplit) : $pluginView ? paneBounds($pluginView.key) : {});
|
||||
$effect(() => {
|
||||
const order = workingTabs.map(tab => tab.id);
|
||||
if (order.length !== tabOrder.length || order.some((id, index) => id !== tabOrder[index])) tabOrder = order;
|
||||
});
|
||||
const dirty = $derived(buffer !== null && buffer.contents !== buffer.saved);
|
||||
const isIde = $derived(view === "Ide");
|
||||
const outlineItems = $derived(
|
||||
@@ -213,6 +283,38 @@
|
||||
status = documents?.active?.kind === "empty" ? "New tab" : relPath;
|
||||
}
|
||||
|
||||
function selectWorkingTab(path: string) {
|
||||
const tab = workingTabs.find(tab => tab.relPath === path);
|
||||
if (!tab) return;
|
||||
if ("plugin" in tab) selectPluginEditor(tab.plugin);
|
||||
else selectTab(path);
|
||||
}
|
||||
|
||||
function moveWorkingTab(path: string, index: number) {
|
||||
const from = workingTabs.findIndex(tab => tab.relPath === path);
|
||||
if (from < 0 || !Number.isInteger(index)) return;
|
||||
const ordered = [...workingTabs];
|
||||
const [tab] = ordered.splice(from, 1);
|
||||
const destination = Math.max(0, Math.min(index, ordered.length));
|
||||
ordered.splice(destination, 0, tab);
|
||||
tabOrder = ordered.map(tab => tab.id);
|
||||
if ("buffer" in tab) documents?.move(path, ordered.slice(0, destination).filter(tab => "buffer" in tab).length);
|
||||
}
|
||||
|
||||
function workingTabFileActions(item: WorkbenchTab): ActionMenuItem[] {
|
||||
const tab = workingTabs.find(tab => tab.id === item.id);
|
||||
return tab && "buffer" in tab ? tabFileActions(tab.buffer) : [];
|
||||
}
|
||||
function workingTabActions(item: WorkbenchTab): ActionMenuItem[] {
|
||||
const tab = workingTabs.find(tab => tab.id === item.id);
|
||||
return tab && "plugin" in tab ? pluginTabActions(tab.plugin) : [];
|
||||
}
|
||||
function pinWorkingTab(path: string) {
|
||||
const tab = workingTabs.find(tab => tab.relPath === path);
|
||||
if (tab && "plugin" in tab) pinPluginEditor(tab.plugin.key);
|
||||
else documents?.togglePin(path);
|
||||
}
|
||||
|
||||
function newTab() {
|
||||
cancelPluginDocumentOpen();
|
||||
if (switching) return;
|
||||
@@ -231,19 +333,27 @@
|
||||
|
||||
async function closeTabs(path: string, scope: TabCloseScope) {
|
||||
const current = documents;
|
||||
if (!current || closingTabs || switching) return;
|
||||
if (closingTabs || switching) return;
|
||||
closingTabs = true;
|
||||
try {
|
||||
const targets = tabsToClose(current.buffers, path, scope);
|
||||
const targets = tabsToClose(workingTabs, path, scope);
|
||||
for (const target of targets) {
|
||||
if (documents !== current || switching) break;
|
||||
const tab = current.buffers.find(item => item.id === target.id);
|
||||
if (!tab || (scope !== "one" && tab.pinned)) continue;
|
||||
const contents = tab.contents;
|
||||
if (contents !== tab.saved && !await confirm(`Discard unsaved edits in ${tab.name}?`, { title: "Close document", kind: "warning" })) break;
|
||||
if (documents !== current || switching || tab.contents !== contents) break;
|
||||
if (scope !== "one" && tab.pinned) continue;
|
||||
current.close(tab.relPath);
|
||||
const tab = "buffer" in target ? current?.buffers.find(item => item.id === target.buffer.id) : undefined;
|
||||
if ("buffer" in target) {
|
||||
if (!tab || (scope !== "one" && tab.pinned)) continue;
|
||||
const contents = tab.contents;
|
||||
if (contents !== tab.saved && !await confirm(`Discard unsaved edits in ${tab.name}?`, { title: "Close document", kind: "warning" })) break;
|
||||
if (documents !== current || switching || tab.contents !== contents) break;
|
||||
if (scope !== "one" && tab.pinned) continue;
|
||||
}
|
||||
const index = workingTabs.findIndex(item => item.id === target.id);
|
||||
if (index < 0) continue;
|
||||
const selected = workingTabs[index].relPath === activeTabPath
|
||||
? (workingTabs[index + 1] ?? workingTabs[index - 1])?.relPath : activeTabPath;
|
||||
if ("plugin" in target) closePluginEditor(target.plugin.key);
|
||||
else if (tab) current?.close(tab.relPath);
|
||||
if (selected && selected !== activeTabPath) selectWorkingTab(selected);
|
||||
}
|
||||
} catch (err) { error = String(err); }
|
||||
finally { closingTabs = false; }
|
||||
@@ -437,7 +547,7 @@
|
||||
function onPreferencesKeydown(event: KeyboardEvent) {
|
||||
if (event.target instanceof Element && event.target.closest("dialog, [role=dialog], [role=menu]")) return;
|
||||
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey && event.key === ",") {
|
||||
event.preventDefault(); event.stopPropagation(); preferences = "settings";
|
||||
event.preventDefault(); event.stopPropagation(); void openSettings();
|
||||
}
|
||||
if (event.key === "F1" && !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
|
||||
event.preventDefault(); event.stopPropagation(); preferences = "help";
|
||||
@@ -445,7 +555,11 @@
|
||||
}
|
||||
|
||||
function onKeydown(event: KeyboardEvent) {
|
||||
if (event.defaultPrevented) return;
|
||||
if (event.target instanceof Element && event.target.closest("dialog, [role=dialog], [role=menu]")) return;
|
||||
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey && event.key.toLowerCase() === "f" && editorPluginVisible && $pluginView) {
|
||||
if (findPluginEditor($pluginView)) { event.preventDefault(); return; }
|
||||
}
|
||||
const action = pluginHost.get("terminal")?.shortcut(event);
|
||||
const terminalTarget = event.target instanceof Element && !!event.target.closest(".dock");
|
||||
if (action && (["toggle", "new", "split", "window"].includes(action) || terminalTarget)) {
|
||||
@@ -488,7 +602,7 @@
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "w") {
|
||||
event.preventDefault();
|
||||
if (editorPluginVisible) {
|
||||
if ($pluginView) closePluginEditor($pluginView.key);
|
||||
if (activeTabPath) void closeTab(activeTabPath);
|
||||
} else if (activePath) {
|
||||
closeTab(activePath);
|
||||
}
|
||||
@@ -561,7 +675,10 @@
|
||||
|
||||
async function openLink(kind: "md" | "wiki", target: string) {
|
||||
if (/^(https?:\/\/|mailto:)/i.test(target)) {
|
||||
try { await openUrl(target); } catch (err) { error = String(err); }
|
||||
try {
|
||||
if (/^https?:\/\//i.test(target) && await pluginHost.get("browser")?.open(target)) return;
|
||||
await openUrl(target);
|
||||
} catch (err) { error = String(err); }
|
||||
return;
|
||||
}
|
||||
const rels = linkCandidates(activePath ?? "", target, kind);
|
||||
@@ -718,17 +835,17 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="header-center" data-tauri-drag-region>
|
||||
{#if tabs.length > 0}
|
||||
<TabBar {tabs} activePath={editorPluginVisible ? null : activePath} onSelect={selectTab} onClose={closeTab}
|
||||
onCloseTabs={(path, scope) => void closeTabs(path, scope)} onPin={(path) => documents?.togglePin(path)}
|
||||
fileActions={tabFileActions} onMove={(path, index) => documents?.move(path, index)} />
|
||||
{/if}
|
||||
<PluginEditorTab />
|
||||
<TabBar tabs={workingTabs} activePath={activeTabPath} onSelect={selectWorkingTab} onClose={closeTab}
|
||||
onCloseTabs={(path, scope) => void closeTabs(path, scope)} onPin={pinWorkingTab}
|
||||
fileActions={workingTabFileActions} tabActions={workingTabActions} onMove={moveWorkingTab}
|
||||
tabDragData={workingTabDragData} onDropTab={(data, index) => void receiveTab(data, index)} />
|
||||
<IconButton icon="plus" label="New tab (Ctrl T)" onclick={newTab} />
|
||||
<PluginAccessMenu surface="open" />
|
||||
{#if desktop}<div class="window-drag-space" data-tauri-drag-region></div>{/if}
|
||||
</div>
|
||||
<div class="header-right" data-tauri-drag-region>
|
||||
<PluginTools />
|
||||
<PluginAccessMenu surface="commands" />
|
||||
<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
|
||||
@@ -744,7 +861,7 @@
|
||||
<nav class="plugin-ribbon" aria-label="Plugin shortcuts" hidden={$pluginNavigation.length === 0}>
|
||||
{#each $pluginNavigation as item (`${item.owner}:${item.id}`)}
|
||||
<IconButton
|
||||
icon={item.icon === "list" || item.icon === "kanban" ? item.icon : "puzzle"}
|
||||
icon={item.icon === "list" || item.icon === "kanban" || item.icon === "globe" ? item.icon : "puzzle"}
|
||||
label={item.title}
|
||||
side="right"
|
||||
active={$pluginView?.owner === item.owner && $pluginView?.id === item.id && !$pluginView?.document && ($pluginView?.placement === "dialog" || $pluginEditorActive)}
|
||||
@@ -757,7 +874,7 @@
|
||||
<aside class="left">
|
||||
<div class="left-body">
|
||||
{#if !workspace}
|
||||
<p class="placeholder">No folder is open.</p>
|
||||
{#if leftView === "bookmarks"}<BrowserSlot kind="bookmarks" />{:else}<p class="placeholder">No folder is open.</p>{/if}
|
||||
{:else}
|
||||
<div class="left-stack">
|
||||
<div class="left-layer" class:shown={leftView === "files"}>
|
||||
@@ -793,7 +910,7 @@
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<IconButton icon="help" label="Help and about (F1)" onclick={() => preferences = "help"} />
|
||||
<IconButton icon="settings" label="Settings (Ctrl+,)" onclick={() => preferences = "settings"} />
|
||||
<IconButton icon="settings" label="Settings (Ctrl+,)" onclick={() => void openSettings()} />
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -807,7 +924,25 @@
|
||||
|
||||
<div class="center-stack" class:terminal-maximized={terminalOpen && terminalMaximized} bind:this={centerStack}>
|
||||
<main class="center">
|
||||
{#each $pluginEditors as view (view.key)}<PluginEditor {view} />{/each}
|
||||
<div class="plugin-panes" class:inactive={!editorPluginVisible}>
|
||||
{#each $pluginEditors as pane (pane.key)}
|
||||
{@const bounds = pluginBounds[pane.key]}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions (Focus selects the pane that owns the input.) -->
|
||||
<div class="plugin-pane" class:inactive={!bounds} class:split={!!activeSplit} class:focused={$pluginView?.key === pane.key}
|
||||
style:left={`${bounds?.left ?? 0}%`} style:top={`${bounds?.top ?? 0}%`}
|
||||
style:width={`${bounds?.width ?? 100}%`} style:height={`${bounds?.height ?? 100}%`}
|
||||
onfocusin={() => { if ($pluginView?.key !== pane.key) selectPluginEditor(pane); }}
|
||||
onpointerdown={() => { if ($pluginView?.key !== pane.key) selectPluginEditor(pane); }}>
|
||||
{#if activeSplit && bounds}
|
||||
<TabBar tabs={workingTabs.filter(tab => tab.id === pane.key)} activePath={activeTabPath}
|
||||
onSelect={selectWorkingTab} onClose={closeTab} onMove={moveWorkingTab} onPin={pinWorkingTab}
|
||||
onCloseTabs={(path, scope) => void closeTabs(path, scope)} fileActions={workingTabFileActions} tabActions={workingTabActions}
|
||||
tabDragData={workingTabDragData} onDropTab={(data, index) => void receiveTab(data, index)} />
|
||||
{/if}
|
||||
<PluginEditor view={pane} />
|
||||
</div>
|
||||
{/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>
|
||||
@@ -827,6 +962,8 @@
|
||||
onOpenWorkspace={() => void chooseWorkspace()}
|
||||
onNewFile={() => void newFile()}
|
||||
onQuickOpen={() => quickOpen = true}
|
||||
onOpenBrowser={browserContribution?.newTab ? () => void openBrowser() : undefined}
|
||||
{browserOpening}
|
||||
{buffer}
|
||||
chrome={view}
|
||||
{reading}
|
||||
@@ -997,6 +1134,7 @@
|
||||
background: transparent;
|
||||
border-bottom: 0;
|
||||
}
|
||||
.header-center :global(.tabs:empty) { min-width: 80px; }
|
||||
|
||||
.header-center :global(.tab) {
|
||||
max-width: 180px;
|
||||
@@ -1047,6 +1185,12 @@
|
||||
}
|
||||
|
||||
.editor-host.plugin-covered { display: none; }
|
||||
.center { position: relative; }
|
||||
.plugin-panes { position: relative; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
|
||||
.plugin-pane { position: absolute; display: flex; flex-direction: column; min-width: 0; min-height: 0; box-sizing: border-box; }
|
||||
.plugin-pane.split { border: 1px solid var(--rs-border); }
|
||||
.plugin-pane.split.focused { border-color: var(--rs-accent); }
|
||||
.plugin-panes.inactive, .plugin-pane.inactive { display: none; }
|
||||
|
||||
.left,
|
||||
.right {
|
||||
|
||||
Reference in New Issue
Block a user