@bloklabs/cli 1.16.0 → 1.16.1
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/block-builder-BEbdp0xc.mjs +1019 -0
- package/dist/block-builder-BV7ySSOn.mjs +1269 -0
- package/dist/block-builder-CTpURcXu.mjs +1022 -0
- package/dist/block-builder-DaGEOJ2S.mjs +831 -0
- package/dist/block-builder-Dc6PL7RK.mjs +825 -0
- package/dist/block-builder-DeebuGHy.mjs +1453 -0
- package/dist/block-builder-Dqos6hzP.mjs +1067 -0
- package/dist/block-builder-lzpU_6ZF.mjs +827 -0
- package/dist/cli.mjs +2 -2
- package/dist/convert-gdocs--8aPMm3f.mjs +205 -0
- package/dist/convert-gdocs-7NAwDDZ2.mjs +214 -0
- package/dist/convert-gdocs-9-fmO8W7.mjs +214 -0
- package/dist/convert-gdocs-BNVlyZ1j.mjs +13 -0
- package/dist/convert-gdocs-BSQNj9_W.mjs +13 -0
- package/dist/convert-gdocs-BZ2ovDNS.mjs +205 -0
- package/dist/convert-gdocs-CB-kubaI.mjs +208 -0
- package/dist/convert-gdocs-CizVIpiR.mjs +205 -0
- package/dist/convert-gdocs-DtU-P2qd.mjs +13 -0
- package/dist/convert-gdocs-msIm10vX.mjs +214 -0
- package/dist/convert-html-1lRolRGH.mjs +13 -0
- package/dist/convert-html-BI7SFKwK.mjs +13 -0
- package/dist/convert-html-BbJEHZTW.mjs +13 -0
- package/dist/convert-html-BcYeUJKw.mjs +13 -0
- package/dist/convert-html-BxJX_msU.mjs +13 -0
- package/dist/convert-html-CS_2LG6q.mjs +13 -0
- package/dist/convert-html-DEW3D-Ub.mjs +13 -0
- package/dist/convert-html-DGBMQXkH.mjs +13 -0
- package/dist/convert-html-DGTszKTe.mjs +13 -0
- package/dist/convert-html-Oocfb7JD.mjs +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
//#region src/components/shared/color-presets.ts
|
|
2
|
+
var e = [
|
|
3
|
+
{
|
|
4
|
+
name: "gray",
|
|
5
|
+
text: "#787774",
|
|
6
|
+
bg: "#f1f1ef"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: "brown",
|
|
10
|
+
text: "#9f6b53",
|
|
11
|
+
bg: "#f4eeee"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "orange",
|
|
15
|
+
text: "#d9730d",
|
|
16
|
+
bg: "#fbecdd"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "yellow",
|
|
20
|
+
text: "#cb9b00",
|
|
21
|
+
bg: "#fbf3db"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "green",
|
|
25
|
+
text: "#448361",
|
|
26
|
+
bg: "#edf3ec"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "blue",
|
|
30
|
+
text: "#337ea9",
|
|
31
|
+
bg: "#e7f3f8"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "purple",
|
|
35
|
+
text: "#9065b0",
|
|
36
|
+
bg: "#f6f3f9"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "pink",
|
|
40
|
+
text: "#c14c8a",
|
|
41
|
+
bg: "#f9f0f5"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "red",
|
|
45
|
+
text: "#d44c47",
|
|
46
|
+
bg: "#fdebec"
|
|
47
|
+
}
|
|
48
|
+
], t = [
|
|
49
|
+
{
|
|
50
|
+
name: "gray",
|
|
51
|
+
text: "#9b9b9b",
|
|
52
|
+
bg: "#2f2f2f"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "brown",
|
|
56
|
+
text: "#c59177",
|
|
57
|
+
bg: "#452a1c"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "orange",
|
|
61
|
+
text: "#dc8c47",
|
|
62
|
+
bg: "#4d2f14"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "yellow",
|
|
66
|
+
text: "#d4ab49",
|
|
67
|
+
bg: "#544012"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "green",
|
|
71
|
+
text: "#5db184",
|
|
72
|
+
bg: "#1e432f"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "blue",
|
|
76
|
+
text: "#5c9fcc",
|
|
77
|
+
bg: "#123a54"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "purple",
|
|
81
|
+
text: "#a67dca",
|
|
82
|
+
bg: "#341d49"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "pink",
|
|
86
|
+
text: "#d45e99",
|
|
87
|
+
bg: "#4b1b33"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "red",
|
|
91
|
+
text: "#dd5e5a",
|
|
92
|
+
bg: "#4e1a18"
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/components/utils/default-page-colors.ts
|
|
97
|
+
function n(e) {
|
|
98
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
99
|
+
return t === "rgb(255,255,255)" || t === "#ffffff" || t === "#fff" || t === "white";
|
|
100
|
+
}
|
|
101
|
+
function r(e) {
|
|
102
|
+
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
|
|
103
|
+
if (n) {
|
|
104
|
+
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
105
|
+
return .2126 * e + .7152 * t + .0722 * r;
|
|
106
|
+
}
|
|
107
|
+
let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
|
|
108
|
+
if (r) {
|
|
109
|
+
let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
|
|
110
|
+
if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
|
|
111
|
+
let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => e < 0 ? e + 1 : e > 1 ? e - 1 : e, s = (e) => {
|
|
112
|
+
let t = o(e);
|
|
113
|
+
return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
|
|
114
|
+
}, c = s(e + 1 / 3), l = s(e), u = s(e - 1 / 3);
|
|
115
|
+
return .2126 * c + .7152 * l + .0722 * u;
|
|
116
|
+
}
|
|
117
|
+
let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
118
|
+
if (i) {
|
|
119
|
+
let e = i[1], t = e.length === 3 ? [
|
|
120
|
+
e[0] + e[0],
|
|
121
|
+
e[1] + e[1],
|
|
122
|
+
e[2] + e[2]
|
|
123
|
+
] : [
|
|
124
|
+
e.substring(0, 2),
|
|
125
|
+
e.substring(2, 4),
|
|
126
|
+
e.substring(4, 6)
|
|
127
|
+
], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
128
|
+
return .2126 * n + .7152 * r + .0722 * a;
|
|
129
|
+
}
|
|
130
|
+
return -1;
|
|
131
|
+
}
|
|
132
|
+
function i(e) {
|
|
133
|
+
let t = r(e);
|
|
134
|
+
return t >= 0 && t < .12;
|
|
135
|
+
}
|
|
136
|
+
var a = 250;
|
|
137
|
+
function o(e) {
|
|
138
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
139
|
+
if (t === "transparent") return {
|
|
140
|
+
r: 0,
|
|
141
|
+
g: 0,
|
|
142
|
+
b: 0,
|
|
143
|
+
a: 0
|
|
144
|
+
};
|
|
145
|
+
if (t === "white") return {
|
|
146
|
+
r: 255,
|
|
147
|
+
g: 255,
|
|
148
|
+
b: 255,
|
|
149
|
+
a: 1
|
|
150
|
+
};
|
|
151
|
+
let n = /^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/.exec(t);
|
|
152
|
+
if (n) return {
|
|
153
|
+
r: parseInt(n[1], 10),
|
|
154
|
+
g: parseInt(n[2], 10),
|
|
155
|
+
b: parseInt(n[3], 10),
|
|
156
|
+
a: n[4] === void 0 ? 1 : parseFloat(n[4])
|
|
157
|
+
};
|
|
158
|
+
let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
159
|
+
if (r) {
|
|
160
|
+
let e = r[1], t = e.length === 3 ? [
|
|
161
|
+
e[0] + e[0],
|
|
162
|
+
e[1] + e[1],
|
|
163
|
+
e[2] + e[2]
|
|
164
|
+
] : [
|
|
165
|
+
e.substring(0, 2),
|
|
166
|
+
e.substring(2, 4),
|
|
167
|
+
e.substring(4, 6)
|
|
168
|
+
];
|
|
169
|
+
return {
|
|
170
|
+
r: parseInt(t[0], 16),
|
|
171
|
+
g: parseInt(t[1], 16),
|
|
172
|
+
b: parseInt(t[2], 16),
|
|
173
|
+
a: 1
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
function s(e) {
|
|
179
|
+
let t = o(e);
|
|
180
|
+
return t !== null && (t.a === 0 || t.r >= a && t.g >= a && t.b >= a) || i(e);
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/components/utils/color-mapping.ts
|
|
184
|
+
function c(e, t, n) {
|
|
185
|
+
let r = t / 100, i = n / 100;
|
|
186
|
+
if (r === 0) {
|
|
187
|
+
let e = Math.round(i * 255);
|
|
188
|
+
return [
|
|
189
|
+
e,
|
|
190
|
+
e,
|
|
191
|
+
e
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
let a = (e) => e < 0 ? e + 1 : e > 1 ? e - 1 : e, o = (e, t, n) => {
|
|
195
|
+
let r = a(n);
|
|
196
|
+
return r < 1 / 6 ? e + (t - e) * 6 * r : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e;
|
|
197
|
+
}, s = i < .5 ? i * (1 + r) : i + r - i * r, c = 2 * i - s, l = e / 360;
|
|
198
|
+
return [
|
|
199
|
+
Math.round(o(c, s, l + 1 / 3) * 255),
|
|
200
|
+
Math.round(o(c, s, l) * 255),
|
|
201
|
+
Math.round(o(c, s, l - 1 / 3) * 255)
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
function l(e) {
|
|
205
|
+
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
206
|
+
if (t) return [
|
|
207
|
+
parseInt(t[1], 16),
|
|
208
|
+
parseInt(t[2], 16),
|
|
209
|
+
parseInt(t[3], 16)
|
|
210
|
+
];
|
|
211
|
+
let n = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})[0-9a-f]{2}$/i.exec(e);
|
|
212
|
+
if (n) return [
|
|
213
|
+
parseInt(n[1], 16),
|
|
214
|
+
parseInt(n[2], 16),
|
|
215
|
+
parseInt(n[3], 16)
|
|
216
|
+
];
|
|
217
|
+
let r = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);
|
|
218
|
+
if (r) return [
|
|
219
|
+
parseInt(r[1] + r[1], 16),
|
|
220
|
+
parseInt(r[2] + r[2], 16),
|
|
221
|
+
parseInt(r[3] + r[3], 16)
|
|
222
|
+
];
|
|
223
|
+
let i = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]$/i.exec(e);
|
|
224
|
+
if (i) return [
|
|
225
|
+
parseInt(i[1] + i[1], 16),
|
|
226
|
+
parseInt(i[2] + i[2], 16),
|
|
227
|
+
parseInt(i[3] + i[3], 16)
|
|
228
|
+
];
|
|
229
|
+
let a = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
230
|
+
if (a) return [
|
|
231
|
+
Number(a[1]),
|
|
232
|
+
Number(a[2]),
|
|
233
|
+
Number(a[3])
|
|
234
|
+
];
|
|
235
|
+
let o = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
236
|
+
return o ? c(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
237
|
+
}
|
|
238
|
+
var u = .1;
|
|
239
|
+
function d(e) {
|
|
240
|
+
let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.max(t, n, r), a = Math.min(t, n, r), o = (i + a) / 2;
|
|
241
|
+
if (i === a) return [
|
|
242
|
+
0,
|
|
243
|
+
0,
|
|
244
|
+
o
|
|
245
|
+
];
|
|
246
|
+
let s = i - a, c = o > .5 ? s / (2 - i - a) : s / (i + a);
|
|
247
|
+
return [
|
|
248
|
+
((e) => e === t ? ((n - r) / s + (n < r ? 6 : 0)) / 6 : e === n ? ((r - t) / s + 2) / 6 : ((t - n) / s + 4) / 6)(i) * 360,
|
|
249
|
+
c,
|
|
250
|
+
o
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
function f(e, t) {
|
|
254
|
+
let n = e[1] < u, r = t[1] < u;
|
|
255
|
+
if (n && r) {
|
|
256
|
+
let n = Math.abs(e[2] - t[2]);
|
|
257
|
+
return n * n;
|
|
258
|
+
}
|
|
259
|
+
if (n !== r) return 1e3;
|
|
260
|
+
let i = Math.abs(e[0] - t[0]), a = Math.min(i, 360 - i) / 180, o = Math.abs(e[1] - t[1]), s = Math.abs(e[2] - t[2]);
|
|
261
|
+
return 8 * a * a + 1 * o * o + 1 * s * s;
|
|
262
|
+
}
|
|
263
|
+
function p(t, r) {
|
|
264
|
+
if (r === "bg" && (n(t) || i(t))) return t;
|
|
265
|
+
let a = l(t);
|
|
266
|
+
if (a === null) return t;
|
|
267
|
+
let o = d(a);
|
|
268
|
+
return e.reduce((e, t) => {
|
|
269
|
+
let n = l(t[r]);
|
|
270
|
+
if (n === null) return e;
|
|
271
|
+
let i = f(o, d(n));
|
|
272
|
+
return i < e.distance ? {
|
|
273
|
+
color: t[r],
|
|
274
|
+
distance: i
|
|
275
|
+
} : e;
|
|
276
|
+
}, {
|
|
277
|
+
color: t,
|
|
278
|
+
distance: Infinity
|
|
279
|
+
}).color;
|
|
280
|
+
}
|
|
281
|
+
function m(r, a) {
|
|
282
|
+
if (a === "bg" && (n(r) || i(r))) return null;
|
|
283
|
+
let o = l(r);
|
|
284
|
+
if (o === null) return null;
|
|
285
|
+
let s = d(o);
|
|
286
|
+
return [...e, ...t].reduce((e, t) => {
|
|
287
|
+
let n = l(t[a]);
|
|
288
|
+
if (n === null) return e;
|
|
289
|
+
let r = f(s, d(n));
|
|
290
|
+
return e === null || r < e.distance ? {
|
|
291
|
+
name: t.name,
|
|
292
|
+
distance: r
|
|
293
|
+
} : e;
|
|
294
|
+
}, null)?.name ?? null;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/shared/inline-normalization-policy.ts
|
|
298
|
+
var h = /* @__PURE__ */ new Set([
|
|
299
|
+
"A",
|
|
300
|
+
"B",
|
|
301
|
+
"STRONG",
|
|
302
|
+
"I",
|
|
303
|
+
"EM",
|
|
304
|
+
"U",
|
|
305
|
+
"S",
|
|
306
|
+
"DEL",
|
|
307
|
+
"INS",
|
|
308
|
+
"MARK",
|
|
309
|
+
"CODE",
|
|
310
|
+
"SUB",
|
|
311
|
+
"SUP",
|
|
312
|
+
"SMALL",
|
|
313
|
+
"SPAN",
|
|
314
|
+
"FONT"
|
|
315
|
+
]), g = new Set([...h].filter((e) => e !== "A")), _ = /* @__PURE__ */ new Set([
|
|
316
|
+
"IMG",
|
|
317
|
+
"IFRAME",
|
|
318
|
+
"VIDEO",
|
|
319
|
+
"AUDIO",
|
|
320
|
+
"INPUT",
|
|
321
|
+
"SVG",
|
|
322
|
+
"CANVAS",
|
|
323
|
+
"OBJECT",
|
|
324
|
+
"EMBED"
|
|
325
|
+
]), ee = /* @__PURE__ */ new Set([
|
|
326
|
+
"U",
|
|
327
|
+
"S",
|
|
328
|
+
"DEL",
|
|
329
|
+
"INS"
|
|
330
|
+
]), te = /* @__PURE__ */ new Set([
|
|
331
|
+
"background-color",
|
|
332
|
+
"background",
|
|
333
|
+
"text-decoration",
|
|
334
|
+
"text-decoration-line",
|
|
335
|
+
"border",
|
|
336
|
+
"border-bottom",
|
|
337
|
+
"box-shadow",
|
|
338
|
+
"outline"
|
|
339
|
+
]), v = /* @__PURE__ */ new Set([
|
|
340
|
+
"",
|
|
341
|
+
"none",
|
|
342
|
+
"transparent",
|
|
343
|
+
"initial",
|
|
344
|
+
"unset"
|
|
345
|
+
]), y = (e) => {
|
|
346
|
+
let t = e.attributes.filter((e) => e.name.toLowerCase() !== "style").map((e) => `${e.name.toLowerCase()}=${e.value}`).sort(), n = e.styleDeclarations.map((e) => `${e.property.toLowerCase()}:${e.value.trim()}`).sort();
|
|
347
|
+
return `${e.tagName}|${t.join("|")}|${n.join(";")}`;
|
|
348
|
+
}, b = (e) => e.attributes.some((e) => e.name.toLowerCase() === "id"), x = (e) => ee.has(e.tagName) ? !0 : e.styleDeclarations.some((e) => te.has(e.property.toLowerCase()) && !v.has(e.value.trim().toLowerCase())), S = (e) => {
|
|
349
|
+
if (!g.has(e.tagName)) return !1;
|
|
350
|
+
let t = e.text();
|
|
351
|
+
return t.trim().length > 0 || e.hasVoidContentDescendant() ? !1 : t.length === 0 || !x(e);
|
|
352
|
+
}, C = (e, t) => !h.has(e.tagName) || b(e) || b(t) ? !1 : y(e) === y(t), ne = (e, t) => {
|
|
353
|
+
if (!h.has(e.tagName) || b(e)) return !1;
|
|
354
|
+
let n = y(e);
|
|
355
|
+
return t.some((e) => y(e) === n);
|
|
356
|
+
}, w = (e) => {
|
|
357
|
+
let t = e.style, n = Array.from({ length: t.length }, (e, n) => {
|
|
358
|
+
let r = t.item(n);
|
|
359
|
+
return {
|
|
360
|
+
property: r,
|
|
361
|
+
value: t.getPropertyValue(r)
|
|
362
|
+
};
|
|
363
|
+
});
|
|
364
|
+
return {
|
|
365
|
+
tagName: e.tagName.toUpperCase(),
|
|
366
|
+
attributes: Array.from(e.attributes).map((e) => ({
|
|
367
|
+
name: e.name,
|
|
368
|
+
value: e.value
|
|
369
|
+
})),
|
|
370
|
+
styleDeclarations: n,
|
|
371
|
+
text: () => e.textContent ?? "",
|
|
372
|
+
hasVoidContentDescendant: () => Array.from(e.querySelectorAll("*")).some((e) => _.has(e.tagName.toUpperCase()))
|
|
373
|
+
};
|
|
374
|
+
}, T = (e, t) => {
|
|
375
|
+
let n = e.parentElement;
|
|
376
|
+
return n === null || n === t ? [] : [w(n), ...T(n, t)];
|
|
377
|
+
}, E = (e) => {
|
|
378
|
+
let t = e.parentNode;
|
|
379
|
+
if (t !== null) {
|
|
380
|
+
for (; e.firstChild !== null;) t.insertBefore(e.firstChild, e);
|
|
381
|
+
t.removeChild(e);
|
|
382
|
+
}
|
|
383
|
+
}, D = (e) => {
|
|
384
|
+
let t = (t) => e.contains(t), n = (e) => t(e) && h.has(e.tagName.toUpperCase()), r = Array.from(e.querySelectorAll("*")).filter((t) => {
|
|
385
|
+
if (!n(t)) return !1;
|
|
386
|
+
let r = w(t);
|
|
387
|
+
return S(r) || ne(r, T(t, e));
|
|
388
|
+
});
|
|
389
|
+
r.forEach(E);
|
|
390
|
+
let i = (e, t) => {
|
|
391
|
+
let n = e.nextSibling;
|
|
392
|
+
if (n === null || n.nodeType !== Node.ELEMENT_NODE || !C(t, w(n))) return !1;
|
|
393
|
+
let r = n;
|
|
394
|
+
for (; r.firstChild !== null;) e.appendChild(r.firstChild);
|
|
395
|
+
return r.remove(), i(e, t), !0;
|
|
396
|
+
}, a = Array.from(e.querySelectorAll("*")).filter(n).map((e) => t(e) && i(e, w(e))).some(Boolean);
|
|
397
|
+
return r.length > 0 || a;
|
|
398
|
+
}, O = (e) => {
|
|
399
|
+
let t = (n) => n === 0 || !D(e) ? !1 : (t(n - 1), !0), n = t(10);
|
|
400
|
+
return n && e.normalize?.(), n;
|
|
401
|
+
};
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/cli/commands/convert-html/preprocessor.ts
|
|
404
|
+
function k(e) {
|
|
405
|
+
A(e), P(e), R(e), B(e), V(e), U(e);
|
|
406
|
+
}
|
|
407
|
+
function A(e) {
|
|
408
|
+
let t = e.ownerDocument;
|
|
409
|
+
for (let n of Array.from(e.querySelectorAll("div[style]"))) {
|
|
410
|
+
if (n.closest("table")) continue;
|
|
411
|
+
let e = L(n);
|
|
412
|
+
if (!e || F(e)) continue;
|
|
413
|
+
let r = t.createElement("aside");
|
|
414
|
+
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), j(r), M(r), n.replaceWith(r);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function j(e) {
|
|
418
|
+
for (;;) {
|
|
419
|
+
let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
|
|
420
|
+
if (t.length === 0) break;
|
|
421
|
+
for (let e of t) e.replaceWith(...Array.from(e.childNodes));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function M(e) {
|
|
425
|
+
for (let t of Array.from(e.querySelectorAll("p"))) {
|
|
426
|
+
let e = t.lastElementChild;
|
|
427
|
+
e?.tagName === "BR" && e.remove();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
var N = 250;
|
|
431
|
+
function P(e) {
|
|
432
|
+
let t = e.querySelectorAll("[style*=\"background-color\"]");
|
|
433
|
+
for (let e of Array.from(t)) F(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), I(e) && e.replaceWith(...Array.from(e.childNodes)));
|
|
434
|
+
}
|
|
435
|
+
function F(e) {
|
|
436
|
+
if (!e) return !1;
|
|
437
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
438
|
+
if (t === "transparent") return !0;
|
|
439
|
+
let n = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
|
|
440
|
+
if (!n) return !1;
|
|
441
|
+
if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
|
|
442
|
+
let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
|
|
443
|
+
return r >= N && i >= N && a >= N;
|
|
444
|
+
}
|
|
445
|
+
function I(e) {
|
|
446
|
+
return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
|
|
447
|
+
}
|
|
448
|
+
function L(e) {
|
|
449
|
+
if (e.style.backgroundColor) return e.style.backgroundColor;
|
|
450
|
+
let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
|
|
451
|
+
if (t) {
|
|
452
|
+
let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
|
|
453
|
+
if (e) return e[1];
|
|
454
|
+
}
|
|
455
|
+
return "";
|
|
456
|
+
}
|
|
457
|
+
function R(e) {
|
|
458
|
+
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
459
|
+
let e = t.querySelectorAll("p");
|
|
460
|
+
if (e.length !== 0) {
|
|
461
|
+
for (let t of Array.from(e)) z(t);
|
|
462
|
+
K(t);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function z(e) {
|
|
467
|
+
if (e.innerHTML.trim() === "" || e.innerHTML.trim() === " ") {
|
|
468
|
+
e.remove();
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
let t = e.ownerDocument, n = t.createDocumentFragment();
|
|
472
|
+
n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
|
|
473
|
+
}
|
|
474
|
+
function B(e) {
|
|
475
|
+
for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || (t.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0 && t.remove();
|
|
476
|
+
}
|
|
477
|
+
function V(e) {
|
|
478
|
+
let t = e.ownerDocument;
|
|
479
|
+
for (let n of Array.from(e.querySelectorAll("del, strike"))) {
|
|
480
|
+
let e = t.createElement("s");
|
|
481
|
+
e.append(...Array.from(n.childNodes)), n.replaceWith(e);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
var H = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
|
|
485
|
+
function U(e) {
|
|
486
|
+
let t = e.ownerDocument, n = W(e);
|
|
487
|
+
for (let e of n) {
|
|
488
|
+
let n = t.createElement("ul");
|
|
489
|
+
e[0].before(n);
|
|
490
|
+
for (let t of e) re(t, n);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function re(e, t) {
|
|
494
|
+
let n = e.ownerDocument.createElement("li"), r = q(e);
|
|
495
|
+
r && (r.textContent = (r.textContent ?? "").replace(H, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
|
|
496
|
+
}
|
|
497
|
+
function W(e) {
|
|
498
|
+
let t = [], n = Array.from(e.childNodes);
|
|
499
|
+
for (let e of n) {
|
|
500
|
+
if (e.nodeType !== Node.ELEMENT_NODE) continue;
|
|
501
|
+
let n = e;
|
|
502
|
+
if (!(n.tagName === "P" && H.test(n.textContent ?? ""))) continue;
|
|
503
|
+
let r = t[t.length - 1], i = G(n);
|
|
504
|
+
r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
|
|
505
|
+
}
|
|
506
|
+
return t;
|
|
507
|
+
}
|
|
508
|
+
function G(e) {
|
|
509
|
+
let t = e.previousSibling;
|
|
510
|
+
return t && t.nodeType === Node.ELEMENT_NODE ? t : null;
|
|
511
|
+
}
|
|
512
|
+
function K(e) {
|
|
513
|
+
for (;;) {
|
|
514
|
+
let t = e.lastChild;
|
|
515
|
+
if (!t) break;
|
|
516
|
+
let n = t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR", r = t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "";
|
|
517
|
+
if (!n && !r) break;
|
|
518
|
+
t.remove();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function q(e) {
|
|
522
|
+
if (e.nodeType === Node.TEXT_NODE) return e;
|
|
523
|
+
for (let t of Array.from(e.childNodes)) {
|
|
524
|
+
let e = q(t);
|
|
525
|
+
if (e) return e;
|
|
526
|
+
}
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/cli/commands/convert-html/sanitizer.ts
|
|
531
|
+
var J = {
|
|
532
|
+
B: !0,
|
|
533
|
+
STRONG: !0,
|
|
534
|
+
I: !0,
|
|
535
|
+
EM: !0,
|
|
536
|
+
A: /* @__PURE__ */ new Set(["href"]),
|
|
537
|
+
S: !0,
|
|
538
|
+
U: !0,
|
|
539
|
+
CODE: !0,
|
|
540
|
+
MARK: /* @__PURE__ */ new Set(["style"]),
|
|
541
|
+
BR: !0,
|
|
542
|
+
P: !0,
|
|
543
|
+
H1: !0,
|
|
544
|
+
H2: !0,
|
|
545
|
+
H3: !0,
|
|
546
|
+
H4: !0,
|
|
547
|
+
H5: !0,
|
|
548
|
+
H6: !0,
|
|
549
|
+
UL: !0,
|
|
550
|
+
OL: !0,
|
|
551
|
+
LI: /* @__PURE__ */ new Set(["aria-level"]),
|
|
552
|
+
TABLE: !0,
|
|
553
|
+
THEAD: !0,
|
|
554
|
+
TBODY: !0,
|
|
555
|
+
TR: !0,
|
|
556
|
+
TD: /* @__PURE__ */ new Set(["style"]),
|
|
557
|
+
TH: /* @__PURE__ */ new Set(["style"]),
|
|
558
|
+
BLOCKQUOTE: !0,
|
|
559
|
+
PRE: !0,
|
|
560
|
+
HR: !0,
|
|
561
|
+
ASIDE: /* @__PURE__ */ new Set(["style"]),
|
|
562
|
+
DETAILS: !0,
|
|
563
|
+
SUMMARY: !0,
|
|
564
|
+
IMG: /* @__PURE__ */ new Set(["src", "style"])
|
|
565
|
+
};
|
|
566
|
+
function Y(e) {
|
|
567
|
+
Z(e);
|
|
568
|
+
}
|
|
569
|
+
function X(e) {
|
|
570
|
+
let t = Array.from(e.childNodes);
|
|
571
|
+
for (let n of t) e.before(n);
|
|
572
|
+
return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
|
|
573
|
+
}
|
|
574
|
+
function ie(e, t) {
|
|
575
|
+
for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
|
|
576
|
+
}
|
|
577
|
+
function Z(e) {
|
|
578
|
+
let t = Array.from(e.childNodes);
|
|
579
|
+
for (let e of t) {
|
|
580
|
+
if (e.nodeType !== e.ELEMENT_NODE) continue;
|
|
581
|
+
let n = e, r = J[n.tagName];
|
|
582
|
+
if (r === void 0) {
|
|
583
|
+
t.push(...X(n));
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
ie(n, r), Z(n);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/cli/commands/convert-html/id-generator.ts
|
|
591
|
+
function ae() {
|
|
592
|
+
let e = /* @__PURE__ */ new Map();
|
|
593
|
+
return (t) => {
|
|
594
|
+
let n = (e.get(t) ?? 0) + 1;
|
|
595
|
+
return e.set(t, n), `${t}-${n}`;
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region src/cli/commands/convert-html/block-builder.ts
|
|
600
|
+
function oe(e) {
|
|
601
|
+
let t = ae(), n = [];
|
|
602
|
+
for (let r of Array.from(e.childNodes)) se(r, n, t);
|
|
603
|
+
return n;
|
|
604
|
+
}
|
|
605
|
+
function se(e, t, n) {
|
|
606
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
607
|
+
let r = e.textContent?.trim() ?? "";
|
|
608
|
+
r && t.push({
|
|
609
|
+
id: n("paragraph"),
|
|
610
|
+
type: "paragraph",
|
|
611
|
+
data: { text: r }
|
|
612
|
+
});
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
616
|
+
let r = e, i = r.tagName;
|
|
617
|
+
if (i === "P") {
|
|
618
|
+
t.push({
|
|
619
|
+
id: n("paragraph"),
|
|
620
|
+
type: "paragraph",
|
|
621
|
+
data: { text: r.innerHTML }
|
|
622
|
+
});
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if (/^H[1-6]$/.test(i)) {
|
|
626
|
+
let e = Number(i[1]);
|
|
627
|
+
t.push({
|
|
628
|
+
id: n("header"),
|
|
629
|
+
type: "header",
|
|
630
|
+
data: {
|
|
631
|
+
text: r.innerHTML,
|
|
632
|
+
level: e
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
if (i === "BLOCKQUOTE") {
|
|
638
|
+
t.push({
|
|
639
|
+
id: n("quote"),
|
|
640
|
+
type: "quote",
|
|
641
|
+
data: {
|
|
642
|
+
text: r.innerHTML,
|
|
643
|
+
size: "default"
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
if (i === "PRE") {
|
|
649
|
+
t.push({
|
|
650
|
+
id: n("code"),
|
|
651
|
+
type: "code",
|
|
652
|
+
data: {
|
|
653
|
+
code: r.textContent ?? "",
|
|
654
|
+
language: "plain-text"
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (i === "HR") {
|
|
660
|
+
t.push({
|
|
661
|
+
id: n("divider"),
|
|
662
|
+
type: "divider",
|
|
663
|
+
data: {}
|
|
664
|
+
});
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
if (i === "IMG") {
|
|
668
|
+
let e = r.getAttribute("src") ?? "", i = fe(r, "width");
|
|
669
|
+
t.push({
|
|
670
|
+
id: n("image"),
|
|
671
|
+
type: "image",
|
|
672
|
+
data: { url: e },
|
|
673
|
+
stretched: null,
|
|
674
|
+
key: null,
|
|
675
|
+
width: i
|
|
676
|
+
});
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (i === "DETAILS") {
|
|
680
|
+
let e = r.querySelector("summary"), i = e ? e.innerHTML : r.innerHTML;
|
|
681
|
+
t.push({
|
|
682
|
+
id: n("toggle"),
|
|
683
|
+
type: "toggle",
|
|
684
|
+
data: { text: i }
|
|
685
|
+
});
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
if (i === "UL" || i === "OL") {
|
|
689
|
+
Q(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
if (i === "TABLE") {
|
|
693
|
+
ce(r, t, n);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (i === "ASIDE") {
|
|
697
|
+
le(r, t, n);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
t.push({
|
|
701
|
+
id: n("paragraph"),
|
|
702
|
+
type: "paragraph",
|
|
703
|
+
data: { text: r.innerHTML }
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
function Q(e, t, n, r, i) {
|
|
707
|
+
let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
|
|
708
|
+
for (let [e, a] of s.entries()) {
|
|
709
|
+
let s = a.cloneNode(!0), c = [];
|
|
710
|
+
for (let e of Array.from(s.querySelectorAll("ul, ol"))) c.push(e.cloneNode(!0)), e.remove();
|
|
711
|
+
let l = s.innerHTML.trim(), u = a.getAttribute("aria-level"), d = u ? Math.max(0, parseInt(u, 10) - 1) : n;
|
|
712
|
+
r.push({
|
|
713
|
+
id: i("list"),
|
|
714
|
+
type: "list",
|
|
715
|
+
data: {
|
|
716
|
+
text: l,
|
|
717
|
+
style: t,
|
|
718
|
+
depth: d === 0 ? null : d,
|
|
719
|
+
checked: null,
|
|
720
|
+
start: e === 0 && o !== null ? o : null
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
for (let e of c) Q(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function ce(e, t, n) {
|
|
727
|
+
let r = n("table"), i = Array.from(e.querySelectorAll("tr")), a = [];
|
|
728
|
+
for (let e of i) {
|
|
729
|
+
let i = Array.from(e.querySelectorAll("td, th")).map((e) => ue(e, r, t, n));
|
|
730
|
+
a.push(i);
|
|
731
|
+
}
|
|
732
|
+
let o = i[0] ? Array.from(i[0].querySelectorAll("td, th")) : [], s = o.some((e) => e.tagName === "TH"), c = o.map((e) => {
|
|
733
|
+
let t = $(e, "width");
|
|
734
|
+
if (t) {
|
|
735
|
+
let e = parseInt(t, 10);
|
|
736
|
+
return isNaN(e) ? null : e;
|
|
737
|
+
}
|
|
738
|
+
return null;
|
|
739
|
+
}), l = {
|
|
740
|
+
id: r,
|
|
741
|
+
type: "table",
|
|
742
|
+
data: {
|
|
743
|
+
withHeadings: s,
|
|
744
|
+
withHeadingColumn: !1,
|
|
745
|
+
content: a,
|
|
746
|
+
...c.some((e) => e !== null) ? { colWidths: c } : {}
|
|
747
|
+
}
|
|
748
|
+
}, u = t.findIndex((e) => e.parent === r);
|
|
749
|
+
u >= 0 ? t.splice(u, 0, l) : t.push(l);
|
|
750
|
+
}
|
|
751
|
+
function le(e, t, r) {
|
|
752
|
+
let a = r("callout"), o = $(e, "background-color"), s = o && !n(o) && !i(o) ? m(o, "bg") : null, c = [];
|
|
753
|
+
for (let n of Array.from(e.childNodes)) {
|
|
754
|
+
let e = de(n, a, t, r);
|
|
755
|
+
e && c.push(e);
|
|
756
|
+
}
|
|
757
|
+
let l = t.findIndex((e) => e.parent === a), u = {
|
|
758
|
+
id: a,
|
|
759
|
+
type: "callout",
|
|
760
|
+
data: {
|
|
761
|
+
emoji: "💡",
|
|
762
|
+
backgroundColor: s
|
|
763
|
+
},
|
|
764
|
+
content: c
|
|
765
|
+
};
|
|
766
|
+
l >= 0 ? t.splice(l, 0, u) : t.push(u);
|
|
767
|
+
}
|
|
768
|
+
function ue(e, t, r, a) {
|
|
769
|
+
let o = e.innerHTML.trim();
|
|
770
|
+
if (!o) return {
|
|
771
|
+
blocks: [],
|
|
772
|
+
color: null,
|
|
773
|
+
textColor: null
|
|
774
|
+
};
|
|
775
|
+
let s = a("paragraph");
|
|
776
|
+
r.push({
|
|
777
|
+
id: s,
|
|
778
|
+
type: "paragraph",
|
|
779
|
+
parent: t,
|
|
780
|
+
data: { text: o }
|
|
781
|
+
});
|
|
782
|
+
let c = $(e, "background-color"), l = $(e, "color"), u = c && !n(c) && !i(c) ? m(c, "bg") : null;
|
|
783
|
+
return {
|
|
784
|
+
blocks: [s],
|
|
785
|
+
color: u,
|
|
786
|
+
textColor: l ? m(l, "text") : null
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function de(e, t, n, r) {
|
|
790
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
791
|
+
let i = e, a = r("paragraph");
|
|
792
|
+
return n.push({
|
|
793
|
+
id: a,
|
|
794
|
+
type: "paragraph",
|
|
795
|
+
parent: t,
|
|
796
|
+
data: { text: i.innerHTML }
|
|
797
|
+
}), a;
|
|
798
|
+
}
|
|
799
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
800
|
+
let i = e.textContent?.trim() ?? "";
|
|
801
|
+
if (!i) return null;
|
|
802
|
+
let a = r("paragraph");
|
|
803
|
+
return n.push({
|
|
804
|
+
id: a,
|
|
805
|
+
type: "paragraph",
|
|
806
|
+
parent: t,
|
|
807
|
+
data: { text: i }
|
|
808
|
+
}), a;
|
|
809
|
+
}
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
function fe(e, t) {
|
|
813
|
+
let n = $(e, t);
|
|
814
|
+
if (!n) return null;
|
|
815
|
+
let r = parseInt(n, 10);
|
|
816
|
+
return isNaN(r) ? null : r;
|
|
817
|
+
}
|
|
818
|
+
function $(e, t) {
|
|
819
|
+
let n = e.getAttribute("style");
|
|
820
|
+
if (!n) return null;
|
|
821
|
+
let r = RegExp(`(?<![\\-a-z])${t}\\s*:\\s*([^;]+)`).exec(n);
|
|
822
|
+
return r ? r[1].trim() : null;
|
|
823
|
+
}
|
|
824
|
+
//#endregion
|
|
825
|
+
export { p as a, O as i, Y as n, s as o, k as r, oe as t };
|