By listening to selectionChange events, i forbid selection to go in the ignored places.
However, when returning a DOM Node in a DOMOutputSpec, that DOM Node is not “drawn” by pm, and in particular, the inner div is not flattened like:
which is a problem, since it becomes flattened the first time the user selects it, which offsets the position by 1 (because of the span wrapping).
I know this is all unsupported, but it would be fantastic if there was a way to ask pm to “flatten” arbitrary DOM Nodes (or parts of them) that are returned by toDOM.
The the flattening function doing it is not accessible in version 0.10.1.
I could somewhat achieve a correct rendering by exporting it and calling
var dopts = pm.draw.drawOptions(pm.ranges.activeRangeTracker())
Oh yes, i failed to set contenteditable=false on the nodes to ignore.
So it’s possible to render a node A to a DOM Node with some childNodes ignored by pm.
I could reformulate what i’m trying to do as:
Is it possible to render a pm node A to a dom node domA containing domB containing domC, but without domB being rendered from a pm node B, as if A > C was rendered into dom as domA > domB > domC ?
(When i try to do that i need to feedle with pm-offset attribute).
Do I understand correctly that you want to render intermediate DOM structure between the outer node and its children? Yes, that’s definitely possible, just return something like ["div", ["div", 0]], but make sure your DOM parsing logic also notifies the parser (using the content property in its returned spec) that it has to continue parsing in a child node.