Auto load editor if not open when send-to-editor is triggered.
This commit is contained in:
+19
-8
@@ -78,7 +78,7 @@ app.registerExtension({
|
||||
function initEditorNode(node)
|
||||
{
|
||||
node.collected_images = [];
|
||||
node.addWidget("button","Edit","bingo", (widget,graphCanvas, node, {x,y}, event) => openOrFocusEditor(node));
|
||||
node.addWidget("button","Edit","bingo", (widget,graphCanvas, node, {x,y}, event) => focusEditor(node));
|
||||
|
||||
node.widgets.reverse();// because auto created widget get put in first
|
||||
|
||||
@@ -102,18 +102,24 @@ function initTransmitNode(node)
|
||||
node.collected_images = [];
|
||||
|
||||
node.onExecuted = (output)=> {
|
||||
if (output?.collected_images && editor.channel) {
|
||||
if (!editor.window || editor.window.closed) openEditor();
|
||||
|
||||
if (output?.collected_images) {
|
||||
if(editor.channel) {
|
||||
editor.channel.port1.postMessage( {images:output.collected_images})
|
||||
} else {
|
||||
//try again after half a second just in case we caught it setting up.
|
||||
setTimeout(_=>{editor?.channel.port1.postMessage( {images:output.collected_images})}, 500);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function openOrFocusEditor() {
|
||||
if (!editor.window || editor.window.closed) {
|
||||
function openEditor() {
|
||||
editor = {};// start over with new editor;
|
||||
if (getSignal('clientPage')) {
|
||||
//if clientPage is set, there might be a new page to replace the lost one
|
||||
setSignal('findImageEditor')
|
||||
@@ -126,11 +132,16 @@ function openOrFocusEditor() {
|
||||
} else {
|
||||
editor.window = window.open('/extensions/canvas_tab/page/index.html', plugin_name);
|
||||
}
|
||||
}
|
||||
|
||||
function focusEditor() {
|
||||
if (!editor.window || editor.window.closed) {
|
||||
openEditor();
|
||||
} else {
|
||||
editor.window.focus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function launchEditorWindow(node) {
|
||||
if (!(node.editor.window)) {
|
||||
editor.window = window.open('/extensions/canvas_tab/page/index.html');
|
||||
@@ -165,7 +176,7 @@ function launchEditorWindow(node) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
async function uploadBlob(blob,filename="blob") {
|
||||
|
||||
Reference in New Issue
Block a user