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