@marvalt/wparser 0.1.56 → 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 +70 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +70 -10
- 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.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
|
|
@@ -2760,19 +2798,41 @@ function createDefaultRegistry(colorMapper, spacingConfig) {
|
|
|
2760
2798
|
},
|
|
2761
2799
|
// Navigation block - renders WordPress navigation menu
|
|
2762
2800
|
'core/navigation': ({ block, context }) => {
|
|
2763
|
-
|
|
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)
|
|
2801
|
+
// Render innerHTML which WordPress provides (contains the menu HTML with all classes)
|
|
2768
2802
|
if (block.innerHTML) {
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
return (jsxRuntimeExports.jsx("nav", { className: navClasses, "aria-label": ariaLabel || 'Navigation', dangerouslySetInnerHTML: { __html: 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 } });
|
|
2773
2806
|
}
|
|
2774
2807
|
// Fallback: render empty nav
|
|
2775
|
-
return jsxRuntimeExports.jsx("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;
|
|
2776
2836
|
},
|
|
2777
2837
|
};
|
|
2778
2838
|
return {
|