fix(editor): guard unresolved page mentions and bare anchor links

A page mention without a slug rendered as a link ending in -null; it now
renders as plain text. A link whose href is a bare #fragment scrolls to
the target on the current page instead of opening about:blank.
This commit is contained in:
Philipinho
2026-09-07 05:03:28 +01:00
parent caf049a181
commit 84aea058f3
2 changed files with 29 additions and 3 deletions
@@ -224,6 +224,16 @@ export default function LinkView(props: MarkViewProps) {
const handleNavigate = useCallback(() => {
if (!href) return;
if (href.startsWith("#")) {
const anchor = href.slice(1);
const element =
document.querySelector(`[id="${anchor}"]`) ||
document.querySelector(`[data-id="${anchor}"]`);
element?.scrollIntoView({ behavior: "smooth", block: "start" });
navigate(`${location.pathname}#${anchor}`, { replace: true });
return;
}
if (isInternal) {
let targetPath = href;
let anchor = "";