diff --git a/kyuubi-server/web-ui/src/components/monaco-editor/index.vue b/kyuubi-server/web-ui/src/components/monaco-editor/index.vue index 65a2dba3421..9cc032a2b3a 100644 --- a/kyuubi-server/web-ui/src/components/monaco-editor/index.vue +++ b/kyuubi-server/web-ui/src/components/monaco-editor/index.vue @@ -105,6 +105,17 @@ }) emit('editorMounted', editor) } + const getSelectValue = () => { + const selection: any = editor.getSelection() + const range: any = { + startLineNumber: selection.selectionStartLineNumber, + startColumn: selection.selectionStartColumn, + endLineNumber: selection.positionLineNumber, + endColumn: selection.positionColumn + } + const model: any = editor.getModel() + return model.getValueInRange(range) + } watch( () => props.modelValue, (newValue) => { @@ -146,4 +157,7 @@ onMounted(() => { init() }) + defineExpose({ + getSelectValue + }) diff --git a/kyuubi-server/web-ui/src/views/editor/components/Editor.vue b/kyuubi-server/web-ui/src/views/editor/components/Editor.vue index c1bdbaa0968..2f4a1b3a509 100644 --- a/kyuubi-server/web-ui/src/views/editor/components/Editor.vue +++ b/kyuubi-server/web-ui/src/views/editor/components/Editor.vue @@ -55,6 +55,7 @@
= ref(null) + const monacoEditor = ref() const sqlLog = ref('') const activeTab = ref('result') const resultLoading = ref(false) @@ -156,10 +158,10 @@ if (!openSessionResponse) return sessionIdentifier.value = openSessionResponse.identifier } - + const selectValue = monacoEditor.value.getSelectValue() const runSqlResponse: IResponse = await runSql( { - statement: editorVariables.content, + statement: selectValue || editorVariables.content, runAsync: false }, sessionIdentifier.value