android - 如何存储富文本数据?

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

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

我想添加富文本 (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

关于android - 如何存储富文本数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49167176/

相关文章:

android - 谷歌地图标记阵列?

java - 队列运行时 Volley 发送请求

java - 将值从数组转换为 findViewById id

android - 如何在 Android 的 Canvas 上画一条圆角线

ios - 如何从 Firestore 将包含对象的数组获取到 Xcode 中的模型

ios - Firebase 数据未显示在 xcode 的 tableview 中

swift - Firebase RemoteConfigSettings 不反射(reflect)minimumFetchInterval 更改

java - FCM - 未注册

firebase - Firestore - 单个测试用户导致 50K+ 读取

javascript - 如何检查 firestore 中的 querySnapshot 是否为空