@livelybone/copy
Version:
About clipboard copy, Object simple&deep copy
10 lines (8 loc) • 872 B
JavaScript
/**
* Bundle of @livelybone/copy
* Generated: 2023-07-25
* Version: 2.6.6
* License: MIT
* Author: 2631541504@qq.com
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).copyDom=n()}(this,function(){"use strict";return function(e,n){var t,o,c=(n=Object.assign({},{clearSelect:!1,cut:!1},n)).clearSelect,n=n.cut;if(window.getSelection){if(!(o=window.getSelection()))return console.error("copyDom: window.getSelection() return null"),!1;t=window.document.createRange(),o.removeAllRanges(),t.selectNode(e),o.addRange(t)}else{var l=document.body.createTextRange;l&&((t=l()).moveToElementText(e),t.select())}return l=document.execCommand("copy"),o&&c&&o.removeAllRanges(),n&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value="":e.innerHTML=""),l}});