web: open authored stage definitions in managed graph popup

This commit is contained in:
2026-10-20 17:35:13 +01:00
parent ae69e03157
commit f31806cfcb
18 changed files with 273 additions and 15 deletions
+21
View File
@@ -0,0 +1,21 @@
// Exact source ranges, following internal/pipeline/definition.go's block rules.
// Never reserialize graph fields: defaults and authored spelling differ.
export function stageSource(source, key) {
if (typeof source !== "string") return null;
let active = false;
let start = null;
let offset = 0;
for (const line of source.match(/[^\n]*\n|[^\n]+$/g) ?? []) {
const trim = line.trim();
if (active) {
if (trim === "```") active = false;
} else if (trim.startsWith("# stage ")) {
if (start !== null) return source.slice(start, offset);
if (trim.slice(8).trim() === key) start = offset;
} else if (trim.startsWith("```")) {
active = true;
}
offset += line.length;
}
return start === null ? null : source.slice(start);
}