a2bei4-utils 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -459,7 +459,37 @@ const fullscreenHelper = {
459
459
  document.removeEventListener("msfullscreenchange", handler);
460
460
  };
461
461
  }
462
- };
462
+ };
463
+
464
+ /**
465
+ * 复制文本到剪贴板
466
+ * @param {String} text
467
+ * @returns {Promise<void>}
468
+ */
469
+ async function copyTextToClipboard(text) {
470
+ if (window.navigator.clipboard) {
471
+ await window.navigator.clipboard.writeText(text);
472
+ return;
473
+ }
474
+
475
+ return new Promise((resolve, reject) => {
476
+ const ta = document.createElement("textarea");
477
+ ta.value = text;
478
+ ta.style.position = "fixed"; // 防止滚动
479
+ ta.style.opacity = "0";
480
+ document.body.appendChild(ta);
481
+ ta.focus();
482
+ ta.select();
483
+
484
+ try {
485
+ document.execCommand("copy") ? resolve() : reject(new Error("execCommand failed"));
486
+ } catch (err) {
487
+ reject(err);
488
+ } finally {
489
+ document.body.removeChild(ta);
490
+ }
491
+ });
492
+ }
463
493
 
464
494
  //#region 数据类型判断
465
495
 
@@ -2469,5 +2499,5 @@ class WebSocketManager {
2469
2499
  }
2470
2500
  }
2471
2501
 
2472
- export { AudioStreamResampler, IntervalTimer, MyEvent, MyEvent_CrossPagePlugin, MyId, WebSocketManager, assignExisting, debounce, deepCloneByJSON, downloadByBlob, downloadByData, downloadByUrl, downloadExcel, downloadJSON, extractFullyCheckedKeys, fetchOrDownloadByUrl, findObjAttrValueById, findTreeNodeById, findTreeNodePath, flatCompleteTree2NestedTree, formatTimeForLocale, fullscreenHelper, getAllSearchParams, getDataType, getFunctionArgNames, getGUID, getSearchParam, getTimePeriodName, getViewportSize, handleDbMenuItems, isBlob, isDate, isFunction, isNonEmptyString, isPlainObject, isPromise, millisecond2Duration, millisecond2DurationMaxDay, millisecond2DurationMaxHour, moveItem, nestedTree2IdMap, pcmToWavBlob, randomDateInRange, randomEnLetter, randomHan, randomHanOrEn, randomIntInRange, readBlobAsText, second2Duration, second2DurationMaxDay, second2DurationMaxHour, shuffle, throttle, toDate };
2502
+ export { AudioStreamResampler, IntervalTimer, MyEvent, MyEvent_CrossPagePlugin, MyId, WebSocketManager, assignExisting, copyTextToClipboard, debounce, deepCloneByJSON, downloadByBlob, downloadByData, downloadByUrl, downloadExcel, downloadJSON, extractFullyCheckedKeys, fetchOrDownloadByUrl, findObjAttrValueById, findTreeNodeById, findTreeNodePath, flatCompleteTree2NestedTree, formatTimeForLocale, fullscreenHelper, getAllSearchParams, getDataType, getFunctionArgNames, getGUID, getSearchParam, getTimePeriodName, getViewportSize, handleDbMenuItems, isBlob, isDate, isFunction, isNonEmptyString, isPlainObject, isPromise, millisecond2Duration, millisecond2DurationMaxDay, millisecond2DurationMaxHour, moveItem, nestedTree2IdMap, pcmToWavBlob, randomDateInRange, randomEnLetter, randomHan, randomHanOrEn, randomIntInRange, readBlobAsText, second2Duration, second2DurationMaxDay, second2DurationMaxHour, shuffle, throttle, toDate };
2473
2503
  //# sourceMappingURL=a2bei4.utils.esm.js.map