@trafica/editor 1.0.56 → 1.0.58
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 +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1725,15 +1725,20 @@ function serializeBlock(node, idCounts = /* @__PURE__ */ new Map(), inCell = fal
|
|
|
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
1727
|
const width = ((_m = node.attrs) == null ? void 0 : _m.width) ? ` width="${node.attrs.width}"` : "";
|
|
1728
|
-
const
|
|
1728
|
+
const alignVal = (_n = node.attrs) == null ? void 0 : _n.align;
|
|
1729
|
+
const alignAttr = alignVal ? ` data-align="${alignVal}"` : "";
|
|
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
|
+
const isDraggable = x !== void 0;
|
|
1734
|
+
const effectiveAlign = alignVal != null ? alignVal : isDraggable ? "left" : void 0;
|
|
1735
|
+
const alignStyle = effectiveAlign === "center" ? "display:block;margin-left:auto;margin-right:auto;text-align:center;" : effectiveAlign === "right" ? "display:block;margin-left:auto;text-align:right;" : effectiveAlign === "left" ? "display:block;margin-right:auto;text-align:left;" : "";
|
|
1736
|
+
const posAttrs = isDraggable ? ` data-x="${Math.round(x)}" data-y="${Math.round(y != null ? y : 0)}"` : "";
|
|
1737
|
+
const figStyle = alignStyle ? ` style="${alignStyle}"` : "";
|
|
1733
1738
|
if (caption) {
|
|
1734
|
-
return `<figure${
|
|
1739
|
+
return `<figure${alignAttr}${posAttrs}${figStyle}><img src="${src}" alt="${alt}"${width} style="max-width:100%;height:auto;" /><figcaption>${caption}</figcaption></figure>`;
|
|
1735
1740
|
}
|
|
1736
|
-
return `<figure${
|
|
1741
|
+
return `<figure${alignAttr}${posAttrs}${figStyle}><img src="${src}" alt="${alt}"${width} style="max-width:100%;height:auto;" /></figure>`;
|
|
1737
1742
|
}
|
|
1738
1743
|
case "horizontal_rule":
|
|
1739
1744
|
return "<hr />";
|