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
d388c203
Commit
d388c203
authored
Aug 08, 2024
by
Timothy J. Baek
Browse files
enh: codeblock i18n
parent
13403cd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
src/lib/components/chat/Messages/CodeBlock.svelte
src/lib/components/chat/Messages/CodeBlock.svelte
+3
-3
src/lib/components/chat/Messages/MarkdownTokens.svelte
src/lib/components/chat/Messages/MarkdownTokens.svelte
+7
-3
No files found.
src/lib/components/chat/Messages/CodeBlock.svelte
View file @
d388c203
<script lang="ts">
import hljs from 'highlight.js';
import { loadPyodide } from 'pyodide';
import { getContext } from 'svelte';
import { getContext
, getAllContexts
} from 'svelte';
import { copyToClipboard } from '$lib/utils';
import 'highlight.js/styles/github-dark.min.css';
...
...
@@ -236,12 +236,12 @@ __builtins__.input = input`);
class="copy-code-button bg-none border-none p-1"
on:click={() => {
executePython(code);
}}>
Run
</button
}}>
{$i18n.t('Run')}
</button
>
{/if}
{/if}
<button class="copy-code-button bg-none border-none p-1" on:click={copyCode}
>{copied ? 'Copied' : 'Copy Code'}</button
>{copied ?
$i18n.t(
'Copied'
)
:
$i18n.t(
'Copy Code'
)
}</button
>
</div>
</div>
...
...
src/lib/components/chat/Messages/MarkdownTokens.svelte
View file @
d388c203
...
...
@@ -3,7 +3,10 @@
import type { Token } from 'marked';
import { revertSanitizedResponseContent, unescapeHtml } from '$lib/utils';
import { onMount } from 'svelte';
import { onMount, getContext, getAllContexts } from 'svelte';
const context = getAllContexts();
const i18n = getContext('i18n');
import Image from '$lib/components/common/Image.svelte';
import CodeBlock from '$lib/components/chat/Messages/CodeBlock.svelte';
...
...
@@ -44,7 +47,7 @@
return;
}
new CodeBlock({
const element =
new CodeBlock({
target: codeElement,
props: {
id: `${id}-${codes.length}`,
...
...
@@ -52,7 +55,8 @@
code: revertSanitizedResponseContent(code)
},
hydrate: true,
$$inline: true
$$inline: true,
context: context
});
}
}, 10);
...
...
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