import React, { useState } from "react"; const INVISIBLE_COMMENT_CHARS = /[\u200B-\u200D\u2060-\u206F\uFEFF]/g; /** * CommentTrack is a tiny demonstration component that allows users to add * comments to a list. It purposely avoids persistence and rich features so the * surrounding editor pages remain lightweight. */ export default function CommentTrack() { const [comment, setComment] = useState(""); const [comments, setComments] = useState([]); function add() { const cleaned = comment.replace(INVISIBLE_COMMENT_CHARS, ""); const trimmed = cleaned.trim(); if (!trimmed) return; // Use functional updates to avoid stale state when called rapidly setComments((prev: string[]) => [...prev, trimmed]); setComment(""); } return (
setComment(e.target.value)} placeholder="Add a comment for this draft" />
{comments.length > 0 && ( )}
); }