bc-grid
GitHub

Copy / paste

View source

Cmd+C copies the active range as TSV (tab-separated values, the format Excel and Google Sheets use). Cmd+V pastes TSV back, applying value parsers + per-column validate, with atomic rollback on failure.

Edit a cell, drag a range, Cmd+C, paste back to overwrite. Paste-driven commits show source: "paste".0 cells updated via paste
Order #
Customer
Sales rep
Amount
Status
Region
R-000001
Customer 00001
Avery Chen
$0.00
active
North
R-000002
Customer 00002
Ben Singh
$31.42
pending
North
R-000003
Customer 00003
Cara Diaz
$62.83
closed
North
R-000004
Customer 00004
Drew Lin
$94.25
active
North
R-000005
Customer 00005
Elena Park
$125.66
pending
South
R-000006
Customer 00006
Felix Roy
$157.08
closed
South
R-000007
Customer 00007
Gita Bose
$188.50
active
South
R-000008
Customer 00008
Henry Kao
$219.91
pending
South
R-000009
Customer 00009
Avery Chen
$251.33
closed
East
R-000010
Customer 00010
Ben Singh
$282.74
active
East
R-000011
Customer 00011
Cara Diaz
$314.16
pending
East
R-000012
Customer 00012
Drew Lin
$345.57
closed
East
R-000013
Customer 00013
Elena Park
$376.99
active
West
R-000014
Customer 00014
Felix Roy
$408.41
pending
West
R-000015
Customer 00015
Gita Bose
$439.82
closed
West

Try this

Customer / Sales rep / Amount columns are editable. Status / Region are read-only — pasting into them is silently skipped.

  • Click a cell, drag to select a range, then Cmd+C.
  • Paste it into Excel / Sheets / VSCode — same rectangular shape.
  • Now click a different anchor cell in the grid and Cmd+V — the values overwrite from that anchor.
  • Copy a single column from Excel and paste in — works the same way.
  • Try pasting non-numeric text into Amount — the cell rejects, the row rolls back, the error surfaces in the cell.

Copy

  • TSV by default. Cmd+C on a range emits TSV using each cell's formatted value (the same value the renderer paints). Round-trip-safe with Excel.
  • HTML alongside. Where the platform allows multiple clipboard formats, bc-grid also writes an HTML table mirror so paste targets that prefer HTML (e.g. rich-text editors) get a styled table.
  • Hooks. onCopy lets the consumer transform or augment the clipboard payload (e.g. add a JSON variant for round-trip-safe paste back into this app).

Paste

  • TSV parsed. Paste from Excel / Sheets / any TSV — bc-grid splits rows by \\n, cells by \\t, and walks the active cell as the anchor.
  • Through the column pipeline. Each pasted cell goes through column.valueParser (string → typed value) and column.validate before commit. A rejected cell rolls back the whole row patch.
  • Read-only cells skipped. Cells in non-editable columns are ignored without aborting the paste; pasted rectangle keeps its alignment.
  • Source = "paste". onCellEditCommit fires for each accepted cell with source: "paste" so consumers can branch (audit log, telemetry, etc.).
  • Imperative API. apiRef.current?.pasteTsv(tsv, { mode }) for programmatic paste (e.g. drag-drop a CSV file onto the grid).