Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Add support to SyntaxTree 6 and Mermaid.js #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add mermaidjs dependency
  • Loading branch information
wenderjean committed Feb 18, 2023
commit dfa8d3d6dcad1e5cc2ff0d3ae0c9aad0f6d4951d
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@monaco-editor/loader": "^1.3.2",
"@wasmer/wasi": "^0.12.0",
"@wasmer/wasmfs": "^0.12.0",
"mermaid": "^9.4.0",
"path-browserify": "^1.0.1",
"ruby-head-wasm-wasi": "^0.3.0"
},
Expand Down
24 changes: 24 additions & 0 deletions src/mermaid-js.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import mermaidjs from "mermaid";

const getCleanContainer = () => {
const div = document.querySelector("#graph-container");

div.innerHTML = '';

return div;
}

const render = (fn: Function) => {
let container = getCleanContainer();

container.setAttribute("style", "display: block;");

mermaidjs.initialize({ startOnLoad: false });
mermaidjs.render('preparedScheme', fn(), (svg) => {
container.innerHTML = svg;
}, container);
}

const reset = () => getCleanContainer().setAttribute("style", "display: none;");

export { render, reset };
Loading