Skip to content

Conversation

matthewlipski
Copy link
Collaborator

This PR fixes an bug with the link toolbar, where mouseHoveredLinkMark may be defined even when the mouse cursor isn't hovering any links. This is because the plugin would check if a link is currently hovered by the keyboard or mouse on every state update. State updates may cause the link under the mouse cursor move or be removed outright (such as moving blocks up & down, where it's briefly removed when replacing blocks). However, as no mouseover event is fired, mouseHoveredLinkMark doesn't get cleared and so an error is thrown if the link doesn't exist.

Therefore, this PR changes the behaviour so that only keyboardHoveredLinkMark is considered when updating the link toolbar, unless the update was explicitly called by the mouseover handler.

Closes #1479

Copy link

vercel bot commented Mar 4, 2025

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Mar 4, 2025 3:16pm
blocknote-website ✅ Ready (Inspect) Visit Preview Mar 4, 2025 3:16pm

}

update(view: EditorView, oldState?: EditorState) {
update(view: EditorView, oldState?: EditorState, fromMouseOver = false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I crazy to think that no one else is calling this update method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah this is part of the PluginView spec from ProseMirror, it automatically gets called on state updates (https://prosemirror.net/docs/ref/#state.PluginView). It's just harder to see that since in our case the view does a lot of stuff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also I guess normally you'd pass in a plain object, so the fact that we're using a class also obfuscates things

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohh ok. Eh, this definitely is a hack. But, I think it is okay for now

@nperez0111 nperez0111 merged commit 4a0e316 into main Mar 4, 2025
6 of 7 checks passed
@nperez0111 nperez0111 deleted the link-toolbar-error-fix branch March 4, 2025 15:13
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.

Move up multiple blocks - content disappear

2 participants