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