consider close by 'esc' key on maskeditor.

This commit is contained in:
Dr.Lt.Data 2023-05-13 13:44:51 +09:00
parent f31fcf5280
commit 2d50ec4a98
2 changed files with 21 additions and 3 deletions

View File

@ -195,7 +195,6 @@ class MaskEditorDialog extends ComfyDialog {
var cancelButton = this.createRightButton("Cancel", () => {
document.removeEventListener("mouseup", MaskEditorDialog.handleMouseUp);
document.removeEventListener("keydown", MaskEditorDialog.handleKeyDown);
ComfyApp.onClipspaceEditorClosed(false);
self.close();
});
@ -245,6 +244,22 @@ class MaskEditorDialog extends ComfyDialog {
this.setEventHandler(maskCanvas);
this.is_layout_created = true;
// replacement of onClose hook since close is not real close
const self = this;
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
if(self.last_style && self.last_style != 'none')
ComfyApp.onClipspaceEditorClosed();
self.last_style = self.element.style;
}
});
});
const config = { attributes: true };
observer.observe(this.element, config);
}
this.setImages(this.imgCanvas, this.backupCanvas);

View File

@ -55,14 +55,17 @@ export class ComfyApp {
return node.imgs || (node && node.widgets && node.widgets.findIndex(obj => obj.name === 'image') >= 0);
}
static onClipspaceEditorClosed(save_mode) {
static onClipspaceEditorSave() {
if(ComfyApp.clipspace_return_node) {
if(save_mode)
ComfyApp.pasteToClipspace(ComfyApp.clipspace_return_node);
ComfyApp.clipspace_return_node = null;
}
}
static onClipspaceEditorClosed() {
ComfyApp.clipspace_return_node = null;
}
static copyToClipspace(node) {
var widgets = null;
if(node.widgets) {