mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat: tools page
This commit is contained in:
34
src/lib/components/common/CodeEditor.svelte
Normal file
34
src/lib/components/common/CodeEditor.svelte
Normal file
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { basicSetup, EditorView } from 'codemirror';
|
||||
import { keymap, placeholder } from '@codemirror/view';
|
||||
import { EditorState } from '@codemirror/state';
|
||||
|
||||
import { acceptCompletion } from '@codemirror/autocomplete';
|
||||
import { indentWithTab } from '@codemirror/commands';
|
||||
|
||||
import { python } from '@codemirror/lang-python';
|
||||
import { oneDark } from '@codemirror/theme-one-dark';
|
||||
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let value = '';
|
||||
|
||||
onMount(() => {
|
||||
// python code editor, highlight python code
|
||||
const codeEditor = new EditorView({
|
||||
state: EditorState.create({
|
||||
doc: value,
|
||||
extensions: [
|
||||
basicSetup,
|
||||
keymap.of([{ key: 'Tab', run: acceptCompletion }, indentWithTab]),
|
||||
python(),
|
||||
oneDark,
|
||||
placeholder('Enter your code here...')
|
||||
]
|
||||
}),
|
||||
parent: document.getElementById('code-textarea')
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="code-textarea" />
|
||||
Reference in New Issue
Block a user