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

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 = {});
@@ -16437,7 +16470,9 @@ const FilePreviewMD = (props) => {
16437
16470
  };
16438
16471
  y$1(() => {
16439
16472
  vditorEditor.current = new Vditor(previewRef.current, {
16440
- theme: c2.state.value.theme === "light" ? "classic" : c2.state.value.theme,
16473
+ // 预览内容白色背景,与word、pdf对齐
16474
+ // theme: c.state.value.theme === 'light' ? 'classic' : c.state.value.theme,
16475
+ theme: "classic",
16441
16476
  width: "100%",
16442
16477
  height: "100%",
16443
16478
  cache: {
@@ -20315,7 +20350,7 @@ class FilePreviewShellController {
20315
20350
  */
20316
20351
  async copyTextContent(_event) {
20317
20352
  if (!this.options.getContent) return;
20318
- await navigator.clipboard.writeText("");
20353
+ await copyTextToClipboard("");
20319
20354
  const { fileId, fileType, fileCat, fileContent } = this.state.value;
20320
20355
  let content = fileContent;
20321
20356
  if (content === "") {
@@ -20326,7 +20361,7 @@ class FilePreviewShellController {
20326
20361
  );
20327
20362
  }
20328
20363
  if (content) {
20329
- await navigator.clipboard.writeText(content);
20364
+ await copyTextToClipboard(content);
20330
20365
  }
20331
20366
  if (this.options.actionSuccessCallBack) {
20332
20367
  await this.options.actionSuccessCallBack(ActionType.COPYTEXTCONTENT);