Hello!
First of all, thank you so much for working on prosemirror, it is a real pleasure to use.
In our editor, we have a node that can only appear at most once.
The node, when it exists, can be dragged and dropped, but the dropcursor element does not appear.
It happens at this point, where the plugin calls dropPoint that eventually calls this.contentMatchAt(from).matchFragment(replacement, start, end)on this line, which doesn't match because the editor (rightfully) thinks that the node is already in use somewhere else.
The cursor should appear since it is legal to move the node.
Here is a test project that illustrates the situation.
In case it gets deleted, the modification from the standard project are
const {nodes, marks} = require("prosemirror-schema-basic")
const myNodes = {
...nodes,
/// The top level document, the document can contain at most one unique_horizontal_rule
doc: {
content: "block* unique_horizontal_rule? block*"
},
/// A horizontal rule that can only appear once
unique_horizontal_rule: {
parseDOM: [{tag: "uniquehr"}],
toDOM() { return ["hr", { style: "background-color: red;"}] }
},
}
const schema = new Schema({nodes: myNodes, marks})
in index.js and
<h3>Hello ProseMirror</h3>
<p>The horizontal rule below is a normal one, it can be dragged around with the dropcursor</p>
<hr>
<p>The horizontal rule below is one that can only be in the document once, it can be dragged around, but the dropcursor doesn't appear</p>
<uniquehr></uniquehr>
Hello! First of all, thank you so much for working on prosemirror, it is a real pleasure to use.
In our editor, we have a node that can only appear at most once. The node, when it exists, can be dragged and dropped, but the
dropcursor
element does not appear.It happens at this point, where the plugin calls
dropPoint
that eventually callsthis.contentMatchAt(from).matchFragment(replacement, start, end)
on this line, which doesn't match because the editor (rightfully) thinks that the node is already in use somewhere else.The cursor should appear since it is legal to move the node.
Here is a test project that illustrates the situation. In case it gets deleted, the modification from the standard project are
in
index.js
andin
index.html
.