@@ -34,6 +34,7 @@ const loadingStores = ref(true)
3434const globalLoading = ref (false )
3535const showOverflowTooltip = ref (true )
3636const complexEditor = ref (false )
37+ const sqlEditorView = ref (null as any )
3738const dataFormat = ref (' table' )
3839const dataFormatOptions = [' table' , ' json' ]
3940const queryDataMeta = ref ({} as QueryDataMeta )
@@ -293,18 +294,29 @@ watch(largeContent, (e) => {
293294 largeContentDialogVisible .value = e !== ' '
294295})
295296
296- Magic .AdvancedKeys ([{
297- Keys: [' Ctrl+E' , ' Ctrl+Enter' ],
298- Func: executeQuery ,
299- Description: ' Execute query'
300- }, {
301- Keys: [' Ctrl+Shift+O' ],
302- Func : () => {
297+ const sqlEditorReady = (editor : any ) => {
298+ sqlEditorView .value = editor .view
299+ }
300+
301+ const executeWithSelectedQuery = () => {
302+ const selectedTextObj = sqlEditorView .value .state .selection .main
303+ const selectedText = sqlEditorView .value .state .sliceDoc (selectedTextObj .from , selectedTextObj .to )
304+ if (selectedText !== ' ' ) {
305+ showNativeSQL .value = false
306+ executeWithQuery (selectedText )
307+ }
308+ }
309+
310+ const executeQueryWithoutShowingNativeSQL = () => {
303311 showNativeSQL .value = false
304312 executeWithQuery (sqlQuery .value )
305- },
306- Description: ' Execute query without showing native SQL'
307- }])
313+ }
314+
315+ Magic .LoadMagicKeys (import .meta .url , new Map ([
316+ [" executeQuery" , executeQuery ],
317+ [" executeWithSelectedQuery" , executeWithSelectedQuery ],
318+ [" executeQueryWithoutShowingNativeSQL" , executeQueryWithoutShowingNativeSQL ],
319+ ]))
308320 </script >
309321
310322<template >
@@ -384,6 +396,7 @@ Magic.AdvancedKeys([{
384396 </el-row >
385397 </el-form >
386398 <Codemirror
399+ @ready =" sqlEditorReady"
387400 v-model =" sqlQuery"
388401 v-if =" complexEditor"
389402 style =" height : var (--sql-editor-height );"
0 commit comments