The editor is typed NonNullable by useCreateBlockNote, but It cannot be accessed (or at least not mounted) on initial hook call.
const editor = useCreateBlockNote({
schema: schema,
initialContent: safevalue(defaultValue),
});
useEffect(() => {
if (!editor) return;
if (!editor.focus) return;
editor.focus();
}, [editor]);
Am I missing something here?
Below will work when called via click event
<div
className="prose dark:prose-invert mx-auto w-full"
onClick={() => editor.focus()}
>
<ThemedRichTextEditorContent
onKeyDown={(e) => {
// this is required for preventing exit on enter pressed
e.stopPropagation();
}}
editor={editor}
/>
</div>