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

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
@@ -2118,16 +2118,22 @@ var PdfPlugin = class {
2118
2118
  container.className = "fp-pdf-container";
2119
2119
  container.style.width = "100%";
2120
2120
  container.style.height = "100%";
2121
- container.style.overflowX = "hidden";
2122
- container.style.overflowY = "auto";
2123
- container.style.display = "flex";
2124
- container.style.flexDirection = "column";
2125
- container.style.alignItems = "center";
2126
- container.style.justifyContent = "flex-start";
2127
- container.style.padding = "16px 8px";
2121
+ container.style.overflow = "auto";
2128
2122
  container.style.backgroundColor = "#0f172a";
2129
2123
  container.style.boxSizing = "border-box";
2130
2124
  container.style.position = "relative";
2125
+ const scrollWrapper = document.createElement("div");
2126
+ scrollWrapper.className = "fp-pdf-scroll-wrapper";
2127
+ scrollWrapper.style.minWidth = "100%";
2128
+ scrollWrapper.style.minHeight = "100%";
2129
+ scrollWrapper.style.width = "max-content";
2130
+ scrollWrapper.style.height = "max-content";
2131
+ scrollWrapper.style.display = "flex";
2132
+ scrollWrapper.style.flexDirection = "column";
2133
+ scrollWrapper.style.alignItems = "center";
2134
+ scrollWrapper.style.justifyContent = "flex-start";
2135
+ scrollWrapper.style.padding = "16px 8px";
2136
+ scrollWrapper.style.boxSizing = "border-box";
2131
2137
  const pageCard = document.createElement("div");
2132
2138
  pageCard.className = "fp-pdf-page-card";
2133
2139
  pageCard.style.boxShadow = "0 10px 35px rgba(0, 0, 0, 0.5)";
@@ -2140,7 +2146,8 @@ var PdfPlugin = class {
2140
2146
  pageCard.style.transition = "box-shadow 0.2s ease";
2141
2147
  let canvas = document.createElement("canvas");
2142
2148
  pageCard.appendChild(canvas);
2143
- container.appendChild(pageCard);
2149
+ scrollWrapper.appendChild(pageCard);
2150
+ container.appendChild(scrollWrapper);
2144
2151
  ctx.container.appendChild(container);
2145
2152
  const standardFontsUrl = typeof window !== "undefined" && window.__PDF_STANDARD_FONTS_URL__ || "./standard_fonts/";
2146
2153
  const cmapsUrl = typeof window !== "undefined" && window.__PDF_CMAPS_URL__ || "./cmaps/";
@@ -2649,17 +2656,86 @@ var MediaPlugin = class {
2649
2656
  element = document.createElement("div");
2650
2657
  element.textContent = "Unsupported media type";
2651
2658
  }
2652
- ctx.container.style.display = "flex";
2653
- ctx.container.style.alignItems = "center";
2654
- ctx.container.style.justifyContent = "center";
2655
- ctx.container.style.overflow = "hidden";
2656
- ctx.container.appendChild(element);
2659
+ const scrollWrapper = document.createElement("div");
2660
+ scrollWrapper.className = "fp-media-scroll-wrapper";
2661
+ scrollWrapper.style.minWidth = "100%";
2662
+ scrollWrapper.style.minHeight = "100%";
2663
+ scrollWrapper.style.width = "max-content";
2664
+ scrollWrapper.style.height = "max-content";
2665
+ scrollWrapper.style.display = "flex";
2666
+ scrollWrapper.style.justifyContent = "center";
2667
+ scrollWrapper.style.alignItems = "center";
2668
+ scrollWrapper.style.padding = "16px";
2669
+ scrollWrapper.style.boxSizing = "border-box";
2670
+ const sizer = document.createElement("div");
2671
+ sizer.className = "fp-media-sizer";
2672
+ sizer.style.position = "relative";
2673
+ sizer.style.flexShrink = "0";
2674
+ sizer.style.display = "flex";
2675
+ sizer.style.justifyContent = "center";
2676
+ sizer.style.alignItems = "center";
2677
+ sizer.appendChild(element);
2678
+ scrollWrapper.appendChild(sizer);
2679
+ ctx.container.style.overflow = "auto";
2680
+ ctx.container.style.padding = "0";
2681
+ ctx.container.innerHTML = "";
2682
+ ctx.container.appendChild(scrollWrapper);
2683
+ let naturalW = 800;
2684
+ let naturalH = 600;
2685
+ let baseW = 800;
2686
+ let baseH = 600;
2687
+ const updateBaseDimensions = () => {
2688
+ if (!isImage) return;
2689
+ const img = element;
2690
+ naturalW = img.naturalWidth || naturalW;
2691
+ naturalH = img.naturalHeight || naturalH;
2692
+ const availW = Math.max(100, ctx.container.clientWidth - 48);
2693
+ const availH = Math.max(100, ctx.container.clientHeight - 48);
2694
+ const fitRatio = Math.min(1, availW / naturalW, availH / naturalH);
2695
+ baseW = Math.max(1, Math.round(naturalW * fitRatio));
2696
+ baseH = Math.max(1, Math.round(naturalH * fitRatio));
2697
+ };
2657
2698
  const applyTransform = () => {
2658
- element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2699
+ if (isImage) {
2700
+ updateBaseDimensions();
2701
+ const isRotated90 = rotation % 180 !== 0;
2702
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * currentZoom);
2703
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * currentZoom);
2704
+ sizer.style.width = `${boxW}px`;
2705
+ sizer.style.height = `${boxH}px`;
2706
+ element.style.width = `${baseW}px`;
2707
+ element.style.height = `${baseH}px`;
2708
+ element.style.maxWidth = "none";
2709
+ element.style.maxHeight = "none";
2710
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2711
+ element.style.transformOrigin = "center center";
2712
+ element.style.flexShrink = "0";
2713
+ } else {
2714
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2715
+ }
2659
2716
  };
2717
+ if (isImage) {
2718
+ const img = element;
2719
+ if (img.complete && img.naturalWidth > 0) {
2720
+ updateBaseDimensions();
2721
+ applyTransform();
2722
+ } else {
2723
+ img.onload = () => {
2724
+ updateBaseDimensions();
2725
+ applyTransform();
2726
+ };
2727
+ }
2728
+ }
2729
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
2730
+ if (currentZoom === 1) {
2731
+ applyTransform();
2732
+ }
2733
+ }) : null;
2734
+ ro?.observe(ctx.container);
2660
2735
  const cleanup = () => {
2736
+ ro?.disconnect();
2661
2737
  if (url) URL.revokeObjectURL(url);
2662
- element.remove();
2738
+ scrollWrapper.remove();
2663
2739
  ctx.container.innerHTML = "";
2664
2740
  };
2665
2741
  ctx.signal.addEventListener("abort", cleanup);
