@files-preview-app/preview-file 1.3.3 → 1.3.4
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 +89 -18
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.js +89 -18
- package/dist/angular.js.map +1 -1
- package/dist/index.cjs +89 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +89 -18
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +89 -18
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +89 -18
- package/dist/react.js.map +1 -1
- package/dist/vue.cjs +89 -18
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.js +89 -18
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
package/dist/vue.js
CHANGED
|
@@ -5381,6 +5381,24 @@ function renderRtfTableElement(table) {
|
|
|
5381
5381
|
tableEl.appendChild(tbody);
|
|
5382
5382
|
return tableEl;
|
|
5383
5383
|
}
|
|
5384
|
+
function extractMediaFingerprint(el) {
|
|
5385
|
+
const img = el.tagName.toLowerCase() === "img" ? el : el.querySelector("img");
|
|
5386
|
+
if (img && img.src) {
|
|
5387
|
+
const s = img.src;
|
|
5388
|
+
return s.length > 300 ? `img_${s.slice(0, 80)}_${s.length}_${s.slice(-80)}` : `img_${s}`;
|
|
5389
|
+
}
|
|
5390
|
+
const innerImg = el.querySelector("image");
|
|
5391
|
+
if (innerImg) {
|
|
5392
|
+
const h2 = innerImg.getAttribute("xlink:href") || innerImg.getAttribute("href") || "";
|
|
5393
|
+
if (h2) return h2.length > 300 ? `svgimg_${h2.slice(0, 80)}_${h2.length}_${h2.slice(-80)}` : `svgimg_${h2}`;
|
|
5394
|
+
}
|
|
5395
|
+
const svg = el.tagName.toLowerCase() === "svg" ? el : el.querySelector("svg");
|
|
5396
|
+
if (svg) {
|
|
5397
|
+
const vb = svg.getAttribute("viewBox") || "";
|
|
5398
|
+
return `svg_${vb}_${svg.innerHTML.length}`;
|
|
5399
|
+
}
|
|
5400
|
+
return null;
|
|
5401
|
+
}
|
|
5384
5402
|
var RtfPlugin = class {
|
|
5385
5403
|
id = "rtf";
|
|
5386
5404
|
name = "Rich Text Format (RTF)";
|
|
@@ -5553,9 +5571,27 @@ var RtfPlugin = class {
|
|
|
5553
5571
|
}
|
|
5554
5572
|
const rawText = new TextDecoder("latin1").decode(ctx.buffer);
|
|
5555
5573
|
const tables = parseRtfTables(rawText);
|
|
5556
|
-
const
|
|
5574
|
+
const seenMediaSignatures = /* @__PURE__ */ new Set();
|
|
5575
|
+
const doc = new RTFJS.Document(ctx.buffer, {
|
|
5576
|
+
onPicture: (isLegacy, createPic) => {
|
|
5577
|
+
if (isLegacy === true) {
|
|
5578
|
+
return null;
|
|
5579
|
+
}
|
|
5580
|
+
const pic = createPic();
|
|
5581
|
+
if (!pic) return null;
|
|
5582
|
+
const fp = extractMediaFingerprint(pic);
|
|
5583
|
+
if (fp) {
|
|
5584
|
+
if (seenMediaSignatures.has(fp)) {
|
|
5585
|
+
return null;
|
|
5586
|
+
}
|
|
5587
|
+
seenMediaSignatures.add(fp);
|
|
5588
|
+
}
|
|
5589
|
+
return pic;
|
|
5590
|
+
}
|
|
5591
|
+
});
|
|
5557
5592
|
const htmlElements = await doc.render();
|
|
5558
5593
|
const contentNodes = [];
|
|
5594
|
+
const seenInContentBlocks = /* @__PURE__ */ new Set();
|
|
5559
5595
|
const extractBlocks = (nodes) => {
|
|
5560
5596
|
for (const item of nodes) {
|
|
5561
5597
|
if (!item || !(item instanceof HTMLElement)) continue;
|
|
@@ -5567,6 +5603,18 @@ var RtfPlugin = class {
|
|
|
5567
5603
|
if (hasChildBlocks && !["table", "tr", "td", "th", "ul", "ol", "li"].includes(tag)) {
|
|
5568
5604
|
extractBlocks(Array.from(item.children));
|
|
5569
5605
|
} else {
|
|
5606
|
+
const fp = extractMediaFingerprint(item);
|
|
5607
|
+
if (fp) {
|
|
5608
|
+
if (seenInContentBlocks.has(fp)) {
|
|
5609
|
+
continue;
|
|
5610
|
+
}
|
|
5611
|
+
seenInContentBlocks.add(fp);
|
|
5612
|
+
}
|
|
5613
|
+
const hasMedia = item.querySelector("img, svg, canvas, table") !== null || ["img", "svg", "table"].includes(tag);
|
|
5614
|
+
const textContent = (item.textContent || "").trim();
|
|
5615
|
+
if (!hasMedia && textContent.length === 0) {
|
|
5616
|
+
continue;
|
|
5617
|
+
}
|
|
5570
5618
|
const svgs = item.querySelectorAll("svg, img");
|
|
5571
5619
|
svgs.forEach((s) => {
|
|
5572
5620
|
const el = s;
|
|
@@ -5622,38 +5670,59 @@ var RtfPlugin = class {
|
|
|
5622
5670
|
}
|
|
5623
5671
|
}
|
|
5624
5672
|
});
|
|
5625
|
-
|
|
5626
|
-
contentNodes.forEach((node) => wrapper.appendChild(node));
|
|
5627
|
-
const childHeights = contentNodes.map((c) => {
|
|
5628
|
-
const rectH = c.getBoundingClientRect ? c.getBoundingClientRect().height : 0;
|
|
5629
|
-
const offH = c.offsetHeight || 0;
|
|
5630
|
-
const realH = Math.max(rectH, offH);
|
|
5631
|
-
if (realH > 0) return realH;
|
|
5632
|
-
const textLen = c.textContent?.trim().length || 0;
|
|
5633
|
-
return Math.max(24, Math.ceil(textLen / 95) * 22 + 12);
|
|
5634
|
-
});
|
|
5635
|
-
wrapper.innerHTML = "";
|
|
5636
|
-
const createRtfCard = () => {
|
|
5673
|
+
const createRtfCard = (pageNum) => {
|
|
5637
5674
|
const card = document.createElement("div");
|
|
5638
5675
|
card.className = "fp-rtf-page-card";
|
|
5676
|
+
card.setAttribute("data-page-number", String(pageNum));
|
|
5639
5677
|
card.style.backgroundColor = "#ffffff";
|
|
5640
|
-
card.style.boxShadow = "0 4px 24px rgba(0,0,0,0.08)";
|
|
5678
|
+
card.style.boxShadow = "0 4px 24px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04)";
|
|
5641
5679
|
card.style.borderRadius = "4px";
|
|
5642
5680
|
card.style.padding = "64px 56px";
|
|
5643
5681
|
card.style.width = "816px";
|
|
5644
5682
|
card.style.minHeight = "1056px";
|
|
5683
|
+
card.style.maxHeight = "1056px";
|
|
5684
|
+
card.style.overflow = "hidden";
|
|
5645
5685
|
card.style.boxSizing = "border-box";
|
|
5646
5686
|
card.style.marginBottom = "24px";
|
|
5647
5687
|
card.style.fontFamily = 'Calibri, "Segoe UI", Arial, sans-serif';
|
|
5648
5688
|
card.style.lineHeight = "1.6";
|
|
5649
5689
|
card.style.color = "#1e293b";
|
|
5690
|
+
card.style.position = "relative";
|
|
5650
5691
|
return card;
|
|
5651
5692
|
};
|
|
5652
|
-
|
|
5693
|
+
wrapper.innerHTML = "";
|
|
5694
|
+
const measureCard = createRtfCard(0);
|
|
5695
|
+
measureCard.style.maxHeight = "none";
|
|
5696
|
+
measureCard.style.height = "auto";
|
|
5697
|
+
wrapper.appendChild(measureCard);
|
|
5698
|
+
contentNodes.forEach((node) => measureCard.appendChild(node));
|
|
5699
|
+
const childHeights = contentNodes.map((c) => {
|
|
5700
|
+
const rect = c.getBoundingClientRect ? c.getBoundingClientRect() : null;
|
|
5701
|
+
const rectH = rect ? rect.height : 0;
|
|
5702
|
+
const offH = c.offsetHeight || 0;
|
|
5703
|
+
let realH = Math.max(rectH, offH);
|
|
5704
|
+
try {
|
|
5705
|
+
const cs = window.getComputedStyle(c);
|
|
5706
|
+
realH += (parseFloat(cs.marginTop) || 0) + (parseFloat(cs.marginBottom) || 0);
|
|
5707
|
+
} catch {
|
|
5708
|
+
}
|
|
5709
|
+
const hasMedia = c.querySelector("img, svg") !== null || ["img", "svg"].includes(c.tagName.toLowerCase());
|
|
5710
|
+
const hasTable = c.querySelector("table") !== null || c.tagName.toLowerCase() === "table";
|
|
5711
|
+
if (hasMedia) {
|
|
5712
|
+
realH = Math.max(realH, 300);
|
|
5713
|
+
} else if (hasTable) {
|
|
5714
|
+
realH = Math.max(realH, 240);
|
|
5715
|
+
}
|
|
5716
|
+
if (realH > 0) return realH;
|
|
5717
|
+
const textLen = c.textContent?.trim().length || 0;
|
|
5718
|
+
return Math.max(28, Math.ceil(textLen / 75) * 26 + 16);
|
|
5719
|
+
});
|
|
5720
|
+
wrapper.innerHTML = "";
|
|
5721
|
+
let curCard = createRtfCard(1);
|
|
5653
5722
|
wrapper.appendChild(curCard);
|
|
5654
5723
|
pageElements = [curCard];
|
|
5655
5724
|
let curH = 0;
|
|
5656
|
-
const maxH =
|
|
5725
|
+
const maxH = 860;
|
|
5657
5726
|
for (let i = 0; i < contentNodes.length; i++) {
|
|
5658
5727
|
const child = contentNodes[i];
|
|
5659
5728
|
const chH = childHeights[i];
|
|
@@ -5661,8 +5730,10 @@ var RtfPlugin = class {
|
|
|
5661
5730
|
if (curH === 0 && isChildEmpty) {
|
|
5662
5731
|
continue;
|
|
5663
5732
|
}
|
|
5664
|
-
|
|
5665
|
-
|
|
5733
|
+
const isTable = child.querySelector("table") !== null || child.tagName.toLowerCase() === "table";
|
|
5734
|
+
const shouldBreakBeforeTable = isTable && curH > 400 && curCard.childNodes.length > 0;
|
|
5735
|
+
if ((curH + chH > maxH || shouldBreakBeforeTable) && curCard.childNodes.length > 0) {
|
|
5736
|
+
curCard = createRtfCard(pageElements.length + 1);
|
|
5666
5737
|
wrapper.appendChild(curCard);
|
|
5667
5738
|
pageElements.push(curCard);
|
|
5668
5739
|
curH = 0;
|