This commit is contained in:
Timothy J. Baek 2024-09-23 23:39:33 +02:00
parent 35f64cc53f
commit e06667ead8
2 changed files with 14 additions and 2 deletions

View File

@ -128,7 +128,6 @@
: 30 : 30
: 0} : 0}
onResize={(size) => { onResize={(size) => {
console.log(size);
if (size === 0) { if (size === 0) {
showControls.set(false); showControls.set(false);
} else { } else {

View File

@ -20,6 +20,8 @@
export let lang = ''; export let lang = '';
export let code = ''; export let code = '';
let _token = null;
let mermaidHtml = null; let mermaidHtml = null;
let highlightedCode = null; let highlightedCode = null;
@ -226,7 +228,7 @@ __builtins__.input = input`);
} }
}; };
$: if (token) { const render = async () => {
if (lang === 'mermaid' && (token?.raw ?? '').slice(-4).includes('```')) { if (lang === 'mermaid' && (token?.raw ?? '').slice(-4).includes('```')) {
(async () => { (async () => {
await drawMermaidDiagram(); await drawMermaidDiagram();
@ -242,6 +244,17 @@ __builtins__.input = input`);
// Set a new timeout to debounce the code highlighting // Set a new timeout to debounce the code highlighting
debounceTimeout = setTimeout(highlightCode, 10); debounceTimeout = setTimeout(highlightCode, 10);
} }
};
$: if (token) {
if (JSON.stringify(token) !== JSON.stringify(_token)) {
console.log('hi');
_token = token;
}
}
$: if (_token) {
render();
} }
onMount(async () => { onMount(async () => {