Make Project Management a native feature
- Move the storage and model of the plugin into src/lib/features/pm/ as pure TypeScript, so the skill can still bundle them. - Move the DOM interface onto the host menus, the shared tooltip, and the host icons. - A ribbon button opens Project Management. Board tabs keep the owner runestone.pm and the board-<hex> view IDs through view patterns. - Read only .runestone/pm/. Offer the plugin migration, with backups, for legacy notes. - A save, move, or delete reads only that card again. Watcher paths reach the feature. - Add Settings → Project Management and the projectManagement section. View states move to localStorage. - Background reads the boards from workspace.json. Remove api.backgrounds and the boards service. - Add yaml 2.9.1. Use the host markdown-it. - Move 18 plugin test files to tests/unit/features/pm/ and add native tests.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { Workspace } from "./model.ts";
|
||||
import { boardKey, readCatalog } from "../storage/catalog.ts";
|
||||
import { boardDocument } from "../storage/board.ts";
|
||||
|
||||
/**
|
||||
* The board that opens first in this workspace: the `pm-board:` key of a saved board, the path of a legacy Markdown board,
|
||||
* or undefined for All tasks. Settings → Project Management writes `defaultBoardId` and `defaultBoardPath` of the catalog.
|
||||
*/
|
||||
export async function defaultBoardPath(workspace: Workspace): Promise<string | undefined> {
|
||||
const snapshot = await readCatalog(workspace);
|
||||
if (typeof snapshot.value.defaultBoardId !== "string") return;
|
||||
const board = snapshot.value.boards.find(board => board.value.id === snapshot.value.defaultBoardId);
|
||||
if (board) return board.archived ? undefined : boardKey(board.value.id);
|
||||
if (snapshot.value.deletedBoardIds?.includes(snapshot.value.defaultBoardId)) return;
|
||||
const path = snapshot.value.defaultBoardPath;
|
||||
if (typeof path !== "string" || path.startsWith(".") || path.includes("\\") || path.split("/").some(part => !part || part === "..")) return;
|
||||
try {
|
||||
const legacy = boardDocument(await workspace.read(path), path);
|
||||
return legacy?.id === snapshot.value.defaultBoardId && !legacy.archived ? path : undefined;
|
||||
} catch { return; }
|
||||
}
|
||||
Reference in New Issue
Block a user