fix: keep a header-only table without a filled body row - #350
Merged
Conversation
The GFM preset declares the table node as `table_header_row table_row+`, so a table authored without body rows has no legal representation and ProseMirror fills a cell-less row into it. That row reaches the rendered table as an empty `<tr>` but never reaches the file: the serializer writes the same two lines either way, and the document round-trips because the fill is deterministic, which is why neither the corpus guard nor a byte comparison can see it. Deleting the last body row still removes the table. A header-only table is now a shape a file can open, but producing one from a command is a separate decision.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
table_header_row table_row+totable_header_row table_row*. The+left a table authored without body rows with no legal representation, so ProseMirror filled a cell-less row into every one of them.docs/specification.mdthat a header-only table is kept and rendered as one, and make theDelete rowrule say what it does now that a header-only table is a valid shape.Related Issue
Closes #323
Verification
src/features/editor/plugins/tableShape.test.tsasserts the document rather than the bytes: a header-only table holds no body rows on open, preserves its document across a save, and writes back without a row. It also pins that a body row shorter than the header is still filled, which is #254's behavior through the same code.src/features/editor/commands/formatting/tables.test.tscovers the command paths the relaxed schema reaches:Add row belowfrom the header of a header-only table inserts the first body row, and deleting the only body row still removes the table.pnpm check:frontendpasses.Manually verified in the editor mount used by the plugin tests, on Windows:
| Header only | No body rows |with its delimiter row renders one<tr>; before the change it rendered a second, empty<tr>holding no cells.Not verified: no assembled-desktop run, and no manual pass in the built application.
Notes
The measurement in #323 said the save appended the row. It does not, and the issue has been corrected. The row was only ever in the document and the rendered table: the serializer writes the same two lines whether or not the empty row is present, and the document round-trips because the fill is deterministic, so neither the corpus guard nor a byte comparison could see it. The defect is document fidelity, not file content.
Deleting the last body row still removes the table rather than leaving its header. That is now a choice rather than a consequence of the schema, and changing it is a command decision this fix deliberately does not take.
The padding in the expected file output is the normalization
Preserve the form a file was written inaccepts, recorded in #348. The omitted outer pipes from the original #323 are #349.