Release RuneStone 0.1.7 with plugin documents and shared menus

This commit is contained in:
Knotty Wyvern
2026-10-06 09:29:09 -07:00
parent 6b7af0d527
commit 5d0a4a24f9
75 changed files with 2286 additions and 1665 deletions
+33 -8
View File
@@ -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)}