You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
678 B
32 lines
678 B
import mermaid from "mermaid"; |
|
|
|
let is_running = false; |
|
const queue = []; |
|
|
|
export default { |
|
template: `<div></div>`, |
|
data: () => ({ |
|
last_content: "", |
|
}), |
|
mounted() { |
|
this.update(this.content); |
|
}, |
|
methods: { |
|
async update(content) { |
|
if (this.last_content === content) return; |
|
this.last_content = content; |
|
this.$el.innerHTML = content; |
|
this.$el.removeAttribute("data-processed"); |
|
queue.push(this.$el); |
|
if (is_running) return; |
|
is_running = true; |
|
while (queue.length) { |
|
await mermaid.run({ nodes: [queue.shift()] }); |
|
} |
|
is_running = false; |
|
}, |
|
}, |
|
props: { |
|
content: String, |
|
}, |
|
};
|
|
|