支持消息 Markdown 与欢迎语富文本
聊天/离线提示使用 Markdown 安全渲染;欢迎语改为 TipTap 富文本(颜色字号),DOMPurify 白名单清洗后展示。
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
||||
} from '@ant-design/icons'
|
||||
import EmojiPicker, { insertAtCursor } from '@/components/common/EmojiPicker'
|
||||
import { ChatImage } from '@/components/common/ImagePreview'
|
||||
import MarkdownBody from '@/components/common/MarkdownBody'
|
||||
import SafeHtml, { looksLikeHtml } from '@/components/common/SafeHtml'
|
||||
|
||||
interface Message {
|
||||
id: number
|
||||
@@ -949,15 +951,23 @@ const VisitorChat = ({
|
||||
) : (
|
||||
<div
|
||||
key={`w-${i}`}
|
||||
className="px-4 py-2.5 rounded-xl bg-white border border-neutral-200 text-[13px] text-neutral-700 leading-normal whitespace-pre-wrap"
|
||||
className="px-4 py-2.5 rounded-xl bg-white border border-neutral-200 text-[13px] text-neutral-700 leading-normal"
|
||||
>
|
||||
{seg.content}
|
||||
{looksLikeHtml(seg.content) ? (
|
||||
<SafeHtml html={seg.content} />
|
||||
) : (
|
||||
<MarkdownBody>{seg.content}</MarkdownBody>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
)
|
||||
) : (
|
||||
<div className="px-4 py-2.5 rounded-xl bg-white border border-neutral-200 text-[13px] text-neutral-600 leading-normal">
|
||||
{offlinePrompt}
|
||||
{looksLikeHtml(offlinePrompt) ? (
|
||||
<SafeHtml html={offlinePrompt} />
|
||||
) : (
|
||||
<MarkdownBody>{offlinePrompt}</MarkdownBody>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -986,7 +996,7 @@ const VisitorChat = ({
|
||||
{msg.type === 'image' ? (
|
||||
<ChatImage src={msg.content} alt="图片" className="max-w-[180px] max-h-[180px]" />
|
||||
) : (
|
||||
<p className="m-0 whitespace-pre-wrap break-words">{msg.content}</p>
|
||||
<MarkdownBody tone="inverse">{msg.content}</MarkdownBody>
|
||||
)}
|
||||
</div>
|
||||
{msg.time && (
|
||||
@@ -1003,7 +1013,7 @@ const VisitorChat = ({
|
||||
{msg.type === 'image' ? (
|
||||
<ChatImage src={msg.content} alt="图片" className="max-w-[180px] max-h-[180px]" />
|
||||
) : (
|
||||
<p className="m-0 whitespace-pre-wrap break-words">{msg.content}</p>
|
||||
<MarkdownBody>{msg.content}</MarkdownBody>
|
||||
)}
|
||||
</div>
|
||||
{msg.time && (
|
||||
|
||||
Reference in New Issue
Block a user