(
options: Options = {} as Options,
deps: DependencyList = [],
)
| 12 | * Hook to instantiate a BlockNote Editor instance in React |
| 13 | */ |
| 14 | export const useCreateBlockNote = < |
| 15 | Options extends Partial<BlockNoteEditorOptions<any, any, any>> | undefined, |
| 16 | >( |
| 17 | options: Options = {} as Options, |
| 18 | deps: DependencyList = [], |
| 19 | ): Options extends { |
| 20 | schema: CustomBlockNoteSchema<infer BSchema, infer ISchema, infer SSchema>; |
| 21 | } |
| 22 | ? BlockNoteEditor<BSchema, ISchema, SSchema> |
| 23 | : BlockNoteEditor< |
| 24 | DefaultBlockSchema, |
| 25 | DefaultInlineContentSchema, |
| 26 | DefaultStyleSchema |
| 27 | > => { |
| 28 | return useMemo(() => { |
| 29 | const editor = BlockNoteEditor.create(options) as any; |
| 30 | if (window) { |
| 31 | // for testing / dev purposes |
| 32 | (window as any).ProseMirror = editor._tiptapEditor; |
| 33 | } |
| 34 | return editor; |
| 35 | }, deps); //eslint-disable-line react-hooks/exhaustive-deps |
| 36 | }; |
no test coverage detected