@files-preview-app/preview-file 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue.js CHANGED
@@ -433,7 +433,8 @@ function createElement(tag, attrs, ...children) {
433
433
  }
434
434
  var ICON_ZOOM_IN = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="11" y1="8" x2="11" y2="14"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>`;
435
435
  var ICON_ZOOM_OUT = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>`;
436
- var ICON_FIT_PAGE = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" y1="3" x2="14" y2="10"></line><line x1="3" y1="21" x2="10" y2="14"></line></svg>`;
436
+ var ICON_FIT_PAGE = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"></rect><line x1="8" y1="12" x2="16" y2="12"></line><polyline points="11 9 8 12 11 15"></polyline><polyline points="13 9 16 12 13 15"></polyline></svg>`;
437
+ var ICON_FIT_WIDTH = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="2" y1="12" x2="22" y2="12"></line><polyline points="5 9 2 12 5 15"></polyline><polyline points="19 9 22 12 19 15"></polyline><line x1="2" y1="5" x2="2" y2="19"></line><line x1="22" y1="5" x2="22" y2="19"></line></svg>`;
437
438
  var ICON_ROTATE_CW = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"></polyline><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path></svg>`;
438
439
  var ICON_ROTATE_CCW = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>`;
439
440
  var ICON_DOWNLOAD = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`;
