From dc415a81259dba1afdc3570c9882288940bd3c29 Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Mon, 7 Feb 2022 21:36:54 +0100
Subject: cleanup editor code

---
 web/pw-server/src/lib/components/EditorView.svelte | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 web/pw-server/src/lib/components/EditorView.svelte

(limited to 'web/pw-server/src/lib/components/EditorView.svelte')

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>
-- 
cgit v1.2.3

