vscode-webview-ui-toolkit
vscode-webview-ui-toolkit copied to clipboard
Provide way to get the selected text of a text field.
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.
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
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.
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.