From 46606abbf960fd55576f1b244febbaee0ee46a23 Mon Sep 17 00:00:00 2001
From: ajvpot <553597+ajvpot@users.noreply.github.com>
Date: Thu, 11 Sep 2025 17:53:13 +0200
Subject: [PATCH] Replies/highlights
---
src/components/ChatMessageItem.tsx | 62 ++++++++++++++++++++----------
1 file changed, 41 insertions(+), 21 deletions(-)
diff --git a/src/components/ChatMessageItem.tsx b/src/components/ChatMessageItem.tsx
index 92d78a5..cf0986b 100644
--- a/src/components/ChatMessageItem.tsx
+++ b/src/components/ChatMessageItem.tsx
@@ -27,28 +27,48 @@ function formatLocalTime(utcString: string): string {
return utcDate.toLocaleString();
}
-function linkifyText(text: string): React.ReactNode {
- // URL regex pattern to match http/https URLs
- const urlRegex = /(https?:\/\/[^\s]+)/g;
+function ChatMessageContent({ text }: { text: string }) {
+ // Combined regex to match both URLs and @[node_name] patterns
+ const combinedRegex = /(https?:\/\/[^\s]+|@\[[^\]]+\])/g;
- const parts = text.split(urlRegex);
+ const parts = text.split(combinedRegex);
- return parts.map((part, index) => {
- if (urlRegex.test(part)) {
- return (
-
- {part}
-
- );
- }
- return part;
- });
+ return (
+ <>
+ {parts.map((part, index) => {
+ // Check if it's a URL
+ if (/^https?:\/\//.test(part)) {
+ return (
+
+ {part}
+
+ );
+ }
+
+ // Check if it's a node mention @[node_name]
+ if (/^@\[.+\]$/.test(part)) {
+ const nodeName = part.slice(2, -1); // Remove @[ and ]
+ return (
+
+ @{nodeName}
+
+ );
+ }
+
+ // Regular text
+ return part;
+ })}
+ >
+ );
}
function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessage, showErrorRow?: boolean }) {
@@ -102,7 +122,7 @@ function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessage, showErrorRow
) : null}
{parsed.sender && ": "}
- {linkifyText(parsed.text)}
+