@marvalt/wparser 0.1.51 → 0.1.53
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 +33 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +33 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/registry/defaultRegistry.d.ts.map +1 -1
- package/dist/utils/blockExtractors.d.ts +11 -0
- package/dist/utils/blockExtractors.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -484,6 +484,17 @@ declare function extractVideoIframeFromInnerBlocks(block: WordPressBlock): strin
|
|
|
484
484
|
* ```
|
|
485
485
|
*/
|
|
486
486
|
declare function extractBackgroundColor(block: WordPressBlock, context: RenderContext): string | null;
|
|
487
|
+
/**
|
|
488
|
+
* Extract the actual color value (hex/rgb) from background color attribute
|
|
489
|
+
* Used to check if a section has a custom background color that should override alternating system
|
|
490
|
+
*
|
|
491
|
+
* @param block - WordPress block to extract background color value from
|
|
492
|
+
* @param context - Render context containing optional themePalette
|
|
493
|
+
* @returns Color value string (e.g., '#eb8900') or null if no color
|
|
494
|
+
*/
|
|
495
|
+
declare function extractBackgroundColorValue(block: WordPressBlock, context: RenderContext & {
|
|
496
|
+
themePalette?: Record<string, string>;
|
|
497
|
+
}): string | null;
|
|
487
498
|
/**
|
|
488
499
|
* Extract and map text color from block attributes
|
|
489
500
|
* Uses colorMapper from context to convert WordPress theme colors to app CSS classes
|
|
@@ -550,5 +561,5 @@ interface SectionWrapperProps {
|
|
|
550
561
|
*/
|
|
551
562
|
declare const SectionWrapper: React$1.FC<SectionWrapperProps>;
|
|
552
563
|
|
|
553
|
-
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
564
|
+
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundColorValue, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
554
565
|
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 };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,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,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -2092,6 +2092,28 @@ function extractBackgroundColor(block, context) {
|
|
|
2092
2092
|
// Fallback: return null (no background applied)
|
|
2093
2093
|
return null;
|
|
2094
2094
|
}
|
|
2095
|
+
/**
|
|
2096
|
+
* Extract the actual color value (hex/rgb) from background color attribute
|
|
2097
|
+
* Used to check if a section has a custom background color that should override alternating system
|
|
2098
|
+
*
|
|
2099
|
+
* @param block - WordPress block to extract background color value from
|
|
2100
|
+
* @param context - Render context containing optional themePalette
|
|
2101
|
+
* @returns Color value string (e.g., '#eb8900') or null if no color
|
|
2102
|
+
*/
|
|
2103
|
+
function extractBackgroundColorValue(block, context) {
|
|
2104
|
+
const attrs = block.attributes || {};
|
|
2105
|
+
const wpColorName = attrs['backgroundColor'] || attrs['background'];
|
|
2106
|
+
if (!wpColorName || typeof wpColorName !== 'string') {
|
|
2107
|
+
return null;
|
|
2108
|
+
}
|
|
2109
|
+
// If themePalette is available, get the actual color value
|
|
2110
|
+
if (context.themePalette?.[wpColorName]) {
|
|
2111
|
+
const color = context.themePalette[wpColorName];
|
|
2112
|
+
// Return the color value (could be hex, rgb, or other CSS color format)
|
|
2113
|
+
return color;
|
|
2114
|
+
}
|
|
2115
|
+
return null;
|
|
2116
|
+
}
|
|
2095
2117
|
/**
|
|
2096
2118
|
* Extract and map text color from block attributes
|
|
2097
2119
|
* Uses colorMapper from context to convert WordPress theme colors to app CSS classes
|
|
@@ -2117,13 +2139,17 @@ function extractTextColor(block, context) {
|
|
|
2117
2139
|
return textColorMap[wpColorName];
|
|
2118
2140
|
}
|
|
2119
2141
|
// Use colorMapper from context if available
|
|
2120
|
-
// Note: colorMapper might return combined classes like "bg-gray-900 text-white"
|
|
2121
|
-
// We'll extract just the text color part
|
|
2142
|
+
// Note: colorMapper might return combined classes like "bg-gray-900 text-white" or "bg-[#eb8900] text-[#eb8900] text-white"
|
|
2143
|
+
// We'll extract just the text color part, prioritizing actual color values over generic classes
|
|
2122
2144
|
if (context.colorMapper) {
|
|
2123
2145
|
const mapped = context.colorMapper(wpColorName);
|
|
2124
2146
|
if (mapped) {
|
|
2125
|
-
//
|
|
2126
|
-
|
|
2147
|
+
// First, try to extract text-[#color] (actual color value)
|
|
2148
|
+
const textColorValueMatch = mapped.match(/\btext-\[([^\]]+)\]/);
|
|
2149
|
+
if (textColorValueMatch) {
|
|
2150
|
+
return `text-[${textColorValueMatch[1]}]`;
|
|
2151
|
+
}
|
|
2152
|
+
// Then, try to extract generic text color classes (e.g., "text-white", "text-gray-900")
|
|
2127
2153
|
const textColorMatch = mapped.match(/\btext-\S+/);
|
|
2128
2154
|
if (textColorMatch) {
|
|
2129
2155
|
return textColorMatch[0];
|
|
@@ -2335,7 +2361,8 @@ const Heading = ({ block, children, context }) => {
|
|
|
2335
2361
|
// Extract text color if specified, otherwise inherit from parent (CSS variables handle default)
|
|
2336
2362
|
const textColor = extractTextColor(block, context);
|
|
2337
2363
|
const textColorClass = textColor || ''; // Don't hardcode - let CSS variables handle default
|
|
2338
|
-
|
|
2364
|
+
// Don't hardcode font-bold - let CSS variables handle font weight from WordPress
|
|
2365
|
+
return (jsxRuntimeExports.jsx(Tag, { className: buildClassName(textColorClass, sizeClass, textAlign, spacingClass), children: children ?? content }));
|
|
2339
2366
|
};
|
|
2340
2367
|
const Image = ({ block, context }) => {
|
|
2341
2368
|
const imageAttrs = getImageAttributes(block);
|
|
@@ -2972,5 +2999,5 @@ const SectionWrapper = ({ children, background = 'light', spacing = 'medium', co
|
|
|
2972
2999
|
return (jsxRuntimeExports.jsx("section", { className: buildClassName(backgroundClasses[finalBackground] || backgroundClasses.light, spacingClasses[finalSpacing] || spacingClasses.medium, containerClasses[finalContainer] || containerClasses.contained, className), children: children }));
|
|
2973
3000
|
};
|
|
2974
3001
|
|
|
2975
|
-
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
3002
|
+
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundColorValue, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextColor, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
2976
3003
|
//# sourceMappingURL=index.esm.js.map
|