@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/angular.cjs +124 -39
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.js +124 -39
- package/dist/angular.js.map +1 -1
- package/dist/index.cjs +124 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +124 -39
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +124 -39
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +124 -39
- package/dist/react.js.map +1 -1
- package/dist/vue.cjs +124 -39
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.js +124 -39
- package/dist/vue.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -506,7 +506,8 @@ function createElement(tag, attrs, ...children) {
|
|
|
506
506
|
}
|
|
507
507
|
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>`;
|
|
508
508
|
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>`;
|
|
509
|
-
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"><
|
|
509
|
+
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>`;
|
|
510
|
+
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>`;
|
|
510
511
|
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>`;
|
|
511
512
|
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>`;
|
|
512
513
|
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>`;
|
|
@@ -526,6 +527,7 @@ var ICON_MAP = {
|
|
|
526
527
|
"zoom-in": ICON_ZOOM_IN,
|
|
527
528
|
"zoom-out": ICON_ZOOM_OUT,
|
|
528
529
|
"fit-page": ICON_FIT_PAGE,
|
|
530
|
+
"fit-width": ICON_FIT_WIDTH,
|
|
529
531
|
"fit-slide": ICON_FIT_PAGE,
|
|
530
532
|
"rotate-cw": ICON_ROTATE_CW,
|
|
531
533
|
"rotate-ccw": ICON_ROTATE_CCW,
|
|
@@ -1472,6 +1474,7 @@ var PdfPlugin = class {
|
|
|
1472
1474
|
let currentPage = 1;
|
|
1473
1475
|
let zoomScale = 1;
|
|
1474
1476
|
let rotation = 0;
|
|
1477
|
+
let fitMode = "width";
|
|
1475
1478
|
let currentRenderTask = null;
|
|
1476
1479
|
const renderPage = async (pageNum) => {
|
|
1477
1480
|
if (currentRenderTask) {
|
|
@@ -1491,11 +1494,16 @@ var PdfPlugin = class {
|
|
|
1491
1494
|
const containerWidth = container.clientWidth || 900;
|
|
1492
1495
|
const containerHeight = container.clientHeight || 700;
|
|
1493
1496
|
const unscaledVp = page.getViewport({ scale: 1, rotation });
|
|
1494
|
-
const availWidth = Math.max(
|
|
1495
|
-
const availHeight = Math.max(
|
|
1497
|
+
const availWidth = Math.max(280, containerWidth - 48);
|
|
1498
|
+
const availHeight = Math.max(280, containerHeight - 88);
|
|
1496
1499
|
const scaleW = availWidth / unscaledVp.width;
|
|
1497
1500
|
const scaleH = availHeight / unscaledVp.height;
|
|
1498
|
-
|
|
1501
|
+
let fitScale;
|
|
1502
|
+
if (fitMode === "page") {
|
|
1503
|
+
fitScale = Math.max(0.5, Math.min(scaleW, scaleH));
|
|
1504
|
+
} else {
|
|
1505
|
+
fitScale = Math.max(0.65, Math.min(1.15, scaleW));
|
|
1506
|
+
}
|
|
1499
1507
|
const effectiveScale = (fitScale > 0 ? fitScale : 1) * zoomScale;
|
|
1500
1508
|
const pixelRatio = window.devicePixelRatio || 1;
|
|
1501
1509
|
const viewport = page.getViewport({ scale: effectiveScale, rotation });
|
|
@@ -1564,6 +1572,7 @@ var PdfPlugin = class {
|
|
|
1564
1572
|
renderPage(currentPage);
|
|
1565
1573
|
},
|
|
1566
1574
|
fitToPage: () => {
|
|
1575
|
+
fitMode = fitMode === "width" ? "page" : "width";
|
|
1567
1576
|
zoomScale = 1;
|
|
1568
1577
|
rotation = 0;
|
|
1569
1578
|
renderPage(currentPage);
|
|
@@ -2117,8 +2126,53 @@ var DocxPlugin = class {
|
|
|
2117
2126
|
}
|
|
2118
2127
|
}
|
|
2119
2128
|
}
|
|
2120
|
-
|
|
2121
|
-
const cards = wrapper.querySelectorAll(".fp-docx-page-card");
|
|
2129
|
+
let sections = Array.from(wrapper.querySelectorAll("section.docx"));
|
|
2130
|
+
const cards = Array.from(wrapper.querySelectorAll(".fp-docx-page-card"));
|
|
2131
|
+
if (sections.length === 1 && cards.length === 0) {
|
|
2132
|
+
const singleSec = sections[0];
|
|
2133
|
+
const pageH = 1056;
|
|
2134
|
+
const secH = singleSec.offsetHeight || singleSec.scrollHeight;
|
|
2135
|
+
if (secH > pageH * 1.25) {
|
|
2136
|
+
const children = Array.from(singleSec.children);
|
|
2137
|
+
if (children.length > 1) {
|
|
2138
|
+
const parent = singleSec.parentElement || wrapper;
|
|
2139
|
+
const newSections = [singleSec];
|
|
2140
|
+
singleSec.innerHTML = "";
|
|
2141
|
+
singleSec.style.minHeight = `${pageH}px`;
|
|
2142
|
+
singleSec.style.maxHeight = `${pageH}px`;
|
|
2143
|
+
singleSec.style.overflow = "hidden";
|
|
2144
|
+
singleSec.style.boxSizing = "border-box";
|
|
2145
|
+
let curSec = singleSec;
|
|
2146
|
+
let curH = 0;
|
|
2147
|
+
const maxH = pageH - 96;
|
|
2148
|
+
for (let i = 0; i < children.length; i++) {
|
|
2149
|
+
const child = children[i];
|
|
2150
|
+
curSec.appendChild(child);
|
|
2151
|
+
const chH = child.offsetHeight || 28;
|
|
2152
|
+
curH += chH;
|
|
2153
|
+
if (curH >= maxH && i < children.length - 1) {
|
|
2154
|
+
const nextSec = document.createElement("section");
|
|
2155
|
+
nextSec.className = singleSec.className;
|
|
2156
|
+
nextSec.style.cssText = singleSec.style.cssText;
|
|
2157
|
+
nextSec.style.width = singleSec.style.width || "816px";
|
|
2158
|
+
nextSec.style.minHeight = `${pageH}px`;
|
|
2159
|
+
nextSec.style.maxHeight = `${pageH}px`;
|
|
2160
|
+
nextSec.style.overflow = "hidden";
|
|
2161
|
+
nextSec.style.boxSizing = "border-box";
|
|
2162
|
+
nextSec.style.backgroundColor = "#ffffff";
|
|
2163
|
+
nextSec.style.boxShadow = "0 4px 24px rgba(0, 0, 0, 0.08)";
|
|
2164
|
+
nextSec.style.borderRadius = "4px";
|
|
2165
|
+
nextSec.style.marginBottom = "24px";
|
|
2166
|
+
parent.appendChild(nextSec);
|
|
2167
|
+
newSections.push(nextSec);
|
|
2168
|
+
curSec = nextSec;
|
|
2169
|
+
curH = 0;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
sections = newSections;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2122
2176
|
const pageElements = sections.length > 0 ? sections : cards;
|
|
2123
2177
|
const totalPages = Math.max(1, pageElements.length);
|
|
2124
2178
|
let currentPage = 1;
|
|
@@ -2162,22 +2216,27 @@ var DocxPlugin = class {
|
|
|
2162
2216
|
}
|
|
2163
2217
|
scale = 1;
|
|
2164
2218
|
let rotation = 0;
|
|
2165
|
-
|
|
2219
|
+
let fitMode = "width";
|
|
2220
|
+
const calculateFitScale = (mode = fitMode) => {
|
|
2166
2221
|
const activeEl = pageElements[currentPage - 1] || wrapper.firstElementChild || wrapper;
|
|
2167
2222
|
const elW = activeEl.offsetWidth || 816;
|
|
2168
|
-
const
|
|
2169
|
-
const availW = Math.max(
|
|
2170
|
-
const availH = Math.max(
|
|
2223
|
+
const singlePageH = Math.min(activeEl.offsetHeight || 1056, Math.round(elW * 1.32));
|
|
2224
|
+
const availW = Math.max(280, ctx.container.clientWidth - 48);
|
|
2225
|
+
const availH = Math.max(280, ctx.container.clientHeight - 80);
|
|
2171
2226
|
const sW = availW / elW;
|
|
2172
|
-
const sH = availH /
|
|
2173
|
-
|
|
2227
|
+
const sH = availH / singlePageH;
|
|
2228
|
+
if (mode === "page") {
|
|
2229
|
+
return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
|
|
2230
|
+
}
|
|
2231
|
+
return Math.max(0.65, Math.min(1.05, sW));
|
|
2174
2232
|
};
|
|
2175
2233
|
const applyTransform = () => {
|
|
2176
2234
|
wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
|
|
2177
2235
|
wrapper.style.transformOrigin = "top center";
|
|
2178
2236
|
};
|
|
2179
2237
|
setTimeout(() => {
|
|
2180
|
-
|
|
2238
|
+
fitMode = "width";
|
|
2239
|
+
scale = calculateFitScale("width");
|
|
2181
2240
|
applyTransform();
|
|
2182
2241
|
}, 60);
|
|
2183
2242
|
const cleanup = () => {
|
|
@@ -2211,7 +2270,8 @@ var DocxPlugin = class {
|
|
|
2211
2270
|
applyTransform();
|
|
2212
2271
|
},
|
|
2213
2272
|
fitToPage: () => {
|
|
2214
|
-
|
|
2273
|
+
fitMode = fitMode === "width" ? "page" : "width";
|
|
2274
|
+
scale = calculateFitScale(fitMode);
|
|
2215
2275
|
rotation = 0;
|
|
2216
2276
|
applyTransform();
|
|
2217
2277
|
},
|
|
@@ -2655,11 +2715,9 @@ var ExcelPlugin = class {
|
|
|
2655
2715
|
const calculateFitScale = () => {
|
|
2656
2716
|
const table = contentArea.querySelector("table");
|
|
2657
2717
|
if (!table) return 1;
|
|
2658
|
-
const availW = Math.max(
|
|
2659
|
-
const availH = Math.max(200, container.clientHeight - 80);
|
|
2718
|
+
const availW = Math.max(280, container.clientWidth - 48);
|
|
2660
2719
|
const tW = table.offsetWidth || 800;
|
|
2661
|
-
|
|
2662
|
-
return Math.min(1, Math.min(availW / tW, availH / tH));
|
|
2720
|
+
return Math.max(0.65, Math.min(1, availW / tW));
|
|
2663
2721
|
};
|
|
2664
2722
|
try {
|
|
2665
2723
|
wb = XLSX__namespace.read(new Uint8Array(ctx.buffer), { type: "array", cellDates: true });
|
|
@@ -3256,7 +3314,7 @@ var CodePlugin = class {
|
|
|
3256
3314
|
fitToPage: () => {
|
|
3257
3315
|
fontSize = 13;
|
|
3258
3316
|
rotation = 0;
|
|
3259
|
-
zoomLevel = 1;
|
|
3317
|
+
zoomLevel = isTxt ? Math.max(0.65, Math.min(1.05, (container.clientWidth - 48) / 816)) : 1;
|
|
3260
3318
|
updateTransform();
|
|
3261
3319
|
},
|
|
3262
3320
|
rotateCW: () => {
|
|
@@ -4238,20 +4296,27 @@ var RtfPlugin = class {
|
|
|
4238
4296
|
let scale = 1;
|
|
4239
4297
|
let rotation = 0;
|
|
4240
4298
|
let pageElements = [];
|
|
4241
|
-
|
|
4299
|
+
let fitMode = "width";
|
|
4300
|
+
const calculateFitScale = (mode = fitMode) => {
|
|
4242
4301
|
const activeEl = pageElements[currentPage - 1] || wrapper;
|
|
4243
4302
|
const elW = activeEl.offsetWidth || 850;
|
|
4244
|
-
const
|
|
4245
|
-
const availW = Math.max(
|
|
4246
|
-
const availH = Math.max(
|
|
4247
|
-
|
|
4303
|
+
const singlePageH = Math.min(activeEl.offsetHeight || 1056, Math.round(elW * 1.32));
|
|
4304
|
+
const availW = Math.max(280, ctx.container.clientWidth - 48);
|
|
4305
|
+
const availH = Math.max(280, ctx.container.clientHeight - 80);
|
|
4306
|
+
const sW = availW / elW;
|
|
4307
|
+
const sH = availH / singlePageH;
|
|
4308
|
+
if (mode === "page") {
|
|
4309
|
+
return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
|
|
4310
|
+
}
|
|
4311
|
+
return Math.max(0.65, Math.min(1.05, sW));
|
|
4248
4312
|
};
|
|
4249
4313
|
const applyTransform = () => {
|
|
4250
4314
|
wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
|
|
4251
4315
|
wrapper.style.transformOrigin = "top center";
|
|
4252
4316
|
};
|
|
4253
4317
|
setTimeout(() => {
|
|
4254
|
-
|
|
4318
|
+
fitMode = "width";
|
|
4319
|
+
scale = calculateFitScale("width");
|
|
4255
4320
|
applyTransform();
|
|
4256
4321
|
}, 60);
|
|
4257
4322
|
try {
|
|
@@ -4360,7 +4425,8 @@ var RtfPlugin = class {
|
|
|
4360
4425
|
applyTransform();
|
|
4361
4426
|
},
|
|
4362
4427
|
fitToPage: () => {
|
|
4363
|
-
|
|
4428
|
+
fitMode = fitMode === "width" ? "page" : "width";
|
|
4429
|
+
scale = calculateFitScale(fitMode);
|
|
4364
4430
|
rotation = 0;
|
|
4365
4431
|
applyTransform();
|
|
4366
4432
|
},
|
|
@@ -4679,19 +4745,29 @@ var OpenDocumentPlugin = class {
|
|
|
4679
4745
|
ctx.container.appendChild(container);
|
|
4680
4746
|
let scale = 1;
|
|
4681
4747
|
let rotation = 0;
|
|
4682
|
-
|
|
4748
|
+
let fitMode = "width";
|
|
4749
|
+
const calculateFitScale = (mode = fitMode) => {
|
|
4683
4750
|
const elW = wrapper.offsetWidth || 850;
|
|
4684
|
-
const
|
|
4685
|
-
const availW = Math.max(
|
|
4686
|
-
const availH = Math.max(
|
|
4687
|
-
|
|
4751
|
+
const singlePageH = Math.min(wrapper.offsetHeight || 1056, Math.round(elW * 1.32));
|
|
4752
|
+
const availW = Math.max(280, ctx.container.clientWidth - 48);
|
|
4753
|
+
const availH = Math.max(280, ctx.container.clientHeight - 80);
|
|
4754
|
+
const sW = availW / elW;
|
|
4755
|
+
const sH = availH / (isPresentation ? 540 : singlePageH);
|
|
4756
|
+
if (isPresentation) {
|
|
4757
|
+
return Math.min(1, Math.min(sW, sH));
|
|
4758
|
+
}
|
|
4759
|
+
if (mode === "page") {
|
|
4760
|
+
return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
|
|
4761
|
+
}
|
|
4762
|
+
return Math.max(0.65, Math.min(1.05, sW));
|
|
4688
4763
|
};
|
|
4689
4764
|
const applyTransform = () => {
|
|
4690
4765
|
wrapper.style.transform = `scale(${scale}) rotate(${rotation}deg)`;
|
|
4691
4766
|
wrapper.style.transformOrigin = "top center";
|
|
4692
4767
|
};
|
|
4693
4768
|
setTimeout(() => {
|
|
4694
|
-
|
|
4769
|
+
fitMode = "width";
|
|
4770
|
+
scale = calculateFitScale("width");
|
|
4695
4771
|
applyTransform();
|
|
4696
4772
|
}, 60);
|
|
4697
4773
|
let currentPage = 1;
|
|
@@ -4852,7 +4928,8 @@ var OpenDocumentPlugin = class {
|
|
|
4852
4928
|
applyTransform();
|
|
4853
4929
|
},
|
|
4854
4930
|
fitToPage: () => {
|
|
4855
|
-
|
|
4931
|
+
fitMode = fitMode === "width" ? "page" : "width";
|
|
4932
|
+
scale = calculateFitScale(fitMode);
|
|
4856
4933
|
rotation = 0;
|
|
4857
4934
|
applyTransform();
|
|
4858
4935
|
},
|
|
@@ -5329,15 +5406,22 @@ var DocPlugin = class {
|
|
|
5329
5406
|
if (totalPages > 1) {
|
|
5330
5407
|
showPage(1);
|
|
5331
5408
|
}
|
|
5332
|
-
|
|
5409
|
+
let fitMode = "width";
|
|
5410
|
+
const calculateFitScale = (mode = fitMode) => {
|
|
5333
5411
|
const elW = 816;
|
|
5334
5412
|
const elH = 1056;
|
|
5335
|
-
const availW = Math.max(
|
|
5336
|
-
const availH = Math.max(
|
|
5337
|
-
|
|
5413
|
+
const availW = Math.max(280, ctx.container.clientWidth - 48);
|
|
5414
|
+
const availH = Math.max(280, ctx.container.clientHeight - 80);
|
|
5415
|
+
const sW = availW / elW;
|
|
5416
|
+
const sH = availH / elH;
|
|
5417
|
+
if (mode === "page") {
|
|
5418
|
+
return Math.max(0.55, Math.min(1.15, Math.min(sW, sH)));
|
|
5419
|
+
}
|
|
5420
|
+
return Math.max(0.65, Math.min(1.05, sW));
|
|
5338
5421
|
};
|
|
5339
5422
|
setTimeout(() => {
|
|
5340
|
-
|
|
5423
|
+
fitMode = "width";
|
|
5424
|
+
scale = calculateFitScale("width");
|
|
5341
5425
|
applyTransform();
|
|
5342
5426
|
}, 60);
|
|
5343
5427
|
const cleanup = () => {
|
|
@@ -5365,7 +5449,8 @@ var DocPlugin = class {
|
|
|
5365
5449
|
applyTransform();
|
|
5366
5450
|
},
|
|
5367
5451
|
fitToPage: () => {
|
|
5368
|
-
|
|
5452
|
+
fitMode = fitMode === "width" ? "page" : "width";
|
|
5453
|
+
scale = calculateFitScale(fitMode);
|
|
5369
5454
|
rotation = 0;
|
|
5370
5455
|
applyTransform();
|
|
5371
5456
|
},
|