We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d84a8b commit 7a3e42fCopy full SHA for 7a3e42f
packages/shared-utils/src/util.ts
@@ -701,13 +701,15 @@ function escapeChar (a) {
701
}
702
703
export function copyToClipboard (state) {
704
- if (typeof document === 'undefined') return
705
- const dummyTextArea = document.createElement('textarea')
706
- dummyTextArea.textContent = stringify(state)
707
- document.body.appendChild(dummyTextArea)
708
- dummyTextArea.select()
709
- document.execCommand('copy')
710
- document.body.removeChild(dummyTextArea)
+ let text: string
+
+ if (typeof state !== 'object') {
+ text = String(state)
+ } else {
+ text = stringify(state)
+ }
711
712
+ navigator.clipboard.writeText(text)
713
714
715
export function isEmptyObject (obj) {
0 commit comments