@jackuait/blok-cli 0.19.2 → 0.21.0
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/cli.mjs +2 -2
- package/dist/{convert-gdocs-CE9U-ffM.mjs → convert-gdocs-BnJm2wSS.mjs} +1 -1
- package/dist/{convert-gdocs-CFjoer3R.mjs → convert-gdocs-CwqIzHDl.mjs} +1 -1
- package/dist/{convert-html-2QUTiRcG.mjs → convert-html-Bi6ervFd.mjs} +1 -1
- package/dist/{convert-html-586sEV0_.mjs → convert-html-JmnpFRtf.mjs} +1 -1
- package/package.json +1 -1
- package/dist/block-builder-B8WkPORz.mjs +0 -630
- package/dist/convert-gdocs-8oAKK7gL.mjs +0 -116
- package/dist/convert-gdocs-B1oeKXdN.mjs +0 -155
- package/dist/convert-gdocs-B54NOJz2.mjs +0 -116
- package/dist/convert-gdocs-B9s2I4A8.mjs +0 -105
- package/dist/convert-gdocs-BJoOR21I.mjs +0 -105
- package/dist/convert-gdocs-BWtnXDrx.mjs +0 -116
- package/dist/convert-gdocs-Bk86x7Am.mjs +0 -116
- package/dist/convert-gdocs-CUEZPGNw.mjs +0 -165
- package/dist/convert-gdocs-CUnEZELn.mjs +0 -116
- package/dist/convert-gdocs-CVcwrgg9.mjs +0 -116
- package/dist/convert-gdocs-Ccu4VdoO.mjs +0 -165
- package/dist/convert-gdocs-CdQEKFFh.mjs +0 -165
- package/dist/convert-gdocs-CjTkseqT.mjs +0 -165
- package/dist/convert-gdocs-ClcnLZSB.mjs +0 -116
- package/dist/convert-gdocs-D0R4oXkb.mjs +0 -116
- package/dist/convert-gdocs-D9tB9WOz.mjs +0 -165
- package/dist/convert-gdocs-DDIpSNYG.mjs +0 -165
- package/dist/convert-gdocs-DMHZJD4L.mjs +0 -116
- package/dist/convert-gdocs-DOdtHmMi.mjs +0 -165
- package/dist/convert-gdocs-DQihIQqC.mjs +0 -105
- package/dist/convert-gdocs-DX3RgpMI.mjs +0 -165
- package/dist/convert-gdocs-Dj3_VsOi.mjs +0 -165
- package/dist/convert-gdocs-DjfegUKM.mjs +0 -105
- package/dist/convert-gdocs-DoeAZEVT.mjs +0 -165
- package/dist/convert-gdocs-DqgXHZEp.mjs +0 -105
- package/dist/convert-gdocs-Dyv6RGuv.mjs +0 -116
- package/dist/convert-gdocs-K0B32Ft0.mjs +0 -165
- package/dist/convert-gdocs-KzkLEyuI.mjs +0 -105
- package/dist/convert-gdocs-MgRJyLkW.mjs +0 -105
- package/dist/convert-gdocs-W66DN100.mjs +0 -116
- package/dist/convert-gdocs-dSkuKTRp.mjs +0 -116
- package/dist/convert-gdocs-h19gVsx9.mjs +0 -116
- package/dist/convert-gdocs-vENtgLwR.mjs +0 -105
- package/dist/convert-html-AH35uNJI.mjs +0 -13
- package/dist/convert-html-B0NSZAgE.mjs +0 -13
- package/dist/convert-html-B9fkyNN-.mjs +0 -13
- package/dist/convert-html-BGrkD0K6.mjs +0 -13
- package/dist/convert-html-BNGKtzw7.mjs +0 -13
- package/dist/convert-html-BPTM0IT5.mjs +0 -13
- package/dist/convert-html-BPtM4FbY.mjs +0 -13
- package/dist/convert-html-BW0ACGvy.mjs +0 -13
- package/dist/convert-html-BdAWdexX.mjs +0 -13
- package/dist/convert-html-BfUpTbgb.mjs +0 -13
- package/dist/convert-html-C0OO15ZO.mjs +0 -13
- package/dist/convert-html-C64uLRWC.mjs +0 -13
- package/dist/convert-html-C9AP1X3W.mjs +0 -13
- package/dist/convert-html-CT48tUDe.mjs +0 -13
- package/dist/convert-html-CVWVcd7Q.mjs +0 -13
- package/dist/convert-html-CavJ5q2p.mjs +0 -13
- package/dist/convert-html-CgskoYVh.mjs +0 -13
- package/dist/convert-html-Cw2X3jAq.mjs +0 -13
- package/dist/convert-html-D9_Z0H6_.mjs +0 -13
- package/dist/convert-html-DB9P-Rse.mjs +0 -13
- package/dist/convert-html-DJ31Xfr7.mjs +0 -13
- package/dist/convert-html-DManAUWg.mjs +0 -13
- package/dist/convert-html-DPcdNESm.mjs +0 -13
- package/dist/convert-html-DWcDlr_4.mjs +0 -13
- package/dist/convert-html-D_BpXDxn.mjs +0 -13
- package/dist/convert-html-DeeR-tPb.mjs +0 -13
- package/dist/convert-html-DlYMRs1S.mjs +0 -13
- package/dist/convert-html-DvUpbKJ9.mjs +0 -13
- package/dist/convert-html-DzNIWUBh.mjs +0 -13
- package/dist/convert-html-SA7GUiea.mjs +0 -13
- package/dist/convert-html-WL8I_bbx.mjs +0 -13
- package/dist/convert-html-X6xWA34I.mjs +0 -13
- package/dist/convert-html-jjot_9K5.mjs +0 -13
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-
|
|
44
|
+
let { convertHtml: t } = await import("./convert-html-Bi6ervFd.mjs");
|
|
45
45
|
r(t((await import("node:fs")).readFileSync("/dev/stdin", "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-
|
|
51
|
+
let { convertGdocs: t } = await import("./convert-gdocs-CwqIzHDl.mjs");
|
|
52
52
|
r(t((await import("node:fs")).readFileSync("/dev/stdin", "utf-8")), s);
|
|
53
53
|
break;
|
|
54
54
|
}
|
package/package.json
CHANGED
|
@@ -1,630 +0,0 @@
|
|
|
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/color-mapping.ts
|
|
97
|
-
function n(e, t, n) {
|
|
98
|
-
let r = t / 100, i = n / 100;
|
|
99
|
-
if (r === 0) {
|
|
100
|
-
let e = Math.round(i * 255);
|
|
101
|
-
return [
|
|
102
|
-
e,
|
|
103
|
-
e,
|
|
104
|
-
e
|
|
105
|
-
];
|
|
106
|
-
}
|
|
107
|
-
let a = (e) => e < 0 ? e + 1 : e > 1 ? e - 1 : e, o = (e, t, n) => {
|
|
108
|
-
let r = a(n);
|
|
109
|
-
return r < 1 / 6 ? e + (t - e) * 6 * r : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e;
|
|
110
|
-
}, s = i < .5 ? i * (1 + r) : i + r - i * r, c = 2 * i - s, l = e / 360;
|
|
111
|
-
return [
|
|
112
|
-
Math.round(o(c, s, l + 1 / 3) * 255),
|
|
113
|
-
Math.round(o(c, s, l) * 255),
|
|
114
|
-
Math.round(o(c, s, l - 1 / 3) * 255)
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
function r(e) {
|
|
118
|
-
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
119
|
-
if (t) return [
|
|
120
|
-
parseInt(t[1], 16),
|
|
121
|
-
parseInt(t[2], 16),
|
|
122
|
-
parseInt(t[3], 16)
|
|
123
|
-
];
|
|
124
|
-
let r = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})[0-9a-f]{2}$/i.exec(e);
|
|
125
|
-
if (r) return [
|
|
126
|
-
parseInt(r[1], 16),
|
|
127
|
-
parseInt(r[2], 16),
|
|
128
|
-
parseInt(r[3], 16)
|
|
129
|
-
];
|
|
130
|
-
let i = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);
|
|
131
|
-
if (i) return [
|
|
132
|
-
parseInt(i[1] + i[1], 16),
|
|
133
|
-
parseInt(i[2] + i[2], 16),
|
|
134
|
-
parseInt(i[3] + i[3], 16)
|
|
135
|
-
];
|
|
136
|
-
let a = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]$/i.exec(e);
|
|
137
|
-
if (a) return [
|
|
138
|
-
parseInt(a[1] + a[1], 16),
|
|
139
|
-
parseInt(a[2] + a[2], 16),
|
|
140
|
-
parseInt(a[3] + a[3], 16)
|
|
141
|
-
];
|
|
142
|
-
let o = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
143
|
-
if (o) return [
|
|
144
|
-
Number(o[1]),
|
|
145
|
-
Number(o[2]),
|
|
146
|
-
Number(o[3])
|
|
147
|
-
];
|
|
148
|
-
let s = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
149
|
-
return s ? n(Number(s[1]), Number(s[2]), Number(s[3])) : null;
|
|
150
|
-
}
|
|
151
|
-
var i = .1;
|
|
152
|
-
function a(e) {
|
|
153
|
-
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;
|
|
154
|
-
if (i === a) return [
|
|
155
|
-
0,
|
|
156
|
-
0,
|
|
157
|
-
o
|
|
158
|
-
];
|
|
159
|
-
let s = i - a, c = o > .5 ? s / (2 - i - a) : s / (i + a);
|
|
160
|
-
return [
|
|
161
|
-
((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,
|
|
162
|
-
c,
|
|
163
|
-
o
|
|
164
|
-
];
|
|
165
|
-
}
|
|
166
|
-
function o(e, t) {
|
|
167
|
-
let n = e[1] < i, r = t[1] < i;
|
|
168
|
-
if (n && r) {
|
|
169
|
-
let n = Math.abs(e[2] - t[2]);
|
|
170
|
-
return n * n;
|
|
171
|
-
}
|
|
172
|
-
if (n !== r) return 1e3;
|
|
173
|
-
let a = Math.abs(e[0] - t[0]), o = Math.min(a, 360 - a) / 180, s = Math.abs(e[1] - t[1]), c = Math.abs(e[2] - t[2]);
|
|
174
|
-
return 8 * o * o + 1 * s * s + 1 * c * c;
|
|
175
|
-
}
|
|
176
|
-
function s(t, n) {
|
|
177
|
-
let i = r(t);
|
|
178
|
-
if (i === null) return t;
|
|
179
|
-
let s = a(i);
|
|
180
|
-
return e.reduce((e, t) => {
|
|
181
|
-
let i = r(t[n]);
|
|
182
|
-
if (i === null) return e;
|
|
183
|
-
let c = o(s, a(i));
|
|
184
|
-
return c < e.distance ? {
|
|
185
|
-
color: t[n],
|
|
186
|
-
distance: c
|
|
187
|
-
} : e;
|
|
188
|
-
}, {
|
|
189
|
-
color: t,
|
|
190
|
-
distance: Infinity
|
|
191
|
-
}).color;
|
|
192
|
-
}
|
|
193
|
-
function c(n, i) {
|
|
194
|
-
let s = r(n);
|
|
195
|
-
if (s === null) return null;
|
|
196
|
-
let c = a(s);
|
|
197
|
-
return [...e, ...t].reduce((e, t) => {
|
|
198
|
-
let n = r(t[i]);
|
|
199
|
-
if (n === null) return e;
|
|
200
|
-
let s = o(c, a(n));
|
|
201
|
-
return e === null || s < e.distance ? {
|
|
202
|
-
name: t.name,
|
|
203
|
-
distance: s
|
|
204
|
-
} : e;
|
|
205
|
-
}, null)?.name ?? null;
|
|
206
|
-
}
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/cli/commands/convert-html/preprocessor.ts
|
|
209
|
-
function l(e) {
|
|
210
|
-
u(e), m(e), v(e), b(e), x(e), C(e);
|
|
211
|
-
}
|
|
212
|
-
function u(e) {
|
|
213
|
-
let t = e.ownerDocument;
|
|
214
|
-
for (let n of Array.from(e.querySelectorAll("div[style]"))) {
|
|
215
|
-
if (n.closest("table")) continue;
|
|
216
|
-
let e = _(n);
|
|
217
|
-
if (!e || h(e)) continue;
|
|
218
|
-
let r = t.createElement("aside");
|
|
219
|
-
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), d(r), f(r), n.replaceWith(r);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
function d(e) {
|
|
223
|
-
for (;;) {
|
|
224
|
-
let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
|
|
225
|
-
if (t.length === 0) break;
|
|
226
|
-
for (let e of t) e.replaceWith(...Array.from(e.childNodes));
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function f(e) {
|
|
230
|
-
for (let t of Array.from(e.querySelectorAll("p"))) {
|
|
231
|
-
let e = t.lastElementChild;
|
|
232
|
-
e?.tagName === "BR" && e.remove();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
var p = 250;
|
|
236
|
-
function m(e) {
|
|
237
|
-
let t = e.querySelectorAll("[style*=\"background-color\"]");
|
|
238
|
-
for (let e of Array.from(t)) h(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), g(e) && e.replaceWith(...Array.from(e.childNodes)));
|
|
239
|
-
}
|
|
240
|
-
function h(e) {
|
|
241
|
-
if (!e) return !1;
|
|
242
|
-
let t = e.replace(/\s/g, "").toLowerCase();
|
|
243
|
-
if (t === "transparent") return !0;
|
|
244
|
-
let n = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
|
|
245
|
-
if (!n) return !1;
|
|
246
|
-
if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
|
|
247
|
-
let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
|
|
248
|
-
return r >= p && i >= p && a >= p;
|
|
249
|
-
}
|
|
250
|
-
function g(e) {
|
|
251
|
-
return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
|
|
252
|
-
}
|
|
253
|
-
function _(e) {
|
|
254
|
-
if (e.style.backgroundColor) return e.style.backgroundColor;
|
|
255
|
-
let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
|
|
256
|
-
if (t) {
|
|
257
|
-
let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
|
|
258
|
-
if (e) return e[1];
|
|
259
|
-
}
|
|
260
|
-
return "";
|
|
261
|
-
}
|
|
262
|
-
function v(e) {
|
|
263
|
-
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
264
|
-
let e = t.querySelectorAll("p");
|
|
265
|
-
if (e.length !== 0) {
|
|
266
|
-
for (let t of Array.from(e)) y(t);
|
|
267
|
-
D(t);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function y(e) {
|
|
272
|
-
if (e.innerHTML.trim() === "" || e.innerHTML.trim() === " ") {
|
|
273
|
-
e.remove();
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
let t = e.ownerDocument, n = t.createDocumentFragment();
|
|
277
|
-
n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
|
|
278
|
-
}
|
|
279
|
-
function b(e) {
|
|
280
|
-
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();
|
|
281
|
-
}
|
|
282
|
-
function x(e) {
|
|
283
|
-
let t = e.ownerDocument;
|
|
284
|
-
for (let n of Array.from(e.querySelectorAll("del, strike"))) {
|
|
285
|
-
let e = t.createElement("s");
|
|
286
|
-
e.append(...Array.from(n.childNodes)), n.replaceWith(e);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
var S = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
|
|
290
|
-
function C(e) {
|
|
291
|
-
let t = e.ownerDocument, n = T(e);
|
|
292
|
-
for (let e of n) {
|
|
293
|
-
let n = t.createElement("ul");
|
|
294
|
-
e[0].before(n);
|
|
295
|
-
for (let t of e) w(t, n);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
function w(e, t) {
|
|
299
|
-
let n = e.ownerDocument.createElement("li"), r = O(e);
|
|
300
|
-
r && (r.textContent = (r.textContent ?? "").replace(S, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
|
|
301
|
-
}
|
|
302
|
-
function T(e) {
|
|
303
|
-
let t = [], n = Array.from(e.childNodes);
|
|
304
|
-
for (let e of n) {
|
|
305
|
-
if (e.nodeType !== Node.ELEMENT_NODE) continue;
|
|
306
|
-
let n = e;
|
|
307
|
-
if (!(n.tagName === "P" && S.test(n.textContent ?? ""))) continue;
|
|
308
|
-
let r = t[t.length - 1], i = E(n);
|
|
309
|
-
r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
|
|
310
|
-
}
|
|
311
|
-
return t;
|
|
312
|
-
}
|
|
313
|
-
function E(e) {
|
|
314
|
-
let t = e.previousSibling;
|
|
315
|
-
return t && t.nodeType === Node.ELEMENT_NODE ? t : null;
|
|
316
|
-
}
|
|
317
|
-
function D(e) {
|
|
318
|
-
for (;;) {
|
|
319
|
-
let t = e.lastChild;
|
|
320
|
-
if (!t) break;
|
|
321
|
-
let n = t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR", r = t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "";
|
|
322
|
-
if (!n && !r) break;
|
|
323
|
-
t.remove();
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
function O(e) {
|
|
327
|
-
if (e.nodeType === Node.TEXT_NODE) return e;
|
|
328
|
-
for (let t of Array.from(e.childNodes)) {
|
|
329
|
-
let e = O(t);
|
|
330
|
-
if (e) return e;
|
|
331
|
-
}
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
//#endregion
|
|
335
|
-
//#region src/cli/commands/convert-html/sanitizer.ts
|
|
336
|
-
var k = {
|
|
337
|
-
B: !0,
|
|
338
|
-
STRONG: !0,
|
|
339
|
-
I: !0,
|
|
340
|
-
EM: !0,
|
|
341
|
-
A: new Set(["href"]),
|
|
342
|
-
S: !0,
|
|
343
|
-
U: !0,
|
|
344
|
-
CODE: !0,
|
|
345
|
-
MARK: new Set(["style"]),
|
|
346
|
-
BR: !0,
|
|
347
|
-
P: !0,
|
|
348
|
-
H1: !0,
|
|
349
|
-
H2: !0,
|
|
350
|
-
H3: !0,
|
|
351
|
-
H4: !0,
|
|
352
|
-
H5: !0,
|
|
353
|
-
H6: !0,
|
|
354
|
-
UL: !0,
|
|
355
|
-
OL: !0,
|
|
356
|
-
LI: new Set(["aria-level"]),
|
|
357
|
-
TABLE: !0,
|
|
358
|
-
THEAD: !0,
|
|
359
|
-
TBODY: !0,
|
|
360
|
-
TR: !0,
|
|
361
|
-
TD: new Set(["style"]),
|
|
362
|
-
TH: new Set(["style"]),
|
|
363
|
-
BLOCKQUOTE: !0,
|
|
364
|
-
PRE: !0,
|
|
365
|
-
HR: !0,
|
|
366
|
-
ASIDE: new Set(["style"]),
|
|
367
|
-
DETAILS: !0,
|
|
368
|
-
SUMMARY: !0,
|
|
369
|
-
IMG: new Set(["src", "style"])
|
|
370
|
-
};
|
|
371
|
-
function A(e) {
|
|
372
|
-
N(e);
|
|
373
|
-
}
|
|
374
|
-
function j(e) {
|
|
375
|
-
let t = Array.from(e.childNodes);
|
|
376
|
-
for (let n of t) e.before(n);
|
|
377
|
-
return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
|
|
378
|
-
}
|
|
379
|
-
function M(e, t) {
|
|
380
|
-
for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
|
|
381
|
-
}
|
|
382
|
-
function N(e) {
|
|
383
|
-
let t = Array.from(e.childNodes);
|
|
384
|
-
for (let e of t) {
|
|
385
|
-
if (e.nodeType !== e.ELEMENT_NODE) continue;
|
|
386
|
-
let n = e, r = k[n.tagName];
|
|
387
|
-
if (r === void 0) {
|
|
388
|
-
t.push(...j(n));
|
|
389
|
-
continue;
|
|
390
|
-
}
|
|
391
|
-
M(n, r), N(n);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
//#endregion
|
|
395
|
-
//#region src/cli/commands/convert-html/id-generator.ts
|
|
396
|
-
function P() {
|
|
397
|
-
let e = /* @__PURE__ */ new Map();
|
|
398
|
-
return (t) => {
|
|
399
|
-
let n = (e.get(t) ?? 0) + 1;
|
|
400
|
-
return e.set(t, n), `${t}-${n}`;
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
//#endregion
|
|
404
|
-
//#region src/cli/commands/convert-html/block-builder.ts
|
|
405
|
-
function F(e) {
|
|
406
|
-
let t = P(), n = [];
|
|
407
|
-
for (let r of Array.from(e.childNodes)) I(r, n, t);
|
|
408
|
-
return n;
|
|
409
|
-
}
|
|
410
|
-
function I(e, t, n) {
|
|
411
|
-
if (e.nodeType === Node.TEXT_NODE) {
|
|
412
|
-
let r = e.textContent?.trim() ?? "";
|
|
413
|
-
r && t.push({
|
|
414
|
-
id: n("paragraph"),
|
|
415
|
-
type: "paragraph",
|
|
416
|
-
data: { text: r }
|
|
417
|
-
});
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
421
|
-
let r = e, i = r.tagName;
|
|
422
|
-
if (i === "P") {
|
|
423
|
-
t.push({
|
|
424
|
-
id: n("paragraph"),
|
|
425
|
-
type: "paragraph",
|
|
426
|
-
data: { text: r.innerHTML }
|
|
427
|
-
});
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
if (/^H[1-6]$/.test(i)) {
|
|
431
|
-
let e = Number(i[1]);
|
|
432
|
-
t.push({
|
|
433
|
-
id: n("header"),
|
|
434
|
-
type: "header",
|
|
435
|
-
data: {
|
|
436
|
-
text: r.innerHTML,
|
|
437
|
-
level: e
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (i === "BLOCKQUOTE") {
|
|
443
|
-
t.push({
|
|
444
|
-
id: n("quote"),
|
|
445
|
-
type: "quote",
|
|
446
|
-
data: {
|
|
447
|
-
text: r.innerHTML,
|
|
448
|
-
size: "default"
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (i === "PRE") {
|
|
454
|
-
t.push({
|
|
455
|
-
id: n("code"),
|
|
456
|
-
type: "code",
|
|
457
|
-
data: {
|
|
458
|
-
code: r.textContent ?? "",
|
|
459
|
-
language: "plain-text"
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
if (i === "HR") {
|
|
465
|
-
t.push({
|
|
466
|
-
id: n("divider"),
|
|
467
|
-
type: "divider",
|
|
468
|
-
data: {}
|
|
469
|
-
});
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
if (i === "IMG") {
|
|
473
|
-
let e = r.getAttribute("src") ?? "", i = H(r, "width");
|
|
474
|
-
t.push({
|
|
475
|
-
id: n("image"),
|
|
476
|
-
type: "image",
|
|
477
|
-
data: { url: e },
|
|
478
|
-
stretched: null,
|
|
479
|
-
key: null,
|
|
480
|
-
width: i
|
|
481
|
-
});
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
if (i === "DETAILS") {
|
|
485
|
-
let e = r.querySelector("summary"), i = e ? e.innerHTML : r.innerHTML;
|
|
486
|
-
t.push({
|
|
487
|
-
id: n("toggle"),
|
|
488
|
-
type: "toggle",
|
|
489
|
-
data: { text: i }
|
|
490
|
-
});
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
if (i === "UL" || i === "OL") {
|
|
494
|
-
L(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
if (i === "TABLE") {
|
|
498
|
-
R(r, t, n);
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
if (i === "ASIDE") {
|
|
502
|
-
z(r, t, n);
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
t.push({
|
|
506
|
-
id: n("paragraph"),
|
|
507
|
-
type: "paragraph",
|
|
508
|
-
data: { text: r.innerHTML }
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
function L(e, t, n, r, i) {
|
|
512
|
-
let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
|
|
513
|
-
for (let [e, a] of s.entries()) {
|
|
514
|
-
let s = a.cloneNode(!0), c = [];
|
|
515
|
-
for (let e of Array.from(s.querySelectorAll("ul, ol"))) c.push(e.cloneNode(!0)), e.remove();
|
|
516
|
-
let l = s.innerHTML.trim(), u = a.getAttribute("aria-level"), d = u ? Math.max(0, parseInt(u, 10) - 1) : n;
|
|
517
|
-
r.push({
|
|
518
|
-
id: i("list"),
|
|
519
|
-
type: "list",
|
|
520
|
-
data: {
|
|
521
|
-
text: l,
|
|
522
|
-
style: t,
|
|
523
|
-
depth: d === 0 ? null : d,
|
|
524
|
-
checked: null,
|
|
525
|
-
start: e === 0 && o !== null ? o : null
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
for (let e of c) L(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
function R(e, t, n) {
|
|
532
|
-
let r = n("table"), i = Array.from(e.querySelectorAll("tr")), a = [];
|
|
533
|
-
for (let e of i) {
|
|
534
|
-
let i = Array.from(e.querySelectorAll("td, th")).map((e) => B(e, r, t, n));
|
|
535
|
-
a.push(i);
|
|
536
|
-
}
|
|
537
|
-
let o = i[0] ? Array.from(i[0].querySelectorAll("td, th")) : [], s = o.some((e) => e.tagName === "TH"), c = o.map((e) => {
|
|
538
|
-
let t = U(e, "width");
|
|
539
|
-
if (t) {
|
|
540
|
-
let e = parseInt(t, 10);
|
|
541
|
-
return isNaN(e) ? null : e;
|
|
542
|
-
}
|
|
543
|
-
return null;
|
|
544
|
-
}), l = {
|
|
545
|
-
id: r,
|
|
546
|
-
type: "table",
|
|
547
|
-
data: {
|
|
548
|
-
withHeadings: s,
|
|
549
|
-
withHeadingColumn: !1,
|
|
550
|
-
content: a,
|
|
551
|
-
...c.some((e) => e !== null) ? { colWidths: c } : {}
|
|
552
|
-
}
|
|
553
|
-
}, u = t.findIndex((e) => e.parent === r);
|
|
554
|
-
u >= 0 ? t.splice(u, 0, l) : t.push(l);
|
|
555
|
-
}
|
|
556
|
-
function z(e, t, n) {
|
|
557
|
-
let r = n("callout"), i = U(e, "background-color"), a = i ? c(i, "bg") : null, o = [];
|
|
558
|
-
for (let i of Array.from(e.childNodes)) {
|
|
559
|
-
let e = V(i, r, t, n);
|
|
560
|
-
e && o.push(e);
|
|
561
|
-
}
|
|
562
|
-
let s = t.findIndex((e) => e.parent === r), l = {
|
|
563
|
-
id: r,
|
|
564
|
-
type: "callout",
|
|
565
|
-
data: {
|
|
566
|
-
emoji: "💡",
|
|
567
|
-
backgroundColor: a ?? "gray"
|
|
568
|
-
},
|
|
569
|
-
content: o
|
|
570
|
-
};
|
|
571
|
-
s >= 0 ? t.splice(s, 0, l) : t.push(l);
|
|
572
|
-
}
|
|
573
|
-
function B(e, t, n, r) {
|
|
574
|
-
let i = e.innerHTML.trim();
|
|
575
|
-
if (!i) return {
|
|
576
|
-
blocks: [],
|
|
577
|
-
color: null,
|
|
578
|
-
textColor: null
|
|
579
|
-
};
|
|
580
|
-
let a = r("paragraph");
|
|
581
|
-
n.push({
|
|
582
|
-
id: a,
|
|
583
|
-
type: "paragraph",
|
|
584
|
-
parent: t,
|
|
585
|
-
data: { text: i }
|
|
586
|
-
});
|
|
587
|
-
let o = U(e, "background-color"), s = U(e, "color");
|
|
588
|
-
return {
|
|
589
|
-
blocks: [a],
|
|
590
|
-
color: o ? c(o, "bg") : null,
|
|
591
|
-
textColor: s ? c(s, "text") : null
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
function V(e, t, n, r) {
|
|
595
|
-
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
596
|
-
let i = e, a = r("paragraph");
|
|
597
|
-
return n.push({
|
|
598
|
-
id: a,
|
|
599
|
-
type: "paragraph",
|
|
600
|
-
parent: t,
|
|
601
|
-
data: { text: i.innerHTML }
|
|
602
|
-
}), a;
|
|
603
|
-
}
|
|
604
|
-
if (e.nodeType === Node.TEXT_NODE) {
|
|
605
|
-
let i = e.textContent?.trim() ?? "";
|
|
606
|
-
if (!i) return null;
|
|
607
|
-
let a = r("paragraph");
|
|
608
|
-
return n.push({
|
|
609
|
-
id: a,
|
|
610
|
-
type: "paragraph",
|
|
611
|
-
parent: t,
|
|
612
|
-
data: { text: i }
|
|
613
|
-
}), a;
|
|
614
|
-
}
|
|
615
|
-
return null;
|
|
616
|
-
}
|
|
617
|
-
function H(e, t) {
|
|
618
|
-
let n = U(e, t);
|
|
619
|
-
if (!n) return null;
|
|
620
|
-
let r = parseInt(n, 10);
|
|
621
|
-
return isNaN(r) ? null : r;
|
|
622
|
-
}
|
|
623
|
-
function U(e, t) {
|
|
624
|
-
let n = e.getAttribute("style");
|
|
625
|
-
if (!n) return null;
|
|
626
|
-
let r = RegExp(`(?<![\\-a-z])${t}\\s*:\\s*([^;]+)`).exec(n);
|
|
627
|
-
return r ? r[1].trim() : null;
|
|
628
|
-
}
|
|
629
|
-
//#endregion
|
|
630
|
-
export { s as i, A as n, l as r, F as t };
|