BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Data render issue

Open koushikxd opened this issue 2 years ago • 5 comments

Describe the bug i stored the data typed in the description as you can see in my first picture in my database(mongodb) and when i try to display the data it is displayed in this format as shown in the second picture.

Screenshot 2023-12-05 170749

The above picture is the form description component

Screenshot 2023-12-05 170727

the above picture is how the editor value is displayed

image_2023-12-05_171225381

image_2023-12-05_171248583

the above 2 images are the editor.tsx file and onEditorChange function.

can someone give me an idea on how to fix this issue

koushikxd avatar Dec 05 '23 11:12 koushikxd

Hmm not sure I entirely understand the issue you're having. blocknote.topLevelBlocks gets all the non-nested blocks in the editor in a JSON format - I suppose for your form you just want the text content, is that correct?

matthewlipski avatar Dec 05 '23 13:12 matthewlipski

@matthewlipski yeah . i just want the text content to be displayed on the fetched post data. my website is basically a blog website consisting of a title, summary and a description. This descrption has the editor component in it

koushikxd avatar Dec 05 '23 14:12 koushikxd

Ah I see, in that case you will have to process the result of blocknote.topLevelBlocks manually to get that, keep in mind there is also markup information that you may or may not want to keep. But in general I would probably use blocknote.forEachBlock to traverse all blocks & their children, get just the text content from block.content for each block, and then set the form value to the concatenation of the text content of each block. Have a look at these doc pages, they should help you out:

Traversing all blocks: https://www.blocknotejs.org/docs/manipulating-blocks#traversing-all-blocks How block.content is structured (helpful to define a function that just gets text content): https://www.blocknotejs.org/docs/inline-content

matthewlipski avatar Dec 05 '23 14:12 matthewlipski

@matthewlipski thank you . ill look into the docs and btw by the text content i meant like the markup and other features the blocknote editor gives us. i want the description to be highly customizable so that the user can express his blog post however they want to.

koushikxd avatar Dec 05 '23 15:12 koushikxd

Closing, we'll need a bit clearer description / requirements if this is still an issue in 0.12

YousefED avatar Mar 14 '24 13:03 YousefED