fix(core): report mutations that remove the contentDOM to ProseMirror#255
Draft
ocavue wants to merge 1 commit into
Draft
fix(core): report mutations that remove the contentDOM to ProseMirror#255ocavue wants to merge 1 commit into
contentDOM to ProseMirror#255ocavue wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@prosemirror-adapter/core
@prosemirror-adapter/lit
@prosemirror-adapter/preact
@prosemirror-adapter/react
@prosemirror-adapter/solid
@prosemirror-adapter/svelte
@prosemirror-adapter/vue
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the selection covers all of a node view's content and the user types, Chrome and Safari delete the whole
contentDOMelement and insert the typed text into its component-owned parent.shouldIgnoreMutationtreats every mutation outsidecontentDOMas 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
childListmutation whoseremovedNodesinclude thecontentDOM(in bothCoreNodeViewandCoreMarkView), 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 inlinecontentDOMwhose 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
contentLostfallback (it reparses a node with a lostcontentDOMas empty), but the state and the DOM now stay consistent and the editor keeps working, which matches how a plaintoDOM-rendered node behaves in the same scenario.