Is there a simpler way to decorate a node without doing the calculations of from and to?
static node(from: number, to: number, attrs: DecorationAttrs, options: ?Object) → Decoration Creates a node decoration. from and to should point precisely before and after a node in the document. That node, and only that node, will receive the given attributes.
I found this, but thought if there’s a way to decorate a node by simply giving that node, something like:
Decoration.node(node, attrs, options)
I’m referring to the code in drop-cursor
if (!$pos.parent.isTextblock) {
let before, after
if (before = $pos.nodeBefore)
deco = Decoration.node(pos - before.nodeSize, pos, {nodeName: "div", style: style(options, "right")})
else if (after = $pos.nodeAfter)
deco = Decoration.node(pos, pos + after.nodeSize, {nodeName: "div", style: style(options, "left")})
}
Another part that I’m trying to understand is if there’s a way to reference a DOM node back to the state?
In the drag and drop plugin there’s a lot of calculations being done with:
view.posAtCoords({ left: event.clientX, top: event.clientY })
I was looking to make the plugin simpler because I’m only interested in dragging and dropping blocks. So, I was thinking if there would be a way to refer a DOM node back to its State node representation.
view.root.elementFromPoint(event.clientX, event.clientY)