Allow click on link decoration to open, closes #4076
This commit is contained in:
@@ -755,6 +755,7 @@ mark {
|
||||
}
|
||||
|
||||
.external-link {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user