fix: Clicking internal links in shared documents sometimes reroutes to Login

This commit is contained in:
Tom Moor
2022-02-22 19:57:42 -08:00
parent 63265b49ea
commit f244e864e1
2 changed files with 18 additions and 3 deletions

View File

@@ -159,10 +159,11 @@ export default class Link extends Mark {
props: {
decorations: (state) => plugin.getState(state),
handleDOMEvents: {
mouseover: (_view, event: MouseEvent) => {
mouseover: (view, event: MouseEvent) => {
if (
event.target instanceof HTMLAnchorElement &&
!event.target.className.includes("ProseMirror-widget")
!event.target.className.includes("ProseMirror-widget") &&
(!view.editable || (view.editable && !view.hasFocus()))
) {
if (this.options.onHoverLink) {
return this.options.onHoverLink(event);
@@ -199,6 +200,20 @@ export default class Link extends Mark {
return true;
}
return false;
},
click: (view, event) => {
if (!(event.target instanceof HTMLAnchorElement)) {
return false;
}
// Prevent all default click behavior of links, see mousedown above
// for custom link handling.
if (this.options.onClickLink) {
event.stopPropagation();
event.preventDefault();
}
return false;
},
},

View File

@@ -248,8 +248,8 @@
"Restore": "Restore",
"Choose a collection": "Choose a collection",
"Unpublish": "Unpublish",
"Permanently delete": "Permanently delete",
"Move": "Move",
"Permanently delete": "Permanently delete",
"Enable embeds": "Enable embeds",
"Disable embeds": "Disable embeds",
"Full width": "Full width",