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: Custom blocks without inline content #312

Merged
merged 3 commits into from
Aug 18, 2023

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented Aug 14, 2023

A recent change has broken custom blocks which don't contain inline content. This is because we added edge case handling in getBlockInfoFromPos, for situations where the selection is outside of any blocks. However, nodeToBlock was unnecessarily and incorrectly calling getBlockInfoFromPos with the blockContainer node instead of the doc, and was causing errors when inserting custom blocks without inline content.

Closes #300

@vercel
Copy link

vercel bot commented Aug 14, 2023

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

Name Status Preview Updated (UTC)
blocknote-website ✅ Ready (Inspect) Visit Preview Aug 18, 2023 10:30pm

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

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

Why was the call incorrect?

Nice that it's fixed. I do think we can improve this by making getBlockInfoFromPos and nodeToBlock call a method blockContainerNodeToBlockInfo or something? That would remove some duplicate code right?

@matthewlipski
Copy link
Collaborator Author

Why was the call incorrect?

Nice that it's fixed. I do think we can improve this by making getBlockInfoFromPos and nodeToBlock call a method blockContainerNodeToBlockInfo or something? That would remove some duplicate code right?

Well thing is that the main point of getBlockInfoFromPos is finding the nearest blockContainer node. Getting stuff like child count, depth, etc is pretty trivial after that. So it doesn't really make sense to call it if you already have the blockContainer node imo. Your suggestion makes sense though, just having a getBlockInfo function which takes a blockContainer node instead of a position.

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.

getBlockInfoFromPos is still buggy in 0.8.5
2 participants