@marvalt/wparser 0.1.5 → 0.1.7
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/components/SectionWrapper.d.ts +30 -0
- package/dist/components/SectionWrapper.d.ts.map +1 -0
- package/dist/index.cjs +434 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +209 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +414 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/react/WPPage.d.ts.map +1 -1
- package/dist/registry/defaultRegistry.d.ts.map +1 -1
- package/dist/registry/enhancedRegistry.d.ts +31 -0
- package/dist/registry/enhancedRegistry.d.ts.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/blockExtractors.d.ts +77 -0
- package/dist/utils/blockExtractors.d.ts.map +1 -0
- package/dist/utils/contentExtractor.d.ts +1 -0
- package/dist/utils/contentExtractor.d.ts.map +1 -1
- package/dist/utils/imageUrlConverter.d.ts +23 -0
- package/dist/utils/imageUrlConverter.d.ts.map +1 -0
- package/dist/utils/patternMatcher.d.ts +11 -0
- package/dist/utils/patternMatcher.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WordPressBlock, RenderContext } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Extract background image URL from a block
|
|
5
|
+
* Checks various possible sources: url, backgroundImage, innerHTML
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractBackgroundImage(block: WordPressBlock): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Extract image URL from a block
|
|
10
|
+
* Returns Cloudflare URL if available, otherwise WordPress URL
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractImageUrl(block: WordPressBlock): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Extract image attributes (url, alt, width, height)
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractImageAttributes(block: WordPressBlock): {
|
|
17
|
+
url: string | null;
|
|
18
|
+
alt: string;
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Extract title/heading text from a block
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractTitle(block: WordPressBlock): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Extract content/text from a block
|
|
28
|
+
* Returns React node for rendering
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractContent(block: WordPressBlock, context: RenderContext): React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Extract media position from media-text block
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractMediaPosition(block: WordPressBlock): 'left' | 'right';
|
|
35
|
+
/**
|
|
36
|
+
* Extract vertical alignment from block
|
|
37
|
+
*/
|
|
38
|
+
export declare function extractVerticalAlignment(block: WordPressBlock): 'top' | 'center' | 'bottom';
|
|
39
|
+
/**
|
|
40
|
+
* Extract alignment (full, wide, contained) from block
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractAlignment(block: WordPressBlock): 'full' | 'wide' | 'contained';
|
|
43
|
+
/**
|
|
44
|
+
* Extract overlay color from cover block
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractOverlayColor(block: WordPressBlock): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Extract dim ratio (overlay opacity) from cover block
|
|
49
|
+
*/
|
|
50
|
+
export declare function extractDimRatio(block: WordPressBlock): number;
|
|
51
|
+
/**
|
|
52
|
+
* Extract min height from block
|
|
53
|
+
*/
|
|
54
|
+
export declare function extractMinHeight(block: WordPressBlock): {
|
|
55
|
+
value: number;
|
|
56
|
+
unit: string;
|
|
57
|
+
} | null;
|
|
58
|
+
/**
|
|
59
|
+
* Extract heading level from heading block
|
|
60
|
+
*/
|
|
61
|
+
export declare function extractHeadingLevel(block: WordPressBlock): number;
|
|
62
|
+
/**
|
|
63
|
+
* Extract text alignment from block
|
|
64
|
+
*/
|
|
65
|
+
export declare function extractTextAlign(block: WordPressBlock): 'left' | 'center' | 'right' | null;
|
|
66
|
+
/**
|
|
67
|
+
* Extract font size from block
|
|
68
|
+
*/
|
|
69
|
+
export declare function extractFontSize(block: WordPressBlock): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Convert image URL to Cloudflare variant if it's a Cloudflare URL
|
|
72
|
+
*/
|
|
73
|
+
export declare function convertImageToCloudflareVariant(url: string | null, options?: {
|
|
74
|
+
width?: number;
|
|
75
|
+
height?: number;
|
|
76
|
+
}): string | null;
|
|
77
|
+
//# sourceMappingURL=blockExtractors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockExtractors.d.ts","sourceRoot":"","sources":["../../src/utils/blockExtractors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9D;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CA4B3E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAEpE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG;IAC7D,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAEA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAIjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK,CAAC,SAAS,CAG7F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,OAAO,CAI5E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAO3F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,CAOrF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAOxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAO7D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAU9F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAOjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAO1F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAIpE;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAChD,MAAM,GAAG,IAAI,CAUf"}
|
|
@@ -14,6 +14,7 @@ export declare function getBlockTextContent(block: WordPressBlock): string;
|
|
|
14
14
|
/**
|
|
15
15
|
* Extract image URL from block attributes
|
|
16
16
|
* Checks for Cloudflare URLs first, then falls back to regular URLs
|
|
17
|
+
* Also extracts from innerHTML if needed
|
|
17
18
|
*/
|
|
18
19
|
export declare function getImageUrl(block: WordPressBlock): string | null;
|
|
19
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentExtractor.d.ts","sourceRoot":"","sources":["../../src/utils/contentExtractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"contentExtractor.d.ts","sourceRoot":"","sources":["../../src/utils/contentExtractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAuB3E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAgBjE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CA6BhE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG;IACzD,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAUA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ImageConversionOptions {
|
|
2
|
+
/** Convert to Cloudflare variant if URL is already Cloudflare */
|
|
3
|
+
convertToCloudflare?: boolean;
|
|
4
|
+
/** Default width for Cloudflare variant */
|
|
5
|
+
defaultWidth?: number;
|
|
6
|
+
/** Default height for Cloudflare variant */
|
|
7
|
+
defaultHeight?: number;
|
|
8
|
+
/** Force conversion even if URL is not Cloudflare (not recommended) */
|
|
9
|
+
forceCloudflare?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Convert image URL with optional Cloudflare variant transformation
|
|
13
|
+
*
|
|
14
|
+
* @param url - Image URL (WordPress or Cloudflare)
|
|
15
|
+
* @param options - Conversion options
|
|
16
|
+
* @returns Converted URL or original if conversion not applicable
|
|
17
|
+
*/
|
|
18
|
+
export declare function convertImageUrl(url: string | null | undefined, options?: ImageConversionOptions): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Batch convert multiple image URLs
|
|
21
|
+
*/
|
|
22
|
+
export declare function convertImageUrls(urls: (string | null | undefined)[], options?: ImageConversionOptions): (string | null)[];
|
|
23
|
+
//# sourceMappingURL=imageUrlConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageUrlConverter.d.ts","sourceRoot":"","sources":["../../src/utils/imageUrlConverter.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,iEAAiE;IACjE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,OAAO,GAAE,sBAA2B,GACnC,MAAM,GAAG,IAAI,CA8Bf;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACnC,OAAO,GAAE,sBAA2B,GACnC,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAEnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WordPressBlock, BlockPattern, ComponentMapping } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a block matches a pattern
|
|
4
|
+
*/
|
|
5
|
+
export declare function matchesPattern(block: WordPressBlock, pattern: BlockPattern): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Find the best matching component mapping for a block
|
|
8
|
+
* Returns the mapping with highest priority that matches, or null
|
|
9
|
+
*/
|
|
10
|
+
export declare function findMatchingMapping(block: WordPressBlock, mappings: ComponentMapping[]): ComponentMapping | null;
|
|
11
|
+
//# sourceMappingURL=patternMatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patternMatcher.d.ts","sourceRoot":"","sources":["../../src/utils/patternMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE/E;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,YAAY,GACpB,OAAO,CAiCT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,gBAAgB,GAAG,IAAI,CAmBzB"}
|
package/package.json
CHANGED