@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.js CHANGED
@@ -579,6 +579,7 @@ var ICON_COPY = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" str
579
579
  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>`;
580
580
  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>`;
581
581
  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>`;
582
+ 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>`;
582
583
  var ICON_MAP = {
583
584
  "zoom-in": ICON_ZOOM_IN,
584
585
  "zoom-out": ICON_ZOOM_OUT,
@@ -608,7 +609,10 @@ var ICON_MAP = {
608
609
  "open-window": ICON_EXTERNAL_WINDOW,
609
610
  "external-window": ICON_EXTERNAL_WINDOW,
610
611
  "openWindow": ICON_EXTERNAL_WINDOW,
611
- "openSeparateWindow": ICON_EXTERNAL_WINDOW
612
+ "openSeparateWindow": ICON_EXTERNAL_WINDOW,
613
+ "reset-zoom": ICON_RESET_ZOOM,
614
+ "zoom-reset": ICON_RESET_ZOOM,
615
+ "resetZoom": ICON_RESET_ZOOM
612
616
  };
613
617
  var ToolbarController = class {
614
618
  el;
@@ -641,6 +645,10 @@ var ToolbarController = class {
641
645
  this.config.fitToPage = false;
642
646
  this.config.fitWidth = false;
643
647
  }
648
+ if (actionId === "reset-zoom" || actionId === "zoom-reset" || actionId === "resetZoom") {
649
+ this.config.resetZoom = false;
650
+ this.config.zoomReset = false;
651
+ }
644
652
  if (actionId === "rotate-cw" || actionId === "rotate" || actionId === "rotateCW") this.config.rotate = false;
645
653
  if (actionId === "fullscreen") this.config.fullscreen = false;
646
654
  if (actionId === "download") this.config.download = false;
@@ -665,6 +673,10 @@ var ToolbarController = class {
665
673
  this.config.fitToPage = true;
666
674
  this.config.fitWidth = true;
667
675
  }
676
+ if (actionId === "reset-zoom" || actionId === "zoom-reset" || actionId === "resetZoom") {
677
+ this.config.resetZoom = true;
678
+ this.config.zoomReset = true;
679
+ }
668
680
  if (actionId === "rotate-cw" || actionId === "rotate" || actionId === "rotateCW") this.config.rotate = true;
669
681
  if (actionId === "fullscreen") this.config.fullscreen = true;
670
682
  if (actionId === "download") this.config.download = true;
@@ -684,6 +696,7 @@ var ToolbarController = class {
684
696
  if (actionId === "zoomIn") return "zoom-in";
685
697
  if (actionId === "zoomOut") return "zoom-out";
686
698
  if (actionId === "fitPage" || actionId === "fitToPage" || actionId === "fitWidth") return "fit-page";
699
+ if (actionId === "resetZoom" || actionId === "zoomReset") return "reset-zoom";
687
700
  if (actionId === "rotateCW") return "rotate-cw";
688
701
  if (actionId === "rotateCCW") return "rotate-ccw";
689
702
  if (actionId === "openWindow" || actionId === "openSeparateWindow") return "open-window";
@@ -726,6 +739,9 @@ var ToolbarController = class {
726
739
  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)) {
727
740
  return false;
728
741
  }
742
+ if ((id === "reset-zoom" || id === "zoom-reset") && (c.resetZoom === false || c.zoomReset === false || c["reset-zoom"] === false || c["zoom-reset"] === false)) {
743
+ return false;
744
+ }
729
745
  if ((id === "rotate-cw" || id === "rotate-ccw" || id === "rotate") && (c.rotate === false || c.rotateCW === false || c.rotateCCW === false || c["rotate-cw"] === false)) {
730
746
  return false;
731
747
  }
@@ -1172,6 +1188,9 @@ var FilePreviewViewer = class _FilePreviewViewer {
1172
1188
  this.activeInstance = instance;
1173
1189
  instance.openInSeparateWindow = () => this.openInSeparateWindow();
1174
1190
  instance.toggleThumbnails = () => this.toggleThumbnails();
1191
+ if (!instance.resetZoom && instance.fitToPage) {
1192
+ instance.resetZoom = () => instance.fitToPage?.();
1193
+ }
1175
1194
  this.hideLoading();
1176
1195
  this.eventEmitter.emit("loaded", { metadata, plugin: matchedPlugin.id });
1177
1196
  const isToolbarVisible = options.showToolbar !== false && options.toolbar !== false;
@@ -1455,6 +1474,16 @@ var FilePreviewViewer = class _FilePreviewViewer {
1455
1474
  fitToPage() {
1456
1475
  this.activeInstance?.fitToPage?.();
1457
1476
  }
1477
+ /**
1478
+ * Reset zoom level to initial/default fit state.
1479
+ */
1480
+ resetZoom() {
1481
+ if (this.activeInstance?.resetZoom) {
1482
+ this.activeInstance.resetZoom();
1483
+ } else if (this.activeInstance?.fitToPage) {
1484
+ this.activeInstance.fitToPage();
1485
+ }
1486
+ }
1458
1487
  /**
1459
1488
  * Zoom in.
1460
1489
  */
@@ -2076,6 +2105,14 @@ var PdfPlugin = class {
2076
2105
  group: "zoom",
2077
2106
  execute: () => instance.fitToPage?.()
2078
2107
  },
2108
+ {
2109
+ id: "reset-zoom",
2110
+ icon: "reset-zoom",
2111
+ label: "Reset Zoom",
2112
+ type: "button",
2113
+ group: "zoom",
2114
+ execute: () => instance.resetZoom?.()
2115
+ },
2079
2116
  {
2080
2117
  id: "fit-width",
2081
2118
  icon: "fit-width",
@@ -2338,6 +2375,14 @@ var PdfPlugin = class {
2338
2375
  zoomScale = 1;
2339
2376
  renderPage(currentPage);
2340
2377
  },
2378
+ resetZoom: () => {
2379
+ fitMode = "page";
2380
+ zoomScale = 1;
2381
+ rotation = 0;
2382
+ container.scrollTop = 0;
2383
+ container.scrollLeft = 0;
2384
+ renderPage(currentPage);
2385
+ },
2341
2386
  fitToWidth: () => {
2342
2387
  fitMode = "width";
2343
2388
  zoomScale = 1;
@@ -2505,6 +2550,16 @@ var MediaPlugin = class {
2505
2550
  instance.fitToPage?.();
2506
2551
  }
2507
2552
  },
2553
+ {
2554
+ id: "reset-zoom",
2555
+ icon: "reset-zoom",
2556
+ label: "Reset Zoom",
2557
+ type: "button",
2558
+ group: "zoom",
2559
+ execute: () => {
2560
+ instance.resetZoom?.();
2561
+ }
2562
+ },
2508
2563
  {
2509
2564
  id: "rotate-cw",
2510
2565
  icon: "rotate-cw",
@@ -2678,6 +2733,13 @@ var MediaPlugin = class {
2678
2733
  rotation = 0;
2679
2734
  applyTransform();
2680
2735
  } : void 0,
2736
+ resetZoom: isImage ? () => {
2737
+ currentZoom = 1;
2738
+ rotation = 0;
2739
+ ctx.container.scrollTop = 0;
2740
+ ctx.container.scrollLeft = 0;
2741
+ applyTransform();
2742
+ } : void 0,
2681
2743
  rotateCW: isImage || isVideo ? () => {
2682
2744
  rotation = (rotation + 90) % 360;
2683
2745
  applyTransform();
@@ -2794,6 +2856,14 @@ var DocxPlugin = class {
2794
2856
  group: "zoom",
2795
2857
  execute: () => instance.fitToPage?.()
2796
2858
  },
2859
+ {
2860
+ id: "reset-zoom",
2861
+ icon: "reset-zoom",
2862
+ label: "Reset Zoom",
2863
+ type: "button",
2864
+ group: "zoom",
2865
+ execute: () => instance.resetZoom?.()
2866
+ },
2797
2867
  {
2798
2868
  id: "rotate-cw",
2799
2869
  icon: "rotate-cw",
@@ -3110,6 +3180,14 @@ var DocxPlugin = class {
3110
3180
  rotation = 0;
3111
3181
  applyTransform();
3112
3182
  },
3183
+ resetZoom: () => {
3184
+ isUserZoomed = false;
3185
+ scale = calculateFitScale("page");
3186
+ rotation = 0;
3187
+ ctx.container.scrollTop = 0;
3188
+ ctx.container.scrollLeft = 0;
3189
+ applyTransform();
3190
+ },
3113
3191
  rotateCW: () => {
3114
3192
  rotation = (rotation + 90) % 360;
3115
3193
  applyTransform();
@@ -3559,6 +3637,16 @@ var ExcelPlugin = class {
3559
3637
  instance.zoomIn?.();
3560
3638
  }
3561
3639
  },
3640
+ {
3641
+ id: "reset-zoom",
3642
+ icon: "reset-zoom",
3643
+ label: "Reset Zoom",
3644
+ type: "button",
3645
+ group: "zoom",
3646
+ execute: () => {
3647
+ instance.resetZoom?.();
3648
+ }
3649
+ },
3562
3650
  {
3563
3651
  id: "download",
3564
3652
  icon: "download",
@@ -3746,6 +3834,12 @@ var ExcelPlugin = class {
3746
3834
  scale = calculateFitScale();
3747
3835
  applyTransform();
3748
3836
  },
3837
+ resetZoom: () => {
3838
+ scale = calculateFitScale();
3839
+ contentArea.scrollTop = 0;
3840
+ contentArea.scrollLeft = 0;
3841
+ applyTransform();
3842
+ },
3749
3843
  rotateCW: () => {
3750
3844
  },
3751
3845
  rotateCCW: () => {
@@ -3876,6 +3970,16 @@ var CsvPlugin = class {
3876
3970
  instance.zoomIn?.();
3877
3971
  }
3878
3972
  },
3973
+ {
3974
+ id: "reset-zoom",
3975
+ icon: "reset-zoom",
3976
+ label: "Reset Zoom",
3977
+ type: "button",
3978
+ group: "zoom",
3979
+ execute: () => {
3980
+ instance.resetZoom?.();
3981
+ }
3982
+ },
3879
3983
  {
3880
3984
  id: "download",
3881
3985
  icon: "download",
@@ -4065,6 +4169,12 @@ var CsvPlugin = class {
4065
4169
  scale = calculateFitScale();
4066
4170
  applyScale();
4067
4171
  },
4172
+ resetZoom: () => {
4173
+ scale = calculateFitScale();
4174
+ container.scrollTop = 0;
4175
+ container.scrollLeft = 0;
4176
+ applyScale();
4177
+ },
4068
4178
  rotateCW: () => {
4069
4179
  },
4070
4180
  rotateCCW: () => {
@@ -4180,6 +4290,16 @@ var CodePlugin = class {
4180
4290
  instance.zoomIn?.();
4181
4291
  }
4182
4292
  },
4293
+ {
4294
+ id: "reset-zoom",
4295
+ icon: "reset-zoom",
4296
+ label: "Reset Zoom",
4297
+ type: "button",
4298
+ group: "zoom",
4299
+ execute: () => {
4300
+ instance.resetZoom?.();
4301
+ }
4302
+ },
4183
4303
  {
4184
4304
  id: "copy",
4185
4305
  icon: "copy",
@@ -4459,6 +4579,15 @@ var CodePlugin = class {
4459
4579
  zoomLevel = isTxt ? calculateTxtFit() : 1;
4460
4580
  updateTransform();
4461
4581
  },
4582
+ resetZoom: () => {
4583
+ isUserZoomed = false;
4584
+ fontSize = 13;
4585
+ rotation = 0;
4586
+ zoomLevel = isTxt ? calculateTxtFit() : 1;
4587
+ container.scrollTop = 0;
4588
+ container.scrollLeft = 0;
4589
+ updateTransform();
4590
+ },
4462
4591
  rotateCW: () => {
4463
4592
  rotation = (rotation + 90) % 360;
4464
4593
  updateTransform();
@@ -4521,11 +4650,19 @@ var ArchivePlugin = class {
4521
4650
  {
4522
4651
  id: "fit-page",
4523
4652
  icon: "fit-page",
4524
- label: "Reset Zoom",
4653
+ label: "Fit to Page",
4525
4654
  type: "button",
4526
4655
  group: "zoom",
4527
4656
  execute: () => instance.fitToPage?.()
4528
4657
  },
4658
+ {
4659
+ id: "reset-zoom",
4660
+ icon: "reset-zoom",
4661
+ label: "Reset Zoom",
4662
+ type: "button",
4663
+ group: "zoom",
4664
+ execute: () => instance.resetZoom?.()
4665
+ },
4529
4666
  {
4530
4667
  id: "download",
4531
4668
  icon: "download",
@@ -4680,7 +4817,13 @@ var ArchivePlugin = class {
4680
4817
  },
4681
4818
  fitToPage: () => {
4682
4819
  scale = 1;
4683
- wrapper.style.transform = `scale(1)`;
4820
+ wrapper.style.transform = "scale(1)";
4821
+ },
4822
+ resetZoom: () => {
4823
+ scale = 1;
4824
+ wrapper.style.transform = "scale(1)";
4825
+ ctx.container.scrollTop = 0;
4826
+ ctx.container.scrollLeft = 0;
4684
4827
  },
4685
4828
  download: () => {
4686
4829
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -4732,6 +4875,14 @@ var MarkdownPlugin = class {
4732
4875
  group: "zoom",
4733
4876
  execute: () => instance.fitToPage?.()
4734
4877
  },
4878
+ {
4879
+ id: "reset-zoom",
4880
+ icon: "reset-zoom",
4881
+ label: "Reset Zoom",
4882
+ type: "button",
4883
+ group: "zoom",
4884
+ execute: () => instance.resetZoom?.()
4885
+ },
4735
4886
  {
4736
4887
  id: "copy",
4737
4888
  icon: "copy",
@@ -4885,6 +5036,12 @@ var MarkdownPlugin = class {
4885
5036
  fontSize = 15;
4886
5037
  wrapper.style.fontSize = "15px";
4887
5038
  },
5039
+ resetZoom: () => {
5040
+ fontSize = 15;
5041
+ wrapper.style.fontSize = "15px";
5042
+ ctx.container.scrollTop = 0;
5043
+ ctx.container.scrollLeft = 0;
5044
+ },
4888
5045
  download: () => {
4889
5046
  downloadFile(ctx.buffer, ctx.metadata.name || "document.md", "text/markdown");
4890
5047
  },
@@ -4978,6 +5135,14 @@ var PptxPlugin = class {
4978
5135
  group: "zoom",
4979
5136
  execute: () => instance.fitToPage?.()
4980
5137
  },
5138
+ {
5139
+ id: "reset-zoom",
5140
+ icon: "reset-zoom",
5141
+ label: "Reset Zoom",
5142
+ type: "button",
5143
+ group: "zoom",
5144
+ execute: () => instance.resetZoom?.()
5145
+ },
4981
5146
  {
4982
5147
  id: "rotate-cw",
4983
5148
  icon: "rotate-cw",
@@ -5097,6 +5262,13 @@ var PptxPlugin = class {
5097
5262
  rotation = 0;
5098
5263
  applyTransform();
5099
5264
  },
5265
+ resetZoom: () => {
5266
+ scale = calculateFitScale();
5267
+ rotation = 0;
5268
+ wrapper.scrollTop = 0;
5269
+ wrapper.scrollLeft = 0;
5270
+ applyTransform();
5271
+ },
5100
5272
  rotateCW: () => {
5101
5273
  rotation = (rotation + 90) % 360;
5102
5274
  applyTransform();
@@ -5172,6 +5344,14 @@ var ThreeDPlugin = class {
5172
5344
  group: "zoom",
5173
5345
  execute: () => instance.fitToPage?.()
5174
5346
  },
5347
+ {
5348
+ id: "reset-zoom",
5349
+ icon: "reset-zoom",
5350
+ label: "Reset Zoom",
5351
+ type: "button",
5352
+ group: "zoom",
5353
+ execute: () => instance.resetZoom?.()
5354
+ },
5175
5355
  {
5176
5356
  id: "rotate-cw",
5177
5357
  icon: "rotate-cw",
@@ -5308,6 +5488,7 @@ var ThreeDPlugin = class {
5308
5488
  controls.update();
5309
5489
  },
5310
5490
  fitToPage: fitCamera,
5491
+ resetZoom: fitCamera,
5311
5492
  rotateCW: () => {
5312
5493
  isWireframe = !isWireframe;
5313
5494
  materials.forEach((m) => {
@@ -5522,6 +5703,14 @@ var RtfPlugin = class {
5522
5703
  group: "zoom",
5523
5704
  execute: () => instance.fitToPage?.()
5524
5705
  },
5706
+ {
5707
+ id: "reset-zoom",
5708
+ icon: "reset-zoom",
5709
+ label: "Reset Zoom",
5710
+ type: "button",
5711
+ group: "zoom",
5712
+ execute: () => instance.resetZoom?.()
5713
+ },
5525
5714
  {
5526
5715
  id: "rotate-cw",
5527
5716
  icon: "rotate-cw",
@@ -5991,6 +6180,15 @@ var RtfPlugin = class {
5991
6180
  rotation = 0;
5992
6181
  applyTransform();
5993
6182
  },
6183
+ resetZoom: () => {
6184
+ isUserZoomed = false;
6185
+ fitMode = "width";
6186
+ scale = calculateFitScale("width");
6187
+ rotation = 0;
6188
+ ctx.container.scrollTop = 0;
6189
+ ctx.container.scrollLeft = 0;
6190
+ applyTransform();
6191
+ },
5994
6192
  rotateCW: () => {
5995
6193
  rotation = (rotation + 90) % 360;
5996
6194
  applyTransform();
@@ -6058,6 +6256,14 @@ var HtmlPreviewPlugin = class {
6058
6256
  group: "zoom",
6059
6257
  execute: () => instance.fitToPage?.()
6060
6258
  },
6259
+ {
6260
+ id: "reset-zoom",
6261
+ icon: "reset-zoom",
6262
+ label: "Reset Zoom",
6263
+ type: "button",
6264
+ group: "zoom",
6265
+ execute: () => instance.resetZoom?.()
6266
+ },
6061
6267
  {
6062
6268
  id: "copy",
6063
6269
  icon: "copy",
@@ -6130,6 +6336,12 @@ var HtmlPreviewPlugin = class {
6130
6336
  scale = 1;
6131
6337
  iframe.style.transform = "scale(1)";
6132
6338
  },
6339
+ resetZoom: () => {
6340
+ scale = 1;
6341
+ iframe.style.transform = "scale(1)";
6342
+ ctx.container.scrollTop = 0;
6343
+ ctx.container.scrollLeft = 0;
6344
+ },
6133
6345
  copy: () => {
6134
6346
  navigator.clipboard.writeText(rawHtml);
6135
6347
  },
@@ -6230,6 +6442,14 @@ var OpenDocumentPlugin = class {
6230
6442
  group: "zoom",
6231
6443
  execute: () => instance.fitToPage?.()
6232
6444
  },
6445
+ {
6446
+ id: "reset-zoom",
6447
+ icon: "reset-zoom",
6448
+ label: "Reset Zoom",
6449
+ type: "button",
6450
+ group: "zoom",
6451
+ execute: () => instance.resetZoom?.()
6452
+ },
6233
6453
  {
6234
6454
  id: "rotate-cw",
6235
6455
  icon: "rotate-cw",
@@ -6497,6 +6717,15 @@ var OpenDocumentPlugin = class {
6497
6717
  rotation = 0;
6498
6718
  applyTransform();
6499
6719
  },
6720
+ resetZoom: () => {
6721
+ isUserZoomed = false;
6722
+ fitMode = "width";
6723
+ scale = calculateFitScale("width");
6724
+ rotation = 0;
6725
+ container.scrollTop = 0;
6726
+ container.scrollLeft = 0;
6727
+ applyTransform();
6728
+ },
6500
6729
  rotateCW: () => {
6501
6730
  rotation = (rotation + 90) % 360;
6502
6731
  applyTransform();
@@ -6840,6 +7069,14 @@ var DocPlugin = class {
6840
7069
  group: "zoom",
6841
7070
  execute: () => instance.fitToPage?.()
6842
7071
  },
7072
+ {
7073
+ id: "reset-zoom",
7074
+ icon: "reset-zoom",
7075
+ label: "Reset Zoom",
7076
+ type: "button",
7077
+ group: "zoom",
7078
+ execute: () => instance.resetZoom?.()
7079
+ },
6843
7080
  {
6844
7081
  id: "rotate-cw",
6845
7082
  icon: "rotate-cw",
@@ -7046,6 +7283,15 @@ var DocPlugin = class {
7046
7283
  rotation = 0;
7047
7284
  applyTransform();
7048
7285
  },
7286
+ resetZoom: () => {
7287
+ isUserZoomed = false;
7288
+ fitMode = "width";
7289
+ scale = calculateFitScale("width");
7290
+ rotation = 0;
7291
+ ctx.container.scrollTop = 0;
7292
+ ctx.container.scrollLeft = 0;
7293
+ applyTransform();
7294
+ },
7049
7295
  rotateCW: () => {
7050
7296
  rotation = (rotation + 90) % 360;
7051
7297
  applyTransform();
@@ -7526,6 +7772,14 @@ var PptPlugin = class {
7526
7772
  group: "zoom",
7527
7773
  execute: () => instance.fitToPage?.()
7528
7774
  },
7775
+ {
7776
+ id: "reset-zoom",
7777
+ icon: "reset-zoom",
7778
+ label: "Reset Zoom",
7779
+ type: "button",
7780
+ group: "zoom",
7781
+ execute: () => instance.resetZoom?.()
7782
+ },
7529
7783
  {
7530
7784
  id: "rotate-cw",
7531
7785
  icon: "rotate-cw",
@@ -7714,6 +7968,13 @@ var PptPlugin = class {
7714
7968
  rotation = 0;
7715
7969
  applyTransform();
7716
7970
  },
7971
+ resetZoom: () => {
7972
+ scale = calculateFitScale();
7973
+ rotation = 0;
7974
+ container.scrollTop = 0;
7975
+ container.scrollLeft = 0;
7976
+ applyTransform();
7977
+ },
7717
7978
  rotateCW: () => {
7718
7979
  rotation = (rotation + 90) % 360;
7719
7980
  applyTransform();