BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Storing of output data

Open Orekiie opened this issue 2 years ago • 3 comments

Blocknote is an amazing editor, I loved the ui and how it was easy to setup but right now there's no good way for storing the output data, be it raw json, html or markdown.

  1. If you try to store in markdown there is complete loss of indentation, alignment, colors etc.
  2. If you try to store it in HTML, the output instead of using the style prop uses class prop which would definitely make it harder to adapt with custom components.
  3. Storing data in json is absolutely is no go since there's no way to actually convert it to html or markdown at a later point with utility functions.

Possible solutions -

  1. Markdown output will always have lossy output, there's no way to fix this except for using inline HTML.
  2. For HTML, it should use the style prop rather than using custom class prop.
  3. Storing the raw data can be extremely helpful if there's an way to convert the blocks to HTML without initialisation of a editor.

Orekiie avatar Aug 14 '23 14:08 Orekiie

Basic styles like bold, italic, etc should be getting serialized to HTML correctly already, but color styles and text alignment information is removed. I think fixing this would be a good improvement.

matthewlipski avatar Aug 14 '23 18:08 matthewlipski

Thanks @Oreki-Dev for the clear description.

I understand that your use-case is: (a) you want to serialize and deserialize content to/from a database. (b) you want to display render the content as HTML (probably on the backend?), without rendering an entire editor on the client.

a) is currently supported, but b) not very well, because the HTML is kind of "lossy". I think this makes a lot of sense and should be a very common use-case, for example if you use BlockNote as an editor inside a CMS - where you want to have the editor in the admin panel, and then use the HTML version of the written content for pages of the website (that visitors see).

Let me know if we understand the use-case correctly. I agree this would require extra work on the HTML export function, and a function that can also be run server-side without loading the entire editor

cc @matthewlipski

YousefED avatar Aug 16 '23 07:08 YousefED

Hello @YousefED, yes you've more or less understood my use-case, I'm actually building a content platform (blog to be precise) and I would love to store the output as raw JSON but that would only be possible if

  1. It is possible to convert data from/to JSON/HTML/MD without initialisation of an actual client
  2. The HTML output uses style prop instead of class prop

However beside this issue I've loved it and I would love to keep up with the updates and probably use it in the future as well Thank you!

Orekiie avatar Aug 16 '23 08:08 Orekiie