@marvalt/wparser 0.1.42 → 0.1.43

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.esm.js CHANGED
@@ -2150,16 +2150,21 @@ function extractTextColor(block, context) {
2150
2150
  if (colorMatch && colorMatch[1]) {
2151
2151
  wpColorName = colorMatch[1];
2152
2152
  }
2153
- // Debug logging
2154
- if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development' && !wpColorName) {
2155
- // Check if there are any color-related classes
2156
- const hasColorClass = className.includes('-color');
2157
- if (hasColorClass && context.colorMapper) {
2158
- console.log('🔍 extractTextColor - Found color class in className but no match:', {
2159
- blockName: block.name,
2160
- className: className,
2161
- colorClasses: className.split(' ').filter(c => c.includes('-color')),
2162
- });
2153
+ // Enhanced debug logging
2154
+ if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development') {
2155
+ if (!wpColorName) {
2156
+ const hasColorClass = className.includes('-color');
2157
+ if (hasColorClass && context.colorMapper) {
2158
+ console.log('🔍 extractTextColor - Found color class in className but no match:', {
2159
+ blockName: block.name,
2160
+ className: className,
2161
+ colorClasses: className.split(' ').filter(c => c.includes('-color')),
2162
+ allAttrs: Object.keys(attrs),
2163
+ });
2164
+ }
2165
+ }
2166
+ else {
2167
+ console.log('✅ extractTextColor - Found color in className:', wpColorName);
2163
2168
  }
2164
2169
  }
2165
2170
  }
@@ -2333,6 +2338,9 @@ const Paragraph = ({ block, context }) => {
2333
2338
  const attrs = block.attributes || {};
2334
2339
  const textAlign = getTextAlignClasses(attrs['align']);
2335
2340
  const spacing = getSpacing(context.spacingConfig || context.registry.spacingConfig, 'paragraph', 'my-6');
2341
+ // Extract text color if specified
2342
+ const textColor = extractTextColor(block, context);
2343
+ const textColorClass = textColor || '';
2336
2344
  // Check if innerHTML contains HTML elements (like links, strong, em, etc.)
2337
2345
  const hasHTML = block.innerHTML && /<[a-z][\s\S]*>/i.test(block.innerHTML);
2338
2346
  // Check if content contains shortcodes (check both HTML and text content)
@@ -2368,17 +2376,17 @@ const Paragraph = ({ block, context }) => {
2368
2376
  const hasBlockLevelContent = React.Children.toArray(parts).some((part) => isBlockLevelElement(part));
2369
2377
  if (hasBlockLevelContent) {
2370
2378
  // Render block-level content without <p> wrapper, but add spacing wrapper
2371
- return jsxRuntimeExports.jsx("div", { className: spacing, children: parts });
2379
+ return jsxRuntimeExports.jsx("div", { className: buildClassName(spacing, textColorClass), children: parts });
2372
2380
  }
2373
2381
  // Render shortcode parts inside paragraph (shortcodes are processed as React components)
2374
- return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), children: parts });
2382
+ return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign, textColorClass), children: parts });
2375
2383
  }
2376
2384
  // If innerHTML contains HTML elements but no shortcodes, render it directly (preserves links, formatting, etc.)
2377
2385
  if (hasHTML && block.innerHTML) {
2378
- return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), dangerouslySetInnerHTML: { __html: htmlContent } });
2386
+ return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign, textColorClass), dangerouslySetInnerHTML: { __html: htmlContent } });
2379
2387
  }
2380
2388
  // No HTML and no shortcodes, just render plain text content
2381
- return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), children: textContent });
2389
+ return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign, textColorClass), children: textContent });
2382
2390
  };
2383
2391
  const Heading = ({ block, children, context }) => {
2384
2392
  const attrs = block.attributes || {};