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