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

Ouverte
#6,474 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
javascript, typescript
Domaine
frontend, testing

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

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.

Langage dominant
JavaScript
Étoiles
214
Forks
327
Merge moyen
17 h 5 min
PR mergées (30 j)
25

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de learningequality/studio

Toutes les issues de learningequality/studio

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.