mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
dbeaver/pro#8427 feat: enable default fold keymap in CodeMirror (#4446)
* dbeaver/pro#8427 feat: enable default fold keymap in CodeMirror * dbeaver/pro#8427 feat: add SQL editor shortcuts for folding and unfolding code blocks --------- Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> Co-authored-by: sergeyteleshev <iamsergeyteleshev@gmail.com>
This commit is contained in:
co-authored by
Evgenia
sergeyteleshev
parent
b3127b9aa7
commit
9df99fb62e
@@ -6,7 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { defaultKeymap, indentWithTab } from '@codemirror/commands';
|
||||
import { bracketMatching, foldGutter, indentOnInput, indentUnit, syntaxHighlighting } from '@codemirror/language';
|
||||
import { bracketMatching, foldGutter, foldKeymap, indentOnInput, indentUnit, syntaxHighlighting } from '@codemirror/language';
|
||||
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
|
||||
import { Compartment, type Extension } from '@codemirror/state';
|
||||
import {
|
||||
@@ -37,6 +37,7 @@ DEFAULT_KEY_MAP.push({
|
||||
run: () => true,
|
||||
});
|
||||
DEFAULT_KEY_MAP.push(...searchKeymap);
|
||||
DEFAULT_KEY_MAP.push(...foldKeymap);
|
||||
|
||||
const defaultExtensionsFlags: IDefaultExtensions = {
|
||||
lineNumbers: false,
|
||||
|
||||
@@ -39,6 +39,28 @@ const KEY_BINDING_FIND = createKeyBinding({
|
||||
keys: ['mod+f'],
|
||||
});
|
||||
|
||||
const KEY_BINDING_SQL_EDITOR_FOLD_CODE = createKeyBinding({
|
||||
id: 'sql-editor-fold-code',
|
||||
keysMac: ['cmd+alt+['],
|
||||
keysWin: ['ctrl+shift+['],
|
||||
});
|
||||
|
||||
const KEY_BINDING_SQL_EDITOR_UNFOLD_CODE = createKeyBinding({
|
||||
id: 'sql-editor-unfold-code',
|
||||
keysMac: ['cmd+alt+]'],
|
||||
keysWin: ['ctrl+shift+]'],
|
||||
});
|
||||
|
||||
const KEY_BINDING_SQL_EDITOR_FOLD_ALL = createKeyBinding({
|
||||
id: 'sql-editor-fold-all',
|
||||
keys: ['ctrl+alt+['],
|
||||
});
|
||||
|
||||
const KEY_BINDING_SQL_EDITOR_UNFOLD_ALL = createKeyBinding({
|
||||
id: 'sql-editor-unfold-all',
|
||||
keys: ['ctrl+alt+]'],
|
||||
});
|
||||
|
||||
import type { IShortcut } from './IShortcut.js';
|
||||
|
||||
export const DATA_VIEWER_SHORTCUTS: IShortcut[] = [
|
||||
@@ -105,6 +127,22 @@ export const SQL_EDITOR_SHORTCUTS: IShortcut[] = [
|
||||
label: 'sql_editor_shortcut_format',
|
||||
code: transformKeys(KEY_BINDING_SQL_EDITOR_FORMAT),
|
||||
},
|
||||
{
|
||||
label: 'sql_editor_shortcut_fold_code',
|
||||
code: transformKeys(KEY_BINDING_SQL_EDITOR_FOLD_CODE),
|
||||
},
|
||||
{
|
||||
label: 'sql_editor_shortcut_unfold_code',
|
||||
code: transformKeys(KEY_BINDING_SQL_EDITOR_UNFOLD_CODE),
|
||||
},
|
||||
{
|
||||
label: 'sql_editor_shortcut_fold_all',
|
||||
code: transformKeys(KEY_BINDING_SQL_EDITOR_FOLD_ALL),
|
||||
},
|
||||
{
|
||||
label: 'sql_editor_shortcut_unfold_all',
|
||||
code: transformKeys(KEY_BINDING_SQL_EDITOR_UNFOLD_ALL),
|
||||
},
|
||||
{
|
||||
label: 'ui_processing_save',
|
||||
code: transformKeys(KEY_BINDING_SQL_EDITOR_SAVE_AS_SCRIPT),
|
||||
|
||||
@@ -18,6 +18,10 @@ export default [
|
||||
['sql_editor_shortcut_execute_script', 'Execute script'],
|
||||
['sql_editor_shortcut_show_execution_plan', 'Show Execution plan'],
|
||||
['sql_editor_shortcut_format', 'Format script'],
|
||||
['sql_editor_shortcut_fold_code', 'Fold code block'],
|
||||
['sql_editor_shortcut_unfold_code', 'Unfold code block'],
|
||||
['sql_editor_shortcut_fold_all', 'Fold all code blocks'],
|
||||
['sql_editor_shortcut_unfold_all', 'Unfold all code blocks'],
|
||||
['sql_editor_shortcut_open_editor_in_new_tab', 'Open SQL Editor in the separate browser Tab'],
|
||||
['sql_editor_shortcut_comment_uncomment_selection', 'Comment/Uncomment selection'],
|
||||
['sql_editor_shortcut_start_completion', 'Show autocomplete suggestions'],
|
||||
|
||||
@@ -17,6 +17,10 @@ export default [
|
||||
['sql_editor_shortcut_execute_script', 'Exécuter le script'],
|
||||
['sql_editor_shortcut_show_execution_plan', "Afficher le plan d'exécution"],
|
||||
['sql_editor_shortcut_format', 'Formater le script'],
|
||||
['sql_editor_shortcut_fold_code', 'Plier le bloc de code'],
|
||||
['sql_editor_shortcut_unfold_code', 'Déplier le bloc de code'],
|
||||
['sql_editor_shortcut_fold_all', 'Plier tous les blocs de code'],
|
||||
['sql_editor_shortcut_unfold_all', 'Déplier tous les blocs de code'],
|
||||
['sql_editor_shortcut_open_editor_in_new_tab', "Ouvrir l'éditeur SQL dans un nouvel onglet"],
|
||||
['sql_editor_shortcut_comment_uncomment_selection', 'Commenter/Décommenter la sélection'],
|
||||
['sql_editor_shortcut_start_completion', 'Afficher les suggestions de saisie semi-automatique'],
|
||||
|
||||
@@ -18,6 +18,10 @@ export default [
|
||||
['sql_editor_shortcut_execute_script', 'Execute script'],
|
||||
['sql_editor_shortcut_show_execution_plan', 'Show Execution plan'],
|
||||
['sql_editor_shortcut_format', 'Format script'],
|
||||
['sql_editor_shortcut_fold_code', 'Fold code block'],
|
||||
['sql_editor_shortcut_unfold_code', 'Unfold code block'],
|
||||
['sql_editor_shortcut_fold_all', 'Fold all code blocks'],
|
||||
['sql_editor_shortcut_unfold_all', 'Unfold all code blocks'],
|
||||
['sql_editor_shortcut_open_editor_in_new_tab', 'Open SQL Editor in the separate browser Tab'],
|
||||
['sql_editor_shortcut_comment_uncomment_selection', 'Comment/Uncomment selection'],
|
||||
['sql_editor_shortcut_start_completion', 'Show autocomplete suggestions'],
|
||||
|
||||
@@ -18,6 +18,10 @@ export default [
|
||||
['sql_editor_shortcut_execute_script', 'Выполнить скрипт'],
|
||||
['sql_editor_shortcut_show_execution_plan', 'Показать план выполнения'],
|
||||
['sql_editor_shortcut_format', 'Форматировать скрипт'],
|
||||
['sql_editor_shortcut_fold_code', 'Свернуть блок кода'],
|
||||
['sql_editor_shortcut_unfold_code', 'Развернуть блок кода'],
|
||||
['sql_editor_shortcut_fold_all', 'Свернуть все блоки кода'],
|
||||
['sql_editor_shortcut_unfold_all', 'Развернуть все блоки кода'],
|
||||
['sql_editor_shortcut_open_editor_in_new_tab', 'Открыть SQL редактор в новой бразуерной вкладке'],
|
||||
['sql_editor_shortcut_comment_uncomment_selection', 'Закомментировать/раскомментировать выделение'],
|
||||
['sql_editor_shortcut_start_completion', 'Показать подсказки автодополнения'],
|
||||
|
||||
@@ -18,6 +18,10 @@ export default [
|
||||
['sql_editor_shortcut_execute_script', 'Thực thi kịch bản'],
|
||||
['sql_editor_shortcut_show_execution_plan', 'Hiển thị kế hoạch thực thi'],
|
||||
['sql_editor_shortcut_format', 'Định dạng kịch bản'],
|
||||
['sql_editor_shortcut_fold_code', 'Thu gọn khối mã'],
|
||||
['sql_editor_shortcut_unfold_code', 'Mở rộng khối mã'],
|
||||
['sql_editor_shortcut_fold_all', 'Thu gọn tất cả khối mã'],
|
||||
['sql_editor_shortcut_unfold_all', 'Mở rộng tất cả khối mã'],
|
||||
['sql_editor_shortcut_open_editor_in_new_tab', 'Mở Trình chỉnh sửa SQL trong tab riêng biệt'],
|
||||
['sql_editor_shortcut_comment_uncomment_selection', 'Bình luận/Bỏ bình luận lựa chọn'],
|
||||
['sql_editor_shortcut_start_completion', 'Hiển thị gợi ý tự động hoàn thành'],
|
||||
|
||||
@@ -18,6 +18,10 @@ export default [
|
||||
['sql_editor_shortcut_execute_script', '执行脚本'],
|
||||
['sql_editor_shortcut_show_execution_plan', '显示执行计划'],
|
||||
['sql_editor_shortcut_format', '格式化脚本'],
|
||||
['sql_editor_shortcut_fold_code', '折叠代码块'],
|
||||
['sql_editor_shortcut_unfold_code', '展开代码块'],
|
||||
['sql_editor_shortcut_fold_all', '折叠所有代码块'],
|
||||
['sql_editor_shortcut_unfold_all', '展开所有代码块'],
|
||||
['sql_editor_shortcut_open_editor_in_new_tab', '在单独的浏览器标签下打开SQL编辑器'],
|
||||
['sql_editor_shortcut_comment_uncomment_selection', '注释/取消注释所选内容'],
|
||||
['sql_editor_shortcut_start_completion', '显示自动完成建议'],
|
||||
|
||||
Reference in New Issue
Block a user