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

Empty block is unnecessarily created #631

Closed
1 task
moroshko opened this issue Mar 9, 2024 · 14 comments
Closed
1 task

Empty block is unnecessarily created #631

moroshko opened this issue Mar 9, 2024 · 14 comments

Comments

@moroshko
Copy link

moroshko commented Mar 9, 2024

Describe the bug
Empty block is unnecessarily created. I'm wondering why is this and whether there is a way to avoid this?

To Reproduce

  1. Visit https://www.blocknotejs.org/examples/basic/minimal
  2. Focus the editor
  3. Press "a"
    You'll see that a new empty block is added under the "a" (you can press the Down arrow to go there)

Misc

  • Node version: 20
  • Package manager: bun
  • Browser: Chrome
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖
@moroshko moroshko added the bug Something isn't working label Mar 9, 2024
@YousefED YousefED added good first issue Good for newcomers and removed bug Something isn't working labels Mar 12, 2024
@YousefED
Copy link
Collaborator

This is because we're adding a so-called trailing node. This makes it easier for users to use their mouse and click below the document and start adding content. It's similar to what notion does.

If you want to disable this, you could try creating a PR. We could add an editor option that would disable the extension here:

@jaredly
Copy link

jaredly commented Mar 14, 2024

ooh yes I want this disabled as well

@jaredly
Copy link

jaredly commented Mar 14, 2024

@YousefED I can imagine three different levels of intervention:

(1) add an option noTrailingNode: boolean, simple & only solves the present issue
(2) add an option customizeExtensions: (extensions: AnyExtension[]) => AnyExtension[] -- allows the user to remove or modify any of the list of default extensions, allowing users to customize things further
(3) add an option customizeTipTapOptions: (options: TipTapEditorOptions) => TipTapEditorOptions, allowing the greatest amount of control, not just over the extensions that are loaded, but a bunch of other things as well. This would superceded the _tipTapOptions option that's currently available.

Do you have a preference?

@jaredly
Copy link

jaredly commented Mar 14, 2024

Alternatively, @moroshko here's the hack that I've figured out, while waiting for PRs to happen and such:

const ext = editor._tiptapEditor.extensionManager.extensions.find((e) => e.name === 'trailingNode');
if (ext) {
    // Disable the trailingNode extension
    ext.config.addProseMirrorPlugins = () => [];
}

@YousefED
Copy link
Collaborator

``
Thanks @jaredly! I feel like this should be a first-class option without needing to know about TipTap, so I'd be in favor of:

(1) add an option noTrailingNode: boolean, simple & only solves the present issue

Small caveat: I'd use trailingBlock: boolean which defaults to true ("Block" is more BlockNote like, and I think it's a bit nicer to not have a negation ("no") ).

@YousefED
Copy link
Collaborator

/bounty 50

Copy link

algora-pbc bot commented Mar 27, 2024

💎 $50 bounty • BlockNote

Steps to solve:

  1. Start working: Comment /attempt #631 with your implementation plan
  2. Submit work: Create a pull request including /claim #631 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
🔴 @35C4n0r Mar 27, 2024, 3:04:17 PM WIP
🔴 @ezhil56x Mar 27, 2024, 3:33:14 PM WIP
🟢 @Kashifwahaj Apr 2, 2024, 5:15:51 PM #679

@35C4n0r
Copy link

35C4n0r commented Mar 27, 2024

/attempt 631

Algora profile Completed bounties Tech Active attempts Options
@35C4n0r 13 bounties from 4 projects
Python, JavaScript,
HTML & more
Cancel attempt

@ezhil56x
Copy link
Contributor

ezhil56x commented Mar 27, 2024

/attempt #631

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

@YousefED
Copy link
Collaborator

YousefED commented Mar 28, 2024

@35C4n0r @ezhil56x Thanks for your submissions! I'll look into the PRs next week (out of town at the moment). Could you make sure to add relevant unit and / or playwright tests?

Also note that only one of you can be rewarded the bounty afaik

@Kashifwahaj
Copy link
Contributor

Kashifwahaj commented Apr 2, 2024

/attempt #631

Copy link

algora-pbc bot commented Apr 2, 2024

💡 @Kashifwahaj submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Kashifwahaj added a commit to Kashifwahaj/BlockNote that referenced this issue Apr 9, 2024
Kashifwahaj added a commit to Kashifwahaj/BlockNote that referenced this issue Apr 9, 2024
Kashifwahaj added a commit to Kashifwahaj/BlockNote that referenced this issue Apr 9, 2024
Kashifwahaj added a commit to Kashifwahaj/BlockNote that referenced this issue Apr 9, 2024
Kashifwahaj added a commit to Kashifwahaj/BlockNote that referenced this issue Apr 9, 2024
YousefED pushed a commit that referenced this issue May 1, 2024
* feat-#631 extended block options for traiing block

* feat-#631 Code Updated with less and better changes for feature

* feat-#631- updated documentation for this new `trailingBlock` option
@YousefED
Copy link
Collaborator

YousefED commented May 1, 2024

closed by #679

@YousefED YousefED closed this as completed May 1, 2024
Copy link

algora-pbc bot commented May 28, 2024

🎉🎈 @Kashifwahaj has been awarded $55! 🎈🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants