@marvalt/wparser 0.1.55 → 0.1.57

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
@@ -2491,6 +2491,44 @@ const ListItem = ({ block, children, context }) => {
2491
2491
  return jsxRuntimeExports.jsx("li", { className: textColorClass || undefined, children: content || children });
2492
2492
  };
2493
2493
  const Group = ({ block, children, context }) => {
2494
+ // If innerHTML exists, WordPress has already rendered the block wrapper with all its classes
2495
+ // Extract the wrapper div attributes and use them, then render children inside
2496
+ if (block.innerHTML) {
2497
+ // Extract the opening div tag with all attributes
2498
+ const openingDivMatch = block.innerHTML.match(/<div([^>]*)>/i);
2499
+ if (openingDivMatch) {
2500
+ const divAttributes = openingDivMatch[1];
2501
+ // Parse class attribute to preserve WordPress classes
2502
+ const classMatch = divAttributes.match(/class=["']([^"']+)["']/);
2503
+ const styleMatch = divAttributes.match(/style=["']([^"']+)["']/);
2504
+ // Build props for the div
2505
+ const divProps = {};
2506
+ if (classMatch) {
2507
+ divProps.className = classMatch[1];
2508
+ }
2509
+ if (styleMatch) {
2510
+ // Parse inline styles into React style object
2511
+ const styles = {};
2512
+ styleMatch[1].split(';').forEach(style => {
2513
+ const [key, value] = style.split(':').map(s => s.trim());
2514
+ if (key && value) {
2515
+ // Convert CSS property names to camelCase
2516
+ const cssKey = key.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
2517
+ styles[cssKey] = value;
2518
+ }
2519
+ });
2520
+ if (Object.keys(styles).length > 0) {
2521
+ divProps.style = styles;
2522
+ }
2523
+ }
2524
+ // Render with preserved WordPress classes/styles and children
2525
+ return React.createElement('div', divProps, children);
2526
+ }
2527
+ // If we can't parse, fall back to rendering innerHTML as-is
2528
+ // This will preserve structure but children may be duplicated
2529
+ return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } });
2530
+ }
2531
+ // No innerHTML - use custom rendering logic
2494
2532
  const attrs = block.attributes || {};
2495
2533
  const align = attrs['align'];
2496
2534
  // Layout can be an object with type property, or nested structure
@@ -2746,6 +2784,56 @@ function createDefaultRegistry(colorMapper, spacingConfig) {
2746
2784
  // Default fallback if height not found
2747
2785
  return jsxRuntimeExports.jsx("div", { style: { height: '100px' }, "aria-hidden": "true" });
2748
2786
  },
2787
+ // Site Logo block - renders site logo from WordPress settings
2788
+ 'core/site-logo': ({ block, context }) => {
2789
+ const attrs = block.attributes || {};
2790
+ const width = attrs['width'];
2791
+ // Try to get logo from site settings (if available in context)
2792
+ // For now, render innerHTML which WordPress provides
2793
+ if (block.innerHTML) {
2794
+ return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } });
2795
+ }
2796
+ // Fallback: render empty div (logo will be handled by app-level components)
2797
+ return jsxRuntimeExports.jsx("div", { className: "site-logo", style: width ? { width: `${width}px` } : undefined });
2798
+ },
2799
+ // Navigation block - renders WordPress navigation menu
2800
+ 'core/navigation': ({ block, context }) => {
2801
+ // Render innerHTML which WordPress provides (contains the menu HTML with all classes)
2802
+ if (block.innerHTML) {
2803
+ // Extract the nav element from innerHTML to preserve WordPress classes
2804
+ // WordPress renders: <nav class="...">...</nav>
2805
+ return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } });
2806
+ }
2807
+ // Fallback: render empty nav
2808
+ return jsxRuntimeExports.jsx("nav", { "aria-label": "Navigation" });
2809
+ },
2810
+ // Site Title block - renders site title
2811
+ 'core/site-title': ({ block, context }) => {
2812
+ // Render innerHTML which WordPress provides
2813
+ if (block.innerHTML) {
2814
+ return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } });
2815
+ }
2816
+ // Fallback: render site name from context if available
2817
+ return null;
2818
+ },
2819
+ // Site Tagline block - renders site tagline/description
2820
+ 'core/site-tagline': ({ block, context }) => {
2821
+ // Render innerHTML which WordPress provides
2822
+ if (block.innerHTML) {
2823
+ return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } });
2824
+ }
2825
+ // Fallback: render site description from context if available
2826
+ return null;
2827
+ },
2828
+ // Post Date block - renders post date
2829
+ 'core/post-date': ({ block, context }) => {
2830
+ // Render innerHTML which WordPress provides
2831
+ if (block.innerHTML) {
2832
+ return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } });
2833
+ }
2834
+ // Fallback: render current date
2835
+ return null;
2836
+ },
2749
2837
  };
2750
2838
  return {
2751
2839
  renderers,