@marvalt/wparser 0.1.27 → 0.1.29
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.cjs +40 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +40 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/registry/defaultRegistry.d.ts.map +1 -1
- package/dist/utils/blockExtractors.d.ts +5 -0
- package/dist/utils/blockExtractors.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2057,6 +2057,36 @@ function extractBackgroundColor(block, context) {
|
|
|
2057
2057
|
// Fallback: return null (no background applied)
|
|
2058
2058
|
return null;
|
|
2059
2059
|
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Extract spacer height from block attributes or innerHTML
|
|
2062
|
+
* Returns height in pixels, or null if not found
|
|
2063
|
+
*/
|
|
2064
|
+
function extractSpacerHeight(block) {
|
|
2065
|
+
const attrs = block.attributes || {};
|
|
2066
|
+
// First, try to get height from attributes
|
|
2067
|
+
const height = attrs['height'];
|
|
2068
|
+
if (typeof height === 'number') {
|
|
2069
|
+
return height;
|
|
2070
|
+
}
|
|
2071
|
+
if (typeof height === 'string') {
|
|
2072
|
+
// Parse "100px" or "100" to number
|
|
2073
|
+
const match = height.match(/^(\d+)/);
|
|
2074
|
+
if (match) {
|
|
2075
|
+
return parseInt(match[1], 10);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
// Fall back to parsing innerHTML for style="height:100px"
|
|
2079
|
+
if (block.innerHTML) {
|
|
2080
|
+
const styleMatch = block.innerHTML.match(/style=["']([^"']+)["']/i);
|
|
2081
|
+
if (styleMatch) {
|
|
2082
|
+
const heightMatch = styleMatch[1].match(/height:\s*(\d+)px/i);
|
|
2083
|
+
if (heightMatch) {
|
|
2084
|
+
return parseInt(heightMatch[1], 10);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
return null;
|
|
2089
|
+
}
|
|
2060
2090
|
|
|
2061
2091
|
/**
|
|
2062
2092
|
* Style mapping utilities
|
|
@@ -2458,6 +2488,15 @@ function createDefaultRegistry(colorMapper, spacingConfig) {
|
|
|
2458
2488
|
const html = block.innerHTML || '';
|
|
2459
2489
|
return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: html } });
|
|
2460
2490
|
},
|
|
2491
|
+
// Spacer block - adds vertical spacing
|
|
2492
|
+
'core/spacer': ({ block }) => {
|
|
2493
|
+
const height = extractSpacerHeight(block);
|
|
2494
|
+
if (height && height > 0) {
|
|
2495
|
+
return jsxRuntimeExports.jsx("div", { style: { height: `${height}px` }, "aria-hidden": "true" });
|
|
2496
|
+
}
|
|
2497
|
+
// Default fallback if height not found
|
|
2498
|
+
return jsxRuntimeExports.jsx("div", { style: { height: '100px' }, "aria-hidden": "true" });
|
|
2499
|
+
},
|
|
2461
2500
|
};
|
|
2462
2501
|
return {
|
|
2463
2502
|
renderers,
|
|
@@ -2773,5 +2812,5 @@ const SectionWrapper = ({ children, background = 'light', spacing = 'medium', co
|
|
|
2773
2812
|
return (jsxRuntimeExports.jsx("section", { className: buildClassName(backgroundClasses[finalBackground] || backgroundClasses.light, spacingClasses[finalSpacing] || spacingClasses.medium, containerClasses[finalContainer] || containerClasses.contained, className), children: children }));
|
|
2774
2813
|
};
|
|
2775
2814
|
|
|
2776
|
-
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
2815
|
+
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
2777
2816
|
//# sourceMappingURL=index.esm.js.map
|