mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-18 05:31:03 +00:00
## Summary - Adds a **Paste Image** context menu option to nodes that support image pasting (e.g. Load Image), complementing the existing **Copy Image** option - Reads clipboard image data via `navigator.clipboard.read()` and delegates to `node.pasteFiles()` — same path as `Ctrl+V` paste - Only shown on nodes that implement `pasteFiles` (e.g. LoadImage) - Available even when no image is loaded yet (e.g. fresh LoadImage node) - **Node 2.0 context menu only** — legacy litegraph menu is not supported - Fixes #9989 <img width="852" height="685" alt="스크린샷 2026-03-16 오후 5 34 28" src="https://github.com/user-attachments/assets/219e8162-312a-400b-90ec-961b95b5f472" /> ## Test plan - [x] Right-click a Load Image node (with or without image loaded) → verify "Paste Image" appears - [x] Copy an image to clipboard → click "Paste Image" → verify image is loaded into the node - [x] Verify "Paste Image" does not appear on output-only image nodes (e.g. Save Image, Preview Image) - [x] Unit tests pass: `pnpm vitest run src/composables/graph/useImageMenuOptions.test.ts` --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.describe('Paste Image context menu option', { tag: ['@node'] }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', true)
|
|
})
|
|
|
|
test('shows Paste Image in LoadImage node context menu', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('widgets/load_image_widget')
|
|
|
|
const loadImageNode = (
|
|
await comfyPage.nodeOps.getNodeRefsByType('LoadImage')
|
|
)[0]
|
|
|
|
const nodeEl = comfyPage.page.locator(
|
|
`[data-node-id="${loadImageNode.id}"]`
|
|
)
|
|
await nodeEl.click({ button: 'right' })
|
|
const menu = comfyPage.page.locator('.p-contextmenu')
|
|
await menu.waitFor({ state: 'visible' })
|
|
const menuLabels = await menu
|
|
.locator('[role="menuitem"] span.flex-1')
|
|
.allInnerTexts()
|
|
|
|
expect(menuLabels).toContain('Paste Image')
|
|
})
|
|
|
|
test('does not show Paste Image on output-only image nodes', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('nodes/single_save_image_node')
|
|
|
|
const saveImageNode = (
|
|
await comfyPage.nodeOps.getNodeRefsByType('SaveImage')
|
|
)[0]
|
|
|
|
const nodeEl = comfyPage.page.locator(
|
|
`[data-node-id="${saveImageNode.id}"]`
|
|
)
|
|
await nodeEl.click({ button: 'right' })
|
|
const menu = comfyPage.page.locator('.p-contextmenu')
|
|
await menu.waitFor({ state: 'visible' })
|
|
const menuLabels = await menu
|
|
.locator('[role="menuitem"] span.flex-1')
|
|
.allInnerTexts()
|
|
|
|
expect(menuLabels).not.toContain('Paste Image')
|
|
expect(menuLabels).not.toContain('Open Image')
|
|
})
|
|
})
|