mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-25 14:25:44 -03:00
Replace MaskEditor menu option with custom handler
Removes the default 'Open in MaskEditor' option from the menu and adds a new custom option with improved error handling and logging. This ensures the MaskEditor is opened through a controlled callback, providing better user feedback in case of errors.
This commit is contained in:
@@ -1237,7 +1237,33 @@ app.registerExtension({
|
|||||||
originalGetExtraMenuOptions?.apply(this, arguments);
|
originalGetExtraMenuOptions?.apply(this, arguments);
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
// Usuń standardową opcję "Open in MaskEditor" jeśli istnieje
|
||||||
|
const maskEditorIndex = options.findIndex(option =>
|
||||||
|
option && option.content === "Open in MaskEditor"
|
||||||
|
);
|
||||||
|
if (maskEditorIndex !== -1) {
|
||||||
|
options.splice(maskEditorIndex, 1);
|
||||||
|
}
|
||||||
|
|
||||||
const newOptions = [
|
const newOptions = [
|
||||||
|
{
|
||||||
|
content: "Open in MaskEditor",
|
||||||
|
callback: async () => {
|
||||||
|
try {
|
||||||
|
log.info("Opening LayerForge canvas in MaskEditor");
|
||||||
|
if (self.canvasWidget && self.canvasWidget.startMaskEditor) {
|
||||||
|
await self.canvasWidget.startMaskEditor();
|
||||||
|
} else {
|
||||||
|
log.error("Canvas widget not available");
|
||||||
|
alert("Canvas not ready. Please try again.");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Error opening MaskEditor:", e);
|
||||||
|
alert(`Failed to open MaskEditor: ${e.message}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
content: "Open Image",
|
content: "Open Image",
|
||||||
callback: async () => {
|
callback: async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user