AlexandrAI AGENTS.md
agents-md

HTML Editor Sheet and Table Grid Agent Guide

Module-specific agent guide for top-level sheets, slide tables, grid commands, and TSV paste.

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.ts defines cellSchema, sheetNode, and tableNode.
  • src/model/command.ts applies cell.set and grid.set to either a sheet or a slide table.
  • src/renderer/src/state/grid.ts owns pure helpers for adding rows, removing rows, adding columns, removing columns, TSV paste, and merge metadata.
  • src/renderer/src/render/renderModel.ts renders grids with cellGridTable.
  • src/renderer/src/ui/PropertyPanel.tsx exposes 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 through cell.set.
  • Keep grid helpers pure and return new GridSnapshot objects.
  • 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 test and npm run typecheck pass.