Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fallback to active mark attributes for open and copy link at boundaries

kashaf-ansari-dev09b0ef83a459
diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsx
index 741948ee5..88df5739d 100644
--- a/packages/editor/src/toolbar/tools/link.tsx
+++ b/packages/editor/src/toolbar/tools/link.tsx
@@ -208,7 +208,10 @@ export function OpenLink(props: ToolProps) {
);
const { node } = selectedNode.current || {};
const link = node ? findMark(node, "link") : null;
- const href = link?.attrs.href ?? null;
+ const href =
+ link?.attrs.href ??
+ (getMarkAttributes(editor.state, "link")?.href as string) ??
+ null;
const [loading, setLoading] = useState(false);
const [linkData, setLinkData] = useState<LinkData | undefined>(undefined);
@@ -227,7 +230,7 @@ export function OpenLink(props: ToolProps) {
})();
}, [href]);
- if (!link || !href) return null;
+ if (!href) return null;
const title = linkData?.title || href;
@@ -285,8 +288,10 @@ export function CopyLink(props: ToolProps) {
);
const { node } = selectedNode.current || {};
const link = node ? findMark(node, "link") : null;
- if (!link) return null;
- const href = link?.attrs.href;
+ const href =
+ link?.attrs.href ??
+ (getMarkAttributes(editor.state, "link")?.href as string) ??
+ null;
if (!href) return null;
return (