import { REWRITE_STYLES } from './SelectionBubble' // RewritePreview shows the result of a tone-rewrite before it touches the // document: the writer's original passage, the model's rewrite beneath it, and // accept/cancel. It mirrors the SuggestionCard's warm, bilingual chrome. While // the model runs it shows a breathing dot; on failure it offers a gentle retry. export type RewriteStatus = 'loading' | 'ready' | 'error' interface Props { style: string // the chosen rewrite style key (for the header label) status: RewriteStatus original: string rewrite: string cardStyle: React.CSSProperties onAccept: () => void onCancel: () => void onRetry: () => void } const CJK = "'Nunito','PingFang SC','Microsoft YaHei','Noto Sans CJK SC',sans-serif" export function RewritePreview({ style, status, original, rewrite, cardStyle, onAccept, onCancel, onRetry, }: Props) { const meta = REWRITE_STYLES.find((s) => s.value === style) ?? REWRITE_STYLES[0] return (
e.stopPropagation()} style={{ width: 340, background: 'var(--color-surface)', border: '1px solid var(--color-border)', borderRadius: 'var(--radius-card)', boxShadow: 'var(--shadow-soft)', fontFamily: CJK, ...cardStyle, }} >
{meta.emoji} {meta.zh} · {meta.en} 改写 · Rewrite
{/* Original passage, dimmed — what's being replaced. */}

{original}

{status === 'loading' && (
改写中… · Rewriting…
)} {status === 'error' && (

改写失败,请再试一次 · Couldn’t rewrite — try again

)} {status === 'ready' && ( <>

{rewrite}

)}
) }