@marvalt/wparser 0.1.72 → 0.1.73

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
@@ -2112,10 +2112,14 @@ function extractTextAlignFromInnerBlocks(block) {
2112
2112
  const innerBlocks = block.innerBlocks || [];
2113
2113
  // First, recursively search for heading or paragraph blocks with textAlign
2114
2114
  // (These take priority over group justifyContent)
2115
+ // Note: heading blocks use 'textAlign', paragraph blocks use 'align'
2115
2116
  for (const innerBlock of innerBlocks) {
2116
2117
  if (innerBlock.name === 'core/heading' || innerBlock.name === 'core/paragraph') {
2117
2118
  const attrs = innerBlock.attributes || {};
2118
- const textAlign = attrs['textAlign'];
2119
+ // Heading blocks use 'textAlign', paragraph blocks use 'align'
2120
+ const textAlign = innerBlock.name === 'core/heading'
2121
+ ? attrs['textAlign']
2122
+ : attrs['align'] || attrs['textAlign']; // Check both for paragraph (fallback)
2119
2123
  if (textAlign === 'left' || textAlign === 'center' || textAlign === 'right') {
2120
2124
  return textAlign;
2121
2125
  }
@@ -2126,6 +2130,7 @@ function extractTextAlignFromInnerBlocks(block) {
2126
2130
  return nestedAlign;
2127
2131
  }
2128
2132
  // Only check group blocks if no heading/paragraph alignment found
2133
+ // Recursively search group blocks for justifyContent
2129
2134
  for (const innerBlock of innerBlocks) {
2130
2135
  if (innerBlock.name === 'core/group') {
2131
2136
  const attrs = innerBlock.attributes || {};
@@ -2137,6 +2142,10 @@ function extractTextAlignFromInnerBlocks(block) {
2137
2142
  return 'center';
2138
2143
  if (justifyContent === 'right')
2139
2144
  return 'right';
2145
+ // Also recursively check nested blocks within the group
2146
+ const nestedAlign = extractTextAlignFromInnerBlocks(innerBlock);
2147
+ if (nestedAlign)
2148
+ return nestedAlign;
2140
2149
  }
2141
2150
  }
2142
2151
  return null;