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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2199,16 +2199,22 @@ var PdfPlugin = class {
2199
2199
  container.className = "fp-pdf-container";
2200
2200
  container.style.width = "100%";
2201
2201
  container.style.height = "100%";
2202
- container.style.overflowX = "hidden";
2203
- container.style.overflowY = "auto";
2204
- container.style.display = "flex";
2205
- container.style.flexDirection = "column";
2206
- container.style.alignItems = "center";
2207
- container.style.justifyContent = "flex-start";
2208
- container.style.padding = "16px 8px";
2202
+ container.style.overflow = "auto";
2209
2203
  container.style.backgroundColor = "#0f172a";
2210
2204
  container.style.boxSizing = "border-box";
2211
2205
  container.style.position = "relative";
2206
+ const scrollWrapper = document.createElement("div");
2207
+ scrollWrapper.className = "fp-pdf-scroll-wrapper";
2208
+ scrollWrapper.style.minWidth = "100%";
2209
+ scrollWrapper.style.minHeight = "100%";
2210
+ scrollWrapper.style.width = "max-content";
2211
+ scrollWrapper.style.height = "max-content";
2212
+ scrollWrapper.style.display = "flex";
2213
+ scrollWrapper.style.flexDirection = "column";
2214
+ scrollWrapper.style.alignItems = "center";
2215
+ scrollWrapper.style.justifyContent = "flex-start";
2216
+ scrollWrapper.style.padding = "16px 8px";
2217
+ scrollWrapper.style.boxSizing = "border-box";
2212
2218
  const pageCard = document.createElement("div");
2213
2219
  pageCard.className = "fp-pdf-page-card";
2214
2220
  pageCard.style.boxShadow = "0 10px 35px rgba(0, 0, 0, 0.5)";
@@ -2221,7 +2227,8 @@ var PdfPlugin = class {
2221
2227
  pageCard.style.transition = "box-shadow 0.2s ease";
2222
2228
  let canvas = document.createElement("canvas");
2223
2229
  pageCard.appendChild(canvas);
2224
- container.appendChild(pageCard);
2230
+ scrollWrapper.appendChild(pageCard);
2231
+ container.appendChild(scrollWrapper);
2225
2232
  ctx.container.appendChild(container);
2226
2233
  const standardFontsUrl = typeof window !== "undefined" && window.__PDF_STANDARD_FONTS_URL__ || "./standard_fonts/";
2227
2234
  const cmapsUrl = typeof window !== "undefined" && window.__PDF_CMAPS_URL__ || "./cmaps/";
@@ -2730,17 +2737,86 @@ var MediaPlugin = class {
2730
2737
  element = document.createElement("div");
2731
2738
  element.textContent = "Unsupported media type";
2732
2739
  }
2733
- ctx.container.style.display = "flex";
2734
- ctx.container.style.alignItems = "center";
2735
- ctx.container.style.justifyContent = "center";
2736
- ctx.container.style.overflow = "hidden";
2737
- ctx.container.appendChild(element);
2740
+ const scrollWrapper = document.createElement("div");
2741
+ scrollWrapper.className = "fp-media-scroll-wrapper";
2742
+ scrollWrapper.style.minWidth = "100%";
2743
+ scrollWrapper.style.minHeight = "100%";
2744
+ scrollWrapper.style.width = "max-content";
2745
+ scrollWrapper.style.height = "max-content";
2746
+ scrollWrapper.style.display = "flex";
2747
+ scrollWrapper.style.justifyContent = "center";
2748
+ scrollWrapper.style.alignItems = "center";
2749
+ scrollWrapper.style.padding = "16px";
2750
+ scrollWrapper.style.boxSizing = "border-box";
2751
+ const sizer = document.createElement("div");
2752
+ sizer.className = "fp-media-sizer";
2753
+ sizer.style.position = "relative";
2754
+ sizer.style.flexShrink = "0";
2755
+ sizer.style.display = "flex";
2756
+ sizer.style.justifyContent = "center";
2757
+ sizer.style.alignItems = "center";
2758
+ sizer.appendChild(element);
2759
+ scrollWrapper.appendChild(sizer);
2760
+ ctx.container.style.overflow = "auto";
2761
+ ctx.container.style.padding = "0";
2762
+ ctx.container.innerHTML = "";
2763
+ ctx.container.appendChild(scrollWrapper);
2764
+ let naturalW = 800;
2765
+ let naturalH = 600;
2766
+ let baseW = 800;
2767
+ let baseH = 600;
2768
+ const updateBaseDimensions = () => {
2769
+ if (!isImage) return;
2770
+ const img = element;
2771
+ naturalW = img.naturalWidth || naturalW;
2772
+ naturalH = img.naturalHeight || naturalH;
2773
+ const availW = Math.max(100, ctx.container.clientWidth - 48);
2774
+ const availH = Math.max(100, ctx.container.clientHeight - 48);
2775
+ const fitRatio = Math.min(1, availW / naturalW, availH / naturalH);
2776
+ baseW = Math.max(1, Math.round(naturalW * fitRatio));
2777
+ baseH = Math.max(1, Math.round(naturalH * fitRatio));
2778
+ };
2738
2779
  const applyTransform = () => {
2739
- element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2780
+ if (isImage) {
2781
+ updateBaseDimensions();
2782
+ const isRotated90 = rotation % 180 !== 0;
2783
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * currentZoom);
2784
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * currentZoom);
2785
+ sizer.style.width = `${boxW}px`;
2786
+ sizer.style.height = `${boxH}px`;
2787
+ element.style.width = `${baseW}px`;
2788
+ element.style.height = `${baseH}px`;
2789
+ element.style.maxWidth = "none";
2790
+ element.style.maxHeight = "none";
2791
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2792
+ element.style.transformOrigin = "center center";
2793
+ element.style.flexShrink = "0";
2794
+ } else {
2795
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2796
+ }
2740
2797
  };
2798
+ if (isImage) {
2799
+ const img = element;
2800
+ if (img.complete && img.naturalWidth > 0) {
2801
+ updateBaseDimensions();
2802
+ applyTransform();
2803
+ } else {
2804
+ img.onload = () => {
2805
+ updateBaseDimensions();
2806
+ applyTransform();
2807
+ };
2808
+ }
2809
+ }
2810
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
2811
+ if (currentZoom === 1) {
2812
+ applyTransform();
2813
+ }
2814
+ }) : null;
2815
+ ro?.observe(ctx.container);
2741
2816
  const cleanup = () => {
2817
+ ro?.disconnect();
2742
2818
  if (url) URL.revokeObjectURL(url);
2743
- element.remove();
2819
+ scrollWrapper.remove();
2744
2820
  ctx.container.innerHTML = "";
2745
2821
  };
2746
2822
  ctx.signal.addEventListener("abort", cleanup);
