Preferred method for saving formatted text in string fields?
It's still early days for me in Convex and my app. For now I need to display a block of text made up of a number of paragraphs. What is the secret sauce to copy/paste into a string field and maintain paragraphs? Eventually I will be building something more sophisticated with TipTap or similar. For now, I'd like this block to have some paragraph breaks. I tried \r and \n thinking it might interpret those but it doesn't seem to.
6 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Do you mean, on the dashboard?
if so, try backticks, like `
that's the way to write a multi-line string in javascript
How do line breaks translate when it's used in a compnent via something like {data.descriptionField}? Right now it displays as all one paragraph, no line breaks even though they do appear in the Dashboard.
That's an HTML thing, if you view source (well inspect the element) you'll see the spaces there, but HTML collapses spaces. You'll need to use
<pre>
tags to preserve the formatting, or run that text through a function that adds e.g. <p>
tags.I figured as much, just making sure I wasn't missing a convex detail.