Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public copySelectedTextToClipboard() {
- const selection = getSelectedText();
- if (selection != "") {
- window.navigator.clipboard.writeTextToClipboard(this.value)
- const inputfield = this.$refs.input as any
- inputfield.focus()
- }
- else{
- window.navigator.clipboard.writeTextToClipboard(selection)
- }
- }
- public cutSelectedTextToClipboard() {
- document.execCommand("cut")
- }
- public pasteSelectedTextFromClipboard() {
- const inputfield = this.$refs.input as any
- inputfield.focus()
- document.execCommand("paste")
- }
- private getSelectedText() {
- var text = "";
- if (typeof window.getSelection != "undefined") {
- text = window.getSelection().toString();
- } else if (typeof document.selection != "undefined" && document.selection.type == "Text") {
- text = document.selection.createRange().text;
- }
- return text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement