docxodus 12.6.4 → 13.0.0
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/README.md +8 -5
- package/dist/canonical.d.ts.map +1 -1
- package/dist/canonical.js +7 -3
- package/dist/canonical.js.map +1 -1
- package/dist/conversion-options.d.ts +16 -0
- package/dist/conversion-options.d.ts.map +1 -0
- package/dist/conversion-options.js +31 -0
- package/dist/conversion-options.js.map +1 -0
- package/dist/core.d.ts +17 -9
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +23 -24
- package/dist/core.js.map +1 -1
- package/dist/docxodus.worker.js +2 -1073
- package/dist/docxodus.worker.js.map +7 -1
- package/dist/editor.bundle.js +35 -14296
- package/dist/editor.bundle.js.map +7 -0
- package/dist/editor.d.ts +33 -2
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +6739 -4773
- package/dist/editor.js.map +7 -1
- package/dist/embed.bundle.js +159 -18703
- package/dist/embed.bundle.js.map +7 -0
- package/dist/embed.d.ts +1 -1
- package/dist/embed.iife.js +37 -18595
- package/dist/embed.iife.js.map +7 -0
- package/dist/embed.js +1 -1
- package/dist/export-assets.json +27 -27
- package/dist/export-browser.bundle.js +1388 -477
- package/dist/export-browser.d.ts +20 -0
- package/dist/export-browser.d.ts.map +1 -1
- package/dist/export-browser.js +132 -37
- package/dist/export-browser.js.map +1 -1
- package/dist/font-runtime.d.ts.map +1 -1
- package/dist/font-runtime.js +54 -0
- package/dist/font-runtime.js.map +1 -1
- package/dist/line-metrics.d.ts +60 -0
- package/dist/line-metrics.d.ts.map +1 -0
- package/dist/line-metrics.js +343 -0
- package/dist/line-metrics.js.map +1 -0
- package/dist/pagination.bundle.js +3 -3214
- package/dist/pagination.bundle.js.map +7 -0
- package/dist/pagination.d.ts +86 -9
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +358 -55
- package/dist/pagination.js.map +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +63 -12
- package/dist/react.js.map +1 -1
- package/dist/render-report-v2.schema.json +29 -0
- package/dist/session.bundle.js +2 -2013
- package/dist/session.bundle.js.map +7 -0
- package/dist/session.d.ts +14 -5
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +62 -29
- package/dist/session.js.map +1 -1
- package/dist/types.d.ts +137 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -1
- package/dist/wasm/_framework/Docxodus.wasm +0 -0
- package/dist/wasm/_framework/Docxodus.wasm.br +0 -0
- package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
- package/dist/wasm/_framework/DocxodusWasm.wasm.br +0 -0
- package/dist/wasm/_framework/System.Collections.wasm +0 -0
- package/dist/wasm/_framework/System.Collections.wasm.br +0 -0
- package/dist/wasm/_framework/System.IO.Compression.wasm +0 -0
- package/dist/wasm/_framework/System.IO.Compression.wasm.br +0 -0
- package/dist/wasm/_framework/System.Linq.wasm +0 -0
- package/dist/wasm/_framework/System.Linq.wasm.br +0 -0
- package/dist/wasm/_framework/System.Memory.wasm +0 -0
- package/dist/wasm/_framework/System.Memory.wasm.br +0 -0
- package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
- package/dist/wasm/_framework/System.Private.CoreLib.wasm.br +0 -0
- package/dist/wasm/_framework/System.Private.Xml.Linq.wasm +0 -0
- package/dist/wasm/_framework/System.Private.Xml.Linq.wasm.br +0 -0
- package/dist/wasm/_framework/System.Text.RegularExpressions.wasm +0 -0
- package/dist/wasm/_framework/System.Text.RegularExpressions.wasm.br +0 -0
- package/dist/wasm/_framework/dotnet.boot.js +11 -11
- package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
- package/dist/wasm/_framework/dotnet.native.wasm +0 -0
- package/dist/wasm/_framework/dotnet.native.wasm.br +0 -0
- package/dist/word-text.d.ts +14 -0
- package/dist/word-text.d.ts.map +1 -0
- package/dist/word-text.js +377 -0
- package/dist/word-text.js.map +1 -0
- package/dist/worker-proxy.bundle.js +2 -536
- package/dist/worker-proxy.bundle.js.map +7 -0
- package/dist/worker-proxy.d.ts +14 -1
- package/dist/worker-proxy.d.ts.map +1 -1
- package/dist/worker-proxy.js +357 -339
- package/dist/worker-proxy.js.map +1 -1
- package/package.json +13 -12
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unrounded natural line heights for the paginated export (issue #850).
|
|
3
|
+
*
|
|
4
|
+
* Chromium lays a `line-height: normal` line out at the font's natural line height — ascent +
|
|
5
|
+
* descent + line gap from its metrics — but first rounds that to a whole CSS pixel (0.75 pt). The
|
|
6
|
+
* converter relies on `normal` for single spacing and on `calc(1lh * m)` for Word's `auto`
|
|
7
|
+
* multiples, so every line inherits the rounding: 11 pt Carlito advances 18 px instead of
|
|
8
|
+
* 17.90 px, and the error accumulates down the page and moves page breaks. An explicit length keeps
|
|
9
|
+
* Chromium's 1/64-pixel layout precision, so this pass replaces each `normal` with the same font's
|
|
10
|
+
* natural height measured where rounding is negligible.
|
|
11
|
+
*/
|
|
12
|
+
/** Font size the natural line height is probed at: rounding to a pixel there is < 0.0005 em. */
|
|
13
|
+
const PROBE_FONT_SIZE_PX = 1000;
|
|
14
|
+
/** Probe text for an element whose own text the primary font covers (Latin, through U+024F). */
|
|
15
|
+
const LATIN_PROBE = "Hg";
|
|
16
|
+
/** At most this many distinct characters of an element's own text go into its probe. */
|
|
17
|
+
const MAX_PROBE_CHARACTERS = 256;
|
|
18
|
+
/**
|
|
19
|
+
* What to measure an element's natural line height with. Under `normal`, Chromium also grows a line
|
|
20
|
+
* for the fallback fonts its text needs (a CJK run in a Calibri paragraph lays out taller than Latin
|
|
21
|
+
* text), so an element whose own text goes beyond Latin is probed with those characters themselves.
|
|
22
|
+
*/
|
|
23
|
+
function probeText(element) {
|
|
24
|
+
const characters = new Set();
|
|
25
|
+
for (const node of Array.from(element.childNodes)) {
|
|
26
|
+
if (node.nodeType !== 3)
|
|
27
|
+
continue;
|
|
28
|
+
for (const character of node.textContent ?? "") {
|
|
29
|
+
if (/\s/.test(character))
|
|
30
|
+
continue;
|
|
31
|
+
characters.add(character);
|
|
32
|
+
if (characters.size >= MAX_PROBE_CHARACTERS)
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const beyondLatin = Array.from(characters).filter((character) => character.codePointAt(0) > 0x024f);
|
|
37
|
+
return beyondLatin.length === 0 ? LATIN_PROBE : LATIN_PROBE + beyondLatin.sort().join("");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A cached measure of a font's natural line height as a fraction of its size, probed at
|
|
41
|
+
* {@link PROBE_FONT_SIZE_PX} with the given text.
|
|
42
|
+
*/
|
|
43
|
+
function naturalLineHeightRatios(document) {
|
|
44
|
+
const ratios = new Map();
|
|
45
|
+
return (style, text) => {
|
|
46
|
+
const key = `${style.fontStyle}|${style.fontWeight}|${style.fontStretch}|${style.fontFamily}|${text}`;
|
|
47
|
+
let ratio = ratios.get(key);
|
|
48
|
+
if (ratio === undefined) {
|
|
49
|
+
const probe = document.createElement("span");
|
|
50
|
+
probe.setAttribute("aria-hidden", "true");
|
|
51
|
+
probe.style.cssText = "position:absolute;left:-100000px;top:0;visibility:hidden;"
|
|
52
|
+
+ "display:inline-block;white-space:nowrap;line-height:normal;margin:0;padding:0;border:0;";
|
|
53
|
+
probe.style.fontFamily = style.fontFamily;
|
|
54
|
+
probe.style.fontStyle = style.fontStyle;
|
|
55
|
+
probe.style.fontWeight = style.fontWeight;
|
|
56
|
+
probe.style.fontStretch = style.fontStretch;
|
|
57
|
+
probe.style.fontSize = `${PROBE_FONT_SIZE_PX}px`;
|
|
58
|
+
probe.textContent = text;
|
|
59
|
+
(document.body ?? document.documentElement).appendChild(probe);
|
|
60
|
+
ratio = probe.getBoundingClientRect().height / PROBE_FONT_SIZE_PX;
|
|
61
|
+
probe.remove();
|
|
62
|
+
ratios.set(key, ratio);
|
|
63
|
+
}
|
|
64
|
+
return ratio;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Give every element under `root` whose computed `line-height` is `normal` an explicit line height
|
|
69
|
+
* equal to its own font's unrounded natural line height (including any fallback font its own text
|
|
70
|
+
* needs). Elements are collected before any is
|
|
71
|
+
* changed, because an explicit value on a parent would otherwise be inherited by children that
|
|
72
|
+
* should keep sizing their lines from their own font. Returns how many elements changed.
|
|
73
|
+
*/
|
|
74
|
+
export function applyUnroundedNormalLineHeights(root) {
|
|
75
|
+
const document = root.ownerDocument;
|
|
76
|
+
const view = document.defaultView;
|
|
77
|
+
if (!view)
|
|
78
|
+
return 0;
|
|
79
|
+
const ratioFor = naturalLineHeightRatios(document);
|
|
80
|
+
const targets = [];
|
|
81
|
+
for (const element of [root, ...Array.from(root.querySelectorAll("*"))]) {
|
|
82
|
+
if (!(element instanceof view.HTMLElement))
|
|
83
|
+
continue;
|
|
84
|
+
const style = view.getComputedStyle(element);
|
|
85
|
+
if (style.lineHeight !== "normal")
|
|
86
|
+
continue;
|
|
87
|
+
const fontSize = Number.parseFloat(style.fontSize);
|
|
88
|
+
const ratio = ratioFor(style, probeText(element));
|
|
89
|
+
if (!(fontSize > 0) || !(ratio > 0))
|
|
90
|
+
continue;
|
|
91
|
+
targets.push({ element, lineHeight: ratio * fontSize });
|
|
92
|
+
}
|
|
93
|
+
for (const { element, lineHeight } of targets) {
|
|
94
|
+
element.style.setProperty("line-height", `${lineHeight.toFixed(4)}px`);
|
|
95
|
+
}
|
|
96
|
+
return targets.length;
|
|
97
|
+
}
|
|
98
|
+
/** The elements the converter writes a Word paragraph as. */
|
|
99
|
+
const PARAGRAPH_SELECTOR = "p, h1, h2, h3, h4, h5, h6";
|
|
100
|
+
/** How far Chromium puts the first baseline below the top of a paragraph shaped like this one. */
|
|
101
|
+
function baselineOffsets(document) {
|
|
102
|
+
const offsets = new Map();
|
|
103
|
+
const host = document.body ?? document.documentElement;
|
|
104
|
+
return (paragraph, child) => {
|
|
105
|
+
const key = [paragraph.fontStyle, paragraph.fontWeight, paragraph.fontStretch, paragraph.fontFamily,
|
|
106
|
+
paragraph.fontSize, paragraph.lineHeight, child.fontStyle, child.fontWeight, child.fontStretch,
|
|
107
|
+
child.fontFamily, child.fontSize, child.lineHeight, child.verticalAlign, child.top].join("|");
|
|
108
|
+
let offset = offsets.get(key);
|
|
109
|
+
if (offset === undefined) {
|
|
110
|
+
const probe = document.createElement("div");
|
|
111
|
+
probe.setAttribute("aria-hidden", "true");
|
|
112
|
+
probe.style.cssText = "position:absolute;left:-100000px;top:0;visibility:hidden;width:max-content;"
|
|
113
|
+
+ "margin:0;padding:0;border:0;white-space:nowrap;";
|
|
114
|
+
for (const property of ["font-family", "font-style", "font-weight", "font-stretch", "font-size", "line-height"])
|
|
115
|
+
probe.style.setProperty(property, paragraph.getPropertyValue(property));
|
|
116
|
+
const span = document.createElement("span");
|
|
117
|
+
for (const property of ["font-family", "font-style", "font-weight", "font-stretch", "font-size", "line-height",
|
|
118
|
+
"vertical-align", "position", "top"])
|
|
119
|
+
span.style.setProperty(property, child.getPropertyValue(property));
|
|
120
|
+
const marker = document.createElement("span");
|
|
121
|
+
marker.style.cssText = "display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0;";
|
|
122
|
+
span.append(marker, LATIN_PROBE);
|
|
123
|
+
probe.append(span);
|
|
124
|
+
host.appendChild(probe);
|
|
125
|
+
offset = marker.getBoundingClientRect().bottom - probe.getBoundingClientRect().top;
|
|
126
|
+
probe.remove();
|
|
127
|
+
offsets.set(key, offset);
|
|
128
|
+
}
|
|
129
|
+
return offset;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Word places an exact-spaced line's baseline at 80% of its height, independent of font size
|
|
134
|
+
* (issue #882; fixtures/exact-line-spacing/word.json). Move each run by its own font's offset,
|
|
135
|
+
* retaining the converter's top alignment so mixed font sizes cannot enlarge the line boxes.
|
|
136
|
+
*/
|
|
137
|
+
export function alignExactLineBaselines(root) {
|
|
138
|
+
const view = root.ownerDocument.defaultView;
|
|
139
|
+
if (!view)
|
|
140
|
+
return;
|
|
141
|
+
const offsetFor = baselineOffsets(root.ownerDocument);
|
|
142
|
+
for (const run of Array.from(root.querySelectorAll("[data-docx-exact-run]"))) {
|
|
143
|
+
const paragraph = run.closest(PARAGRAPH_SELECTOR);
|
|
144
|
+
if (!paragraph || !movable(run, view))
|
|
145
|
+
continue;
|
|
146
|
+
const style = view.getComputedStyle(paragraph);
|
|
147
|
+
if (!style.getPropertyValue("--docx-exact-line-height"))
|
|
148
|
+
continue;
|
|
149
|
+
const height = Number.parseFloat(style.lineHeight);
|
|
150
|
+
const runStyle = view.getComputedStyle(run);
|
|
151
|
+
if (!(height > 0) || runStyle.display !== "inline" || runStyle.verticalAlign !== "top")
|
|
152
|
+
continue;
|
|
153
|
+
const top = Number.parseFloat(runStyle.top) || 0;
|
|
154
|
+
const offset = offsetFor(style, runStyle) - top;
|
|
155
|
+
const shift = height * 0.8 - offset;
|
|
156
|
+
if (!Number.isFinite(shift))
|
|
157
|
+
continue;
|
|
158
|
+
run.style.position = "relative";
|
|
159
|
+
run.style.top = `${(top + shift).toFixed(4)}px`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const EXACT_INK_ATTRIBUTE = "data-docx-exact-ink";
|
|
163
|
+
/**
|
|
164
|
+
* Exact line boxes still occupy their declared height when their glyphs extend outside them.
|
|
165
|
+
* Word lets that ink enter the margins. Expand only the paint clip, after placement, for plain
|
|
166
|
+
* inline text whose paragraph fits its band and whose ink cannot enter a running story or leave
|
|
167
|
+
* the paper. Block geometry and pagination budgets remain unchanged.
|
|
168
|
+
*/
|
|
169
|
+
export function preserveExactLineInk(content, topLimit, bottomLimit, paper) {
|
|
170
|
+
const view = content.ownerDocument.defaultView;
|
|
171
|
+
if (!view)
|
|
172
|
+
return;
|
|
173
|
+
const band = content.getBoundingClientRect();
|
|
174
|
+
const scale = band.width / content.offsetWidth || 1;
|
|
175
|
+
let above = 0;
|
|
176
|
+
let below = 0;
|
|
177
|
+
for (const paragraph of Array.from(content.querySelectorAll(PARAGRAPH_SELECTOR))) {
|
|
178
|
+
if (!view.getComputedStyle(paragraph).getPropertyValue("--docx-exact-line-height"))
|
|
179
|
+
continue;
|
|
180
|
+
const box = paragraph.getBoundingClientRect();
|
|
181
|
+
if (box.top < band.top - 0.5 || box.bottom > band.bottom + 0.5)
|
|
182
|
+
continue;
|
|
183
|
+
if (!paragraph.querySelector("[data-docx-exact-run]") || paragraph.querySelector("img, svg, canvas, video, object, iframe"))
|
|
184
|
+
continue;
|
|
185
|
+
if (Array.from(paragraph.querySelectorAll("*")).some(element => {
|
|
186
|
+
const style = view.getComputedStyle(element);
|
|
187
|
+
return style.display !== "inline" || !["static", "relative"].includes(style.position);
|
|
188
|
+
}))
|
|
189
|
+
continue;
|
|
190
|
+
const range = content.ownerDocument.createRange();
|
|
191
|
+
range.selectNodeContents(paragraph);
|
|
192
|
+
const rects = Array.from(range.getClientRects()).filter(rect => rect.width > 0 && rect.height > 0);
|
|
193
|
+
if (rects.length === 0)
|
|
194
|
+
continue;
|
|
195
|
+
const top = Math.min(...rects.map(rect => rect.top));
|
|
196
|
+
const bottom = Math.max(...rects.map(rect => rect.bottom));
|
|
197
|
+
if (top < topLimit || bottom > bottomLimit)
|
|
198
|
+
continue;
|
|
199
|
+
const extra = Math.max(0, band.top - top, bottom - band.bottom);
|
|
200
|
+
if (extra === 0)
|
|
201
|
+
continue;
|
|
202
|
+
paragraph.setAttribute(EXACT_INK_ATTRIBUTE, "true");
|
|
203
|
+
above = Math.max(above, band.top - top);
|
|
204
|
+
below = Math.max(below, bottom - band.bottom);
|
|
205
|
+
}
|
|
206
|
+
if (above > 0 || below > 0) {
|
|
207
|
+
const up = Math.ceil(above / scale * 64) / 64;
|
|
208
|
+
const down = Math.ceil(below / scale * 64) / 64;
|
|
209
|
+
// overflow-clip-margin is ignored by Chromium when the other axis stays visible. A pixel
|
|
210
|
+
// inset clips each vertical edge independently and keeps horizontal clipping at the paper.
|
|
211
|
+
content.style.overflowY = "visible";
|
|
212
|
+
content.style.clipPath = `inset(${-up}px ${(band.right - paper.right) / scale}px ${-down}px ${(paper.left - band.left) / scale}px)`;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Read the pixel inset used for the exact-text paint clip, including CSS's 1-4 value shorthand. */
|
|
216
|
+
export function insetClipBounds(value, box, scale) {
|
|
217
|
+
const match = /^inset\(((?:-?\d+(?:\.\d+)?px\s*){1,4})\)$/.exec(value);
|
|
218
|
+
if (!match)
|
|
219
|
+
return null;
|
|
220
|
+
const parts = match[1].trim().split(/\s+/).map(Number.parseFloat);
|
|
221
|
+
const [top, right = top, bottom = top, left = right] = parts;
|
|
222
|
+
return { top: box.top + top * scale, right: box.right - right * scale,
|
|
223
|
+
bottom: box.bottom - bottom * scale, left: box.left + left * scale };
|
|
224
|
+
}
|
|
225
|
+
/** Only inline ink in a fitting exact-spaced paragraph may use the expanded paint clip. */
|
|
226
|
+
export function isPreservedExactLineInk(element, content) {
|
|
227
|
+
const paragraph = element.closest(`[${EXACT_INK_ATTRIBUTE}]`);
|
|
228
|
+
const view = content.ownerDocument.defaultView;
|
|
229
|
+
if (!paragraph || !view || element === paragraph || !content.contains(paragraph))
|
|
230
|
+
return false;
|
|
231
|
+
if (view.getComputedStyle(element).display !== "inline")
|
|
232
|
+
return false;
|
|
233
|
+
const band = content.getBoundingClientRect();
|
|
234
|
+
const box = paragraph.getBoundingClientRect();
|
|
235
|
+
const clip = insetClipBounds(view.getComputedStyle(content).clipPath, band, band.width / content.offsetWidth || 1);
|
|
236
|
+
const ink = element.getBoundingClientRect();
|
|
237
|
+
return clip !== null && box.top >= band.top - 0.5 && box.bottom <= band.bottom + 0.5
|
|
238
|
+
&& ink.top >= clip.top - 0.02 && ink.bottom <= clip.bottom + 0.02;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Put every exported baseline where Word puts it, to a fraction of a pixel (issue #942).
|
|
242
|
+
*
|
|
243
|
+
* Word sets a line's baseline its natural line height less the font's descent below the line's top: the
|
|
244
|
+
* font's ascent, with any line gap above it. Chromium instead rounds the ascent and descent to whole pixels
|
|
245
|
+
* and floors half the remaining leading, so the baseline lands up to a pixel off; for 11 pt Calibri and 12 pt
|
|
246
|
+
* Arial it is one pixel high. Word also puts a font's line gap above the text where CSS splits it, which moves
|
|
247
|
+
* Arial's baseline a little further. That offset is the same on every line of a paragraph, whatever its position, so
|
|
248
|
+
* it is measured once per paragraph shape in a probe and taken back with relative positioning, which moves the
|
|
249
|
+
* glyphs without changing any line box: pagination and line pitch are untouched.
|
|
250
|
+
*
|
|
251
|
+
* Each direct inline child of a paragraph is moved, composing with a `top` it already has. A child positioned
|
|
252
|
+
* some other way, or holding an image, an SVG or an absolutely positioned element (for which a relative child
|
|
253
|
+
* would become the containing block), is left alone. Run once the page tree is final: the moved boxes count
|
|
254
|
+
* toward a page band's overflow, which the export's clipping check must not see.
|
|
255
|
+
* Returns how many children moved.
|
|
256
|
+
*/
|
|
257
|
+
export function alignBaselinesToWord(root) {
|
|
258
|
+
const document = root.ownerDocument;
|
|
259
|
+
const view = document.defaultView;
|
|
260
|
+
if (!view)
|
|
261
|
+
return 0;
|
|
262
|
+
const descents = new Map();
|
|
263
|
+
const ratioFor = naturalLineHeightRatios(document);
|
|
264
|
+
const chromiumOffset = baselineOffsets(document);
|
|
265
|
+
/** The font's descent as a fraction of its size, read where rounding is negligible. */
|
|
266
|
+
const descentRatio = (style) => {
|
|
267
|
+
// The canvas font shorthand takes no percentage stretch (computed styles give one), and ignores a value it
|
|
268
|
+
// cannot parse, so the stretch is left out and an assignment that did not take counts as unmeasurable.
|
|
269
|
+
const font = `${style.fontStyle} ${style.fontWeight} ${PROBE_FONT_SIZE_PX}px ${style.fontFamily}`;
|
|
270
|
+
let ratio = descents.get(font);
|
|
271
|
+
if (ratio === undefined) {
|
|
272
|
+
const context = document.createElement("canvas").getContext("2d");
|
|
273
|
+
ratio = Number.NaN;
|
|
274
|
+
if (context) {
|
|
275
|
+
context.font = font;
|
|
276
|
+
if (context.font.includes(`${PROBE_FONT_SIZE_PX}px`))
|
|
277
|
+
ratio = context.measureText(LATIN_PROBE).fontBoundingBoxDescent / PROBE_FONT_SIZE_PX;
|
|
278
|
+
}
|
|
279
|
+
descents.set(font, ratio);
|
|
280
|
+
}
|
|
281
|
+
return ratio;
|
|
282
|
+
};
|
|
283
|
+
const moves = [];
|
|
284
|
+
for (const paragraph of Array.from(root.querySelectorAll(PARAGRAPH_SELECTOR))) {
|
|
285
|
+
if (!(paragraph instanceof view.HTMLElement))
|
|
286
|
+
continue;
|
|
287
|
+
const style = view.getComputedStyle(paragraph);
|
|
288
|
+
// Probe with a child that sits on the baseline (not a raised or lowered run), preferably in the
|
|
289
|
+
// paragraph's own font rather than, say, a list marker's.
|
|
290
|
+
const candidates = Array.from(paragraph.children).filter((child) => child instanceof view.HTMLElement && (child.textContent ?? "").trim() !== "" && movable(child, view) &&
|
|
291
|
+
view.getComputedStyle(child).display === "inline" && view.getComputedStyle(child).verticalAlign === "baseline");
|
|
292
|
+
const first = candidates.find((child) => view.getComputedStyle(child).fontFamily === style.fontFamily) ??
|
|
293
|
+
candidates[0];
|
|
294
|
+
if (!first)
|
|
295
|
+
continue;
|
|
296
|
+
const lineHeight = Number.parseFloat(style.lineHeight);
|
|
297
|
+
const fontSize = Number.parseFloat(style.fontSize);
|
|
298
|
+
// Word's placement is recorded for natural line heights (single spacing and auto multiples, which the
|
|
299
|
+
// converter builds on the paragraph's natural height), not for exact or at-least ones.
|
|
300
|
+
if (!(lineHeight > 0) || !(fontSize > 0) ||
|
|
301
|
+
Math.abs(lineHeight - ratioFor(style, LATIN_PROBE) * fontSize) > 0.01)
|
|
302
|
+
continue;
|
|
303
|
+
const descent = descentRatio(style);
|
|
304
|
+
if (!(descent > 0))
|
|
305
|
+
continue;
|
|
306
|
+
const childStyle = view.getComputedStyle(first);
|
|
307
|
+
// Word: the extra height of a multiple goes below the text (issue #908), so the baseline is one natural
|
|
308
|
+
// line height less the descent below the line's top, however tall the line is.
|
|
309
|
+
const shift = (lineHeight - descent * fontSize) - chromiumOffset(style, childStyle);
|
|
310
|
+
// The correction is Chromium's rounding plus the half of any line gap it puts below the text, which Word
|
|
311
|
+
// puts above: a fraction of the line. Half a line or more means the font does not follow this model.
|
|
312
|
+
if (!Number.isFinite(shift) || Math.abs(shift) < 1 / 64 || Math.abs(shift) >= lineHeight / 2)
|
|
313
|
+
continue;
|
|
314
|
+
for (const child of Array.from(paragraph.children))
|
|
315
|
+
if (child instanceof view.HTMLElement && movable(child, view)) {
|
|
316
|
+
// Compose with the offset the child already has (a run's w:position, or the lift of an auto multiple),
|
|
317
|
+
// which may come from a stylesheet rule rather than its own style attribute.
|
|
318
|
+
const top = Number.parseFloat(view.getComputedStyle(child).top);
|
|
319
|
+
moves.push({ element: child, top: (Number.isFinite(top) ? top : 0) + shift });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
for (const { element, top } of moves) {
|
|
323
|
+
element.style.setProperty("position", "relative");
|
|
324
|
+
element.style.setProperty("top", `${top.toFixed(4)}px`);
|
|
325
|
+
}
|
|
326
|
+
return moves.length;
|
|
327
|
+
}
|
|
328
|
+
/** Whether relative positioning can move a paragraph child without disturbing anything laid out from it. */
|
|
329
|
+
function movable(element, view) {
|
|
330
|
+
const position = view.getComputedStyle(element).position;
|
|
331
|
+
if (position !== "static" && position !== "relative")
|
|
332
|
+
return false;
|
|
333
|
+
// Inline boxes share the line's baseline; tab stops and leaders are inline-blocks on the same line.
|
|
334
|
+
if (!["inline", "inline-block"].includes(view.getComputedStyle(element).display))
|
|
335
|
+
return false;
|
|
336
|
+
if (element.querySelector("img, svg"))
|
|
337
|
+
return false;
|
|
338
|
+
for (const descendant of Array.from(element.querySelectorAll("*")))
|
|
339
|
+
if (["absolute", "fixed"].includes(view.getComputedStyle(descendant).position))
|
|
340
|
+
return false;
|
|
341
|
+
return true;
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