11import { DatabaseIcon } from "lucide-react" ;
2+ import { Switch } from "@heroui/react" ;
23
34// @ts -ignore
45import { createReactBlockSpec } from "@blocknote/react" ;
@@ -25,6 +26,7 @@ interface SQLProps {
2526 setAutoRefresh : ( autoRefresh : number ) => void ;
2627 setName : ( name : string ) => void ;
2728 setDependency : ( dependency : DependencySpec ) => void ;
29+ setSkipSqlModeInit : ( skip : boolean ) => void ;
2830 onCodeMirrorFocus ?: ( ) => void ;
2931}
3032
@@ -38,8 +40,28 @@ const MySQL = ({
3840 collapseQuery,
3941 setCollapseQuery,
4042 setDependency,
43+ setSkipSqlModeInit,
4144 onCodeMirrorFocus,
4245} : SQLProps ) => {
46+ const settingsContent = (
47+ < div className = "flex items-center justify-between gap-4" >
48+ < div className = "flex flex-col" >
49+ < span className = "text-sm font-medium text-gray-700 dark:text-gray-300" >
50+ Skip SQL mode initialization
51+ </ span >
52+ < span className = "text-xs text-gray-500 dark:text-gray-400" >
53+ Enable for MySQL-compatible databases like StarRocks or Doris
54+ </ span >
55+ </ div >
56+ < Switch
57+ size = "sm"
58+ isSelected = { mysql . skipSqlModeInit }
59+ onValueChange = { setSkipSqlModeInit }
60+ isDisabled = { ! isEditable }
61+ />
62+ </ div >
63+ ) ;
64+
4365 return (
4466 < SQL
4567 block = { mysql }
@@ -59,6 +81,8 @@ const MySQL = ({
5981 setCollapseQuery = { setCollapseQuery }
6082 setDependency = { setDependency }
6183 onCodeMirrorFocus = { onCodeMirrorFocus }
84+ settingsContent = { settingsContent }
85+ settingsTitle = "MySQL Settings"
6286 />
6387 ) ;
6488} ;
@@ -72,6 +96,7 @@ export default createReactBlockSpec(
7296 uri : { default : "" } ,
7397 autoRefresh : { default : 0 } ,
7498 dependency : { default : "{}" } ,
99+ skipSqlModeInit : { default : false } ,
75100 } ,
76101 content : "none" ,
77102 } ,
@@ -133,6 +158,13 @@ export default createReactBlockSpec(
133158 } ) ;
134159 } ;
135160
161+ const setSkipSqlModeInit = ( skip : boolean ) => {
162+ editor . updateBlock ( block , {
163+ // @ts -ignore
164+ props : { ...block . props , skipSqlModeInit : skip } ,
165+ } ) ;
166+ } ;
167+
136168 let dependency = DependencySpec . deserialize ( block . props . dependency ) ;
137169 let mysql = new MySqlBlock (
138170 block . id ,
@@ -141,6 +173,7 @@ export default createReactBlockSpec(
141173 block . props . query ,
142174 block . props . uri ,
143175 block . props . autoRefresh ,
176+ block . props . skipSqlModeInit ,
144177 ) ;
145178
146179 return (
@@ -154,6 +187,7 @@ export default createReactBlockSpec(
154187 collapseQuery = { collapseQuery }
155188 setCollapseQuery = { setCollapseQuery }
156189 setDependency = { setDependency }
190+ setSkipSqlModeInit = { setSkipSqlModeInit }
157191 onCodeMirrorFocus = { handleCodeMirrorFocus }
158192 />
159193 ) ;
0 commit comments