Skip to content

Commit 10336ba

Browse files
committed
feat(richtext-lexical): allow SerializedBlockNode fields to be typed via generic
1 parent 43b971c commit 10336ba

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/richtext-lexical/src/features/blocks/nodes/BlocksNode.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@ import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'
1414
import ObjectID from 'bson-objectid'
1515
import React, { type JSX } from 'react'
1616

17-
export type BlockFields = {
17+
export type BlockFields<TBlockFields extends object = Record<string, unknown>> = {
1818
/** Block form data */
19-
[key: string]: any
2019
blockName: string
2120
blockType: string
2221
id: string
23-
}
22+
} & TBlockFields
2423

2524
const BlockComponent = React.lazy(() =>
2625
import('../component/index.js').then((module) => ({
2726
default: module.BlockComponent,
2827
})),
2928
)
3029

31-
export type SerializedBlockNode = Spread<
30+
export type SerializedBlockNode<TBlockFields extends object = Record<string, unknown>> = Spread<
3231
{
3332
children?: never // required so that our typed editor state doesn't automatically add children
34-
fields: BlockFields
33+
fields: BlockFields<TBlockFields>
3534
type: 'block'
3635
},
3736
SerializedDecoratorBlockNode

0 commit comments

Comments
 (0)