mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 07:44:11 +00:00
## Summary Removes the legacy mask editor. May also want to remove the "Beta" tags on all the current mask editor components/mentions in the app now as well. ## Context Telemetry data shows zero users using the legacy mask editor. It has been considerable time since we switched to the new one, and there really is no reason to use the legacy version given how lacking it is. In https://github.com/Comfy-Org/ComfyUI_frontend/pull/7332 (v1.35.2 - Dec 11, 2025), we added a final warning that the legacy mask editor is being removed. On 1.36, this PR can be merged, as more than enough warning will have been given. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7370-cleanup-remove-the-legacy-mask-editor-and-all-related-code-2c66d73d365081d58fbed0f3c84bcb0d) by [Unito](https://www.unito.io)
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import _ from 'es-toolkit/compat'
|
|
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
|
|
|
import { app } from '@/scripts/app'
|
|
import { useMaskEditorStore } from '@/stores/maskEditorStore'
|
|
import { useDialogStore } from '@/stores/dialogStore'
|
|
import { useMaskEditor } from '@/composables/maskeditor/useMaskEditor'
|
|
|
|
function openMaskEditor(node: LGraphNode): void {
|
|
if (!node) {
|
|
console.error('[MaskEditor] No node provided')
|
|
return
|
|
}
|
|
|
|
if (!node.imgs?.length && node.previewMediaType !== 'image') {
|
|
console.error('[MaskEditor] Node has no images')
|
|
return
|
|
}
|
|
|
|
useMaskEditor().openMaskEditor(node)
|
|
}
|
|
|
|
// Check if the dialog is already opened
|
|
function isOpened(): boolean {
|
|
return useDialogStore().isDialogOpen('global-mask-editor')
|
|
}
|
|
|
|
app.registerExtension({
|
|
name: 'Comfy.MaskEditor',
|
|
settings: [
|
|
{
|
|
id: 'Comfy.MaskEditor.BrushAdjustmentSpeed',
|
|
category: ['Mask Editor', 'BrushAdjustment', 'Sensitivity'],
|
|
name: 'Brush adjustment speed multiplier',
|
|
tooltip:
|
|
'Controls how quickly the brush size and hardness change when adjusting. Higher values mean faster changes.',
|
|
type: 'slider',
|
|
attrs: {
|
|
min: 0.1,
|
|
max: 2.0,
|
|
step: 0.1
|
|
},
|
|
defaultValue: 1.0,
|
|
versionAdded: '1.0.0'
|
|
},
|
|
{
|
|
id: 'Comfy.MaskEditor.UseDominantAxis',
|
|
category: ['Mask Editor', 'BrushAdjustment', 'UseDominantAxis'],
|
|
name: 'Lock brush adjustment to dominant axis',
|
|
tooltip:
|
|
'When enabled, brush adjustments will only affect size OR hardness based on which direction you move more',
|
|
type: 'boolean',
|
|
defaultValue: true
|
|
}
|
|
],
|
|
commands: [
|
|
{
|
|
id: 'Comfy.MaskEditor.OpenMaskEditor',
|
|
icon: 'pi pi-pencil',
|
|
label: 'Open Mask Editor for Selected Node',
|
|
function: () => {
|
|
const selectedNodes = app.canvas.selected_nodes
|
|
if (!selectedNodes || Object.keys(selectedNodes).length !== 1) return
|
|
|
|
const selectedNode = selectedNodes[Object.keys(selectedNodes)[0]]
|
|
openMaskEditor(selectedNode)
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy.MaskEditor.BrushSize.Increase',
|
|
icon: 'pi pi-plus-circle',
|
|
label: 'Increase Brush Size in MaskEditor',
|
|
function: () => changeBrushSize((old) => _.clamp(old + 4, 1, 100))
|
|
},
|
|
{
|
|
id: 'Comfy.MaskEditor.BrushSize.Decrease',
|
|
icon: 'pi pi-minus-circle',
|
|
label: 'Decrease Brush Size in MaskEditor',
|
|
function: () => changeBrushSize((old) => _.clamp(old - 4, 1, 100))
|
|
}
|
|
]
|
|
})
|
|
|
|
const changeBrushSize = async (sizeChanger: (oldSize: number) => number) => {
|
|
if (!isOpened()) return
|
|
|
|
const store = useMaskEditorStore()
|
|
const oldBrushSize = store.brushSettings.size
|
|
const newBrushSize = sizeChanger(oldBrushSize)
|
|
store.setBrushSize(newBrushSize)
|
|
}
|