BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Getting errors while using blocknote/react

Open ShaquibKhanhub opened this issue 2 years ago • 1 comments

Describe the bug so i created a notion-clone and now i want to add editor option inside my app so i used blocknote/react libarary and blacknote/core for css but and im hovering on my sidebar im getting error which says TypeError: Cannot read properties of undefined (reading 'SideMenu') and in my whole code there's nothing called SideMenu to coutner this i exported every component which i have installed from shadcn and puts this inside shadCNComponents and let me you my whole code inside editor.ts im getting error only inside this

"use client"; import * as Button from "@/components/ui/button" import * as DropdownMenu from "@/components/ui/dropdown-menu" import * as Command from "@/components/ui/command" import * as Input from "@/components/ui/input" import * as Label from "@/components/ui/label" import * as Popover from "@/components/ui/popover" import * as Dialog from "@/components/ui/dialog" import * as Skeleton from "@/components/ui/skeleton"

import { BlockNoteEditor, PartialBlock } from "@blocknote/core"; import { BlockNoteViewRaw, useCreateBlockNote } from "@blocknote/react"; import "@blocknote/core/style.css"; import { useTheme } from "next-themes"; import { useEdgeStore } from "@/lib/edgestore";

interface EditorProps { onChange: (value: string) => void; initialContent?: string; editable?: boolean; }

const Editor = ({ onChange, initialContent, editable }: EditorProps) => { const { resolvedTheme } = useTheme(); const { edgestore } = useEdgeStore();

const handleUpload = async (file: File) => { const res = await edgestore.publicFiles.upload({ file, });

return res.url;

};

const editor: BlockNoteEditor = useCreateBlockNote({ editable, initialContent: initialContent ? (JSON.parse(initialContent) as PartialBlock[]) : undefined, uploadFile: handleUpload, });

// Update your onChange handler according to the expected signature const handleEditorChange = () => { onChange(JSON.stringify(editor.document, null, 2)); };

return (

<BlockNoteViewRaw editor={editor} theme={resolvedTheme === "dark" ? "dark" : "light"} onChange={handleEditorChange} shadCNComponents={{ Button, Skeleton, DropdownMenu, Popover, Dialog, Label, Command, Input,

      }}
  />
</div>

); };

export default Editor;

and inside this code everything is updated and latest ver.

To Reproduce <clear steps to reproduce are super helpful! Best is to provide an online sandbox, click to create one>

Misc

  • Node version:
  • Package manager:
  • Browser:
  • [ ] I'm a sponsor and would appreciate if you could look into this sooner than later 💖

ShaquibKhanhub avatar Jul 13 '24 17:07 ShaquibKhanhub

If you're using ShadCN, you should import BlockNoteView from @blocknote/shadcn and styles from @blocknote/shadcn/style.css. If you still get the same error, comment out the shadCNComponents prop and see if that changes anything.

matthewlipski avatar Jul 16 '24 13:07 matthewlipski