|
|
|
|
|
by codebeaker
1690 days ago
|
|
>Much like Notion and other block editing methods, site content is represented in a JSON format. Each block has a type, for example, a block of Paragraph would have the type "Paragraph" and would be represented by {"type":"paragraph", "text": "Hello World"}, and an image would have the type "Image" represented by {"type":"image", "url":"http://placekitten.com/200/300"}. A page consists of an array of blocks representing the blocks in the page. A page that consists of a Heading, a Paragraph, and an Image would be represented by an array of maps with types “heading”, “paragraph”, and “image” respectively. A block can also have children. For example, a block of type “Container” may have 3 children of “Paragraph” blocks. It’s very similar to the DOM structure. Why not make a DOM Editor then with virtual components? The JSON<>React serialization doesn't seem to offer much value, unless it's purely mechanical. I don't mean to detract from the praise your product is getting here, but I'm really curious about those motivations if you have time to answer my query in amongst the other more excited threads, I'd be glad to understand what the trade-off buys you? |
|
The JSON format allows us to only specify the main type/value of each block, while giving full flexibility on how to render them. I think there are several approaches to rich text editing out there, we picked this one because it seemed to be the most flexible and portable, as we need to invent our own types of standard "blocks", like columns, containers, etc.
Not sure if this answers your question though, happy to go deeper if you have more thoughts on it.