feat: add SQL editor, query results, and workspace panels
Add CodeMirror 6 SQL editor with Ctrl+Enter execution, ResultsTable with virtual scrolling and resizable columns, ResultsPanel, EditableCell, WorkspacePanel (editor + results split), and TabContent router. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
58
src/components/editor/SqlEditor.tsx
Normal file
58
src/components/editor/SqlEditor.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
import CodeMirror from "@uiw/react-codemirror";
|
||||
import { sql, PostgreSQL } from "@codemirror/lang-sql";
|
||||
import { keymap } from "@codemirror/view";
|
||||
import { useCallback, useMemo } from "react";
|
||||
|
||||
interface Props {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
onExecute: () => void;
|
||||
}
|
||||
|
||||
export function SqlEditor({ value, onChange, onExecute }: Props) {
|
||||
const handleChange = useCallback(
|
||||
(val: string) => {
|
||||
onChange(val);
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
|
||||
const extensions = useMemo(
|
||||
() => [
|
||||
sql({ dialect: PostgreSQL }),
|
||||
keymap.of([
|
||||
{
|
||||
key: "Ctrl-Enter",
|
||||
run: () => {
|
||||
onExecute();
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "Mod-Enter",
|
||||
run: () => {
|
||||
onExecute();
|
||||
return true;
|
||||
},
|
||||
},
|
||||
]),
|
||||
],
|
||||
[onExecute]
|
||||
);
|
||||
|
||||
return (
|
||||
<CodeMirror
|
||||
value={value}
|
||||
onChange={handleChange}
|
||||
extensions={extensions}
|
||||
theme="dark"
|
||||
className="h-full text-sm"
|
||||
basicSetup={{
|
||||
lineNumbers: true,
|
||||
foldGutter: true,
|
||||
highlightActiveLine: true,
|
||||
autocompletion: true,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user