Hacker News new | ask | show | jobs
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?

2 comments

I'm not sure I can visualize what you mean by a DOM Editor, would love it if you can expand on that.

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.

> The JSON<>React serialization doesn't seem to offer much value

I mean, you don't see any value in being able to declaratively state an entire app? ...

The DOM is a declarative state for a document.
Is this a joke? Ask any mobile or desktop app developer (people who program UIs in a non-broken platform) how they think about having state inside the views.

Only on the web there exist people who hack around for so long they actually believe the hack is the right way.

React is fine for web apps, but static sites are not web apps. Using the DOM where appropriate is perfectly fine.
His point, stated with a bit too much ad hominem, is that with such a serialization you can scaffold entire dynamic web apps which can include form submission where the form dynamically updates based on rules & current state, uses a configurable method, and more, whereas DOM is inherently a "view" and has no concept of state