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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue.cjs CHANGED
@@ -2117,16 +2117,22 @@ var PdfPlugin = class {
2117
2117
  container.className = "fp-pdf-container";
2118
2118
  container.style.width = "100%";
2119
2119
  container.style.height = "100%";
2120
- container.style.overflowX = "hidden";
2121
- container.style.overflowY = "auto";
2122
- container.style.display = "flex";
2123
- container.style.flexDirection = "column";
2124
- container.style.alignItems = "center";
2125
- container.style.justifyContent = "flex-start";
2126
- container.style.padding = "16px 8px";
2120
+ container.style.overflow = "auto";
2127
2121
  container.style.backgroundColor = "#0f172a";
2128
2122
  container.style.boxSizing = "border-box";
2129
2123
  container.style.position = "relative";
2124
+ const scrollWrapper = document.createElement("div");
2125
+ scrollWrapper.className = "fp-pdf-scroll-wrapper";
2126
+ scrollWrapper.style.minWidth = "100%";
2127
+ scrollWrapper.style.minHeight = "100%";
2128
+ scrollWrapper.style.width = "max-content";
2129
+ scrollWrapper.style.height = "max-content";
2130
+ scrollWrapper.style.display = "flex";
2131
+ scrollWrapper.style.flexDirection = "column";
2132
+ scrollWrapper.style.alignItems = "center";
2133
+ scrollWrapper.style.justifyContent = "flex-start";
2134
+ scrollWrapper.style.padding = "16px 8px";
2135
+ scrollWrapper.style.boxSizing = "border-box";
2130
2136
  const pageCard = document.createElement("div");
2131
2137
  pageCard.className = "fp-pdf-page-card";
2132
2138
  pageCard.style.boxShadow = "0 10px 35px rgba(0, 0, 0, 0.5)";
@@ -2139,7 +2145,8 @@ var PdfPlugin = class {
2139
2145
  pageCard.style.transition = "box-shadow 0.2s ease";
2140
2146
  let canvas = document.createElement("canvas");
2141
2147
  pageCard.appendChild(canvas);
2142
- container.appendChild(pageCard);
2148
+ scrollWrapper.appendChild(pageCard);
2149
+ container.appendChild(scrollWrapper);
2143
2150
  ctx.container.appendChild(container);
2144
2151
  const standardFontsUrl = typeof window !== "undefined" && window.__PDF_STANDARD_FONTS_URL__ || "./standard_fonts/";
2145
2152
  const cmapsUrl = typeof window !== "undefined" && window.__PDF_CMAPS_URL__ || "./cmaps/";
@@ -2648,17 +2655,86 @@ var MediaPlugin = class {
2648
2655
  element = document.createElement("div");
2649
2656
  element.textContent = "Unsupported media type";
2650
2657
  }
2651
- ctx.container.style.display = "flex";
2652
- ctx.container.style.alignItems = "center";
2653
- ctx.container.style.justifyContent = "center";
2654
- ctx.container.style.overflow = "hidden";
2655
- ctx.container.appendChild(element);
2658
+ const scrollWrapper = document.createElement("div");
2659
+ scrollWrapper.className = "fp-media-scroll-wrapper";
2660
+ scrollWrapper.style.minWidth = "100%";
2661
+ scrollWrapper.style.minHeight = "100%";
2662
+ scrollWrapper.style.width = "max-content";
2663
+ scrollWrapper.style.height = "max-content";
2664
+ scrollWrapper.style.display = "flex";
2665
+ scrollWrapper.style.justifyContent = "center";
2666
+ scrollWrapper.style.alignItems = "center";
2667
+ scrollWrapper.style.padding = "16px";
2668
+ scrollWrapper.style.boxSizing = "border-box";
2669
+ const sizer = document.createElement("div");
2670
+ sizer.className = "fp-media-sizer";
2671
+ sizer.style.position = "relative";
2672
+ sizer.style.flexShrink = "0";
2673
+ sizer.style.display = "flex";
2674
+ sizer.style.justifyContent = "center";
2675
+ sizer.style.alignItems = "center";
2676
+ sizer.appendChild(element);
2677
+ scrollWrapper.appendChild(sizer);
2678
+ ctx.container.style.overflow = "auto";
2679
+ ctx.container.style.padding = "0";
2680
+ ctx.container.innerHTML = "";
2681
+ ctx.container.appendChild(scrollWrapper);
2682
+ let naturalW = 800;
2683
+ let naturalH = 600;
2684
+ let baseW = 800;
2685
+ let baseH = 600;
2686
+ const updateBaseDimensions = () => {
2687
+ if (!isImage) return;
2688
+ const img = element;
2689
+ naturalW = img.naturalWidth || naturalW;
2690
+ naturalH = img.naturalHeight || naturalH;
2691
+ const availW = Math.max(100, ctx.container.clientWidth - 48);
2692
+ const availH = Math.max(100, ctx.container.clientHeight - 48);
2693
+ const fitRatio = Math.min(1, availW / naturalW, availH / naturalH);
2694
+ baseW = Math.max(1, Math.round(naturalW * fitRatio));
2695
+ baseH = Math.max(1, Math.round(naturalH * fitRatio));
2696
+ };
2656
2697
  const applyTransform = () => {
2657
- element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2698
+ if (isImage) {
2699
+ updateBaseDimensions();
2700
+ const isRotated90 = rotation % 180 !== 0;
2701
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * currentZoom);
2702
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * currentZoom);
2703
+ sizer.style.width = `${boxW}px`;
2704
+ sizer.style.height = `${boxH}px`;
2705
+ element.style.width = `${baseW}px`;
2706
+ element.style.height = `${baseH}px`;
2707
+ element.style.maxWidth = "none";
2708
+ element.style.maxHeight = "none";
2709
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2710
+ element.style.transformOrigin = "center center";
2711
+ element.style.flexShrink = "0";
2712
+ } else {
2713
+ element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2714
+ }
2658
2715
  };
2716
+ if (isImage) {
2717
+ const img = element;
2718
+ if (img.complete && img.naturalWidth > 0) {
2719
+ updateBaseDimensions();
2720
+ applyTransform();
2721
+ } else {
2722
+ img.onload = () => {
2723
+ updateBaseDimensions();
2724
+ applyTransform();
2725
+ };
2726
+ }
2727
+ }
2728
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
2729
+ if (currentZoom === 1) {
2730
+ applyTransform();
2731
+ }
2732
+ }) : null;
2733
+ ro?.observe(ctx.container);
2659
2734
  const cleanup = () => {
2735
+ ro?.disconnect();
2660
2736
  if (url) URL.revokeObjectURL(url);
2661
- element.remove();
2737
+ scrollWrapper.remove();
2662
2738
  ctx.container.innerHTML = "";
2663
2739
  };
2664
2740
  ctx.signal.addEventListener("abort", cleanup);
