@bloklabs/cli 1.15.0 → 1.15.2

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.
@@ -0,0 +1,827 @@
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
+ ]), ee = new Set([...h].filter((e) => e !== "A")), g = /* @__PURE__ */ new Set([
316
+ "IMG",
317
+ "IFRAME",
318
+ "VIDEO",
319
+ "AUDIO",
320
+ "INPUT",
321
+ "SVG",
322
+ "CANVAS",
323
+ "OBJECT",
324
+ "EMBED"
325
+ ]), te = /* @__PURE__ */ new Set([
326
+ "U",
327
+ "S",
328
+ "DEL",
329
+ "INS"
330
+ ]), ne = /* @__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
+ ]), _ = /* @__PURE__ */ new Set([
340
+ "",
341
+ "none",
342
+ "transparent",
343
+ "initial",
344
+ "unset"
345
+ ]), v = (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
+ }, y = (e) => e.attributes.some((e) => e.name.toLowerCase() === "id"), b = (e) => te.has(e.tagName) ? !0 : e.styleDeclarations.some((e) => ne.has(e.property.toLowerCase()) && !_.has(e.value.trim().toLowerCase())), x = (e) => {
349
+ if (!ee.has(e.tagName)) return !1;
350
+ let t = e.text();
351
+ return t.trim().length > 0 || e.hasVoidContentDescendant() ? !1 : t.length === 0 || !b(e);
352
+ }, S = (e, t) => !h.has(e.tagName) || y(e) || y(t) ? !1 : v(e) === v(t), C = (e, t) => {
353
+ if (!h.has(e.tagName) || y(e)) return !1;
354
+ let n = v(e);
355
+ return t.some((e) => v(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) => g.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 x(r) || C(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 || !S(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/components/utils/spacer-paragraph.ts
404
+ function k(e, t = {}) {
405
+ let { lineBreaksAreContent: n = !0 } = t, r = Array.from(e.children);
406
+ return !(n ? r.length > 0 : r.some((e) => e.tagName !== "BR")) && (e.textContent ?? "").replace(/\s/g, "") === "";
407
+ }
408
+ //#endregion
409
+ //#region src/preprocess/legacy-cms-html.ts
410
+ function A(e) {
411
+ j(e), F(e), z(e), re(e), V(e), U(e);
412
+ }
413
+ function j(e) {
414
+ let t = e.ownerDocument;
415
+ for (let n of Array.from(e.querySelectorAll("div[style]"))) {
416
+ if (n.closest("table")) continue;
417
+ let e = R(n);
418
+ if (!e || I(e)) continue;
419
+ let r = t.createElement("aside");
420
+ r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), M(r), N(r), n.replaceWith(r);
421
+ }
422
+ }
423
+ function M(e) {
424
+ for (;;) {
425
+ let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
426
+ if (t.length === 0) break;
427
+ for (let e of t) e.replaceWith(...Array.from(e.childNodes));
428
+ }
429
+ }
430
+ function N(e) {
431
+ for (let t of Array.from(e.querySelectorAll("p"))) {
432
+ let e = t.lastElementChild;
433
+ e?.tagName === "BR" && e.remove();
434
+ }
435
+ }
436
+ var P = 250;
437
+ function F(e) {
438
+ let t = e.querySelectorAll("[style*=\"background-color\"]");
439
+ for (let e of Array.from(t)) I(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), L(e) && e.replaceWith(...Array.from(e.childNodes)));
440
+ }
441
+ function I(e) {
442
+ if (!e) return !1;
443
+ let t = e.replace(/\s/g, "").toLowerCase();
444
+ if (t === "transparent") return !0;
445
+ let n = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
446
+ if (!n) return !1;
447
+ if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
448
+ let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
449
+ return r >= P && i >= P && a >= P;
450
+ }
451
+ function L(e) {
452
+ return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
453
+ }
454
+ function R(e) {
455
+ if (e.style.backgroundColor) return e.style.backgroundColor;
456
+ let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
457
+ if (t) {
458
+ let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
459
+ if (e) return e[1];
460
+ }
461
+ return "";
462
+ }
463
+ function z(e) {
464
+ for (let t of Array.from(e.querySelectorAll("td, th"))) {
465
+ let e = t.querySelectorAll("p");
466
+ if (e.length !== 0) {
467
+ for (let t of Array.from(e)) B(t);
468
+ K(t);
469
+ }
470
+ }
471
+ }
472
+ function B(e) {
473
+ if (e.innerHTML.trim() === "" || e.innerHTML.trim() === "&nbsp;") {
474
+ e.remove();
475
+ return;
476
+ }
477
+ let t = e.ownerDocument, n = t.createDocumentFragment();
478
+ n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
479
+ }
480
+ function re(e) {
481
+ for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || k(t, { lineBreaksAreContent: !1 }) && t.remove();
482
+ }
483
+ function V(e) {
484
+ let t = e.ownerDocument;
485
+ for (let n of Array.from(e.querySelectorAll("del, strike"))) {
486
+ let e = t.createElement("s");
487
+ e.append(...Array.from(n.childNodes)), n.replaceWith(e);
488
+ }
489
+ }
490
+ var H = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
491
+ function U(e) {
492
+ let t = e.ownerDocument, n = G(e);
493
+ for (let e of n) {
494
+ let n = t.createElement("ul");
495
+ e[0].before(n);
496
+ for (let t of e) W(t, n);
497
+ }
498
+ }
499
+ function W(e, t) {
500
+ let n = e.ownerDocument.createElement("li"), r = q(e);
501
+ r && (r.textContent = (r.textContent ?? "").replace(H, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
502
+ }
503
+ function G(e) {
504
+ let t = [], n = Array.from(e.childNodes);
505
+ for (let e of n) {
506
+ if (e.nodeType !== Node.ELEMENT_NODE) continue;
507
+ let n = e;
508
+ if (!(n.tagName === "P" && H.test(n.textContent ?? ""))) continue;
509
+ let r = t[t.length - 1], i = n.previousElementSibling;
510
+ r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
511
+ }
512
+ return t;
513
+ }
514
+ function K(e) {
515
+ for (;;) {
516
+ let t = e.lastChild;
517
+ if (!t) break;
518
+ let n = t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR", r = t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "";
519
+ if (!n && !r) break;
520
+ t.remove();
521
+ }
522
+ }
523
+ function q(e) {
524
+ if (e.nodeType === Node.TEXT_NODE) return e;
525
+ for (let t of Array.from(e.childNodes)) {
526
+ let e = q(t);
527
+ if (e) return e;
528
+ }
529
+ return null;
530
+ }
531
+ //#endregion
532
+ //#region src/cli/commands/convert-html/sanitizer.ts
533
+ var J = {
534
+ B: !0,
535
+ STRONG: !0,
536
+ I: !0,
537
+ EM: !0,
538
+ A: /* @__PURE__ */ new Set(["href"]),
539
+ S: !0,
540
+ U: !0,
541
+ CODE: !0,
542
+ MARK: /* @__PURE__ */ new Set(["style"]),
543
+ BR: !0,
544
+ P: !0,
545
+ H1: !0,
546
+ H2: !0,
547
+ H3: !0,
548
+ H4: !0,
549
+ H5: !0,
550
+ H6: !0,
551
+ UL: !0,
552
+ OL: !0,
553
+ LI: /* @__PURE__ */ new Set(["aria-level"]),
554
+ TABLE: !0,
555
+ THEAD: !0,
556
+ TBODY: !0,
557
+ TR: !0,
558
+ TD: /* @__PURE__ */ new Set(["style"]),
559
+ TH: /* @__PURE__ */ new Set(["style"]),
560
+ BLOCKQUOTE: !0,
561
+ PRE: !0,
562
+ HR: !0,
563
+ ASIDE: /* @__PURE__ */ new Set(["style"]),
564
+ DETAILS: !0,
565
+ SUMMARY: !0,
566
+ IMG: /* @__PURE__ */ new Set(["src", "style"])
567
+ };
568
+ function Y(e) {
569
+ Z(e);
570
+ }
571
+ function X(e) {
572
+ let t = Array.from(e.childNodes);
573
+ for (let n of t) e.before(n);
574
+ return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
575
+ }
576
+ function ie(e, t) {
577
+ for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
578
+ }
579
+ function Z(e) {
580
+ let t = Array.from(e.childNodes);
581
+ for (let e of t) {
582
+ if (e.nodeType !== e.ELEMENT_NODE) continue;
583
+ let n = e, r = J[n.tagName];
584
+ if (r === void 0) {
585
+ t.push(...X(n));
586
+ continue;
587
+ }
588
+ ie(n, r), Z(n);
589
+ }
590
+ }
591
+ //#endregion
592
+ //#region src/cli/commands/convert-html/id-generator.ts
593
+ function ae() {
594
+ let e = /* @__PURE__ */ new Map();
595
+ return (t) => {
596
+ let n = (e.get(t) ?? 0) + 1;
597
+ return e.set(t, n), `${t}-${n}`;
598
+ };
599
+ }
600
+ //#endregion
601
+ //#region src/cli/commands/convert-html/block-builder.ts
602
+ function oe(e) {
603
+ let t = ae(), n = [];
604
+ for (let r of Array.from(e.childNodes)) se(r, n, t);
605
+ return n;
606
+ }
607
+ function se(e, t, n) {
608
+ if (e.nodeType === Node.TEXT_NODE) {
609
+ let r = e.textContent?.trim() ?? "";
610
+ r && t.push({
611
+ id: n("paragraph"),
612
+ type: "paragraph",
613
+ data: { text: r }
614
+ });
615
+ return;
616
+ }
617
+ if (e.nodeType !== Node.ELEMENT_NODE) return;
618
+ let r = e, i = r.tagName;
619
+ if (i === "P") {
620
+ t.push({
621
+ id: n("paragraph"),
622
+ type: "paragraph",
623
+ data: { text: r.innerHTML }
624
+ });
625
+ return;
626
+ }
627
+ if (/^H[1-6]$/.test(i)) {
628
+ let e = Number(i[1]);
629
+ t.push({
630
+ id: n("header"),
631
+ type: "header",
632
+ data: {
633
+ text: r.innerHTML,
634
+ level: e
635
+ }
636
+ });
637
+ return;
638
+ }
639
+ if (i === "BLOCKQUOTE") {
640
+ t.push({
641
+ id: n("quote"),
642
+ type: "quote",
643
+ data: {
644
+ text: r.innerHTML,
645
+ size: "default"
646
+ }
647
+ });
648
+ return;
649
+ }
650
+ if (i === "PRE") {
651
+ t.push({
652
+ id: n("code"),
653
+ type: "code",
654
+ data: {
655
+ code: r.textContent ?? "",
656
+ language: "plain-text"
657
+ }
658
+ });
659
+ return;
660
+ }
661
+ if (i === "HR") {
662
+ t.push({
663
+ id: n("divider"),
664
+ type: "divider",
665
+ data: {}
666
+ });
667
+ return;
668
+ }
669
+ if (i === "IMG") {
670
+ let e = r.getAttribute("src") ?? "", i = fe(r, "width");
671
+ t.push({
672
+ id: n("image"),
673
+ type: "image",
674
+ data: { url: e },
675
+ stretched: null,
676
+ key: null,
677
+ width: i
678
+ });
679
+ return;
680
+ }
681
+ if (i === "DETAILS") {
682
+ let e = r.querySelector("summary"), i = e ? e.innerHTML : r.innerHTML;
683
+ t.push({
684
+ id: n("toggle"),
685
+ type: "toggle",
686
+ data: { text: i }
687
+ });
688
+ return;
689
+ }
690
+ if (i === "UL" || i === "OL") {
691
+ Q(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
692
+ return;
693
+ }
694
+ if (i === "TABLE") {
695
+ ce(r, t, n);
696
+ return;
697
+ }
698
+ if (i === "ASIDE") {
699
+ le(r, t, n);
700
+ return;
701
+ }
702
+ t.push({
703
+ id: n("paragraph"),
704
+ type: "paragraph",
705
+ data: { text: r.innerHTML }
706
+ });
707
+ }
708
+ function Q(e, t, n, r, i) {
709
+ let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
710
+ for (let [e, a] of s.entries()) {
711
+ let s = a.cloneNode(!0), c = [];
712
+ for (let e of Array.from(s.querySelectorAll("ul, ol"))) c.push(e.cloneNode(!0)), e.remove();
713
+ let l = s.innerHTML.trim(), u = a.getAttribute("aria-level"), d = u ? Math.max(0, parseInt(u, 10) - 1) : n;
714
+ r.push({
715
+ id: i("list"),
716
+ type: "list",
717
+ data: {
718
+ text: l,
719
+ style: t,
720
+ depth: d === 0 ? null : d,
721
+ checked: null,
722
+ start: e === 0 && o !== null ? o : null
723
+ }
724
+ });
725
+ for (let e of c) Q(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
726
+ }
727
+ }
728
+ function ce(e, t, n) {
729
+ let r = n("table"), i = Array.from(e.querySelectorAll("tr")), a = [];
730
+ for (let e of i) {
731
+ let i = Array.from(e.querySelectorAll("td, th")).map((e) => ue(e, r, t, n));
732
+ a.push(i);
733
+ }
734
+ let o = i[0] ? Array.from(i[0].querySelectorAll("td, th")) : [], s = o.some((e) => e.tagName === "TH"), c = o.map((e) => {
735
+ let t = $(e, "width");
736
+ if (t) {
737
+ let e = parseInt(t, 10);
738
+ return isNaN(e) ? null : e;
739
+ }
740
+ return null;
741
+ }), l = {
742
+ id: r,
743
+ type: "table",
744
+ data: {
745
+ withHeadings: s,
746
+ withHeadingColumn: !1,
747
+ content: a,
748
+ ...c.some((e) => e !== null) ? { colWidths: c } : {}
749
+ }
750
+ }, u = t.findIndex((e) => e.parent === r);
751
+ u >= 0 ? t.splice(u, 0, l) : t.push(l);
752
+ }
753
+ function le(e, t, r) {
754
+ let a = r("callout"), o = $(e, "background-color"), s = o && !n(o) && !i(o) ? m(o, "bg") : null, c = [];
755
+ for (let n of Array.from(e.childNodes)) {
756
+ let e = de(n, a, t, r);
757
+ e && c.push(e);
758
+ }
759
+ let l = t.findIndex((e) => e.parent === a), u = {
760
+ id: a,
761
+ type: "callout",
762
+ data: {
763
+ emoji: "💡",
764
+ backgroundColor: s
765
+ },
766
+ content: c
767
+ };
768
+ l >= 0 ? t.splice(l, 0, u) : t.push(u);
769
+ }
770
+ function ue(e, t, r, a) {
771
+ let o = e.innerHTML.trim();
772
+ if (!o) return {
773
+ blocks: [],
774
+ color: null,
775
+ textColor: null
776
+ };
777
+ let s = a("paragraph");
778
+ r.push({
779
+ id: s,
780
+ type: "paragraph",
781
+ parent: t,
782
+ data: { text: o }
783
+ });
784
+ let c = $(e, "background-color"), l = $(e, "color"), u = c && !n(c) && !i(c) ? m(c, "bg") : null;
785
+ return {
786
+ blocks: [s],
787
+ color: u,
788
+ textColor: l ? m(l, "text") : null
789
+ };
790
+ }
791
+ function de(e, t, n, r) {
792
+ if (e.nodeType === Node.ELEMENT_NODE) {
793
+ let i = e, a = r("paragraph");
794
+ return n.push({
795
+ id: a,
796
+ type: "paragraph",
797
+ parent: t,
798
+ data: { text: i.innerHTML }
799
+ }), a;
800
+ }
801
+ if (e.nodeType === Node.TEXT_NODE) {
802
+ let i = e.textContent?.trim() ?? "";
803
+ if (!i) return null;
804
+ let a = r("paragraph");
805
+ return n.push({
806
+ id: a,
807
+ type: "paragraph",
808
+ parent: t,
809
+ data: { text: i }
810
+ }), a;
811
+ }
812
+ return null;
813
+ }
814
+ function fe(e, t) {
815
+ let n = $(e, t);
816
+ if (!n) return null;
817
+ let r = parseInt(n, 10);
818
+ return isNaN(r) ? null : r;
819
+ }
820
+ function $(e, t) {
821
+ let n = e.getAttribute("style");
822
+ if (!n) return null;
823
+ let r = RegExp(`(?<![\\-a-z])${t}\\s*:\\s*([^;]+)`).exec(n);
824
+ return r ? r[1].trim() : null;
825
+ }
826
+ //#endregion
827
+ export { O as a, k as i, Y as n, p as o, A as r, s, oe as t };
package/dist/cli.mjs CHANGED
@@ -41,14 +41,14 @@ var t = "# Migrating from EditorJS to Blok\n\nThis guide covers the breaking cha
41
41
  case "convert-html": {
42
42
  let e = new (await (import("jsdom"))).JSDOM("");
43
43
  globalThis.DOMParser = e.window.DOMParser, globalThis.Node = e.window.Node;
44
- let { convertHtml: t } = await import("./convert-html-DEW3D-Ub.mjs");
44
+ let { convertHtml: t } = await import("./convert-html-BI7SFKwK.mjs");
45
45
  r(t((await import("node:fs")).readFileSync(0, "utf-8")), s);
46
46
  break;
47
47
  }
48
48
  case "convert-gdocs": {
49
49
  let e = new (await (import("jsdom"))).JSDOM("");
50
50
  globalThis.DOMParser = e.window.DOMParser, globalThis.Node = e.window.Node, globalThis.document = e.window.document;
51
- let { convertGdocs: t } = await import("./convert-gdocs--8aPMm3f.mjs");
51
+ let { convertGdocs: t } = await import("./convert-gdocs-BZ2ovDNS.mjs");
52
52
  r(t((await import("node:fs")).readFileSync(0, "utf-8")), s);
53
53
  break;
54
54
  }
@@ -0,0 +1,205 @@
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./block-builder-lzpU_6ZF.mjs";
2
+ //#region src/components/utils/inert-html.ts
3
+ var s = { current: void 0 };
4
+ function c(e) {
5
+ s.current ??= document.implementation.createHTMLDocument("");
6
+ let t = s.current.createElement("div");
7
+ return t.innerHTML = e, t;
8
+ }
9
+ //#endregion
10
+ //#region src/components/modules/paste/constants.ts
11
+ var l = "data-blok-columns-candidate", u = /(<br\s*\/?>)/i, d = /^<br\s*\/?>$/i;
12
+ function f(e) {
13
+ let t = e.split(u), n = t.reduce((e, t, n) => d.test(t) || t.trim() === "" ? e : n, -1);
14
+ return t.slice(0, n + 1).join("").trimEnd();
15
+ }
16
+ //#endregion
17
+ //#region src/components/modules/paste/google-docs-preprocessor.ts
18
+ function p(t) {
19
+ let n = c(t), r = b(n);
20
+ return A(n, r), r && N(n), I(n), r && (P(n), y(n)), e(n), n.innerHTML;
21
+ }
22
+ function m(e, t) {
23
+ let n = e.parentElement;
24
+ return n === null ? null : n === t ? e : m(n, t);
25
+ }
26
+ function h(e, t, n) {
27
+ let r = e.cloneNode(!1), i = [];
28
+ for (let n of Array.from(e.childNodes)) {
29
+ if (n === t) break;
30
+ i.push(n);
31
+ }
32
+ return i.forEach((e) => r.appendChild(e)), n !== null && r.appendChild(n), r.childNodes.length > 0 ? r : null;
33
+ }
34
+ function g(e, t, n) {
35
+ let r = e.cloneNode(!1), i = Array.from(e.childNodes), a = i.findIndex((e) => e === t), o = i.slice(a + 1);
36
+ return n !== null && r.appendChild(n), o.forEach((e) => r.appendChild(e)), r.childNodes.length > 0 ? r : null;
37
+ }
38
+ function _(e, t) {
39
+ let n = (e, r, i) => {
40
+ if (e === t) return {
41
+ before: r,
42
+ after: i
43
+ };
44
+ let a = e.parentElement;
45
+ if (a === null) return {
46
+ before: r,
47
+ after: i
48
+ };
49
+ let o = h(a, e, r), s = g(a, e, i);
50
+ return n(a, o, s);
51
+ };
52
+ return n(e, null, null);
53
+ }
54
+ function v(e, t) {
55
+ let n = e.parentElement;
56
+ return n === null || n === t ? !1 : n.tagName === "TABLE" || v(n, t);
57
+ }
58
+ function y(e) {
59
+ let t = Array.from(e.querySelectorAll("img"));
60
+ for (let n of t) {
61
+ if (v(n, e)) continue;
62
+ let t = m(n, e);
63
+ if (!t) continue;
64
+ let { before: r, after: i } = _(n, t), a = document.createDocumentFragment();
65
+ r && a.appendChild(r), a.appendChild(n), i && a.appendChild(i), t.replaceWith(a);
66
+ }
67
+ }
68
+ function b(e) {
69
+ let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
70
+ if (!t) return !1;
71
+ let n = document.createDocumentFragment();
72
+ for (; t.firstChild;) n.appendChild(t.firstChild);
73
+ return t.replaceWith(n), !0;
74
+ }
75
+ function x(e, t, n) {
76
+ return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
77
+ }
78
+ function S(e) {
79
+ let t = e.replace(/\s/g, "");
80
+ return t === "rgb(0,0,0)" || t === "#000000";
81
+ }
82
+ function C(e) {
83
+ if (e.closest("a") !== null) return !0;
84
+ let t = e.querySelector("a");
85
+ return t !== null && t.textContent?.trim() === e.textContent?.trim();
86
+ }
87
+ function w(e) {
88
+ let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
89
+ if (n) {
90
+ let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
91
+ return .2126 * e + .7152 * t + .0722 * r;
92
+ }
93
+ let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
94
+ if (r) {
95
+ let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
96
+ if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
97
+ let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => {
98
+ let t = e < 0 ? e + 1 : e > 1 ? e - 1 : e;
99
+ return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
100
+ }, s = o(e + 1 / 3), c = o(e), l = o(e - 1 / 3);
101
+ return .2126 * s + .7152 * c + .0722 * l;
102
+ }
103
+ let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
104
+ if (i) {
105
+ let e = i[1], t = e.length === 3 ? [
106
+ e[0] + e[0],
107
+ e[1] + e[1],
108
+ e[2] + e[2]
109
+ ] : [
110
+ e.substring(0, 2),
111
+ e.substring(2, 4),
112
+ e.substring(4, 6)
113
+ ], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
114
+ return .2126 * n + .7152 * r + .0722 * a;
115
+ }
116
+ return -1;
117
+ }
118
+ function T(e) {
119
+ let t = w(e);
120
+ return t >= 0 && t > .75;
121
+ }
122
+ function E(e, t, n, i, a) {
123
+ if (!t && !n) return e;
124
+ let o = t && i !== void 0 ? r(i, "text") : "", s = n && a !== void 0 ? r(a, "bg") : "", c = [t ? `color: ${o}` : "", x(n, t, s)].filter(Boolean).join("; ");
125
+ return c ? `<mark style="${c};">${e}</mark>` : e;
126
+ }
127
+ var D = /* @__PURE__ */ new Set([
128
+ "H1",
129
+ "H2",
130
+ "H3",
131
+ "H4",
132
+ "H5",
133
+ "H6"
134
+ ]);
135
+ function O(e) {
136
+ let t = e.parentElement;
137
+ return t === null ? !1 : D.has(t.tagName) ? !0 : O(t);
138
+ }
139
+ function k(e, t) {
140
+ let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n) && !O(e), i = /font-style\s*:\s*italic/i.test(n), o = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(n), s = /background-color\s*:\s*([^;]+)/i.exec(n), c = o?.[1]?.trim(), l = s?.[1]?.trim(), u = !(c !== void 0 && C(e)) && (t ? c !== void 0 && !S(c) : c !== void 0 && !S(c) && !T(c)), d = l !== void 0 && !a(l);
141
+ if (!r && !i && !u && !d) return null;
142
+ let f = E(e.innerHTML, u, d, c, l), p = i ? `<i>${f}</i>` : f;
143
+ return r ? `<b>${p}</b>` : p;
144
+ }
145
+ function A(e, t) {
146
+ for (let n of Array.from(e.querySelectorAll("span[style]"))) {
147
+ let e = k(n, t);
148
+ e !== null && n.replaceWith(n.ownerDocument.createRange().createContextualFragment(e));
149
+ }
150
+ t && j(e);
151
+ }
152
+ function j(e) {
153
+ for (let t of Array.from(e.querySelectorAll("a[style]"))) {
154
+ let e = t.getAttribute("style") ?? "", n = /background-color\s*:\s*([^;]+)/i.exec(e)?.[1]?.trim(), i = n !== void 0 && n !== "transparent" && n !== "inherit", a = t;
155
+ a.style.removeProperty("color"), i && (a.innerHTML = `<mark style="background-color: ${r(n, "bg")};">${a.innerHTML}</mark>`, a.style.removeProperty("background-color"));
156
+ }
157
+ }
158
+ function M(e) {
159
+ return Array.from(e.querySelectorAll("tr")).filter((t) => t.closest("table") === e).map((e) => Array.from(e.children).filter((e) => e.tagName === "TD" || e.tagName === "TH"));
160
+ }
161
+ function N(e) {
162
+ if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
163
+ if (t.parentElement?.closest("table") !== null) continue;
164
+ let e = M(t);
165
+ e.length === 0 || e.some((e) => e.length !== 1) || (e.length === 1 || t.querySelector("img") !== null) && t.replaceWith(...e.flatMap(([e]) => Array.from(e.childNodes)));
166
+ }
167
+ }
168
+ function P(e) {
169
+ if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
170
+ if (t.parentElement?.closest("table") !== null) continue;
171
+ let e = M(t);
172
+ if (e.length === 0) continue;
173
+ let n = e[0].length;
174
+ if (!e.every((e) => e.length === n)) continue;
175
+ let r = e.length === 1 && (n === 2 || n === 3), i = e.length > 1 && n === 2 && t.querySelector("img") !== null;
176
+ (r || i) && t.setAttribute(l, "");
177
+ }
178
+ }
179
+ function F(e) {
180
+ if (t(e)) {
181
+ e.remove();
182
+ return;
183
+ }
184
+ let n = e.ownerDocument.createRange().createContextualFragment(e.innerHTML + "<br>");
185
+ e.replaceWith(n);
186
+ }
187
+ function I(e) {
188
+ for (let t of Array.from(e.querySelectorAll("td, th"))) {
189
+ let e = t.querySelectorAll("p");
190
+ e.length !== 0 && (Array.from(e).forEach(F), t.innerHTML = f(t.innerHTML));
191
+ }
192
+ }
193
+ //#endregion
194
+ //#region src/cli/commands/convert-gdocs/index.ts
195
+ function L(e) {
196
+ let t = p(e), r = new DOMParser().parseFromString(t, "text/html").body;
197
+ i(r), n(r);
198
+ let a = {
199
+ version: "1.15.2",
200
+ blocks: o(r)
201
+ };
202
+ return JSON.stringify(a);
203
+ }
204
+ //#endregion
205
+ export { L as convertGdocs };
@@ -0,0 +1,205 @@
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./block-builder-DaGEOJ2S.mjs";
2
+ //#region src/components/utils/inert-html.ts
3
+ var s = { current: void 0 };
4
+ function c(e) {
5
+ s.current ??= document.implementation.createHTMLDocument("");
6
+ let t = s.current.createElement("div");
7
+ return t.innerHTML = e, t;
8
+ }
9
+ //#endregion
10
+ //#region src/components/modules/paste/constants.ts
11
+ var l = "data-blok-columns-candidate", u = /(<br\s*\/?>)/i, d = /^<br\s*\/?>$/i;
12
+ function f(e) {
13
+ let t = e.split(u), n = t.reduce((e, t, n) => d.test(t) || t.trim() === "" ? e : n, -1);
14
+ return t.slice(0, n + 1).join("").trimEnd();
15
+ }
16
+ //#endregion
17
+ //#region src/components/modules/paste/google-docs-preprocessor.ts
18
+ function p(t) {
19
+ let n = c(t), r = b(n);
20
+ return A(n, r), r && N(n), I(n), r && (P(n), y(n)), e(n), n.innerHTML;
21
+ }
22
+ function m(e, t) {
23
+ let n = e.parentElement;
24
+ return n === null ? null : n === t ? e : m(n, t);
25
+ }
26
+ function h(e, t, n) {
27
+ let r = e.cloneNode(!1), i = [];
28
+ for (let n of Array.from(e.childNodes)) {
29
+ if (n === t) break;
30
+ i.push(n);
31
+ }
32
+ return i.forEach((e) => r.appendChild(e)), n !== null && r.appendChild(n), r.childNodes.length > 0 ? r : null;
33
+ }
34
+ function g(e, t, n) {
35
+ let r = e.cloneNode(!1), i = Array.from(e.childNodes), a = i.findIndex((e) => e === t), o = i.slice(a + 1);
36
+ return n !== null && r.appendChild(n), o.forEach((e) => r.appendChild(e)), r.childNodes.length > 0 ? r : null;
37
+ }
38
+ function _(e, t) {
39
+ let n = (e, r, i) => {
40
+ if (e === t) return {
41
+ before: r,
42
+ after: i
43
+ };
44
+ let a = e.parentElement;
45
+ if (a === null) return {
46
+ before: r,
47
+ after: i
48
+ };
49
+ let o = h(a, e, r), s = g(a, e, i);
50
+ return n(a, o, s);
51
+ };
52
+ return n(e, null, null);
53
+ }
54
+ function v(e, t) {
55
+ let n = e.parentElement;
56
+ return n === null || n === t ? !1 : n.tagName === "TABLE" || v(n, t);
57
+ }
58
+ function y(e) {
59
+ let t = Array.from(e.querySelectorAll("img"));
60
+ for (let n of t) {
61
+ if (v(n, e)) continue;
62
+ let t = m(n, e);
63
+ if (!t) continue;
64
+ let { before: r, after: i } = _(n, t), a = document.createDocumentFragment();
65
+ r && a.appendChild(r), a.appendChild(n), i && a.appendChild(i), t.replaceWith(a);
66
+ }
67
+ }
68
+ function b(e) {
69
+ let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
70
+ if (!t) return !1;
71
+ let n = document.createDocumentFragment();
72
+ for (; t.firstChild;) n.appendChild(t.firstChild);
73
+ return t.replaceWith(n), !0;
74
+ }
75
+ function x(e, t, n) {
76
+ return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
77
+ }
78
+ function S(e) {
79
+ let t = e.replace(/\s/g, "");
80
+ return t === "rgb(0,0,0)" || t === "#000000";
81
+ }
82
+ function C(e) {
83
+ if (e.closest("a") !== null) return !0;
84
+ let t = e.querySelector("a");
85
+ return t !== null && t.textContent?.trim() === e.textContent?.trim();
86
+ }
87
+ function w(e) {
88
+ let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
89
+ if (n) {
90
+ let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
91
+ return .2126 * e + .7152 * t + .0722 * r;
92
+ }
93
+ let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
94
+ if (r) {
95
+ let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
96
+ if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
97
+ let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => {
98
+ let t = e < 0 ? e + 1 : e > 1 ? e - 1 : e;
99
+ return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
100
+ }, s = o(e + 1 / 3), c = o(e), l = o(e - 1 / 3);
101
+ return .2126 * s + .7152 * c + .0722 * l;
102
+ }
103
+ let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
104
+ if (i) {
105
+ let e = i[1], t = e.length === 3 ? [
106
+ e[0] + e[0],
107
+ e[1] + e[1],
108
+ e[2] + e[2]
109
+ ] : [
110
+ e.substring(0, 2),
111
+ e.substring(2, 4),
112
+ e.substring(4, 6)
113
+ ], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
114
+ return .2126 * n + .7152 * r + .0722 * a;
115
+ }
116
+ return -1;
117
+ }
118
+ function T(e) {
119
+ let t = w(e);
120
+ return t >= 0 && t > .75;
121
+ }
122
+ function E(e, t, n, i, a) {
123
+ if (!t && !n) return e;
124
+ let o = t && i !== void 0 ? r(i, "text") : "", s = n && a !== void 0 ? r(a, "bg") : "", c = [t ? `color: ${o}` : "", x(n, t, s)].filter(Boolean).join("; ");
125
+ return c ? `<mark style="${c};">${e}</mark>` : e;
126
+ }
127
+ var D = /* @__PURE__ */ new Set([
128
+ "H1",
129
+ "H2",
130
+ "H3",
131
+ "H4",
132
+ "H5",
133
+ "H6"
134
+ ]);
135
+ function O(e) {
136
+ let t = e.parentElement;
137
+ return t === null ? !1 : D.has(t.tagName) ? !0 : O(t);
138
+ }
139
+ function k(e, t) {
140
+ let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n) && !O(e), i = /font-style\s*:\s*italic/i.test(n), o = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(n), s = /background-color\s*:\s*([^;]+)/i.exec(n), c = o?.[1]?.trim(), l = s?.[1]?.trim(), u = !(c !== void 0 && C(e)) && (t ? c !== void 0 && !S(c) : c !== void 0 && !S(c) && !T(c)), d = l !== void 0 && !a(l);
141
+ if (!r && !i && !u && !d) return null;
142
+ let f = E(e.innerHTML, u, d, c, l), p = i ? `<i>${f}</i>` : f;
143
+ return r ? `<b>${p}</b>` : p;
144
+ }
145
+ function A(e, t) {
146
+ for (let n of Array.from(e.querySelectorAll("span[style]"))) {
147
+ let e = k(n, t);
148
+ e !== null && n.replaceWith(n.ownerDocument.createRange().createContextualFragment(e));
149
+ }
150
+ t && j(e);
151
+ }
152
+ function j(e) {
153
+ for (let t of Array.from(e.querySelectorAll("a[style]"))) {
154
+ let e = t.getAttribute("style") ?? "", n = /background-color\s*:\s*([^;]+)/i.exec(e)?.[1]?.trim(), i = n !== void 0 && n !== "transparent" && n !== "inherit", a = t;
155
+ a.style.removeProperty("color"), i && (a.innerHTML = `<mark style="background-color: ${r(n, "bg")};">${a.innerHTML}</mark>`, a.style.removeProperty("background-color"));
156
+ }
157
+ }
158
+ function M(e) {
159
+ return Array.from(e.querySelectorAll("tr")).filter((t) => t.closest("table") === e).map((e) => Array.from(e.children).filter((e) => e.tagName === "TD" || e.tagName === "TH"));
160
+ }
161
+ function N(e) {
162
+ if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
163
+ if (t.parentElement?.closest("table") !== null) continue;
164
+ let e = M(t);
165
+ e.length === 0 || e.some((e) => e.length !== 1) || (e.length === 1 || t.querySelector("img") !== null) && t.replaceWith(...e.flatMap(([e]) => Array.from(e.childNodes)));
166
+ }
167
+ }
168
+ function P(e) {
169
+ if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
170
+ if (t.parentElement?.closest("table") !== null) continue;
171
+ let e = M(t);
172
+ if (e.length === 0) continue;
173
+ let n = e[0].length;
174
+ if (!e.every((e) => e.length === n)) continue;
175
+ let r = e.length === 1 && (n === 2 || n === 3), i = e.length > 1 && n === 2 && t.querySelector("img") !== null;
176
+ (r || i) && t.setAttribute(l, "");
177
+ }
178
+ }
179
+ function F(e) {
180
+ if (t(e)) {
181
+ e.remove();
182
+ return;
183
+ }
184
+ let n = e.ownerDocument.createRange().createContextualFragment(e.innerHTML + "<br>");
185
+ e.replaceWith(n);
186
+ }
187
+ function I(e) {
188
+ for (let t of Array.from(e.querySelectorAll("td, th"))) {
189
+ let e = t.querySelectorAll("p");
190
+ e.length !== 0 && (Array.from(e).forEach(F), t.innerHTML = f(t.innerHTML));
191
+ }
192
+ }
193
+ //#endregion
194
+ //#region src/cli/commands/convert-gdocs/index.ts
195
+ function L(e) {
196
+ let t = p(e), r = new DOMParser().parseFromString(t, "text/html").body;
197
+ i(r), n(r);
198
+ let a = {
199
+ version: "1.15.1",
200
+ blocks: o(r)
201
+ };
202
+ return JSON.stringify(a);
203
+ }
204
+ //#endregion
205
+ export { L as convertGdocs };
@@ -0,0 +1,13 @@
1
+ import { a as e, n as t, r as n, t as r } from "./block-builder-lzpU_6ZF.mjs";
2
+ //#region src/cli/commands/convert-html/index.ts
3
+ function i(i) {
4
+ let a = new DOMParser().parseFromString(i, "text/html").body;
5
+ n(a), t(a), e(a);
6
+ let o = {
7
+ version: "1.15.2",
8
+ blocks: r(a)
9
+ };
10
+ return JSON.stringify(o);
11
+ }
12
+ //#endregion
13
+ export { i as convertHtml };
@@ -0,0 +1,13 @@
1
+ import { a as e, n as t, r as n, t as r } from "./block-builder-DaGEOJ2S.mjs";
2
+ //#region src/cli/commands/convert-html/index.ts
3
+ function i(i) {
4
+ let a = new DOMParser().parseFromString(i, "text/html").body;
5
+ n(a), t(a), e(a);
6
+ let o = {
7
+ version: "1.15.1",
8
+ blocks: r(a)
9
+ };
10
+ return JSON.stringify(o);
11
+ }
12
+ //#endregion
13
+ export { i as convertHtml };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloklabs/cli",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
4
4
  "description": "CLI tools for Blok — convert HTML to Blok JSON, generate migration guides",
5
5
  "bin": {
6
6
  "blok-cli": "bin/blok-cli.mjs"