Skip to content

Commit

Permalink
revert: remove mermaid prop
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdehaven committed Jan 8, 2024
1 parent 05bbd52 commit e8297b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ When the editor is in fullscreen, the top offset, in pixels.

The `z-index` of the component when in fullscreen. Defaults to `1001`.

#### `mermaid`

- type: `Boolean`
- default: `true`

MermaidJs is a bit heavy when parsing the document nodes; set to `false` to opt-out of rendering Mermaid diagrams within code blocks. Defaults to `true`.

### Slots

#### `editor-actions`
Expand Down
11 changes: 3 additions & 8 deletions src/components/MarkdownUi.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ const props = defineProps({
type: Number,
default: 1001,
},
/** MermaidJs is heavy; allow it opting-out by passing false. Defaults to true. */
mermaid: {
type: Boolean,
default: true,
},
})
const emit = defineEmits<{
Expand Down Expand Up @@ -330,10 +325,10 @@ watchEffect((): void => {
})
const updateMermaid = async (): Promise<void> => {
if (props.mermaid) {
if (typeof MermaidJs !== 'undefined' && typeof MermaidJs?.run === 'function') {
// Scope the query selector to this instance of the markdown component (unique container id)
const mermaidNodes = `#${componentContainerId.value} .markdown-content-container .mermaid`
if (typeof MermaidJs !== 'undefined' && typeof MermaidJs?.run === 'function' && document.querySelector(mermaidNodes)) {
if (document.querySelector(mermaidNodes)) {
await MermaidJs.run({
querySelector: mermaidNodes,
suppressErrors: true,
Expand Down Expand Up @@ -457,7 +452,7 @@ const save = (): void => {
}
const initializeMermaid = (): void => {
if (props.mermaid && typeof MermaidJs !== 'undefined' && typeof MermaidJs?.initialize === 'function') {
if (typeof MermaidJs !== 'undefined' && typeof MermaidJs?.initialize === 'function') {
MermaidJs?.initialize({
startOnLoad: false,
securityLevel: 'strict',
Expand Down

0 comments on commit e8297b2

Please sign in to comment.