Best practices for saving the content in a database #1840
-
Are there any best practices on saving the data to a database? What data would we need to save, and how would we populate the composer with that data? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You may want to check how file import/export works! https://github.com/facebook/lexical/blob/main/packages/lexical-file/src/fileImportExport.js That said, and one of the reasons why we have a Alternatively, you can build your own format based on the tree structure.
The last works best when you already have documents in certain format on the database, like it is the case for many surfaces at Meta. |
Beta Was this translation helpful? Give feedback.
JSON.stringify(editorState)
andeditor.setEditorState(editor.parseEditorState(editorStateJSON))
You may want to check how file import/export works! https://github.com/facebook/lexical/blob/main/packages/lexical-file/src/fileImportExport.js
That said, and one of the reasons why we have a⚠️ on the main README is that we're actively working on a versioning system, especially oriented towards custom app nodes.
Alternatively, you can build your own format based on the tree structure.
The last works best when you already have documents in certain format on the datab…