4

I have book summaries that I would like to show to users. What's the best way to store rich text in firebase to show to the user? Should I be using firebase database? I have a database with all the books and I was just going to create a column for the book summary text.

Chris Hansen
  • 7,813
  • 15
  • 81
  • 165

1 Answers1

3

You need to convert the data to a format that can work in the database. This is really going to depend on your rich text editor.

For example, if you use Draft.js, there are functions convertToRaw and convertFromRaw.

Other formats, such as Markdown, is already in a format that can be stored in a database. Markdown is just a big text string.

Another possible option is to save your data in Base64. There are libraries for encoding and decoding Base64 depending on your source language.

Brian McBride
  • 302
  • 2
  • 4
  • I have another question. Is there a way to set cors settings for firebase storage? I'm having trouble accessing items there from my local development. – Chris Hansen Oct 08 '19 at 19:23
  • It looks like this was answered in the stack overflow question around Firebase Storage and Access-Control-Allow-Origin: https://stackoverflow.com/questions/37760695/firebase-storage-and-access-control-allow-origin – Brian McBride Oct 20 '19 at 01:21