Repository navigation
fix(editor): serialize copied rich selections as Markdown - #21529
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the rich Markdown editor now places Markdown source on the clipboard as text/plain rather than rendered visible text.
- Clipboard plain text is Markdown.
rich-markdown-editor-config.tsadds aclipboardTextSerializertoeditorPropsthat resolveseditorRef.current?.markdownand delegates to the new slice helper, returning''when the manager is unavailable. - New slice→Markdown helper.
serializeRichMarkdownSliceAsMarkdownserializesslice.content.toJSON()when it is an array (ProseMirror returnsnullfor an empty fragment) and otherwise yields''. - Empty-selection cut uses the same serializer.
rich-markdown-clipboard-write.tswrites the serializer output astext/plainand falls back tovisibleTextwhen it is absent or empty, keeping the readback check consistent. - Tests. A helper unit test and a table-padding regression test for
renderTableToCompactMarkdown's outlier clamp.
The fallback behavior is sound: ProseMirror's own copy path already does someProp('clipboardTextSerializer', …) || textBetween(…), so an empty serializer result degrades to the previous plain text, and non-empty selections (which defer to ProseMirror) pick up the same prop. Slices the markdown serializer can't render (a bare tableRow returns '') fall back to visibleText through the ||. Paste consumers prefer text/html, so no internal round trip regresses. pnpm tc:web and the three affected suites (29 tests) pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Readiness pass for the incremental clipboard layer at fd0b481: reviewed all eight checklist areas; no unresolved review threads or proven findings. No mobile-facing surface, remote wire, filesystem ownership, dependency, shell, or persisted-schema changes. Clipboard HTML metadata and write/readback-before-delete remain intact. Fifteen focused unit tests and two rebuilt hidden Electron copy runs passed; PR Checks run 35416503335 succeeded. Visual proof and exact clipboard output are in the description. This merge folds clipboard into #21527, not main; native OS clipboard shortcuts remain outside the hidden test scope. |

ELI5
Copying a rich selection keeps Markdown formatting.
What Changed
Uses the Markdown serializer for clipboard text and wires it into editor copy handling. Adds clipboard and table-pipe coverage.
Why
Reuses the editor serializer instead of maintaining a separate clipboard formatter.
Linked Issue
Related to #9858; this stack is a partial compatibility improvement and does not close the full request.
Visual Proof
Hidden Electron copy check on fd0b481, rebuilt from this branch. Selected only the rendered paragraph; copy preserved bold and link Markdown, preserved HTML, excluded the heading, and left the document unchanged. The test uses an isolated ClipboardEvent/DataTransfer, not the system clipboard or native keyboard shortcut.
Captured plain-text clipboard content:
Testing
Exact clipboard layer fd0b481: 15 focused unit tests passed; hidden Electron copy flow passed twice. The new browser regression will be retained in the parent integration PR when this layer is folded into it.
Final stack bd17fae:
All launches used ORCA_BACKGROUND_LAUNCH=1. Paired-client coverage runs on macOS; live SSH/network failures and Windows/Linux Electron UI were not exercised. Latest CI reruns are separate from these local results.
Review
Low incremental risk: clipboard serialization. Depends on #21527.
Independent readiness reviews covered #21527 and #21531. Later preview/scanner findings were fixed with regressions. The fence tracker retains mixed-marker closers to match the installed parser; over-indented closers are rejected.
Remaining stack: #21565 → #21527 → #21529 → #21530 → #21531 → #21532. Retarget each next PR after squash-merging its base. #21553 is on main. #9858 remains open because full GFM compatibility is broader than this stack.
Agent skill upstream boundary
Checklist