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