- 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.
32 lines
1.7 KiB
TypeScript
32 lines
1.7 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { headingEdit } from "../../../../src/lib/features/pm/model/description-format.ts";
|
|
|
|
function apply(value: string, start: number, end = start) {
|
|
const edit = headingEdit(value, start, end);
|
|
return { value: value.slice(0, edit.start) + edit.text + value.slice(edit.end), start: edit.selectionStart, end: edit.selectionEnd };
|
|
}
|
|
|
|
test("Heading formats the caret line and preserves the caret inside its text", () => {
|
|
assert.deepEqual(apply("Before\nTyped text\nAfter", 12), { value: "Before\n## Typed text\nAfter", start: 15, end: 15 });
|
|
assert.deepEqual(apply("Typed text", 0), { value: "## Typed text", start: 3, end: 3 });
|
|
assert.deepEqual(apply("Typed text", 10), { value: "## Typed text", start: 13, end: 13 });
|
|
});
|
|
|
|
test("Heading preserves selected text and formats all selected lines", () => {
|
|
assert.deepEqual(apply("One line\nTwo lines\nLast", 2, 12), { value: "## One line\n## Two lines\nLast", start: 5, end: 18 });
|
|
assert.deepEqual(apply("One\nTwo", 0, 4), { value: "## One\nTwo", start: 3, end: 7 });
|
|
});
|
|
|
|
test("Heading changes an existing heading without duplicate markers", () => {
|
|
assert.deepEqual(apply("# Title", 7), { value: "## Title", start: 8, end: 8 });
|
|
assert.deepEqual(apply("## Title", 5), { value: "## Title", start: 5, end: 5 });
|
|
assert.deepEqual(apply("### Title", 1), { value: "## Title", start: 3, end: 3 });
|
|
});
|
|
|
|
test("Heading leaves the caret after the marker on empty lines", () => {
|
|
assert.deepEqual(apply("", 0), { value: "## ", start: 3, end: 3 });
|
|
assert.deepEqual(apply("Text\n", 5), { value: "Text\n## ", start: 8, end: 8 });
|
|
assert.deepEqual(apply("\nText", 0), { value: "## \nText", start: 3, end: 3 });
|
|
});
|