mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
feat(assistant): chat, note and poll cards drawn like the Collab tab
This commit is contained in:
@@ -1,19 +1,28 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { URL_REGEX } from './CollabChat.constants'
|
||||
|
||||
/* ── Message Text with clickable URLs ── */
|
||||
interface MessageTextProps {
|
||||
text: string
|
||||
/** Links read as underlined words that open nothing, as in the assistant chat's copy of a message. */
|
||||
plain?: boolean
|
||||
}
|
||||
|
||||
export function MessageText({ text }: MessageTextProps) {
|
||||
export function MessageText({ text, plain = false }: MessageTextProps) {
|
||||
const parts = text.split(URL_REGEX)
|
||||
const urls = text.match(URL_REGEX) || []
|
||||
const result = []
|
||||
const result: ReactNode[] = []
|
||||
parts.forEach((part, i) => {
|
||||
if (part) result.push(part)
|
||||
if (urls[i]) result.push(
|
||||
<a key={i} href={urls[i]} target="_blank" rel="noopener noreferrer" style={{ color: 'inherit', textDecoration: 'underline', textUnderlineOffset: 2, opacity: 0.85 }}>
|
||||
{urls[i]}
|
||||
const url = urls[i]
|
||||
if (url && plain) result.push(
|
||||
<span key={i} style={{ textDecoration: 'underline', textUnderlineOffset: 2, opacity: 0.85, overflowWrap: 'anywhere' }}>
|
||||
{url}
|
||||
</span>
|
||||
)
|
||||
else if (url) result.push(
|
||||
<a key={i} href={url} target="_blank" rel="noopener noreferrer" style={{ color: 'inherit', textDecoration: 'underline', textUnderlineOffset: 2, opacity: 0.85 }}>
|
||||
{url}
|
||||
</a>
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user