@@ -2851,7 +2927,7 @@ var DocxPlugin = class {
2851
2927
  async render(ctx) {
2852
2928
  const wrapper = document.createElement("div");
2853
2929
  wrapper.className = "fp-docx-wrapper";
2854
- wrapper.style.transformOrigin = "top center";
2930
+ wrapper.style.transformOrigin = "center center";
2855
2931
  wrapper.style.transition = "transform 0.2s ease";
2856
2932
  wrapper.style.padding = "0";
2857
2933
  wrapper.style.maxWidth = "none";
@@ -2861,11 +2937,31 @@ var DocxPlugin = class {
2861
2937
  wrapper.style.flexDirection = "column";
2862
2938
  wrapper.style.alignItems = "center";
2863
2939
  wrapper.style.boxSizing = "border-box";
2864
- ctx.container.style.overflowX = "hidden";
2865
- ctx.container.style.overflowY = "auto";
2866
- ctx.container.style.padding = "16px 8px";
2940
+ wrapper.style.flexShrink = "0";
2941
+ const sizer = document.createElement("div");
2942
+ sizer.className = "fp-docx-sizer";
2943
+ sizer.style.position = "relative";
2944
+ sizer.style.flexShrink = "0";
2945
+ sizer.style.display = "flex";
2946
+ sizer.style.justifyContent = "center";
2947
+ sizer.style.alignItems = "center";
2948
+ const scrollWrapper = document.createElement("div");
2949
+ scrollWrapper.className = "fp-docx-scroll-wrapper";
2950
+ scrollWrapper.style.minWidth = "100%";
2951
+ scrollWrapper.style.minHeight = "100%";
2952
+ scrollWrapper.style.width = "max-content";
2953
+ scrollWrapper.style.height = "max-content";
2954
+ scrollWrapper.style.display = "flex";
2955
+ scrollWrapper.style.justifyContent = "center";
2956
+ scrollWrapper.style.alignItems = "flex-start";
2957
+ scrollWrapper.style.padding = "16px 8px";
2958
+ scrollWrapper.style.boxSizing = "border-box";
2959
+ sizer.appendChild(wrapper);
2960
+ scrollWrapper.appendChild(sizer);
2961
+ ctx.container.style.overflow = "auto";
2962
+ ctx.container.style.padding = "0";
2867
2963
  ctx.container.style.backgroundColor = "#f1f5f9";
2868
- ctx.container.appendChild(wrapper);
2964
+ ctx.container.appendChild(scrollWrapper);
2869
2965
  const styleOverride = document.createElement("style");
2870
2966
  styleOverride.textContent = `
2871
2967
  .fp-docx-wrapper .docx-wrapper {
@@ -2904,8 +3000,8 @@ var DocxPlugin = class {
2904
3000
  renderEndnotes: true,
2905
3001
  useBase64URL: true
2906
3002
  });
2907
- if (!ctx.container.contains(wrapper)) {
2908
- ctx.container.appendChild(wrapper);
3003
+ if (!sizer.contains(wrapper)) {
3004
+ sizer.appendChild(wrapper);
2909
3005
  }
2910
3006
  if (wrapper.children.length > 0 && (wrapper.textContent?.trim().length ?? 0) > 0) {
2911
3007
  renderedSuccessfully = true;
@@ -2942,8 +3038,8 @@ var DocxPlugin = class {
2942
3038
  try {
2943
3039
  wrapper.innerHTML = "";
2944
3040
  this.renderXmlFallback(ctx, wrapper, createdBlobUrls);
2945
- if (!ctx.container.contains(wrapper)) {
2946
- ctx.container.appendChild(wrapper);
3041
+ if (!sizer.contains(wrapper)) {
3042
+ sizer.appendChild(wrapper);
2947
3043
  }
2948
3044
  renderedSuccessfully = true;
2949
3045
  } catch (fallbackErr) {
@@ -2958,8 +3054,8 @@ var DocxPlugin = class {
2958
3054
  </p>
2959
3055
  </div>
2960
3056
  `;
2961
- if (!ctx.container.contains(wrapper)) {
2962
- ctx.container.appendChild(wrapper);
3057
+ if (!sizer.contains(wrapper)) {
3058
+ sizer.appendChild(wrapper);
2963
3059
  }
2964
3060
  }
2965
3061
  }
@@ -3062,15 +3158,18 @@ var DocxPlugin = class {
3062
3158
  return Math.max(0.35, Math.min(3, sW));
3063
3159
  };
3064
3160
  const applyTransform = () => {
3065
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3066
- wrapper.style.transformOrigin = "top center";
3067
3161
  const activeEl = pageElements[currentPage - 1] || wrapper.querySelector("section.docx") || wrapper;
3162
+ const elW = activeEl.offsetWidth || 816;
3068
3163
  const elH = activeEl.offsetHeight || 1056;
3069
- if (scale > 1) {
3070
- wrapper.style.marginBottom = `${Math.round(elH * scale - elH + 32)}px`;
3071
- } else {
3072
- wrapper.style.marginBottom = "32px";
3073
- }
3164
+ const isRotated90 = rotation % 180 !== 0;
3165
+ const boxW = Math.round((isRotated90 ? elH : elW) * scale);
3166
+ const boxH = Math.round((isRotated90 ? elW : elH) * scale);
3167
+ sizer.style.width = `${boxW}px`;
3168
+ sizer.style.height = `${boxH}px`;
3169
+ wrapper.style.width = `${elW}px`;
3170
+ wrapper.style.height = `${elH}px`;
3171
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
3172
+ wrapper.style.transformOrigin = "center center";
3074
3173
  };
3075
3174
  let resizeObserver = null;
3076
3175
  if (typeof ResizeObserver !== "undefined") {
@@ -3095,7 +3194,7 @@ var DocxPlugin = class {
3095
3194
  for (const url of createdBlobUrls) {
3096
3195
  URL.revokeObjectURL(url);
3097
3196
  }
3098
- wrapper.remove();
3197
+ scrollWrapper.remove();
3099
3198
  styleOverride.remove();
3100
3199
  ctx.container.innerHTML = "";
3101
3200
  };
@@ -3642,7 +3741,7 @@ var ExcelPlugin = class {
3642
3741
  contentArea.style.flex = "1";
3643
3742
  contentArea.style.overflow = "auto";
3644
3743
  contentArea.style.padding = "16px";
3645
- contentArea.style.transformOrigin = "top left";
3744
+ contentArea.style.boxSizing = "border-box";
3646
3745
  const tabsArea = document.createElement("div");
3647
3746
  tabsArea.className = "fp-excel-tabs";
3648
3747
  tabsArea.style.display = "flex";
@@ -3656,18 +3755,35 @@ var ExcelPlugin = class {
3656
3755
  container.appendChild(tabsArea);
3657
3756
  ctx.container.appendChild(container);
3658
3757
  let scale = 1;
3758
+ let isUserZoomed = false;
3659
3759
  let currentSheetIndex = 1;
3660
3760
  let sheetNames = [];
3661
3761
  let wb = null;
3662
3762
  const applyTransform = () => {
3663
- contentArea.style.transform = `scale(${scale})`;
3664
- contentArea.style.transformOrigin = "top left";
3763
+ const sizer = contentArea.querySelector(".fp-excel-sizer");
3764
+ const table = contentArea.querySelector("table");
3765
+ if (!sizer || !table) return;
3766
+ if (!table._baseWidth && table.offsetWidth > 0) {
3767
+ table._baseWidth = table.offsetWidth;
3768
+ table._baseHeight = table.offsetHeight;
3769
+ }
3770
+ const baseW = table._baseWidth || table.offsetWidth || 800;
3771
+ const baseH = table._baseHeight || table.offsetHeight || 600;
3772
+ const scaledW = Math.round(baseW * scale);
3773
+ const scaledH = Math.round(baseH * scale);
3774
+ sizer.style.width = `${scaledW}px`;
3775
+ sizer.style.height = `${scaledH}px`;
3776
+ table.style.position = "absolute";
3777
+ table.style.top = "0";
3778
+ table.style.left = "0";
3779
+ table.style.transform = `scale(${scale})`;
3780
+ table.style.transformOrigin = "top left";
3665
3781
  };
3666
3782
  const calculateFitScale = () => {
3667
3783
  const table = contentArea.querySelector("table");
3668
3784
  if (!table) return 1;
3669
3785
  const availW = Math.max(280, container.clientWidth - 48);
3670
- const tW = table.offsetWidth || 800;
3786
+ const tW = table._baseWidth || table.offsetWidth || 800;
3671
3787
  return Math.max(0.4, Math.min(1, availW / tW));
3672
3788
  };
3673
3789
  try {
@@ -3687,9 +3803,13 @@ var ExcelPlugin = class {
3687
3803
  contentArea.innerHTML = '<div style="padding: 24px; color: #888;">Empty sheet</div>';
3688
3804
  return;
3689
3805
  }
3806
+ const sizer = document.createElement("div");
3807
+ sizer.className = "fp-excel-sizer";
3808
+ sizer.style.position = "relative";
3690
3809
  const html = XLSX__namespace.utils.sheet_to_html(ws, { id: "fp-sheet-table", editable: false });
3691
- contentArea.innerHTML = html;
3692
- const table = contentArea.querySelector("table");
3810
+ sizer.innerHTML = html;
3811
+ contentArea.appendChild(sizer);
3812
+ const table = sizer.querySelector("table");
3693
3813
  if (table) {
3694
3814
  table.style.borderCollapse = "collapse";
3695
3815
  table.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
@@ -3724,13 +3844,17 @@ var ExcelPlugin = class {
3724
3844
  });
3725
3845
  ctx.emit("page-change", { page: currentSheetIndex, total: sheetNames.length });
3726
3846
  requestAnimationFrame(() => {
3727
- scale = calculateFitScale();
3847
+ if (!isUserZoomed) {
3848
+ scale = calculateFitScale();
3849
+ }
3728
3850
  applyTransform();
3729
3851
  });
3730
3852
  };
3731
3853
  const ro = new ResizeObserver(() => {
3732
- scale = calculateFitScale();
3733
- applyTransform();
3854
+ if (!isUserZoomed) {
3855
+ scale = calculateFitScale();
3856
+ applyTransform();
3857
+ }
3734
3858
  });
3735
3859
  ro.observe(container);
3736
3860
  if (sheetNames.length > 0) {
@@ -3767,23 +3891,28 @@ var ExcelPlugin = class {
3767
3891
  return {
3768
3892
  destroy: cleanup,
3769
3893
  zoomIn: () => {
3894
+ isUserZoomed = true;
3770
3895
  scale += 0.15;
3771
3896
  applyTransform();
3772
3897
  },
3773
3898
  zoomOut: () => {
3899
+ isUserZoomed = true;
3774
3900
  scale = Math.max(0.2, scale - 0.15);
3775
3901
  applyTransform();
3776
3902
  },
3777
3903
  getZoom: () => scale,
3778
3904
  setZoom: (level) => {
3905
+ isUserZoomed = true;
3779
3906
  scale = level;
3780
3907
  applyTransform();
3781
3908
  },
3782
3909
  fitToPage: () => {
3910
+ isUserZoomed = false;
3783
3911
  scale = calculateFitScale();
3784
3912
  applyTransform();
3785
3913
  },
3786
3914
  resetZoom: () => {
3915
+ isUserZoomed = false;
3787
3916
  scale = calculateFitScale();
3788
3917
  contentArea.scrollTop = 0;
3789
3918
  contentArea.scrollLeft = 0;
@@ -4015,21 +4144,41 @@ var CsvPlugin = class {
4015
4144
  container.appendChild(tableWrapper);
4016
4145
  ctx.container.appendChild(container);
4017
4146
  let scale = 1;
4147
+ let isUserZoomed = false;
4018
4148
  const calculateFitScale = () => {
4019
4149
  const availW = Math.max(280, container.clientWidth - 48);
4020
- const tW = table.offsetWidth || 800;
4150
+ const tW = table._baseWidth || table.offsetWidth || 800;
4021
4151
  return Math.max(0.4, Math.min(1, availW / tW));
4022
4152
  };
4023
4153
  const applyScale = () => {
4024
- tableWrapper.style.transform = `scale(${scale})`;
4154
+ if (!table._baseWidth && table.offsetWidth > 0) {
4155
+ table._baseWidth = table.offsetWidth;
4156
+ table._baseHeight = table.offsetHeight;
4157
+ }
4158
+ const baseW = table._baseWidth || table.offsetWidth || 800;
4159
+ const baseH = table._baseHeight || table.offsetHeight || 600;
4160
+ const scaledW = Math.round(baseW * scale);
4161
+ const scaledH = Math.round(baseH * scale);
4162
+ tableWrapper.style.position = "relative";
4163
+ tableWrapper.style.width = `${scaledW}px`;
4164
+ tableWrapper.style.height = `${scaledH}px`;
4165
+ table.style.position = "absolute";
4166
+ table.style.top = "0";
4167
+ table.style.left = "0";
4168
+ table.style.transform = `scale(${scale})`;
4169
+ table.style.transformOrigin = "top left";
4025
4170
  };
4026
4171
  requestAnimationFrame(() => {
4027
- scale = calculateFitScale();
4172
+ if (!isUserZoomed) {
4173
+ scale = calculateFitScale();
4174
+ }
4028
4175
  applyScale();
4029
4176
  });
4030
4177
  const ro = new ResizeObserver(() => {
4031
- scale = calculateFitScale();
4032
- applyScale();
4178
+ if (!isUserZoomed) {
4179
+ scale = calculateFitScale();
4180
+ applyScale();
4181
+ }
4033
4182
  });
4034
4183
  ro.observe(container);
4035
4184
  const cleanup = () => {
@@ -4102,23 +4251,28 @@ var CsvPlugin = class {
4102
4251
  }];
4103
4252
  },
4104
4253
  zoomIn: () => {
4254
+ isUserZoomed = true;
4105
4255
  scale += 0.1;
4106
4256
  applyScale();
4107
4257
  },
4108
4258
  zoomOut: () => {
4259
+ isUserZoomed = true;
4109
4260
  scale = Math.max(0.2, scale - 0.1);
4110
4261
  applyScale();
4111
4262
  },
4112
4263
  getZoom: () => scale,
4113
4264
  setZoom: (level) => {
4265
+ isUserZoomed = true;
4114
4266
  scale = level;
4115
4267
  applyScale();
4116
4268
  },
4117
4269
  fitToPage: () => {
4270
+ isUserZoomed = false;
4118
4271
  scale = calculateFitScale();
4119
4272
  applyScale();
4120
4273
  },
4121
4274
  resetZoom: () => {
4275
+ isUserZoomed = false;
4122
4276
  scale = calculateFitScale();
4123
4277
  container.scrollTop = 0;
4124
4278
  container.scrollLeft = 0;
@@ -4354,15 +4508,27 @@ var CodePlugin = class {
4354
4508
  let isUserZoomed = false;
4355
4509
  const pre = document.createElement("pre");
4356
4510
  const code = document.createElement("code");
4511
+ const sizer = document.createElement("div");
4512
+ const scrollWrapper = document.createElement("div");
4357
4513
  if (isTxt) {
4358
- container.style.overflowX = "hidden";
4359
- container.style.overflowY = "auto";
4514
+ container.style.overflow = "auto";
4360
4515
  container.style.backgroundColor = "#f1f5f9";
4361
- container.style.padding = "16px 8px";
4362
- container.style.boxSizing = "border-box";
4363
- container.style.display = "flex";
4364
- container.style.flexDirection = "column";
4365
- container.style.alignItems = "center";
4516
+ scrollWrapper.className = "fp-code-scroll-wrapper";
4517
+ scrollWrapper.style.minWidth = "100%";
4518
+ scrollWrapper.style.minHeight = "100%";
4519
+ scrollWrapper.style.width = "max-content";
4520
+ scrollWrapper.style.height = "max-content";
4521
+ scrollWrapper.style.display = "flex";
4522
+ scrollWrapper.style.justifyContent = "center";
4523
+ scrollWrapper.style.alignItems = "flex-start";
4524
+ scrollWrapper.style.padding = "16px 8px";
4525
+ scrollWrapper.style.boxSizing = "border-box";
4526
+ sizer.className = "fp-code-sizer";
4527
+ sizer.style.position = "relative";
4528
+ sizer.style.flexShrink = "0";
4529
+ sizer.style.display = "flex";
4530
+ sizer.style.justifyContent = "center";
4531
+ sizer.style.alignItems = "center";
4366
4532
  pre.style.margin = "0 auto";
4367
4533
  pre.style.fontFamily = "Consolas, 'Courier New', monospace";
4368
4534
  pre.style.fontSize = "13px";
@@ -4377,8 +4543,9 @@ var CodePlugin = class {
4377
4543
  pre.style.boxSizing = "border-box";
4378
4544
  pre.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
4379
4545
  pre.style.borderRadius = "4px";
4380
- pre.style.transformOrigin = "top center";
4546
+ pre.style.transformOrigin = "center center";
4381
4547
  pre.style.transition = "transform 0.15s ease";
4548
+ pre.style.flexShrink = "0";
4382
4549
  } else {
4383
4550
  container.style.overflow = "auto";
4384
4551
  container.style.backgroundColor = "#1e1e1e";
@@ -4411,7 +4578,13 @@ var CodePlugin = class {
4411
4578
  };
4412
4579
  renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
4413
4580
  pre.appendChild(code);
4414
- container.appendChild(pre);
4581
+ if (isTxt) {
4582
+ sizer.appendChild(pre);
4583
+ scrollWrapper.appendChild(sizer);
4584
+ container.appendChild(scrollWrapper);
4585
+ } else {
4586
+ container.appendChild(pre);
4587
+ }
4415
4588
  const showPage = (pageNum) => {
4416
4589
  currentPage = Math.max(1, Math.min(totalPages, pageNum));
4417
4590
  renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
@@ -4428,10 +4601,16 @@ var CodePlugin = class {
4428
4601
  };
4429
4602
  const updateTransform = () => {
4430
4603
  if (isTxt) {
4604
+ const elW = 816;
4605
+ const baseH = pre.offsetHeight || 1056;
4606
+ const isRotated90 = rotation % 180 !== 0;
4607
+ const boxW = Math.round((isRotated90 ? baseH : elW) * zoomLevel);
4608
+ const boxH = Math.round((isRotated90 ? elW : baseH) * zoomLevel);
4609
+ sizer.style.width = `${boxW}px`;
4610
+ sizer.style.height = `${boxH}px`;
4611
+ pre.style.width = `${elW}px`;
4431
4612
  pre.style.transform = `scale(${zoomLevel}) rotate(${rotation}deg)`;
4432
- const scaledH = 1056 * zoomLevel;
4433
- const extraH = Math.max(0, scaledH - 1056);
4434
- pre.style.marginBottom = `${extraH + 32}px`;
4613
+ pre.style.transformOrigin = "center center";
4435
4614
  } else {
4436
4615
  pre.style.transform = `rotate(${rotation}deg)`;
4437
4616
  pre.style.fontSize = `${fontSize}px`;
@@ -4637,16 +4816,56 @@ var ArchivePlugin = class {
4637
4816
  width: 100%;
4638
4817
  height: 100%;
4639
4818
  overflow: auto;
4640
- padding: 24px;
4641
4819
  box-sizing: border-box;
4642
4820
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
4643
- transform-origin: top left;
4644
- transition: transform 0.2s ease;
4645
4821
  `;
4822
+ const scrollWrapper = document.createElement("div");
4823
+ scrollWrapper.className = "fp-archive-scroll-wrapper";
4824
+ scrollWrapper.style.cssText = `
4825
+ min-width: 100%;
4826
+ min-height: 100%;
4827
+ width: max-content;
4828
+ height: max-content;
4829
+ display: flex;
4830
+ justify-content: center;
4831
+ align-items: flex-start;
4832
+ padding: 24px;
4833
+ box-sizing: border-box;
4834
+ `;
4835
+ const sizer = document.createElement("div");
4836
+ sizer.className = "fp-archive-sizer";
4837
+ sizer.style.cssText = `
4838
+ position: relative;
4839
+ flex-shrink: 0;
4840
+ display: flex;
4841
+ justify-content: center;
4842
+ align-items: flex-start;
4843
+ `;
4844
+ const card = document.createElement("div");
4845
+ card.className = "fp-archive-card";
4846
+ card.style.cssText = `
4847
+ width: 900px;
4848
+ box-sizing: border-box;
4849
+ transform-origin: top center;
4850
+ transition: transform 0.15s ease;
4851
+ flex-shrink: 0;
4852
+ `;
4853
+ sizer.appendChild(card);
4854
+ scrollWrapper.appendChild(sizer);
4855
+ wrapper.appendChild(scrollWrapper);
4646
4856
  ctx.container.innerHTML = "";
4647
4857
  ctx.container.style.overflow = "auto";
4648
4858
  ctx.container.appendChild(wrapper);
4649
4859
  let scale = 1;
4860
+ const applyTransform = () => {
4861
+ const boxW = Math.round(900 * scale);
4862
+ const cardH = card.offsetHeight || 600;
4863
+ const boxH = Math.round(cardH * scale);
4864
+ sizer.style.width = `${boxW}px`;
4865
+ sizer.style.height = `${boxH}px`;
4866
+ card.style.transform = `scale(${scale})`;
4867
+ card.style.transformOrigin = "top center";
4868
+ };
4650
4869
  const entries = await new Promise((resolve, reject) => {
4651
4870
  fflate.unzip(new Uint8Array(ctx.buffer), (err, unzipped) => {
4652
4871
  if (err) {
@@ -4670,7 +4889,7 @@ var ArchivePlugin = class {
4670
4889
  });
4671
4890
  const totalUncompressedSize = entries.reduce((acc, e) => acc + e.size, 0);
4672
4891
  const renderUI = (filteredEntries) => {
4673
- wrapper.innerHTML = `
4892
+ card.innerHTML = `
4674
4893
  <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;">
4675
4894
  <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;">
4676
4895
  <div>
@@ -4700,7 +4919,7 @@ var ArchivePlugin = class {
4700
4919
  </div>
4701
4920
  </div>
4702
4921
  `;
4703
- const tbody = wrapper.querySelector("#fp-archive-body");
4922
+ const tbody = card.querySelector("#fp-archive-body");
4704
4923
  if (filteredEntries.length === 0) {
4705
4924
  tbody.innerHTML = `<tr><td colspan="3" style="padding: 24px; text-align: center; color: #9ca3af;">No matching files found</td></tr>`;
4706
4925
  } else {
@@ -4729,19 +4948,20 @@ var ArchivePlugin = class {
4729
4948
  }
4730
4949
  });
4731
4950
  });
4732
- const searchInput = wrapper.querySelector("#fp-archive-search");
4951
+ const searchInput = card.querySelector("#fp-archive-search");
4733
4952
  if (searchInput) {
4734
4953
  searchInput.addEventListener("input", () => {
4735
4954
  const q = searchInput.value.toLowerCase().trim();
4736
4955
  const filtered = q ? entries.filter((e) => e.path.toLowerCase().includes(q)) : entries;
4737
4956
  renderUI(filtered);
4738
- const newSearch = wrapper.querySelector("#fp-archive-search");
4957
+ const newSearch = card.querySelector("#fp-archive-search");
4739
4958
  if (newSearch) {
4740
4959
  newSearch.value = q;
4741
4960
  newSearch.focus();
4742
4961
  }
4743
4962
  });
4744
4963
  }
4964
+ applyTransform();
4745
4965
  };
4746
4966
  renderUI(entries);
4747
4967
  const cleanup = () => {
@@ -4753,26 +4973,26 @@ var ArchivePlugin = class {
4753
4973
  destroy: cleanup,
4754
4974
  zoomIn: () => {
4755
4975
  scale += 0.1;
4756
- wrapper.style.transform = `scale(${scale})`;
4976
+ applyTransform();
4757
4977
  },
4758
4978
  zoomOut: () => {
4759
4979
  scale = Math.max(0.3, scale - 0.1);
4760
- wrapper.style.transform = `scale(${scale})`;
4980
+ applyTransform();
4761
4981
  },
4762
4982
  getZoom: () => scale,
4763
4983
  setZoom: (level) => {
4764
4984
  scale = level;
4765
- wrapper.style.transform = `scale(${scale})`;
4985
+ applyTransform();
4766
4986
  },
4767
4987
  fitToPage: () => {
4768
4988
  scale = 1;
4769
- wrapper.style.transform = "scale(1)";
4989
+ applyTransform();
4770
4990
  },
4771
4991
  resetZoom: () => {
4772
4992
  scale = 1;
4773
- wrapper.style.transform = "scale(1)";
4774
- ctx.container.scrollTop = 0;
4775
- ctx.container.scrollLeft = 0;
4993
+ wrapper.scrollTop = 0;
4994
+ wrapper.scrollLeft = 0;
4995
+ applyTransform();
4776
4996
  },
4777
4997
  download: () => {
4778
4998
  downloadFile(ctx.buffer, ctx.metadata.name || "archive.zip", "application/zip");
@@ -5131,12 +5351,30 @@ var PptxPlugin = class {
5131
5351
  width: 100%;
5132
5352
  height: 100%;
5133
5353
  overflow: auto;
5354
+ box-sizing: border-box;
5355
+ background: var(--fp-bg-canvas, #525659);
5356
+ `;
5357
+ const scrollWrapper = document.createElement("div");
5358
+ scrollWrapper.className = "fp-pptx-scroll-wrapper";
5359
+ scrollWrapper.style.cssText = `
5360
+ min-width: 100%;
5361
+ min-height: 100%;
5362
+ width: max-content;
5363
+ height: max-content;
5134
5364
  display: flex;
5135
5365
  justify-content: center;
5136
- align-items: flex-start;
5366
+ align-items: center;
5137
5367
  padding: 24px;
5138
5368
  box-sizing: border-box;
5139
- background: var(--fp-bg-canvas, #525659);
5369
+ `;
5370
+ const sizer = document.createElement("div");
5371
+ sizer.className = "fp-pptx-sizer";
5372
+ sizer.style.cssText = `
5373
+ position: relative;
5374
+ flex-shrink: 0;
5375
+ display: flex;
5376
+ justify-content: center;
5377
+ align-items: center;
5140
5378
  `;
5141
5379
  const slideContainer = document.createElement("div");
5142
5380
  slideContainer.className = "fp-slide-container";
@@ -5145,14 +5383,15 @@ var PptxPlugin = class {
5145
5383
  border-radius: 4px;
5146
5384
  overflow: hidden;
5147
5385
  background: #ffffff;
5148
- transform-origin: top center;
5386
+ transform-origin: center center;
5149
5387
  transition: transform 0.2s ease;
5150
- max-width: calc(100% - 32px);
5151
- max-height: calc(100% - 48px);
5388
+ flex-shrink: 0;
5152
5389
  `;
5153
5390
  const canvas = document.createElement("canvas");
5154
5391
  slideContainer.appendChild(canvas);
5155
- wrapper.appendChild(slideContainer);
5392
+ sizer.appendChild(slideContainer);
5393
+ scrollWrapper.appendChild(sizer);
5394
+ wrapper.appendChild(scrollWrapper);
5156
5395
  ctx.container.innerHTML = "";
5157
5396
  ctx.container.style.overflow = "auto";
5158
5397
  ctx.container.appendChild(wrapper);
@@ -5164,7 +5403,17 @@ var PptxPlugin = class {
5164
5403
  return Math.min(1, Math.min(availW / cW, availH / cH));
5165
5404
  };
5166
5405
  const applyTransform = () => {
5406
+ const cW = canvas.offsetWidth || 1280;
5407
+ const cH = canvas.offsetHeight || 720;
5408
+ const isRotated90 = rotation % 180 !== 0;
5409
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
5410
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
5411
+ sizer.style.width = `${boxW}px`;
5412
+ sizer.style.height = `${boxH}px`;
5413
+ slideContainer.style.width = `${cW}px`;
5414
+ slideContainer.style.height = `${cH}px`;
5167
5415
  slideContainer.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5416
+ slideContainer.style.transformOrigin = "center center";
5168
5417
  };
5169
5418
  const renderCurrentSlide = async () => {
5170
5419
  try {
@@ -5770,13 +6019,33 @@ var RtfPlugin = class {
5770
6019
  wrapper.style.flexDirection = "column";
5771
6020
  wrapper.style.alignItems = "center";
5772
6021
  wrapper.style.backgroundColor = "transparent";
5773
- wrapper.style.transformOrigin = "top center";
6022
+ wrapper.style.transformOrigin = "center center";
5774
6023
  wrapper.style.transition = "transform 0.15s ease";
5775
- ctx.container.style.overflowX = "hidden";
5776
- ctx.container.style.overflowY = "auto";
5777
- ctx.container.style.padding = "16px 8px";
6024
+ wrapper.style.flexShrink = "0";
6025
+ const sizer = document.createElement("div");
6026
+ sizer.className = "fp-rtf-sizer";
6027
+ sizer.style.position = "relative";
6028
+ sizer.style.flexShrink = "0";
6029
+ sizer.style.display = "flex";
6030
+ sizer.style.justifyContent = "center";
6031
+ sizer.style.alignItems = "center";
6032
+ const scrollWrapper = document.createElement("div");
6033
+ scrollWrapper.className = "fp-rtf-scroll-wrapper";
6034
+ scrollWrapper.style.minWidth = "100%";
6035
+ scrollWrapper.style.minHeight = "100%";
6036
+ scrollWrapper.style.width = "max-content";
6037
+ scrollWrapper.style.height = "max-content";
6038
+ scrollWrapper.style.display = "flex";
6039
+ scrollWrapper.style.justifyContent = "center";
6040
+ scrollWrapper.style.alignItems = "flex-start";
6041
+ scrollWrapper.style.padding = "16px 8px";
6042
+ scrollWrapper.style.boxSizing = "border-box";
6043
+ sizer.appendChild(wrapper);
6044
+ scrollWrapper.appendChild(sizer);
6045
+ ctx.container.style.overflow = "auto";
6046
+ ctx.container.style.padding = "0";
5778
6047
  ctx.container.style.backgroundColor = "#f1f5f9";
5779
- ctx.container.appendChild(wrapper);
6048
+ ctx.container.appendChild(scrollWrapper);
5780
6049
  let scale = 1;
5781
6050
  let rotation = 0;
5782
6051
  let pageElements = [];
@@ -5795,12 +6064,17 @@ var RtfPlugin = class {
5795
6064
  return Math.max(0.4, Math.min(3, sW));
5796
6065
  };
5797
6066
  const applyTransform = () => {
5798
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
5799
- wrapper.style.transformOrigin = "top center";
6067
+ const elW = pageWidth;
5800
6068
  const baseH = pageHeight;
5801
- const scaledH = baseH * scale;
5802
- const extraH = Math.max(0, scaledH - baseH);
5803
- wrapper.style.marginBottom = `${extraH + 32}px`;
6069
+ const isRotated90 = rotation % 180 !== 0;
6070
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6071
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6072
+ sizer.style.width = `${boxW}px`;
6073
+ sizer.style.height = `${boxH}px`;
6074
+ wrapper.style.width = `${elW}px`;
6075
+ wrapper.style.height = `${baseH}px`;
6076
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6077
+ wrapper.style.transformOrigin = "center center";
5804
6078
  };
5805
6079
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
5806
6080
  if (!isUserZoomed) {
@@ -6071,7 +6345,7 @@ var RtfPlugin = class {
6071
6345
  }
6072
6346
  const cleanup = () => {
6073
6347
  resizeObserver?.disconnect();
6074
- wrapper.remove();
6348
+ scrollWrapper.remove();
6075
6349
  ctx.container.innerHTML = "";
6076
6350
  };
6077
6351
  ctx.signal.addEventListener("abort", cleanup);
@@ -6246,23 +6520,44 @@ var HtmlPreviewPlugin = class {
6246
6520
  ADD_TAGS: ["style", "link"],
6247
6521
  ADD_ATTR: ["target", "rel"]
6248
6522
  });
6523
+ const sizer = document.createElement("div");
6524
+ sizer.className = "fp-html-sizer";
6525
+ sizer.style.position = "relative";
6249
6526
  const iframe = document.createElement("iframe");
6250
6527
  iframe.className = "fp-html-iframe";
6251
- iframe.style.width = "100%";
6252
- iframe.style.height = "100%";
6253
6528
  iframe.style.border = "none";
6254
6529
  iframe.style.backgroundColor = "#ffffff";
6255
6530
  iframe.style.transformOrigin = "top left";
6256
6531
  iframe.style.transition = "transform 0.2s ease";
6257
6532
  iframe.sandbox.add("allow-same-origin");
6533
+ sizer.appendChild(iframe);
6258
6534
  ctx.container.style.overflow = "auto";
6259
6535
  ctx.container.style.width = "100%";
6260
6536
  ctx.container.style.height = "100%";
6261
- ctx.container.appendChild(iframe);
6537
+ ctx.container.innerHTML = "";
6538
+ ctx.container.appendChild(sizer);
6262
6539
  iframe.srcdoc = sanitized;
6263
6540
  let scale = 1;
6541
+ const applyTransform = () => {
6542
+ const baseW = Math.max(600, ctx.container.clientWidth || 800);
6543
+ const baseH = Math.max(400, ctx.container.clientHeight || 600);
6544
+ const scaledW = Math.round(baseW * scale);
6545
+ const scaledH = Math.round(baseH * scale);
6546
+ sizer.style.width = `${scaledW}px`;
6547
+ sizer.style.height = `${scaledH}px`;
6548
+ iframe.style.position = "absolute";
6549
+ iframe.style.top = "0";
6550
+ iframe.style.left = "0";
6551
+ iframe.style.width = `${baseW}px`;
6552
+ iframe.style.height = `${baseH}px`;
6553
+ iframe.style.transform = `scale(${scale})`;
6554
+ iframe.style.transformOrigin = "top left";
6555
+ };
6556
+ requestAnimationFrame(() => {
6557
+ applyTransform();
6558
+ });
6264
6559
  const cleanup = () => {
6265
- iframe.remove();
6560
+ sizer.remove();
6266
6561
  ctx.container.innerHTML = "";
6267
6562
  };
6268
6563
  ctx.signal.addEventListener("abort", cleanup);
@@ -6270,26 +6565,26 @@ var HtmlPreviewPlugin = class {
6270
6565
  destroy: cleanup,
6271
6566
  zoomIn: () => {
6272
6567
  scale += 0.1;
6273
- iframe.style.transform = `scale(${scale})`;
6568
+ applyTransform();
6274
6569
  },
6275
6570
  zoomOut: () => {
6276
6571
  scale = Math.max(0.2, scale - 0.1);
6277
- iframe.style.transform = `scale(${scale})`;
6572
+ applyTransform();
6278
6573
  },
6279
6574
  getZoom: () => scale,
6280
6575
  setZoom: (level) => {
6281
6576
  scale = level;
6282
- iframe.style.transform = `scale(${scale})`;
6577
+ applyTransform();
6283
6578
  },
6284
6579
  fitToPage: () => {
6285
6580
  scale = 1;
6286
- iframe.style.transform = "scale(1)";
6581
+ applyTransform();
6287
6582
  },
6288
6583
  resetZoom: () => {
6289
6584
  scale = 1;
6290
- iframe.style.transform = "scale(1)";
6291
6585
  ctx.container.scrollTop = 0;
6292
6586
  ctx.container.scrollLeft = 0;
6587
+ applyTransform();
6293
6588
  },
6294
6589
  copy: () => {
6295
6590
  navigator.clipboard.writeText(rawHtml);
@@ -6464,10 +6759,26 @@ var OpenDocumentPlugin = class {
6464
6759
  container.className = "fp-odf-container";
6465
6760
  container.style.width = "100%";
6466
6761
  container.style.height = "100%";
6467
- container.style.overflowX = "hidden";
6468
- container.style.overflowY = "auto";
6469
- container.style.padding = "16px 8px";
6762
+ container.style.overflow = "auto";
6470
6763
  container.style.backgroundColor = "#f1f5f9";
6764
+ const scrollWrapper = document.createElement("div");
6765
+ scrollWrapper.className = "fp-odf-scroll-wrapper";
6766
+ scrollWrapper.style.minWidth = "100%";
6767
+ scrollWrapper.style.minHeight = "100%";
6768
+ scrollWrapper.style.width = "max-content";
6769
+ scrollWrapper.style.height = "max-content";
6770
+ scrollWrapper.style.display = "flex";
6771
+ scrollWrapper.style.justifyContent = "center";
6772
+ scrollWrapper.style.alignItems = "flex-start";
6773
+ scrollWrapper.style.padding = "16px 8px";
6774
+ scrollWrapper.style.boxSizing = "border-box";
6775
+ const sizer = document.createElement("div");
6776
+ sizer.className = "fp-odf-sizer";
6777
+ sizer.style.position = "relative";
6778
+ sizer.style.flexShrink = "0";
6779
+ sizer.style.display = "flex";
6780
+ sizer.style.justifyContent = "center";
6781
+ sizer.style.alignItems = "center";
6471
6782
  const wrapper = document.createElement("div");
6472
6783
  wrapper.className = "fp-odf-wrapper";
6473
6784
  wrapper.style.margin = "0 auto";
@@ -6476,9 +6787,12 @@ var OpenDocumentPlugin = class {
6476
6787
  wrapper.style.backgroundColor = "#ffffff";
6477
6788
  wrapper.style.boxShadow = "0 2px 10px rgba(0,0,0,0.08)";
6478
6789
  wrapper.style.borderRadius = "4px";
6479
- wrapper.style.transformOrigin = "top center";
6790
+ wrapper.style.transformOrigin = "center center";
6480
6791
  wrapper.style.transition = "transform 0.15s ease";
6481
- container.appendChild(wrapper);
6792
+ wrapper.style.flexShrink = "0";
6793
+ sizer.appendChild(wrapper);
6794
+ scrollWrapper.appendChild(sizer);
6795
+ container.appendChild(scrollWrapper);
6482
6796
  ctx.container.appendChild(container);
6483
6797
  let scale = 1;
6484
6798
  let rotation = 0;
@@ -6504,13 +6818,18 @@ var OpenDocumentPlugin = class {
6504
6818
  return Math.max(0.4, Math.min(3, sW));
6505
6819
  };
6506
6820
  const applyTransform = () => {
6507
- wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6508
- wrapper.style.transformOrigin = "top center";
6509
6821
  const activeSlide = slides[currentPage - 1];
6822
+ const elW = isPresentation ? 960 : 816;
6510
6823
  const baseH = activeSlide?.offsetHeight || wrapper.offsetHeight || 1056;
6511
- const scaledH = baseH * scale;
6512
- const extraH = Math.max(0, scaledH - baseH);
6513
- wrapper.style.marginBottom = `${extraH + 32}px`;
6824
+ const isRotated90 = rotation % 180 !== 0;
6825
+ const boxW = Math.round((isRotated90 ? baseH : elW) * scale);
6826
+ const boxH = Math.round((isRotated90 ? elW : baseH) * scale);
6827
+ sizer.style.width = `${boxW}px`;
6828
+ sizer.style.height = `${boxH}px`;
6829
+ wrapper.style.width = `${elW}px`;
6830
+ wrapper.style.height = `${baseH}px`;
6831
+ wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
6832
+ wrapper.style.transformOrigin = "center center";
6514
6833
  };
6515
6834
  const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
6516
6835
  if (!isUserZoomed) {
@@ -7074,13 +7393,28 @@ var DocPlugin = class {
7074
7393
  container.className = "fp-doc-container";
7075
7394
  container.style.width = "100%";
7076
7395
  container.style.height = "100%";
7077
- container.style.overflowX = "hidden";
7078
- container.style.overflowY = "auto";
7079
- container.style.padding = "16px 8px";
7396
+ container.style.overflow = "auto";
7080
7397
  container.style.backgroundColor = "#f1f5f9";
7081
- container.style.display = "flex";
7082
- container.style.justifyContent = "center";
7083
- container.style.alignItems = "flex-start";
7398
+ const scrollWrapper = document.createElement("div");
7399
+ scrollWrapper.className = "fp-doc-scroll-wrapper";
7400
+ scrollWrapper.style.minWidth = "100%";
7401
+ scrollWrapper.style.minHeight = "100%";
7402
+ scrollWrapper.style.width = "max-content";
7403
+ scrollWrapper.style.height = "max-content";
7404
+ scrollWrapper.style.display = "flex";
7405
+ scrollWrapper.style.justifyContent = "center";
7406
+ scrollWrapper.style.alignItems = "flex-start";
7407
+ scrollWrapper.style.padding = "16px 8px";
7408
+ scrollWrapper.style.boxSizing = "border-box";
7409
+ const sizer = document.createElement("div");
7410
+ sizer.className = "fp-doc-sizer";
7411
+ sizer.style.position = "relative";
7412
+ sizer.style.flexShrink = "0";
7413
+ sizer.style.display = "flex";
7414
+ sizer.style.justifyContent = "center";
7415
+ sizer.style.alignItems = "center";
7416
+ scrollWrapper.appendChild(sizer);
7417
+ container.appendChild(scrollWrapper);
7084
7418
  ctx.container.appendChild(container);
7085
7419
  let scale = 1;
7086
7420
  let extractedRawText = "";
@@ -7128,10 +7462,11 @@ var DocPlugin = class {
7128
7462
  pageCard.style.padding = "72px 56px";
7129
7463
  pageCard.style.boxSizing = "border-box";
7130
7464
  pageCard.style.display = i === 0 ? "block" : "none";
7131
- pageCard.style.transformOrigin = "top center";
7465
+ pageCard.style.transformOrigin = "center center";
7132
7466
  pageCard.style.transition = "transform 0.15s ease";
7133
7467
  pageCard.style.fontFamily = 'Calibri, "Segoe UI", Arial, sans-serif';
7134
7468
  pageCard.style.color = "#1e293b";
7469
+ pageCard.style.flexShrink = "0";
7135
7470
  if (isFallback && i === 0) {
7136
7471
  pageCard.innerHTML = `
7137
7472
  <div style="border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 24px;">
@@ -7143,18 +7478,23 @@ var DocPlugin = class {
7143
7478
  } else {
7144
7479
  pageCard.innerHTML = this.formatDocToHtml(rawPages[i], ctx.metadata.name || "Document");
7145
7480
  }
7146
- container.appendChild(pageCard);
7481
+ sizer.appendChild(pageCard);
7147
7482
  pageCards.push(pageCard);
7148
7483
  }
7149
7484
  let rotation = 0;
7150
7485
  const applyTransform = () => {
7151
7486
  const activeCard = pageCards[currentPage - 1];
7152
7487
  if (activeCard) {
7153
- activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7488
+ const baseW = 816;
7154
7489
  const baseH = activeCard.offsetHeight || 1056;
7155
- const scaledH = baseH * scale;
7156
- const extraH = Math.max(0, scaledH - baseH);
7157
- activeCard.style.marginBottom = `${extraH + 32}px`;
7490
+ const isRotated90 = rotation % 180 !== 0;
7491
+ const boxW = Math.round((isRotated90 ? baseH : baseW) * scale);
7492
+ const boxH = Math.round((isRotated90 ? baseW : baseH) * scale);
7493
+ sizer.style.width = `${boxW}px`;
7494
+ sizer.style.height = `${boxH}px`;
7495
+ activeCard.style.width = `${baseW}px`;
7496
+ activeCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7497
+ activeCard.style.transformOrigin = "center center";
7158
7498
  }
7159
7499
  };
7160
7500
  const showPage = (pageNum) => {
@@ -7162,11 +7502,11 @@ var DocPlugin = class {
7162
7502
  pageCards.forEach((card, idx) => {
7163
7503
  if (idx + 1 === currentPage) {
7164
7504
  card.style.display = "block";
7165
- card.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
7166
7505
  } else {
7167
7506
  card.style.display = "none";
7168
7507
  }
7169
7508
  });
7509
+ applyTransform();
7170
7510
  container.scrollTop = 0;
7171
7511
  ctx.emit("page-change", { page: currentPage, total: totalPages });
7172
7512
  };
@@ -7237,6 +7577,8 @@ var DocPlugin = class {
7237
7577
  fitMode = "width";
7238
7578
  scale = calculateFitScale("width");
7239
7579
  rotation = 0;
7580
+ container.scrollTop = 0;
7581
+ container.scrollLeft = 0;
7240
7582
  ctx.container.scrollTop = 0;
7241
7583
  ctx.container.scrollLeft = 0;
7242
7584
  applyTransform();
@@ -7761,17 +8103,30 @@ var PptPlugin = class {
7761
8103
  container.style.width = "100%";
7762
8104
  container.style.height = "100%";
7763
8105
  container.style.overflow = "auto";
7764
- container.style.display = "flex";
7765
- container.style.justifyContent = "center";
7766
- container.style.alignItems = "center";
7767
- container.style.padding = "32px 16px";
7768
8106
  container.style.backgroundColor = "#0f172a";
7769
8107
  container.style.boxSizing = "border-box";
8108
+ const scrollWrapper = document.createElement("div");
8109
+ scrollWrapper.className = "fp-ppt-scroll-wrapper";
8110
+ scrollWrapper.style.minWidth = "100%";
8111
+ scrollWrapper.style.minHeight = "100%";
8112
+ scrollWrapper.style.width = "max-content";
8113
+ scrollWrapper.style.height = "max-content";
8114
+ scrollWrapper.style.display = "flex";
8115
+ scrollWrapper.style.justifyContent = "center";
8116
+ scrollWrapper.style.alignItems = "center";
8117
+ scrollWrapper.style.padding = "32px 16px";
8118
+ scrollWrapper.style.boxSizing = "border-box";
8119
+ const sizer = document.createElement("div");
8120
+ sizer.className = "fp-ppt-sizer";
8121
+ sizer.style.position = "relative";
8122
+ sizer.style.flexShrink = "0";
8123
+ sizer.style.display = "flex";
8124
+ sizer.style.justifyContent = "center";
8125
+ sizer.style.alignItems = "center";
7770
8126
  const slideCard = document.createElement("div");
7771
8127
  slideCard.className = "fp-ppt-slide-card";
7772
8128
  slideCard.style.width = "960px";
7773
- slideCard.style.maxWidth = "calc(100% - 32px)";
7774
- slideCard.style.maxHeight = "calc(100% - 48px)";
8129
+ slideCard.style.height = "540px";
7775
8130
  slideCard.style.aspectRatio = "16 / 9";
7776
8131
  slideCard.style.backgroundColor = "#ffffff";
7777
8132
  slideCard.style.boxShadow = "0 12px 40px rgba(0,0,0,0.35)";
@@ -7781,7 +8136,9 @@ var PptPlugin = class {
7781
8136
  slideCard.style.transition = "transform 0.2s ease";
7782
8137
  slideCard.style.transformOrigin = "center center";
7783
8138
  slideCard.style.flexShrink = "0";
7784
- container.appendChild(slideCard);
8139
+ sizer.appendChild(slideCard);
8140
+ scrollWrapper.appendChild(sizer);
8141
+ container.appendChild(scrollWrapper);
7785
8142
  ctx.container.appendChild(container);
7786
8143
  let scale = 1;
7787
8144
  let rotation = 0;
@@ -7794,7 +8151,17 @@ var PptPlugin = class {
7794
8151
  return Math.min(1, Math.min(availW / 960, availH / 540));
7795
8152
  };
7796
8153
  const applyTransform = () => {
8154
+ const cW = 960;
8155
+ const cH = 540;
8156
+ const isRotated90 = rotation % 180 !== 0;
8157
+ const boxW = Math.round((isRotated90 ? cH : cW) * scale);
8158
+ const boxH = Math.round((isRotated90 ? cW : cH) * scale);
8159
+ sizer.style.width = `${boxW}px`;
8160
+ sizer.style.height = `${boxH}px`;
8161
+ slideCard.style.width = `${cW}px`;
8162
+ slideCard.style.height = `${cH}px`;
7797
8163
  slideCard.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
8164
+ slideCard.style.transformOrigin = "center center";
7798
8165
  };
7799
8166
  setTimeout(() => {
7800
8167
  scale = calculateFitScale();