Fix copying selected text in workflow editor

The only text we could copy had to be within input boxes, but we may
want to also copy text from the error / upgrade message modal or from
the help text or other links.
So if there's currently any highlighted text we skip the workflow copy
logic.
This commit is contained in:
mvdbeek
2021-06-09 17:01:28 +02:00
parent 326e4c9c63
commit fd45fc50ed
@@ -220,12 +220,17 @@ class CanvasManager {
}
init_copy_paste() {
/*
Both of these copy/paste event bindings check the active element
The copy/paste event bindings check the active element
and, if it's one of the text inputs, skip the workflow copy/paste
logic so we don't interfere with standard copy/paste functionality.
The copy binding also skips the node copy if text is currently highlighted.
*/
document.addEventListener("copy", (e) => {
if (document.activeElement && !inputElementTypes.includes(document.activeElement.type)) {
if (
document.activeElement &&
!inputElementTypes.includes(document.activeElement.type) &&
!document.getSelection().toString()
) {
if (this.app.activeNode && this.app.activeNode.type !== "subworkflow") {
e.clipboardData.setData(
"application/json",
@@ -233,8 +238,8 @@ class CanvasManager {
nodeId: this.app.activeNode.id,
})
);
e.preventDefault();
}
e.preventDefault();
}
});
document.addEventListener("paste", (e) => {