Timothy Jaeryang Baek 3 هفته پیش
والد
کامیت
d8ad384b06
1فایلهای تغییر یافته به همراه25 افزوده شده و 2 حذف شده
  1. 25 2
      src/lib/components/chat/Messages/Markdown/MarkdownInlineTokens/MentionToken.svelte

+ 25 - 2
src/lib/components/chat/Messages/Markdown/MarkdownInlineTokens/MentionToken.svelte

@@ -3,8 +3,31 @@
 	import Tooltip from '$lib/components/common/Tooltip.svelte';
 
 	export let token: Token;
+
+	let triggerChar = '';
+	let label = '';
+
+	let idType = '';
+	let id = '';
+
+	$: if (token) {
+		init();
+	}
+
+	const init = () => {
+		const _id = token?.id;
+		if (_id?.includes(':')) {
+			idType = _id.split(':')[0];
+			id = _id.split(':')[1];
+		} else {
+			id = _id;
+		}
+
+		label = token?.label ?? id;
+		triggerChar = token?.triggerChar ?? '@';
+	};
 </script>
 
-<Tooltip as="span" className="mention" content={token.id} placement="top">
-	{token?.triggerChar ?? '@'}{token?.label ?? token?.id}
+<Tooltip as="span" className="mention" content={id} placement="top">
+	{triggerChar}{label}
 </Tooltip>