Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
d692649b
Commit
d692649b
authored
Aug 07, 2024
by
Timothy J. Baek
Browse files
refac
parent
0d019a00
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
src/lib/components/chat/Messages/MarkdownTokens.svelte
src/lib/components/chat/Messages/MarkdownTokens.svelte
+16
-8
No files found.
src/lib/components/chat/Messages/MarkdownTokens.svelte
View file @
d692649b
...
@@ -36,11 +36,12 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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.
ge
t
Element
ById(`image-${imageId}`)
,
target:
ima
geElement,
props: {
props: {
src: href,
src: href,
alt: text
alt: text
},
},
hydrat
e: true
$$inlin
e: 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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment