question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to save to firestore

See original GitHub issue

I was trying to save data from quill to firestore and restore it next time I need quill. I initially tried to extract the html and then find the method to restor it to quill, but soon found out that _“dangerouslyPasteHTML” is big no no. So next I tried just save the data as a Delta object and then I can easily restore it using “setContents” . However, and here comes the problem firestore doesn’t allow custom object to be saved only pure object. Meaning I can use Object.assing({},DeltaObj) but then I’ll lose all delta methods and can’t restore the content.

So my question is is there is way to save and retrieve data from quill to firestore and back to quill. Or is it that quill and firestore incompatible? thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
benbrocommented, Sep 7, 2018

If you need it as array:

quill.getContents().ops;

If you need it as string:

JSON.stringify(quill.getContents());
1reaction
Fawwaz-2009commented, Sep 7, 2018

After seeing the example that benbro referenced I went and try to hack again at a solution and I think I found one. Not sure if it’s best practice or any thing but seems to work.

//save the ops (which contains the array similar to the example above) property of the Delta Object into a variable 

let x=quill.getContents().ops;
//now you can send x to the database. Next time you can use x to load the text
quill.setContents(x);

I’ll double check and try this on firestore and then close the issue. But for now I don’t see what this wouldn’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get started with Cloud Firestore - Firebase
Navigate to the Cloud Firestore section of the Firebase console. You'll be prompted to select an existing Firebase project. Follow the database ...
Read more >
Adding data | Firestore - Google Cloud
Stay organized with collections Save and categorize content based on your preferences. There are several ways to write data to Firestore: Set the...
Read more >
Firebase Firestore Tutorial #4 - Saving Data - YouTube
Hey gang, in this Firebase Firestore tutorial we'll look at how to input data into a form & then save it to our...
Read more >
Save data to Cloud Firestore in Google Firebase - YouTube
In this video I walk through step by step on how to setup the Firestore database and configure my app to save user...
Read more >
I am trying to save form data to cloud Firestore - Stack Overflow
I am trying to save form data to cloud Firestore. Using the following link - https://firebase.google.com/docs/firestore/manage-data/add-data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found