@seed-hypermedia/client 0.0.51 → 0.0.52
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 +22 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4107,8 +4107,30 @@ function toImageWidthNumber(width) {
|
|
|
4107
4107
|
}
|
|
4108
4108
|
return toNumber(width);
|
|
4109
4109
|
}
|
|
4110
|
+
function unknownEditorBlockToHMBlock(editorBlock) {
|
|
4111
|
+
const props = editorBlock.props ?? {};
|
|
4112
|
+
if (props.originalData) {
|
|
4113
|
+
try {
|
|
4114
|
+
const parsed = JSON.parse(props.originalData);
|
|
4115
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
4116
|
+
return { ...parsed, id: editorBlock.id };
|
|
4117
|
+
}
|
|
4118
|
+
} catch {
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
4121
|
+
return {
|
|
4122
|
+
id: editorBlock.id,
|
|
4123
|
+
type: props.originalType || "unknown",
|
|
4124
|
+
text: "",
|
|
4125
|
+
annotations: [],
|
|
4126
|
+
attributes: {}
|
|
4127
|
+
};
|
|
4128
|
+
}
|
|
4110
4129
|
function editorBlockToHMBlock(editorBlock) {
|
|
4111
4130
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4131
|
+
if (editorBlock.type === "unknown") {
|
|
4132
|
+
return unknownEditorBlockToHMBlock(editorBlock);
|
|
4133
|
+
}
|
|
4112
4134
|
const blockType = toHMBlockType(editorBlock.type);
|
|
4113
4135
|
if (!blockType) throw new Error("Unsupported block type " + editorBlock.type);
|
|
4114
4136
|
let block = {
|