From cbe65ddcd7ad407bd7099ad34c2f49a6b463b4e1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 17 Feb 2022 20:08:04 -0800 Subject: [PATCH] fix: Clicking links when editor hasn't been focused should navigate --- app/editor/components/Styles.ts | 6 ++++++ shared/editor/marks/Link.tsx | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/editor/components/Styles.ts b/app/editor/components/Styles.ts index 7436a4c45..527c3b94c 100644 --- a/app/editor/components/Styles.ts +++ b/app/editor/components/Styles.ts @@ -548,6 +548,12 @@ const EditorStyles = styled.div<{ cursor: pointer; } + .ProseMirror-focused { + a { + cursor: text; + } + } + a:hover { text-decoration: ${(props) => (props.readOnly ? "underline" : "none")}; } diff --git a/shared/editor/marks/Link.tsx b/shared/editor/marks/Link.tsx index 6fb579327..64611b391 100644 --- a/shared/editor/marks/Link.tsx +++ b/shared/editor/marks/Link.tsx @@ -170,14 +170,14 @@ export default class Link extends Mark { } return false; }, - click: (view, event: MouseEvent) => { + mousedown: (view, event: MouseEvent) => { if (!(event.target instanceof HTMLAnchorElement)) { return false; } // clicking a link while editing should show the link toolbar, // clicking in read-only will navigate - if (!view.editable) { + if (!view.editable || (view.editable && !view.hasFocus())) { const href = event.target.href || (event.target.parentNode instanceof HTMLAnchorElement