@jackuait/blok-cli 0.10.0-beta.15 → 0.10.0-beta.19
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/{convert-html-CnpK6ocW.mjs → block-builder-B8WkPORz.mjs} +342 -315
- package/dist/cli.mjs +16 -2
- package/dist/convert-gdocs-BJoOR21I.mjs +105 -0
- package/dist/convert-gdocs-DQihIQqC.mjs +105 -0
- package/dist/convert-gdocs-DjfegUKM.mjs +105 -0
- package/dist/convert-gdocs-MgRJyLkW.mjs +105 -0
- package/dist/convert-html-BGrkD0K6.mjs +13 -0
- package/dist/convert-html-C0OO15ZO.mjs +13 -0
- package/dist/convert-html-CavJ5q2p.mjs +13 -0
- package/dist/convert-html-DWcDlr_4.mjs +13 -0
- package/package.json +1 -1
|
@@ -1,185 +1,5 @@
|
|
|
1
|
-
//#region src/cli/commands/convert-html/preprocessor.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
t(e), r(e), s(e), c(e), l(e), d(e);
|
|
4
|
-
}
|
|
5
|
-
function t(e) {
|
|
6
|
-
let t = e.ownerDocument;
|
|
7
|
-
for (let n of Array.from(e.querySelectorAll("div[style]"))) {
|
|
8
|
-
if (n.closest("table")) continue;
|
|
9
|
-
let e = o(n);
|
|
10
|
-
if (!e || i(e)) continue;
|
|
11
|
-
let r = t.createElement("aside");
|
|
12
|
-
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes));
|
|
13
|
-
let a;
|
|
14
|
-
for (; (a = Array.from(r.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"))).length > 0;) for (let e of a) e.replaceWith(...Array.from(e.childNodes));
|
|
15
|
-
for (let e of Array.from(r.querySelectorAll("p"))) {
|
|
16
|
-
let t = e.lastElementChild;
|
|
17
|
-
t?.tagName === "BR" && t.remove();
|
|
18
|
-
}
|
|
19
|
-
n.replaceWith(r);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
var n = 250;
|
|
23
|
-
function r(e) {
|
|
24
|
-
let t = e.querySelectorAll("[style*=\"background-color\"]");
|
|
25
|
-
for (let e of Array.from(t)) i(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), a(e) && e.replaceWith(...Array.from(e.childNodes)));
|
|
26
|
-
}
|
|
27
|
-
function i(e) {
|
|
28
|
-
if (!e) return !1;
|
|
29
|
-
let t = e.replace(/\s/g, "").toLowerCase();
|
|
30
|
-
if (t === "transparent") return !0;
|
|
31
|
-
let r = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
|
|
32
|
-
if (!r) return !1;
|
|
33
|
-
if ((r[4] === void 0 ? 1 : parseFloat(r[4])) === 0) return !0;
|
|
34
|
-
let i = parseInt(r[1], 10), a = parseInt(r[2], 10), o = parseInt(r[3], 10);
|
|
35
|
-
return i >= n && a >= n && o >= n;
|
|
36
|
-
}
|
|
37
|
-
function a(e) {
|
|
38
|
-
return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
|
|
39
|
-
}
|
|
40
|
-
function o(e) {
|
|
41
|
-
if (e.style.backgroundColor) return e.style.backgroundColor;
|
|
42
|
-
let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
|
|
43
|
-
if (t) {
|
|
44
|
-
let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
|
|
45
|
-
if (e) return e[1];
|
|
46
|
-
}
|
|
47
|
-
return "";
|
|
48
|
-
}
|
|
49
|
-
function s(e) {
|
|
50
|
-
let t = e.ownerDocument;
|
|
51
|
-
for (let n of Array.from(e.querySelectorAll("td, th"))) {
|
|
52
|
-
let e = n.querySelectorAll("p");
|
|
53
|
-
if (e.length !== 0) {
|
|
54
|
-
for (let n of Array.from(e)) {
|
|
55
|
-
if (n.innerHTML.trim() === "" || n.innerHTML.trim() === " ") {
|
|
56
|
-
n.remove();
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
let e = t.createDocumentFragment();
|
|
60
|
-
e.append(...Array.from(n.childNodes)), e.append(t.createElement("br")), n.replaceWith(e);
|
|
61
|
-
}
|
|
62
|
-
f(n);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function c(e) {
|
|
67
|
-
for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || (t.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0 && t.remove();
|
|
68
|
-
}
|
|
69
|
-
function l(e) {
|
|
70
|
-
let t = e.ownerDocument;
|
|
71
|
-
for (let n of Array.from(e.querySelectorAll("del, strike"))) {
|
|
72
|
-
let e = t.createElement("s");
|
|
73
|
-
e.append(...Array.from(n.childNodes)), n.replaceWith(e);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
var u = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
|
|
77
|
-
function d(e) {
|
|
78
|
-
let t = e.ownerDocument, n = Array.from(e.childNodes), r = null;
|
|
79
|
-
for (let e of n) {
|
|
80
|
-
if (e.nodeType !== Node.ELEMENT_NODE) continue;
|
|
81
|
-
let n = e;
|
|
82
|
-
if (n.tagName !== "P") {
|
|
83
|
-
r = null;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
let i = n.textContent ?? "";
|
|
87
|
-
if (!u.test(i)) {
|
|
88
|
-
r = null;
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
r || (r = t.createElement("ul"), n.before(r));
|
|
92
|
-
let a = t.createElement("li"), o = p(n);
|
|
93
|
-
o && (o.textContent = (o.textContent ?? "").replace(u, "")), a.append(...Array.from(n.childNodes)), r.appendChild(a), n.remove();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function f(e) {
|
|
97
|
-
let t = e.lastChild;
|
|
98
|
-
for (; t;) if (t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR") {
|
|
99
|
-
let e = t.previousSibling;
|
|
100
|
-
t.remove(), t = e;
|
|
101
|
-
} else if (t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "") {
|
|
102
|
-
let e = t.previousSibling;
|
|
103
|
-
t.remove(), t = e;
|
|
104
|
-
} else break;
|
|
105
|
-
}
|
|
106
|
-
function p(e) {
|
|
107
|
-
if (e.nodeType === Node.TEXT_NODE) return e;
|
|
108
|
-
for (let t of Array.from(e.childNodes)) {
|
|
109
|
-
let e = p(t);
|
|
110
|
-
if (e) return e;
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/cli/commands/convert-html/sanitizer.ts
|
|
116
|
-
var m = {
|
|
117
|
-
B: !0,
|
|
118
|
-
STRONG: !0,
|
|
119
|
-
I: !0,
|
|
120
|
-
EM: !0,
|
|
121
|
-
A: new Set(["href"]),
|
|
122
|
-
S: !0,
|
|
123
|
-
U: !0,
|
|
124
|
-
CODE: !0,
|
|
125
|
-
MARK: new Set(["style"]),
|
|
126
|
-
BR: !0,
|
|
127
|
-
P: !0,
|
|
128
|
-
H1: !0,
|
|
129
|
-
H2: !0,
|
|
130
|
-
H3: !0,
|
|
131
|
-
H4: !0,
|
|
132
|
-
H5: !0,
|
|
133
|
-
H6: !0,
|
|
134
|
-
UL: !0,
|
|
135
|
-
OL: !0,
|
|
136
|
-
LI: new Set(["aria-level"]),
|
|
137
|
-
TABLE: !0,
|
|
138
|
-
THEAD: !0,
|
|
139
|
-
TBODY: !0,
|
|
140
|
-
TR: !0,
|
|
141
|
-
TD: new Set(["style"]),
|
|
142
|
-
TH: new Set(["style"]),
|
|
143
|
-
BLOCKQUOTE: !0,
|
|
144
|
-
PRE: !0,
|
|
145
|
-
HR: !0,
|
|
146
|
-
ASIDE: new Set(["style"]),
|
|
147
|
-
DETAILS: !0,
|
|
148
|
-
SUMMARY: !0,
|
|
149
|
-
IMG: new Set(["src", "style"])
|
|
150
|
-
};
|
|
151
|
-
function h(e) {
|
|
152
|
-
g(e);
|
|
153
|
-
}
|
|
154
|
-
function g(e) {
|
|
155
|
-
let t = Array.from(e.childNodes);
|
|
156
|
-
for (let e of t) {
|
|
157
|
-
if (e.nodeType !== e.ELEMENT_NODE) continue;
|
|
158
|
-
let n = e, r = m[n.tagName];
|
|
159
|
-
if (r === void 0) {
|
|
160
|
-
let e = Array.from(n.childNodes);
|
|
161
|
-
for (let t of e) n.before(t);
|
|
162
|
-
n.remove();
|
|
163
|
-
for (let n of e) n.nodeType === n.ELEMENT_NODE && t.push(n);
|
|
164
|
-
} else {
|
|
165
|
-
if (r !== !0) for (let e of Array.from(n.attributes)) r.has(e.name) || n.removeAttribute(e.name);
|
|
166
|
-
else for (let e of Array.from(n.attributes)) n.removeAttribute(e.name);
|
|
167
|
-
g(n);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
//#endregion
|
|
172
|
-
//#region src/cli/commands/convert-html/id-generator.ts
|
|
173
|
-
function _() {
|
|
174
|
-
let e = /* @__PURE__ */ new Map();
|
|
175
|
-
return (t) => {
|
|
176
|
-
let n = (e.get(t) ?? 0) + 1;
|
|
177
|
-
return e.set(t, n), `${t}-${n}`;
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
//#endregion
|
|
181
1
|
//#region src/components/shared/color-presets.ts
|
|
182
|
-
var
|
|
2
|
+
var e = [
|
|
183
3
|
{
|
|
184
4
|
name: "gray",
|
|
185
5
|
text: "#787774",
|
|
@@ -225,7 +45,7 @@ var v = [
|
|
|
225
45
|
text: "#d44c47",
|
|
226
46
|
bg: "#fdebec"
|
|
227
47
|
}
|
|
228
|
-
],
|
|
48
|
+
], t = [
|
|
229
49
|
{
|
|
230
50
|
name: "gray",
|
|
231
51
|
text: "#9b9b9b",
|
|
@@ -274,7 +94,7 @@ var v = [
|
|
|
274
94
|
];
|
|
275
95
|
//#endregion
|
|
276
96
|
//#region src/components/utils/color-mapping.ts
|
|
277
|
-
function
|
|
97
|
+
function n(e, t, n) {
|
|
278
98
|
let r = t / 100, i = n / 100;
|
|
279
99
|
if (r === 0) {
|
|
280
100
|
let e = Math.round(i * 255);
|
|
@@ -294,42 +114,42 @@ function b(e, t, n) {
|
|
|
294
114
|
Math.round(o(c, s, l - 1 / 3) * 255)
|
|
295
115
|
];
|
|
296
116
|
}
|
|
297
|
-
function
|
|
117
|
+
function r(e) {
|
|
298
118
|
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
299
119
|
if (t) return [
|
|
300
120
|
parseInt(t[1], 16),
|
|
301
121
|
parseInt(t[2], 16),
|
|
302
122
|
parseInt(t[3], 16)
|
|
303
123
|
];
|
|
304
|
-
let
|
|
305
|
-
if (n) return [
|
|
306
|
-
parseInt(n[1], 16),
|
|
307
|
-
parseInt(n[2], 16),
|
|
308
|
-
parseInt(n[3], 16)
|
|
309
|
-
];
|
|
310
|
-
let r = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);
|
|
124
|
+
let r = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})[0-9a-f]{2}$/i.exec(e);
|
|
311
125
|
if (r) return [
|
|
312
|
-
parseInt(r[1]
|
|
313
|
-
parseInt(r[2]
|
|
314
|
-
parseInt(r[3]
|
|
126
|
+
parseInt(r[1], 16),
|
|
127
|
+
parseInt(r[2], 16),
|
|
128
|
+
parseInt(r[3], 16)
|
|
315
129
|
];
|
|
316
|
-
let i = /^#([0-9a-f])([0-9a-f])([0-9a-f])
|
|
130
|
+
let i = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);
|
|
317
131
|
if (i) return [
|
|
318
132
|
parseInt(i[1] + i[1], 16),
|
|
319
133
|
parseInt(i[2] + i[2], 16),
|
|
320
134
|
parseInt(i[3] + i[3], 16)
|
|
321
135
|
];
|
|
322
|
-
let a =
|
|
136
|
+
let a = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]$/i.exec(e);
|
|
323
137
|
if (a) return [
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
138
|
+
parseInt(a[1] + a[1], 16),
|
|
139
|
+
parseInt(a[2] + a[2], 16),
|
|
140
|
+
parseInt(a[3] + a[3], 16)
|
|
141
|
+
];
|
|
142
|
+
let o = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
143
|
+
if (o) return [
|
|
144
|
+
Number(o[1]),
|
|
145
|
+
Number(o[2]),
|
|
146
|
+
Number(o[3])
|
|
327
147
|
];
|
|
328
|
-
let
|
|
329
|
-
return
|
|
148
|
+
let s = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
149
|
+
return s ? n(Number(s[1]), Number(s[2]), Number(s[3])) : null;
|
|
330
150
|
}
|
|
331
|
-
var
|
|
332
|
-
function
|
|
151
|
+
var i = .1;
|
|
152
|
+
function a(e) {
|
|
333
153
|
let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.max(t, n, r), a = Math.min(t, n, r), o = (i + a) / 2;
|
|
334
154
|
if (i === a) return [
|
|
335
155
|
0,
|
|
@@ -343,38 +163,251 @@ function C(e) {
|
|
|
343
163
|
o
|
|
344
164
|
];
|
|
345
165
|
}
|
|
346
|
-
function
|
|
347
|
-
let n = e[1] <
|
|
166
|
+
function o(e, t) {
|
|
167
|
+
let n = e[1] < i, r = t[1] < i;
|
|
348
168
|
if (n && r) {
|
|
349
169
|
let n = Math.abs(e[2] - t[2]);
|
|
350
170
|
return n * n;
|
|
351
171
|
}
|
|
352
172
|
if (n !== r) return 1e3;
|
|
353
|
-
let
|
|
354
|
-
return 8 *
|
|
355
|
-
}
|
|
356
|
-
function
|
|
357
|
-
let
|
|
358
|
-
if (
|
|
359
|
-
let
|
|
360
|
-
return
|
|
361
|
-
let i =
|
|
173
|
+
let a = Math.abs(e[0] - t[0]), o = Math.min(a, 360 - a) / 180, s = Math.abs(e[1] - t[1]), c = Math.abs(e[2] - t[2]);
|
|
174
|
+
return 8 * o * o + 1 * s * s + 1 * c * c;
|
|
175
|
+
}
|
|
176
|
+
function s(t, n) {
|
|
177
|
+
let i = r(t);
|
|
178
|
+
if (i === null) return t;
|
|
179
|
+
let s = a(i);
|
|
180
|
+
return e.reduce((e, t) => {
|
|
181
|
+
let i = r(t[n]);
|
|
362
182
|
if (i === null) return e;
|
|
363
|
-
let
|
|
364
|
-
return
|
|
365
|
-
|
|
366
|
-
distance:
|
|
183
|
+
let c = o(s, a(i));
|
|
184
|
+
return c < e.distance ? {
|
|
185
|
+
color: t[n],
|
|
186
|
+
distance: c
|
|
187
|
+
} : e;
|
|
188
|
+
}, {
|
|
189
|
+
color: t,
|
|
190
|
+
distance: Infinity
|
|
191
|
+
}).color;
|
|
192
|
+
}
|
|
193
|
+
function c(n, i) {
|
|
194
|
+
let s = r(n);
|
|
195
|
+
if (s === null) return null;
|
|
196
|
+
let c = a(s);
|
|
197
|
+
return [...e, ...t].reduce((e, t) => {
|
|
198
|
+
let n = r(t[i]);
|
|
199
|
+
if (n === null) return e;
|
|
200
|
+
let s = o(c, a(n));
|
|
201
|
+
return e === null || s < e.distance ? {
|
|
202
|
+
name: t.name,
|
|
203
|
+
distance: s
|
|
367
204
|
} : e;
|
|
368
205
|
}, null)?.name ?? null;
|
|
369
206
|
}
|
|
370
207
|
//#endregion
|
|
371
|
-
//#region src/cli/commands/convert-html/
|
|
208
|
+
//#region src/cli/commands/convert-html/preprocessor.ts
|
|
209
|
+
function l(e) {
|
|
210
|
+
u(e), m(e), v(e), b(e), x(e), C(e);
|
|
211
|
+
}
|
|
212
|
+
function u(e) {
|
|
213
|
+
let t = e.ownerDocument;
|
|
214
|
+
for (let n of Array.from(e.querySelectorAll("div[style]"))) {
|
|
215
|
+
if (n.closest("table")) continue;
|
|
216
|
+
let e = _(n);
|
|
217
|
+
if (!e || h(e)) continue;
|
|
218
|
+
let r = t.createElement("aside");
|
|
219
|
+
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), d(r), f(r), n.replaceWith(r);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function d(e) {
|
|
223
|
+
for (;;) {
|
|
224
|
+
let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
|
|
225
|
+
if (t.length === 0) break;
|
|
226
|
+
for (let e of t) e.replaceWith(...Array.from(e.childNodes));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function f(e) {
|
|
230
|
+
for (let t of Array.from(e.querySelectorAll("p"))) {
|
|
231
|
+
let e = t.lastElementChild;
|
|
232
|
+
e?.tagName === "BR" && e.remove();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
var p = 250;
|
|
236
|
+
function m(e) {
|
|
237
|
+
let t = e.querySelectorAll("[style*=\"background-color\"]");
|
|
238
|
+
for (let e of Array.from(t)) h(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), g(e) && e.replaceWith(...Array.from(e.childNodes)));
|
|
239
|
+
}
|
|
240
|
+
function h(e) {
|
|
241
|
+
if (!e) return !1;
|
|
242
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
243
|
+
if (t === "transparent") return !0;
|
|
244
|
+
let n = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
|
|
245
|
+
if (!n) return !1;
|
|
246
|
+
if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
|
|
247
|
+
let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
|
|
248
|
+
return r >= p && i >= p && a >= p;
|
|
249
|
+
}
|
|
250
|
+
function g(e) {
|
|
251
|
+
return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
|
|
252
|
+
}
|
|
253
|
+
function _(e) {
|
|
254
|
+
if (e.style.backgroundColor) return e.style.backgroundColor;
|
|
255
|
+
let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
|
|
256
|
+
if (t) {
|
|
257
|
+
let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
|
|
258
|
+
if (e) return e[1];
|
|
259
|
+
}
|
|
260
|
+
return "";
|
|
261
|
+
}
|
|
262
|
+
function v(e) {
|
|
263
|
+
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
264
|
+
let e = t.querySelectorAll("p");
|
|
265
|
+
if (e.length !== 0) {
|
|
266
|
+
for (let t of Array.from(e)) y(t);
|
|
267
|
+
D(t);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function y(e) {
|
|
272
|
+
if (e.innerHTML.trim() === "" || e.innerHTML.trim() === " ") {
|
|
273
|
+
e.remove();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
let t = e.ownerDocument, n = t.createDocumentFragment();
|
|
277
|
+
n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
|
|
278
|
+
}
|
|
279
|
+
function b(e) {
|
|
280
|
+
for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || (t.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0 && t.remove();
|
|
281
|
+
}
|
|
282
|
+
function x(e) {
|
|
283
|
+
let t = e.ownerDocument;
|
|
284
|
+
for (let n of Array.from(e.querySelectorAll("del, strike"))) {
|
|
285
|
+
let e = t.createElement("s");
|
|
286
|
+
e.append(...Array.from(n.childNodes)), n.replaceWith(e);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
var S = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
|
|
290
|
+
function C(e) {
|
|
291
|
+
let t = e.ownerDocument, n = T(e);
|
|
292
|
+
for (let e of n) {
|
|
293
|
+
let n = t.createElement("ul");
|
|
294
|
+
e[0].before(n);
|
|
295
|
+
for (let t of e) w(t, n);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function w(e, t) {
|
|
299
|
+
let n = e.ownerDocument.createElement("li"), r = O(e);
|
|
300
|
+
r && (r.textContent = (r.textContent ?? "").replace(S, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
|
|
301
|
+
}
|
|
302
|
+
function T(e) {
|
|
303
|
+
let t = [], n = Array.from(e.childNodes);
|
|
304
|
+
for (let e of n) {
|
|
305
|
+
if (e.nodeType !== Node.ELEMENT_NODE) continue;
|
|
306
|
+
let n = e;
|
|
307
|
+
if (!(n.tagName === "P" && S.test(n.textContent ?? ""))) continue;
|
|
308
|
+
let r = t[t.length - 1], i = E(n);
|
|
309
|
+
r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
|
|
310
|
+
}
|
|
311
|
+
return t;
|
|
312
|
+
}
|
|
372
313
|
function E(e) {
|
|
373
|
-
let t =
|
|
374
|
-
|
|
314
|
+
let t = e.previousSibling;
|
|
315
|
+
return t && t.nodeType === Node.ELEMENT_NODE ? t : null;
|
|
316
|
+
}
|
|
317
|
+
function D(e) {
|
|
318
|
+
for (;;) {
|
|
319
|
+
let t = e.lastChild;
|
|
320
|
+
if (!t) break;
|
|
321
|
+
let n = t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR", r = t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "";
|
|
322
|
+
if (!n && !r) break;
|
|
323
|
+
t.remove();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function O(e) {
|
|
327
|
+
if (e.nodeType === Node.TEXT_NODE) return e;
|
|
328
|
+
for (let t of Array.from(e.childNodes)) {
|
|
329
|
+
let e = O(t);
|
|
330
|
+
if (e) return e;
|
|
331
|
+
}
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/cli/commands/convert-html/sanitizer.ts
|
|
336
|
+
var k = {
|
|
337
|
+
B: !0,
|
|
338
|
+
STRONG: !0,
|
|
339
|
+
I: !0,
|
|
340
|
+
EM: !0,
|
|
341
|
+
A: new Set(["href"]),
|
|
342
|
+
S: !0,
|
|
343
|
+
U: !0,
|
|
344
|
+
CODE: !0,
|
|
345
|
+
MARK: new Set(["style"]),
|
|
346
|
+
BR: !0,
|
|
347
|
+
P: !0,
|
|
348
|
+
H1: !0,
|
|
349
|
+
H2: !0,
|
|
350
|
+
H3: !0,
|
|
351
|
+
H4: !0,
|
|
352
|
+
H5: !0,
|
|
353
|
+
H6: !0,
|
|
354
|
+
UL: !0,
|
|
355
|
+
OL: !0,
|
|
356
|
+
LI: new Set(["aria-level"]),
|
|
357
|
+
TABLE: !0,
|
|
358
|
+
THEAD: !0,
|
|
359
|
+
TBODY: !0,
|
|
360
|
+
TR: !0,
|
|
361
|
+
TD: new Set(["style"]),
|
|
362
|
+
TH: new Set(["style"]),
|
|
363
|
+
BLOCKQUOTE: !0,
|
|
364
|
+
PRE: !0,
|
|
365
|
+
HR: !0,
|
|
366
|
+
ASIDE: new Set(["style"]),
|
|
367
|
+
DETAILS: !0,
|
|
368
|
+
SUMMARY: !0,
|
|
369
|
+
IMG: new Set(["src", "style"])
|
|
370
|
+
};
|
|
371
|
+
function A(e) {
|
|
372
|
+
N(e);
|
|
373
|
+
}
|
|
374
|
+
function j(e) {
|
|
375
|
+
let t = Array.from(e.childNodes);
|
|
376
|
+
for (let n of t) e.before(n);
|
|
377
|
+
return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
|
|
378
|
+
}
|
|
379
|
+
function M(e, t) {
|
|
380
|
+
for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
|
|
381
|
+
}
|
|
382
|
+
function N(e) {
|
|
383
|
+
let t = Array.from(e.childNodes);
|
|
384
|
+
for (let e of t) {
|
|
385
|
+
if (e.nodeType !== e.ELEMENT_NODE) continue;
|
|
386
|
+
let n = e, r = k[n.tagName];
|
|
387
|
+
if (r === void 0) {
|
|
388
|
+
t.push(...j(n));
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
M(n, r), N(n);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/cli/commands/convert-html/id-generator.ts
|
|
396
|
+
function P() {
|
|
397
|
+
let e = /* @__PURE__ */ new Map();
|
|
398
|
+
return (t) => {
|
|
399
|
+
let n = (e.get(t) ?? 0) + 1;
|
|
400
|
+
return e.set(t, n), `${t}-${n}`;
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/cli/commands/convert-html/block-builder.ts
|
|
405
|
+
function F(e) {
|
|
406
|
+
let t = P(), n = [];
|
|
407
|
+
for (let r of Array.from(e.childNodes)) I(r, n, t);
|
|
375
408
|
return n;
|
|
376
409
|
}
|
|
377
|
-
function
|
|
410
|
+
function I(e, t, n) {
|
|
378
411
|
if (e.nodeType === Node.TEXT_NODE) {
|
|
379
412
|
let r = e.textContent?.trim() ?? "";
|
|
380
413
|
r && t.push({
|
|
@@ -437,18 +470,14 @@ function D(e, t, n) {
|
|
|
437
470
|
return;
|
|
438
471
|
}
|
|
439
472
|
if (i === "IMG") {
|
|
440
|
-
let e = r.getAttribute("src") ?? "", i =
|
|
441
|
-
if (i) {
|
|
442
|
-
let e = parseInt(i, 10);
|
|
443
|
-
isNaN(e) || (a = e);
|
|
444
|
-
}
|
|
473
|
+
let e = r.getAttribute("src") ?? "", i = H(r, "width");
|
|
445
474
|
t.push({
|
|
446
475
|
id: n("image"),
|
|
447
476
|
type: "image",
|
|
448
477
|
data: { url: e },
|
|
449
478
|
stretched: null,
|
|
450
479
|
key: null,
|
|
451
|
-
width:
|
|
480
|
+
width: i
|
|
452
481
|
});
|
|
453
482
|
return;
|
|
454
483
|
}
|
|
@@ -462,15 +491,15 @@ function D(e, t, n) {
|
|
|
462
491
|
return;
|
|
463
492
|
}
|
|
464
493
|
if (i === "UL" || i === "OL") {
|
|
465
|
-
|
|
494
|
+
L(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
|
|
466
495
|
return;
|
|
467
496
|
}
|
|
468
497
|
if (i === "TABLE") {
|
|
469
|
-
|
|
498
|
+
R(r, t, n);
|
|
470
499
|
return;
|
|
471
500
|
}
|
|
472
501
|
if (i === "ASIDE") {
|
|
473
|
-
|
|
502
|
+
z(r, t, n);
|
|
474
503
|
return;
|
|
475
504
|
}
|
|
476
505
|
t.push({
|
|
@@ -479,14 +508,13 @@ function D(e, t, n) {
|
|
|
479
508
|
data: { text: r.innerHTML }
|
|
480
509
|
});
|
|
481
510
|
}
|
|
482
|
-
function
|
|
483
|
-
let a = e.getAttribute("start"), o = a ? Number(a) : null, s =
|
|
484
|
-
for (let a of
|
|
485
|
-
|
|
486
|
-
let e
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
u && (d = Math.max(0, parseInt(u, 10) - 1)), r.push({
|
|
511
|
+
function L(e, t, n, r, i) {
|
|
512
|
+
let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
|
|
513
|
+
for (let [e, a] of s.entries()) {
|
|
514
|
+
let s = a.cloneNode(!0), c = [];
|
|
515
|
+
for (let e of Array.from(s.querySelectorAll("ul, ol"))) c.push(e.cloneNode(!0)), e.remove();
|
|
516
|
+
let l = s.innerHTML.trim(), u = a.getAttribute("aria-level"), d = u ? Math.max(0, parseInt(u, 10) - 1) : n;
|
|
517
|
+
r.push({
|
|
490
518
|
id: i("list"),
|
|
491
519
|
type: "list",
|
|
492
520
|
data: {
|
|
@@ -494,84 +522,44 @@ function O(e, t, n, r, i) {
|
|
|
494
522
|
style: t,
|
|
495
523
|
depth: d === 0 ? null : d,
|
|
496
524
|
checked: null,
|
|
497
|
-
start:
|
|
525
|
+
start: e === 0 && o !== null ? o : null
|
|
498
526
|
}
|
|
499
|
-
})
|
|
500
|
-
for (let e of c)
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
function k(e, t, n) {
|
|
504
|
-
let r = n("table"), i = Array.from(e.querySelectorAll("tr")), a = !1, o = [];
|
|
505
|
-
for (let e = 0; e < i.length; e++) {
|
|
506
|
-
let s = i[e], c = Array.from(s.querySelectorAll("td, th"));
|
|
507
|
-
e === 0 && c.some((e) => e.tagName === "TH") && (a = !0);
|
|
508
|
-
let l = [];
|
|
509
|
-
for (let e of c) {
|
|
510
|
-
let i = e, a = i.innerHTML.trim();
|
|
511
|
-
if (a) {
|
|
512
|
-
let e = n("paragraph");
|
|
513
|
-
t.push({
|
|
514
|
-
id: e,
|
|
515
|
-
type: "paragraph",
|
|
516
|
-
parent: r,
|
|
517
|
-
data: { text: a }
|
|
518
|
-
});
|
|
519
|
-
let o = j(i, "background-color"), s = j(i, "color");
|
|
520
|
-
l.push({
|
|
521
|
-
blocks: [e],
|
|
522
|
-
color: o ? T(o, "bg") : null,
|
|
523
|
-
textColor: s ? T(s, "text") : null
|
|
524
|
-
});
|
|
525
|
-
} else l.push({
|
|
526
|
-
blocks: [],
|
|
527
|
-
color: null,
|
|
528
|
-
textColor: null
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
o.push(l);
|
|
527
|
+
});
|
|
528
|
+
for (let e of c) L(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
|
|
532
529
|
}
|
|
533
|
-
|
|
534
|
-
|
|
530
|
+
}
|
|
531
|
+
function R(e, t, n) {
|
|
532
|
+
let r = n("table"), i = Array.from(e.querySelectorAll("tr")), a = [];
|
|
533
|
+
for (let e of i) {
|
|
534
|
+
let i = Array.from(e.querySelectorAll("td, th")).map((e) => B(e, r, t, n));
|
|
535
|
+
a.push(i);
|
|
536
|
+
}
|
|
537
|
+
let o = i[0] ? Array.from(i[0].querySelectorAll("td, th")) : [], s = o.some((e) => e.tagName === "TH"), c = o.map((e) => {
|
|
538
|
+
let t = U(e, "width");
|
|
535
539
|
if (t) {
|
|
536
540
|
let e = parseInt(t, 10);
|
|
537
541
|
return isNaN(e) ? null : e;
|
|
538
542
|
}
|
|
539
543
|
return null;
|
|
540
|
-
}),
|
|
544
|
+
}), l = {
|
|
541
545
|
id: r,
|
|
542
546
|
type: "table",
|
|
543
547
|
data: {
|
|
544
|
-
withHeadings:
|
|
548
|
+
withHeadings: s,
|
|
545
549
|
withHeadingColumn: !1,
|
|
546
|
-
content:
|
|
547
|
-
...c ? { colWidths:
|
|
550
|
+
content: a,
|
|
551
|
+
...c.some((e) => e !== null) ? { colWidths: c } : {}
|
|
548
552
|
}
|
|
549
553
|
}, u = t.findIndex((e) => e.parent === r);
|
|
550
554
|
u >= 0 ? t.splice(u, 0, l) : t.push(l);
|
|
551
555
|
}
|
|
552
|
-
function
|
|
553
|
-
let r = n("callout"), i =
|
|
554
|
-
for (let i of Array.from(e.childNodes))
|
|
555
|
-
let e = i,
|
|
556
|
-
|
|
557
|
-
id: a,
|
|
558
|
-
type: "paragraph",
|
|
559
|
-
parent: r,
|
|
560
|
-
data: { text: e.innerHTML }
|
|
561
|
-
}), o.push(a);
|
|
562
|
-
} else if (i.nodeType === Node.TEXT_NODE) {
|
|
563
|
-
let e = i.textContent?.trim() ?? "";
|
|
564
|
-
if (e) {
|
|
565
|
-
let i = n("paragraph");
|
|
566
|
-
t.push({
|
|
567
|
-
id: i,
|
|
568
|
-
type: "paragraph",
|
|
569
|
-
parent: r,
|
|
570
|
-
data: { text: e }
|
|
571
|
-
}), o.push(i);
|
|
572
|
-
}
|
|
556
|
+
function z(e, t, n) {
|
|
557
|
+
let r = n("callout"), i = U(e, "background-color"), a = i ? c(i, "bg") : null, o = [];
|
|
558
|
+
for (let i of Array.from(e.childNodes)) {
|
|
559
|
+
let e = V(i, r, t, n);
|
|
560
|
+
e && o.push(e);
|
|
573
561
|
}
|
|
574
|
-
let s = t.findIndex((e) => e.parent === r),
|
|
562
|
+
let s = t.findIndex((e) => e.parent === r), l = {
|
|
575
563
|
id: r,
|
|
576
564
|
type: "callout",
|
|
577
565
|
data: {
|
|
@@ -580,24 +568,63 @@ function A(e, t, n) {
|
|
|
580
568
|
},
|
|
581
569
|
content: o
|
|
582
570
|
};
|
|
583
|
-
s >= 0 ? t.splice(s, 0,
|
|
571
|
+
s >= 0 ? t.splice(s, 0, l) : t.push(l);
|
|
584
572
|
}
|
|
585
|
-
function
|
|
573
|
+
function B(e, t, n, r) {
|
|
574
|
+
let i = e.innerHTML.trim();
|
|
575
|
+
if (!i) return {
|
|
576
|
+
blocks: [],
|
|
577
|
+
color: null,
|
|
578
|
+
textColor: null
|
|
579
|
+
};
|
|
580
|
+
let a = r("paragraph");
|
|
581
|
+
n.push({
|
|
582
|
+
id: a,
|
|
583
|
+
type: "paragraph",
|
|
584
|
+
parent: t,
|
|
585
|
+
data: { text: i }
|
|
586
|
+
});
|
|
587
|
+
let o = U(e, "background-color"), s = U(e, "color");
|
|
588
|
+
return {
|
|
589
|
+
blocks: [a],
|
|
590
|
+
color: o ? c(o, "bg") : null,
|
|
591
|
+
textColor: s ? c(s, "text") : null
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function V(e, t, n, r) {
|
|
595
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
596
|
+
let i = e, a = r("paragraph");
|
|
597
|
+
return n.push({
|
|
598
|
+
id: a,
|
|
599
|
+
type: "paragraph",
|
|
600
|
+
parent: t,
|
|
601
|
+
data: { text: i.innerHTML }
|
|
602
|
+
}), a;
|
|
603
|
+
}
|
|
604
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
605
|
+
let i = e.textContent?.trim() ?? "";
|
|
606
|
+
if (!i) return null;
|
|
607
|
+
let a = r("paragraph");
|
|
608
|
+
return n.push({
|
|
609
|
+
id: a,
|
|
610
|
+
type: "paragraph",
|
|
611
|
+
parent: t,
|
|
612
|
+
data: { text: i }
|
|
613
|
+
}), a;
|
|
614
|
+
}
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
function H(e, t) {
|
|
618
|
+
let n = U(e, t);
|
|
619
|
+
if (!n) return null;
|
|
620
|
+
let r = parseInt(n, 10);
|
|
621
|
+
return isNaN(r) ? null : r;
|
|
622
|
+
}
|
|
623
|
+
function U(e, t) {
|
|
586
624
|
let n = e.getAttribute("style");
|
|
587
625
|
if (!n) return null;
|
|
588
626
|
let r = RegExp(`(?<![\\-a-z])${t}\\s*:\\s*([^;]+)`).exec(n);
|
|
589
627
|
return r ? r[1].trim() : null;
|
|
590
628
|
}
|
|
591
629
|
//#endregion
|
|
592
|
-
|
|
593
|
-
function M(t) {
|
|
594
|
-
let n = new DOMParser().parseFromString(t, "text/html").body;
|
|
595
|
-
e(n), h(n);
|
|
596
|
-
let r = {
|
|
597
|
-
version: "2.31.0",
|
|
598
|
-
blocks: E(n)
|
|
599
|
-
};
|
|
600
|
-
return JSON.stringify(r);
|
|
601
|
-
}
|
|
602
|
-
//#endregion
|
|
603
|
-
export { M as convertHtml };
|
|
630
|
+
export { s as i, A as n, l as r, F as t };
|
package/dist/cli.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var t = "# Migrating from EditorJS to Blok\n\nThis guide covers the breaking cha
|
|
|
11
11
|
""
|
|
12
12
|
].join("\n") + t, r = (t, n) => {
|
|
13
13
|
n ? (e.writeFileSync(n, t, "utf-8"), process.stderr.write(`Written to ${n}\n`)) : process.stdout.write(t);
|
|
14
|
-
}, i = "Usage: blok-cli [options]\n\nOptions:\n --convert-html Convert legacy HTML from stdin to Blok JSON (stdout)\n --migration Output the EditorJS to Blok migration guide (LLM-friendly)\n --output <file> Write output to a file instead of stdout\n --help Show this help message\n\nExamples:\n npx @jackuait/blok-cli --convert-html < article.html\n npx @jackuait/blok-cli --convert-html < article.html --output article.json\n npx @jackuait/blok-cli --migration\n npx @jackuait/blok-cli --migration | pbcopy\n npx @jackuait/blok-cli --migration --output migration-guide.md\n", a = (e) => {
|
|
14
|
+
}, i = "Usage: blok-cli [options]\n\nOptions:\n --convert-html Convert legacy HTML from stdin to Blok JSON (stdout)\n --convert-gdocs Convert Google Docs HTML from stdin to Blok JSON (stdout)\n --migration Output the EditorJS to Blok migration guide (LLM-friendly)\n --output <file> Write output to a file instead of stdout\n --help Show this help message\n\nExamples:\n npx @jackuait/blok-cli --convert-html < article.html\n npx @jackuait/blok-cli --convert-html < article.html --output article.json\n npx @jackuait/blok-cli --convert-gdocs < gdocs-export.html\n npx @jackuait/blok-cli --convert-gdocs < gdocs-export.html --output doc.json\n npx @jackuait/blok-cli --migration\n npx @jackuait/blok-cli --migration | pbcopy\n npx @jackuait/blok-cli --migration --output migration-guide.md\n", a = (e) => {
|
|
15
15
|
if (e.includes("--help")) return { command: "help" };
|
|
16
16
|
if (e.includes("--convert-html")) {
|
|
17
17
|
let t = e.indexOf("--output");
|
|
@@ -20,6 +20,13 @@ var t = "# Migrating from EditorJS to Blok\n\nThis guide covers the breaking cha
|
|
|
20
20
|
output: t === -1 ? void 0 : e[t + 1]
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
if (e.includes("--convert-gdocs")) {
|
|
24
|
+
let t = e.indexOf("--output");
|
|
25
|
+
return {
|
|
26
|
+
command: "convert-gdocs",
|
|
27
|
+
output: t === -1 ? void 0 : e[t + 1]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
23
30
|
if (e.includes("--migration")) {
|
|
24
31
|
let t = e.indexOf("--output");
|
|
25
32
|
return {
|
|
@@ -34,7 +41,14 @@ var t = "# Migrating from EditorJS to Blok\n\nThis guide covers the breaking cha
|
|
|
34
41
|
case "convert-html": {
|
|
35
42
|
let e = new (await (import("jsdom"))).JSDOM("");
|
|
36
43
|
globalThis.DOMParser = e.window.DOMParser, globalThis.Node = e.window.Node;
|
|
37
|
-
let { convertHtml: t } = await import("./convert-html-
|
|
44
|
+
let { convertHtml: t } = await import("./convert-html-C0OO15ZO.mjs");
|
|
45
|
+
r(t((await import("node:fs")).readFileSync("/dev/stdin", "utf-8")), s);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "convert-gdocs": {
|
|
49
|
+
let e = new (await (import("jsdom"))).JSDOM("");
|
|
50
|
+
globalThis.DOMParser = e.window.DOMParser, globalThis.Node = e.window.Node, globalThis.document = e.window.document;
|
|
51
|
+
let { convertGdocs: t } = await import("./convert-gdocs-DjfegUKM.mjs");
|
|
38
52
|
r(t((await import("node:fs")).readFileSync("/dev/stdin", "utf-8")), s);
|
|
39
53
|
break;
|
|
40
54
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
3
|
+
function i(e) {
|
|
4
|
+
let t = document.createElement("div");
|
|
5
|
+
t.innerHTML = e;
|
|
6
|
+
let n = a(t);
|
|
7
|
+
return m(t, n), n && g(t), t.innerHTML;
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
11
|
+
if (!t) return !1;
|
|
12
|
+
let n = document.createDocumentFragment();
|
|
13
|
+
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
14
|
+
return t.replaceWith(n), !0;
|
|
15
|
+
}
|
|
16
|
+
function o(e, t, n) {
|
|
17
|
+
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
18
|
+
}
|
|
19
|
+
function s(e) {
|
|
20
|
+
let t = e.replace(/\s/g, "");
|
|
21
|
+
return t === "rgb(0,0,0)" || t === "#000000";
|
|
22
|
+
}
|
|
23
|
+
function c(e) {
|
|
24
|
+
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgb\((\d+),(\d+),(\d+)\)$/.exec(t);
|
|
25
|
+
if (n) {
|
|
26
|
+
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
27
|
+
return .2126 * e + .7152 * t + .0722 * r;
|
|
28
|
+
}
|
|
29
|
+
let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
30
|
+
if (r) {
|
|
31
|
+
let e = r[1], t = e.length === 3 ? [
|
|
32
|
+
e[0] + e[0],
|
|
33
|
+
e[1] + e[1],
|
|
34
|
+
e[2] + e[2]
|
|
35
|
+
] : [
|
|
36
|
+
e.substring(0, 2),
|
|
37
|
+
e.substring(2, 4),
|
|
38
|
+
e.substring(4, 6)
|
|
39
|
+
], n = parseInt(t[0], 16) / 255, i = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
40
|
+
return .2126 * n + .7152 * i + .0722 * a;
|
|
41
|
+
}
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
function l(e) {
|
|
45
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
46
|
+
return t === "rgb(255,255,255)" || t === "#ffffff" || t === "white";
|
|
47
|
+
}
|
|
48
|
+
function u(e) {
|
|
49
|
+
let t = c(e);
|
|
50
|
+
return t >= 0 && t < .12;
|
|
51
|
+
}
|
|
52
|
+
function d(e) {
|
|
53
|
+
return c(e) > .75;
|
|
54
|
+
}
|
|
55
|
+
function f(t, n, r, i, a) {
|
|
56
|
+
if (!n && !r) return t;
|
|
57
|
+
let s = n && i !== void 0 ? e(i, "text") : "", c = r && a !== void 0 ? e(a, "bg") : "", l = [n ? `color: ${s}` : "", o(r, n, c)].filter(Boolean).join("; ");
|
|
58
|
+
return l ? `<mark style="${l};">${t}</mark>` : t;
|
|
59
|
+
}
|
|
60
|
+
function p(e, t) {
|
|
61
|
+
let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n), 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(), p = o?.[1]?.trim(), m = t ? c !== void 0 && !s(c) : c !== void 0 && !s(c) && !d(c), h = t ? p !== void 0 && p !== "transparent" : p !== void 0 && p !== "transparent" && !l(p) && !u(p);
|
|
62
|
+
if (!r && !i && !m && !h) return null;
|
|
63
|
+
let g = f(e.innerHTML, m, h, c, p), _ = i ? `<i>${g}</i>` : g;
|
|
64
|
+
return r ? `<b>${_}</b>` : _;
|
|
65
|
+
}
|
|
66
|
+
function m(e, t) {
|
|
67
|
+
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
68
|
+
let e = p(n, t);
|
|
69
|
+
e !== null && n.replaceWith(document.createRange().createContextualFragment(e));
|
|
70
|
+
}
|
|
71
|
+
t && h(e);
|
|
72
|
+
}
|
|
73
|
+
function h(t) {
|
|
74
|
+
for (let n of Array.from(t.querySelectorAll("a[style]"))) {
|
|
75
|
+
let t = n.getAttribute("style") ?? "", r = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(t), i = /background-color\s*:\s*([^;]+)/i.exec(t), a = r?.[1]?.trim(), c = i?.[1]?.trim(), l = a !== void 0 && !s(a) && a !== "inherit", u = c !== void 0 && c !== "transparent" && c !== "inherit";
|
|
76
|
+
if (!l && !u) continue;
|
|
77
|
+
let d = l ? e(a, "text") : "", f = u ? e(c, "bg") : "", p = [l ? `color: ${d}` : "", o(u, l, f)].filter(Boolean).join("; "), m = n;
|
|
78
|
+
m.innerHTML = `<mark style="${p};">${m.innerHTML}</mark>`, m.style.removeProperty("color"), m.style.removeProperty("background-color");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function g(e) {
|
|
82
|
+
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
83
|
+
let e = t.querySelectorAll("p");
|
|
84
|
+
if (e.length !== 0) {
|
|
85
|
+
for (let t of Array.from(e)) {
|
|
86
|
+
let e = document.createRange().createContextualFragment(t.innerHTML + "<br>");
|
|
87
|
+
t.replaceWith(e);
|
|
88
|
+
}
|
|
89
|
+
t.innerHTML = t.innerHTML.replace(/(<br\s*\/?>|\s)+$/i, "");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/cli/commands/convert-gdocs/index.ts
|
|
95
|
+
function _(e) {
|
|
96
|
+
let a = i(e), o = new DOMParser().parseFromString(a, "text/html").body;
|
|
97
|
+
n(o), t(o);
|
|
98
|
+
let s = {
|
|
99
|
+
version: "0.10.0-beta.16",
|
|
100
|
+
blocks: r(o)
|
|
101
|
+
};
|
|
102
|
+
return JSON.stringify(s);
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { _ as convertGdocs };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
3
|
+
function i(e) {
|
|
4
|
+
let t = document.createElement("div");
|
|
5
|
+
t.innerHTML = e;
|
|
6
|
+
let n = a(t);
|
|
7
|
+
return m(t, n), n && g(t), t.innerHTML;
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
11
|
+
if (!t) return !1;
|
|
12
|
+
let n = document.createDocumentFragment();
|
|
13
|
+
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
14
|
+
return t.replaceWith(n), !0;
|
|
15
|
+
}
|
|
16
|
+
function o(e, t, n) {
|
|
17
|
+
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
18
|
+
}
|
|
19
|
+
function s(e) {
|
|
20
|
+
let t = e.replace(/\s/g, "");
|
|
21
|
+
return t === "rgb(0,0,0)" || t === "#000000";
|
|
22
|
+
}
|
|
23
|
+
function c(e) {
|
|
24
|
+
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgb\((\d+),(\d+),(\d+)\)$/.exec(t);
|
|
25
|
+
if (n) {
|
|
26
|
+
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
27
|
+
return .2126 * e + .7152 * t + .0722 * r;
|
|
28
|
+
}
|
|
29
|
+
let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
30
|
+
if (r) {
|
|
31
|
+
let e = r[1], t = e.length === 3 ? [
|
|
32
|
+
e[0] + e[0],
|
|
33
|
+
e[1] + e[1],
|
|
34
|
+
e[2] + e[2]
|
|
35
|
+
] : [
|
|
36
|
+
e.substring(0, 2),
|
|
37
|
+
e.substring(2, 4),
|
|
38
|
+
e.substring(4, 6)
|
|
39
|
+
], n = parseInt(t[0], 16) / 255, i = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
40
|
+
return .2126 * n + .7152 * i + .0722 * a;
|
|
41
|
+
}
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
function l(e) {
|
|
45
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
46
|
+
return t === "rgb(255,255,255)" || t === "#ffffff" || t === "white";
|
|
47
|
+
}
|
|
48
|
+
function u(e) {
|
|
49
|
+
let t = c(e);
|
|
50
|
+
return t >= 0 && t < .12;
|
|
51
|
+
}
|
|
52
|
+
function d(e) {
|
|
53
|
+
return c(e) > .75;
|
|
54
|
+
}
|
|
55
|
+
function f(t, n, r, i, a) {
|
|
56
|
+
if (!n && !r) return t;
|
|
57
|
+
let s = n && i !== void 0 ? e(i, "text") : "", c = r && a !== void 0 ? e(a, "bg") : "", l = [n ? `color: ${s}` : "", o(r, n, c)].filter(Boolean).join("; ");
|
|
58
|
+
return l ? `<mark style="${l};">${t}</mark>` : t;
|
|
59
|
+
}
|
|
60
|
+
function p(e, t) {
|
|
61
|
+
let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n), 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(), p = o?.[1]?.trim(), m = t ? c !== void 0 && !s(c) : c !== void 0 && !s(c) && !d(c), h = t ? p !== void 0 && p !== "transparent" : p !== void 0 && p !== "transparent" && !l(p) && !u(p);
|
|
62
|
+
if (!r && !i && !m && !h) return null;
|
|
63
|
+
let g = f(e.innerHTML, m, h, c, p), _ = i ? `<i>${g}</i>` : g;
|
|
64
|
+
return r ? `<b>${_}</b>` : _;
|
|
65
|
+
}
|
|
66
|
+
function m(e, t) {
|
|
67
|
+
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
68
|
+
let e = p(n, t);
|
|
69
|
+
e !== null && n.replaceWith(document.createRange().createContextualFragment(e));
|
|
70
|
+
}
|
|
71
|
+
t && h(e);
|
|
72
|
+
}
|
|
73
|
+
function h(t) {
|
|
74
|
+
for (let n of Array.from(t.querySelectorAll("a[style]"))) {
|
|
75
|
+
let t = n.getAttribute("style") ?? "", r = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(t), i = /background-color\s*:\s*([^;]+)/i.exec(t), a = r?.[1]?.trim(), c = i?.[1]?.trim(), l = a !== void 0 && !s(a) && a !== "inherit", u = c !== void 0 && c !== "transparent" && c !== "inherit";
|
|
76
|
+
if (!l && !u) continue;
|
|
77
|
+
let d = l ? e(a, "text") : "", f = u ? e(c, "bg") : "", p = [l ? `color: ${d}` : "", o(u, l, f)].filter(Boolean).join("; "), m = n;
|
|
78
|
+
m.innerHTML = `<mark style="${p};">${m.innerHTML}</mark>`, m.style.removeProperty("color"), m.style.removeProperty("background-color");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function g(e) {
|
|
82
|
+
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
83
|
+
let e = t.querySelectorAll("p");
|
|
84
|
+
if (e.length !== 0) {
|
|
85
|
+
for (let t of Array.from(e)) {
|
|
86
|
+
let e = document.createRange().createContextualFragment(t.innerHTML + "<br>");
|
|
87
|
+
t.replaceWith(e);
|
|
88
|
+
}
|
|
89
|
+
t.innerHTML = t.innerHTML.replace(/(<br\s*\/?>|\s)+$/i, "");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/cli/commands/convert-gdocs/index.ts
|
|
95
|
+
function _(e) {
|
|
96
|
+
let a = i(e), o = new DOMParser().parseFromString(a, "text/html").body;
|
|
97
|
+
n(o), t(o);
|
|
98
|
+
let s = {
|
|
99
|
+
version: "0.10.0-beta.17",
|
|
100
|
+
blocks: r(o)
|
|
101
|
+
};
|
|
102
|
+
return JSON.stringify(s);
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { _ as convertGdocs };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
3
|
+
function i(e) {
|
|
4
|
+
let t = document.createElement("div");
|
|
5
|
+
t.innerHTML = e;
|
|
6
|
+
let n = a(t);
|
|
7
|
+
return m(t, n), n && g(t), t.innerHTML;
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
11
|
+
if (!t) return !1;
|
|
12
|
+
let n = document.createDocumentFragment();
|
|
13
|
+
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
14
|
+
return t.replaceWith(n), !0;
|
|
15
|
+
}
|
|
16
|
+
function o(e, t, n) {
|
|
17
|
+
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
18
|
+
}
|
|
19
|
+
function s(e) {
|
|
20
|
+
let t = e.replace(/\s/g, "");
|
|
21
|
+
return t === "rgb(0,0,0)" || t === "#000000";
|
|
22
|
+
}
|
|
23
|
+
function c(e) {
|
|
24
|
+
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgb\((\d+),(\d+),(\d+)\)$/.exec(t);
|
|
25
|
+
if (n) {
|
|
26
|
+
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
27
|
+
return .2126 * e + .7152 * t + .0722 * r;
|
|
28
|
+
}
|
|
29
|
+
let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
30
|
+
if (r) {
|
|
31
|
+
let e = r[1], t = e.length === 3 ? [
|
|
32
|
+
e[0] + e[0],
|
|
33
|
+
e[1] + e[1],
|
|
34
|
+
e[2] + e[2]
|
|
35
|
+
] : [
|
|
36
|
+
e.substring(0, 2),
|
|
37
|
+
e.substring(2, 4),
|
|
38
|
+
e.substring(4, 6)
|
|
39
|
+
], n = parseInt(t[0], 16) / 255, i = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
40
|
+
return .2126 * n + .7152 * i + .0722 * a;
|
|
41
|
+
}
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
function l(e) {
|
|
45
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
46
|
+
return t === "rgb(255,255,255)" || t === "#ffffff" || t === "white";
|
|
47
|
+
}
|
|
48
|
+
function u(e) {
|
|
49
|
+
let t = c(e);
|
|
50
|
+
return t >= 0 && t < .12;
|
|
51
|
+
}
|
|
52
|
+
function d(e) {
|
|
53
|
+
return c(e) > .75;
|
|
54
|
+
}
|
|
55
|
+
function f(t, n, r, i, a) {
|
|
56
|
+
if (!n && !r) return t;
|
|
57
|
+
let s = n && i !== void 0 ? e(i, "text") : "", c = r && a !== void 0 ? e(a, "bg") : "", l = [n ? `color: ${s}` : "", o(r, n, c)].filter(Boolean).join("; ");
|
|
58
|
+
return l ? `<mark style="${l};">${t}</mark>` : t;
|
|
59
|
+
}
|
|
60
|
+
function p(e, t) {
|
|
61
|
+
let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n), 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(), p = o?.[1]?.trim(), m = t ? c !== void 0 && !s(c) : c !== void 0 && !s(c) && !d(c), h = t ? p !== void 0 && p !== "transparent" : p !== void 0 && p !== "transparent" && !l(p) && !u(p);
|
|
62
|
+
if (!r && !i && !m && !h) return null;
|
|
63
|
+
let g = f(e.innerHTML, m, h, c, p), _ = i ? `<i>${g}</i>` : g;
|
|
64
|
+
return r ? `<b>${_}</b>` : _;
|
|
65
|
+
}
|
|
66
|
+
function m(e, t) {
|
|
67
|
+
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
68
|
+
let e = p(n, t);
|
|
69
|
+
e !== null && n.replaceWith(document.createRange().createContextualFragment(e));
|
|
70
|
+
}
|
|
71
|
+
t && h(e);
|
|
72
|
+
}
|
|
73
|
+
function h(t) {
|
|
74
|
+
for (let n of Array.from(t.querySelectorAll("a[style]"))) {
|
|
75
|
+
let t = n.getAttribute("style") ?? "", r = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(t), i = /background-color\s*:\s*([^;]+)/i.exec(t), a = r?.[1]?.trim(), c = i?.[1]?.trim(), l = a !== void 0 && !s(a) && a !== "inherit", u = c !== void 0 && c !== "transparent" && c !== "inherit";
|
|
76
|
+
if (!l && !u) continue;
|
|
77
|
+
let d = l ? e(a, "text") : "", f = u ? e(c, "bg") : "", p = [l ? `color: ${d}` : "", o(u, l, f)].filter(Boolean).join("; "), m = n;
|
|
78
|
+
m.innerHTML = `<mark style="${p};">${m.innerHTML}</mark>`, m.style.removeProperty("color"), m.style.removeProperty("background-color");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function g(e) {
|
|
82
|
+
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
83
|
+
let e = t.querySelectorAll("p");
|
|
84
|
+
if (e.length !== 0) {
|
|
85
|
+
for (let t of Array.from(e)) {
|
|
86
|
+
let e = document.createRange().createContextualFragment(t.innerHTML + "<br>");
|
|
87
|
+
t.replaceWith(e);
|
|
88
|
+
}
|
|
89
|
+
t.innerHTML = t.innerHTML.replace(/(<br\s*\/?>|\s)+$/i, "");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/cli/commands/convert-gdocs/index.ts
|
|
95
|
+
function _(e) {
|
|
96
|
+
let a = i(e), o = new DOMParser().parseFromString(a, "text/html").body;
|
|
97
|
+
n(o), t(o);
|
|
98
|
+
let s = {
|
|
99
|
+
version: "0.10.0-beta.19",
|
|
100
|
+
blocks: r(o)
|
|
101
|
+
};
|
|
102
|
+
return JSON.stringify(s);
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { _ as convertGdocs };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
3
|
+
function i(e) {
|
|
4
|
+
let t = document.createElement("div");
|
|
5
|
+
t.innerHTML = e;
|
|
6
|
+
let n = a(t);
|
|
7
|
+
return m(t, n), n && g(t), t.innerHTML;
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
11
|
+
if (!t) return !1;
|
|
12
|
+
let n = document.createDocumentFragment();
|
|
13
|
+
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
14
|
+
return t.replaceWith(n), !0;
|
|
15
|
+
}
|
|
16
|
+
function o(e, t, n) {
|
|
17
|
+
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
18
|
+
}
|
|
19
|
+
function s(e) {
|
|
20
|
+
let t = e.replace(/\s/g, "");
|
|
21
|
+
return t === "rgb(0,0,0)" || t === "#000000";
|
|
22
|
+
}
|
|
23
|
+
function c(e) {
|
|
24
|
+
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgb\((\d+),(\d+),(\d+)\)$/.exec(t);
|
|
25
|
+
if (n) {
|
|
26
|
+
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
27
|
+
return .2126 * e + .7152 * t + .0722 * r;
|
|
28
|
+
}
|
|
29
|
+
let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
30
|
+
if (r) {
|
|
31
|
+
let e = r[1], t = e.length === 3 ? [
|
|
32
|
+
e[0] + e[0],
|
|
33
|
+
e[1] + e[1],
|
|
34
|
+
e[2] + e[2]
|
|
35
|
+
] : [
|
|
36
|
+
e.substring(0, 2),
|
|
37
|
+
e.substring(2, 4),
|
|
38
|
+
e.substring(4, 6)
|
|
39
|
+
], n = parseInt(t[0], 16) / 255, i = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
40
|
+
return .2126 * n + .7152 * i + .0722 * a;
|
|
41
|
+
}
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
function l(e) {
|
|
45
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
46
|
+
return t === "rgb(255,255,255)" || t === "#ffffff" || t === "white";
|
|
47
|
+
}
|
|
48
|
+
function u(e) {
|
|
49
|
+
let t = c(e);
|
|
50
|
+
return t >= 0 && t < .12;
|
|
51
|
+
}
|
|
52
|
+
function d(e) {
|
|
53
|
+
return c(e) > .75;
|
|
54
|
+
}
|
|
55
|
+
function f(t, n, r, i, a) {
|
|
56
|
+
if (!n && !r) return t;
|
|
57
|
+
let s = n && i !== void 0 ? e(i, "text") : "", c = r && a !== void 0 ? e(a, "bg") : "", l = [n ? `color: ${s}` : "", o(r, n, c)].filter(Boolean).join("; ");
|
|
58
|
+
return l ? `<mark style="${l};">${t}</mark>` : t;
|
|
59
|
+
}
|
|
60
|
+
function p(e, t) {
|
|
61
|
+
let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n), 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(), p = o?.[1]?.trim(), m = t ? c !== void 0 && !s(c) : c !== void 0 && !s(c) && !d(c), h = t ? p !== void 0 && p !== "transparent" : p !== void 0 && p !== "transparent" && !l(p) && !u(p);
|
|
62
|
+
if (!r && !i && !m && !h) return null;
|
|
63
|
+
let g = f(e.innerHTML, m, h, c, p), _ = i ? `<i>${g}</i>` : g;
|
|
64
|
+
return r ? `<b>${_}</b>` : _;
|
|
65
|
+
}
|
|
66
|
+
function m(e, t) {
|
|
67
|
+
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
68
|
+
let e = p(n, t);
|
|
69
|
+
e !== null && n.replaceWith(document.createRange().createContextualFragment(e));
|
|
70
|
+
}
|
|
71
|
+
t && h(e);
|
|
72
|
+
}
|
|
73
|
+
function h(t) {
|
|
74
|
+
for (let n of Array.from(t.querySelectorAll("a[style]"))) {
|
|
75
|
+
let t = n.getAttribute("style") ?? "", r = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(t), i = /background-color\s*:\s*([^;]+)/i.exec(t), a = r?.[1]?.trim(), c = i?.[1]?.trim(), l = a !== void 0 && !s(a) && a !== "inherit", u = c !== void 0 && c !== "transparent" && c !== "inherit";
|
|
76
|
+
if (!l && !u) continue;
|
|
77
|
+
let d = l ? e(a, "text") : "", f = u ? e(c, "bg") : "", p = [l ? `color: ${d}` : "", o(u, l, f)].filter(Boolean).join("; "), m = n;
|
|
78
|
+
m.innerHTML = `<mark style="${p};">${m.innerHTML}</mark>`, m.style.removeProperty("color"), m.style.removeProperty("background-color");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function g(e) {
|
|
82
|
+
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
83
|
+
let e = t.querySelectorAll("p");
|
|
84
|
+
if (e.length !== 0) {
|
|
85
|
+
for (let t of Array.from(e)) {
|
|
86
|
+
let e = document.createRange().createContextualFragment(t.innerHTML + "<br>");
|
|
87
|
+
t.replaceWith(e);
|
|
88
|
+
}
|
|
89
|
+
t.innerHTML = t.innerHTML.replace(/(<br\s*\/?>|\s)+$/i, "");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/cli/commands/convert-gdocs/index.ts
|
|
95
|
+
function _(e) {
|
|
96
|
+
let a = i(e), o = new DOMParser().parseFromString(a, "text/html").body;
|
|
97
|
+
n(o), t(o);
|
|
98
|
+
let s = {
|
|
99
|
+
version: "0.10.0-beta.18",
|
|
100
|
+
blocks: r(o)
|
|
101
|
+
};
|
|
102
|
+
return JSON.stringify(s);
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { _ as convertGdocs };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/cli/commands/convert-html/index.ts
|
|
3
|
+
function r(r) {
|
|
4
|
+
let i = new DOMParser().parseFromString(r, "text/html").body;
|
|
5
|
+
t(i), e(i);
|
|
6
|
+
let a = {
|
|
7
|
+
version: "0.10.0-beta.17",
|
|
8
|
+
blocks: n(i)
|
|
9
|
+
};
|
|
10
|
+
return JSON.stringify(a);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as convertHtml };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/cli/commands/convert-html/index.ts
|
|
3
|
+
function r(r) {
|
|
4
|
+
let i = new DOMParser().parseFromString(r, "text/html").body;
|
|
5
|
+
t(i), e(i);
|
|
6
|
+
let a = {
|
|
7
|
+
version: "0.10.0-beta.19",
|
|
8
|
+
blocks: n(i)
|
|
9
|
+
};
|
|
10
|
+
return JSON.stringify(a);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as convertHtml };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/cli/commands/convert-html/index.ts
|
|
3
|
+
function r(r) {
|
|
4
|
+
let i = new DOMParser().parseFromString(r, "text/html").body;
|
|
5
|
+
t(i), e(i);
|
|
6
|
+
let a = {
|
|
7
|
+
version: "0.10.0-beta.16",
|
|
8
|
+
blocks: n(i)
|
|
9
|
+
};
|
|
10
|
+
return JSON.stringify(a);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as convertHtml };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./block-builder-B8WkPORz.mjs";
|
|
2
|
+
//#region src/cli/commands/convert-html/index.ts
|
|
3
|
+
function r(r) {
|
|
4
|
+
let i = new DOMParser().parseFromString(r, "text/html").body;
|
|
5
|
+
t(i), e(i);
|
|
6
|
+
let a = {
|
|
7
|
+
version: "0.10.0-beta.18",
|
|
8
|
+
blocks: n(i)
|
|
9
|
+
};
|
|
10
|
+
return JSON.stringify(a);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as convertHtml };
|