mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-22 13:32:11 +00:00
Group Nodes are a legacy feature superseded by Subgraphs. This removes all UI entry points for creating new Group Nodes, while keeping the loading, ungrouping, and management code intact so existing workflows that contain Group Nodes continue to load and can still be unpacked or managed. Removed entry points: - 'Convert selected nodes to group node' command - Alt+G keybinding - 'Convert to Group Node (Deprecated)' canvas and node context menu items - 'Convert to Group Node' option in the Vue selection menu - Associated en locale strings - Browser tests that exercised the creation flow
145 lines
3.5 KiB
TypeScript
145 lines
3.5 KiB
TypeScript
import { computed } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import { useFrameNodes } from './useFrameNodes'
|
|
import { BadgeVariant } from './useMoreOptionsMenu'
|
|
import type { MenuOption } from './useMoreOptionsMenu'
|
|
import { useNodeArrangement } from './useNodeArrangement'
|
|
import { useSelectionOperations } from './useSelectionOperations'
|
|
import { useSubgraphOperations } from './useSubgraphOperations'
|
|
|
|
/**
|
|
* Composable for selection-related menu operations
|
|
*/
|
|
export function useSelectionMenuOptions() {
|
|
const { t } = useI18n()
|
|
const {
|
|
copySelection,
|
|
duplicateSelection,
|
|
deleteSelection,
|
|
renameSelection
|
|
} = useSelectionOperations()
|
|
|
|
const { alignOptions, distributeOptions, applyAlign, applyDistribute } =
|
|
useNodeArrangement()
|
|
|
|
const { convertToSubgraph, unpackSubgraph, addSubgraphToLibrary } =
|
|
useSubgraphOperations()
|
|
|
|
const { frameNodes } = useFrameNodes()
|
|
|
|
const alignSubmenu = computed(() =>
|
|
alignOptions.map((align) => ({
|
|
label: align.localizedName,
|
|
icon: align.icon,
|
|
action: () => applyAlign(align)
|
|
}))
|
|
)
|
|
|
|
const distributeSubmenu = computed(() =>
|
|
distributeOptions.map((distribute) => ({
|
|
label: distribute.localizedName,
|
|
icon: distribute.icon,
|
|
action: () => applyDistribute(distribute)
|
|
}))
|
|
)
|
|
|
|
const getBasicSelectionOptions = (): MenuOption[] => [
|
|
{
|
|
label: t('contextMenu.Rename'),
|
|
action: renameSelection
|
|
},
|
|
{
|
|
label: t('contextMenu.Copy'),
|
|
shortcut: 'Ctrl+C',
|
|
action: copySelection
|
|
},
|
|
{
|
|
label: t('contextMenu.Duplicate'),
|
|
shortcut: 'Ctrl+D',
|
|
action: duplicateSelection
|
|
}
|
|
]
|
|
|
|
const getSubgraphOptions = ({
|
|
hasSubgraphs,
|
|
hasMultipleSelection
|
|
}: {
|
|
hasSubgraphs: boolean
|
|
hasMultipleSelection: boolean
|
|
}): MenuOption[] => {
|
|
const convertOption: MenuOption = {
|
|
label: t('contextMenu.Convert to Subgraph'),
|
|
icon: 'icon-[lucide--shrink]',
|
|
action: convertToSubgraph,
|
|
badge: BadgeVariant.NEW
|
|
}
|
|
|
|
const options: MenuOption[] = []
|
|
const showConvertOption = !hasSubgraphs || hasMultipleSelection
|
|
|
|
if (showConvertOption) {
|
|
options.push(convertOption)
|
|
}
|
|
|
|
if (hasSubgraphs) {
|
|
if (!hasMultipleSelection) {
|
|
options.push({
|
|
label: t('contextMenu.Add Subgraph to Library'),
|
|
icon: 'icon-[lucide--folder-plus]',
|
|
action: addSubgraphToLibrary
|
|
})
|
|
}
|
|
options.push({
|
|
label: t('contextMenu.Unpack Subgraph'),
|
|
icon: 'icon-[lucide--expand]',
|
|
action: unpackSubgraph
|
|
})
|
|
}
|
|
|
|
return options
|
|
}
|
|
|
|
const getMultipleNodesOptions = (): MenuOption[] => [
|
|
{
|
|
label: t('g.frameNodes'),
|
|
icon: 'icon-[lucide--frame]',
|
|
action: frameNodes
|
|
}
|
|
]
|
|
|
|
const getAlignmentOptions = (): MenuOption[] => [
|
|
{
|
|
label: t('contextMenu.Align Selected To'),
|
|
icon: 'icon-[lucide--align-start-horizontal]',
|
|
hasSubmenu: true,
|
|
submenu: alignSubmenu.value,
|
|
action: () => {}
|
|
},
|
|
{
|
|
label: t('contextMenu.Distribute Nodes'),
|
|
icon: 'icon-[lucide--align-center-horizontal]',
|
|
hasSubmenu: true,
|
|
submenu: distributeSubmenu.value,
|
|
action: () => {}
|
|
}
|
|
]
|
|
|
|
const getDeleteOption = (): MenuOption => ({
|
|
label: t('contextMenu.Delete'),
|
|
icon: 'icon-[lucide--trash-2]',
|
|
shortcut: 'Delete',
|
|
action: deleteSelection
|
|
})
|
|
|
|
return {
|
|
getBasicSelectionOptions,
|
|
getSubgraphOptions,
|
|
getMultipleNodesOptions,
|
|
getDeleteOption,
|
|
getAlignmentOptions,
|
|
alignSubmenu,
|
|
distributeSubmenu
|
|
}
|
|
}
|