@ibiz-template-plugin/ibiz-file-previewer 0.0.15 → 0.0.16

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.
package/dist/index.es.js CHANGED
@@ -1189,6 +1189,39 @@ const throttle = (func, wait) => {
1189
1189
  }
1190
1190
  };
1191
1191
  };
1192
+ const fallbackCopyTextToClipboard = (text) => {
1193
+ const textArea = document.createElement("textarea");
1194
+ textArea.value = text;
1195
+ textArea.style.position = "fixed";
1196
+ textArea.style.left = "-999999px";
1197
+ textArea.style.top = "-999999px";
1198
+ document.body.appendChild(textArea);
1199
+ textArea.focus();
1200
+ textArea.select();
1201
+ try {
1202
+ const successful = document.execCommand("copy");
1203
+ document.body.removeChild(textArea);
1204
+ if (successful) {
1205
+ return true;
1206
+ }
1207
+ return false;
1208
+ } catch (err) {
1209
+ document.body.removeChild(textArea);
1210
+ return false;
1211
+ }
1212
+ };
1213
+ const copyTextToClipboard = async (text) => {
1214
+ if (navigator.clipboard && window.isSecureContext) {
1215
+ try {
1216
+ await navigator.clipboard.writeText(text);
1217
+ return true;
1218
+ } catch (err) {
1219
+ return fallbackCopyTextToClipboard(text);
1220
+ }
1221
+ } else {
1222
+ return fallbackCopyTextToClipboard(text);
1223
+ }
1224
+ };
1192
1225
  var f = 0;
1193
1226
  function u(e2, t2, n2, o2, i2, u2) {
1194
1227
  t2 || (t2 = {});
@@ -20315,7 +20348,7 @@ class FilePreviewShellController {
20315
20348
  */
20316
20349
  async copyTextContent(_event) {
20317
20350
  if (!this.options.getContent) return;
20318
- await navigator.clipboard.writeText("");
20351
+ await copyTextToClipboard("");
20319
20352
  const { fileId, fileType, fileCat, fileContent } = this.state.value;
20320
20353
  let content = fileContent;
20321
20354
  if (content === "") {
@@ -20326,7 +20359,7 @@ class FilePreviewShellController {
20326
20359
  );
20327
20360
  }
20328
20361
  if (content) {
20329
- await navigator.clipboard.writeText(content);
20362
+ await copyTextToClipboard(content);
20330
20363
  }
20331
20364
  if (this.options.actionSuccessCallBack) {
20332
20365
  await this.options.actionSuccessCallBack(ActionType.COPYTEXTCONTENT);