Allow click on link decoration to open, closes #4076

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

No files matched your search

+1
View File
@@ -755,6 +755,7 @@ mark {
}
.external-link {
cursor: pointer;
display: inline-block;
position: relative;
top: 2px;
+17 -1
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,