@marvalt/wparser 0.1.30 → 0.1.31
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 +51 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +51 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/registry/defaultRegistry.d.ts.map +1 -1
- package/dist/utils/blockExtractors.d.ts +9 -0
- package/dist/utils/blockExtractors.d.ts.map +1 -1
- package/package.json +1 -1
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,MAAM,0BAA0B,CAAC;AAClH,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,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,MAAM,0BAA0B,CAAC;AAClH,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"}
|
package/dist/index.esm.js
CHANGED
|
@@ -2057,6 +2057,38 @@ function extractBackgroundColor(block, context) {
|
|
|
2057
2057
|
// Fallback: return null (no background applied)
|
|
2058
2058
|
return null;
|
|
2059
2059
|
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Extract and map text color from block attributes
|
|
2062
|
+
* Uses colorMapper from context to convert WordPress theme colors to app CSS classes
|
|
2063
|
+
*
|
|
2064
|
+
* @param block - WordPress block to extract text color from
|
|
2065
|
+
* @param context - Render context containing optional colorMapper
|
|
2066
|
+
* @returns CSS class string (e.g., 'text-white') or null if no mapping
|
|
2067
|
+
*/
|
|
2068
|
+
function extractTextColor(block, context) {
|
|
2069
|
+
const attrs = block.attributes || {};
|
|
2070
|
+
const wpColorName = attrs['textColor'] || attrs['text'];
|
|
2071
|
+
if (!wpColorName || typeof wpColorName !== 'string') {
|
|
2072
|
+
return null;
|
|
2073
|
+
}
|
|
2074
|
+
// Use colorMapper from context if available
|
|
2075
|
+
// Note: colorMapper might return combined classes like "bg-gray-900 text-white"
|
|
2076
|
+
// We'll extract just the text color part, or create a separate text color mapping
|
|
2077
|
+
if (context.colorMapper) {
|
|
2078
|
+
const mapped = context.colorMapper(wpColorName);
|
|
2079
|
+
if (mapped) {
|
|
2080
|
+
// If the mapped class includes text color (e.g., "bg-gray-900 text-white"),
|
|
2081
|
+
// extract just the text color part
|
|
2082
|
+
const textColorMatch = mapped.match(/\btext-\S+/);
|
|
2083
|
+
if (textColorMatch) {
|
|
2084
|
+
return textColorMatch[0];
|
|
2085
|
+
}
|
|
2086
|
+
// If no text color in the mapped class, try to infer from the color name
|
|
2087
|
+
// For now, return null and let the app handle it via a separate text color mapper
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
return null;
|
|
2091
|
+
}
|
|
2060
2092
|
/**
|
|
2061
2093
|
* Extract spacer height from block attributes or innerHTML
|
|
2062
2094
|
* Returns height in pixels, or null if not found
|
|
@@ -2268,7 +2300,11 @@ const List = ({ block, children, context }) => {
|
|
|
2268
2300
|
const { ordered } = attrs;
|
|
2269
2301
|
const Tag = ordered ? 'ol' : 'ul';
|
|
2270
2302
|
const spacing = getSpacing(context.spacingConfig || context.registry.spacingConfig, 'list', 'my-6');
|
|
2271
|
-
|
|
2303
|
+
// Extract text color if specified
|
|
2304
|
+
const textColor = extractTextColor(block, context);
|
|
2305
|
+
// Default text color if none specified
|
|
2306
|
+
const textColorClass = textColor || 'text-gray-700';
|
|
2307
|
+
return React.createElement(Tag, { className: buildClassName('list-disc pl-6 space-y-2', textColorClass, spacing) }, children);
|
|
2272
2308
|
};
|
|
2273
2309
|
const ListItem = ({ block, children }) => {
|
|
2274
2310
|
// List items store their content in innerHTML (e.g., "<li>Text<br>More text</li>")
|
|
@@ -2324,15 +2360,17 @@ const Columns = ({ block, children }) => {
|
|
|
2324
2360
|
const alignClass = getAlignmentClasses(align);
|
|
2325
2361
|
return (jsxRuntimeExports.jsx("div", { className: buildClassName('grid grid-cols-1 md:grid-cols-2 gap-6 lg:gap-12', alignClass), children: children }));
|
|
2326
2362
|
};
|
|
2327
|
-
const Column = ({ block, children }) => {
|
|
2363
|
+
const Column = ({ block, children, context }) => {
|
|
2328
2364
|
const attrs = block.attributes || {};
|
|
2329
2365
|
const width = attrs['width'];
|
|
2366
|
+
// Extract background color using color mapper
|
|
2367
|
+
const backgroundColor = extractBackgroundColor(block, context);
|
|
2330
2368
|
// Handle column width (e.g., "50%" becomes flex-basis)
|
|
2331
2369
|
const style = width ? { flexBasis: width } : undefined;
|
|
2332
|
-
return (jsxRuntimeExports.jsx("div", { className:
|
|
2370
|
+
return (jsxRuntimeExports.jsx("div", { className: buildClassName('space-y-4 p-6 rounded-lg', backgroundColor), style: style, children: children }));
|
|
2333
2371
|
};
|
|
2334
2372
|
const Separator = () => jsxRuntimeExports.jsx("hr", { className: "border-gray-200 my-8" });
|
|
2335
|
-
const ButtonBlock = ({ block }) => {
|
|
2373
|
+
const ButtonBlock = ({ block, context }) => {
|
|
2336
2374
|
const attrs = block.attributes || {};
|
|
2337
2375
|
let url = attrs['url'];
|
|
2338
2376
|
let text = attrs['text'];
|
|
@@ -2352,10 +2390,17 @@ const ButtonBlock = ({ block }) => {
|
|
|
2352
2390
|
if (!url && !text)
|
|
2353
2391
|
return null;
|
|
2354
2392
|
const buttonText = text || 'Learn more';
|
|
2393
|
+
// Extract background and text colors from button attributes
|
|
2394
|
+
const backgroundColor = extractBackgroundColor(block, context);
|
|
2395
|
+
const textColor = extractTextColor(block, context);
|
|
2396
|
+
// Build button classes - use extracted colors or defaults
|
|
2397
|
+
const bgClass = backgroundColor || 'bg-primary';
|
|
2398
|
+
const textClass = textColor || 'text-primary-foreground';
|
|
2399
|
+
const hoverClass = backgroundColor ? 'hover:opacity-90' : 'hover:bg-primary/90';
|
|
2355
2400
|
// Handle internal vs external links
|
|
2356
2401
|
const isExternal = url && (url.startsWith('http://') || url.startsWith('https://'));
|
|
2357
2402
|
const linkProps = isExternal ? { target: '_blank', rel: 'noopener noreferrer' } : {};
|
|
2358
|
-
return (jsxRuntimeExports.jsx("a", { href: url || '#', className:
|
|
2403
|
+
return (jsxRuntimeExports.jsx("a", { href: url || '#', className: buildClassName('inline-flex items-center justify-center rounded-md px-6 py-3 font-medium transition-colors', bgClass, textClass, hoverClass), ...linkProps, children: buttonText }));
|
|
2359
2404
|
};
|
|
2360
2405
|
const Cover = ({ block, children }) => {
|
|
2361
2406
|
const attrs = block.attributes || {};
|
|
@@ -2833,5 +2878,5 @@ const SectionWrapper = ({ children, background = 'light', spacing = 'medium', co
|
|
|
2833
2878
|
return (jsxRuntimeExports.jsx("section", { className: buildClassName(backgroundClasses[finalBackground] || backgroundClasses.light, spacingClasses[finalSpacing] || spacingClasses.medium, containerClasses[finalContainer] || containerClasses.contained, className), children: children }));
|
|
2834
2879
|
};
|
|
2835
2880
|
|
|
2836
|
-
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, 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 };
|
|
2881
|
+
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 };
|
|
2837
2882
|
//# sourceMappingURL=index.esm.js.map
|