@marvalt/wparser 0.1.71 → 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 +18 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +18 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/blockExtractors.d.ts +1 -0
- package/dist/utils/blockExtractors.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1886,12 +1886,18 @@ function extractAlignment(block) {
|
|
|
1886
1886
|
}
|
|
1887
1887
|
/**
|
|
1888
1888
|
* Extract overlay color from cover block
|
|
1889
|
+
* Checks both customOverlayColor (hex) and overlayColor (theme color name)
|
|
1889
1890
|
*/
|
|
1890
1891
|
function extractOverlayColor(block) {
|
|
1891
1892
|
const attrs = block.attributes || {};
|
|
1893
|
+
// Priority: customOverlayColor (hex) > overlayColor (theme color name)
|
|
1894
|
+
const customOverlayColor = attrs['customOverlayColor'];
|
|
1895
|
+
if (typeof customOverlayColor === 'string' && customOverlayColor.trim()) {
|
|
1896
|
+
return customOverlayColor.trim();
|
|
1897
|
+
}
|
|
1892
1898
|
const overlayColor = attrs['overlayColor'];
|
|
1893
|
-
if (typeof overlayColor === 'string') {
|
|
1894
|
-
return overlayColor;
|
|
1899
|
+
if (typeof overlayColor === 'string' && overlayColor.trim()) {
|
|
1900
|
+
return overlayColor.trim();
|
|
1895
1901
|
}
|
|
1896
1902
|
return null;
|
|
1897
1903
|
}
|
|
@@ -2106,10 +2112,14 @@ function extractTextAlignFromInnerBlocks(block) {
|
|
|
2106
2112
|
const innerBlocks = block.innerBlocks || [];
|
|
2107
2113
|
// First, recursively search for heading or paragraph blocks with textAlign
|
|
2108
2114
|
// (These take priority over group justifyContent)
|
|
2115
|
+
// Note: heading blocks use 'textAlign', paragraph blocks use 'align'
|
|
2109
2116
|
for (const innerBlock of innerBlocks) {
|
|
2110
2117
|
if (innerBlock.name === 'core/heading' || innerBlock.name === 'core/paragraph') {
|
|
2111
2118
|
const attrs = innerBlock.attributes || {};
|
|
2112
|
-
|
|
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)
|
|
2113
2123
|
if (textAlign === 'left' || textAlign === 'center' || textAlign === 'right') {
|
|
2114
2124
|
return textAlign;
|
|
2115
2125
|
}
|
|
@@ -2120,6 +2130,7 @@ function extractTextAlignFromInnerBlocks(block) {
|
|
|
2120
2130
|
return nestedAlign;
|
|
2121
2131
|
}
|
|
2122
2132
|
// Only check group blocks if no heading/paragraph alignment found
|
|
2133
|
+
// Recursively search group blocks for justifyContent
|
|
2123
2134
|
for (const innerBlock of innerBlocks) {
|
|
2124
2135
|
if (innerBlock.name === 'core/group') {
|
|
2125
2136
|
const attrs = innerBlock.attributes || {};
|
|
@@ -2131,6 +2142,10 @@ function extractTextAlignFromInnerBlocks(block) {
|
|
|
2131
2142
|
return 'center';
|
|
2132
2143
|
if (justifyContent === 'right')
|
|
2133
2144
|
return 'right';
|
|
2145
|
+
// Also recursively check nested blocks within the group
|
|
2146
|
+
const nestedAlign = extractTextAlignFromInnerBlocks(innerBlock);
|
|
2147
|
+
if (nestedAlign)
|
|
2148
|
+
return nestedAlign;
|
|
2134
2149
|
}
|
|
2135
2150
|
}
|
|
2136
2151
|
return null;
|