Merge pull request #941 from dbgate/feature/word-wrap-option
Some checks are pending
Run tests / test-runner (push) Waiting to run

feat: add word wrap option #823
This commit is contained in:
Jan Prochazka 2024-11-21 12:20:18 +01:00 committed by GitHub
commit 477636e0d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 1 deletions

View File

@ -59,6 +59,7 @@
on:blur
bind:this={domEditor}
options={{
...$$props.options,
enableBasicAutocompletion: true,
}}
/>

View File

@ -21,6 +21,7 @@
import SqlEditor from '../query/SqlEditor.svelte';
import {
currentEditorFontSize,
currentEditorWrapEnabled,
currentEditorTheme,
currentEditorKeybindigMode,
extensions,
@ -162,6 +163,14 @@ ORDER BY
/>
</FormFieldTemplateLarge>
</div>
<div class="col-3">
<FormFieldTemplateLarge label="Enable word wrap" type="combo">
<CheckboxField
checked={$currentEditorWrapEnabled}
on:change={e => ($currentEditorWrapEnabled = e.target.checked)}
/>
</FormFieldTemplateLarge>
</div>
</div>
</svelte:fragment>
<svelte:fragment slot="2">

View File

@ -106,6 +106,9 @@ export const currentEditorTheme = getElectron()
export const currentEditorKeybindigMode = getElectron()
? writableSettingsValue(null, 'currentEditorKeybindigMode')
: writableWithStorage(null, 'currentEditorKeybindigMode');
export const currentEditorWrapEnabled = getElectron()
? writableSettingsValue(false, 'currentEditorWrapEnabled')
: writableWithStorage(false, 'currentEditorWrapEnabled');
export const currentEditorFontSize = getElectron()
? writableSettingsValue(null, 'currentEditorFontSize')
: writableWithStorage(null, 'currentEditorFontSize');

View File

@ -62,7 +62,7 @@
import VerticalSplitter from '../elements/VerticalSplitter.svelte';
import SqlEditor from '../query/SqlEditor.svelte';
import useEditorData from '../query/useEditorData';
import { extensions } from '../stores';
import { currentEditorWrapEnabled, extensions } from '../stores';
import applyScriptTemplate from '../utility/applyScriptTemplate';
import { changeTab, markTabUnsaved } from '../utility/common';
import { getDatabaseInfo, useConnectionInfo } from '../utility/metadataLoaders';
@ -154,6 +154,7 @@
$: connection = useConnectionInfo({ conid });
$: driver = findEngineDriver($connection, $extensions);
$: enableWrap = $currentEditorWrapEnabled || false;
$: effect = useEffect(() => {
return onSession(sessionId);
@ -427,6 +428,9 @@
{conid}
{database}
splitterOptions={driver?.getQuerySplitterOptions('editor')}
options={{
wrap: enableWrap,
}}
value={$editorState.value || ''}
menu={createMenu()}
on:input={e => {
@ -453,6 +457,9 @@
mode={driver?.editorMode || 'text'}
value={$editorState.value || ''}
splitterOptions={driver?.getQuerySplitterOptions('editor')}
options={{
wrap: enableWrap,
}}
menu={createMenu()}
on:input={e => setEditorData(e.detail)}
on:focus={() => {