简体   繁体   中英

How to save textarea multiline text to Cloud Firestore?

I have this textArea input field for blogPost text content that may contain multiline text, like:

This is paragraph one.
(empty line)
This is paragraph two.

I will display it (when loading the blogPosts in my App) inside a <p> tag with white-space: pre-wrap;

How should I save this to Cloud Firestore?

What I've got so far:

I'm thinking about saving as JSON.stringify(textareaValue);

How can I do this? Any better options?

Cloud Firestore will store exactly what you send it. If you need the string to be something different at the time you render it on screen (like converting newlines to <br> ), then you will have to make those modifications yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM