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

未关闭
#6,474 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
领域
frontend, testing

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
JavaScript
星标
214
派生
327
平均合并
17 小时 5 分钟
30 天内合并 PR
25

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

learningequality/studio 的其他 Issue

查看 learningequality/studio 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。