@seed-hypermedia/client 0.0.34 → 0.0.35
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.mjs +9 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3506,6 +3506,13 @@ function toHMBlockType(editorBlockType) {
|
|
|
3506
3506
|
if (editorBlockType === "query") return "Query";
|
|
3507
3507
|
return void 0;
|
|
3508
3508
|
}
|
|
3509
|
+
function toImageWidthNumber(width) {
|
|
3510
|
+
if (width == null ? void 0 : width.trim().endsWith("%")) {
|
|
3511
|
+
const percentage = Number(width.trim().slice(0, -1));
|
|
3512
|
+
return Number.isFinite(percentage) && percentage > 0 ? percentage : null;
|
|
3513
|
+
}
|
|
3514
|
+
return toNumber(width);
|
|
3515
|
+
}
|
|
3509
3516
|
function editorBlockToHMBlock(editorBlock) {
|
|
3510
3517
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3511
3518
|
const blockType = toHMBlockType(editorBlock.type);
|
|
@@ -3592,7 +3599,7 @@ function editorBlockToHMBlock(editorBlock) {
|
|
|
3592
3599
|
} else {
|
|
3593
3600
|
blockImage.link = "";
|
|
3594
3601
|
}
|
|
3595
|
-
const width =
|
|
3602
|
+
const width = toImageWidthNumber(editorBlock.props.width);
|
|
3596
3603
|
if (width) {
|
|
3597
3604
|
blockImage.attributes.width = width;
|
|
3598
3605
|
}
|
|
@@ -3805,7 +3812,7 @@ function hmBlockToEditorBlock(block) {
|
|
|
3805
3812
|
if (key == "width" || key == "size") {
|
|
3806
3813
|
if (typeof value == "number") {
|
|
3807
3814
|
;
|
|
3808
|
-
out.props[key] = String(value);
|
|
3815
|
+
out.props[key] = blockType === "image" && key === "width" && value > 0 && value <= 100 ? `${value}%` : String(value);
|
|
3809
3816
|
}
|
|
3810
3817
|
} else if (typeof value == "boolean") {
|
|
3811
3818
|
;
|