with open("frontend/src/App.tsx", "r", encoding="utf-8") as f: content = f.read() # Add ContentPaste to imports content = content.replace("CallSplit,", "CallSplit,\n ContentPaste,") content = content.replace("import { IconButton, Tooltip } from \"@mui/material\";", "import { IconButton, Tooltip, InputAdornment } from \"@mui/material\";") if "InputAdornment" not in content: content = content.replace("TextField,", "TextField,\n InputAdornment,") old_start_input = """ handleSegmentDraftChange(rowIndex, "start", e.target.value)} onBlur={() => commitSegmentDraft(rowIndex, "start")} onKeyDown={(e) => { if (e.key === "Enter") { commitSegmentDraft(rowIndex, "start"); } }} disabled={!row.startEditable} inputProps={{ style: { fontFamily: "monospace" } }} />""" new_start_input = """ handleSegmentDraftChange(rowIndex, "start", e.target.value)} onBlur={() => commitSegmentDraft(rowIndex, "start")} onKeyDown={(e) => { if (e.key === "Enter") { commitSegmentDraft(rowIndex, "start"); } }} disabled={!row.startEditable} inputProps={{ style: { fontFamily: "monospace" } }} InputProps={{ endAdornment: row.startEditable ? ( { e.preventDefault(); try { const text = await navigator.clipboard.readText(); handleSegmentDraftChange(rowIndex, "start", text); setTimeout(() => commitSegmentDraft(rowIndex, "start"), 50); } catch (err) {} }} > ) : null }} />""" content = content.replace(old_start_input, new_start_input) old_end_input = """ handleSegmentDraftChange(rowIndex, "end", e.target.value)} onBlur={() => commitSegmentDraft(rowIndex, "end")} onKeyDown={(e) => { if (e.key === "Enter") { commitSegmentDraft(rowIndex, "end"); } }} disabled={!row.endEditable} inputProps={{ style: { fontFamily: "monospace" } }} />""" new_end_input = """ handleSegmentDraftChange(rowIndex, "end", e.target.value)} onBlur={() => commitSegmentDraft(rowIndex, "end")} onKeyDown={(e) => { if (e.key === "Enter") { commitSegmentDraft(rowIndex, "end"); } }} disabled={!row.endEditable} inputProps={{ style: { fontFamily: "monospace" } }} InputProps={{ endAdornment: row.endEditable ? ( { e.preventDefault(); try { const text = await navigator.clipboard.readText(); handleSegmentDraftChange(rowIndex, "end", text); setTimeout(() => commitSegmentDraft(rowIndex, "end"), 50); } catch (err) {} }} > ) : null }} />""" content = content.replace(old_end_input, new_end_input) with open("frontend/src/App.tsx", "w", encoding="utf-8") as f: f.write(content) print("App.tsx paste buttons patched")