@marvalt/wparser 0.1.40 → 0.1.41
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 +34 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +34 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/blockExtractors.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2083,13 +2083,45 @@ function extractVideoIframeFromInnerBlocks(block) {
|
|
|
2083
2083
|
*/
|
|
2084
2084
|
function extractBackgroundColor(block, context) {
|
|
2085
2085
|
const attrs = block.attributes || {};
|
|
2086
|
-
|
|
2086
|
+
// Try multiple possible attribute names for background color
|
|
2087
|
+
// WordPress can store it as backgroundColor, background, or in style
|
|
2088
|
+
let wpColorName = attrs['backgroundColor'] ||
|
|
2089
|
+
attrs['background'] ||
|
|
2090
|
+
attrs['backgroundColorSlug'] ||
|
|
2091
|
+
null;
|
|
2092
|
+
// If not found in attributes, check className for WordPress color classes
|
|
2093
|
+
// WordPress uses classes like: has-accent-4-background-color, has-contrast-background-color
|
|
2094
|
+
if (!wpColorName && attrs['className']) {
|
|
2095
|
+
const className = attrs['className'];
|
|
2096
|
+
const colorMatch = className.match(/has-([\w-]+)-background-color/);
|
|
2097
|
+
if (colorMatch && colorMatch[1]) {
|
|
2098
|
+
// Convert kebab-case to slug (e.g., "accent-4" stays "accent-4", "contrast" stays "contrast")
|
|
2099
|
+
wpColorName = colorMatch[1];
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
// Debug logging in development
|
|
2103
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development') {
|
|
2104
|
+
if (!wpColorName && context.colorMapper) {
|
|
2105
|
+
console.log('🔍 extractBackgroundColor - No backgroundColor found in block:', {
|
|
2106
|
+
blockName: block.name,
|
|
2107
|
+
hasClassName: !!attrs['className'],
|
|
2108
|
+
className: attrs['className'],
|
|
2109
|
+
hasStyle: !!attrs['style'],
|
|
2110
|
+
availableAttrs: Object.keys(attrs),
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2087
2114
|
if (!wpColorName || typeof wpColorName !== 'string') {
|
|
2088
2115
|
return null;
|
|
2089
2116
|
}
|
|
2090
2117
|
// Use colorMapper from context if available
|
|
2091
2118
|
if (context.colorMapper) {
|
|
2092
|
-
|
|
2119
|
+
const result = context.colorMapper(wpColorName);
|
|
2120
|
+
// Debug logging
|
|
2121
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development') {
|
|
2122
|
+
console.log('🎨 extractBackgroundColor - Mapped', wpColorName, '→', result);
|
|
2123
|
+
}
|
|
2124
|
+
return result;
|
|
2093
2125
|
}
|
|
2094
2126
|
// Fallback: return null (no background applied)
|
|
2095
2127
|
return null;
|