Description
The goal of this RFC is to find a good format to store the blog post contents in the user Gaia storage. Sigle is currently using slatejs for it's editor. We use the version 0.47.X
and would like to upgrade to the latest slate version. The problem is that slate released a major breaking change in the 0.50.X
version regarding how the data is formatted. In a centralised way, it should be fairly easy to migrate the current data to this new format using a database migration.
In a decentralized world, this is quite different as Sigle can't write to the user storage on his behalf. As there is no automatic way to do the migration we will need to keep a migration script in our codebase for a very long time (1+ year or maybe forever).
This issue brings actually a bigger problem, what format is the best to store the blog post content. We need to find a solution so this situation does not happen again in the future.
The solution will need to cover the following requirements:
- No lock-in - Is not tied to an editor (current format is tied to slate < 0.47)
- Extensible - we should be able to create custom blocks of content (eg: image carousel)
- Safe - we need to protect the user from XSS attacks etc.. (allow only some kind of blocks)
- Standard - another app could use the same format to render the content
The user will not see any change in how the editor is currently working, these changes will be done in the background, we do not plan (for now) to have a brand new editor (eg: markdown with side preview).
Markdown
https://daringfireball.net/projects/markdown/syntax
Format
For the following article:
Slate format:
{
"object": "value",
"document": {
"object": "document",
"data": {},
"nodes": [
{
"object": "block",
"type": "paragraph",
"data": {},
"nodes": [
{ "object": "text", "text": "Simple lorem ipsum ", "marks": [] },
{
"object": "inline",
"type": "link",
"data": { "href": "https://app.sigle.io/" },
"nodes": [{ "object": "text", "text": "with a link", "marks": [] }]
},
{ "object": "text", "text": ", voila.", "marks": [] }
]
}
]
}
}
Markdown format:
Simple lorem ipsum [with a link](https://app.sigle.io/), voila.
Requirements
- No lock-in: It is not tied to any editor and can be rendered easily in any programming language
- Extensible: We can create custom block contents but at the same time the format limits the blocks we can create. Eg we can't really create 2 columns of text side by side except if we are mixing markdown and HTML tags.
- Safe: Markdown is safe as we can only render the markdown tags and avoid rendering the HTML tags.
- Standard: There are multiple flavours of markdown but the GitHub standard is widely adopted already.
Libraries
Here is a list of libraries that can be used to parse the markdown content. More research is needed to pick the good one.
Conclusion
The markdown format looks like the most simple solution, it can be integrated super easily, is fast to parse and render. The only downside could be the lack of customisation if we want to create custom blocks. This can be solved using HTML blocks but at the same time will complicate the implementation.
Any feedback is welcome regarding this change :) I would love to add more options to this list!