@open-file-viewer/core 0.1.3 → 0.1.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/index.cjs +24 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5089,6 +5089,7 @@ async function renderDocx(panel, arrayBuffer) {
|
|
|
5089
5089
|
experimental: true,
|
|
5090
5090
|
useBase64URL: true
|
|
5091
5091
|
});
|
|
5092
|
+
normalizeDocxLayout(content);
|
|
5092
5093
|
return fitDocxPages(content);
|
|
5093
5094
|
} catch (error) {
|
|
5094
5095
|
content.replaceChildren();
|
|
@@ -5106,6 +5107,29 @@ async function renderDocx(panel, arrayBuffer) {
|
|
|
5106
5107
|
}
|
|
5107
5108
|
return () => void 0;
|
|
5108
5109
|
}
|
|
5110
|
+
function normalizeDocxLayout(container) {
|
|
5111
|
+
const pages = container.querySelectorAll("section.ofv-docx");
|
|
5112
|
+
for (const page of pages) {
|
|
5113
|
+
for (const element of page.querySelectorAll("[style*='line-height']")) {
|
|
5114
|
+
const lineHeight = parseCssLineHeight(element.style.lineHeight);
|
|
5115
|
+
if (lineHeight > 0 && lineHeight < 1) {
|
|
5116
|
+
element.style.lineHeight = "1.2";
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
function parseCssLineHeight(value) {
|
|
5122
|
+
const trimmed = value.trim();
|
|
5123
|
+
if (!trimmed || trimmed === "normal") {
|
|
5124
|
+
return 0;
|
|
5125
|
+
}
|
|
5126
|
+
if (trimmed.endsWith("%")) {
|
|
5127
|
+
const parsedPercent = Number.parseFloat(trimmed);
|
|
5128
|
+
return Number.isFinite(parsedPercent) ? parsedPercent / 100 : 0;
|
|
5129
|
+
}
|
|
5130
|
+
const parsed = Number.parseFloat(trimmed);
|
|
5131
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
5132
|
+
}
|
|
5109
5133
|
function fitDocxPages(container) {
|
|
5110
5134
|
const wrapper = container.querySelector(".ofv-docx-wrapper");
|
|
5111
5135
|
if (!wrapper) {
|