editor: a rich-text body followed by two or more item rows fails to load (adjacent text nodes) #230
Labels
No labels
bug
enhancement
needs-triage
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/deckle#230
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happens
An items owner (text-media, image, figures) whose file pretty-prints its body and rows onto their own lines cannot be opened in the editor once it has two or more rows:
GET /api/element/bodyanswers422 {"error":"adjacent text nodes","code":"error.unexpected"}and the form never opens. With one row it loads. This is exactly the shape the shippedtext-media.yamlcomment and AGENTS.md teach, so every hand-authored or migrated text-media with two images hits it.Why
handleElementBody(internal/server/body.go) pulls the item rows out of the children withelemops.PartitionItemsand serializes what is left. The newline after each self-closing row is its own text node (the parser only swallows the separator after block shortcodes), so removing two rows leaves two text nodes side by side, whichcontent.SerializeFragmentrefuses.The save path (
elemops.ApplyEdit) already merges those text runs with its owncoalesceText; the read path never got the same treatment. Two implementations of one split, only one of them correct.Fix
Make
PartitionItemsitself return a serializable rest (merge adjacent text there), so every caller is covered and the save path's separate merge goes away. Regression tests at the elemops and the HTTP layer.Not in scope here: the one-line rewrite on save (rows and body glued onto one line, noisy diffs, whitespace leaking into the translation hash). That is a canonical-layout change and is tracked separately.