Skip to content

Rich-text editing for Plain blocks (tight list items)#376

Merged
cscheid merged 1 commit into
mainfrom
feature/bd-7pxub583-richtext-plain-blocks
Jul 6, 2026
Merged

Rich-text editing for Plain blocks (tight list items)#376
cscheid merged 1 commit into
mainfrom
feature/bd-7pxub583-richtext-plain-blocks

Conversation

@cscheid

@cscheid cscheid commented Jul 6, 2026

Copy link
Copy Markdown
Member

What & why

In format: q2-preview, the tiptap rich-text block editor only activated for a subset of Pandoc block types — its gate RICHTEXT_SUPPORTED_TYPES listed {Para, Header} but not Plain. Tight bullet/ordered lists store each item's content as a Plain block (loose lists use Para; table cells are also Plain), so clicking a tight-list item resolved a Plain sourceNode, the availability check returned false, and the block fell back to the monospaced textarea instead of the rich editor.

This adds Plain to the set (broad scope, per product direction: the more places the rich editor works, the better). Everything downstream was already Plain-aware:

  • astToProseMirror maps both Para and Plain to a paragraph node.
  • The text-commit channel's preserve_leaf_variant (pampa apply_node_edit.rs) coerces the re-parsed Paragraph back to Plain, so editing a tight-list item does not silently loosen the list. Already covered by text_edit_preserves_{bullet,ordered}_list_tightness.

So the change is a one-line gate fix plus tests.

Tests (TDD)

  • richTextSupport.test.ts — the availability gate (the module had no direct test before). The Plain assertions fail before this change, pass after.
  • plain-list-item-richtext.integration.test.tsx — drives the real PreviewRoot: a tight-list item opens the rich editor (toolbar present) with the flag on, the textarea with it off. Confirmed to fail when the fix is reverted (true regression guard).
  • richtext/plainSeed.test.ts — the single-Plain seed the editor uses serializes back to bare inline text (marks included), no dropped nodes, no list marker.

Local: preview-renderer 484 unit + 517 integration + 15 oracle round-trip green; tsc clean.

End-to-end verification

Built the real chain (cargo xtask build-q2-preview-spa + cargo build --bin q2) and drove q2 preview --allow-edit in a browser on a tight-list fixture:

  • Clicking a tight bullet-list item opens the tiptap rich editor (ProseMirror <p>, formatting toolbar, Pl breadcrumb) — before this change it opened the textarea.
  • A text edit (bananabanana XX) commits and the on-disk file stays tight (pampa -t json → all items Plain).

Known pre-existing bug (not from this change) — bd-hafs0qho

During E2E I found that a select-all + bold commit can drop the item's content (the committed ProseMirror doc becomes paragraph[hardBreak]). The serializer and the Rust commit path are both verified correct; the fault is upstream in the editor. It is not Plain-specific — the RichTextEditor / astToProseMirror / serializer are type-agnostic (Para and Plain share the code), a Para repro shows the same spurious hardBreak, and it predates this change. Filed as bd-hafs0qho (P1) for a clean root-cause.

Strand: bd-7pxub583

🤖 Generated with Claude Code

Tight bullet/ordered lists store each item's content as a `Plain` block
(loose lists use `Para`; table cells are also `Plain`). The rich-text
block editor's gate `RICHTEXT_SUPPORTED_TYPES` listed only {Para, Header},
so clicking a tight-list item resolved a `Plain` sourceNode, the
availability check returned false, and the block fell back to the
monospaced textarea instead of the tiptap rich editor.

Add `Plain` to the set. Everything downstream is already Plain-aware:
`astToProseMirror` maps both Para and Plain to a paragraph node, and the
text-commit channel's `preserve_leaf_variant` (pampa `apply_node_edit.rs`)
coerces the re-parsed Paragraph back to Plain so editing a tight-list item
does not silently loosen the list (already covered by
`text_edit_preserves_{bullet,ordered}_list_tightness`).

Tests (TDD):
- richTextSupport.test.ts: the availability gate (module had no direct
  test); the Plain assertions fail before this change, pass after.
- plain-list-item-richtext.integration.test.tsx: drives the real
  PreviewRoot — a tight-list item opens the rich editor (toolbar present)
  with the flag on, the textarea with it off. Fails when the fix is
  reverted (true regression guard).
- richtext/plainSeed.test.ts: the single-Plain seed the editor uses
  serializes back to the bare inline text (marks included), no dropped
  nodes, no list marker.

Verified end-to-end via `q2 preview --allow-edit`: clicking a tight-list
item opens the tiptap editor (Pl breadcrumb); a text edit round-trips and
the on-disk list stays tight (all items Plain).

Note: a pre-existing rich-editor bug where a select-all + bold commit can
drop content (spurious hardBreak) is tracked separately as bd-hafs0qho;
it is not Plain-specific (shared, type-agnostic RichTextEditor path,
affects Para equally) and predates this change.

Strand: bd-7pxub583

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@posit-snyk-bot

posit-snyk-bot commented Jul 6, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid cscheid merged commit fc512c1 into main Jul 6, 2026
8 checks passed
@cscheid cscheid deleted the feature/bd-7pxub583-richtext-plain-blocks branch July 6, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants