html-to-gutenberg 4.2.9 → 4.2.11
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/.env.example +20 -3
- package/.github/workflows/sync-npm.yml +154 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/launch.json +50 -0
- package/.vscode/settings.json +23 -0
- package/.vscode/spellright.dict +2 -0
- package/.vscode/tasks.json +33 -0
- package/fetch-page-assets.test.ts +448 -0
- package/index.d.ts +173 -0
- package/index.js +570 -224
- package/index.test.ts +633 -4
- package/index.ts +168 -63
- package/package.json +25 -24
- package/public/fonts/README.md +24 -0
- package/public/fonts/fa-brands-400.eot +0 -0
- package/public/fonts/fa-brands-400.svg +3570 -0
- package/public/fonts/fa-brands-400.ttf +0 -0
- package/public/fonts/fa-brands-400.woff +0 -0
- package/public/fonts/fa-brands-400.woff2 +0 -0
- package/public/fonts/fa-regular-400.eot +0 -0
- package/public/fonts/fa-regular-400.svg +803 -0
- package/public/fonts/fa-regular-400.ttf +0 -0
- package/public/fonts/fa-regular-400.woff +0 -0
- package/public/fonts/fa-regular-400.woff2 +0 -0
- package/public/fonts/fa-solid-400.woff2 +1 -0
- package/public/fonts/fa-solid-900.eot +0 -0
- package/public/fonts/fa-solid-900.svg +4938 -0
- package/public/fonts/fa-solid-900.ttf +0 -0
- package/public/fonts/fa-solid-900.woff +0 -0
- package/public/fonts/fa-solid-900.woff2 +0 -0
- package/r2.js +163 -0
- package/readme.md +122 -88
- package/scripts/patch-fetch-page-assets.mjs +13 -0
- package/scripts/sync-from-npm.mjs +115 -0
- package/tsconfig.json +17 -2
- package/vendor/fetch-page-assets/LICENSE.MD +21 -0
- package/vendor/fetch-page-assets/README.md +117 -0
- package/vendor/fetch-page-assets/index.js +362 -0
- package/vendor/fetch-page-assets/package.json +48 -0
- package/.env +0 -1
package/index.ts
CHANGED
|
@@ -1,68 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1
|
+
export type GeneratedFiles = Record<string, string>;
|
|
2
|
+
|
|
3
|
+
export type JobOutputFile = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
size: number;
|
|
8
|
+
path: string;
|
|
9
|
+
url: string;
|
|
10
|
+
kind: 'source' | 'asset' | 'bundle';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type JobBundle = {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
size: number;
|
|
18
|
+
path: string;
|
|
19
|
+
url: string;
|
|
20
|
+
zipUrl: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type JobManifest = {
|
|
24
|
+
jobId: string;
|
|
25
|
+
status: 'completed';
|
|
26
|
+
output: {
|
|
27
|
+
files: JobOutputFile[];
|
|
28
|
+
bundle: JobBundle;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type NormalizedBlockOptions = {
|
|
33
|
+
title: string;
|
|
34
|
+
name: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
namespace: string;
|
|
37
|
+
prefix: string;
|
|
38
|
+
baseUrl: string | null;
|
|
39
|
+
source: string | null;
|
|
40
|
+
category: string;
|
|
41
|
+
registerCategoryIfMissing: boolean;
|
|
42
|
+
outputPath: string;
|
|
43
|
+
basePath: string;
|
|
44
|
+
writeFiles: boolean;
|
|
45
|
+
shouldSaveFiles: boolean;
|
|
46
|
+
generatePreviewImage: boolean;
|
|
47
|
+
generateIconPreview: boolean;
|
|
48
|
+
jsFiles: string[];
|
|
49
|
+
cssFiles: string[];
|
|
50
|
+
outputMode: 'job' | 'legacy';
|
|
51
|
+
uploadToR2: boolean;
|
|
52
|
+
jobId?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type BlockOptions = {
|
|
56
|
+
title?: string;
|
|
57
|
+
slug?: string;
|
|
58
|
+
baseUrl?: string | null;
|
|
59
|
+
namespace?: string;
|
|
60
|
+
category?: string;
|
|
61
|
+
registerCategoryIfMissing?: boolean;
|
|
62
|
+
outputPath?: string;
|
|
63
|
+
writeFiles?: boolean;
|
|
64
|
+
generatePreviewImage?: boolean;
|
|
65
|
+
jsFiles?: string[];
|
|
66
|
+
cssFiles?: string[];
|
|
67
|
+
outputMode?: 'job' | 'legacy';
|
|
68
|
+
uploadToR2?: boolean;
|
|
69
|
+
jobId?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
prefix?: string;
|
|
72
|
+
source?: string | null;
|
|
73
|
+
basePath?: string;
|
|
74
|
+
shouldSaveFiles?: boolean;
|
|
75
|
+
generateIconPreview?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export declare const createProfiler: (enabled: boolean) => {
|
|
79
|
+
start(label: string): void;
|
|
80
|
+
end(label: string): void;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export declare const findSelfClosingJsxEnd: (
|
|
84
|
+
content: string,
|
|
85
|
+
startIndex: number
|
|
86
|
+
) => number;
|
|
87
|
+
|
|
88
|
+
export declare const replaceSelfClosingJsxComponent: (
|
|
89
|
+
content: string,
|
|
90
|
+
componentName: string,
|
|
91
|
+
replacer: (componentSource: string) => string
|
|
92
|
+
) => string;
|
|
93
|
+
|
|
94
|
+
export declare const getMediaUploadSaveTemplate: (
|
|
95
|
+
image?: {
|
|
96
|
+
randomUrlVariable: string;
|
|
97
|
+
randomAltVariable: string;
|
|
98
|
+
imgClass?: string;
|
|
99
|
+
}
|
|
100
|
+
) => string;
|
|
101
|
+
|
|
102
|
+
export declare const replaceMediaUploadComponents: (
|
|
103
|
+
content: string,
|
|
104
|
+
imageRegistry: Array<{
|
|
105
|
+
randomUrlVariable: string;
|
|
106
|
+
randomAltVariable: string;
|
|
107
|
+
imgClass?: string;
|
|
108
|
+
}>
|
|
109
|
+
) => string;
|
|
110
|
+
|
|
111
|
+
export declare const replaceRichTextComponents: (content: string) => string;
|
|
112
|
+
|
|
113
|
+
export declare const buildAssetExtractionOptions: (
|
|
114
|
+
basePath: string,
|
|
115
|
+
options?: {
|
|
116
|
+
uploadToR2?: boolean;
|
|
117
|
+
returnDetails?: boolean;
|
|
118
|
+
jobId?: string;
|
|
119
|
+
r2Prefix?: string;
|
|
120
|
+
}
|
|
62
121
|
) => {
|
|
63
|
-
|
|
122
|
+
basePath: string;
|
|
123
|
+
saveFile: false;
|
|
124
|
+
verbose: false;
|
|
125
|
+
maxRetryAttempts: 1;
|
|
126
|
+
retryDelay: 0;
|
|
127
|
+
concurrency: 8;
|
|
128
|
+
uploadToR2: boolean;
|
|
129
|
+
returnDetails: boolean;
|
|
130
|
+
jobId?: string;
|
|
131
|
+
r2Prefix?: string;
|
|
64
132
|
};
|
|
65
133
|
|
|
66
|
-
export
|
|
134
|
+
export declare const slugifyBlockValue: (value?: string) => string;
|
|
135
|
+
export declare const formatCategoryLabel: (category?: string) => string;
|
|
136
|
+
export declare const normalizeBlockOptions: (
|
|
137
|
+
options?: BlockOptions
|
|
138
|
+
) => NormalizedBlockOptions;
|
|
139
|
+
|
|
140
|
+
export declare const replaceRelativeUrls: (
|
|
141
|
+
html: string,
|
|
142
|
+
replacer: (url: string) => string
|
|
143
|
+
) => string;
|
|
144
|
+
|
|
145
|
+
export declare const replaceRelativeUrlsInCss: (
|
|
146
|
+
css: string,
|
|
147
|
+
replacer: (url: string) => string
|
|
148
|
+
) => string;
|
|
67
149
|
|
|
150
|
+
export declare const replaceRelativeUrlsInHtml: (
|
|
151
|
+
html: string,
|
|
152
|
+
baseUrl: string
|
|
153
|
+
) => string;
|
|
68
154
|
|
|
155
|
+
export declare const replaceRelativeUrlsInCssWithBase: (
|
|
156
|
+
css: string,
|
|
157
|
+
cssFileUrl: string
|
|
158
|
+
) => string;
|
|
159
|
+
|
|
160
|
+
export declare const unwrapBody: (code: string) => string;
|
|
161
|
+
|
|
162
|
+
export declare const transformBlockFile: (
|
|
163
|
+
blockCode: string
|
|
164
|
+
) => { code?: string } | string;
|
|
165
|
+
|
|
166
|
+
export declare const getSnapApiUrl: () => string;
|
|
167
|
+
|
|
168
|
+
declare const block: (
|
|
169
|
+
htmlContent: string,
|
|
170
|
+
options?: BlockOptions
|
|
171
|
+
) => Promise<GeneratedFiles | JobManifest>;
|
|
172
|
+
|
|
173
|
+
export default block;
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
+
"@aws-sdk/client-s3": "^3.888.0",
|
|
3
4
|
"@babel/core": "^7.29.0",
|
|
4
5
|
"@babel/preset-react": "^7.28.5",
|
|
5
6
|
"@svgr/core": "^8.1.0",
|
|
@@ -8,6 +9,8 @@
|
|
|
8
9
|
"dotenv": "^17.3.1",
|
|
9
10
|
"fetch-page-assets": "^1.2.7",
|
|
10
11
|
"fs": "^0.0.1-security",
|
|
12
|
+
"jszip": "^3.10.1",
|
|
13
|
+
"mime-types": "^3.0.1",
|
|
11
14
|
"node-fetch": "^3.3.2",
|
|
12
15
|
"node-html-to-jsx": "^1.4.4",
|
|
13
16
|
"path": "^0.12.7"
|
|
@@ -25,6 +28,7 @@
|
|
|
25
28
|
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
26
29
|
"@typescript-eslint/parser": "^8.56.1",
|
|
27
30
|
"chai": "^6.2.2",
|
|
31
|
+
"c8": "^11.0.0",
|
|
28
32
|
"coveralls": "^3.1.1",
|
|
29
33
|
"eslint": "^10.0.2",
|
|
30
34
|
"mocha": "^11.3.0",
|
|
@@ -34,20 +38,20 @@
|
|
|
34
38
|
"ts-node": "^10.9.2",
|
|
35
39
|
"typescript-eslint": "^8.56.1"
|
|
36
40
|
},
|
|
37
|
-
"types": "index.ts",
|
|
41
|
+
"types": "index.d.ts",
|
|
38
42
|
"name": "html-to-gutenberg",
|
|
39
|
-
"version": "4.2.
|
|
43
|
+
"version": "4.2.11",
|
|
40
44
|
"description": "Transform any valid HTML string into fully editable WP Gutenberg blocks in seconds rather than hours.",
|
|
41
45
|
"main": "index.js",
|
|
42
46
|
"directories": {
|
|
43
47
|
"test": "test"
|
|
44
48
|
},
|
|
45
49
|
"scripts": {
|
|
46
|
-
"postinstall": "mv ./node_modules/fetch-page-assets/index.ts ./node_modules/fetch-page-assets/index.ts.bak || true",
|
|
47
|
-
"test": "mocha -r ts-node/register index.test.ts",
|
|
50
|
+
"postinstall": "mv ./node_modules/fetch-page-assets/index.ts ./node_modules/fetch-page-assets/index.ts.bak || true && node ./scripts/patch-fetch-page-assets.mjs",
|
|
51
|
+
"test": "mocha -r ts-node/register/transpile-only index.test.ts fetch-page-assets.test.ts",
|
|
48
52
|
"build": "tsc",
|
|
49
|
-
"coverage": "
|
|
50
|
-
"coveralls": "
|
|
53
|
+
"coverage": "c8 mocha -r ts-node/register/transpile-only index.test.ts fetch-page-assets.test.ts",
|
|
54
|
+
"coveralls": "c8 mocha -r ts-node/register/transpile-only index.test.ts fetch-page-assets.test.ts && c8 report --reporter=lcov && cat coverage/lcov.info | coveralls"
|
|
51
55
|
},
|
|
52
56
|
"repository": {
|
|
53
57
|
"type": "git",
|
|
@@ -72,28 +76,25 @@
|
|
|
72
76
|
"url": "https://github.com/DiogoAngelim/html-to-gutenberg/issues"
|
|
73
77
|
},
|
|
74
78
|
"homepage": "https://www.html-to-gutenberg.io",
|
|
75
|
-
"
|
|
79
|
+
"c8": {
|
|
76
80
|
"reporter": [
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
],
|
|
80
|
-
"exclude": [
|
|
81
|
-
"coverage"
|
|
81
|
+
"text",
|
|
82
|
+
"lcov"
|
|
82
83
|
],
|
|
83
84
|
"include": [
|
|
84
|
-
"
|
|
85
|
-
"
|
|
85
|
+
"index.js",
|
|
86
|
+
"utils.ts",
|
|
87
|
+
"globals.js",
|
|
88
|
+
"vendor/fetch-page-assets/index.js"
|
|
86
89
|
],
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
+
"exclude": [
|
|
91
|
+
"coverage",
|
|
92
|
+
"dist",
|
|
93
|
+
"node_modules",
|
|
94
|
+
"scripts",
|
|
95
|
+
"**/*.test.ts"
|
|
90
96
|
],
|
|
91
|
-
"all": true
|
|
92
|
-
"sourceMap": true,
|
|
93
|
-
"instrument": true,
|
|
94
|
-
"require": [
|
|
95
|
-
"ts-node/register"
|
|
96
|
-
]
|
|
97
|
+
"all": true
|
|
97
98
|
},
|
|
98
99
|
"jest": {
|
|
99
100
|
"preset": "ts-jest/presets/js-with-ts",
|
|
@@ -127,4 +128,4 @@
|
|
|
127
128
|
"<rootDir>/dist/*.test.js"
|
|
128
129
|
]
|
|
129
130
|
}
|
|
130
|
-
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Fonts Directory
|
|
2
|
+
|
|
3
|
+
This directory contains custom fonts for the Blockchain Explorer application.
|
|
4
|
+
|
|
5
|
+
## Required Font Files
|
|
6
|
+
|
|
7
|
+
The application expects the following font files:
|
|
8
|
+
|
|
9
|
+
1. **BlockchainFont-Regular.woff2** and **BlockchainFont-Regular.woff**
|
|
10
|
+
- Regular weight font for the main UI
|
|
11
|
+
|
|
12
|
+
2. **BlockchainFont-Bold.woff2** and **BlockchainFont-Bold.woff**
|
|
13
|
+
- Bold weight font for headings
|
|
14
|
+
|
|
15
|
+
3. **TechMono-Regular.woff2** and **TechMono-Regular.woff**
|
|
16
|
+
- Monospace font for code and hash displays
|
|
17
|
+
|
|
18
|
+
## Note
|
|
19
|
+
|
|
20
|
+
If you don't have custom fonts, the application will fall back to system fonts:
|
|
21
|
+
- BlockchainFont → system sans-serif fonts
|
|
22
|
+
- TechMono → system monospace fonts (Courier New, etc.)
|
|
23
|
+
|
|
24
|
+
The fonts are referenced in `public/index.html` and will be loaded automatically when available.
|
|
Binary file
|