@@ -2852,7 +2928,7 @@ var DocxPlugin = class {
2852
2928
  async render(ctx) {
2853
2929
  const wrapper = document.createElement("div");
2854
2930
  wrapper.className = "fp-docx-wrapper";
2855
- wrapper.style.transformOrigin = "top center";
2931
+ wrapper.style.transformOrigin = "center center";
2856
2932
  wrapper.style.transition = "transform 0.2s ease";
2857
2933
  wrapper.style.padding = "0";
2858
2934
  wrapper.style.maxWidth = "none";
@@ -2862,11 +2938,31 @@ var DocxPlugin = class {
2862
2938
  wrapper.style.flexDirection = "column";
2863
2939
  wrapper.style.alignItems = "center";
2864
2940
  wrapper.style.boxSizing = "border-box";
2865
- ctx.container.style.overflowX = "hidden";
2866
- ctx.container.style.overflowY = "auto";
2867
- ctx.container.style.padding = "16px 8px";
2941
+ wrapper.style.flexShrink = "0";
2942
+ const sizer = document.createElement("div");
2943
+ sizer.className = "fp-docx-sizer";
2944
+ sizer.style.position = "relative";
2945
+ sizer.style.flexShrink = "0";
2946
+ sizer.style.display = "flex";
2947
+ sizer.style.justifyContent = "center";
2948
+ sizer.style.alignItems = "center";
2949
+ const scrollWrapper = document.createElement("div");
2950
+ scrollWrapper.className = "fp-docx-scroll-wrapper";
2951
+ scrollWrapper.style.minWidth = "100%";
2952
+ scrollWrapper.style.minHeight = "100%";
2953
+ scrollWrapper.style.width = "max-content";
2954
+ scrollWrapper.style.height = "max-content";
2955
+ scrollWrapper.style.display = "flex";
2956
+ scrollWrapper.style.justifyContent = "center";
2957
+ scrollWrapper.style.alignItems = "flex-start";
2958
+ scrollWrapper.style.padding = "16px 8px";
2959
+ scrollWrapper.style.boxSizing = "border-box";
2960
+ sizer.appendChild(wrapper);
2961
+ scrollWrapper.appendChild(sizer);
2962
+ ctx.container.style.overflow = "auto";
2963
+ ctx.container.style.padding = "0";
2868
2964
  ctx.container.style.backgroundColor = "#f1f5f9";
2869
- ctx.container.appendChild(wrapper);
2965
+ ctx.container.appendChild(scrollWrapper);
2870
2966
  const styleOverride = document.createElement("style");
2871
2967
  styleOverride.textContent = `
2872
2968
  .fp-docx-wrapper .docx-wrapper {
@@ -2905,8 +3001,8 @@ var DocxPlugin = class {
2905
3001
  renderEndnotes: true,
2906
3002
  useBase64URL: true
2907
3003
  });
2908
- if (!ctx.container.contains(wrapper)) {
2909
- ctx.container.appendChild(wrapper);
3004
+ if (!sizer.contains(wrapper)) {
3005
+ sizer.appendChild(wrapper);
2910
3006
  }
2911
3007
  if (wrapper.children.length > 0 && (wrapper.textContent?.trim().length ?? 0) > 0) {
2912
3008
  renderedSuccessfully = true;
@@ -2943,8 +3039,8 @@ var DocxPlugin = class {
2943
3039
  try {
2944
3040
  wrapper.innerHTML = "";
2945
3041
  this.renderXmlFallback(ctx, wrapper, createdBlobUrls);
2946
- if (!ctx.container.contains(wrapper)) {
2947
- ctx.container.appendChild(wrapper);
3042
+ if (!sizer.contains(wrapper)) {
3043
+ sizer.appendChild(wrapper);
2948
3044
  }
2949
3045
  renderedSuccessfully = true;
2950
3046
  } catch (fallbackErr) {
@@ -2959,8 +3055,8 @@ var DocxPlugin = class {
2959
3055
  </p>
2960
3056
  </div>
2961
3057
  `;
2962
- if (!ctx.container.contains(wrapper)) {
2963
- ctx.container.appendChild(wrapper);
3058
+ if (!sizer.contains(wrapper)) {
3059
+ sizer.appendChild(wrapper);
2964
3060
  }
2965
3061
  }
2966
3062
  }
@@ -3063,15 +3159,18 @@ var DocxPlugin = class {
3063
3159
  return Math.max(0.35, Math.min(3, sW));
3064
3160
  };
3065
3161
  const applyTransform = () => {
3066
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3067
- wrapper.style.transformOrigin = "top center";
3068
3162
  const activeEl = pageElements[currentPage - 1] || wrapper.querySelector("section.docx") || wrapper;
3163
+ const elW = activeEl.offsetWidth || 816;
3069
3164
  const elH = activeEl.offsetHeight || 1056;
3070
- if (scale > 1) {
3071
- wrapper.style.marginBottom = `${Math.round(elH * scale - elH + 32)}px`;
3072
- } else {
3073
- wrapper.style.marginBottom = "32px";
3074
- }
3165
+ const isRotated90 = rotation % 180 !== 0;
3166
+ const boxW = Math.round((isRotated90 ? elH : elW) * scale);
3167
+ const boxH = Math.round((isRotated90 ? elW : elH) * scale);
3168
+ sizer.style.width = `${boxW}px`;
3169
+ sizer.style.height = `${boxH}px`;
3170
+ wrapper.style.width = `${elW}px`;
3171
+ wrapper.style.height = `${elH}px`;
3172
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3173
+ wrapper.style.transformOrigin = "center center";
3075
3174
  };
3076
3175
  let resizeObserver = null;
3077
3176
  if (typeof ResizeObserver !== "undefined") {
@@ -3096,7 +3195,7 @@ var DocxPlugin = class {
3096
3195
  for (const url of createdBlobUrls) {
3097
3196
  URL.revokeObjectURL(url);
3098
3197
  }
3099
- wrapper.remove();
3198
+ scrollWrapper.remove();
3100
3199
  styleOverride.remove();
3101
3200
  ctx.container.innerHTML = "";
3102
3201
  };
@@ -3643,7 +3742,7 @@ var ExcelPlugin = class {
3643
3742
  contentArea.style.flex = "1";
3644
3743
  contentArea.style.overflow = "auto";
3645
3744
  contentArea.style.padding = "16px";
3646
- contentArea.style.transformOrigin = "top left";
3745
+ contentArea.style.boxSizing = "border-box";
3647
3746
  const tabsArea = document.createElement("div");
3648
3747
  tabsArea.className = "fp-excel-tabs";
3649
3748
  tabsArea.style.display = "flex";
@@ -3657,18 +3756,35 @@ var ExcelPlugin = class {
3657
3756
  container.appendChild(tabsArea);
3658
3757
  ctx.container.appendChild(container);
3659
3758
  let scale = 1;
3759
+ let isUserZoomed = false;
3660
3760
  let currentSheetIndex = 1;
3661
3761
  let sheetNames = [];
3662
3762
  let wb = null;
3663
3763
  const applyTransform = () => {
3664
- contentArea.style.transform = `scale(${scale})`;
3665
- contentArea.style.transformOrigin = "top left";
3764
+ const sizer = contentArea.querySelector(".fp-excel-sizer");
3765
+ const table = contentArea.querySelector("table");
3766
+ if (!sizer || !table) return;
3767
+ if (!table._baseWidth && table.offsetWidth > 0) {
3768
+ table._baseWidth = table.offsetWidth;
3769
+ table._baseHeight = table.offsetHeight;
3770
+ }
3771
+ const baseW = table._baseWidth || table.offsetWidth || 800;
3772
+ const baseH = table._baseHeight || table.offsetHeight || 600;
3773
+ const scaledW = Math.round(baseW * scale);
3774
+ const scaledH = Math.round(baseH * scale);
3775
+ sizer.style.width = `${scaledW}px`;
3776
+ sizer.style.height = `${scaledH}px`;
3777
+ table.style.position = "absolute";
3778
+ table.style.top = "0";
3779
+ table.style.left = "0";
3780
+ table.style.transform = `scale(${scale})`;
3781
+ table.style.transformOrigin = "top left";
3666
3782
  };
3667
3783
  const calculateFitScale = () => {
3668
3784
  const table = contentArea.querySelector("table");
3669
3785
  if (!table) return 1;
3670
3786
  const availW = Math.max(280, container.clientWidth - 48);
3671
- const tW = table.offsetWidth || 800;
3787
+ const tW = table._baseWidth || table.offsetWidth || 800;
3672
3788
  return Math.max(0.4, Math.min(1, availW / tW));
3673
3789
  };
3674
3790
  try {
@@ -3688,9 +3804,13 @@ var ExcelPlugin = class {
3688
3804
  contentArea.innerHTML = '<div style="padding: 24px; color: #888;">Empty sheet</div>';
3689
3805
  return;
3690
3806
  }
3807
+ const sizer = document.createElement("div");
3808
+ sizer.className = "fp-excel-sizer";
3809
+ sizer.style.position = "relative";
3691
3810
  const html = XLSX__namespace.utils.sheet_to_html(ws, { id: "fp-sheet-table", editable: false });
3692
- contentArea.innerHTML = html;
3693
- const table = contentArea.querySelector("table");
3811
+ sizer.innerHTML = html;
3812
+ contentArea.appendChild(sizer);
3813
+ const table = sizer.querySelector("table");
3694
3814
  if (table) {
3695
3815
  table.style.borderCollapse = "collapse";
3696
3816
  table.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
@@ -3725,13 +3845,17 @@ var ExcelPlugin = class {
3725
3845
  });
3726
3846
  ctx.emit("page-change", { page: currentSheetIndex, total: sheetNames.length });
3727
3847
  requestAnimationFrame(() => {
3728
- scale = calculateFitScale();
3848
+ if (!isUserZoomed) {
3849
+ scale = calculateFitScale();
3850
+ }
3729
3851
  applyTransform();
3730
3852
  });
3731
3853
  };
3732
3854
  const ro = new ResizeObserver(() => {
3733
- scale = calculateFitScale();
3734
- applyTransform();
3855
+ if (!isUserZoomed) {
3856
+ scale = calculateFitScale();
3857
+ applyTransform();
3858
+ }
3735
3859
  });
3736
3860
  ro.observe(container);
3737
3861
  if (sheetNames.length > 0) {
@@ -3768,23 +3892,28 @@ var ExcelPlugin = class {
3768
3892
  return {
3769
3893
  destroy: cleanup,
3770
3894
  zoomIn: () => {
3895
+ isUserZoomed = true;
3771
3896
  scale += 0.15;
3772
3897
  applyTransform();
3773
3898
  },
3774
3899
  zoomOut: () => {
3900
+ isUserZoomed = true;
3775
3901
  scale = Math.max(0.2, scale - 0.15);
3776
3902
  applyTransform();
3777
3903
  },
3778
3904
  getZoom: () => scale,
3779
3905
  setZoom: (level) => {
3906
+ isUserZoomed = true;
3780
3907
  scale = level;
3781
3908
  applyTransform();
3782
3909
  },
3783
3910
  fitToPage: () => {
3911
+ isUserZoomed = false;
3784
3912
  scale = calculateFitScale();
3785
3913
  applyTransform();
3786
3914
  },
3787
3915
  resetZoom: () => {
3916
+ isUserZoomed = false;
3788
3917
  scale = calculateFitScale();
3789
3918
  contentArea.scrollTop = 0;
3790
3919
  contentArea.scrollLeft = 0;
@@ -4016,21 +4145,41 @@ var CsvPlugin = class {
4016
4145
  container.appendChild(tableWrapper);
4017
4146
  ctx.container.appendChild(container);
4018
4147
  let scale = 1;
4148
+ let isUserZoomed = false;
4019
4149
  const calculateFitScale = () => {
4020
4150
  const availW = Math.max(280, container.clientWidth - 48);
4021
- const tW = table.offsetWidth || 800;
4151
+ const tW = table._baseWidth || table.offsetWidth || 800;
4022
4152
  return Math.max(0.4, Math.min(1, availW / tW));
4023
4153
  };
4024
4154
  const applyScale = () => {
4025
- tableWrapper.style.transform = `scale(${scale})`;
4155
+ if (!table._baseWidth && table.offsetWidth > 0) {
4156
+ table._baseWidth = table.offsetWidth;
4157
+ table._baseHeight = table.offsetHeight;
4158
+ }
4159
+ const baseW = table._baseWidth || table.offsetWidth || 800;
4160
+ const baseH = table._baseHeight || table.offsetHeight || 600;
4161
+ const scaledW = Math.round(baseW * scale);
4162
+ const scaledH = Math.round(baseH * scale);
4163
+ tableWrapper.style.position = "relative";
4164
+ tableWrapper.style.width = `${scaledW}px`;
4165
+ tableWrapper.style.height = `${scaledH}px`;
4166
+ table.style.position = "absolute";
4167
+ table.style.top = "0";
4168
+ table.style.left = "0";
4169
+ table.style.transform = `scale(${scale})`;
4170
+ table.style.transformOrigin = "top left";
4026
4171
  };
4027
4172
  requestAnimationFrame(() => {
4028
- scale = calculateFitScale();
4173
+ if (!isUserZoomed) {
4174
+ scale = calculateFitScale();
4175
+ }
4029
4176
  applyScale();
4030
4177
  });
4031
4178
  const ro = new ResizeObserver(() => {
4032
- scale = calculateFitScale();
4033
- applyScale();
4179
+ if (!isUserZoomed) {
4180
+ scale = calculateFitScale();
4181
+ applyScale();
4182
+ }
4034
4183
  });
4035
4184
  ro.observe(container);
4036
4185
  const cleanup = () => {
@@ -4103,23 +4252,28 @@ var CsvPlugin = class {
4103
4252
  }];
4104
4253
  },
4105
4254
  zoomIn: () => {
4255
+ isUserZoomed = true;
4106
4256
  scale += 0.1;
4107
4257
  applyScale();
4108
4258
  },
4109
4259
  zoomOut: () => {
4260
+ isUserZoomed = true;
4110
4261
  scale = Math.max(0.2, scale - 0.1);
4111
4262
  applyScale();
4112
4263
  },
4113
4264
  getZoom: () => scale,
4114
4265
  setZoom: (level) => {
4266
+ isUserZoomed = true;
4115
4267
  scale = level;
4116
4268
  applyScale();
4117
4269
  },
4118
4270
  fitToPage: () => {
4271
+ isUserZoomed = false;
4119
4272
  scale = calculateFitScale();
4120
4273
  applyScale();
4121
4274
  },
4122
4275
  resetZoom: () => {
4276
+ isUserZoomed = false;
4123
4277
  scale = calculateFitScale();
4124
4278
  container.scrollTop = 0;
4125
4279
  container.scrollLeft = 0;
@@ -4355,15 +4509,27 @@ var CodePlugin = class {
4355
4509
  let isUserZoomed = false;
4356
4510
  const pre = document.createElement("pre");
4357
4511
  const code = document.createElement("code");
4512
+ const sizer = document.createElement("div");
4513
+ const scrollWrapper = document.createElement("div");
4358
4514
  if (isTxt) {
4359
- container.style.overflowX = "hidden";
4360
- container.style.overflowY = "auto";
4515
+ container.style.overflow = "auto";
4361
4516
  container.style.backgroundColor = "#f1f5f9";
4362
- container.style.padding = "16px 8px";
4363
- container.style.boxSizing = "border-box";
4364
- container.style.display = "flex";
4365
- container.style.flexDirection = "column";
4366
- container.style.alignItems = "center";
4517
+ scrollWrapper.className = "fp-code-scroll-wrapper";
4518
+ scrollWrapper.style.minWidth = "100%";
4519
+ scrollWrapper.style.minHeight = "100%";
4520
+ scrollWrapper.style.width = "max-content";
4521
+ scrollWrapper.style.height = "max-content";
4522
+ scrollWrapper.style.display = "flex";
4523
+ scrollWrapper.style.justifyContent = "center";
4524
+ scrollWrapper.style.alignItems = "flex-start";
4525
+ scrollWrapper.style.padding = "16px 8px";
4526
+ scrollWrapper.style.boxSizing = "border-box";
4527
+ sizer.className = "fp-code-sizer";
4528
+ sizer.style.position = "relative";
4529
+ sizer.style.flexShrink = "0";
4530
+ sizer.style.display = "flex";
4531
+ sizer.style.justifyContent = "center";
4532
+ sizer.style.alignItems = "center";
4367
4533
  pre.style.margin = "0 auto";
4368
4534
  pre.style.fontFamily = "Consolas, 'Courier New', monospace";
4369
4535
  pre.style.fontSize = "13px";
@@ -4378,8 +4544,9 @@ var CodePlugin = class {
4378
4544
  pre.style.boxSizing = "border-box";
4379
4545
  pre.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
4380
4546
  pre.style.borderRadius = "4px";
4381
- pre.style.transformOrigin = "top center";
4547
+ pre.style.transformOrigin = "center center";
4382
4548
  pre.style.transition = "transform 0.15s ease";
4549
+ pre.style.flexShrink = "0";
4383
4550
  } else {
4384
4551
  container.style.overflow = "auto";
4385
4552
  container.style.backgroundColor = "#1e1e1e";
@@ -4412,7 +4579,13 @@ var CodePlugin = class {
4412
4579
  };
4413
4580
  renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
4414
4581
  pre.appendChild(code);
4415
- container.appendChild(pre);
4582
+ if (isTxt) {
4583
+ sizer.appendChild(pre);
4584
+ scrollWrapper.appendChild(sizer);
4585
+ container.appendChild(scrollWrapper);
4586
+ } else {
4587
+ container.appendChild(pre);
4588
+ }
4416
4589
  const showPage = (pageNum) => {
4417
4590
  currentPage = Math.max(1, Math.min(totalPages, pageNum));
4418
4591
  renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
@@ -4429,10 +4602,16 @@ var CodePlugin = class {
4429
4602
  };
4430
4603
  const updateTransform = () => {
4431
4604
  if (isTxt) {
4605
+ const elW = 816;
4606
+ const baseH = pre.offsetHeight || 1056;
4607
+ const isRotated90 = rotation % 180 !== 0;
4608
+ const boxW = Math.round((isRotated90 ? baseH : elW) * zoomLevel);
4609
+ const boxH = Math.round((isRotated90 ? elW : baseH) * zoomLevel);
4610
+ sizer.style.width = `${boxW}px`;
4611
+ sizer.style.height = `${boxH}px`;
4612
+ pre.style.width = `${elW}px`;
4432
4613
  pre.style.transform = `scale(${zoomLevel}) rotate(${rotation}deg)`;
4433
- const scaledH = 1056 * zoomLevel;
4434
- const extraH = Math.max(0, scaledH - 1056);
4435
- pre.style.marginBottom = `${extraH + 32}px`;
4614
+ pre.style.transformOrigin = "center center";
4436
4615
  } else {
4437
4616
  pre.style.transform = `rotate(${rotation}deg)`;
4438
4617
  pre.style.fontSize = `${fontSize}px`;
@@ -4638,16 +4817,56 @@ var ArchivePlugin = class {
4638
4817
  width: 100%;
4639
4818
  height: 100%;
4640
4819
  overflow: auto;
4641
- padding: 24px;
4642
4820
  box-sizing: border-box;
4643
4821
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
4644
- transform-origin: top left;
4645
- transition: transform 0.2s ease;
4646
4822
  `;
4823
+ const scrollWrapper = document.createElement("div");
4824
+ scrollWrapper.className = "fp-archive-scroll-wrapper";
4825
+ scrollWrapper.style.cssText = `
4826
+ min-width: 100%;
4827
+ min-height: 100%;
4828
+ width: max-content;
4829
+ height: max-content;
4830
+ display: flex;
4831
+ justify-content: center;
4832
+ align-items: flex-start;
4833
+ padding: 24px;
4834
+ box-sizing: border-box;
4835
+ `;
4836
+ const sizer = document.createElement("div");
4837
+ sizer.className = "fp-archive-sizer";
4838
+ sizer.style.cssText = `
4839
+ position: relative;
4840
+ flex-shrink: 0;
4841
+ display: flex;
4842
+ justify-content: center;
4843
+ align-items: flex-start;
4844
+ `;
4845
+ const card = document.createElement("div");
4846
+ card.className = "fp-archive-card";
4847
+ card.style.cssText = `
4848
+ width: 900px;
4849
+ box-sizing: border-box;
4850
+ transform-origin: top center;
4851
+ transition: transform 0.15s ease;
4852
+ flex-shrink: 0;
4853
+ `;
4854
+ sizer.appendChild(card);
4855
+ scrollWrapper.appendChild(sizer);
4856
+ wrapper.appendChild(scrollWrapper);
4647
4857
  ctx.container.innerHTML = "";
4648
4858
  ctx.container.style.overflow = "auto";
4649
4859
  ctx.container.appendChild(wrapper);
4650
4860
  let scale = 1;
4861
+ const applyTransform = () => {
4862
+ const boxW = Math.round(900 * scale);
4863
+ const cardH = card.offsetHeight || 600;
4864
+ const boxH = Math.round(cardH * scale);
4865
+ sizer.style.width = `${boxW}px`;
4866
+ sizer.style.height = `${boxH}px`;
4867
+ card.style.transform = `scale(${scale})`;
4868
+ card.style.transformOrigin = "top center";
4869
+ };
4651
4870
  const entries = await new Promise((resolve, reject) => {
4652
4871
  fflate.unzip(new Uint8Array(ctx.buffer), (err, unzipped) => {
4653
4872
  if (err) {
@@ -4671,7 +4890,7 @@ var ArchivePlugin = class {
4671
4890
  });
4672
4891
  const totalUncompressedSize = entries.reduce((acc, e) => acc + e.size, 0);
4673
4892
  const renderUI = (filteredEntries) => {
4674
- wrapper.innerHTML = `
4893
+ card.innerHTML = `
4675
4894
  <div style="max-width: 900px; margin: 0 auto; background: var(--fp-bg, #ffffff); border: 1px solid var(--fp-border, #e5e7eb); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); overflow: hidden;">
4676
4895
  <div style="padding: 16px 20px; background: var(--fp-toolbar-bg, #f9fafb); border-bottom: 1px solid var(--fp-border, #e5e7eb); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;">
4677
4896
  <div>
@@ -4701,7 +4920,7 @@ var ArchivePlugin = class {
4701
4920
  </div>
4702
4921
  </div>
4703
4922
  `;
4704
- const tbody = wrapper.querySelector("#fp-archive-body");
4923
+ const tbody = card.querySelector("#fp-archive-body");
4705
4924
  if (filteredEntries.length === 0) {
4706
4925
  tbody.innerHTML = `<tr><td colspan="3" style="padding: 24px; text-align: center; color: #9ca3af;">No matching files found</td></tr>`;
4707
4926
  } else {
@@ -4730,19 +4949,20 @@ var ArchivePlugin = class {
4730
4949
  }
4731
4950
  });
4732
4951
  });
4733
- const searchInput = wrapper.querySelector("#fp-archive-search");
4952
+ const searchInput = card.querySelector("#fp-archive-search");
4734
4953
  if (searchInput) {
4735
4954
  searchInput.addEventListener("input", () => {
4736
4955
  const q = searchInput.value.toLowerCase().trim();
4737
4956
  const filtered = q ? entries.filter((e) => e.path.toLowerCase().includes(q)) : entries;
4738
4957
  renderUI(filtered);
4739
- const newSearch = wrapper.querySelector("#fp-archive-search");
4958
+ const newSearch = card.querySelector("#fp-archive-search");
4740
4959
  if (newSearch) {
4741
4960
  newSearch.value = q;
4742
4961
  newSearch.focus();
4743
4962
  }
4744
4963
  });
4745
4964
  }
4965
+ applyTransform();
4746
4966
  };
4747
4967
  renderUI(entries);
4748
4968
  const cleanup = () => {
@@ -4754,26 +4974,26 @@ var ArchivePlugin = class {
4754
4974
  destroy: cleanup,
4755
4975
  zoomIn: () => {
4756
4976
  scale += 0.1;
4757
- wrapper.style.transform = `scale(${scale})`;
4977
+ applyTransform();
4758
4978
  },
4759
4979
  zoomOut: () => {
4760
4980
  scale = Math.max(0.3, scale - 0.1);
4761
- wrapper.style.transform = `scale(${scale})`;
4981
+ applyTransform();
4762
4982
  },
4763
4983
  getZoom: () => scale,
4764
4984
  setZoom: (level) => {
4765
4985
  scale = level;
4766
- wrapper.style.transform = `scale(${scale})`;
4986
+ applyTransform();
4767
4987
  },
4768
4988
  fitToPage: () => {
4769
4989
  scale = 1;
4770
- wrapper.style.transform = "scale(1)";
4990
+ applyTransform();
4771
4991
  },
4772
4992
  resetZoom: () => {
4773
4993
  scale = 1;
4774
- wrapper.style.transform = "scale(1)";
4775
- ctx.container.scrollTop = 0;
4776
- ctx.container.scrollLeft = 0;
4994
+ wrapper.scrollTop = 0;
4995
+ wrapper.scrollLeft = 0;
4996
+ applyTransform();
4777
4997
  },
4778
4998
  download: () => {
4779
4999
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -5132,12 +5352,30 @@ var PptxPlugin = class {
5132
5352
  width: 100%;
5133
5353
  height: 100%;
5134
5354
  overflow: auto;
5355
+ box-sizing: border-box;
5356
+ background: var(--fp-bg-canvas, #525659);
5357
+ `;
5358
+ const scrollWrapper = document.createElement("div");
5359
+ scrollWrapper.className = "fp-pptx-scroll-wrapper";
5360
+ scrollWrapper.style.cssText = `
5361
+ min-width: 100%;
5362
+ min-height: 100%;
5363
+ width: max-content;
5364
+ height: max-content;
5135
5365
  display: flex;
5136
5366
  justify-content: center;
5137
- align-items: flex-start;
5367
+ align-items: center;
5138
5368
  padding: 24px;
5139
5369
  box-sizing: border-box;
5140
- background: var(--fp-bg-canvas, #525659);
5370
+ `;
5371
+ const sizer = document.createElement("div");
5372
+ sizer.className = "fp-pptx-sizer";
5373
+ sizer.style.cssText = `
5374
+ position: relative;
5375
+ flex-shrink: 0;
5376
+ display: flex;
5377
+ justify-content: center;
5378
+ align-items: center;
5141
5379
  `;
5142
5380
  const slideContainer = document.createElement("div");
5143
5381
  slideContainer.className = "fp-slide-container";
@@ -5146,14 +5384,15 @@ var PptxPlugin = class {
5146
5384
  border-radius: 4px;
5147
5385
  overflow: hidden;
5148
5386
  background: #ffffff;
5149
- transform-origin: top center;
5387
+ transform-origin: center center;
5150
5388
  transition: transform 0.2s ease;
5151
- max-width: calc(100% - 32px);
5152
- max-height: calc(100% - 48px);
5389
+ flex-shrink: 0;
5153
5390
  `;
5154
5391
  const canvas = document.createElement("canvas");
5155
5392
  slideContainer.appendChild(canvas);
5156
- wrapper.appendChild(slideContainer);
5393
+ sizer.appendChild(slideContainer);
5394
+ scrollWrapper.appendChild(sizer);
5395
+ wrapper.appendChild(scrollWrapper);
5157
5396
  ctx.container.innerHTML = "";
5158
5397
  ctx.container.style.overflow = "auto";
5159
5398
  ctx.container.appendChild(wrapper);
@@ -5165,7 +5404,17 @@ var PptxPlugin = class {
5165
5404
  return Math.min(1, Math.min(availW / cW, availH / cH));
5166
5405
  };
5167
5406
  const applyTransform = () => {
5407
+ const cW = canvas.offsetWidth || 1280;
5408
+ const cH = canvas.offsetHeight || 720;
5409
+ const isRotated90 = rotation % 180 !== 0;
5410
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
5411
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
5412
+ sizer.style.width = `${boxW}px`;
5413
+ sizer.style.height = `${boxH}px`;
5414
+ slideContainer.style.width = `${cW}px`;
5415
+ slideContainer.style.height = `${cH}px`;
5168
5416
  slideContainer.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5417
+ slideContainer.style.transformOrigin = "center center";
5169
5418
  };
5170
5419
  const renderCurrentSlide = async () => {
5171
5420
  try {
@@ -5771,13 +6020,33 @@ var RtfPlugin = class {
5771
6020
  wrapper.style.flexDirection = "column";
5772
6021
  wrapper.style.alignItems = "center";
5773
6022
  wrapper.style.backgroundColor = "transparent";
5774
- wrapper.style.transformOrigin = "top center";
6023
+ wrapper.style.transformOrigin = "center center";
5775
6024
  wrapper.style.transition = "transform 0.15s ease";
5776
- ctx.container.style.overflowX = "hidden";
5777
- ctx.container.style.overflowY = "auto";
5778
- ctx.container.style.padding = "16px 8px";
6025
+ wrapper.style.flexShrink = "0";
6026
+ const sizer = document.createElement("div");
6027
+ sizer.className = "fp-rtf-sizer";
6028
+ sizer.style.position = "relative";
6029
+ sizer.style.flexShrink = "0";
6030
+ sizer.style.display = "flex";
6031
+ sizer.style.justifyContent = "center";
6032
+ sizer.style.alignItems = "center";
6033
+ const scrollWrapper = document.createElement("div");
6034
+ scrollWrapper.className = "fp-rtf-scroll-wrapper";
6035
+ scrollWrapper.style.minWidth = "100%";
6036
+ scrollWrapper.style.minHeight = "100%";
6037
+ scrollWrapper.style.width = "max-content";
6038
+ scrollWrapper.style.height = "max-content";
6039
+ scrollWrapper.style.display = "flex";
6040
+ scrollWrapper.style.justifyContent = "center";
6041
+ scrollWrapper.style.alignItems = "flex-start";
6042
+ scrollWrapper.style.padding = "16px 8px";
6043
+ scrollWrapper.style.boxSizing = "border-box";
6044
+ sizer.appendChild(wrapper);
6045
+ scrollWrapper.appendChild(sizer);
6046
+ ctx.container.style.overflow = "auto";
6047
+ ctx.container.style.padding = "0";
5779
6048
  ctx.container.style.backgroundColor = "#f1f5f9";
5780
- ctx.container.appendChild(wrapper);
6049
+ ctx.container.appendChild(scrollWrapper);
5781
6050
  let scale = 1;
5782
6051
  let rotation = 0;
5783
6052
  let pageElements = [];
@@ -5796,12 +6065,17 @@ var RtfPlugin = class {
5796
6065
  return Math.max(0.4, Math.min(3, sW));
5797
6066
  };
5798
6067
  const applyTransform = () => {
5799
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5800
- wrapper.style.transformOrigin = "top center";
6068
+ const elW = pageWidth;
5801
6069
  const baseH = pageHeight;
5802
- const scaledH = baseH * scale;
5803
- const extraH = Math.max(0, scaledH - baseH);
5804
- wrapper.style.marginBottom = `${extraH + 32}px`;
6070
+ const isRotated90 = rotation % 180 !== 0;
6071
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6072
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6073
+ sizer.style.width = `${boxW}px`;
6074
+ sizer.style.height = `${boxH}px`;
6075
+ wrapper.style.width = `${elW}px`;
6076
+ wrapper.style.height = `${baseH}px`;
6077
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6078
+ wrapper.style.transformOrigin = "center center";
5805
6079
  };
5806
6080
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
5807
6081
  if (!isUserZoomed) {
@@ -6072,7 +6346,7 @@ var RtfPlugin = class {
6072
6346
  }
6073
6347
  const cleanup = () => {
6074
6348
  resizeObserver?.disconnect();
6075
- wrapper.remove();
6349
+ scrollWrapper.remove();
6076
6350
  ctx.container.innerHTML = "";
6077
6351
  };
6078
6352
  ctx.signal.addEventListener("abort", cleanup);
@@ -6247,23 +6521,44 @@ var HtmlPreviewPlugin = class {
6247
6521
  ADD_TAGS: ["style", "link"],
6248
6522
  ADD_ATTR: ["target", "rel"]
6249
6523
  });
6524
+ const sizer = document.createElement("div");
6525
+ sizer.className = "fp-html-sizer";
6526
+ sizer.style.position = "relative";
6250
6527
  const iframe = document.createElement("iframe");
6251
6528
  iframe.className = "fp-html-iframe";
6252
- iframe.style.width = "100%";
6253
- iframe.style.height = "100%";
6254
6529
  iframe.style.border = "none";
6255
6530
  iframe.style.backgroundColor = "#ffffff";
6256
6531
  iframe.style.transformOrigin = "top left";
6257
6532
  iframe.style.transition = "transform 0.2s ease";
6258
6533
  iframe.sandbox.add("allow-same-origin");
6534
+ sizer.appendChild(iframe);
6259
6535
  ctx.container.style.overflow = "auto";
6260
6536
  ctx.container.style.width = "100%";
6261
6537
  ctx.container.style.height = "100%";
6262
- ctx.container.appendChild(iframe);
6538
+ ctx.container.innerHTML = "";
6539
+ ctx.container.appendChild(sizer);
6263
6540
  iframe.srcdoc = sanitized;
6264
6541
  let scale = 1;
6542
+ const applyTransform = () => {
6543
+ const baseW = Math.max(600, ctx.container.clientWidth || 800);
6544
+ const baseH = Math.max(400, ctx.container.clientHeight || 600);
6545
+ const scaledW = Math.round(baseW * scale);
6546
+ const scaledH = Math.round(baseH * scale);
6547
+ sizer.style.width = `${scaledW}px`;
6548
+ sizer.style.height = `${scaledH}px`;
6549
+ iframe.style.position = "absolute";
6550
+ iframe.style.top = "0";
6551
+ iframe.style.left = "0";
6552
+ iframe.style.width = `${baseW}px`;
6553
+ iframe.style.height = `${baseH}px`;
6554
+ iframe.style.transform = `scale(${scale})`;
6555
+ iframe.style.transformOrigin = "top left";
6556
+ };
6557
+ requestAnimationFrame(() => {
6558
+ applyTransform();
6559
+ });
6265
6560
  const cleanup = () => {
6266
- iframe.remove();
6561
+ sizer.remove();
6267
6562
  ctx.container.innerHTML = "";
6268
6563
  };
6269
6564
  ctx.signal.addEventListener("abort", cleanup);
@@ -6271,26 +6566,26 @@ var HtmlPreviewPlugin = class {
6271
6566
  destroy: cleanup,
6272
6567
  zoomIn: () => {
6273
6568
  scale += 0.1;
6274
- iframe.style.transform = `scale(${scale})`;
6569
+ applyTransform();
6275
6570
  },
6276
6571
  zoomOut: () => {
6277
6572
  scale = Math.max(0.2, scale - 0.1);
6278
- iframe.style.transform = `scale(${scale})`;
6573
+ applyTransform();
6279
6574
  },
6280
6575
  getZoom: () => scale,
6281
6576
  setZoom: (level) => {
6282
6577
  scale = level;
6283
- iframe.style.transform = `scale(${scale})`;
6578
+ applyTransform();
6284
6579
  },
6285
6580
  fitToPage: () => {
6286
6581
  scale = 1;
6287
- iframe.style.transform = "scale(1)";
6582
+ applyTransform();
6288
6583
  },
6289
6584
  resetZoom: () => {
6290
6585
  scale = 1;
6291
- iframe.style.transform = "scale(1)";
6292
6586
  ctx.container.scrollTop = 0;
6293
6587
  ctx.container.scrollLeft = 0;
6588
+ applyTransform();
6294
6589
  },
6295
6590
  copy: () => {
6296
6591
  navigator.clipboard.writeText(rawHtml);
@@ -6465,10 +6760,26 @@ var OpenDocumentPlugin = class {
6465
6760
  container.className = "fp-odf-container";
6466
6761
  container.style.width = "100%";
6467
6762
  container.style.height = "100%";
6468
- container.style.overflowX = "hidden";
6469
- container.style.overflowY = "auto";
6470
- container.style.padding = "16px 8px";
6763
+ container.style.overflow = "auto";
6471
6764
  container.style.backgroundColor = "#f1f5f9";
6765
+ const scrollWrapper = document.createElement("div");
6766
+ scrollWrapper.className = "fp-odf-scroll-wrapper";
6767
+ scrollWrapper.style.minWidth = "100%";
6768
+ scrollWrapper.style.minHeight = "100%";
6769
+ scrollWrapper.style.width = "max-content";
6770
+ scrollWrapper.style.height = "max-content";
6771
+ scrollWrapper.style.display = "flex";
6772
+ scrollWrapper.style.justifyContent = "center";
6773
+ scrollWrapper.style.alignItems = "flex-start";
6774
+ scrollWrapper.style.padding = "16px 8px";
6775
+ scrollWrapper.style.boxSizing = "border-box";
6776
+ const sizer = document.createElement("div");
6777
+ sizer.className = "fp-odf-sizer";
6778
+ sizer.style.position = "relative";
6779
+ sizer.style.flexShrink = "0";
6780
+ sizer.style.display = "flex";
6781
+ sizer.style.justifyContent = "center";
6782
+ sizer.style.alignItems = "center";
6472
6783
  const wrapper = document.createElement("div");
6473
6784
  wrapper.className = "fp-odf-wrapper";
6474
6785
  wrapper.style.margin = "0 auto";
@@ -6477,9 +6788,12 @@ var OpenDocumentPlugin = class {
6477
6788
  wrapper.style.backgroundColor = "#ffffff";
6478
6789
  wrapper.style.boxShadow = "0 2px 10px rgba(0,0,0,0.08)";
6479
6790
  wrapper.style.borderRadius = "4px";
6480
- wrapper.style.transformOrigin = "top center";
6791
+ wrapper.style.transformOrigin = "center center";
6481
6792
  wrapper.style.transition = "transform 0.15s ease";
6482
- container.appendChild(wrapper);
6793
+ wrapper.style.flexShrink = "0";
6794
+ sizer.appendChild(wrapper);
6795
+ scrollWrapper.appendChild(sizer);
6796
+ container.appendChild(scrollWrapper);
6483
6797
  ctx.container.appendChild(container);
6484
6798
  let scale = 1;
6485
6799
  let rotation = 0;
@@ -6505,13 +6819,18 @@ var OpenDocumentPlugin = class {
6505
6819
  return Math.max(0.4, Math.min(3, sW));
6506
6820
  };
6507
6821
  const applyTransform = () => {
6508
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6509
- wrapper.style.transformOrigin = "top center";
6510
6822
  const activeSlide = slides[currentPage - 1];
6823
+ const elW = isPresentation ? 960 : 816;
6511
6824
  const baseH = activeSlide?.offsetHeight || wrapper.offsetHeight || 1056;
6512
- const scaledH = baseH * scale;
6513
- const extraH = Math.max(0, scaledH - baseH);
6514
- wrapper.style.marginBottom = `${extraH + 32}px`;
6825
+ const isRotated90 = rotation % 180 !== 0;
6826
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6827
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6828
+ sizer.style.width = `${boxW}px`;
6829
+ sizer.style.height = `${boxH}px`;
6830
+ wrapper.style.width = `${elW}px`;
6831
+ wrapper.style.height = `${baseH}px`;
6832
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6833
+ wrapper.style.transformOrigin = "center center";
6515
6834
  };
6516
6835
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
6517
6836
  if (!isUserZoomed) {
@@ -7075,13 +7394,28 @@ var DocPlugin = class {
7075
7394
  container.className = "fp-doc-container";
7076
7395
  container.style.width = "100%";
7077
7396
  container.style.height = "100%";
7078
- container.style.overflowX = "hidden";
7079
- container.style.overflowY = "auto";
7080
- container.style.padding = "16px 8px";
7397
+ container.style.overflow = "auto";
7081
7398
  container.style.backgroundColor = "#f1f5f9";
7082
- container.style.display = "flex";
7083
- container.style.justifyContent = "center";
7084
- container.style.alignItems = "flex-start";
7399
+ const scrollWrapper = document.createElement("div");
7400
+ scrollWrapper.className = "fp-doc-scroll-wrapper";
7401
+ scrollWrapper.style.minWidth = "100%";
7402
+ scrollWrapper.style.minHeight = "100%";
7403
+ scrollWrapper.style.width = "max-content";
7404
+ scrollWrapper.style.height = "max-content";
7405
+ scrollWrapper.style.display = "flex";
7406
+ scrollWrapper.style.justifyContent = "center";
7407
+ scrollWrapper.style.alignItems = "flex-start";
7408
+ scrollWrapper.style.padding = "16px 8px";
7409
+ scrollWrapper.style.boxSizing = "border-box";
7410
+ const sizer = document.createElement("div");
7411
+ sizer.className = "fp-doc-sizer";
7412
+ sizer.style.position = "relative";
7413
+ sizer.style.flexShrink = "0";
7414
+ sizer.style.display = "flex";
7415
+ sizer.style.justifyContent = "center";
7416
+ sizer.style.alignItems = "center";
7417
+ scrollWrapper.appendChild(sizer);
7418
+ container.appendChild(scrollWrapper);
7085
7419
  ctx.container.appendChild(container);
7086
7420
  let scale = 1;
7087
7421
  let extractedRawText = "";
@@ -7129,10 +7463,11 @@ var DocPlugin = class {
7129
7463
  pageCard.style.padding = "72px 56px";
7130
7464
  pageCard.style.boxSizing = "border-box";
7131
7465
  pageCard.style.display = i === 0 ? "block" : "none";
7132
- pageCard.style.transformOrigin = "top center";
7466
+ pageCard.style.transformOrigin = "center center";
7133
7467
  pageCard.style.transition = "transform 0.15s ease";
7134
7468
  pageCard.style.fontFamily = 'Calibri, "Segoe UI", Arial, sans-serif';
7135
7469
  pageCard.style.color = "#1e293b";
7470
+ pageCard.style.flexShrink = "0";
7136
7471
  if (isFallback && i === 0) {
7137
7472
  pageCard.innerHTML = `
7138
7473
  <div style="border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 24px;">
@@ -7144,18 +7479,23 @@ var DocPlugin = class {
7144
7479
  } else {
7145
7480
  pageCard.innerHTML = this.formatDocToHtml(rawPages[i], ctx.metadata.name || "Document");
7146
7481
  }
7147
- container.appendChild(pageCard);
7482
+ sizer.appendChild(pageCard);
7148
7483
  pageCards.push(pageCard);
7149
7484
  }
7150
7485
  let rotation = 0;
7151
7486
  const applyTransform = () => {
7152
7487
  const activeCard = pageCards[currentPage - 1];
7153
7488
  if (activeCard) {
7154
- activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7489
+ const baseW = 816;
7155
7490
  const baseH = activeCard.offsetHeight || 1056;
7156
- const scaledH = baseH * scale;
7157
- const extraH = Math.max(0, scaledH - baseH);
7158
- activeCard.style.marginBottom = `${extraH + 32}px`;
7491
+ const isRotated90 = rotation % 180 !== 0;
7492
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * scale);
7493
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * scale);
7494
+ sizer.style.width = `${boxW}px`;
7495
+ sizer.style.height = `${boxH}px`;
7496
+ activeCard.style.width = `${baseW}px`;
7497
+ activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7498
+ activeCard.style.transformOrigin = "center center";
7159
7499
  }
7160
7500
  };
7161
7501
  const showPage = (pageNum) => {
@@ -7163,11 +7503,11 @@ var DocPlugin = class {
7163
7503
  pageCards.forEach((card, idx) => {
7164
7504
  if (idx + 1 === currentPage) {
7165
7505
  card.style.display = "block";
7166
- card.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7167
7506
  } else {
7168
7507
  card.style.display = "none";
7169
7508
  }
7170
7509
  });
7510
+ applyTransform();
7171
7511
  container.scrollTop = 0;
7172
7512
  ctx.emit("page-change", { page: currentPage, total: totalPages });
7173
7513
  };
@@ -7238,6 +7578,8 @@ var DocPlugin = class {
7238
7578
  fitMode = "width";
7239
7579
  scale = calculateFitScale("width");
7240
7580
  rotation = 0;
7581
+ container.scrollTop = 0;
7582
+ container.scrollLeft = 0;
7241
7583
  ctx.container.scrollTop = 0;
7242
7584
  ctx.container.scrollLeft = 0;
7243
7585
  applyTransform();
@@ -7762,17 +8104,30 @@ var PptPlugin = class {
7762
8104
  container.style.width = "100%";
7763
8105
  container.style.height = "100%";
7764
8106
  container.style.overflow = "auto";
7765
- container.style.display = "flex";
7766
- container.style.justifyContent = "center";
7767
- container.style.alignItems = "center";
7768
- container.style.padding = "32px 16px";
7769
8107
  container.style.backgroundColor = "#0f172a";
7770
8108
  container.style.boxSizing = "border-box";
8109
+ const scrollWrapper = document.createElement("div");
8110
+ scrollWrapper.className = "fp-ppt-scroll-wrapper";
8111
+ scrollWrapper.style.minWidth = "100%";
8112
+ scrollWrapper.style.minHeight = "100%";
8113
+ scrollWrapper.style.width = "max-content";
8114
+ scrollWrapper.style.height = "max-content";
8115
+ scrollWrapper.style.display = "flex";
8116
+ scrollWrapper.style.justifyContent = "center";
8117
+ scrollWrapper.style.alignItems = "center";
8118
+ scrollWrapper.style.padding = "32px 16px";
8119
+ scrollWrapper.style.boxSizing = "border-box";
8120
+ const sizer = document.createElement("div");
8121
+ sizer.className = "fp-ppt-sizer";
8122
+ sizer.style.position = "relative";
8123
+ sizer.style.flexShrink = "0";
8124
+ sizer.style.display = "flex";
8125
+ sizer.style.justifyContent = "center";
8126
+ sizer.style.alignItems = "center";
7771
8127
  const slideCard = document.createElement("div");
7772
8128
  slideCard.className = "fp-ppt-slide-card";
7773
8129
  slideCard.style.width = "960px";
7774
- slideCard.style.maxWidth = "calc(100% - 32px)";
7775
- slideCard.style.maxHeight = "calc(100% - 48px)";
8130
+ slideCard.style.height = "540px";
7776
8131
  slideCard.style.aspectRatio = "16 / 9";
7777
8132
  slideCard.style.backgroundColor = "#ffffff";
7778
8133
  slideCard.style.boxShadow = "0 12px 40px rgba(0,0,0,0.35)";
@@ -7782,7 +8137,9 @@ var PptPlugin = class {
7782
8137
  slideCard.style.transition = "transform 0.2s ease";
7783
8138
  slideCard.style.transformOrigin = "center center";
7784
8139
  slideCard.style.flexShrink = "0";
7785
- container.appendChild(slideCard);
8140
+ sizer.appendChild(slideCard);
8141
+ scrollWrapper.appendChild(sizer);
8142
+ container.appendChild(scrollWrapper);
7786
8143
  ctx.container.appendChild(container);
7787
8144
  let scale = 1;
7788
8145
  let rotation = 0;
@@ -7795,7 +8152,17 @@ var PptPlugin = class {
7795
8152
  return Math.min(1, Math.min(availW / 960, availH / 540));
7796
8153
  };
7797
8154
  const applyTransform = () => {
8155
+ const cW = 960;
8156
+ const cH = 540;
8157
+ const isRotated90 = rotation % 180 !== 0;
8158
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
8159
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
8160
+ sizer.style.width = `${boxW}px`;
8161
+ sizer.style.height = `${boxH}px`;
8162
+ slideCard.style.width = `${cW}px`;
8163
+ slideCard.style.height = `${cH}px`;
7798
8164
  slideCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
8165
+ slideCard.style.transformOrigin = "center center";
7799
8166
  };
7800
8167
  setTimeout(() => {
7801
8168
  scale = calculateFitScale();