如何存储富文本数据?

How to store rich text data?

我正在开发一个博客应用程序。目前,当 post 编辑博客条目时,每个 post.

可以上传纯文本和不超过一张图片

我想添加富文本 (WYSIWYG) 编辑器。我如何在 firebase 数据库中保存和检索富文本格式(样式、字体、颜色等)?

此外,如何添加存储任意数量图像的容量?

根据文档,他们有以下方法来获取内容和渲染

render(); //Render the editor. This method must be called to render the editor.
render(String html); //Render the editor with HTML as parameter.
render(EditorState state); //Render the editor with the state as a parameter

getContent(); //returns the content in the editor as EditorState
getContentAsSerialized(); //returns the content as serialized form of EditorState
getContentAsSerialized(EditorState state); //returns the provided parameter as serialized.
getContentAsHTML(); //returns the editor content in HTML format.

所以你可以根据自己的需要使用getContent(),直接存储内容,在显示的时候使用render方法。

您可以搜索如何在 Firebase 中存储序列化对象以存储 EditorState 对象或直接将 HTML 文本存储为 String