@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 CHANGED
@@ -2059,6 +2059,36 @@ function extractBackgroundColor(block, context) {
2059
2059
  // Fallback: return null (no background applied)
2060
2060
  return null;
2061
2061
  }
2062
+ /**
2063
+ * Extract spacer height from block attributes or innerHTML
2064
+ * Returns height in pixels, or null if not found
2065
+ */
2066
+ function extractSpacerHeight(block) {
2067
+ const attrs = block.attributes || {};
2068
+ // First, try to get height from attributes
2069
+ const height = attrs['height'];
2070
+ if (typeof height === 'number') {
2071
+ return height;
2072
+ }
2073
+ if (typeof height === 'string') {
2074
+ // Parse "100px" or "100" to number
2075
+ const match = height.match(/^(\d+)/);
2076
+ if (match) {
2077
+ return parseInt(match[1], 10);
2078
+ }
2079
+ }
2080
+ // Fall back to parsing innerHTML for style="height:100px"
2081
+ if (block.innerHTML) {
2082
+ const styleMatch = block.innerHTML.match(/style=["']([^"']+)["']/i);
2083
+ if (styleMatch) {
2084
+ const heightMatch = styleMatch[1].match(/height:\s*(\d+)px/i);
2085
+ if (heightMatch) {
2086
+ return parseInt(heightMatch[1], 10);
2087
+ }
2088
+ }
2089
+ }
2090
+ return null;
2091
+ }
2062
2092
 
2063
2093
  /**
2064
2094
  * Style mapping utilities
@@ -2460,6 +2490,15 @@ function createDefaultRegistry(colorMapper, spacingConfig) {
2460
2490
  const html = block.innerHTML || '';
2461
2491
  return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: html } });
2462
2492
  },
2493
+ // Spacer block - adds vertical spacing
2494
+ 'core/spacer': ({ block }) => {
2495
+ const height = extractSpacerHeight(block);
2496
+ if (height && height > 0) {
2497
+ return jsxRuntimeExports.jsx("div", { style: { height: `${height}px` }, "aria-hidden": "true" });
2498
+ }
2499
+ // Default fallback if height not found
2500
+ return jsxRuntimeExports.jsx("div", { style: { height: '100px' }, "aria-hidden": "true" });
2501
+ },
2463
2502
  };
2464
2503
  return {
2465
2504
  renderers,
@@ -2799,6 +2838,7 @@ exports.extractImageUrlWithFallback = extractImageUrlWithFallback;
2799
2838
  exports.extractMediaPosition = extractMediaPosition;
2800
2839
  exports.extractMinHeight = extractMinHeight;
2801
2840
  exports.extractOverlayColor = extractOverlayColor;
2841
+ exports.extractSpacerHeight = extractSpacerHeight;
2802
2842
  exports.extractSubtitleFromInnerBlocks = extractSubtitleFromInnerBlocks;
2803
2843
  exports.extractTextAlign = extractTextAlign;
2804
2844
  exports.extractTextAlignFromInnerBlocks = extractTextAlignFromInnerBlocks;