clippie
Advanced tools
Comparing version 4.0.3 to 4.0.4
export async function clippie(content, {reject = false} = {}) { | ||
try { | ||
if (!navigator?.clipboard) { // navigator.clipboard is undefined on insecure origin | ||
return fallback(content); | ||
} | ||
if (Array.isArray(content)) { | ||
if (!navigator?.clipboard && content.length === 1 && typeof content[0] === "string") { | ||
return fallback(content); | ||
} | ||
await navigator.clipboard.write([ | ||
@@ -8,0 +8,0 @@ new ClipboardItem(Object.fromEntries(content.map(c => [c.type ?? "text/plain", c]))), |
{ | ||
"name": "clippie", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "Teeny-tiny browser clipboard copy", | ||
@@ -16,6 +16,6 @@ "author": "silverwind", | ||
"blob-polyfill": "7.0.20220408", | ||
"eslint": "8.44.0", | ||
"eslint-config-silverwind": "73.1.2", | ||
"eslint": "8.46.0", | ||
"eslint-config-silverwind": "74.0.0", | ||
"jsdom": "22.1.0", | ||
"updates": "14.3.2", | ||
"updates": "14.3.4", | ||
"versions": "11.0.1", | ||
@@ -22,0 +22,0 @@ "vitest": "0.33.0", |
# clippie | ||
[![](https://img.shields.io/npm/v/clippie.svg?style=flat)](https://www.npmjs.org/package/clippie) [![](https://img.shields.io/npm/dm/clippie.svg)](https://www.npmjs.org/package/clippie) [![](https://img.shields.io/bundlephobia/minzip/clippie.svg)](https://bundlephobia.com/package/clippie) [![](https://packagephobia.com/badge?p=clippie)](https://packagephobia.com/result?p=clippie) | ||
`clippie` copies text and images to clipboard in browsers. Text copy works on both secure and insecure contexts (via fallback), image copy requires a secure context (https or localhost). | ||
`clippie` copies text and images to clipboard in browsers. Text copy works on both secure and insecure contexts (via fallback), image or array copy requires a secure context (https or localhost). | ||
@@ -6,0 +6,0 @@ ## Usage |
3436