@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.js CHANGED
@@ -2085,16 +2085,22 @@ var PdfPlugin = class {
2085
2085
  container.className = "fp-pdf-container";
2086
2086
  container.style.width = "100%";
2087
2087
  container.style.height = "100%";
2088
- container.style.overflowX = "hidden";
2089
- container.style.overflowY = "auto";
2090
- container.style.display = "flex";
2091
- container.style.flexDirection = "column";
2092
- container.style.alignItems = "center";
2093
- container.style.justifyContent = "flex-start";
2094
- container.style.padding = "16px 8px";
2088
+ container.style.overflow = "auto";
2095
2089
  container.style.backgroundColor = "#0f172a";
2096
2090
  container.style.boxSizing = "border-box";
2097
2091
  container.style.position = "relative";
2092
+ const scrollWrapper = document.createElement("div");
2093
+ scrollWrapper.className = "fp-pdf-scroll-wrapper";
2094
+ scrollWrapper.style.minWidth = "100%";
2095
+ scrollWrapper.style.minHeight = "100%";
2096
+ scrollWrapper.style.width = "max-content";
2097
+ scrollWrapper.style.height = "max-content";
2098
+ scrollWrapper.style.display = "flex";
2099
+ scrollWrapper.style.flexDirection = "column";
2100
+ scrollWrapper.style.alignItems = "center";
2101
+ scrollWrapper.style.justifyContent = "flex-start";
2102
+ scrollWrapper.style.padding = "16px 8px";
2103
+ scrollWrapper.style.boxSizing = "border-box";
2098
2104
  const pageCard = document.createElement("div");
2099
2105
  pageCard.className = "fp-pdf-page-card";
2100
2106
  pageCard.style.boxShadow = "0 10px 35px rgba(0, 0, 0, 0.5)";
@@ -2107,7 +2113,8 @@ var PdfPlugin = class {
2107
2113
  pageCard.style.transition = "box-shadow 0.2s ease";
2108
2114
  let canvas = document.createElement("canvas");
2109
2115
  pageCard.appendChild(canvas);
2110
- container.appendChild(pageCard);
2116
+ scrollWrapper.appendChild(pageCard);
2117
+ container.appendChild(scrollWrapper);
2111
2118
  ctx.container.appendChild(container);
2112
2119
  const standardFontsUrl = typeof window !== "undefined" && window.__PDF_STANDARD_FONTS_URL__ || "./standard_fonts/";
2113
2120
  const cmapsUrl = typeof window !== "undefined" && window.__PDF_CMAPS_URL__ || "./cmaps/";
@@ -2616,17 +2623,86 @@ var MediaPlugin = class {
2616
2623
  element = document.createElement("div");
2617
2624
  element.textContent = "Unsupported media type";
2618
2625
  }
2619
- ctx.container.style.display = "flex";
2620
- ctx.container.style.alignItems = "center";
2621
- ctx.container.style.justifyContent = "center";
2622
- ctx.container.style.overflow = "hidden";
2623
- ctx.container.appendChild(element);
2626
+ const scrollWrapper = document.createElement("div");
2627
+ scrollWrapper.className = "fp-media-scroll-wrapper";
2628
+ scrollWrapper.style.minWidth = "100%";
2629
+ scrollWrapper.style.minHeight = "100%";
2630
+ scrollWrapper.style.width = "max-content";
2631
+ scrollWrapper.style.height = "max-content";
2632
+ scrollWrapper.style.display = "flex";
2633
+ scrollWrapper.style.justifyContent = "center";
2634
+ scrollWrapper.style.alignItems = "center";
2635
+ scrollWrapper.style.padding = "16px";
2636
+ scrollWrapper.style.boxSizing = "border-box";
2637
+ const sizer = document.createElement("div");
2638
+ sizer.className = "fp-media-sizer";
2639
+ sizer.style.position = "relative";
2640
+ sizer.style.flexShrink = "0";
2641
+ sizer.style.display = "flex";
2642
+ sizer.style.justifyContent = "center";
2643
+ sizer.style.alignItems = "center";
2644
+ sizer.appendChild(element);
2645
+ scrollWrapper.appendChild(sizer);
2646
+ ctx.container.style.overflow = "auto";
2647
+ ctx.container.style.padding = "0";
2648
+ ctx.container.innerHTML = "";
2649
+ ctx.container.appendChild(scrollWrapper);
2650
+ let naturalW = 800;
2651
+ let naturalH = 600;
2652
+ let baseW = 800;
2653
+ let baseH = 600;
2654
+ const updateBaseDimensions = () => {
2655
+ if (!isImage) return;
2656
+ const img = element;
2657
+ naturalW = img.naturalWidth || naturalW;
2658
+ naturalH = img.naturalHeight || naturalH;
2659
+ const availW = Math.max(100, ctx.container.clientWidth - 48);
2660
+ const availH = Math.max(100, ctx.container.clientHeight - 48);
2661
+ const fitRatio = Math.min(1, availW / naturalW, availH / naturalH);
2662
+ baseW = Math.max(1, Math.round(naturalW * fitRatio));
2663
+ baseH = Math.max(1, Math.round(naturalH * fitRatio));
2664
+ };
2624
2665
  const applyTransform = () => {
2625
- element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2666
+ if (isImage) {
2667
+ updateBaseDimensions();
2668
+ const isRotated90 = rotation % 180 !== 0;
2669
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * currentZoom);
2670
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * currentZoom);
2671
+ sizer.style.width = `${boxW}px`;
2672
+ sizer.style.height = `${boxH}px`;
2673
+ element.style.width = `${baseW}px`;
2674
+ element.style.height = `${baseH}px`;
2675
+ element.style.maxWidth = "none";
2676
+ element.style.maxHeight = "none";
2677
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2678
+ element.style.transformOrigin = "center center";
2679
+ element.style.flexShrink = "0";
2680
+ } else {
2681
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2682
+ }
2626
2683
  };
2684
+ if (isImage) {
2685
+ const img = element;
2686
+ if (img.complete && img.naturalWidth > 0) {
2687
+ updateBaseDimensions();
2688
+ applyTransform();
2689
+ } else {
2690
+ img.onload = () => {
2691
+ updateBaseDimensions();
2692
+ applyTransform();
2693
+ };
2694
+ }
2695
+ }
2696
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
2697
+ if (currentZoom === 1) {
2698
+ applyTransform();
2699
+ }
2700
+ }) : null;
2701
+ ro?.observe(ctx.container);
2627
2702
  const cleanup = () => {
2703
+ ro?.disconnect();
2628
2704
  if (url) URL.revokeObjectURL(url);
2629
- element.remove();
2705
+ scrollWrapper.remove();
2630
2706
  ctx.container.innerHTML = "";
2631
2707
  };
2632
2708
  ctx.signal.addEventListener("abort", cleanup);
