-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mermaid): Integrate mermaid in markdown renderer (#413)
- Loading branch information
1 parent
00431f2
commit 259f1df
Showing
5 changed files
with
6,961 additions
and
4,685 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script lang="ts"> | ||
import mermaid, {type MermaidConfig} from 'mermaid'; | ||
export let code: string; | ||
const mermaidDirective = (element: HTMLElement, config: MermaidConfig = {}) => { | ||
const renderMermaid = async () => { | ||
const {svg} = await mermaid.render('mermaid', code); | ||
element.innerHTML = svg; | ||
}; | ||
mermaid.initialize(config); | ||
if (code) { | ||
renderMermaid(); | ||
} | ||
return { | ||
update: (newConfig: MermaidConfig) => { | ||
config = newConfig; | ||
mermaid.initialize(config); | ||
if (code) { | ||
renderMermaid(); | ||
} | ||
}, | ||
}; | ||
}; | ||
</script> | ||
|
||
<div use:mermaidDirective class={`bg-light-subtle doc p-1 d-flex flex-nowrap align-items-start py-2 px-2 px-sm-4`}></div> | ||
|
||
<style lang="scss"> | ||
</style> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ export default defineConfig({ | |
'@floating-ui/dom', | ||
'svelte-markdown', | ||
'marked', | ||
'mermaid', | ||
], | ||
}, | ||
}); |
Oops, something went wrong.