mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-29 06:28:23 +02:00
- Fix issue mention cards incorrectly triggering Link Hover Card - Guard editor.view access in BubbleMenu against unmounted/destroyed view Proxy (fixes desktop Inbox fast-switching crash) - Use useEditorState for precise formatting state subscriptions in BubbleMenu instead of relying on parent re-renders - Add markdownTokenizer to FileCard for unambiguous !file[name](url) roundtrip syntax (legacy CDN hostname matching kept for compat) - Extract shared openLink/isMentionHref into utils/link-handler.ts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
780 B
TypeScript
23 lines
780 B
TypeScript
/**
|
|
* Shared link handling utilities for the editor system.
|
|
*
|
|
* Used by content-editor (ProseMirror click handler), readonly-content
|
|
* (react-markdown link component), and link-hover-card (Open button).
|
|
*/
|
|
|
|
/** Open a link — internal paths dispatch multica:navigate, external open new tab. */
|
|
export function openLink(href: string): void {
|
|
if (href.startsWith("/")) {
|
|
window.dispatchEvent(
|
|
new CustomEvent("multica:navigate", { detail: { path: href } }),
|
|
);
|
|
} else {
|
|
window.open(href, "_blank", "noopener,noreferrer");
|
|
}
|
|
}
|
|
|
|
/** Check if a href is a mention protocol link (should not be opened as a regular link). */
|
|
export function isMentionHref(href: string | null | undefined): href is string {
|
|
return !!href && href.startsWith("mention://");
|
|
}
|