Our documents have “markers” which are rendered as little blue flags by a nodeview. Ideally, these would be treated atomically, with the cursor navigation moving from one side to the other with a single arrow press (i.e. like a single character). What we see, though, is this:
As far as I can tell, when the cursor is “inside” the marker, the marker node is selected; indeed, if I type something in that state, the marker is replaced by the text.
If I make the marker node unselectable through its NodeSpec, I get the cursor navigation behavior I want, but I lose the ability to select and move the flag with the mouse.
Is there a way to get both qualities, the navigation around the marker and the ability to select it?
It should definitely be selectable, but I guess the problems have to do with how that’s presented to the user. For navigation around a normal character, if the cursor is to the left of that character and I press right-arrow, then the cursor moves to the right side of that character. For our marker, that first right-arrow moves the cursor “into” the marker, and a subsequent right-arrow moves it to the right of the marker. Our users get confused by it, and ideally (naively?) we would expect selection of the marker to work like selection of a character.
To make things more concrete, here’s what the nodeview-created DOM for a marker looks like:
When I use shift+right-arrow to select a marker, what I see is that the first shift+right-arrow selects the span child in its entirety. Then the next shift+right-arrow selects the following character, like this:
When the cursor is “inside” the marker, then, I guess it’s actually on the span in some sense.
Is there some way to treat the entire div+span construct as a unit from the perspective of selection? My sense is that I’ve just got the wrong model of how things should work, so I’m working against the grain.
That seems reasonable. So if you don’t need node selections, I guess setting up a handleClickOn handler that creates a regular text selection over the marker might be a more consistent way to handle this—so that the two ways of selecting it produce the same type of selection.