mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix: reference parameters and add test cases (#8740)
Upstreams: https://github.com/toeverything/blocksuite/pull/8689 Closes: AF-1650
This commit is contained in:
@@ -63,3 +63,26 @@ export async function pasteByKeyboard(page: Page) {
|
||||
await page.keyboard.press('v', { delay: 50 });
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function writeTextToClipboard(page: Page, text: string) {
|
||||
// paste the url
|
||||
await page.evaluate(
|
||||
async ([text]) => {
|
||||
const clipData = {
|
||||
'text/plain': text,
|
||||
};
|
||||
const e = new ClipboardEvent('paste', {
|
||||
clipboardData: new DataTransfer(),
|
||||
});
|
||||
Object.defineProperty(e, 'target', {
|
||||
writable: false,
|
||||
value: document,
|
||||
});
|
||||
Object.entries(clipData).forEach(([key, value]) => {
|
||||
e.clipboardData?.setData(key, value);
|
||||
});
|
||||
document.dispatchEvent(e);
|
||||
},
|
||||
[text]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user