File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
apps/web/src/components/v2Editor/customBlocks/sql
packages/editor/src/blocks Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -403,14 +403,15 @@ function SQLBlock(props: Props) {
403
403
} , [ router , props . document . workspaceId ] )
404
404
405
405
const onToggleFormatSQLCode = useCallback ( ( ) => {
406
- const formattedCode = getSQLCodeFormatted ( source )
406
+ const sqlCodeFormatted = getSQLCodeFormatted ( source )
407
407
408
- if ( ! formattedCode ) {
408
+ if ( ! sqlCodeFormatted ) {
409
409
return
410
410
}
411
411
412
- updateYText ( source , formattedCode )
413
- } , [ source ] )
412
+ // Reuse the `EditWithAIForm` component to show the formatted SQL code
413
+ props . block . setAttribute ( 'aiSuggestions' , sqlCodeFormatted )
414
+ } , [ source , props . block ] )
414
415
415
416
const onToggleIsBlockHiddenInPublished = useCallback ( ( ) => {
416
417
props . onToggleIsBlockHiddenInPublished ( blockId )
Original file line number Diff line number Diff line change @@ -149,8 +149,8 @@ export function duplicateSQLBlock(
149
149
source : duplicateYText ( prevAttributes . source ) ,
150
150
dataframeName : clone ( prevAttributes . dataframeName ) ,
151
151
dataSourceId : prevAttributes . dataSourceId
152
- ? options ?. datasourceMap ?. get ( prevAttributes . dataSourceId ) ??
153
- prevAttributes . dataSourceId
152
+ ? ( options ?. datasourceMap ?. get ( prevAttributes . dataSourceId ) ??
153
+ prevAttributes . dataSourceId )
154
154
: null ,
155
155
isFileDataSource : prevAttributes . isFileDataSource ,
156
156
result : options ?. noState ? null : clone ( prevAttributes . result ) ,
@@ -364,5 +364,5 @@ export function getSQLCodeFormatted(source: Y.Text) {
364
364
tabWidth : 4 ,
365
365
} )
366
366
367
- return formatted ;
367
+ return new Y . Text ( formatted )
368
368
}
You can’t perform that action at this time.
0 commit comments