@trafica/editor 1.0.59 → 1.0.60
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 +24 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1724,16 +1724,34 @@ function serializeBlock(node, idCounts = /* @__PURE__ */ new Map(), inCell = fal
|
|
|
1724
1724
|
case "image": {
|
|
1725
1725
|
const src = escapeAttr((_j = (_i = node.attrs) == null ? void 0 : _i.src) != null ? _j : "");
|
|
1726
1726
|
const alt = escapeAttr((_l = (_k = node.attrs) == null ? void 0 : _k.alt) != null ? _l : "");
|
|
1727
|
-
const
|
|
1728
|
-
const
|
|
1727
|
+
const widthPx = (_m = node.attrs) == null ? void 0 : _m.width;
|
|
1728
|
+
const widthAttr = widthPx ? ` width="${widthPx}"` : "";
|
|
1729
|
+
const align = (_n = node.attrs) == null ? void 0 : _n.align;
|
|
1729
1730
|
const caption = ((_o = node.attrs) == null ? void 0 : _o.caption) ? escapeHTML(node.attrs.caption) : "";
|
|
1730
1731
|
const x = (_p = node.attrs) == null ? void 0 : _p.x;
|
|
1731
1732
|
const y = (_q = node.attrs) == null ? void 0 : _q.y;
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
|
|
1733
|
+
const figStyles = ["display:block", "max-width:100%", "width:fit-content", "margin:1em 0"];
|
|
1734
|
+
const dataAttrs = [];
|
|
1735
|
+
if (x !== void 0) {
|
|
1736
|
+
const ix = Math.round(x);
|
|
1737
|
+
const iy = Math.round(y != null ? y : 0);
|
|
1738
|
+
dataAttrs.push(`data-x="${ix}"`, `data-y="${iy}"`);
|
|
1739
|
+
figStyles.push("position:absolute", `left:${ix}px`, `top:${iy}px`, "margin:0", "z-index:10");
|
|
1740
|
+
} else if (align === "center") {
|
|
1741
|
+
dataAttrs.push('data-align="center"');
|
|
1742
|
+
figStyles.push("margin-left:auto", "margin-right:auto");
|
|
1743
|
+
} else if (align === "right") {
|
|
1744
|
+
dataAttrs.push('data-align="right"');
|
|
1745
|
+
figStyles.push("margin-left:auto", "margin-right:0");
|
|
1746
|
+
} else if (align === "left") {
|
|
1747
|
+
dataAttrs.push('data-align="left"');
|
|
1748
|
+
figStyles.push("margin-left:0", "margin-right:auto");
|
|
1735
1749
|
}
|
|
1736
|
-
|
|
1750
|
+
const figAttrStr = dataAttrs.length ? " " + dataAttrs.join(" ") : "";
|
|
1751
|
+
const figStyleStr = ` style="${figStyles.join(";")};"`;
|
|
1752
|
+
const imgStyle = ` style="display:block;max-width:100%;height:auto${widthPx ? `;width:${widthPx}px` : ""};"`;
|
|
1753
|
+
const captionHTML = caption ? `<figcaption style="display:block;text-align:center;font-size:0.8em;color:#6b7280;margin-top:0.4em;font-style:italic;">${caption}</figcaption>` : "";
|
|
1754
|
+
return `<figure${figAttrStr}${figStyleStr}><img src="${src}" alt="${alt}"${widthAttr}${imgStyle} />${captionHTML}</figure>`;
|
|
1737
1755
|
}
|
|
1738
1756
|
case "horizontal_rule":
|
|
1739
1757
|
return "<hr />";
|