I have the node structured as below,
<blockquote>
<el1>el1 content</el1>
<el2>el2 content</el2>
</blockquote>
After i triple clicked the node, the whole node is selected and the current selection is a node selection. Then when i press ctrl-c
to copy the node, i found that sometimes the node can be copied but sometimes it is not. When i drill into the function in prosemirror-view
, i found that sometime when i press ctrl-c
, it doesn’t trigger the event handler below and the result is the node is not copied:
handlers.copy = editHandlers.cut = function (view, e) {
console.log('handle copy')
var sel = view.state.selection, cut = e.type == "cut";
if (sel.empty) { return }
// IE and Edge's clipboard interface is completely broken
var data = brokenClipboardAPI ? null : e.clipboardData;
var slice = sel.content();
var ref = serializeForClipboard(view, slice);
var dom = ref.dom;
var text = ref.text;
if (data) {
e.preventDefault();
data.clearData();
data.setData("text/html", dom.innerHTML);
data.setData("text/plain", text);
} else {
captureCopy(view, dom);
}
if (cut) { view.dispatch(view.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut")); }
};
Does anyone have any idea on what could be the possible reason for this? Any help would be great, thanks. Below is my schema:
blockquote: {
group: 'block',
content: 'el1 el2',
selectable: true,
draggable: false,
parseDOM: [
{
tag: 'blockquote'
}
],
toDOM() {
return ['blockquote', 0]
}
},
el1: {
content: 'text*',
defining: true,
parseDOM: [
{
tag: 'div[node-type="el1"]'
}
],
toDOM() {
return ['div', { 'node-type': 'el1' }, 0]
}
}
el2: {
content: 'text*',
defining: true,
parseDOM: [
{
tag: 'div[node-type="el2"]'
}
],
toDOM() {
return ['div', { 'node-type': 'el2' }, 0]
}
}