@trafica/editor 1.0.55 → 1.0.57
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 +18 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -903,11 +903,20 @@ function patchDocument(prevDoc, nextDoc, container) {
|
|
|
903
903
|
renderDocument(nextDoc, container);
|
|
904
904
|
return;
|
|
905
905
|
}
|
|
906
|
+
if (container.children.length !== next.length) {
|
|
907
|
+
renderDocument(nextDoc, container);
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
906
910
|
const domChildren = container.children;
|
|
907
911
|
for (let i = 0; i < next.length; i++) {
|
|
908
912
|
if (next[i] !== prev[i]) {
|
|
913
|
+
const oldEl = domChildren[i];
|
|
914
|
+
if (!oldEl) {
|
|
915
|
+
renderDocument(nextDoc, container);
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
909
918
|
const newEl = renderBlock(next[i], [i]);
|
|
910
|
-
container.replaceChild(newEl,
|
|
919
|
+
container.replaceChild(newEl, oldEl);
|
|
911
920
|
}
|
|
912
921
|
}
|
|
913
922
|
}
|
|
@@ -1716,15 +1725,19 @@ function serializeBlock(node, idCounts = /* @__PURE__ */ new Map(), inCell = fal
|
|
|
1716
1725
|
const src = escapeAttr((_j = (_i = node.attrs) == null ? void 0 : _i.src) != null ? _j : "");
|
|
1717
1726
|
const alt = escapeAttr((_l = (_k = node.attrs) == null ? void 0 : _k.alt) != null ? _l : "");
|
|
1718
1727
|
const width = ((_m = node.attrs) == null ? void 0 : _m.width) ? ` width="${node.attrs.width}"` : "";
|
|
1719
|
-
const
|
|
1728
|
+
const alignVal = (_n = node.attrs) == null ? void 0 : _n.align;
|
|
1729
|
+
const alignAttr = alignVal ? ` data-align="${alignVal}"` : "";
|
|
1720
1730
|
const caption = ((_o = node.attrs) == null ? void 0 : _o.caption) ? escapeHTML(node.attrs.caption) : "";
|
|
1721
1731
|
const x = (_p = node.attrs) == null ? void 0 : _p.x;
|
|
1722
1732
|
const y = (_q = node.attrs) == null ? void 0 : _q.y;
|
|
1723
|
-
const
|
|
1733
|
+
const alignStyle = alignVal === "center" ? "display:block;margin-left:auto;margin-right:auto;text-align:center;" : alignVal === "right" ? "display:block;margin-left:auto;text-align:right;" : alignVal === "left" ? "display:block;margin-right:auto;text-align:left;" : "";
|
|
1734
|
+
const posStyle = x !== void 0 ? `position:absolute;left:${Math.round(x)}px;top:${Math.round(y != null ? y : 0)}px;` : "";
|
|
1735
|
+
const posAttrs = x !== void 0 ? ` data-x="${Math.round(x)}" data-y="${Math.round(y != null ? y : 0)}"` : "";
|
|
1736
|
+
const figStyle = alignStyle || posStyle ? ` style="${alignStyle}${posStyle}"` : "";
|
|
1724
1737
|
if (caption) {
|
|
1725
|
-
return `<figure${
|
|
1738
|
+
return `<figure${alignAttr}${posAttrs}${figStyle}><img src="${src}" alt="${alt}"${width} style="max-width:100%;height:auto;" /><figcaption>${caption}</figcaption></figure>`;
|
|
1726
1739
|
}
|
|
1727
|
-
return `<figure${
|
|
1740
|
+
return `<figure${alignAttr}${posAttrs}${figStyle}><img src="${src}" alt="${alt}"${width} style="max-width:100%;height:auto;" /></figure>`;
|
|
1728
1741
|
}
|
|
1729
1742
|
case "horizontal_rule":
|
|
1730
1743
|
return "<hr />";
|