Hi, I found some inconsistencies regarding draggable node views I would like to understand. For now this looks like a bug to me.
Let’s say I have a simple node (called rectangle) as a node view.
const rectangleSpec = {
group: "block",
draggable: true,
selectable: false,
toDOM: node => ["div", { class: "rectangle" }],
parseDOM: [{
tag: "div.rectangle",
}]
}
class RectangleView {
constructor(node) {
this.dom = document.createElement("div")
this.dom.className = 'rectangle'
this.contentDOM = undefined
}
stopEvent() { return true }
}
As you can see stopEvent
returns always true
. I would expect, that I can’t drag this node because of that. This is true but prosemirror-dropcursor
still renders a drop cursor.
I created another node called circle
. It’s the same like rectangle
but it has a contentDOM.
const circleSpec = {
group: "block",
draggable: true,
selectable: false,
toDOM: node => ["div", { class: "circle" }],
parseDOM: [{
tag: "div.circle",
}]
}
class CircleView {
constructor(node) {
this.dom = document.createElement("div")
this.dom.className = 'circle'
const child = document.createElement("div")
this.dom.appendChild(child)
this.contentDOM = child
}
stopEvent() { return true }
}
For that circle
node prosemirror-dropcursor
doesn’t render a drop cursor. And when I’m looking at the rendered HTML I can also see some differnces:
rectangle markup:
<div class="rectangle" contenteditable="false" draggable="true"></div>
circle markup:
<div class="circle"><div></div></div>
In the end, this causes me problems in the implementation of custom drag handles – whether with or without contentDOM.
I created a demo here: https://glitch.com/edit/#!/stop-event-bug