ace editor

This commit is contained in:
Jan Prochazka
2021-03-07 10:17:05 +01:00
parent c6e95dbb6a
commit 00d5b25baa
6 changed files with 23 additions and 25 deletions

View File

@@ -40,6 +40,9 @@ body {
.bold { .bold {
font-weight: bold; font-weight: bold;
} }
.flex1 {
flex: 1;
}
.col-9 { .col-9 {
flex-basis: 75%; flex-basis: 75%;

View File

@@ -3,18 +3,6 @@ import './utility/connectionsPinger';
import './utility/changeCurrentDbByTab'; import './utility/changeCurrentDbByTab';
import './commands/stdCommands'; import './commands/stdCommands';
import 'ace-builds/src-noconflict/mode-sql';
import 'ace-builds/src-noconflict/mode-mysql';
import 'ace-builds/src-noconflict/mode-pgsql';
import 'ace-builds/src-noconflict/mode-sqlserver';
import 'ace-builds/src-noconflict/mode-json';
import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/mode-markdown';
import 'ace-builds/src-noconflict/theme-github';
import 'ace-builds/src-noconflict/theme-twilight';
import 'ace-builds/src-noconflict/ext-searchbox';
import 'ace-builds/src-noconflict/ext-language_tools';
const app = new App({ const app = new App({
target: document.body, target: document.body,
props: {}, props: {},

View File

@@ -5,12 +5,12 @@
let clientHeight; let clientHeight;
</script> </script>
<div bind:clientWidth bind:clientHeight> <div bind:clientWidth bind:clientHeight class="ace-container">
<AceEditorCore {...$$props} width={clientWidth} height={clientHeight} /> <AceEditorCore {...$$props} width={clientWidth} height={clientHeight} />
</div> </div>
<style> <style>
div { .ace-container {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;

View File

@@ -32,12 +32,15 @@
paste: string; paste: string;
}>(); }>();
export let height: number; /**
export let width: number; * translation of vue component to svelte:
* @link https://github.com/chairuosen/vue2-ace-editor/blob/91051422b36482eaf94271f1a263afa4b998f099/index.js
**/
export let value: string = ''; // String, required export let value: string = ''; // String, required
export let mode: string = 'text'; // String export let mode: string = 'text'; // String
export let theme: string = 'github'; // String export let theme: string = 'github'; // String
export let height: number;
export let width: number;
export let options: any = {}; // Object export let options: any = {}; // Object
let editor: ace.Editor; let editor: ace.Editor;
@@ -89,7 +92,7 @@
} }
}); });
$: if (height !== null && width !== null) { $: if (height != null && width != null) {
resizeOnNextTick(); resizeOnNextTick();
} }

View File

@@ -2,15 +2,20 @@
const engineToMode = { const engineToMode = {
mssql: 'sqlserver', mssql: 'sqlserver',
mysql: 'mysql', mysql: 'mysql',
postgre: 'pgsql', postgres: 'pgsql',
}; };
</script> </script>
<script lang="ts"> <script lang="ts">
import AceEditor from './AceEditorCore.svelte'; import AceEditor from './AceEditor.svelte';
export let engine; export let engine;
$: console.log('engine', engine); let mode;
$: {
const match = (engine || '').match(/^([^@]*)@/);
mode = engineToMode[match ? match[1] : engine] || 'sql';
}
</script> </script>
<AceEditor mode={engineToMode[engine] || 'sql'} /> <AceEditor {mode} />

View File

@@ -7,12 +7,11 @@
export let conid; export let conid;
export let database; export let database;
// $: connection = useConnectionInfo({ conid }); $: connection = useConnectionInfo({ conid });
// engine={$connection && $connection.engine}
</script> </script>
<VerticalSplitter> <VerticalSplitter>
<svelte:fragment slot="1"> <svelte:fragment slot="1">
<SqlEditor /> <SqlEditor engine={$connection && $connection.engine} />
</svelte:fragment> </svelte:fragment>
</VerticalSplitter> </VerticalSplitter>