import { VoicePlaybackButton } from "./VoicePlaybackButton"; interface ChatBubbleProps { role: "user" | "character"; text: string; characterId?: string; userId?: string; } // H-3 動作描寫標記渲染:把 *…* 標記以暮空紫小字呈現,與台詞區分。 function renderContent(text: string) { const parts = text.split(/(*[^*]+*)/g).filter(Boolean); return parts.map((part, index) => { const match = part.match(/^*([^*]+)*$/); if (match) { return ( {match[1]} ); } return {part}; }); } export function ChatBubble({ role, text, characterId, userId }: ChatBubbleProps) { const isUser = role === "user"; return (
{renderContent(text)}
{/* P-6:語音播放介面只在角色訊息旁提供,使用者自己的訊息不需要播放。 */} {!isUser && characterId && userId && }
); }