@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/angular.js CHANGED
@@ -2132,16 +2132,22 @@ var PdfPlugin = class {
2132
2132
  container.className = "fp-pdf-container";
2133
2133
  container.style.width = "100%";
2134
2134
  container.style.height = "100%";
2135
- container.style.overflowX = "hidden";
2136
- container.style.overflowY = "auto";
2137
- container.style.display = "flex";
2138
- container.style.flexDirection = "column";
2139
- container.style.alignItems = "center";
2140
- container.style.justifyContent = "flex-start";
2141
- container.style.padding = "16px 8px";
2135
+ container.style.overflow = "auto";
2142
2136
  container.style.backgroundColor = "#0f172a";
2143
2137
  container.style.boxSizing = "border-box";
2144
2138
  container.style.position = "relative";
2139
+ const scrollWrapper = document.createElement("div");
2140
+ scrollWrapper.className = "fp-pdf-scroll-wrapper";
2141
+ scrollWrapper.style.minWidth = "100%";
2142
+ scrollWrapper.style.minHeight = "100%";
2143
+ scrollWrapper.style.width = "max-content";
2144
+ scrollWrapper.style.height = "max-content";
2145
+ scrollWrapper.style.display = "flex";
2146
+ scrollWrapper.style.flexDirection = "column";
2147
+ scrollWrapper.style.alignItems = "center";
2148
+ scrollWrapper.style.justifyContent = "flex-start";
2149
+ scrollWrapper.style.padding = "16px 8px";
2150
+ scrollWrapper.style.boxSizing = "border-box";
2145
2151
  const pageCard = document.createElement("div");
2146
2152
  pageCard.className = "fp-pdf-page-card";
2147
2153
  pageCard.style.boxShadow = "0 10px 35px rgba(0, 0, 0, 0.5)";
@@ -2154,7 +2160,8 @@ var PdfPlugin = class {
2154
2160
  pageCard.style.transition = "box-shadow 0.2s ease";
2155
2161
  let canvas = document.createElement("canvas");
2156
2162
  pageCard.appendChild(canvas);
2157
- container.appendChild(pageCard);
2163
+ scrollWrapper.appendChild(pageCard);
2164
+ container.appendChild(scrollWrapper);
2158
2165
  ctx.container.appendChild(container);
2159
2166
  const standardFontsUrl = typeof window !== "undefined" && window.__PDF_STANDARD_FONTS_URL__ || "./standard_fonts/";
2160
2167
  const cmapsUrl = typeof window !== "undefined" && window.__PDF_CMAPS_URL__ || "./cmaps/";
@@ -2663,17 +2670,86 @@ var MediaPlugin = class {
2663
2670
  element = document.createElement("div");
2664
2671
  element.textContent = "Unsupported media type";
2665
2672
  }
2666
- ctx.container.style.display = "flex";
2667
- ctx.container.style.alignItems = "center";
2668
- ctx.container.style.justifyContent = "center";
2669
- ctx.container.style.overflow = "hidden";
2670
- ctx.container.appendChild(element);
2673
+ const scrollWrapper = document.createElement("div");
2674
+ scrollWrapper.className = "fp-media-scroll-wrapper";
2675
+ scrollWrapper.style.minWidth = "100%";
2676
+ scrollWrapper.style.minHeight = "100%";
2677
+ scrollWrapper.style.width = "max-content";
2678
+ scrollWrapper.style.height = "max-content";
2679
+ scrollWrapper.style.display = "flex";
2680
+ scrollWrapper.style.justifyContent = "center";
2681
+ scrollWrapper.style.alignItems = "center";
2682
+ scrollWrapper.style.padding = "16px";
2683
+ scrollWrapper.style.boxSizing = "border-box";
2684
+ const sizer = document.createElement("div");
2685
+ sizer.className = "fp-media-sizer";
2686
+ sizer.style.position = "relative";
2687
+ sizer.style.flexShrink = "0";
2688
+ sizer.style.display = "flex";
2689
+ sizer.style.justifyContent = "center";
2690
+ sizer.style.alignItems = "center";
2691
+ sizer.appendChild(element);
2692
+ scrollWrapper.appendChild(sizer);
2693
+ ctx.container.style.overflow = "auto";
2694
+ ctx.container.style.padding = "0";
2695
+ ctx.container.innerHTML = "";
2696
+ ctx.container.appendChild(scrollWrapper);
2697
+ let naturalW = 800;
2698
+ let naturalH = 600;
2699
+ let baseW = 800;
2700
+ let baseH = 600;
2701
+ const updateBaseDimensions = () => {
2702
+ if (!isImage) return;
2703
+ const img = element;
2704
+ naturalW = img.naturalWidth || naturalW;
2705
+ naturalH = img.naturalHeight || naturalH;
2706
+ const availW = Math.max(100, ctx.container.clientWidth - 48);
2707
+ const availH = Math.max(100, ctx.container.clientHeight - 48);
2708
+ const fitRatio = Math.min(1, availW / naturalW, availH / naturalH);
2709
+ baseW = Math.max(1, Math.round(naturalW * fitRatio));
2710
+ baseH = Math.max(1, Math.round(naturalH * fitRatio));
2711
+ };
2671
2712
  const applyTransform = () => {
2672
- element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2713
+ if (isImage) {
2714
+ updateBaseDimensions();
2715
+ const isRotated90 = rotation % 180 !== 0;
2716
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * currentZoom);
2717
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * currentZoom);
2718
+ sizer.style.width = `${boxW}px`;
2719
+ sizer.style.height = `${boxH}px`;
2720
+ element.style.width = `${baseW}px`;
2721
+ element.style.height = `${baseH}px`;
2722
+ element.style.maxWidth = "none";
2723
+ element.style.maxHeight = "none";
2724
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2725
+ element.style.transformOrigin = "center center";
2726
+ element.style.flexShrink = "0";
2727
+ } else {
2728
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2729
+ }
2673
2730
  };
2731
+ if (isImage) {
2732
+ const img = element;
2733
+ if (img.complete && img.naturalWidth > 0) {
2734
+ updateBaseDimensions();
2735
+ applyTransform();
2736
+ } else {
2737
+ img.onload = () => {
2738
+ updateBaseDimensions();
2739
+ applyTransform();
2740
+ };
2741
+ }
2742
+ }
2743
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
2744
+ if (currentZoom === 1) {
2745
+ applyTransform();
2746
+ }
2747
+ }) : null;
2748
+ ro?.observe(ctx.container);
2674
2749
  const cleanup = () => {
2750
+ ro?.disconnect();
2675
2751
  if (url) URL.revokeObjectURL(url);
2676
- element.remove();
2752
+ scrollWrapper.remove();
2677
2753
  ctx.container.innerHTML = "";
2678
2754
  };
2679
2755
  ctx.signal.addEventListener("abort", cleanup);
