mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-29 06:46:03 +08:00
Fix unnecessary vertical whitespace in Mermaid graphs (#1415)
This commit is contained in:
parent
3be3164e20
commit
9e43af7b4a
1 changed files with 14 additions and 1 deletions
|
|
@ -45,6 +45,8 @@ class Markdown {
|
|||
// can use morphdom's childrenOnly option
|
||||
const wrappedHtml = `<div>${html}</div>`;
|
||||
morphdom(this.container, wrappedHtml, { childrenOnly: true });
|
||||
|
||||
this._fixMermaidSpacing();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +85,13 @@ class Markdown {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
_fixMermaidSpacing() {
|
||||
// A workaround for https://github.com/mermaid-js/mermaid/issues/1758
|
||||
for (const svg of this.container.querySelectorAll(".mermaid svg")) {
|
||||
svg.removeAttribute("height");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Markdown;
|
||||
|
|
@ -171,7 +180,11 @@ function remarkPrepareMermaid(options) {
|
|||
visit(ast, "code", (node, index, parent) => {
|
||||
if (node.lang === "mermaid") {
|
||||
node.type = "html";
|
||||
node.value = `<div class="mermaid">${escapeHtml(node.value)}</div>`;
|
||||
node.value = `
|
||||
<div class="mermaid max-h-[600px] overflow-auto tiny-scrollbar">
|
||||
${escapeHtml(node.value)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue