copy-to-clipboard-ultralight
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -1,1 +0,1 @@ | ||
function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=document;if(t.execCommand("copy")){var o=t.createElement("input");return o.setAttribute("readonly","readonly"),o.setAttribute("style","position: fixed; top:0; left:0; opacity:0;"),o.setAttribute("value",e),t.body.appendChild(o),o.setSelectionRange(0,e.length),o.select(),t.execCommand("copy"),t.body.removeChild(o),!0}return!1}export default e; | ||
function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=document;try{var n=t.createElement("input");return n.setAttribute("readonly","readonly"),n.setAttribute("style","position: fixed; top:0; left:0; opacity:0;"),n.setAttribute("value",e),t.body.appendChild(n),n.setSelectionRange(0,e.length),n.select(),t.execCommand("copy"),t.body.removeChild(n),!0}catch(e){return!1}}export default e; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ultralightCopy=t()}(this,(function(){"use strict";return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=document;if(t.execCommand("copy")){var o=t.createElement("input");return o.setAttribute("readonly","readonly"),o.setAttribute("style","position: fixed; top:0; left:0; opacity:0;"),o.setAttribute("value",e),t.body.appendChild(o),o.setSelectionRange(0,e.length),o.select(),t.execCommand("copy"),t.body.removeChild(o),!0}return!1}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ultralightCopy=t()}(this,(function(){"use strict";return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=document;try{var n=t.createElement("input");return n.setAttribute("readonly","readonly"),n.setAttribute("style","position: fixed; top:0; left:0; opacity:0;"),n.setAttribute("value",e),t.body.appendChild(n),n.setSelectionRange(0,e.length),n.select(),t.execCommand("copy"),t.body.removeChild(n),!0}catch(e){return!1}}})); |
{ | ||
"name": "copy-to-clipboard-ultralight", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Copy text to clipboard, support TypeScript.", | ||
@@ -14,3 +14,3 @@ "repository": { | ||
"build": "rollup -c", | ||
"server": "ws -p 3000 --static.index demo.html", | ||
"server": "ws -p 3000 --static.index test.html", | ||
"test": "jest" | ||
@@ -33,18 +33,18 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.12.3", | ||
"@babel/preset-env": "^7.12.1", | ||
"@babel/preset-typescript": "^7.12.1", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@types/jest": "^26.0.15", | ||
"jest": "^26.6.3", | ||
"jest-dev-server": "^4.4.0", | ||
"jest-puppeteer": "^4.4.0", | ||
"@babel/core": "^7.14.3", | ||
"@babel/preset-env": "^7.14.4", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@rollup/plugin-node-resolve": "^13.0.0", | ||
"@types/jest": "^26.0.23", | ||
"jest": "^27.0.4", | ||
"jest-dev-server": "^5.0.3", | ||
"jest-puppeteer": "^5.0.4", | ||
"local-web-server": "^4.2.1", | ||
"puppeteer": "^2.1.1", | ||
"puppeteer": "^10.0.0", | ||
"regenerator-runtime": "^0.13.7", | ||
"rollup": "^2.33.3", | ||
"rollup": "^2.51.0", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-dts": "^1.4.14", | ||
"rollup-plugin-dts": "^3.0.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.0.5" | ||
"typescript": "^4.3.2" | ||
}, | ||
@@ -51,0 +51,0 @@ "browserslist": [ |
function ultralightCopy(sourceStr: string = ""): boolean { | ||
const d = document // rudeuce size | ||
if (d.execCommand('copy')) { | ||
try { | ||
const inputDom = d.createElement('input'); | ||
@@ -14,3 +14,3 @@ inputDom.setAttribute('readonly', 'readonly'); | ||
return true | ||
} else { | ||
} catch (error) { | ||
return false | ||
@@ -17,0 +17,0 @@ } |
Sorry, the diff of this file is not supported yet
17556
17