@bloklabs/cli 1.16.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/block-builder-BEbdp0xc.mjs +1019 -0
- package/dist/block-builder-BV7ySSOn.mjs +1269 -0
- package/dist/block-builder-CTpURcXu.mjs +1022 -0
- package/dist/block-builder-DaGEOJ2S.mjs +831 -0
- package/dist/block-builder-Dc6PL7RK.mjs +825 -0
- package/dist/block-builder-DeebuGHy.mjs +1453 -0
- package/dist/block-builder-Dqos6hzP.mjs +1067 -0
- package/dist/block-builder-lzpU_6ZF.mjs +827 -0
- package/dist/cli.mjs +2 -2
- package/dist/convert-gdocs--8aPMm3f.mjs +205 -0
- package/dist/convert-gdocs-7NAwDDZ2.mjs +214 -0
- package/dist/convert-gdocs-9-fmO8W7.mjs +214 -0
- package/dist/convert-gdocs-BNVlyZ1j.mjs +13 -0
- package/dist/convert-gdocs-BSQNj9_W.mjs +13 -0
- package/dist/convert-gdocs-BZ2ovDNS.mjs +205 -0
- package/dist/convert-gdocs-CB-kubaI.mjs +208 -0
- package/dist/convert-gdocs-CizVIpiR.mjs +205 -0
- package/dist/convert-gdocs-DtU-P2qd.mjs +13 -0
- package/dist/convert-gdocs-msIm10vX.mjs +214 -0
- package/dist/convert-html-1lRolRGH.mjs +13 -0
- package/dist/convert-html-BI7SFKwK.mjs +13 -0
- package/dist/convert-html-BbJEHZTW.mjs +13 -0
- package/dist/convert-html-BcYeUJKw.mjs +13 -0
- package/dist/convert-html-BxJX_msU.mjs +13 -0
- package/dist/convert-html-CS_2LG6q.mjs +13 -0
- package/dist/convert-html-DEW3D-Ub.mjs +13 -0
- package/dist/convert-html-DGBMQXkH.mjs +13 -0
- package/dist/convert-html-DGTszKTe.mjs +13 -0
- package/dist/convert-html-Oocfb7JD.mjs +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1269 @@
|
|
|
1
|
+
//#region src/components/shared/color-presets.ts
|
|
2
|
+
var e = [
|
|
3
|
+
{
|
|
4
|
+
name: "gray",
|
|
5
|
+
text: "#787774",
|
|
6
|
+
bg: "#f1f1ef"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: "brown",
|
|
10
|
+
text: "#9f6b53",
|
|
11
|
+
bg: "#f4eeee"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "orange",
|
|
15
|
+
text: "#d9730d",
|
|
16
|
+
bg: "#fbecdd"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "yellow",
|
|
20
|
+
text: "#cb9b00",
|
|
21
|
+
bg: "#fbf3db"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "green",
|
|
25
|
+
text: "#448361",
|
|
26
|
+
bg: "#edf3ec"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "blue",
|
|
30
|
+
text: "#337ea9",
|
|
31
|
+
bg: "#e7f3f8"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "purple",
|
|
35
|
+
text: "#9065b0",
|
|
36
|
+
bg: "#f6f3f9"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "pink",
|
|
40
|
+
text: "#c14c8a",
|
|
41
|
+
bg: "#f9f0f5"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "red",
|
|
45
|
+
text: "#d44c47",
|
|
46
|
+
bg: "#fdebec"
|
|
47
|
+
}
|
|
48
|
+
], t = [
|
|
49
|
+
{
|
|
50
|
+
name: "gray",
|
|
51
|
+
text: "#9b9b9b",
|
|
52
|
+
bg: "#2f2f2f"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "brown",
|
|
56
|
+
text: "#c59177",
|
|
57
|
+
bg: "#452a1c"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "orange",
|
|
61
|
+
text: "#dc8c47",
|
|
62
|
+
bg: "#4d2f14"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "yellow",
|
|
66
|
+
text: "#d4ab49",
|
|
67
|
+
bg: "#544012"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "green",
|
|
71
|
+
text: "#5db184",
|
|
72
|
+
bg: "#1e432f"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "blue",
|
|
76
|
+
text: "#5c9fcc",
|
|
77
|
+
bg: "#123a54"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "purple",
|
|
81
|
+
text: "#a67dca",
|
|
82
|
+
bg: "#341d49"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "pink",
|
|
86
|
+
text: "#d45e99",
|
|
87
|
+
bg: "#4b1b33"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "red",
|
|
91
|
+
text: "#dd5e5a",
|
|
92
|
+
bg: "#4e1a18"
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/components/utils/default-page-colors.ts
|
|
97
|
+
function n(e) {
|
|
98
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
99
|
+
return t === "rgb(255,255,255)" || t === "#ffffff" || t === "#fff" || t === "white";
|
|
100
|
+
}
|
|
101
|
+
function r(e) {
|
|
102
|
+
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
|
|
103
|
+
if (n) {
|
|
104
|
+
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
105
|
+
return .2126 * e + .7152 * t + .0722 * r;
|
|
106
|
+
}
|
|
107
|
+
let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
|
|
108
|
+
if (r) {
|
|
109
|
+
let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
|
|
110
|
+
if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
|
|
111
|
+
let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => e < 0 ? e + 1 : e > 1 ? e - 1 : e, s = (e) => {
|
|
112
|
+
let t = o(e);
|
|
113
|
+
return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
|
|
114
|
+
}, c = s(e + 1 / 3), l = s(e), u = s(e - 1 / 3);
|
|
115
|
+
return .2126 * c + .7152 * l + .0722 * u;
|
|
116
|
+
}
|
|
117
|
+
let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
118
|
+
if (i) {
|
|
119
|
+
let e = i[1], t = e.length === 3 ? [
|
|
120
|
+
e[0] + e[0],
|
|
121
|
+
e[1] + e[1],
|
|
122
|
+
e[2] + e[2]
|
|
123
|
+
] : [
|
|
124
|
+
e.substring(0, 2),
|
|
125
|
+
e.substring(2, 4),
|
|
126
|
+
e.substring(4, 6)
|
|
127
|
+
], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
128
|
+
return .2126 * n + .7152 * r + .0722 * a;
|
|
129
|
+
}
|
|
130
|
+
return -1;
|
|
131
|
+
}
|
|
132
|
+
function i(e) {
|
|
133
|
+
let t = r(e);
|
|
134
|
+
return t >= 0 && t < .12;
|
|
135
|
+
}
|
|
136
|
+
var a = 250;
|
|
137
|
+
function o(e) {
|
|
138
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
139
|
+
if (t === "transparent") return {
|
|
140
|
+
r: 0,
|
|
141
|
+
g: 0,
|
|
142
|
+
b: 0,
|
|
143
|
+
a: 0
|
|
144
|
+
};
|
|
145
|
+
if (t === "white") return {
|
|
146
|
+
r: 255,
|
|
147
|
+
g: 255,
|
|
148
|
+
b: 255,
|
|
149
|
+
a: 1
|
|
150
|
+
};
|
|
151
|
+
let n = /^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/.exec(t);
|
|
152
|
+
if (n) return {
|
|
153
|
+
r: parseInt(n[1], 10),
|
|
154
|
+
g: parseInt(n[2], 10),
|
|
155
|
+
b: parseInt(n[3], 10),
|
|
156
|
+
a: n[4] === void 0 ? 1 : parseFloat(n[4])
|
|
157
|
+
};
|
|
158
|
+
let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
159
|
+
if (r) {
|
|
160
|
+
let e = r[1], t = e.length === 3 ? [
|
|
161
|
+
e[0] + e[0],
|
|
162
|
+
e[1] + e[1],
|
|
163
|
+
e[2] + e[2]
|
|
164
|
+
] : [
|
|
165
|
+
e.substring(0, 2),
|
|
166
|
+
e.substring(2, 4),
|
|
167
|
+
e.substring(4, 6)
|
|
168
|
+
];
|
|
169
|
+
return {
|
|
170
|
+
r: parseInt(t[0], 16),
|
|
171
|
+
g: parseInt(t[1], 16),
|
|
172
|
+
b: parseInt(t[2], 16),
|
|
173
|
+
a: 1
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
function s(e) {
|
|
179
|
+
let t = o(e);
|
|
180
|
+
return t !== null && (t.a === 0 || t.r >= a && t.g >= a && t.b >= a) || i(e);
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/components/utils/color-mapping.ts
|
|
184
|
+
function c(e, t, n) {
|
|
185
|
+
let r = t / 100, i = n / 100;
|
|
186
|
+
if (r === 0) {
|
|
187
|
+
let e = Math.round(i * 255);
|
|
188
|
+
return [
|
|
189
|
+
e,
|
|
190
|
+
e,
|
|
191
|
+
e
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
let a = (e) => e < 0 ? e + 1 : e > 1 ? e - 1 : e, o = (e, t, n) => {
|
|
195
|
+
let r = a(n);
|
|
196
|
+
return r < 1 / 6 ? e + (t - e) * 6 * r : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e;
|
|
197
|
+
}, s = i < .5 ? i * (1 + r) : i + r - i * r, c = 2 * i - s, l = e / 360;
|
|
198
|
+
return [
|
|
199
|
+
Math.round(o(c, s, l + 1 / 3) * 255),
|
|
200
|
+
Math.round(o(c, s, l) * 255),
|
|
201
|
+
Math.round(o(c, s, l - 1 / 3) * 255)
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
function l(e) {
|
|
205
|
+
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
206
|
+
if (t) return [
|
|
207
|
+
parseInt(t[1], 16),
|
|
208
|
+
parseInt(t[2], 16),
|
|
209
|
+
parseInt(t[3], 16)
|
|
210
|
+
];
|
|
211
|
+
let n = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})[0-9a-f]{2}$/i.exec(e);
|
|
212
|
+
if (n) return [
|
|
213
|
+
parseInt(n[1], 16),
|
|
214
|
+
parseInt(n[2], 16),
|
|
215
|
+
parseInt(n[3], 16)
|
|
216
|
+
];
|
|
217
|
+
let r = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);
|
|
218
|
+
if (r) return [
|
|
219
|
+
parseInt(r[1] + r[1], 16),
|
|
220
|
+
parseInt(r[2] + r[2], 16),
|
|
221
|
+
parseInt(r[3] + r[3], 16)
|
|
222
|
+
];
|
|
223
|
+
let i = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]$/i.exec(e);
|
|
224
|
+
if (i) return [
|
|
225
|
+
parseInt(i[1] + i[1], 16),
|
|
226
|
+
parseInt(i[2] + i[2], 16),
|
|
227
|
+
parseInt(i[3] + i[3], 16)
|
|
228
|
+
];
|
|
229
|
+
let a = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
230
|
+
if (a) return [
|
|
231
|
+
Number(a[1]),
|
|
232
|
+
Number(a[2]),
|
|
233
|
+
Number(a[3])
|
|
234
|
+
];
|
|
235
|
+
let o = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
236
|
+
return o ? c(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
237
|
+
}
|
|
238
|
+
var u = .1;
|
|
239
|
+
function d(e) {
|
|
240
|
+
let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.max(t, n, r), a = Math.min(t, n, r), o = (i + a) / 2;
|
|
241
|
+
if (i === a) return [
|
|
242
|
+
0,
|
|
243
|
+
0,
|
|
244
|
+
o
|
|
245
|
+
];
|
|
246
|
+
let s = i - a, c = o > .5 ? s / (2 - i - a) : s / (i + a);
|
|
247
|
+
return [
|
|
248
|
+
((e) => e === t ? ((n - r) / s + (n < r ? 6 : 0)) / 6 : e === n ? ((r - t) / s + 2) / 6 : ((t - n) / s + 4) / 6)(i) * 360,
|
|
249
|
+
c,
|
|
250
|
+
o
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
function f(e, t) {
|
|
254
|
+
let n = e[1] < u, r = t[1] < u;
|
|
255
|
+
if (n && r) {
|
|
256
|
+
let n = Math.abs(e[2] - t[2]);
|
|
257
|
+
return n * n;
|
|
258
|
+
}
|
|
259
|
+
if (n !== r) return 1e3;
|
|
260
|
+
let i = Math.abs(e[0] - t[0]), a = Math.min(i, 360 - i) / 180, o = Math.abs(e[1] - t[1]), s = Math.abs(e[2] - t[2]);
|
|
261
|
+
return 8 * a * a + 1 * o * o + 1 * s * s;
|
|
262
|
+
}
|
|
263
|
+
function p(t, r) {
|
|
264
|
+
if (r === "bg" && (n(t) || i(t))) return t;
|
|
265
|
+
let a = l(t);
|
|
266
|
+
if (a === null) return t;
|
|
267
|
+
let o = d(a);
|
|
268
|
+
return e.reduce((e, t) => {
|
|
269
|
+
let n = l(t[r]);
|
|
270
|
+
if (n === null) return e;
|
|
271
|
+
let i = f(o, d(n));
|
|
272
|
+
return i < e.distance ? {
|
|
273
|
+
color: t[r],
|
|
274
|
+
distance: i
|
|
275
|
+
} : e;
|
|
276
|
+
}, {
|
|
277
|
+
color: t,
|
|
278
|
+
distance: Infinity
|
|
279
|
+
}).color;
|
|
280
|
+
}
|
|
281
|
+
function m(r, a) {
|
|
282
|
+
if (a === "bg" && (n(r) || i(r))) return null;
|
|
283
|
+
let o = l(r);
|
|
284
|
+
if (o === null) return null;
|
|
285
|
+
let s = d(o);
|
|
286
|
+
return [...e, ...t].reduce((e, t) => {
|
|
287
|
+
let n = l(t[a]);
|
|
288
|
+
if (n === null) return e;
|
|
289
|
+
let r = f(s, d(n));
|
|
290
|
+
return e === null || r < e.distance ? {
|
|
291
|
+
name: t.name,
|
|
292
|
+
distance: r
|
|
293
|
+
} : e;
|
|
294
|
+
}, null)?.name ?? null;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/shared/inline-normalization-policy.ts
|
|
298
|
+
var h = /* @__PURE__ */ new Set([
|
|
299
|
+
"A",
|
|
300
|
+
"B",
|
|
301
|
+
"STRONG",
|
|
302
|
+
"I",
|
|
303
|
+
"EM",
|
|
304
|
+
"U",
|
|
305
|
+
"S",
|
|
306
|
+
"DEL",
|
|
307
|
+
"INS",
|
|
308
|
+
"MARK",
|
|
309
|
+
"CODE",
|
|
310
|
+
"SUB",
|
|
311
|
+
"SUP",
|
|
312
|
+
"SMALL",
|
|
313
|
+
"SPAN",
|
|
314
|
+
"FONT"
|
|
315
|
+
]), g = new Set([...h].filter((e) => e !== "A")), _ = /* @__PURE__ */ new Set([
|
|
316
|
+
"IMG",
|
|
317
|
+
"IFRAME",
|
|
318
|
+
"VIDEO",
|
|
319
|
+
"AUDIO",
|
|
320
|
+
"INPUT",
|
|
321
|
+
"SVG",
|
|
322
|
+
"CANVAS",
|
|
323
|
+
"OBJECT",
|
|
324
|
+
"EMBED"
|
|
325
|
+
]), ee = /* @__PURE__ */ new Set([
|
|
326
|
+
"U",
|
|
327
|
+
"S",
|
|
328
|
+
"DEL",
|
|
329
|
+
"INS"
|
|
330
|
+
]), te = /* @__PURE__ */ new Set([
|
|
331
|
+
"background-color",
|
|
332
|
+
"background",
|
|
333
|
+
"text-decoration",
|
|
334
|
+
"text-decoration-line",
|
|
335
|
+
"border",
|
|
336
|
+
"border-bottom",
|
|
337
|
+
"box-shadow",
|
|
338
|
+
"outline"
|
|
339
|
+
]), ne = /* @__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"), re = (e) => ee.has(e.tagName) ? !0 : e.styleDeclarations.some((e) => te.has(e.property.toLowerCase()) && !ne.has(e.value.trim().toLowerCase())), ie = (e) => {
|
|
349
|
+
if (!g.has(e.tagName)) return !1;
|
|
350
|
+
let t = e.text();
|
|
351
|
+
return t.trim().length > 0 || e.hasVoidContentDescendant() ? !1 : t.length === 0 || !re(e);
|
|
352
|
+
}, ae = (e, t) => !h.has(e.tagName) || y(e) || y(t) ? !1 : v(e) === v(t), oe = (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
|
+
}, b = { current: void 0 };
|
|
357
|
+
function se(e) {
|
|
358
|
+
b.current ??= document.implementation.createHTMLDocument("");
|
|
359
|
+
let t = b.current.createElement("div");
|
|
360
|
+
return t.innerHTML = e, t;
|
|
361
|
+
}
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/components/utils/inline-normalization.ts
|
|
364
|
+
var x = (e) => {
|
|
365
|
+
let t = e.style, n = Array.from({ length: t.length }, (e, n) => {
|
|
366
|
+
let r = t.item(n);
|
|
367
|
+
return {
|
|
368
|
+
property: r,
|
|
369
|
+
value: t.getPropertyValue(r)
|
|
370
|
+
};
|
|
371
|
+
});
|
|
372
|
+
return {
|
|
373
|
+
tagName: e.tagName.toUpperCase(),
|
|
374
|
+
attributes: Array.from(e.attributes).map((e) => ({
|
|
375
|
+
name: e.name,
|
|
376
|
+
value: e.value
|
|
377
|
+
})),
|
|
378
|
+
styleDeclarations: n,
|
|
379
|
+
text: () => e.textContent ?? "",
|
|
380
|
+
hasVoidContentDescendant: () => Array.from(e.querySelectorAll("*")).some((e) => _.has(e.tagName.toUpperCase()))
|
|
381
|
+
};
|
|
382
|
+
}, S = (e, t) => {
|
|
383
|
+
let n = e.parentElement;
|
|
384
|
+
return n === null || n === t ? [] : [x(n), ...S(n, t)];
|
|
385
|
+
}, ce = (e) => {
|
|
386
|
+
let t = e.parentNode;
|
|
387
|
+
if (t !== null) {
|
|
388
|
+
for (; e.firstChild !== null;) t.insertBefore(e.firstChild, e);
|
|
389
|
+
t.removeChild(e);
|
|
390
|
+
}
|
|
391
|
+
}, le = (e) => {
|
|
392
|
+
let t = (t) => e.contains(t), n = (e) => t(e) && h.has(e.tagName.toUpperCase()), r = Array.from(e.querySelectorAll("*")).filter((t) => {
|
|
393
|
+
if (!n(t)) return !1;
|
|
394
|
+
let r = x(t);
|
|
395
|
+
return ie(r) || oe(r, S(t, e));
|
|
396
|
+
});
|
|
397
|
+
r.forEach(ce);
|
|
398
|
+
let i = (e, t) => {
|
|
399
|
+
let n = e.nextSibling;
|
|
400
|
+
if (n === null || n.nodeType !== Node.ELEMENT_NODE || !ae(t, x(n))) return !1;
|
|
401
|
+
let r = n;
|
|
402
|
+
for (; r.firstChild !== null;) e.appendChild(r.firstChild);
|
|
403
|
+
return r.remove(), i(e, t), !0;
|
|
404
|
+
}, a = Array.from(e.querySelectorAll("*")).filter(n).map((e) => t(e) && i(e, x(e))).some(Boolean);
|
|
405
|
+
return r.length > 0 || a;
|
|
406
|
+
}, C = (e) => {
|
|
407
|
+
let t = (n) => n === 0 || !le(e) ? !1 : (t(n - 1), !0), n = t(10);
|
|
408
|
+
return n && e.normalize?.(), n;
|
|
409
|
+
}, ue = "data-blok-columns-candidate", de = /(<br\s*\/?>)/i, fe = /^<br\s*\/?>$/i;
|
|
410
|
+
function w(e) {
|
|
411
|
+
let t = e.split(de), n = t.reduce((e, t, n) => fe.test(t) || t.trim() === "" ? e : n, -1);
|
|
412
|
+
return t.slice(0, n + 1).join("").trimEnd();
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/components/utils/spacer-paragraph.ts
|
|
416
|
+
function T(e, t = {}) {
|
|
417
|
+
let { lineBreaksAreContent: n = !0 } = t, r = Array.from(e.children);
|
|
418
|
+
return !(n ? r.length > 0 : r.some((e) => e.tagName !== "BR")) && (e.textContent ?? "").replace(/\s/g, "") === "";
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/tools/list/paste-handler.ts
|
|
422
|
+
var pe = /* @__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(".")), me = /* @__PURE__ */ new Set([
|
|
423
|
+
"disc",
|
|
424
|
+
"circle",
|
|
425
|
+
"square",
|
|
426
|
+
"none"
|
|
427
|
+
]), he = (e) => {
|
|
428
|
+
let t = e.getAttribute("data-list-style");
|
|
429
|
+
if (t === "ordered") return "ordered";
|
|
430
|
+
if (t === "unordered") return "unordered";
|
|
431
|
+
let n = e.getAttribute("style");
|
|
432
|
+
if (!n) return null;
|
|
433
|
+
let r = n.match(/list-style-type\s*:\s*([^;]+)/);
|
|
434
|
+
if (!r) return null;
|
|
435
|
+
let i = r[1].trim().toLowerCase();
|
|
436
|
+
return pe.has(i) ? "ordered" : me.has(i) ? "unordered" : null;
|
|
437
|
+
}, E = (e) => {
|
|
438
|
+
if (e instanceof HTMLInputElement && e.type === "checkbox") return e;
|
|
439
|
+
let t = e.querySelector("input[type=\"checkbox\"]");
|
|
440
|
+
return t instanceof HTMLInputElement ? t : null;
|
|
441
|
+
}, ge = (e, t) => {
|
|
442
|
+
let n = e.parentElement, r = E(e) !== null;
|
|
443
|
+
return n?.tagName === "OL" ? "ordered" : n?.tagName === "UL" ? r ? "checklist" : "unordered" : he(e) || (r ? "checklist" : t);
|
|
444
|
+
}, _e = (e) => {
|
|
445
|
+
let t = E(e);
|
|
446
|
+
if (t === null) return {
|
|
447
|
+
text: e.innerHTML || e.textContent || "",
|
|
448
|
+
checked: !1
|
|
449
|
+
};
|
|
450
|
+
let n = e.cloneNode(!0);
|
|
451
|
+
return n.querySelectorAll("input[type=\"checkbox\"]").forEach((e) => e.remove()), {
|
|
452
|
+
text: n.innerHTML.trim(),
|
|
453
|
+
checked: t.checked
|
|
454
|
+
};
|
|
455
|
+
}, ve = (e) => {
|
|
456
|
+
let t = e.getAttribute("aria-level");
|
|
457
|
+
if (t) return Math.max(0, parseInt(t, 10) - 1);
|
|
458
|
+
let n = D(e) - 1;
|
|
459
|
+
return n > 0 ? n : 0;
|
|
460
|
+
}, D = (e) => {
|
|
461
|
+
let t = e.parentElement;
|
|
462
|
+
return t === null ? 0 : +(t.tagName === "UL" || t.tagName === "OL") + D(t);
|
|
463
|
+
}, ye = /<br\s*\/?>/i, be = (e) => e.split(ye).map((e) => e.trim()).filter(Boolean), xe = (e) => e instanceof HTMLElement && (e.tagName === "UL" || e.tagName === "OL"), Se = (e) => Array.from(e.querySelectorAll("li")).map((t) => {
|
|
464
|
+
let n = ge(t, e.tagName === "OL" ? "ordered" : "unordered"), r = ve(t), i = t.cloneNode(!0);
|
|
465
|
+
i.querySelectorAll("ul, ol").forEach((e) => e.remove());
|
|
466
|
+
let { text: a, checked: o } = _e(i);
|
|
467
|
+
return {
|
|
468
|
+
tool: "list",
|
|
469
|
+
data: {
|
|
470
|
+
text: w(a).trim(),
|
|
471
|
+
style: n,
|
|
472
|
+
checked: o,
|
|
473
|
+
depth: r
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}), O = (e) => Array.from(e.querySelectorAll("tr")).filter((t) => {
|
|
477
|
+
let n = t.closest("table")?.parentElement?.closest("table");
|
|
478
|
+
return n == null || !e.contains(n);
|
|
479
|
+
}), k = (e) => Array.from(e.children).filter((e) => e.tagName === "TD" || e.tagName === "TH"), Ce = (e) => {
|
|
480
|
+
let t = e.cloneNode(!0);
|
|
481
|
+
return t.querySelectorAll("br").forEach((e) => e.replaceWith("\n")), t.textContent ?? "";
|
|
482
|
+
}, we = [
|
|
483
|
+
"h1",
|
|
484
|
+
"h2",
|
|
485
|
+
"h3",
|
|
486
|
+
"h4",
|
|
487
|
+
"h5",
|
|
488
|
+
"h6",
|
|
489
|
+
"blockquote"
|
|
490
|
+
].flatMap((e) => [`td ${e}`, `th ${e}`]).join(", "), Te = (e) => {
|
|
491
|
+
for (let t of Array.from(e.querySelectorAll(we))) {
|
|
492
|
+
let e = t.ownerDocument;
|
|
493
|
+
t.replaceWith(e.createElement("br"), ...Array.from(t.childNodes), e.createElement("br"));
|
|
494
|
+
}
|
|
495
|
+
}, Ee = (e) => e instanceof HTMLElement && (e.tagName === "PRE" || e.tagName === "BLOK-CELL-CODE"), A = (e) => {
|
|
496
|
+
let t = [], n = [], r = () => {
|
|
497
|
+
be(n.join("")).forEach((e) => t.push({
|
|
498
|
+
tool: "paragraph",
|
|
499
|
+
data: { text: e }
|
|
500
|
+
})), n.length = 0;
|
|
501
|
+
};
|
|
502
|
+
for (let i of e) xe(i) ? (r(), t.push(...Se(i))) : i instanceof HTMLElement && (i.tagName === "P" || i.tagName === "DIV") ? (r(), n.push(i.innerHTML), r()) : Ee(i) ? (r(), t.push({
|
|
503
|
+
tool: "code",
|
|
504
|
+
data: { code: Ce(i) }
|
|
505
|
+
})) : i instanceof HTMLElement && i.tagName === "TABLE" ? (r(), O(i).flatMap(k).forEach((e) => t.push(...A(Array.from(e.childNodes))))) : n.push(i instanceof HTMLElement ? i.outerHTML : i.textContent ?? "");
|
|
506
|
+
return r(), t;
|
|
507
|
+
}, De = (e) => {
|
|
508
|
+
let t = document.createElement("div");
|
|
509
|
+
t.innerHTML = e;
|
|
510
|
+
let n = A(Array.from(t.childNodes));
|
|
511
|
+
return n.length > 0 ? n : [{
|
|
512
|
+
tool: "paragraph",
|
|
513
|
+
data: { text: "" }
|
|
514
|
+
}];
|
|
515
|
+
};
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
518
|
+
function Oe(e) {
|
|
519
|
+
let t = se(e), n = Ne(t);
|
|
520
|
+
return Ve(t, n), n && Ue(t), Ke(t), n && (We(t), Me(t)), C(t), t.innerHTML;
|
|
521
|
+
}
|
|
522
|
+
function j(e, t) {
|
|
523
|
+
let n = e.parentElement;
|
|
524
|
+
return n === null ? null : n === t ? e : j(n, t);
|
|
525
|
+
}
|
|
526
|
+
function ke(e, t, n) {
|
|
527
|
+
let r = e.cloneNode(!1), i = [];
|
|
528
|
+
for (let n of Array.from(e.childNodes)) {
|
|
529
|
+
if (n === t) break;
|
|
530
|
+
i.push(n);
|
|
531
|
+
}
|
|
532
|
+
return i.forEach((e) => r.appendChild(e)), n !== null && r.appendChild(n), r.childNodes.length > 0 ? r : null;
|
|
533
|
+
}
|
|
534
|
+
function Ae(e, t, n) {
|
|
535
|
+
let r = e.cloneNode(!1), i = Array.from(e.childNodes), a = i.findIndex((e) => e === t), o = i.slice(a + 1);
|
|
536
|
+
return n !== null && r.appendChild(n), o.forEach((e) => r.appendChild(e)), r.childNodes.length > 0 ? r : null;
|
|
537
|
+
}
|
|
538
|
+
function je(e, t) {
|
|
539
|
+
let n = (e, r, i) => {
|
|
540
|
+
if (e === t) return {
|
|
541
|
+
before: r,
|
|
542
|
+
after: i
|
|
543
|
+
};
|
|
544
|
+
let a = e.parentElement;
|
|
545
|
+
if (a === null) return {
|
|
546
|
+
before: r,
|
|
547
|
+
after: i
|
|
548
|
+
};
|
|
549
|
+
let o = ke(a, e, r), s = Ae(a, e, i);
|
|
550
|
+
return n(a, o, s);
|
|
551
|
+
};
|
|
552
|
+
return n(e, null, null);
|
|
553
|
+
}
|
|
554
|
+
function M(e, t) {
|
|
555
|
+
let n = e.parentElement;
|
|
556
|
+
return n === null || n === t ? !1 : n.tagName === "TABLE" || M(n, t);
|
|
557
|
+
}
|
|
558
|
+
function Me(e) {
|
|
559
|
+
let t = Array.from(e.querySelectorAll("img"));
|
|
560
|
+
for (let n of t) {
|
|
561
|
+
if (M(n, e)) continue;
|
|
562
|
+
let t = j(n, e);
|
|
563
|
+
if (!t) continue;
|
|
564
|
+
let { before: r, after: i } = je(n, t), a = document.createDocumentFragment();
|
|
565
|
+
r && a.appendChild(r), a.appendChild(n), i && a.appendChild(i), t.replaceWith(a);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function Ne(e) {
|
|
569
|
+
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
570
|
+
if (!t) return !1;
|
|
571
|
+
let n = document.createDocumentFragment();
|
|
572
|
+
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
573
|
+
return t.replaceWith(n), !0;
|
|
574
|
+
}
|
|
575
|
+
function Pe(e, t, n) {
|
|
576
|
+
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
577
|
+
}
|
|
578
|
+
function N(e) {
|
|
579
|
+
let t = e.replace(/\s/g, "");
|
|
580
|
+
return t === "rgb(0,0,0)" || t === "#000000";
|
|
581
|
+
}
|
|
582
|
+
function P(e) {
|
|
583
|
+
if (e.closest("a") !== null) return !0;
|
|
584
|
+
let t = e.querySelector("a");
|
|
585
|
+
return t !== null && t.textContent?.trim() === e.textContent?.trim();
|
|
586
|
+
}
|
|
587
|
+
function Fe(e) {
|
|
588
|
+
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
|
|
589
|
+
if (n) {
|
|
590
|
+
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
591
|
+
return .2126 * e + .7152 * t + .0722 * r;
|
|
592
|
+
}
|
|
593
|
+
let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
|
|
594
|
+
if (r) {
|
|
595
|
+
let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
|
|
596
|
+
if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
|
|
597
|
+
let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => {
|
|
598
|
+
let t = e < 0 ? e + 1 : e > 1 ? e - 1 : e;
|
|
599
|
+
return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
|
|
600
|
+
}, s = o(e + 1 / 3), c = o(e), l = o(e - 1 / 3);
|
|
601
|
+
return .2126 * s + .7152 * c + .0722 * l;
|
|
602
|
+
}
|
|
603
|
+
let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
604
|
+
if (i) {
|
|
605
|
+
let e = i[1], t = e.length === 3 ? [
|
|
606
|
+
e[0] + e[0],
|
|
607
|
+
e[1] + e[1],
|
|
608
|
+
e[2] + e[2]
|
|
609
|
+
] : [
|
|
610
|
+
e.substring(0, 2),
|
|
611
|
+
e.substring(2, 4),
|
|
612
|
+
e.substring(4, 6)
|
|
613
|
+
], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
614
|
+
return .2126 * n + .7152 * r + .0722 * a;
|
|
615
|
+
}
|
|
616
|
+
return -1;
|
|
617
|
+
}
|
|
618
|
+
function Ie(e) {
|
|
619
|
+
let t = Fe(e);
|
|
620
|
+
return t >= 0 && t > .75;
|
|
621
|
+
}
|
|
622
|
+
function Le(e, t, n, r, i) {
|
|
623
|
+
if (!t && !n) return e;
|
|
624
|
+
let a = t && r !== void 0 ? p(r, "text") : "", o = n && i !== void 0 ? p(i, "bg") : "", s = [t ? `color: ${a}` : "", Pe(n, t, o)].filter(Boolean).join("; ");
|
|
625
|
+
return s ? `<mark style="${s};">${e}</mark>` : e;
|
|
626
|
+
}
|
|
627
|
+
var Re = /* @__PURE__ */ new Set([
|
|
628
|
+
"H1",
|
|
629
|
+
"H2",
|
|
630
|
+
"H3",
|
|
631
|
+
"H4",
|
|
632
|
+
"H5",
|
|
633
|
+
"H6"
|
|
634
|
+
]);
|
|
635
|
+
function F(e) {
|
|
636
|
+
let t = e.parentElement;
|
|
637
|
+
return t === null ? !1 : Re.has(t.tagName) ? !0 : F(t);
|
|
638
|
+
}
|
|
639
|
+
var ze = {
|
|
640
|
+
super: "sup",
|
|
641
|
+
sub: "sub"
|
|
642
|
+
};
|
|
643
|
+
function Be(e, t) {
|
|
644
|
+
let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n) && !F(e), i = /font-style\s*:\s*italic/i.test(n), a = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(n), o = /background-color\s*:\s*([^;]+)/i.exec(n), c = a?.[1]?.trim(), l = o?.[1]?.trim(), u = !(c !== void 0 && P(e)) && (t ? c !== void 0 && !N(c) : c !== void 0 && !N(c) && !Ie(c)), d = l !== void 0 && !s(l), f = t ? /text-decoration(?:-line)?\s*:\s*([^;]+)/i.exec(n)?.[1] ?? "" : "", p = t ? /vertical-align\s*:\s*([^;]+)/i.exec(n)?.[1]?.trim() ?? "" : "", m = /underline/i.test(f) && !P(e), h = /line-through/i.test(f), g = ze[p.toLowerCase()];
|
|
645
|
+
if (!r && !i && !u && !d && !m && !h && g === void 0) return null;
|
|
646
|
+
let _ = Le(e.innerHTML, u, d, c, l);
|
|
647
|
+
return [
|
|
648
|
+
r ? "b" : "",
|
|
649
|
+
i ? "i" : "",
|
|
650
|
+
m ? "u" : "",
|
|
651
|
+
h ? "s" : "",
|
|
652
|
+
g ?? ""
|
|
653
|
+
].filter(Boolean).reduceRight((e, t) => `<${t}>${e}</${t}>`, _);
|
|
654
|
+
}
|
|
655
|
+
function Ve(e, t) {
|
|
656
|
+
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
657
|
+
let e = Be(n, t);
|
|
658
|
+
e !== null && n.replaceWith(n.ownerDocument.createRange().createContextualFragment(e));
|
|
659
|
+
}
|
|
660
|
+
t && He(e);
|
|
661
|
+
}
|
|
662
|
+
function He(e) {
|
|
663
|
+
for (let t of Array.from(e.querySelectorAll("a[style]"))) {
|
|
664
|
+
let e = t.getAttribute("style") ?? "", n = /background-color\s*:\s*([^;]+)/i.exec(e)?.[1]?.trim(), r = n !== void 0 && n !== "transparent" && n !== "inherit", i = t;
|
|
665
|
+
i.style.removeProperty("color"), r && (i.innerHTML = `<mark style="background-color: ${p(n, "bg")};">${i.innerHTML}</mark>`, i.style.removeProperty("background-color"));
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function Ue(e) {
|
|
669
|
+
if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
|
|
670
|
+
if (t.parentElement?.closest("table") !== null) continue;
|
|
671
|
+
let e = O(t).map(k);
|
|
672
|
+
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)));
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
function We(e) {
|
|
676
|
+
if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
|
|
677
|
+
if (t.parentElement?.closest("table") !== null) continue;
|
|
678
|
+
let e = O(t).map(k);
|
|
679
|
+
if (e.length === 0) continue;
|
|
680
|
+
let n = e[0].length;
|
|
681
|
+
if (!e.every((e) => e.length === n)) continue;
|
|
682
|
+
let r = e.length === 1 && (n === 2 || n === 3), i = e.length > 1 && n === 2 && t.querySelector("img") !== null;
|
|
683
|
+
(r || i) && t.setAttribute(ue, "");
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function Ge(e) {
|
|
687
|
+
if (T(e)) {
|
|
688
|
+
e.remove();
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
let t = e.ownerDocument.createRange().createContextualFragment(e.innerHTML + "<br>");
|
|
692
|
+
e.replaceWith(t);
|
|
693
|
+
}
|
|
694
|
+
var I = /(?<![a-z-])text-align\s*:\s*([^;]+)/i;
|
|
695
|
+
function L(e) {
|
|
696
|
+
let t = e.getAttribute("style") ?? "";
|
|
697
|
+
if (I.test(t)) return;
|
|
698
|
+
let n = Array.from(e.querySelectorAll("p")).filter((t) => t.closest("td, th") === e && !T(t)), r = new Set(n.map((e) => I.exec(e.getAttribute("style") ?? "")?.[1]?.trim().toLowerCase())), [i] = r;
|
|
699
|
+
r.size === 1 && i !== void 0 && e.setAttribute("style", t === "" ? `text-align:${i}` : `${t};text-align:${i}`);
|
|
700
|
+
}
|
|
701
|
+
function Ke(e) {
|
|
702
|
+
let t = Array.from(e.querySelectorAll("td, th"));
|
|
703
|
+
t.forEach(L);
|
|
704
|
+
for (let e of t) {
|
|
705
|
+
let t = e.querySelectorAll("p");
|
|
706
|
+
t.length !== 0 && (Array.from(t).forEach(Ge), e.innerHTML = w(e.innerHTML));
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region src/tools/table/table-operations.ts
|
|
711
|
+
var qe = 1e3, Je = 65534, R = (e, t, n) => {
|
|
712
|
+
let r = Number.parseInt(e.getAttribute(t) ?? "", 10);
|
|
713
|
+
return !Number.isFinite(r) || r < 1 ? 1 : Math.min(r, n);
|
|
714
|
+
}, Ye = (e, t) => {
|
|
715
|
+
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) => {
|
|
716
|
+
Array.from({ length: i }).forEach((i, o) => {
|
|
717
|
+
Array.from({ length: a }).forEach((i, a) => {
|
|
718
|
+
(o !== 0 || a !== 0) && (r[e + o][n + a] ??= t.covered([e, n]));
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
n.forEach((e, s) => {
|
|
723
|
+
k(e).reduce((e, c) => {
|
|
724
|
+
let l = a(r[s], e), u = R(c, "colspan", qe), d = Math.min(R(c, "rowspan", Je), n.length - s);
|
|
725
|
+
return r[s][l] = t.cell(c, {
|
|
726
|
+
colspan: u,
|
|
727
|
+
rowspan: d
|
|
728
|
+
}), (u > 1 || d > 1) && (i.hasMerges = !0, o(s, l, d, u)), l + u;
|
|
729
|
+
}, 0);
|
|
730
|
+
});
|
|
731
|
+
let s = i.hasMerges ? r : r.filter((e) => e.length > 0), c = s.reduce((e, t) => Math.max(e, t.length), 0);
|
|
732
|
+
return s.map((e) => Array.from({ length: c }, (n, r) => e[r] ?? t.filler()));
|
|
733
|
+
}, Xe = /* @__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(".")), Ze = /* @__PURE__ */ new Set(["transparent", "currentcolor"]), Qe = 256, z = "[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)", B = `${z}%?`, V = `${z}%`, H = `${z}(?:deg|grad|rad|turn)?`, U = " *, *", W = " +", G = `(?: */ *${B})?`, $e = RegExp(`^rgba?\\( *${B}${U}${B}${U}${B}(?:${U}${B})? *\\)$`, "i"), et = RegExp(`^rgba?\\( *${B}${W}${B}${W}${B}${G} *\\)$`, "i"), tt = RegExp(`^hsla?\\( *${H}${U}${V}${U}${V}(?:${U}${B})? *\\)$`, "i"), nt = RegExp(`^hsla?\\( *${H}${W}${B}${W}${B}${G} *\\)$`, "i"), rt = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, it = /^var\(--[a-zA-Z0-9_-]+\)$/, at = (e) => {
|
|
734
|
+
if (typeof e != "string" || e.length === 0 || e.length > Qe) return !1;
|
|
735
|
+
let t = e.toLowerCase();
|
|
736
|
+
return Xe.has(t) || Ze.has(t) || rt.test(e) || it.test(e) || $e.test(e) || et.test(e) || tt.test(e) || nt.test(e);
|
|
737
|
+
}, K = "data-latex", ot = /* @__PURE__ */ new Set(["color", "background-color"]), st = {
|
|
738
|
+
br: !0,
|
|
739
|
+
strong: {},
|
|
740
|
+
b: {},
|
|
741
|
+
em: {},
|
|
742
|
+
i: {},
|
|
743
|
+
u: {},
|
|
744
|
+
s: {},
|
|
745
|
+
del: {},
|
|
746
|
+
a: {
|
|
747
|
+
href: !0,
|
|
748
|
+
target: !0,
|
|
749
|
+
rel: !0
|
|
750
|
+
},
|
|
751
|
+
code: {},
|
|
752
|
+
sup: {},
|
|
753
|
+
sub: {},
|
|
754
|
+
mark: (e) => {
|
|
755
|
+
let t = e.style, n = Array.from({ length: t.length }, (e, n) => t.item(n));
|
|
756
|
+
for (let e of n) ot.has(e) || t.removeProperty(e);
|
|
757
|
+
return t.length > 0 ? { style: !0 } : {};
|
|
758
|
+
},
|
|
759
|
+
span: (e) => {
|
|
760
|
+
let t = e.getAttribute(K);
|
|
761
|
+
return t !== null && (e.textContent !== t && (e.textContent = t), { [K]: !0 });
|
|
762
|
+
}
|
|
763
|
+
}, ct = [
|
|
764
|
+
"left",
|
|
765
|
+
"center",
|
|
766
|
+
"right"
|
|
767
|
+
], lt = [
|
|
768
|
+
"top",
|
|
769
|
+
"middle",
|
|
770
|
+
"bottom"
|
|
771
|
+
], ut = {
|
|
772
|
+
left: "right",
|
|
773
|
+
center: "center",
|
|
774
|
+
right: "left"
|
|
775
|
+
};
|
|
776
|
+
function dt(e, t) {
|
|
777
|
+
return t === "rtl" ? ut[e] : e;
|
|
778
|
+
}
|
|
779
|
+
function ft(e, t, n = "ltr") {
|
|
780
|
+
let r = e?.trim().toLowerCase(), i = ct.find((e) => e === r), a = i === void 0 ? r === "end" ? "right" : "left" : dt(i, n), o = lt.find((e) => e === t?.trim().toLowerCase()) ?? "top";
|
|
781
|
+
if (a !== "left" || o !== "top") return `${o}-${a}`;
|
|
782
|
+
}
|
|
783
|
+
({ ...st });
|
|
784
|
+
function pt(e) {
|
|
785
|
+
let t = e.replace(/\s/g, "");
|
|
786
|
+
return t === "rgb(0,0,0)" || t === "#000000";
|
|
787
|
+
}
|
|
788
|
+
function mt(e) {
|
|
789
|
+
let t = /background-color\s*:\s*([^;]+)/i.exec(e)?.[1];
|
|
790
|
+
if (t !== void 0) return t.trim();
|
|
791
|
+
if (!/(?<![a-z-])background\s*:/i.test(e)) return;
|
|
792
|
+
let n = document.implementation.createHTMLDocument("").createElement("div");
|
|
793
|
+
return n.style.cssText = e, n.style.backgroundColor || void 0;
|
|
794
|
+
}
|
|
795
|
+
function q(e) {
|
|
796
|
+
let t = (/(?<![a-z-])direction\s*:\s*(rtl|ltr)\b/i.exec(e.getAttribute("style") ?? "")?.[1] ?? e.getAttribute("dir"))?.trim().toLowerCase();
|
|
797
|
+
return t === "rtl" || t === "ltr" ? t : e.parentElement === null ? "ltr" : q(e.parentElement);
|
|
798
|
+
}
|
|
799
|
+
function ht(e, t = "ltr") {
|
|
800
|
+
let n = {}, r = mt(e);
|
|
801
|
+
r !== void 0 && !s(r) && (n.color = p(r, "bg"));
|
|
802
|
+
let i = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(e)?.[1]?.trim();
|
|
803
|
+
i !== void 0 && !pt(i) && (n.textColor = p(i, "text"));
|
|
804
|
+
let a = ft(/(?<![a-z-])text-align\s*:\s*([^;]+)/i.exec(e)?.[1], /vertical-align\s*:\s*([^;]+)/i.exec(e)?.[1], t);
|
|
805
|
+
return a !== void 0 && (n.placement = a), n;
|
|
806
|
+
}
|
|
807
|
+
function gt(e, t = "ltr") {
|
|
808
|
+
let n = e.getAttribute("style") ?? "", r = [n], i = e.getAttribute("align")?.trim(), a = e.getAttribute("valign")?.trim(), o = e.getAttribute("bgcolor")?.trim();
|
|
809
|
+
return i !== void 0 && /^[a-z]+$/i.test(i) && !/(?<![a-z-])text-align\s*:/i.test(n) && r.push(`text-align:${i}`), a !== void 0 && /^[a-z]+$/i.test(a) && !/vertical-align\s*:/i.test(n) && r.push(`vertical-align:${a}`), at(o) && !/(?<![a-z-])background(?:-color)?\s*:/i.test(n) && r.push(`background-color:${o}`), ht(r.join(";"), t);
|
|
810
|
+
}
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/components/modules/paste/table-direction-preprocessor.ts
|
|
813
|
+
function _t(e) {
|
|
814
|
+
if (!/<table[\s>]/i.test(e)) return e;
|
|
815
|
+
let t = new DOMParser().parseFromString(e, "text/html"), n = Array.from(t.querySelectorAll("table")).filter((e) => {
|
|
816
|
+
let t = e.getAttribute("dir")?.trim().toLowerCase() === "rtl" ? "rtl" : "ltr";
|
|
817
|
+
return q(e) !== t;
|
|
818
|
+
});
|
|
819
|
+
return n.length === 0 ? e : (n.forEach((e) => e.setAttribute("dir", q(e))), t.documentElement.outerHTML);
|
|
820
|
+
}
|
|
821
|
+
//#endregion
|
|
822
|
+
//#region src/preprocess/legacy-cms-html.ts
|
|
823
|
+
function vt(e) {
|
|
824
|
+
yt(e), St(e), Tt(e), Dt(e), Ot(e), kt(e);
|
|
825
|
+
}
|
|
826
|
+
function yt(e) {
|
|
827
|
+
let t = e.ownerDocument;
|
|
828
|
+
for (let n of Array.from(e.querySelectorAll("div[style]"))) {
|
|
829
|
+
if (n.closest("table")) continue;
|
|
830
|
+
let e = wt(n);
|
|
831
|
+
if (!e || Y(e)) continue;
|
|
832
|
+
let r = t.createElement("aside");
|
|
833
|
+
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), bt(r), xt(r), n.replaceWith(r);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
function bt(e) {
|
|
837
|
+
for (;;) {
|
|
838
|
+
let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
|
|
839
|
+
if (t.length === 0) break;
|
|
840
|
+
for (let e of t) e.replaceWith(...Array.from(e.childNodes));
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
function xt(e) {
|
|
844
|
+
for (let t of Array.from(e.querySelectorAll("p"))) {
|
|
845
|
+
let e = t.lastElementChild;
|
|
846
|
+
e?.tagName === "BR" && e.remove();
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
var J = 250;
|
|
850
|
+
function St(e) {
|
|
851
|
+
let t = e.querySelectorAll("[style*=\"background-color\"]");
|
|
852
|
+
for (let e of Array.from(t)) Y(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), Ct(e) && e.replaceWith(...Array.from(e.childNodes)));
|
|
853
|
+
}
|
|
854
|
+
function Y(e) {
|
|
855
|
+
if (!e) return !1;
|
|
856
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
857
|
+
if (t === "transparent") return !0;
|
|
858
|
+
let n = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
|
|
859
|
+
if (!n) return !1;
|
|
860
|
+
if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
|
|
861
|
+
let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
|
|
862
|
+
return r >= J && i >= J && a >= J;
|
|
863
|
+
}
|
|
864
|
+
function Ct(e) {
|
|
865
|
+
return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
|
|
866
|
+
}
|
|
867
|
+
function wt(e) {
|
|
868
|
+
if (e.style.backgroundColor) return e.style.backgroundColor;
|
|
869
|
+
let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
|
|
870
|
+
if (t) {
|
|
871
|
+
let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
|
|
872
|
+
if (e) return e[1];
|
|
873
|
+
}
|
|
874
|
+
return "";
|
|
875
|
+
}
|
|
876
|
+
function Tt(e) {
|
|
877
|
+
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
878
|
+
let e = t.querySelectorAll("p");
|
|
879
|
+
if (e.length !== 0) {
|
|
880
|
+
for (let t of Array.from(e)) Et(t);
|
|
881
|
+
Mt(t);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function Et(e) {
|
|
886
|
+
if (e.innerHTML.trim() === "" || e.innerHTML.trim() === " ") {
|
|
887
|
+
e.remove();
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
let t = e.ownerDocument, n = t.createDocumentFragment();
|
|
891
|
+
n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
|
|
892
|
+
}
|
|
893
|
+
function Dt(e) {
|
|
894
|
+
for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || T(t, { lineBreaksAreContent: !1 }) && t.remove();
|
|
895
|
+
}
|
|
896
|
+
function Ot(e) {
|
|
897
|
+
let t = e.ownerDocument;
|
|
898
|
+
for (let n of Array.from(e.querySelectorAll("del, strike"))) {
|
|
899
|
+
let e = t.createElement("s");
|
|
900
|
+
e.append(...Array.from(n.childNodes)), n.replaceWith(e);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
var X = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
|
|
904
|
+
function kt(e) {
|
|
905
|
+
let t = e.ownerDocument, n = jt(e);
|
|
906
|
+
for (let e of n) {
|
|
907
|
+
let n = t.createElement("ul");
|
|
908
|
+
e[0].before(n);
|
|
909
|
+
for (let t of e) At(t, n);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
function At(e, t) {
|
|
913
|
+
let n = e.ownerDocument.createElement("li"), r = Z(e);
|
|
914
|
+
r && (r.textContent = (r.textContent ?? "").replace(X, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
|
|
915
|
+
}
|
|
916
|
+
function jt(e) {
|
|
917
|
+
let t = [], n = Array.from(e.childNodes);
|
|
918
|
+
for (let e of n) {
|
|
919
|
+
if (e.nodeType !== Node.ELEMENT_NODE) continue;
|
|
920
|
+
let n = e;
|
|
921
|
+
if (!(n.tagName === "P" && X.test(n.textContent ?? ""))) continue;
|
|
922
|
+
let r = t[t.length - 1], i = n.previousElementSibling;
|
|
923
|
+
r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
|
|
924
|
+
}
|
|
925
|
+
return t;
|
|
926
|
+
}
|
|
927
|
+
function Mt(e) {
|
|
928
|
+
for (;;) {
|
|
929
|
+
let t = e.lastChild;
|
|
930
|
+
if (!t) break;
|
|
931
|
+
let n = t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR", r = t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "";
|
|
932
|
+
if (!n && !r) break;
|
|
933
|
+
t.remove();
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
function Z(e) {
|
|
937
|
+
if (e.nodeType === Node.TEXT_NODE) return e;
|
|
938
|
+
for (let t of Array.from(e.childNodes)) {
|
|
939
|
+
let e = Z(t);
|
|
940
|
+
if (e) return e;
|
|
941
|
+
}
|
|
942
|
+
return null;
|
|
943
|
+
}
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region src/cli/commands/convert-html/sanitizer.ts
|
|
946
|
+
var Nt = {
|
|
947
|
+
B: !0,
|
|
948
|
+
STRONG: !0,
|
|
949
|
+
I: !0,
|
|
950
|
+
EM: !0,
|
|
951
|
+
A: /* @__PURE__ */ new Set(["href"]),
|
|
952
|
+
S: !0,
|
|
953
|
+
U: !0,
|
|
954
|
+
CODE: !0,
|
|
955
|
+
MARK: /* @__PURE__ */ new Set(["style"]),
|
|
956
|
+
BR: !0,
|
|
957
|
+
P: !0,
|
|
958
|
+
H1: !0,
|
|
959
|
+
H2: !0,
|
|
960
|
+
H3: !0,
|
|
961
|
+
H4: !0,
|
|
962
|
+
H5: !0,
|
|
963
|
+
H6: !0,
|
|
964
|
+
UL: !0,
|
|
965
|
+
OL: !0,
|
|
966
|
+
LI: /* @__PURE__ */ new Set(["aria-level"]),
|
|
967
|
+
TABLE: /* @__PURE__ */ new Set(["dir"]),
|
|
968
|
+
THEAD: !0,
|
|
969
|
+
TBODY: !0,
|
|
970
|
+
TR: !0,
|
|
971
|
+
CAPTION: !0,
|
|
972
|
+
TD: /* @__PURE__ */ new Set([
|
|
973
|
+
"style",
|
|
974
|
+
"colspan",
|
|
975
|
+
"rowspan",
|
|
976
|
+
"align",
|
|
977
|
+
"valign",
|
|
978
|
+
"bgcolor"
|
|
979
|
+
]),
|
|
980
|
+
TH: /* @__PURE__ */ new Set([
|
|
981
|
+
"style",
|
|
982
|
+
"colspan",
|
|
983
|
+
"rowspan",
|
|
984
|
+
"align",
|
|
985
|
+
"valign",
|
|
986
|
+
"bgcolor"
|
|
987
|
+
]),
|
|
988
|
+
BLOCKQUOTE: !0,
|
|
989
|
+
PRE: !0,
|
|
990
|
+
HR: !0,
|
|
991
|
+
ASIDE: /* @__PURE__ */ new Set(["style"]),
|
|
992
|
+
DETAILS: !0,
|
|
993
|
+
SUMMARY: !0,
|
|
994
|
+
IMG: /* @__PURE__ */ new Set(["src", "style"])
|
|
995
|
+
};
|
|
996
|
+
function Pt(e) {
|
|
997
|
+
Q(e);
|
|
998
|
+
}
|
|
999
|
+
function Ft(e) {
|
|
1000
|
+
let t = Array.from(e.childNodes);
|
|
1001
|
+
for (let n of t) e.before(n);
|
|
1002
|
+
return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
|
|
1003
|
+
}
|
|
1004
|
+
function It(e, t) {
|
|
1005
|
+
for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
|
|
1006
|
+
}
|
|
1007
|
+
function Q(e) {
|
|
1008
|
+
let t = Array.from(e.childNodes);
|
|
1009
|
+
for (let e of t) {
|
|
1010
|
+
if (e.nodeType !== e.ELEMENT_NODE) continue;
|
|
1011
|
+
let n = e, r = Nt[n.tagName];
|
|
1012
|
+
if (r === void 0) {
|
|
1013
|
+
t.push(...Ft(n));
|
|
1014
|
+
continue;
|
|
1015
|
+
}
|
|
1016
|
+
It(n, r), Q(n);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
//#endregion
|
|
1020
|
+
//#region src/cli/commands/convert-html/id-generator.ts
|
|
1021
|
+
function Lt() {
|
|
1022
|
+
let e = /* @__PURE__ */ new Map();
|
|
1023
|
+
return (t) => {
|
|
1024
|
+
let n = (e.get(t) ?? 0) + 1;
|
|
1025
|
+
return e.set(t, n), `${t}-${n}`;
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
//#endregion
|
|
1029
|
+
//#region src/cli/commands/convert-html/block-builder.ts
|
|
1030
|
+
function Rt(e) {
|
|
1031
|
+
let t = Lt(), n = [];
|
|
1032
|
+
for (let r of Array.from(e.childNodes)) zt(r, n, t);
|
|
1033
|
+
return n;
|
|
1034
|
+
}
|
|
1035
|
+
function zt(e, t, n) {
|
|
1036
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
1037
|
+
let r = e.textContent?.trim() ?? "";
|
|
1038
|
+
r && t.push({
|
|
1039
|
+
id: n("paragraph"),
|
|
1040
|
+
type: "paragraph",
|
|
1041
|
+
data: { text: r }
|
|
1042
|
+
});
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
1046
|
+
let r = e, i = r.tagName;
|
|
1047
|
+
if (i === "P") {
|
|
1048
|
+
t.push({
|
|
1049
|
+
id: n("paragraph"),
|
|
1050
|
+
type: "paragraph",
|
|
1051
|
+
data: { text: r.innerHTML }
|
|
1052
|
+
});
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
if (/^H[1-6]$/.test(i)) {
|
|
1056
|
+
let e = Number(i[1]);
|
|
1057
|
+
t.push({
|
|
1058
|
+
id: n("header"),
|
|
1059
|
+
type: "header",
|
|
1060
|
+
data: {
|
|
1061
|
+
text: r.innerHTML,
|
|
1062
|
+
level: e
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
if (i === "BLOCKQUOTE") {
|
|
1068
|
+
t.push({
|
|
1069
|
+
id: n("quote"),
|
|
1070
|
+
type: "quote",
|
|
1071
|
+
data: {
|
|
1072
|
+
text: r.innerHTML,
|
|
1073
|
+
size: "default"
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
if (i === "PRE") {
|
|
1079
|
+
t.push({
|
|
1080
|
+
id: n("code"),
|
|
1081
|
+
type: "code",
|
|
1082
|
+
data: {
|
|
1083
|
+
code: r.textContent ?? "",
|
|
1084
|
+
language: "plain-text"
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
if (i === "HR") {
|
|
1090
|
+
t.push({
|
|
1091
|
+
id: n("divider"),
|
|
1092
|
+
type: "divider",
|
|
1093
|
+
data: {}
|
|
1094
|
+
});
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
if (i === "IMG") {
|
|
1098
|
+
let e = r.getAttribute("src") ?? "", i = Gt(r, "width");
|
|
1099
|
+
t.push({
|
|
1100
|
+
id: n("image"),
|
|
1101
|
+
type: "image",
|
|
1102
|
+
data: { url: e },
|
|
1103
|
+
stretched: null,
|
|
1104
|
+
key: null,
|
|
1105
|
+
width: i
|
|
1106
|
+
});
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
if (i === "DETAILS") {
|
|
1110
|
+
let e = r.querySelector("summary"), i = e ? e.innerHTML : r.innerHTML;
|
|
1111
|
+
t.push({
|
|
1112
|
+
id: n("toggle"),
|
|
1113
|
+
type: "toggle",
|
|
1114
|
+
data: { text: i }
|
|
1115
|
+
});
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
if (i === "UL" || i === "OL") {
|
|
1119
|
+
Bt(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
if (i === "TABLE") {
|
|
1123
|
+
Vt(r, t, n);
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
if (i === "ASIDE") {
|
|
1127
|
+
Ht(r, t, n);
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
t.push({
|
|
1131
|
+
id: n("paragraph"),
|
|
1132
|
+
type: "paragraph",
|
|
1133
|
+
data: { text: r.innerHTML }
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
function Bt(e, t, n, r, i) {
|
|
1137
|
+
let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
|
|
1138
|
+
for (let [e, a] of s.entries()) {
|
|
1139
|
+
let s = a.cloneNode(!0), c = [];
|
|
1140
|
+
for (let e of Array.from(s.querySelectorAll("ul, ol"))) c.push(e.cloneNode(!0)), e.remove();
|
|
1141
|
+
let l = s.innerHTML.trim(), u = a.getAttribute("aria-level"), d = u ? Math.max(0, parseInt(u, 10) - 1) : n;
|
|
1142
|
+
r.push({
|
|
1143
|
+
id: i("list"),
|
|
1144
|
+
type: "list",
|
|
1145
|
+
data: {
|
|
1146
|
+
text: l,
|
|
1147
|
+
style: t,
|
|
1148
|
+
depth: d === 0 ? null : d,
|
|
1149
|
+
checked: null,
|
|
1150
|
+
start: e === 0 && o !== null ? o : null
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
for (let e of c) Bt(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
function Vt(e, t, n) {
|
|
1157
|
+
let r = Array.from(e.children).find((e) => e.tagName === "CAPTION")?.innerHTML.trim() ?? "";
|
|
1158
|
+
r && t.push({
|
|
1159
|
+
id: n("paragraph"),
|
|
1160
|
+
type: "paragraph",
|
|
1161
|
+
data: { text: r }
|
|
1162
|
+
}), Te(e);
|
|
1163
|
+
let i = n("table"), a = O(e), o = Ye(a, {
|
|
1164
|
+
cell: (e, t) => ({
|
|
1165
|
+
kind: "cell",
|
|
1166
|
+
el: e,
|
|
1167
|
+
...t
|
|
1168
|
+
}),
|
|
1169
|
+
covered: (e) => ({
|
|
1170
|
+
kind: "covered",
|
|
1171
|
+
origin: e
|
|
1172
|
+
}),
|
|
1173
|
+
filler: () => ({ kind: "filler" })
|
|
1174
|
+
}), s = q(e), c = o.map((e) => e.map((e) => e.kind === "covered" ? {
|
|
1175
|
+
blocks: [],
|
|
1176
|
+
mergedInto: e.origin
|
|
1177
|
+
} : e.kind === "filler" ? {
|
|
1178
|
+
blocks: [],
|
|
1179
|
+
color: null,
|
|
1180
|
+
textColor: null
|
|
1181
|
+
} : Ut(e, s, i, t, n))), l = (e) => e?.tagName === "TH", u = a[0] ? k(a[0]) : [], d = a.some((e) => e.parentElement?.tagName === "THEAD") || u.length > 0 && u.every(l), f = a.length >= 2 && a.every((e) => l(k(e)[0])), p = (o[0] ?? []).map((e) => {
|
|
1182
|
+
if (e.kind !== "cell" || e.colspan > 1) return null;
|
|
1183
|
+
let t = parseInt($(e.el, "width") ?? "", 10);
|
|
1184
|
+
return isNaN(t) ? null : t;
|
|
1185
|
+
}), m = {
|
|
1186
|
+
id: i,
|
|
1187
|
+
type: "table",
|
|
1188
|
+
data: {
|
|
1189
|
+
withHeadings: d,
|
|
1190
|
+
withHeadingColumn: f,
|
|
1191
|
+
content: c,
|
|
1192
|
+
...p.some((e) => e !== null) ? { colWidths: p } : {}
|
|
1193
|
+
}
|
|
1194
|
+
}, h = t.findIndex((e) => e.parent === i);
|
|
1195
|
+
h >= 0 ? t.splice(h, 0, m) : t.push(m);
|
|
1196
|
+
}
|
|
1197
|
+
function Ht(e, t, r) {
|
|
1198
|
+
let a = r("callout"), o = $(e, "background-color"), s = o && !n(o) && !i(o) ? m(o, "bg") : null, c = [];
|
|
1199
|
+
for (let n of Array.from(e.childNodes)) {
|
|
1200
|
+
let e = Wt(n, a, t, r);
|
|
1201
|
+
e && c.push(e);
|
|
1202
|
+
}
|
|
1203
|
+
let l = t.findIndex((e) => e.parent === a), u = {
|
|
1204
|
+
id: a,
|
|
1205
|
+
type: "callout",
|
|
1206
|
+
data: {
|
|
1207
|
+
emoji: "💡",
|
|
1208
|
+
backgroundColor: s
|
|
1209
|
+
},
|
|
1210
|
+
content: c
|
|
1211
|
+
};
|
|
1212
|
+
l >= 0 ? t.splice(l, 0, u) : t.push(u);
|
|
1213
|
+
}
|
|
1214
|
+
function Ut(e, t, n, r, i) {
|
|
1215
|
+
let a = e.el, { color: o, textColor: s, placement: c } = gt(a, t), l = a.innerHTML.trim();
|
|
1216
|
+
return {
|
|
1217
|
+
blocks: l ? De(l).map((e) => {
|
|
1218
|
+
let t = i(e.tool);
|
|
1219
|
+
return r.push({
|
|
1220
|
+
id: t,
|
|
1221
|
+
type: e.tool,
|
|
1222
|
+
parent: n,
|
|
1223
|
+
data: e.data
|
|
1224
|
+
}), t;
|
|
1225
|
+
}) : [],
|
|
1226
|
+
color: o === void 0 ? null : m(o, "bg"),
|
|
1227
|
+
textColor: s === void 0 ? null : m(s, "text"),
|
|
1228
|
+
...c === void 0 ? {} : { placement: c },
|
|
1229
|
+
...e.colspan > 1 ? { colspan: e.colspan } : {},
|
|
1230
|
+
...e.rowspan > 1 ? { rowspan: e.rowspan } : {}
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
function Wt(e, t, n, r) {
|
|
1234
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
1235
|
+
let i = e, a = r("paragraph");
|
|
1236
|
+
return n.push({
|
|
1237
|
+
id: a,
|
|
1238
|
+
type: "paragraph",
|
|
1239
|
+
parent: t,
|
|
1240
|
+
data: { text: i.innerHTML }
|
|
1241
|
+
}), a;
|
|
1242
|
+
}
|
|
1243
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
1244
|
+
let i = e.textContent?.trim() ?? "";
|
|
1245
|
+
if (!i) return null;
|
|
1246
|
+
let a = r("paragraph");
|
|
1247
|
+
return n.push({
|
|
1248
|
+
id: a,
|
|
1249
|
+
type: "paragraph",
|
|
1250
|
+
parent: t,
|
|
1251
|
+
data: { text: i }
|
|
1252
|
+
}), a;
|
|
1253
|
+
}
|
|
1254
|
+
return null;
|
|
1255
|
+
}
|
|
1256
|
+
function Gt(e, t) {
|
|
1257
|
+
let n = $(e, t);
|
|
1258
|
+
if (!n) return null;
|
|
1259
|
+
let r = parseInt(n, 10);
|
|
1260
|
+
return isNaN(r) ? null : r;
|
|
1261
|
+
}
|
|
1262
|
+
function $(e, t) {
|
|
1263
|
+
let n = e.getAttribute("style");
|
|
1264
|
+
if (!n) return null;
|
|
1265
|
+
let r = RegExp(`(?<![\\-a-z])${t}\\s*:\\s*([^;]+)`).exec(n);
|
|
1266
|
+
return r ? r[1].trim() : null;
|
|
1267
|
+
}
|
|
1268
|
+
//#endregion
|
|
1269
|
+
export { L as a, _t as i, Pt as n, Oe as o, vt as r, C as s, Rt as t };
|