@marvalt/wparser 0.1.53 → 0.1.54

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
@@ -1910,6 +1910,28 @@ function extractTitleFromInnerBlocks(block) {
1910
1910
  }
1911
1911
  return null;
1912
1912
  }
1913
+ /**
1914
+ * Extract text color from heading block in innerBlocks
1915
+ * Used to get custom text color for hero headings
1916
+ *
1917
+ * @param block - Block to search (typically a cover block)
1918
+ * @param context - Render context containing colorMapper
1919
+ * @returns CSS class string (e.g., 'text-white') or null if no custom color
1920
+ */
1921
+ function extractTitleTextColorFromInnerBlocks(block, context) {
1922
+ const innerBlocks = block.innerBlocks || [];
1923
+ // Recursively search for heading blocks
1924
+ for (const innerBlock of innerBlocks) {
1925
+ if (innerBlock.name === 'core/heading') {
1926
+ return extractTextColor(innerBlock, context);
1927
+ }
1928
+ // Recursively search nested blocks
1929
+ const nestedColor = extractTitleTextColorFromInnerBlocks(innerBlock, context);
1930
+ if (nestedColor)
1931
+ return nestedColor;
1932
+ }
1933
+ return null;
1934
+ }
1913
1935
  /**
1914
1936
  * Extract subtitle/description from innerBlocks (finds first paragraph block)
1915
1937
  */
@@ -2116,6 +2138,21 @@ function extractBackgroundColorValue(block, context) {
2116
2138
  }
2117
2139
  return null;
2118
2140
  }
2141
+ /**
2142
+ * Extract gradient background from block attributes
2143
+ * WordPress stores gradients in attributes.style.color.gradient
2144
+ *
2145
+ * @param block - WordPress block to extract gradient from
2146
+ * @returns Gradient string (e.g., "linear-gradient(...)") or null if no gradient
2147
+ */
2148
+ function extractGradientBackground(block) {
2149
+ const attrs = block.attributes || {};
2150
+ const style = attrs['style'];
2151
+ if (style?.color?.gradient && typeof style.color.gradient === 'string') {
2152
+ return style.color.gradient;
2153
+ }
2154
+ return null;
2155
+ }
2119
2156
  /**
2120
2157
  * Extract and map text color from block attributes
2121
2158
  * Uses colorMapper from context to convert WordPress theme colors to app CSS classes
@@ -3019,6 +3056,7 @@ exports.extractButtonsFromInnerBlocks = extractButtonsFromInnerBlocks;
3019
3056
  exports.extractContent = extractContent;
3020
3057
  exports.extractDimRatio = extractDimRatio;
3021
3058
  exports.extractFontSize = extractFontSize;
3059
+ exports.extractGradientBackground = extractGradientBackground;
3022
3060
  exports.extractHeadingLevel = extractHeadingLevel;
3023
3061
  exports.extractImageAttributes = extractImageAttributes;
3024
3062
  exports.extractImageUrl = extractImageUrl;
@@ -3034,6 +3072,7 @@ exports.extractTextColor = extractTextColor;
3034
3072
  exports.extractTextFromHTML = extractTextFromHTML;
3035
3073
  exports.extractTitle = extractTitle;
3036
3074
  exports.extractTitleFromInnerBlocks = extractTitleFromInnerBlocks;
3075
+ exports.extractTitleTextColorFromInnerBlocks = extractTitleTextColorFromInnerBlocks;
3037
3076
  exports.extractVerticalAlignment = extractVerticalAlignment;
3038
3077
  exports.extractVideoIframeFromInnerBlocks = extractVideoIframeFromInnerBlocks;
3039
3078
  exports.findMatchingMapping = findMatchingMapping;