Not only code: a writing assistant tightens a Markdown release note, with `wrap` on and no line numbers. The reply under it follows `onComplete` and `onReview`.
registry/demos/diff-apply-copy-demo.tsx
"use client";
import * as React from "react";
import { DiffApply, type DiffApplyDecision } from "@/components/ui/diff-apply";
const before = `
## Tinta 2.4
We are really excited to announce that Tinta 2.4 is finally here and available for everyone to use today!
### What's new
- Exports are now a lot faster than they used to be.
- Fixed a bug where some people could sometimes not sign in.
- Dark mode.
Thanks to everyone who sent us feedback!
`;
const after = `
## Tinta 2.4
Tinta 2.4 is out today.
### What's new
- PDF exports finish up to 3× faster.
- Fixed sign-in failing for accounts created with Google.
- Dark mode now follows your system setting.
Thanks to the 412 people who sent feedback during the beta.
`;
export function DiffApplyCopyDemo() {
const [done, setDone] = React.useState(false);
const [decisions, setDecisions] = React.useState<DiffApplyDecision[]>([]);
const kept = decisions.filter((d) => d === "kept").length;
const undone = decisions.filter((d) => d === "undone").length;
const reviewed = decisions.length > 0 && decisions.every((d) => d !== "pending");
return (
<div className="flex w-full max-w-xl flex-col gap-3">
<div className="ml-auto max-w-[85%] rounded-2xl rounded-br-md bg-zinc-900 px-3.5 py-2 text-[14px] leading-snug text-white dark:bg-zinc-100 dark:text-zinc-900">
Tighten this for the changelog. Be specific.
</div>
<DiffApply
filename="release-notes.md"
before={before}
after={after}
wrap
lineNumbers={false}
onComplete={() => setDone(true)}
onReview={setDecisions}
/>
<p
aria-live="polite"
className="min-h-5 px-1 text-[13px] text-zinc-500 transition-opacity duration-300 dark:text-zinc-400"
style={{ opacity: done ? 1 : 0 }}
>
{reviewed
? kept === decisions.length
? "All three edits kept. Ready to publish."
: `${kept} kept, ${undone} undone.`
: "Cut 12 words and named the numbers. Keep what reads right."}
</p>
</div>
);
}
Live preview, examples and props: https://keyframeui.com/components/diff-apply#diff-apply-copy-demo