@bloklabs/cli 1.13.0 → 1.15.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/README.md +1 -1
- package/dist/{block-builder-Cp5f8JCh.mjs → block-builder-DaGEOJ2S.mjs} +173 -121
- package/dist/cli.mjs +2 -2
- package/dist/{convert-gdocs-QvYOI8ct.mjs → convert-gdocs--8aPMm3f.mjs} +70 -69
- package/dist/{convert-gdocs-CN976X03.mjs → convert-gdocs-CB-kubaI.mjs} +1 -1
- package/dist/{convert-html-BJmjy5WC.mjs → convert-html-BcYeUJKw.mjs} +1 -1
- package/dist/{convert-html-2MRXCAV7.mjs → convert-html-DEW3D-Ub.mjs} +2 -2
- package/package.json +1 -1
- package/dist/block-builder-B_eFe3eS.mjs +0 -673
- package/dist/block-builder-BhbHyKmd.mjs +0 -673
- package/dist/convert-gdocs-37lxDj3f.mjs +0 -198
- package/dist/convert-gdocs-4swiirRR.mjs +0 -198
- package/dist/convert-gdocs-6yY_wt82.mjs +0 -182
- package/dist/convert-gdocs-BDD1tJ_Q.mjs +0 -168
- package/dist/convert-gdocs-BLvHjlsM.mjs +0 -198
- package/dist/convert-gdocs-BVnty-_F.mjs +0 -186
- package/dist/convert-gdocs-BZA8nIXm.mjs +0 -165
- package/dist/convert-gdocs-BeTateXm.mjs +0 -168
- package/dist/convert-gdocs-BhHRt3Cx.mjs +0 -168
- package/dist/convert-gdocs-BnJm2wSS.mjs +0 -165
- package/dist/convert-gdocs-Bp3j6l4q.mjs +0 -182
- package/dist/convert-gdocs-BvHmiAhV.mjs +0 -168
- package/dist/convert-gdocs-Bw88sUiB.mjs +0 -168
- package/dist/convert-gdocs-BxtZIyfN.mjs +0 -168
- package/dist/convert-gdocs-C2s8p7mh.mjs +0 -168
- package/dist/convert-gdocs-C71xkLGm.mjs +0 -165
- package/dist/convert-gdocs-CBRViTQf.mjs +0 -180
- package/dist/convert-gdocs-CHHN9rsx.mjs +0 -168
- package/dist/convert-gdocs-CKB34RE1.mjs +0 -168
- package/dist/convert-gdocs-CP4hP3lh.mjs +0 -165
- package/dist/convert-gdocs-CdKyF8Q9.mjs +0 -168
- package/dist/convert-gdocs-Ckxs9BwZ.mjs +0 -165
- package/dist/convert-gdocs-CuJPQDXZ.mjs +0 -198
- package/dist/convert-gdocs-CwqIzHDl.mjs +0 -165
- package/dist/convert-gdocs-D0GC6YDQ.mjs +0 -165
- package/dist/convert-gdocs-D2pNV_P2.mjs +0 -165
- package/dist/convert-gdocs-DGmfsVqf.mjs +0 -165
- package/dist/convert-gdocs-DLaumLJ0.mjs +0 -182
- package/dist/convert-gdocs-DMeKpRiv.mjs +0 -198
- package/dist/convert-gdocs-DTOupd5x.mjs +0 -198
- package/dist/convert-gdocs-DfDkgIvB.mjs +0 -168
- package/dist/convert-gdocs-Dg4BvXJv.mjs +0 -165
- package/dist/convert-gdocs-DgEV2uq0.mjs +0 -168
- package/dist/convert-gdocs-DhqPnu2C.mjs +0 -182
- package/dist/convert-gdocs-DmNzRwar.mjs +0 -198
- package/dist/convert-gdocs-DxCZJg3f.mjs +0 -168
- package/dist/convert-gdocs-Dxv8hZRN.mjs +0 -168
- package/dist/convert-gdocs-Dy45OFlW.mjs +0 -198
- package/dist/convert-gdocs-E0xZ8aMJ.mjs +0 -168
- package/dist/convert-gdocs-Gr31yEVO.mjs +0 -168
- package/dist/convert-gdocs-Y3Psy87D.mjs +0 -186
- package/dist/convert-gdocs-aFuepVmO.mjs +0 -198
- package/dist/convert-gdocs-qBKpfEIJ.mjs +0 -168
- package/dist/convert-gdocs-tLm59QcA.mjs +0 -198
- package/dist/convert-gdocs-xm_P1jci.mjs +0 -186
- package/dist/convert-gdocs-yWEz40tc.mjs +0 -198
- package/dist/convert-html--cLXJ4AY.mjs +0 -13
- package/dist/convert-html-2hMWDvO2.mjs +0 -13
- package/dist/convert-html-8dOFToww.mjs +0 -13
- package/dist/convert-html-B0G5pVra.mjs +0 -13
- package/dist/convert-html-BE95-_tJ.mjs +0 -13
- package/dist/convert-html-BLSIt9Cz.mjs +0 -13
- package/dist/convert-html-BM5cG4wR.mjs +0 -13
- package/dist/convert-html-BMfw-V_A.mjs +0 -13
- package/dist/convert-html-BXXGxsNA.mjs +0 -13
- package/dist/convert-html-Bi6ervFd.mjs +0 -13
- package/dist/convert-html-BkMfT06o.mjs +0 -13
- package/dist/convert-html-BwGfSIdd.mjs +0 -13
- package/dist/convert-html-BxOQfxMe.mjs +0 -13
- package/dist/convert-html-C1hIHsG2.mjs +0 -13
- package/dist/convert-html-C5HKrrnY.mjs +0 -13
- package/dist/convert-html-CMgcEfdF.mjs +0 -13
- package/dist/convert-html-CSFMRW8-.mjs +0 -13
- package/dist/convert-html-CUYvaNyX.mjs +0 -13
- package/dist/convert-html-CWU4BKK2.mjs +0 -13
- package/dist/convert-html-C_XAR-3k.mjs +0 -13
- package/dist/convert-html-CblPztis.mjs +0 -13
- package/dist/convert-html-CtLOMx8H.mjs +0 -13
- package/dist/convert-html-D-QH5JkA.mjs +0 -13
- package/dist/convert-html-D4ge5XCh.mjs +0 -13
- package/dist/convert-html-D8Q3QlMm.mjs +0 -13
- package/dist/convert-html-DCWeObhy.mjs +0 -13
- package/dist/convert-html-DLCj5_Ti.mjs +0 -13
- package/dist/convert-html-DNyat7Li.mjs +0 -13
- package/dist/convert-html-DXBGjTBH.mjs +0 -13
- package/dist/convert-html-DofDta-k.mjs +0 -13
- package/dist/convert-html-Dr2a_D0l.mjs +0 -13
- package/dist/convert-html-DsfU0_R9.mjs +0 -13
- package/dist/convert-html-DtP-Ofru.mjs +0 -13
- package/dist/convert-html-GFOTARll.mjs +0 -13
- package/dist/convert-html-HPcZYDNv.mjs +0 -13
- package/dist/convert-html-JmnpFRtf.mjs +0 -13
- package/dist/convert-html-Qy4nomiO.mjs +0 -13
- package/dist/convert-html-XLlIOrad.mjs +0 -13
- package/dist/convert-html-Y87KeWXA.mjs +0 -13
- package/dist/convert-html-dnxmpyLt.mjs +0 -13
- package/dist/convert-html-gVS6hEIk.mjs +0 -13
- package/dist/convert-html-nZIHLjp5.mjs +0 -13
- package/dist/convert-html-pNLuv-6b.mjs +0 -13
- package/dist/convert-html-vk0C2MGe.mjs +0 -13
- package/dist/convert-html-wpLDZrzb.mjs +0 -13
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloklabs/cli
|
|
2
2
|
|
|
3
|
-
Command-line tools for [Blok](https://blokeditor.com)
|
|
3
|
+
Command-line tools for [Blok](https://blokeditor.com). Blok is a headless, Notion-like block editor whose content is JSON blocks, not HTML. Converts legacy HTML into Blok JSON and prints the Editor.js migration guide.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -133,9 +133,55 @@ function i(e) {
|
|
|
133
133
|
let t = r(e);
|
|
134
134
|
return t >= 0 && t < .12;
|
|
135
135
|
}
|
|
136
|
+
var a = 250;
|
|
137
|
+
function o(e) {
|
|
138
|
+
let t = e.replace(/\s/g, "").toLowerCase();
|
|
139
|
+
if (t === "transparent") return {
|
|
140
|
+
r: 0,
|
|
141
|
+
g: 0,
|
|
142
|
+
b: 0,
|
|
143
|
+
a: 0
|
|
144
|
+
};
|
|
145
|
+
if (t === "white") return {
|
|
146
|
+
r: 255,
|
|
147
|
+
g: 255,
|
|
148
|
+
b: 255,
|
|
149
|
+
a: 1
|
|
150
|
+
};
|
|
151
|
+
let n = /^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/.exec(t);
|
|
152
|
+
if (n) return {
|
|
153
|
+
r: parseInt(n[1], 10),
|
|
154
|
+
g: parseInt(n[2], 10),
|
|
155
|
+
b: parseInt(n[3], 10),
|
|
156
|
+
a: n[4] === void 0 ? 1 : parseFloat(n[4])
|
|
157
|
+
};
|
|
158
|
+
let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
|
|
159
|
+
if (r) {
|
|
160
|
+
let e = r[1], t = e.length === 3 ? [
|
|
161
|
+
e[0] + e[0],
|
|
162
|
+
e[1] + e[1],
|
|
163
|
+
e[2] + e[2]
|
|
164
|
+
] : [
|
|
165
|
+
e.substring(0, 2),
|
|
166
|
+
e.substring(2, 4),
|
|
167
|
+
e.substring(4, 6)
|
|
168
|
+
];
|
|
169
|
+
return {
|
|
170
|
+
r: parseInt(t[0], 16),
|
|
171
|
+
g: parseInt(t[1], 16),
|
|
172
|
+
b: parseInt(t[2], 16),
|
|
173
|
+
a: 1
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
function s(e) {
|
|
179
|
+
let t = o(e);
|
|
180
|
+
return t !== null && (t.a === 0 || t.r >= a && t.g >= a && t.b >= a) || i(e);
|
|
181
|
+
}
|
|
136
182
|
//#endregion
|
|
137
183
|
//#region src/components/utils/color-mapping.ts
|
|
138
|
-
function
|
|
184
|
+
function c(e, t, n) {
|
|
139
185
|
let r = t / 100, i = n / 100;
|
|
140
186
|
if (r === 0) {
|
|
141
187
|
let e = Math.round(i * 255);
|
|
@@ -155,7 +201,7 @@ function a(e, t, n) {
|
|
|
155
201
|
Math.round(o(c, s, l - 1 / 3) * 255)
|
|
156
202
|
];
|
|
157
203
|
}
|
|
158
|
-
function
|
|
204
|
+
function l(e) {
|
|
159
205
|
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
160
206
|
if (t) return [
|
|
161
207
|
parseInt(t[1], 16),
|
|
@@ -180,17 +226,17 @@ function o(e) {
|
|
|
180
226
|
parseInt(i[2] + i[2], 16),
|
|
181
227
|
parseInt(i[3] + i[3], 16)
|
|
182
228
|
];
|
|
183
|
-
let
|
|
184
|
-
if (
|
|
185
|
-
Number(
|
|
186
|
-
Number(
|
|
187
|
-
Number(
|
|
229
|
+
let a = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
230
|
+
if (a) return [
|
|
231
|
+
Number(a[1]),
|
|
232
|
+
Number(a[2]),
|
|
233
|
+
Number(a[3])
|
|
188
234
|
];
|
|
189
|
-
let
|
|
190
|
-
return
|
|
235
|
+
let o = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
|
|
236
|
+
return o ? c(Number(o[1]), Number(o[2]), Number(o[3])) : null;
|
|
191
237
|
}
|
|
192
|
-
var
|
|
193
|
-
function
|
|
238
|
+
var u = .1;
|
|
239
|
+
function d(e) {
|
|
194
240
|
let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.max(t, n, r), a = Math.min(t, n, r), o = (i + a) / 2;
|
|
195
241
|
if (i === a) return [
|
|
196
242
|
0,
|
|
@@ -204,25 +250,25 @@ function c(e) {
|
|
|
204
250
|
o
|
|
205
251
|
];
|
|
206
252
|
}
|
|
207
|
-
function
|
|
208
|
-
let n = e[1] <
|
|
253
|
+
function f(e, t) {
|
|
254
|
+
let n = e[1] < u, r = t[1] < u;
|
|
209
255
|
if (n && r) {
|
|
210
256
|
let n = Math.abs(e[2] - t[2]);
|
|
211
257
|
return n * n;
|
|
212
258
|
}
|
|
213
259
|
if (n !== r) return 1e3;
|
|
214
|
-
let i = Math.abs(e[0] - t[0]), a = Math.min(i, 360 - i) / 180, o = Math.abs(e[1] - t[1]),
|
|
215
|
-
return 8 * a * a + 1 * o * o + 1 *
|
|
260
|
+
let i = Math.abs(e[0] - t[0]), a = Math.min(i, 360 - i) / 180, o = Math.abs(e[1] - t[1]), s = Math.abs(e[2] - t[2]);
|
|
261
|
+
return 8 * a * a + 1 * o * o + 1 * s * s;
|
|
216
262
|
}
|
|
217
|
-
function
|
|
263
|
+
function p(t, r) {
|
|
218
264
|
if (r === "bg" && (n(t) || i(t))) return t;
|
|
219
|
-
let a =
|
|
265
|
+
let a = l(t);
|
|
220
266
|
if (a === null) return t;
|
|
221
|
-
let
|
|
267
|
+
let o = d(a);
|
|
222
268
|
return e.reduce((e, t) => {
|
|
223
|
-
let n =
|
|
269
|
+
let n = l(t[r]);
|
|
224
270
|
if (n === null) return e;
|
|
225
|
-
let i =
|
|
271
|
+
let i = f(o, d(n));
|
|
226
272
|
return i < e.distance ? {
|
|
227
273
|
color: t[r],
|
|
228
274
|
distance: i
|
|
@@ -232,15 +278,15 @@ function u(t, r) {
|
|
|
232
278
|
distance: Infinity
|
|
233
279
|
}).color;
|
|
234
280
|
}
|
|
235
|
-
function
|
|
281
|
+
function m(r, a) {
|
|
236
282
|
if (a === "bg" && (n(r) || i(r))) return null;
|
|
237
|
-
let
|
|
238
|
-
if (
|
|
239
|
-
let
|
|
283
|
+
let o = l(r);
|
|
284
|
+
if (o === null) return null;
|
|
285
|
+
let s = d(o);
|
|
240
286
|
return [...e, ...t].reduce((e, t) => {
|
|
241
|
-
let n =
|
|
287
|
+
let n = l(t[a]);
|
|
242
288
|
if (n === null) return e;
|
|
243
|
-
let r =
|
|
289
|
+
let r = f(s, d(n));
|
|
244
290
|
return e === null || r < e.distance ? {
|
|
245
291
|
name: t.name,
|
|
246
292
|
distance: r
|
|
@@ -249,7 +295,7 @@ function d(r, a) {
|
|
|
249
295
|
}
|
|
250
296
|
//#endregion
|
|
251
297
|
//#region src/shared/inline-normalization-policy.ts
|
|
252
|
-
var
|
|
298
|
+
var h = /* @__PURE__ */ new Set([
|
|
253
299
|
"A",
|
|
254
300
|
"B",
|
|
255
301
|
"STRONG",
|
|
@@ -266,7 +312,7 @@ var f = /* @__PURE__ */ new Set([
|
|
|
266
312
|
"SMALL",
|
|
267
313
|
"SPAN",
|
|
268
314
|
"FONT"
|
|
269
|
-
]),
|
|
315
|
+
]), ee = new Set([...h].filter((e) => e !== "A")), g = /* @__PURE__ */ new Set([
|
|
270
316
|
"IMG",
|
|
271
317
|
"IFRAME",
|
|
272
318
|
"VIDEO",
|
|
@@ -276,12 +322,12 @@ var f = /* @__PURE__ */ new Set([
|
|
|
276
322
|
"CANVAS",
|
|
277
323
|
"OBJECT",
|
|
278
324
|
"EMBED"
|
|
279
|
-
]),
|
|
325
|
+
]), _ = /* @__PURE__ */ new Set([
|
|
280
326
|
"U",
|
|
281
327
|
"S",
|
|
282
328
|
"DEL",
|
|
283
329
|
"INS"
|
|
284
|
-
]),
|
|
330
|
+
]), te = /* @__PURE__ */ new Set([
|
|
285
331
|
"background-color",
|
|
286
332
|
"background",
|
|
287
333
|
"text-decoration",
|
|
@@ -290,24 +336,24 @@ var f = /* @__PURE__ */ new Set([
|
|
|
290
336
|
"border-bottom",
|
|
291
337
|
"box-shadow",
|
|
292
338
|
"outline"
|
|
293
|
-
]),
|
|
339
|
+
]), v = /* @__PURE__ */ new Set([
|
|
294
340
|
"",
|
|
295
341
|
"none",
|
|
296
342
|
"transparent",
|
|
297
343
|
"initial",
|
|
298
344
|
"unset"
|
|
299
|
-
]),
|
|
345
|
+
]), y = (e) => {
|
|
300
346
|
let t = e.attributes.filter((e) => e.name.toLowerCase() !== "style").map((e) => `${e.name.toLowerCase()}=${e.value}`).sort(), n = e.styleDeclarations.map((e) => `${e.property.toLowerCase()}:${e.value.trim()}`).sort();
|
|
301
347
|
return `${e.tagName}|${t.join("|")}|${n.join(";")}`;
|
|
302
|
-
},
|
|
303
|
-
if (!
|
|
348
|
+
}, b = (e) => e.attributes.some((e) => e.name.toLowerCase() === "id"), x = (e) => _.has(e.tagName) ? !0 : e.styleDeclarations.some((e) => te.has(e.property.toLowerCase()) && !v.has(e.value.trim().toLowerCase())), S = (e) => {
|
|
349
|
+
if (!ee.has(e.tagName)) return !1;
|
|
304
350
|
let t = e.text();
|
|
305
|
-
return t.trim().length > 0 || e.hasVoidContentDescendant() ? !1 : t.length === 0 || !
|
|
306
|
-
},
|
|
307
|
-
if (!
|
|
308
|
-
let n =
|
|
309
|
-
return t.some((e) =>
|
|
310
|
-
},
|
|
351
|
+
return t.trim().length > 0 || e.hasVoidContentDescendant() ? !1 : t.length === 0 || !x(e);
|
|
352
|
+
}, C = (e, t) => !h.has(e.tagName) || b(e) || b(t) ? !1 : y(e) === y(t), ne = (e, t) => {
|
|
353
|
+
if (!h.has(e.tagName) || b(e)) return !1;
|
|
354
|
+
let n = y(e);
|
|
355
|
+
return t.some((e) => y(e) === n);
|
|
356
|
+
}, w = (e) => {
|
|
311
357
|
let t = e.style, n = Array.from({ length: t.length }, (e, n) => {
|
|
312
358
|
let r = t.item(n);
|
|
313
359
|
return {
|
|
@@ -323,70 +369,76 @@ var f = /* @__PURE__ */ new Set([
|
|
|
323
369
|
})),
|
|
324
370
|
styleDeclarations: n,
|
|
325
371
|
text: () => e.textContent ?? "",
|
|
326
|
-
hasVoidContentDescendant: () => Array.from(e.querySelectorAll("*")).some((e) =>
|
|
372
|
+
hasVoidContentDescendant: () => Array.from(e.querySelectorAll("*")).some((e) => g.has(e.tagName.toUpperCase()))
|
|
327
373
|
};
|
|
328
|
-
},
|
|
374
|
+
}, T = (e, t) => {
|
|
329
375
|
let n = e.parentElement;
|
|
330
|
-
return n === null || n === t ? [] : [
|
|
331
|
-
},
|
|
376
|
+
return n === null || n === t ? [] : [w(n), ...T(n, t)];
|
|
377
|
+
}, E = (e) => {
|
|
332
378
|
let t = e.parentNode;
|
|
333
379
|
if (t !== null) {
|
|
334
380
|
for (; e.firstChild !== null;) t.insertBefore(e.firstChild, e);
|
|
335
381
|
t.removeChild(e);
|
|
336
382
|
}
|
|
337
|
-
},
|
|
338
|
-
let t = (t) => e.contains(t), n = (e) => t(e) &&
|
|
383
|
+
}, D = (e) => {
|
|
384
|
+
let t = (t) => e.contains(t), n = (e) => t(e) && h.has(e.tagName.toUpperCase()), r = Array.from(e.querySelectorAll("*")).filter((t) => {
|
|
339
385
|
if (!n(t)) return !1;
|
|
340
|
-
let r =
|
|
341
|
-
return
|
|
386
|
+
let r = w(t);
|
|
387
|
+
return S(r) || ne(r, T(t, e));
|
|
342
388
|
});
|
|
343
|
-
r.forEach(
|
|
389
|
+
r.forEach(E);
|
|
344
390
|
let i = (e, t) => {
|
|
345
391
|
let n = e.nextSibling;
|
|
346
|
-
if (n === null || n.nodeType !== Node.ELEMENT_NODE || !
|
|
392
|
+
if (n === null || n.nodeType !== Node.ELEMENT_NODE || !C(t, w(n))) return !1;
|
|
347
393
|
let r = n;
|
|
348
394
|
for (; r.firstChild !== null;) e.appendChild(r.firstChild);
|
|
349
395
|
return r.remove(), i(e, t), !0;
|
|
350
|
-
}, a = Array.from(e.querySelectorAll("*")).filter(n).map((e) => t(e) && i(e,
|
|
396
|
+
}, a = Array.from(e.querySelectorAll("*")).filter(n).map((e) => t(e) && i(e, w(e))).some(Boolean);
|
|
351
397
|
return r.length > 0 || a;
|
|
352
|
-
},
|
|
353
|
-
let t = (n) => n === 0 || !
|
|
398
|
+
}, O = (e) => {
|
|
399
|
+
let t = (n) => n === 0 || !D(e) ? !1 : (t(n - 1), !0), n = t(10);
|
|
354
400
|
return n && e.normalize?.(), n;
|
|
355
401
|
};
|
|
356
402
|
//#endregion
|
|
357
|
-
//#region src/
|
|
358
|
-
function
|
|
359
|
-
|
|
403
|
+
//#region src/components/utils/spacer-paragraph.ts
|
|
404
|
+
function k(e, t = {}) {
|
|
405
|
+
let { lineBreaksAreContent: n = !0 } = t, r = Array.from(e.children);
|
|
406
|
+
return !(n ? r.length > 0 : r.some((e) => e.tagName !== "BR")) && (e.textContent ?? "").replace(/\s/g, "") === "";
|
|
360
407
|
}
|
|
361
|
-
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/preprocess/legacy-cms-html.ts
|
|
410
|
+
function A(e) {
|
|
411
|
+
j(e), F(e), z(e), V(e), H(e), W(e);
|
|
412
|
+
}
|
|
413
|
+
function j(e) {
|
|
362
414
|
let t = e.ownerDocument;
|
|
363
415
|
for (let n of Array.from(e.querySelectorAll("div[style]"))) {
|
|
364
416
|
if (n.closest("table")) continue;
|
|
365
|
-
let e =
|
|
366
|
-
if (!e ||
|
|
417
|
+
let e = R(n);
|
|
418
|
+
if (!e || I(e)) continue;
|
|
367
419
|
let r = t.createElement("aside");
|
|
368
|
-
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)),
|
|
420
|
+
r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), M(r), N(r), n.replaceWith(r);
|
|
369
421
|
}
|
|
370
422
|
}
|
|
371
|
-
function
|
|
423
|
+
function M(e) {
|
|
372
424
|
for (;;) {
|
|
373
425
|
let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
|
|
374
426
|
if (t.length === 0) break;
|
|
375
427
|
for (let e of t) e.replaceWith(...Array.from(e.childNodes));
|
|
376
428
|
}
|
|
377
429
|
}
|
|
378
|
-
function
|
|
430
|
+
function N(e) {
|
|
379
431
|
for (let t of Array.from(e.querySelectorAll("p"))) {
|
|
380
432
|
let e = t.lastElementChild;
|
|
381
433
|
e?.tagName === "BR" && e.remove();
|
|
382
434
|
}
|
|
383
435
|
}
|
|
384
|
-
var
|
|
385
|
-
function
|
|
436
|
+
var P = 250;
|
|
437
|
+
function F(e) {
|
|
386
438
|
let t = e.querySelectorAll("[style*=\"background-color\"]");
|
|
387
|
-
for (let e of Array.from(t))
|
|
439
|
+
for (let e of Array.from(t)) I(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), L(e) && e.replaceWith(...Array.from(e.childNodes)));
|
|
388
440
|
}
|
|
389
|
-
function
|
|
441
|
+
function I(e) {
|
|
390
442
|
if (!e) return !1;
|
|
391
443
|
let t = e.replace(/\s/g, "").toLowerCase();
|
|
392
444
|
if (t === "transparent") return !0;
|
|
@@ -394,12 +446,12 @@ function M(e) {
|
|
|
394
446
|
if (!n) return !1;
|
|
395
447
|
if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
|
|
396
448
|
let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
|
|
397
|
-
return r >=
|
|
449
|
+
return r >= P && i >= P && a >= P;
|
|
398
450
|
}
|
|
399
|
-
function
|
|
451
|
+
function L(e) {
|
|
400
452
|
return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
|
|
401
453
|
}
|
|
402
|
-
function
|
|
454
|
+
function R(e) {
|
|
403
455
|
if (e.style.backgroundColor) return e.style.backgroundColor;
|
|
404
456
|
let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
|
|
405
457
|
if (t) {
|
|
@@ -408,16 +460,16 @@ function P(e) {
|
|
|
408
460
|
}
|
|
409
461
|
return "";
|
|
410
462
|
}
|
|
411
|
-
function
|
|
463
|
+
function z(e) {
|
|
412
464
|
for (let t of Array.from(e.querySelectorAll("td, th"))) {
|
|
413
465
|
let e = t.querySelectorAll("p");
|
|
414
466
|
if (e.length !== 0) {
|
|
415
|
-
for (let t of Array.from(e))
|
|
416
|
-
|
|
467
|
+
for (let t of Array.from(e)) B(t);
|
|
468
|
+
q(t);
|
|
417
469
|
}
|
|
418
470
|
}
|
|
419
471
|
}
|
|
420
|
-
function
|
|
472
|
+
function B(e) {
|
|
421
473
|
if (e.innerHTML.trim() === "" || e.innerHTML.trim() === " ") {
|
|
422
474
|
e.remove();
|
|
423
475
|
return;
|
|
@@ -425,45 +477,45 @@ function I(e) {
|
|
|
425
477
|
let t = e.ownerDocument, n = t.createDocumentFragment();
|
|
426
478
|
n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
|
|
427
479
|
}
|
|
428
|
-
function
|
|
429
|
-
for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || (t
|
|
480
|
+
function V(e) {
|
|
481
|
+
for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || k(t, { lineBreaksAreContent: !1 }) && t.remove();
|
|
430
482
|
}
|
|
431
|
-
function
|
|
483
|
+
function H(e) {
|
|
432
484
|
let t = e.ownerDocument;
|
|
433
485
|
for (let n of Array.from(e.querySelectorAll("del, strike"))) {
|
|
434
486
|
let e = t.createElement("s");
|
|
435
487
|
e.append(...Array.from(n.childNodes)), n.replaceWith(e);
|
|
436
488
|
}
|
|
437
489
|
}
|
|
438
|
-
var
|
|
439
|
-
function
|
|
440
|
-
let t = e.ownerDocument, n =
|
|
490
|
+
var U = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
|
|
491
|
+
function W(e) {
|
|
492
|
+
let t = e.ownerDocument, n = G(e);
|
|
441
493
|
for (let e of n) {
|
|
442
494
|
let n = t.createElement("ul");
|
|
443
495
|
e[0].before(n);
|
|
444
|
-
for (let t of e)
|
|
496
|
+
for (let t of e) re(t, n);
|
|
445
497
|
}
|
|
446
498
|
}
|
|
447
|
-
function
|
|
448
|
-
let n = e.ownerDocument.createElement("li"), r =
|
|
449
|
-
r && (r.textContent = (r.textContent ?? "").replace(
|
|
499
|
+
function re(e, t) {
|
|
500
|
+
let n = e.ownerDocument.createElement("li"), r = J(e);
|
|
501
|
+
r && (r.textContent = (r.textContent ?? "").replace(U, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
|
|
450
502
|
}
|
|
451
|
-
function
|
|
503
|
+
function G(e) {
|
|
452
504
|
let t = [], n = Array.from(e.childNodes);
|
|
453
505
|
for (let e of n) {
|
|
454
506
|
if (e.nodeType !== Node.ELEMENT_NODE) continue;
|
|
455
507
|
let n = e;
|
|
456
|
-
if (!(n.tagName === "P" &&
|
|
457
|
-
let r = t[t.length - 1], i =
|
|
508
|
+
if (!(n.tagName === "P" && U.test(n.textContent ?? ""))) continue;
|
|
509
|
+
let r = t[t.length - 1], i = K(n);
|
|
458
510
|
r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
|
|
459
511
|
}
|
|
460
512
|
return t;
|
|
461
513
|
}
|
|
462
|
-
function
|
|
514
|
+
function K(e) {
|
|
463
515
|
let t = e.previousSibling;
|
|
464
516
|
return t && t.nodeType === Node.ELEMENT_NODE ? t : null;
|
|
465
517
|
}
|
|
466
|
-
function
|
|
518
|
+
function q(e) {
|
|
467
519
|
for (;;) {
|
|
468
520
|
let t = e.lastChild;
|
|
469
521
|
if (!t) break;
|
|
@@ -472,17 +524,17 @@ function U(e) {
|
|
|
472
524
|
t.remove();
|
|
473
525
|
}
|
|
474
526
|
}
|
|
475
|
-
function
|
|
527
|
+
function J(e) {
|
|
476
528
|
if (e.nodeType === Node.TEXT_NODE) return e;
|
|
477
529
|
for (let t of Array.from(e.childNodes)) {
|
|
478
|
-
let e =
|
|
530
|
+
let e = J(t);
|
|
479
531
|
if (e) return e;
|
|
480
532
|
}
|
|
481
533
|
return null;
|
|
482
534
|
}
|
|
483
535
|
//#endregion
|
|
484
536
|
//#region src/cli/commands/convert-html/sanitizer.ts
|
|
485
|
-
var
|
|
537
|
+
var Y = {
|
|
486
538
|
B: !0,
|
|
487
539
|
STRONG: !0,
|
|
488
540
|
I: !0,
|
|
@@ -517,32 +569,32 @@ var G = {
|
|
|
517
569
|
SUMMARY: !0,
|
|
518
570
|
IMG: /* @__PURE__ */ new Set(["src", "style"])
|
|
519
571
|
};
|
|
520
|
-
function
|
|
521
|
-
|
|
572
|
+
function X(e) {
|
|
573
|
+
Z(e);
|
|
522
574
|
}
|
|
523
|
-
function
|
|
575
|
+
function ie(e) {
|
|
524
576
|
let t = Array.from(e.childNodes);
|
|
525
577
|
for (let n of t) e.before(n);
|
|
526
578
|
return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
|
|
527
579
|
}
|
|
528
|
-
function
|
|
580
|
+
function ae(e, t) {
|
|
529
581
|
for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
|
|
530
582
|
}
|
|
531
|
-
function
|
|
583
|
+
function Z(e) {
|
|
532
584
|
let t = Array.from(e.childNodes);
|
|
533
585
|
for (let e of t) {
|
|
534
586
|
if (e.nodeType !== e.ELEMENT_NODE) continue;
|
|
535
|
-
let n = e, r =
|
|
587
|
+
let n = e, r = Y[n.tagName];
|
|
536
588
|
if (r === void 0) {
|
|
537
|
-
t.push(...
|
|
589
|
+
t.push(...ie(n));
|
|
538
590
|
continue;
|
|
539
591
|
}
|
|
540
|
-
|
|
592
|
+
ae(n, r), Z(n);
|
|
541
593
|
}
|
|
542
594
|
}
|
|
543
595
|
//#endregion
|
|
544
596
|
//#region src/cli/commands/convert-html/id-generator.ts
|
|
545
|
-
function
|
|
597
|
+
function oe() {
|
|
546
598
|
let e = /* @__PURE__ */ new Map();
|
|
547
599
|
return (t) => {
|
|
548
600
|
let n = (e.get(t) ?? 0) + 1;
|
|
@@ -551,12 +603,12 @@ function X() {
|
|
|
551
603
|
}
|
|
552
604
|
//#endregion
|
|
553
605
|
//#region src/cli/commands/convert-html/block-builder.ts
|
|
554
|
-
function
|
|
555
|
-
let t =
|
|
556
|
-
for (let r of Array.from(e.childNodes))
|
|
606
|
+
function se(e) {
|
|
607
|
+
let t = oe(), n = [];
|
|
608
|
+
for (let r of Array.from(e.childNodes)) ce(r, n, t);
|
|
557
609
|
return n;
|
|
558
610
|
}
|
|
559
|
-
function
|
|
611
|
+
function ce(e, t, n) {
|
|
560
612
|
if (e.nodeType === Node.TEXT_NODE) {
|
|
561
613
|
let r = e.textContent?.trim() ?? "";
|
|
562
614
|
r && t.push({
|
|
@@ -619,7 +671,7 @@ function ae(e, t, n) {
|
|
|
619
671
|
return;
|
|
620
672
|
}
|
|
621
673
|
if (i === "IMG") {
|
|
622
|
-
let e = r.getAttribute("src") ?? "", i =
|
|
674
|
+
let e = r.getAttribute("src") ?? "", i = pe(r, "width");
|
|
623
675
|
t.push({
|
|
624
676
|
id: n("image"),
|
|
625
677
|
type: "image",
|
|
@@ -640,15 +692,15 @@ function ae(e, t, n) {
|
|
|
640
692
|
return;
|
|
641
693
|
}
|
|
642
694
|
if (i === "UL" || i === "OL") {
|
|
643
|
-
|
|
695
|
+
Q(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
|
|
644
696
|
return;
|
|
645
697
|
}
|
|
646
698
|
if (i === "TABLE") {
|
|
647
|
-
|
|
699
|
+
le(r, t, n);
|
|
648
700
|
return;
|
|
649
701
|
}
|
|
650
702
|
if (i === "ASIDE") {
|
|
651
|
-
|
|
703
|
+
ue(r, t, n);
|
|
652
704
|
return;
|
|
653
705
|
}
|
|
654
706
|
t.push({
|
|
@@ -657,7 +709,7 @@ function ae(e, t, n) {
|
|
|
657
709
|
data: { text: r.innerHTML }
|
|
658
710
|
});
|
|
659
711
|
}
|
|
660
|
-
function
|
|
712
|
+
function Q(e, t, n, r, i) {
|
|
661
713
|
let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
|
|
662
714
|
for (let [e, a] of s.entries()) {
|
|
663
715
|
let s = a.cloneNode(!0), c = [];
|
|
@@ -674,13 +726,13 @@ function Z(e, t, n, r, i) {
|
|
|
674
726
|
start: e === 0 && o !== null ? o : null
|
|
675
727
|
}
|
|
676
728
|
});
|
|
677
|
-
for (let e of c)
|
|
729
|
+
for (let e of c) Q(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
|
|
678
730
|
}
|
|
679
731
|
}
|
|
680
|
-
function
|
|
732
|
+
function le(e, t, n) {
|
|
681
733
|
let r = n("table"), i = Array.from(e.querySelectorAll("tr")), a = [];
|
|
682
734
|
for (let e of i) {
|
|
683
|
-
let i = Array.from(e.querySelectorAll("td, th")).map((e) =>
|
|
735
|
+
let i = Array.from(e.querySelectorAll("td, th")).map((e) => de(e, r, t, n));
|
|
684
736
|
a.push(i);
|
|
685
737
|
}
|
|
686
738
|
let o = i[0] ? Array.from(i[0].querySelectorAll("td, th")) : [], s = o.some((e) => e.tagName === "TH"), c = o.map((e) => {
|
|
@@ -702,10 +754,10 @@ function oe(e, t, n) {
|
|
|
702
754
|
}, u = t.findIndex((e) => e.parent === r);
|
|
703
755
|
u >= 0 ? t.splice(u, 0, l) : t.push(l);
|
|
704
756
|
}
|
|
705
|
-
function
|
|
706
|
-
let a = r("callout"), o = $(e, "background-color"), s = o && !n(o) && !i(o) ?
|
|
757
|
+
function ue(e, t, r) {
|
|
758
|
+
let a = r("callout"), o = $(e, "background-color"), s = o && !n(o) && !i(o) ? m(o, "bg") : null, c = [];
|
|
707
759
|
for (let n of Array.from(e.childNodes)) {
|
|
708
|
-
let e =
|
|
760
|
+
let e = fe(n, a, t, r);
|
|
709
761
|
e && c.push(e);
|
|
710
762
|
}
|
|
711
763
|
let l = t.findIndex((e) => e.parent === a), u = {
|
|
@@ -719,7 +771,7 @@ function se(e, t, r) {
|
|
|
719
771
|
};
|
|
720
772
|
l >= 0 ? t.splice(l, 0, u) : t.push(u);
|
|
721
773
|
}
|
|
722
|
-
function
|
|
774
|
+
function de(e, t, r, a) {
|
|
723
775
|
let o = e.innerHTML.trim();
|
|
724
776
|
if (!o) return {
|
|
725
777
|
blocks: [],
|
|
@@ -733,14 +785,14 @@ function Q(e, t, r, a) {
|
|
|
733
785
|
parent: t,
|
|
734
786
|
data: { text: o }
|
|
735
787
|
});
|
|
736
|
-
let c = $(e, "background-color"), l = $(e, "color"), u = c && !n(c) && !i(c) ?
|
|
788
|
+
let c = $(e, "background-color"), l = $(e, "color"), u = c && !n(c) && !i(c) ? m(c, "bg") : null;
|
|
737
789
|
return {
|
|
738
790
|
blocks: [s],
|
|
739
791
|
color: u,
|
|
740
|
-
textColor: l ?
|
|
792
|
+
textColor: l ? m(l, "text") : null
|
|
741
793
|
};
|
|
742
794
|
}
|
|
743
|
-
function
|
|
795
|
+
function fe(e, t, n, r) {
|
|
744
796
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
745
797
|
let i = e, a = r("paragraph");
|
|
746
798
|
return n.push({
|
|
@@ -763,7 +815,7 @@ function ce(e, t, n, r) {
|
|
|
763
815
|
}
|
|
764
816
|
return null;
|
|
765
817
|
}
|
|
766
|
-
function
|
|
818
|
+
function pe(e, t) {
|
|
767
819
|
let n = $(e, t);
|
|
768
820
|
if (!n) return null;
|
|
769
821
|
let r = parseInt(n, 10);
|
|
@@ -776,4 +828,4 @@ function $(e, t) {
|
|
|
776
828
|
return r ? r[1].trim() : null;
|
|
777
829
|
}
|
|
778
830
|
//#endregion
|
|
779
|
-
export {
|
|
831
|
+
export { O as a, k as i, X as n, p as o, A as r, s, se as t };
|
package/dist/cli.mjs
CHANGED
|
@@ -41,14 +41,14 @@ var t = "# Migrating from EditorJS to Blok\n\nThis guide covers the breaking cha
|
|
|
41
41
|
case "convert-html": {
|
|
42
42
|
let e = new (await (import("jsdom"))).JSDOM("");
|
|
43
43
|
globalThis.DOMParser = e.window.DOMParser, globalThis.Node = e.window.Node;
|
|
44
|
-
let { convertHtml: t } = await import("./convert-html-
|
|
44
|
+
let { convertHtml: t } = await import("./convert-html-DEW3D-Ub.mjs");
|
|
45
45
|
r(t((await import("node:fs")).readFileSync(0, "utf-8")), s);
|
|
46
46
|
break;
|
|
47
47
|
}
|
|
48
48
|
case "convert-gdocs": {
|
|
49
49
|
let e = new (await (import("jsdom"))).JSDOM("");
|
|
50
50
|
globalThis.DOMParser = e.window.DOMParser, globalThis.Node = e.window.Node, globalThis.document = e.window.document;
|
|
51
|
-
let { convertGdocs: t } = await import("./convert-gdocs
|
|
51
|
+
let { convertGdocs: t } = await import("./convert-gdocs--8aPMm3f.mjs");
|
|
52
52
|
r(t((await import("node:fs")).readFileSync(0, "utf-8")), s);
|
|
53
53
|
break;
|
|
54
54
|
}
|