mirror of
https://github.com/open-webui/open-webui
synced 2024-11-08 17:49:57 +00:00
35 lines
910 B
Svelte
35 lines
910 B
Svelte
|
<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" />
|