mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
feat(trace-viewer): allow pasting traces (#31608)
This commit is contained in:
parent
5c8fe5c33c
commit
0c11d6ed80
@ -58,6 +58,21 @@ export const WorkbenchLoader: React.FunctionComponent<{
|
|||||||
setProcessingErrorMessage(null);
|
setProcessingErrorMessage(null);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const listener = async (e: ClipboardEvent) => {
|
||||||
|
if (!e.clipboardData?.files.length)
|
||||||
|
return;
|
||||||
|
for (const file of e.clipboardData.files) {
|
||||||
|
if (file.type !== 'application/zip')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
processTraceFiles(e.clipboardData.files);
|
||||||
|
};
|
||||||
|
document.addEventListener('paste', listener);
|
||||||
|
return () => document.removeEventListener('paste', listener);
|
||||||
|
});
|
||||||
|
|
||||||
const handleDropEvent = React.useCallback((event: React.DragEvent<HTMLDivElement>) => {
|
const handleDropEvent = React.useCallback((event: React.DragEvent<HTMLDivElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
processTraceFiles(event.dataTransfer.files);
|
processTraceFiles(event.dataTransfer.files);
|
||||||
|
Loading…
Reference in New Issue
Block a user