import { Tooltip, Typography } from "antd"; import { type Change, diffChars } from "diff" const { Text } = Typography; interface IWidget { content?: string | null; oldContent?: string | null; showToolTip?: boolean; } const TextDiffWidget = ({ content, oldContent, showToolTip = true, }: IWidget) => { if (content) { if (oldContent) { const diff: Change[] = diffChars(oldContent, content); const diffResult = diff.map((item, id) => { return ( {item.value} ); }); return showToolTip ? (
{diffResult}
) : (
{diffResult}
); } else { return {content}; } } else { return <>; } }; export default TextDiffWidget;