cleanup editor code

This commit is contained in:
Ilion Beyst 2022-02-07 21:36:54 +01:00
parent 4feebe5043
commit dc415a8125
2 changed files with 17 additions and 15 deletions

View file

@ -10,11 +10,15 @@
let editorDiv: HTMLDivElement | undefined; let editorDiv: HTMLDivElement | undefined;
let editor: Ace.Editor | undefined; let editor: Ace.Editor | undefined;
onMount(async () => { onMount(() => {
let renderer = new ace.VirtualRenderer(editorDiv); let renderer = new ace.VirtualRenderer(editorDiv);
editor = new ace.Editor(renderer, editSession); editor = new ace.Editor(renderer, editSession);
editor.setTheme(aceGithubTheme); editor.setTheme(aceGithubTheme);
}); });
$: if (editor !== undefined) {
editor.setSession(editSession);
}
</script> </script>
<div bind:this={editorDiv} class="editor" /> <div bind:this={editorDiv} class="editor" />

View file

@ -1,12 +1,12 @@
<script lang="ts"> <script lang="ts">
import { goto } from "$app/navigation";
import Visualizer from "$lib/components/Visualizer.svelte"; import Visualizer from "$lib/components/Visualizer.svelte";
import EditorView from "$lib/components/EditorView.svelte";
import { onMount } from "svelte"; import { onMount } from "svelte";
import "./style.css"; import "./style.css";
import ace from "ace-builds/src-noconflict/ace?client";
import Editor from "$lib/components/Editor.svelte";
import type { Ace } from "ace-builds"; import type { Ace } from "ace-builds";
import ace from "ace-builds/src-noconflict/ace?client";
import * as AcePythonMode from "ace-builds/src-noconflict/mode-python?client";
let matches = []; let matches = [];
@ -15,12 +15,11 @@
let editSession: Ace.EditSession; let editSession: Ace.EditSession;
onMount(async () => { onMount(() => {
await init_editor(); init_editor();
}); });
async function init_editor() { function init_editor() {
const AcePythonMode = await import("ace-builds/src-noconflict/mode-python");
editSession = new ace.EditSession(""); editSession = new ace.EditSession("");
editSession.setMode(new AcePythonMode.Mode()); editSession.setMode(new AcePythonMode.Mode());
} }
@ -85,7 +84,11 @@
</div> </div>
<ul class="match-list"> <ul class="match-list">
{#each matches as match} {#each matches as match}
<li class="match-card sidebar-item" on:click={() => selectMatch(match.matchId)}> <li
class="match-card sidebar-item"
on:click={() => selectMatch(match.matchId)}
class:selected={match.matchId === selectedMatchId}
>
<div class="match-name">{match.matchId}</div> <div class="match-name">{match.matchId}</div>
</li> </li>
{/each} {/each}
@ -95,7 +98,7 @@
{#if selectedMatchLog !== undefined} {#if selectedMatchLog !== undefined}
<Visualizer matchLog={selectedMatchLog} /> <Visualizer matchLog={selectedMatchLog} />
{:else} {:else}
<Editor {editSession} /> <EditorView {editSession} />
{/if} {/if}
</div> </div>
<div class="sidebar-right"> <div class="sidebar-right">
@ -168,11 +171,6 @@
background-color: #333; background-color: #333;
} }
.toolbar-editor {
padding: 15px;
color: #eee;
}
.match-list { .match-list {
list-style: none; list-style: none;
color: #eee; color: #eee;