mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 23:26:30 +08:00
15e9acefc2
[BS-2512](https://linear.app/affine-design/issue/BS-2512/选中多段粘贴,多段只有第一段会被replace,这个bug还在)
25 lines
603 B
TypeScript
25 lines
603 B
TypeScript
import type { Page } from '@playwright/test';
|
|
|
|
export async function pasteContent(
|
|
page: Page,
|
|
clipData: Record<string, unknown>
|
|
) {
|
|
await page.evaluate(
|
|
({ clipData }) => {
|
|
const e = new ClipboardEvent('paste', {
|
|
clipboardData: new DataTransfer(),
|
|
});
|
|
Object.defineProperty(e, 'target', {
|
|
writable: false,
|
|
value: document,
|
|
});
|
|
Object.keys(clipData).forEach(key => {
|
|
e.clipboardData?.setData(key, clipData[key] as string);
|
|
});
|
|
document.dispatchEvent(e);
|
|
},
|
|
{ clipData }
|
|
);
|
|
await page.waitForTimeout(100);
|
|
}
|