Allow click on link decoration to open, closes #4076

This commit is contained in:
Tom Moor
2022-09-22 21:14:07 -04:00
parent da62307b43
commit 7da4b50f4f
2 changed files with 18 additions and 1 deletions

View File

@@ -755,6 +755,7 @@ mark {
}
.external-link {
cursor: pointer;
display: inline-block;
position: relative;
top: 2px;

View File

@@ -160,7 +160,23 @@ export default class Link extends Mark {
Decoration.widget(
// place the decoration at the end of the link
nodeWithPos.pos + nodeWithPos.node.nodeSize,
() => icon.cloneNode(true),
() => {
const cloned = icon.cloneNode(true);
cloned.addEventListener("click", (event) => {
try {
if (this.options.onClickLink) {
event.stopPropagation();
event.preventDefault();
this.options.onClickLink(linkMark.attrs.href, event);
}
} catch (err) {
this.editor.props.onShowToast(
this.options.dictionary.openLinkError
);
}
});
return cloned;
},
{
// position on the right side of the position
side: 1,