[RTE] Copying a formula as plain text leaves it out

Open
#6,474 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Domain
frontend, testing

Research direction

Start with Math.js and useToolbarActions.js, then trace how TipTap serializes selections for text/plain and how toolbar Copy builds clipboard data. Check the existing Jest tests and add coverage for both copy paths, unchanged text/html, and typing a space after a formula beginning with -. Done means all acceptance criteria pass; the issue says the formula’s plain text representation is still undecided.

Written by the indexing model from the issue text.

Description

bug

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

Target branch: unstable

Observed behavior

  • Copying a selection that spans a formula puts no text for the formula in text/plain: A, the formula \frac{x}{y}, B copies as AB.
  • Ctrl+C and the toolbar's Copy both do this. The formula node defines no text (Math.js#L5-L49), and toolbar Copy reads textBetween (useToolbarActions.js#L127).
  • text/html holds the formula, so pasting into another rich text editor keeps it.
  • The fix for #6309 keeps formulas imported as MathML as formula nodes, so they copy the same way.

Expected behavior

text/plain holds each formula the selection spans. Which text stands for a formula is undecided, and the rich text editor's maintainers choose: its LaTeX (\frac{x}{y}), the $$\frac{x}{y}$$ the editor writes in Markdown, or the \(\frac{x}{y}\) toolbar Copy writes into its HTML.

User-facing consequences

An author who pastes question text into a plain-text field (a title, a search box, a chat message) gets the sentence with its formulas missing, and nothing marks the gaps.

Steps to reproduce

  1. Create an editor with editorExtensions() and the content <p>A<span data-latex="\frac{x}{y}"></span>B</p>.
  2. Run editor.commands.selectAll().
  3. Read editor.view.serializeForClipboard(editor.state.selection.content()).text: it is AB.
  4. Read editor.state.doc.textBetween(1, 4, '\n'): it is AB.

Context

unstable at 2713cbf33, Jest with jsdom.

Acceptance Criteria

  • Ctrl+C on A, the formula \frac{x}{y}, B puts the chosen text for the formula between A and B in text/plain.
  • Toolbar Copy puts the same text/plain on the clipboard for that selection.
  • text/html for that selection is what it was before the change.
  • A formula whose text starts with -, at the start of a paragraph, does not become a list when a space is typed after it. TipTap's typing shortcuts read a node's text through renderText (InlineChoiceNode.js#L159-L161).
  • Unit tests cover each criterion above.

AI usage

Claude Code found this while working on #6309, reproduced both copy paths with Jest on unstable, and drafted this issue.

Dominant language
JavaScript
Stars
214
Forks
327
Avg merge
17h 5m
Merged PRs (30d)
25

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from learningequality/studio

All issues in learningequality/studio

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.