Comments (5)
Thanks for looking into it!
Yes, I came to the same conclusion. When trying to add my code to SanityContent, the approach didn't feel right.
At first I thought that SanityContent stripped the newline characters, but actually they're still in the HTML. Using white-space: pre-line
is easy and works as expected.
from sanity.
Yes, I would π
from sanity.
I am using this module for the first time and was confused about the new line handling. Thank god I found this issue here π
I'm not sure there is an easy fix within SanityContent, as it would require turning text into HTML
So far, I have used https://github.com/rdunk/sanity-blocks-vue-component, which produces a <br>
, and this is actually what I also expect when portable text gets transformed into HTML. Because of that, the CSS workaround doesn't feel quite right to me.
@danielroe would you consider to add <br>
for new lines?
from sanity.
@mornir So having taken a look at this, I'm not sure there is an easy fix within SanityContent
as it would require turning text into HTML, which I think is somewhat against the grain of the Portable Text concept. I think the best solution is white-space: pre-line
as you've suggested.
What do you think?
Sample paragraph with newlines:
const children = [
{
"_key": "82dc1243fc1c",
"_type": "span",
"marks": [],
"text": "d\n\n\nd"
}
]
from sanity.
@danielroe is this still on the radar? Perhaps Iβm doing something wrong but \n
s donβt seem to be spitting out <br />
s by default. (Thanks!)
from sanity.
Related Issues (20)
- SanityContent type not the same as Sanity CLI output HOT 1
- useSanity in server handler broken in build version (module not found) HOT 8
- investigate using `@portabletext/vue` HOT 2
- Nuxt 3: Error __vite_ssr_import_1__.createClient is not a function
- useSanityQuery return data: null HOT 1
- Long queries via POST with perspective return 400 error HOT 1
- Return type for `useSanityQuery<T>(...)` is `any`
- Wrong type when using image-url like in the example?
- Forwarding Props to Dynamically Rendered Components using <SanityContent> in Nuxt 3
- How do I get the index or nth value of a specific block type within the portable text types in SanityContent? HOT 1
- Direct support for Visual Editing in Presentation HOT 5
- import `client` from `@sanity-typed/client` instead of `@sanity/client` HOT 3
- Nuxt Devtools and Visual Editing HOT 6
- NuxtLink not working when using useSanityQuery HOT 1
- Parent operator provides wrong value (exact same code works in Vision) HOT 4
- Issue with Nuxt Server API Call "Cannot read from private field" HOT 10
- Component inside <ClientOnly> is not rendered
- Hydration mismatching when using Pinia actions to fetch data with useSanityQuery HOT 5
- ISR does not work in in presentation mode HOT 6
- Sanity dependencies must be installed when deploying to netlify. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanity.