mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-25 12:05:06 +02:00
- Move 55 shadcn components → packages/ui/components/ui/ - Move lib/utils.ts (cn function) → packages/ui/lib/ - Move 3 DOM hooks (auto-scroll, mobile, scroll-fade) → packages/ui/hooks/ - Extract CSS design tokens (@theme + :root + .dark) → packages/ui/styles/tokens.css - Refactor 3 common components to pure-props (actor-avatar, mention-hover-card, reaction-bar) - Move 6 markdown components with renderMention slot for IssueMentionCard decoupling - Create wrapper components in apps/web/ for data-aware ActorAvatar and Markdown - Update 116 import paths across apps/web/ - Add @source directives for Tailwind to scan packages Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
931 B
TypeScript
26 lines
931 B
TypeScript
/**
|
|
* Convert legacy mention shortcodes [@ id="UUID" label="LABEL"] to the
|
|
* standard markdown link format [@LABEL](mention://member/UUID).
|
|
*
|
|
* These shortcodes exist in older database records from a previous mention
|
|
* serialization format. This function normalises them so downstream parsers
|
|
* (Tiptap @tiptap/markdown, react-markdown) only need to handle one syntax.
|
|
*/
|
|
export function preprocessMentionShortcodes(text: string): string {
|
|
if (!text.includes("[@ ")) return text;
|
|
return text.replace(
|
|
/\[@\s+([^\]]*)\]/g,
|
|
(match, attrString: string) => {
|
|
const attrs: Record<string, string> = {};
|
|
const re = /(\w+)="([^"]*)"/g;
|
|
let m;
|
|
while ((m = re.exec(attrString)) !== null) {
|
|
if (m[1] && m[2] !== undefined) attrs[m[1]] = m[2];
|
|
}
|
|
const { id, label } = attrs;
|
|
if (!id || !label) return match;
|
|
return `[@${label}](mention://member/${id})`;
|
|
},
|
|
);
|
|
}
|