diff --git a/src/lib/components/Editor/Editor.svelte b/src/lib/components/Editor/Editor.svelte index d7f7134..7083955 100644 --- a/src/lib/components/Editor/Editor.svelte +++ b/src/lib/components/Editor/Editor.svelte @@ -2,7 +2,7 @@ import type { Table } from '$lib/olap-engine'; import { sql } from '@codemirror/lang-sql'; import { Compartment, EditorState } from '@codemirror/state'; - import { EditorView, keymap, placeholder } from '@codemirror/view'; + import { EditorView, placeholder } from '@codemirror/view'; import { untrack } from 'svelte'; import './codemirror.css'; import { default_extensions, default_keymaps } from './extensions'; @@ -11,11 +11,10 @@ type Props = { value: string; - onExec?: () => unknown; tables?: Table[]; }; - let { value = $bindable(''), onExec, tables = [] }: Props = $props(); + let { value = $bindable(''), tables = [] }: Props = $props(); let container: HTMLDivElement; let editor_view: EditorView; @@ -37,16 +36,7 @@ value = update.state.doc.toString(); } }), - placeholder('Enter a query...'), - keymap.of([ - { - key: 'Mod-Enter', - run: () => { - onExec?.(); - return true; - } - } - ]) + placeholder('Enter a query...') ] }); diff --git a/src/lib/icons/XMark.svelte b/src/lib/icons/XMark.svelte new file mode 100644 index 0000000..18c0cab --- /dev/null +++ b/src/lib/icons/XMark.svelte @@ -0,0 +1,18 @@ + + + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 4129c7a..a7e213f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -9,7 +9,9 @@ import { set_app_context } from '$lib/context'; import Bars3 from '$lib/icons/Bars3.svelte'; import Play from '$lib/icons/Play.svelte'; + import Plus from '$lib/icons/Plus.svelte'; import Save from '$lib/icons/Save.svelte'; + import XMark from '$lib/icons/XMark.svelte'; import type { Table } from '$lib/olap-engine'; import { engine, type OLAPResponse } from '$lib/olap-engine'; import { history_repository, type HistoryEntry } from '$lib/repositories/history'; @@ -23,19 +25,17 @@ let loading = $state(false); async function handleExec() { + const query = current_tab.contents; if (loading || !query) { return; } loading = true; - const query_to_execute = query; - response = await engine.exec(query_to_execute).finally(() => (loading = false)); + response = await engine.exec(query).finally(() => (loading = false)); const last = await history_repository.getLast(); - if (response && last?.content !== query_to_execute) { - await addHistoryEntry(query_to_execute); - } + if (response && last?.content !== query) await addHistoryEntry(query); } let tables = $state.raw