@lofcz/platejs-markdown 53.3.4 → 53.3.5
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 +13 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1561,17 +1561,26 @@ const defaultRules = {
|
|
|
1561
1561
|
},
|
|
1562
1562
|
callout: {
|
|
1563
1563
|
deserialize: (mdastNode, deco, options) => {
|
|
1564
|
-
const
|
|
1564
|
+
const { type: calloutType, variant, ...rest } = parseAttributes(mdastNode.attributes);
|
|
1565
|
+
const normalize = (value) => {
|
|
1566
|
+
if (typeof value !== "string") return;
|
|
1567
|
+
const trimmed = value.trim().toLowerCase();
|
|
1568
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
1569
|
+
};
|
|
1570
|
+
const resolvedVariant = normalize(calloutType) ?? normalize(variant);
|
|
1565
1571
|
return {
|
|
1566
1572
|
children: convertChildrenDeserialize(mdastNode.children, deco, options),
|
|
1567
1573
|
type: getPluginType(options.editor, KEYS.callout),
|
|
1568
|
-
...
|
|
1574
|
+
...resolvedVariant ? { variant: resolvedVariant } : {},
|
|
1575
|
+
...rest
|
|
1569
1576
|
};
|
|
1570
1577
|
},
|
|
1571
1578
|
serialize(slateNode, options) {
|
|
1572
|
-
const { children, type, ...rest } = slateNode;
|
|
1579
|
+
const { children, type: _type, variant, ...rest } = slateNode;
|
|
1580
|
+
const attrs = { ...rest };
|
|
1581
|
+
if (typeof variant === "string" && variant.length > 0) attrs.type = variant;
|
|
1573
1582
|
return {
|
|
1574
|
-
attributes: propsToAttributes(
|
|
1583
|
+
attributes: propsToAttributes(attrs),
|
|
1575
1584
|
children: convertNodesSerialize(children, options),
|
|
1576
1585
|
name: "callout",
|
|
1577
1586
|
type: "mdxJsxFlowElement"
|