Skip to content

feat(editor): support collapsible <details>/<summary> blocks in issue & comment rendering - #5629

Draft
sapk wants to merge 4 commits into
multica-ai:mainfrom
sapk-fork:agent/details-block
Draft

feat(editor): support collapsible <details>/<summary> blocks in issue & comment rendering#5629
sapk wants to merge 4 commits into
multica-ai:mainfrom
sapk-fork:agent/details-block

Conversation

@sapk

@sapk sapk commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds full support for <details>/<summary> collapsible HTML blocks in the issue description and comment editor. Previously these blocks rendered flat/expanded on issues (while working correctly in the autopilot view). This PR adds tokenization, rendering, and inline editing for the block.

Changes

1. feat(editor): support collapsible <details>/<summary> blocks in issue and comment rendering

  • New details ProseMirror node type with HTML tokenization from <details>/<summary> markdown
  • DetailsBlockView NodeView: collapsed preview in read-only mode (via ReadonlyContent), full markdown rendering with headings, lists, code blocks
  • Dedicated details.css styles for the collapsible block

2. refactor(editor): harden details/summary tokenizer per review

  • Hardened the HTML tokenizer against edge cases (malformed HTML, nested blocks, missing summary)

3. fix(editor): make details/summary block editable in the editor

  • Editable mode renders an inline <input> for the summary and a source-edit <textarea> (raw Markdown) for the body
  • Both write back to node attributes via updateAttributes, preserving the open flag
  • Read-only path unchanged — collapsed preview via ReadonlyContent
  • Node stays an atom with Markdown source as the verbatim source of truth, guaranteeing parse → edit → serialize round-trip fidelity

Files changed

File Description
packages/views/editor/extensions/details.tsx Node spec, tokenizer, and DetailsBlockView NodeView
packages/views/editor/extensions/index.ts Register the details extension
packages/views/editor/extensions/details.test.tsx Model-level parse/serialize round-trip tests
packages/views/editor/extensions/details-view.test.tsx NodeView rendering tests (editable + read-only)
packages/views/editor/styles/details.css Block styles
packages/views/editor/styles/index.css Import details styles

Verification

  • pnpm typecheck — pass (all 6 packages)
  • Editor suite (packages/views/editor) — 582 tests passed, including 8 new/updated details tests
  • pnpm lint (views) — 0 errors in changed files

Before / After

Before:
image

After:
image
image

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

@sapk is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

sapk and others added 4 commits July 26, 2026 23:13
… descriptions

The issue description renders through the Tiptap ContentEditor, which had no
node for <details>/<summary>. @tiptap/markdown dropped the tags on both load
(flattened display) and save (the block was silently destroyed on any edit).

Add a DetailsBlock atom node (modeled on the math / file-card atoms): a
block-level markdown tokenizer captures a whole <details><summary>…</summary>
…</details> block and stores the summary and inner body markdown verbatim, so
renderMarkdown re-emits it unchanged and edits elsewhere round-trip the block.
The NodeView renders the body collapsibly through the same ReadonlyContent
renderer the autopilot view uses, so a collapsed block looks identical there.

Nested <details> is a documented limitation: the tokenizer declines it (the
inner </details> would close the outer), falling back to the previous
flattened rendering rather than breaking the round-trip.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Implements the low-risk robustness suggestions from the code review of the
details/summary block:

- Tolerate blank lines between <details> and <summary> (regex \n? -> \s*),
  fixing hand-authored blocks that were previously not recognized.
- Guard the `open` flag against false positives inside other attribute
  values (e.g. class="is open") with a word-boundary-aware pattern.
- Decline a body truncated inside a code fence (odd fence count) so a fenced
  sample containing </details> falls back to flat rendering instead of
  leaking an unterminated fence.
- Add tests covering blank-line tolerance, the `open` false-positive,
  empty body, consecutive blocks, and the fenced-</details> fallback.

Summary markdown-parity in the NodeView is left as a follow-up (needs
inline, not block, rendering inside <summary>).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The DetailsBlock node view rendered read-only (contentEditable=false), so
users could delete the block but not edit its summary or body. Keep the
node an atom (to preserve verbatim <details> round-trip) and, in an
editable editor, render an inline summary input and a source-edit body
textarea that write back to the node attributes via updateAttributes.
Read-only mode still renders the collapsed preview via ReadonlyContent.

Adds DOM tests for the editable/read-only node view and model-level
edit -> serialize round-trip tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The editable-mode rewrite (6b151e6) swapped the native <details> for an
always-expanded form panel, so the block never collapsed on issues (the
description editor is always editable). Keep the native <details> chrome
in editable mode too: summary <input> inline, body source <textarea> in
the expanded region. The fold is local UI state initialized from the open
attr — folding/unfolding no longer writes back, so peeking doesn't dirty
the doc. Atom + verbatim round-trip unchanged.
@sapk
sapk force-pushed the agent/details-block branch from 78c7fe2 to be8ed01 Compare July 26, 2026 21:13
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.

1 participant