0.1.4 • Published 11 months ago
sql-editor-react v0.1.4
sql-editor-react
安装
npm install sql-editor-react
or
yarn add sql-editor-react
使用
import { useRef, useState, type FC } from "react";
import {Editor} from 'sql-editor-react'
import {RefEditorInstance} from 'sql-editor-react/types'
import 'sql-editor-react/style'
const App: FC = () => {
const editorRef = useRef<RefEditorInstance>(null);
const [code] = useState("SELECT * FROM users;");
return (
<>
<Editor
ref={editorRef}
height={200}
theme="naruto"
value={code}
options={
{ readOnly: false}
}
/>
</>
);
};
export default App;
// 引用实例的类型定义
export interface RefEditorInstance {
container: HTMLDivElement | null
editor?: editor.IStandaloneCodeEditor
monaco: IMonacoEditor
format: () => void // 暴露 formatSQL 方法
setReadOnly: (value: boolean) => void
}
// 定义组件的属性类型
export interface MonacoEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
width?: number | string
height?: number | string
value?: string
defaultValue?: string
dataBase?: Record<string, string[]> //支持数据库 表名
language?: editor.IStandaloneEditorConstructionOptions['language']
autoComplete?: (model: editor.ITextModel, position: monaco.Position) => monaco.languages.CompletionItem[]
theme?: editor.IStandaloneEditorConstructionOptions['theme']
options?: editor.IStandaloneEditorConstructionOptions //继承MonacoEditor options属性
editorDidMount?: (editor: editor.IStandaloneCodeEditor, monaco: IMonacoEditor) => void
onChange?: (value: string, event: editor.IModelContentChangedEvent) => void
children?: ReactNode //传递过来的Toolbar 组件 默认支持全屏
}
export type Monaco = typeof monaco;
export type Theme = 'vs-dark' | 'light';
0.1.4
11 months ago
0.1.3
11 months ago
0.1.2
11 months ago
0.1.1
11 months ago
0.8.31
11 months ago
0.8.29
11 months ago
0.8.28
11 months ago
0.8.27
11 months ago
0.8.26
11 months ago
0.8.25
11 months ago
0.8.24
11 months ago
0.8.23
11 months ago
0.8.22
11 months ago
0.8.21
11 months ago
0.8.20
11 months ago
0.8.19
11 months ago
0.8.18
11 months ago
0.8.17
11 months ago
0.8.16
11 months ago
0.8.15
11 months ago
0.8.14
11 months ago
0.8.13
11 months ago
0.8.12
11 months ago
0.8.11
11 months ago
0.8.10
11 months ago
0.8.9
11 months ago
0.8.8
11 months ago
0.8.7
11 months ago
0.8.6
11 months ago
0.8.5
11 months ago
0.8.3
11 months ago
0.8.2
11 months ago
0.8.1
11 months ago
0.8.0
11 months ago
0.7.0
11 months ago
0.6.0
11 months ago
0.5.0
11 months ago
0.4.0
11 months ago
0.3.0
11 months ago
0.2.0
11 months ago
0.1.0
11 months ago