fix: harden external link navigation in the web app

- add a shared external-navigation guard at the document level
- route onboarding, markdown, settings, and node source links through one helper
- stop browser fallback code from replacing the current app page on failures

Generated with Codex
This commit is contained in:
“BeeRad”
2026-03-17 18:20:37 +11:00
parent 213c054c9f
commit 7444599817
8 changed files with 164 additions and 41 deletions
@@ -3,6 +3,7 @@
import React from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { openExternalUrl, shouldOpenExternally } from '@/utils/openExternalUrl';
interface NodeLabelInlineProps {
id: string;
@@ -197,8 +198,17 @@ export default function MarkdownWithNodeTokens({ content, onNodeClick }: Markdow
a: ({ href, children }) => (
<a
href={href}
target="_blank"
rel="noopener noreferrer"
onClick={(event) => {
if (!href || !shouldOpenExternally(href)) {
return;
}
event.preventDefault();
void openExternalUrl(href).catch((error) => {
console.error('[MarkdownWithNodeTokens] Failed to open external link', error);
window.alert(`Unable to open ${href}`);
});
}}
style={{ color: '#22c55e', textDecoration: 'underline' }}
>
{processChildren(children, 'a')}