@marvalt/wparser 0.1.73 → 0.1.75

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
@@ -1398,6 +1398,7 @@ function renderBlock(block, registry, key, options, page) {
1398
1398
  page,
1399
1399
  colorMapper: registry.colorMapper,
1400
1400
  spacingConfig: registry.spacingConfig,
1401
+ themePalette: registry.themePalette,
1401
1402
  }
1402
1403
  });
1403
1404
  if (options?.debugWrappers) {
@@ -2277,6 +2278,27 @@ function extractBackgroundColorValue(block, context) {
2277
2278
  }
2278
2279
  return null;
2279
2280
  }
2281
+ /**
2282
+ * Return inline style for background color when no Tailwind class is available.
2283
+ * Supports WordPress custom color (style.color.background) and theme slug (themePalette).
2284
+ *
2285
+ * @param block - WordPress block
2286
+ * @param context - Render context with optional themePalette
2287
+ * @returns React.CSSProperties with backgroundColor or null
2288
+ */
2289
+ function getBackgroundInlineStyle(block, context) {
2290
+ const attrs = block.attributes || {};
2291
+ const styleAttr = attrs['style'];
2292
+ const customBg = styleAttr?.color?.background;
2293
+ if (typeof customBg === 'string' && customBg.trim()) {
2294
+ return { backgroundColor: customBg.trim() };
2295
+ }
2296
+ const wpColorName = attrs['backgroundColor'] || attrs['background'];
2297
+ if (typeof wpColorName === 'string' && context.themePalette?.[wpColorName]) {
2298
+ return { backgroundColor: context.themePalette[wpColorName] };
2299
+ }
2300
+ return null;
2301
+ }
2280
2302
  /**
2281
2303
  * Extract gradient background from block attributes
2282
2304
  * WordPress stores gradients in attributes.style.color.gradient
@@ -2735,11 +2757,12 @@ const Columns = ({ block, children }) => {
2735
2757
  const Column = ({ block, children, context }) => {
2736
2758
  const attrs = block.attributes || {};
2737
2759
  const width = attrs['width'];
2738
- // Extract background color using color mapper
2760
+ // Extract background color using color mapper (Tailwind class)
2739
2761
  const backgroundColor = extractBackgroundColor(block, context);
2740
- // Handle column width (e.g., "50%" becomes flex-basis)
2741
- const style = width ? { flexBasis: width } : undefined;
2742
- return (jsxRuntimeExports.jsx("div", { className: buildClassName('space-y-4 p-6 rounded-lg', backgroundColor), style: style, children: children }));
2762
+ // Inline background when no class (custom color or theme slug via themePalette)
2763
+ const backgroundStyle = getBackgroundInlineStyle(block, context);
2764
+ const style = { ...(width ? { flexBasis: width } : {}), ...(backgroundStyle || {}) };
2765
+ return (jsxRuntimeExports.jsx("div", { className: buildClassName('space-y-4 p-6 rounded-lg', backgroundColor), style: Object.keys(style).length ? style : undefined, children: children }));
2743
2766
  };
2744
2767
  const Separator = () => jsxRuntimeExports.jsx("hr", { className: "border-gray-200 my-8" });
2745
2768
  const ButtonBlock = ({ block, context }) => {
@@ -3366,6 +3389,7 @@ exports.extractVideoIframeFromInnerBlocks = extractVideoIframeFromInnerBlocks;
3366
3389
  exports.findMatchingMapping = findMatchingMapping;
3367
3390
  exports.findShortcodes = findShortcodes;
3368
3391
  exports.getAlignmentClasses = getAlignmentClasses;
3392
+ exports.getBackgroundInlineStyle = getBackgroundInlineStyle;
3369
3393
  exports.getBlockTextContent = getBlockTextContent;
3370
3394
  exports.getCloudflareVariantUrl = getCloudflareVariantUrl;
3371
3395
  exports.getContainerClasses = getContainerClasses;