@marvalt/wparser 0.1.20 → 0.1.22

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.esm.js CHANGED
@@ -1851,7 +1851,7 @@ const Image = ({ block }) => {
1851
1851
  const height = imageAttrs.height;
1852
1852
  imageUrl = getCloudflareVariantUrl(imageUrl, { width, height });
1853
1853
  }
1854
- return (jsxRuntimeExports.jsx("img", { src: imageUrl, alt: imageAttrs.alt, width: imageAttrs.width, height: imageAttrs.height, className: "w-full h-auto object-cover rounded-lg", loading: "lazy" }));
1854
+ return (jsxRuntimeExports.jsx("img", { src: imageUrl, alt: imageAttrs.alt, width: imageAttrs.width, height: imageAttrs.height, className: "w-full h-auto max-w-full object-contain rounded-lg", loading: "lazy" }));
1855
1855
  };
1856
1856
  const List = ({ block, children }) => {
1857
1857
  const attrs = block.attributes || {};
@@ -1865,12 +1865,17 @@ const ListItem = ({ children }) => {
1865
1865
  const Group = ({ block, children }) => {
1866
1866
  const attrs = block.attributes || {};
1867
1867
  const align = attrs['align'];
1868
+ // Layout can be an object with type property, or nested structure
1868
1869
  const layout = attrs['layout'];
1869
1870
  // Determine if this is a section-level group (has alignment) or content-level
1870
1871
  const isSection = align === 'full' || align === 'wide';
1871
1872
  const containerClass = getContainerClasses(align, layout);
1872
1873
  const spacingClass = isSection ? getSectionSpacingClasses() : getContentSpacingClasses();
1873
- return (jsxRuntimeExports.jsx("div", { className: buildClassName(containerClass, spacingClass), children: children }));
1874
+ // Ensure container class is always applied for constrained groups
1875
+ const finalContainerClass = layout?.type === 'constrained' && align === 'wide'
1876
+ ? 'container'
1877
+ : containerClass;
1878
+ return (jsxRuntimeExports.jsx("div", { className: buildClassName(finalContainerClass, spacingClass), children: children }));
1874
1879
  };
1875
1880
  const Columns = ({ block, children }) => {
1876
1881
  const attrs = block.attributes || {};
@@ -1979,7 +1984,7 @@ const MediaText = ({ block, children, context }) => {
1979
1984
  const finalImageUrl = isCloudflareImageUrl(imageUrl)
1980
1985
  ? getCloudflareVariantUrl(imageUrl, { width: 1024 })
1981
1986
  : imageUrl;
1982
- mediaElement = (jsxRuntimeExports.jsx("img", { src: finalImageUrl, alt: "", className: "w-full h-auto rounded-lg shadow-lg object-cover", loading: "lazy" }));
1987
+ mediaElement = (jsxRuntimeExports.jsx("img", { src: finalImageUrl, alt: "", className: "w-full h-auto max-w-full rounded-lg shadow-lg object-contain", loading: "lazy" }));
1983
1988
  }
1984
1989
  }
1985
1990
  // Content is all other children
@@ -1989,17 +1994,23 @@ const MediaText = ({ block, children, context }) => {
1989
1994
  // So we should use 'w-full' to fill the parent container, not apply another max-width
1990
1995
  // Only use 'max-w-7xl' for truly standalone wide blocks (rare case)
1991
1996
  let alignClass;
1997
+ let spacingClass;
1992
1998
  if (align === 'full') {
1993
1999
  alignClass = 'w-full';
2000
+ // Full-width blocks are typically top-level sections, so add section spacing
2001
+ spacingClass = getSectionSpacingClasses();
1994
2002
  }
1995
2003
  else if (align === 'wide') {
1996
- // Default to w-full for wide blocks (they're usually inside constrained containers)
1997
- // This ensures they fill the parent container which is already boxed
2004
+ // Wide blocks are usually inside constrained groups (which already have container and spacing)
2005
+ // So just fill the parent container without adding section spacing
1998
2006
  alignClass = 'w-full';
2007
+ spacingClass = ''; // No section spacing - parent group handles it
1999
2008
  }
2000
2009
  else {
2001
2010
  // Default to contained width (not full width)
2002
2011
  alignClass = 'container mx-auto';
2012
+ // Contained blocks might be standalone, so add section spacing
2013
+ spacingClass = getSectionSpacingClasses();
2003
2014
  }
2004
2015
  // Vertical alignment classes
2005
2016
  const verticalAlignClass = verticalAlignment === 'top' ? 'items-start' :
@@ -2009,9 +2020,11 @@ const MediaText = ({ block, children, context }) => {
2009
2020
  const stackClass = 'flex-col md:flex-row';
2010
2021
  // Media position determines order
2011
2022
  const isMediaRight = mediaPosition === 'right';
2012
- // Add section spacing for consistent vertical rhythm
2013
- const spacingClass = getSectionSpacingClasses();
2014
- return (jsxRuntimeExports.jsx("div", { className: buildClassName(alignClass, spacingClass, 'px-4'), children: jsxRuntimeExports.jsxs("div", { className: buildClassName('flex', stackClass, verticalAlignClass, 'gap-6 lg:gap-12'), children: [jsxRuntimeExports.jsx("div", { className: buildClassName(isMediaRight ? 'order-2' : 'order-1', imageFill ? 'w-full md:w-1/2' : 'flex-shrink-0 md:w-1/2'), children: mediaElement || jsxRuntimeExports.jsx("div", { className: "bg-gray-200 h-64 rounded-lg" }) }), jsxRuntimeExports.jsx("div", { className: buildClassName(isMediaRight ? 'order-1' : 'order-2', 'md:w-1/2', getContentSpacingClasses()), children: contentElements.length > 0 ? contentElements : children })] }) }));
2023
+ return (jsxRuntimeExports.jsx("div", { className: buildClassName(alignClass, spacingClass), children: jsxRuntimeExports.jsxs("div", { className: buildClassName('flex', stackClass, verticalAlignClass, 'gap-6 lg:gap-12'), children: [jsxRuntimeExports.jsx("div", { className: buildClassName(isMediaRight ? 'order-2' : 'order-1', imageFill ? 'w-full md:w-1/2' : 'flex-shrink-0 md:w-1/2', 'overflow-hidden', // Ensure images don't overflow
2024
+ 'max-w-full' // Ensure section doesn't exceed container
2025
+ ), children: mediaElement || jsxRuntimeExports.jsx("div", { className: "bg-gray-200 h-64 rounded-lg" }) }), jsxRuntimeExports.jsx("div", { className: buildClassName(isMediaRight ? 'order-1' : 'order-2', 'w-full md:w-1/2', // Explicit width to ensure proper sizing
2026
+ 'flex-shrink-0', // Prevent content from shrinking
2027
+ getContentSpacingClasses()), children: contentElements.length > 0 ? contentElements : children })] }) }));
2015
2028
  };
2016
2029
  const Fallback = ({ block, children }) => {
2017
2030
  // Minimal fallback; do not render innerHTML directly in v1 for safety