diff --git a/webapp/packages/plugin-codemirror6/src/useEditorDefaultExtensions.ts b/webapp/packages/plugin-codemirror6/src/useEditorDefaultExtensions.ts index a48b3e3a41..13fb53626e 100644 --- a/webapp/packages/plugin-codemirror6/src/useEditorDefaultExtensions.ts +++ b/webapp/packages/plugin-codemirror6/src/useEditorDefaultExtensions.ts @@ -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, diff --git a/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts b/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts index 8a54274077..20b7ae8863 100644 --- a/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts +++ b/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts @@ -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), diff --git a/webapp/packages/plugin-help/src/locales/en.ts b/webapp/packages/plugin-help/src/locales/en.ts index 732beb88ed..69972606d3 100644 --- a/webapp/packages/plugin-help/src/locales/en.ts +++ b/webapp/packages/plugin-help/src/locales/en.ts @@ -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'], diff --git a/webapp/packages/plugin-help/src/locales/fr.ts b/webapp/packages/plugin-help/src/locales/fr.ts index f333d76387..317794312f 100644 --- a/webapp/packages/plugin-help/src/locales/fr.ts +++ b/webapp/packages/plugin-help/src/locales/fr.ts @@ -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'], diff --git a/webapp/packages/plugin-help/src/locales/it.ts b/webapp/packages/plugin-help/src/locales/it.ts index 00438fc1d9..5bcfa8b111 100644 --- a/webapp/packages/plugin-help/src/locales/it.ts +++ b/webapp/packages/plugin-help/src/locales/it.ts @@ -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'], diff --git a/webapp/packages/plugin-help/src/locales/ru.ts b/webapp/packages/plugin-help/src/locales/ru.ts index 9a5283e886..f1d41333fb 100644 --- a/webapp/packages/plugin-help/src/locales/ru.ts +++ b/webapp/packages/plugin-help/src/locales/ru.ts @@ -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', 'Показать подсказки автодополнения'], diff --git a/webapp/packages/plugin-help/src/locales/vi.ts b/webapp/packages/plugin-help/src/locales/vi.ts index 7c25033a49..bdf243c59c 100644 --- a/webapp/packages/plugin-help/src/locales/vi.ts +++ b/webapp/packages/plugin-help/src/locales/vi.ts @@ -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'], diff --git a/webapp/packages/plugin-help/src/locales/zh.ts b/webapp/packages/plugin-help/src/locales/zh.ts index 001d796714..2530d823ac 100644 --- a/webapp/packages/plugin-help/src/locales/zh.ts +++ b/webapp/packages/plugin-help/src/locales/zh.ts @@ -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', '显示自动完成建议'],