mirror of
https://github.com/open-webui/open-webui
synced 2024-11-24 04:54:12 +00:00
refac
This commit is contained in:
parent
b23600b49d
commit
20f31b5bc8
@ -116,14 +116,25 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(async () => {
|
||||||
let content = '';
|
async function tryParse(value, attempts = 3, interval = 100) {
|
||||||
try {
|
try {
|
||||||
content = marked.parse(value);
|
// Try parsing the value
|
||||||
} catch (error) {
|
return marked.parse(value);
|
||||||
console.error('Error parsing markdown content:', error);
|
} catch (error) {
|
||||||
|
// If no attempts remain, fallback to plain text
|
||||||
|
if (attempts <= 1) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
// Wait for the interval, then retry
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
||||||
|
return tryParse(value, attempts - 1, interval); // Recursive call
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Usage example
|
||||||
|
let content = await tryParse(value);
|
||||||
|
|
||||||
editor = new Editor({
|
editor = new Editor({
|
||||||
element: element,
|
element: element,
|
||||||
extensions: [
|
extensions: [
|
||||||
|
Loading…
Reference in New Issue
Block a user