I have inline atom nodes that act as field markers (fieldStart / fieldEnd) wrapping ordinary editable text inside a paragraph. I’m seeing a replace (typing over a selection) delete these atom nodes even though my selection ended before them, and I’d like to confirm whether this is correct/expected behavior.
Setup
Two inline atom nodes (simplified):
const fieldStart = {
group: "inline", inline: true, atom: true, selectable: false,
attrs: { guid: {} },
// toDOM / parseDOM ...
};
const fieldEnd = { /* same shape */ };
Document (positions shown):
<p>
<span font-size:14pt>PROCEDURE:</span> // styled run
<span font-size:10pt> </span>
fieldStart@16
"one two" // editable field content
fieldEnd@24
</p>
Reproduction
- Selection from pos 1 (inside the font-size:14pt span) to pos 20 (in the middle of one two).
- Type a single character x to replace the selection. What I observe
The selection is [1 → 20], but the actual step is:
[
{ "text": "x", "marks": [{ "type": "style", "attrs": { "style": "font-size: 18.6667px;" } }] },
{ "text": " two", "marks": [{ "type": "style", "attrs": { "style": "font-size: 10pt;" } }] }
]
So the inserted x took the start mark (14pt), the trailing " two" was preserved, but the two atom nodes in the interior were dropped.
My questions
-
Is the widening of step.to from 20 to 24 expected here?
-
Is it expected that inline atom nodes sitting in the interior of the widened range are simply discarded (not preserved like the open trailing content)?
-
Is there a supported way to make these marker atoms resist being crossed/consumed by such a widened replace, short of redesigning them into a single isolating wrapper node with content? (isolating on the inline atoms themselves didn’t help.)
Versions: prosemirror-view 1.28.2, prosemirror-transform 1.7.0, prosemirror-state/model current.
Thanks!
