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:
Dariusz L
2025-06-30 01:49:06 +02:00
parent ed62d8df78
commit 8a800a4bee

View File

@@ -1237,7 +1237,33 @@ app.registerExtension({
originalGetExtraMenuOptions?.apply(this, arguments);
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 = [
{
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",
callback: async () => {