aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/lib/components/EditorView.svelte
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-02-07 21:36:54 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-02-07 21:36:54 +0100
commitdc415a81259dba1afdc3570c9882288940bd3c29 (patch)
tree655767587169ff47016d28dad2300d175024b336 /web/pw-server/src/lib/components/EditorView.svelte
parent4feebe50430236a331b439c31af13d0d390be805 (diff)
downloadplanetwars.dev-dc415a81259dba1afdc3570c9882288940bd3c29.tar.xz
planetwars.dev-dc415a81259dba1afdc3570c9882288940bd3c29.zip
cleanup editor code
Diffstat (limited to 'web/pw-server/src/lib/components/EditorView.svelte')
-rw-r--r--web/pw-server/src/lib/components/EditorView.svelte31
1 files changed, 31 insertions, 0 deletions
diff --git a/web/pw-server/src/lib/components/EditorView.svelte b/web/pw-server/src/lib/components/EditorView.svelte
new file mode 100644
index 0000000..c0dd109
--- /dev/null
+++ b/web/pw-server/src/lib/components/EditorView.svelte
@@ -0,0 +1,31 @@
+<script lang="ts">
+ import type { Ace } from "ace-builds";
+ import ace from "ace-builds/src-noconflict/ace?client";
+ import * as aceGithubTheme from "ace-builds/src-noconflict/theme-github?client";
+
+ import { onMount } from "svelte";
+
+ export let editSession: Ace.EditSession;
+
+ let editorDiv: HTMLDivElement | undefined;
+ let editor: Ace.Editor | undefined;
+
+ onMount(() => {
+ let renderer = new ace.VirtualRenderer(editorDiv);
+ editor = new ace.Editor(renderer, editSession);
+ editor.setTheme(aceGithubTheme);
+ });
+
+ $: if (editor !== undefined) {
+ editor.setSession(editSession);
+ }
+</script>
+
+<div bind:this={editorDiv} class="editor" />
+
+<style>
+ .editor {
+ width: 100%;
+ height: 100%;
+ }
+</style>