Support anchor links in page mentions

This commit is contained in:
Philipinho
2025-07-08 21:06:33 -07:00
parent b82171c24c
commit 703bfad424
12 changed files with 82 additions and 32 deletions
+19
View File
@@ -33,6 +33,11 @@ export interface MentionNodeAttrs {
* the id of the user who initiated the mention
*/
creatorId?: string;
/**
* the anchor hash for page mentions (e.g., "heading-1")
*/
anchor?: string;
}
export type MentionOptions<
@@ -246,6 +251,20 @@ export const Mention = Node.create<MentionOptions>({
};
},
},
anchor: {
default: null,
parseHTML: (element) => element.getAttribute("data-anchor"),
renderHTML: (attributes) => {
if (!attributes.anchor) {
return {};
}
return {
"data-anchor": attributes.anchor,
};
},
},
};
},