From 4195fa5cb897f05d6477e9d7f42c7b4dc5ccb7ad Mon Sep 17 00:00:00 2001 From: CTomlyn Date: Wed, 15 May 2024 16:23:57 -0700 Subject: [PATCH] =?UTF-8?q?#1943=20Feature=20request:=20Allow=20categories?= =?UTF-8?q?[0].node=5Ftypes[0].app=5Fdata.ui=5F=E2=80=A6=20(#1953)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/common-canvas/canvas-controller.js | 18 +++++++++++------- .../jsx-icons/jsx-icons-canvas.jsx | 13 +++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/canvas_modules/common-canvas/src/common-canvas/canvas-controller.js b/canvas_modules/common-canvas/src/common-canvas/canvas-controller.js index 66233dd3a2..631595a214 100644 --- a/canvas_modules/common-canvas/src/common-canvas/canvas-controller.js +++ b/canvas_modules/common-canvas/src/common-canvas/canvas-controller.js @@ -2294,6 +2294,14 @@ export default class CanvasController { data.editType === "deconstructSuperNode" || data.editType === "convertSuperNodeExternalToLocal") { data = this.preProcessForExternalPipelines(data); + + } else if (data.editType === "paste") { + const pasteObjects = this.objectModel.getObjectsToPaste(); + if (pasteObjects) { + data.objects = pasteObjects; + } else { + return false; + } } // Check with host application if it wants to proceed with the command @@ -2618,13 +2626,9 @@ export default class CanvasController { break; } case "paste": { - const pasteObjects = this.objectModel.getObjectsToPaste(); - if (pasteObjects) { - data.objects = pasteObjects; - command = new PasteAction(data, this); - this.commandStack.do(command); - data = command.getData(); - } + command = new PasteAction(data, this); + this.commandStack.do(command); + data = command.getData(); break; } case "undo": { diff --git a/canvas_modules/harness/src/client/components/custom-canvases/jsx-icons/jsx-icons-canvas.jsx b/canvas_modules/harness/src/client/components/custom-canvases/jsx-icons/jsx-icons-canvas.jsx index 02a27e801e..2a1d1795db 100644 --- a/canvas_modules/harness/src/client/components/custom-canvases/jsx-icons/jsx-icons-canvas.jsx +++ b/canvas_modules/harness/src/client/components/custom-canvases/jsx-icons/jsx-icons-canvas.jsx @@ -35,6 +35,7 @@ export default class JsxIconsCanvas extends React.Component { this.canvasController.setPipelineFlow(this.getConvertedFlow(JsxIconsCanvasFlow)); this.getConfig = this.getConfig.bind(this); + this.beforeEditActionHandler = this.beforeEditActionHandler.bind(this); } getConvertedPalette(palette) { @@ -95,12 +96,24 @@ export default class JsxIconsCanvas extends React.Component { } } + // If nodes are pasted into the canvas ensure their image fields + // are set appropriately. + beforeEditActionHandler(data, command) { + if (data.editType === "paste") { + data.objects?.nodes?.forEach((n) => { + n.image = this.convertOpToImage(n.op); + }); + } + return data; + } + render() { const config = this.getConfig(); return ( );