Last active
May 16, 2025 16:37
-
-
Save kindly/7ba3aa5a4fb87c2888b2cfb11d8eb357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.gem.wiki/Test_ObservableOwnershipTree | |
https://www.gem.wiki/Test_ObservableOwnershipTree_large |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://unpkg.com/@panzoom/[email protected]/dist/panzoom.min.js"></script> | |
<script type="module"> | |
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs'; | |
console.log("here") | |
const drawDiagram = async function () { | |
var element = document.getElementById("mermaid-graph"); | |
console.log(element) | |
const binGraphDefinition = atob("<!--{$data|escape:'javascript'}-->"); | |
const graphDefinition= new TextDecoder().decode(Uint8Array.from(binGraphDefinition, (m) => m.codePointAt(0))); | |
console.log(graphDefinition) | |
const { svg } = await mermaid.render('mermaid-svg', graphDefinition); | |
console.log(svg) | |
element.innerHTML = svg; | |
var svg_element = document.getElementById("mermaid-svg"); | |
let width = parseFloat(svg_element.style['max-width']) * 0.8 | |
svg_element.style.margin = 'auto' | |
if (width < 1600) { | |
svg_element.style.width = width + "px" | |
svg_element.style.margin = 'auto' | |
element.style.display = 'flex' | |
element.scrollTop = element.scrollHeight | |
} else { | |
element.style.height = "500px" | |
let panzoom = Panzoom(svg_element, {"maxScale": 20}) | |
svg_element.parentElement.addEventListener('wheel', panzoom.zoomWithWheel) | |
window.panzoom = panzoom | |
} | |
}; | |
drawDiagram(); | |
</script> | |
<pre id="mermaid-graph" style="max-height: 800px; background-color:white"></pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment