From 4bca77e4e9c96596d584cf71b8d831dc2ab0a421 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Fri, 7 Jul 2023 18:31:41 +0500 Subject: [PATCH] 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 --- packages/extension-link/src/helpers/clickHandler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/extension-link/src/helpers/clickHandler.ts b/packages/extension-link/src/helpers/clickHandler.ts index 64360acb3..5312881ca 100644 --- a/packages/extension-link/src/helpers/clickHandler.ts +++ b/packages/extension-link/src/helpers/clickHandler.ts @@ -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 }