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

Cannot have \n in custom block content. #742

Open
colinstantos opened this issue May 14, 2024 · 5 comments
Open

Cannot have \n in custom block content. #742

colinstantos opened this issue May 14, 2024 · 5 comments
Labels
💎 Bounty bug Something isn't working

Comments

@colinstantos
Copy link

Describe the bug
{
type: 'alert',
content: 'This is an \n example \n alert!!',
}

the above content is in a single line instead of 3.

To Reproduce
https://stackblitz.com/edit/github-qx9fhr?file=App.tsx

@colinstantos colinstantos added the bug Something isn't working label May 14, 2024
@YousefED
Copy link
Collaborator

/bounty 10

Copy link

algora-pbc bot commented May 28, 2024

💎 $10 bounty • BlockNote

Steps to solve:

  1. Start working: Comment /attempt #742 with your implementation plan
  2. Submit work: Create a pull request including /claim #742 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to TypeCellOS/BlockNote!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @Bhavyajain21 Jun 1, 2024, 6:23:06 AM WIP

@jkcs
Copy link

jkcs commented May 30, 2024

Hello @YousefED , Could you please describe your expected solution more specifically? In fact, it can be addressed simply by changing it to

     {
        type: "alert",
        content: [
          {
            type: "text",
            styles: {},
            text: "This is an \n example \n alert!!",
          },
        ],
      },

Here are a few possible solutions:

  • Best option, Have users use it as is, and when a line break is needed, they can directly pass raw JSON without modifying any code.

  • Implement it within the Alert component by extending the createReactBlockSpec method, allowing it to convert content into the aforementioned format.

  • Add an identifier in useCreateBlockNote for transforming initialContent.

@jkcs
Copy link

jkcs commented May 30, 2024

By the way, if the <Alert /> needs to display the line breaks correctly, you'll need to change height: 48px; to min-height: 48px;

@Bhavyajain21
Copy link

Bhavyajain21 commented Jun 1, 2024

Hey @YousefED , I'd like to give this a try. Can you please assign this issue under my name?

/attempt

Algora profile Completed bounties Tech Active attempts Options
@Bhavyajain21 10 bounties from 3 projects
TypeScript, Rust,
JavaScript & more
Cancel attempt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants