mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-12 08:30:08 +00:00
Amp-Thread-ID: https://ampcode.com/threads/T-019c1373-f6d0-7426-a3ee-5673891f9dcc Co-authored-by: Amp <amp@ampcode.com>
30 lines
786 B
TypeScript
30 lines
786 B
TypeScript
import type { Locator, Page } from '@playwright/test'
|
|
|
|
export class ClipboardHelper {
|
|
constructor(
|
|
private readonly page: Page,
|
|
private readonly canvas: Locator
|
|
) {}
|
|
|
|
private async nextFrame(): Promise<void> {
|
|
await this.page.evaluate(() => new Promise<number>(requestAnimationFrame))
|
|
}
|
|
|
|
private async ctrlSend(
|
|
keyToPress: string,
|
|
locator: Locator | null = this.canvas
|
|
): Promise<void> {
|
|
const target = locator ?? this.page.keyboard
|
|
await target.press(`Control+${keyToPress}`)
|
|
await this.nextFrame()
|
|
}
|
|
|
|
async copy(locator?: Locator | null): Promise<void> {
|
|
await this.ctrlSend('KeyC', locator ?? this.canvas)
|
|
}
|
|
|
|
async paste(locator?: Locator | null): Promise<void> {
|
|
await this.ctrlSend('KeyV', locator ?? this.canvas)
|
|
}
|
|
}
|