@bloklabs/cli 1.16.1 → 2.1.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/{block-builder-Cg5bL2dS.mjs → block-builder-DZMbuM0Z.mjs} +159 -208
- package/dist/cli.mjs +3 -4
- package/dist/{convert-gdocs-BNVlyZ1j.mjs → convert-gdocs-88U6OWzq.mjs} +3 -4
- package/dist/{convert-html-1lRolRGH.mjs → convert-html-BgTU9Qpk.mjs} +3 -4
- package/package.json +1 -1
- package/dist/block-builder-BEbdp0xc.mjs +0 -1019
- package/dist/block-builder-BV7ySSOn.mjs +0 -1269
- package/dist/block-builder-CTpURcXu.mjs +0 -1022
- package/dist/block-builder-DaGEOJ2S.mjs +0 -831
- package/dist/block-builder-Dc6PL7RK.mjs +0 -825
- package/dist/block-builder-DeebuGHy.mjs +0 -1453
- package/dist/block-builder-Dqos6hzP.mjs +0 -1067
- package/dist/block-builder-lzpU_6ZF.mjs +0 -827
- package/dist/convert-gdocs--8aPMm3f.mjs +0 -205
- package/dist/convert-gdocs-7NAwDDZ2.mjs +0 -214
- package/dist/convert-gdocs-9-fmO8W7.mjs +0 -214
- package/dist/convert-gdocs-BSQNj9_W.mjs +0 -13
- package/dist/convert-gdocs-BZ2ovDNS.mjs +0 -205
- package/dist/convert-gdocs-CB-kubaI.mjs +0 -208
- package/dist/convert-gdocs-CizVIpiR.mjs +0 -205
- package/dist/convert-gdocs-DtU-P2qd.mjs +0 -13
- package/dist/convert-gdocs-ZqRLNT9X.mjs +0 -13
- package/dist/convert-gdocs-msIm10vX.mjs +0 -214
- package/dist/convert-html-BI7SFKwK.mjs +0 -13
- package/dist/convert-html-BbJEHZTW.mjs +0 -13
- package/dist/convert-html-BcYeUJKw.mjs +0 -13
- package/dist/convert-html-BxJX_msU.mjs +0 -13
- package/dist/convert-html-CS_2LG6q.mjs +0 -13
- package/dist/convert-html-DEW3D-Ub.mjs +0 -13
- package/dist/convert-html-DGBMQXkH.mjs +0 -13
- package/dist/convert-html-DGTszKTe.mjs +0 -13
- package/dist/convert-html-Oocfb7JD.mjs +0 -13
- package/dist/convert-html-RCkTt7d_.mjs +0 -13
|
@@ -1,1022 +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/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")), te = /* @__PURE__ */ new Set([
|
|
316
|
-
"IMG",
|
|
317
|
-
"IFRAME",
|
|
318
|
-
"VIDEO",
|
|
319
|
-
"AUDIO",
|
|
320
|
-
"INPUT",
|
|
321
|
-
"SVG",
|
|
322
|
-
"CANVAS",
|
|
323
|
-
"OBJECT",
|
|
324
|
-
"EMBED"
|
|
325
|
-
]), ne = /* @__PURE__ */ new Set([
|
|
326
|
-
"U",
|
|
327
|
-
"S",
|
|
328
|
-
"DEL",
|
|
329
|
-
"INS"
|
|
330
|
-
]), re = /* @__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
|
-
]), ie = /* @__PURE__ */ new Set([
|
|
340
|
-
"",
|
|
341
|
-
"none",
|
|
342
|
-
"transparent",
|
|
343
|
-
"initial",
|
|
344
|
-
"unset"
|
|
345
|
-
]), g = (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
|
-
}, _ = (e) => e.attributes.some((e) => e.name.toLowerCase() === "id"), ae = (e) => ne.has(e.tagName) ? !0 : e.styleDeclarations.some((e) => re.has(e.property.toLowerCase()) && !ie.has(e.value.trim().toLowerCase())), v = (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 || !ae(e);
|
|
352
|
-
}, y = (e, t) => !h.has(e.tagName) || _(e) || _(t) ? !1 : g(e) === g(t), b = (e, t) => {
|
|
353
|
-
if (!h.has(e.tagName) || _(e)) return !1;
|
|
354
|
-
let n = g(e);
|
|
355
|
-
return t.some((e) => g(e) === n);
|
|
356
|
-
}, x = (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) => te.has(e.tagName.toUpperCase()))
|
|
373
|
-
};
|
|
374
|
-
}, S = (e, t) => {
|
|
375
|
-
let n = e.parentElement;
|
|
376
|
-
return n === null || n === t ? [] : [x(n), ...S(n, t)];
|
|
377
|
-
}, oe = (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
|
-
}, se = (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 = x(t);
|
|
387
|
-
return v(r) || b(r, S(t, e));
|
|
388
|
-
});
|
|
389
|
-
r.forEach(oe);
|
|
390
|
-
let i = (e, t) => {
|
|
391
|
-
let n = e.nextSibling;
|
|
392
|
-
if (n === null || n.nodeType !== Node.ELEMENT_NODE || !y(t, x(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, x(e))).some(Boolean);
|
|
397
|
-
return r.length > 0 || a;
|
|
398
|
-
}, ce = (e) => {
|
|
399
|
-
let t = (n) => n === 0 || !se(e) ? !1 : (t(n - 1), !0), n = t(10);
|
|
400
|
-
return n && e.normalize?.(), n;
|
|
401
|
-
}, le = "data-blok-columns-candidate", ue = /(<br\s*\/?>)/i, de = /^<br\s*\/?>$/i;
|
|
402
|
-
function C(e) {
|
|
403
|
-
let t = e.split(ue), n = t.reduce((e, t, n) => de.test(t) || t.trim() === "" ? e : n, -1);
|
|
404
|
-
return t.slice(0, n + 1).join("").trimEnd();
|
|
405
|
-
}
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region src/components/utils/spacer-paragraph.ts
|
|
408
|
-
function w(e, t = {}) {
|
|
409
|
-
let { lineBreaksAreContent: n = !0 } = t, r = Array.from(e.children);
|
|
410
|
-
return !(n ? r.length > 0 : r.some((e) => e.tagName !== "BR")) && (e.textContent ?? "").replace(/\s/g, "") === "";
|
|
411
|
-
}
|
|
412
|
-
//#endregion
|
|
413
|
-
//#region src/tools/list/paste-handler.ts
|
|
414
|
-
var fe = /* @__PURE__ */ new Set(/* @__PURE__ */ "decimal.decimal-leading-zero.lower-roman.upper-roman.lower-greek.lower-latin.upper-latin.lower-alpha.upper-alpha.arabic-indic.armenian.bengali.cambodian.cjk-decimal.devanagari.georgian.gujarati.gurmukhi.hebrew.kannada.khmer.lao.malayalam.mongolian.myanmar.oriya.persian.telugu.thai.tibetan".split(".")), pe = /* @__PURE__ */ new Set([
|
|
415
|
-
"disc",
|
|
416
|
-
"circle",
|
|
417
|
-
"square",
|
|
418
|
-
"none"
|
|
419
|
-
]), me = (e) => {
|
|
420
|
-
let t = e.getAttribute("data-list-style");
|
|
421
|
-
if (t === "ordered") return "ordered";
|
|
422
|
-
if (t === "unordered") return "unordered";
|
|
423
|
-
let n = e.getAttribute("style");
|
|
424
|
-
if (!n) return null;
|
|
425
|
-
let r = n.match(/list-style-type\s*:\s*([^;]+)/);
|
|
426
|
-
if (!r) return null;
|
|
427
|
-
let i = r[1].trim().toLowerCase();
|
|
428
|
-
return fe.has(i) ? "ordered" : pe.has(i) ? "unordered" : null;
|
|
429
|
-
}, T = (e) => {
|
|
430
|
-
if (e instanceof HTMLInputElement && e.type === "checkbox") return e;
|
|
431
|
-
let t = e.querySelector("input[type=\"checkbox\"]");
|
|
432
|
-
return t instanceof HTMLInputElement ? t : null;
|
|
433
|
-
}, he = (e, t) => {
|
|
434
|
-
let n = e.parentElement, r = T(e) !== null;
|
|
435
|
-
return n?.tagName === "OL" ? "ordered" : n?.tagName === "UL" ? r ? "checklist" : "unordered" : me(e) || (r ? "checklist" : t);
|
|
436
|
-
}, ge = (e) => {
|
|
437
|
-
let t = T(e);
|
|
438
|
-
if (t === null) return {
|
|
439
|
-
text: e.innerHTML || e.textContent || "",
|
|
440
|
-
checked: !1
|
|
441
|
-
};
|
|
442
|
-
let n = e.cloneNode(!0);
|
|
443
|
-
return n.querySelectorAll("input[type=\"checkbox\"]").forEach((e) => e.remove()), {
|
|
444
|
-
text: n.innerHTML.trim(),
|
|
445
|
-
checked: t.checked
|
|
446
|
-
};
|
|
447
|
-
}, _e = (e) => {
|
|
448
|
-
let t = e.getAttribute("aria-level");
|
|
449
|
-
if (t) return Math.max(0, parseInt(t, 10) - 1);
|
|
450
|
-
let n = E(e) - 1;
|
|
451
|
-
return n > 0 ? n : 0;
|
|
452
|
-
}, E = (e) => {
|
|
453
|
-
let t = e.parentElement;
|
|
454
|
-
return t === null ? 0 : +(t.tagName === "UL" || t.tagName === "OL") + E(t);
|
|
455
|
-
}, ve = /<br\s*\/?>/i, D = (e) => e.split(ve).map((e) => e.trim()).filter(Boolean), O = (e) => e instanceof HTMLElement && (e.tagName === "UL" || e.tagName === "OL"), k = (e) => Array.from(e.querySelectorAll("li")).map((t) => {
|
|
456
|
-
let n = he(t, e.tagName === "OL" ? "ordered" : "unordered"), r = _e(t), i = t.cloneNode(!0);
|
|
457
|
-
i.querySelectorAll("ul, ol").forEach((e) => e.remove());
|
|
458
|
-
let { text: a, checked: o } = ge(i);
|
|
459
|
-
return {
|
|
460
|
-
tool: "list",
|
|
461
|
-
data: {
|
|
462
|
-
text: C(a).trim(),
|
|
463
|
-
style: n,
|
|
464
|
-
checked: o,
|
|
465
|
-
depth: r
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
}), A = (e) => Array.from(e.querySelectorAll("tr")).filter((t) => {
|
|
469
|
-
let n = t.closest("table")?.parentElement?.closest("table");
|
|
470
|
-
return n == null || !e.contains(n);
|
|
471
|
-
}), j = (e) => Array.from(e.children).filter((e) => e.tagName === "TD" || e.tagName === "TH"), M = (e) => {
|
|
472
|
-
let t = e.cloneNode(!0);
|
|
473
|
-
return t.querySelectorAll("br").forEach((e) => e.replaceWith("\n")), t.textContent ?? "";
|
|
474
|
-
}, N = (e) => e instanceof HTMLElement && (e.tagName === "PRE" || e.tagName === "BLOK-CELL-CODE"), P = (e) => {
|
|
475
|
-
let t = [], n = [], r = () => {
|
|
476
|
-
D(n.join("")).forEach((e) => t.push({
|
|
477
|
-
tool: "paragraph",
|
|
478
|
-
data: { text: e }
|
|
479
|
-
})), n.length = 0;
|
|
480
|
-
};
|
|
481
|
-
for (let i of e) O(i) ? (r(), t.push(...k(i))) : i instanceof HTMLElement && (i.tagName === "P" || i.tagName === "DIV") ? (r(), n.push(i.innerHTML), r()) : N(i) ? (r(), t.push({
|
|
482
|
-
tool: "code",
|
|
483
|
-
data: { code: M(i) }
|
|
484
|
-
})) : i instanceof HTMLElement && i.tagName === "TABLE" ? (r(), A(i).flatMap(j).forEach((e) => t.push(...P(Array.from(e.childNodes))))) : n.push(i instanceof HTMLElement ? i.outerHTML : i.textContent ?? "");
|
|
485
|
-
return r(), t;
|
|
486
|
-
}, F = (e) => {
|
|
487
|
-
let t = document.createElement("div");
|
|
488
|
-
t.innerHTML = e;
|
|
489
|
-
let n = P(Array.from(t.childNodes));
|
|
490
|
-
return n.length > 0 ? n : [{
|
|
491
|
-
tool: "paragraph",
|
|
492
|
-
data: { text: "" }
|
|
493
|
-
}];
|
|
494
|
-
};
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region src/preprocess/legacy-cms-html.ts
|
|
497
|
-
function ye(e) {
|
|
498
|
-
be(e), Ce(e), Ee(e), Oe(e), ke(e), Ae(e);
|
|
499
|
-
}
|
|
500
|
-
function be(e) {
|
|
501
|
-
let t = e.ownerDocument;
|
|
502
|
-
for (let n of Array.from(e.querySelectorAll("div[style]"))) {
|
|
503
|
-
if (n.closest("table")) continue;
|
|
504
|
-
let e = Te(n);
|
|
505
|
-
if (!e || L(e)) continue;
|
|
506
|
-
let r = t.createElement("aside");
|
|
507
|
-
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), xe(r), Se(r), n.replaceWith(r);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
function xe(e) {
|
|
511
|
-
for (;;) {
|
|
512
|
-
let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
|
|
513
|
-
if (t.length === 0) break;
|
|
514
|
-
for (let e of t) e.replaceWith(...Array.from(e.childNodes));
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
function Se(e) {
|
|
518
|
-
for (let t of Array.from(e.querySelectorAll("p"))) {
|
|
519
|
-
let e = t.lastElementChild;
|
|
520
|
-
e?.tagName === "BR" && e.remove();
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
var I = 250;
|
|
524
|
-
function Ce(e) {
|
|
525
|
-
let t = e.querySelectorAll("[style*=\"background-color\"]");
|
|
526
|
-
for (let e of Array.from(t)) L(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), we(e) && e.replaceWith(...Array.from(e.childNodes)));
|
|
527
|
-
}
|
|
528
|
-
function L(e) {
|
|
529
|
-
if (!e) return !1;
|
|
530
|
-
let t = e.replace(/\s/g, "").toLowerCase();
|
|
531
|
-
if (t === "transparent") return !0;
|
|
532
|
-
let n = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
|
|
533
|
-
if (!n) return !1;
|
|
534
|
-
if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
|
|
535
|
-
let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
|
|
536
|
-
return r >= I && i >= I && a >= I;
|
|
537
|
-
}
|
|
538
|
-
function we(e) {
|
|
539
|
-
return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
|
|
540
|
-
}
|
|
541
|
-
function Te(e) {
|
|
542
|
-
if (e.style.backgroundColor) return e.style.backgroundColor;
|
|
543
|
-
let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
|
|
544
|
-
if (t) {
|
|
545
|
-
let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
|
|
546
|
-
if (e) return e[1];
|
|
547
|
-
}
|
|
548
|
-
return "";
|
|
549
|
-
}
|
|
550
|
-
function Ee(e) {
|
|
551
|
-
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
552
|
-
let e = t.querySelectorAll("p");
|
|
553
|
-
if (e.length !== 0) {
|
|
554
|
-
for (let t of Array.from(e)) De(t);
|
|
555
|
-
Ne(t);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
function De(e) {
|
|
560
|
-
if (e.innerHTML.trim() === "" || e.innerHTML.trim() === " ") {
|
|
561
|
-
e.remove();
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
let t = e.ownerDocument, n = t.createDocumentFragment();
|
|
565
|
-
n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
|
|
566
|
-
}
|
|
567
|
-
function Oe(e) {
|
|
568
|
-
for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || w(t, { lineBreaksAreContent: !1 }) && t.remove();
|
|
569
|
-
}
|
|
570
|
-
function ke(e) {
|
|
571
|
-
let t = e.ownerDocument;
|
|
572
|
-
for (let n of Array.from(e.querySelectorAll("del, strike"))) {
|
|
573
|
-
let e = t.createElement("s");
|
|
574
|
-
e.append(...Array.from(n.childNodes)), n.replaceWith(e);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
var R = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
|
|
578
|
-
function Ae(e) {
|
|
579
|
-
let t = e.ownerDocument, n = Me(e);
|
|
580
|
-
for (let e of n) {
|
|
581
|
-
let n = t.createElement("ul");
|
|
582
|
-
e[0].before(n);
|
|
583
|
-
for (let t of e) je(t, n);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
function je(e, t) {
|
|
587
|
-
let n = e.ownerDocument.createElement("li"), r = z(e);
|
|
588
|
-
r && (r.textContent = (r.textContent ?? "").replace(R, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
|
|
589
|
-
}
|
|
590
|
-
function Me(e) {
|
|
591
|
-
let t = [], n = Array.from(e.childNodes);
|
|
592
|
-
for (let e of n) {
|
|
593
|
-
if (e.nodeType !== Node.ELEMENT_NODE) continue;
|
|
594
|
-
let n = e;
|
|
595
|
-
if (!(n.tagName === "P" && R.test(n.textContent ?? ""))) continue;
|
|
596
|
-
let r = t[t.length - 1], i = n.previousElementSibling;
|
|
597
|
-
r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
|
|
598
|
-
}
|
|
599
|
-
return t;
|
|
600
|
-
}
|
|
601
|
-
function Ne(e) {
|
|
602
|
-
for (;;) {
|
|
603
|
-
let t = e.lastChild;
|
|
604
|
-
if (!t) break;
|
|
605
|
-
let n = t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR", r = t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "";
|
|
606
|
-
if (!n && !r) break;
|
|
607
|
-
t.remove();
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
function z(e) {
|
|
611
|
-
if (e.nodeType === Node.TEXT_NODE) return e;
|
|
612
|
-
for (let t of Array.from(e.childNodes)) {
|
|
613
|
-
let e = z(t);
|
|
614
|
-
if (e) return e;
|
|
615
|
-
}
|
|
616
|
-
return null;
|
|
617
|
-
}
|
|
618
|
-
//#endregion
|
|
619
|
-
//#region src/cli/commands/convert-html/sanitizer.ts
|
|
620
|
-
var Pe = {
|
|
621
|
-
B: !0,
|
|
622
|
-
STRONG: !0,
|
|
623
|
-
I: !0,
|
|
624
|
-
EM: !0,
|
|
625
|
-
A: /* @__PURE__ */ new Set(["href"]),
|
|
626
|
-
S: !0,
|
|
627
|
-
U: !0,
|
|
628
|
-
CODE: !0,
|
|
629
|
-
MARK: /* @__PURE__ */ new Set(["style"]),
|
|
630
|
-
BR: !0,
|
|
631
|
-
P: !0,
|
|
632
|
-
H1: !0,
|
|
633
|
-
H2: !0,
|
|
634
|
-
H3: !0,
|
|
635
|
-
H4: !0,
|
|
636
|
-
H5: !0,
|
|
637
|
-
H6: !0,
|
|
638
|
-
UL: !0,
|
|
639
|
-
OL: !0,
|
|
640
|
-
LI: /* @__PURE__ */ new Set(["aria-level"]),
|
|
641
|
-
TABLE: !0,
|
|
642
|
-
THEAD: !0,
|
|
643
|
-
TBODY: !0,
|
|
644
|
-
TR: !0,
|
|
645
|
-
CAPTION: !0,
|
|
646
|
-
TD: /* @__PURE__ */ new Set([
|
|
647
|
-
"style",
|
|
648
|
-
"colspan",
|
|
649
|
-
"rowspan"
|
|
650
|
-
]),
|
|
651
|
-
TH: /* @__PURE__ */ new Set([
|
|
652
|
-
"style",
|
|
653
|
-
"colspan",
|
|
654
|
-
"rowspan"
|
|
655
|
-
]),
|
|
656
|
-
BLOCKQUOTE: !0,
|
|
657
|
-
PRE: !0,
|
|
658
|
-
HR: !0,
|
|
659
|
-
ASIDE: /* @__PURE__ */ new Set(["style"]),
|
|
660
|
-
DETAILS: !0,
|
|
661
|
-
SUMMARY: !0,
|
|
662
|
-
IMG: /* @__PURE__ */ new Set(["src", "style"])
|
|
663
|
-
};
|
|
664
|
-
function Fe(e) {
|
|
665
|
-
B(e);
|
|
666
|
-
}
|
|
667
|
-
function Ie(e) {
|
|
668
|
-
let t = Array.from(e.childNodes);
|
|
669
|
-
for (let n of t) e.before(n);
|
|
670
|
-
return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
|
|
671
|
-
}
|
|
672
|
-
function Le(e, t) {
|
|
673
|
-
for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
|
|
674
|
-
}
|
|
675
|
-
function B(e) {
|
|
676
|
-
let t = Array.from(e.childNodes);
|
|
677
|
-
for (let e of t) {
|
|
678
|
-
if (e.nodeType !== e.ELEMENT_NODE) continue;
|
|
679
|
-
let n = e, r = Pe[n.tagName];
|
|
680
|
-
if (r === void 0) {
|
|
681
|
-
t.push(...Ie(n));
|
|
682
|
-
continue;
|
|
683
|
-
}
|
|
684
|
-
Le(n, r), B(n);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
//#endregion
|
|
688
|
-
//#region src/cli/commands/convert-html/id-generator.ts
|
|
689
|
-
function Re() {
|
|
690
|
-
let e = /* @__PURE__ */ new Map();
|
|
691
|
-
return (t) => {
|
|
692
|
-
let n = (e.get(t) ?? 0) + 1;
|
|
693
|
-
return e.set(t, n), `${t}-${n}`;
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
//#endregion
|
|
697
|
-
//#region src/shared/css-color.ts
|
|
698
|
-
var ze = /* @__PURE__ */ new Set(/* @__PURE__ */ "aliceblue.antiquewhite.aqua.aquamarine.azure.beige.bisque.black.blanchedalmond.blue.blueviolet.brown.burlywood.cadetblue.chartreuse.chocolate.coral.cornflowerblue.cornsilk.crimson.cyan.darkblue.darkcyan.darkgoldenrod.darkgray.darkgreen.darkgrey.darkkhaki.darkmagenta.darkolivegreen.darkorange.darkorchid.darkred.darksalmon.darkseagreen.darkslateblue.darkslategray.darkslategrey.darkturquoise.darkviolet.deeppink.deepskyblue.dimgray.dimgrey.dodgerblue.firebrick.floralwhite.forestgreen.fuchsia.gainsboro.ghostwhite.gold.goldenrod.gray.green.greenyellow.grey.honeydew.hotpink.indianred.indigo.ivory.khaki.lavender.lavenderblush.lawngreen.lemonchiffon.lightblue.lightcoral.lightcyan.lightgoldenrodyellow.lightgray.lightgreen.lightgrey.lightpink.lightsalmon.lightseagreen.lightskyblue.lightslategray.lightslategrey.lightsteelblue.lightyellow.lime.limegreen.linen.magenta.maroon.mediumaquamarine.mediumblue.mediumorchid.mediumpurple.mediumseagreen.mediumslateblue.mediumspringgreen.mediumturquoise.mediumvioletred.midnightblue.mintcream.mistyrose.moccasin.navajowhite.navy.oldlace.olive.olivedrab.orange.orangered.orchid.palegoldenrod.palegreen.paleturquoise.palevioletred.papayawhip.peachpuff.peru.pink.plum.powderblue.purple.rebeccapurple.red.rosybrown.royalblue.saddlebrown.salmon.sandybrown.seagreen.seashell.sienna.silver.skyblue.slateblue.slategray.slategrey.snow.springgreen.steelblue.tan.teal.thistle.tomato.turquoise.violet.wheat.white.whitesmoke.yellow.yellowgreen".split(".")), Be = /* @__PURE__ */ new Set(["transparent", "currentcolor"]), Ve = 256, V = "[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)", H = `${V}%?`, U = `${V}%`, W = `${V}(?:deg|grad|rad|turn)?`, G = " *, *", K = " +", q = `(?: */ *${H})?`, He = RegExp(`^rgba?\\( *${H}${G}${H}${G}${H}(?:${G}${H})? *\\)$`, "i"), Ue = RegExp(`^rgba?\\( *${H}${K}${H}${K}${H}${q} *\\)$`, "i"), We = RegExp(`^hsla?\\( *${W}${G}${U}${G}${U}(?:${G}${H})? *\\)$`, "i"), Ge = RegExp(`^hsla?\\( *${W}${K}${H}${K}${H}${q} *\\)$`, "i"), Ke = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, qe = /^var\(--[a-zA-Z0-9_-]+\)$/, Je = (e) => {
|
|
699
|
-
if (typeof e != "string" || e.length === 0 || e.length > Ve) return !1;
|
|
700
|
-
let t = e.toLowerCase();
|
|
701
|
-
return ze.has(t) || Be.has(t) || Ke.test(e) || qe.test(e) || He.test(e) || Ue.test(e) || We.test(e) || Ge.test(e);
|
|
702
|
-
}, Ye = 1e3, Xe = 65534, J = (e, t, n) => {
|
|
703
|
-
let r = Number.parseInt(e.getAttribute(t) ?? "", 10);
|
|
704
|
-
return !Number.isFinite(r) || r < 1 ? 1 : Math.min(r, n);
|
|
705
|
-
}, Ze = (e, t) => {
|
|
706
|
-
let n = Array.from(e), r = n.map(() => []), i = { hasMerges: !1 }, a = (e, t) => e[t] === void 0 ? t : a(e, t + 1), o = (e, n, i, a) => {
|
|
707
|
-
Array.from({ length: i }).forEach((i, o) => {
|
|
708
|
-
Array.from({ length: a }).forEach((i, a) => {
|
|
709
|
-
(o !== 0 || a !== 0) && (r[e + o][n + a] ??= t.covered([e, n]));
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
};
|
|
713
|
-
n.forEach((e, s) => {
|
|
714
|
-
j(e).reduce((e, c) => {
|
|
715
|
-
let l = a(r[s], e), u = J(c, "colspan", Ye), d = Math.min(J(c, "rowspan", Xe), n.length - s);
|
|
716
|
-
return r[s][l] = t.cell(c, {
|
|
717
|
-
colspan: u,
|
|
718
|
-
rowspan: d
|
|
719
|
-
}), (u > 1 || d > 1) && (i.hasMerges = !0, o(s, l, d, u)), l + u;
|
|
720
|
-
}, 0);
|
|
721
|
-
});
|
|
722
|
-
let s = i.hasMerges ? r : r.filter((e) => e.length > 0), c = s.reduce((e, t) => Math.max(e, t.length), 0);
|
|
723
|
-
return s.map((e) => Array.from({ length: c }, (n, r) => e[r] ?? t.filler()));
|
|
724
|
-
}, Y = "data-latex", Qe = /* @__PURE__ */ new Set(["color", "background-color"]), $e = {
|
|
725
|
-
br: !0,
|
|
726
|
-
strong: {},
|
|
727
|
-
b: {},
|
|
728
|
-
em: {},
|
|
729
|
-
i: {},
|
|
730
|
-
u: {},
|
|
731
|
-
s: {},
|
|
732
|
-
del: {},
|
|
733
|
-
a: {
|
|
734
|
-
href: !0,
|
|
735
|
-
target: !0,
|
|
736
|
-
rel: !0
|
|
737
|
-
},
|
|
738
|
-
code: {},
|
|
739
|
-
sup: {},
|
|
740
|
-
sub: {},
|
|
741
|
-
mark: (e) => {
|
|
742
|
-
let t = e.style, n = Array.from({ length: t.length }, (e, n) => t.item(n));
|
|
743
|
-
for (let e of n) Qe.has(e) || t.removeProperty(e);
|
|
744
|
-
return t.length > 0 ? { style: !0 } : {};
|
|
745
|
-
},
|
|
746
|
-
span: (e) => {
|
|
747
|
-
let t = e.getAttribute(Y);
|
|
748
|
-
return t !== null && (e.textContent !== t && (e.textContent = t), { [Y]: !0 });
|
|
749
|
-
}
|
|
750
|
-
}, et = [
|
|
751
|
-
"left",
|
|
752
|
-
"center",
|
|
753
|
-
"right"
|
|
754
|
-
], tt = [
|
|
755
|
-
"top",
|
|
756
|
-
"middle",
|
|
757
|
-
"bottom"
|
|
758
|
-
], nt = {
|
|
759
|
-
left: "right",
|
|
760
|
-
center: "center",
|
|
761
|
-
right: "left"
|
|
762
|
-
};
|
|
763
|
-
function rt(e, t) {
|
|
764
|
-
return t === "rtl" ? nt[e] : e;
|
|
765
|
-
}
|
|
766
|
-
function it(e, t, n = "ltr") {
|
|
767
|
-
let r = e?.trim().toLowerCase(), i = et.find((e) => e === r), a = i === void 0 ? r === "end" ? "right" : "left" : rt(i, n), o = tt.find((e) => e === t?.trim().toLowerCase()) ?? "top";
|
|
768
|
-
if (a !== "left" || o !== "top") return `${o}-${a}`;
|
|
769
|
-
}
|
|
770
|
-
({ ...$e });
|
|
771
|
-
function X(e) {
|
|
772
|
-
for (let t = e; t !== null; t = t.parentElement) {
|
|
773
|
-
let e = (/(?<![a-z-])direction\s*:\s*(rtl|ltr)\b/i.exec(t.getAttribute("style") ?? "")?.[1] ?? t.getAttribute("dir"))?.trim().toLowerCase();
|
|
774
|
-
if (e === "rtl" || e === "ltr") return e;
|
|
775
|
-
}
|
|
776
|
-
return "ltr";
|
|
777
|
-
}
|
|
778
|
-
//#endregion
|
|
779
|
-
//#region src/cli/commands/convert-html/block-builder.ts
|
|
780
|
-
function at(e) {
|
|
781
|
-
let t = Re(), n = [];
|
|
782
|
-
for (let r of Array.from(e.childNodes)) ot(r, n, t);
|
|
783
|
-
return n;
|
|
784
|
-
}
|
|
785
|
-
function ot(e, t, n) {
|
|
786
|
-
if (e.nodeType === Node.TEXT_NODE) {
|
|
787
|
-
let r = e.textContent?.trim() ?? "";
|
|
788
|
-
r && t.push({
|
|
789
|
-
id: n("paragraph"),
|
|
790
|
-
type: "paragraph",
|
|
791
|
-
data: { text: r }
|
|
792
|
-
});
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
796
|
-
let r = e, i = r.tagName;
|
|
797
|
-
if (i === "P") {
|
|
798
|
-
t.push({
|
|
799
|
-
id: n("paragraph"),
|
|
800
|
-
type: "paragraph",
|
|
801
|
-
data: { text: r.innerHTML }
|
|
802
|
-
});
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
if (/^H[1-6]$/.test(i)) {
|
|
806
|
-
let e = Number(i[1]);
|
|
807
|
-
t.push({
|
|
808
|
-
id: n("header"),
|
|
809
|
-
type: "header",
|
|
810
|
-
data: {
|
|
811
|
-
text: r.innerHTML,
|
|
812
|
-
level: e
|
|
813
|
-
}
|
|
814
|
-
});
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
if (i === "BLOCKQUOTE") {
|
|
818
|
-
t.push({
|
|
819
|
-
id: n("quote"),
|
|
820
|
-
type: "quote",
|
|
821
|
-
data: {
|
|
822
|
-
text: r.innerHTML,
|
|
823
|
-
size: "default"
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
if (i === "PRE") {
|
|
829
|
-
t.push({
|
|
830
|
-
id: n("code"),
|
|
831
|
-
type: "code",
|
|
832
|
-
data: {
|
|
833
|
-
code: r.textContent ?? "",
|
|
834
|
-
language: "plain-text"
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
if (i === "HR") {
|
|
840
|
-
t.push({
|
|
841
|
-
id: n("divider"),
|
|
842
|
-
type: "divider",
|
|
843
|
-
data: {}
|
|
844
|
-
});
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
if (i === "IMG") {
|
|
848
|
-
let e = r.getAttribute("src") ?? "", i = dt(r, "width");
|
|
849
|
-
t.push({
|
|
850
|
-
id: n("image"),
|
|
851
|
-
type: "image",
|
|
852
|
-
data: { url: e },
|
|
853
|
-
stretched: null,
|
|
854
|
-
key: null,
|
|
855
|
-
width: i
|
|
856
|
-
});
|
|
857
|
-
return;
|
|
858
|
-
}
|
|
859
|
-
if (i === "DETAILS") {
|
|
860
|
-
let e = r.querySelector("summary"), i = e ? e.innerHTML : r.innerHTML;
|
|
861
|
-
t.push({
|
|
862
|
-
id: n("toggle"),
|
|
863
|
-
type: "toggle",
|
|
864
|
-
data: { text: i }
|
|
865
|
-
});
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
if (i === "UL" || i === "OL") {
|
|
869
|
-
Z(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
if (i === "TABLE") {
|
|
873
|
-
st(r, t, n);
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
if (i === "ASIDE") {
|
|
877
|
-
ct(r, t, n);
|
|
878
|
-
return;
|
|
879
|
-
}
|
|
880
|
-
t.push({
|
|
881
|
-
id: n("paragraph"),
|
|
882
|
-
type: "paragraph",
|
|
883
|
-
data: { text: r.innerHTML }
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
function Z(e, t, n, r, i) {
|
|
887
|
-
let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
|
|
888
|
-
for (let [e, a] of s.entries()) {
|
|
889
|
-
let s = a.cloneNode(!0), c = [];
|
|
890
|
-
for (let e of Array.from(s.querySelectorAll("ul, ol"))) c.push(e.cloneNode(!0)), e.remove();
|
|
891
|
-
let l = s.innerHTML.trim(), u = a.getAttribute("aria-level"), d = u ? Math.max(0, parseInt(u, 10) - 1) : n;
|
|
892
|
-
r.push({
|
|
893
|
-
id: i("list"),
|
|
894
|
-
type: "list",
|
|
895
|
-
data: {
|
|
896
|
-
text: l,
|
|
897
|
-
style: t,
|
|
898
|
-
depth: d === 0 ? null : d,
|
|
899
|
-
checked: null,
|
|
900
|
-
start: e === 0 && o !== null ? o : null
|
|
901
|
-
}
|
|
902
|
-
});
|
|
903
|
-
for (let e of c) Z(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
function st(e, t, n) {
|
|
907
|
-
let r = Array.from(e.children).find((e) => e.tagName === "CAPTION")?.innerHTML.trim() ?? "";
|
|
908
|
-
r && t.push({
|
|
909
|
-
id: n("paragraph"),
|
|
910
|
-
type: "paragraph",
|
|
911
|
-
data: { text: r }
|
|
912
|
-
});
|
|
913
|
-
let i = n("table"), a = A(e), o = Ze(a, {
|
|
914
|
-
cell: (e, t) => ({
|
|
915
|
-
kind: "cell",
|
|
916
|
-
el: e,
|
|
917
|
-
...t
|
|
918
|
-
}),
|
|
919
|
-
covered: (e) => ({
|
|
920
|
-
kind: "covered",
|
|
921
|
-
origin: e
|
|
922
|
-
}),
|
|
923
|
-
filler: () => ({ kind: "filler" })
|
|
924
|
-
}), s = X(e), c = o.map((e) => e.map((e) => e.kind === "covered" ? {
|
|
925
|
-
blocks: [],
|
|
926
|
-
mergedInto: e.origin
|
|
927
|
-
} : e.kind === "filler" ? {
|
|
928
|
-
blocks: [],
|
|
929
|
-
color: null,
|
|
930
|
-
textColor: null
|
|
931
|
-
} : lt(e, s, i, t, n))), l = (e) => e?.tagName === "TH", u = a[0] ? j(a[0]) : [], d = a.some((e) => e.parentElement?.tagName === "THEAD") || u.length > 0 && u.every(l), f = a.length >= 2 && a.every((e) => l(j(e)[0])), p = (o[0] ?? []).map((e) => {
|
|
932
|
-
if (e.kind !== "cell" || e.colspan > 1) return null;
|
|
933
|
-
let t = parseInt($(e.el, "width") ?? "", 10);
|
|
934
|
-
return isNaN(t) ? null : t;
|
|
935
|
-
}), m = {
|
|
936
|
-
id: i,
|
|
937
|
-
type: "table",
|
|
938
|
-
data: {
|
|
939
|
-
withHeadings: d,
|
|
940
|
-
withHeadingColumn: f,
|
|
941
|
-
content: c,
|
|
942
|
-
...p.some((e) => e !== null) ? { colWidths: p } : {}
|
|
943
|
-
}
|
|
944
|
-
}, h = t.findIndex((e) => e.parent === i);
|
|
945
|
-
h >= 0 ? t.splice(h, 0, m) : t.push(m);
|
|
946
|
-
}
|
|
947
|
-
function ct(e, t, r) {
|
|
948
|
-
let a = r("callout"), o = $(e, "background-color"), s = o && !n(o) && !i(o) ? m(o, "bg") : null, c = [];
|
|
949
|
-
for (let n of Array.from(e.childNodes)) {
|
|
950
|
-
let e = ut(n, a, t, r);
|
|
951
|
-
e && c.push(e);
|
|
952
|
-
}
|
|
953
|
-
let l = t.findIndex((e) => e.parent === a), u = {
|
|
954
|
-
id: a,
|
|
955
|
-
type: "callout",
|
|
956
|
-
data: {
|
|
957
|
-
emoji: "💡",
|
|
958
|
-
backgroundColor: s
|
|
959
|
-
},
|
|
960
|
-
content: c
|
|
961
|
-
};
|
|
962
|
-
l >= 0 ? t.splice(l, 0, u) : t.push(u);
|
|
963
|
-
}
|
|
964
|
-
function lt(e, t, r, a, o) {
|
|
965
|
-
let s = e.el, c = Q($(s, "background-color")), l = Q($(s, "color")), u = c && !n(c) && !i(c) ? m(c, "bg") : null, d = it($(s, "text-align") ?? void 0, $(s, "vertical-align") ?? void 0, t), f = s.innerHTML.trim();
|
|
966
|
-
return {
|
|
967
|
-
blocks: f ? F(f).map((e) => {
|
|
968
|
-
let t = o(e.tool);
|
|
969
|
-
return a.push({
|
|
970
|
-
id: t,
|
|
971
|
-
type: e.tool,
|
|
972
|
-
parent: r,
|
|
973
|
-
data: e.data
|
|
974
|
-
}), t;
|
|
975
|
-
}) : [],
|
|
976
|
-
color: u,
|
|
977
|
-
textColor: l ? m(l, "text") : null,
|
|
978
|
-
...d === void 0 ? {} : { placement: d },
|
|
979
|
-
...e.colspan > 1 ? { colspan: e.colspan } : {},
|
|
980
|
-
...e.rowspan > 1 ? { rowspan: e.rowspan } : {}
|
|
981
|
-
};
|
|
982
|
-
}
|
|
983
|
-
function Q(e) {
|
|
984
|
-
return Je(e) ? e : null;
|
|
985
|
-
}
|
|
986
|
-
function ut(e, t, n, r) {
|
|
987
|
-
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
988
|
-
let i = e, a = r("paragraph");
|
|
989
|
-
return n.push({
|
|
990
|
-
id: a,
|
|
991
|
-
type: "paragraph",
|
|
992
|
-
parent: t,
|
|
993
|
-
data: { text: i.innerHTML }
|
|
994
|
-
}), a;
|
|
995
|
-
}
|
|
996
|
-
if (e.nodeType === Node.TEXT_NODE) {
|
|
997
|
-
let i = e.textContent?.trim() ?? "";
|
|
998
|
-
if (!i) return null;
|
|
999
|
-
let a = r("paragraph");
|
|
1000
|
-
return n.push({
|
|
1001
|
-
id: a,
|
|
1002
|
-
type: "paragraph",
|
|
1003
|
-
parent: t,
|
|
1004
|
-
data: { text: i }
|
|
1005
|
-
}), a;
|
|
1006
|
-
}
|
|
1007
|
-
return null;
|
|
1008
|
-
}
|
|
1009
|
-
function dt(e, t) {
|
|
1010
|
-
let n = $(e, t);
|
|
1011
|
-
if (!n) return null;
|
|
1012
|
-
let r = parseInt(n, 10);
|
|
1013
|
-
return isNaN(r) ? null : r;
|
|
1014
|
-
}
|
|
1015
|
-
function $(e, t) {
|
|
1016
|
-
let n = e.getAttribute("style");
|
|
1017
|
-
if (!n) return null;
|
|
1018
|
-
let r = RegExp(`(?<![\\-a-z])${t}\\s*:\\s*([^;]+)`).exec(n);
|
|
1019
|
-
return r ? r[1].trim() : null;
|
|
1020
|
-
}
|
|
1021
|
-
//#endregion
|
|
1022
|
-
export { A as a, le as c, s as d, j as i, ce as l, Fe as n, w as o, ye as r, C as s, at as t, p as u };
|