@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/index.js CHANGED
@@ -2168,16 +2168,22 @@ var PdfPlugin = class {
2168
2168
  container.className = "fp-pdf-container";
2169
2169
  container.style.width = "100%";
2170
2170
  container.style.height = "100%";
2171
- container.style.overflowX = "hidden";
2172
- container.style.overflowY = "auto";
2173
- container.style.display = "flex";
2174
- container.style.flexDirection = "column";
2175
- container.style.alignItems = "center";
2176
- container.style.justifyContent = "flex-start";
2177
- container.style.padding = "16px 8px";
2171
+ container.style.overflow = "auto";
2178
2172
  container.style.backgroundColor = "#0f172a";
2179
2173
  container.style.boxSizing = "border-box";
2180
2174
  container.style.position = "relative";
2175
+ const scrollWrapper = document.createElement("div");
2176
+ scrollWrapper.className = "fp-pdf-scroll-wrapper";
2177
+ scrollWrapper.style.minWidth = "100%";
2178
+ scrollWrapper.style.minHeight = "100%";
2179
+ scrollWrapper.style.width = "max-content";
2180
+ scrollWrapper.style.height = "max-content";
2181
+ scrollWrapper.style.display = "flex";
2182
+ scrollWrapper.style.flexDirection = "column";
2183
+ scrollWrapper.style.alignItems = "center";
2184
+ scrollWrapper.style.justifyContent = "flex-start";
2185
+ scrollWrapper.style.padding = "16px 8px";
2186
+ scrollWrapper.style.boxSizing = "border-box";
2181
2187
  const pageCard = document.createElement("div");
2182
2188
  pageCard.className = "fp-pdf-page-card";
2183
2189
  pageCard.style.boxShadow = "0 10px 35px rgba(0, 0, 0, 0.5)";
@@ -2190,7 +2196,8 @@ var PdfPlugin = class {
2190
2196
  pageCard.style.transition = "box-shadow 0.2s ease";
2191
2197
  let canvas = document.createElement("canvas");
2192
2198
  pageCard.appendChild(canvas);
2193
- container.appendChild(pageCard);
2199
+ scrollWrapper.appendChild(pageCard);
2200
+ container.appendChild(scrollWrapper);
2194
2201
  ctx.container.appendChild(container);
2195
2202
  const standardFontsUrl = typeof window !== "undefined" && window.__PDF_STANDARD_FONTS_URL__ || "./standard_fonts/";
2196
2203
  const cmapsUrl = typeof window !== "undefined" && window.__PDF_CMAPS_URL__ || "./cmaps/";
@@ -2699,17 +2706,86 @@ var MediaPlugin = class {
2699
2706
  element = document.createElement("div");
2700
2707
  element.textContent = "Unsupported media type";
2701
2708
  }
2702
- ctx.container.style.display = "flex";
2703
- ctx.container.style.alignItems = "center";
2704
- ctx.container.style.justifyContent = "center";
2705
- ctx.container.style.overflow = "hidden";
2706
- ctx.container.appendChild(element);
2709
+ const scrollWrapper = document.createElement("div");
2710
+ scrollWrapper.className = "fp-media-scroll-wrapper";
2711
+ scrollWrapper.style.minWidth = "100%";
2712
+ scrollWrapper.style.minHeight = "100%";
2713
+ scrollWrapper.style.width = "max-content";
2714
+ scrollWrapper.style.height = "max-content";
2715
+ scrollWrapper.style.display = "flex";
2716
+ scrollWrapper.style.justifyContent = "center";
2717
+ scrollWrapper.style.alignItems = "center";
2718
+ scrollWrapper.style.padding = "16px";
2719
+ scrollWrapper.style.boxSizing = "border-box";
2720
+ const sizer = document.createElement("div");
2721
+ sizer.className = "fp-media-sizer";
2722
+ sizer.style.position = "relative";
2723
+ sizer.style.flexShrink = "0";
2724
+ sizer.style.display = "flex";
2725
+ sizer.style.justifyContent = "center";
2726
+ sizer.style.alignItems = "center";
2727
+ sizer.appendChild(element);
2728
+ scrollWrapper.appendChild(sizer);
2729
+ ctx.container.style.overflow = "auto";
2730
+ ctx.container.style.padding = "0";
2731
+ ctx.container.innerHTML = "";
2732
+ ctx.container.appendChild(scrollWrapper);
2733
+ let naturalW = 800;
2734
+ let naturalH = 600;
2735
+ let baseW = 800;
2736
+ let baseH = 600;
2737
+ const updateBaseDimensions = () => {
2738
+ if (!isImage) return;
2739
+ const img = element;
2740
+ naturalW = img.naturalWidth || naturalW;
2741
+ naturalH = img.naturalHeight || naturalH;
2742
+ const availW = Math.max(100, ctx.container.clientWidth - 48);
2743
+ const availH = Math.max(100, ctx.container.clientHeight - 48);
2744
+ const fitRatio = Math.min(1, availW / naturalW, availH / naturalH);
2745
+ baseW = Math.max(1, Math.round(naturalW * fitRatio));
2746
+ baseH = Math.max(1, Math.round(naturalH * fitRatio));
2747
+ };
2707
2748
  const applyTransform = () => {
2708
- element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2749
+ if (isImage) {
2750
+ updateBaseDimensions();
2751
+ const isRotated90 = rotation % 180 !== 0;
2752
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * currentZoom);
2753
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * currentZoom);
2754
+ sizer.style.width = `${boxW}px`;
2755
+ sizer.style.height = `${boxH}px`;
2756
+ element.style.width = `${baseW}px`;
2757
+ element.style.height = `${baseH}px`;
2758
+ element.style.maxWidth = "none";
2759
+ element.style.maxHeight = "none";
2760
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2761
+ element.style.transformOrigin = "center center";
2762
+ element.style.flexShrink = "0";
2763
+ } else {
2764
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2765
+ }
2709
2766
  };
2767
+ if (isImage) {
2768
+ const img = element;
2769
+ if (img.complete && img.naturalWidth > 0) {
2770
+ updateBaseDimensions();
2771
+ applyTransform();
2772
+ } else {
2773
+ img.onload = () => {
2774
+ updateBaseDimensions();
2775
+ applyTransform();
2776
+ };
2777
+ }
2778
+ }
2779
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
2780
+ if (currentZoom === 1) {
2781
+ applyTransform();
2782
+ }
2783
+ }) : null;
2784
+ ro?.observe(ctx.container);
2710
2785
  const cleanup = () => {
2786
+ ro?.disconnect();
2711
2787
  if (url) URL.revokeObjectURL(url);
2712
- element.remove();
2788
+ scrollWrapper.remove();
2713
2789
  ctx.container.innerHTML = "";
2714
2790
  };
2715
2791
  ctx.signal.addEventListener("abort", cleanup);
