|
@@ -1,6 +1,6 @@
|
|
|
let onCopy = () => {}
|
|
|
|
|
|
-const copy = (target) => {
|
|
|
+const copy = (target, mimeType = undefined) => {
|
|
|
if (typeof target === 'function') {
|
|
|
target = target()
|
|
|
}
|
|
@@ -9,6 +9,17 @@ const copy = (target) => {
|
|
|
target = JSON.stringify(target)
|
|
|
}
|
|
|
|
|
|
+ if (mimeType !== undefined) {
|
|
|
+ return window.navigator.clipboard.write([
|
|
|
+ new ClipboardItem({
|
|
|
+ [mimeType]: new Blob([target], {
|
|
|
+ type: mimeType,
|
|
|
+ })
|
|
|
+ })
|
|
|
+ ])
|
|
|
+ .then(onCopy)
|
|
|
+ }
|
|
|
+
|
|
|
return window.navigator.clipboard.writeText(target)
|
|
|
.then(onCopy)
|
|
|
}
|