@bloklabs/cli 1.16.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{block-builder-Cg5bL2dS.mjs → block-builder-DZMbuM0Z.mjs} +159 -208
- package/dist/cli.mjs +3 -4
- package/dist/{convert-gdocs-BNVlyZ1j.mjs → convert-gdocs-D4ZDpR0c.mjs} +3 -4
- package/dist/{convert-gdocs-BSQNj9_W.mjs → convert-gdocs-y870jCLm.mjs} +2 -3
- package/dist/{convert-html-1lRolRGH.mjs → convert-html-BATOFBHq.mjs} +3 -4
- package/dist/{convert-html-CS_2LG6q.mjs → convert-html-CbxmvYPY.mjs} +2 -3
- package/package.json +1 -1
- package/dist/block-builder-BEbdp0xc.mjs +0 -1019
- package/dist/block-builder-BV7ySSOn.mjs +0 -1269
- package/dist/block-builder-CTpURcXu.mjs +0 -1022
- package/dist/block-builder-DaGEOJ2S.mjs +0 -831
- package/dist/block-builder-Dc6PL7RK.mjs +0 -825
- package/dist/block-builder-DeebuGHy.mjs +0 -1453
- package/dist/block-builder-Dqos6hzP.mjs +0 -1067
- package/dist/block-builder-lzpU_6ZF.mjs +0 -827
- package/dist/convert-gdocs--8aPMm3f.mjs +0 -205
- package/dist/convert-gdocs-7NAwDDZ2.mjs +0 -214
- package/dist/convert-gdocs-9-fmO8W7.mjs +0 -214
- package/dist/convert-gdocs-BZ2ovDNS.mjs +0 -205
- package/dist/convert-gdocs-CB-kubaI.mjs +0 -208
- package/dist/convert-gdocs-CizVIpiR.mjs +0 -205
- package/dist/convert-gdocs-DtU-P2qd.mjs +0 -13
- package/dist/convert-gdocs-ZqRLNT9X.mjs +0 -13
- package/dist/convert-gdocs-msIm10vX.mjs +0 -214
- package/dist/convert-html-BI7SFKwK.mjs +0 -13
- package/dist/convert-html-BbJEHZTW.mjs +0 -13
- package/dist/convert-html-BcYeUJKw.mjs +0 -13
- package/dist/convert-html-BxJX_msU.mjs +0 -13
- package/dist/convert-html-DEW3D-Ub.mjs +0 -13
- package/dist/convert-html-DGBMQXkH.mjs +0 -13
- package/dist/convert-html-DGTszKTe.mjs +0 -13
- package/dist/convert-html-Oocfb7JD.mjs +0 -13
- package/dist/convert-html-RCkTt7d_.mjs +0 -13
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./block-builder-DaGEOJ2S.mjs";
|
|
2
|
-
//#region src/components/utils/inert-html.ts
|
|
3
|
-
var s = { current: void 0 };
|
|
4
|
-
function c(e) {
|
|
5
|
-
s.current ??= document.implementation.createHTMLDocument("");
|
|
6
|
-
let t = s.current.createElement("div");
|
|
7
|
-
return t.innerHTML = e, t;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/components/modules/paste/constants.ts
|
|
11
|
-
var l = "data-blok-columns-candidate", u = /(<br\s*\/?>)/i, d = /^<br\s*\/?>$/i;
|
|
12
|
-
function f(e) {
|
|
13
|
-
let t = e.split(u), n = t.reduce((e, t, n) => d.test(t) || t.trim() === "" ? e : n, -1);
|
|
14
|
-
return t.slice(0, n + 1).join("").trimEnd();
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
18
|
-
function p(t) {
|
|
19
|
-
let n = c(t), r = b(n);
|
|
20
|
-
return A(n, r), r && N(n), I(n), r && (P(n), y(n)), e(n), n.innerHTML;
|
|
21
|
-
}
|
|
22
|
-
function m(e, t) {
|
|
23
|
-
let n = e.parentElement;
|
|
24
|
-
return n === null ? null : n === t ? e : m(n, t);
|
|
25
|
-
}
|
|
26
|
-
function h(e, t, n) {
|
|
27
|
-
let r = e.cloneNode(!1), i = [];
|
|
28
|
-
for (let n of Array.from(e.childNodes)) {
|
|
29
|
-
if (n === t) break;
|
|
30
|
-
i.push(n);
|
|
31
|
-
}
|
|
32
|
-
return i.forEach((e) => r.appendChild(e)), n !== null && r.appendChild(n), r.childNodes.length > 0 ? r : null;
|
|
33
|
-
}
|
|
34
|
-
function g(e, t, n) {
|
|
35
|
-
let r = e.cloneNode(!1), i = Array.from(e.childNodes), a = i.findIndex((e) => e === t), o = i.slice(a + 1);
|
|
36
|
-
return n !== null && r.appendChild(n), o.forEach((e) => r.appendChild(e)), r.childNodes.length > 0 ? r : null;
|
|
37
|
-
}
|
|
38
|
-
function _(e, t) {
|
|
39
|
-
let n = (e, r, i) => {
|
|
40
|
-
if (e === t) return {
|
|
41
|
-
before: r,
|
|
42
|
-
after: i
|
|
43
|
-
};
|
|
44
|
-
let a = e.parentElement;
|
|
45
|
-
if (a === null) return {
|
|
46
|
-
before: r,
|
|
47
|
-
after: i
|
|
48
|
-
};
|
|
49
|
-
let o = h(a, e, r), s = g(a, e, i);
|
|
50
|
-
return n(a, o, s);
|
|
51
|
-
};
|
|
52
|
-
return n(e, null, null);
|
|
53
|
-
}
|
|
54
|
-
function v(e, t) {
|
|
55
|
-
let n = e.parentElement;
|
|
56
|
-
return n === null || n === t ? !1 : n.tagName === "TABLE" || v(n, t);
|
|
57
|
-
}
|
|
58
|
-
function y(e) {
|
|
59
|
-
let t = Array.from(e.querySelectorAll("img"));
|
|
60
|
-
for (let n of t) {
|
|
61
|
-
if (v(n, e)) continue;
|
|
62
|
-
let t = m(n, e);
|
|
63
|
-
if (!t) continue;
|
|
64
|
-
let { before: r, after: i } = _(n, t), a = document.createDocumentFragment();
|
|
65
|
-
r && a.appendChild(r), a.appendChild(n), i && a.appendChild(i), t.replaceWith(a);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function b(e) {
|
|
69
|
-
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
70
|
-
if (!t) return !1;
|
|
71
|
-
let n = document.createDocumentFragment();
|
|
72
|
-
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
73
|
-
return t.replaceWith(n), !0;
|
|
74
|
-
}
|
|
75
|
-
function x(e, t, n) {
|
|
76
|
-
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
77
|
-
}
|
|
78
|
-
function S(e) {
|
|
79
|
-
let t = e.replace(/\s/g, "");
|
|
80
|
-
return t === "rgb(0,0,0)" || t === "#000000";
|
|
81
|
-
}
|
|
82
|
-
function C(e) {
|
|
83
|
-
if (e.closest("a") !== null) return !0;
|
|
84
|
-
let t = e.querySelector("a");
|
|
85
|
-
return t !== null && t.textContent?.trim() === e.textContent?.trim();
|
|
86
|
-
}
|
|
87
|
-
function w(e) {
|
|
88
|
-
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
|
|
89
|
-
if (n) {
|
|
90
|
-
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
91
|
-
return .2126 * e + .7152 * t + .0722 * r;
|
|
92
|
-
}
|
|
93
|
-
let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
|
|
94
|
-
if (r) {
|
|
95
|
-
let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
|
|
96
|
-
if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
|
|
97
|
-
let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => {
|
|
98
|
-
let t = e < 0 ? e + 1 : e > 1 ? e - 1 : e;
|
|
99
|
-
return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
|
|
100
|
-
}, s = o(e + 1 / 3), c = o(e), l = o(e - 1 / 3);
|
|
101
|
-
return .2126 * s + .7152 * c + .0722 * l;
|
|
102
|
-
}
|
|
103
|
-
let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
104
|
-
if (i) {
|
|
105
|
-
let e = i[1], t = e.length === 3 ? [
|
|
106
|
-
e[0] + e[0],
|
|
107
|
-
e[1] + e[1],
|
|
108
|
-
e[2] + e[2]
|
|
109
|
-
] : [
|
|
110
|
-
e.substring(0, 2),
|
|
111
|
-
e.substring(2, 4),
|
|
112
|
-
e.substring(4, 6)
|
|
113
|
-
], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
114
|
-
return .2126 * n + .7152 * r + .0722 * a;
|
|
115
|
-
}
|
|
116
|
-
return -1;
|
|
117
|
-
}
|
|
118
|
-
function T(e) {
|
|
119
|
-
let t = w(e);
|
|
120
|
-
return t >= 0 && t > .75;
|
|
121
|
-
}
|
|
122
|
-
function E(e, t, n, i, a) {
|
|
123
|
-
if (!t && !n) return e;
|
|
124
|
-
let o = t && i !== void 0 ? r(i, "text") : "", s = n && a !== void 0 ? r(a, "bg") : "", c = [t ? `color: ${o}` : "", x(n, t, s)].filter(Boolean).join("; ");
|
|
125
|
-
return c ? `<mark style="${c};">${e}</mark>` : e;
|
|
126
|
-
}
|
|
127
|
-
var D = /* @__PURE__ */ new Set([
|
|
128
|
-
"H1",
|
|
129
|
-
"H2",
|
|
130
|
-
"H3",
|
|
131
|
-
"H4",
|
|
132
|
-
"H5",
|
|
133
|
-
"H6"
|
|
134
|
-
]);
|
|
135
|
-
function O(e) {
|
|
136
|
-
let t = e.parentElement;
|
|
137
|
-
return t === null ? !1 : D.has(t.tagName) ? !0 : O(t);
|
|
138
|
-
}
|
|
139
|
-
function k(e, t) {
|
|
140
|
-
let n = e.getAttribute("style") ?? "", r = /font-weight\s*:\s*(700|bold)/i.test(n) && !O(e), i = /font-style\s*:\s*italic/i.test(n), o = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(n), s = /background-color\s*:\s*([^;]+)/i.exec(n), c = o?.[1]?.trim(), l = s?.[1]?.trim(), u = !(c !== void 0 && C(e)) && (t ? c !== void 0 && !S(c) : c !== void 0 && !S(c) && !T(c)), d = l !== void 0 && !a(l);
|
|
141
|
-
if (!r && !i && !u && !d) return null;
|
|
142
|
-
let f = E(e.innerHTML, u, d, c, l), p = i ? `<i>${f}</i>` : f;
|
|
143
|
-
return r ? `<b>${p}</b>` : p;
|
|
144
|
-
}
|
|
145
|
-
function A(e, t) {
|
|
146
|
-
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
147
|
-
let e = k(n, t);
|
|
148
|
-
e !== null && n.replaceWith(n.ownerDocument.createRange().createContextualFragment(e));
|
|
149
|
-
}
|
|
150
|
-
t && j(e);
|
|
151
|
-
}
|
|
152
|
-
function j(e) {
|
|
153
|
-
for (let t of Array.from(e.querySelectorAll("a[style]"))) {
|
|
154
|
-
let e = t.getAttribute("style") ?? "", n = /background-color\s*:\s*([^;]+)/i.exec(e)?.[1]?.trim(), i = n !== void 0 && n !== "transparent" && n !== "inherit", a = t;
|
|
155
|
-
a.style.removeProperty("color"), i && (a.innerHTML = `<mark style="background-color: ${r(n, "bg")};">${a.innerHTML}</mark>`, a.style.removeProperty("background-color"));
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function M(e) {
|
|
159
|
-
return Array.from(e.querySelectorAll("tr")).filter((t) => t.closest("table") === e).map((e) => Array.from(e.children).filter((e) => e.tagName === "TD" || e.tagName === "TH"));
|
|
160
|
-
}
|
|
161
|
-
function N(e) {
|
|
162
|
-
if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
|
|
163
|
-
if (t.parentElement?.closest("table") !== null) continue;
|
|
164
|
-
let e = M(t);
|
|
165
|
-
e.length === 0 || e.some((e) => e.length !== 1) || (e.length === 1 || t.querySelector("img") !== null) && t.replaceWith(...e.flatMap(([e]) => Array.from(e.childNodes)));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function P(e) {
|
|
169
|
-
if (e.querySelector("google-sheets-html-origin") === null) for (let t of Array.from(e.querySelectorAll("table"))) {
|
|
170
|
-
if (t.parentElement?.closest("table") !== null) continue;
|
|
171
|
-
let e = M(t);
|
|
172
|
-
if (e.length === 0) continue;
|
|
173
|
-
let n = e[0].length;
|
|
174
|
-
if (!e.every((e) => e.length === n)) continue;
|
|
175
|
-
let r = e.length === 1 && (n === 2 || n === 3), i = e.length > 1 && n === 2 && t.querySelector("img") !== null;
|
|
176
|
-
(r || i) && t.setAttribute(l, "");
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function F(e) {
|
|
180
|
-
if (t(e)) {
|
|
181
|
-
e.remove();
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
let n = e.ownerDocument.createRange().createContextualFragment(e.innerHTML + "<br>");
|
|
185
|
-
e.replaceWith(n);
|
|
186
|
-
}
|
|
187
|
-
function I(e) {
|
|
188
|
-
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
189
|
-
let e = t.querySelectorAll("p");
|
|
190
|
-
e.length !== 0 && (Array.from(e).forEach(F), t.innerHTML = f(t.innerHTML));
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/cli/commands/convert-gdocs/index.ts
|
|
195
|
-
function L(e) {
|
|
196
|
-
let t = p(e), r = new DOMParser().parseFromString(t, "text/html").body;
|
|
197
|
-
i(r), n(r);
|
|
198
|
-
let a = {
|
|
199
|
-
version: "1.15.0",
|
|
200
|
-
blocks: o(r)
|
|
201
|
-
};
|
|
202
|
-
return JSON.stringify(a);
|
|
203
|
-
}
|
|
204
|
-
//#endregion
|
|
205
|
-
export { L as convertGdocs };
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./block-builder-Dqos6hzP.mjs";
|
|
2
|
-
//#region src/components/utils/inert-html.ts
|
|
3
|
-
var f = { current: void 0 };
|
|
4
|
-
function p(e) {
|
|
5
|
-
f.current ??= document.implementation.createHTMLDocument("");
|
|
6
|
-
let t = f.current.createElement("div");
|
|
7
|
-
return t.innerHTML = e, t;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
11
|
-
function m(e) {
|
|
12
|
-
let t = p(e), n = x(t);
|
|
13
|
-
return M(t, n), n && P(t), z(t), n && (F(t), b(t)), d(t), t.innerHTML;
|
|
14
|
-
}
|
|
15
|
-
function h(e, t) {
|
|
16
|
-
let n = e.parentElement;
|
|
17
|
-
return n === null ? null : n === t ? e : h(n, t);
|
|
18
|
-
}
|
|
19
|
-
function g(e, t, n) {
|
|
20
|
-
let r = e.cloneNode(!1), i = [];
|
|
21
|
-
for (let n of Array.from(e.childNodes)) {
|
|
22
|
-
if (n === t) break;
|
|
23
|
-
i.push(n);
|
|
24
|
-
}
|
|
25
|
-
return i.forEach((e) => r.appendChild(e)), n !== null && r.appendChild(n), r.childNodes.length > 0 ? r : null;
|
|
26
|
-
}
|
|
27
|
-
function _(e, t, n) {
|
|
28
|
-
let r = e.cloneNode(!1), i = Array.from(e.childNodes), a = i.findIndex((e) => e === t), o = i.slice(a + 1);
|
|
29
|
-
return n !== null && r.appendChild(n), o.forEach((e) => r.appendChild(e)), r.childNodes.length > 0 ? r : null;
|
|
30
|
-
}
|
|
31
|
-
function v(e, t) {
|
|
32
|
-
let n = (e, r, i) => {
|
|
33
|
-
if (e === t) return {
|
|
34
|
-
before: r,
|
|
35
|
-
after: i
|
|
36
|
-
};
|
|
37
|
-
let a = e.parentElement;
|
|
38
|
-
if (a === null) return {
|
|
39
|
-
before: r,
|
|
40
|
-
after: i
|
|
41
|
-
};
|
|
42
|
-
let o = g(a, e, r), s = _(a, e, i);
|
|
43
|
-
return n(a, o, s);
|
|
44
|
-
};
|
|
45
|
-
return n(e, null, null);
|
|
46
|
-
}
|
|
47
|
-
function y(e, t) {
|
|
48
|
-
let n = e.parentElement;
|
|
49
|
-
return n === null || n === t ? !1 : n.tagName === "TABLE" || y(n, t);
|
|
50
|
-
}
|
|
51
|
-
function b(e) {
|
|
52
|
-
let t = Array.from(e.querySelectorAll("img"));
|
|
53
|
-
for (let n of t) {
|
|
54
|
-
if (y(n, e)) continue;
|
|
55
|
-
let t = h(n, e);
|
|
56
|
-
if (!t) continue;
|
|
57
|
-
let { before: r, after: i } = v(n, t), a = document.createDocumentFragment();
|
|
58
|
-
r && a.appendChild(r), a.appendChild(n), i && a.appendChild(i), t.replaceWith(a);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function x(e) {
|
|
62
|
-
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
63
|
-
if (!t) return !1;
|
|
64
|
-
let n = document.createDocumentFragment();
|
|
65
|
-
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
66
|
-
return t.replaceWith(n), !0;
|
|
67
|
-
}
|
|
68
|
-
function S(e, t, n) {
|
|
69
|
-
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
70
|
-
}
|
|
71
|
-
function C(e) {
|
|
72
|
-
let t = e.replace(/\s/g, "");
|
|
73
|
-
return t === "rgb(0,0,0)" || t === "#000000";
|
|
74
|
-
}
|
|
75
|
-
function w(e) {
|
|
76
|
-
if (e.closest("a") !== null) return !0;
|
|
77
|
-
let t = e.querySelector("a");
|
|
78
|
-
return t !== null && t.textContent?.trim() === e.textContent?.trim();
|
|
79
|
-
}
|
|
80
|
-
function T(e) {
|
|
81
|
-
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
|
|
82
|
-
if (n) {
|
|
83
|
-
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
84
|
-
return .2126 * e + .7152 * t + .0722 * r;
|
|
85
|
-
}
|
|
86
|
-
let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
|
|
87
|
-
if (r) {
|
|
88
|
-
let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
|
|
89
|
-
if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
|
|
90
|
-
let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => {
|
|
91
|
-
let t = e < 0 ? e + 1 : e > 1 ? e - 1 : e;
|
|
92
|
-
return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
|
|
93
|
-
}, s = o(e + 1 / 3), c = o(e), l = o(e - 1 / 3);
|
|
94
|
-
return .2126 * s + .7152 * c + .0722 * l;
|
|
95
|
-
}
|
|
96
|
-
let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
97
|
-
if (i) {
|
|
98
|
-
let e = i[1], t = e.length === 3 ? [
|
|
99
|
-
e[0] + e[0],
|
|
100
|
-
e[1] + e[1],
|
|
101
|
-
e[2] + e[2]
|
|
102
|
-
] : [
|
|
103
|
-
e.substring(0, 2),
|
|
104
|
-
e.substring(2, 4),
|
|
105
|
-
e.substring(4, 6)
|
|
106
|
-
], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
107
|
-
return .2126 * n + .7152 * r + .0722 * a;
|
|
108
|
-
}
|
|
109
|
-
return -1;
|
|
110
|
-
}
|
|
111
|
-
function E(e) {
|
|
112
|
-
let t = T(e);
|
|
113
|
-
return t >= 0 && t > .75;
|
|
114
|
-
}
|
|
115
|
-
function D(e, t, r, i, a) {
|
|
116
|
-
if (!t && !r) return e;
|
|
117
|
-
let o = t && i !== void 0 ? n(i, "text") : "", s = r && a !== void 0 ? n(a, "bg") : "", c = [t ? `color: ${o}` : "", S(r, t, s)].filter(Boolean).join("; ");
|
|
118
|
-
return c ? `<mark style="${c};">${e}</mark>` : e;
|
|
119
|
-
}
|
|
120
|
-
var O = /* @__PURE__ */ new Set([
|
|
121
|
-
"H1",
|
|
122
|
-
"H2",
|
|
123
|
-
"H3",
|
|
124
|
-
"H4",
|
|
125
|
-
"H5",
|
|
126
|
-
"H6"
|
|
127
|
-
]);
|
|
128
|
-
function k(e) {
|
|
129
|
-
let t = e.parentElement;
|
|
130
|
-
return t === null ? !1 : O.has(t.tagName) ? !0 : k(t);
|
|
131
|
-
}
|
|
132
|
-
var A = {
|
|
133
|
-
super: "sup",
|
|
134
|
-
sub: "sub"
|
|
135
|
-
};
|
|
136
|
-
function j(e, t) {
|
|
137
|
-
let n = e.getAttribute("style") ?? "", i = /font-weight\s*:\s*(700|bold)/i.test(n) && !k(e), a = /font-style\s*:\s*italic/i.test(n), o = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(n), s = /background-color\s*:\s*([^;]+)/i.exec(n), c = o?.[1]?.trim(), l = s?.[1]?.trim(), u = !(c !== void 0 && w(e)) && (t ? c !== void 0 && !C(c) : c !== void 0 && !C(c) && !E(c)), d = l !== void 0 && !r(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) && !w(e), h = /line-through/i.test(f), g = A[p.toLowerCase()];
|
|
138
|
-
if (!i && !a && !u && !d && !m && !h && g === void 0) return null;
|
|
139
|
-
let _ = D(e.innerHTML, u, d, c, l);
|
|
140
|
-
return [
|
|
141
|
-
i ? "b" : "",
|
|
142
|
-
a ? "i" : "",
|
|
143
|
-
m ? "u" : "",
|
|
144
|
-
h ? "s" : "",
|
|
145
|
-
g ?? ""
|
|
146
|
-
].filter(Boolean).reduceRight((e, t) => `<${t}>${e}</${t}>`, _);
|
|
147
|
-
}
|
|
148
|
-
function M(e, t) {
|
|
149
|
-
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
150
|
-
let e = j(n, t);
|
|
151
|
-
e !== null && n.replaceWith(n.ownerDocument.createRange().createContextualFragment(e));
|
|
152
|
-
}
|
|
153
|
-
t && N(e);
|
|
154
|
-
}
|
|
155
|
-
function N(e) {
|
|
156
|
-
for (let t of Array.from(e.querySelectorAll("a[style]"))) {
|
|
157
|
-
let e = t.getAttribute("style") ?? "", r = /background-color\s*:\s*([^;]+)/i.exec(e)?.[1]?.trim(), i = r !== void 0 && r !== "transparent" && r !== "inherit", a = t;
|
|
158
|
-
a.style.removeProperty("color"), i && (a.innerHTML = `<mark style="background-color: ${n(r, "bg")};">${a.innerHTML}</mark>`, a.style.removeProperty("background-color"));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function P(t) {
|
|
162
|
-
if (t.querySelector("google-sheets-html-origin") === null) for (let n of Array.from(t.querySelectorAll("table"))) {
|
|
163
|
-
if (n.parentElement?.closest("table") !== null) continue;
|
|
164
|
-
let t = s(n).map(e);
|
|
165
|
-
t.length === 0 || t.some((e) => e.length !== 1) || (t.length === 1 || n.querySelector("img") !== null) && n.replaceWith(...t.flatMap(([e]) => Array.from(e.childNodes)));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function F(t) {
|
|
169
|
-
if (t.querySelector("google-sheets-html-origin") === null) for (let n of Array.from(t.querySelectorAll("table"))) {
|
|
170
|
-
if (n.parentElement?.closest("table") !== null) continue;
|
|
171
|
-
let t = s(n).map(e);
|
|
172
|
-
if (t.length === 0) continue;
|
|
173
|
-
let r = t[0].length;
|
|
174
|
-
if (!t.every((e) => e.length === r)) continue;
|
|
175
|
-
let i = t.length === 1 && (r === 2 || r === 3), o = t.length > 1 && r === 2 && n.querySelector("img") !== null;
|
|
176
|
-
(i || o) && n.setAttribute(a, "");
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function I(e) {
|
|
180
|
-
if (l(e)) {
|
|
181
|
-
e.remove();
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
let t = e.ownerDocument.createRange().createContextualFragment(e.innerHTML + "<br>");
|
|
185
|
-
e.replaceWith(t);
|
|
186
|
-
}
|
|
187
|
-
var L = /(?<![a-z-])text-align\s*:\s*([^;]+)/i;
|
|
188
|
-
function R(e) {
|
|
189
|
-
let t = e.getAttribute("style") ?? "";
|
|
190
|
-
if (L.test(t)) return;
|
|
191
|
-
let n = Array.from(e.querySelectorAll("p")).filter((t) => t.closest("td, th") === e && !l(t)), r = new Set(n.map((e) => L.exec(e.getAttribute("style") ?? "")?.[1]?.trim().toLowerCase())), [i] = r;
|
|
192
|
-
r.size === 1 && i !== void 0 && e.setAttribute("style", t === "" ? `text-align:${i}` : `${t};text-align:${i}`);
|
|
193
|
-
}
|
|
194
|
-
function z(e) {
|
|
195
|
-
let n = Array.from(e.querySelectorAll("td, th"));
|
|
196
|
-
n.forEach(R);
|
|
197
|
-
for (let e of n) {
|
|
198
|
-
let n = e.querySelectorAll("p");
|
|
199
|
-
n.length !== 0 && (Array.from(n).forEach(I), e.innerHTML = t(e.innerHTML));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
|
-
//#region src/cli/commands/convert-gdocs/index.ts
|
|
204
|
-
function B(e) {
|
|
205
|
-
let t = m(i(e)), n = new DOMParser().parseFromString(t, "text/html").body;
|
|
206
|
-
c(n), o(n);
|
|
207
|
-
let r = {
|
|
208
|
-
version: "1.15.2",
|
|
209
|
-
blocks: u(n)
|
|
210
|
-
};
|
|
211
|
-
return JSON.stringify(r);
|
|
212
|
-
}
|
|
213
|
-
//#endregion
|
|
214
|
-
export { B as convertGdocs };
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./block-builder-BEbdp0xc.mjs";
|
|
2
|
-
//#region src/components/utils/inert-html.ts
|
|
3
|
-
var d = { current: void 0 };
|
|
4
|
-
function f(e) {
|
|
5
|
-
d.current ??= document.implementation.createHTMLDocument("");
|
|
6
|
-
let t = d.current.createElement("div");
|
|
7
|
-
return t.innerHTML = e, t;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/components/modules/paste/google-docs-preprocessor.ts
|
|
11
|
-
function p(e) {
|
|
12
|
-
let t = f(e), n = b(t);
|
|
13
|
-
return j(t, n), n && N(t), R(t), n && (P(t), y(t)), i(t), t.innerHTML;
|
|
14
|
-
}
|
|
15
|
-
function m(e, t) {
|
|
16
|
-
let n = e.parentElement;
|
|
17
|
-
return n === null ? null : n === t ? e : m(n, t);
|
|
18
|
-
}
|
|
19
|
-
function h(e, t, n) {
|
|
20
|
-
let r = e.cloneNode(!1), i = [];
|
|
21
|
-
for (let n of Array.from(e.childNodes)) {
|
|
22
|
-
if (n === t) break;
|
|
23
|
-
i.push(n);
|
|
24
|
-
}
|
|
25
|
-
return i.forEach((e) => r.appendChild(e)), n !== null && r.appendChild(n), r.childNodes.length > 0 ? r : null;
|
|
26
|
-
}
|
|
27
|
-
function g(e, t, n) {
|
|
28
|
-
let r = e.cloneNode(!1), i = Array.from(e.childNodes), a = i.findIndex((e) => e === t), o = i.slice(a + 1);
|
|
29
|
-
return n !== null && r.appendChild(n), o.forEach((e) => r.appendChild(e)), r.childNodes.length > 0 ? r : null;
|
|
30
|
-
}
|
|
31
|
-
function _(e, t) {
|
|
32
|
-
let n = (e, r, i) => {
|
|
33
|
-
if (e === t) return {
|
|
34
|
-
before: r,
|
|
35
|
-
after: i
|
|
36
|
-
};
|
|
37
|
-
let a = e.parentElement;
|
|
38
|
-
if (a === null) return {
|
|
39
|
-
before: r,
|
|
40
|
-
after: i
|
|
41
|
-
};
|
|
42
|
-
let o = h(a, e, r), s = g(a, e, i);
|
|
43
|
-
return n(a, o, s);
|
|
44
|
-
};
|
|
45
|
-
return n(e, null, null);
|
|
46
|
-
}
|
|
47
|
-
function v(e, t) {
|
|
48
|
-
let n = e.parentElement;
|
|
49
|
-
return n === null || n === t ? !1 : n.tagName === "TABLE" || v(n, t);
|
|
50
|
-
}
|
|
51
|
-
function y(e) {
|
|
52
|
-
let t = Array.from(e.querySelectorAll("img"));
|
|
53
|
-
for (let n of t) {
|
|
54
|
-
if (v(n, e)) continue;
|
|
55
|
-
let t = m(n, e);
|
|
56
|
-
if (!t) continue;
|
|
57
|
-
let { before: r, after: i } = _(n, t), a = document.createDocumentFragment();
|
|
58
|
-
r && a.appendChild(r), a.appendChild(n), i && a.appendChild(i), t.replaceWith(a);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function b(e) {
|
|
62
|
-
let t = e.querySelector("b[id^=\"docs-internal-guid-\"]");
|
|
63
|
-
if (!t) return !1;
|
|
64
|
-
let n = document.createDocumentFragment();
|
|
65
|
-
for (; t.firstChild;) n.appendChild(t.firstChild);
|
|
66
|
-
return t.replaceWith(n), !0;
|
|
67
|
-
}
|
|
68
|
-
function x(e, t, n) {
|
|
69
|
-
return e ? `background-color: ${n}` : t ? "background-color: transparent" : "";
|
|
70
|
-
}
|
|
71
|
-
function S(e) {
|
|
72
|
-
let t = e.replace(/\s/g, "");
|
|
73
|
-
return t === "rgb(0,0,0)" || t === "#000000";
|
|
74
|
-
}
|
|
75
|
-
function C(e) {
|
|
76
|
-
if (e.closest("a") !== null) return !0;
|
|
77
|
-
let t = e.querySelector("a");
|
|
78
|
-
return t !== null && t.textContent?.trim() === e.textContent?.trim();
|
|
79
|
-
}
|
|
80
|
-
function w(e) {
|
|
81
|
-
let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
|
|
82
|
-
if (n) {
|
|
83
|
-
let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
|
|
84
|
-
return .2126 * e + .7152 * t + .0722 * r;
|
|
85
|
-
}
|
|
86
|
-
let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
|
|
87
|
-
if (r) {
|
|
88
|
-
let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
|
|
89
|
-
if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
|
|
90
|
-
let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => {
|
|
91
|
-
let t = e < 0 ? e + 1 : e > 1 ? e - 1 : e;
|
|
92
|
-
return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
|
|
93
|
-
}, s = o(e + 1 / 3), c = o(e), l = o(e - 1 / 3);
|
|
94
|
-
return .2126 * s + .7152 * c + .0722 * l;
|
|
95
|
-
}
|
|
96
|
-
let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
97
|
-
if (i) {
|
|
98
|
-
let e = i[1], t = e.length === 3 ? [
|
|
99
|
-
e[0] + e[0],
|
|
100
|
-
e[1] + e[1],
|
|
101
|
-
e[2] + e[2]
|
|
102
|
-
] : [
|
|
103
|
-
e.substring(0, 2),
|
|
104
|
-
e.substring(2, 4),
|
|
105
|
-
e.substring(4, 6)
|
|
106
|
-
], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
|
|
107
|
-
return .2126 * n + .7152 * r + .0722 * a;
|
|
108
|
-
}
|
|
109
|
-
return -1;
|
|
110
|
-
}
|
|
111
|
-
function T(e) {
|
|
112
|
-
let t = w(e);
|
|
113
|
-
return t >= 0 && t > .75;
|
|
114
|
-
}
|
|
115
|
-
function E(e, t, n, r, i) {
|
|
116
|
-
if (!t && !n) return e;
|
|
117
|
-
let a = t && r !== void 0 ? u(r, "text") : "", o = n && i !== void 0 ? u(i, "bg") : "", s = [t ? `color: ${a}` : "", x(n, t, o)].filter(Boolean).join("; ");
|
|
118
|
-
return s ? `<mark style="${s};">${e}</mark>` : e;
|
|
119
|
-
}
|
|
120
|
-
var D = /* @__PURE__ */ new Set([
|
|
121
|
-
"H1",
|
|
122
|
-
"H2",
|
|
123
|
-
"H3",
|
|
124
|
-
"H4",
|
|
125
|
-
"H5",
|
|
126
|
-
"H6"
|
|
127
|
-
]);
|
|
128
|
-
function O(e) {
|
|
129
|
-
let t = e.parentElement;
|
|
130
|
-
return t === null ? !1 : D.has(t.tagName) ? !0 : O(t);
|
|
131
|
-
}
|
|
132
|
-
var k = {
|
|
133
|
-
super: "sup",
|
|
134
|
-
sub: "sub"
|
|
135
|
-
};
|
|
136
|
-
function A(e, t) {
|
|
137
|
-
let r = e.getAttribute("style") ?? "", i = /font-weight\s*:\s*(700|bold)/i.test(r) && !O(e), a = /font-style\s*:\s*italic/i.test(r), o = /(?<![a-z-])color\s*:\s*([^;]+)/i.exec(r), s = /background-color\s*:\s*([^;]+)/i.exec(r), c = o?.[1]?.trim(), l = s?.[1]?.trim(), u = !(c !== void 0 && C(e)) && (t ? c !== void 0 && !S(c) : c !== void 0 && !S(c) && !T(c)), d = l !== void 0 && !n(l), f = t ? /text-decoration(?:-line)?\s*:\s*([^;]+)/i.exec(r)?.[1] ?? "" : "", p = t ? /vertical-align\s*:\s*([^;]+)/i.exec(r)?.[1]?.trim() ?? "" : "", m = /underline/i.test(f) && !C(e), h = /line-through/i.test(f), g = k[p.toLowerCase()];
|
|
138
|
-
if (!i && !a && !u && !d && !m && !h && g === void 0) return null;
|
|
139
|
-
let _ = E(e.innerHTML, u, d, c, l);
|
|
140
|
-
return [
|
|
141
|
-
i ? "b" : "",
|
|
142
|
-
a ? "i" : "",
|
|
143
|
-
m ? "u" : "",
|
|
144
|
-
h ? "s" : "",
|
|
145
|
-
g ?? ""
|
|
146
|
-
].filter(Boolean).reduceRight((e, t) => `<${t}>${e}</${t}>`, _);
|
|
147
|
-
}
|
|
148
|
-
function j(e, t) {
|
|
149
|
-
for (let n of Array.from(e.querySelectorAll("span[style]"))) {
|
|
150
|
-
let e = A(n, t);
|
|
151
|
-
e !== null && n.replaceWith(n.ownerDocument.createRange().createContextualFragment(e));
|
|
152
|
-
}
|
|
153
|
-
t && M(e);
|
|
154
|
-
}
|
|
155
|
-
function M(e) {
|
|
156
|
-
for (let t of Array.from(e.querySelectorAll("a[style]"))) {
|
|
157
|
-
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;
|
|
158
|
-
i.style.removeProperty("color"), r && (i.innerHTML = `<mark style="background-color: ${u(n, "bg")};">${i.innerHTML}</mark>`, i.style.removeProperty("background-color"));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function N(t) {
|
|
162
|
-
if (t.querySelector("google-sheets-html-origin") === null) for (let n of Array.from(t.querySelectorAll("table"))) {
|
|
163
|
-
if (n.parentElement?.closest("table") !== null) continue;
|
|
164
|
-
let t = e(n).map(r);
|
|
165
|
-
t.length === 0 || t.some((e) => e.length !== 1) || (t.length === 1 || n.querySelector("img") !== null) && n.replaceWith(...t.flatMap(([e]) => Array.from(e.childNodes)));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function P(n) {
|
|
169
|
-
if (n.querySelector("google-sheets-html-origin") === null) for (let i of Array.from(n.querySelectorAll("table"))) {
|
|
170
|
-
if (i.parentElement?.closest("table") !== null) continue;
|
|
171
|
-
let n = e(i).map(r);
|
|
172
|
-
if (n.length === 0) continue;
|
|
173
|
-
let a = n[0].length;
|
|
174
|
-
if (!n.every((e) => e.length === a)) continue;
|
|
175
|
-
let o = n.length === 1 && (a === 2 || a === 3), s = n.length > 1 && a === 2 && i.querySelector("img") !== null;
|
|
176
|
-
(o || s) && i.setAttribute(t, "");
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function F(e) {
|
|
180
|
-
if (o(e)) {
|
|
181
|
-
e.remove();
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
let t = e.ownerDocument.createRange().createContextualFragment(e.innerHTML + "<br>");
|
|
185
|
-
e.replaceWith(t);
|
|
186
|
-
}
|
|
187
|
-
var I = /(?<![a-z-])text-align\s*:\s*([^;]+)/i;
|
|
188
|
-
function L(e) {
|
|
189
|
-
let t = e.getAttribute("style") ?? "";
|
|
190
|
-
if (I.test(t)) return;
|
|
191
|
-
let n = Array.from(e.querySelectorAll("p")).filter((t) => t.closest("td, th") === e && !o(t)), r = new Set(n.map((e) => I.exec(e.getAttribute("style") ?? "")?.[1]?.trim().toLowerCase())), [i] = r;
|
|
192
|
-
r.size === 1 && i !== void 0 && e.setAttribute("style", t === "" ? `text-align:${i}` : `${t};text-align:${i}`);
|
|
193
|
-
}
|
|
194
|
-
function R(e) {
|
|
195
|
-
let t = Array.from(e.querySelectorAll("td, th"));
|
|
196
|
-
t.forEach(L);
|
|
197
|
-
for (let e of t) {
|
|
198
|
-
let t = e.querySelectorAll("p");
|
|
199
|
-
t.length !== 0 && (Array.from(t).forEach(F), e.innerHTML = c(e.innerHTML));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
|
-
//#region src/cli/commands/convert-gdocs/index.ts
|
|
204
|
-
function z(e) {
|
|
205
|
-
let t = p(e), n = new DOMParser().parseFromString(t, "text/html").body;
|
|
206
|
-
s(n), a(n);
|
|
207
|
-
let r = {
|
|
208
|
-
version: "1.15.2",
|
|
209
|
-
blocks: l(n)
|
|
210
|
-
};
|
|
211
|
-
return JSON.stringify(r);
|
|
212
|
-
}
|
|
213
|
-
//#endregion
|
|
214
|
-
export { z as convertGdocs };
|