Skip to content

fix: drag & drop issues #1458

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 6 commits into from
Feb 25, 2025
Merged

fix: drag & drop issues #1458

merged 6 commits into from
Feb 25, 2025

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented Feb 24, 2025

This PR fixes 3 additional issues with drag & drop that we didn't previously catch:

  1. When using the multi-column extension, it's possible to drag a block and drop it next to itself. BlockNote will attempt to create 2 columns containing the same block, but will throw an error it tries to remove the same block twice. This edge case has been fixed and now, nothing happens.
  2. It's possible that a dragged block is dropped in an element that is not a valid drop target. In this case, only a dragend event fires, and not a drop. Since we only clear view.dragging on drop events, BlockNote will throw an error the next time the user attempts to drag a block, as it will think that a block is already being dragged. Therefore, this has been fixed by making view.dragging get cleared on dragend events instead.
  3. When pasting content from the clipboard (via paste or drop events), the UniqueID plugin sets transformPasted = true. This signals that any pasted blocks should have their IDs reset & re-generated. After the IDs are reset, transformPasted is reset back to false. However, transformPasted doesn't get called at all when external content, such as files, is pasted. This means that if external content is pasted, it remains true for any subsequent drop events, causing errors as the dragged block has no ID. This has been changed so that transformPasted is always set to true or false before the subsequent paste or drop.

Closes #1444
Closes #1451
Closes #1382

Copy link

vercel bot commented Feb 24, 2025

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Feb 25, 2025 2:49pm
blocknote-website ✅ Ready (Inspect) Visit Preview Feb 25, 2025 2:49pm

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.

great fix that actually gets rid of the hacky settimeout!

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