@@ -2819,7 +2895,7 @@ var DocxPlugin = class {
2819
2895
  async render(ctx) {
2820
2896
  const wrapper = document.createElement("div");
2821
2897
  wrapper.className = "fp-docx-wrapper";
2822
- wrapper.style.transformOrigin = "top center";
2898
+ wrapper.style.transformOrigin = "center center";
2823
2899
  wrapper.style.transition = "transform 0.2s ease";
2824
2900
  wrapper.style.padding = "0";
2825
2901
  wrapper.style.maxWidth = "none";
@@ -2829,11 +2905,31 @@ var DocxPlugin = class {
2829
2905
  wrapper.style.flexDirection = "column";
2830
2906
  wrapper.style.alignItems = "center";
2831
2907
  wrapper.style.boxSizing = "border-box";
2832
- ctx.container.style.overflowX = "hidden";
2833
- ctx.container.style.overflowY = "auto";
2834
- ctx.container.style.padding = "16px 8px";
2908
+ wrapper.style.flexShrink = "0";
2909
+ const sizer = document.createElement("div");
2910
+ sizer.className = "fp-docx-sizer";
2911
+ sizer.style.position = "relative";
2912
+ sizer.style.flexShrink = "0";
2913
+ sizer.style.display = "flex";
2914
+ sizer.style.justifyContent = "center";
2915
+ sizer.style.alignItems = "center";
2916
+ const scrollWrapper = document.createElement("div");
2917
+ scrollWrapper.className = "fp-docx-scroll-wrapper";
2918
+ scrollWrapper.style.minWidth = "100%";
2919
+ scrollWrapper.style.minHeight = "100%";
2920
+ scrollWrapper.style.width = "max-content";
2921
+ scrollWrapper.style.height = "max-content";
2922
+ scrollWrapper.style.display = "flex";
2923
+ scrollWrapper.style.justifyContent = "center";
2924
+ scrollWrapper.style.alignItems = "flex-start";
2925
+ scrollWrapper.style.padding = "16px 8px";
2926
+ scrollWrapper.style.boxSizing = "border-box";
2927
+ sizer.appendChild(wrapper);
2928
+ scrollWrapper.appendChild(sizer);
2929
+ ctx.container.style.overflow = "auto";
2930
+ ctx.container.style.padding = "0";
2835
2931
  ctx.container.style.backgroundColor = "#f1f5f9";
2836
- ctx.container.appendChild(wrapper);
2932
+ ctx.container.appendChild(scrollWrapper);
2837
2933
  const styleOverride = document.createElement("style");
2838
2934
  styleOverride.textContent = `
2839
2935
  .fp-docx-wrapper .docx-wrapper {
@@ -2872,8 +2968,8 @@ var DocxPlugin = class {
2872
2968
  renderEndnotes: true,
2873
2969
  useBase64URL: true
2874
2970
  });
2875
- if (!ctx.container.contains(wrapper)) {
2876
- ctx.container.appendChild(wrapper);
2971
+ if (!sizer.contains(wrapper)) {
2972
+ sizer.appendChild(wrapper);
2877
2973
  }
2878
2974
  if (wrapper.children.length > 0 && (wrapper.textContent?.trim().length ?? 0) > 0) {
2879
2975
  renderedSuccessfully = true;
@@ -2910,8 +3006,8 @@ var DocxPlugin = class {
2910
3006
  try {
2911
3007
  wrapper.innerHTML = "";
2912
3008
  this.renderXmlFallback(ctx, wrapper, createdBlobUrls);
2913
- if (!ctx.container.contains(wrapper)) {
2914
- ctx.container.appendChild(wrapper);
3009
+ if (!sizer.contains(wrapper)) {
3010
+ sizer.appendChild(wrapper);
2915
3011
  }
2916
3012
  renderedSuccessfully = true;
2917
3013
  } catch (fallbackErr) {
@@ -2926,8 +3022,8 @@ var DocxPlugin = class {
2926
3022
  </p>
2927
3023
  </div>
2928
3024
  `;
2929
- if (!ctx.container.contains(wrapper)) {
2930
- ctx.container.appendChild(wrapper);
3025
+ if (!sizer.contains(wrapper)) {
3026
+ sizer.appendChild(wrapper);
2931
3027
  }
2932
3028
  }
2933
3029
  }
@@ -3030,15 +3126,18 @@ var DocxPlugin = class {
3030
3126
  return Math.max(0.35, Math.min(3, sW));
3031
3127
  };
3032
3128
  const applyTransform = () => {
3033
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3034
- wrapper.style.transformOrigin = "top center";
3035
3129
  const activeEl = pageElements[currentPage - 1] || wrapper.querySelector("section.docx") || wrapper;
3130
+ const elW = activeEl.offsetWidth || 816;
3036
3131
  const elH = activeEl.offsetHeight || 1056;
3037
- if (scale > 1) {
3038
- wrapper.style.marginBottom = `${Math.round(elH * scale - elH + 32)}px`;
3039
- } else {
3040
- wrapper.style.marginBottom = "32px";
3041
- }
3132
+ const isRotated90 = rotation % 180 !== 0;
3133
+ const boxW = Math.round((isRotated90 ? elH : elW) * scale);
3134
+ const boxH = Math.round((isRotated90 ? elW : elH) * scale);
3135
+ sizer.style.width = `${boxW}px`;
3136
+ sizer.style.height = `${boxH}px`;
3137
+ wrapper.style.width = `${elW}px`;
3138
+ wrapper.style.height = `${elH}px`;
3139
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3140
+ wrapper.style.transformOrigin = "center center";
3042
3141
  };
3043
3142
  let resizeObserver = null;
3044
3143
  if (typeof ResizeObserver !== "undefined") {
@@ -3063,7 +3162,7 @@ var DocxPlugin = class {
3063
3162
  for (const url of createdBlobUrls) {
3064
3163
  URL.revokeObjectURL(url);
3065
3164
  }
3066
- wrapper.remove();
3165
+ scrollWrapper.remove();
3067
3166
  styleOverride.remove();
3068
3167
  ctx.container.innerHTML = "";
3069
3168
  };
@@ -3610,7 +3709,7 @@ var ExcelPlugin = class {
3610
3709
  contentArea.style.flex = "1";
3611
3710
  contentArea.style.overflow = "auto";
3612
3711
  contentArea.style.padding = "16px";
3613
- contentArea.style.transformOrigin = "top left";
3712
+ contentArea.style.boxSizing = "border-box";
3614
3713
  const tabsArea = document.createElement("div");
3615
3714
  tabsArea.className = "fp-excel-tabs";
3616
3715
  tabsArea.style.display = "flex";
@@ -3624,18 +3723,35 @@ var ExcelPlugin = class {
3624
3723
  container.appendChild(tabsArea);
3625
3724
  ctx.container.appendChild(container);
3626
3725
  let scale = 1;
3726
+ let isUserZoomed = false;
3627
3727
  let currentSheetIndex = 1;
3628
3728
  let sheetNames = [];
3629
3729
  let wb = null;
3630
3730
  const applyTransform = () => {
3631
- contentArea.style.transform = `scale(${scale})`;
3632
- contentArea.style.transformOrigin = "top left";
3731
+ const sizer = contentArea.querySelector(".fp-excel-sizer");
3732
+ const table = contentArea.querySelector("table");
3733
+ if (!sizer || !table) return;
3734
+ if (!table._baseWidth && table.offsetWidth > 0) {
3735
+ table._baseWidth = table.offsetWidth;
3736
+ table._baseHeight = table.offsetHeight;
3737
+ }
3738
+ const baseW = table._baseWidth || table.offsetWidth || 800;
3739
+ const baseH = table._baseHeight || table.offsetHeight || 600;
3740
+ const scaledW = Math.round(baseW * scale);
3741
+ const scaledH = Math.round(baseH * scale);
3742
+ sizer.style.width = `${scaledW}px`;
3743
+ sizer.style.height = `${scaledH}px`;
3744
+ table.style.position = "absolute";
3745
+ table.style.top = "0";
3746
+ table.style.left = "0";
3747
+ table.style.transform = `scale(${scale})`;
3748
+ table.style.transformOrigin = "top left";
3633
3749
  };
3634
3750
  const calculateFitScale = () => {
3635
3751
  const table = contentArea.querySelector("table");
3636
3752
  if (!table) return 1;
3637
3753
  const availW = Math.max(280, container.clientWidth - 48);
3638
- const tW = table.offsetWidth || 800;
3754
+ const tW = table._baseWidth || table.offsetWidth || 800;
3639
3755
  return Math.max(0.4, Math.min(1, availW / tW));
3640
3756
  };
3641
3757
  try {
@@ -3655,9 +3771,13 @@ var ExcelPlugin = class {
3655
3771
  contentArea.innerHTML = '<div style="padding: 24px; color: #888;">Empty sheet</div>';
3656
3772
  return;
3657
3773
  }
3774
+ const sizer = document.createElement("div");
3775
+ sizer.className = "fp-excel-sizer";
3776
+ sizer.style.position = "relative";
3658
3777
  const html = XLSX.utils.sheet_to_html(ws, { id: "fp-sheet-table", editable: false });
3659
- contentArea.innerHTML = html;
3660
- const table = contentArea.querySelector("table");
3778
+ sizer.innerHTML = html;
3779
+ contentArea.appendChild(sizer);
3780
+ const table = sizer.querySelector("table");
3661
3781
  if (table) {
3662
3782
  table.style.borderCollapse = "collapse";
3663
3783
  table.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
@@ -3692,13 +3812,17 @@ var ExcelPlugin = class {
3692
3812
  });
3693
3813
  ctx.emit("page-change", { page: currentSheetIndex, total: sheetNames.length });
3694
3814
  requestAnimationFrame(() => {
3695
- scale = calculateFitScale();
3815
+ if (!isUserZoomed) {
3816
+ scale = calculateFitScale();
3817
+ }
3696
3818
  applyTransform();
3697
3819
  });
3698
3820
  };
3699
3821
  const ro = new ResizeObserver(() => {
3700
- scale = calculateFitScale();
3701
- applyTransform();
3822
+ if (!isUserZoomed) {
3823
+ scale = calculateFitScale();
3824
+ applyTransform();
3825
+ }
3702
3826
  });
3703
3827
  ro.observe(container);
3704
3828
  if (sheetNames.length > 0) {
@@ -3735,23 +3859,28 @@ var ExcelPlugin = class {
3735
3859
  return {
3736
3860
  destroy: cleanup,
3737
3861
  zoomIn: () => {
3862
+ isUserZoomed = true;
3738
3863
  scale += 0.15;
3739
3864
  applyTransform();
3740
3865
  },
3741
3866
  zoomOut: () => {
3867
+ isUserZoomed = true;
3742
3868
  scale = Math.max(0.2, scale - 0.15);
3743
3869
  applyTransform();
3744
3870
  },
3745
3871
  getZoom: () => scale,
3746
3872
  setZoom: (level) => {
3873
+ isUserZoomed = true;
3747
3874
  scale = level;
3748
3875
  applyTransform();
3749
3876
  },
3750
3877
  fitToPage: () => {
3878
+ isUserZoomed = false;
3751
3879
  scale = calculateFitScale();
3752
3880
  applyTransform();
3753
3881
  },
3754
3882
  resetZoom: () => {
3883
+ isUserZoomed = false;
3755
3884
  scale = calculateFitScale();
3756
3885
  contentArea.scrollTop = 0;
3757
3886
  contentArea.scrollLeft = 0;
@@ -3983,21 +4112,41 @@ var CsvPlugin = class {
3983
4112
  container.appendChild(tableWrapper);
3984
4113
  ctx.container.appendChild(container);
3985
4114
  let scale = 1;
4115
+ let isUserZoomed = false;
3986
4116
  const calculateFitScale = () => {
3987
4117
  const availW = Math.max(280, container.clientWidth - 48);
3988
- const tW = table.offsetWidth || 800;
4118
+ const tW = table._baseWidth || table.offsetWidth || 800;
3989
4119
  return Math.max(0.4, Math.min(1, availW / tW));
3990
4120
  };
3991
4121
  const applyScale = () => {
3992
- tableWrapper.style.transform = `scale(${scale})`;
4122
+ if (!table._baseWidth && table.offsetWidth > 0) {
4123
+ table._baseWidth = table.offsetWidth;
4124
+ table._baseHeight = table.offsetHeight;
4125
+ }
4126
+ const baseW = table._baseWidth || table.offsetWidth || 800;
4127
+ const baseH = table._baseHeight || table.offsetHeight || 600;
4128
+ const scaledW = Math.round(baseW * scale);
4129
+ const scaledH = Math.round(baseH * scale);
4130
+ tableWrapper.style.position = "relative";
4131
+ tableWrapper.style.width = `${scaledW}px`;
4132
+ tableWrapper.style.height = `${scaledH}px`;
4133
+ table.style.position = "absolute";
4134
+ table.style.top = "0";
4135
+ table.style.left = "0";
4136
+ table.style.transform = `scale(${scale})`;
4137
+ table.style.transformOrigin = "top left";
3993
4138
  };
3994
4139
  requestAnimationFrame(() => {
3995
- scale = calculateFitScale();
4140
+ if (!isUserZoomed) {
4141
+ scale = calculateFitScale();
4142
+ }
3996
4143
  applyScale();
3997
4144
  });
3998
4145
  const ro = new ResizeObserver(() => {
3999
- scale = calculateFitScale();
4000
- applyScale();
4146
+ if (!isUserZoomed) {
4147
+ scale = calculateFitScale();
4148
+ applyScale();
4149
+ }
4001
4150
  });
4002
4151
  ro.observe(container);
4003
4152
  const cleanup = () => {
@@ -4070,23 +4219,28 @@ var CsvPlugin = class {
4070
4219
  }];
4071
4220
  },
4072
4221
  zoomIn: () => {
4222
+ isUserZoomed = true;
4073
4223
  scale += 0.1;
4074
4224
  applyScale();
4075
4225
  },
4076
4226
  zoomOut: () => {
4227
+ isUserZoomed = true;
4077
4228
  scale = Math.max(0.2, scale - 0.1);
4078
4229
  applyScale();
4079
4230
  },
4080
4231
  getZoom: () => scale,
4081
4232
  setZoom: (level) => {
4233
+ isUserZoomed = true;
4082
4234
  scale = level;
4083
4235
  applyScale();
4084
4236
  },
4085
4237
  fitToPage: () => {
4238
+ isUserZoomed = false;
4086
4239
  scale = calculateFitScale();
4087
4240
  applyScale();
4088
4241
  },
4089
4242
  resetZoom: () => {
4243
+ isUserZoomed = false;
4090
4244
  scale = calculateFitScale();
4091
4245
  container.scrollTop = 0;
4092
4246
  container.scrollLeft = 0;
@@ -4322,15 +4476,27 @@ var CodePlugin = class {
4322
4476
  let isUserZoomed = false;
4323
4477
  const pre = document.createElement("pre");
4324
4478
  const code = document.createElement("code");
4479
+ const sizer = document.createElement("div");
4480
+ const scrollWrapper = document.createElement("div");
4325
4481
  if (isTxt) {
4326
- container.style.overflowX = "hidden";
4327
- container.style.overflowY = "auto";
4482
+ container.style.overflow = "auto";
4328
4483
  container.style.backgroundColor = "#f1f5f9";
4329
- container.style.padding = "16px 8px";
4330
- container.style.boxSizing = "border-box";
4331
- container.style.display = "flex";
4332
- container.style.flexDirection = "column";
4333
- container.style.alignItems = "center";
4484
+ scrollWrapper.className = "fp-code-scroll-wrapper";
4485
+ scrollWrapper.style.minWidth = "100%";
4486
+ scrollWrapper.style.minHeight = "100%";
4487
+ scrollWrapper.style.width = "max-content";
4488
+ scrollWrapper.style.height = "max-content";
4489
+ scrollWrapper.style.display = "flex";
4490
+ scrollWrapper.style.justifyContent = "center";
4491
+ scrollWrapper.style.alignItems = "flex-start";
4492
+ scrollWrapper.style.padding = "16px 8px";
4493
+ scrollWrapper.style.boxSizing = "border-box";
4494
+ sizer.className = "fp-code-sizer";
4495
+ sizer.style.position = "relative";
4496
+ sizer.style.flexShrink = "0";
4497
+ sizer.style.display = "flex";
4498
+ sizer.style.justifyContent = "center";
4499
+ sizer.style.alignItems = "center";
4334
4500
  pre.style.margin = "0 auto";
4335
4501
  pre.style.fontFamily = "Consolas, 'Courier New', monospace";
4336
4502
  pre.style.fontSize = "13px";
@@ -4345,8 +4511,9 @@ var CodePlugin = class {
4345
4511
  pre.style.boxSizing = "border-box";
4346
4512
  pre.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
4347
4513
  pre.style.borderRadius = "4px";
4348
- pre.style.transformOrigin = "top center";
4514
+ pre.style.transformOrigin = "center center";
4349
4515
  pre.style.transition = "transform 0.15s ease";
4516
+ pre.style.flexShrink = "0";
4350
4517
  } else {
4351
4518
  container.style.overflow = "auto";
4352
4519
  container.style.backgroundColor = "#1e1e1e";
@@ -4379,7 +4546,13 @@ var CodePlugin = class {
4379
4546
  };
4380
4547
  renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
4381
4548
  pre.appendChild(code);
4382
- container.appendChild(pre);
4549
+ if (isTxt) {
4550
+ sizer.appendChild(pre);
4551
+ scrollWrapper.appendChild(sizer);
4552
+ container.appendChild(scrollWrapper);
4553
+ } else {
4554
+ container.appendChild(pre);
4555
+ }
4383
4556
  const showPage = (pageNum) => {
4384
4557
  currentPage = Math.max(1, Math.min(totalPages, pageNum));
4385
4558
  renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
@@ -4396,10 +4569,16 @@ var CodePlugin = class {
4396
4569
  };
4397
4570
  const updateTransform = () => {
4398
4571
  if (isTxt) {
4572
+ const elW = 816;
4573
+ const baseH = pre.offsetHeight || 1056;
4574
+ const isRotated90 = rotation % 180 !== 0;
4575
+ const boxW = Math.round((isRotated90 ? baseH : elW) * zoomLevel);
4576
+ const boxH = Math.round((isRotated90 ? elW : baseH) * zoomLevel);
4577
+ sizer.style.width = `${boxW}px`;
4578
+ sizer.style.height = `${boxH}px`;
4579
+ pre.style.width = `${elW}px`;
4399
4580
  pre.style.transform = `scale(${zoomLevel}) rotate(${rotation}deg)`;
4400
- const scaledH = 1056 * zoomLevel;
4401
- const extraH = Math.max(0, scaledH - 1056);
4402
- pre.style.marginBottom = `${extraH + 32}px`;
4581
+ pre.style.transformOrigin = "center center";
4403
4582
  } else {
4404
4583
  pre.style.transform = `rotate(${rotation}deg)`;
4405
4584
  pre.style.fontSize = `${fontSize}px`;
@@ -4605,16 +4784,56 @@ var ArchivePlugin = class {
4605
4784
  width: 100%;
4606
4785
  height: 100%;
4607
4786
  overflow: auto;
4608
- padding: 24px;
4609
4787
  box-sizing: border-box;
4610
4788
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
4611
- transform-origin: top left;
4612
- transition: transform 0.2s ease;
4613
4789
  `;
4790
+ const scrollWrapper = document.createElement("div");
4791
+ scrollWrapper.className = "fp-archive-scroll-wrapper";
4792
+ scrollWrapper.style.cssText = `
4793
+ min-width: 100%;
4794
+ min-height: 100%;
4795
+ width: max-content;
4796
+ height: max-content;
4797
+ display: flex;
4798
+ justify-content: center;
4799
+ align-items: flex-start;
4800
+ padding: 24px;
4801
+ box-sizing: border-box;
4802
+ `;
4803
+ const sizer = document.createElement("div");
4804
+ sizer.className = "fp-archive-sizer";
4805
+ sizer.style.cssText = `
4806
+ position: relative;
4807
+ flex-shrink: 0;
4808
+ display: flex;
4809
+ justify-content: center;
4810
+ align-items: flex-start;
4811
+ `;
4812
+ const card = document.createElement("div");
4813
+ card.className = "fp-archive-card";
4814
+ card.style.cssText = `
4815
+ width: 900px;
4816
+ box-sizing: border-box;
4817
+ transform-origin: top center;
4818
+ transition: transform 0.15s ease;
4819
+ flex-shrink: 0;
4820
+ `;
4821
+ sizer.appendChild(card);
4822
+ scrollWrapper.appendChild(sizer);
4823
+ wrapper.appendChild(scrollWrapper);
4614
4824
  ctx.container.innerHTML = "";
4615
4825
  ctx.container.style.overflow = "auto";
4616
4826
  ctx.container.appendChild(wrapper);
4617
4827
  let scale = 1;
4828
+ const applyTransform = () => {
4829
+ const boxW = Math.round(900 * scale);
4830
+ const cardH = card.offsetHeight || 600;
4831
+ const boxH = Math.round(cardH * scale);
4832
+ sizer.style.width = `${boxW}px`;
4833
+ sizer.style.height = `${boxH}px`;
4834
+ card.style.transform = `scale(${scale})`;
4835
+ card.style.transformOrigin = "top center";
4836
+ };
4618
4837
  const entries = await new Promise((resolve, reject) => {
4619
4838
  unzip(new Uint8Array(ctx.buffer), (err, unzipped) => {
4620
4839
  if (err) {
@@ -4638,7 +4857,7 @@ var ArchivePlugin = class {
4638
4857
  });
4639
4858
  const totalUncompressedSize = entries.reduce((acc, e) => acc + e.size, 0);
4640
4859
  const renderUI = (filteredEntries) => {
4641
- wrapper.innerHTML = `
4860
+ card.innerHTML = `
4642
4861
  <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;">
4643
4862
  <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;">
4644
4863
  <div>
@@ -4668,7 +4887,7 @@ var ArchivePlugin = class {
4668
4887
  </div>
4669
4888
  </div>
4670
4889
  `;
4671
- const tbody = wrapper.querySelector("#fp-archive-body");
4890
+ const tbody = card.querySelector("#fp-archive-body");
4672
4891
  if (filteredEntries.length === 0) {
4673
4892
  tbody.innerHTML = `<tr><td colspan="3" style="padding: 24px; text-align: center; color: #9ca3af;">No matching files found</td></tr>`;
4674
4893
  } else {
@@ -4697,19 +4916,20 @@ var ArchivePlugin = class {
4697
4916
  }
4698
4917
  });
4699
4918
  });
4700
- const searchInput = wrapper.querySelector("#fp-archive-search");
4919
+ const searchInput = card.querySelector("#fp-archive-search");
4701
4920
  if (searchInput) {
4702
4921
  searchInput.addEventListener("input", () => {
4703
4922
  const q = searchInput.value.toLowerCase().trim();
4704
4923
  const filtered = q ? entries.filter((e) => e.path.toLowerCase().includes(q)) : entries;
4705
4924
  renderUI(filtered);
4706
- const newSearch = wrapper.querySelector("#fp-archive-search");
4925
+ const newSearch = card.querySelector("#fp-archive-search");
4707
4926
  if (newSearch) {
4708
4927
  newSearch.value = q;
4709
4928
  newSearch.focus();
4710
4929
  }
4711
4930
  });
4712
4931
  }
4932
+ applyTransform();
4713
4933
  };
4714
4934
  renderUI(entries);
4715
4935
  const cleanup = () => {
@@ -4721,26 +4941,26 @@ var ArchivePlugin = class {
4721
4941
  destroy: cleanup,
4722
4942
  zoomIn: () => {
4723
4943
  scale += 0.1;
4724
- wrapper.style.transform = `scale(${scale})`;
4944
+ applyTransform();
4725
4945
  },
4726
4946
  zoomOut: () => {
4727
4947
  scale = Math.max(0.3, scale - 0.1);
4728
- wrapper.style.transform = `scale(${scale})`;
4948
+ applyTransform();
4729
4949
  },
4730
4950
  getZoom: () => scale,
4731
4951
  setZoom: (level) => {
4732
4952
  scale = level;
4733
- wrapper.style.transform = `scale(${scale})`;
4953
+ applyTransform();
4734
4954
  },
4735
4955
  fitToPage: () => {
4736
4956
  scale = 1;
4737
- wrapper.style.transform = "scale(1)";
4957
+ applyTransform();
4738
4958
  },
4739
4959
  resetZoom: () => {
4740
4960
  scale = 1;
4741
- wrapper.style.transform = "scale(1)";
4742
- ctx.container.scrollTop = 0;
4743
- ctx.container.scrollLeft = 0;
4961
+ wrapper.scrollTop = 0;
4962
+ wrapper.scrollLeft = 0;
4963
+ applyTransform();
4744
4964
  },
4745
4965
  download: () => {
4746
4966
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -5099,12 +5319,30 @@ var PptxPlugin = class {
5099
5319
  width: 100%;
5100
5320
  height: 100%;
5101
5321
  overflow: auto;
5322
+ box-sizing: border-box;
5323
+ background: var(--fp-bg-canvas, #525659);
5324
+ `;
5325
+ const scrollWrapper = document.createElement("div");
5326
+ scrollWrapper.className = "fp-pptx-scroll-wrapper";
5327
+ scrollWrapper.style.cssText = `
5328
+ min-width: 100%;
5329
+ min-height: 100%;
5330
+ width: max-content;
5331
+ height: max-content;
5102
5332
  display: flex;
5103
5333
  justify-content: center;
5104
- align-items: flex-start;
5334
+ align-items: center;
5105
5335
  padding: 24px;
5106
5336
  box-sizing: border-box;
5107
- background: var(--fp-bg-canvas, #525659);
5337
+ `;
5338
+ const sizer = document.createElement("div");
5339
+ sizer.className = "fp-pptx-sizer";
5340
+ sizer.style.cssText = `
5341
+ position: relative;
5342
+ flex-shrink: 0;
5343
+ display: flex;
5344
+ justify-content: center;
5345
+ align-items: center;
5108
5346
  `;
5109
5347
  const slideContainer = document.createElement("div");
5110
5348
  slideContainer.className = "fp-slide-container";
@@ -5113,14 +5351,15 @@ var PptxPlugin = class {
5113
5351
  border-radius: 4px;
5114
5352
  overflow: hidden;
5115
5353
  background: #ffffff;
5116
- transform-origin: top center;
5354
+ transform-origin: center center;
5117
5355
  transition: transform 0.2s ease;
5118
- max-width: calc(100% - 32px);
5119
- max-height: calc(100% - 48px);
5356
+ flex-shrink: 0;
5120
5357
  `;
5121
5358
  const canvas = document.createElement("canvas");
5122
5359
  slideContainer.appendChild(canvas);
5123
- wrapper.appendChild(slideContainer);
5360
+ sizer.appendChild(slideContainer);
5361
+ scrollWrapper.appendChild(sizer);
5362
+ wrapper.appendChild(scrollWrapper);
5124
5363
  ctx.container.innerHTML = "";
5125
5364
  ctx.container.style.overflow = "auto";
5126
5365
  ctx.container.appendChild(wrapper);
@@ -5132,7 +5371,17 @@ var PptxPlugin = class {
5132
5371
  return Math.min(1, Math.min(availW / cW, availH / cH));
5133
5372
  };
5134
5373
  const applyTransform = () => {
5374
+ const cW = canvas.offsetWidth || 1280;
5375
+ const cH = canvas.offsetHeight || 720;
5376
+ const isRotated90 = rotation % 180 !== 0;
5377
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
5378
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
5379
+ sizer.style.width = `${boxW}px`;
5380
+ sizer.style.height = `${boxH}px`;
5381
+ slideContainer.style.width = `${cW}px`;
5382
+ slideContainer.style.height = `${cH}px`;
5135
5383
  slideContainer.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5384
+ slideContainer.style.transformOrigin = "center center";
5136
5385
  };
5137
5386
  const renderCurrentSlide = async () => {
5138
5387
  try {
@@ -5738,13 +5987,33 @@ var RtfPlugin = class {
5738
5987
  wrapper.style.flexDirection = "column";
5739
5988
  wrapper.style.alignItems = "center";
5740
5989
  wrapper.style.backgroundColor = "transparent";
5741
- wrapper.style.transformOrigin = "top center";
5990
+ wrapper.style.transformOrigin = "center center";
5742
5991
  wrapper.style.transition = "transform 0.15s ease";
5743
- ctx.container.style.overflowX = "hidden";
5744
- ctx.container.style.overflowY = "auto";
5745
- ctx.container.style.padding = "16px 8px";
5992
+ wrapper.style.flexShrink = "0";
5993
+ const sizer = document.createElement("div");
5994
+ sizer.className = "fp-rtf-sizer";
5995
+ sizer.style.position = "relative";
5996
+ sizer.style.flexShrink = "0";
5997
+ sizer.style.display = "flex";
5998
+ sizer.style.justifyContent = "center";
5999
+ sizer.style.alignItems = "center";
6000
+ const scrollWrapper = document.createElement("div");
6001
+ scrollWrapper.className = "fp-rtf-scroll-wrapper";
6002
+ scrollWrapper.style.minWidth = "100%";
6003
+ scrollWrapper.style.minHeight = "100%";
6004
+ scrollWrapper.style.width = "max-content";
6005
+ scrollWrapper.style.height = "max-content";
6006
+ scrollWrapper.style.display = "flex";
6007
+ scrollWrapper.style.justifyContent = "center";
6008
+ scrollWrapper.style.alignItems = "flex-start";
6009
+ scrollWrapper.style.padding = "16px 8px";
6010
+ scrollWrapper.style.boxSizing = "border-box";
6011
+ sizer.appendChild(wrapper);
6012
+ scrollWrapper.appendChild(sizer);
6013
+ ctx.container.style.overflow = "auto";
6014
+ ctx.container.style.padding = "0";
5746
6015
  ctx.container.style.backgroundColor = "#f1f5f9";
5747
- ctx.container.appendChild(wrapper);
6016
+ ctx.container.appendChild(scrollWrapper);
5748
6017
  let scale = 1;
5749
6018
  let rotation = 0;
5750
6019
  let pageElements = [];
@@ -5763,12 +6032,17 @@ var RtfPlugin = class {
5763
6032
  return Math.max(0.4, Math.min(3, sW));
5764
6033
  };
5765
6034
  const applyTransform = () => {
5766
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5767
- wrapper.style.transformOrigin = "top center";
6035
+ const elW = pageWidth;
5768
6036
  const baseH = pageHeight;
5769
- const scaledH = baseH * scale;
5770
- const extraH = Math.max(0, scaledH - baseH);
5771
- wrapper.style.marginBottom = `${extraH + 32}px`;
6037
+ const isRotated90 = rotation % 180 !== 0;
6038
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6039
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6040
+ sizer.style.width = `${boxW}px`;
6041
+ sizer.style.height = `${boxH}px`;
6042
+ wrapper.style.width = `${elW}px`;
6043
+ wrapper.style.height = `${baseH}px`;
6044
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6045
+ wrapper.style.transformOrigin = "center center";
5772
6046
  };
5773
6047
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
5774
6048
  if (!isUserZoomed) {
@@ -6039,7 +6313,7 @@ var RtfPlugin = class {
6039
6313
  }
6040
6314
  const cleanup = () => {
6041
6315
  resizeObserver?.disconnect();
6042
- wrapper.remove();
6316
+ scrollWrapper.remove();
6043
6317
  ctx.container.innerHTML = "";
6044
6318
  };
6045
6319
  ctx.signal.addEventListener("abort", cleanup);
@@ -6214,23 +6488,44 @@ var HtmlPreviewPlugin = class {
6214
6488
  ADD_TAGS: ["style", "link"],
6215
6489
  ADD_ATTR: ["target", "rel"]
6216
6490
  });
6491
+ const sizer = document.createElement("div");
6492
+ sizer.className = "fp-html-sizer";
6493
+ sizer.style.position = "relative";
6217
6494
  const iframe = document.createElement("iframe");
6218
6495
  iframe.className = "fp-html-iframe";
6219
- iframe.style.width = "100%";
6220
- iframe.style.height = "100%";
6221
6496
  iframe.style.border = "none";
6222
6497
  iframe.style.backgroundColor = "#ffffff";
6223
6498
  iframe.style.transformOrigin = "top left";
6224
6499
  iframe.style.transition = "transform 0.2s ease";
6225
6500
  iframe.sandbox.add("allow-same-origin");
6501
+ sizer.appendChild(iframe);
6226
6502
  ctx.container.style.overflow = "auto";
6227
6503
  ctx.container.style.width = "100%";
6228
6504
  ctx.container.style.height = "100%";
6229
- ctx.container.appendChild(iframe);
6505
+ ctx.container.innerHTML = "";
6506
+ ctx.container.appendChild(sizer);
6230
6507
  iframe.srcdoc = sanitized;
6231
6508
  let scale = 1;
6509
+ const applyTransform = () => {
6510
+ const baseW = Math.max(600, ctx.container.clientWidth || 800);
6511
+ const baseH = Math.max(400, ctx.container.clientHeight || 600);
6512
+ const scaledW = Math.round(baseW * scale);
6513
+ const scaledH = Math.round(baseH * scale);
6514
+ sizer.style.width = `${scaledW}px`;
6515
+ sizer.style.height = `${scaledH}px`;
6516
+ iframe.style.position = "absolute";
6517
+ iframe.style.top = "0";
6518
+ iframe.style.left = "0";
6519
+ iframe.style.width = `${baseW}px`;
6520
+ iframe.style.height = `${baseH}px`;
6521
+ iframe.style.transform = `scale(${scale})`;
6522
+ iframe.style.transformOrigin = "top left";
6523
+ };
6524
+ requestAnimationFrame(() => {
6525
+ applyTransform();
6526
+ });
6232
6527
  const cleanup = () => {
6233
- iframe.remove();
6528
+ sizer.remove();
6234
6529
  ctx.container.innerHTML = "";
6235
6530
  };
6236
6531
  ctx.signal.addEventListener("abort", cleanup);
@@ -6238,26 +6533,26 @@ var HtmlPreviewPlugin = class {
6238
6533
  destroy: cleanup,
6239
6534
  zoomIn: () => {
6240
6535
  scale += 0.1;
6241
- iframe.style.transform = `scale(${scale})`;
6536
+ applyTransform();
6242
6537
  },
6243
6538
  zoomOut: () => {
6244
6539
  scale = Math.max(0.2, scale - 0.1);
6245
- iframe.style.transform = `scale(${scale})`;
6540
+ applyTransform();
6246
6541
  },
6247
6542
  getZoom: () => scale,
6248
6543
  setZoom: (level) => {
6249
6544
  scale = level;
6250
- iframe.style.transform = `scale(${scale})`;
6545
+ applyTransform();
6251
6546
  },
6252
6547
  fitToPage: () => {
6253
6548
  scale = 1;
6254
- iframe.style.transform = "scale(1)";
6549
+ applyTransform();
6255
6550
  },
6256
6551
  resetZoom: () => {
6257
6552
  scale = 1;
6258
- iframe.style.transform = "scale(1)";
6259
6553
  ctx.container.scrollTop = 0;
6260
6554
  ctx.container.scrollLeft = 0;
6555
+ applyTransform();
6261
6556
  },
6262
6557
  copy: () => {
6263
6558
  navigator.clipboard.writeText(rawHtml);
@@ -6432,10 +6727,26 @@ var OpenDocumentPlugin = class {
6432
6727
  container.className = "fp-odf-container";
6433
6728
  container.style.width = "100%";
6434
6729
  container.style.height = "100%";
6435
- container.style.overflowX = "hidden";
6436
- container.style.overflowY = "auto";
6437
- container.style.padding = "16px 8px";
6730
+ container.style.overflow = "auto";
6438
6731
  container.style.backgroundColor = "#f1f5f9";
6732
+ const scrollWrapper = document.createElement("div");
6733
+ scrollWrapper.className = "fp-odf-scroll-wrapper";
6734
+ scrollWrapper.style.minWidth = "100%";
6735
+ scrollWrapper.style.minHeight = "100%";
6736
+ scrollWrapper.style.width = "max-content";
6737
+ scrollWrapper.style.height = "max-content";
6738
+ scrollWrapper.style.display = "flex";
6739
+ scrollWrapper.style.justifyContent = "center";
6740
+ scrollWrapper.style.alignItems = "flex-start";
6741
+ scrollWrapper.style.padding = "16px 8px";
6742
+ scrollWrapper.style.boxSizing = "border-box";
6743
+ const sizer = document.createElement("div");
6744
+ sizer.className = "fp-odf-sizer";
6745
+ sizer.style.position = "relative";
6746
+ sizer.style.flexShrink = "0";
6747
+ sizer.style.display = "flex";
6748
+ sizer.style.justifyContent = "center";
6749
+ sizer.style.alignItems = "center";
6439
6750
  const wrapper = document.createElement("div");
6440
6751
  wrapper.className = "fp-odf-wrapper";
6441
6752
  wrapper.style.margin = "0 auto";
@@ -6444,9 +6755,12 @@ var OpenDocumentPlugin = class {
6444
6755
  wrapper.style.backgroundColor = "#ffffff";
6445
6756
  wrapper.style.boxShadow = "0 2px 10px rgba(0,0,0,0.08)";
6446
6757
  wrapper.style.borderRadius = "4px";
6447
- wrapper.style.transformOrigin = "top center";
6758
+ wrapper.style.transformOrigin = "center center";
6448
6759
  wrapper.style.transition = "transform 0.15s ease";
6449
- container.appendChild(wrapper);
6760
+ wrapper.style.flexShrink = "0";
6761
+ sizer.appendChild(wrapper);
6762
+ scrollWrapper.appendChild(sizer);
6763
+ container.appendChild(scrollWrapper);
6450
6764
  ctx.container.appendChild(container);
6451
6765
  let scale = 1;
6452
6766
  let rotation = 0;
@@ -6472,13 +6786,18 @@ var OpenDocumentPlugin = class {
6472
6786
  return Math.max(0.4, Math.min(3, sW));
6473
6787
  };
6474
6788
  const applyTransform = () => {
6475
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6476
- wrapper.style.transformOrigin = "top center";
6477
6789
  const activeSlide = slides[currentPage - 1];
6790
+ const elW = isPresentation ? 960 : 816;
6478
6791
  const baseH = activeSlide?.offsetHeight || wrapper.offsetHeight || 1056;
6479
- const scaledH = baseH * scale;
6480
- const extraH = Math.max(0, scaledH - baseH);
6481
- wrapper.style.marginBottom = `${extraH + 32}px`;
6792
+ const isRotated90 = rotation % 180 !== 0;
6793
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6794
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6795
+ sizer.style.width = `${boxW}px`;
6796
+ sizer.style.height = `${boxH}px`;
6797
+ wrapper.style.width = `${elW}px`;
6798
+ wrapper.style.height = `${baseH}px`;
6799
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6800
+ wrapper.style.transformOrigin = "center center";
6482
6801
  };
6483
6802
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
6484
6803
  if (!isUserZoomed) {
@@ -7042,13 +7361,28 @@ var DocPlugin = class {
7042
7361
  container.className = "fp-doc-container";
7043
7362
  container.style.width = "100%";
7044
7363
  container.style.height = "100%";
7045
- container.style.overflowX = "hidden";
7046
- container.style.overflowY = "auto";
7047
- container.style.padding = "16px 8px";
7364
+ container.style.overflow = "auto";
7048
7365
  container.style.backgroundColor = "#f1f5f9";
7049
- container.style.display = "flex";
7050
- container.style.justifyContent = "center";
7051
- container.style.alignItems = "flex-start";
7366
+ const scrollWrapper = document.createElement("div");
7367
+ scrollWrapper.className = "fp-doc-scroll-wrapper";
7368
+ scrollWrapper.style.minWidth = "100%";
7369
+ scrollWrapper.style.minHeight = "100%";
7370
+ scrollWrapper.style.width = "max-content";
7371
+ scrollWrapper.style.height = "max-content";
7372
+ scrollWrapper.style.display = "flex";
7373
+ scrollWrapper.style.justifyContent = "center";
7374
+ scrollWrapper.style.alignItems = "flex-start";
7375
+ scrollWrapper.style.padding = "16px 8px";
7376
+ scrollWrapper.style.boxSizing = "border-box";
7377
+ const sizer = document.createElement("div");
7378
+ sizer.className = "fp-doc-sizer";
7379
+ sizer.style.position = "relative";
7380
+ sizer.style.flexShrink = "0";
7381
+ sizer.style.display = "flex";
7382
+ sizer.style.justifyContent = "center";
7383
+ sizer.style.alignItems = "center";
7384
+ scrollWrapper.appendChild(sizer);
7385
+ container.appendChild(scrollWrapper);
7052
7386
  ctx.container.appendChild(container);
7053
7387
  let scale = 1;
7054
7388
  let extractedRawText = "";
@@ -7096,10 +7430,11 @@ var DocPlugin = class {
7096
7430
  pageCard.style.padding = "72px 56px";
7097
7431
  pageCard.style.boxSizing = "border-box";
7098
7432
  pageCard.style.display = i === 0 ? "block" : "none";
7099
- pageCard.style.transformOrigin = "top center";
7433
+ pageCard.style.transformOrigin = "center center";
7100
7434
  pageCard.style.transition = "transform 0.15s ease";
7101
7435
  pageCard.style.fontFamily = 'Calibri, "Segoe UI", Arial, sans-serif';
7102
7436
  pageCard.style.color = "#1e293b";
7437
+ pageCard.style.flexShrink = "0";
7103
7438
  if (isFallback && i === 0) {
7104
7439
  pageCard.innerHTML = `
7105
7440
  <div style="border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 24px;">
@@ -7111,18 +7446,23 @@ var DocPlugin = class {
7111
7446
  } else {
7112
7447
  pageCard.innerHTML = this.formatDocToHtml(rawPages[i], ctx.metadata.name || "Document");
7113
7448
  }
7114
- container.appendChild(pageCard);
7449
+ sizer.appendChild(pageCard);
7115
7450
  pageCards.push(pageCard);
7116
7451
  }
7117
7452
  let rotation = 0;
7118
7453
  const applyTransform = () => {
7119
7454
  const activeCard = pageCards[currentPage - 1];
7120
7455
  if (activeCard) {
7121
- activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7456
+ const baseW = 816;
7122
7457
  const baseH = activeCard.offsetHeight || 1056;
7123
- const scaledH = baseH * scale;
7124
- const extraH = Math.max(0, scaledH - baseH);
7125
- activeCard.style.marginBottom = `${extraH + 32}px`;
7458
+ const isRotated90 = rotation % 180 !== 0;
7459
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * scale);
7460
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * scale);
7461
+ sizer.style.width = `${boxW}px`;
7462
+ sizer.style.height = `${boxH}px`;
7463
+ activeCard.style.width = `${baseW}px`;
7464
+ activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7465
+ activeCard.style.transformOrigin = "center center";
7126
7466
  }
7127
7467
  };
7128
7468
  const showPage = (pageNum) => {
@@ -7130,11 +7470,11 @@ var DocPlugin = class {
7130
7470
  pageCards.forEach((card, idx) => {
7131
7471
  if (idx + 1 === currentPage) {
7132
7472
  card.style.display = "block";
7133
- card.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7134
7473
  } else {
7135
7474
  card.style.display = "none";
7136
7475
  }
7137
7476
  });
7477
+ applyTransform();
7138
7478
  container.scrollTop = 0;
7139
7479
  ctx.emit("page-change", { page: currentPage, total: totalPages });
7140
7480
  };
@@ -7205,6 +7545,8 @@ var DocPlugin = class {
7205
7545
  fitMode = "width";
7206
7546
  scale = calculateFitScale("width");
7207
7547
  rotation = 0;
7548
+ container.scrollTop = 0;
7549
+ container.scrollLeft = 0;
7208
7550
  ctx.container.scrollTop = 0;
7209
7551
  ctx.container.scrollLeft = 0;
7210
7552
  applyTransform();
@@ -7729,17 +8071,30 @@ var PptPlugin = class {
7729
8071
  container.style.width = "100%";
7730
8072
  container.style.height = "100%";
7731
8073
  container.style.overflow = "auto";
7732
- container.style.display = "flex";
7733
- container.style.justifyContent = "center";
7734
- container.style.alignItems = "center";
7735
- container.style.padding = "32px 16px";
7736
8074
  container.style.backgroundColor = "#0f172a";
7737
8075
  container.style.boxSizing = "border-box";
8076
+ const scrollWrapper = document.createElement("div");
8077
+ scrollWrapper.className = "fp-ppt-scroll-wrapper";
8078
+ scrollWrapper.style.minWidth = "100%";
8079
+ scrollWrapper.style.minHeight = "100%";
8080
+ scrollWrapper.style.width = "max-content";
8081
+ scrollWrapper.style.height = "max-content";
8082
+ scrollWrapper.style.display = "flex";
8083
+ scrollWrapper.style.justifyContent = "center";
8084
+ scrollWrapper.style.alignItems = "center";
8085
+ scrollWrapper.style.padding = "32px 16px";
8086
+ scrollWrapper.style.boxSizing = "border-box";
8087
+ const sizer = document.createElement("div");
8088
+ sizer.className = "fp-ppt-sizer";
8089
+ sizer.style.position = "relative";
8090
+ sizer.style.flexShrink = "0";
8091
+ sizer.style.display = "flex";
8092
+ sizer.style.justifyContent = "center";
8093
+ sizer.style.alignItems = "center";
7738
8094
  const slideCard = document.createElement("div");
7739
8095
  slideCard.className = "fp-ppt-slide-card";
7740
8096
  slideCard.style.width = "960px";
7741
- slideCard.style.maxWidth = "calc(100% - 32px)";
7742
- slideCard.style.maxHeight = "calc(100% - 48px)";
8097
+ slideCard.style.height = "540px";
7743
8098
  slideCard.style.aspectRatio = "16 / 9";
7744
8099
  slideCard.style.backgroundColor = "#ffffff";
7745
8100
  slideCard.style.boxShadow = "0 12px 40px rgba(0,0,0,0.35)";
@@ -7749,7 +8104,9 @@ var PptPlugin = class {
7749
8104
  slideCard.style.transition = "transform 0.2s ease";
7750
8105
  slideCard.style.transformOrigin = "center center";
7751
8106
  slideCard.style.flexShrink = "0";
7752
- container.appendChild(slideCard);
8107
+ sizer.appendChild(slideCard);
8108
+ scrollWrapper.appendChild(sizer);
8109
+ container.appendChild(scrollWrapper);
7753
8110
  ctx.container.appendChild(container);
7754
8111
  let scale = 1;
7755
8112
  let rotation = 0;
@@ -7762,7 +8119,17 @@ var PptPlugin = class {
7762
8119
  return Math.min(1, Math.min(availW / 960, availH / 540));
7763
8120
  };
7764
8121
  const applyTransform = () => {
8122
+ const cW = 960;
8123
+ const cH = 540;
8124
+ const isRotated90 = rotation % 180 !== 0;
8125
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
8126
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
8127
+ sizer.style.width = `${boxW}px`;
8128
+ sizer.style.height = `${boxH}px`;
8129
+ slideCard.style.width = `${cW}px`;
8130
+ slideCard.style.height = `${cH}px`;
7765
8131
  slideCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
8132
+ slideCard.style.transformOrigin = "center center";
7766
8133
  };
7767
8134
  setTimeout(() => {
7768
8135
  scale = calculateFitScale();