@@ -2933,7 +3009,7 @@ var DocxPlugin = class {
2933
3009
  async render(ctx) {
2934
3010
  const wrapper = document.createElement("div");
2935
3011
  wrapper.className = "fp-docx-wrapper";
2936
- wrapper.style.transformOrigin = "top center";
3012
+ wrapper.style.transformOrigin = "center center";
2937
3013
  wrapper.style.transition = "transform 0.2s ease";
2938
3014
  wrapper.style.padding = "0";
2939
3015
  wrapper.style.maxWidth = "none";
@@ -2943,11 +3019,31 @@ var DocxPlugin = class {
2943
3019
  wrapper.style.flexDirection = "column";
2944
3020
  wrapper.style.alignItems = "center";
2945
3021
  wrapper.style.boxSizing = "border-box";
2946
- ctx.container.style.overflowX = "hidden";
2947
- ctx.container.style.overflowY = "auto";
2948
- ctx.container.style.padding = "16px 8px";
3022
+ wrapper.style.flexShrink = "0";
3023
+ const sizer = document.createElement("div");
3024
+ sizer.className = "fp-docx-sizer";
3025
+ sizer.style.position = "relative";
3026
+ sizer.style.flexShrink = "0";
3027
+ sizer.style.display = "flex";
3028
+ sizer.style.justifyContent = "center";
3029
+ sizer.style.alignItems = "center";
3030
+ const scrollWrapper = document.createElement("div");
3031
+ scrollWrapper.className = "fp-docx-scroll-wrapper";
3032
+ scrollWrapper.style.minWidth = "100%";
3033
+ scrollWrapper.style.minHeight = "100%";
3034
+ scrollWrapper.style.width = "max-content";
3035
+ scrollWrapper.style.height = "max-content";
3036
+ scrollWrapper.style.display = "flex";
3037
+ scrollWrapper.style.justifyContent = "center";
3038
+ scrollWrapper.style.alignItems = "flex-start";
3039
+ scrollWrapper.style.padding = "16px 8px";
3040
+ scrollWrapper.style.boxSizing = "border-box";
3041
+ sizer.appendChild(wrapper);
3042
+ scrollWrapper.appendChild(sizer);
3043
+ ctx.container.style.overflow = "auto";
3044
+ ctx.container.style.padding = "0";
2949
3045
  ctx.container.style.backgroundColor = "#f1f5f9";
2950
- ctx.container.appendChild(wrapper);
3046
+ ctx.container.appendChild(scrollWrapper);
2951
3047
  const styleOverride = document.createElement("style");
2952
3048
  styleOverride.textContent = `
2953
3049
  .fp-docx-wrapper .docx-wrapper {
@@ -2986,8 +3082,8 @@ var DocxPlugin = class {
2986
3082
  renderEndnotes: true,
2987
3083
  useBase64URL: true
2988
3084
  });
2989
- if (!ctx.container.contains(wrapper)) {
2990
- ctx.container.appendChild(wrapper);
3085
+ if (!sizer.contains(wrapper)) {
3086
+ sizer.appendChild(wrapper);
2991
3087
  }
2992
3088
  if (wrapper.children.length > 0 && (wrapper.textContent?.trim().length ?? 0) > 0) {
2993
3089
  renderedSuccessfully = true;
@@ -3024,8 +3120,8 @@ var DocxPlugin = class {
3024
3120
  try {
3025
3121
  wrapper.innerHTML = "";
3026
3122
  this.renderXmlFallback(ctx, wrapper, createdBlobUrls);
3027
- if (!ctx.container.contains(wrapper)) {
3028
- ctx.container.appendChild(wrapper);
3123
+ if (!sizer.contains(wrapper)) {
3124
+ sizer.appendChild(wrapper);
3029
3125
  }
3030
3126
  renderedSuccessfully = true;
3031
3127
  } catch (fallbackErr) {
@@ -3040,8 +3136,8 @@ var DocxPlugin = class {
3040
3136
  </p>
3041
3137
  </div>
3042
3138
  `;
3043
- if (!ctx.container.contains(wrapper)) {
3044
- ctx.container.appendChild(wrapper);
3139
+ if (!sizer.contains(wrapper)) {
3140
+ sizer.appendChild(wrapper);
3045
3141
  }
3046
3142
  }
3047
3143
  }
@@ -3144,15 +3240,18 @@ var DocxPlugin = class {
3144
3240
  return Math.max(0.35, Math.min(3, sW));
3145
3241
  };
3146
3242
  const applyTransform = () => {
3147
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3148
- wrapper.style.transformOrigin = "top center";
3149
3243
  const activeEl = pageElements[currentPage - 1] || wrapper.querySelector("section.docx") || wrapper;
3244
+ const elW = activeEl.offsetWidth || 816;
3150
3245
  const elH = activeEl.offsetHeight || 1056;
3151
- if (scale > 1) {
3152
- wrapper.style.marginBottom = `${Math.round(elH * scale - elH + 32)}px`;
3153
- } else {
3154
- wrapper.style.marginBottom = "32px";
3155
- }
3246
+ const isRotated90 = rotation % 180 !== 0;
3247
+ const boxW = Math.round((isRotated90 ? elH : elW) * scale);
3248
+ const boxH = Math.round((isRotated90 ? elW : elH) * scale);
3249
+ sizer.style.width = `${boxW}px`;
3250
+ sizer.style.height = `${boxH}px`;
3251
+ wrapper.style.width = `${elW}px`;
3252
+ wrapper.style.height = `${elH}px`;
3253
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3254
+ wrapper.style.transformOrigin = "center center";
3156
3255
  };
3157
3256
  let resizeObserver = null;
3158
3257
  if (typeof ResizeObserver !== "undefined") {
@@ -3177,7 +3276,7 @@ var DocxPlugin = class {
3177
3276
  for (const url of createdBlobUrls) {
3178
3277
  URL.revokeObjectURL(url);
3179
3278
  }
3180
- wrapper.remove();
3279
+ scrollWrapper.remove();
3181
3280
  styleOverride.remove();
3182
3281
  ctx.container.innerHTML = "";
3183
3282
  };
@@ -3724,7 +3823,7 @@ var ExcelPlugin = class {
3724
3823
  contentArea.style.flex = "1";
3725
3824
  contentArea.style.overflow = "auto";
3726
3825
  contentArea.style.padding = "16px";
3727
- contentArea.style.transformOrigin = "top left";
3826
+ contentArea.style.boxSizing = "border-box";
3728
3827
  const tabsArea = document.createElement("div");
3729
3828
  tabsArea.className = "fp-excel-tabs";
3730
3829
  tabsArea.style.display = "flex";
@@ -3738,18 +3837,35 @@ var ExcelPlugin = class {
3738
3837
  container.appendChild(tabsArea);
3739
3838
  ctx.container.appendChild(container);
3740
3839
  let scale = 1;
3840
+ let isUserZoomed = false;
3741
3841
  let currentSheetIndex = 1;
3742
3842
  let sheetNames = [];
3743
3843
  let wb = null;
3744
3844
  const applyTransform = () => {
3745
- contentArea.style.transform = `scale(${scale})`;
3746
- contentArea.style.transformOrigin = "top left";
3845
+ const sizer = contentArea.querySelector(".fp-excel-sizer");
3846
+ const table = contentArea.querySelector("table");
3847
+ if (!sizer || !table) return;
3848
+ if (!table._baseWidth && table.offsetWidth > 0) {
3849
+ table._baseWidth = table.offsetWidth;
3850
+ table._baseHeight = table.offsetHeight;
3851
+ }
3852
+ const baseW = table._baseWidth || table.offsetWidth || 800;
3853
+ const baseH = table._baseHeight || table.offsetHeight || 600;
3854
+ const scaledW = Math.round(baseW * scale);
3855
+ const scaledH = Math.round(baseH * scale);
3856
+ sizer.style.width = `${scaledW}px`;
3857
+ sizer.style.height = `${scaledH}px`;
3858
+ table.style.position = "absolute";
3859
+ table.style.top = "0";
3860
+ table.style.left = "0";
3861
+ table.style.transform = `scale(${scale})`;
3862
+ table.style.transformOrigin = "top left";
3747
3863
  };
3748
3864
  const calculateFitScale = () => {
3749
3865
  const table = contentArea.querySelector("table");
3750
3866
  if (!table) return 1;
3751
3867
  const availW = Math.max(280, container.clientWidth - 48);
3752
- const tW = table.offsetWidth || 800;
3868
+ const tW = table._baseWidth || table.offsetWidth || 800;
3753
3869
  return Math.max(0.4, Math.min(1, availW / tW));
3754
3870
  };
3755
3871
  try {
@@ -3769,9 +3885,13 @@ var ExcelPlugin = class {
3769
3885
  contentArea.innerHTML = '<div style="padding: 24px; color: #888;">Empty sheet</div>';
3770
3886
  return;
3771
3887
  }
3888
+ const sizer = document.createElement("div");
3889
+ sizer.className = "fp-excel-sizer";
3890
+ sizer.style.position = "relative";
3772
3891
  const html = XLSX__namespace.utils.sheet_to_html(ws, { id: "fp-sheet-table", editable: false });
3773
- contentArea.innerHTML = html;
3774
- const table = contentArea.querySelector("table");
3892
+ sizer.innerHTML = html;
3893
+ contentArea.appendChild(sizer);
3894
+ const table = sizer.querySelector("table");
3775
3895
  if (table) {
3776
3896
  table.style.borderCollapse = "collapse";
3777
3897
  table.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
@@ -3806,13 +3926,17 @@ var ExcelPlugin = class {
3806
3926
  });
3807
3927
  ctx.emit("page-change", { page: currentSheetIndex, total: sheetNames.length });
3808
3928
  requestAnimationFrame(() => {
3809
- scale = calculateFitScale();
3929
+ if (!isUserZoomed) {
3930
+ scale = calculateFitScale();
3931
+ }
3810
3932
  applyTransform();
3811
3933
  });
3812
3934
  };
3813
3935
  const ro = new ResizeObserver(() => {
3814
- scale = calculateFitScale();
3815
- applyTransform();
3936
+ if (!isUserZoomed) {
3937
+ scale = calculateFitScale();
3938
+ applyTransform();
3939
+ }
3816
3940
  });
3817
3941
  ro.observe(container);
3818
3942
  if (sheetNames.length > 0) {
@@ -3849,23 +3973,28 @@ var ExcelPlugin = class {
3849
3973
  return {
3850
3974
  destroy: cleanup,
3851
3975
  zoomIn: () => {
3976
+ isUserZoomed = true;
3852
3977
  scale += 0.15;
3853
3978
  applyTransform();
3854
3979
  },
3855
3980
  zoomOut: () => {
3981
+ isUserZoomed = true;
3856
3982
  scale = Math.max(0.2, scale - 0.15);
3857
3983
  applyTransform();
3858
3984
  },
3859
3985
  getZoom: () => scale,
3860
3986
  setZoom: (level) => {
3987
+ isUserZoomed = true;
3861
3988
  scale = level;
3862
3989
  applyTransform();
3863
3990
  },
3864
3991
  fitToPage: () => {
3992
+ isUserZoomed = false;
3865
3993
  scale = calculateFitScale();
3866
3994
  applyTransform();
3867
3995
  },
3868
3996
  resetZoom: () => {
3997
+ isUserZoomed = false;
3869
3998
  scale = calculateFitScale();
3870
3999
  contentArea.scrollTop = 0;
3871
4000
  contentArea.scrollLeft = 0;
@@ -4097,21 +4226,41 @@ var CsvPlugin = class {
4097
4226
  container.appendChild(tableWrapper);
4098
4227
  ctx.container.appendChild(container);
4099
4228
  let scale = 1;
4229
+ let isUserZoomed = false;
4100
4230
  const calculateFitScale = () => {
4101
4231
  const availW = Math.max(280, container.clientWidth - 48);
4102
- const tW = table.offsetWidth || 800;
4232
+ const tW = table._baseWidth || table.offsetWidth || 800;
4103
4233
  return Math.max(0.4, Math.min(1, availW / tW));
4104
4234
  };
4105
4235
  const applyScale = () => {
4106
- tableWrapper.style.transform = `scale(${scale})`;
4236
+ if (!table._baseWidth && table.offsetWidth > 0) {
4237
+ table._baseWidth = table.offsetWidth;
4238
+ table._baseHeight = table.offsetHeight;
4239
+ }
4240
+ const baseW = table._baseWidth || table.offsetWidth || 800;
4241
+ const baseH = table._baseHeight || table.offsetHeight || 600;
4242
+ const scaledW = Math.round(baseW * scale);
4243
+ const scaledH = Math.round(baseH * scale);
4244
+ tableWrapper.style.position = "relative";
4245
+ tableWrapper.style.width = `${scaledW}px`;
4246
+ tableWrapper.style.height = `${scaledH}px`;
4247
+ table.style.position = "absolute";
4248
+ table.style.top = "0";
4249
+ table.style.left = "0";
4250
+ table.style.transform = `scale(${scale})`;
4251
+ table.style.transformOrigin = "top left";
4107
4252
  };
4108
4253
  requestAnimationFrame(() => {
4109
- scale = calculateFitScale();
4254
+ if (!isUserZoomed) {
4255
+ scale = calculateFitScale();
4256
+ }
4110
4257
  applyScale();
4111
4258
  });
4112
4259
  const ro = new ResizeObserver(() => {
4113
- scale = calculateFitScale();
4114
- applyScale();
4260
+ if (!isUserZoomed) {
4261
+ scale = calculateFitScale();
4262
+ applyScale();
4263
+ }
4115
4264
  });
4116
4265
  ro.observe(container);
4117
4266
  const cleanup = () => {
@@ -4184,23 +4333,28 @@ var CsvPlugin = class {
4184
4333
  }];
4185
4334
  },
4186
4335
  zoomIn: () => {
4336
+ isUserZoomed = true;
4187
4337
  scale += 0.1;
4188
4338
  applyScale();
4189
4339
  },
4190
4340
  zoomOut: () => {
4341
+ isUserZoomed = true;
4191
4342
  scale = Math.max(0.2, scale - 0.1);
4192
4343
  applyScale();
4193
4344
  },
4194
4345
  getZoom: () => scale,
4195
4346
  setZoom: (level) => {
4347
+ isUserZoomed = true;
4196
4348
  scale = level;
4197
4349
  applyScale();
4198
4350
  },
4199
4351
  fitToPage: () => {
4352
+ isUserZoomed = false;
4200
4353
  scale = calculateFitScale();
4201
4354
  applyScale();
4202
4355
  },
4203
4356
  resetZoom: () => {
4357
+ isUserZoomed = false;
4204
4358
  scale = calculateFitScale();
4205
4359
  container.scrollTop = 0;
4206
4360
  container.scrollLeft = 0;
@@ -4436,15 +4590,27 @@ var CodePlugin = class {
4436
4590
  let isUserZoomed = false;
4437
4591
  const pre = document.createElement("pre");
4438
4592
  const code = document.createElement("code");
4593
+ const sizer = document.createElement("div");
4594
+ const scrollWrapper = document.createElement("div");
4439
4595
  if (isTxt) {
4440
- container.style.overflowX = "hidden";
4441
- container.style.overflowY = "auto";
4596
+ container.style.overflow = "auto";
4442
4597
  container.style.backgroundColor = "#f1f5f9";
4443
- container.style.padding = "16px 8px";
4444
- container.style.boxSizing = "border-box";
4445
- container.style.display = "flex";
4446
- container.style.flexDirection = "column";
4447
- container.style.alignItems = "center";
4598
+ scrollWrapper.className = "fp-code-scroll-wrapper";
4599
+ scrollWrapper.style.minWidth = "100%";
4600
+ scrollWrapper.style.minHeight = "100%";
4601
+ scrollWrapper.style.width = "max-content";
4602
+ scrollWrapper.style.height = "max-content";
4603
+ scrollWrapper.style.display = "flex";
4604
+ scrollWrapper.style.justifyContent = "center";
4605
+ scrollWrapper.style.alignItems = "flex-start";
4606
+ scrollWrapper.style.padding = "16px 8px";
4607
+ scrollWrapper.style.boxSizing = "border-box";
4608
+ sizer.className = "fp-code-sizer";
4609
+ sizer.style.position = "relative";
4610
+ sizer.style.flexShrink = "0";
4611
+ sizer.style.display = "flex";
4612
+ sizer.style.justifyContent = "center";
4613
+ sizer.style.alignItems = "center";
4448
4614
  pre.style.margin = "0 auto";
4449
4615
  pre.style.fontFamily = "Consolas, 'Courier New', monospace";
4450
4616
  pre.style.fontSize = "13px";
@@ -4459,8 +4625,9 @@ var CodePlugin = class {
4459
4625
  pre.style.boxSizing = "border-box";
4460
4626
  pre.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
4461
4627
  pre.style.borderRadius = "4px";
4462
- pre.style.transformOrigin = "top center";
4628
+ pre.style.transformOrigin = "center center";
4463
4629
  pre.style.transition = "transform 0.15s ease";
4630
+ pre.style.flexShrink = "0";
4464
4631
  } else {
4465
4632
  container.style.overflow = "auto";
4466
4633
  container.style.backgroundColor = "#1e1e1e";
@@ -4493,7 +4660,13 @@ var CodePlugin = class {
4493
4660
  };
4494
4661
  renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
4495
4662
  pre.appendChild(code);
4496
- container.appendChild(pre);
4663
+ if (isTxt) {
4664
+ sizer.appendChild(pre);
4665
+ scrollWrapper.appendChild(sizer);
4666
+ container.appendChild(scrollWrapper);
4667
+ } else {
4668
+ container.appendChild(pre);
4669
+ }
4497
4670
  const showPage = (pageNum) => {
4498
4671
  currentPage = Math.max(1, Math.min(totalPages, pageNum));
4499
4672
  renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
@@ -4510,10 +4683,16 @@ var CodePlugin = class {
4510
4683
  };
4511
4684
  const updateTransform = () => {
4512
4685
  if (isTxt) {
4686
+ const elW = 816;
4687
+ const baseH = pre.offsetHeight || 1056;
4688
+ const isRotated90 = rotation % 180 !== 0;
4689
+ const boxW = Math.round((isRotated90 ? baseH : elW) * zoomLevel);
4690
+ const boxH = Math.round((isRotated90 ? elW : baseH) * zoomLevel);
4691
+ sizer.style.width = `${boxW}px`;
4692
+ sizer.style.height = `${boxH}px`;
4693
+ pre.style.width = `${elW}px`;
4513
4694
  pre.style.transform = `scale(${zoomLevel}) rotate(${rotation}deg)`;
4514
- const scaledH = 1056 * zoomLevel;
4515
- const extraH = Math.max(0, scaledH - 1056);
4516
- pre.style.marginBottom = `${extraH + 32}px`;
4695
+ pre.style.transformOrigin = "center center";
4517
4696
  } else {
4518
4697
  pre.style.transform = `rotate(${rotation}deg)`;
4519
4698
  pre.style.fontSize = `${fontSize}px`;
@@ -4719,16 +4898,56 @@ var ArchivePlugin = class {
4719
4898
  width: 100%;
4720
4899
  height: 100%;
4721
4900
  overflow: auto;
4722
- padding: 24px;
4723
4901
  box-sizing: border-box;
4724
4902
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
4725
- transform-origin: top left;
4726
- transition: transform 0.2s ease;
4727
4903
  `;
4904
+ const scrollWrapper = document.createElement("div");
4905
+ scrollWrapper.className = "fp-archive-scroll-wrapper";
4906
+ scrollWrapper.style.cssText = `
4907
+ min-width: 100%;
4908
+ min-height: 100%;
4909
+ width: max-content;
4910
+ height: max-content;
4911
+ display: flex;
4912
+ justify-content: center;
4913
+ align-items: flex-start;
4914
+ padding: 24px;
4915
+ box-sizing: border-box;
4916
+ `;
4917
+ const sizer = document.createElement("div");
4918
+ sizer.className = "fp-archive-sizer";
4919
+ sizer.style.cssText = `
4920
+ position: relative;
4921
+ flex-shrink: 0;
4922
+ display: flex;
4923
+ justify-content: center;
4924
+ align-items: flex-start;
4925
+ `;
4926
+ const card = document.createElement("div");
4927
+ card.className = "fp-archive-card";
4928
+ card.style.cssText = `
4929
+ width: 900px;
4930
+ box-sizing: border-box;
4931
+ transform-origin: top center;
4932
+ transition: transform 0.15s ease;
4933
+ flex-shrink: 0;
4934
+ `;
4935
+ sizer.appendChild(card);
4936
+ scrollWrapper.appendChild(sizer);
4937
+ wrapper.appendChild(scrollWrapper);
4728
4938
  ctx.container.innerHTML = "";
4729
4939
  ctx.container.style.overflow = "auto";
4730
4940
  ctx.container.appendChild(wrapper);
4731
4941
  let scale = 1;
4942
+ const applyTransform = () => {
4943
+ const boxW = Math.round(900 * scale);
4944
+ const cardH = card.offsetHeight || 600;
4945
+ const boxH = Math.round(cardH * scale);
4946
+ sizer.style.width = `${boxW}px`;
4947
+ sizer.style.height = `${boxH}px`;
4948
+ card.style.transform = `scale(${scale})`;
4949
+ card.style.transformOrigin = "top center";
4950
+ };
4732
4951
  const entries = await new Promise((resolve, reject) => {
4733
4952
  fflate.unzip(new Uint8Array(ctx.buffer), (err, unzipped) => {
4734
4953
  if (err) {
@@ -4752,7 +4971,7 @@ var ArchivePlugin = class {
4752
4971
  });
4753
4972
  const totalUncompressedSize = entries.reduce((acc, e) => acc + e.size, 0);
4754
4973
  const renderUI = (filteredEntries) => {
4755
- wrapper.innerHTML = `
4974
+ card.innerHTML = `
4756
4975
  <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;">
4757
4976
  <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;">
4758
4977
  <div>
@@ -4782,7 +5001,7 @@ var ArchivePlugin = class {
4782
5001
  </div>
4783
5002
  </div>
4784
5003
  `;
4785
- const tbody = wrapper.querySelector("#fp-archive-body");
5004
+ const tbody = card.querySelector("#fp-archive-body");
4786
5005
  if (filteredEntries.length === 0) {
4787
5006
  tbody.innerHTML = `<tr><td colspan="3" style="padding: 24px; text-align: center; color: #9ca3af;">No matching files found</td></tr>`;
4788
5007
  } else {
@@ -4811,19 +5030,20 @@ var ArchivePlugin = class {
4811
5030
  }
4812
5031
  });
4813
5032
  });
4814
- const searchInput = wrapper.querySelector("#fp-archive-search");
5033
+ const searchInput = card.querySelector("#fp-archive-search");
4815
5034
  if (searchInput) {
4816
5035
  searchInput.addEventListener("input", () => {
4817
5036
  const q = searchInput.value.toLowerCase().trim();
4818
5037
  const filtered = q ? entries.filter((e) => e.path.toLowerCase().includes(q)) : entries;
4819
5038
  renderUI(filtered);
4820
- const newSearch = wrapper.querySelector("#fp-archive-search");
5039
+ const newSearch = card.querySelector("#fp-archive-search");
4821
5040
  if (newSearch) {
4822
5041
  newSearch.value = q;
4823
5042
  newSearch.focus();
4824
5043
  }
4825
5044
  });
4826
5045
  }
5046
+ applyTransform();
4827
5047
  };
4828
5048
  renderUI(entries);
4829
5049
  const cleanup = () => {
@@ -4835,26 +5055,26 @@ var ArchivePlugin = class {
4835
5055
  destroy: cleanup,
4836
5056
  zoomIn: () => {
4837
5057
  scale += 0.1;
4838
- wrapper.style.transform = `scale(${scale})`;
5058
+ applyTransform();
4839
5059
  },
4840
5060
  zoomOut: () => {
4841
5061
  scale = Math.max(0.3, scale - 0.1);
4842
- wrapper.style.transform = `scale(${scale})`;
5062
+ applyTransform();
4843
5063
  },
4844
5064
  getZoom: () => scale,
4845
5065
  setZoom: (level) => {
4846
5066
  scale = level;
4847
- wrapper.style.transform = `scale(${scale})`;
5067
+ applyTransform();
4848
5068
  },
4849
5069
  fitToPage: () => {
4850
5070
  scale = 1;
4851
- wrapper.style.transform = "scale(1)";
5071
+ applyTransform();
4852
5072
  },
4853
5073
  resetZoom: () => {
4854
5074
  scale = 1;
4855
- wrapper.style.transform = "scale(1)";
4856
- ctx.container.scrollTop = 0;
4857
- ctx.container.scrollLeft = 0;
5075
+ wrapper.scrollTop = 0;
5076
+ wrapper.scrollLeft = 0;
5077
+ applyTransform();
4858
5078
  },
4859
5079
  download: () => {
4860
5080
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -5213,12 +5433,30 @@ var PptxPlugin = class {
5213
5433
  width: 100%;
5214
5434
  height: 100%;
5215
5435
  overflow: auto;
5436
+ box-sizing: border-box;
5437
+ background: var(--fp-bg-canvas, #525659);
5438
+ `;
5439
+ const scrollWrapper = document.createElement("div");
5440
+ scrollWrapper.className = "fp-pptx-scroll-wrapper";
5441
+ scrollWrapper.style.cssText = `
5442
+ min-width: 100%;
5443
+ min-height: 100%;
5444
+ width: max-content;
5445
+ height: max-content;
5216
5446
  display: flex;
5217
5447
  justify-content: center;
5218
- align-items: flex-start;
5448
+ align-items: center;
5219
5449
  padding: 24px;
5220
5450
  box-sizing: border-box;
5221
- background: var(--fp-bg-canvas, #525659);
5451
+ `;
5452
+ const sizer = document.createElement("div");
5453
+ sizer.className = "fp-pptx-sizer";
5454
+ sizer.style.cssText = `
5455
+ position: relative;
5456
+ flex-shrink: 0;
5457
+ display: flex;
5458
+ justify-content: center;
5459
+ align-items: center;
5222
5460
  `;
5223
5461
  const slideContainer = document.createElement("div");
5224
5462
  slideContainer.className = "fp-slide-container";
@@ -5227,14 +5465,15 @@ var PptxPlugin = class {
5227
5465
  border-radius: 4px;
5228
5466
  overflow: hidden;
5229
5467
  background: #ffffff;
5230
- transform-origin: top center;
5468
+ transform-origin: center center;
5231
5469
  transition: transform 0.2s ease;
5232
- max-width: calc(100% - 32px);
5233
- max-height: calc(100% - 48px);
5470
+ flex-shrink: 0;
5234
5471
  `;
5235
5472
  const canvas = document.createElement("canvas");
5236
5473
  slideContainer.appendChild(canvas);
5237
- wrapper.appendChild(slideContainer);
5474
+ sizer.appendChild(slideContainer);
5475
+ scrollWrapper.appendChild(sizer);
5476
+ wrapper.appendChild(scrollWrapper);
5238
5477
  ctx.container.innerHTML = "";
5239
5478
  ctx.container.style.overflow = "auto";
5240
5479
  ctx.container.appendChild(wrapper);
@@ -5246,7 +5485,17 @@ var PptxPlugin = class {
5246
5485
  return Math.min(1, Math.min(availW / cW, availH / cH));
5247
5486
  };
5248
5487
  const applyTransform = () => {
5488
+ const cW = canvas.offsetWidth || 1280;
5489
+ const cH = canvas.offsetHeight || 720;
5490
+ const isRotated90 = rotation % 180 !== 0;
5491
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
5492
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
5493
+ sizer.style.width = `${boxW}px`;
5494
+ sizer.style.height = `${boxH}px`;
5495
+ slideContainer.style.width = `${cW}px`;
5496
+ slideContainer.style.height = `${cH}px`;
5249
5497
  slideContainer.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5498
+ slideContainer.style.transformOrigin = "center center";
5250
5499
  };
5251
5500
  const renderCurrentSlide = async () => {
5252
5501
  try {
@@ -5852,13 +6101,33 @@ var RtfPlugin = class {
5852
6101
  wrapper.style.flexDirection = "column";
5853
6102
  wrapper.style.alignItems = "center";
5854
6103
  wrapper.style.backgroundColor = "transparent";
5855
- wrapper.style.transformOrigin = "top center";
6104
+ wrapper.style.transformOrigin = "center center";
5856
6105
  wrapper.style.transition = "transform 0.15s ease";
5857
- ctx.container.style.overflowX = "hidden";
5858
- ctx.container.style.overflowY = "auto";
5859
- ctx.container.style.padding = "16px 8px";
6106
+ wrapper.style.flexShrink = "0";
6107
+ const sizer = document.createElement("div");
6108
+ sizer.className = "fp-rtf-sizer";
6109
+ sizer.style.position = "relative";
6110
+ sizer.style.flexShrink = "0";
6111
+ sizer.style.display = "flex";
6112
+ sizer.style.justifyContent = "center";
6113
+ sizer.style.alignItems = "center";
6114
+ const scrollWrapper = document.createElement("div");
6115
+ scrollWrapper.className = "fp-rtf-scroll-wrapper";
6116
+ scrollWrapper.style.minWidth = "100%";
6117
+ scrollWrapper.style.minHeight = "100%";
6118
+ scrollWrapper.style.width = "max-content";
6119
+ scrollWrapper.style.height = "max-content";
6120
+ scrollWrapper.style.display = "flex";
6121
+ scrollWrapper.style.justifyContent = "center";
6122
+ scrollWrapper.style.alignItems = "flex-start";
6123
+ scrollWrapper.style.padding = "16px 8px";
6124
+ scrollWrapper.style.boxSizing = "border-box";
6125
+ sizer.appendChild(wrapper);
6126
+ scrollWrapper.appendChild(sizer);
6127
+ ctx.container.style.overflow = "auto";
6128
+ ctx.container.style.padding = "0";
5860
6129
  ctx.container.style.backgroundColor = "#f1f5f9";
5861
- ctx.container.appendChild(wrapper);
6130
+ ctx.container.appendChild(scrollWrapper);
5862
6131
  let scale = 1;
5863
6132
  let rotation = 0;
5864
6133
  let pageElements = [];
@@ -5877,12 +6146,17 @@ var RtfPlugin = class {
5877
6146
  return Math.max(0.4, Math.min(3, sW));
5878
6147
  };
5879
6148
  const applyTransform = () => {
5880
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5881
- wrapper.style.transformOrigin = "top center";
6149
+ const elW = pageWidth;
5882
6150
  const baseH = pageHeight;
5883
- const scaledH = baseH * scale;
5884
- const extraH = Math.max(0, scaledH - baseH);
5885
- wrapper.style.marginBottom = `${extraH + 32}px`;
6151
+ const isRotated90 = rotation % 180 !== 0;
6152
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6153
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6154
+ sizer.style.width = `${boxW}px`;
6155
+ sizer.style.height = `${boxH}px`;
6156
+ wrapper.style.width = `${elW}px`;
6157
+ wrapper.style.height = `${baseH}px`;
6158
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6159
+ wrapper.style.transformOrigin = "center center";
5886
6160
  };
5887
6161
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
5888
6162
  if (!isUserZoomed) {
@@ -6153,7 +6427,7 @@ var RtfPlugin = class {
6153
6427
  }
6154
6428
  const cleanup = () => {
6155
6429
  resizeObserver?.disconnect();
6156
- wrapper.remove();
6430
+ scrollWrapper.remove();
6157
6431
  ctx.container.innerHTML = "";
6158
6432
  };
6159
6433
  ctx.signal.addEventListener("abort", cleanup);
@@ -6328,23 +6602,44 @@ var HtmlPreviewPlugin = class {
6328
6602
  ADD_TAGS: ["style", "link"],
6329
6603
  ADD_ATTR: ["target", "rel"]
6330
6604
  });
6605
+ const sizer = document.createElement("div");
6606
+ sizer.className = "fp-html-sizer";
6607
+ sizer.style.position = "relative";
6331
6608
  const iframe = document.createElement("iframe");
6332
6609
  iframe.className = "fp-html-iframe";
6333
- iframe.style.width = "100%";
6334
- iframe.style.height = "100%";
6335
6610
  iframe.style.border = "none";
6336
6611
  iframe.style.backgroundColor = "#ffffff";
6337
6612
  iframe.style.transformOrigin = "top left";
6338
6613
  iframe.style.transition = "transform 0.2s ease";
6339
6614
  iframe.sandbox.add("allow-same-origin");
6615
+ sizer.appendChild(iframe);
6340
6616
  ctx.container.style.overflow = "auto";
6341
6617
  ctx.container.style.width = "100%";
6342
6618
  ctx.container.style.height = "100%";
6343
- ctx.container.appendChild(iframe);
6619
+ ctx.container.innerHTML = "";
6620
+ ctx.container.appendChild(sizer);
6344
6621
  iframe.srcdoc = sanitized;
6345
6622
  let scale = 1;
6623
+ const applyTransform = () => {
6624
+ const baseW = Math.max(600, ctx.container.clientWidth || 800);
6625
+ const baseH = Math.max(400, ctx.container.clientHeight || 600);
6626
+ const scaledW = Math.round(baseW * scale);
6627
+ const scaledH = Math.round(baseH * scale);
6628
+ sizer.style.width = `${scaledW}px`;
6629
+ sizer.style.height = `${scaledH}px`;
6630
+ iframe.style.position = "absolute";
6631
+ iframe.style.top = "0";
6632
+ iframe.style.left = "0";
6633
+ iframe.style.width = `${baseW}px`;
6634
+ iframe.style.height = `${baseH}px`;
6635
+ iframe.style.transform = `scale(${scale})`;
6636
+ iframe.style.transformOrigin = "top left";
6637
+ };
6638
+ requestAnimationFrame(() => {
6639
+ applyTransform();
6640
+ });
6346
6641
  const cleanup = () => {
6347
- iframe.remove();
6642
+ sizer.remove();
6348
6643
  ctx.container.innerHTML = "";
6349
6644
  };
6350
6645
  ctx.signal.addEventListener("abort", cleanup);
@@ -6352,26 +6647,26 @@ var HtmlPreviewPlugin = class {
6352
6647
  destroy: cleanup,
6353
6648
  zoomIn: () => {
6354
6649
  scale += 0.1;
6355
- iframe.style.transform = `scale(${scale})`;
6650
+ applyTransform();
6356
6651
  },
6357
6652
  zoomOut: () => {
6358
6653
  scale = Math.max(0.2, scale - 0.1);
6359
- iframe.style.transform = `scale(${scale})`;
6654
+ applyTransform();
6360
6655
  },
6361
6656
  getZoom: () => scale,
6362
6657
  setZoom: (level) => {
6363
6658
  scale = level;
6364
- iframe.style.transform = `scale(${scale})`;
6659
+ applyTransform();
6365
6660
  },
6366
6661
  fitToPage: () => {
6367
6662
  scale = 1;
6368
- iframe.style.transform = "scale(1)";
6663
+ applyTransform();
6369
6664
  },
6370
6665
  resetZoom: () => {
6371
6666
  scale = 1;
6372
- iframe.style.transform = "scale(1)";
6373
6667
  ctx.container.scrollTop = 0;
6374
6668
  ctx.container.scrollLeft = 0;
6669
+ applyTransform();
6375
6670
  },
6376
6671
  copy: () => {
6377
6672
  navigator.clipboard.writeText(rawHtml);
@@ -6546,10 +6841,26 @@ var OpenDocumentPlugin = class {
6546
6841
  container.className = "fp-odf-container";
6547
6842
  container.style.width = "100%";
6548
6843
  container.style.height = "100%";
6549
- container.style.overflowX = "hidden";
6550
- container.style.overflowY = "auto";
6551
- container.style.padding = "16px 8px";
6844
+ container.style.overflow = "auto";
6552
6845
  container.style.backgroundColor = "#f1f5f9";
6846
+ const scrollWrapper = document.createElement("div");
6847
+ scrollWrapper.className = "fp-odf-scroll-wrapper";
6848
+ scrollWrapper.style.minWidth = "100%";
6849
+ scrollWrapper.style.minHeight = "100%";
6850
+ scrollWrapper.style.width = "max-content";
6851
+ scrollWrapper.style.height = "max-content";
6852
+ scrollWrapper.style.display = "flex";
6853
+ scrollWrapper.style.justifyContent = "center";
6854
+ scrollWrapper.style.alignItems = "flex-start";
6855
+ scrollWrapper.style.padding = "16px 8px";
6856
+ scrollWrapper.style.boxSizing = "border-box";
6857
+ const sizer = document.createElement("div");
6858
+ sizer.className = "fp-odf-sizer";
6859
+ sizer.style.position = "relative";
6860
+ sizer.style.flexShrink = "0";
6861
+ sizer.style.display = "flex";
6862
+ sizer.style.justifyContent = "center";
6863
+ sizer.style.alignItems = "center";
6553
6864
  const wrapper = document.createElement("div");
6554
6865
  wrapper.className = "fp-odf-wrapper";
6555
6866
  wrapper.style.margin = "0 auto";
@@ -6558,9 +6869,12 @@ var OpenDocumentPlugin = class {
6558
6869
  wrapper.style.backgroundColor = "#ffffff";
6559
6870
  wrapper.style.boxShadow = "0 2px 10px rgba(0,0,0,0.08)";
6560
6871
  wrapper.style.borderRadius = "4px";
6561
- wrapper.style.transformOrigin = "top center";
6872
+ wrapper.style.transformOrigin = "center center";
6562
6873
  wrapper.style.transition = "transform 0.15s ease";
6563
- container.appendChild(wrapper);
6874
+ wrapper.style.flexShrink = "0";
6875
+ sizer.appendChild(wrapper);
6876
+ scrollWrapper.appendChild(sizer);
6877
+ container.appendChild(scrollWrapper);
6564
6878
  ctx.container.appendChild(container);
6565
6879
  let scale = 1;
6566
6880
  let rotation = 0;
@@ -6586,13 +6900,18 @@ var OpenDocumentPlugin = class {
6586
6900
  return Math.max(0.4, Math.min(3, sW));
6587
6901
  };
6588
6902
  const applyTransform = () => {
6589
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6590
- wrapper.style.transformOrigin = "top center";
6591
6903
  const activeSlide = slides[currentPage - 1];
6904
+ const elW = isPresentation ? 960 : 816;
6592
6905
  const baseH = activeSlide?.offsetHeight || wrapper.offsetHeight || 1056;
6593
- const scaledH = baseH * scale;
6594
- const extraH = Math.max(0, scaledH - baseH);
6595
- wrapper.style.marginBottom = `${extraH + 32}px`;
6906
+ const isRotated90 = rotation % 180 !== 0;
6907
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6908
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6909
+ sizer.style.width = `${boxW}px`;
6910
+ sizer.style.height = `${boxH}px`;
6911
+ wrapper.style.width = `${elW}px`;
6912
+ wrapper.style.height = `${baseH}px`;
6913
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6914
+ wrapper.style.transformOrigin = "center center";
6596
6915
  };
6597
6916
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
6598
6917
  if (!isUserZoomed) {
@@ -7156,13 +7475,28 @@ var DocPlugin = class {
7156
7475
  container.className = "fp-doc-container";
7157
7476
  container.style.width = "100%";
7158
7477
  container.style.height = "100%";
7159
- container.style.overflowX = "hidden";
7160
- container.style.overflowY = "auto";
7161
- container.style.padding = "16px 8px";
7478
+ container.style.overflow = "auto";
7162
7479
  container.style.backgroundColor = "#f1f5f9";
7163
- container.style.display = "flex";
7164
- container.style.justifyContent = "center";
7165
- container.style.alignItems = "flex-start";
7480
+ const scrollWrapper = document.createElement("div");
7481
+ scrollWrapper.className = "fp-doc-scroll-wrapper";
7482
+ scrollWrapper.style.minWidth = "100%";
7483
+ scrollWrapper.style.minHeight = "100%";
7484
+ scrollWrapper.style.width = "max-content";
7485
+ scrollWrapper.style.height = "max-content";
7486
+ scrollWrapper.style.display = "flex";
7487
+ scrollWrapper.style.justifyContent = "center";
7488
+ scrollWrapper.style.alignItems = "flex-start";
7489
+ scrollWrapper.style.padding = "16px 8px";
7490
+ scrollWrapper.style.boxSizing = "border-box";
7491
+ const sizer = document.createElement("div");
7492
+ sizer.className = "fp-doc-sizer";
7493
+ sizer.style.position = "relative";
7494
+ sizer.style.flexShrink = "0";
7495
+ sizer.style.display = "flex";
7496
+ sizer.style.justifyContent = "center";
7497
+ sizer.style.alignItems = "center";
7498
+ scrollWrapper.appendChild(sizer);
7499
+ container.appendChild(scrollWrapper);
7166
7500
  ctx.container.appendChild(container);
7167
7501
  let scale = 1;
7168
7502
  let extractedRawText = "";
@@ -7210,10 +7544,11 @@ var DocPlugin = class {
7210
7544
  pageCard.style.padding = "72px 56px";
7211
7545
  pageCard.style.boxSizing = "border-box";
7212
7546
  pageCard.style.display = i === 0 ? "block" : "none";
7213
- pageCard.style.transformOrigin = "top center";
7547
+ pageCard.style.transformOrigin = "center center";
7214
7548
  pageCard.style.transition = "transform 0.15s ease";
7215
7549
  pageCard.style.fontFamily = 'Calibri, "Segoe UI", Arial, sans-serif';
7216
7550
  pageCard.style.color = "#1e293b";
7551
+ pageCard.style.flexShrink = "0";
7217
7552
  if (isFallback && i === 0) {
7218
7553
  pageCard.innerHTML = `
7219
7554
  <div style="border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 24px;">
@@ -7225,18 +7560,23 @@ var DocPlugin = class {
7225
7560
  } else {
7226
7561
  pageCard.innerHTML = this.formatDocToHtml(rawPages[i], ctx.metadata.name || "Document");
7227
7562
  }
7228
- container.appendChild(pageCard);
7563
+ sizer.appendChild(pageCard);
7229
7564
  pageCards.push(pageCard);
7230
7565
  }
7231
7566
  let rotation = 0;
7232
7567
  const applyTransform = () => {
7233
7568
  const activeCard = pageCards[currentPage - 1];
7234
7569
  if (activeCard) {
7235
- activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7570
+ const baseW = 816;
7236
7571
  const baseH = activeCard.offsetHeight || 1056;
7237
- const scaledH = baseH * scale;
7238
- const extraH = Math.max(0, scaledH - baseH);
7239
- activeCard.style.marginBottom = `${extraH + 32}px`;
7572
+ const isRotated90 = rotation % 180 !== 0;
7573
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * scale);
7574
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * scale);
7575
+ sizer.style.width = `${boxW}px`;
7576
+ sizer.style.height = `${boxH}px`;
7577
+ activeCard.style.width = `${baseW}px`;
7578
+ activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7579
+ activeCard.style.transformOrigin = "center center";
7240
7580
  }
7241
7581
  };
7242
7582
  const showPage = (pageNum) => {
@@ -7244,11 +7584,11 @@ var DocPlugin = class {
7244
7584
  pageCards.forEach((card, idx) => {
7245
7585
  if (idx + 1 === currentPage) {
7246
7586
  card.style.display = "block";
7247
- card.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7248
7587
  } else {
7249
7588
  card.style.display = "none";
7250
7589
  }
7251
7590
  });
7591
+ applyTransform();
7252
7592
  container.scrollTop = 0;
7253
7593
  ctx.emit("page-change", { page: currentPage, total: totalPages });
7254
7594
  };
@@ -7319,6 +7659,8 @@ var DocPlugin = class {
7319
7659
  fitMode = "width";
7320
7660
  scale = calculateFitScale("width");
7321
7661
  rotation = 0;
7662
+ container.scrollTop = 0;
7663
+ container.scrollLeft = 0;
7322
7664
  ctx.container.scrollTop = 0;
7323
7665
  ctx.container.scrollLeft = 0;
7324
7666
  applyTransform();
@@ -7843,17 +8185,30 @@ var PptPlugin = class {
7843
8185
  container.style.width = "100%";
7844
8186
  container.style.height = "100%";
7845
8187
  container.style.overflow = "auto";
7846
- container.style.display = "flex";
7847
- container.style.justifyContent = "center";
7848
- container.style.alignItems = "center";
7849
- container.style.padding = "32px 16px";
7850
8188
  container.style.backgroundColor = "#0f172a";
7851
8189
  container.style.boxSizing = "border-box";
8190
+ const scrollWrapper = document.createElement("div");
8191
+ scrollWrapper.className = "fp-ppt-scroll-wrapper";
8192
+ scrollWrapper.style.minWidth = "100%";
8193
+ scrollWrapper.style.minHeight = "100%";
8194
+ scrollWrapper.style.width = "max-content";
8195
+ scrollWrapper.style.height = "max-content";
8196
+ scrollWrapper.style.display = "flex";
8197
+ scrollWrapper.style.justifyContent = "center";
8198
+ scrollWrapper.style.alignItems = "center";
8199
+ scrollWrapper.style.padding = "32px 16px";
8200
+ scrollWrapper.style.boxSizing = "border-box";
8201
+ const sizer = document.createElement("div");
8202
+ sizer.className = "fp-ppt-sizer";
8203
+ sizer.style.position = "relative";
8204
+ sizer.style.flexShrink = "0";
8205
+ sizer.style.display = "flex";
8206
+ sizer.style.justifyContent = "center";
8207
+ sizer.style.alignItems = "center";
7852
8208
  const slideCard = document.createElement("div");
7853
8209
  slideCard.className = "fp-ppt-slide-card";
7854
8210
  slideCard.style.width = "960px";
7855
- slideCard.style.maxWidth = "calc(100% - 32px)";
7856
- slideCard.style.maxHeight = "calc(100% - 48px)";
8211
+ slideCard.style.height = "540px";
7857
8212
  slideCard.style.aspectRatio = "16 / 9";
7858
8213
  slideCard.style.backgroundColor = "#ffffff";
7859
8214
  slideCard.style.boxShadow = "0 12px 40px rgba(0,0,0,0.35)";
@@ -7863,7 +8218,9 @@ var PptPlugin = class {
7863
8218
  slideCard.style.transition = "transform 0.2s ease";
7864
8219
  slideCard.style.transformOrigin = "center center";
7865
8220
  slideCard.style.flexShrink = "0";
7866
- container.appendChild(slideCard);
8221
+ sizer.appendChild(slideCard);
8222
+ scrollWrapper.appendChild(sizer);
8223
+ container.appendChild(scrollWrapper);
7867
8224
  ctx.container.appendChild(container);
7868
8225
  let scale = 1;
7869
8226
  let rotation = 0;
@@ -7876,7 +8233,17 @@ var PptPlugin = class {
7876
8233
  return Math.min(1, Math.min(availW / 960, availH / 540));
7877
8234
  };
7878
8235
  const applyTransform = () => {
8236
+ const cW = 960;
8237
+ const cH = 540;
8238
+ const isRotated90 = rotation % 180 !== 0;
8239
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
8240
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
8241
+ sizer.style.width = `${boxW}px`;
8242
+ sizer.style.height = `${boxH}px`;
8243
+ slideCard.style.width = `${cW}px`;
8244
+ slideCard.style.height = `${cH}px`;
7879
8245
  slideCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
8246
+ slideCard.style.transformOrigin = "center center";
7880
8247
  };
7881
8248
  setTimeout(() => {
7882
8249
  scale = calculateFitScale();