@files-preview-app/preview-file 1.3.5 → 1.3.6

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.cjs CHANGED
@@ -610,6 +610,7 @@ var ICON_COPY = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" str
610
610
  var ICON_FAST_FORWARD = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 19 22 12 13 5 13 19"></polygon><polygon points="2 19 11 12 2 5 2 19"></polygon></svg>`;
611
611
  var ICON_REWIND = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 19 2 12 11 5 11 19"></polygon><polygon points="22 19 13 12 22 5 22 19"></polygon></svg>`;
612
612
  var ICON_EXTERNAL_WINDOW = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"></rect><line x1="3" y1="8" x2="21" y2="8"></line><circle cx="6" cy="5.5" r="0.75" fill="currentColor"></circle><circle cx="8.5" cy="5.5" r="0.75" fill="currentColor"></circle><polyline points="14 13 18 13 18 17"></polyline><line x1="11" y1="20" x2="18" y2="13"></line></svg>`;
613
+ var ICON_RESET_ZOOM = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><path d="M13 11a3 3 0 1 0-3 3"></path><path d="M10 11v3h3"></path></svg>`;
613
614
  var ICON_MAP = {
614
615
  "zoom-in": ICON_ZOOM_IN,
615
616
  "zoom-out": ICON_ZOOM_OUT,
@@ -639,7 +640,10 @@ var ICON_MAP = {
639
640
  "open-window": ICON_EXTERNAL_WINDOW,
640
641
  "external-window": ICON_EXTERNAL_WINDOW,
641
642
  "openWindow": ICON_EXTERNAL_WINDOW,
642
- "openSeparateWindow": ICON_EXTERNAL_WINDOW
643
+ "openSeparateWindow": ICON_EXTERNAL_WINDOW,
644
+ "reset-zoom": ICON_RESET_ZOOM,
645
+ "zoom-reset": ICON_RESET_ZOOM,
646
+ "resetZoom": ICON_RESET_ZOOM
643
647
  };
644
648
  var ToolbarController = class {
645
649
  el;
@@ -672,6 +676,10 @@ var ToolbarController = class {
672
676
  this.config.fitToPage = false;
673
677
  this.config.fitWidth = false;
674
678
  }
679
+ if (actionId === "reset-zoom" || actionId === "zoom-reset" || actionId === "resetZoom") {
680
+ this.config.resetZoom = false;
681
+ this.config.zoomReset = false;
682
+ }
675
683
  if (actionId === "rotate-cw" || actionId === "rotate" || actionId === "rotateCW") this.config.rotate = false;
676
684
  if (actionId === "fullscreen") this.config.fullscreen = false;
677
685
  if (actionId === "download") this.config.download = false;
@@ -696,6 +704,10 @@ var ToolbarController = class {
696
704
  this.config.fitToPage = true;
697
705
  this.config.fitWidth = true;
698
706
  }
707
+ if (actionId === "reset-zoom" || actionId === "zoom-reset" || actionId === "resetZoom") {
708
+ this.config.resetZoom = true;
709
+ this.config.zoomReset = true;
710
+ }
699
711
  if (actionId === "rotate-cw" || actionId === "rotate" || actionId === "rotateCW") this.config.rotate = true;
700
712
  if (actionId === "fullscreen") this.config.fullscreen = true;
701
713
  if (actionId === "download") this.config.download = true;
@@ -715,6 +727,7 @@ var ToolbarController = class {
715
727
  if (actionId === "zoomIn") return "zoom-in";
716
728
  if (actionId === "zoomOut") return "zoom-out";
717
729
  if (actionId === "fitPage" || actionId === "fitToPage" || actionId === "fitWidth") return "fit-page";
730
+ if (actionId === "resetZoom" || actionId === "zoomReset") return "reset-zoom";
718
731
  if (actionId === "rotateCW") return "rotate-cw";
719
732
  if (actionId === "rotateCCW") return "rotate-ccw";
720
733
  if (actionId === "openWindow" || actionId === "openSeparateWindow") return "open-window";
@@ -757,6 +770,9 @@ var ToolbarController = class {
757
770
  if ((id === "fit-page" || id === "fit-width" || id === "fit-slide") && (c.fitPage === false || c.fitToPage === false || c.fitWidth === false || c["fit-page"] === false || c["fit-width"] === false)) {
758
771
  return false;
759
772
  }
773
+ if ((id === "reset-zoom" || id === "zoom-reset") && (c.resetZoom === false || c.zoomReset === false || c["reset-zoom"] === false || c["zoom-reset"] === false)) {
774
+ return false;
775
+ }
760
776
  if ((id === "rotate-cw" || id === "rotate-ccw" || id === "rotate") && (c.rotate === false || c.rotateCW === false || c.rotateCCW === false || c["rotate-cw"] === false)) {
761
777
  return false;
762
778
  }
@@ -1203,6 +1219,9 @@ var FilePreviewViewer = class _FilePreviewViewer {
1203
1219
  this.activeInstance = instance;
1204
1220
  instance.openInSeparateWindow = () => this.openInSeparateWindow();
1205
1221
  instance.toggleThumbnails = () => this.toggleThumbnails();
1222
+ if (!instance.resetZoom && instance.fitToPage) {
1223
+ instance.resetZoom = () => instance.fitToPage?.();
1224
+ }
1206
1225
  this.hideLoading();
1207
1226
  this.eventEmitter.emit("loaded", { metadata, plugin: matchedPlugin.id });
1208
1227
  const isToolbarVisible = options.showToolbar !== false && options.toolbar !== false;
@@ -1486,6 +1505,16 @@ var FilePreviewViewer = class _FilePreviewViewer {
1486
1505
  fitToPage() {
1487
1506
  this.activeInstance?.fitToPage?.();
1488
1507
  }
1508
+ /**
1509
+ * Reset zoom level to initial/default fit state.
1510
+ */
1511
+ resetZoom() {
1512
+ if (this.activeInstance?.resetZoom) {
1513
+ this.activeInstance.resetZoom();
1514
+ } else if (this.activeInstance?.fitToPage) {
1515
+ this.activeInstance.fitToPage();
1516
+ }
1517
+ }
1489
1518
  /**
1490
1519
  * Zoom in.
1491
1520
  */
@@ -2107,6 +2136,14 @@ var PdfPlugin = class {
2107
2136
  group: "zoom",
2108
2137
  execute: () => instance.fitToPage?.()
2109
2138
  },
2139
+ {
2140
+ id: "reset-zoom",
2141
+ icon: "reset-zoom",
2142
+ label: "Reset Zoom",
2143
+ type: "button",
2144
+ group: "zoom",
2145
+ execute: () => instance.resetZoom?.()
2146
+ },
2110
2147
  {
2111
2148
  id: "fit-width",
2112
2149
  icon: "fit-width",
@@ -2369,6 +2406,14 @@ var PdfPlugin = class {
2369
2406
  zoomScale = 1;
2370
2407
  renderPage(currentPage);
2371
2408
  },
2409
+ resetZoom: () => {
2410
+ fitMode = "page";
2411
+ zoomScale = 1;
2412
+ rotation = 0;
2413
+ container.scrollTop = 0;
2414
+ container.scrollLeft = 0;
2415
+ renderPage(currentPage);
2416
+ },
2372
2417
  fitToWidth: () => {
2373
2418
  fitMode = "width";
2374
2419
  zoomScale = 1;
@@ -2536,6 +2581,16 @@ var MediaPlugin = class {
2536
2581
  instance.fitToPage?.();
2537
2582
  }
2538
2583
  },
2584
+ {
2585
+ id: "reset-zoom",
2586
+ icon: "reset-zoom",
2587
+ label: "Reset Zoom",
2588
+ type: "button",
2589
+ group: "zoom",
2590
+ execute: () => {
2591
+ instance.resetZoom?.();
2592
+ }
2593
+ },
2539
2594
  {
2540
2595
  id: "rotate-cw",
2541
2596
  icon: "rotate-cw",
@@ -2709,6 +2764,13 @@ var MediaPlugin = class {
2709
2764
  rotation = 0;
2710
2765
  applyTransform();
2711
2766
  } : void 0,
2767
+ resetZoom: isImage ? () => {
2768
+ currentZoom = 1;
2769
+ rotation = 0;
2770
+ ctx.container.scrollTop = 0;
2771
+ ctx.container.scrollLeft = 0;
2772
+ applyTransform();
2773
+ } : void 0,
2712
2774
  rotateCW: isImage || isVideo ? () => {
2713
2775
  rotation = (rotation + 90) % 360;
2714
2776
  applyTransform();
@@ -2825,6 +2887,14 @@ var DocxPlugin = class {
2825
2887
  group: "zoom",
2826
2888
  execute: () => instance.fitToPage?.()
2827
2889
  },
2890
+ {
2891
+ id: "reset-zoom",
2892
+ icon: "reset-zoom",
2893
+ label: "Reset Zoom",
2894
+ type: "button",
2895
+ group: "zoom",
2896
+ execute: () => instance.resetZoom?.()
2897
+ },
2828
2898
  {
2829
2899
  id: "rotate-cw",
2830
2900
  icon: "rotate-cw",
@@ -3141,6 +3211,14 @@ var DocxPlugin = class {
3141
3211
  rotation = 0;
3142
3212
  applyTransform();
3143
3213
  },
3214
+ resetZoom: () => {
3215
+ isUserZoomed = false;
3216
+ scale = calculateFitScale("page");
3217
+ rotation = 0;
3218
+ ctx.container.scrollTop = 0;
3219
+ ctx.container.scrollLeft = 0;
3220
+ applyTransform();
3221
+ },
3144
3222
  rotateCW: () => {
3145
3223
  rotation = (rotation + 90) % 360;
3146
3224
  applyTransform();
@@ -3590,6 +3668,16 @@ var ExcelPlugin = class {
3590
3668
  instance.zoomIn?.();
3591
3669
  }
3592
3670
  },
3671
+ {
3672
+ id: "reset-zoom",
3673
+ icon: "reset-zoom",
3674
+ label: "Reset Zoom",
3675
+ type: "button",
3676
+ group: "zoom",
3677
+ execute: () => {
3678
+ instance.resetZoom?.();
3679
+ }
3680
+ },
3593
3681
  {
3594
3682
  id: "download",
3595
3683
  icon: "download",
@@ -3777,6 +3865,12 @@ var ExcelPlugin = class {
3777
3865
  scale = calculateFitScale();
3778
3866
  applyTransform();
3779
3867
  },
3868
+ resetZoom: () => {
3869
+ scale = calculateFitScale();
3870
+ contentArea.scrollTop = 0;
3871
+ contentArea.scrollLeft = 0;
3872
+ applyTransform();
3873
+ },
3780
3874
  rotateCW: () => {
3781
3875
  },
3782
3876
  rotateCCW: () => {
@@ -3907,6 +4001,16 @@ var CsvPlugin = class {
3907
4001
  instance.zoomIn?.();
3908
4002
  }
3909
4003
  },
4004
+ {
4005
+ id: "reset-zoom",
4006
+ icon: "reset-zoom",
4007
+ label: "Reset Zoom",
4008
+ type: "button",
4009
+ group: "zoom",
4010
+ execute: () => {
4011
+ instance.resetZoom?.();
4012
+ }
4013
+ },
3910
4014
  {
3911
4015
  id: "download",
3912
4016
  icon: "download",
@@ -4096,6 +4200,12 @@ var CsvPlugin = class {
4096
4200
  scale = calculateFitScale();
4097
4201
  applyScale();
4098
4202
  },
4203
+ resetZoom: () => {
4204
+ scale = calculateFitScale();
4205
+ container.scrollTop = 0;
4206
+ container.scrollLeft = 0;
4207
+ applyScale();
4208
+ },
4099
4209
  rotateCW: () => {
4100
4210
  },
4101
4211
  rotateCCW: () => {
@@ -4211,6 +4321,16 @@ var CodePlugin = class {
4211
4321
  instance.zoomIn?.();
4212
4322
  }
4213
4323
  },
4324
+ {
4325
+ id: "reset-zoom",
4326
+ icon: "reset-zoom",
4327
+ label: "Reset Zoom",
4328
+ type: "button",
4329
+ group: "zoom",
4330
+ execute: () => {
4331
+ instance.resetZoom?.();
4332
+ }
4333
+ },
4214
4334
  {
4215
4335
  id: "copy",
4216
4336
  icon: "copy",
@@ -4490,6 +4610,15 @@ var CodePlugin = class {
4490
4610
  zoomLevel = isTxt ? calculateTxtFit() : 1;
4491
4611
  updateTransform();
4492
4612
  },
4613
+ resetZoom: () => {
4614
+ isUserZoomed = false;
4615
+ fontSize = 13;
4616
+ rotation = 0;
4617
+ zoomLevel = isTxt ? calculateTxtFit() : 1;
4618
+ container.scrollTop = 0;
4619
+ container.scrollLeft = 0;
4620
+ updateTransform();
4621
+ },
4493
4622
  rotateCW: () => {
4494
4623
  rotation = (rotation + 90) % 360;
4495
4624
  updateTransform();
@@ -4552,11 +4681,19 @@ var ArchivePlugin = class {
4552
4681
  {
4553
4682
  id: "fit-page",
4554
4683
  icon: "fit-page",
4555
- label: "Reset Zoom",
4684
+ label: "Fit to Page",
4556
4685
  type: "button",
4557
4686
  group: "zoom",
4558
4687
  execute: () => instance.fitToPage?.()
4559
4688
  },
4689
+ {
4690
+ id: "reset-zoom",
4691
+ icon: "reset-zoom",
4692
+ label: "Reset Zoom",
4693
+ type: "button",
4694
+ group: "zoom",
4695
+ execute: () => instance.resetZoom?.()
4696
+ },
4560
4697
  {
4561
4698
  id: "download",
4562
4699
  icon: "download",
@@ -4711,7 +4848,13 @@ var ArchivePlugin = class {
4711
4848
  },
4712
4849
  fitToPage: () => {
4713
4850
  scale = 1;
4714
- wrapper.style.transform = `scale(1)`;
4851
+ wrapper.style.transform = "scale(1)";
4852
+ },
4853
+ resetZoom: () => {
4854
+ scale = 1;
4855
+ wrapper.style.transform = "scale(1)";
4856
+ ctx.container.scrollTop = 0;
4857
+ ctx.container.scrollLeft = 0;
4715
4858
  },
4716
4859
  download: () => {
4717
4860
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -4763,6 +4906,14 @@ var MarkdownPlugin = class {
4763
4906
  group: "zoom",
4764
4907
  execute: () => instance.fitToPage?.()
4765
4908
  },
4909
+ {
4910
+ id: "reset-zoom",
4911
+ icon: "reset-zoom",
4912
+ label: "Reset Zoom",
4913
+ type: "button",
4914
+ group: "zoom",
4915
+ execute: () => instance.resetZoom?.()
4916
+ },
4766
4917
  {
4767
4918
  id: "copy",
4768
4919
  icon: "copy",
@@ -4916,6 +5067,12 @@ var MarkdownPlugin = class {
4916
5067
  fontSize = 15;
4917
5068
  wrapper.style.fontSize = "15px";
4918
5069
  },
5070
+ resetZoom: () => {
5071
+ fontSize = 15;
5072
+ wrapper.style.fontSize = "15px";
5073
+ ctx.container.scrollTop = 0;
5074
+ ctx.container.scrollLeft = 0;
5075
+ },
4919
5076
  download: () => {
4920
5077
  downloadFile(ctx.buffer, ctx.metadata.name || "document.md", "text/markdown");
4921
5078
  },
@@ -5009,6 +5166,14 @@ var PptxPlugin = class {
5009
5166
  group: "zoom",
5010
5167
  execute: () => instance.fitToPage?.()
5011
5168
  },
5169
+ {
5170
+ id: "reset-zoom",
5171
+ icon: "reset-zoom",
5172
+ label: "Reset Zoom",
5173
+ type: "button",
5174
+ group: "zoom",
5175
+ execute: () => instance.resetZoom?.()
5176
+ },
5012
5177
  {
5013
5178
  id: "rotate-cw",
5014
5179
  icon: "rotate-cw",
@@ -5128,6 +5293,13 @@ var PptxPlugin = class {
5128
5293
  rotation = 0;
5129
5294
  applyTransform();
5130
5295
  },
5296
+ resetZoom: () => {
5297
+ scale = calculateFitScale();
5298
+ rotation = 0;
5299
+ wrapper.scrollTop = 0;
5300
+ wrapper.scrollLeft = 0;
5301
+ applyTransform();
5302
+ },
5131
5303
  rotateCW: () => {
5132
5304
  rotation = (rotation + 90) % 360;
5133
5305
  applyTransform();
@@ -5203,6 +5375,14 @@ var ThreeDPlugin = class {
5203
5375
  group: "zoom",
5204
5376
  execute: () => instance.fitToPage?.()
5205
5377
  },
5378
+ {
5379
+ id: "reset-zoom",
5380
+ icon: "reset-zoom",
5381
+ label: "Reset Zoom",
5382
+ type: "button",
5383
+ group: "zoom",
5384
+ execute: () => instance.resetZoom?.()
5385
+ },
5206
5386
  {
5207
5387
  id: "rotate-cw",
5208
5388
  icon: "rotate-cw",
@@ -5339,6 +5519,7 @@ var ThreeDPlugin = class {
5339
5519
  controls.update();
5340
5520
  },
5341
5521
  fitToPage: fitCamera,
5522
+ resetZoom: fitCamera,
5342
5523
  rotateCW: () => {
5343
5524
  isWireframe = !isWireframe;
5344
5525
  materials.forEach((m) => {
@@ -5553,6 +5734,14 @@ var RtfPlugin = class {
5553
5734
  group: "zoom",
5554
5735
  execute: () => instance.fitToPage?.()
5555
5736
  },
5737
+ {
5738
+ id: "reset-zoom",
5739
+ icon: "reset-zoom",
5740
+ label: "Reset Zoom",
5741
+ type: "button",
5742
+ group: "zoom",
5743
+ execute: () => instance.resetZoom?.()
5744
+ },
5556
5745
  {
5557
5746
  id: "rotate-cw",
5558
5747
  icon: "rotate-cw",
@@ -6022,6 +6211,15 @@ var RtfPlugin = class {
6022
6211
  rotation = 0;
6023
6212
  applyTransform();
6024
6213
  },
6214
+ resetZoom: () => {
6215
+ isUserZoomed = false;
6216
+ fitMode = "width";
6217
+ scale = calculateFitScale("width");
6218
+ rotation = 0;
6219
+ ctx.container.scrollTop = 0;
6220
+ ctx.container.scrollLeft = 0;
6221
+ applyTransform();
6222
+ },
6025
6223
  rotateCW: () => {
6026
6224
  rotation = (rotation + 90) % 360;
6027
6225
  applyTransform();
@@ -6089,6 +6287,14 @@ var HtmlPreviewPlugin = class {
6089
6287
  group: "zoom",
6090
6288
  execute: () => instance.fitToPage?.()
6091
6289
  },
6290
+ {
6291
+ id: "reset-zoom",
6292
+ icon: "reset-zoom",
6293
+ label: "Reset Zoom",
6294
+ type: "button",
6295
+ group: "zoom",
6296
+ execute: () => instance.resetZoom?.()
6297
+ },
6092
6298
  {
6093
6299
  id: "copy",
6094
6300
  icon: "copy",
@@ -6161,6 +6367,12 @@ var HtmlPreviewPlugin = class {
6161
6367
  scale = 1;
6162
6368
  iframe.style.transform = "scale(1)";
6163
6369
  },
6370
+ resetZoom: () => {
6371
+ scale = 1;
6372
+ iframe.style.transform = "scale(1)";
6373
+ ctx.container.scrollTop = 0;
6374
+ ctx.container.scrollLeft = 0;
6375
+ },
6164
6376
  copy: () => {
6165
6377
  navigator.clipboard.writeText(rawHtml);
6166
6378
  },
@@ -6261,6 +6473,14 @@ var OpenDocumentPlugin = class {
6261
6473
  group: "zoom",
6262
6474
  execute: () => instance.fitToPage?.()
6263
6475
  },
6476
+ {
6477
+ id: "reset-zoom",
6478
+ icon: "reset-zoom",
6479
+ label: "Reset Zoom",
6480
+ type: "button",
6481
+ group: "zoom",
6482
+ execute: () => instance.resetZoom?.()
6483
+ },
6264
6484
  {
6265
6485
  id: "rotate-cw",
6266
6486
  icon: "rotate-cw",
@@ -6528,6 +6748,15 @@ var OpenDocumentPlugin = class {
6528
6748
  rotation = 0;
6529
6749
  applyTransform();
6530
6750
  },
6751
+ resetZoom: () => {
6752
+ isUserZoomed = false;
6753
+ fitMode = "width";
6754
+ scale = calculateFitScale("width");
6755
+ rotation = 0;
6756
+ container.scrollTop = 0;
6757
+ container.scrollLeft = 0;
6758
+ applyTransform();
6759
+ },
6531
6760
  rotateCW: () => {
6532
6761
  rotation = (rotation + 90) % 360;
6533
6762
  applyTransform();
@@ -6871,6 +7100,14 @@ var DocPlugin = class {
6871
7100
  group: "zoom",
6872
7101
  execute: () => instance.fitToPage?.()
6873
7102
  },
7103
+ {
7104
+ id: "reset-zoom",
7105
+ icon: "reset-zoom",
7106
+ label: "Reset Zoom",
7107
+ type: "button",
7108
+ group: "zoom",
7109
+ execute: () => instance.resetZoom?.()
7110
+ },
6874
7111
  {
6875
7112
  id: "rotate-cw",
6876
7113
  icon: "rotate-cw",
@@ -7077,6 +7314,15 @@ var DocPlugin = class {
7077
7314
  rotation = 0;
7078
7315
  applyTransform();
7079
7316
  },
7317
+ resetZoom: () => {
7318
+ isUserZoomed = false;
7319
+ fitMode = "width";
7320
+ scale = calculateFitScale("width");
7321
+ rotation = 0;
7322
+ ctx.container.scrollTop = 0;
7323
+ ctx.container.scrollLeft = 0;
7324
+ applyTransform();
7325
+ },
7080
7326
  rotateCW: () => {
7081
7327
  rotation = (rotation + 90) % 360;
7082
7328
  applyTransform();
@@ -7557,6 +7803,14 @@ var PptPlugin = class {
7557
7803
  group: "zoom",
7558
7804
  execute: () => instance.fitToPage?.()
7559
7805
  },
7806
+ {
7807
+ id: "reset-zoom",
7808
+ icon: "reset-zoom",
7809
+ label: "Reset Zoom",
7810
+ type: "button",
7811
+ group: "zoom",
7812
+ execute: () => instance.resetZoom?.()
7813
+ },
7560
7814
  {
7561
7815
  id: "rotate-cw",
7562
7816
  icon: "rotate-cw",
@@ -7745,6 +7999,13 @@ var PptPlugin = class {
7745
7999
  rotation = 0;
7746
8000
  applyTransform();
7747
8001
  },
8002
+ resetZoom: () => {
8003
+ scale = calculateFitScale();
8004
+ rotation = 0;
8005
+ container.scrollTop = 0;
8006
+ container.scrollLeft = 0;
8007
+ applyTransform();
8008
+ },
7748
8009
  rotateCW: () => {
7749
8010
  rotation = (rotation + 90) % 360;
7750
8011
  applyTransform();