TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
6.76k stars 471 forks source link

fix: `getNearestBlockContainerPos` unclear #1241

Closed matthewlipski closed 1 week ago

matthewlipski commented 1 week ago

Closes #1237

Currently, getNearestBlockContainerPos gets the nearest block, which may be a columnList, column, or blockContainer. I think the functionality is fine, but this PR renames it to getNearestBlockPos for better clarity and removes the error in getBlockInfoFromSelection for when something other than a blockContainer is returned. This fixes a bug that caused said error to be thrown by selecting a column node using triple click (I think) or Cmd+click.

vercel[bot] commented 1 week ago

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Nov 13, 2024 5:03pm
blocknote-website ✅ Ready (Inspect) Visit Preview Nov 13, 2024 5:03pm
matthewlipski commented 1 week ago

nice fix! What's the part that actually fixes the clicking?

Removing the error throw from getBlockInfoFromSelection - it was getting triggered in double/triple clicking the resize bar as that would select the column, and then the formatting toolbar buttons would try to render. They pretty much all use getBlockInfoFromSelection somewhere, and so the error would be thrown. Basically all the changes are to accommodate for the fact that we no longer throw this error.