The idea is for Wordgard to properly support plots (nodes with content) that are inline. ProseMirror mostly punted on these—you can define them, but because the library just interprets native editing behavior, and native editing behavior is weird about inline element boundaries, it was hard to make it work in a useful way. Wordgard controls more of the editing and cursor management, and should be able to make this work better.
Plots introduce new document positions on their boundaries (before/after the open/close tokens) in ways that marks don’t. My original thinking was that you don’t always want the cursor to stop there—when you style such a plot in a way that doesn’t produce an obvious extra, visually distinct cursor position inside it, it’ll just look like your cursor is failing to move when you press arrow left/right. That feels janky and makes it unclear, to the user, whether the cursor is inside or outside the node. So at the moment the code has a cursorInsideBounds option on plots that controls whether positions directly inside the node are normalized to be outside of it or not. (Note that it doesn’t work very well yet in 0.4.0. I’m working on it, which prompted this post.)
But I’m finding in practice that the mode where an inline plot doesn’t have extra cursor positions inside its bounds doesn’t work very well. It’s annoying to not be able to type at its boundaries, and if you empty such a node, you end up with a silly invisible node that you cannot type into anymore.
One possible direction would be to forbid such empty nodes, much like empty block-content nodes are disallowed. Inline plots with cursor positions inside their bounds are allowed (you can put the cursor into them and start typing), but regular inline plots cannot be empty. Could enforce this at the change-application level and automatically enforce it like the block-content constraint.
But as I was looking into that I started wondering whether this type of plots is useful enough to support. For most inline plots I can think of (mentions, placeholder tags, links-as-nodes) it wouldn’t be much of an issue to style them in such a way that you can tell the difference between inside and outside cursor positions, and the extra control provided by the ability to place the cursor on both sides of their bounds is great to have.
So I wonder—can anybody think of a use case where that type of inline plot, which looks like a mark and has no extra cursor positions, is useful?
The most compelling one I’ve been able to come up with is when you want to treat something like links as actual coherent document units, rather than markup (and thus model them as nodes rather than marks) but still style them as usual (with just an underline and color). That presentation doesn’t allow for visually distinguishing inside/outside cursor positions. But it can be made to rather easily.