mirror of
https://github.com/docmost/docmost.git
synced 2026-09-11 07:56:54 +08:00
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:
@@ -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 = "";
|
||||
|
||||
Reference in New Issue
Block a user