Question about the expected behavior of definingAsContext property on blockquote nodes

Issue Description

While using ProseMirror, I’ve noticed that setting definingAsContext: false on blockquote nodes doesn’t seem to work as described in the documentation. According to the docs, non-defining nodes should be dropped when their entire content is replaced, but in my testing, the blockquote node is still preserved after completely replacing its content.

Environment Information

Code Configuration

Here’s my blockquote node specification:

blockquote: {
    content: "block+",
    group: "block",
    definingAsContext: false,
    parseDOM: [{tag: "blockquote"}],
    toDOM() { return blockquoteDOM }
} as NodeSpec

ezgif-24df490a69fc0b

Steps to Reproduce

  1. Create a document with a blockquote
  2. Add paragraph text inside the blockquote
  3. Select all content inside the blockquote
  4. Copy some text from an external source (like Notepad)
  5. Paste into the selected blockquote content

Expected Behavior

According to the documentation, since definingAsContext is set to false, when the blockquote content is completely replaced, the blockquote node itself should be dropped, and the pasted content should become a regular paragraph.

Actual Behavior

The blockquote node remains unchanged, and the pasted content is still wrapped in the blockquote.

Question

Is this a misunderstanding of how the definingAsContext property works, or is this behavior not as expected? Are there other factors affecting this behavior? Thank you for your help!

I think so, yes. If you’ll paste a whole block node into an empty non-defining node, it’ll replace it. But if you only copy text, that’ll fit in the existing paragraph, so replacing the block elements around it isn’t even considered.

1 Like

Thank you for your help as I clumsily climb through the ProseMirror source code repository. I greatly appreciate your response!