@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.d.ts CHANGED
@@ -51,6 +51,8 @@ interface RenderContext {
51
51
  page?: WordPressPageMinimal;
52
52
  colorMapper?: ColorMapper;
53
53
  spacingConfig?: SpacingConfig;
54
+ /** WordPress theme color slug to hex/rgb for resolving background/text colors when colorMapper has no mapping */
55
+ themePalette?: Record<string, string>;
54
56
  }
55
57
  interface BlockRendererProps {
56
58
  block: WordPressBlock;
@@ -73,6 +75,8 @@ interface ComponentRegistry {
73
75
  colorMapper?: ColorMapper;
74
76
  /** Optional spacing configuration for customizing element spacing */
75
77
  spacingConfig?: SpacingConfig;
78
+ /** Optional WordPress theme color slug to hex/rgb for block background/text resolution */
79
+ themePalette?: Record<string, string>;
76
80
  }
77
81
  /**
78
82
  * Pattern matching for blocks - allows matching blocks by name and attributes
@@ -510,6 +514,15 @@ declare function extractBackgroundColor(block: WordPressBlock, context: RenderCo
510
514
  declare function extractBackgroundColorValue(block: WordPressBlock, context: RenderContext & {
511
515
  themePalette?: Record<string, string>;
512
516
  }): string | null;
517
+ /**
518
+ * Return inline style for background color when no Tailwind class is available.
519
+ * Supports WordPress custom color (style.color.background) and theme slug (themePalette).
520
+ *
521
+ * @param block - WordPress block
522
+ * @param context - Render context with optional themePalette
523
+ * @returns React.CSSProperties with backgroundColor or null
524
+ */
525
+ declare function getBackgroundInlineStyle(block: WordPressBlock, context: RenderContext): React$1.CSSProperties | null;
513
526
  /**
514
527
  * Extract gradient background from block attributes
515
528
  * WordPress stores gradients in attributes.style.color.gradient
@@ -585,5 +598,5 @@ interface SectionWrapperProps {
585
598
  */
586
599
  declare const SectionWrapper: React$1.FC<SectionWrapperProps>;
587
600
 
588
- export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundColorValue, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractGradientBackground, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractTitleTextColorFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
601
+ export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundColorValue, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractGradientBackground, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractTitleTextColorFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBackgroundInlineStyle, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
589
602
  export type { AuthMode, BlockPattern, BlockRenderer, BlockRendererProps, CloudflareVariantOptions, ColorMapper, ComponentMapping, ComponentRegistry, EnhancedRegistry, ImageConversionOptions, ParseOptions, ParsedShortcode, RenderContext, RenderOptions, SectionWrapperProps, ShortcodeAttributes, ShortcodeRenderer, SpacingConfig, WPContentProps, WPNode, WPPageProps, WordPressBlock, WordPressEmbedded, WordPressFeaturedMedia, WordPressPageMinimal, WordPressTitleField };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACtI,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,EACpC,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACtI,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,EACpC,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1396,6 +1396,7 @@ function renderBlock(block, registry, key, options, page) {
1396
1396
  page,
1397
1397
  colorMapper: registry.colorMapper,
1398
1398
  spacingConfig: registry.spacingConfig,
1399
+ themePalette: registry.themePalette,
1399
1400
  }
1400
1401
  });
1401
1402
  if (options?.debugWrappers) {
@@ -2275,6 +2276,27 @@ function extractBackgroundColorValue(block, context) {
2275
2276
  }
2276
2277
  return null;
2277
2278
  }
2279
+ /**
2280
+ * Return inline style for background color when no Tailwind class is available.
2281
+ * Supports WordPress custom color (style.color.background) and theme slug (themePalette).
2282
+ *
2283
+ * @param block - WordPress block
2284
+ * @param context - Render context with optional themePalette
2285
+ * @returns React.CSSProperties with backgroundColor or null
2286
+ */
2287
+ function getBackgroundInlineStyle(block, context) {
2288
+ const attrs = block.attributes || {};
2289
+ const styleAttr = attrs['style'];
2290
+ const customBg = styleAttr?.color?.background;
2291
+ if (typeof customBg === 'string' && customBg.trim()) {
2292
+ return { backgroundColor: customBg.trim() };
2293
+ }
2294
+ const wpColorName = attrs['backgroundColor'] || attrs['background'];
2295
+ if (typeof wpColorName === 'string' && context.themePalette?.[wpColorName]) {
2296
+ return { backgroundColor: context.themePalette[wpColorName] };
2297
+ }
2298
+ return null;
2299
+ }
2278
2300
  /**
2279
2301
  * Extract gradient background from block attributes
2280
2302
  * WordPress stores gradients in attributes.style.color.gradient
@@ -2733,11 +2755,12 @@ const Columns = ({ block, children }) => {
2733
2755
  const Column = ({ block, children, context }) => {
2734
2756
  const attrs = block.attributes || {};
2735
2757
  const width = attrs['width'];
2736
- // Extract background color using color mapper
2758
+ // Extract background color using color mapper (Tailwind class)
2737
2759
  const backgroundColor = extractBackgroundColor(block, context);
2738
- // Handle column width (e.g., "50%" becomes flex-basis)
2739
- const style = width ? { flexBasis: width } : undefined;
2740
- return (jsxRuntimeExports.jsx("div", { className: buildClassName('space-y-4 p-6 rounded-lg', backgroundColor), style: style, children: children }));
2760
+ // Inline background when no class (custom color or theme slug via themePalette)
2761
+ const backgroundStyle = getBackgroundInlineStyle(block, context);
2762
+ const style = { ...(width ? { flexBasis: width } : {}), ...(backgroundStyle || {}) };
2763
+ return (jsxRuntimeExports.jsx("div", { className: buildClassName('space-y-4 p-6 rounded-lg', backgroundColor), style: Object.keys(style).length ? style : undefined, children: children }));
2741
2764
  };
2742
2765
  const Separator = () => jsxRuntimeExports.jsx("hr", { className: "border-gray-200 my-8" });
2743
2766
  const ButtonBlock = ({ block, context }) => {
@@ -3324,5 +3347,5 @@ const SectionWrapper = ({ children, background = 'light', spacing = 'medium', co
3324
3347
  return (jsxRuntimeExports.jsx("section", { className: buildClassName(backgroundClasses[finalBackground] || backgroundClasses.light, spacingClasses[finalSpacing] || spacingClasses.medium, containerClasses[finalContainer] || containerClasses.contained, className), children: children }));
3325
3348
  };
3326
3349
 
3327
- export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundColorValue, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractGradientBackground, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractTitleTextColorFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
3350
+ export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundColorValue, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractGradientBackground, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractTitleTextColorFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBackgroundInlineStyle, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
3328
3351
  //# sourceMappingURL=index.esm.js.map