Release RuneStone 0.1.7 with plugin documents and shared menus
This commit is contained in:
@@ -1,174 +1,45 @@
|
||||
<script lang="ts">
|
||||
import type { MenuAction, MenuItem } from "./menuTypes";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import { untrack } from "svelte";
|
||||
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
|
||||
import type { MenuItem } from "./menuTypes";
|
||||
|
||||
type Props = {
|
||||
x: number;
|
||||
y: number;
|
||||
items: MenuItem[];
|
||||
onClose: () => void;
|
||||
label?: string;
|
||||
};
|
||||
|
||||
let { x, y, items, onClose }: Props = $props();
|
||||
|
||||
let root: HTMLElement | undefined = $state();
|
||||
let left = $state(0);
|
||||
let top = $state(0);
|
||||
let { x, y, items, onClose, label = "Context actions" }: Props = $props();
|
||||
|
||||
$effect(() => {
|
||||
left = x;
|
||||
top = y;
|
||||
void items;
|
||||
queueMicrotask(() => {
|
||||
if (!root) {
|
||||
return;
|
||||
}
|
||||
const rect = root.getBoundingClientRect();
|
||||
left = Math.min(x, window.innerWidth - rect.width - 8);
|
||||
top = Math.min(y, window.innerHeight - rect.height - 8);
|
||||
});
|
||||
const menuX = x, menuY = y, entries = items, name = label;
|
||||
const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
function close(restoreFocus = false) {
|
||||
root.remove();
|
||||
if (restoreFocus) previous?.focus({ preventScroll: true });
|
||||
onClose();
|
||||
}
|
||||
function convert(entries: MenuItem[]): ActionMenuItem[] {
|
||||
return entries.map(item => {
|
||||
if (item.kind === "sep") return { separator: true };
|
||||
if (item.kind === "group") return { label: item.label, icon: item.icon, children: convert(item.items) };
|
||||
return { label: item.label, icon: item.icon, disabled: item.disabled, run: () => {
|
||||
close(true);
|
||||
item.run();
|
||||
} };
|
||||
});
|
||||
}
|
||||
const root = untrack(() => actionMenu(menuX, menuY, convert(entries), () => close(true), name));
|
||||
const outside = (event: PointerEvent) => { if (!root.contains(event.target as Node)) close(); };
|
||||
const resize = () => close();
|
||||
window.addEventListener("pointerdown", outside);
|
||||
window.addEventListener("resize", resize);
|
||||
return () => {
|
||||
root.remove();
|
||||
window.removeEventListener("pointerdown", outside);
|
||||
window.removeEventListener("resize", resize);
|
||||
};
|
||||
});
|
||||
|
||||
function onWindowDown(event: MouseEvent) {
|
||||
if (root && !root.contains(event.target as Node)) {
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
|
||||
function onKey(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") {
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
|
||||
function runAction(item: MenuAction) {
|
||||
if (item.disabled) {
|
||||
return;
|
||||
}
|
||||
item.run();
|
||||
onClose();
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onmousedown={onWindowDown} onkeydown={onKey} />
|
||||
|
||||
<div
|
||||
bind:this={root}
|
||||
class="menu"
|
||||
style:left="{left}px"
|
||||
style:top="{top}px"
|
||||
role="menu"
|
||||
>
|
||||
{#each items as item, i (i)}
|
||||
{#if item.kind === "sep"}
|
||||
<div class="sep"></div>
|
||||
{:else if item.kind === "group"}
|
||||
<div class="group">
|
||||
<div class="group-label" role="none">{item.label}</div>
|
||||
<div class="flyout" role="menu">
|
||||
{#each item.items as sub, j (`${i}-${j}`)}
|
||||
{#if sub.kind === "sep"}
|
||||
<div class="sep"></div>
|
||||
{:else if sub.kind === "action"}
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
disabled={sub.disabled}
|
||||
onclick={() => runAction(sub)}
|
||||
>
|
||||
{#if sub.icon}<Icon icon={sub.icon} />{/if}
|
||||
{sub.label}
|
||||
</button>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
disabled={item.disabled}
|
||||
onclick={() => runAction(item)}
|
||||
>
|
||||
{#if item.icon}<Icon icon={item.icon} />{/if}
|
||||
{item.label}
|
||||
</button>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.menu,
|
||||
.flyout {
|
||||
min-width: 200px;
|
||||
padding: 4px 0;
|
||||
background: var(--rs-bg-elevated);
|
||||
border: 1px solid var(--rs-border);
|
||||
border-radius: var(--rs-control-radius);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.menu {
|
||||
position: fixed;
|
||||
z-index: 40;
|
||||
}
|
||||
|
||||
.group {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.group-label {
|
||||
padding: 6px 12px;
|
||||
color: var(--rs-text);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.group-label::after {
|
||||
content: "▸";
|
||||
float: right;
|
||||
color: var(--rs-text-dim);
|
||||
}
|
||||
|
||||
.flyout {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 100%;
|
||||
top: 0;
|
||||
z-index: 41;
|
||||
}
|
||||
|
||||
.group:hover > .flyout,
|
||||
.group:focus-within > .flyout {
|
||||
display: block;
|
||||
}
|
||||
|
||||
button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--rs-text-strong);
|
||||
text-align: left;
|
||||
padding: 6px 12px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
}
|
||||
|
||||
button:hover,
|
||||
button:focus-visible {
|
||||
background: var(--rs-bg-active);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: var(--rs-text-dim);
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.sep {
|
||||
height: 1px;
|
||||
margin: 4px 0;
|
||||
background: var(--rs-border);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
type DropPlace,
|
||||
type DropTarget,
|
||||
} from "$lib/workspace/treeDrop";
|
||||
import { planRename } from "$lib/workspace/renamePath";
|
||||
import { planRename, planDocumentTitleRename } 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";
|
||||
import TreeNode from "./TreeNode.svelte";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import { dropWorkspaceImage, highlightImageDrop } from "$lib/editor/workspaceImageDrop";
|
||||
import { pluginDocuments, pluginDocumentTypes, inspectPluginDocuments, createPluginDocument } from "$lib/plugins/external";
|
||||
|
||||
type Props = {
|
||||
workspaceRoot: string;
|
||||
@@ -72,6 +73,7 @@
|
||||
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;
|
||||
@@ -117,6 +119,7 @@
|
||||
try {
|
||||
const entries = await workspaceList(rel);
|
||||
childrenMap = { ...childrenMap, [rel]: sortEntries(rel, entries) };
|
||||
void inspectPluginDocuments(entries);
|
||||
error = null;
|
||||
} catch (err) {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
@@ -139,6 +142,7 @@
|
||||
|
||||
$effect(() => {
|
||||
void refreshToken;
|
||||
void $pluginDocumentTypes;
|
||||
const keys = untrack(() => Object.keys(childrenMap));
|
||||
for (const key of keys) {
|
||||
void load(key);
|
||||
@@ -348,7 +352,8 @@
|
||||
function startRename(entry: TreeEntry) {
|
||||
selectOnly(entry.rel_path);
|
||||
renameRel = entry.rel_path;
|
||||
renameDraft = entry.name;
|
||||
renameDocument = entry.kind === "file" && (!!$pluginDocuments[entry.rel_path] || /\.(md|markdown|mdown)$/i.test(entry.name));
|
||||
renameDraft = renameDocument ? entry.name.replace(/\.[^.]+$/, "") : entry.name;
|
||||
}
|
||||
|
||||
function cancelRename() {
|
||||
@@ -361,7 +366,7 @@
|
||||
if (!from) {
|
||||
return;
|
||||
}
|
||||
const plan = planRename(from, renameDraft);
|
||||
const plan = renameDocument ? planDocumentTitleRename(from, renameDraft) : planRename(from, renameDraft);
|
||||
cancelRename();
|
||||
if (plan.action === "noop") {
|
||||
return;
|
||||
@@ -531,6 +536,24 @@
|
||||
void createIn(parent, "note");
|
||||
},
|
||||
},
|
||||
...$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 () => {
|
||||
const create = type.create!;
|
||||
const typed = await requestText(create.label, create.defaultName);
|
||||
if (typed === null) return;
|
||||
const name = typed.trim().replace(new RegExp(`\\.${create.extension}$`, "i"), "");
|
||||
if (!name || name.length > 100 || /[<>:"/\\|?*\x00-\x1f]/.test(name) || /[. ]$/.test(name) || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(name)) { error = "Enter a valid document name."; return; }
|
||||
const fileName = `${name}.${create.extension}`;
|
||||
const path = joinRel(parent, fileName);
|
||||
try {
|
||||
await createPluginDocument(owner, type.id, path);
|
||||
expanded = new Set([...expanded, parent]);
|
||||
await load(parent);
|
||||
onOpenFile({ name: fileName, rel_path: path, kind: "file" }, true);
|
||||
} catch (reason) { error = String(reason); }
|
||||
})(); },
|
||||
})),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -551,7 +574,7 @@
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? `Make copies (${entries.length})` : "Make a copy",
|
||||
icon: "files",
|
||||
icon: "copy",
|
||||
run: () => { void copyEntries(entries); },
|
||||
},
|
||||
{
|
||||
@@ -569,7 +592,7 @@
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? "Copy workspace paths" : "Copy workspace path",
|
||||
icon: "files",
|
||||
icon: "copy",
|
||||
run: () => {
|
||||
void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? "workspace paths" : "workspace path");
|
||||
},
|
||||
@@ -577,7 +600,7 @@
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? "Copy system paths" : "Copy system path",
|
||||
icon: "files",
|
||||
icon: "copy",
|
||||
run: () => {
|
||||
void (async () => {
|
||||
try {
|
||||
@@ -592,7 +615,7 @@
|
||||
{
|
||||
kind: "action",
|
||||
label: "Show in Explorer",
|
||||
icon: "folder-open",
|
||||
icon: "folder",
|
||||
run: () => {
|
||||
void (async () => {
|
||||
const result = await runTreeActions(entries, item => workspaceReveal(item.rel_path));
|
||||
@@ -604,6 +627,7 @@
|
||||
{
|
||||
kind: "action",
|
||||
label: pinned ? "Unpin" : "Pin",
|
||||
icon: "pin",
|
||||
run: () => {
|
||||
void persistMarks({
|
||||
...marks,
|
||||
@@ -614,7 +638,7 @@
|
||||
{
|
||||
kind: "action",
|
||||
label: "Rename",
|
||||
icon: "pen",
|
||||
icon: "rename",
|
||||
disabled: multiple,
|
||||
run: () => {
|
||||
startRename(entry);
|
||||
@@ -714,6 +738,7 @@
|
||||
|
||||
{#if menu}
|
||||
<ContextMenu
|
||||
label="File actions"
|
||||
x={menu.x}
|
||||
y={menu.y}
|
||||
items={menuItems(menu.entry)}
|
||||
|
||||
@@ -303,9 +303,6 @@
|
||||
}
|
||||
|
||||
.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; }
|
||||
:global(.tab-menu) { width: 244px; border-radius: var(--rs-control-radius); }
|
||||
:global(.tab-menu button) { border-radius: var(--rs-control-radius); min-height: 30px; }
|
||||
:global(.tab-menu .table-cell-submenu) { border-radius: var(--rs-control-radius); }
|
||||
|
||||
.close {
|
||||
border: 0;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
import type { SelectionModifiers, TreeSelectionEdges } from "$lib/workspace/treeSelection";
|
||||
import { treeFileParts } from "$lib/workspace/chrome";
|
||||
import TreeNode from "./TreeNode.svelte";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import { pluginDocuments } from "$lib/plugins/external";
|
||||
|
||||
type Props = {
|
||||
entry: TreeEntry;
|
||||
@@ -125,6 +127,9 @@
|
||||
</span>
|
||||
{/if}
|
||||
<span class="twist" class:open={isOpen} class:folder={entry.kind === "folder"}></span>
|
||||
{#if $pluginDocuments[entry.rel_path]}
|
||||
<span class="document-icon" title={$pluginDocuments[entry.rel_path].title}><Icon icon={$pluginDocuments[entry.rel_path].icon === "kanban" ? "kanban" : "files"} /></span>
|
||||
{/if}
|
||||
{#if isRenaming}
|
||||
<input
|
||||
class="rename"
|
||||
@@ -183,6 +188,7 @@
|
||||
</li>
|
||||
|
||||
<style>
|
||||
.document-icon { display: inline-flex; width: 16px; height: 16px; flex-shrink: 0; margin-right: 5px; }
|
||||
li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<script lang="ts">
|
||||
import TerminalSlot from "$lib/plugins/TerminalSlot.svelte";
|
||||
import PluginTools from "$lib/plugins/PluginTools.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 { onMount, tick } from "svelte";
|
||||
import { selectedEditorText } from "$lib/editor/selection";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
@@ -44,7 +47,7 @@
|
||||
workspaceWriteBytes,
|
||||
} from "$lib/workspace/api";
|
||||
import { detectChrome } from "$lib/workspace/chrome";
|
||||
import { planRename, planMarkdownTitleRename } from "$lib/workspace/renamePath";
|
||||
import { planRename, planMarkdownTitleRename, planDocumentTitleRename } from "$lib/workspace/renamePath";
|
||||
import { attachmentRel, isImagePath, isMarkdownPath } from "$lib/workspace/media";
|
||||
import { linkCandidates } from "$lib/workspace/markdownLinks";
|
||||
import type { Chrome, OpenBuffer, TreeEntry, WorkspaceInfo } from "$lib/workspace/types";
|
||||
@@ -109,6 +112,7 @@
|
||||
let dragging = $state<"left" | "right" | "bottom" | null>(null);
|
||||
let centerStack: HTMLElement | undefined = $state();
|
||||
|
||||
const editorPluginVisible = $derived($pluginView?.placement === "editor" && $pluginEditorActive);
|
||||
const dirty = $derived(buffer !== null && buffer.contents !== buffer.saved);
|
||||
const isIde = $derived(view === "Ide");
|
||||
const outlineItems = $derived(
|
||||
@@ -202,13 +206,17 @@
|
||||
}
|
||||
|
||||
function selectTab(relPath: string) {
|
||||
cancelPluginDocumentOpen();
|
||||
pluginEditorActive.set(false);
|
||||
focusLine = null;
|
||||
documents?.select(relPath);
|
||||
status = documents?.active?.kind === "empty" ? "New tab" : relPath;
|
||||
}
|
||||
|
||||
function newTab() {
|
||||
cancelPluginDocumentOpen();
|
||||
if (switching) return;
|
||||
pluginEditorActive.set(false);
|
||||
documents ??= createDocuments();
|
||||
focusLine = null;
|
||||
documents.newTab();
|
||||
@@ -276,8 +284,13 @@
|
||||
const current = documents;
|
||||
if (!current || switching) return;
|
||||
try {
|
||||
const open = current.buffers.find(tab => tab.relPath === entry.rel_path);
|
||||
if (!line && !(open && open.contents !== open.saved) && await openPluginDocument(entry.rel_path, () => documents === current && !switching)) {
|
||||
status = entry.rel_path; error = null; return;
|
||||
}
|
||||
await current.open(entry, target);
|
||||
if (documents !== current) return;
|
||||
pluginEditorActive.set(false);
|
||||
status = entry.rel_path;
|
||||
error = null;
|
||||
focusLine = null;
|
||||
@@ -454,7 +467,7 @@
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "s") {
|
||||
event.preventDefault();
|
||||
void save();
|
||||
if (!editorPluginVisible) void save();
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "o") {
|
||||
event.preventDefault();
|
||||
@@ -466,7 +479,7 @@
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "e") {
|
||||
event.preventDefault();
|
||||
toggleChrome();
|
||||
if (!editorPluginVisible) toggleChrome();
|
||||
}
|
||||
if (terminalEnabled && (event.ctrlKey || event.metaKey) && event.key === "`") {
|
||||
event.preventDefault();
|
||||
@@ -474,7 +487,9 @@
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "w") {
|
||||
event.preventDefault();
|
||||
if (activePath) {
|
||||
if (editorPluginVisible) {
|
||||
if ($pluginView) closePluginEditor($pluginView.key);
|
||||
} else if (activePath) {
|
||||
closeTab(activePath);
|
||||
}
|
||||
}
|
||||
@@ -487,7 +502,7 @@
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
if (!(leftOpen && leftView === "files")) {
|
||||
if (!editorPluginVisible && !(leftOpen && leftView === "files")) {
|
||||
void renameActive();
|
||||
}
|
||||
}
|
||||
@@ -495,6 +510,7 @@
|
||||
|
||||
function applyPathRename(from: string, to: string) {
|
||||
documents?.rename(from, to);
|
||||
renamePluginDocuments(from, to);
|
||||
}
|
||||
|
||||
async function renameNoteTitle(id: string, title: string) {
|
||||
@@ -566,7 +582,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));
|
||||
leftWidth = Math.min(480, Math.max(160, event.clientX - rect.left - ($pluginNavigation.length ? 44 : 0)));
|
||||
}
|
||||
if (dragging === "right") {
|
||||
rightWidth = Math.min(480, Math.max(160, rect.right - event.clientX));
|
||||
@@ -608,6 +624,22 @@
|
||||
void restoreLast();
|
||||
let disposed = false;
|
||||
const unlisteners: (() => void)[] = [];
|
||||
unlisteners.push(handlePluginDocumentRename(async (from, name) => {
|
||||
const current = documents;
|
||||
if (!current || switching) throw new Error("Open a workspace before renaming a document.");
|
||||
const plan = planDocumentTitleRename(from, name);
|
||||
if (plan.action === "error") throw new Error(plan.message);
|
||||
if (plan.action === "noop") return from;
|
||||
await workspaceRename(from, plan.to);
|
||||
if (documents !== current) throw new Error("The workspace changed. Reopen the document.");
|
||||
applyPathRename(from, plan.to);
|
||||
refreshToken++;
|
||||
return plan.to;
|
||||
}));
|
||||
unlisteners.push(guardPluginWrites(path => {
|
||||
const open = documents?.buffers.find(tab => tab.relPath === path);
|
||||
if (open && open.contents !== open.saved) throw new Error("Save or discard the open note's edits before changing it from a plugin.");
|
||||
}));
|
||||
let refreshTimer: ReturnType<typeof setTimeout>;
|
||||
const register = (off: () => void) => { if (disposed) off(); else unlisteners.push(off); };
|
||||
void onWorkspaceEvent((event) => {
|
||||
@@ -617,6 +649,7 @@
|
||||
refreshTimer = setTimeout(() => {
|
||||
refreshToken++;
|
||||
void documents?.refresh();
|
||||
notifyPluginWorkspace();
|
||||
}, 200);
|
||||
}).then(register).catch(err => error = String(err));
|
||||
let closing = false;
|
||||
@@ -651,6 +684,7 @@
|
||||
|
||||
<div
|
||||
class="shell"
|
||||
class:has-ribbon={$pluginNavigation.length > 0}
|
||||
class:left-open={leftOpen}
|
||||
class:right-open={rightOpen}
|
||||
role="application"
|
||||
@@ -685,16 +719,17 @@
|
||||
</div>
|
||||
<div class="header-center" data-tauri-drag-region>
|
||||
{#if tabs.length > 0}
|
||||
<TabBar {tabs} {activePath} onSelect={selectTab} onClose={closeTab}
|
||||
<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 />
|
||||
<IconButton icon="plus" label="New tab (Ctrl T)" onclick={newTab} />
|
||||
{#if desktop}<div class="window-drag-space" data-tauri-drag-region></div>{/if}
|
||||
</div>
|
||||
<div class="header-right" data-tauri-drag-region>
|
||||
<PluginTools />
|
||||
<IconButton icon="save" label="Save" disabled={!dirty || saving} onclick={() => void save()} />
|
||||
<IconButton icon="save" label="Save" disabled={editorPluginVisible || !dirty || saving} onclick={() => void save()} />
|
||||
{#if terminalEnabled}<IconButton icon="terminal" label="Terminal" active={terminalOpen} onclick={toggleTerminal} />{/if}
|
||||
<IconButton
|
||||
icon="panel-right"
|
||||
@@ -706,6 +741,18 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<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"}
|
||||
label={item.title}
|
||||
side="right"
|
||||
active={$pluginView?.owner === item.owner && $pluginView?.id === item.id && !$pluginView?.document && ($pluginView?.placement === "dialog" || $pluginEditorActive)}
|
||||
onclick={() => openPluginView(item.owner, item.id)}
|
||||
/>
|
||||
{/each}
|
||||
</nav>
|
||||
|
||||
{#if leftOpen}
|
||||
<aside class="left">
|
||||
<div class="left-body">
|
||||
@@ -716,7 +763,7 @@
|
||||
<div class="left-layer" class:shown={leftView === "files"}>
|
||||
<FileTree
|
||||
workspaceRoot={workspace.root}
|
||||
{activePath}
|
||||
activePath={editorPluginVisible ? $pluginView?.document?.path ?? null : activePath}
|
||||
onOpenFile={(entry, newTab) => void openFile(entry, undefined, newTab ? "new" : "current")}
|
||||
{refreshToken}
|
||||
keysActive={leftView === "files"}
|
||||
@@ -727,7 +774,7 @@
|
||||
status = message;
|
||||
error = null;
|
||||
}}
|
||||
onEntryGone={() => { void documents?.refresh(); }}
|
||||
onEntryGone={(path) => { removePluginDocuments(path); void documents?.refresh(); }}
|
||||
onEntryRenamed={applyPathRename}
|
||||
/>
|
||||
</div>
|
||||
@@ -760,7 +807,8 @@
|
||||
|
||||
<div class="center-stack" class:terminal-maximized={terminalOpen && terminalMaximized} bind:this={centerStack}>
|
||||
<main class="center">
|
||||
<div class="editor-host">
|
||||
{#each $pluginEditors as view (view.key)}<PluginEditor {view} />{/each}
|
||||
<div class="editor-host" class:plugin-covered={editorPluginVisible}>
|
||||
{#if buffer?.diskError}
|
||||
<div class="conflict" role="alert"><span>{buffer.diskError}</span><button onclick={() => void saveCopy()}>Save a copy</button><button onclick={() => void documents?.refresh()}>Retry</button></div>
|
||||
{:else if buffer?.diskContents != null}
|
||||
@@ -824,6 +872,7 @@
|
||||
<OutlinePane
|
||||
items={outlineItems}
|
||||
onJump={(line) => {
|
||||
pluginEditorActive.set(false);
|
||||
reading = false;
|
||||
focusLine = null;
|
||||
queueMicrotask(() => {
|
||||
@@ -855,23 +904,43 @@
|
||||
.shell {
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
--ribbon-width: 0px;
|
||||
grid-template-columns: var(--ribbon-width) minmax(0, 1fr);
|
||||
grid-template-rows: 36px minmax(0, 1fr) 22px;
|
||||
background: var(--rs-bg);
|
||||
}
|
||||
|
||||
.shell.left-open {
|
||||
grid-template-columns: var(--left) 1px minmax(0, 1fr);
|
||||
grid-template-columns: var(--ribbon-width) var(--left) 1px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.shell.right-open {
|
||||
grid-template-columns: minmax(0, 1fr) 1px var(--right);
|
||||
grid-template-columns: var(--ribbon-width) minmax(0, 1fr) 1px var(--right);
|
||||
}
|
||||
|
||||
.shell.left-open.right-open {
|
||||
grid-template-columns: var(--left) 1px minmax(0, 1fr) 1px var(--right);
|
||||
grid-template-columns: var(--ribbon-width) var(--left) 1px minmax(0, 1fr) 1px var(--right);
|
||||
}
|
||||
|
||||
.shell.has-ribbon { --ribbon-width: 44px; }
|
||||
|
||||
.plugin-ribbon {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-height: 0;
|
||||
padding: 6px 5px;
|
||||
overflow-y: auto;
|
||||
background: var(--rs-bg-elevated);
|
||||
border-right: 1px solid var(--rs-border);
|
||||
}
|
||||
|
||||
.plugin-ribbon[hidden] { display: block; visibility: hidden; padding: 0; border: 0; }
|
||||
.plugin-ribbon :global(.icon-btn) { width: 32px; height: 32px; flex-basis: 32px; }
|
||||
|
||||
.header {
|
||||
grid-column: 1 / -1;
|
||||
display: grid;
|
||||
@@ -885,7 +954,7 @@
|
||||
}
|
||||
|
||||
.shell.left-open .header {
|
||||
grid-template-columns: var(--left) minmax(0, 1fr) auto;
|
||||
grid-template-columns: calc(var(--left) + var(--ribbon-width)) minmax(0, 1fr) auto;
|
||||
}
|
||||
|
||||
.shell.right-open .header {
|
||||
@@ -893,7 +962,7 @@
|
||||
}
|
||||
|
||||
.shell.left-open.right-open .header {
|
||||
grid-template-columns: var(--left) minmax(0, 1fr) minmax(max-content, var(--right));
|
||||
grid-template-columns: calc(var(--left) + var(--ribbon-width)) minmax(0, 1fr) minmax(max-content, var(--right));
|
||||
}
|
||||
|
||||
.header-left,
|
||||
@@ -977,6 +1046,8 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.editor-host.plugin-covered { display: none; }
|
||||
|
||||
.left,
|
||||
.right {
|
||||
background: var(--rs-bg-elevated);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { IconName } from "$lib/ui/IconButton.svelte";
|
||||
import type { ActionIcon } from "$lib/ui/actionIcons";
|
||||
|
||||
export type MenuAction = {
|
||||
kind: "action";
|
||||
label: string;
|
||||
run: () => void;
|
||||
disabled?: boolean;
|
||||
icon?: IconName;
|
||||
icon?: ActionIcon;
|
||||
};
|
||||
|
||||
export type MenuSep = { kind: "sep" };
|
||||
@@ -13,6 +13,7 @@ export type MenuSep = { kind: "sep" };
|
||||
export type MenuGroup = {
|
||||
kind: "group";
|
||||
label: string;
|
||||
icon?: ActionIcon;
|
||||
items: MenuItem[];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user