@marvalt/wparser 0.1.31 → 0.1.32
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.esm.js
CHANGED
|
@@ -2073,7 +2073,7 @@ function extractTextColor(block, context) {
|
|
|
2073
2073
|
}
|
|
2074
2074
|
// Use colorMapper from context if available
|
|
2075
2075
|
// Note: colorMapper might return combined classes like "bg-gray-900 text-white"
|
|
2076
|
-
// We'll extract just the text color part
|
|
2076
|
+
// We'll extract just the text color part
|
|
2077
2077
|
if (context.colorMapper) {
|
|
2078
2078
|
const mapped = context.colorMapper(wpColorName);
|
|
2079
2079
|
if (mapped) {
|
|
@@ -2083,11 +2083,15 @@ function extractTextColor(block, context) {
|
|
|
2083
2083
|
if (textColorMatch) {
|
|
2084
2084
|
return textColorMatch[0];
|
|
2085
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
2086
|
}
|
|
2089
2087
|
}
|
|
2090
|
-
|
|
2088
|
+
// Special handling for common WordPress color names when used as text color
|
|
2089
|
+
// These are common text color mappings that might not be in the colorMapper
|
|
2090
|
+
const textColorMap = {
|
|
2091
|
+
'contrast': 'text-gray-900', // Contrast text is typically dark/black
|
|
2092
|
+
'base': 'text-white', // Base text on dark backgrounds
|
|
2093
|
+
};
|
|
2094
|
+
return textColorMap[wpColorName] || null;
|
|
2091
2095
|
}
|
|
2092
2096
|
/**
|
|
2093
2097
|
* Extract spacer height from block attributes or innerHTML
|
|
@@ -2264,9 +2268,11 @@ const Paragraph = ({ block, context }) => {
|
|
|
2264
2268
|
// Render block-level content without <p> wrapper, but add spacing wrapper
|
|
2265
2269
|
return jsxRuntimeExports.jsx("div", { className: spacing, children: parts });
|
|
2266
2270
|
}
|
|
2267
|
-
|
|
2271
|
+
// Don't hardcode text color - let it inherit from parent (e.g., column with background color)
|
|
2272
|
+
return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), children: parts });
|
|
2268
2273
|
}
|
|
2269
|
-
|
|
2274
|
+
// Don't hardcode text color - let it inherit from parent (e.g., column with background color)
|
|
2275
|
+
return jsxRuntimeExports.jsx("p", { className: buildClassName(spacing, textAlign), children: content });
|
|
2270
2276
|
};
|
|
2271
2277
|
const Heading = ({ block, children, context }) => {
|
|
2272
2278
|
const attrs = block.attributes || {};
|
|
@@ -2279,7 +2285,10 @@ const Heading = ({ block, children, context }) => {
|
|
|
2279
2285
|
const sizeClass = fontSize || (level === 1 ? 'text-4xl' : level === 2 ? 'text-3xl' : level === 3 ? 'text-2xl' : 'text-xl');
|
|
2280
2286
|
// Get spacing from config with improved defaults
|
|
2281
2287
|
const spacingClass = getHeadingSpacing(context.spacingConfig || context.registry.spacingConfig, level);
|
|
2282
|
-
|
|
2288
|
+
// Extract text color if specified, otherwise inherit from parent
|
|
2289
|
+
const textColor = extractTextColor(block, context);
|
|
2290
|
+
const textColorClass = textColor || ''; // Don't hardcode - let it inherit from parent
|
|
2291
|
+
return (jsxRuntimeExports.jsx(Tag, { className: buildClassName('font-bold', textColorClass, sizeClass, textAlign, spacingClass), children: children ?? content }));
|
|
2283
2292
|
};
|
|
2284
2293
|
const Image = ({ block, context }) => {
|
|
2285
2294
|
const imageAttrs = getImageAttributes(block);
|
|
@@ -2300,13 +2309,12 @@ const List = ({ block, children, context }) => {
|
|
|
2300
2309
|
const { ordered } = attrs;
|
|
2301
2310
|
const Tag = ordered ? 'ol' : 'ul';
|
|
2302
2311
|
const spacing = getSpacing(context.spacingConfig || context.registry.spacingConfig, 'list', 'my-6');
|
|
2303
|
-
// Extract text color if specified
|
|
2312
|
+
// Extract text color if specified, otherwise inherit from parent
|
|
2304
2313
|
const textColor = extractTextColor(block, context);
|
|
2305
|
-
//
|
|
2306
|
-
const textColorClass = textColor || 'text-gray-700';
|
|
2314
|
+
const textColorClass = textColor || ''; // Don't hardcode - let it inherit from parent
|
|
2307
2315
|
return React.createElement(Tag, { className: buildClassName('list-disc pl-6 space-y-2', textColorClass, spacing) }, children);
|
|
2308
2316
|
};
|
|
2309
|
-
const ListItem = ({ block, children }) => {
|
|
2317
|
+
const ListItem = ({ block, children, context }) => {
|
|
2310
2318
|
// List items store their content in innerHTML (e.g., "<li>Text<br>More text</li>")
|
|
2311
2319
|
// We need to extract the content from inside the <li> tag and render it properly
|
|
2312
2320
|
let content = null;
|
|
@@ -2323,12 +2331,15 @@ const ListItem = ({ block, children }) => {
|
|
|
2323
2331
|
}
|
|
2324
2332
|
}
|
|
2325
2333
|
}
|
|
2334
|
+
// Extract text color if specified, otherwise inherit from parent
|
|
2335
|
+
const textColor = extractTextColor(block, context);
|
|
2336
|
+
const textColorClass = textColor || ''; // Don't hardcode - let it inherit from parent
|
|
2326
2337
|
// If we have both innerHTML content and children (innerBlocks), combine them
|
|
2327
2338
|
if (content && children && React.Children.count(children) > 0) {
|
|
2328
|
-
return (jsxRuntimeExports.jsxs("li", { className:
|
|
2339
|
+
return (jsxRuntimeExports.jsxs("li", { className: textColorClass || undefined, children: [content, children] }));
|
|
2329
2340
|
}
|
|
2330
2341
|
// Return content from innerHTML if available, otherwise use children
|
|
2331
|
-
return jsxRuntimeExports.jsx("li", { className:
|
|
2342
|
+
return jsxRuntimeExports.jsx("li", { className: textColorClass || undefined, children: content || children });
|
|
2332
2343
|
};
|
|
2333
2344
|
const Group = ({ block, children, context }) => {
|
|
2334
2345
|
const attrs = block.attributes || {};
|
|
@@ -2393,9 +2404,12 @@ const ButtonBlock = ({ block, context }) => {
|
|
|
2393
2404
|
// Extract background and text colors from button attributes
|
|
2394
2405
|
const backgroundColor = extractBackgroundColor(block, context);
|
|
2395
2406
|
const textColor = extractTextColor(block, context);
|
|
2396
|
-
// Build button classes
|
|
2407
|
+
// Build button classes
|
|
2408
|
+
// Background: use extracted or default (buttons need a background)
|
|
2397
2409
|
const bgClass = backgroundColor || 'bg-primary';
|
|
2398
|
-
|
|
2410
|
+
// Text color: use extracted if specified, otherwise inherit from parent (don't force default)
|
|
2411
|
+
const textClass = textColor || '';
|
|
2412
|
+
// Hover: adjust based on whether we have a custom background
|
|
2399
2413
|
const hoverClass = backgroundColor ? 'hover:opacity-90' : 'hover:bg-primary/90';
|
|
2400
2414
|
// Handle internal vs external links
|
|
2401
2415
|
const isExternal = url && (url.startsWith('http://') || url.startsWith('https://'));
|