@jackuait/blok 0.6.0-beta.1 → 0.6.0-beta.4
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/blok.mjs +2 -2
- package/dist/chunks/{blok-BCb-TePJ.mjs → blok-DK-97ZTf.mjs} +4 -4
- package/dist/chunks/{i18next-loader-O9hLUUxC.mjs → i18next-loader-CRollibS.mjs} +1 -1
- package/dist/chunks/{index-B9OatijR.mjs → index-jgHmMDND.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-Y0pOGkpb.mjs → inline-tool-convert-BIwvipPw.mjs} +1 -1
- package/dist/full.mjs +2 -2
- package/dist/tools.mjs +58 -44
- package/package.json +1 -1
- package/src/tools/table/table-operations.ts +19 -0
package/dist/blok.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as s, v as a } from "./chunks/blok-
|
|
2
|
-
import { D as A } from "./chunks/inline-tool-convert-
|
|
1
|
+
import { B as s, v as a } from "./chunks/blok-DK-97ZTf.mjs";
|
|
2
|
+
import { D as A } from "./chunks/inline-tool-convert-BIwvipPw.mjs";
|
|
3
3
|
export {
|
|
4
4
|
s as Blok,
|
|
5
5
|
A as DATA_ATTR,
|
|
@@ -20,7 +20,7 @@ var Co = (s, t) => {
|
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
22
|
var Ie = (s, t, e) => Io(s, typeof t != "symbol" ? t + "" : t, e);
|
|
23
|
-
import { L as ho, l as I, c as Zi, i as U, a as k, S as w, D as y, t as R, b as C, P as X, E as yn, g as wt, d as Ji, e as gr, f as Ye, h as st, j as A, k as le, m as zt, n as kr, s as Qi, o as uo, p as Bn, q as wn, r as T, u as Ko, v as hs, F as ae, w as Vo, x as ds, y as us, z as ut, A as tl, B as el, C as ol, I as nl, G as Wo, H as $e, J as Ke, K as Mt, M as br, N as Rt, O as K, Q as Ht, R as sl, T as rl, U as ps, V as il, W as ll, X as al, Y as cl, Z as hl, _ as mr, $ as dl, a0 as yr, a1 as Br, a2 as It, a3 as ul, a4 as wr, a5 as vr, a6 as pl, a7 as fl, a8 as gl, a9 as kl, aa as bl, ab as ml, ac as fs, ad as xr, ae as yl, af as Bl, ag as wl, ah as vl, ai as xl, aj as Tl, ak as Sl, al as Il } from "./inline-tool-convert-
|
|
23
|
+
import { L as ho, l as I, c as Zi, i as U, a as k, S as w, D as y, t as R, b as C, P as X, E as yn, g as wt, d as Ji, e as gr, f as Ye, h as st, j as A, k as le, m as zt, n as kr, s as Qi, o as uo, p as Bn, q as wn, r as T, u as Ko, v as hs, F as ae, w as Vo, x as ds, y as us, z as ut, A as tl, B as el, C as ol, I as nl, G as Wo, H as $e, J as Ke, K as Mt, M as br, N as Rt, O as K, Q as Ht, R as sl, T as rl, U as ps, V as il, W as ll, X as al, Y as cl, Z as hl, _ as mr, $ as dl, a0 as yr, a1 as Br, a2 as It, a3 as ul, a4 as wr, a5 as vr, a6 as pl, a7 as fl, a8 as gl, a9 as kl, aa as bl, ab as ml, ac as fs, ad as xr, ae as yl, af as Bl, ag as wl, ah as vl, ai as xl, aj as Tl, ak as Sl, al as Il } from "./inline-tool-convert-BIwvipPw.mjs";
|
|
24
24
|
function Cl(s) {
|
|
25
25
|
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
26
26
|
}
|
|
@@ -1728,7 +1728,7 @@ class Kl {
|
|
|
1728
1728
|
* @returns {Promise<NotifierModule>} loaded notifier module
|
|
1729
1729
|
*/
|
|
1730
1730
|
loadNotifierModule() {
|
|
1731
|
-
return this.notifierModule !== null ? Promise.resolve(this.notifierModule) : (this.loadingPromise === null && (this.loadingPromise = import("./index-
|
|
1731
|
+
return this.notifierModule !== null ? Promise.resolve(this.notifierModule) : (this.loadingPromise === null && (this.loadingPromise = import("./index-jgHmMDND.mjs").then((t) => {
|
|
1732
1732
|
const e = t;
|
|
1733
1733
|
if (!this.isNotifierModule(e))
|
|
1734
1734
|
throw new Error('notifier module does not expose a "show" method.');
|
|
@@ -13503,7 +13503,7 @@ class nu extends x {
|
|
|
13503
13503
|
async ensureI18nextLoaded(t, e) {
|
|
13504
13504
|
if (this.i18nextWrapper !== null)
|
|
13505
13505
|
return;
|
|
13506
|
-
const { loadI18next: o } = await import("./i18next-loader-
|
|
13506
|
+
const { loadI18next: o } = await import("./i18next-loader-CRollibS.mjs");
|
|
13507
13507
|
this.i18nextWrapper = await o(t, e);
|
|
13508
13508
|
}
|
|
13509
13509
|
/**
|
|
@@ -13677,7 +13677,7 @@ class Te {
|
|
|
13677
13677
|
* Process paste of single Block tool content.
|
|
13678
13678
|
*/
|
|
13679
13679
|
async processSingleBlock(t, e) {
|
|
13680
|
-
const { Caret: o, BlockManager: n } = this.Blok, { currentBlock: r } = n, { Dom: i } = await import("./inline-tool-convert-
|
|
13680
|
+
const { Caret: o, BlockManager: n } = this.Blok, { currentBlock: r } = n, { Dom: i } = await import("./inline-tool-convert-BIwvipPw.mjs").then((a) => a.aI), l = i;
|
|
13681
13681
|
if (!r || t.tool !== r.name || !l.containsOnlyInlineElements(t.content.innerHTML)) {
|
|
13682
13682
|
await this.insertBlock(t, e);
|
|
13683
13683
|
return;
|
|
@@ -278,7 +278,7 @@ const d = {
|
|
|
278
278
|
DELETE: 46
|
|
279
279
|
}, Ae = {
|
|
280
280
|
LEFT: 0
|
|
281
|
-
}, Se = 650, Wt = () => "0.6.0-beta.
|
|
281
|
+
}, Se = 650, Wt = () => "0.6.0-beta.4";
|
|
282
282
|
var Vt = /* @__PURE__ */ ((n) => (n.VERBOSE = "VERBOSE", n.INFO = "INFO", n.WARN = "WARN", n.ERROR = "ERROR", n))(Vt || {});
|
|
283
283
|
const V = (n, t, e = "log", o, s = "color: inherit") => {
|
|
284
284
|
const i = typeof console == "undefined" ? void 0 : console;
|
package/dist/full.mjs
CHANGED
|
@@ -12,8 +12,8 @@ var e = (a, l, o) => l in a ? n(a, l, { enumerable: !0, configurable: !0, writab
|
|
|
12
12
|
}, r = (a, l) => t(a, c(l));
|
|
13
13
|
import { List as p, Header as f, Paragraph as I, Link as k, Italic as u, Bold as B } from "./tools.mjs";
|
|
14
14
|
import { defaultBlockTools as v, defaultInlineTools as A } from "./tools.mjs";
|
|
15
|
-
import { B as H, v as P } from "./chunks/blok-
|
|
16
|
-
import { D as _ } from "./chunks/inline-tool-convert-
|
|
15
|
+
import { B as H, v as P } from "./chunks/blok-DK-97ZTf.mjs";
|
|
16
|
+
import { D as _ } from "./chunks/inline-tool-convert-BIwvipPw.mjs";
|
|
17
17
|
const m = {
|
|
18
18
|
paragraph: {
|
|
19
19
|
class: I,
|
package/dist/tools.mjs
CHANGED
|
@@ -10,8 +10,8 @@ var kt = (i, t, e) => t in i ? Ee(i, t, { enumerable: !0, configurable: !0, writ
|
|
|
10
10
|
Le.call(t, e) && kt(i, e, t[e]);
|
|
11
11
|
return i;
|
|
12
12
|
}, tt = (i, t) => ke(i, xe(t));
|
|
13
|
-
import { t as v, D as E, am as Re, an as Be, _ as Ie, ao as De, ap as Ne, aq as Pe, ar as _e, as as He, at as Me, au as te, av as ee, aw as ne, o as Oe, p as xt, a5 as Tt, a3 as $e, J as se, ax as Ge, Q as oe, P as F, ay as We, az as qe, a0 as Lt, aA as Fe, aB as ze, aC as Ve, aD as Ue, aE as Ke, z as O, aF as je, aG as Xe, S as et, aH as Ye, l as Ze, a8 as Je } from "./chunks/inline-tool-convert-
|
|
14
|
-
import { ab as fo } from "./chunks/inline-tool-convert-
|
|
13
|
+
import { t as v, D as E, am as Re, an as Be, _ as Ie, ao as De, ap as Ne, aq as Pe, ar as _e, as as He, at as Me, au as te, av as ee, aw as ne, o as Oe, p as xt, a5 as Tt, a3 as $e, J as se, ax as Ge, Q as oe, P as F, ay as We, az as qe, a0 as Lt, aA as Fe, aB as ze, aC as Ve, aD as Ue, aE as Ke, z as O, aF as je, aG as Xe, S as et, aH as Ye, l as Ze, a8 as Je } from "./chunks/inline-tool-convert-BIwvipPw.mjs";
|
|
14
|
+
import { ab as fo } from "./chunks/inline-tool-convert-BIwvipPw.mjs";
|
|
15
15
|
const ie = (i) => {
|
|
16
16
|
if (!i || !i.includes("data-blok-fake-background"))
|
|
17
17
|
return i;
|
|
@@ -327,7 +327,7 @@ const q = class q {
|
|
|
327
327
|
buildSettingsFromToolboxEntries(t) {
|
|
328
328
|
return t.map((e) => {
|
|
329
329
|
var c, d, h, p;
|
|
330
|
-
const n = e.data, s = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, o = q.DEFAULT_LEVELS.find((
|
|
330
|
+
const n = e.data, s = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, o = q.DEFAULT_LEVELS.find((m) => m.number === s), r = (d = o == null ? void 0 : o.name) != null ? d : `Heading ${s}`, l = this.resolveToolboxEntryTitle(e, r);
|
|
331
331
|
return {
|
|
332
332
|
icon: (p = (h = e.icon) != null ? h : o == null ? void 0 : o.icon) != null ? p : Be,
|
|
333
333
|
title: l,
|
|
@@ -647,10 +647,10 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
|
|
|
647
647
|
};
|
|
648
648
|
return i.start !== void 0 && i.start !== 1 && (o.start = i.start), i.depth !== void 0 && i.depth > 0 && (o.depth = i.depth), o;
|
|
649
649
|
}, Cn = (i, t, e, n, s) => {
|
|
650
|
-
var
|
|
650
|
+
var f, y, b;
|
|
651
651
|
if (!e)
|
|
652
652
|
return { newData: i, inPlace: !1 };
|
|
653
|
-
const o = (
|
|
653
|
+
const o = (f = i.depth) != null ? f : 0, r = (y = t.depth) != null ? y : 0, l = i.style, a = t.style;
|
|
654
654
|
if (l !== a)
|
|
655
655
|
return { newData: i, inPlace: !1 };
|
|
656
656
|
const c = "depth" in t ? t.depth : 0, d = tt(L(L({}, i), t), {
|
|
@@ -864,8 +864,8 @@ const Pn = (i, t) => {
|
|
|
864
864
|
const l = t.getBlockIndex(i.id);
|
|
865
865
|
if (l == null)
|
|
866
866
|
return;
|
|
867
|
-
const a = de(i, e), c = he(i, n) || "ordered", d = n.getSiblingIndex(l, a, c), p = n.getGroupStartValue(l, a, d, c) + d,
|
|
868
|
-
r.textContent =
|
|
867
|
+
const a = de(i, e), c = he(i, n) || "ordered", d = n.getSiblingIndex(l, a, c), p = n.getGroupStartValue(l, a, d, c) + d, m = n.formatNumber(p, a);
|
|
868
|
+
r.textContent = m;
|
|
869
869
|
}, $n = (i, t, e, n, s, o, r, l) => {
|
|
870
870
|
const a = (c) => {
|
|
871
871
|
if (c >= t)
|
|
@@ -912,7 +912,7 @@ const Pn = (i, t) => {
|
|
|
912
912
|
e === "start" ? (r.setStart(s, 0), r.collapse(!0)) : (r.selectNodeContents(s), r.collapse(!1)), o.removeAllRanges(), o.addRange(r), i.caret.updateLastCaretAfterPosition();
|
|
913
913
|
});
|
|
914
914
|
}, Wn = async (i) => {
|
|
915
|
-
var
|
|
915
|
+
var f;
|
|
916
916
|
const { api: t, blockId: e, data: n, element: s, getContentElement: o } = i, r = window.getSelection();
|
|
917
917
|
if (!r || !s) return;
|
|
918
918
|
const l = o();
|
|
@@ -922,7 +922,7 @@ const Pn = (i, t) => {
|
|
|
922
922
|
await qn(i);
|
|
923
923
|
return;
|
|
924
924
|
}
|
|
925
|
-
const c = r.getRangeAt(0), { beforeContent: d, afterContent: h } = An(l, c), p = e && (
|
|
925
|
+
const c = r.getRangeAt(0), { beforeContent: d, afterContent: h } = An(l, c), p = e && (f = t.blocks.getBlockIndex(e)) != null ? f : t.blocks.getCurrentBlockIndex();
|
|
926
926
|
if (!e) {
|
|
927
927
|
l.innerHTML = d, n.text = d;
|
|
928
928
|
const y = t.blocks.insert(w, {
|
|
@@ -934,7 +934,7 @@ const Pn = (i, t) => {
|
|
|
934
934
|
Y(t, y, "start");
|
|
935
935
|
return;
|
|
936
936
|
}
|
|
937
|
-
const
|
|
937
|
+
const m = t.blocks.splitBlock(
|
|
938
938
|
e,
|
|
939
939
|
{ text: d },
|
|
940
940
|
w,
|
|
@@ -946,7 +946,7 @@ const Pn = (i, t) => {
|
|
|
946
946
|
},
|
|
947
947
|
p + 1
|
|
948
948
|
);
|
|
949
|
-
n.text = d, Y(t,
|
|
949
|
+
n.text = d, Y(t, m, "start");
|
|
950
950
|
}, qn = async (i) => {
|
|
951
951
|
const { api: t, blockId: e, getDepth: n } = i;
|
|
952
952
|
if (n() > 0) {
|
|
@@ -963,7 +963,7 @@ const Pn = (i, t) => {
|
|
|
963
963
|
const d = c.getRangeAt(0), h = r();
|
|
964
964
|
if (!h) return;
|
|
965
965
|
a();
|
|
966
|
-
const p = s.text,
|
|
966
|
+
const p = s.text, m = l();
|
|
967
967
|
if (xn(h, d) && !c.isCollapsed) {
|
|
968
968
|
t.preventDefault(), h.innerHTML = "", s.text = "";
|
|
969
969
|
const b = document.createRange();
|
|
@@ -973,9 +973,9 @@ const Pn = (i, t) => {
|
|
|
973
973
|
if (!kn(h, d) || (t.preventDefault(), n === void 0))
|
|
974
974
|
return;
|
|
975
975
|
const y = await e.blocks.convert(n, "paragraph", { text: p });
|
|
976
|
-
|
|
976
|
+
m > 0 && requestAnimationFrame(() => {
|
|
977
977
|
const b = y.holder;
|
|
978
|
-
b && (b.style.marginLeft = `${
|
|
978
|
+
b && (b.style.marginLeft = `${m * V}px`, b.setAttribute("data-blok-depth", String(m)));
|
|
979
979
|
}), Y(e, y, "start");
|
|
980
980
|
}, zn = async (i, t) => {
|
|
981
981
|
const { api: e, blockId: n, data: s, syncContentFromDOM: o, getDepth: r } = i, l = e.blocks.getCurrentBlockIndex();
|
|
@@ -1311,9 +1311,9 @@ class jn {
|
|
|
1311
1311
|
if (o == null)
|
|
1312
1312
|
return;
|
|
1313
1313
|
const r = this.depthValidator.getBlockDepth(t), l = this.getBlockStyle(t) || "ordered", a = this.markerCalculator.getSiblingIndex(o, r, l), c = this.markerCalculator.getGroupStartValue(o, r, a, l), h = (a === 0 && c === 1 ? (() => {
|
|
1314
|
-
const
|
|
1315
|
-
if (!
|
|
1316
|
-
const y = parseInt(
|
|
1314
|
+
const m = n.closest("[data-list-start]"), f = m == null ? void 0 : m.getAttribute("data-list-start");
|
|
1315
|
+
if (!f) return c;
|
|
1316
|
+
const y = parseInt(f, 10);
|
|
1317
1317
|
return isNaN(y) ? c : y;
|
|
1318
1318
|
})() : c) + a, p = this.markerCalculator.formatNumber(h, r);
|
|
1319
1319
|
s.textContent = p;
|
|
@@ -1991,8 +1991,8 @@ class ps {
|
|
|
1991
1991
|
const o = 1 - 0.5 / e;
|
|
1992
1992
|
t.forEach((r) => {
|
|
1993
1993
|
r.querySelectorAll(`[${u}]`).forEach((p) => {
|
|
1994
|
-
const
|
|
1995
|
-
|
|
1994
|
+
const m = p, f = parseFloat(m.style.width) || 100 / e, y = Math.round(f * o * 100) / 100;
|
|
1995
|
+
m.style.width = `${y}%`;
|
|
1996
1996
|
});
|
|
1997
1997
|
const a = Math.round(100 / e / 2 * 100) / 100, c = r.querySelectorAll(`[${u}]`), d = n === void 0 || n >= c.length, h = this.createCell(`${a}%`);
|
|
1998
1998
|
if (!d) {
|
|
@@ -2282,8 +2282,8 @@ class gs {
|
|
|
2282
2282
|
if (fe(c))
|
|
2283
2283
|
this.mountBlocksInCell(p, c.blocks), a.push(c);
|
|
2284
2284
|
else {
|
|
2285
|
-
const
|
|
2286
|
-
p.appendChild(
|
|
2285
|
+
const m = typeof c == "string" ? c : "", f = this.api.blocks.insert("paragraph", { text: m }, {}, this.api.blocks.getBlocksCount(), !1);
|
|
2286
|
+
p.appendChild(f.holder), a.push({ blocks: [f.id] });
|
|
2287
2287
|
}
|
|
2288
2288
|
this.stripPlaceholders(p);
|
|
2289
2289
|
}
|
|
@@ -2571,10 +2571,10 @@ class As {
|
|
|
2571
2571
|
const r = (D = o[t]) == null ? void 0 : D.querySelectorAll(`[${u}]`)[n], l = (N = o[e]) == null ? void 0 : N.querySelectorAll(`[${u}]`)[s];
|
|
2572
2572
|
if (!r || !l)
|
|
2573
2573
|
return;
|
|
2574
|
-
const a = this.grid.getBoundingClientRect(), c = r.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), p = parseFloat(h.borderTopWidth) || 0,
|
|
2575
|
-
let
|
|
2574
|
+
const a = this.grid.getBoundingClientRect(), c = r.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), p = parseFloat(h.borderTopWidth) || 0, m = parseFloat(h.borderLeftWidth) || 0;
|
|
2575
|
+
let f = c.top - a.top - p, y = c.left - a.left - m;
|
|
2576
2576
|
const b = d.right - c.left + 1, I = d.bottom - c.top + 1;
|
|
2577
|
-
|
|
2577
|
+
f -= 1, y -= 1, this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = ys, this.overlay.style.pointerEvents = "none", this.overlay.style.boxSizing = "border-box", this.overlay.style.borderRadius = "2px", this.grid.appendChild(this.overlay)), this.overlay.style.top = `${f}px`, this.overlay.style.left = `${y}px`, this.overlay.style.width = `${b}px`, this.overlay.style.height = `${I}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${y + b - 1}px`, this.pill.style.top = `${f + I / 2}px`;
|
|
2578
2578
|
}
|
|
2579
2579
|
createPill() {
|
|
2580
2580
|
const t = document.createElement("div");
|
|
@@ -2645,7 +2645,7 @@ class As {
|
|
|
2645
2645
|
return l < 0 ? null : { row: o, col: l };
|
|
2646
2646
|
}
|
|
2647
2647
|
clampExtentToEdge(t) {
|
|
2648
|
-
var c, d, h, p,
|
|
2648
|
+
var c, d, h, p, m, f;
|
|
2649
2649
|
if (!this.anchorCell || !this.isSelecting)
|
|
2650
2650
|
return;
|
|
2651
2651
|
const e = this.grid.getBoundingClientRect(), n = this.grid.querySelectorAll(`[${g}]`), s = n.length, o = (d = (c = n[0]) == null ? void 0 : c.querySelectorAll(`[${u}]`).length) != null ? d : 0;
|
|
@@ -2654,7 +2654,7 @@ class As {
|
|
|
2654
2654
|
let r;
|
|
2655
2655
|
t.clientY < e.top ? r = 0 : t.clientY > e.bottom ? r = s - 1 : r = (p = (h = this.extentCell) == null ? void 0 : h.row) != null ? p : this.anchorCell.row;
|
|
2656
2656
|
let l;
|
|
2657
|
-
t.clientX < e.left ? l = 0 : t.clientX > e.right ? l = o - 1 : l = (
|
|
2657
|
+
t.clientX < e.left ? l = 0 : t.clientX > e.right ? l = o - 1 : l = (f = (m = this.extentCell) == null ? void 0 : m.col) != null ? f : this.anchorCell.col;
|
|
2658
2658
|
const a = { row: r, col: l };
|
|
2659
2659
|
(!this.extentCell || this.extentCell.row !== a.row || this.extentCell.col !== a.col) && (this.extentCell = a, this.paintSelection());
|
|
2660
2660
|
}
|
|
@@ -2783,18 +2783,32 @@ const lt = (i) => {
|
|
|
2783
2783
|
if (!d)
|
|
2784
2784
|
return;
|
|
2785
2785
|
const h = d.querySelector(`[${B}]`);
|
|
2786
|
-
if (h
|
|
2786
|
+
if (h) {
|
|
2787
|
+
if (!fe(a)) {
|
|
2788
|
+
if (h.querySelectorAll("[data-blok-id]").length > 0)
|
|
2789
|
+
return;
|
|
2790
|
+
const m = typeof a == "string" ? a : "", f = e.blocks.insert(
|
|
2791
|
+
"paragraph",
|
|
2792
|
+
{ text: m },
|
|
2793
|
+
{},
|
|
2794
|
+
void 0,
|
|
2795
|
+
!0
|
|
2796
|
+
);
|
|
2797
|
+
f != null && f.holder && h.appendChild(f.holder);
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2787
2800
|
for (const p of a.blocks) {
|
|
2788
|
-
const
|
|
2789
|
-
if (
|
|
2801
|
+
const m = e.blocks.getBlockIndex(p);
|
|
2802
|
+
if (m === void 0)
|
|
2790
2803
|
continue;
|
|
2791
|
-
const
|
|
2792
|
-
|
|
2804
|
+
const f = e.blocks.getBlockByIndex(m);
|
|
2805
|
+
f && h.appendChild(f.holder);
|
|
2793
2806
|
}
|
|
2807
|
+
}
|
|
2794
2808
|
});
|
|
2795
2809
|
});
|
|
2796
2810
|
}, Ns = (i, t) => {
|
|
2797
|
-
var l, a, c, d, h, p,
|
|
2811
|
+
var l, a, c, d, h, p, m, f, y, b;
|
|
2798
2812
|
if (!(typeof i == "object" && i !== null && "content" in i))
|
|
2799
2813
|
return {
|
|
2800
2814
|
withHeadings: (l = t.withHeadings) != null ? l : !1,
|
|
@@ -2805,8 +2819,8 @@ const lt = (i) => {
|
|
|
2805
2819
|
const n = i, s = (d = (c = n.content) == null ? void 0 : c[0]) == null ? void 0 : d.length, o = n.colWidths, r = o && s && o.length === s ? o : void 0;
|
|
2806
2820
|
return {
|
|
2807
2821
|
withHeadings: (p = (h = n.withHeadings) != null ? h : t.withHeadings) != null ? p : !1,
|
|
2808
|
-
withHeadingColumn: (
|
|
2809
|
-
stretched: (y = (
|
|
2822
|
+
withHeadingColumn: (m = n.withHeadingColumn) != null ? m : !1,
|
|
2823
|
+
stretched: (y = (f = n.stretched) != null ? f : t.stretched) != null ? y : !1,
|
|
2810
2824
|
content: (b = n.content) != null ? b : [],
|
|
2811
2825
|
colWidths: r
|
|
2812
2826
|
};
|
|
@@ -3591,10 +3605,10 @@ class co {
|
|
|
3591
3605
|
var d, h;
|
|
3592
3606
|
const e = t.detail.data, n = e.querySelectorAll("tr"), s = [];
|
|
3593
3607
|
n.forEach((p) => {
|
|
3594
|
-
const
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
}),
|
|
3608
|
+
const m = p.querySelectorAll("td, th"), f = [];
|
|
3609
|
+
m.forEach((y) => {
|
|
3610
|
+
f.push(y.innerHTML);
|
|
3611
|
+
}), f.length > 0 && s.push(f);
|
|
3598
3612
|
});
|
|
3599
3613
|
const o = e.querySelector("thead") !== null, r = ((d = n[0]) == null ? void 0 : d.querySelector("th")) !== null, l = o || r;
|
|
3600
3614
|
if (this.data = {
|
|
@@ -3988,11 +4002,11 @@ const z = (i) => {
|
|
|
3988
4002
|
const h = Number(c);
|
|
3989
4003
|
if (!Number.isFinite(h))
|
|
3990
4004
|
return;
|
|
3991
|
-
const p = d,
|
|
3992
|
-
if (
|
|
4005
|
+
const p = d, m = p.textContent;
|
|
4006
|
+
if (m.length <= h)
|
|
3993
4007
|
return;
|
|
3994
|
-
const
|
|
3995
|
-
p.textContent =
|
|
4008
|
+
const f = m.slice(0, h), y = m.slice(h);
|
|
4009
|
+
p.textContent = f;
|
|
3996
4010
|
const b = y.match(/^[\u00A0\s]+/);
|
|
3997
4011
|
if (b && !a.hasAttribute(S.LEADING_WHITESPACE) && a.setAttribute(S.LEADING_WHITESPACE, b[0]), y.length === 0)
|
|
3998
4012
|
return;
|
|
@@ -4025,9 +4039,9 @@ const z = (i) => {
|
|
|
4025
4039
|
const c = Number(a), d = l.textContent;
|
|
4026
4040
|
if (!Number.isFinite(c))
|
|
4027
4041
|
return;
|
|
4028
|
-
const h = d.length > c, p = h ? this.splitCollapsedBoldText(l, c, d) : null,
|
|
4042
|
+
const h = d.length > c, p = h ? this.splitCollapsedBoldText(l, c, d) : null, m = l.getAttribute(S.PREV_LENGTH), f = m ? Number(m) : NaN, y = l.previousSibling, b = (y == null ? void 0 : y.nodeType) === Node.TEXT_NODE ? y : null, I = (N = b == null ? void 0 : b.textContent) != null ? N : "", D = !!(m && Number.isFinite(f) && b && I.length > f);
|
|
4029
4043
|
if (D && b) {
|
|
4030
|
-
const T = I.slice(0,
|
|
4044
|
+
const T = I.slice(0, f), _ = I.slice(f);
|
|
4031
4045
|
b.textContent = T;
|
|
4032
4046
|
const H = document.createTextNode(_);
|
|
4033
4047
|
(P = l.parentNode) == null || P.insertBefore(H, l.nextSibling);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackuait/blok",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.4",
|
|
4
4
|
"description": "Blok — headless, highly extensible rich text editor built for developers who need to implement a block-based editing experience (similar to Notion) without building it from scratch",
|
|
5
5
|
"module": "dist/blok.mjs",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -310,6 +310,25 @@ export const mountCellBlocksReadOnly = (
|
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
if (!isCellWithBlocks(cellContent)) {
|
|
313
|
+
// Handle legacy string content by creating a paragraph block
|
|
314
|
+
// Check if container already has blocks to ensure idempotency
|
|
315
|
+
const existingBlocks = container.querySelectorAll('[data-blok-id]');
|
|
316
|
+
|
|
317
|
+
if (existingBlocks.length > 0) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const legacyText = typeof cellContent === 'string' ? cellContent : '';
|
|
322
|
+
const insertedBlock = api.blocks.insert(
|
|
323
|
+
'paragraph',
|
|
324
|
+
{ text: legacyText },
|
|
325
|
+
{},
|
|
326
|
+
undefined,
|
|
327
|
+
true
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
insertedBlock?.holder && container.appendChild(insertedBlock.holder);
|
|
331
|
+
|
|
313
332
|
return;
|
|
314
333
|
}
|
|
315
334
|
|