Skip to content

Commit

Permalink
fix: do not use window.open for links in readonly mode (#4073)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thecodrr authored Jul 7, 2023
1 parent 3053865 commit 4bca77e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/extension-link/src/helpers/clickHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4bca77e

Please sign in to comment.