@emailens/cli 0.13.12 → 0.13.13
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/{chunk-3TDW4LHR.js → chunk-Y3WSDM76.js} +311 -38
- package/dist/index.js +314 -41
- package/dist/test.js +1 -1
- package/package.json +2 -2
|
@@ -63434,27 +63434,28 @@ function vmlToCss(html3) {
|
|
|
63434
63434
|
out = out.replace(
|
|
63435
63435
|
/<v:roundrect([^>]*)>([\s\S]*?)<\/v:roundrect>/gi,
|
|
63436
63436
|
(_m2, rawAttrs, inner) => {
|
|
63437
|
-
var _a22, _b, _c2, _d, _e2, _f, _g, _h2;
|
|
63437
|
+
var _a22, _b, _c2, _d, _e2, _f, _g, _h2, _i2, _j;
|
|
63438
63438
|
const a2 = attrs(rawAttrs);
|
|
63439
63439
|
const s2 = styleProps((_a22 = a2.style) != null ? _a22 : "");
|
|
63440
|
-
const
|
|
63441
|
-
const
|
|
63442
|
-
const
|
|
63440
|
+
const auto = /^auto$/i.test((_c2 = (_b = s2.width) == null ? void 0 : _b.trim()) != null ? _c2 : "");
|
|
63441
|
+
const w2 = auto ? 64 : (_d = px(s2.width)) != null ? _d : 0;
|
|
63442
|
+
const h = (_e2 = px(s2.height)) != null ? _e2 : 0;
|
|
63443
|
+
const radius = arcsizeToRadius((_f = a2.arcsize) != null ? _f : "20%", w2, h);
|
|
63443
63444
|
const fillTag = inner.match(/<v:fill([^>]*?)\/?>/i);
|
|
63444
63445
|
const f3 = fillTag ? attrs(fillTag[1]) : {};
|
|
63445
63446
|
const imageData = inner.match(/<v:imagedata([^>]*?)\/?>/i);
|
|
63446
63447
|
const imageSrc = imageData ? attrs(imageData[1]).src : void 0;
|
|
63447
|
-
const fill = (
|
|
63448
|
+
const fill = (_h2 = (_g = f3.color) != null ? _g : a2.fillcolor) != null ? _h2 : "transparent";
|
|
63448
63449
|
const image = imageSrc ? `;background-image:url('${imageSrc}');background-size:100% 100%;background-repeat:no-repeat` : "";
|
|
63449
63450
|
const stroked = !(a2.stroke === "f" || a2.stroke === "false");
|
|
63450
|
-
const middle = /middle/i.test((
|
|
63451
|
-
const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim();
|
|
63451
|
+
const middle = /middle/i.test((_i2 = s2["v-text-anchor"]) != null ? _i2 : "");
|
|
63452
|
+
const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim().replace(/^<span(?: style="([^"]*)")?/i, (tag, style) => auto ? `<span style="display:block;max-height:1lh;overflow:hidden;padding:0 9.6px;${style != null ? style : ""}"` : tag);
|
|
63452
63453
|
const box2 = [
|
|
63453
63454
|
w2 ? `width:${w2}px` : "",
|
|
63454
63455
|
h ? `height:${h}px` : "",
|
|
63455
63456
|
`border-radius:${radius}px`,
|
|
63456
63457
|
`background:${fill}${image}`,
|
|
63457
|
-
stroked ? `border:1px solid ${(
|
|
63458
|
+
stroked ? `border:1px solid ${(_j = a2.strokecolor) != null ? _j : "#000"}` : "border:none",
|
|
63458
63459
|
"display:inline-flex",
|
|
63459
63460
|
"justify-content:center",
|
|
63460
63461
|
`align-items:${middle ? "center" : "flex-start"}`,
|
|
@@ -63625,6 +63626,14 @@ var BORDER_WIDTH = [
|
|
|
63625
63626
|
"border-left-width"
|
|
63626
63627
|
];
|
|
63627
63628
|
var NATURAL_LINE = 1.15;
|
|
63629
|
+
var GILL_VDMX = [14, 14, 15, 16, 18, 18, 21, 21, 23, 25, 27, 27, 29, 30, 31];
|
|
63630
|
+
var isGill = (family = "") => /^\s*['"]?gill sans/i.test(family);
|
|
63631
|
+
var naturalHeight = (size, family = "") => {
|
|
63632
|
+
if (!isGill(family)) return Math.round(size * NATURAL_LINE);
|
|
63633
|
+
const ppem = Math.round(size);
|
|
63634
|
+
return ppem <= 22 ? GILL_VDMX[Math.max(ppem, 8) - 8] : Math.ceil(0.9292 * size) + Math.ceil(0.2305 * size);
|
|
63635
|
+
};
|
|
63636
|
+
var GILL_LARGE = "'Gill Sans MT Large'";
|
|
63628
63637
|
var TABLE_GUTTER = 3.5;
|
|
63629
63638
|
var INVISIBLE_ONLY = /^[\s\u00a0\u00ad\u034f\u200b-\u200d\u2007\ufeff]+$/;
|
|
63630
63639
|
var LIST_TRAILING_PX = 18;
|
|
@@ -63785,8 +63794,27 @@ function markHiddenCells(html3) {
|
|
|
63785
63794
|
);
|
|
63786
63795
|
}
|
|
63787
63796
|
function prepareWordSource(html3) {
|
|
63788
|
-
return markHiddenCells(dropWordUnknownColors(html3));
|
|
63789
|
-
}
|
|
63797
|
+
return wordSubstitutes(markHiddenCells(dropWordUnknownColors(html3)));
|
|
63798
|
+
}
|
|
63799
|
+
var WORD_SUBSTITUTES = { rubik: "Calibri" };
|
|
63800
|
+
var SUBSTITUTED = new RegExp(String.raw`(font(?:-family)?\s*:[^;"}]*?)(['"]?)\b(${Object.keys(WORD_SUBSTITUTES).join("|")})\b\2`, "gi");
|
|
63801
|
+
var wordSubstitutes = (html3) => html3.replace(SUBSTITUTED, (_3, lead, _q, name) => `${lead}${WORD_SUBSTITUTES[name.toLowerCase()]}`);
|
|
63802
|
+
var OFFICE_CLOUD_FONTS = [
|
|
63803
|
+
"Work Sans",
|
|
63804
|
+
"Lato",
|
|
63805
|
+
"Montserrat",
|
|
63806
|
+
"Nunito",
|
|
63807
|
+
"Nunito Sans",
|
|
63808
|
+
"Open Sans",
|
|
63809
|
+
"DM Sans",
|
|
63810
|
+
"IBM Plex Sans",
|
|
63811
|
+
"Ubuntu",
|
|
63812
|
+
"Source Code Pro",
|
|
63813
|
+
"Raleway",
|
|
63814
|
+
"Playfair Display",
|
|
63815
|
+
"Poppins"
|
|
63816
|
+
];
|
|
63817
|
+
var CLOUD = new Set(OFFICE_CLOUD_FONTS.map((f3) => f3.toLowerCase()));
|
|
63790
63818
|
function declaredFaces($3) {
|
|
63791
63819
|
const faces = /* @__PURE__ */ new Map();
|
|
63792
63820
|
$3("style").each((_3, block) => {
|
|
@@ -63796,7 +63824,7 @@ function declaredFaces($3) {
|
|
|
63796
63824
|
const family = props.get("font-family");
|
|
63797
63825
|
const named = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
|
|
63798
63826
|
const alt = named && /^sans-serif$/i.test(named) ? WORD_DEFAULT : named;
|
|
63799
|
-
if (family) faces.set(firstFamily(family), (_c2 = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c2 : null);
|
|
63827
|
+
if (family && !CLOUD.has(firstFamily(family))) faces.set(firstFamily(family), (_c2 = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c2 : null);
|
|
63800
63828
|
}
|
|
63801
63829
|
});
|
|
63802
63830
|
return faces;
|
|
@@ -63828,8 +63856,36 @@ function leftPadding(props) {
|
|
|
63828
63856
|
const value = parts.length === 4 ? parts[3] : parts.length >= 2 ? parts[1] : parts[0];
|
|
63829
63857
|
return /^\d+(?:\.\d+)?(?:px)?$/.test(value != null ? value : "") ? parseFloat(value) : 0;
|
|
63830
63858
|
}
|
|
63859
|
+
var SPACING = /^(?:line-height|mso-line-height-rule|mso-line-height-alt|font-size|font|font-family|background|background-color)$/;
|
|
63860
|
+
function sheetSpacing($3) {
|
|
63861
|
+
const found = /* @__PURE__ */ new Map();
|
|
63862
|
+
$3("style").each((_3, block) => {
|
|
63863
|
+
var _a22, _b;
|
|
63864
|
+
for (const { selector, body } of topLevelRules((_a22 = $3(block).html()) != null ? _a22 : "")) {
|
|
63865
|
+
const rule = [...parseInlineStyle(body.replace(/!important/gi, ""))].filter(([k2]) => SPACING.test(k2));
|
|
63866
|
+
if (!rule.length) continue;
|
|
63867
|
+
for (const one of selector.split(",")) {
|
|
63868
|
+
for (const el2 of matchedByWord($3, one)) {
|
|
63869
|
+
const has2 = (_b = found.get(el2)) != null ? _b : /* @__PURE__ */ new Map();
|
|
63870
|
+
for (const [k2, v] of rule) has2.set(k2, v);
|
|
63871
|
+
found.set(el2, has2);
|
|
63872
|
+
}
|
|
63873
|
+
}
|
|
63874
|
+
}
|
|
63875
|
+
});
|
|
63876
|
+
return found;
|
|
63877
|
+
}
|
|
63831
63878
|
function applyWordBoxModel($3) {
|
|
63832
63879
|
const faces = declaredFaces($3);
|
|
63880
|
+
const sheet = sheetSpacing($3);
|
|
63881
|
+
const spacingOf = (el2) => {
|
|
63882
|
+
var _a22, _b;
|
|
63883
|
+
const all = new Map([...(_a22 = sheet.get(el2)) != null ? _a22 : [], ...parseInlineStyle($3(el2).attr("style") || "")]);
|
|
63884
|
+
const alt = (_b = all.get("mso-line-height-alt")) == null ? void 0 : _b.trim();
|
|
63885
|
+
const altEm = /^([\d.]+)em$/i.exec(alt != null ? alt : "");
|
|
63886
|
+
if (alt) all.set("line-height", altEm ? `${Number(altEm[1]) * 16}px` : alt);
|
|
63887
|
+
return all;
|
|
63888
|
+
};
|
|
63833
63889
|
$3("[style]").each((_3, node) => {
|
|
63834
63890
|
var _a22, _b, _c2, _d, _e2, _f, _g, _h2, _i2, _j, _k, _l2, _m2, _n2;
|
|
63835
63891
|
const el2 = node;
|
|
@@ -63889,7 +63945,7 @@ function applyWordBoxModel($3) {
|
|
|
63889
63945
|
const lineHeight = /^([\d.]+)px$/i.exec((_k = props.get("line-height")) != null ? _k : "");
|
|
63890
63946
|
const fontSize = /^([\d.]+)px$/i.exec((_l2 = props.get("font-size")) != null ? _l2 : "");
|
|
63891
63947
|
if (lineHeight && fontSize && !/exactly/i.test((_m2 = props.get("mso-line-height-rule")) != null ? _m2 : "")) {
|
|
63892
|
-
const natural =
|
|
63948
|
+
const natural = naturalHeight(Number(fontSize[1]), props.get("font-family"));
|
|
63893
63949
|
if (Number(lineHeight[1]) < natural) props.set("line-height", `${natural}px`);
|
|
63894
63950
|
}
|
|
63895
63951
|
for (const prop2 of ["word-spacing", "outline", "outline-width", "outline-style", "outline-color", "outline-offset"]) {
|
|
@@ -63927,6 +63983,18 @@ function applyWordBoxModel($3) {
|
|
|
63927
63983
|
props.set("line-height", "0");
|
|
63928
63984
|
cell.empty().attr("style", serializeStyle(props));
|
|
63929
63985
|
});
|
|
63986
|
+
$3("p").each((_3, node) => {
|
|
63987
|
+
if (!$3(node).children().length && !/[^ \t\r\n]/.test($3(node).text())) $3(node).remove();
|
|
63988
|
+
});
|
|
63989
|
+
$3("img").each((_3, node) => {
|
|
63990
|
+
var _a22, _b;
|
|
63991
|
+
const img = $3(node);
|
|
63992
|
+
const props = parseInlineStyle(img.attr("style") || "");
|
|
63993
|
+
const height = Number.parseFloat((_b = (_a22 = props.get("height")) != null ? _a22 : img.attr("height")) != null ? _b : "");
|
|
63994
|
+
if (img.closest("td, th").length || !(height <= 1)) return;
|
|
63995
|
+
props.set("display", "block");
|
|
63996
|
+
img.attr("style", serializeStyle(props));
|
|
63997
|
+
});
|
|
63930
63998
|
$3("hr").each((_3, node) => {
|
|
63931
63999
|
var _a22, _b, _c2;
|
|
63932
64000
|
const props = parseInlineStyle($3(node).attr("style") || "");
|
|
@@ -63942,7 +64010,7 @@ function applyWordBoxModel($3) {
|
|
|
63942
64010
|
$3(node).attr("style", serializeStyle(set));
|
|
63943
64011
|
});
|
|
63944
64012
|
$3("a").each((_3, node) => {
|
|
63945
|
-
if (!$3(node).children("div").length) return;
|
|
64013
|
+
if (!$3(node).children("div, p").length) return;
|
|
63946
64014
|
$3(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
|
|
63947
64015
|
});
|
|
63948
64016
|
$3("a[style*='text-decoration-line']").each((_3, node) => {
|
|
@@ -64049,37 +64117,91 @@ function applyWordBoxModel($3) {
|
|
|
64049
64117
|
})) return;
|
|
64050
64118
|
cell.attr("style", `${style}${style.trim() === "" || /;\s*$/.test(style) ? "" : ";"}text-align:left`);
|
|
64051
64119
|
});
|
|
64120
|
+
const sheetMargins = /* @__PURE__ */ new Map();
|
|
64121
|
+
$3("style").each((_3, block) => {
|
|
64122
|
+
var _a22, _b;
|
|
64123
|
+
for (const { selector, body } of topLevelRules((_a22 = $3(block).html()) != null ? _a22 : "")) {
|
|
64124
|
+
if (!/margin/i.test(body)) continue;
|
|
64125
|
+
let cells = [];
|
|
64126
|
+
try {
|
|
64127
|
+
cells = $3(selector).filter("td, th").toArray();
|
|
64128
|
+
} catch (e2) {
|
|
64129
|
+
continue;
|
|
64130
|
+
}
|
|
64131
|
+
const rule = parseInlineStyle(body.replace(/!important/gi, ""));
|
|
64132
|
+
for (const cell of cells) {
|
|
64133
|
+
const has2 = (_b = sheetMargins.get(cell)) != null ? _b : /* @__PURE__ */ new Map();
|
|
64134
|
+
for (const [k2, v] of rule) if (/^margin(?:-top|-bottom)?$/.test(k2)) has2.set(k2, v);
|
|
64135
|
+
sheetMargins.set(cell, has2);
|
|
64136
|
+
}
|
|
64137
|
+
}
|
|
64138
|
+
});
|
|
64139
|
+
const verticalMargins = (props) => {
|
|
64140
|
+
var _a22, _b, _c2, _d;
|
|
64141
|
+
const box2 = ((_a22 = props.get("margin")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
|
|
64142
|
+
const read = (v) => v === void 0 ? void 0 : Number.parseFloat(v) || 0;
|
|
64143
|
+
return { top: read((_b = props.get("margin-top")) != null ? _b : box2[0]), bottom: read((_d = (_c2 = props.get("margin-bottom")) != null ? _c2 : box2[2]) != null ? _d : box2[0]) };
|
|
64144
|
+
};
|
|
64145
|
+
const holdsBareText = (cell) => {
|
|
64146
|
+
const inline = $3(cell).clone();
|
|
64147
|
+
inline.find("table, div, p, ul, ol, h1, h2, h3, h4, h5, h6").remove();
|
|
64148
|
+
return /[^\s ]/.test(inline.text());
|
|
64149
|
+
};
|
|
64052
64150
|
$3("table").each((_3, node) => {
|
|
64053
|
-
var _a22, _b, _c2, _d, _e2
|
|
64151
|
+
var _a22, _b, _c2, _d, _e2;
|
|
64054
64152
|
const table = $3(node);
|
|
64055
64153
|
const props = parseInlineStyle(table.attr("style") || "");
|
|
64056
64154
|
const box2 = ((_a22 = props.get("margin")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
|
|
64057
|
-
const
|
|
64058
|
-
const
|
|
64059
|
-
|
|
64060
|
-
const
|
|
64061
|
-
|
|
64062
|
-
|
|
64063
|
-
|
|
64064
|
-
|
|
64065
|
-
|
|
64066
|
-
|
|
64067
|
-
|
|
64068
|
-
$3(cell).attr("style"
|
|
64069
|
-
|
|
64070
|
-
|
|
64071
|
-
|
|
64072
|
-
|
|
64073
|
-
|
|
64155
|
+
const centred = /center/i.test((_b = table.attr("align")) != null ? _b : "");
|
|
64156
|
+
const margins = verticalMargins(props);
|
|
64157
|
+
const top = centred ? 0 : (_c2 = margins.top) != null ? _c2 : 0;
|
|
64158
|
+
const bottom = centred ? 0 : (_d = margins.bottom) != null ? _d : 0;
|
|
64159
|
+
table.find("> tr, > tbody > tr").each((_22, row) => {
|
|
64160
|
+
var _a32, _b2, _c22, _d2, _e22, _f, _g;
|
|
64161
|
+
const cells = $3(row).children("td, th").toArray();
|
|
64162
|
+
const bare = cells.filter(holdsBareText);
|
|
64163
|
+
if (!bare.length) return;
|
|
64164
|
+
for (const cell of cells) {
|
|
64165
|
+
const mine = bare.includes(cell) ? verticalMargins(new Map([...(_a32 = sheetMargins.get(cell)) != null ? _a32 : [], ...parseInlineStyle($3(cell).attr("style") || "")])) : { top: void 0, bottom: void 0 };
|
|
64166
|
+
const style = parseInlineStyle($3(cell).attr("style") || "");
|
|
64167
|
+
const pad = ((_b2 = style.get("padding")) != null ? _b2 : "").trim().split(/\s+/).filter(Boolean);
|
|
64168
|
+
for (const [side, by2] of [["top", (_c22 = mine.top) != null ? _c22 : top], ["bottom", (_d2 = mine.bottom) != null ? _d2 : bottom]]) {
|
|
64169
|
+
if (by2 <= 0) continue;
|
|
64170
|
+
const was = Number.parseFloat((_g = (_f = style.get(`padding-${side}`)) != null ? _f : side === "top" ? pad[0] : (_e22 = pad[2]) != null ? _e22 : pad[0]) != null ? _g : "") || 0;
|
|
64171
|
+
style.set(`padding-${side}`, `${was + by2}px`);
|
|
64172
|
+
}
|
|
64173
|
+
$3(cell).attr("style", serializeStyle(style));
|
|
64174
|
+
}
|
|
64175
|
+
});
|
|
64176
|
+
if (top <= 0 && bottom <= 0 || centred) return;
|
|
64074
64177
|
props.delete("margin-top");
|
|
64075
64178
|
props.delete("margin-bottom");
|
|
64076
64179
|
if (box2.length) {
|
|
64077
64180
|
props.delete("margin");
|
|
64078
|
-
if (box2[1]) props.set("margin-left", (
|
|
64181
|
+
if (box2[1]) props.set("margin-left", (_e2 = box2[3]) != null ? _e2 : box2[1]);
|
|
64079
64182
|
if (box2[1]) props.set("margin-right", box2[1]);
|
|
64080
64183
|
}
|
|
64081
64184
|
table.attr("style", serializeStyle(props));
|
|
64082
64185
|
});
|
|
64186
|
+
$3("tr").each((_3, row) => {
|
|
64187
|
+
const cells = $3(row).children("td, th").toArray();
|
|
64188
|
+
if (cells.length < 2) return;
|
|
64189
|
+
const sides = cells.map((cell) => {
|
|
64190
|
+
var _a22, _b, _c2, _d;
|
|
64191
|
+
const style = parseInlineStyle($3(cell).attr("style") || "");
|
|
64192
|
+
const pad = ((_a22 = style.get("padding")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
|
|
64193
|
+
const read = (v) => Number.parseFloat(v != null ? v : "") || 0;
|
|
64194
|
+
return { style, top: read((_b = style.get("padding-top")) != null ? _b : pad[0]), bottom: read((_d = (_c2 = style.get("padding-bottom")) != null ? _c2 : pad[2]) != null ? _d : pad[0]) };
|
|
64195
|
+
});
|
|
64196
|
+
const top = Math.max(...sides.map((s2) => s2.top));
|
|
64197
|
+
const bottom = Math.max(...sides.map((s2) => s2.bottom));
|
|
64198
|
+
cells.forEach((cell, i2) => {
|
|
64199
|
+
const { style } = sides[i2];
|
|
64200
|
+
if (sides[i2].top < top) style.set("padding-top", `${top}px`);
|
|
64201
|
+
if (sides[i2].bottom < bottom) style.set("padding-bottom", `${bottom}px`);
|
|
64202
|
+
if (sides[i2].top < top || sides[i2].bottom < bottom) $3(cell).attr("style", serializeStyle(style));
|
|
64203
|
+
});
|
|
64204
|
+
});
|
|
64083
64205
|
$3("table").each((_3, node) => {
|
|
64084
64206
|
var _a22, _b;
|
|
64085
64207
|
const props = parseInlineStyle($3(node).attr("style") || "");
|
|
@@ -64136,10 +64258,84 @@ function applyWordBoxModel($3) {
|
|
|
64136
64258
|
const after2 = serializeStyle(props);
|
|
64137
64259
|
if (after2) p.attr("style", after2);
|
|
64138
64260
|
});
|
|
64139
|
-
|
|
64261
|
+
$3("span, a, strong, b, em, i, u, font").each((_3, node) => {
|
|
64262
|
+
var _a22, _b, _c2;
|
|
64263
|
+
const el2 = node;
|
|
64264
|
+
const props = parseInlineStyle($3(el2).attr("style") || "");
|
|
64265
|
+
if (/block/i.test((_a22 = props.get("display")) != null ? _a22 : "")) return;
|
|
64266
|
+
const spacing = $3(el2).parents().toArray().map(spacingOf).find((st2) => st2.has("line-height"));
|
|
64267
|
+
if (!/^[\d.]+px$/i.test((_b = spacing == null ? void 0 : spacing.get("line-height")) != null ? _b : "") || /exactly/i.test((_c2 = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _c2 : "")) return;
|
|
64268
|
+
props.set("line-height", "normal");
|
|
64269
|
+
$3(el2).attr("style", serializeStyle(props));
|
|
64270
|
+
});
|
|
64271
|
+
const inherited2 = (el2, prop2) => [el2, ...$3(el2).parents().toArray()].map(spacingOf).find((st2) => st2.has(prop2));
|
|
64272
|
+
const sizeOf = (el2) => {
|
|
64273
|
+
var _a22, _b, _c2;
|
|
64274
|
+
const sized = [el2, ...$3(el2).parents().toArray()].map(spacingOf).find((st2) => {
|
|
64275
|
+
var _a32;
|
|
64276
|
+
return st2.has("font-size") || /\d(?:\.\d+)?px/.test((_a32 = st2.get("font")) != null ? _a32 : "");
|
|
64277
|
+
});
|
|
64278
|
+
const px2 = (_c2 = /^([\d.]+)px$/i.exec((_a22 = sized == null ? void 0 : sized.get("font-size")) != null ? _a22 : "")) != null ? _c2 : /(?:^|\s)([\d.]+)px/.exec((_b = sized == null ? void 0 : sized.get("font")) != null ? _b : "");
|
|
64279
|
+
return px2 ? Number(px2[1]) : void 0;
|
|
64280
|
+
};
|
|
64281
|
+
$3("p, div, h1, h2, h3, h4, h5, h6, li, td, th").each((_3, node) => {
|
|
64282
|
+
var _a22, _b, _c2, _d;
|
|
64283
|
+
const el2 = node;
|
|
64284
|
+
const block = $3(el2);
|
|
64285
|
+
if (block.find("p, div, h1, h2, h3, h4, h5, h6, li, table, ul, ol").length || !/[^\s ]/.test(block.text())) return;
|
|
64286
|
+
const own = parseInlineStyle(block.attr("style") || "");
|
|
64287
|
+
if (hasBorder(own)) return;
|
|
64288
|
+
const mine = spacingOf(el2);
|
|
64289
|
+
const spacing = inherited2(el2, "line-height");
|
|
64290
|
+
const line = /^([\d.]+)px$/i.exec((_a22 = spacing == null ? void 0 : spacing.get("line-height")) != null ? _a22 : "");
|
|
64291
|
+
const size = sizeOf(el2);
|
|
64292
|
+
if (!line || !size) return;
|
|
64293
|
+
let largest = size;
|
|
64294
|
+
block.find("*").each((_22, inner) => {
|
|
64295
|
+
var _a32;
|
|
64296
|
+
const px2 = /^([\d.]+)px$/i.exec((_a32 = spacingOf(inner).get("font-size")) != null ? _a32 : "");
|
|
64297
|
+
if (px2) largest = Math.max(largest, Number(px2[1]));
|
|
64298
|
+
});
|
|
64299
|
+
const exactly = /exactly/i.test((_b = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _b : "");
|
|
64300
|
+
const natural = naturalHeight(size, (_c2 = inherited2(el2, "font-family")) == null ? void 0 : _c2.get("font-family"));
|
|
64301
|
+
if (!exactly && largest === size && Number(line[1]) < natural) {
|
|
64302
|
+
own.set("line-height", `${natural}px`);
|
|
64303
|
+
block.attr("style", serializeStyle(own));
|
|
64304
|
+
return;
|
|
64305
|
+
}
|
|
64306
|
+
const leading = Math.round((Number(line[1]) - largest * NATURAL_LINE) * 10) / 10;
|
|
64307
|
+
const shift = Math.round(leading * (exactly ? 0.3 : 0.5) * 10) / 10;
|
|
64308
|
+
if (shift <= 0) return;
|
|
64309
|
+
block.wrapInner(
|
|
64310
|
+
exactly ? `<span style="position:relative;top:${shift}px"></span>` : `<span style="vertical-align:bottom;line-height:normal"></span>`
|
|
64311
|
+
);
|
|
64312
|
+
const tag = el2.tagName.toLowerCase();
|
|
64313
|
+
const fill = (_d = mine.get("background-color")) != null ? _d : mine.get("background");
|
|
64314
|
+
if (exactly || tag === "td" || tag === "th" || !fill || /\(|\s/.test(fill.trim())) return;
|
|
64315
|
+
own.delete("background-color");
|
|
64316
|
+
own.set("background", `linear-gradient(transparent ${leading}px, ${fill.trim()} ${leading}px)`);
|
|
64317
|
+
block.attr("style", serializeStyle(own));
|
|
64318
|
+
});
|
|
64319
|
+
$3("body *").each((_3, node) => {
|
|
64320
|
+
var _a22, _b;
|
|
64321
|
+
const el2 = node;
|
|
64322
|
+
if (!$3(el2).contents().toArray().some((n2) => n2.type === "text" && /[^\s ]/.test(n2.data))) return;
|
|
64323
|
+
const family = (_b = (_a22 = inherited2(el2, "font-family")) == null ? void 0 : _a22.get("font-family")) != null ? _b : "";
|
|
64324
|
+
const size = sizeOf(el2);
|
|
64325
|
+
if (!isGill(family) || size === void 0) return;
|
|
64326
|
+
const block = $3(el2).closest("p, div, li, td, th, h1, h2, h3, h4, h5, h6").get(0);
|
|
64327
|
+
const blockSize = block && block !== el2 ? sizeOf(block) : void 0;
|
|
64328
|
+
const large = family.trim().startsWith(GILL_LARGE);
|
|
64329
|
+
if (large === (size > 22 || blockSize !== void 0 && size > blockSize)) return;
|
|
64330
|
+
const props = parseInlineStyle($3(el2).attr("style") || "");
|
|
64331
|
+
const stack = family.replace(new RegExp(String.raw`^\s*${GILL_LARGE},\s*`), "");
|
|
64332
|
+
props.set("font-family", large ? stack : `${GILL_LARGE}, ${stack}`);
|
|
64333
|
+
$3(el2).attr("style", serializeStyle(props));
|
|
64334
|
+
});
|
|
64335
|
+
const reset = "<style>h2{margin:0}p{margin:14pt 0}td,th{box-sizing:border-box}</style>";
|
|
64140
64336
|
const head = $3("head");
|
|
64141
64337
|
if (head.length) head.prepend(reset);
|
|
64142
|
-
else if ($3("p,h2").length) $3.root().prepend(reset);
|
|
64338
|
+
else if ($3("p,h2,td,th").length) $3.root().prepend(reset);
|
|
64143
64339
|
}
|
|
64144
64340
|
var MAX_HTML_SIZE = 2 * 1024 * 1024;
|
|
64145
64341
|
var MAX_WARNING_LOCATIONS = 100;
|
|
@@ -66616,7 +66812,7 @@ function simulateDarkMode(html3, clientId) {
|
|
|
66616
66812
|
}
|
|
66617
66813
|
break;
|
|
66618
66814
|
case "outlook-windows-legacy":
|
|
66619
|
-
applyColorInversion($3, "
|
|
66815
|
+
applyColorInversion($3, "outlook-classic", clientId);
|
|
66620
66816
|
if (!html3.includes("prefers-color-scheme")) {
|
|
66621
66817
|
warnings.push({
|
|
66622
66818
|
severity: "info",
|
|
@@ -66698,7 +66894,9 @@ function simulateDarkMode(html3, clientId) {
|
|
|
66698
66894
|
return { html: $3.html(), warnings };
|
|
66699
66895
|
}
|
|
66700
66896
|
var MEASURED_CANVAS = {
|
|
66701
|
-
"outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" }
|
|
66897
|
+
"outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" },
|
|
66898
|
+
// ponytail: fg unmeasured; Word's automatic text is black, which maps here.
|
|
66899
|
+
"outlook-windows-legacy": { bg: "#262626", fg: "#f6f6f6" }
|
|
66702
66900
|
};
|
|
66703
66901
|
var SAMPLED_DARK = {
|
|
66704
66902
|
"outlook-web": { eeeae4: "#595651" },
|
|
@@ -66755,6 +66953,53 @@ function outlookMacColor(value, role) {
|
|
|
66755
66953
|
if (c2.r === c2.g && c2.g === c2.b) return withLabLightness(c2, (l2) => Math.min(l2, 88.5 - 0.772 * l2), D65);
|
|
66756
66954
|
return withLabLightness(c2, () => 34.6, D65);
|
|
66757
66955
|
}
|
|
66956
|
+
var WORD_DARK_GREYS = [
|
|
66957
|
+
[0, 246],
|
|
66958
|
+
[15, 233],
|
|
66959
|
+
[30, 225],
|
|
66960
|
+
[45, 216],
|
|
66961
|
+
[60, 206],
|
|
66962
|
+
[75, 196],
|
|
66963
|
+
[90, 185],
|
|
66964
|
+
[105, 174],
|
|
66965
|
+
[120, 163],
|
|
66966
|
+
[135, 151],
|
|
66967
|
+
[150, 139],
|
|
66968
|
+
[165, 126],
|
|
66969
|
+
[180, 113],
|
|
66970
|
+
[195, 99],
|
|
66971
|
+
[210, 85],
|
|
66972
|
+
[225, 70],
|
|
66973
|
+
[240, 55],
|
|
66974
|
+
[255, 38]
|
|
66975
|
+
];
|
|
66976
|
+
var greyL = (v) => {
|
|
66977
|
+
const s2 = v / 255;
|
|
66978
|
+
return 116 * labF(s2 <= 0.04045 ? s2 / 12.92 : ((s2 + 0.055) / 1.055) ** 2.4) - 16;
|
|
66979
|
+
};
|
|
66980
|
+
var WORD_DARK_L = WORD_DARK_GREYS.map(([from, to2]) => [greyL(from), greyL(to2)]);
|
|
66981
|
+
var wordDarkL = (l2) => {
|
|
66982
|
+
const i2 = Math.max(1, WORD_DARK_L.findIndex(([x2]) => x2 >= Math.min(l2, 100)));
|
|
66983
|
+
const [[x0, y0], [x1, y1]] = [WORD_DARK_L[i2 - 1], WORD_DARK_L[i2]];
|
|
66984
|
+
return y0 + (y1 - y0) * (l2 - x0) / (x1 - x0);
|
|
66985
|
+
};
|
|
66986
|
+
function outlookClassicColor(value) {
|
|
66987
|
+
const c2 = parseColor(value);
|
|
66988
|
+
if (!c2 || c2.a === 0) return null;
|
|
66989
|
+
const linear = [c2.r, c2.g, c2.b].map((v) => {
|
|
66990
|
+
const s2 = v / 255;
|
|
66991
|
+
return s2 <= 0.04045 ? s2 / 12.92 : ((s2 + 0.055) / 1.055) ** 2.4;
|
|
66992
|
+
});
|
|
66993
|
+
const y3 = 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2];
|
|
66994
|
+
const l2 = 116 * labF(y3) - 16;
|
|
66995
|
+
const out = labFInv((wordDarkL(l2) + 16) / 116);
|
|
66996
|
+
const k2 = y3 > 0 ? Math.sqrt(out / y3) : 1;
|
|
66997
|
+
const [r2, g3, b2] = linear.map((v) => {
|
|
66998
|
+
const t2 = Math.min(1, Math.max(0, out + k2 * (v - y3)));
|
|
66999
|
+
return Math.round(255 * (t2 <= 31308e-7 ? 12.92 * t2 : 1.055 * t2 ** (1 / 2.4) - 0.055));
|
|
67000
|
+
});
|
|
67001
|
+
return hex({ r: r2, g: g3, b: b2 });
|
|
67002
|
+
}
|
|
66758
67003
|
function gmailAndroidColor(value, role) {
|
|
66759
67004
|
const parsed = parseColor(value);
|
|
66760
67005
|
if (!parsed || parsed.a === 0) return null;
|
|
@@ -66767,6 +67012,7 @@ function invertColor(value, mode, clientId, role = "bg") {
|
|
|
66767
67012
|
var _a22;
|
|
66768
67013
|
if (mode === "gmail-android") return gmailAndroidColor(value, role);
|
|
66769
67014
|
if (mode === "outlook-macos") return outlookMacColor(value, role);
|
|
67015
|
+
if (mode === "outlook-classic") return outlookClassicColor(value);
|
|
66770
67016
|
const pinned = clientId && ((_a22 = SAMPLED_DARK[clientId]) == null ? void 0 : _a22[value.trim().replace("#", "").toLowerCase()]);
|
|
66771
67017
|
if (pinned) return pinned;
|
|
66772
67018
|
const parsed = parseColor(value);
|
|
@@ -66808,12 +67054,25 @@ function extractBackgroundColor(value) {
|
|
|
66808
67054
|
}
|
|
66809
67055
|
return null;
|
|
66810
67056
|
}
|
|
67057
|
+
var BORDER_SHORTHAND = /^border(-(top|right|bottom|left))?$/;
|
|
67058
|
+
function invertBorder(value, mode, clientId) {
|
|
67059
|
+
let changed = false;
|
|
67060
|
+
const next2 = value.replace(/#[0-9a-f]{3,8}(?![0-9a-z])|rgba?\([^)]*\)/gi, (token) => {
|
|
67061
|
+
const inverted = invertColor(token, mode, clientId);
|
|
67062
|
+
if (!inverted) return token;
|
|
67063
|
+
changed = true;
|
|
67064
|
+
return inverted;
|
|
67065
|
+
});
|
|
67066
|
+
return changed ? next2 : null;
|
|
67067
|
+
}
|
|
66811
67068
|
function applyColorInversion($3, mode, clientId) {
|
|
66812
67069
|
$3("[style]").each((_3, el2) => {
|
|
66813
67070
|
const style = $3(el2).attr("style") || "";
|
|
66814
67071
|
const props = parseInlineStyle(style);
|
|
66815
67072
|
let changed = false;
|
|
67073
|
+
const keepFill = mode === "outlook-classic" && $3(el2).is("[data-vml]");
|
|
66816
67074
|
props.forEach((value, prop2) => {
|
|
67075
|
+
if (keepFill && prop2 !== "color") return;
|
|
66817
67076
|
if (COLOR_PROPS.has(prop2)) {
|
|
66818
67077
|
const inverted = invertColor(value, mode, clientId, prop2 === "color" ? "fg" : "bg");
|
|
66819
67078
|
if (inverted) {
|
|
@@ -66821,6 +67080,13 @@ function applyColorInversion($3, mode, clientId) {
|
|
|
66821
67080
|
changed = true;
|
|
66822
67081
|
}
|
|
66823
67082
|
}
|
|
67083
|
+
if (BORDER_SHORTHAND.test(prop2)) {
|
|
67084
|
+
const inverted = invertBorder(value, mode, clientId);
|
|
67085
|
+
if (inverted) {
|
|
67086
|
+
props.set(prop2, inverted);
|
|
67087
|
+
changed = true;
|
|
67088
|
+
}
|
|
67089
|
+
}
|
|
66824
67090
|
if (prop2 === "background") {
|
|
66825
67091
|
const bgColor = extractBackgroundColor(value);
|
|
66826
67092
|
if (bgColor) {
|
|
@@ -66845,9 +67111,16 @@ function applyColorInversion($3, mode, clientId) {
|
|
|
66845
67111
|
enter(node) {
|
|
66846
67112
|
if (node.type !== "Declaration") return;
|
|
66847
67113
|
const prop2 = node.property.toLowerCase();
|
|
66848
|
-
|
|
67114
|
+
const border = BORDER_SHORTHAND.test(prop2);
|
|
67115
|
+
if (!COLOR_PROPS.has(prop2) && prop2 !== "background" && !border) return;
|
|
66849
67116
|
const valueStr = hy(node.value);
|
|
66850
|
-
if (
|
|
67117
|
+
if (border) {
|
|
67118
|
+
const inverted = invertBorder(valueStr, mode, clientId);
|
|
67119
|
+
if (inverted) {
|
|
67120
|
+
node.value = py(inverted, { context: "value" });
|
|
67121
|
+
modified = true;
|
|
67122
|
+
}
|
|
67123
|
+
} else if (prop2 === "background") {
|
|
66851
67124
|
const bgColor = extractBackgroundColor(valueStr);
|
|
66852
67125
|
if (bgColor) {
|
|
66853
67126
|
const inverted = invertColor(bgColor, mode, clientId);
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
simulateDarkMode,
|
|
33
33
|
toFramework,
|
|
34
34
|
transformForAllClients
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-Y3WSDM76.js";
|
|
36
36
|
import "./chunk-ABDTBRVK.js";
|
|
37
37
|
import "./chunk-2AP7CT6R.js";
|
|
38
38
|
import "./chunk-NXBRJX3V.js";
|
|
@@ -33468,27 +33468,28 @@ h1 {
|
|
|
33468
33468
|
out = out.replace(
|
|
33469
33469
|
/<v:roundrect([^>]*)>([\s\S]*?)<\/v:roundrect>/gi,
|
|
33470
33470
|
(_m, rawAttrs, inner) => {
|
|
33471
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
33471
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
33472
33472
|
const a = attrs(rawAttrs);
|
|
33473
33473
|
const s = styleProps((_a2 = a.style) != null ? _a2 : "");
|
|
33474
|
-
const
|
|
33475
|
-
const
|
|
33476
|
-
const
|
|
33474
|
+
const auto = /^auto$/i.test((_c = (_b = s.width) == null ? void 0 : _b.trim()) != null ? _c : "");
|
|
33475
|
+
const w = auto ? 64 : (_d = px(s.width)) != null ? _d : 0;
|
|
33476
|
+
const h = (_e = px(s.height)) != null ? _e : 0;
|
|
33477
|
+
const radius = arcsizeToRadius((_f = a.arcsize) != null ? _f : "20%", w, h);
|
|
33477
33478
|
const fillTag = inner.match(/<v:fill([^>]*?)\/?>/i);
|
|
33478
33479
|
const f = fillTag ? attrs(fillTag[1]) : {};
|
|
33479
33480
|
const imageData = inner.match(/<v:imagedata([^>]*?)\/?>/i);
|
|
33480
33481
|
const imageSrc = imageData ? attrs(imageData[1]).src : void 0;
|
|
33481
|
-
const fill = (
|
|
33482
|
+
const fill = (_h = (_g = f.color) != null ? _g : a.fillcolor) != null ? _h : "transparent";
|
|
33482
33483
|
const image = imageSrc ? `;background-image:url('${imageSrc}');background-size:100% 100%;background-repeat:no-repeat` : "";
|
|
33483
33484
|
const stroked = !(a.stroke === "f" || a.stroke === "false");
|
|
33484
|
-
const middle = /middle/i.test((
|
|
33485
|
-
const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim();
|
|
33485
|
+
const middle = /middle/i.test((_i = s["v-text-anchor"]) != null ? _i : "");
|
|
33486
|
+
const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim().replace(/^<span(?: style="([^"]*)")?/i, (tag, style) => auto ? `<span style="display:block;max-height:1lh;overflow:hidden;padding:0 9.6px;${style != null ? style : ""}"` : tag);
|
|
33486
33487
|
const box = [
|
|
33487
33488
|
w ? `width:${w}px` : "",
|
|
33488
33489
|
h ? `height:${h}px` : "",
|
|
33489
33490
|
`border-radius:${radius}px`,
|
|
33490
33491
|
`background:${fill}${image}`,
|
|
33491
|
-
stroked ? `border:1px solid ${(
|
|
33492
|
+
stroked ? `border:1px solid ${(_j = a.strokecolor) != null ? _j : "#000"}` : "border:none",
|
|
33492
33493
|
"display:inline-flex",
|
|
33493
33494
|
"justify-content:center",
|
|
33494
33495
|
`align-items:${middle ? "center" : "flex-start"}`,
|
|
@@ -33663,6 +33664,14 @@ h1 {
|
|
|
33663
33664
|
"border-left-width"
|
|
33664
33665
|
];
|
|
33665
33666
|
var NATURAL_LINE = 1.15;
|
|
33667
|
+
var GILL_VDMX = [14, 14, 15, 16, 18, 18, 21, 21, 23, 25, 27, 27, 29, 30, 31];
|
|
33668
|
+
var isGill = (family = "") => /^\s*['"]?gill sans/i.test(family);
|
|
33669
|
+
var naturalHeight = (size, family = "") => {
|
|
33670
|
+
if (!isGill(family)) return Math.round(size * NATURAL_LINE);
|
|
33671
|
+
const ppem = Math.round(size);
|
|
33672
|
+
return ppem <= 22 ? GILL_VDMX[Math.max(ppem, 8) - 8] : Math.ceil(0.9292 * size) + Math.ceil(0.2305 * size);
|
|
33673
|
+
};
|
|
33674
|
+
var GILL_LARGE = "'Gill Sans MT Large'";
|
|
33666
33675
|
var TABLE_GUTTER = 3.5;
|
|
33667
33676
|
var INVISIBLE_ONLY = /^[\s\u00a0\u00ad\u034f\u200b-\u200d\u2007\ufeff]+$/;
|
|
33668
33677
|
var LIST_TRAILING_PX = 18;
|
|
@@ -33823,8 +33832,27 @@ h1 {
|
|
|
33823
33832
|
);
|
|
33824
33833
|
}
|
|
33825
33834
|
function prepareWordSource(html) {
|
|
33826
|
-
return markHiddenCells(dropWordUnknownColors(html));
|
|
33827
|
-
}
|
|
33835
|
+
return wordSubstitutes(markHiddenCells(dropWordUnknownColors(html)));
|
|
33836
|
+
}
|
|
33837
|
+
var WORD_SUBSTITUTES = { rubik: "Calibri" };
|
|
33838
|
+
var SUBSTITUTED = new RegExp(String.raw`(font(?:-family)?\s*:[^;"}]*?)(['"]?)\b(${Object.keys(WORD_SUBSTITUTES).join("|")})\b\2`, "gi");
|
|
33839
|
+
var wordSubstitutes = (html) => html.replace(SUBSTITUTED, (_, lead, _q, name) => `${lead}${WORD_SUBSTITUTES[name.toLowerCase()]}`);
|
|
33840
|
+
var OFFICE_CLOUD_FONTS = [
|
|
33841
|
+
"Work Sans",
|
|
33842
|
+
"Lato",
|
|
33843
|
+
"Montserrat",
|
|
33844
|
+
"Nunito",
|
|
33845
|
+
"Nunito Sans",
|
|
33846
|
+
"Open Sans",
|
|
33847
|
+
"DM Sans",
|
|
33848
|
+
"IBM Plex Sans",
|
|
33849
|
+
"Ubuntu",
|
|
33850
|
+
"Source Code Pro",
|
|
33851
|
+
"Raleway",
|
|
33852
|
+
"Playfair Display",
|
|
33853
|
+
"Poppins"
|
|
33854
|
+
];
|
|
33855
|
+
var CLOUD = new Set(OFFICE_CLOUD_FONTS.map((f) => f.toLowerCase()));
|
|
33828
33856
|
function declaredFaces($) {
|
|
33829
33857
|
const faces = /* @__PURE__ */ new Map();
|
|
33830
33858
|
$("style").each((_, block) => {
|
|
@@ -33834,7 +33862,7 @@ h1 {
|
|
|
33834
33862
|
const family = props.get("font-family");
|
|
33835
33863
|
const named = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
|
|
33836
33864
|
const alt = named && /^sans-serif$/i.test(named) ? WORD_DEFAULT : named;
|
|
33837
|
-
if (family) faces.set(firstFamily(family), (_c = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c : null);
|
|
33865
|
+
if (family && !CLOUD.has(firstFamily(family))) faces.set(firstFamily(family), (_c = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c : null);
|
|
33838
33866
|
}
|
|
33839
33867
|
});
|
|
33840
33868
|
return faces;
|
|
@@ -33866,8 +33894,36 @@ h1 {
|
|
|
33866
33894
|
const value = parts.length === 4 ? parts[3] : parts.length >= 2 ? parts[1] : parts[0];
|
|
33867
33895
|
return /^\d+(?:\.\d+)?(?:px)?$/.test(value != null ? value : "") ? parseFloat(value) : 0;
|
|
33868
33896
|
}
|
|
33897
|
+
var SPACING = /^(?:line-height|mso-line-height-rule|mso-line-height-alt|font-size|font|font-family|background|background-color)$/;
|
|
33898
|
+
function sheetSpacing($) {
|
|
33899
|
+
const found = /* @__PURE__ */ new Map();
|
|
33900
|
+
$("style").each((_, block) => {
|
|
33901
|
+
var _a2, _b;
|
|
33902
|
+
for (const { selector, body } of topLevelRules((_a2 = $(block).html()) != null ? _a2 : "")) {
|
|
33903
|
+
const rule = [...parseInlineStyle(body.replace(/!important/gi, ""))].filter(([k]) => SPACING.test(k));
|
|
33904
|
+
if (!rule.length) continue;
|
|
33905
|
+
for (const one of selector.split(",")) {
|
|
33906
|
+
for (const el of matchedByWord($, one)) {
|
|
33907
|
+
const has = (_b = found.get(el)) != null ? _b : /* @__PURE__ */ new Map();
|
|
33908
|
+
for (const [k, v] of rule) has.set(k, v);
|
|
33909
|
+
found.set(el, has);
|
|
33910
|
+
}
|
|
33911
|
+
}
|
|
33912
|
+
}
|
|
33913
|
+
});
|
|
33914
|
+
return found;
|
|
33915
|
+
}
|
|
33869
33916
|
function applyWordBoxModel($) {
|
|
33870
33917
|
const faces = declaredFaces($);
|
|
33918
|
+
const sheet = sheetSpacing($);
|
|
33919
|
+
const spacingOf = (el) => {
|
|
33920
|
+
var _a2, _b;
|
|
33921
|
+
const all = new Map([...(_a2 = sheet.get(el)) != null ? _a2 : [], ...parseInlineStyle($(el).attr("style") || "")]);
|
|
33922
|
+
const alt = (_b = all.get("mso-line-height-alt")) == null ? void 0 : _b.trim();
|
|
33923
|
+
const altEm = /^([\d.]+)em$/i.exec(alt != null ? alt : "");
|
|
33924
|
+
if (alt) all.set("line-height", altEm ? `${Number(altEm[1]) * 16}px` : alt);
|
|
33925
|
+
return all;
|
|
33926
|
+
};
|
|
33871
33927
|
$("[style]").each((_, node) => {
|
|
33872
33928
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
33873
33929
|
const el = node;
|
|
@@ -33927,7 +33983,7 @@ h1 {
|
|
|
33927
33983
|
const lineHeight = /^([\d.]+)px$/i.exec((_k = props.get("line-height")) != null ? _k : "");
|
|
33928
33984
|
const fontSize = /^([\d.]+)px$/i.exec((_l = props.get("font-size")) != null ? _l : "");
|
|
33929
33985
|
if (lineHeight && fontSize && !/exactly/i.test((_m = props.get("mso-line-height-rule")) != null ? _m : "")) {
|
|
33930
|
-
const natural =
|
|
33986
|
+
const natural = naturalHeight(Number(fontSize[1]), props.get("font-family"));
|
|
33931
33987
|
if (Number(lineHeight[1]) < natural) props.set("line-height", `${natural}px`);
|
|
33932
33988
|
}
|
|
33933
33989
|
for (const prop of ["word-spacing", "outline", "outline-width", "outline-style", "outline-color", "outline-offset"]) {
|
|
@@ -33965,6 +34021,18 @@ h1 {
|
|
|
33965
34021
|
props.set("line-height", "0");
|
|
33966
34022
|
cell.empty().attr("style", serializeStyle(props));
|
|
33967
34023
|
});
|
|
34024
|
+
$("p").each((_, node) => {
|
|
34025
|
+
if (!$(node).children().length && !/[^ \t\r\n]/.test($(node).text())) $(node).remove();
|
|
34026
|
+
});
|
|
34027
|
+
$("img").each((_, node) => {
|
|
34028
|
+
var _a2, _b;
|
|
34029
|
+
const img = $(node);
|
|
34030
|
+
const props = parseInlineStyle(img.attr("style") || "");
|
|
34031
|
+
const height = Number.parseFloat((_b = (_a2 = props.get("height")) != null ? _a2 : img.attr("height")) != null ? _b : "");
|
|
34032
|
+
if (img.closest("td, th").length || !(height <= 1)) return;
|
|
34033
|
+
props.set("display", "block");
|
|
34034
|
+
img.attr("style", serializeStyle(props));
|
|
34035
|
+
});
|
|
33968
34036
|
$("hr").each((_, node) => {
|
|
33969
34037
|
var _a2, _b, _c;
|
|
33970
34038
|
const props = parseInlineStyle($(node).attr("style") || "");
|
|
@@ -33980,7 +34048,7 @@ h1 {
|
|
|
33980
34048
|
$(node).attr("style", serializeStyle(set));
|
|
33981
34049
|
});
|
|
33982
34050
|
$("a").each((_, node) => {
|
|
33983
|
-
if (!$(node).children("div").length) return;
|
|
34051
|
+
if (!$(node).children("div, p").length) return;
|
|
33984
34052
|
$(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
|
|
33985
34053
|
});
|
|
33986
34054
|
$("a[style*='text-decoration-line']").each((_, node) => {
|
|
@@ -34087,37 +34155,91 @@ h1 {
|
|
|
34087
34155
|
})) return;
|
|
34088
34156
|
cell.attr("style", `${style}${style.trim() === "" || /;\s*$/.test(style) ? "" : ";"}text-align:left`);
|
|
34089
34157
|
});
|
|
34158
|
+
const sheetMargins = /* @__PURE__ */ new Map();
|
|
34159
|
+
$("style").each((_, block) => {
|
|
34160
|
+
var _a2, _b;
|
|
34161
|
+
for (const { selector, body } of topLevelRules((_a2 = $(block).html()) != null ? _a2 : "")) {
|
|
34162
|
+
if (!/margin/i.test(body)) continue;
|
|
34163
|
+
let cells = [];
|
|
34164
|
+
try {
|
|
34165
|
+
cells = $(selector).filter("td, th").toArray();
|
|
34166
|
+
} catch (e) {
|
|
34167
|
+
continue;
|
|
34168
|
+
}
|
|
34169
|
+
const rule = parseInlineStyle(body.replace(/!important/gi, ""));
|
|
34170
|
+
for (const cell of cells) {
|
|
34171
|
+
const has = (_b = sheetMargins.get(cell)) != null ? _b : /* @__PURE__ */ new Map();
|
|
34172
|
+
for (const [k, v] of rule) if (/^margin(?:-top|-bottom)?$/.test(k)) has.set(k, v);
|
|
34173
|
+
sheetMargins.set(cell, has);
|
|
34174
|
+
}
|
|
34175
|
+
}
|
|
34176
|
+
});
|
|
34177
|
+
const verticalMargins = (props) => {
|
|
34178
|
+
var _a2, _b, _c, _d;
|
|
34179
|
+
const box = ((_a2 = props.get("margin")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
|
|
34180
|
+
const read = (v) => v === void 0 ? void 0 : Number.parseFloat(v) || 0;
|
|
34181
|
+
return { top: read((_b = props.get("margin-top")) != null ? _b : box[0]), bottom: read((_d = (_c = props.get("margin-bottom")) != null ? _c : box[2]) != null ? _d : box[0]) };
|
|
34182
|
+
};
|
|
34183
|
+
const holdsBareText = (cell) => {
|
|
34184
|
+
const inline = $(cell).clone();
|
|
34185
|
+
inline.find("table, div, p, ul, ol, h1, h2, h3, h4, h5, h6").remove();
|
|
34186
|
+
return /[^\s ]/.test(inline.text());
|
|
34187
|
+
};
|
|
34090
34188
|
$("table").each((_, node) => {
|
|
34091
|
-
var _a2, _b, _c, _d, _e
|
|
34189
|
+
var _a2, _b, _c, _d, _e;
|
|
34092
34190
|
const table = $(node);
|
|
34093
34191
|
const props = parseInlineStyle(table.attr("style") || "");
|
|
34094
34192
|
const box = ((_a2 = props.get("margin")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
|
|
34095
|
-
const
|
|
34096
|
-
const
|
|
34097
|
-
|
|
34098
|
-
const
|
|
34099
|
-
|
|
34100
|
-
|
|
34101
|
-
|
|
34102
|
-
|
|
34103
|
-
|
|
34104
|
-
|
|
34105
|
-
|
|
34106
|
-
$(cell).attr("style"
|
|
34107
|
-
|
|
34108
|
-
|
|
34109
|
-
|
|
34110
|
-
|
|
34111
|
-
|
|
34193
|
+
const centred = /center/i.test((_b = table.attr("align")) != null ? _b : "");
|
|
34194
|
+
const margins = verticalMargins(props);
|
|
34195
|
+
const top = centred ? 0 : (_c = margins.top) != null ? _c : 0;
|
|
34196
|
+
const bottom = centred ? 0 : (_d = margins.bottom) != null ? _d : 0;
|
|
34197
|
+
table.find("> tr, > tbody > tr").each((_2, row) => {
|
|
34198
|
+
var _a3, _b2, _c2, _d2, _e2, _f, _g;
|
|
34199
|
+
const cells = $(row).children("td, th").toArray();
|
|
34200
|
+
const bare = cells.filter(holdsBareText);
|
|
34201
|
+
if (!bare.length) return;
|
|
34202
|
+
for (const cell of cells) {
|
|
34203
|
+
const mine = bare.includes(cell) ? verticalMargins(new Map([...(_a3 = sheetMargins.get(cell)) != null ? _a3 : [], ...parseInlineStyle($(cell).attr("style") || "")])) : { top: void 0, bottom: void 0 };
|
|
34204
|
+
const style = parseInlineStyle($(cell).attr("style") || "");
|
|
34205
|
+
const pad = ((_b2 = style.get("padding")) != null ? _b2 : "").trim().split(/\s+/).filter(Boolean);
|
|
34206
|
+
for (const [side, by] of [["top", (_c2 = mine.top) != null ? _c2 : top], ["bottom", (_d2 = mine.bottom) != null ? _d2 : bottom]]) {
|
|
34207
|
+
if (by <= 0) continue;
|
|
34208
|
+
const was = Number.parseFloat((_g = (_f = style.get(`padding-${side}`)) != null ? _f : side === "top" ? pad[0] : (_e2 = pad[2]) != null ? _e2 : pad[0]) != null ? _g : "") || 0;
|
|
34209
|
+
style.set(`padding-${side}`, `${was + by}px`);
|
|
34210
|
+
}
|
|
34211
|
+
$(cell).attr("style", serializeStyle(style));
|
|
34212
|
+
}
|
|
34213
|
+
});
|
|
34214
|
+
if (top <= 0 && bottom <= 0 || centred) return;
|
|
34112
34215
|
props.delete("margin-top");
|
|
34113
34216
|
props.delete("margin-bottom");
|
|
34114
34217
|
if (box.length) {
|
|
34115
34218
|
props.delete("margin");
|
|
34116
|
-
if (box[1]) props.set("margin-left", (
|
|
34219
|
+
if (box[1]) props.set("margin-left", (_e = box[3]) != null ? _e : box[1]);
|
|
34117
34220
|
if (box[1]) props.set("margin-right", box[1]);
|
|
34118
34221
|
}
|
|
34119
34222
|
table.attr("style", serializeStyle(props));
|
|
34120
34223
|
});
|
|
34224
|
+
$("tr").each((_, row) => {
|
|
34225
|
+
const cells = $(row).children("td, th").toArray();
|
|
34226
|
+
if (cells.length < 2) return;
|
|
34227
|
+
const sides = cells.map((cell) => {
|
|
34228
|
+
var _a2, _b, _c, _d;
|
|
34229
|
+
const style = parseInlineStyle($(cell).attr("style") || "");
|
|
34230
|
+
const pad = ((_a2 = style.get("padding")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
|
|
34231
|
+
const read = (v) => Number.parseFloat(v != null ? v : "") || 0;
|
|
34232
|
+
return { style, top: read((_b = style.get("padding-top")) != null ? _b : pad[0]), bottom: read((_d = (_c = style.get("padding-bottom")) != null ? _c : pad[2]) != null ? _d : pad[0]) };
|
|
34233
|
+
});
|
|
34234
|
+
const top = Math.max(...sides.map((s) => s.top));
|
|
34235
|
+
const bottom = Math.max(...sides.map((s) => s.bottom));
|
|
34236
|
+
cells.forEach((cell, i) => {
|
|
34237
|
+
const { style } = sides[i];
|
|
34238
|
+
if (sides[i].top < top) style.set("padding-top", `${top}px`);
|
|
34239
|
+
if (sides[i].bottom < bottom) style.set("padding-bottom", `${bottom}px`);
|
|
34240
|
+
if (sides[i].top < top || sides[i].bottom < bottom) $(cell).attr("style", serializeStyle(style));
|
|
34241
|
+
});
|
|
34242
|
+
});
|
|
34121
34243
|
$("table").each((_, node) => {
|
|
34122
34244
|
var _a2, _b;
|
|
34123
34245
|
const props = parseInlineStyle($(node).attr("style") || "");
|
|
@@ -34174,10 +34296,84 @@ h1 {
|
|
|
34174
34296
|
const after = serializeStyle(props);
|
|
34175
34297
|
if (after) p.attr("style", after);
|
|
34176
34298
|
});
|
|
34177
|
-
|
|
34299
|
+
$("span, a, strong, b, em, i, u, font").each((_, node) => {
|
|
34300
|
+
var _a2, _b, _c;
|
|
34301
|
+
const el = node;
|
|
34302
|
+
const props = parseInlineStyle($(el).attr("style") || "");
|
|
34303
|
+
if (/block/i.test((_a2 = props.get("display")) != null ? _a2 : "")) return;
|
|
34304
|
+
const spacing = $(el).parents().toArray().map(spacingOf).find((st) => st.has("line-height"));
|
|
34305
|
+
if (!/^[\d.]+px$/i.test((_b = spacing == null ? void 0 : spacing.get("line-height")) != null ? _b : "") || /exactly/i.test((_c = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _c : "")) return;
|
|
34306
|
+
props.set("line-height", "normal");
|
|
34307
|
+
$(el).attr("style", serializeStyle(props));
|
|
34308
|
+
});
|
|
34309
|
+
const inherited2 = (el, prop) => [el, ...$(el).parents().toArray()].map(spacingOf).find((st) => st.has(prop));
|
|
34310
|
+
const sizeOf = (el) => {
|
|
34311
|
+
var _a2, _b, _c;
|
|
34312
|
+
const sized = [el, ...$(el).parents().toArray()].map(spacingOf).find((st) => {
|
|
34313
|
+
var _a3;
|
|
34314
|
+
return st.has("font-size") || /\d(?:\.\d+)?px/.test((_a3 = st.get("font")) != null ? _a3 : "");
|
|
34315
|
+
});
|
|
34316
|
+
const px2 = (_c = /^([\d.]+)px$/i.exec((_a2 = sized == null ? void 0 : sized.get("font-size")) != null ? _a2 : "")) != null ? _c : /(?:^|\s)([\d.]+)px/.exec((_b = sized == null ? void 0 : sized.get("font")) != null ? _b : "");
|
|
34317
|
+
return px2 ? Number(px2[1]) : void 0;
|
|
34318
|
+
};
|
|
34319
|
+
$("p, div, h1, h2, h3, h4, h5, h6, li, td, th").each((_, node) => {
|
|
34320
|
+
var _a2, _b, _c, _d;
|
|
34321
|
+
const el = node;
|
|
34322
|
+
const block = $(el);
|
|
34323
|
+
if (block.find("p, div, h1, h2, h3, h4, h5, h6, li, table, ul, ol").length || !/[^\s ]/.test(block.text())) return;
|
|
34324
|
+
const own = parseInlineStyle(block.attr("style") || "");
|
|
34325
|
+
if (hasBorder(own)) return;
|
|
34326
|
+
const mine = spacingOf(el);
|
|
34327
|
+
const spacing = inherited2(el, "line-height");
|
|
34328
|
+
const line = /^([\d.]+)px$/i.exec((_a2 = spacing == null ? void 0 : spacing.get("line-height")) != null ? _a2 : "");
|
|
34329
|
+
const size = sizeOf(el);
|
|
34330
|
+
if (!line || !size) return;
|
|
34331
|
+
let largest = size;
|
|
34332
|
+
block.find("*").each((_2, inner) => {
|
|
34333
|
+
var _a3;
|
|
34334
|
+
const px2 = /^([\d.]+)px$/i.exec((_a3 = spacingOf(inner).get("font-size")) != null ? _a3 : "");
|
|
34335
|
+
if (px2) largest = Math.max(largest, Number(px2[1]));
|
|
34336
|
+
});
|
|
34337
|
+
const exactly = /exactly/i.test((_b = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _b : "");
|
|
34338
|
+
const natural = naturalHeight(size, (_c = inherited2(el, "font-family")) == null ? void 0 : _c.get("font-family"));
|
|
34339
|
+
if (!exactly && largest === size && Number(line[1]) < natural) {
|
|
34340
|
+
own.set("line-height", `${natural}px`);
|
|
34341
|
+
block.attr("style", serializeStyle(own));
|
|
34342
|
+
return;
|
|
34343
|
+
}
|
|
34344
|
+
const leading = Math.round((Number(line[1]) - largest * NATURAL_LINE) * 10) / 10;
|
|
34345
|
+
const shift = Math.round(leading * (exactly ? 0.3 : 0.5) * 10) / 10;
|
|
34346
|
+
if (shift <= 0) return;
|
|
34347
|
+
block.wrapInner(
|
|
34348
|
+
exactly ? `<span style="position:relative;top:${shift}px"></span>` : `<span style="vertical-align:bottom;line-height:normal"></span>`
|
|
34349
|
+
);
|
|
34350
|
+
const tag = el.tagName.toLowerCase();
|
|
34351
|
+
const fill = (_d = mine.get("background-color")) != null ? _d : mine.get("background");
|
|
34352
|
+
if (exactly || tag === "td" || tag === "th" || !fill || /\(|\s/.test(fill.trim())) return;
|
|
34353
|
+
own.delete("background-color");
|
|
34354
|
+
own.set("background", `linear-gradient(transparent ${leading}px, ${fill.trim()} ${leading}px)`);
|
|
34355
|
+
block.attr("style", serializeStyle(own));
|
|
34356
|
+
});
|
|
34357
|
+
$("body *").each((_, node) => {
|
|
34358
|
+
var _a2, _b;
|
|
34359
|
+
const el = node;
|
|
34360
|
+
if (!$(el).contents().toArray().some((n) => n.type === "text" && /[^\s ]/.test(n.data))) return;
|
|
34361
|
+
const family = (_b = (_a2 = inherited2(el, "font-family")) == null ? void 0 : _a2.get("font-family")) != null ? _b : "";
|
|
34362
|
+
const size = sizeOf(el);
|
|
34363
|
+
if (!isGill(family) || size === void 0) return;
|
|
34364
|
+
const block = $(el).closest("p, div, li, td, th, h1, h2, h3, h4, h5, h6").get(0);
|
|
34365
|
+
const blockSize = block && block !== el ? sizeOf(block) : void 0;
|
|
34366
|
+
const large = family.trim().startsWith(GILL_LARGE);
|
|
34367
|
+
if (large === (size > 22 || blockSize !== void 0 && size > blockSize)) return;
|
|
34368
|
+
const props = parseInlineStyle($(el).attr("style") || "");
|
|
34369
|
+
const stack = family.replace(new RegExp(String.raw`^\s*${GILL_LARGE},\s*`), "");
|
|
34370
|
+
props.set("font-family", large ? stack : `${GILL_LARGE}, ${stack}`);
|
|
34371
|
+
$(el).attr("style", serializeStyle(props));
|
|
34372
|
+
});
|
|
34373
|
+
const reset = "<style>h2{margin:0}p{margin:14pt 0}td,th{box-sizing:border-box}</style>";
|
|
34178
34374
|
const head = $("head");
|
|
34179
34375
|
if (head.length) head.prepend(reset);
|
|
34180
|
-
else if ($("p,h2").length) $.root().prepend(reset);
|
|
34376
|
+
else if ($("p,h2,td,th").length) $.root().prepend(reset);
|
|
34181
34377
|
}
|
|
34182
34378
|
var MAX_HTML_SIZE = 2 * 1024 * 1024;
|
|
34183
34379
|
var MAX_WARNING_LOCATIONS = 100;
|
|
@@ -36704,7 +36900,7 @@ h1 {
|
|
|
36704
36900
|
}
|
|
36705
36901
|
break;
|
|
36706
36902
|
case "outlook-windows-legacy":
|
|
36707
|
-
applyColorInversion($, "
|
|
36903
|
+
applyColorInversion($, "outlook-classic", clientId);
|
|
36708
36904
|
if (!html.includes("prefers-color-scheme")) {
|
|
36709
36905
|
warnings.push({
|
|
36710
36906
|
severity: "info",
|
|
@@ -36786,7 +36982,9 @@ h1 {
|
|
|
36786
36982
|
return { html: $.html(), warnings };
|
|
36787
36983
|
}
|
|
36788
36984
|
var MEASURED_CANVAS = {
|
|
36789
|
-
"outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" }
|
|
36985
|
+
"outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" },
|
|
36986
|
+
// ponytail: fg unmeasured; Word's automatic text is black, which maps here.
|
|
36987
|
+
"outlook-windows-legacy": { bg: "#262626", fg: "#f6f6f6" }
|
|
36790
36988
|
};
|
|
36791
36989
|
var SAMPLED_DARK = {
|
|
36792
36990
|
"outlook-web": { eeeae4: "#595651" },
|
|
@@ -36843,6 +37041,53 @@ h1 {
|
|
|
36843
37041
|
if (c.r === c.g && c.g === c.b) return withLabLightness(c, (l) => Math.min(l, 88.5 - 0.772 * l), D65);
|
|
36844
37042
|
return withLabLightness(c, () => 34.6, D65);
|
|
36845
37043
|
}
|
|
37044
|
+
var WORD_DARK_GREYS = [
|
|
37045
|
+
[0, 246],
|
|
37046
|
+
[15, 233],
|
|
37047
|
+
[30, 225],
|
|
37048
|
+
[45, 216],
|
|
37049
|
+
[60, 206],
|
|
37050
|
+
[75, 196],
|
|
37051
|
+
[90, 185],
|
|
37052
|
+
[105, 174],
|
|
37053
|
+
[120, 163],
|
|
37054
|
+
[135, 151],
|
|
37055
|
+
[150, 139],
|
|
37056
|
+
[165, 126],
|
|
37057
|
+
[180, 113],
|
|
37058
|
+
[195, 99],
|
|
37059
|
+
[210, 85],
|
|
37060
|
+
[225, 70],
|
|
37061
|
+
[240, 55],
|
|
37062
|
+
[255, 38]
|
|
37063
|
+
];
|
|
37064
|
+
var greyL = (v) => {
|
|
37065
|
+
const s = v / 255;
|
|
37066
|
+
return 116 * labF(s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4) - 16;
|
|
37067
|
+
};
|
|
37068
|
+
var WORD_DARK_L = WORD_DARK_GREYS.map(([from, to]) => [greyL(from), greyL(to)]);
|
|
37069
|
+
var wordDarkL = (l) => {
|
|
37070
|
+
const i = Math.max(1, WORD_DARK_L.findIndex(([x]) => x >= Math.min(l, 100)));
|
|
37071
|
+
const [[x0, y0], [x1, y1]] = [WORD_DARK_L[i - 1], WORD_DARK_L[i]];
|
|
37072
|
+
return y0 + (y1 - y0) * (l - x0) / (x1 - x0);
|
|
37073
|
+
};
|
|
37074
|
+
function outlookClassicColor(value) {
|
|
37075
|
+
const c = parseColor(value);
|
|
37076
|
+
if (!c || c.a === 0) return null;
|
|
37077
|
+
const linear = [c.r, c.g, c.b].map((v) => {
|
|
37078
|
+
const s = v / 255;
|
|
37079
|
+
return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
37080
|
+
});
|
|
37081
|
+
const y = 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2];
|
|
37082
|
+
const l = 116 * labF(y) - 16;
|
|
37083
|
+
const out = labFInv((wordDarkL(l) + 16) / 116);
|
|
37084
|
+
const k = y > 0 ? Math.sqrt(out / y) : 1;
|
|
37085
|
+
const [r, g, b] = linear.map((v) => {
|
|
37086
|
+
const t = Math.min(1, Math.max(0, out + k * (v - y)));
|
|
37087
|
+
return Math.round(255 * (t <= 31308e-7 ? 12.92 * t : 1.055 * t ** (1 / 2.4) - 0.055));
|
|
37088
|
+
});
|
|
37089
|
+
return hex({ r, g, b });
|
|
37090
|
+
}
|
|
36846
37091
|
function gmailAndroidColor(value, role) {
|
|
36847
37092
|
const parsed = parseColor(value);
|
|
36848
37093
|
if (!parsed || parsed.a === 0) return null;
|
|
@@ -36855,6 +37100,7 @@ h1 {
|
|
|
36855
37100
|
var _a2;
|
|
36856
37101
|
if (mode === "gmail-android") return gmailAndroidColor(value, role);
|
|
36857
37102
|
if (mode === "outlook-macos") return outlookMacColor(value, role);
|
|
37103
|
+
if (mode === "outlook-classic") return outlookClassicColor(value);
|
|
36858
37104
|
const pinned = clientId && ((_a2 = SAMPLED_DARK[clientId]) == null ? void 0 : _a2[value.trim().replace("#", "").toLowerCase()]);
|
|
36859
37105
|
if (pinned) return pinned;
|
|
36860
37106
|
const parsed = parseColor(value);
|
|
@@ -36896,12 +37142,25 @@ h1 {
|
|
|
36896
37142
|
}
|
|
36897
37143
|
return null;
|
|
36898
37144
|
}
|
|
37145
|
+
var BORDER_SHORTHAND = /^border(-(top|right|bottom|left))?$/;
|
|
37146
|
+
function invertBorder(value, mode, clientId) {
|
|
37147
|
+
let changed = false;
|
|
37148
|
+
const next = value.replace(/#[0-9a-f]{3,8}(?![0-9a-z])|rgba?\([^)]*\)/gi, (token) => {
|
|
37149
|
+
const inverted = invertColor(token, mode, clientId);
|
|
37150
|
+
if (!inverted) return token;
|
|
37151
|
+
changed = true;
|
|
37152
|
+
return inverted;
|
|
37153
|
+
});
|
|
37154
|
+
return changed ? next : null;
|
|
37155
|
+
}
|
|
36899
37156
|
function applyColorInversion($, mode, clientId) {
|
|
36900
37157
|
$("[style]").each((_, el) => {
|
|
36901
37158
|
const style = $(el).attr("style") || "";
|
|
36902
37159
|
const props = parseInlineStyle(style);
|
|
36903
37160
|
let changed = false;
|
|
37161
|
+
const keepFill = mode === "outlook-classic" && $(el).is("[data-vml]");
|
|
36904
37162
|
props.forEach((value, prop) => {
|
|
37163
|
+
if (keepFill && prop !== "color") return;
|
|
36905
37164
|
if (COLOR_PROPS.has(prop)) {
|
|
36906
37165
|
const inverted = invertColor(value, mode, clientId, prop === "color" ? "fg" : "bg");
|
|
36907
37166
|
if (inverted) {
|
|
@@ -36909,6 +37168,13 @@ h1 {
|
|
|
36909
37168
|
changed = true;
|
|
36910
37169
|
}
|
|
36911
37170
|
}
|
|
37171
|
+
if (BORDER_SHORTHAND.test(prop)) {
|
|
37172
|
+
const inverted = invertBorder(value, mode, clientId);
|
|
37173
|
+
if (inverted) {
|
|
37174
|
+
props.set(prop, inverted);
|
|
37175
|
+
changed = true;
|
|
37176
|
+
}
|
|
37177
|
+
}
|
|
36912
37178
|
if (prop === "background") {
|
|
36913
37179
|
const bgColor = extractBackgroundColor(value);
|
|
36914
37180
|
if (bgColor) {
|
|
@@ -36933,9 +37199,16 @@ h1 {
|
|
|
36933
37199
|
enter(node) {
|
|
36934
37200
|
if (node.type !== "Declaration") return;
|
|
36935
37201
|
const prop = node.property.toLowerCase();
|
|
36936
|
-
|
|
37202
|
+
const border = BORDER_SHORTHAND.test(prop);
|
|
37203
|
+
if (!COLOR_PROPS.has(prop) && prop !== "background" && !border) return;
|
|
36937
37204
|
const valueStr = csstree4.generate(node.value);
|
|
36938
|
-
if (
|
|
37205
|
+
if (border) {
|
|
37206
|
+
const inverted = invertBorder(valueStr, mode, clientId);
|
|
37207
|
+
if (inverted) {
|
|
37208
|
+
node.value = csstree4.parse(inverted, { context: "value" });
|
|
37209
|
+
modified = true;
|
|
37210
|
+
}
|
|
37211
|
+
} else if (prop === "background") {
|
|
36939
37212
|
const bgColor = extractBackgroundColor(valueStr);
|
|
36940
37213
|
if (bgColor) {
|
|
36941
37214
|
const inverted = invertColor(bgColor, mode, clientId);
|
|
@@ -43085,7 +43358,7 @@ Href: ${href}`
|
|
|
43085
43358
|
// package.json
|
|
43086
43359
|
var package_default = {
|
|
43087
43360
|
name: "@emailens/cli",
|
|
43088
|
-
version: "0.13.
|
|
43361
|
+
version: "0.13.13",
|
|
43089
43362
|
description: "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
|
|
43090
43363
|
type: "module",
|
|
43091
43364
|
bin: {
|
|
@@ -43126,7 +43399,7 @@ var package_default = {
|
|
|
43126
43399
|
},
|
|
43127
43400
|
devDependencies: {
|
|
43128
43401
|
"@anthropic-ai/sdk": "^0.52.0",
|
|
43129
|
-
"@emailens/engine": "^0.18.
|
|
43402
|
+
"@emailens/engine": "^0.18.15",
|
|
43130
43403
|
"@types/bun": "^1.4.0",
|
|
43131
43404
|
"@types/mjml": "^4.7.4",
|
|
43132
43405
|
"@types/node": "^25.9.5",
|
package/dist/test.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emailens/cli",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.13",
|
|
4
4
|
"description": "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@anthropic-ai/sdk": "^0.52.0",
|
|
44
|
-
"@emailens/engine": "^0.18.
|
|
44
|
+
"@emailens/engine": "^0.18.15",
|
|
45
45
|
"@types/bun": "^1.4.0",
|
|
46
46
|
"@types/mjml": "^4.7.4",
|
|
47
47
|
"@types/node": "^25.9.5",
|