Skip to content

Commit d4d6ed0

Browse files
[backport core/1.32] Fix: Opening mask editor on context menu (#6869)
Backport of #6825 to `core/1.32` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6869-backport-core-1-32-Fix-Opening-mask-editor-on-context-menu-2b46d73d36508196a2bfd8412f468196) by [Unito](https://www.unito.io) Co-authored-by: Terry Jia <terryjia88@gmail.com>
1 parent d7f11dd commit d4d6ed0

File tree

3 files changed

+52
-33
lines changed

3 files changed

+52
-33
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
2+
import { useDialogStore } from '@/stores/dialogStore'
3+
import TopBarHeader from '@/components/maskeditor/dialog/TopBarHeader.vue'
4+
import MaskEditorContent from '@/components/maskeditor/MaskEditorContent.vue'
5+
6+
export function useMaskEditor() {
7+
const openMaskEditor = (node: LGraphNode) => {
8+
if (!node) {
9+
console.error('[MaskEditor] No node provided')
10+
return
11+
}
12+
13+
if (!node.imgs?.length && node.previewMediaType !== 'image') {
14+
console.error('[MaskEditor] Node has no images')
15+
return
16+
}
17+
18+
useDialogStore().showDialog({
19+
key: 'global-mask-editor',
20+
headerComponent: TopBarHeader,
21+
component: MaskEditorContent,
22+
props: {
23+
node
24+
},
25+
dialogComponentProps: {
26+
style: 'width: 90vw; height: 90vh;',
27+
modal: true,
28+
maximizable: true,
29+
closable: true,
30+
pt: {
31+
root: {
32+
class: 'mask-editor-dialog flex flex-col'
33+
},
34+
content: {
35+
class: 'flex flex-col min-h-0 flex-1 !p-0'
36+
},
37+
header: {
38+
class: '!p-2'
39+
}
40+
}
41+
}
42+
})
43+
}
44+
45+
return {
46+
openMaskEditor
47+
}
48+
}

src/extensions/core/maskeditor.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import { app } from '@/scripts/app'
55
import { ComfyApp } from '@/scripts/app'
66
import { useMaskEditorStore } from '@/stores/maskEditorStore'
77
import { useDialogStore } from '@/stores/dialogStore'
8-
import MaskEditorContent from '@/components/maskeditor/MaskEditorContent.vue'
9-
import TopBarHeader from '@/components/maskeditor/dialog/TopBarHeader.vue'
108
import { MaskEditorDialogOld } from './maskEditorOld'
119
import { ClipspaceDialog } from './clipspace'
10+
import { useMaskEditor } from '@/composables/maskeditor/useMaskEditor'
1211

1312
function openMaskEditor(node: LGraphNode): void {
1413
if (!node) {
@@ -26,32 +25,7 @@ function openMaskEditor(node: LGraphNode): void {
2625
)
2726

2827
if (useNewEditor) {
29-
// Use new refactored editor
30-
useDialogStore().showDialog({
31-
key: 'global-mask-editor',
32-
headerComponent: TopBarHeader,
33-
component: MaskEditorContent,
34-
props: {
35-
node
36-
},
37-
dialogComponentProps: {
38-
style: 'width: 90vw; height: 90vh;',
39-
modal: true,
40-
maximizable: true,
41-
closable: true,
42-
pt: {
43-
root: {
44-
class: 'mask-editor-dialog flex flex-col'
45-
},
46-
content: {
47-
class: 'flex flex-col min-h-0 flex-1 !p-0'
48-
},
49-
header: {
50-
class: '!p-2'
51-
}
52-
}
53-
}
54-
})
28+
useMaskEditor().openMaskEditor(node)
5529
} else {
5630
// Use old editor
5731
ComfyApp.copyToClipspace(node)

src/services/litegraphService.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
import { getOrderedInputSpecs } from '@/workbench/utils/nodeDefOrderingUtil'
5959

6060
import { useExtensionService } from './extensionService'
61+
import { useMaskEditor } from '@/composables/maskeditor/useMaskEditor'
6162

6263
export const CONFIG = Symbol()
6364
export const GET_CONFIG = Symbol()
@@ -796,11 +797,7 @@ export const useLitegraphService = () => {
796797
options.push({
797798
content: 'Open in MaskEditor | Image Canvas',
798799
callback: () => {
799-
ComfyApp.copyToClipspace(this)
800-
// @ts-expect-error fixme ts strict error
801-
ComfyApp.clipspace_return_node = this
802-
// @ts-expect-error fixme ts strict error
803-
ComfyApp.open_maskeditor()
800+
useMaskEditor().openMaskEditor(this)
804801
}
805802
})
806803
}

0 commit comments

Comments
 (0)