2
2
import { insertOrUpdateBlock } from '@blocknote/core' ;
3
3
import { createReactBlockSpec } from '@blocknote/react' ;
4
4
import { Button } from '@openfun/cunningham-react' ;
5
+ import { ColDef } from 'ag-grid-community' ;
6
+ import { AgGridReact } from 'ag-grid-react' ;
5
7
import { TFunction } from 'i18next' ;
8
+ import React , { useRef } from 'react' ;
6
9
7
10
import { Box , Icon , Text } from '@/components' ;
8
11
@@ -27,13 +30,34 @@ export const DatabaseBlock = createReactBlockSpec(
27
30
} ,
28
31
{
29
32
render : ( { block, editor } ) => {
33
+ const gridRef = useRef ( null ) ;
34
+
35
+ const rowData = [
36
+ { make : 'Tesla' , model : 'Model Y' , price : 64950 , electric : true } ,
37
+ { make : 'Ford' , model : 'F-Series' , price : 33850 , electric : false } ,
38
+ { make : 'Toyota' , model : 'Corolla' , price : 29600 , electric : false } ,
39
+ ] ;
40
+
41
+ // Column Definitions: Defines the columns to be displayed.
42
+ const colDefs : ColDef [ ] = [
43
+ { field : 'make' } as const ,
44
+ { field : 'model' } as const ,
45
+ { field : 'price' } as const ,
46
+ { field : 'electric' } as const ,
47
+ ] ;
48
+
49
+ const defaultColDef = {
50
+ flex : 1 ,
51
+ } ;
30
52
return (
31
53
< Box
32
54
$padding = "1rem"
33
55
$gap = "0.625rem"
34
56
style = { {
35
57
flexGrow : 1 ,
36
58
flexDirection : 'row' ,
59
+ height : '500px' ,
60
+ width : '100%' ,
37
61
} }
38
62
>
39
63
< Box as = "div" />
@@ -43,6 +67,14 @@ export const DatabaseBlock = createReactBlockSpec(
43
67
documentId = { block . props . documentId }
44
68
tableId = { block . props . tableId }
45
69
/>
70
+ < Box style = { { height : '100%' , width : '100%' } } >
71
+ < AgGridReact
72
+ ref = { gridRef }
73
+ rowData = { rowData }
74
+ columnDefs = { colDefs }
75
+ defaultColDef = { defaultColDef }
76
+ />
77
+ </ Box >
46
78
</ Box >
47
79
) : (
48
80
< Box
0 commit comments