@acrool/js-utils
Advanced tools
+2
-1
@@ -32,4 +32,5 @@ /** | ||
| * @param scriptContent | ||
| * @param type | ||
| */ | ||
| export declare function insertScriptContent(scriptId: string, scriptContent: string): void; | ||
| export declare function insertScriptContent(scriptId: string, scriptContent: string, type: string): void; | ||
| /** | ||
@@ -36,0 +37,0 @@ * 插入Script |
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e,o){return!!e.className.match(new RegExp(`(\\s|^)${o}(\\s|$)`))}function d(e,o){c(e,o)||e.classList.add(o)}function a(e,o){e.classList.remove(o)}function s(e,o,t){if(document.getElementById(e)===null){const n=document.createElement("iframe");n.id=e,n.src=o,n.scrolling="no",n.frameborder="0",n.width=0,n.height=0,n.onload=()=>{t&&t(n)},document.body.appendChild(n)}}function m(e,o){if(document.getElementById(e)===null){const t=document.createElement("script");t.id=e,t.append(o),document.head.appendChild(t)}}function p(e,o,t){if(document.getElementById(e)===null){const n=document.createElement("script");n.id=e,n.src=o,t&&(n.onload=t),document.head.appendChild(n)}return!1}const u=async(e,o)=>{if(navigator.clipboard&&window.ClipboardItem)try{const t=new Blob([e],{type:"text/plain"}),n=new ClipboardItem({"text/plain":t});await navigator.clipboard.write([n]),console.log("Text copied using Clipboard API");return}catch{console.warn("Clipboard API failed, falling back to execCommand")}return new Promise((t,n)=>{const i=document.createElement("textarea");i.style.position="fixed",i.style.opacity="0",i.inputMode="none",o?i.value=e:i.innerText=e,document.body.appendChild(i),i.select();try{document.execCommand("copy")?(console.log("Text copied using execCommand"),t()):n(new Error("execCommand failed"))}catch(r){n(r)}finally{i.remove()}})},b=(e,o)=>{l(window.URL.createObjectURL(e),o)},l=(e,o)=>{const t=document.createElement("a");t.href=e,t.download=o,t.click()},f=e=>{const t=e.getBoundingClientRect().top;return window.innerHeight-t>t?"bottom":"top"},C=()=>{document.activeElement.blur()};exports.activeElementBlur=C;exports.addClass=d;exports.copyToClipboard=u;exports.downloadBlob=b;exports.downloadUrl=l;exports.getVisiblePosition=f;exports.hasClass=c;exports.insertIFrame=s;exports.insertScriptContent=m;exports.insertScriptSrc=p;exports.removeClass=a; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e,o){return!!e.className.match(new RegExp(`(\\s|^)${o}(\\s|$)`))}function d(e,o){c(e,o)||e.classList.add(o)}function a(e,o){e.classList.remove(o)}function s(e,o,n){if(document.getElementById(e)===null){const t=document.createElement("iframe");t.id=e,t.src=o,t.scrolling="no",t.frameborder="0",t.width=0,t.height=0,t.onload=()=>{n&&n(t)},document.body.appendChild(t)}}function m(e,o,n){if(document.getElementById(e)===null){const t=document.createElement("script");t.id=e,n&&(t.type=n),t.append(o),document.head.appendChild(t)}}function p(e,o,n){if(document.getElementById(e)===null){const t=document.createElement("script");t.id=e,t.src=o,n&&(t.onload=n),document.head.appendChild(t)}return!1}const u=async(e,o)=>{if(navigator.clipboard&&window.ClipboardItem)try{const n=new Blob([e],{type:"text/plain"}),t=new ClipboardItem({"text/plain":n});await navigator.clipboard.write([t]),console.log("Text copied using Clipboard API");return}catch{console.warn("Clipboard API failed, falling back to execCommand")}return new Promise((n,t)=>{const i=document.createElement("textarea");i.style.position="fixed",i.style.opacity="0",i.inputMode="none",o?i.value=e:i.innerText=e,document.body.appendChild(i),i.select();try{document.execCommand("copy")?(console.log("Text copied using execCommand"),n()):t(new Error("execCommand failed"))}catch(r){t(r)}finally{i.remove()}})},b=(e,o)=>{l(window.URL.createObjectURL(e),o)},l=(e,o)=>{const n=document.createElement("a");n.href=e,n.download=o,n.click()},f=e=>{const n=e.getBoundingClientRect().top;return window.innerHeight-n>n?"bottom":"top"},C=()=>{document.activeElement.blur()};exports.activeElementBlur=C;exports.addClass=d;exports.copyToClipboard=u;exports.downloadBlob=b;exports.downloadUrl=l;exports.getVisiblePosition=f;exports.hasClass=c;exports.insertIFrame=s;exports.insertScriptContent=m;exports.insertScriptSrc=p;exports.removeClass=a; |
+19
-19
@@ -10,20 +10,20 @@ function d(e, o) { | ||
| } | ||
| function s(e, o, t) { | ||
| function s(e, o, n) { | ||
| if (document.getElementById(e) === null) { | ||
| const n = document.createElement("iframe"); | ||
| n.id = e, n.src = o, n.scrolling = "no", n.frameborder = "0", n.width = 0, n.height = 0, n.onload = () => { | ||
| t && t(n); | ||
| }, document.body.appendChild(n); | ||
| const t = document.createElement("iframe"); | ||
| t.id = e, t.src = o, t.scrolling = "no", t.frameborder = "0", t.width = 0, t.height = 0, t.onload = () => { | ||
| n && n(t); | ||
| }, document.body.appendChild(t); | ||
| } | ||
| } | ||
| function m(e, o) { | ||
| function m(e, o, n) { | ||
| if (document.getElementById(e) === null) { | ||
| const t = document.createElement("script"); | ||
| t.id = e, t.append(o), document.head.appendChild(t); | ||
| t.id = e, n && (t.type = n), t.append(o), document.head.appendChild(t); | ||
| } | ||
| } | ||
| function p(e, o, t) { | ||
| function p(e, o, n) { | ||
| if (document.getElementById(e) === null) { | ||
| const n = document.createElement("script"); | ||
| n.id = e, n.src = o, t && (n.onload = t), document.head.appendChild(n); | ||
| const t = document.createElement("script"); | ||
| t.id = e, t.src = o, n && (t.onload = n), document.head.appendChild(t); | ||
| } | ||
@@ -35,4 +35,4 @@ return !1; | ||
| try { | ||
| const t = new Blob([e], { type: "text/plain" }), n = new ClipboardItem({ "text/plain": t }); | ||
| await navigator.clipboard.write([n]), console.log("Text copied using Clipboard API"); | ||
| const n = new Blob([e], { type: "text/plain" }), t = new ClipboardItem({ "text/plain": n }); | ||
| await navigator.clipboard.write([t]), console.log("Text copied using Clipboard API"); | ||
| return; | ||
@@ -42,9 +42,9 @@ } catch { | ||
| } | ||
| return new Promise((t, n) => { | ||
| return new Promise((n, t) => { | ||
| const i = document.createElement("textarea"); | ||
| i.style.position = "fixed", i.style.opacity = "0", i.inputMode = "none", o ? i.value = e : i.innerText = e, document.body.appendChild(i), i.select(); | ||
| try { | ||
| document.execCommand("copy") ? (console.log("Text copied using execCommand"), t()) : n(new Error("execCommand failed")); | ||
| document.execCommand("copy") ? (console.log("Text copied using execCommand"), n()) : t(new Error("execCommand failed")); | ||
| } catch (c) { | ||
| n(c); | ||
| t(c); | ||
| } finally { | ||
@@ -57,7 +57,7 @@ i.remove(); | ||
| }, l = (e, o) => { | ||
| const t = document.createElement("a"); | ||
| t.href = e, t.download = o, t.click(); | ||
| const n = document.createElement("a"); | ||
| n.href = e, n.download = o, n.click(); | ||
| }, b = (e) => { | ||
| const t = e.getBoundingClientRect().top; | ||
| return window.innerHeight - t > t ? "bottom" : "top"; | ||
| const n = e.getBoundingClientRect().top; | ||
| return window.innerHeight - n > n ? "bottom" : "top"; | ||
| }, w = () => { | ||
@@ -64,0 +64,0 @@ document.activeElement.blur(); |
+1
-1
| { | ||
| "name": "@acrool/js-utils", | ||
| "version": "3.2.25", | ||
| "version": "3.2.26-alpha.0", | ||
| "description": "Common javascript utils methods for project development", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
106318
0.07%2332
0.04%14
7.69%