fix(extension-link): Click handler opens selected link instead of clicked link (#3732)

This commit is contained in:
James Taber 2023-02-18 17:19:04 +01:00 committed by GitHub
parent a81019a6b7
commit 6997bcad6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,8 +14,11 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {
const attrs = getAttributes(view.state, options.type.name)
const link = (event.target as HTMLElement)?.closest('a')
if (link && attrs.href) {
window.open(attrs.href, attrs.target)
const href = link?.href ?? attrs.href
const target = link?.target ?? attrs.target
if (link && href) {
window.open(href, target)
return true
}