mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
[CB] Support real tab characters in SQL Editor (#4298)
* dbeaver/pro#7864 adds tabulation with actual tab indent for code mirror * adds EDITOR_INDENT_UNIT to unify indent for sql editor and vqb
This commit is contained in:
@@ -37,6 +37,7 @@ export const Editor = observer<IEditorProps & IDefaultExtensions, IEditorRef>(
|
||||
keymap,
|
||||
lineWrapping,
|
||||
search,
|
||||
tabIndentation,
|
||||
...rest
|
||||
},
|
||||
ref,
|
||||
@@ -61,6 +62,7 @@ export const Editor = observer<IEditorProps & IDefaultExtensions, IEditorRef>(
|
||||
keymap,
|
||||
lineWrapping,
|
||||
search,
|
||||
tabIndentation,
|
||||
});
|
||||
|
||||
extensions.set(...defaultExtensions);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2025 DBeaver Corp and others
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { defaultKeymap, indentWithTab } from '@codemirror/commands';
|
||||
import { bracketMatching, foldGutter, indentOnInput, syntaxHighlighting } from '@codemirror/language';
|
||||
import { bracketMatching, foldGutter, indentOnInput, indentUnit, syntaxHighlighting } from '@codemirror/language';
|
||||
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
|
||||
import { Compartment, type Extension } from '@codemirror/state';
|
||||
import {
|
||||
@@ -29,6 +29,7 @@ import { clsx } from '@dbeaver/ui-kit';
|
||||
|
||||
// @TODO allow to configure bindings outside of the component
|
||||
const DEFAULT_KEY_MAP = defaultKeymap.filter(binding => binding.mac !== 'Ctrl-f' && binding.key !== 'Mod-Enter');
|
||||
export const EDITOR_INDENT_UNIT = '\t';
|
||||
|
||||
DEFAULT_KEY_MAP.push(indentWithTab);
|
||||
DEFAULT_KEY_MAP.push({
|
||||
@@ -54,6 +55,7 @@ const defaultExtensionsFlags: IDefaultExtensions = {
|
||||
keymap: true,
|
||||
lineWrapping: false,
|
||||
search: true,
|
||||
tabIndentation: true,
|
||||
};
|
||||
|
||||
export interface IDefaultExtensions {
|
||||
@@ -73,6 +75,7 @@ export interface IDefaultExtensions {
|
||||
keymap?: boolean;
|
||||
lineWrapping?: boolean;
|
||||
search?: boolean;
|
||||
tabIndentation?: boolean;
|
||||
}
|
||||
|
||||
const extensionMap = {
|
||||
@@ -109,6 +112,7 @@ const extensionMap = {
|
||||
rectangularSelection,
|
||||
keymap: () => keymap.of(DEFAULT_KEY_MAP),
|
||||
lineWrapping: () => EditorView.lineWrapping,
|
||||
tabIndentation: () => indentUnit.of(EDITOR_INDENT_UNIT),
|
||||
};
|
||||
|
||||
const DEFAULT_EXTENSIONS_COMPARTMENT = new Compartment();
|
||||
|
||||
Reference in New Issue
Block a user