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