New VSCode fallback behaviour for copyToClipboard#6598
New VSCode fallback behaviour for copyToClipboard#6598auto-submit[bot] merged 12 commits intoflutter:masterfrom
Conversation
| // This post message is only relevant in VSCode. If the parent frame is | ||
| // listening for this command, then it will attempt to copy the contents | ||
| // to the clipboard in the context of the parent frame. | ||
| window.parent?.postMessage( |
There was a problem hiding this comment.
You can probably use the existing postMessage in packages\devtools_app\lib\src\shared\config_specific\post_message\post_message_web.dart to avoid needing multiple stub files for this API? (eg. have a single copy function that just calls the shared postMessage)?
Edit: Actually looks like the postMessage function there maybe isn't used... maybe it was only partly done? 🤔
There was a problem hiding this comment.
interesting, yeah it doesn't look like it exposed 🤔
Would you be alright with me just leaving the multi stub files for the copy behaviour?
There was a problem hiding this comment.
Seems reasonable to me (if that's what's tested and works). It seems to be what the "launch URL" functionality (that I just re-discovered) does. Maybe it's worth adding a TODO that we could possibly refactor these to reduce the number of stubs though (both copy + launch url)?
(I suspect I added some of that dead postMessage code, so I'm happy to look, and either consolidate or delete the unused bits)
| @@ -0,0 +1,7 @@ | |||
| // Copyright 2023 The Chromium Authors. All rights reserved. | |||
There was a problem hiding this comment.
remove the stub file and just use the desktop file in the conditional import
| // ignore: avoid_web_libraries_in_flutter, as designed | ||
| import 'dart:html'; |
|
|
||
| if (successMessage != null) notificationService.push(successMessage); | ||
| } catch (e) { | ||
| _log.warning( |
There was a problem hiding this comment.
check if we are embedded and in VS code before doing any of this
There was a problem hiding this comment.
You can check if we are embedded by using ideTheme.embed and you can check which IDE is hosting by checking here: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/shared/analytics/_analytics_web.dart/#L733.
Although, I think we may want to modify the IdeTheme class to include the IDE name so we can look it up from there instead of having to look at our analytics file.
 Adds a fallback behaviour for copying which will allow copy buttons to actually work in VSCode. NOTE: success toasts will no longer show in VSCode though. I've also added some logging just in case a user is looking at their console when a copy fails. Hopefully this provides enough information that the unhide-able error doesn't look suspicious.  Related to Dart-Code/Dart-Code#4814 Fixes #5775
 Adds a fallback behaviour for copying which will allow copy buttons to actually work in VSCode. NOTE: success toasts will no longer show in VSCode though. I've also added some logging just in case a user is looking at their console when a copy fails. Hopefully this provides enough information that the unhide-able error doesn't look suspicious.  Related to Dart-Code/Dart-Code#4814 Fixes #5775 Mirror package:web version from Flutter SDK
Adds a fallback behaviour for copying which will allow copy buttons to actually work in VSCode.
NOTE: success toasts will no longer show in VSCode though.
I've also added some logging just in case a user is looking at their console when a copy fails. Hopefully this provides enough information that the unhide-able error doesn't look suspicious.

Related to Dart-Code/Dart-Code#4814
Fixes #5775