Skip to content

[RTE] Toolbar Copy should copy the selection's serialized content, not its DOM #6296

Description

@rtibblesbot

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

The rich text editor's toolbar Copy button builds its HTML by cloning the selection's DOM, so every node view that holds data must special-case itself to copy correctly. Copy should produce the same HTML as ProseMirror's own clipboard serializer, the one Ctrl+C uses.

Complexity: Low
Target branch: unstable

Context

The Change

Toolbar Copy should write the HTML ProseMirror serializes for the selection (editor.view.serializeForClipboard(selection.content())), so a node view's DOM no longer decides what is copied.

Acceptance Criteria

  • Toolbar Copy then paste of a selection containing a formula reproduces the formula.
  • Toolbar Copy then paste of a selection containing an inline choice chip reproduces the chip with its options and correct answer.
  • The math-field special case in handleCopy is gone.
  • The inline choice chip's hidden copySource span is gone.
  • Toolbar Copy and Ctrl+C put the same text/html on the clipboard for the same selection.
  • Unit tests cover toolbar Copy of a selection with a formula and with a chip.

AI usage

A reviewer asked for this follow-up on #6277; Claude Code drafted it from that review thread and the current handleCopy code.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions