automeris-io / WebPlotDigitizer

Computer vision assisted tool to extract numerical data from plot images.
https://automeris.io
GNU Affero General Public License v3.0
2.66k stars 364 forks source link

Fix issue of copying/pasting images from PowerPoint #322

Closed hu-xiaonan closed 7 months ago

hu-xiaonan commented 7 months ago

This could fix #301 .

I encountered the same problem as #301 that the page got stuck with "Processing...".

Through console debugging, I found that when copying/pasting a figure from PowerPoint, there may be two items in ev.clipboardData.items, namely

DataTransferItemList {0: DataTransferItem, 1: DataTransferItem, length: 2}
> 0: DataTransferItem {kind: 'string', type: 'image/svg+xml'}
> 1: DataTransferItem {kind: 'file', type: 'image/png'}
  length: 2
> [[Prototype]]: DataTransferItemList

Both items have type containing substring "image", but only the item with kind === "file" is valid for the method .getAsFile(), so an additional judgement items[i].kind === "file" will help exclude invalid items.

The issue seems related to the specific versions and settings of PowerPoint, as the issue exists with my PowerPoint (MS Office 2016, Windows 10) but not with some other versions (for example, MS Office 2019, Windows 10).