feat(tui): render Mermaid diagrams as terminal images (#6320)
* feat(tui): render Mermaid diagrams as terminal images * perf(tui): streamline Mermaid rendering and resource ownership * fix(tui): clarify diagram navigation hints * fix(tui): release viewer layout leases and retain retry targets * docs(tui): keep Mermaid guide focused on usage
This commit is contained in:
1 parent
9b5d552f40
commit
9adbcc2cef
31 files changed
+1983
-21
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import { DOMParser, XMLSerializer } from "@xmldom/xmldom"
|
||||
import type { DiagramFrame } from "./types"
|
||||
|
||||
/** Transform only the already validated image document; frame jobs need no CSS resolver. */
|
||||
export function frameDiagramSvg(svg: string, frame: DiagramFrame): string {
|
||||
const document = new DOMParser().parseFromString(svg, "image/svg+xml")
|
||||
const root = document.documentElement
|
||||
root.setAttribute("width", String(frame.width))
|
||||
root.setAttribute("height", String(frame.height))
|
||||
root.setAttribute("viewBox", `${frame.x} ${frame.y} ${frame.viewWidth} ${frame.viewHeight}`)
|
||||
return new XMLSerializer().serializeToString(document)
|
||||
}
|
||||
Reference in new issue
Block a user