mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 16:46:00 +00:00
editor font size settings
This commit is contained in:
@@ -37,6 +37,19 @@
|
|||||||
'tomorrow_night',
|
'tomorrow_night',
|
||||||
'twilight',
|
'twilight',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const FONT_SIZES = [
|
||||||
|
{ label: '8', value: '8' },
|
||||||
|
{ label: '9', value: '9' },
|
||||||
|
{ label: '10', value: '10' },
|
||||||
|
{ label: '11', value: '11' },
|
||||||
|
{ label: '12 - Normal', value: '12' },
|
||||||
|
{ label: '13', value: '13' },
|
||||||
|
{ label: '14', value: '14' },
|
||||||
|
{ label: '15', value: '15' },
|
||||||
|
{ label: '16', value: '16' },
|
||||||
|
{ label: '17', value: '17' },
|
||||||
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -101,7 +114,7 @@
|
|||||||
import 'ace-builds/src-noconflict/theme-tomorrow_night';
|
import 'ace-builds/src-noconflict/theme-tomorrow_night';
|
||||||
import 'ace-builds/src-noconflict/theme-twilight';
|
import 'ace-builds/src-noconflict/theme-twilight';
|
||||||
|
|
||||||
import { currentDropDownMenu, currentEditorTheme, currentThemeDefinition } from '../stores';
|
import { currentDropDownMenu, currentEditorFontSize, currentEditorTheme, currentThemeDefinition } from '../stores';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { handleCommandKeyDown } from '../commands/CommandListener.svelte';
|
import { handleCommandKeyDown } from '../commands/CommandListener.svelte';
|
||||||
import resizeObserver from '../utility/resizeObserver';
|
import resizeObserver from '../utility/resizeObserver';
|
||||||
@@ -149,11 +162,14 @@
|
|||||||
|
|
||||||
let queryParserWorker;
|
let queryParserWorker;
|
||||||
|
|
||||||
|
let defaultFontSize;
|
||||||
|
|
||||||
const stdOptions = {
|
const stdOptions = {
|
||||||
showPrintMargin: false,
|
showPrintMargin: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
$: theme = $currentEditorTheme || ($currentThemeDefinition?.themeType == 'dark' ? 'merbivore' : 'github');
|
$: theme = $currentEditorTheme || ($currentThemeDefinition?.themeType == 'dark' ? 'merbivore' : 'github');
|
||||||
|
$: watchEditorFontSize($currentEditorFontSize);
|
||||||
|
|
||||||
export function getEditor(): ace.Editor {
|
export function getEditor(): ace.Editor {
|
||||||
return editor;
|
return editor;
|
||||||
@@ -187,6 +203,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function watchEditorFontSize(value) {
|
||||||
|
if (editor) {
|
||||||
|
editor.setFontSize(value ? parseInt(value) : defaultFontSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: watchTheme(theme);
|
$: watchTheme(theme);
|
||||||
function watchTheme(newTheme: string) {
|
function watchTheme(newTheme: string) {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
@@ -400,6 +422,10 @@
|
|||||||
contentBackup = content;
|
contentBackup = content;
|
||||||
changedQueryParts();
|
changedQueryParts();
|
||||||
});
|
});
|
||||||
|
defaultFontSize = editor.getFontSize();
|
||||||
|
if ($currentEditorFontSize) {
|
||||||
|
editor.setFontSize($currentEditorFontSize);
|
||||||
|
}
|
||||||
|
|
||||||
editor.on('changeSelection', () => {
|
editor.on('changeSelection', () => {
|
||||||
changedCurrentQueryPart();
|
changedCurrentQueryPart();
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
import ModalBase from '../modals/ModalBase.svelte';
|
import ModalBase from '../modals/ModalBase.svelte';
|
||||||
import { closeCurrentModal } from '../modals/modalTools';
|
import { closeCurrentModal } from '../modals/modalTools';
|
||||||
import { EDITOR_THEMES } from '../query/AceEditor.svelte';
|
import { EDITOR_THEMES, FONT_SIZES } from '../query/AceEditor.svelte';
|
||||||
import SqlEditor from '../query/SqlEditor.svelte';
|
import SqlEditor from '../query/SqlEditor.svelte';
|
||||||
import { currentEditorTheme, extensions } from '../stores';
|
import { currentEditorFontSize, currentEditorTheme, extensions } from '../stores';
|
||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
import ThemeSkeleton from './ThemeSkeleton.svelte';
|
import ThemeSkeleton from './ThemeSkeleton.svelte';
|
||||||
|
|
||||||
@@ -106,15 +106,31 @@ ORDER BY
|
|||||||
|
|
||||||
<div class="heading">Editor theme</div>
|
<div class="heading">Editor theme</div>
|
||||||
|
|
||||||
<FormFieldTemplateLarge label="Theme" type='combo'>
|
<div class="flex">
|
||||||
<SelectField
|
<div class="col-6">
|
||||||
isNative
|
<FormFieldTemplateLarge label="Theme" type="combo">
|
||||||
notSelected="(use theme default)"
|
<SelectField
|
||||||
options={EDITOR_THEMES.map(theme => ({ label: theme, value: theme }))}
|
isNative
|
||||||
value={$currentEditorTheme}
|
notSelected="(use theme default)"
|
||||||
on:change={e => ($currentEditorTheme = e.detail)}
|
options={EDITOR_THEMES.map(theme => ({ label: theme, value: theme }))}
|
||||||
/>
|
value={$currentEditorTheme}
|
||||||
</FormFieldTemplateLarge>
|
on:change={e => ($currentEditorTheme = e.detail)}
|
||||||
|
/>
|
||||||
|
</FormFieldTemplateLarge>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6">
|
||||||
|
<FormFieldTemplateLarge label="Font size " type="combo">
|
||||||
|
<SelectField
|
||||||
|
isNative
|
||||||
|
notSelected="(default)"
|
||||||
|
options={FONT_SIZES}
|
||||||
|
value={$currentEditorFontSize}
|
||||||
|
on:change={e => ($currentEditorFontSize = e.detail)}
|
||||||
|
/>
|
||||||
|
</FormFieldTemplateLarge>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="editor">
|
<div class="editor">
|
||||||
<SqlEditor value={sqlPreview} readOnly />
|
<SqlEditor value={sqlPreview} readOnly />
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ export const currentTheme = getElectron()
|
|||||||
export const currentEditorTheme = getElectron()
|
export const currentEditorTheme = getElectron()
|
||||||
? writableSettingsValue(null, 'currentEditorTheme')
|
? writableSettingsValue(null, 'currentEditorTheme')
|
||||||
: writableWithStorage(null, 'currentEditorTheme');
|
: writableWithStorage(null, 'currentEditorTheme');
|
||||||
|
export const currentEditorFontSize = getElectron()
|
||||||
|
? writableSettingsValue(null, 'currentEditorFontSize')
|
||||||
|
: writableWithStorage(null, 'currentEditorFontSize');
|
||||||
export const activeTabId = derived([openedTabs], ([$openedTabs]) => $openedTabs.find(x => x.selected)?.tabid);
|
export const activeTabId = derived([openedTabs], ([$openedTabs]) => $openedTabs.find(x => x.selected)?.tabid);
|
||||||
export const activeTab = derived([openedTabs], ([$openedTabs]) => $openedTabs.find(x => x.selected));
|
export const activeTab = derived([openedTabs], ([$openedTabs]) => $openedTabs.find(x => x.selected));
|
||||||
export const recentDatabases = writableWithStorage([], 'recentDatabases');
|
export const recentDatabases = writableWithStorage([], 'recentDatabases');
|
||||||
|
|||||||
Reference in New Issue
Block a user