Giter VIP home page Giter VIP logo

Comments (5)

mornir avatar mornir commented on June 9, 2024 2

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.

danielroe avatar danielroe commented on June 9, 2024 2

Yes, I would πŸ‘

from sanity.

silvio-e avatar silvio-e commented on June 9, 2024 1

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.

danielroe avatar danielroe commented on June 9, 2024

@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.

joelisfar avatar joelisfar commented on June 9, 2024

@danielroe is this still on the radar? Perhaps I’m doing something wrong but \ns don’t seem to be spitting out <br />s by default. (Thanks!)

from sanity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.