From 008ec441783c618e0e9177eec66f4b0d26c86a14 Mon Sep 17 00:00:00 2001 From: Srujan Gurram Date: Sun, 26 Nov 2023 14:59:20 +0530 Subject: [PATCH] fixed image capture --- package.json | 1 + .../Sidebar/chat/ImageCaptureButton.tsx | 6 +- src/lib/getScreenshotImage.ts | 161 +++++++++++++----- yarn.lock | 34 ++++ 4 files changed, 152 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index d7388f3c..6a50e7f6 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "axios": "^1.3.5", "dnd-kit-sortable-tree": "^0.1.58", "endent": "^2.1.0", + "html2canvas": "^1.4.1", "jotai": "^2.4.3", "langchain": "^0.0.197-rc.1", "object-hash": "^3.0.0", diff --git a/src/components/Sidebar/chat/ImageCaptureButton.tsx b/src/components/Sidebar/chat/ImageCaptureButton.tsx index 1bb5c66f..d8c4442e 100644 --- a/src/components/Sidebar/chat/ImageCaptureButton.tsx +++ b/src/components/Sidebar/chat/ImageCaptureButton.tsx @@ -8,7 +8,7 @@ const ImageCaptureButton = ({ addMessageDraftFile, }: ImageCaptureButtonProps) => { const handleScreenshotClick = async () => { - const image = await new Promise((resolve) => { + const imageBlob: Blob = await new Promise((resolve) => { window.parent.postMessage({ action: 'get-screenshot-image' }, '*') window.addEventListener('message', function (event) { const { action, payload } = event.data @@ -17,8 +17,8 @@ const ImageCaptureButton = ({ } }) }) - console.log('image', image) - addMessageDraftFile(image as Blob) + + addMessageDraftFile(imageBlob as Blob) } return (