@@ -453,6 +454,7 @@ var ICON_MAP = {
453
454
  "zoom-in": ICON_ZOOM_IN,
454
455
  "zoom-out": ICON_ZOOM_OUT,
455
456
  "fit-page": ICON_FIT_PAGE,
457
+ "fit-width": ICON_FIT_WIDTH,
456
458
  "fit-slide": ICON_FIT_PAGE,
457
459
  "rotate-cw": ICON_ROTATE_CW,
458
460
  "rotate-ccw": ICON_ROTATE_CCW,
@@ -1399,6 +1401,7 @@ var PdfPlugin = class {
1399
1401
  let currentPage = 1;
1400
1402
  let zoomScale = 1;
1401
1403
  let rotation = 0;
1404
+ let fitMode = "width";
1402
1405
  let currentRenderTask = null;
1403
1406
  const renderPage = async (pageNum) => {
1404
1407
  if (currentRenderTask) {
@@ -1418,11 +1421,16 @@ var PdfPlugin = class {
1418
1421
  const containerWidth = container.clientWidth || 900;
1419
1422
  const containerHeight = container.clientHeight || 700;
1420
1423
  const unscaledVp = page.getViewport({ scale: 1, rotation });
1421
- const availWidth = Math.max(100, containerWidth - 48);
1422
- const availHeight = Math.max(100, containerHeight - 88);
1424
+ const availWidth = Math.max(280, containerWidth - 48);
1425
+ const availHeight = Math.max(280, containerHeight - 88);
1423
1426
  const scaleW = availWidth / unscaledVp.width;
1424
1427
  const scaleH = availHeight / unscaledVp.height;
1425
- const fitScale = Math.min(scaleW, scaleH);
1428
+ let fitScale;
1429
+ if (fitMode === "page") {
1430
+ fitScale = Math.max(0.5, Math.min(scaleW, scaleH));
1431
+ } else {
1432
+ fitScale = Math.max(0.65, Math.min(1.15, scaleW));
1433
+ }
1426
1434
  const effectiveScale = (fitScale > 0 ? fitScale : 1) * zoomScale;
1427
1435
  const pixelRatio = window.devicePixelRatio || 1;
1428
1436
  const viewport = page.getViewport({ scale: effectiveScale, rotation });
@@ -1491,6 +1499,7 @@ var PdfPlugin = class {
1491
1499
  renderPage(currentPage);
1492
1500
  },
1493
1501
  fitToPage: () => {
1502
+ fitMode = fitMode === "width" ? "page" : "width";
1494
1503
  zoomScale = 1;
1495
1504
  rotation = 0;
1496
1505
  renderPage(currentPage);
@@ -2044,8 +2053,53 @@ var DocxPlugin = class {
2044
2053
  }
2045
2054
  }
2046
2055
  }
2047
- const sections = wrapper.querySelectorAll("section.docx");
2048
- const cards = wrapper.querySelectorAll(".fp-docx-page-card");
2056
+ let sections = Array.from(wrapper.querySelectorAll("section.docx"));
2057
+ const cards = Array.from(wrapper.querySelectorAll(".fp-docx-page-card"));
2058
+ if (sections.length === 1 && cards.length === 0) {
2059
+ const singleSec = sections[0];
2060
+ const pageH = 1056;
2061
+ const secH = singleSec.offsetHeight || singleSec.scrollHeight;
2062
+ if (secH > pageH * 1.25) {
2063
+ const children = Array.from(singleSec.children);
2064
+ if (children.length > 1) {
2065
+ const parent = singleSec.parentElement || wrapper;
2066
+ const newSections = [singleSec];
2067
+ singleSec.innerHTML = "";
2068
+ singleSec.style.minHeight = `${pageH}px`;
2069
+ singleSec.style.maxHeight = `${pageH}px`;
2070
+ singleSec.style.overflow = "hidden";
2071
+ singleSec.style.boxSizing = "border-box";
2072
+ let curSec = singleSec;
2073
+ let curH = 0;
2074
+ const maxH = pageH - 96;
2075
+ for (let i = 0; i < children.length; i++) {
2076
+ const child = children[i];
2077
+ curSec.appendChild(child);
2078
+ const chH = child.offsetHeight || 28;
2079
+ curH += chH;
2080
+ if (curH >= maxH && i < children.length - 1) {
2081
+ const nextSec = document.createElement("section");
2082
+ nextSec.className = singleSec.className;
2083
+ nextSec.style.cssText = singleSec.style.cssText;
2084
+ nextSec.style.width = singleSec.style.width || "816px";
2085
+ nextSec.style.minHeight = `${pageH}px`;
2086
+ nextSec.style.maxHeight = `${pageH}px`;
2087
+ nextSec.style.overflow = "hidden";
2088
+ nextSec.style.boxSizing = "border-box";
2089
+ nextSec.style.backgroundColor = "#ffffff";
2090
+ nextSec.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
2091
+ nextSec.style.borderRadius = "4px";
2092
+ nextSec.style.marginBottom = "24px";
2093
+ parent.appendChild(nextSec);
2094
+ newSections.push(nextSec);
2095
+ curSec = nextSec;
2096
+ curH = 0;
2097
+ }
2098
+ }
2099
+ sections = newSections;
2100
+ }
2101
+ }
2102
+ }
2049
2103
  const pageElements = sections.length > 0 ? sections : cards;
2050
2104
  const totalPages = Math.max(1, pageElements.length);
2051
2105
  let currentPage = 1;
@@ -2089,22 +2143,27 @@ var DocxPlugin = class {
2089
2143
  }
2090
2144
  scale = 1;
2091
2145
  let rotation = 0;
2092
- const calculateFitScale = () => {
2146
+ let fitMode = "width";
2147
+ const calculateFitScale = (mode = fitMode) => {
2093
2148
  const activeEl = pageElements[currentPage - 1] || wrapper.firstElementChild || wrapper;
2094
2149
  const elW = activeEl.offsetWidth || 816;
2095
- const elH = activeEl.offsetHeight || 1056;
2096
- const availW = Math.max(200, ctx.container.clientWidth - 48);
2097
- const availH = Math.max(200, ctx.container.clientHeight - 80);
2150
+ const singlePageH = Math.min(activeEl.offsetHeight || 1056, Math.round(elW * 1.32));
2151
+ const availW = Math.max(280, ctx.container.clientWidth - 48);
2152
+ const availH = Math.max(280, ctx.container.clientHeight - 80);
2098
2153
  const sW = availW / elW;
2099
- const sH = availH / elH;
2100
- return Math.min(1.1, Math.min(sW, sH));
2154
+ const sH = availH / singlePageH;
2155
+ if (mode === "page") {
2156
+ return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
2157
+ }
2158
+ return Math.max(0.65, Math.min(1.05, sW));
2101
2159
  };
2102
2160
  const applyTransform = () => {
2103
2161
  wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
2104
2162
  wrapper.style.transformOrigin = "top center";
2105
2163
  };
2106
2164
  setTimeout(() => {
2107
- scale = calculateFitScale();
2165
+ fitMode = "width";
2166
+ scale = calculateFitScale("width");
2108
2167
  applyTransform();
2109
2168
  }, 60);
2110
2169
  const cleanup = () => {
@@ -2138,7 +2197,8 @@ var DocxPlugin = class {
2138
2197
  applyTransform();
2139
2198
  },
2140
2199
  fitToPage: () => {
2141
- scale = calculateFitScale();
2200
+ fitMode = fitMode === "width" ? "page" : "width";
2201
+ scale = calculateFitScale(fitMode);
2142
2202
  rotation = 0;
2143
2203
  applyTransform();
2144
2204
  },
@@ -2582,11 +2642,9 @@ var ExcelPlugin = class {
2582
2642
  const calculateFitScale = () => {
2583
2643
  const table = contentArea.querySelector("table");
2584
2644
  if (!table) return 1;
2585
- const availW = Math.max(200, container.clientWidth - 48);
2586
- const availH = Math.max(200, container.clientHeight - 80);
2645
+ const availW = Math.max(280, container.clientWidth - 48);
2587
2646
  const tW = table.offsetWidth || 800;
2588
- const tH = table.offsetHeight || 600;
2589
- return Math.min(1, Math.min(availW / tW, availH / tH));
2647
+ return Math.max(0.65, Math.min(1, availW / tW));
2590
2648
  };
2591
2649
  try {
2592
2650
  wb = XLSX.read(new Uint8Array(ctx.buffer), { type: "array", cellDates: true });
@@ -3183,7 +3241,7 @@ var CodePlugin = class {
3183
3241
  fitToPage: () => {
3184
3242
  fontSize = 13;
3185
3243
  rotation = 0;
3186
- zoomLevel = 1;
3244
+ zoomLevel = isTxt ? Math.max(0.65, Math.min(1.05, (container.clientWidth - 48) / 816)) : 1;
3187
3245
  updateTransform();
3188
3246
  },
3189
3247
  rotateCW: () => {
@@ -4165,20 +4223,27 @@ var RtfPlugin = class {
4165
4223
  let scale = 1;
4166
4224
  let rotation = 0;
4167
4225
  let pageElements = [];
4168
- const calculateFitScale = () => {
4226
+ let fitMode = "width";
4227
+ const calculateFitScale = (mode = fitMode) => {
4169
4228
  const activeEl = pageElements[currentPage - 1] || wrapper;
4170
4229
  const elW = activeEl.offsetWidth || 850;
4171
- const elH = activeEl.offsetHeight || 1e3;
4172
- const availW = Math.max(200, ctx.container.clientWidth - 48);
4173
- const availH = Math.max(200, ctx.container.clientHeight - 80);
4174
- return Math.min(1.1, Math.min(availW / elW, availH / elH));
4230
+ const singlePageH = Math.min(activeEl.offsetHeight || 1056, Math.round(elW * 1.32));
4231
+ const availW = Math.max(280, ctx.container.clientWidth - 48);
4232
+ const availH = Math.max(280, ctx.container.clientHeight - 80);
4233
+ const sW = availW / elW;
4234
+ const sH = availH / singlePageH;
4235
+ if (mode === "page") {
4236
+ return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
4237
+ }
4238
+ return Math.max(0.65, Math.min(1.05, sW));
4175
4239
  };
4176
4240
  const applyTransform = () => {
4177
4241
  wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
4178
4242
  wrapper.style.transformOrigin = "top center";
4179
4243
  };
4180
4244
  setTimeout(() => {
4181
- scale = calculateFitScale();
4245
+ fitMode = "width";
4246
+ scale = calculateFitScale("width");
4182
4247
  applyTransform();
4183
4248
  }, 60);
4184
4249
  try {
@@ -4287,7 +4352,8 @@ var RtfPlugin = class {
4287
4352
  applyTransform();
4288
4353
  },
4289
4354
  fitToPage: () => {
4290
- scale = calculateFitScale();
4355
+ fitMode = fitMode === "width" ? "page" : "width";
4356
+ scale = calculateFitScale(fitMode);
4291
4357
  rotation = 0;
4292
4358
  applyTransform();
4293
4359
  },
@@ -4606,19 +4672,29 @@ var OpenDocumentPlugin = class {
4606
4672
  ctx.container.appendChild(container);
4607
4673
  let scale = 1;
4608
4674
  let rotation = 0;
4609
- const calculateFitScale = () => {
4675
+ let fitMode = "width";
4676
+ const calculateFitScale = (mode = fitMode) => {
4610
4677
  const elW = wrapper.offsetWidth || 850;
4611
- const elH = wrapper.offsetHeight || (isPresentation ? 540 : 1e3);
4612
- const availW = Math.max(200, ctx.container.clientWidth - 48);
4613
- const availH = Math.max(200, ctx.container.clientHeight - 80);
4614
- return Math.min(1, Math.min(availW / elW, availH / elH));
4678
+ const singlePageH = Math.min(wrapper.offsetHeight || 1056, Math.round(elW * 1.32));
4679
+ const availW = Math.max(280, ctx.container.clientWidth - 48);
4680
+ const availH = Math.max(280, ctx.container.clientHeight - 80);
4681
+ const sW = availW / elW;
4682
+ const sH = availH / (isPresentation ? 540 : singlePageH);
4683
+ if (isPresentation) {
4684
+ return Math.min(1, Math.min(sW, sH));
4685
+ }
4686
+ if (mode === "page") {
4687
+ return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
4688
+ }
4689
+ return Math.max(0.65, Math.min(1.05, sW));
4615
4690
  };
4616
4691
  const applyTransform = () => {
4617
4692
  wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
4618
4693
  wrapper.style.transformOrigin = "top center";
4619
4694
  };
4620
4695
  setTimeout(() => {
4621
- scale = calculateFitScale();
4696
+ fitMode = "width";
4697
+ scale = calculateFitScale("width");
4622
4698
  applyTransform();
4623
4699
  }, 60);
4624
4700
  let currentPage = 1;
@@ -4779,7 +4855,8 @@ var OpenDocumentPlugin = class {
4779
4855
  applyTransform();
4780
4856
  },
4781
4857
  fitToPage: () => {
4782
- scale = calculateFitScale();
4858
+ fitMode = fitMode === "width" ? "page" : "width";
4859
+ scale = calculateFitScale(fitMode);
4783
4860
  rotation = 0;
4784
4861
  applyTransform();
4785
4862
  },
@@ -5256,15 +5333,22 @@ var DocPlugin = class {
5256
5333
  if (totalPages > 1) {
5257
5334
  showPage(1);
5258
5335
  }
5259
- const calculateFitScale = () => {
5336
+ let fitMode = "width";
5337
+ const calculateFitScale = (mode = fitMode) => {
5260
5338
  const elW = 816;
5261
5339
  const elH = 1056;
5262
- const availW = Math.max(200, ctx.container.clientWidth - 48);
5263
- const availH = Math.max(200, ctx.container.clientHeight - 80);
5264
- return Math.min(1.1, Math.min(availW / elW, availH / elH));
5340
+ const availW = Math.max(280, ctx.container.clientWidth - 48);
5341
+ const availH = Math.max(280, ctx.container.clientHeight - 80);
5342
+ const sW = availW / elW;
5343
+ const sH = availH / elH;
5344
+ if (mode === "page") {
5345
+ return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
5346
+ }
5347
+ return Math.max(0.65, Math.min(1.05, sW));
5265
5348
  };
5266
5349
  setTimeout(() => {
5267
- scale = calculateFitScale();
5350
+ fitMode = "width";
5351
+ scale = calculateFitScale("width");
5268
5352
  applyTransform();
5269
5353
  }, 60);
5270
5354
  const cleanup = () => {
@@ -5292,7 +5376,8 @@ var DocPlugin = class {
5292
5376
  applyTransform();
5293
5377
  },
5294
5378
  fitToPage: () => {
5295
- scale = calculateFitScale();
5379
+ fitMode = fitMode === "width" ? "page" : "width";
5380
+ scale = calculateFitScale(fitMode);
5296
5381
  rotation = 0;
5297
5382
  applyTransform();
5298
5383
  },