Skip to content

Commit 70103b3

Browse files
anaisbergSimonClo
authored andcommitted
✨ display hardcoded grid
1 parent 889f1e4 commit 70103b3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { BlockNoteView } from '@blocknote/mantine';
1010
import '@blocknote/mantine/style.css';
1111
import { useCreateBlockNote } from '@blocknote/react';
1212
import { HocuspocusProvider } from '@hocuspocus/provider';
13+
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
1314
import { useEffect } from 'react';
1415
import { useTranslation } from 'react-i18next';
1516
import * as Y from 'yjs';
@@ -29,6 +30,8 @@ import { BlockNoteSuggestionMenu } from './BlockNoteSuggestionMenu';
2930
import { BlockNoteToolbar } from './BlockNoteToolBar/BlockNoteToolbar';
3031
import { CalloutBlock, DatabaseBlock, DividerBlock } from './custom-blocks';
3132

33+
ModuleRegistry.registerModules([AllCommunityModule]);
34+
3235
export const blockNoteSchema = withPageBreak(
3336
BlockNoteSchema.create({
3437
blockSpecs: {

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DatabaseBlock.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import { insertOrUpdateBlock } from '@blocknote/core';
33
import { createReactBlockSpec } from '@blocknote/react';
44
import { Button } from '@openfun/cunningham-react';
5+
import { ColDef } from 'ag-grid-community';
6+
import { AgGridReact } from 'ag-grid-react';
57
import { TFunction } from 'i18next';
8+
import React, { useRef } from 'react';
69

710
import { Box, Icon, Text } from '@/components';
811

@@ -27,13 +30,34 @@ export const DatabaseBlock = createReactBlockSpec(
2730
},
2831
{
2932
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+
};
3052
return (
3153
<Box
3254
$padding="1rem"
3355
$gap="0.625rem"
3456
style={{
3557
flexGrow: 1,
3658
flexDirection: 'row',
59+
height: '500px',
60+
width: '100%',
3761
}}
3862
>
3963
<Box as="div" />
@@ -43,6 +67,14 @@ export const DatabaseBlock = createReactBlockSpec(
4367
documentId={block.props.documentId}
4468
tableId={block.props.tableId}
4569
/>
70+
<Box style={{ height: '100%', width: '100%' }}>
71+
<AgGridReact
72+
ref={gridRef}
73+
rowData={rowData}
74+
columnDefs={colDefs}
75+
defaultColDef={defaultColDef}
76+
/>
77+
</Box>
4678
</Box>
4779
) : (
4880
<Box

0 commit comments

Comments
 (0)