BlockNote
BlockNote copied to clipboard
Cannot read properties of undefined (reading 'dispatch')
Describe the bug I am trying to use replaceBlocks function after initializing the editor. But it is giving an error "Cannot read properties of undefined (reading 'dispatch')"
To Reproduce I have added the link of codesandox: Link to sandbox
Thanks, this seems to be a bug and I'll look into the root of it.
For now, is there a reason why you can't pass data as initialContent when calling useCreateBlockNote?
@YousefED I want to replace all blocks with new ones, so I need a way to control the data
Replace blocks doesnt seem to work, I have same issue
Having same issues, any update on this? @YousefED regarding your comment, I can't use initial content because I need to first convert markdown to blocks using editor.tryParseMarkdownToBlocks so I need my editor initialized first correct?
I'm also having the same problem and it's coming specifically from editor.replaceBlocks()
Here's a sample:
useEffect(() => {
async function loadInitialHTML() {
const blocks = await noteEditor.tryParseMarkdownToBlocks(
"This is a normal text\n\n# And this is a large heading",
);
noteEditor.replaceBlocks(noteEditor.document, blocks);
}
loadInitialHTML();
}, [isLoading]);
I could be wrong but the the issue might be coming from https://github.com/TypeCellOS/BlockNote/blob/99233e5d57e5a4b56eeafd2dd8abe54229dc35fb/packages/core/src/api/blockManipulation/blockManipulation.ts#L189
closed by https://github.com/TypeCellOS/BlockNote/pull/909