@marvalt/wparser 0.1.18 → 0.1.19

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
@@ -1890,12 +1890,24 @@ const Column = ({ block, children }) => {
1890
1890
  const Separator = () => jsxRuntimeExports.jsx("hr", { className: "border-gray-200 my-8" });
1891
1891
  const ButtonBlock = ({ block }) => {
1892
1892
  const attrs = block.attributes || {};
1893
- const url = attrs['url'];
1894
- const text = attrs['text'];
1893
+ let url = attrs['url'];
1894
+ let text = attrs['text'];
1895
1895
  attrs['linkDestination'];
1896
+ // Extract from innerHTML if not in attributes (buttons often store data in innerHTML)
1897
+ if (!url && block.innerHTML) {
1898
+ const linkMatch = block.innerHTML.match(/<a[^>]+href=["']([^"']+)["'][^>]*>([^<]+)<\/a>/i);
1899
+ if (linkMatch) {
1900
+ url = linkMatch[1];
1901
+ text = linkMatch[2] || text;
1902
+ }
1903
+ }
1904
+ // Get text from block content if still missing
1905
+ if (!text) {
1906
+ text = getBlockTextContent(block);
1907
+ }
1896
1908
  if (!url && !text)
1897
1909
  return null;
1898
- const buttonText = text || getBlockTextContent(block) || 'Learn more';
1910
+ const buttonText = text || 'Learn more';
1899
1911
  // Handle internal vs external links
1900
1912
  const isExternal = url && (url.startsWith('http://') || url.startsWith('https://'));
1901
1913
  const linkProps = isExternal ? { target: '_blank', rel: 'noopener noreferrer' } : {};
@@ -1969,19 +1981,34 @@ const MediaText = ({ block, children, context }) => {
1969
1981
  const finalImageUrl = isCloudflareImageUrl(imageUrl)
1970
1982
  ? getCloudflareVariantUrl(imageUrl, { width: 1024 })
1971
1983
  : imageUrl;
1972
- mediaElement = (jsxRuntimeExports.jsx("img", { src: finalImageUrl, alt: "", className: "w-full h-auto rounded-lg object-cover", loading: "lazy" }));
1984
+ mediaElement = (jsxRuntimeExports.jsx("img", { src: finalImageUrl, alt: "", className: "w-full h-auto rounded-lg shadow-lg object-cover", loading: "lazy" }));
1973
1985
  }
1974
1986
  }
1975
1987
  // Content is all other children
1976
1988
  const contentElements = childrenArray.filter((_, index) => index !== mediaBlockIndex);
1977
1989
  // Build alignment classes - ensure proper container width
1978
- // For 'wide', use max-w-7xl; for 'full', use w-full; default to contained
1990
+ // For 'wide', check if we're inside a constrained group context
1991
+ // If innerBlocks contain a group with constrained layout, the parent likely has constrained layout too
1992
+ // In that case, use w-full to fill the parent container (which is already boxed)
1993
+ // Otherwise, use max-w-7xl for standalone wide blocks
1979
1994
  let alignClass;
1980
1995
  if (align === 'full') {
1981
1996
  alignClass = 'w-full';
1982
1997
  }
1983
1998
  else if (align === 'wide') {
1984
- alignClass = 'max-w-7xl mx-auto';
1999
+ // Check if media-text content is wrapped in a constrained group
2000
+ // This indicates the block is in a constrained layout context
2001
+ // In that case, fill the parent container (which is already boxed) rather than applying another container
2002
+ const hasConstrainedGroup = innerBlocks.some((b) => {
2003
+ if (b.name === 'core/group') {
2004
+ const groupLayout = b.attributes?.layout;
2005
+ return groupLayout?.type === 'constrained';
2006
+ }
2007
+ return false;
2008
+ });
2009
+ // If we have a constrained group in innerBlocks, use w-full to fill parent container
2010
+ // Otherwise, use max-w-7xl for standalone wide blocks
2011
+ alignClass = hasConstrainedGroup ? 'w-full' : 'max-w-7xl mx-auto';
1985
2012
  }
1986
2013
  else {
1987
2014
  // Default to contained width (not full width)