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: Link toolbar update error #1486

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/core/src/extensions/LinkToolbar/LinkToolbarPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LinkToolbarView implements PluginView {

this.startMenuUpdateTimer = () => {
this.menuUpdateTimer = setTimeout(() => {
this.update(this.pmView);
this.update(this.pmView, undefined, true);
}, 250);
};

Expand Down Expand Up @@ -190,7 +190,7 @@ class LinkToolbarView implements PluginView {
}
}

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

const { state } = view;

const isSame =
Expand Down Expand Up @@ -235,7 +235,7 @@ class LinkToolbarView implements PluginView {
}
}

if (this.mouseHoveredLinkMark) {
if (this.mouseHoveredLinkMark && fromMouseOver) {
this.linkMark = this.mouseHoveredLinkMark;
this.linkMarkRange = this.mouseHoveredLinkMarkRange;
}
Expand Down
Loading