vscode-webview-ui-toolkit icon indicating copy to clipboard operation
vscode-webview-ui-toolkit copied to clipboard

Provide way to get the selected text of a text field.

Open gcampbell-msft opened this issue 3 years ago • 3 comments

Feature request

Provide the ability to programmatically get the selected text from a vscode-text-field.

Use case

Suppose you have a reference to the html reference, it would be nice to have access to fields that would allow you to get the selected text from the vscode-text-field, rather than only being able to grab the entire text in the field.

Possibly provide fields that are similar to this code such that it can be replicated with this item:

var t = text.value.substr(text.selectionStart, text.selectionEnd - text.selectionStart);

Assume that text is a reference to the html element of the vscode-text-field.

gcampbell-msft avatar Sep 01 '22 19:09 gcampbell-msft

Thanks for the request @gcampbell-msft!

I'd be open to adding this down the road. Just so I have some more context, however, what type of experience are you hoping to implement with this functionality?

cc @daviddossett

hawkticehurst avatar Sep 01 '22 22:09 hawkticehurst

In a webview that I'm working on, there is a desire/need to provide a context menu with options to copy/paste/etc. In order to make this happen, it is necessary to programmatically copy the highlighted text (specifically for the Copy function). This is the use case I'm looking for.

Let me know if that still have questions or need any more explanation.

gcampbell-msft avatar Sep 02 '22 15:09 gcampbell-msft

Ahh, I see. That totally makes sense. More than happy to add this to the backlog then.

And thanks, I think I have enough context to move forward but I'll definitely follow up with other Qs if I have them.

hawkticehurst avatar Sep 02 '22 19:09 hawkticehurst