AGENTS.md
Guidance for coding agents working on HTML Editor Sheet and Table Grid in the html-editor project.
Project overview
This guide covers grid behavior shared by top-level sheets and slide-contained table nodes. The model stores sparse cells with zero-based row and column indexes. Structural grid changes produce a grid.set command with before and after snapshots so undo can restore the entire grid state.
Primary source files
src/model/schema.tsdefinescellSchema,sheetNode, andtableNode.src/model/command.tsappliescell.setandgrid.setto either a sheet or a slide table.src/renderer/src/state/grid.tsowns pure helpers for adding rows, removing rows, adding columns, removing columns, TSV paste, and merge metadata.src/renderer/src/render/renderModel.tsrenders grids withcellGridTable.src/renderer/src/ui/PropertyPanel.tsxexposes grid operations and TSV paste.
Setup commands
npm install npm test npm run typecheck npm run build
For focused validation, run npm test -- src/renderer/src/state/grid.test.ts src/model/command.test.ts when available.
Change rules
- Keep row and column indexes zero-based throughout schema, command, renderer, and UI code.
- Apply grid structure changes through
grid.set; apply single cell text changes throughcell.set. - Keep grid helpers pure and return new
GridSnapshotobjects. - Expand rows and columns when TSV paste extends beyond current bounds.
- When removing a row or column, shift remaining cell coordinates down or left and preserve unrelated cells.
Render contract
cellGridTable skips cells covered by merge spans, emits table cells with data-editor-cell, and writes optional column widths into a colgroup. If merge behavior changes, update rendering and command tests together.
Testing
Test sheets and slide tables. Cover paste with trailing newline, paste beyond bounds, row removal, column removal, column width insertion, and merge span rendering.
PR checklist
- Grid helpers remain pure.
- Both sheet and table paths are covered.
- TSV paste does not introduce invalid indexes.
- Full
npm testandnpm run typecheckpass.