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