@trafica/editor 1.0.27 → 1.0.29
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.js +19 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1628,12 +1628,13 @@ var htmlSerializer = {
|
|
|
1628
1628
|
return parseHTMLBody(parsed.body);
|
|
1629
1629
|
}
|
|
1630
1630
|
};
|
|
1631
|
-
function serializeBlock(node, idCounts = /* @__PURE__ */ new Map()) {
|
|
1632
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
1631
|
+
function serializeBlock(node, idCounts = /* @__PURE__ */ new Map(), inCell = false) {
|
|
1632
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
|
|
1633
1633
|
switch (node.type) {
|
|
1634
1634
|
case "paragraph": {
|
|
1635
1635
|
const align = ((_a = node.attrs) == null ? void 0 : _a.align) ? ` data-align="${node.attrs.align}"` : "";
|
|
1636
|
-
|
|
1636
|
+
const style = inCell ? ` style="margin:0;min-height:1.2em;"` : "";
|
|
1637
|
+
return `<p${align}${style}>${serializeChildren(node.children)}</p>`;
|
|
1637
1638
|
}
|
|
1638
1639
|
case "heading": {
|
|
1639
1640
|
const l = (_c = (_b = node.attrs) == null ? void 0 : _b.level) != null ? _c : 1;
|
|
@@ -1685,23 +1686,29 @@ function serializeBlock(node, idCounts = /* @__PURE__ */ new Map()) {
|
|
|
1685
1686
|
return "<hr />";
|
|
1686
1687
|
case "table": {
|
|
1687
1688
|
const rows = node.children.map((c) => serializeBlock(c)).join("");
|
|
1688
|
-
|
|
1689
|
+
const colWidths = (_q = (_p = node.attrs) == null ? void 0 : _p.colWidths) != null ? _q : [];
|
|
1690
|
+
let colgroup = "";
|
|
1691
|
+
if (colWidths.length > 0) {
|
|
1692
|
+
const total = colWidths.reduce((s, w) => s + w, 0) || colWidths.length * 120;
|
|
1693
|
+
colgroup = `<colgroup>${colWidths.map((w) => `<col style="width:${(w / total * 100).toFixed(4)}%">`).join("")}</colgroup>`;
|
|
1694
|
+
}
|
|
1695
|
+
return `<div style="overflow-x:auto;margin:0.75em 0;"><table style="border-collapse:collapse;table-layout:fixed;width:100%;font-size:inherit;font-family:inherit;">${colgroup}<tbody>${rows}</tbody></table></div>`;
|
|
1689
1696
|
}
|
|
1690
1697
|
case "table_row": {
|
|
1691
1698
|
const cells = node.children.map((c) => serializeBlock(c)).join("");
|
|
1692
1699
|
return `<tr>${cells}</tr>`;
|
|
1693
1700
|
}
|
|
1694
1701
|
case "table_cell": {
|
|
1695
|
-
if ((
|
|
1696
|
-
const cs = ((
|
|
1697
|
-
const rs = ((
|
|
1698
|
-
return `<td${cs}${rs} style="border:1px solid #d1d5db;padding:0.5em 0.75em;vertical-align:top;min-width:40px;word-break:break-word;">${
|
|
1702
|
+
if ((_r = node.attrs) == null ? void 0 : _r.covered) return "";
|
|
1703
|
+
const cs = ((_s = node.attrs) == null ? void 0 : _s.colspan) > 1 ? ` colspan="${(_t = node.attrs) == null ? void 0 : _t.colspan}"` : "";
|
|
1704
|
+
const rs = ((_u = node.attrs) == null ? void 0 : _u.rowspan) > 1 ? ` rowspan="${(_v = node.attrs) == null ? void 0 : _v.rowspan}"` : "";
|
|
1705
|
+
return `<td${cs}${rs} style="border:1px solid #d1d5db;padding:0.5em 0.75em;vertical-align:top;min-width:40px;word-break:break-word;">${node.children.map((c) => serializeBlock(c, /* @__PURE__ */ new Map(), true)).join("")}</td>`;
|
|
1699
1706
|
}
|
|
1700
1707
|
case "table_header": {
|
|
1701
|
-
if ((
|
|
1702
|
-
const cs = ((
|
|
1703
|
-
const rs = ((
|
|
1704
|
-
return `<th${cs}${rs} style="border:1px solid #d1d5db;padding:0.5em 0.75em;vertical-align:top;min-width:40px;word-break:break-word;background:#f9fafb;font-weight:600;text-align:left;">${
|
|
1708
|
+
if ((_w = node.attrs) == null ? void 0 : _w.covered) return "";
|
|
1709
|
+
const cs = ((_x = node.attrs) == null ? void 0 : _x.colspan) > 1 ? ` colspan="${(_y = node.attrs) == null ? void 0 : _y.colspan}"` : "";
|
|
1710
|
+
const rs = ((_z = node.attrs) == null ? void 0 : _z.rowspan) > 1 ? ` rowspan="${(_A = node.attrs) == null ? void 0 : _A.rowspan}"` : "";
|
|
1711
|
+
return `<th${cs}${rs} style="border:1px solid #d1d5db;padding:0.5em 0.75em;vertical-align:top;min-width:40px;word-break:break-word;background:#f9fafb;font-weight:600;text-align:left;">${node.children.map((c) => serializeBlock(c, /* @__PURE__ */ new Map(), true)).join("")}</th>`;
|
|
1705
1712
|
}
|
|
1706
1713
|
default:
|
|
1707
1714
|
return `<p>${serializeChildren(node.children)}</p>`;
|