forked from TypeCellOS/BlockNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseCreateBlockNote.tsx
More file actions
39 lines (37 loc) · 1.07 KB
/
Copy pathuseCreateBlockNote.tsx
File metadata and controls
39 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {
BlockNoteEditor,
BlockNoteEditorOptions,
BlockSchema,
DefaultBlockSchema,
DefaultInlineContentSchema,
DefaultStyleSchema,
InlineContentSchema,
StyleSchema,
} from "@blocknote/core";
import { DependencyList, useMemo } from "react";
/**
* Main hook for importing a BlockNote editor into a React project
*
* TODO: document in docs
*/
export const useCreateBlockNote = <
BSchema extends BlockSchema = DefaultBlockSchema,
ISchema extends InlineContentSchema = DefaultInlineContentSchema,
SSchema extends StyleSchema = DefaultStyleSchema
>(
options: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>> = {},
deps: DependencyList = []
) => {
return useMemo(() => {
const editor = BlockNoteEditor.create<BSchema, ISchema, SSchema>(options);
if (window) {
// for testing / dev purposes
(window as any).ProseMirror = editor._tiptapEditor;
}
return editor;
}, deps); //eslint-disable-line react-hooks/exhaustive-deps
};
/**
* @deprecated use useCreateBlockNote instead
*/
export const useBlockNote = useCreateBlockNote;