[Beta]: Read-only editor is still an editable region: a click focuses it and right-click offers Paste

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
56/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, typescript

调研方向

Start with packages/plitejs/src/react/components/editable.tsx at the contentEditable and read-only handling, then inspect apps/www/src/registry/components/editor/editor.tsx and html-export.tsx for the affected demos. Compare the rendered attributes and focus behavior with the Slate read-only example. Done means read-only content remains selectable and copyable without focusing as an editable region, showing a caret, or offering Cut and Paste.

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

描述

bug target:beta

Testing lane

  • Repository: udecode/plate
  • Branch: next
  • Release channel: Beta
  • Exact commit/package version: 7f98d46ed5 for the agent's 2026-10-21 runs, NOT_ENOUGH_INFO for the others

Summary

A read-only editor on Beta still acts as an editable region. A click moves focus into it, and right-click shows the editing menu with Cut, Paste and Paste and Match Style. In the HTML export demo the click also shows an insertion caret. No input changes the text, so the content stays read-only, but the editor looks like one you can type in. Slate's read-only example and the Slate to HTML demo on platejs.org show read-only content as static text.

Reproduction

Repro 1: /examples/plite/read-only, Chrome
  1. Open https://beta.platejs.org/examples/plite/read-only.
  2. Right-click the in This example shows what happens when the Editor is set to readOnly, it is not editable.
  3. With text on the clipboard, choose Paste. Right-click the again and choose Paste and Match Style.
  4. Click the text.

The menu in step 2 lists Cut, Copy, Paste and Paste and Match Style, with Undo and Redo grayed out. Paste and Paste and Match Style leave the text as it was. After step 4 focus is on the editor root, which reads contenteditable="true" and aria-readonly="true". On https://www.slatejs.org/examples/read-only the menu has Look Up, Copy and Search Google, with no Cut or Paste. After a click there the editor reads contenteditable="false" and focus stays on body.

Repro 2: /docs/examples/html-export, Chrome
  1. Open https://beta.platejs.org/docs/examples/html-export. The demo's preview frame is /view/html-export.
  2. In the left Editor pane, which is read-only, click the end of Heading 1.
  3. Type Q and A, then press Backspace.

After step 2 focus moves into the editor and a caret shows after Heading 1. After step 3 the text has not changed and the caret is still there. The editor root reads contenteditable="true" and aria-readonly="true", with a collapsed selection after Heading 1. On https://platejs.org/docs/examples/slate-to-html (preview frame /view/slate-to-html) the left Editor pane is read-only too, but it reads contenteditable="false". The same click shows no caret, focus stays on body, and typing changes nothing.

Expected

A read-only editor is static text, as on slatejs.org/examples/read-only and platejs.org/docs/examples/slate-to-html. A click does not move focus into it or show a caret, and right-click shows the reading menu without Cut or Paste. Selecting and copying text keeps working, as it does today in Beta's and Slate's read-only examples. natamox checked both pages by hand and counts the editable state on Beta as a bug.

Actual

Beta keeps the read-only editor root contenteditable="true" and only adds aria-readonly="true". A click focuses it, the HTML export demo shows a caret, and right-click offers Cut, Paste and Paste and Match Style. Typing, Paste and Paste and Match Style change nothing.

Environment

  • Exact next commit/Beta package version: 7f98d46ed5 for the agent's 2026-10-21 runs, NOT_ENOUGH_INFO for the others.
  • Repro 1: an agent drove desktop Chrome on macOS on 2026-10-20 (PT) and recorded the menus and both Paste runs. That Chrome version was not recorded. An agent read back the attributes and focus in Chromium 152 in an agent's browser on 2026-10-21 (PT). natamox confirmed the editable region and the Paste menu by hand in Chrome on 2026-10-21 (PT).
  • Repro 2: an agent ran the steps in Chromium 152 in an agent's browser on 2026-10-21 (PT). natamox confirmed the caret and the ignored typing by hand in Chrome the same day.
  • The Chrome version and OS of the hand checks: NOT_ENOUGH_INFO.

Caveat

  • From a reading of the code on next, not confirmed by a fix: Plite's Editable always renders contentEditable (packages/plitejs/src/react/components/editable.tsx:531), and read-only only adds aria-readonly (:516). Its default style hides the caret with caretColor: 'transparent' when read-only (:553). Plate's registry Editor passes disableDefaultStyles (apps/www/src/registry/components/editor/editor.tsx:132), which drops that style. The HTML export pane renders <EditorRoot readOnly> with that Editor (apps/www/src/registry/components/editor/html-export.tsx:97). By this reading, that is why repro 2 shows a caret. Slate's Editable writes contentEditable={!readOnly}.
  • The code comment beside the caret style says read-only editors stay selectable without a caret, so the editable root may be on purpose. Nobody has checked.
  • Firefox notes for the HTML export pane only say that typing does nothing, which is the same read-only design. Whether Firefox shows the caret was not recorded.
  • #5250 is a different problem: edits get through a read-only inline element. Here the content stays read-only, but the editor still presents as editable.

Evidence

  • Repro 1, slides: 12 seconds, Beta beside slatejs.org, built from frames of the agent's Chrome recording and from the agent's readback. From 0:03 the two right-click menus: Beta's has Cut, Paste and Paste and Match Style, with Undo and Redo grayed out, and Slate's has Look Up, Copy and Search, with no Paste. From 0:08 the readback after a click in the text: Beta reads contenteditable="true" and aria-readonly="true" with focus on the editor root, and Slate reads contenteditable="false" with focus on body.
  • Repro 1, menu recording: the agent's Chrome screen recording, 20 seconds, with English captions. The browser's profile button is blurred. Slate's menu shows from 0:01. Beta's menu shows from 0:06. Paste is chosen at 0:10 and Paste and Match Style at 0:17, and the text stays the same both times.
  • Repro 2, slides: 15 seconds, Beta beside platejs.org, built from the agent's screenshots. At 0:03 the click: Beta shows a caret after Heading 1, and platejs.org shows none. At 0:07, after the typing, the text is unchanged on both sites and Beta's caret is still there. From 0:11 the readback: Beta reads contenteditable="true" and aria-readonly="true" with focus on the editor root, and platejs.org reads contenteditable="false" with focus on body.
Repro 1 — Chrome, /examples/plite/read-only

https://github.com/user-attachments/assets/a21163df-3363-4a84-b48d-3389e26749e0

Repro 1 — Chrome, /examples/plite/read-only (menu recording)

https://github.com/user-attachments/assets/a9f67d47-d011-41c2-9274-6ad72b2d0036

Repro 2 — Chromium, /docs/examples/html-export

https://github.com/user-attachments/assets/89af4709-5f5f-43bf-91e4-44e138c02188

主要语言
TypeScript
星标
16.6k
派生
993
平均合并
20 小时 2 分钟
30 天内合并 PR
62

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

udecode/plate 的其他 Issue

查看 udecode/plate 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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