fix: do not use window.open for links in readonly mode (#4073)

* fix: do not use window.open for links in readonly mode

When `contenteditable` is `true`, the browser doesn't allow
direct link opens on clicking the `a` element. This is why we
need to call `window.open` to open our links.

However, when `contenteditable` is `false`, the default
browser mechanism for opening links works and there is no
need for using `window.open`.

* fix: linting errors
This commit is contained in:
Abdullah Atta 2023-07-07 18:31:41 +05:00 committed by GitHub
parent 3053865475
commit 4bca77e4e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,7 +22,9 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {
const target = link?.target ?? attrs.target
if (link && href) {
window.open(href, target)
if (view.editable) {
window.open(href, target)
}
return true
}