Skip to content
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

Cmd+C/Ctrl+C doesn't reach web view #6924

Closed
Huachao opened this issue May 26, 2016 · 7 comments
Closed

Cmd+C/Ctrl+C doesn't reach web view #6924

Huachao opened this issue May 26, 2016 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@Huachao
Copy link
Contributor

Huachao commented May 26, 2016

  • VSCode Version: 1.1.1
  • OS Version: Windows 10 Enterprise x64

Steps to Reproduce:

  1. Use the command 'vscode.previewHtml' in our extension, like the sample code vscode preview html sample.
  2. In another panel will display the previewed html.

However, we can't copy the text from the previewed html in our test, even in the sample extension Preview CSS Properties Sample.

And I think we may have the requirements that, user wish to copy the text(maybe the previewed result is transformed output) in the preview panel.

@jrieken jrieken added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label May 27, 2016
@jrieken
Copy link
Member

jrieken commented May 27, 2016

You can always ask for the context of a previewed document, using the underlying TextDocument and use a node module to copy this contents to the clipboard

@jrieken jrieken closed this as completed May 27, 2016
@Huachao
Copy link
Contributor Author

Huachao commented May 28, 2016

@jrieken, I still don't quite understand what is and how to get the context of a previewed document, could you please give me an example or more details? And I want to say it again that what I want is allow user to Ctrl+C of the previewed document. Thanks in advance

@jrieken
Copy link
Member

jrieken commented May 31, 2016

You can always run openTextDocument and copy the text of the returned document.

The previewHtml command is producing a piece of UI and, as other UI pieces like the git or explorer viewlet, it not generally desirable to have a select all and copy gesture. Tho, I understand that there are cases in which it makes sense to have the contents selectable and copyable. I believe tho that only the extension can make that decision.

The problem I see is that the Cmd+C doesn't travel to the web view container. Reopening to check if this is an issue with us or electron.

@jrieken jrieken reopened this May 31, 2016
@jrieken jrieken added this to the June 2016 milestone May 31, 2016
@jrieken jrieken added bug Issue identified by VS Code Team member as probable bug and removed *question Issue represents a question, should be posted to StackOverflow (VS Code) labels May 31, 2016
@jrieken
Copy link
Member

jrieken commented May 31, 2016

@alexandrudima @bpasero It seems like something has changed here and that we now unconditionally eat up Cmd+C. Ideas?

@jrieken jrieken changed the title Support copy text of previewed html Cmd+C/Ctrl+C doesn't reach web view May 31, 2016
@bpasero
Copy link
Member

bpasero commented May 31, 2016

@jrieken I did not touch this recently, not sure about @alexandrudima. I know we do quite some dances in https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/clipboard/browser/clipboard.ts#L168 to know where to send the action to and we might not handle the webview case here.

Also there may be differences between Mac and Windows...

@bpasero
Copy link
Member

bpasero commented Jun 3, 2016

I can reproduce already in our last release so it seems to be broken since we added the webview component. I can also reproduce on Windows and Mac so it does not seem Mac-Menu specific.

@bpasero
Copy link
Member

bpasero commented Jun 3, 2016

@jrieken I think the issue is that we call document.executeCommand("copy") (or any of the other edit operations) and that usually just works in all cases even in iframes. Since the webview is out of process it just does not participate.

I think the only way out is to install keybinding listeners within the webview and run document.executeCommand() within (or the webview copy method: https://github.com/electron/electron/blob/master/docs/api/web-view-tag.md#webviewcopy) because I cannot even find out if a webview currently has focus (that is, document.activeElement does not return me a webview if focus is within).

@bpasero bpasero added the verified Verification succeeded label Jul 4, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants