diff --git a/components/Blocks/TextBlock/mountProsemirror.ts b/components/Blocks/TextBlock/mountProsemirror.ts index 965f8a43..ff646a80 100644 --- a/components/Blocks/TextBlock/mountProsemirror.ts +++ b/components/Blocks/TextBlock/mountProsemirror.ts @@ -80,6 +80,23 @@ export function useMountProsemirror({ handlePaste, handleClickOn: (_view, _pos, node, _nodePos, _event, direct) => { if (!direct) return; + + // Check for didMention inline nodes + if (node?.type === schema.nodes.didMention) { + window.open( + didToBlueskyUrl(node.attrs.did), + "_blank", + "noopener,noreferrer", + ); + return; + } + + // Check for atMention inline nodes + if (node?.type === schema.nodes.atMention) { + const url = atUriToUrl(node.attrs.atURI); + window.open(url, "_blank", "noopener,noreferrer"); + return; + } if (node.nodeSize - 2 <= _pos) return; // Check for marks at the clicked position @@ -87,34 +104,13 @@ export function useMountProsemirror({ const nodeAt2 = node.nodeAt(Math.max(_pos - 2, 0)); // Check for link marks - let linkMark = nodeAt1?.marks.find((f) => f.type === schema.marks.link) || + let linkMark = + nodeAt1?.marks.find((f) => f.type === schema.marks.link) || nodeAt2?.marks.find((f) => f.type === schema.marks.link); if (linkMark) { window.open(linkMark.attrs.href, "_blank"); return; } - - // Check for didMention inline nodes - if (nodeAt1?.type === schema.nodes.didMention) { - window.open(didToBlueskyUrl(nodeAt1.attrs.did), "_blank", "noopener,noreferrer"); - return; - } - if (nodeAt2?.type === schema.nodes.didMention) { - window.open(didToBlueskyUrl(nodeAt2.attrs.did), "_blank", "noopener,noreferrer"); - return; - } - - // Check for atMention inline nodes - if (nodeAt1?.type === schema.nodes.atMention) { - const url = atUriToUrl(nodeAt1.attrs.atURI); - window.open(url, "_blank", "noopener,noreferrer"); - return; - } - if (nodeAt2?.type === schema.nodes.atMention) { - const url = atUriToUrl(nodeAt2.attrs.atURI); - window.open(url, "_blank", "noopener,noreferrer"); - return; - } }, dispatchTransaction, }, diff --git a/src/utils/mentionUtils.ts b/src/utils/mentionUtils.ts index 706928e0..8e97482f 100644 --- a/src/utils/mentionUtils.ts +++ b/src/utils/mentionUtils.ts @@ -19,11 +19,8 @@ export function atUriToUrl(atUri: string): string { const uri = new AtUri(atUri); if (isPublicationCollection(uri.collection)) { - // Publication URL: /lish/{did}/{rkey} - return `/lish/${uri.host}/${uri.rkey}`; + return `/lish/uri/${encodeURIComponent(atUri)}`; } else if (isDocumentCollection(uri.collection)) { - // Document URL - we need to resolve this via the API - // For now, create a redirect route that will handle it return `/lish/uri/${encodeURIComponent(atUri)}`; } @@ -42,7 +39,7 @@ export function atUriToUrl(atUri: string): string { export function handleMentionClick( e: MouseEvent | React.MouseEvent, type: "did" | "at-uri", - value: string + value: string, ) { e.preventDefault(); e.stopPropagation();