Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle line breaks #42

Merged
merged 5 commits into from
Jan 30, 2025
Merged

fix: handle line breaks #42

merged 5 commits into from
Jan 30, 2025

Conversation

r-o-b-o-t-o
Copy link
Contributor

What does it do?

Transforms \n, \r\n and \r into <br /> tags in <Text />

Why is it needed?

Fixes #37

How to test it?

  • Create rich text blocks with line returns in them (⇧+⏎ in the rich text editor)
  • Render them with <BlocksRenderer />
  • Make sure the newline characters are replaced by <br /> tags

@r-o-b-o-t-o r-o-b-o-t-o changed the title Fix/lf to br fix: handle line breaks Jul 5, 2024
@leelawtondesign
Copy link

This worked perfectly for me, thanks!

@antoine-roux
Copy link

It would be nice to merge :)

@pbozyk
Copy link

pbozyk commented Oct 25, 2024

we need this in production pack! that would be nice.

@r-o-b-o-t-o
Copy link
Contributor Author

r-o-b-o-t-o commented Oct 28, 2024

In the meantime, my fork is available on npm: @roboto_/strapi-blocks-react

Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, could you just add a unit test too?

And sorry I wasn't aware of this PR, it's been a while so if you don't want to get back to it we can make another PR internally

src/Text.tsx Outdated Show resolved Hide resolved
@KasperiP
Copy link

@remidej Could you take a look into this :shipit: ?

remidej
remidej previously approved these changes Jan 30, 2025
@remidej remidej merged commit 8df8041 into strapi:main Jan 30, 2025
2 checks passed
@r-o-b-o-t-o r-o-b-o-t-o deleted the fix/lf-to-br branch February 2, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat]: Support for Interpreting \n as Line Breaks
6 participants