Skip to content

Conversation

@abemedia
Copy link
Member

@abemedia abemedia commented Jun 26, 2020

This PR enables JavaScript clipboard access for Linux, MacOS & Edge Chromium on Windows.

For Linux & macOS it enables both document.execCommand("paste) & navigator.clipboard, however for Edge Chromium only the latter.

I have not been able to find any info about enabling clipboard access for EdgeHTML so I assume it only works with a custom implementation. Since the Webview Runtime is dropping Q3 and will make the EdgeHTML integration obsolete it doesn't seem worth the effort though.

@abemedia abemedia changed the title Allow JS to access clipboard on Linux WIP: Allow JS to access clipboard on Linux Jun 26, 2020
@abemedia abemedia changed the title WIP: Allow JS to access clipboard on Linux WIP: Allow JS to access clipboard Jun 26, 2020
@abemedia abemedia mentioned this pull request Jun 27, 2020
@abemedia abemedia changed the title WIP: Allow JS to access clipboard Allow JS to access clipboard Jul 8, 2020
@nothingismagick
Copy link
Contributor

@abemedia - can you review? I am really not sure why clang-format keeps on failing.

@abemedia
Copy link
Member Author

Sure thing. Will do later today.

@rajivshah3
Copy link
Contributor

rajivshah3 commented Jul 12, 2020

If you run clang-format -style=file -i webview.h it should fix things automatically. It looks like there's an issue with where you put the * (e.g. ICoreWebView2* sender, it prefers ICoreWebView2 *sender) and then your editor might be putting extra whitespace on line 933

@abemedia
Copy link
Member Author

Have fixed the formatting. Think we're ready to merge

@nothingismagick nothingismagick merged commit 9444582 into webview:master Jul 16, 2020
@nothingismagick
Copy link
Contributor

Thankyou!

@abemedia
Copy link
Member Author

No, thank you! ;)

@d1y
Copy link

d1y commented Jul 16, 2020

cool😉

Comment on lines +631 to +638
objc_msgSend(objc_msgSend(config, "preferences"_sel),
"setValue:forKey:"_sel,
objc_msgSend("NSNumber"_cls, "numberWithBool:"_sel, 1),
"javaScriptCanAccessClipboard"_str);
objc_msgSend(objc_msgSend(config, "preferences"_sel),
"setValue:forKey:"_sel,
objc_msgSend("NSNumber"_cls, "numberWithBool:"_sel, 1),
"DOMPasteAllowed"_str);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are private APIs and may result in rejection from the Mac App Store, so we need to figure out another approach

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #425

@PerBothner
Copy link

I just noticed that on Gtk (Fedora Linux) middle-button click does a paste from the clipboard (i.e. CLIPBOARD), but it should do a paste from the current selection (i.e. PRIMARY).

@abemedia
Copy link
Member Author

abemedia commented Aug 5, 2020

I just noticed that on Gtk (Fedora Linux) middle-button click does a paste from the clipboard (i.e. CLIPBOARD), but it should do a paste from the current selection (i.e. PRIMARY).

This is most likely the default in GTK since all this PR does is enable GTK's native clipboard support.

@PerBothner
Copy link

"This is most likely the default in GTK since all this PR does is enable GTK's native clipboard support."

Looks like you're right - using epiphany has the same problem.

@SteffenL SteffenL added this to the v0.10.0 milestone Sep 1, 2023
@SteffenL SteffenL added the type: improvement Pull request is an improvement of an existing feature label Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: improvement Pull request is an improvement of an existing feature

Development

Successfully merging this pull request may close these issues.

6 participants