Skip to content

Commit

Permalink
feat: add zoom controls to mermaid
Browse files Browse the repository at this point in the history
  • Loading branch information
reinaldocosta committed Aug 3, 2023
1 parent 8767807 commit 1fd84b8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion _includes/scripts/mermaid.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10.3.0/dist/mermaid.min.js"></script>

<script>
let giscusTheme = localStorage.getItem("theme")
console.log('theme: ' + giscusTheme)
document.addEventListener('DOMContentLoaded', function () {
mermaid.initialize({
startOnLoad: true,
theme: giscusTheme,
})
window.mermaid.init(undefined, document.querySelectorAll('.language-mermaid'))
})


window.addEventListener('load', function () {
var svgs = d3.selectAll(".mermaid svg")
svgs.each(function () {
var svg = d3.select(this)
svg.html("<g>" + svg.html() + "</g>")
var inner = svg.select("g")
var zoom = d3.zoom().on("zoom", function (event) {
inner.attr("transform", event.transform)
})
svg.call(zoom)
})
});


</script>

0 comments on commit 1fd84b8

Please sign in to comment.