mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 05:24:02 +00:00
refac: code highlight optimisation
This commit is contained in:
parent
deb4e36095
commit
f342f8adc7
@ -203,8 +203,18 @@ __builtins__.input = input`);
|
||||
};
|
||||
};
|
||||
|
||||
let debounceTimeout;
|
||||
$: if (code) {
|
||||
// Function to perform the code highlighting
|
||||
const highlightCode = () => {
|
||||
highlightedCode = hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value || code;
|
||||
};
|
||||
|
||||
// Clear the previous timeout if it exists
|
||||
clearTimeout(debounceTimeout);
|
||||
|
||||
// Set a new timeout to debounce the code highlighting
|
||||
debounceTimeout = setTimeout(highlightCode, 10);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user