@marvalt/wparser 0.1.54 → 0.1.56

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
@@ -2338,6 +2338,9 @@ const Paragraph = ({ block, context }) => {
2338
2338
  const attrs = block.attributes || {};
2339
2339
  const textAlign = getTextAlignClasses(attrs['align']);
2340
2340
  const spacing = getSpacing(context.spacingConfig || context.registry.spacingConfig, 'paragraph', 'my-6');
2341
+ // Extract text color if specified, otherwise inherit from parent (CSS variables handle default)
2342
+ const textColor = extractTextColor(block, context);
2343
+ const textColorClass = textColor || ''; // Don't hardcode - let CSS variables handle default
2341
2344
  // Check if innerHTML contains HTML elements (like links, strong, em, etc.)
2342
2345
  const hasHTML = block.innerHTML && /<[a-z][\s\S]*>/i.test(block.innerHTML);
2343
2346
  // Check if content contains shortcodes (check both HTML and text content)
@@ -2373,17 +2376,17 @@ const Paragraph = ({ block, context }) => {
2373
2376
  const hasBlockLevelContent = React.Children.toArray(parts).some((part) => isBlockLevelElement(part));
2374
2377
  if (hasBlockLevelContent) {
2375
2378
  // Render block-level content without <p> wrapper, but add spacing wrapper
2376
- return jsxRuntimeExports.jsx("div", { className: spacing, children: parts });
2379
+ return jsxRuntimeExports.jsx("div", { className: buildClassName(spacing, textColorClass), children: parts });
2377
2380
  }
2378
2381
  // Render shortcode parts inside paragraph (shortcodes are processed as React components)
2379
- return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), children: parts });
2382
+ return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign, textColorClass), children: parts });
2380
2383
  }
2381
2384
  // If innerHTML contains HTML elements but no shortcodes, render it directly (preserves links, formatting, etc.)
2382
2385
  if (hasHTML && block.innerHTML) {
2383
- return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), dangerouslySetInnerHTML: { __html: htmlContent } });
2386
+ return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign, textColorClass), dangerouslySetInnerHTML: { __html: htmlContent } });
2384
2387
  }
2385
2388
  // No HTML and no shortcodes, just render plain text content
2386
- return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), children: textContent });
2389
+ return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign, textColorClass), children: textContent });
2387
2390
  };
2388
2391
  const Heading = ({ block, children, context }) => {
2389
2392
  const attrs = block.attributes || {};
@@ -2698,12 +2701,32 @@ function createDefaultRegistry(colorMapper, spacingConfig) {
2698
2701
  'justify-start';
2699
2702
  return jsxRuntimeExports.jsx("div", { className: buildClassName('flex flex-wrap gap-3', justifyClass), children: children });
2700
2703
  },
2701
- 'core/quote': ({ children }) => jsxRuntimeExports.jsx("blockquote", { className: "border-l-4 pl-4 italic", children: children }),
2702
- 'core/code': ({ block }) => (jsxRuntimeExports.jsx("pre", { className: "bg-gray-100 p-3 rounded text-sm overflow-auto", children: jsxRuntimeExports.jsx("code", { children: getString(block) }) })),
2703
- 'core/preformatted': ({ block }) => jsxRuntimeExports.jsx("pre", { children: getString(block) }),
2704
+ 'core/quote': ({ block, children, context }) => {
2705
+ // Extract text color if specified, otherwise inherit from parent
2706
+ const textColor = extractTextColor(block, context);
2707
+ const textColorClass = textColor || '';
2708
+ return jsxRuntimeExports.jsx("blockquote", { className: buildClassName('border-l-4 pl-4 italic', textColorClass), children: children });
2709
+ },
2710
+ 'core/code': ({ block, context }) => {
2711
+ // Extract text color if specified, otherwise inherit from parent
2712
+ const textColor = extractTextColor(block, context);
2713
+ const textColorClass = textColor || '';
2714
+ return (jsxRuntimeExports.jsx("pre", { className: buildClassName('bg-gray-100 p-3 rounded text-sm overflow-auto', textColorClass), children: jsxRuntimeExports.jsx("code", { children: getString(block) }) }));
2715
+ },
2716
+ 'core/preformatted': ({ block, context }) => {
2717
+ // Extract text color if specified, otherwise inherit from parent
2718
+ const textColor = extractTextColor(block, context);
2719
+ const textColorClass = textColor || '';
2720
+ return jsxRuntimeExports.jsx("pre", { className: textColorClass || undefined, children: getString(block) });
2721
+ },
2704
2722
  'core/table': ({ children }) => jsxRuntimeExports.jsx("div", { className: "overflow-x-auto", children: jsxRuntimeExports.jsx("table", { className: "table-auto w-full", children: children }) }),
2705
2723
  'core/table-row': ({ children }) => jsxRuntimeExports.jsx("tr", { children: children }),
2706
- 'core/table-cell': ({ children }) => jsxRuntimeExports.jsx("td", { className: "border px-3 py-2", children: children }),
2724
+ 'core/table-cell': ({ block, children, context }) => {
2725
+ // Extract text color if specified, otherwise inherit from parent
2726
+ const textColor = extractTextColor(block, context);
2727
+ const textColorClass = textColor || '';
2728
+ return jsxRuntimeExports.jsx("td", { className: buildClassName('border px-3 py-2', textColorClass), children: children });
2729
+ },
2707
2730
  // Cover block - hero sections with background images
2708
2731
  'core/cover': Cover,
2709
2732
  // Media & Text block - side-by-side media and content
@@ -2723,6 +2746,34 @@ function createDefaultRegistry(colorMapper, spacingConfig) {
2723
2746
  // Default fallback if height not found
2724
2747
  return jsxRuntimeExports.jsx("div", { style: { height: '100px' }, "aria-hidden": "true" });
2725
2748
  },
2749
+ // Site Logo block - renders site logo from WordPress settings
2750
+ 'core/site-logo': ({ block, context }) => {
2751
+ const attrs = block.attributes || {};
2752
+ const width = attrs['width'];
2753
+ // Try to get logo from site settings (if available in context)
2754
+ // For now, render innerHTML which WordPress provides
2755
+ if (block.innerHTML) {
2756
+ return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } });
2757
+ }
2758
+ // Fallback: render empty div (logo will be handled by app-level components)
2759
+ return jsxRuntimeExports.jsx("div", { className: "site-logo", style: width ? { width: `${width}px` } : undefined });
2760
+ },
2761
+ // Navigation block - renders WordPress navigation menu
2762
+ 'core/navigation': ({ block, context }) => {
2763
+ const attrs = block.attributes || {};
2764
+ const layout = attrs['layout'];
2765
+ const orientation = layout?.orientation || 'horizontal';
2766
+ const ariaLabel = attrs['ariaLabel'];
2767
+ // Render innerHTML which WordPress provides (contains the menu HTML)
2768
+ if (block.innerHTML) {
2769
+ const navClasses = orientation === 'vertical'
2770
+ ? 'flex flex-col space-y-2'
2771
+ : 'flex flex-wrap gap-4';
2772
+ return (jsxRuntimeExports.jsx("nav", { className: navClasses, "aria-label": ariaLabel || 'Navigation', dangerouslySetInnerHTML: { __html: block.innerHTML } }));
2773
+ }
2774
+ // Fallback: render empty nav
2775
+ return jsxRuntimeExports.jsx("nav", { className: "flex flex-wrap gap-4", "aria-label": ariaLabel || 'Navigation' });
2776
+ },
2726
2777
  };
2727
2778
  return {
2728
2779
  renderers,