I am starting with this DOM structure:
<p>some inline text. I am a node, not a mark. Yet more inline text.
I am trying to achieve this DOM structure via selecting text and command execution:
<p>some inline text.<span class="fancy">I am a node, not a mark.</span>Yet more inline text.</p>
Is there such a schema definition that would allow <span.fancy> to be a node and not a mark? I’ve been able to do so with a mark, but need to later find all such “span.fancy” occurrences with a plugin. I’m finding that task difficult.
My attempts at defining the type as a node results in either schema syntax errors (mixing block and inline content) or creation of nodes where the content is simply ignored.
Is this even possible?
That should be rather easy using
doc.descendants and checking, for each node, whether the mark is in that node’s set of marks (optionally joining ranges for adjacent nodes that both have the mark).
But yes, inline nodes with content are allowed by the library, but you do have to mark the node as inline. It’s just that native editing handling is sometimes unexpected for those, and the library doesn’t do much to help there.
Thanks. I was able to get the result I needed via an inline node. The subsequent, “find all fancy sentences” plugin had very straightforward traversal logic. I used the wrap() transform to isolate the sentence and wrap it in a “fancy” node. The rendered DOM is the same as if I had used a mark, so I presume the browser edit behavior would be the same either way.