@jackuait/blok-cli 0.10.0-beta.15 → 0.10.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/{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-DqgXHZEp.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-D9_Z0H6_.mjs +13 -0
- package/dist/convert-html-DWcDlr_4.mjs +13 -0
- package/package.json +1 -1
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-D9_Z0H6_.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-DqgXHZEp.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",
|
|
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",
|
|
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 };
|