@@ -2866,7 +2942,7 @@ var DocxPlugin = class {
2866
2942
  async render(ctx) {
2867
2943
  const wrapper = document.createElement("div");
2868
2944
  wrapper.className = "fp-docx-wrapper";
2869
- wrapper.style.transformOrigin = "top center";
2945
+ wrapper.style.transformOrigin = "center center";
2870
2946
  wrapper.style.transition = "transform 0.2s ease";
2871
2947
  wrapper.style.padding = "0";
2872
2948
  wrapper.style.maxWidth = "none";
@@ -2876,11 +2952,31 @@ var DocxPlugin = class {
2876
2952
  wrapper.style.flexDirection = "column";
2877
2953
  wrapper.style.alignItems = "center";
2878
2954
  wrapper.style.boxSizing = "border-box";
2879
- ctx.container.style.overflowX = "hidden";
2880
- ctx.container.style.overflowY = "auto";
2881
- ctx.container.style.padding = "16px 8px";
2955
+ wrapper.style.flexShrink = "0";
2956
+ const sizer = document.createElement("div");
2957
+ sizer.className = "fp-docx-sizer";
2958
+ sizer.style.position = "relative";
2959
+ sizer.style.flexShrink = "0";
2960
+ sizer.style.display = "flex";
2961
+ sizer.style.justifyContent = "center";
2962
+ sizer.style.alignItems = "center";
2963
+ const scrollWrapper = document.createElement("div");
2964
+ scrollWrapper.className = "fp-docx-scroll-wrapper";
2965
+ scrollWrapper.style.minWidth = "100%";
2966
+ scrollWrapper.style.minHeight = "100%";
2967
+ scrollWrapper.style.width = "max-content";
2968
+ scrollWrapper.style.height = "max-content";
2969
+ scrollWrapper.style.display = "flex";
2970
+ scrollWrapper.style.justifyContent = "center";
2971
+ scrollWrapper.style.alignItems = "flex-start";
2972
+ scrollWrapper.style.padding = "16px 8px";
2973
+ scrollWrapper.style.boxSizing = "border-box";
2974
+ sizer.appendChild(wrapper);
2975
+ scrollWrapper.appendChild(sizer);
2976
+ ctx.container.style.overflow = "auto";
2977
+ ctx.container.style.padding = "0";
2882
2978
  ctx.container.style.backgroundColor = "#f1f5f9";
2883
- ctx.container.appendChild(wrapper);
2979
+ ctx.container.appendChild(scrollWrapper);
2884
2980
  const styleOverride = document.createElement("style");
2885
2981
  styleOverride.textContent = `
2886
2982
  .fp-docx-wrapper .docx-wrapper {
@@ -2919,8 +3015,8 @@ var DocxPlugin = class {
2919
3015
  renderEndnotes: true,
2920
3016
  useBase64URL: true
2921
3017
  });
2922
- if (!ctx.container.contains(wrapper)) {
2923
- ctx.container.appendChild(wrapper);
3018
+ if (!sizer.contains(wrapper)) {
3019
+ sizer.appendChild(wrapper);
2924
3020
  }
2925
3021
  if (wrapper.children.length > 0 && (wrapper.textContent?.trim().length ?? 0) > 0) {
2926
3022
  renderedSuccessfully = true;
@@ -2957,8 +3053,8 @@ var DocxPlugin = class {
2957
3053
  try {
2958
3054
  wrapper.innerHTML = "";
2959
3055
  this.renderXmlFallback(ctx, wrapper, createdBlobUrls);
2960
- if (!ctx.container.contains(wrapper)) {
2961
- ctx.container.appendChild(wrapper);
3056
+ if (!sizer.contains(wrapper)) {
3057
+ sizer.appendChild(wrapper);
2962
3058
  }
2963
3059
  renderedSuccessfully = true;
2964
3060
  } catch (fallbackErr) {
@@ -2973,8 +3069,8 @@ var DocxPlugin = class {
2973
3069
  </p>
2974
3070
  </div>
2975
3071
  `;
2976
- if (!ctx.container.contains(wrapper)) {
2977
- ctx.container.appendChild(wrapper);
3072
+ if (!sizer.contains(wrapper)) {
3073
+ sizer.appendChild(wrapper);
2978
3074
  }
2979
3075
  }
2980
3076
  }
@@ -3077,15 +3173,18 @@ var DocxPlugin = class {
3077
3173
  return Math.max(0.35, Math.min(3, sW));
3078
3174
  };
3079
3175
  const applyTransform = () => {
3080
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3081
- wrapper.style.transformOrigin = "top center";
3082
3176
  const activeEl = pageElements[currentPage - 1] || wrapper.querySelector("section.docx") || wrapper;
3177
+ const elW = activeEl.offsetWidth || 816;
3083
3178
  const elH = activeEl.offsetHeight || 1056;
3084
- if (scale > 1) {
3085
- wrapper.style.marginBottom = `${Math.round(elH * scale - elH + 32)}px`;
3086
- } else {
3087
- wrapper.style.marginBottom = "32px";
3088
- }
3179
+ const isRotated90 = rotation % 180 !== 0;
3180
+ const boxW = Math.round((isRotated90 ? elH : elW) * scale);
3181
+ const boxH = Math.round((isRotated90 ? elW : elH) * scale);
3182
+ sizer.style.width = `${boxW}px`;
3183
+ sizer.style.height = `${boxH}px`;
3184
+ wrapper.style.width = `${elW}px`;
3185
+ wrapper.style.height = `${elH}px`;
3186
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3187
+ wrapper.style.transformOrigin = "center center";
3089
3188
  };
3090
3189
  let resizeObserver = null;
3091
3190
  if (typeof ResizeObserver !== "undefined") {
@@ -3110,7 +3209,7 @@ var DocxPlugin = class {
3110
3209
  for (const url of createdBlobUrls) {
3111
3210
  URL.revokeObjectURL(url);
3112
3211
  }
3113
- wrapper.remove();
3212
+ scrollWrapper.remove();
3114
3213
  styleOverride.remove();
3115
3214
  ctx.container.innerHTML = "";
3116
3215
  };
@@ -3657,7 +3756,7 @@ var ExcelPlugin = class {
3657
3756
  contentArea.style.flex = "1";
3658
3757
  contentArea.style.overflow = "auto";
3659
3758
  contentArea.style.padding = "16px";
3660
- contentArea.style.transformOrigin = "top left";
3759
+ contentArea.style.boxSizing = "border-box";
3661
3760
  const tabsArea = document.createElement("div");
3662
3761
  tabsArea.className = "fp-excel-tabs";
3663
3762
  tabsArea.style.display = "flex";
@@ -3671,18 +3770,35 @@ var ExcelPlugin = class {
3671
3770
  container.appendChild(tabsArea);
3672
3771
  ctx.container.appendChild(container);
3673
3772
  let scale = 1;
3773
+ let isUserZoomed = false;
3674
3774
  let currentSheetIndex = 1;
3675
3775
  let sheetNames = [];
3676
3776
  let wb = null;
3677
3777
  const applyTransform = () => {
3678
- contentArea.style.transform = `scale(${scale})`;
3679
- contentArea.style.transformOrigin = "top left";
3778
+ const sizer = contentArea.querySelector(".fp-excel-sizer");
3779
+ const table = contentArea.querySelector("table");
3780
+ if (!sizer || !table) return;
3781
+ if (!table._baseWidth && table.offsetWidth > 0) {
3782
+ table._baseWidth = table.offsetWidth;
3783
+ table._baseHeight = table.offsetHeight;
3784
+ }
3785
+ const baseW = table._baseWidth || table.offsetWidth || 800;
3786
+ const baseH = table._baseHeight || table.offsetHeight || 600;
3787
+ const scaledW = Math.round(baseW * scale);
3788
+ const scaledH = Math.round(baseH * scale);
3789
+ sizer.style.width = `${scaledW}px`;
3790
+ sizer.style.height = `${scaledH}px`;
3791
+ table.style.position = "absolute";
3792
+ table.style.top = "0";
3793
+ table.style.left = "0";
3794
+ table.style.transform = `scale(${scale})`;
3795
+ table.style.transformOrigin = "top left";
3680
3796
  };
3681
3797
  const calculateFitScale = () => {
3682
3798
  const table = contentArea.querySelector("table");
3683
3799
  if (!table) return 1;
3684
3800
  const availW = Math.max(280, container.clientWidth - 48);
3685
- const tW = table.offsetWidth || 800;
3801
+ const tW = table._baseWidth || table.offsetWidth || 800;
3686
3802
  return Math.max(0.4, Math.min(1, availW / tW));
3687
3803
  };
3688
3804
  try {
@@ -3702,9 +3818,13 @@ var ExcelPlugin = class {
3702
3818
  contentArea.innerHTML = '<div style="padding: 24px; color: #888;">Empty sheet</div>';
3703
3819
  return;
3704
3820
  }
3821
+ const sizer = document.createElement("div");
3822
+ sizer.className = "fp-excel-sizer";
3823
+ sizer.style.position = "relative";
3705
3824
  const html = XLSX.utils.sheet_to_html(ws, { id: "fp-sheet-table", editable: false });
3706
- contentArea.innerHTML = html;
3707
- const table = contentArea.querySelector("table");
3825
+ sizer.innerHTML = html;
3826
+ contentArea.appendChild(sizer);
3827
+ const table = sizer.querySelector("table");
3708
3828
  if (table) {
3709
3829
  table.style.borderCollapse = "collapse";
3710
3830
  table.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
@@ -3739,13 +3859,17 @@ var ExcelPlugin = class {
3739
3859
  });
3740
3860
  ctx.emit("page-change", { page: currentSheetIndex, total: sheetNames.length });
3741
3861
  requestAnimationFrame(() => {
3742
- scale = calculateFitScale();
3862
+ if (!isUserZoomed) {
3863
+ scale = calculateFitScale();
3864
+ }
3743
3865
  applyTransform();
3744
3866
  });
3745
3867
  };
3746
3868
  const ro = new ResizeObserver(() => {
3747
- scale = calculateFitScale();
3748
- applyTransform();
3869
+ if (!isUserZoomed) {
3870
+ scale = calculateFitScale();
3871
+ applyTransform();
3872
+ }
3749
3873
  });
3750
3874
  ro.observe(container);
3751
3875
  if (sheetNames.length > 0) {
@@ -3782,23 +3906,28 @@ var ExcelPlugin = class {
3782
3906
  return {
3783
3907
  destroy: cleanup,
3784
3908
  zoomIn: () => {
3909
+ isUserZoomed = true;
3785
3910
  scale += 0.15;
3786
3911
  applyTransform();
3787
3912
  },
3788
3913
  zoomOut: () => {
3914
+ isUserZoomed = true;
3789
3915
  scale = Math.max(0.2, scale - 0.15);
3790
3916
  applyTransform();
3791
3917
  },
3792
3918
  getZoom: () => scale,
3793
3919
  setZoom: (level) => {
3920
+ isUserZoomed = true;
3794
3921
  scale = level;
3795
3922
  applyTransform();
3796
3923
  },
3797
3924
  fitToPage: () => {
3925
+ isUserZoomed = false;
3798
3926
  scale = calculateFitScale();
3799
3927
  applyTransform();
3800
3928
  },
3801
3929
  resetZoom: () => {
3930
+ isUserZoomed = false;
3802
3931
  scale = calculateFitScale();
3803
3932
  contentArea.scrollTop = 0;
3804
3933
  contentArea.scrollLeft = 0;
@@ -4030,21 +4159,41 @@ var CsvPlugin = class {
4030
4159
  container.appendChild(tableWrapper);
4031
4160
  ctx.container.appendChild(container);
4032
4161
  let scale = 1;
4162
+ let isUserZoomed = false;
4033
4163
  const calculateFitScale = () => {
4034
4164
  const availW = Math.max(280, container.clientWidth - 48);
4035
- const tW = table.offsetWidth || 800;
4165
+ const tW = table._baseWidth || table.offsetWidth || 800;
4036
4166
  return Math.max(0.4, Math.min(1, availW / tW));
4037
4167
  };
4038
4168
  const applyScale = () => {
4039
- tableWrapper.style.transform = `scale(${scale})`;
4169
+ if (!table._baseWidth && table.offsetWidth > 0) {
4170
+ table._baseWidth = table.offsetWidth;
4171
+ table._baseHeight = table.offsetHeight;
4172
+ }
4173
+ const baseW = table._baseWidth || table.offsetWidth || 800;
4174
+ const baseH = table._baseHeight || table.offsetHeight || 600;
4175
+ const scaledW = Math.round(baseW * scale);
4176
+ const scaledH = Math.round(baseH * scale);
4177
+ tableWrapper.style.position = "relative";
4178
+ tableWrapper.style.width = `${scaledW}px`;
4179
+ tableWrapper.style.height = `${scaledH}px`;
4180
+ table.style.position = "absolute";
4181
+ table.style.top = "0";
4182
+ table.style.left = "0";
4183
+ table.style.transform = `scale(${scale})`;
4184
+ table.style.transformOrigin = "top left";
4040
4185
  };
4041
4186
  requestAnimationFrame(() => {
4042
- scale = calculateFitScale();
4187
+ if (!isUserZoomed) {
4188
+ scale = calculateFitScale();
4189
+ }
4043
4190
  applyScale();
4044
4191
  });
4045
4192
  const ro = new ResizeObserver(() => {
4046
- scale = calculateFitScale();
4047
- applyScale();
4193
+ if (!isUserZoomed) {
4194
+ scale = calculateFitScale();
4195
+ applyScale();
4196
+ }
4048
4197
  });
4049
4198
  ro.observe(container);
4050
4199
  const cleanup = () => {
@@ -4117,23 +4266,28 @@ var CsvPlugin = class {
4117
4266
  }];
4118
4267
  },
4119
4268
  zoomIn: () => {
4269
+ isUserZoomed = true;
4120
4270
  scale += 0.1;
4121
4271
  applyScale();
4122
4272
  },
4123
4273
  zoomOut: () => {
4274
+ isUserZoomed = true;
4124
4275
  scale = Math.max(0.2, scale - 0.1);
4125
4276
  applyScale();
4126
4277
  },
4127
4278
  getZoom: () => scale,
4128
4279
  setZoom: (level) => {
4280
+ isUserZoomed = true;
4129
4281
  scale = level;
4130
4282
  applyScale();
4131
4283
  },
4132
4284
  fitToPage: () => {
4285
+ isUserZoomed = false;
4133
4286
  scale = calculateFitScale();
4134
4287
  applyScale();
4135
4288
  },
4136
4289
  resetZoom: () => {
4290
+ isUserZoomed = false;
4137
4291
  scale = calculateFitScale();
4138
4292
  container.scrollTop = 0;
4139
4293
  container.scrollLeft = 0;
@@ -4369,15 +4523,27 @@ var CodePlugin = class {
4369
4523
  let isUserZoomed = false;
4370
4524
  const pre = document.createElement("pre");
4371
4525
  const code = document.createElement("code");
4526
+ const sizer = document.createElement("div");
4527
+ const scrollWrapper = document.createElement("div");
4372
4528
  if (isTxt) {
4373
- container.style.overflowX = "hidden";
4374
- container.style.overflowY = "auto";
4529
+ container.style.overflow = "auto";
4375
4530
  container.style.backgroundColor = "#f1f5f9";
4376
- container.style.padding = "16px 8px";
4377
- container.style.boxSizing = "border-box";
4378
- container.style.display = "flex";
4379
- container.style.flexDirection = "column";
4380
- container.style.alignItems = "center";
4531
+ scrollWrapper.className = "fp-code-scroll-wrapper";
4532
+ scrollWrapper.style.minWidth = "100%";
4533
+ scrollWrapper.style.minHeight = "100%";
4534
+ scrollWrapper.style.width = "max-content";
4535
+ scrollWrapper.style.height = "max-content";
4536
+ scrollWrapper.style.display = "flex";
4537
+ scrollWrapper.style.justifyContent = "center";
4538
+ scrollWrapper.style.alignItems = "flex-start";
4539
+ scrollWrapper.style.padding = "16px 8px";
4540
+ scrollWrapper.style.boxSizing = "border-box";
4541
+ sizer.className = "fp-code-sizer";
4542
+ sizer.style.position = "relative";
4543
+ sizer.style.flexShrink = "0";
4544
+ sizer.style.display = "flex";
4545
+ sizer.style.justifyContent = "center";
4546
+ sizer.style.alignItems = "center";
4381
4547
  pre.style.margin = "0 auto";
4382
4548
  pre.style.fontFamily = "Consolas, 'Courier New', monospace";
4383
4549
  pre.style.fontSize = "13px";
@@ -4392,8 +4558,9 @@ var CodePlugin = class {
4392
4558
  pre.style.boxSizing = "border-box";
4393
4559
  pre.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
4394
4560
  pre.style.borderRadius = "4px";
4395
- pre.style.transformOrigin = "top center";
4561
+ pre.style.transformOrigin = "center center";
4396
4562
  pre.style.transition = "transform 0.15s ease";
4563
+ pre.style.flexShrink = "0";
4397
4564
  } else {
4398
4565
  container.style.overflow = "auto";
4399
4566
  container.style.backgroundColor = "#1e1e1e";
@@ -4426,7 +4593,13 @@ var CodePlugin = class {
4426
4593
  };
4427
4594
  renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
4428
4595
  pre.appendChild(code);
4429
- container.appendChild(pre);
4596
+ if (isTxt) {
4597
+ sizer.appendChild(pre);
4598
+ scrollWrapper.appendChild(sizer);
4599
+ container.appendChild(scrollWrapper);
4600
+ } else {
4601
+ container.appendChild(pre);
4602
+ }
4430
4603
  const showPage = (pageNum) => {
4431
4604
  currentPage = Math.max(1, Math.min(totalPages, pageNum));
4432
4605
  renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
@@ -4443,10 +4616,16 @@ var CodePlugin = class {
4443
4616
  };
4444
4617
  const updateTransform = () => {
4445
4618
  if (isTxt) {
4619
+ const elW = 816;
4620
+ const baseH = pre.offsetHeight || 1056;
4621
+ const isRotated90 = rotation % 180 !== 0;
4622
+ const boxW = Math.round((isRotated90 ? baseH : elW) * zoomLevel);
4623
+ const boxH = Math.round((isRotated90 ? elW : baseH) * zoomLevel);
4624
+ sizer.style.width = `${boxW}px`;
4625
+ sizer.style.height = `${boxH}px`;
4626
+ pre.style.width = `${elW}px`;
4446
4627
  pre.style.transform = `scale(${zoomLevel}) rotate(${rotation}deg)`;
4447
- const scaledH = 1056 * zoomLevel;
4448
- const extraH = Math.max(0, scaledH - 1056);
4449
- pre.style.marginBottom = `${extraH + 32}px`;
4628
+ pre.style.transformOrigin = "center center";
4450
4629
  } else {
4451
4630
  pre.style.transform = `rotate(${rotation}deg)`;
4452
4631
  pre.style.fontSize = `${fontSize}px`;
@@ -4652,16 +4831,56 @@ var ArchivePlugin = class {
4652
4831
  width: 100%;
4653
4832
  height: 100%;
4654
4833
  overflow: auto;
4655
- padding: 24px;
4656
4834
  box-sizing: border-box;
4657
4835
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
4658
- transform-origin: top left;
4659
- transition: transform 0.2s ease;
4660
4836
  `;
4837
+ const scrollWrapper = document.createElement("div");
4838
+ scrollWrapper.className = "fp-archive-scroll-wrapper";
4839
+ scrollWrapper.style.cssText = `
4840
+ min-width: 100%;
4841
+ min-height: 100%;
4842
+ width: max-content;
4843
+ height: max-content;
4844
+ display: flex;
4845
+ justify-content: center;
4846
+ align-items: flex-start;
4847
+ padding: 24px;
4848
+ box-sizing: border-box;
4849
+ `;
4850
+ const sizer = document.createElement("div");
4851
+ sizer.className = "fp-archive-sizer";
4852
+ sizer.style.cssText = `
4853
+ position: relative;
4854
+ flex-shrink: 0;
4855
+ display: flex;
4856
+ justify-content: center;
4857
+ align-items: flex-start;
4858
+ `;
4859
+ const card = document.createElement("div");
4860
+ card.className = "fp-archive-card";
4861
+ card.style.cssText = `
4862
+ width: 900px;
4863
+ box-sizing: border-box;
4864
+ transform-origin: top center;
4865
+ transition: transform 0.15s ease;
4866
+ flex-shrink: 0;
4867
+ `;
4868
+ sizer.appendChild(card);
4869
+ scrollWrapper.appendChild(sizer);
4870
+ wrapper.appendChild(scrollWrapper);
4661
4871
  ctx.container.innerHTML = "";
4662
4872
  ctx.container.style.overflow = "auto";
4663
4873
  ctx.container.appendChild(wrapper);
4664
4874
  let scale = 1;
4875
+ const applyTransform = () => {
4876
+ const boxW = Math.round(900 * scale);
4877
+ const cardH = card.offsetHeight || 600;
4878
+ const boxH = Math.round(cardH * scale);
4879
+ sizer.style.width = `${boxW}px`;
4880
+ sizer.style.height = `${boxH}px`;
4881
+ card.style.transform = `scale(${scale})`;
4882
+ card.style.transformOrigin = "top center";
4883
+ };
4665
4884
  const entries = await new Promise((resolve, reject) => {
4666
4885
  unzip(new Uint8Array(ctx.buffer), (err, unzipped) => {
4667
4886
  if (err) {
@@ -4685,7 +4904,7 @@ var ArchivePlugin = class {
4685
4904
  });
4686
4905
  const totalUncompressedSize = entries.reduce((acc, e) => acc + e.size, 0);
4687
4906
  const renderUI = (filteredEntries) => {
4688
- wrapper.innerHTML = `
4907
+ card.innerHTML = `
4689
4908
  <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;">
4690
4909
  <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;">
4691
4910
  <div>
@@ -4715,7 +4934,7 @@ var ArchivePlugin = class {
4715
4934
  </div>
4716
4935
  </div>
4717
4936
  `;
4718
- const tbody = wrapper.querySelector("#fp-archive-body");
4937
+ const tbody = card.querySelector("#fp-archive-body");
4719
4938
  if (filteredEntries.length === 0) {
4720
4939
  tbody.innerHTML = `<tr><td colspan="3" style="padding: 24px; text-align: center; color: #9ca3af;">No matching files found</td></tr>`;
4721
4940
  } else {
@@ -4744,19 +4963,20 @@ var ArchivePlugin = class {
4744
4963
  }
4745
4964
  });
4746
4965
  });
4747
- const searchInput = wrapper.querySelector("#fp-archive-search");
4966
+ const searchInput = card.querySelector("#fp-archive-search");
4748
4967
  if (searchInput) {
4749
4968
  searchInput.addEventListener("input", () => {
4750
4969
  const q = searchInput.value.toLowerCase().trim();
4751
4970
  const filtered = q ? entries.filter((e) => e.path.toLowerCase().includes(q)) : entries;
4752
4971
  renderUI(filtered);
4753
- const newSearch = wrapper.querySelector("#fp-archive-search");
4972
+ const newSearch = card.querySelector("#fp-archive-search");
4754
4973
  if (newSearch) {
4755
4974
  newSearch.value = q;
4756
4975
  newSearch.focus();
4757
4976
  }
4758
4977
  });
4759
4978
  }
4979
+ applyTransform();
4760
4980
  };
4761
4981
  renderUI(entries);
4762
4982
  const cleanup = () => {
@@ -4768,26 +4988,26 @@ var ArchivePlugin = class {
4768
4988
  destroy: cleanup,
4769
4989
  zoomIn: () => {
4770
4990
  scale += 0.1;
4771
- wrapper.style.transform = `scale(${scale})`;
4991
+ applyTransform();
4772
4992
  },
4773
4993
  zoomOut: () => {
4774
4994
  scale = Math.max(0.3, scale - 0.1);
4775
- wrapper.style.transform = `scale(${scale})`;
4995
+ applyTransform();
4776
4996
  },
4777
4997
  getZoom: () => scale,
4778
4998
  setZoom: (level) => {
4779
4999
  scale = level;
4780
- wrapper.style.transform = `scale(${scale})`;
5000
+ applyTransform();
4781
5001
  },
4782
5002
  fitToPage: () => {
4783
5003
  scale = 1;
4784
- wrapper.style.transform = "scale(1)";
5004
+ applyTransform();
4785
5005
  },
4786
5006
  resetZoom: () => {
4787
5007
  scale = 1;
4788
- wrapper.style.transform = "scale(1)";
4789
- ctx.container.scrollTop = 0;
4790
- ctx.container.scrollLeft = 0;
5008
+ wrapper.scrollTop = 0;
5009
+ wrapper.scrollLeft = 0;
5010
+ applyTransform();
4791
5011
  },
4792
5012
  download: () => {
4793
5013
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -5146,12 +5366,30 @@ var PptxPlugin = class {
5146
5366
  width: 100%;
5147
5367
  height: 100%;
5148
5368
  overflow: auto;
5369
+ box-sizing: border-box;
5370
+ background: var(--fp-bg-canvas, #525659);
5371
+ `;
5372
+ const scrollWrapper = document.createElement("div");
5373
+ scrollWrapper.className = "fp-pptx-scroll-wrapper";
5374
+ scrollWrapper.style.cssText = `
5375
+ min-width: 100%;
5376
+ min-height: 100%;
5377
+ width: max-content;
5378
+ height: max-content;
5149
5379
  display: flex;
5150
5380
  justify-content: center;
5151
- align-items: flex-start;
5381
+ align-items: center;
5152
5382
  padding: 24px;
5153
5383
  box-sizing: border-box;
5154
- background: var(--fp-bg-canvas, #525659);
5384
+ `;
5385
+ const sizer = document.createElement("div");
5386
+ sizer.className = "fp-pptx-sizer";
5387
+ sizer.style.cssText = `
5388
+ position: relative;
5389
+ flex-shrink: 0;
5390
+ display: flex;
5391
+ justify-content: center;
5392
+ align-items: center;
5155
5393
  `;
5156
5394
  const slideContainer = document.createElement("div");
5157
5395
  slideContainer.className = "fp-slide-container";
@@ -5160,14 +5398,15 @@ var PptxPlugin = class {
5160
5398
  border-radius: 4px;
5161
5399
  overflow: hidden;
5162
5400
  background: #ffffff;
5163
- transform-origin: top center;
5401
+ transform-origin: center center;
5164
5402
  transition: transform 0.2s ease;
5165
- max-width: calc(100% - 32px);
5166
- max-height: calc(100% - 48px);
5403
+ flex-shrink: 0;
5167
5404
  `;
5168
5405
  const canvas = document.createElement("canvas");
5169
5406
  slideContainer.appendChild(canvas);
5170
- wrapper.appendChild(slideContainer);
5407
+ sizer.appendChild(slideContainer);
5408
+ scrollWrapper.appendChild(sizer);
5409
+ wrapper.appendChild(scrollWrapper);
5171
5410
  ctx.container.innerHTML = "";
5172
5411
  ctx.container.style.overflow = "auto";
5173
5412
  ctx.container.appendChild(wrapper);
@@ -5179,7 +5418,17 @@ var PptxPlugin = class {
5179
5418
  return Math.min(1, Math.min(availW / cW, availH / cH));
5180
5419
  };
5181
5420
  const applyTransform = () => {
5421
+ const cW = canvas.offsetWidth || 1280;
5422
+ const cH = canvas.offsetHeight || 720;
5423
+ const isRotated90 = rotation % 180 !== 0;
5424
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
5425
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
5426
+ sizer.style.width = `${boxW}px`;
5427
+ sizer.style.height = `${boxH}px`;
5428
+ slideContainer.style.width = `${cW}px`;
5429
+ slideContainer.style.height = `${cH}px`;
5182
5430
  slideContainer.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5431
+ slideContainer.style.transformOrigin = "center center";
5183
5432
  };
5184
5433
  const renderCurrentSlide = async () => {
5185
5434
  try {
@@ -5785,13 +6034,33 @@ var RtfPlugin = class {
5785
6034
  wrapper.style.flexDirection = "column";
5786
6035
  wrapper.style.alignItems = "center";
5787
6036
  wrapper.style.backgroundColor = "transparent";
5788
- wrapper.style.transformOrigin = "top center";
6037
+ wrapper.style.transformOrigin = "center center";
5789
6038
  wrapper.style.transition = "transform 0.15s ease";
5790
- ctx.container.style.overflowX = "hidden";
5791
- ctx.container.style.overflowY = "auto";
5792
- ctx.container.style.padding = "16px 8px";
6039
+ wrapper.style.flexShrink = "0";
6040
+ const sizer = document.createElement("div");
6041
+ sizer.className = "fp-rtf-sizer";
6042
+ sizer.style.position = "relative";
6043
+ sizer.style.flexShrink = "0";
6044
+ sizer.style.display = "flex";
6045
+ sizer.style.justifyContent = "center";
6046
+ sizer.style.alignItems = "center";
6047
+ const scrollWrapper = document.createElement("div");
6048
+ scrollWrapper.className = "fp-rtf-scroll-wrapper";
6049
+ scrollWrapper.style.minWidth = "100%";
6050
+ scrollWrapper.style.minHeight = "100%";
6051
+ scrollWrapper.style.width = "max-content";
6052
+ scrollWrapper.style.height = "max-content";
6053
+ scrollWrapper.style.display = "flex";
6054
+ scrollWrapper.style.justifyContent = "center";
6055
+ scrollWrapper.style.alignItems = "flex-start";
6056
+ scrollWrapper.style.padding = "16px 8px";
6057
+ scrollWrapper.style.boxSizing = "border-box";
6058
+ sizer.appendChild(wrapper);
6059
+ scrollWrapper.appendChild(sizer);
6060
+ ctx.container.style.overflow = "auto";
6061
+ ctx.container.style.padding = "0";
5793
6062
  ctx.container.style.backgroundColor = "#f1f5f9";
5794
- ctx.container.appendChild(wrapper);
6063
+ ctx.container.appendChild(scrollWrapper);
5795
6064
  let scale = 1;
5796
6065
  let rotation = 0;
5797
6066
  let pageElements = [];
@@ -5810,12 +6079,17 @@ var RtfPlugin = class {
5810
6079
  return Math.max(0.4, Math.min(3, sW));
5811
6080
  };
5812
6081
  const applyTransform = () => {
5813
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5814
- wrapper.style.transformOrigin = "top center";
6082
+ const elW = pageWidth;
5815
6083
  const baseH = pageHeight;
5816
- const scaledH = baseH * scale;
5817
- const extraH = Math.max(0, scaledH - baseH);
5818
- wrapper.style.marginBottom = `${extraH + 32}px`;
6084
+ const isRotated90 = rotation % 180 !== 0;
6085
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6086
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6087
+ sizer.style.width = `${boxW}px`;
6088
+ sizer.style.height = `${boxH}px`;
6089
+ wrapper.style.width = `${elW}px`;
6090
+ wrapper.style.height = `${baseH}px`;
6091
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6092
+ wrapper.style.transformOrigin = "center center";
5819
6093
  };
5820
6094
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
5821
6095
  if (!isUserZoomed) {
@@ -6086,7 +6360,7 @@ var RtfPlugin = class {
6086
6360
  }
6087
6361
  const cleanup = () => {
6088
6362
  resizeObserver?.disconnect();
6089
- wrapper.remove();
6363
+ scrollWrapper.remove();
6090
6364
  ctx.container.innerHTML = "";
6091
6365
  };
6092
6366
  ctx.signal.addEventListener("abort", cleanup);
@@ -6261,23 +6535,44 @@ var HtmlPreviewPlugin = class {
6261
6535
  ADD_TAGS: ["style", "link"],
6262
6536
  ADD_ATTR: ["target", "rel"]
6263
6537
  });
6538
+ const sizer = document.createElement("div");
6539
+ sizer.className = "fp-html-sizer";
6540
+ sizer.style.position = "relative";
6264
6541
  const iframe = document.createElement("iframe");
6265
6542
  iframe.className = "fp-html-iframe";
6266
- iframe.style.width = "100%";
6267
- iframe.style.height = "100%";
6268
6543
  iframe.style.border = "none";
6269
6544
  iframe.style.backgroundColor = "#ffffff";
6270
6545
  iframe.style.transformOrigin = "top left";
6271
6546
  iframe.style.transition = "transform 0.2s ease";
6272
6547
  iframe.sandbox.add("allow-same-origin");
6548
+ sizer.appendChild(iframe);
6273
6549
  ctx.container.style.overflow = "auto";
6274
6550
  ctx.container.style.width = "100%";
6275
6551
  ctx.container.style.height = "100%";
6276
- ctx.container.appendChild(iframe);
6552
+ ctx.container.innerHTML = "";
6553
+ ctx.container.appendChild(sizer);
6277
6554
  iframe.srcdoc = sanitized;
6278
6555
  let scale = 1;
6556
+ const applyTransform = () => {
6557
+ const baseW = Math.max(600, ctx.container.clientWidth || 800);
6558
+ const baseH = Math.max(400, ctx.container.clientHeight || 600);
6559
+ const scaledW = Math.round(baseW * scale);
6560
+ const scaledH = Math.round(baseH * scale);
6561
+ sizer.style.width = `${scaledW}px`;
6562
+ sizer.style.height = `${scaledH}px`;
6563
+ iframe.style.position = "absolute";
6564
+ iframe.style.top = "0";
6565
+ iframe.style.left = "0";
6566
+ iframe.style.width = `${baseW}px`;
6567
+ iframe.style.height = `${baseH}px`;
6568
+ iframe.style.transform = `scale(${scale})`;
6569
+ iframe.style.transformOrigin = "top left";
6570
+ };
6571
+ requestAnimationFrame(() => {
6572
+ applyTransform();
6573
+ });
6279
6574
  const cleanup = () => {
6280
- iframe.remove();
6575
+ sizer.remove();
6281
6576
  ctx.container.innerHTML = "";
6282
6577
  };
6283
6578
  ctx.signal.addEventListener("abort", cleanup);
@@ -6285,26 +6580,26 @@ var HtmlPreviewPlugin = class {
6285
6580
  destroy: cleanup,
6286
6581
  zoomIn: () => {
6287
6582
  scale += 0.1;
6288
- iframe.style.transform = `scale(${scale})`;
6583
+ applyTransform();
6289
6584
  },
6290
6585
  zoomOut: () => {
6291
6586
  scale = Math.max(0.2, scale - 0.1);
6292
- iframe.style.transform = `scale(${scale})`;
6587
+ applyTransform();
6293
6588
  },
6294
6589
  getZoom: () => scale,
6295
6590
  setZoom: (level) => {
6296
6591
  scale = level;
6297
- iframe.style.transform = `scale(${scale})`;
6592
+ applyTransform();
6298
6593
  },
6299
6594
  fitToPage: () => {
6300
6595
  scale = 1;
6301
- iframe.style.transform = "scale(1)";
6596
+ applyTransform();
6302
6597
  },
6303
6598
  resetZoom: () => {
6304
6599
  scale = 1;
6305
- iframe.style.transform = "scale(1)";
6306
6600
  ctx.container.scrollTop = 0;
6307
6601
  ctx.container.scrollLeft = 0;
6602
+ applyTransform();
6308
6603
  },
6309
6604
  copy: () => {
6310
6605
  navigator.clipboard.writeText(rawHtml);
@@ -6479,10 +6774,26 @@ var OpenDocumentPlugin = class {
6479
6774
  container.className = "fp-odf-container";
6480
6775
  container.style.width = "100%";
6481
6776
  container.style.height = "100%";
6482
- container.style.overflowX = "hidden";
6483
- container.style.overflowY = "auto";
6484
- container.style.padding = "16px 8px";
6777
+ container.style.overflow = "auto";
6485
6778
  container.style.backgroundColor = "#f1f5f9";
6779
+ const scrollWrapper = document.createElement("div");
6780
+ scrollWrapper.className = "fp-odf-scroll-wrapper";
6781
+ scrollWrapper.style.minWidth = "100%";
6782
+ scrollWrapper.style.minHeight = "100%";
6783
+ scrollWrapper.style.width = "max-content";
6784
+ scrollWrapper.style.height = "max-content";
6785
+ scrollWrapper.style.display = "flex";
6786
+ scrollWrapper.style.justifyContent = "center";
6787
+ scrollWrapper.style.alignItems = "flex-start";
6788
+ scrollWrapper.style.padding = "16px 8px";
6789
+ scrollWrapper.style.boxSizing = "border-box";
6790
+ const sizer = document.createElement("div");
6791
+ sizer.className = "fp-odf-sizer";
6792
+ sizer.style.position = "relative";
6793
+ sizer.style.flexShrink = "0";
6794
+ sizer.style.display = "flex";
6795
+ sizer.style.justifyContent = "center";
6796
+ sizer.style.alignItems = "center";
6486
6797
  const wrapper = document.createElement("div");
6487
6798
  wrapper.className = "fp-odf-wrapper";
6488
6799
  wrapper.style.margin = "0 auto";
@@ -6491,9 +6802,12 @@ var OpenDocumentPlugin = class {
6491
6802
  wrapper.style.backgroundColor = "#ffffff";
6492
6803
  wrapper.style.boxShadow = "0 2px 10px rgba(0,0,0,0.08)";
6493
6804
  wrapper.style.borderRadius = "4px";
6494
- wrapper.style.transformOrigin = "top center";
6805
+ wrapper.style.transformOrigin = "center center";
6495
6806
  wrapper.style.transition = "transform 0.15s ease";
6496
- container.appendChild(wrapper);
6807
+ wrapper.style.flexShrink = "0";
6808
+ sizer.appendChild(wrapper);
6809
+ scrollWrapper.appendChild(sizer);
6810
+ container.appendChild(scrollWrapper);
6497
6811
  ctx.container.appendChild(container);
6498
6812
  let scale = 1;
6499
6813
  let rotation = 0;
@@ -6519,13 +6833,18 @@ var OpenDocumentPlugin = class {
6519
6833
  return Math.max(0.4, Math.min(3, sW));
6520
6834
  };
6521
6835
  const applyTransform = () => {
6522
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6523
- wrapper.style.transformOrigin = "top center";
6524
6836
  const activeSlide = slides[currentPage - 1];
6837
+ const elW = isPresentation ? 960 : 816;
6525
6838
  const baseH = activeSlide?.offsetHeight || wrapper.offsetHeight || 1056;
6526
- const scaledH = baseH * scale;
6527
- const extraH = Math.max(0, scaledH - baseH);
6528
- wrapper.style.marginBottom = `${extraH + 32}px`;
6839
+ const isRotated90 = rotation % 180 !== 0;
6840
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6841
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6842
+ sizer.style.width = `${boxW}px`;
6843
+ sizer.style.height = `${boxH}px`;
6844
+ wrapper.style.width = `${elW}px`;
6845
+ wrapper.style.height = `${baseH}px`;
6846
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6847
+ wrapper.style.transformOrigin = "center center";
6529
6848
  };
6530
6849
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
6531
6850
  if (!isUserZoomed) {
@@ -7089,13 +7408,28 @@ var DocPlugin = class {
7089
7408
  container.className = "fp-doc-container";
7090
7409
  container.style.width = "100%";
7091
7410
  container.style.height = "100%";
7092
- container.style.overflowX = "hidden";
7093
- container.style.overflowY = "auto";
7094
- container.style.padding = "16px 8px";
7411
+ container.style.overflow = "auto";
7095
7412
  container.style.backgroundColor = "#f1f5f9";
7096
- container.style.display = "flex";
7097
- container.style.justifyContent = "center";
7098
- container.style.alignItems = "flex-start";
7413
+ const scrollWrapper = document.createElement("div");
7414
+ scrollWrapper.className = "fp-doc-scroll-wrapper";
7415
+ scrollWrapper.style.minWidth = "100%";
7416
+ scrollWrapper.style.minHeight = "100%";
7417
+ scrollWrapper.style.width = "max-content";
7418
+ scrollWrapper.style.height = "max-content";
7419
+ scrollWrapper.style.display = "flex";
7420
+ scrollWrapper.style.justifyContent = "center";
7421
+ scrollWrapper.style.alignItems = "flex-start";
7422
+ scrollWrapper.style.padding = "16px 8px";
7423
+ scrollWrapper.style.boxSizing = "border-box";
7424
+ const sizer = document.createElement("div");
7425
+ sizer.className = "fp-doc-sizer";
7426
+ sizer.style.position = "relative";
7427
+ sizer.style.flexShrink = "0";
7428
+ sizer.style.display = "flex";
7429
+ sizer.style.justifyContent = "center";
7430
+ sizer.style.alignItems = "center";
7431
+ scrollWrapper.appendChild(sizer);
7432
+ container.appendChild(scrollWrapper);
7099
7433
  ctx.container.appendChild(container);
7100
7434
  let scale = 1;
7101
7435
  let extractedRawText = "";
@@ -7143,10 +7477,11 @@ var DocPlugin = class {
7143
7477
  pageCard.style.padding = "72px 56px";
7144
7478
  pageCard.style.boxSizing = "border-box";
7145
7479
  pageCard.style.display = i === 0 ? "block" : "none";
7146
- pageCard.style.transformOrigin = "top center";
7480
+ pageCard.style.transformOrigin = "center center";
7147
7481
  pageCard.style.transition = "transform 0.15s ease";
7148
7482
  pageCard.style.fontFamily = 'Calibri, "Segoe UI", Arial, sans-serif';
7149
7483
  pageCard.style.color = "#1e293b";
7484
+ pageCard.style.flexShrink = "0";
7150
7485
  if (isFallback && i === 0) {
7151
7486
  pageCard.innerHTML = `
7152
7487
  <div style="border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 24px;">
@@ -7158,18 +7493,23 @@ var DocPlugin = class {
7158
7493
  } else {
7159
7494
  pageCard.innerHTML = this.formatDocToHtml(rawPages[i], ctx.metadata.name || "Document");
7160
7495
  }
7161
- container.appendChild(pageCard);
7496
+ sizer.appendChild(pageCard);
7162
7497
  pageCards.push(pageCard);
7163
7498
  }
7164
7499
  let rotation = 0;
7165
7500
  const applyTransform = () => {
7166
7501
  const activeCard = pageCards[currentPage - 1];
7167
7502
  if (activeCard) {
7168
- activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7503
+ const baseW = 816;
7169
7504
  const baseH = activeCard.offsetHeight || 1056;
7170
- const scaledH = baseH * scale;
7171
- const extraH = Math.max(0, scaledH - baseH);
7172
- activeCard.style.marginBottom = `${extraH + 32}px`;
7505
+ const isRotated90 = rotation % 180 !== 0;
7506
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * scale);
7507
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * scale);
7508
+ sizer.style.width = `${boxW}px`;
7509
+ sizer.style.height = `${boxH}px`;
7510
+ activeCard.style.width = `${baseW}px`;
7511
+ activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7512
+ activeCard.style.transformOrigin = "center center";
7173
7513
  }
7174
7514
  };
7175
7515
  const showPage = (pageNum) => {
@@ -7177,11 +7517,11 @@ var DocPlugin = class {
7177
7517
  pageCards.forEach((card, idx) => {
7178
7518
  if (idx + 1 === currentPage) {
7179
7519
  card.style.display = "block";
7180
- card.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7181
7520
  } else {
7182
7521
  card.style.display = "none";
7183
7522
  }
7184
7523
  });
7524
+ applyTransform();
7185
7525
  container.scrollTop = 0;
7186
7526
  ctx.emit("page-change", { page: currentPage, total: totalPages });
7187
7527
  };
@@ -7252,6 +7592,8 @@ var DocPlugin = class {
7252
7592
  fitMode = "width";
7253
7593
  scale = calculateFitScale("width");
7254
7594
  rotation = 0;
7595
+ container.scrollTop = 0;
7596
+ container.scrollLeft = 0;
7255
7597
  ctx.container.scrollTop = 0;
7256
7598
  ctx.container.scrollLeft = 0;
7257
7599
  applyTransform();
@@ -7776,17 +8118,30 @@ var PptPlugin = class {
7776
8118
  container.style.width = "100%";
7777
8119
  container.style.height = "100%";
7778
8120
  container.style.overflow = "auto";
7779
- container.style.display = "flex";
7780
- container.style.justifyContent = "center";
7781
- container.style.alignItems = "center";
7782
- container.style.padding = "32px 16px";
7783
8121
  container.style.backgroundColor = "#0f172a";
7784
8122
  container.style.boxSizing = "border-box";
8123
+ const scrollWrapper = document.createElement("div");
8124
+ scrollWrapper.className = "fp-ppt-scroll-wrapper";
8125
+ scrollWrapper.style.minWidth = "100%";
8126
+ scrollWrapper.style.minHeight = "100%";
8127
+ scrollWrapper.style.width = "max-content";
8128
+ scrollWrapper.style.height = "max-content";
8129
+ scrollWrapper.style.display = "flex";
8130
+ scrollWrapper.style.justifyContent = "center";
8131
+ scrollWrapper.style.alignItems = "center";
8132
+ scrollWrapper.style.padding = "32px 16px";
8133
+ scrollWrapper.style.boxSizing = "border-box";
8134
+ const sizer = document.createElement("div");
8135
+ sizer.className = "fp-ppt-sizer";
8136
+ sizer.style.position = "relative";
8137
+ sizer.style.flexShrink = "0";
8138
+ sizer.style.display = "flex";
8139
+ sizer.style.justifyContent = "center";
8140
+ sizer.style.alignItems = "center";
7785
8141
  const slideCard = document.createElement("div");
7786
8142
  slideCard.className = "fp-ppt-slide-card";
7787
8143
  slideCard.style.width = "960px";
7788
- slideCard.style.maxWidth = "calc(100% - 32px)";
7789
- slideCard.style.maxHeight = "calc(100% - 48px)";
8144
+ slideCard.style.height = "540px";
7790
8145
  slideCard.style.aspectRatio = "16 / 9";
7791
8146
  slideCard.style.backgroundColor = "#ffffff";
7792
8147
  slideCard.style.boxShadow = "0 12px 40px rgba(0,0,0,0.35)";
@@ -7796,7 +8151,9 @@ var PptPlugin = class {
7796
8151
  slideCard.style.transition = "transform 0.2s ease";
7797
8152
  slideCard.style.transformOrigin = "center center";
7798
8153
  slideCard.style.flexShrink = "0";
7799
- container.appendChild(slideCard);
8154
+ sizer.appendChild(slideCard);
8155
+ scrollWrapper.appendChild(sizer);
8156
+ container.appendChild(scrollWrapper);
7800
8157
  ctx.container.appendChild(container);
7801
8158
  let scale = 1;
7802
8159
  let rotation = 0;
@@ -7809,7 +8166,17 @@ var PptPlugin = class {
7809
8166
  return Math.min(1, Math.min(availW / 960, availH / 540));
7810
8167
  };
7811
8168
  const applyTransform = () => {
8169
+ const cW = 960;
8170
+ const cH = 540;
8171
+ const isRotated90 = rotation % 180 !== 0;
8172
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
8173
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
8174
+ sizer.style.width = `${boxW}px`;
8175
+ sizer.style.height = `${boxH}px`;
8176
+ slideCard.style.width = `${cW}px`;
8177
+ slideCard.style.height = `${cH}px`;
7812
8178
  slideCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
8179
+ slideCard.style.transformOrigin = "center center";
7813
8180
  };
7814
8181
  setTimeout(() => {
7815
8182
  scale = calculateFitScale();