Skip to content

fix(core): report mutations that remove the contentDOM to ProseMirror#255

Draft
ocavue wants to merge 1 commit into
mainfrom
fix-content-dom-removal
Draft

fix(core): report mutations that remove the contentDOM to ProseMirror#255
ocavue wants to merge 1 commit into
mainfrom
fix-content-dom-removal

Conversation

@ocavue

@ocavue ocavue commented Jul 6, 2026

Copy link
Copy Markdown
Member

When the selection covers all of a node view's content and the user types, Chrome and Safari delete the whole contentDOM element and insert the typed text into its component-owned parent. shouldIgnoreMutation treats every mutation outside contentDOM as component noise, so ProseMirror never sees the change and the view diverges from the document state silently: the screen shows the typed text while the document keeps the old content, and every later edit in that node is lost too.

This PR reports a childList mutation whose removedNodes include the contentDOM (in both CoreNodeView and CoreMarkView), so ProseMirror reparses the node and takes back control of the DOM. The e2e app gains a react code block node view plus a word-highlight decoration plugin, because the repro needs an inline contentDOM whose fully selected content contains element children, which is exactly the setup of a syntax-highlighted code block.

Note the typed character is still dropped by prosemirror-view's contentLost fallback (it reparses a node with a lost contentDOM as empty), but the state and the DOM now stay consistent and the editor keeps working, which matches how a plain toDOM-rendered node behaves in the same scenario.

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
prosemirror-adapter-e2e Ready Ready Preview, Comment Jul 6, 2026 1:20pm

@pkg-pr-new

pkg-pr-new Bot commented Jul 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prosemirror-adapter/core

npm i https://pkg.pr.new/@prosemirror-adapter/core@255

@prosemirror-adapter/lit

npm i https://pkg.pr.new/@prosemirror-adapter/lit@255

@prosemirror-adapter/preact

npm i https://pkg.pr.new/@prosemirror-adapter/preact@255

@prosemirror-adapter/react

npm i https://pkg.pr.new/@prosemirror-adapter/react@255

@prosemirror-adapter/solid

npm i https://pkg.pr.new/@prosemirror-adapter/solid@255

@prosemirror-adapter/svelte

npm i https://pkg.pr.new/@prosemirror-adapter/svelte@255

@prosemirror-adapter/vue

npm i https://pkg.pr.new/@prosemirror-adapter/vue@255

commit: 540c661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant