@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/react.cjs CHANGED
@@ -529,6 +529,7 @@ var ICON_COPY = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" str
529
529
  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>`;
530
530
  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>`;
531
531
  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>`;
532
+ 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>`;
532
533
  var ICON_MAP = {
533
534
  "zoom-in": ICON_ZOOM_IN,
534
535
  "zoom-out": ICON_ZOOM_OUT,
@@ -558,7 +559,10 @@ var ICON_MAP = {
558
559
  "open-window": ICON_EXTERNAL_WINDOW,
559
560
  "external-window": ICON_EXTERNAL_WINDOW,
560
561
  "openWindow": ICON_EXTERNAL_WINDOW,
561
- "openSeparateWindow": ICON_EXTERNAL_WINDOW
562
+ "openSeparateWindow": ICON_EXTERNAL_WINDOW,
563
+ "reset-zoom": ICON_RESET_ZOOM,
564
+ "zoom-reset": ICON_RESET_ZOOM,
565
+ "resetZoom": ICON_RESET_ZOOM
562
566
  };
563
567
  var ToolbarController = class {
564
568
  el;
@@ -591,6 +595,10 @@ var ToolbarController = class {
591
595
  this.config.fitToPage = false;
592
596
  this.config.fitWidth = false;
593
597
  }
598
+ if (actionId === "reset-zoom" || actionId === "zoom-reset" || actionId === "resetZoom") {
599
+ this.config.resetZoom = false;
600
+ this.config.zoomReset = false;
601
+ }
594
602
  if (actionId === "rotate-cw" || actionId === "rotate" || actionId === "rotateCW") this.config.rotate = false;
595
603
  if (actionId === "fullscreen") this.config.fullscreen = false;
596
604
  if (actionId === "download") this.config.download = false;
@@ -615,6 +623,10 @@ var ToolbarController = class {
615
623
  this.config.fitToPage = true;
616
624
  this.config.fitWidth = true;
617
625
  }
626
+ if (actionId === "reset-zoom" || actionId === "zoom-reset" || actionId === "resetZoom") {
627
+ this.config.resetZoom = true;
628
+ this.config.zoomReset = true;
629
+ }
618
630
  if (actionId === "rotate-cw" || actionId === "rotate" || actionId === "rotateCW") this.config.rotate = true;
619
631
  if (actionId === "fullscreen") this.config.fullscreen = true;
620
632
  if (actionId === "download") this.config.download = true;
@@ -634,6 +646,7 @@ var ToolbarController = class {
634
646
  if (actionId === "zoomIn") return "zoom-in";
635
647
  if (actionId === "zoomOut") return "zoom-out";
636
648
  if (actionId === "fitPage" || actionId === "fitToPage" || actionId === "fitWidth") return "fit-page";
649
+ if (actionId === "resetZoom" || actionId === "zoomReset") return "reset-zoom";
637
650
  if (actionId === "rotateCW") return "rotate-cw";
638
651
  if (actionId === "rotateCCW") return "rotate-ccw";
639
652
  if (actionId === "openWindow" || actionId === "openSeparateWindow") return "open-window";
@@ -676,6 +689,9 @@ var ToolbarController = class {
676
689
  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)) {
677
690
  return false;
678
691
  }
692
+ if ((id === "reset-zoom" || id === "zoom-reset") && (c.resetZoom === false || c.zoomReset === false || c["reset-zoom"] === false || c["zoom-reset"] === false)) {
693
+ return false;
694
+ }
679
695
  if ((id === "rotate-cw" || id === "rotate-ccw" || id === "rotate") && (c.rotate === false || c.rotateCW === false || c.rotateCCW === false || c["rotate-cw"] === false)) {
680
696
  return false;
681
697
  }
@@ -1122,6 +1138,9 @@ var FilePreviewViewer = class _FilePreviewViewer {
1122
1138
  this.activeInstance = instance;
1123
1139
  instance.openInSeparateWindow = () => this.openInSeparateWindow();
1124
1140
  instance.toggleThumbnails = () => this.toggleThumbnails();
1141
+ if (!instance.resetZoom && instance.fitToPage) {
1142
+ instance.resetZoom = () => instance.fitToPage?.();
1143
+ }
1125
1144
  this.hideLoading();
1126
1145
  this.eventEmitter.emit("loaded", { metadata, plugin: matchedPlugin.id });
1127
1146
  const isToolbarVisible = options.showToolbar !== false && options.toolbar !== false;
@@ -1405,6 +1424,16 @@ var FilePreviewViewer = class _FilePreviewViewer {
1405
1424
  fitToPage() {
1406
1425
  this.activeInstance?.fitToPage?.();
1407
1426
  }
1427
+ /**
1428
+ * Reset zoom level to initial/default fit state.
1429
+ */
1430
+ resetZoom() {
1431
+ if (this.activeInstance?.resetZoom) {
1432
+ this.activeInstance.resetZoom();
1433
+ } else if (this.activeInstance?.fitToPage) {
1434
+ this.activeInstance.fitToPage();
1435
+ }
1436
+ }
1408
1437
  /**
1409
1438
  * Zoom in.
1410
1439
  */
@@ -2026,6 +2055,14 @@ var PdfPlugin = class {
2026
2055
  group: "zoom",
2027
2056
  execute: () => instance.fitToPage?.()
2028
2057
  },
2058
+ {
2059
+ id: "reset-zoom",
2060
+ icon: "reset-zoom",
2061
+ label: "Reset Zoom",
2062
+ type: "button",
2063
+ group: "zoom",
2064
+ execute: () => instance.resetZoom?.()
2065
+ },
2029
2066
  {
2030
2067
  id: "fit-width",
2031
2068
  icon: "fit-width",
@@ -2288,6 +2325,14 @@ var PdfPlugin = class {
2288
2325
  zoomScale = 1;
2289
2326
  renderPage(currentPage);
2290
2327
  },
2328
+ resetZoom: () => {
2329
+ fitMode = "page";
2330
+ zoomScale = 1;
2331
+ rotation = 0;
2332
+ container.scrollTop = 0;
2333
+ container.scrollLeft = 0;
2334
+ renderPage(currentPage);
2335
+ },
2291
2336
  fitToWidth: () => {
2292
2337
  fitMode = "width";
2293
2338
  zoomScale = 1;
@@ -2455,6 +2500,16 @@ var MediaPlugin = class {
2455
2500
  instance.fitToPage?.();
2456
2501
  }
2457
2502
  },
2503
+ {
2504
+ id: "reset-zoom",
2505
+ icon: "reset-zoom",
2506
+ label: "Reset Zoom",
2507
+ type: "button",
2508
+ group: "zoom",
2509
+ execute: () => {
2510
+ instance.resetZoom?.();
2511
+ }
2512
+ },
2458
2513
  {
2459
2514
  id: "rotate-cw",
2460
2515
  icon: "rotate-cw",
@@ -2628,6 +2683,13 @@ var MediaPlugin = class {
2628
2683
  rotation = 0;
2629
2684
  applyTransform();
2630
2685
  } : void 0,
2686
+ resetZoom: isImage ? () => {
2687
+ currentZoom = 1;
2688
+ rotation = 0;
2689
+ ctx.container.scrollTop = 0;
2690
+ ctx.container.scrollLeft = 0;
2691
+ applyTransform();
2692
+ } : void 0,
2631
2693
  rotateCW: isImage || isVideo ? () => {
2632
2694
  rotation = (rotation + 90) % 360;
2633
2695
  applyTransform();
@@ -2744,6 +2806,14 @@ var DocxPlugin = class {
2744
2806
  group: "zoom",
2745
2807
  execute: () => instance.fitToPage?.()
2746
2808
  },
2809
+ {
2810
+ id: "reset-zoom",
2811
+ icon: "reset-zoom",
2812
+ label: "Reset Zoom",
2813
+ type: "button",
2814
+ group: "zoom",
2815
+ execute: () => instance.resetZoom?.()
2816
+ },
2747
2817
  {
2748
2818
  id: "rotate-cw",
2749
2819
  icon: "rotate-cw",
@@ -3060,6 +3130,14 @@ var DocxPlugin = class {
3060
3130
  rotation = 0;
3061
3131
  applyTransform();
3062
3132
  },
3133
+ resetZoom: () => {
3134
+ isUserZoomed = false;
3135
+ scale = calculateFitScale("page");
3136
+ rotation = 0;
3137
+ ctx.container.scrollTop = 0;
3138
+ ctx.container.scrollLeft = 0;
3139
+ applyTransform();
3140
+ },
3063
3141
  rotateCW: () => {
3064
3142
  rotation = (rotation + 90) % 360;
3065
3143
  applyTransform();
@@ -3509,6 +3587,16 @@ var ExcelPlugin = class {
3509
3587
  instance.zoomIn?.();
3510
3588
  }
3511
3589
  },
3590
+ {
3591
+ id: "reset-zoom",
3592
+ icon: "reset-zoom",
3593
+ label: "Reset Zoom",
3594
+ type: "button",
3595
+ group: "zoom",
3596
+ execute: () => {
3597
+ instance.resetZoom?.();
3598
+ }
3599
+ },
3512
3600
  {
3513
3601
  id: "download",
3514
3602
  icon: "download",
@@ -3696,6 +3784,12 @@ var ExcelPlugin = class {
3696
3784
  scale = calculateFitScale();
3697
3785
  applyTransform();
3698
3786
  },
3787
+ resetZoom: () => {
3788
+ scale = calculateFitScale();
3789
+ contentArea.scrollTop = 0;
3790
+ contentArea.scrollLeft = 0;
3791
+ applyTransform();
3792
+ },
3699
3793
  rotateCW: () => {
3700
3794
  },
3701
3795
  rotateCCW: () => {
@@ -3826,6 +3920,16 @@ var CsvPlugin = class {
3826
3920
  instance.zoomIn?.();
3827
3921
  }
3828
3922
  },
3923
+ {
3924
+ id: "reset-zoom",
3925
+ icon: "reset-zoom",
3926
+ label: "Reset Zoom",
3927
+ type: "button",
3928
+ group: "zoom",
3929
+ execute: () => {
3930
+ instance.resetZoom?.();
3931
+ }
3932
+ },
3829
3933
  {
3830
3934
  id: "download",
3831
3935
  icon: "download",
@@ -4015,6 +4119,12 @@ var CsvPlugin = class {
4015
4119
  scale = calculateFitScale();
4016
4120
  applyScale();
4017
4121
  },
4122
+ resetZoom: () => {
4123
+ scale = calculateFitScale();
4124
+ container.scrollTop = 0;
4125
+ container.scrollLeft = 0;
4126
+ applyScale();
4127
+ },
4018
4128
  rotateCW: () => {
4019
4129
  },
4020
4130
  rotateCCW: () => {
@@ -4130,6 +4240,16 @@ var CodePlugin = class {
4130
4240
  instance.zoomIn?.();
4131
4241
  }
4132
4242
  },
4243
+ {
4244
+ id: "reset-zoom",
4245
+ icon: "reset-zoom",
4246
+ label: "Reset Zoom",
4247
+ type: "button",
4248
+ group: "zoom",
4249
+ execute: () => {
4250
+ instance.resetZoom?.();
4251
+ }
4252
+ },
4133
4253
  {
4134
4254
  id: "copy",
4135
4255
  icon: "copy",
@@ -4409,6 +4529,15 @@ var CodePlugin = class {
4409
4529
  zoomLevel = isTxt ? calculateTxtFit() : 1;
4410
4530
  updateTransform();
4411
4531
  },
4532
+ resetZoom: () => {
4533
+ isUserZoomed = false;
4534
+ fontSize = 13;
4535
+ rotation = 0;
4536
+ zoomLevel = isTxt ? calculateTxtFit() : 1;
4537
+ container.scrollTop = 0;
4538
+ container.scrollLeft = 0;
4539
+ updateTransform();
4540
+ },
4412
4541
  rotateCW: () => {
4413
4542
  rotation = (rotation + 90) % 360;
4414
4543
  updateTransform();
@@ -4471,11 +4600,19 @@ var ArchivePlugin = class {
4471
4600
  {
4472
4601
  id: "fit-page",
4473
4602
  icon: "fit-page",
4474
- label: "Reset Zoom",
4603
+ label: "Fit to Page",
4475
4604
  type: "button",
4476
4605
  group: "zoom",
4477
4606
  execute: () => instance.fitToPage?.()
4478
4607
  },
4608
+ {
4609
+ id: "reset-zoom",
4610
+ icon: "reset-zoom",
4611
+ label: "Reset Zoom",
4612
+ type: "button",
4613
+ group: "zoom",
4614
+ execute: () => instance.resetZoom?.()
4615
+ },
4479
4616
  {
4480
4617
  id: "download",
4481
4618
  icon: "download",
@@ -4630,7 +4767,13 @@ var ArchivePlugin = class {
4630
4767
  },
4631
4768
  fitToPage: () => {
4632
4769
  scale = 1;
4633
- wrapper.style.transform = `scale(1)`;
4770
+ wrapper.style.transform = "scale(1)";
4771
+ },
4772
+ resetZoom: () => {
4773
+ scale = 1;
4774
+ wrapper.style.transform = "scale(1)";
4775
+ ctx.container.scrollTop = 0;
4776
+ ctx.container.scrollLeft = 0;
4634
4777
  },
4635
4778
  download: () => {
4636
4779
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -4682,6 +4825,14 @@ var MarkdownPlugin = class {
4682
4825
  group: "zoom",
4683
4826
  execute: () => instance.fitToPage?.()
4684
4827
  },
4828
+ {
4829
+ id: "reset-zoom",
4830
+ icon: "reset-zoom",
4831
+ label: "Reset Zoom",
4832
+ type: "button",
4833
+ group: "zoom",
4834
+ execute: () => instance.resetZoom?.()
4835
+ },
4685
4836
  {
4686
4837
  id: "copy",
4687
4838
  icon: "copy",
@@ -4835,6 +4986,12 @@ var MarkdownPlugin = class {
4835
4986
  fontSize = 15;
4836
4987
  wrapper.style.fontSize = "15px";
4837
4988
  },
4989
+ resetZoom: () => {
4990
+ fontSize = 15;
4991
+ wrapper.style.fontSize = "15px";
4992
+ ctx.container.scrollTop = 0;
4993
+ ctx.container.scrollLeft = 0;
4994
+ },
4838
4995
  download: () => {
4839
4996
  downloadFile(ctx.buffer, ctx.metadata.name || "document.md", "text/markdown");
4840
4997
  },
@@ -4928,6 +5085,14 @@ var PptxPlugin = class {
4928
5085
  group: "zoom",
4929
5086
  execute: () => instance.fitToPage?.()
4930
5087
  },
5088
+ {
5089
+ id: "reset-zoom",
5090
+ icon: "reset-zoom",
5091
+ label: "Reset Zoom",
5092
+ type: "button",
5093
+ group: "zoom",
5094
+ execute: () => instance.resetZoom?.()
5095
+ },
4931
5096
  {
4932
5097
  id: "rotate-cw",
4933
5098
  icon: "rotate-cw",
@@ -5047,6 +5212,13 @@ var PptxPlugin = class {
5047
5212
  rotation = 0;
5048
5213
  applyTransform();
5049
5214
  },
5215
+ resetZoom: () => {
5216
+ scale = calculateFitScale();
5217
+ rotation = 0;
5218
+ wrapper.scrollTop = 0;
5219
+ wrapper.scrollLeft = 0;
5220
+ applyTransform();
5221
+ },
5050
5222
  rotateCW: () => {
5051
5223
  rotation = (rotation + 90) % 360;
5052
5224
  applyTransform();
@@ -5122,6 +5294,14 @@ var ThreeDPlugin = class {
5122
5294
  group: "zoom",
5123
5295
  execute: () => instance.fitToPage?.()
5124
5296
  },
5297
+ {
5298
+ id: "reset-zoom",
5299
+ icon: "reset-zoom",
5300
+ label: "Reset Zoom",
5301
+ type: "button",
5302
+ group: "zoom",
5303
+ execute: () => instance.resetZoom?.()
5304
+ },
5125
5305
  {
5126
5306
  id: "rotate-cw",
5127
5307
  icon: "rotate-cw",
@@ -5258,6 +5438,7 @@ var ThreeDPlugin = class {
5258
5438
  controls.update();
5259
5439
  },
5260
5440
  fitToPage: fitCamera,
5441
+ resetZoom: fitCamera,
5261
5442
  rotateCW: () => {
5262
5443
  isWireframe = !isWireframe;
5263
5444
  materials.forEach((m) => {
@@ -5472,6 +5653,14 @@ var RtfPlugin = class {
5472
5653
  group: "zoom",
5473
5654
  execute: () => instance.fitToPage?.()
5474
5655
  },
5656
+ {
5657
+ id: "reset-zoom",
5658
+ icon: "reset-zoom",
5659
+ label: "Reset Zoom",
5660
+ type: "button",
5661
+ group: "zoom",
5662
+ execute: () => instance.resetZoom?.()
5663
+ },
5475
5664
  {
5476
5665
  id: "rotate-cw",
5477
5666
  icon: "rotate-cw",
@@ -5941,6 +6130,15 @@ var RtfPlugin = class {
5941
6130
  rotation = 0;
5942
6131
  applyTransform();
5943
6132
  },
6133
+ resetZoom: () => {
6134
+ isUserZoomed = false;
6135
+ fitMode = "width";
6136
+ scale = calculateFitScale("width");
6137
+ rotation = 0;
6138
+ ctx.container.scrollTop = 0;
6139
+ ctx.container.scrollLeft = 0;
6140
+ applyTransform();
6141
+ },
5944
6142
  rotateCW: () => {
5945
6143
  rotation = (rotation + 90) % 360;
5946
6144
  applyTransform();
@@ -6008,6 +6206,14 @@ var HtmlPreviewPlugin = class {
6008
6206
  group: "zoom",
6009
6207
  execute: () => instance.fitToPage?.()
6010
6208
  },
6209
+ {
6210
+ id: "reset-zoom",
6211
+ icon: "reset-zoom",
6212
+ label: "Reset Zoom",
6213
+ type: "button",
6214
+ group: "zoom",
6215
+ execute: () => instance.resetZoom?.()
6216
+ },
6011
6217
  {
6012
6218
  id: "copy",
6013
6219
  icon: "copy",
@@ -6080,6 +6286,12 @@ var HtmlPreviewPlugin = class {
6080
6286
  scale = 1;
6081
6287
  iframe.style.transform = "scale(1)";
6082
6288
  },
6289
+ resetZoom: () => {
6290
+ scale = 1;
6291
+ iframe.style.transform = "scale(1)";
6292
+ ctx.container.scrollTop = 0;
6293
+ ctx.container.scrollLeft = 0;
6294
+ },
6083
6295
  copy: () => {
6084
6296
  navigator.clipboard.writeText(rawHtml);
6085
6297
  },
@@ -6180,6 +6392,14 @@ var OpenDocumentPlugin = class {
6180
6392
  group: "zoom",
6181
6393
  execute: () => instance.fitToPage?.()
6182
6394
  },
6395
+ {
6396
+ id: "reset-zoom",
6397
+ icon: "reset-zoom",
6398
+ label: "Reset Zoom",
6399
+ type: "button",
6400
+ group: "zoom",
6401
+ execute: () => instance.resetZoom?.()
6402
+ },
6183
6403
  {
6184
6404
  id: "rotate-cw",
6185
6405
  icon: "rotate-cw",
@@ -6447,6 +6667,15 @@ var OpenDocumentPlugin = class {
6447
6667
  rotation = 0;
6448
6668
  applyTransform();
6449
6669
  },
6670
+ resetZoom: () => {
6671
+ isUserZoomed = false;
6672
+ fitMode = "width";
6673
+ scale = calculateFitScale("width");
6674
+ rotation = 0;
6675
+ container.scrollTop = 0;
6676
+ container.scrollLeft = 0;
6677
+ applyTransform();
6678
+ },
6450
6679
  rotateCW: () => {
6451
6680
  rotation = (rotation + 90) % 360;
6452
6681
  applyTransform();
@@ -6790,6 +7019,14 @@ var DocPlugin = class {
6790
7019
  group: "zoom",
6791
7020
  execute: () => instance.fitToPage?.()
6792
7021
  },
7022
+ {
7023
+ id: "reset-zoom",
7024
+ icon: "reset-zoom",
7025
+ label: "Reset Zoom",
7026
+ type: "button",
7027
+ group: "zoom",
7028
+ execute: () => instance.resetZoom?.()
7029
+ },
6793
7030
  {
6794
7031
  id: "rotate-cw",
6795
7032
  icon: "rotate-cw",
@@ -6996,6 +7233,15 @@ var DocPlugin = class {
6996
7233
  rotation = 0;
6997
7234
  applyTransform();
6998
7235
  },
7236
+ resetZoom: () => {
7237
+ isUserZoomed = false;
7238
+ fitMode = "width";
7239
+ scale = calculateFitScale("width");
7240
+ rotation = 0;
7241
+ ctx.container.scrollTop = 0;
7242
+ ctx.container.scrollLeft = 0;
7243
+ applyTransform();
7244
+ },
6999
7245
  rotateCW: () => {
7000
7246
  rotation = (rotation + 90) % 360;
7001
7247
  applyTransform();
@@ -7476,6 +7722,14 @@ var PptPlugin = class {
7476
7722
  group: "zoom",
7477
7723
  execute: () => instance.fitToPage?.()
7478
7724
  },
7725
+ {
7726
+ id: "reset-zoom",
7727
+ icon: "reset-zoom",
7728
+ label: "Reset Zoom",
7729
+ type: "button",
7730
+ group: "zoom",
7731
+ execute: () => instance.resetZoom?.()
7732
+ },
7479
7733
  {
7480
7734
  id: "rotate-cw",
7481
7735
  icon: "rotate-cw",
@@ -7664,6 +7918,13 @@ var PptPlugin = class {
7664
7918
  rotation = 0;
7665
7919
  applyTransform();
7666
7920
  },
7921
+ resetZoom: () => {
7922
+ scale = calculateFitScale();
7923
+ rotation = 0;
7924
+ container.scrollTop = 0;
7925
+ container.scrollLeft = 0;
7926
+ applyTransform();
7927
+ },
7667
7928
  rotateCW: () => {
7668
7929
  rotation = (rotation + 90) % 360;
7669
7930
  applyTransform();