-
Notifications
You must be signed in to change notification settings - Fork 36
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
do we really need navigator.clipboard.platform? #104
Comments
Here is some sample code showing how // Through navigator.clipboard.platform, simple equality checks may be used.
if (navigator.clipboard.platform === 'Windows') {
// Windows code.
} else if (navigator.clipboard.platform === 'MacOS') {
// Mac code.
} else if(navigator.clipboard.platform === 'Android') {
// Android code.
} // Through navigator.platform + navigator.userAgent, detection is slightly more complex
// source: https://stackoverflow.com/questions/38241480/detect-macos-ios-windows-android-and-linux-os-with-js
const windowsPlatforms = ['Win32', 'Win64', 'Windows'];
const macOsPlatforms = ['Macintosh', 'MacIntel'];
if (windowsPlatforms.indexOf(navigator.platform !== -1) {
// Windows code.
} else if (macOsPlatforms.indexOf(navigator.platform) !== -1) {
// Mac code.
} else if(/Android/.test(navigator.platform.userAgent)) {
// Android code.
} That said, While this API may be more direct and simple to use for clipboard, it could certainly also be an unnecessary API that duplicates existing behavior, which increases maintenance costs and may add confusion. It also certainly isn't required to meet the goals for Raw Clipboard Access. Summary: Pros:
Cons:
(Thank you for asking this question, and sorry for the wall of text.) |
I'm confused. Is this about raw clipboard API proposal? The current specification doesn't define this IDL attribute, right? The platform name as currently proposed in https://github.com/dway123/raw-clipboard-access/blob/master/explainer.md#navigatorclipboardplatform isn't workable because iOS and macOS pasteboards are interchangeable via continuity. |
Yes, I think this is about the raw clipboard API proposal (and responded assuming so, but could certainly be wrong). Do iOS and MacOS have the same representation for supported formats? Assuming so, I've updated the explainer appropriately to remove the iOS mention. If there's a better name for the backing clipboard for MacOS/iOS, it may be possible that we should opt for that as well. |
yeah, wrong repo. Sorry for the confusion. @dway123 anyway we could move the explainer to WICG repo? I can re-open the issue there if need be. |
Ah yeah, I'll try to move the explainer to WICG. Thank you for the suggestion. (I've never done this before, so I may take a bit of time to do so). Also, regarding more context for |
I've started a WICG thread here. Thanks! |
Closing this here since the discussion belongs (and has moved to) the https://github.com/WICG/raw-clipboard-access repo. Specifically: WICG/raw-clipboard-access#6 |
Just curious about rationale for navigator.clipboard.platform.
There are ways to get this information today. Exposing platform hook on clipboard interface seems odd.
The text was updated successfully, but these errors were encountered: