@marvalt/wparser 0.1.65 → 0.1.66
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 +38 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.esm.js +38 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/blockExtractors.d.ts +4 -1
- package/dist/utils/blockExtractors.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -465,7 +465,10 @@ declare function extractButtonsFromInnerBlocks(block: WordPressBlock): Array<{
|
|
|
465
465
|
declare function extractTextAlignFromInnerBlocks(block: WordPressBlock): 'left' | 'center' | 'right' | null;
|
|
466
466
|
/**
|
|
467
467
|
* Parse contentPosition string into horizontal and vertical alignment
|
|
468
|
-
*
|
|
468
|
+
* Supports both formats:
|
|
469
|
+
* - "horizontal vertical" (e.g., "left bottom", "center center")
|
|
470
|
+
* - "vertical horizontal" (e.g., "bottom left", "top center")
|
|
471
|
+
* WordPress typically uses "bottom left" format
|
|
469
472
|
*/
|
|
470
473
|
declare function parseContentPosition(contentPosition: string | undefined): {
|
|
471
474
|
horizontal: 'left' | 'center' | 'right';
|
package/dist/index.esm.js
CHANGED
|
@@ -2067,19 +2067,50 @@ function extractTextAlignFromInnerBlocks(block) {
|
|
|
2067
2067
|
}
|
|
2068
2068
|
/**
|
|
2069
2069
|
* Parse contentPosition string into horizontal and vertical alignment
|
|
2070
|
-
*
|
|
2070
|
+
* Supports both formats:
|
|
2071
|
+
* - "horizontal vertical" (e.g., "left bottom", "center center")
|
|
2072
|
+
* - "vertical horizontal" (e.g., "bottom left", "top center")
|
|
2073
|
+
* WordPress typically uses "bottom left" format
|
|
2071
2074
|
*/
|
|
2072
2075
|
function parseContentPosition(contentPosition) {
|
|
2073
2076
|
if (!contentPosition) {
|
|
2074
2077
|
return { horizontal: 'left', vertical: 'center' };
|
|
2075
2078
|
}
|
|
2076
2079
|
const parts = contentPosition.trim().split(/\s+/);
|
|
2077
|
-
const
|
|
2078
|
-
const
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2080
|
+
const part1 = parts[0] || '';
|
|
2081
|
+
const part2 = parts[1] || '';
|
|
2082
|
+
let horizontal = 'left';
|
|
2083
|
+
let vertical = 'center';
|
|
2084
|
+
// Try to detect format: if first part is vertical, WordPress format (vertical horizontal)
|
|
2085
|
+
if (part1 === 'top' || part1 === 'bottom') {
|
|
2086
|
+
// WordPress format: "bottom left" -> vertical=bottom, horizontal=left
|
|
2087
|
+
vertical = part1;
|
|
2088
|
+
horizontal = (part2 === 'center' || part2 === 'right' ? part2 : 'left');
|
|
2089
|
+
}
|
|
2090
|
+
else if (part1 === 'left' || part1 === 'right') {
|
|
2091
|
+
// Standard format: "left bottom" -> horizontal=left, vertical=bottom
|
|
2092
|
+
horizontal = part1;
|
|
2093
|
+
vertical = (part2 === 'top' || part2 === 'bottom' ? part2 : 'center');
|
|
2094
|
+
}
|
|
2095
|
+
else if (part1 === 'center') {
|
|
2096
|
+
// First part is center - check second part to determine format
|
|
2097
|
+
if (part2 === 'top' || part2 === 'bottom') {
|
|
2098
|
+
// "center bottom" -> horizontal=center, vertical=bottom
|
|
2099
|
+
horizontal = 'center';
|
|
2100
|
+
vertical = part2;
|
|
2101
|
+
}
|
|
2102
|
+
else {
|
|
2103
|
+
// "center center" or "center left/right" -> both center or horizontal=center
|
|
2104
|
+
horizontal = 'center';
|
|
2105
|
+
vertical = (part2 === 'top' || part2 === 'bottom' ? part2 : 'center');
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
else {
|
|
2109
|
+
// Unknown format, use defaults
|
|
2110
|
+
horizontal = 'left';
|
|
2111
|
+
vertical = 'center';
|
|
2112
|
+
}
|
|
2113
|
+
return { horizontal, vertical };
|
|
2083
2114
|
}
|
|
2084
2115
|
/**
|
|
2085
2116
|
* Extract video iframe HTML from innerBlocks (finds HTML block with iframe)
|