mirror of
https://github.com/open-webui/open-webui
synced 2025-04-21 23:07:40 +00:00
refac
This commit is contained in:
parent
0d019a00c9
commit
d692649bac
@ -36,11 +36,12 @@
|
|||||||
const codeId = `${id}-${codes.length}`;
|
const codeId = `${id}-${codes.length}`;
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (document.getElementById(`code-${codeId}`)) {
|
const codeElement = document.getElementById(`code-${codeId}`);
|
||||||
|
if (codeElement) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
||||||
new CodeBlock({
|
new CodeBlock({
|
||||||
target: document.getElementById(`code-${codeId}`),
|
target: codeElement,
|
||||||
props: {
|
props: {
|
||||||
id: `${id}-${codes.length}`,
|
id: `${id}-${codes.length}`,
|
||||||
lang: lang,
|
lang: lang,
|
||||||
@ -52,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
return `<div id="code-${id}-${codes.length}" />`;
|
return `<div id="code-${id}-${codes.length}"></div>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
let images = [];
|
let images = [];
|
||||||
@ -65,22 +66,29 @@
|
|||||||
images = images;
|
images = images;
|
||||||
|
|
||||||
const imageId = `${id}-${images.length}`;
|
const imageId = `${id}-${images.length}`;
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (document.getElementById(`image-${imageId}`)) {
|
const imageElement = document.getElementById(`image-${imageId}`);
|
||||||
|
if (imageElement) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
||||||
|
// If the image is already loaded, don't load it again
|
||||||
|
if (imageElement.innerHTML) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('image', href, text);
|
||||||
new Image({
|
new Image({
|
||||||
target: document.getElementById(`image-${imageId}`),
|
target: imageElement,
|
||||||
props: {
|
props: {
|
||||||
src: href,
|
src: href,
|
||||||
alt: text
|
alt: text
|
||||||
},
|
},
|
||||||
hydrate: true
|
$$inline: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
return `<div id="image-${id}-${images.length}" />`;
|
return `<div id="image-${id}-${images.length}"></div>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Open all links in a new tab/window (from https://github.com/markedjs/marked/issues/655#issuecomment-383226346)
|
// Open all links in a new tab/window (from https://github.com/markedjs/marked/issues/655#issuecomment-383226346)
|
||||||
|
Loading…
Reference in New Issue
Block a user