Skip to content

fix: Key inputs in blocks without content #730

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

Merged
merged 2 commits into from
May 10, 2024
Merged

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented May 6, 2024

This PR improves how keystrokes are handled in non-editable blocks like images, so that more edge cases are covered (including special characters like ś and Enter).

A more robust approach might be to filter out transactions in which a no content block is selected before, and replaced with a paragraph block after (will likely need additional filtering e.g. to not filter out updateBlock calls). However, I think the current implementation gets us 90% of the way there with much less complexity so I don't think it's worth looking into.

TODO: We should merge the releases branch into main first

Copy link

vercel bot commented May 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview May 9, 2024 4:31pm
blocknote-website ✅ Ready (Inspect) Visit Preview May 9, 2024 4:31pm

@YousefED
Copy link
Collaborator

YousefED commented May 7, 2024

What are the events that we do want to allow? I suppose things like tab, arrows, etc.?

For the alternative solution, perhaps, we could use an approach like this? ueberdosis/tiptap#181 (comment), and make sure to only do this when a NodeSelection is active. However, indeed we would need to be able to distinguish from keyboard vs programmatic / collaboration events

@matthewlipski matthewlipski changed the title fix: Temp fix for Enter inputs on blocks without content fix: Key inputs in blocks without content May 9, 2024
@matthewlipski
Copy link
Collaborator Author

What are the events that we do want to allow? I suppose things like tab, arrows, etc.?

For the alternative solution, perhaps, we could use an approach like this? ueberdosis/tiptap#181 (comment), and make sure to only do this when a NodeSelection is active. However, indeed we would need to be able to distinguish from keyboard vs programmatic / collaboration events

I've updated the code to handle more edge cases and when comparing the UX to Notion's I think it's quite close. Don't think it's worth the hassle of figuring out which transaction comes from where tbh, since the keyboard input approach gets us the majority of the way there while adding very little complexity.

@matthewlipski matthewlipski merged commit c720a63 into main May 10, 2024
6 checks passed
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.

2 participants