feat(editor): add toggle fold shortcut
This commit is contained in:
1 parent
1a6e00acbb
commit
b1f0784d49
11 files changed
+21
-1
No files matched your search
@@ -821,6 +821,7 @@ const formatterEditorShortcutIds: ShortcutActionId[] = [
|
|||||||
"selectAll",
|
"selectAll",
|
||||||
"uppercaseSelection",
|
"uppercaseSelection",
|
||||||
"lowercaseSelection",
|
"lowercaseSelection",
|
||||||
|
"toggleFold",
|
||||||
];
|
];
|
||||||
const formatterEditorShortcutDefinitions = computed(() => formatterEditorShortcutIds.map((id) => SHORTCUT_DEFINITIONS.find((definition) => definition.id === id)).filter((definition): definition is (typeof SHORTCUT_DEFINITIONS)[number] => !!definition));
|
const formatterEditorShortcutDefinitions = computed(() => formatterEditorShortcutIds.map((id) => SHORTCUT_DEFINITIONS.find((definition) => definition.id === id)).filter((definition): definition is (typeof SHORTCUT_DEFINITIONS)[number] => !!definition));
|
||||||
const filteredShortcutDefinitions = computed(() => {
|
const filteredShortcutDefinitions = computed(() => {
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ let codeMirrorRedo: typeof import("@codemirror/commands").redo | null = null;
|
|||||||
let codeMirrorSelectAll: typeof import("@codemirror/commands").selectAll | null = null;
|
let codeMirrorSelectAll: typeof import("@codemirror/commands").selectAll | null = null;
|
||||||
let codeMirrorInsertNewlineKeepIndent: typeof import("@codemirror/commands").insertNewlineKeepIndent | null = null;
|
let codeMirrorInsertNewlineKeepIndent: typeof import("@codemirror/commands").insertNewlineKeepIndent | null = null;
|
||||||
let codeMirrorToggleLineComment: typeof import("@codemirror/commands").toggleLineComment | null = null;
|
let codeMirrorToggleLineComment: typeof import("@codemirror/commands").toggleLineComment | null = null;
|
||||||
|
let codeMirrorToggleFold: typeof import("@codemirror/language").toggleFold | null = null;
|
||||||
let pendingCompletionTabTimer: ReturnType<typeof setTimeout> | null = null;
|
let pendingCompletionTabTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
let setSqlDiagnosticsEffect: import("@codemirror/state").StateEffectType<SqlSemanticDiagnostic[]> | null = null;
|
let setSqlDiagnosticsEffect: import("@codemirror/state").StateEffectType<SqlSemanticDiagnostic[]> | null = null;
|
||||||
let setPreviewRangeEffect:
|
let setPreviewRangeEffect:
|
||||||
@@ -1395,6 +1396,7 @@ function runKeymapExtension(codeMirrorKeymap: (typeof import("@codemirror/view")
|
|||||||
...binding(shortcuts.uppercaseSelection, () => convertSelectedSqlCase("upper")),
|
...binding(shortcuts.uppercaseSelection, () => convertSelectedSqlCase("upper")),
|
||||||
...binding(shortcuts.lowercaseSelection, () => convertSelectedSqlCase("lower")),
|
...binding(shortcuts.lowercaseSelection, () => convertSelectedSqlCase("lower")),
|
||||||
...binding(shortcuts.toggleLineComment, (view) => codeMirrorToggleLineComment?.(view) ?? false),
|
...binding(shortcuts.toggleLineComment, (view) => codeMirrorToggleLineComment?.(view) ?? false),
|
||||||
|
...binding(shortcuts.toggleFold, (view) => codeMirrorToggleFold?.(view) ?? false),
|
||||||
...binding(shortcuts.exPasteSqlInCondition, () => {
|
...binding(shortcuts.exPasteSqlInCondition, () => {
|
||||||
if (!supportsSqlInListPaste(props.databaseType)) return false;
|
if (!supportsSqlInListPaste(props.databaseType)) return false;
|
||||||
void pasteClipboardAsSqlInCondition();
|
void pasteClipboardAsSqlInCondition();
|
||||||
@@ -3392,7 +3394,7 @@ onMounted(async () => {
|
|||||||
langSql,
|
langSql,
|
||||||
{ autocompletion, startCompletion, acceptCompletion, closeBrackets, closeBracketsKeymap, snippetCompletion, completionStatus, completionKeymap, insertCompletionText, nextSnippetField },
|
{ autocompletion, startCompletion, acceptCompletion, closeBrackets, closeBracketsKeymap, snippetCompletion, completionStatus, completionKeymap, insertCompletionText, nextSnippetField },
|
||||||
{ copyLineDown, copyLineUp, deleteLine, indentLess, indentMore, insertNewlineKeepIndent, moveLineDown, moveLineUp, redo, selectAll, undo, toggleLineComment, history, defaultKeymap, historyKeymap },
|
{ copyLineDown, copyLineUp, deleteLine, indentLess, indentMore, insertNewlineKeepIndent, moveLineDown, moveLineUp, redo, selectAll, undo, toggleLineComment, history, defaultKeymap, historyKeymap },
|
||||||
{ bracketMatching, foldGutter, indentOnInput, indentUnit, syntaxHighlighting, defaultHighlightStyle, foldKeymap, ensureSyntaxTree },
|
{ bracketMatching, foldGutter, indentOnInput, indentUnit, syntaxHighlighting, defaultHighlightStyle, foldKeymap, toggleFold, ensureSyntaxTree },
|
||||||
{ searchKeymap },
|
{ searchKeymap },
|
||||||
] = await Promise.all([import("@codemirror/view"), import("@codemirror/state"), import("@codemirror/lang-sql"), import("@codemirror/autocomplete"), import("@codemirror/commands"), import("@codemirror/language"), import("@codemirror/search")]);
|
] = await Promise.all([import("@codemirror/view"), import("@codemirror/state"), import("@codemirror/lang-sql"), import("@codemirror/autocomplete"), import("@codemirror/commands"), import("@codemirror/language"), import("@codemirror/search")]);
|
||||||
editorViewModule = {
|
editorViewModule = {
|
||||||
@@ -3439,6 +3441,7 @@ onMounted(async () => {
|
|||||||
codeMirrorSelectAll = selectAll;
|
codeMirrorSelectAll = selectAll;
|
||||||
codeMirrorInsertNewlineKeepIndent = insertNewlineKeepIndent;
|
codeMirrorInsertNewlineKeepIndent = insertNewlineKeepIndent;
|
||||||
codeMirrorToggleLineComment = toggleLineComment;
|
codeMirrorToggleLineComment = toggleLineComment;
|
||||||
|
codeMirrorToggleFold = toggleFold;
|
||||||
codeMirrorIndentUnit = indentUnit;
|
codeMirrorIndentUnit = indentUnit;
|
||||||
window.addEventListener("keyup", clearTableNavigationHoverOnModifierRelease);
|
window.addEventListener("keyup", clearTableNavigationHoverOnModifierRelease);
|
||||||
window.addEventListener("blur", clearTableNavigationHover);
|
window.addEventListener("blur", clearTableNavigationHover);
|
||||||
|
|||||||
@@ -4642,6 +4642,7 @@ export default {
|
|||||||
shortcutEditSidebarConnection: "Edit sidebar connection",
|
shortcutEditSidebarConnection: "Edit sidebar connection",
|
||||||
shortcutOpenDataInNewTab: "Open data in new tab (mouse click)",
|
shortcutOpenDataInNewTab: "Open data in new tab (mouse click)",
|
||||||
shortcutSendSelectionToAi: "Send selection to AI",
|
shortcutSendSelectionToAi: "Send selection to AI",
|
||||||
|
shortcutToggleFold: "Toggle fold",
|
||||||
shortcutScopeGlobal: "Global",
|
shortcutScopeGlobal: "Global",
|
||||||
shortcutScopeEditor: "SQL editor",
|
shortcutScopeEditor: "SQL editor",
|
||||||
shortcutScopeGrid: "Data grid",
|
shortcutScopeGrid: "Data grid",
|
||||||
|
|||||||
@@ -4397,6 +4397,7 @@ export default withEnglishFallback({
|
|||||||
shortcutEditSidebarConnection: "Editar conexión de la barra lateral",
|
shortcutEditSidebarConnection: "Editar conexión de la barra lateral",
|
||||||
shortcutOpenDataInNewTab: "Abrir datos en una pestaña nueva (clic del ratón)",
|
shortcutOpenDataInNewTab: "Abrir datos en una pestaña nueva (clic del ratón)",
|
||||||
shortcutSendSelectionToAi: "Enviar selección a IA",
|
shortcutSendSelectionToAi: "Enviar selección a IA",
|
||||||
|
shortcutToggleFold: "Contraer/expandir código",
|
||||||
shortcutScopeGlobal: "Global",
|
shortcutScopeGlobal: "Global",
|
||||||
shortcutScopeEditor: "Editor SQL",
|
shortcutScopeEditor: "Editor SQL",
|
||||||
shortcutScopeGrid: "Cuadrícula de datos",
|
shortcutScopeGrid: "Cuadrícula de datos",
|
||||||
|
|||||||
@@ -4395,6 +4395,7 @@ export default withEnglishFallback({
|
|||||||
shortcutEditSidebarConnection: "Modifica connessione barra laterale",
|
shortcutEditSidebarConnection: "Modifica connessione barra laterale",
|
||||||
shortcutOpenDataInNewTab: "Apri dati in una nuova scheda (clic del mouse)",
|
shortcutOpenDataInNewTab: "Apri dati in una nuova scheda (clic del mouse)",
|
||||||
shortcutSendSelectionToAi: "Invia selezione ad AI",
|
shortcutSendSelectionToAi: "Invia selezione ad AI",
|
||||||
|
shortcutToggleFold: "Comprimi/espandi codice",
|
||||||
shortcutScopeGlobal: "Globale",
|
shortcutScopeGlobal: "Globale",
|
||||||
shortcutScopeEditor: "Editor SQL",
|
shortcutScopeEditor: "Editor SQL",
|
||||||
shortcutScopeGrid: "Griglia dati",
|
shortcutScopeGrid: "Griglia dati",
|
||||||
|
|||||||
@@ -4379,6 +4379,7 @@ export default withEnglishFallback({
|
|||||||
shortcutEditSidebarConnection: "サイドバー接続を編集",
|
shortcutEditSidebarConnection: "サイドバー接続を編集",
|
||||||
shortcutOpenDataInNewTab: "新しいデータタブで開く(マウスクリック)",
|
shortcutOpenDataInNewTab: "新しいデータタブで開く(マウスクリック)",
|
||||||
shortcutSendSelectionToAi: "選択範囲をAIに送信",
|
shortcutSendSelectionToAi: "選択範囲をAIに送信",
|
||||||
|
shortcutToggleFold: "折りたたみの切り替え",
|
||||||
shortcutScopeGlobal: "グローバル",
|
shortcutScopeGlobal: "グローバル",
|
||||||
shortcutScopeEditor: "SQLエディタ",
|
shortcutScopeEditor: "SQLエディタ",
|
||||||
shortcutScopeGrid: "データグリッド",
|
shortcutScopeGrid: "データグリッド",
|
||||||
|
|||||||
@@ -4397,6 +4397,7 @@ export default withEnglishFallback({
|
|||||||
shortcutEditSidebarConnection: "Editar conexão da barra lateral",
|
shortcutEditSidebarConnection: "Editar conexão da barra lateral",
|
||||||
shortcutOpenDataInNewTab: "Abrir dados em nova aba (clique do mouse)",
|
shortcutOpenDataInNewTab: "Abrir dados em nova aba (clique do mouse)",
|
||||||
shortcutSendSelectionToAi: "Enviar seleção para IA",
|
shortcutSendSelectionToAi: "Enviar seleção para IA",
|
||||||
|
shortcutToggleFold: "Recolher/expandir código",
|
||||||
shortcutScopeGlobal: "Global",
|
shortcutScopeGlobal: "Global",
|
||||||
shortcutScopeEditor: "Editor SQL",
|
shortcutScopeEditor: "Editor SQL",
|
||||||
shortcutScopeGrid: "Grade de dados",
|
shortcutScopeGrid: "Grade de dados",
|
||||||
|
|||||||
@@ -4644,6 +4644,7 @@ export default withEnglishFallback({
|
|||||||
shortcutEditSidebarConnection: "编辑侧边栏连接",
|
shortcutEditSidebarConnection: "编辑侧边栏连接",
|
||||||
shortcutOpenDataInNewTab: "在新数据标签页中打开(鼠标点击)",
|
shortcutOpenDataInNewTab: "在新数据标签页中打开(鼠标点击)",
|
||||||
shortcutSendSelectionToAi: "发送选中代码到 AI",
|
shortcutSendSelectionToAi: "发送选中代码到 AI",
|
||||||
|
shortcutToggleFold: "切换折叠",
|
||||||
shortcutScopeGlobal: "全局",
|
shortcutScopeGlobal: "全局",
|
||||||
shortcutScopeEditor: "SQL 编辑器",
|
shortcutScopeEditor: "SQL 编辑器",
|
||||||
shortcutScopeGrid: "数据表格",
|
shortcutScopeGrid: "数据表格",
|
||||||
|
|||||||
@@ -4052,6 +4052,7 @@ export default withEnglishFallback({
|
|||||||
shortcutEditSidebarConnection: "編輯側邊欄連線",
|
shortcutEditSidebarConnection: "編輯側邊欄連線",
|
||||||
shortcutOpenDataInNewTab: "在新資料分頁中開啟(滑鼠點擊)",
|
shortcutOpenDataInNewTab: "在新資料分頁中開啟(滑鼠點擊)",
|
||||||
shortcutSendSelectionToAi: "傳送選取程式碼至 AI",
|
shortcutSendSelectionToAi: "傳送選取程式碼至 AI",
|
||||||
|
shortcutToggleFold: "切換折疊",
|
||||||
shortcutScopeGlobal: "全域",
|
shortcutScopeGlobal: "全域",
|
||||||
shortcutScopeEditor: "SQL 編輯器",
|
shortcutScopeEditor: "SQL 編輯器",
|
||||||
shortcutScopeGrid: "資料表格",
|
shortcutScopeGrid: "資料表格",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ describe("shortcutRegistry editor actions", () => {
|
|||||||
"uppercaseSelection",
|
"uppercaseSelection",
|
||||||
"lowercaseSelection",
|
"lowercaseSelection",
|
||||||
"exPasteSqlInCondition",
|
"exPasteSqlInCondition",
|
||||||
|
"toggleFold",
|
||||||
];
|
];
|
||||||
const sidebarShortcutActionIds: ShortcutActionId[] = ["copySidebarSelection", "pasteSidebarSelection", "editSidebarConnection"];
|
const sidebarShortcutActionIds: ShortcutActionId[] = ["copySidebarSelection", "pasteSidebarSelection", "editSidebarConnection"];
|
||||||
|
|
||||||
@@ -100,6 +101,7 @@ describe("shortcutRegistry editor actions", () => {
|
|||||||
expect(shortcuts.uppercaseSelection).toBe("Shift+Alt+U");
|
expect(shortcuts.uppercaseSelection).toBe("Shift+Alt+U");
|
||||||
expect(shortcuts.lowercaseSelection).toBe("Shift+Alt+L");
|
expect(shortcuts.lowercaseSelection).toBe("Shift+Alt+L");
|
||||||
expect(shortcuts.exPasteSqlInCondition).toBe("");
|
expect(shortcuts.exPasteSqlInCondition).toBe("");
|
||||||
|
expect(shortcuts.toggleFold).toBe("Mod+.");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("detects conflicts between formatter editor shortcuts and other editor shortcuts", () => {
|
it("detects conflicts between formatter editor shortcuts and other editor shortcuts", () => {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export type ShortcutActionId =
|
|||||||
| "uppercaseSelection"
|
| "uppercaseSelection"
|
||||||
| "lowercaseSelection"
|
| "lowercaseSelection"
|
||||||
| "exPasteSqlInCondition"
|
| "exPasteSqlInCondition"
|
||||||
|
| "toggleFold"
|
||||||
| "copyCurrentRow"
|
| "copyCurrentRow"
|
||||||
| "deleteCurrentRow"
|
| "deleteCurrentRow"
|
||||||
| "newQuery"
|
| "newQuery"
|
||||||
@@ -202,6 +203,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
|
|||||||
scope: "editor",
|
scope: "editor",
|
||||||
defaultShortcut: "",
|
defaultShortcut: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "toggleFold",
|
||||||
|
labelKey: "settings.shortcutToggleFold",
|
||||||
|
scope: "editor",
|
||||||
|
defaultShortcut: "Mod+.",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "copyCurrentRow",
|
id: "copyCurrentRow",
|
||||||
labelKey: "settings.shortcutCopyCurrentRow",
|
labelKey: "settings.shortcutCopyCurrentRow",
|
||||||
|
|||||||
Reference in new issue
Block a user