@marvalt/wparser 0.1.25 → 0.1.29
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/README.md +9 -0
- package/dist/index.cjs +89 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +37 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +89 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/registry/defaultRegistry.d.ts +2 -2
- package/dist/registry/defaultRegistry.d.ts.map +1 -1
- package/dist/registry/enhancedRegistry.d.ts +2 -2
- package/dist/registry/enhancedRegistry.d.ts.map +1 -1
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/blockExtractors.d.ts +5 -0
- package/dist/utils/blockExtractors.d.ts.map +1 -1
- package/docs/COLOR_MAPPING.md +82 -0
- package/docs/CUSTOMIZATION.md +144 -0
- package/docs/SPACING.md +136 -0
- package/docs/STYLING.md +96 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ interface RenderContext {
|
|
|
50
50
|
registry: ComponentRegistry;
|
|
51
51
|
page?: WordPressPageMinimal;
|
|
52
52
|
colorMapper?: ColorMapper;
|
|
53
|
+
spacingConfig?: SpacingConfig;
|
|
53
54
|
}
|
|
54
55
|
interface BlockRendererProps {
|
|
55
56
|
block: WordPressBlock;
|
|
@@ -70,6 +71,8 @@ interface ComponentRegistry {
|
|
|
70
71
|
fallback: BlockRenderer;
|
|
71
72
|
/** Optional color mapper for converting WordPress theme colors to CSS classes */
|
|
72
73
|
colorMapper?: ColorMapper;
|
|
74
|
+
/** Optional spacing configuration for customizing element spacing */
|
|
75
|
+
spacingConfig?: SpacingConfig;
|
|
73
76
|
}
|
|
74
77
|
/**
|
|
75
78
|
* Pattern matching for blocks - allows matching blocks by name and attributes
|
|
@@ -111,6 +114,31 @@ interface EnhancedRegistry extends ComponentRegistry {
|
|
|
111
114
|
/** Find matching component mapping for a block */
|
|
112
115
|
matchBlock: (block: WordPressBlock) => ComponentMapping | null;
|
|
113
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Spacing configuration for customizing element and section spacing
|
|
119
|
+
* Allows applications to control spacing values while maintaining consistency
|
|
120
|
+
*/
|
|
121
|
+
interface SpacingConfig {
|
|
122
|
+
/** Spacing for paragraph elements (e.g., 'my-4', 'my-6') */
|
|
123
|
+
paragraph?: string;
|
|
124
|
+
/** Spacing for heading elements by level */
|
|
125
|
+
heading?: {
|
|
126
|
+
/** H1 spacing (e.g., 'mt-8 mb-6') */
|
|
127
|
+
h1?: string;
|
|
128
|
+
/** H2 spacing (e.g., 'mt-6 mb-4') */
|
|
129
|
+
h2?: string;
|
|
130
|
+
/** H3 and below spacing (e.g., 'mt-4 mb-3') */
|
|
131
|
+
h3?: string;
|
|
132
|
+
};
|
|
133
|
+
/** Spacing for image elements (e.g., 'my-4', 'my-6') */
|
|
134
|
+
image?: string;
|
|
135
|
+
/** Spacing for list elements (e.g., 'my-4', 'my-6') */
|
|
136
|
+
list?: string;
|
|
137
|
+
/** Section-level padding (for groups with align: 'full' or 'wide') */
|
|
138
|
+
section?: string;
|
|
139
|
+
/** Content-level spacing (for groups without alignment) */
|
|
140
|
+
content?: string;
|
|
141
|
+
}
|
|
114
142
|
|
|
115
143
|
type WPNode = WordPressBlock;
|
|
116
144
|
interface ParseOptions {
|
|
@@ -122,7 +150,7 @@ interface RenderOptions {
|
|
|
122
150
|
}
|
|
123
151
|
declare function renderNodes(blocks: WordPressBlock[], registry: ComponentRegistry, options?: RenderOptions, page?: WordPressPageMinimal): React$1.ReactNode;
|
|
124
152
|
|
|
125
|
-
declare function createDefaultRegistry(colorMapper?: ColorMapper): ComponentRegistry;
|
|
153
|
+
declare function createDefaultRegistry(colorMapper?: ColorMapper, spacingConfig?: SpacingConfig): ComponentRegistry;
|
|
126
154
|
|
|
127
155
|
/**
|
|
128
156
|
* Create an enhanced registry that supports pattern-based component mapping
|
|
@@ -152,7 +180,7 @@ declare function createDefaultRegistry(colorMapper?: ColorMapper): ComponentRegi
|
|
|
152
180
|
* const registry = createEnhancedRegistry(mappings);
|
|
153
181
|
* ```
|
|
154
182
|
*/
|
|
155
|
-
declare function createEnhancedRegistry(mappings?: ComponentMapping[], baseRegistry?: ComponentRegistry, colorMapper?: ColorMapper): EnhancedRegistry;
|
|
183
|
+
declare function createEnhancedRegistry(mappings?: ComponentMapping[], baseRegistry?: ComponentRegistry, colorMapper?: ColorMapper, spacingConfig?: SpacingConfig): EnhancedRegistry;
|
|
156
184
|
|
|
157
185
|
interface WPContentProps {
|
|
158
186
|
blocks: WordPressBlock[];
|
|
@@ -455,6 +483,11 @@ declare function extractVideoIframeFromInnerBlocks(block: WordPressBlock): strin
|
|
|
455
483
|
* ```
|
|
456
484
|
*/
|
|
457
485
|
declare function extractBackgroundColor(block: WordPressBlock, context: RenderContext): string | null;
|
|
486
|
+
/**
|
|
487
|
+
* Extract spacer height from block attributes or innerHTML
|
|
488
|
+
* Returns height in pixels, or null if not found
|
|
489
|
+
*/
|
|
490
|
+
declare function extractSpacerHeight(block: WordPressBlock): number | null;
|
|
458
491
|
|
|
459
492
|
interface ImageConversionOptions {
|
|
460
493
|
/** Convert to Cloudflare variant if URL is already Cloudflare */
|
|
@@ -507,5 +540,5 @@ interface SectionWrapperProps {
|
|
|
507
540
|
*/
|
|
508
541
|
declare const SectionWrapper: React$1.FC<SectionWrapperProps>;
|
|
509
542
|
|
|
510
|
-
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
511
|
-
export type { AuthMode, BlockPattern, BlockRenderer, BlockRendererProps, CloudflareVariantOptions, ColorMapper, ComponentMapping, ComponentRegistry, EnhancedRegistry, ImageConversionOptions, ParseOptions, ParsedShortcode, RenderContext, RenderOptions, SectionWrapperProps, ShortcodeAttributes, ShortcodeRenderer, WPContentProps, WPNode, WPPageProps, WordPressBlock, WordPressEmbedded, WordPressFeaturedMedia, WordPressPageMinimal, WordPressTitleField };
|
|
543
|
+
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
544
|
+
export type { AuthMode, BlockPattern, BlockRenderer, BlockRendererProps, CloudflareVariantOptions, ColorMapper, ComponentMapping, ComponentRegistry, EnhancedRegistry, ImageConversionOptions, ParseOptions, ParsedShortcode, RenderContext, RenderOptions, SectionWrapperProps, ShortcodeAttributes, ShortcodeRenderer, SpacingConfig, WPContentProps, WPNode, WPPageProps, WordPressBlock, WordPressEmbedded, WordPressFeaturedMedia, WordPressPageMinimal, WordPressTitleField };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClH,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClH,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1388,7 +1388,16 @@ function renderBlock(block, registry, key, options, page) {
|
|
|
1388
1388
|
const children = block.innerBlocks && block.innerBlocks.length
|
|
1389
1389
|
? block.innerBlocks.map((child, i) => renderBlock(child, registry, `${key}-${i}`, options, page))
|
|
1390
1390
|
: undefined;
|
|
1391
|
-
const node = Renderer({
|
|
1391
|
+
const node = Renderer({
|
|
1392
|
+
block,
|
|
1393
|
+
children,
|
|
1394
|
+
context: {
|
|
1395
|
+
registry,
|
|
1396
|
+
page,
|
|
1397
|
+
colorMapper: registry.colorMapper,
|
|
1398
|
+
spacingConfig: registry.spacingConfig,
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1392
1401
|
if (options?.debugWrappers) {
|
|
1393
1402
|
return (jsxRuntimeExports.jsx("div", { "data-block": block.name, className: "wp-block", children: node }, key));
|
|
1394
1403
|
}
|
|
@@ -2048,6 +2057,36 @@ function extractBackgroundColor(block, context) {
|
|
|
2048
2057
|
// Fallback: return null (no background applied)
|
|
2049
2058
|
return null;
|
|
2050
2059
|
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Extract spacer height from block attributes or innerHTML
|
|
2062
|
+
* Returns height in pixels, or null if not found
|
|
2063
|
+
*/
|
|
2064
|
+
function extractSpacerHeight(block) {
|
|
2065
|
+
const attrs = block.attributes || {};
|
|
2066
|
+
// First, try to get height from attributes
|
|
2067
|
+
const height = attrs['height'];
|
|
2068
|
+
if (typeof height === 'number') {
|
|
2069
|
+
return height;
|
|
2070
|
+
}
|
|
2071
|
+
if (typeof height === 'string') {
|
|
2072
|
+
// Parse "100px" or "100" to number
|
|
2073
|
+
const match = height.match(/^(\d+)/);
|
|
2074
|
+
if (match) {
|
|
2075
|
+
return parseInt(match[1], 10);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
// Fall back to parsing innerHTML for style="height:100px"
|
|
2079
|
+
if (block.innerHTML) {
|
|
2080
|
+
const styleMatch = block.innerHTML.match(/style=["']([^"']+)["']/i);
|
|
2081
|
+
if (styleMatch) {
|
|
2082
|
+
const heightMatch = styleMatch[1].match(/height:\s*(\d+)px/i);
|
|
2083
|
+
if (heightMatch) {
|
|
2084
|
+
return parseInt(heightMatch[1], 10);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
return null;
|
|
2089
|
+
}
|
|
2051
2090
|
|
|
2052
2091
|
/**
|
|
2053
2092
|
* Style mapping utilities
|
|
@@ -2141,10 +2180,25 @@ function buildClassName(...classes) {
|
|
|
2141
2180
|
.trim();
|
|
2142
2181
|
}
|
|
2143
2182
|
|
|
2183
|
+
// Helper function to get spacing value with fallback
|
|
2184
|
+
// Only accepts string keys (excludes 'heading' which is an object)
|
|
2185
|
+
function getSpacing(spacingConfig, key, fallback) {
|
|
2186
|
+
return spacingConfig?.[key] || fallback;
|
|
2187
|
+
}
|
|
2188
|
+
// Helper function to get heading spacing
|
|
2189
|
+
function getHeadingSpacing(spacingConfig, level) {
|
|
2190
|
+
const headingConfig = spacingConfig?.heading;
|
|
2191
|
+
if (level === 1)
|
|
2192
|
+
return headingConfig?.h1 || 'mt-10 mb-8';
|
|
2193
|
+
if (level === 2)
|
|
2194
|
+
return headingConfig?.h2 || 'mt-8 mb-6';
|
|
2195
|
+
return headingConfig?.h3 || 'mt-6 mb-4';
|
|
2196
|
+
}
|
|
2144
2197
|
const Paragraph = ({ block, context }) => {
|
|
2145
2198
|
const content = getBlockTextContent(block);
|
|
2146
2199
|
const attrs = block.attributes || {};
|
|
2147
2200
|
const textAlign = getTextAlignClasses(attrs['align']);
|
|
2201
|
+
const spacing = getSpacing(context.spacingConfig || context.registry.spacingConfig, 'paragraph', 'my-6');
|
|
2148
2202
|
// Check if content contains shortcodes
|
|
2149
2203
|
const hasShortcodes = /\[(\w+)/.test(content);
|
|
2150
2204
|
if (hasShortcodes && context.registry.shortcodes) {
|
|
@@ -2175,14 +2229,14 @@ const Paragraph = ({ block, context }) => {
|
|
|
2175
2229
|
};
|
|
2176
2230
|
const hasBlockLevelContent = React.Children.toArray(parts).some((part) => isBlockLevelElement(part));
|
|
2177
2231
|
if (hasBlockLevelContent) {
|
|
2178
|
-
// Render block-level content without <p> wrapper
|
|
2179
|
-
return jsxRuntimeExports.jsx(
|
|
2232
|
+
// Render block-level content without <p> wrapper, but add spacing wrapper
|
|
2233
|
+
return jsxRuntimeExports.jsx("div", { className: spacing, children: parts });
|
|
2180
2234
|
}
|
|
2181
|
-
return jsxRuntimeExports.jsx("p", { className: buildClassName('text-gray-700
|
|
2235
|
+
return jsxRuntimeExports.jsx("p", { className: buildClassName('text-gray-700', spacing, textAlign), children: parts });
|
|
2182
2236
|
}
|
|
2183
|
-
return jsxRuntimeExports.jsx("p", { className: buildClassName('text-gray-700
|
|
2237
|
+
return jsxRuntimeExports.jsx("p", { className: buildClassName('text-gray-700', spacing, textAlign), children: content });
|
|
2184
2238
|
};
|
|
2185
|
-
const Heading = ({ block, children }) => {
|
|
2239
|
+
const Heading = ({ block, children, context }) => {
|
|
2186
2240
|
const attrs = block.attributes || {};
|
|
2187
2241
|
const { level = 2 } = attrs;
|
|
2188
2242
|
const content = getBlockTextContent(block);
|
|
@@ -2191,12 +2245,11 @@ const Heading = ({ block, children }) => {
|
|
|
2191
2245
|
const Tag = `h${Math.min(Math.max(Number(level) || 2, 1), 6)}`;
|
|
2192
2246
|
// Default heading sizes if fontSize not specified
|
|
2193
2247
|
const sizeClass = fontSize || (level === 1 ? 'text-4xl' : level === 2 ? 'text-3xl' : level === 3 ? 'text-2xl' : 'text-xl');
|
|
2194
|
-
//
|
|
2195
|
-
|
|
2196
|
-
const spacingClass = level === 1 ? 'mt-8 mb-6' : level === 2 ? 'mt-6 mb-4' : 'mt-4 mb-3';
|
|
2248
|
+
// Get spacing from config with improved defaults
|
|
2249
|
+
const spacingClass = getHeadingSpacing(context.spacingConfig || context.registry.spacingConfig, level);
|
|
2197
2250
|
return (jsxRuntimeExports.jsx(Tag, { className: buildClassName('font-bold text-gray-900', sizeClass, textAlign, spacingClass), children: children ?? content }));
|
|
2198
2251
|
};
|
|
2199
|
-
const Image = ({ block }) => {
|
|
2252
|
+
const Image = ({ block, context }) => {
|
|
2200
2253
|
const imageAttrs = getImageAttributes(block);
|
|
2201
2254
|
if (!imageAttrs.url)
|
|
2202
2255
|
return null;
|
|
@@ -2207,13 +2260,15 @@ const Image = ({ block }) => {
|
|
|
2207
2260
|
const height = imageAttrs.height;
|
|
2208
2261
|
imageUrl = getCloudflareVariantUrl(imageUrl, { width, height });
|
|
2209
2262
|
}
|
|
2210
|
-
|
|
2263
|
+
const spacing = getSpacing(context.spacingConfig || context.registry.spacingConfig, 'image', 'my-6');
|
|
2264
|
+
return (jsxRuntimeExports.jsx("img", { src: imageUrl, alt: imageAttrs.alt, width: imageAttrs.width, height: imageAttrs.height, className: buildClassName('w-full h-auto rounded-lg object-cover', spacing), style: { maxWidth: '100%', height: 'auto' }, loading: "lazy" }));
|
|
2211
2265
|
};
|
|
2212
|
-
const List = ({ block, children }) => {
|
|
2266
|
+
const List = ({ block, children, context }) => {
|
|
2213
2267
|
const attrs = block.attributes || {};
|
|
2214
2268
|
const { ordered } = attrs;
|
|
2215
2269
|
const Tag = ordered ? 'ol' : 'ul';
|
|
2216
|
-
|
|
2270
|
+
const spacing = getSpacing(context.spacingConfig || context.registry.spacingConfig, 'list', 'my-6');
|
|
2271
|
+
return React.createElement(Tag, { className: buildClassName('list-disc pl-6 space-y-2 text-gray-700', spacing) }, children);
|
|
2217
2272
|
};
|
|
2218
2273
|
const ListItem = ({ children }) => {
|
|
2219
2274
|
return jsxRuntimeExports.jsx("li", { className: "text-gray-700", children: children });
|
|
@@ -2228,7 +2283,11 @@ const Group = ({ block, children, context }) => {
|
|
|
2228
2283
|
// Determine if this is a section-level group (has alignment) or content-level
|
|
2229
2284
|
const isSection = align === 'full' || align === 'wide';
|
|
2230
2285
|
const containerClass = getContainerClasses(align, layout);
|
|
2231
|
-
|
|
2286
|
+
// Get spacing from config or use defaults
|
|
2287
|
+
const spacingConfig = context.spacingConfig || context.registry.spacingConfig;
|
|
2288
|
+
const spacingClass = isSection
|
|
2289
|
+
? (spacingConfig?.section || getSectionSpacingClasses())
|
|
2290
|
+
: (spacingConfig?.content || getContentSpacingClasses());
|
|
2232
2291
|
// Ensure container class is always applied for constrained groups
|
|
2233
2292
|
const finalContainerClass = layout?.type === 'constrained' && align === 'wide'
|
|
2234
2293
|
? 'container'
|
|
@@ -2392,7 +2451,7 @@ const Fallback = ({ block, children }) => {
|
|
|
2392
2451
|
// Minimal fallback; do not render innerHTML directly in v1 for safety
|
|
2393
2452
|
return jsxRuntimeExports.jsx("div", { "data-unknown-block": block.name, children: children });
|
|
2394
2453
|
};
|
|
2395
|
-
function createDefaultRegistry(colorMapper) {
|
|
2454
|
+
function createDefaultRegistry(colorMapper, spacingConfig) {
|
|
2396
2455
|
const renderers = {
|
|
2397
2456
|
'core/paragraph': Paragraph,
|
|
2398
2457
|
'core/heading': Heading,
|
|
@@ -2429,12 +2488,22 @@ function createDefaultRegistry(colorMapper) {
|
|
|
2429
2488
|
const html = block.innerHTML || '';
|
|
2430
2489
|
return jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: html } });
|
|
2431
2490
|
},
|
|
2491
|
+
// Spacer block - adds vertical spacing
|
|
2492
|
+
'core/spacer': ({ block }) => {
|
|
2493
|
+
const height = extractSpacerHeight(block);
|
|
2494
|
+
if (height && height > 0) {
|
|
2495
|
+
return jsxRuntimeExports.jsx("div", { style: { height: `${height}px` }, "aria-hidden": "true" });
|
|
2496
|
+
}
|
|
2497
|
+
// Default fallback if height not found
|
|
2498
|
+
return jsxRuntimeExports.jsx("div", { style: { height: '100px' }, "aria-hidden": "true" });
|
|
2499
|
+
},
|
|
2432
2500
|
};
|
|
2433
2501
|
return {
|
|
2434
2502
|
renderers,
|
|
2435
2503
|
shortcodes: {}, // Empty by default - apps extend this
|
|
2436
2504
|
fallback: Fallback,
|
|
2437
2505
|
colorMapper,
|
|
2506
|
+
spacingConfig,
|
|
2438
2507
|
};
|
|
2439
2508
|
}
|
|
2440
2509
|
// Legacy function for backward compatibility - use getBlockTextContent instead
|
|
@@ -2524,8 +2593,8 @@ function findMatchingMapping(block, mappings) {
|
|
|
2524
2593
|
* const registry = createEnhancedRegistry(mappings);
|
|
2525
2594
|
* ```
|
|
2526
2595
|
*/
|
|
2527
|
-
function createEnhancedRegistry(mappings = [], baseRegistry, colorMapper) {
|
|
2528
|
-
const base = baseRegistry || createDefaultRegistry(colorMapper);
|
|
2596
|
+
function createEnhancedRegistry(mappings = [], baseRegistry, colorMapper, spacingConfig) {
|
|
2597
|
+
const base = baseRegistry || createDefaultRegistry(colorMapper, spacingConfig);
|
|
2529
2598
|
// Create enhanced renderers that check patterns first
|
|
2530
2599
|
const enhancedRenderers = {
|
|
2531
2600
|
...base.renderers,
|
|
@@ -2573,6 +2642,8 @@ function createEnhancedRegistry(mappings = [], baseRegistry, colorMapper) {
|
|
|
2573
2642
|
matchBlock,
|
|
2574
2643
|
// Use provided colorMapper or inherit from base registry
|
|
2575
2644
|
colorMapper: colorMapper || base.colorMapper,
|
|
2645
|
+
// Use provided spacingConfig or inherit from base registry
|
|
2646
|
+
spacingConfig: spacingConfig || base.spacingConfig,
|
|
2576
2647
|
};
|
|
2577
2648
|
}
|
|
2578
2649
|
|
|
@@ -2741,5 +2812,5 @@ const SectionWrapper = ({ children, background = 'light', spacing = 'medium', co
|
|
|
2741
2812
|
return (jsxRuntimeExports.jsx("section", { className: buildClassName(backgroundClasses[finalBackground] || backgroundClasses.light, spacingClasses[finalSpacing] || spacingClasses.medium, containerClasses[finalContainer] || containerClasses.contained, className), children: children }));
|
|
2742
2813
|
};
|
|
2743
2814
|
|
|
2744
|
-
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
2815
|
+
export { SectionWrapper, WPContent, WPErrorBoundary, WPPage, buildClassName, convertImageToCloudflareVariant, convertImageUrl, convertImageUrls, createDefaultRegistry, createEnhancedRegistry, extractAlignment, extractBackgroundColor, extractBackgroundImage, extractButtonsFromInnerBlocks, extractContent, extractDimRatio, extractFontSize, extractHeadingLevel, extractImageAttributes, extractImageUrl, extractImageUrlWithFallback, extractMediaPosition, extractMinHeight, extractOverlayColor, extractSpacerHeight, extractSubtitleFromInnerBlocks, extractTextAlign, extractTextAlignFromInnerBlocks, extractTextFromHTML, extractTitle, extractTitleFromInnerBlocks, extractVerticalAlignment, extractVideoIframeFromInnerBlocks, findMatchingMapping, findShortcodes, getAlignmentClasses, getBlockTextContent, getCloudflareVariantUrl, getContainerClasses, getContentSpacingClasses, getFontSizeClasses, getImageAttributes, getImageUrl, getSectionSpacingClasses, getTextAlignClasses, isCloudflareImageUrl, isValidCloudflareUrl, matchesPattern, parseContentPosition, parseGutenbergBlocks, parseShortcodeAttrs, renderNodes, renderTextWithShortcodes };
|
|
2745
2816
|
//# sourceMappingURL=index.esm.js.map
|