【问题标题】:How to store rich text data? [closed]如何存储富文本数据? [关闭]
【发布时间】:2018-03-08 06:59:01
【问题描述】:

我正在开发一个博客应用程序。目前,在发布博客文章时,您可以上传纯文本,并且每篇文章最多可以上传一张图片。

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

另外,如何增加存储任意数量图像的能力?

【问题讨论】:

  • 编辑器生成哪种格式?

标签: android firebase google-cloud-firestore rich-text-editor


【解决方案1】:

从文档中他们有以下方法来获取内容和渲染

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。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-07
    • 2017-05-07
    • 2012-08-04
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多