Kanaries / pygwalker

PyGWalker: Turn your pandas dataframe into an interactive UI for visual analysis
https://kanaries.net/pygwalker
Apache License 2.0
10.7k stars 545 forks source link

fix: "Copy to Clipboard" in different browser #543

Closed BHznJNs closed 2 months ago

BHznJNs commented 2 months ago

As I reported in this issue #542 , the Copy to Clipboard in the Code Export dislog causes a JavaScript error. The reason of this error was also mentioned in this issue and what I did is just to check the browser the user uses. For the Chromium based browser, just copy as the original way while for the Firefox and Webkit browser, directly calls the navigator.clipboard.writeText function.

longxiaofei commented 2 months ago

It seems that only need to try invoke navigator.clipboard.writeText(content) and judge whether there is any errors.

I think there may be no need to judge permissionStatus and browser type.

BHznJNs commented 2 months ago

It seems that only need to try invoke navigator.clipboard.writeText(content) and judge whether there is any errors.

I think there may be no need to judge permissionStatus and browser type.

In some Chromium based browser, e.g. Microsoft Edge in the picture below, there is permission settings for websites and these settings are just corresponds to the PermissionName for Chromium. Thus I infer that there is still need to check the browser and user permission? 图片

islxyqwe commented 2 months ago

I tried the isChromium function and found that it returns false under Chrome 124.0.6367.119. just use await navigator.clipboard.writeText should be nice in both firefox and chomium.

longxiaofei commented 2 months ago

LGTM