@@ -2902,7 +2978,7 @@ var DocxPlugin = class {
2902
2978
  async render(ctx) {
2903
2979
  const wrapper = document.createElement("div");
2904
2980
  wrapper.className = "fp-docx-wrapper";
2905
- wrapper.style.transformOrigin = "top center";
2981
+ wrapper.style.transformOrigin = "center center";
2906
2982
  wrapper.style.transition = "transform 0.2s ease";
2907
2983
  wrapper.style.padding = "0";
2908
2984
  wrapper.style.maxWidth = "none";
@@ -2912,11 +2988,31 @@ var DocxPlugin = class {
2912
2988
  wrapper.style.flexDirection = "column";
2913
2989
  wrapper.style.alignItems = "center";
2914
2990
  wrapper.style.boxSizing = "border-box";
2915
- ctx.container.style.overflowX = "hidden";
2916
- ctx.container.style.overflowY = "auto";
2917
- ctx.container.style.padding = "16px 8px";
2991
+ wrapper.style.flexShrink = "0";
2992
+ const sizer = document.createElement("div");
2993
+ sizer.className = "fp-docx-sizer";
2994
+ sizer.style.position = "relative";
2995
+ sizer.style.flexShrink = "0";
2996
+ sizer.style.display = "flex";
2997
+ sizer.style.justifyContent = "center";
2998
+ sizer.style.alignItems = "center";
2999
+ const scrollWrapper = document.createElement("div");
3000
+ scrollWrapper.className = "fp-docx-scroll-wrapper";
3001
+ scrollWrapper.style.minWidth = "100%";
3002
+ scrollWrapper.style.minHeight = "100%";
3003
+ scrollWrapper.style.width = "max-content";
3004
+ scrollWrapper.style.height = "max-content";
3005
+ scrollWrapper.style.display = "flex";
3006
+ scrollWrapper.style.justifyContent = "center";
3007
+ scrollWrapper.style.alignItems = "flex-start";
3008
+ scrollWrapper.style.padding = "16px 8px";
3009
+ scrollWrapper.style.boxSizing = "border-box";
3010
+ sizer.appendChild(wrapper);
3011
+ scrollWrapper.appendChild(sizer);
3012
+ ctx.container.style.overflow = "auto";
3013
+ ctx.container.style.padding = "0";
2918
3014
  ctx.container.style.backgroundColor = "#f1f5f9";
2919
- ctx.container.appendChild(wrapper);
3015
+ ctx.container.appendChild(scrollWrapper);
2920
3016
  const styleOverride = document.createElement("style");
2921
3017
  styleOverride.textContent = `
2922
3018
  .fp-docx-wrapper .docx-wrapper {
@@ -2955,8 +3051,8 @@ var DocxPlugin = class {
2955
3051
  renderEndnotes: true,
2956
3052
  useBase64URL: true
2957
3053
  });
2958
- if (!ctx.container.contains(wrapper)) {
2959
- ctx.container.appendChild(wrapper);
3054
+ if (!sizer.contains(wrapper)) {
3055
+ sizer.appendChild(wrapper);
2960
3056
  }
2961
3057
  if (wrapper.children.length > 0 && (wrapper.textContent?.trim().length ?? 0) > 0) {
2962
3058
  renderedSuccessfully = true;
@@ -2993,8 +3089,8 @@ var DocxPlugin = class {
2993
3089
  try {
2994
3090
  wrapper.innerHTML = "";
2995
3091
  this.renderXmlFallback(ctx, wrapper, createdBlobUrls);
2996
- if (!ctx.container.contains(wrapper)) {
2997
- ctx.container.appendChild(wrapper);
3092
+ if (!sizer.contains(wrapper)) {
3093
+ sizer.appendChild(wrapper);
2998
3094
  }
2999
3095
  renderedSuccessfully = true;
3000
3096
  } catch (fallbackErr) {
@@ -3009,8 +3105,8 @@ var DocxPlugin = class {
3009
3105
  </p>
3010
3106
  </div>
3011
3107
  `;
3012
- if (!ctx.container.contains(wrapper)) {
3013
- ctx.container.appendChild(wrapper);
3108
+ if (!sizer.contains(wrapper)) {
3109
+ sizer.appendChild(wrapper);
3014
3110
  }
3015
3111
  }
3016
3112
  }
@@ -3113,15 +3209,18 @@ var DocxPlugin = class {
3113
3209
  return Math.max(0.35, Math.min(3, sW));
3114
3210
  };
3115
3211
  const applyTransform = () => {
3116
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3117
- wrapper.style.transformOrigin = "top center";
3118
3212
  const activeEl = pageElements[currentPage - 1] || wrapper.querySelector("section.docx") || wrapper;
3213
+ const elW = activeEl.offsetWidth || 816;
3119
3214
  const elH = activeEl.offsetHeight || 1056;
3120
- if (scale > 1) {
3121
- wrapper.style.marginBottom = `${Math.round(elH * scale - elH + 32)}px`;
3122
- } else {
3123
- wrapper.style.marginBottom = "32px";
3124
- }
3215
+ const isRotated90 = rotation % 180 !== 0;
3216
+ const boxW = Math.round((isRotated90 ? elH : elW) * scale);
3217
+ const boxH = Math.round((isRotated90 ? elW : elH) * scale);
3218
+ sizer.style.width = `${boxW}px`;
3219
+ sizer.style.height = `${boxH}px`;
3220
+ wrapper.style.width = `${elW}px`;
3221
+ wrapper.style.height = `${elH}px`;
3222
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3223
+ wrapper.style.transformOrigin = "center center";
3125
3224
  };
3126
3225
  let resizeObserver = null;
3127
3226
  if (typeof ResizeObserver !== "undefined") {
@@ -3146,7 +3245,7 @@ var DocxPlugin = class {
3146
3245
  for (const url of createdBlobUrls) {
3147
3246
  URL.revokeObjectURL(url);
3148
3247
  }
3149
- wrapper.remove();
3248
+ scrollWrapper.remove();
3150
3249
  styleOverride.remove();
3151
3250
  ctx.container.innerHTML = "";
3152
3251
  };
@@ -3693,7 +3792,7 @@ var ExcelPlugin = class {
3693
3792
  contentArea.style.flex = "1";
3694
3793
  contentArea.style.overflow = "auto";
3695
3794
  contentArea.style.padding = "16px";
3696
- contentArea.style.transformOrigin = "top left";
3795
+ contentArea.style.boxSizing = "border-box";
3697
3796
  const tabsArea = document.createElement("div");
3698
3797
  tabsArea.className = "fp-excel-tabs";
3699
3798
  tabsArea.style.display = "flex";
@@ -3707,18 +3806,35 @@ var ExcelPlugin = class {
3707
3806
  container.appendChild(tabsArea);
3708
3807
  ctx.container.appendChild(container);
3709
3808
  let scale = 1;
3809
+ let isUserZoomed = false;
3710
3810
  let currentSheetIndex = 1;
3711
3811
  let sheetNames = [];
3712
3812
  let wb = null;
3713
3813
  const applyTransform = () => {
3714
- contentArea.style.transform = `scale(${scale})`;
3715
- contentArea.style.transformOrigin = "top left";
3814
+ const sizer = contentArea.querySelector(".fp-excel-sizer");
3815
+ const table = contentArea.querySelector("table");
3816
+ if (!sizer || !table) return;
3817
+ if (!table._baseWidth && table.offsetWidth > 0) {
3818
+ table._baseWidth = table.offsetWidth;
3819
+ table._baseHeight = table.offsetHeight;
3820
+ }
3821
+ const baseW = table._baseWidth || table.offsetWidth || 800;
3822
+ const baseH = table._baseHeight || table.offsetHeight || 600;
3823
+ const scaledW = Math.round(baseW * scale);
3824
+ const scaledH = Math.round(baseH * scale);
3825
+ sizer.style.width = `${scaledW}px`;
3826
+ sizer.style.height = `${scaledH}px`;
3827
+ table.style.position = "absolute";
3828
+ table.style.top = "0";
3829
+ table.style.left = "0";
3830
+ table.style.transform = `scale(${scale})`;
3831
+ table.style.transformOrigin = "top left";
3716
3832
  };
3717
3833
  const calculateFitScale = () => {
3718
3834
  const table = contentArea.querySelector("table");
3719
3835
  if (!table) return 1;
3720
3836
  const availW = Math.max(280, container.clientWidth - 48);
3721
- const tW = table.offsetWidth || 800;
3837
+ const tW = table._baseWidth || table.offsetWidth || 800;
3722
3838
  return Math.max(0.4, Math.min(1, availW / tW));
3723
3839
  };
3724
3840
  try {
@@ -3738,9 +3854,13 @@ var ExcelPlugin = class {
3738
3854
  contentArea.innerHTML = '<div style="padding: 24px; color: #888;">Empty sheet</div>';
3739
3855
  return;
3740
3856
  }
3857
+ const sizer = document.createElement("div");
3858
+ sizer.className = "fp-excel-sizer";
3859
+ sizer.style.position = "relative";
3741
3860
  const html = XLSX.utils.sheet_to_html(ws, { id: "fp-sheet-table", editable: false });
3742
- contentArea.innerHTML = html;
3743
- const table = contentArea.querySelector("table");
3861
+ sizer.innerHTML = html;
3862
+ contentArea.appendChild(sizer);
3863
+ const table = sizer.querySelector("table");
3744
3864
  if (table) {
3745
3865
  table.style.borderCollapse = "collapse";
3746
3866
  table.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
@@ -3775,13 +3895,17 @@ var ExcelPlugin = class {
3775
3895
  });
3776
3896
  ctx.emit("page-change", { page: currentSheetIndex, total: sheetNames.length });
3777
3897
  requestAnimationFrame(() => {
3778
- scale = calculateFitScale();
3898
+ if (!isUserZoomed) {
3899
+ scale = calculateFitScale();
3900
+ }
3779
3901
  applyTransform();
3780
3902
  });
3781
3903
  };
3782
3904
  const ro = new ResizeObserver(() => {
3783
- scale = calculateFitScale();
3784
- applyTransform();
3905
+ if (!isUserZoomed) {
3906
+ scale = calculateFitScale();
3907
+ applyTransform();
3908
+ }
3785
3909
  });
3786
3910
  ro.observe(container);
3787
3911
  if (sheetNames.length > 0) {
@@ -3818,23 +3942,28 @@ var ExcelPlugin = class {
3818
3942
  return {
3819
3943
  destroy: cleanup,
3820
3944
  zoomIn: () => {
3945
+ isUserZoomed = true;
3821
3946
  scale += 0.15;
3822
3947
  applyTransform();
3823
3948
  },
3824
3949
  zoomOut: () => {
3950
+ isUserZoomed = true;
3825
3951
  scale = Math.max(0.2, scale - 0.15);
3826
3952
  applyTransform();
3827
3953
  },
3828
3954
  getZoom: () => scale,
3829
3955
  setZoom: (level) => {
3956
+ isUserZoomed = true;
3830
3957
  scale = level;
3831
3958
  applyTransform();
3832
3959
  },
3833
3960
  fitToPage: () => {
3961
+ isUserZoomed = false;
3834
3962
  scale = calculateFitScale();
3835
3963
  applyTransform();
3836
3964
  },
3837
3965
  resetZoom: () => {
3966
+ isUserZoomed = false;
3838
3967
  scale = calculateFitScale();
3839
3968
  contentArea.scrollTop = 0;
3840
3969
  contentArea.scrollLeft = 0;
@@ -4066,21 +4195,41 @@ var CsvPlugin = class {
4066
4195
  container.appendChild(tableWrapper);
4067
4196
  ctx.container.appendChild(container);
4068
4197
  let scale = 1;
4198
+ let isUserZoomed = false;
4069
4199
  const calculateFitScale = () => {
4070
4200
  const availW = Math.max(280, container.clientWidth - 48);
4071
- const tW = table.offsetWidth || 800;
4201
+ const tW = table._baseWidth || table.offsetWidth || 800;
4072
4202
  return Math.max(0.4, Math.min(1, availW / tW));
4073
4203
  };
4074
4204
  const applyScale = () => {
4075
- tableWrapper.style.transform = `scale(${scale})`;
4205
+ if (!table._baseWidth && table.offsetWidth > 0) {
4206
+ table._baseWidth = table.offsetWidth;
4207
+ table._baseHeight = table.offsetHeight;
4208
+ }
4209
+ const baseW = table._baseWidth || table.offsetWidth || 800;
4210
+ const baseH = table._baseHeight || table.offsetHeight || 600;
4211
+ const scaledW = Math.round(baseW * scale);
4212
+ const scaledH = Math.round(baseH * scale);
4213
+ tableWrapper.style.position = "relative";
4214
+ tableWrapper.style.width = `${scaledW}px`;
4215
+ tableWrapper.style.height = `${scaledH}px`;
4216
+ table.style.position = "absolute";
4217
+ table.style.top = "0";
4218
+ table.style.left = "0";
4219
+ table.style.transform = `scale(${scale})`;
4220
+ table.style.transformOrigin = "top left";
4076
4221
  };
4077
4222
  requestAnimationFrame(() => {
4078
- scale = calculateFitScale();
4223
+ if (!isUserZoomed) {
4224
+ scale = calculateFitScale();
4225
+ }
4079
4226
  applyScale();
4080
4227
  });
4081
4228
  const ro = new ResizeObserver(() => {
4082
- scale = calculateFitScale();
4083
- applyScale();
4229
+ if (!isUserZoomed) {
4230
+ scale = calculateFitScale();
4231
+ applyScale();
4232
+ }
4084
4233
  });
4085
4234
  ro.observe(container);
4086
4235
  const cleanup = () => {
@@ -4153,23 +4302,28 @@ var CsvPlugin = class {
4153
4302
  }];
4154
4303
  },
4155
4304
  zoomIn: () => {
4305
+ isUserZoomed = true;
4156
4306
  scale += 0.1;
4157
4307
  applyScale();
4158
4308
  },
4159
4309
  zoomOut: () => {
4310
+ isUserZoomed = true;
4160
4311
  scale = Math.max(0.2, scale - 0.1);
4161
4312
  applyScale();
4162
4313
  },
4163
4314
  getZoom: () => scale,
4164
4315
  setZoom: (level) => {
4316
+ isUserZoomed = true;
4165
4317
  scale = level;
4166
4318
  applyScale();
4167
4319
  },
4168
4320
  fitToPage: () => {
4321
+ isUserZoomed = false;
4169
4322
  scale = calculateFitScale();
4170
4323
  applyScale();
4171
4324
  },
4172
4325
  resetZoom: () => {
4326
+ isUserZoomed = false;
4173
4327
  scale = calculateFitScale();
4174
4328
  container.scrollTop = 0;
4175
4329
  container.scrollLeft = 0;
@@ -4405,15 +4559,27 @@ var CodePlugin = class {
4405
4559
  let isUserZoomed = false;
4406
4560
  const pre = document.createElement("pre");
4407
4561
  const code = document.createElement("code");
4562
+ const sizer = document.createElement("div");
4563
+ const scrollWrapper = document.createElement("div");
4408
4564
  if (isTxt) {
4409
- container.style.overflowX = "hidden";
4410
- container.style.overflowY = "auto";
4565
+ container.style.overflow = "auto";
4411
4566
  container.style.backgroundColor = "#f1f5f9";
4412
- container.style.padding = "16px 8px";
4413
- container.style.boxSizing = "border-box";
4414
- container.style.display = "flex";
4415
- container.style.flexDirection = "column";
4416
- container.style.alignItems = "center";
4567
+ scrollWrapper.className = "fp-code-scroll-wrapper";
4568
+ scrollWrapper.style.minWidth = "100%";
4569
+ scrollWrapper.style.minHeight = "100%";
4570
+ scrollWrapper.style.width = "max-content";
4571
+ scrollWrapper.style.height = "max-content";
4572
+ scrollWrapper.style.display = "flex";
4573
+ scrollWrapper.style.justifyContent = "center";
4574
+ scrollWrapper.style.alignItems = "flex-start";
4575
+ scrollWrapper.style.padding = "16px 8px";
4576
+ scrollWrapper.style.boxSizing = "border-box";
4577
+ sizer.className = "fp-code-sizer";
4578
+ sizer.style.position = "relative";
4579
+ sizer.style.flexShrink = "0";
4580
+ sizer.style.display = "flex";
4581
+ sizer.style.justifyContent = "center";
4582
+ sizer.style.alignItems = "center";
4417
4583
  pre.style.margin = "0 auto";
4418
4584
  pre.style.fontFamily = "Consolas, 'Courier New', monospace";
4419
4585
  pre.style.fontSize = "13px";
@@ -4428,8 +4594,9 @@ var CodePlugin = class {
4428
4594
  pre.style.boxSizing = "border-box";
4429
4595
  pre.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
4430
4596
  pre.style.borderRadius = "4px";
4431
- pre.style.transformOrigin = "top center";
4597
+ pre.style.transformOrigin = "center center";
4432
4598
  pre.style.transition = "transform 0.15s ease";
4599
+ pre.style.flexShrink = "0";
4433
4600
  } else {
4434
4601
  container.style.overflow = "auto";
4435
4602
  container.style.backgroundColor = "#1e1e1e";
@@ -4462,7 +4629,13 @@ var CodePlugin = class {
4462
4629
  };
4463
4630
  renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
4464
4631
  pre.appendChild(code);
4465
- container.appendChild(pre);
4632
+ if (isTxt) {
4633
+ sizer.appendChild(pre);
4634
+ scrollWrapper.appendChild(sizer);
4635
+ container.appendChild(scrollWrapper);
4636
+ } else {
4637
+ container.appendChild(pre);
4638
+ }
4466
4639
  const showPage = (pageNum) => {
4467
4640
  currentPage = Math.max(1, Math.min(totalPages, pageNum));
4468
4641
  renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
@@ -4479,10 +4652,16 @@ var CodePlugin = class {
4479
4652
  };
4480
4653
  const updateTransform = () => {
4481
4654
  if (isTxt) {
4655
+ const elW = 816;
4656
+ const baseH = pre.offsetHeight || 1056;
4657
+ const isRotated90 = rotation % 180 !== 0;
4658
+ const boxW = Math.round((isRotated90 ? baseH : elW) * zoomLevel);
4659
+ const boxH = Math.round((isRotated90 ? elW : baseH) * zoomLevel);
4660
+ sizer.style.width = `${boxW}px`;
4661
+ sizer.style.height = `${boxH}px`;
4662
+ pre.style.width = `${elW}px`;
4482
4663
  pre.style.transform = `scale(${zoomLevel}) rotate(${rotation}deg)`;
4483
- const scaledH = 1056 * zoomLevel;
4484
- const extraH = Math.max(0, scaledH - 1056);
4485
- pre.style.marginBottom = `${extraH + 32}px`;
4664
+ pre.style.transformOrigin = "center center";
4486
4665
  } else {
4487
4666
  pre.style.transform = `rotate(${rotation}deg)`;
4488
4667
  pre.style.fontSize = `${fontSize}px`;
@@ -4688,16 +4867,56 @@ var ArchivePlugin = class {
4688
4867
  width: 100%;
4689
4868
  height: 100%;
4690
4869
  overflow: auto;
4691
- padding: 24px;
4692
4870
  box-sizing: border-box;
4693
4871
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
4694
- transform-origin: top left;
4695
- transition: transform 0.2s ease;
4696
4872
  `;
4873
+ const scrollWrapper = document.createElement("div");
4874
+ scrollWrapper.className = "fp-archive-scroll-wrapper";
4875
+ scrollWrapper.style.cssText = `
4876
+ min-width: 100%;
4877
+ min-height: 100%;
4878
+ width: max-content;
4879
+ height: max-content;
4880
+ display: flex;
4881
+ justify-content: center;
4882
+ align-items: flex-start;
4883
+ padding: 24px;
4884
+ box-sizing: border-box;
4885
+ `;
4886
+ const sizer = document.createElement("div");
4887
+ sizer.className = "fp-archive-sizer";
4888
+ sizer.style.cssText = `
4889
+ position: relative;
4890
+ flex-shrink: 0;
4891
+ display: flex;
4892
+ justify-content: center;
4893
+ align-items: flex-start;
4894
+ `;
4895
+ const card = document.createElement("div");
4896
+ card.className = "fp-archive-card";
4897
+ card.style.cssText = `
4898
+ width: 900px;
4899
+ box-sizing: border-box;
4900
+ transform-origin: top center;
4901
+ transition: transform 0.15s ease;
4902
+ flex-shrink: 0;
4903
+ `;
4904
+ sizer.appendChild(card);
4905
+ scrollWrapper.appendChild(sizer);
4906
+ wrapper.appendChild(scrollWrapper);
4697
4907
  ctx.container.innerHTML = "";
4698
4908
  ctx.container.style.overflow = "auto";
4699
4909
  ctx.container.appendChild(wrapper);
4700
4910
  let scale = 1;
4911
+ const applyTransform = () => {
4912
+ const boxW = Math.round(900 * scale);
4913
+ const cardH = card.offsetHeight || 600;
4914
+ const boxH = Math.round(cardH * scale);
4915
+ sizer.style.width = `${boxW}px`;
4916
+ sizer.style.height = `${boxH}px`;
4917
+ card.style.transform = `scale(${scale})`;
4918
+ card.style.transformOrigin = "top center";
4919
+ };
4701
4920
  const entries = await new Promise((resolve, reject) => {
4702
4921
  unzip(new Uint8Array(ctx.buffer), (err, unzipped) => {
4703
4922
  if (err) {
@@ -4721,7 +4940,7 @@ var ArchivePlugin = class {
4721
4940
  });
4722
4941
  const totalUncompressedSize = entries.reduce((acc, e) => acc + e.size, 0);
4723
4942
  const renderUI = (filteredEntries) => {
4724
- wrapper.innerHTML = `
4943
+ card.innerHTML = `
4725
4944
  <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;">
4726
4945
  <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;">
4727
4946
  <div>
@@ -4751,7 +4970,7 @@ var ArchivePlugin = class {
4751
4970
  </div>
4752
4971
  </div>
4753
4972
  `;
4754
- const tbody = wrapper.querySelector("#fp-archive-body");
4973
+ const tbody = card.querySelector("#fp-archive-body");
4755
4974
  if (filteredEntries.length === 0) {
4756
4975
  tbody.innerHTML = `<tr><td colspan="3" style="padding: 24px; text-align: center; color: #9ca3af;">No matching files found</td></tr>`;
4757
4976
  } else {
@@ -4780,19 +4999,20 @@ var ArchivePlugin = class {
4780
4999
  }
4781
5000
  });
4782
5001
  });
4783
- const searchInput = wrapper.querySelector("#fp-archive-search");
5002
+ const searchInput = card.querySelector("#fp-archive-search");
4784
5003
  if (searchInput) {
4785
5004
  searchInput.addEventListener("input", () => {
4786
5005
  const q = searchInput.value.toLowerCase().trim();
4787
5006
  const filtered = q ? entries.filter((e) => e.path.toLowerCase().includes(q)) : entries;
4788
5007
  renderUI(filtered);
4789
- const newSearch = wrapper.querySelector("#fp-archive-search");
5008
+ const newSearch = card.querySelector("#fp-archive-search");
4790
5009
  if (newSearch) {
4791
5010
  newSearch.value = q;
4792
5011
  newSearch.focus();
4793
5012
  }
4794
5013
  });
4795
5014
  }
5015
+ applyTransform();
4796
5016
  };
4797
5017
  renderUI(entries);
4798
5018
  const cleanup = () => {
@@ -4804,26 +5024,26 @@ var ArchivePlugin = class {
4804
5024
  destroy: cleanup,
4805
5025
  zoomIn: () => {
4806
5026
  scale += 0.1;
4807
- wrapper.style.transform = `scale(${scale})`;
5027
+ applyTransform();
4808
5028
  },
4809
5029
  zoomOut: () => {
4810
5030
  scale = Math.max(0.3, scale - 0.1);
4811
- wrapper.style.transform = `scale(${scale})`;
5031
+ applyTransform();
4812
5032
  },
4813
5033
  getZoom: () => scale,
4814
5034
  setZoom: (level) => {
4815
5035
  scale = level;
4816
- wrapper.style.transform = `scale(${scale})`;
5036
+ applyTransform();
4817
5037
  },
4818
5038
  fitToPage: () => {
4819
5039
  scale = 1;
4820
- wrapper.style.transform = "scale(1)";
5040
+ applyTransform();
4821
5041
  },
4822
5042
  resetZoom: () => {
4823
5043
  scale = 1;
4824
- wrapper.style.transform = "scale(1)";
4825
- ctx.container.scrollTop = 0;
4826
- ctx.container.scrollLeft = 0;
5044
+ wrapper.scrollTop = 0;
5045
+ wrapper.scrollLeft = 0;
5046
+ applyTransform();
4827
5047
  },
4828
5048
  download: () => {
4829
5049
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -5182,12 +5402,30 @@ var PptxPlugin = class {
5182
5402
  width: 100%;
5183
5403
  height: 100%;
5184
5404
  overflow: auto;
5405
+ box-sizing: border-box;
5406
+ background: var(--fp-bg-canvas, #525659);
5407
+ `;
5408
+ const scrollWrapper = document.createElement("div");
5409
+ scrollWrapper.className = "fp-pptx-scroll-wrapper";
5410
+ scrollWrapper.style.cssText = `
5411
+ min-width: 100%;
5412
+ min-height: 100%;
5413
+ width: max-content;
5414
+ height: max-content;
5185
5415
  display: flex;
5186
5416
  justify-content: center;
5187
- align-items: flex-start;
5417
+ align-items: center;
5188
5418
  padding: 24px;
5189
5419
  box-sizing: border-box;
5190
- background: var(--fp-bg-canvas, #525659);
5420
+ `;
5421
+ const sizer = document.createElement("div");
5422
+ sizer.className = "fp-pptx-sizer";
5423
+ sizer.style.cssText = `
5424
+ position: relative;
5425
+ flex-shrink: 0;
5426
+ display: flex;
5427
+ justify-content: center;
5428
+ align-items: center;
5191
5429
  `;
5192
5430
  const slideContainer = document.createElement("div");
5193
5431
  slideContainer.className = "fp-slide-container";
@@ -5196,14 +5434,15 @@ var PptxPlugin = class {
5196
5434
  border-radius: 4px;
5197
5435
  overflow: hidden;
5198
5436
  background: #ffffff;
5199
- transform-origin: top center;
5437
+ transform-origin: center center;
5200
5438
  transition: transform 0.2s ease;
5201
- max-width: calc(100% - 32px);
5202
- max-height: calc(100% - 48px);
5439
+ flex-shrink: 0;
5203
5440
  `;
5204
5441
  const canvas = document.createElement("canvas");
5205
5442
  slideContainer.appendChild(canvas);
5206
- wrapper.appendChild(slideContainer);
5443
+ sizer.appendChild(slideContainer);
5444
+ scrollWrapper.appendChild(sizer);
5445
+ wrapper.appendChild(scrollWrapper);
5207
5446
  ctx.container.innerHTML = "";
5208
5447
  ctx.container.style.overflow = "auto";
5209
5448
  ctx.container.appendChild(wrapper);
@@ -5215,7 +5454,17 @@ var PptxPlugin = class {
5215
5454
  return Math.min(1, Math.min(availW / cW, availH / cH));
5216
5455
  };
5217
5456
  const applyTransform = () => {
5457
+ const cW = canvas.offsetWidth || 1280;
5458
+ const cH = canvas.offsetHeight || 720;
5459
+ const isRotated90 = rotation % 180 !== 0;
5460
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
5461
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
5462
+ sizer.style.width = `${boxW}px`;
5463
+ sizer.style.height = `${boxH}px`;
5464
+ slideContainer.style.width = `${cW}px`;
5465
+ slideContainer.style.height = `${cH}px`;
5218
5466
  slideContainer.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5467
+ slideContainer.style.transformOrigin = "center center";
5219
5468
  };
5220
5469
  const renderCurrentSlide = async () => {
5221
5470
  try {
@@ -5821,13 +6070,33 @@ var RtfPlugin = class {
5821
6070
  wrapper.style.flexDirection = "column";
5822
6071
  wrapper.style.alignItems = "center";
5823
6072
  wrapper.style.backgroundColor = "transparent";
5824
- wrapper.style.transformOrigin = "top center";
6073
+ wrapper.style.transformOrigin = "center center";
5825
6074
  wrapper.style.transition = "transform 0.15s ease";
5826
- ctx.container.style.overflowX = "hidden";
5827
- ctx.container.style.overflowY = "auto";
5828
- ctx.container.style.padding = "16px 8px";
6075
+ wrapper.style.flexShrink = "0";
6076
+ const sizer = document.createElement("div");
6077
+ sizer.className = "fp-rtf-sizer";
6078
+ sizer.style.position = "relative";
6079
+ sizer.style.flexShrink = "0";
6080
+ sizer.style.display = "flex";
6081
+ sizer.style.justifyContent = "center";
6082
+ sizer.style.alignItems = "center";
6083
+ const scrollWrapper = document.createElement("div");
6084
+ scrollWrapper.className = "fp-rtf-scroll-wrapper";
6085
+ scrollWrapper.style.minWidth = "100%";
6086
+ scrollWrapper.style.minHeight = "100%";
6087
+ scrollWrapper.style.width = "max-content";
6088
+ scrollWrapper.style.height = "max-content";
6089
+ scrollWrapper.style.display = "flex";
6090
+ scrollWrapper.style.justifyContent = "center";
6091
+ scrollWrapper.style.alignItems = "flex-start";
6092
+ scrollWrapper.style.padding = "16px 8px";
6093
+ scrollWrapper.style.boxSizing = "border-box";
6094
+ sizer.appendChild(wrapper);
6095
+ scrollWrapper.appendChild(sizer);
6096
+ ctx.container.style.overflow = "auto";
6097
+ ctx.container.style.padding = "0";
5829
6098
  ctx.container.style.backgroundColor = "#f1f5f9";
5830
- ctx.container.appendChild(wrapper);
6099
+ ctx.container.appendChild(scrollWrapper);
5831
6100
  let scale = 1;
5832
6101
  let rotation = 0;
5833
6102
  let pageElements = [];
@@ -5846,12 +6115,17 @@ var RtfPlugin = class {
5846
6115
  return Math.max(0.4, Math.min(3, sW));
5847
6116
  };
5848
6117
  const applyTransform = () => {
5849
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5850
- wrapper.style.transformOrigin = "top center";
6118
+ const elW = pageWidth;
5851
6119
  const baseH = pageHeight;
5852
- const scaledH = baseH * scale;
5853
- const extraH = Math.max(0, scaledH - baseH);
5854
- wrapper.style.marginBottom = `${extraH + 32}px`;
6120
+ const isRotated90 = rotation % 180 !== 0;
6121
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6122
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6123
+ sizer.style.width = `${boxW}px`;
6124
+ sizer.style.height = `${boxH}px`;
6125
+ wrapper.style.width = `${elW}px`;
6126
+ wrapper.style.height = `${baseH}px`;
6127
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6128
+ wrapper.style.transformOrigin = "center center";
5855
6129
  };
5856
6130
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
5857
6131
  if (!isUserZoomed) {
@@ -6122,7 +6396,7 @@ var RtfPlugin = class {
6122
6396
  }
6123
6397
  const cleanup = () => {
6124
6398
  resizeObserver?.disconnect();
6125
- wrapper.remove();
6399
+ scrollWrapper.remove();
6126
6400
  ctx.container.innerHTML = "";
6127
6401
  };
6128
6402
  ctx.signal.addEventListener("abort", cleanup);
@@ -6297,23 +6571,44 @@ var HtmlPreviewPlugin = class {
6297
6571
  ADD_TAGS: ["style", "link"],
6298
6572
  ADD_ATTR: ["target", "rel"]
6299
6573
  });
6574
+ const sizer = document.createElement("div");
6575
+ sizer.className = "fp-html-sizer";
6576
+ sizer.style.position = "relative";
6300
6577
  const iframe = document.createElement("iframe");
6301
6578
  iframe.className = "fp-html-iframe";
6302
- iframe.style.width = "100%";
6303
- iframe.style.height = "100%";
6304
6579
  iframe.style.border = "none";
6305
6580
  iframe.style.backgroundColor = "#ffffff";
6306
6581
  iframe.style.transformOrigin = "top left";
6307
6582
  iframe.style.transition = "transform 0.2s ease";
6308
6583
  iframe.sandbox.add("allow-same-origin");
6584
+ sizer.appendChild(iframe);
6309
6585
  ctx.container.style.overflow = "auto";
6310
6586
  ctx.container.style.width = "100%";
6311
6587
  ctx.container.style.height = "100%";
6312
- ctx.container.appendChild(iframe);
6588
+ ctx.container.innerHTML = "";
6589
+ ctx.container.appendChild(sizer);
6313
6590
  iframe.srcdoc = sanitized;
6314
6591
  let scale = 1;
6592
+ const applyTransform = () => {
6593
+ const baseW = Math.max(600, ctx.container.clientWidth || 800);
6594
+ const baseH = Math.max(400, ctx.container.clientHeight || 600);
6595
+ const scaledW = Math.round(baseW * scale);
6596
+ const scaledH = Math.round(baseH * scale);
6597
+ sizer.style.width = `${scaledW}px`;
6598
+ sizer.style.height = `${scaledH}px`;
6599
+ iframe.style.position = "absolute";
6600
+ iframe.style.top = "0";
6601
+ iframe.style.left = "0";
6602
+ iframe.style.width = `${baseW}px`;
6603
+ iframe.style.height = `${baseH}px`;
6604
+ iframe.style.transform = `scale(${scale})`;
6605
+ iframe.style.transformOrigin = "top left";
6606
+ };
6607
+ requestAnimationFrame(() => {
6608
+ applyTransform();
6609
+ });
6315
6610
  const cleanup = () => {
6316
- iframe.remove();
6611
+ sizer.remove();
6317
6612
  ctx.container.innerHTML = "";
6318
6613
  };
6319
6614
  ctx.signal.addEventListener("abort", cleanup);
@@ -6321,26 +6616,26 @@ var HtmlPreviewPlugin = class {
6321
6616
  destroy: cleanup,
6322
6617
  zoomIn: () => {
6323
6618
  scale += 0.1;
6324
- iframe.style.transform = `scale(${scale})`;
6619
+ applyTransform();
6325
6620
  },
6326
6621
  zoomOut: () => {
6327
6622
  scale = Math.max(0.2, scale - 0.1);
6328
- iframe.style.transform = `scale(${scale})`;
6623
+ applyTransform();
6329
6624
  },
6330
6625
  getZoom: () => scale,
6331
6626
  setZoom: (level) => {
6332
6627
  scale = level;
6333
- iframe.style.transform = `scale(${scale})`;
6628
+ applyTransform();
6334
6629
  },
6335
6630
  fitToPage: () => {
6336
6631
  scale = 1;
6337
- iframe.style.transform = "scale(1)";
6632
+ applyTransform();
6338
6633
  },
6339
6634
  resetZoom: () => {
6340
6635
  scale = 1;
6341
- iframe.style.transform = "scale(1)";
6342
6636
  ctx.container.scrollTop = 0;
6343
6637
  ctx.container.scrollLeft = 0;
6638
+ applyTransform();
6344
6639
  },
6345
6640
  copy: () => {
6346
6641
  navigator.clipboard.writeText(rawHtml);
@@ -6515,10 +6810,26 @@ var OpenDocumentPlugin = class {
6515
6810
  container.className = "fp-odf-container";
6516
6811
  container.style.width = "100%";
6517
6812
  container.style.height = "100%";
6518
- container.style.overflowX = "hidden";
6519
- container.style.overflowY = "auto";
6520
- container.style.padding = "16px 8px";
6813
+ container.style.overflow = "auto";
6521
6814
  container.style.backgroundColor = "#f1f5f9";
6815
+ const scrollWrapper = document.createElement("div");
6816
+ scrollWrapper.className = "fp-odf-scroll-wrapper";
6817
+ scrollWrapper.style.minWidth = "100%";
6818
+ scrollWrapper.style.minHeight = "100%";
6819
+ scrollWrapper.style.width = "max-content";
6820
+ scrollWrapper.style.height = "max-content";
6821
+ scrollWrapper.style.display = "flex";
6822
+ scrollWrapper.style.justifyContent = "center";
6823
+ scrollWrapper.style.alignItems = "flex-start";
6824
+ scrollWrapper.style.padding = "16px 8px";
6825
+ scrollWrapper.style.boxSizing = "border-box";
6826
+ const sizer = document.createElement("div");
6827
+ sizer.className = "fp-odf-sizer";
6828
+ sizer.style.position = "relative";
6829
+ sizer.style.flexShrink = "0";
6830
+ sizer.style.display = "flex";
6831
+ sizer.style.justifyContent = "center";
6832
+ sizer.style.alignItems = "center";
6522
6833
  const wrapper = document.createElement("div");
6523
6834
  wrapper.className = "fp-odf-wrapper";
6524
6835
  wrapper.style.margin = "0 auto";
@@ -6527,9 +6838,12 @@ var OpenDocumentPlugin = class {
6527
6838
  wrapper.style.backgroundColor = "#ffffff";
6528
6839
  wrapper.style.boxShadow = "0 2px 10px rgba(0,0,0,0.08)";
6529
6840
  wrapper.style.borderRadius = "4px";
6530
- wrapper.style.transformOrigin = "top center";
6841
+ wrapper.style.transformOrigin = "center center";
6531
6842
  wrapper.style.transition = "transform 0.15s ease";
6532
- container.appendChild(wrapper);
6843
+ wrapper.style.flexShrink = "0";
6844
+ sizer.appendChild(wrapper);
6845
+ scrollWrapper.appendChild(sizer);
6846
+ container.appendChild(scrollWrapper);
6533
6847
  ctx.container.appendChild(container);
6534
6848
  let scale = 1;
6535
6849
  let rotation = 0;
@@ -6555,13 +6869,18 @@ var OpenDocumentPlugin = class {
6555
6869
  return Math.max(0.4, Math.min(3, sW));
6556
6870
  };
6557
6871
  const applyTransform = () => {
6558
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6559
- wrapper.style.transformOrigin = "top center";
6560
6872
  const activeSlide = slides[currentPage - 1];
6873
+ const elW = isPresentation ? 960 : 816;
6561
6874
  const baseH = activeSlide?.offsetHeight || wrapper.offsetHeight || 1056;
6562
- const scaledH = baseH * scale;
6563
- const extraH = Math.max(0, scaledH - baseH);
6564
- wrapper.style.marginBottom = `${extraH + 32}px`;
6875
+ const isRotated90 = rotation % 180 !== 0;
6876
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6877
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6878
+ sizer.style.width = `${boxW}px`;
6879
+ sizer.style.height = `${boxH}px`;
6880
+ wrapper.style.width = `${elW}px`;
6881
+ wrapper.style.height = `${baseH}px`;
6882
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6883
+ wrapper.style.transformOrigin = "center center";
6565
6884
  };
6566
6885
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
6567
6886
  if (!isUserZoomed) {
@@ -7125,13 +7444,28 @@ var DocPlugin = class {
7125
7444
  container.className = "fp-doc-container";
7126
7445
  container.style.width = "100%";
7127
7446
  container.style.height = "100%";
7128
- container.style.overflowX = "hidden";
7129
- container.style.overflowY = "auto";
7130
- container.style.padding = "16px 8px";
7447
+ container.style.overflow = "auto";
7131
7448
  container.style.backgroundColor = "#f1f5f9";
7132
- container.style.display = "flex";
7133
- container.style.justifyContent = "center";
7134
- container.style.alignItems = "flex-start";
7449
+ const scrollWrapper = document.createElement("div");
7450
+ scrollWrapper.className = "fp-doc-scroll-wrapper";
7451
+ scrollWrapper.style.minWidth = "100%";
7452
+ scrollWrapper.style.minHeight = "100%";
7453
+ scrollWrapper.style.width = "max-content";
7454
+ scrollWrapper.style.height = "max-content";
7455
+ scrollWrapper.style.display = "flex";
7456
+ scrollWrapper.style.justifyContent = "center";
7457
+ scrollWrapper.style.alignItems = "flex-start";
7458
+ scrollWrapper.style.padding = "16px 8px";
7459
+ scrollWrapper.style.boxSizing = "border-box";
7460
+ const sizer = document.createElement("div");
7461
+ sizer.className = "fp-doc-sizer";
7462
+ sizer.style.position = "relative";
7463
+ sizer.style.flexShrink = "0";
7464
+ sizer.style.display = "flex";
7465
+ sizer.style.justifyContent = "center";
7466
+ sizer.style.alignItems = "center";
7467
+ scrollWrapper.appendChild(sizer);
7468
+ container.appendChild(scrollWrapper);
7135
7469
  ctx.container.appendChild(container);
7136
7470
  let scale = 1;
7137
7471
  let extractedRawText = "";
@@ -7179,10 +7513,11 @@ var DocPlugin = class {
7179
7513
  pageCard.style.padding = "72px 56px";
7180
7514
  pageCard.style.boxSizing = "border-box";
7181
7515
  pageCard.style.display = i === 0 ? "block" : "none";
7182
- pageCard.style.transformOrigin = "top center";
7516
+ pageCard.style.transformOrigin = "center center";
7183
7517
  pageCard.style.transition = "transform 0.15s ease";
7184
7518
  pageCard.style.fontFamily = 'Calibri, "Segoe UI", Arial, sans-serif';
7185
7519
  pageCard.style.color = "#1e293b";
7520
+ pageCard.style.flexShrink = "0";
7186
7521
  if (isFallback && i === 0) {
7187
7522
  pageCard.innerHTML = `
7188
7523
  <div style="border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 24px;">
@@ -7194,18 +7529,23 @@ var DocPlugin = class {
7194
7529
  } else {
7195
7530
  pageCard.innerHTML = this.formatDocToHtml(rawPages[i], ctx.metadata.name || "Document");
7196
7531
  }
7197
- container.appendChild(pageCard);
7532
+ sizer.appendChild(pageCard);
7198
7533
  pageCards.push(pageCard);
7199
7534
  }
7200
7535
  let rotation = 0;
7201
7536
  const applyTransform = () => {
7202
7537
  const activeCard = pageCards[currentPage - 1];
7203
7538
  if (activeCard) {
7204
- activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7539
+ const baseW = 816;
7205
7540
  const baseH = activeCard.offsetHeight || 1056;
7206
- const scaledH = baseH * scale;
7207
- const extraH = Math.max(0, scaledH - baseH);
7208
- activeCard.style.marginBottom = `${extraH + 32}px`;
7541
+ const isRotated90 = rotation % 180 !== 0;
7542
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * scale);
7543
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * scale);
7544
+ sizer.style.width = `${boxW}px`;
7545
+ sizer.style.height = `${boxH}px`;
7546
+ activeCard.style.width = `${baseW}px`;
7547
+ activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7548
+ activeCard.style.transformOrigin = "center center";
7209
7549
  }
7210
7550
  };
7211
7551
  const showPage = (pageNum) => {
@@ -7213,11 +7553,11 @@ var DocPlugin = class {
7213
7553
  pageCards.forEach((card, idx) => {
7214
7554
  if (idx + 1 === currentPage) {
7215
7555
  card.style.display = "block";
7216
- card.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7217
7556
  } else {
7218
7557
  card.style.display = "none";
7219
7558
  }
7220
7559
  });
7560
+ applyTransform();
7221
7561
  container.scrollTop = 0;
7222
7562
  ctx.emit("page-change", { page: currentPage, total: totalPages });
7223
7563
  };
@@ -7288,6 +7628,8 @@ var DocPlugin = class {
7288
7628
  fitMode = "width";
7289
7629
  scale = calculateFitScale("width");
7290
7630
  rotation = 0;
7631
+ container.scrollTop = 0;
7632
+ container.scrollLeft = 0;
7291
7633
  ctx.container.scrollTop = 0;
7292
7634
  ctx.container.scrollLeft = 0;
7293
7635
  applyTransform();
@@ -7812,17 +8154,30 @@ var PptPlugin = class {
7812
8154
  container.style.width = "100%";
7813
8155
  container.style.height = "100%";
7814
8156
  container.style.overflow = "auto";
7815
- container.style.display = "flex";
7816
- container.style.justifyContent = "center";
7817
- container.style.alignItems = "center";
7818
- container.style.padding = "32px 16px";
7819
8157
  container.style.backgroundColor = "#0f172a";
7820
8158
  container.style.boxSizing = "border-box";
8159
+ const scrollWrapper = document.createElement("div");
8160
+ scrollWrapper.className = "fp-ppt-scroll-wrapper";
8161
+ scrollWrapper.style.minWidth = "100%";
8162
+ scrollWrapper.style.minHeight = "100%";
8163
+ scrollWrapper.style.width = "max-content";
8164
+ scrollWrapper.style.height = "max-content";
8165
+ scrollWrapper.style.display = "flex";
8166
+ scrollWrapper.style.justifyContent = "center";
8167
+ scrollWrapper.style.alignItems = "center";
8168
+ scrollWrapper.style.padding = "32px 16px";
8169
+ scrollWrapper.style.boxSizing = "border-box";
8170
+ const sizer = document.createElement("div");
8171
+ sizer.className = "fp-ppt-sizer";
8172
+ sizer.style.position = "relative";
8173
+ sizer.style.flexShrink = "0";
8174
+ sizer.style.display = "flex";
8175
+ sizer.style.justifyContent = "center";
8176
+ sizer.style.alignItems = "center";
7821
8177
  const slideCard = document.createElement("div");
7822
8178
  slideCard.className = "fp-ppt-slide-card";
7823
8179
  slideCard.style.width = "960px";
7824
- slideCard.style.maxWidth = "calc(100% - 32px)";
7825
- slideCard.style.maxHeight = "calc(100% - 48px)";
8180
+ slideCard.style.height = "540px";
7826
8181
  slideCard.style.aspectRatio = "16 / 9";
7827
8182
  slideCard.style.backgroundColor = "#ffffff";
7828
8183
  slideCard.style.boxShadow = "0 12px 40px rgba(0,0,0,0.35)";
@@ -7832,7 +8187,9 @@ var PptPlugin = class {
7832
8187
  slideCard.style.transition = "transform 0.2s ease";
7833
8188
  slideCard.style.transformOrigin = "center center";
7834
8189
  slideCard.style.flexShrink = "0";
7835
- container.appendChild(slideCard);
8190
+ sizer.appendChild(slideCard);
8191
+ scrollWrapper.appendChild(sizer);
8192
+ container.appendChild(scrollWrapper);
7836
8193
  ctx.container.appendChild(container);
7837
8194
  let scale = 1;
7838
8195
  let rotation = 0;
@@ -7845,7 +8202,17 @@ var PptPlugin = class {
7845
8202
  return Math.min(1, Math.min(availW / 960, availH / 540));
7846
8203
  };
7847
8204
  const applyTransform = () => {
8205
+ const cW = 960;
8206
+ const cH = 540;
8207
+ const isRotated90 = rotation % 180 !== 0;
8208
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
8209
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
8210
+ sizer.style.width = `${boxW}px`;
8211
+ sizer.style.height = `${boxH}px`;
8212
+ slideCard.style.width = `${cW}px`;
8213
+ slideCard.style.height = `${cH}px`;
7848
8214
  slideCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
8215
+ slideCard.style.transformOrigin = "center center";
7849
8216
  };
7850
8217
  setTimeout(() => {
7851
8218
  scale = calculateFitScale();