mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat(extensions): Enhances SQL Lab API (#37642)
This commit is contained in:
committed by
GitHub
parent
f96e90b979
commit
92438322c0
@@ -29,6 +29,7 @@ import type { KeyboardShortcut } from 'src/SqlLab/components/KeyboardShortcutBut
|
||||
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
|
||||
import { SqlLabRootState, type CursorPosition } from 'src/SqlLab/types';
|
||||
import { EditorHost } from 'src/core/editors';
|
||||
import { registerEditorHandle, unregisterEditorHandle } from 'src/core/sqlLab';
|
||||
import { useAnnotations } from './useAnnotations';
|
||||
import { useKeywords } from './useKeywords';
|
||||
|
||||
@@ -253,13 +254,23 @@ const EditorWrapper = ({
|
||||
const handleEditorReady = useCallback(
|
||||
(handle: EditorHandle) => {
|
||||
editorHandleRef.current = handle;
|
||||
// Register handle for SQL Lab API access
|
||||
registerEditorHandle(queryEditorId, handle);
|
||||
// Set initial cursor position
|
||||
const { row, column } = cursorPosition;
|
||||
handle.moveCursorToPosition({ line: row, column });
|
||||
handle.focus();
|
||||
handle.scrollToLine(row);
|
||||
},
|
||||
[cursorPosition],
|
||||
[cursorPosition, queryEditorId],
|
||||
);
|
||||
|
||||
// Unregister editor handle on unmount
|
||||
useEffect(
|
||||
() => () => {
|
||||
unregisterEditorHandle(queryEditorId);
|
||||
},
|
||||
[queryEditorId],
|
||||
);
|
||||
|
||||
const { data: annotations } = useAnnotations({
|
||||
|
||||
Reference in New Issue
Block a user