@jackuait/blok 0.6.0-beta.5 → 0.6.0-beta.7
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 +16 -169
- package/bin/blok.mjs +10 -0
- package/dist/blok.mjs +2 -2
- package/dist/chunks/{blok-XA2L0_-K.mjs → blok-Bjkxis7j.mjs} +1029 -934
- package/dist/chunks/{i18next-loader-Ci2zhA-n.mjs → i18next-loader-D-sjerXt.mjs} +1 -1
- package/dist/chunks/{index-R38OiQ_d.mjs → index-CJfN4Vuv.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-e3PyuxB6.mjs → inline-tool-convert-5DE7c2fi.mjs} +1 -1
- package/dist/{messages-BGxiFoZf.mjs → chunks/messages-7QoX8DkW.mjs} +14 -14
- package/dist/{messages-UX4gkere.mjs → chunks/messages-BMXCuEKO.mjs} +5 -5
- package/dist/{messages-wp_1b1hD.mjs → chunks/messages-BSbjsyHY.mjs} +16 -16
- package/dist/chunks/{messages-DChXyvh2.mjs → messages-BdeLo0N9.mjs} +14 -14
- package/dist/chunks/{messages-B9fe4dQJ.mjs → messages-C2htQ_3F.mjs} +12 -12
- package/dist/{messages-BNe6LuHW.mjs → chunks/messages-C9eaarcK.mjs} +7 -7
- package/dist/chunks/messages-CKI54h6O.mjs +62 -0
- package/dist/{messages-DjvaFRqx.mjs → chunks/messages-CQwpzUFp.mjs} +6 -6
- package/dist/{messages-EL5ARzmK.mjs → chunks/messages-CVw84KdI.mjs} +7 -7
- package/dist/chunks/{messages-49thXXGz.mjs → messages-Diu6jAaR.mjs} +6 -6
- package/dist/{messages-Bfiw5w_W.mjs → chunks/messages-DvFLX36Q.mjs} +10 -10
- package/dist/chunks/{messages-QtoE8uEv.mjs → messages-Dzwxv9v1.mjs} +8 -8
- package/dist/cli.mjs +50 -0
- package/dist/full.mjs +15 -15
- package/dist/locales.mjs +12 -12
- package/dist/{chunks/messages-BGxiFoZf.mjs → messages-7QoX8DkW.mjs} +14 -14
- package/dist/{chunks/messages-UX4gkere.mjs → messages-BMXCuEKO.mjs} +5 -5
- package/dist/{chunks/messages-wp_1b1hD.mjs → messages-BSbjsyHY.mjs} +16 -16
- package/dist/{messages-DChXyvh2.mjs → messages-BdeLo0N9.mjs} +14 -14
- package/dist/{messages-B9fe4dQJ.mjs → messages-C2htQ_3F.mjs} +12 -12
- package/dist/{chunks/messages-BNe6LuHW.mjs → messages-C9eaarcK.mjs} +7 -7
- package/dist/messages-CKI54h6O.mjs +62 -0
- package/dist/{chunks/messages-DjvaFRqx.mjs → messages-CQwpzUFp.mjs} +6 -6
- package/dist/{chunks/messages-EL5ARzmK.mjs → messages-CVw84KdI.mjs} +7 -7
- package/dist/{messages-49thXXGz.mjs → messages-Diu6jAaR.mjs} +6 -6
- package/dist/{chunks/messages-Bfiw5w_W.mjs → messages-DvFLX36Q.mjs} +10 -10
- package/dist/{messages-QtoE8uEv.mjs → messages-Dzwxv9v1.mjs} +8 -8
- package/dist/tools.mjs +222 -207
- package/dist/vendor.LICENSE.txt +1 -1
- package/package.json +13 -8
- package/src/cli/commands/migration.ts +16 -0
- package/src/cli/commands/migrationContent.ts +6 -0
- package/src/cli/index.ts +47 -0
- package/src/cli/utils/output.ts +10 -0
- package/src/components/i18n/locales/bn/messages.json +16 -16
- package/src/components/i18n/locales/fil/messages.json +7 -7
- package/src/components/i18n/locales/hi/messages.json +14 -14
- package/src/components/i18n/locales/id/messages.json +6 -6
- package/src/components/i18n/locales/mr/messages.json +14 -14
- package/src/components/i18n/locales/ms/messages.json +6 -6
- package/src/components/i18n/locales/ne/messages.json +12 -12
- package/src/components/i18n/locales/si/messages.json +8 -8
- package/src/components/i18n/locales/ta/messages.json +7 -7
- package/src/components/i18n/locales/te/messages.json +35 -35
- package/src/components/i18n/locales/th/messages.json +5 -5
- package/src/components/i18n/locales/vi/messages.json +10 -10
- package/src/components/modules/api/history.ts +64 -0
- package/src/components/modules/api/index.ts +1 -0
- package/src/components/modules/api/readonly.ts +11 -1
- package/src/components/modules/blockManager/blockManager.ts +7 -0
- package/src/components/modules/blockManager/yjs-sync.ts +12 -2
- package/src/components/modules/index.ts +3 -0
- package/src/components/modules/readonly.ts +11 -0
- package/src/components/modules/rectangleSelection.ts +7 -3
- package/src/components/modules/saver.ts +3 -2
- package/src/components/modules/toolbar/index.ts +46 -11
- package/src/components/modules/toolbar/plus-button.ts +22 -1
- package/src/components/modules/yjs/index.ts +23 -0
- package/src/tools/table/index.ts +20 -0
- package/src/tools/table/table-add-controls.ts +8 -0
- package/src/tools/table/table-cell-blocks.ts +15 -5
- package/src/types-internal/blok-modules.d.ts +2 -0
- package/types/api/history.d.ts +33 -0
- package/types/api/index.d.ts +1 -0
- package/types/api/readonly.d.ts +12 -2
- package/types/index.d.ts +3 -0
- package/dist/chunks/messages-DsVNtdgM.mjs +0 -62
- package/dist/messages-DsVNtdgM.mjs +0 -62
package/dist/tools.mjs
CHANGED
|
@@ -10,8 +10,8 @@ var Tt = (i, t, e) => t in i ? ke(i, t, { enumerable: !0, configurable: !0, writ
|
|
|
10
10
|
Le.call(t, e) && Tt(i, e, t[e]);
|
|
11
11
|
return i;
|
|
12
12
|
}, tt = (i, t) => xe(i, Te(t));
|
|
13
|
-
import { t as v, D as E, am as Be, an as Ie, _ as
|
|
14
|
-
import { ab as xo } from "./chunks/inline-tool-convert-
|
|
13
|
+
import { t as v, D as E, am as Be, an as Ie, _ as Ne, ao as De, ap as He, aq as Pe, ar as _e, as as Oe, at as Me, au as Qt, av as te, aw as ee, o as We, p as Rt, a5 as Lt, a3 as $e, ax as Ge, J as ne, Q as se, P as F, ay as qe, az as Fe, a0 as oe, aA as ze, aB as Ve, aC as Ue, aD as Ke, aE as je, z as H, aF as Xe, aG as Ye, S as et, aH as Ze, l as Je, a8 as Qe } from "./chunks/inline-tool-convert-5DE7c2fi.mjs";
|
|
14
|
+
import { ab as xo } from "./chunks/inline-tool-convert-5DE7c2fi.mjs";
|
|
15
15
|
const ie = (i) => {
|
|
16
16
|
if (!i || !i.includes("data-blok-fake-background"))
|
|
17
17
|
return i;
|
|
@@ -24,7 +24,7 @@ const ie = (i) => {
|
|
|
24
24
|
s.removeChild(n);
|
|
25
25
|
}
|
|
26
26
|
}), t.innerHTML;
|
|
27
|
-
},
|
|
27
|
+
}, ht = [
|
|
28
28
|
"empty:before:pointer-events-none",
|
|
29
29
|
"empty:before:text-gray-text",
|
|
30
30
|
"empty:before:cursor-text",
|
|
@@ -327,7 +327,7 @@ const O = class O {
|
|
|
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 = O.DEFAULT_LEVELS.find((
|
|
330
|
+
const n = e.data, s = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, o = O.DEFAULT_LEVELS.find((f) => f.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 : Ie,
|
|
333
333
|
title: l,
|
|
@@ -348,7 +348,7 @@ const O = class O {
|
|
|
348
348
|
* @returns Resolved title string
|
|
349
349
|
*/
|
|
350
350
|
resolveToolboxEntryTitle(t, e) {
|
|
351
|
-
return
|
|
351
|
+
return Ne(this.api.i18n, t, e);
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
354
354
|
* Callback for Block's settings buttons
|
|
@@ -450,7 +450,7 @@ const O = class O {
|
|
|
450
450
|
*/
|
|
451
451
|
getTag() {
|
|
452
452
|
const t = document.createElement(this.currentLevel.tag);
|
|
453
|
-
t.innerHTML = this._data.text || "", t.className = v(O.BASE_STYLES, this.currentLevel.styles,
|
|
453
|
+
t.innerHTML = this._data.text || "", t.className = v(O.BASE_STYLES, this.currentLevel.styles, ht);
|
|
454
454
|
const { inlineStyles: e } = this.currentLevel;
|
|
455
455
|
return e && Object.assign(t.style, e), t.setAttribute(E.tool, "header"), t.contentEditable = this.readOnly ? "false" : "true", this.readOnly ? t.setAttribute("data-placeholder", this.api.i18n.t(this._settings.placeholder || "")) : Et(t, this.api.i18n.t(this._settings.placeholder || "")), t;
|
|
456
456
|
}
|
|
@@ -549,7 +549,7 @@ const O = class O {
|
|
|
549
549
|
}
|
|
550
550
|
};
|
|
551
551
|
O.BASE_STYLES = "py-[3px] px-[2px] m-0 !leading-[1.3] outline-none [&_p]:!p-0 [&_p]:!m-0 [&_div]:!p-0 [&_div]:!m-0", O.DEFAULT_LEVELS = [
|
|
552
|
-
{ number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon:
|
|
552
|
+
{ number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon: De, styles: "text-4xl font-bold mt-8 mb-1" },
|
|
553
553
|
{ number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon: He, styles: "text-3xl font-semibold mt-6 mb-px" },
|
|
554
554
|
{ number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon: Pe, styles: "text-2xl font-semibold mt-4 mb-px" },
|
|
555
555
|
{ number: 4, tag: "H4", nameKey: "tools.header.heading4", name: "Heading 4", icon: _e, styles: "text-xl font-semibold mt-3 mb-px" },
|
|
@@ -557,7 +557,7 @@ O.BASE_STYLES = "py-[3px] px-[2px] m-0 !leading-[1.3] outline-none [&_p]:!p-0 [&
|
|
|
557
557
|
{ number: 6, tag: "H6", nameKey: "tools.header.heading6", name: "Heading 6", icon: Me, styles: "text-sm font-semibold mt-3 mb-px" }
|
|
558
558
|
];
|
|
559
559
|
let It = O;
|
|
560
|
-
const
|
|
560
|
+
const z = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl-0.5 leading-[1.6em]", an = "flex items-start pl-0.5", cn = "mt-1 w-4 mr-2 h-4 cursor-pointer accent-current", dn = "tools.list.placeholder", w = "list", re = {
|
|
561
561
|
contentContainer: "list-content-container",
|
|
562
562
|
checklistContent: "list-checklist-content"
|
|
563
563
|
}, le = (i, t) => {
|
|
@@ -585,26 +585,26 @@ const F = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl
|
|
|
585
585
|
}, un = (i) => {
|
|
586
586
|
var c;
|
|
587
587
|
const { data: t, itemColor: e, itemSize: n, placeholder: s } = i, o = document.createElement("div");
|
|
588
|
-
o.setAttribute("role", "listitem"), o.className = v(ln, "flex", ...
|
|
588
|
+
o.setAttribute("role", "listitem"), o.className = v(ln, "flex", ...ht), e && (o.style.color = e), n && (o.style.fontSize = n);
|
|
589
589
|
const r = (c = t.depth) != null ? c : 0;
|
|
590
|
-
r > 0 && (o.style.marginLeft = `${r *
|
|
590
|
+
r > 0 && (o.style.marginLeft = `${r * z}px`);
|
|
591
591
|
const l = gn(t.style, r);
|
|
592
592
|
l.setAttribute("data-list-marker", "true"), l.setAttribute("data-blok-mutation-free", "true"), o.appendChild(l);
|
|
593
593
|
const a = document.createElement("div");
|
|
594
|
-
return a.className = v("flex-1 min-w-0 outline-none", ...
|
|
594
|
+
return a.className = v("flex-1 min-w-0 outline-none", ...ht), a.setAttribute("data-blok-testid", re.contentContainer), a.contentEditable = i.readOnly ? "false" : "true", a.innerHTML = t.text, le(a, s), o.appendChild(a), o;
|
|
595
595
|
}, pn = (i) => {
|
|
596
596
|
var d;
|
|
597
597
|
const { data: t, itemColor: e, itemSize: n, placeholder: s, readOnly: o } = i, r = document.createElement("div");
|
|
598
598
|
r.setAttribute("role", "listitem"), r.className = an, e && (r.style.color = e), n && (r.style.fontSize = n);
|
|
599
599
|
const l = (d = t.depth) != null ? d : 0;
|
|
600
|
-
l > 0 && (r.style.marginLeft = `${l *
|
|
600
|
+
l > 0 && (r.style.marginLeft = `${l * z}px`);
|
|
601
601
|
const a = document.createElement("input");
|
|
602
602
|
a.type = "checkbox", a.className = cn, a.checked = !!t.checked, a.disabled = o;
|
|
603
603
|
const c = document.createElement("div");
|
|
604
604
|
return c.className = v(
|
|
605
605
|
"flex-1 outline-none leading-[1.6em]",
|
|
606
606
|
t.checked ? "line-through opacity-60" : "",
|
|
607
|
-
...
|
|
607
|
+
...ht
|
|
608
608
|
), c.setAttribute("data-blok-testid", re.checklistContent), c.setAttribute("data-checked", String(t.checked)), c.contentEditable = o ? "false" : "true", c.innerHTML = t.text, le(c, s), r.appendChild(a), r.appendChild(c), r;
|
|
609
609
|
}, gn = (i, t) => {
|
|
610
610
|
const e = document.createElement("span");
|
|
@@ -647,10 +647,10 @@ const F = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "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
|
}, yn = (i, t, e, n, s) => {
|
|
650
|
-
var
|
|
650
|
+
var m, C, b;
|
|
651
651
|
if (!e)
|
|
652
652
|
return { newData: i, inPlace: !1 };
|
|
653
|
-
const o = (
|
|
653
|
+
const o = (m = i.depth) != null ? m : 0, r = (C = t.depth) != null ? C : 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(x(x({}, i), t), {
|
|
@@ -689,7 +689,7 @@ const F = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl
|
|
|
689
689
|
if (e === null)
|
|
690
690
|
return;
|
|
691
691
|
const n = parseInt(e, 10);
|
|
692
|
-
return n > 0 ? { left: n *
|
|
692
|
+
return n > 0 ? { left: n * z } : void 0;
|
|
693
693
|
}, An = (i) => {
|
|
694
694
|
const t = i.closest('[role="listitem"]') || i.querySelector('[role="listitem"]'), e = Sn(t);
|
|
695
695
|
return e !== void 0 ? e : wn(i);
|
|
@@ -702,10 +702,10 @@ const F = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl
|
|
|
702
702
|
};
|
|
703
703
|
const n = document.createRange();
|
|
704
704
|
return n.setStart(t.endContainer, t.endOffset), n.setEndAfter(i.lastChild), {
|
|
705
|
-
beforeContent:
|
|
706
|
-
afterContent:
|
|
705
|
+
beforeContent: Nt(e.cloneContents()),
|
|
706
|
+
afterContent: Nt(n.cloneContents())
|
|
707
707
|
};
|
|
708
|
-
},
|
|
708
|
+
}, Nt = (i) => {
|
|
709
709
|
const t = document.createElement("div");
|
|
710
710
|
return t.appendChild(i), t.innerHTML;
|
|
711
711
|
}, kn = (i) => {
|
|
@@ -728,7 +728,7 @@ const F = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl
|
|
|
728
728
|
return !1;
|
|
729
729
|
const e = Object.entries(i).find(([n]) => n === "items");
|
|
730
730
|
return e === void 0 ? !1 : Array.isArray(e[1]);
|
|
731
|
-
}, Ln = (i) => typeof i == "object" && i !== null, Bn = (i) => typeof i == "string" ? i : "", In = (i, t) => i === "unordered" || i === "ordered" || i === "checklist" ? i : t,
|
|
731
|
+
}, Ln = (i) => typeof i == "object" && i !== null, Bn = (i) => typeof i == "string" ? i : "", In = (i, t) => i === "unordered" || i === "ordered" || i === "checklist" ? i : t, Nn = (i) => !!i, Dn = (i, t) => typeof i == "number" ? i : t, Hn = (i, t) => {
|
|
732
732
|
const e = t.defaultStyle || "unordered";
|
|
733
733
|
if (!i || typeof i != "object")
|
|
734
734
|
return {
|
|
@@ -747,7 +747,7 @@ const F = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl
|
|
|
747
747
|
}, i.start !== void 0 && i.start !== 1 ? { start: i.start } : {});
|
|
748
748
|
}
|
|
749
749
|
if (Ln(i)) {
|
|
750
|
-
const n = Bn(i.text), s = In(i.style, e), o =
|
|
750
|
+
const n = Bn(i.text), s = In(i.style, e), o = Nn(i.checked), r = Dn(i.depth, 0), l = i.start, a = typeof l == "number" && l !== void 0 && l !== 1 ? l : void 0;
|
|
751
751
|
return x({
|
|
752
752
|
text: n,
|
|
753
753
|
style: s,
|
|
@@ -819,7 +819,7 @@ class ce {
|
|
|
819
819
|
if (!t)
|
|
820
820
|
return 0;
|
|
821
821
|
const e = (o = (s = t.holder) == null ? void 0 : s.querySelector('[role="listitem"]')) == null ? void 0 : o.getAttribute("style"), n = e == null ? void 0 : e.match(/margin-left:\s*(\d+)px/);
|
|
822
|
-
return n ? Math.round(parseInt(n[1], 10) /
|
|
822
|
+
return n ? Math.round(parseInt(n[1], 10) / z) : 0;
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
const Pn = (i, t) => {
|
|
@@ -833,8 +833,8 @@ const Pn = (i, t) => {
|
|
|
833
833
|
}, _n = (i, t, e) => {
|
|
834
834
|
i && i.setAttribute("data-list-depth", String(e));
|
|
835
835
|
const n = i == null ? void 0 : i.querySelector('[role="listitem"]');
|
|
836
|
-
n instanceof HTMLElement && (n.style.marginLeft = e > 0 ? `${e *
|
|
837
|
-
}, de = (i, t) => t.getBlockDepth(i), he = (i, t) => t.getBlockStyle(i), On = (i, t) => t.getBulletCharacter(i),
|
|
836
|
+
n instanceof HTMLElement && (n.style.marginLeft = e > 0 ? `${e * z}px` : ""), t.depth = e;
|
|
837
|
+
}, de = (i, t) => t.getBlockDepth(i), he = (i, t) => t.getBlockStyle(i), On = (i, t) => t.getBulletCharacter(i), Dt = (i, t, e, n, s) => {
|
|
838
838
|
var r;
|
|
839
839
|
const o = i && (r = n.getBlockIndex(i)) != null ? r : n.getCurrentBlockIndex();
|
|
840
840
|
return o <= 0 ? 0 : s.getSiblingIndex(o, t, e);
|
|
@@ -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, f = n.formatNumber(p, a);
|
|
868
|
+
r.textContent = f;
|
|
869
869
|
}, $n = (i, t, e, n, s, o, r, l) => {
|
|
870
870
|
const a = (c) => {
|
|
871
871
|
if (c >= t)
|
|
@@ -896,7 +896,7 @@ const Pn = (i, t) => {
|
|
|
896
896
|
const r = o.holder;
|
|
897
897
|
r != null && r.querySelector('[data-list-style="ordered"]') && ue(o, i, t, e);
|
|
898
898
|
});
|
|
899
|
-
},
|
|
899
|
+
}, X = (i, t, e = "end") => {
|
|
900
900
|
requestAnimationFrame(() => {
|
|
901
901
|
const n = t.holder;
|
|
902
902
|
if (!n) return;
|
|
@@ -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
|
}, qn = async (i) => {
|
|
915
|
-
var
|
|
915
|
+
var m;
|
|
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,19 +922,19 @@ const Pn = (i, t) => {
|
|
|
922
922
|
await Fn(i);
|
|
923
923
|
return;
|
|
924
924
|
}
|
|
925
|
-
const c = r.getRangeAt(0), { beforeContent: d, afterContent: h } = En(l, c), p = e && (
|
|
925
|
+
const c = r.getRangeAt(0), { beforeContent: d, afterContent: h } = En(l, c), p = e && (m = t.blocks.getBlockIndex(e)) != null ? m : t.blocks.getCurrentBlockIndex();
|
|
926
926
|
if (!e) {
|
|
927
927
|
l.innerHTML = d, n.text = d;
|
|
928
|
-
const
|
|
928
|
+
const C = t.blocks.insert(w, {
|
|
929
929
|
text: h,
|
|
930
930
|
style: n.style,
|
|
931
931
|
checked: !1,
|
|
932
932
|
depth: n.depth
|
|
933
933
|
}, void 0, p + 1, !0);
|
|
934
|
-
|
|
934
|
+
X(t, C, "start");
|
|
935
935
|
return;
|
|
936
936
|
}
|
|
937
|
-
const
|
|
937
|
+
const f = 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,
|
|
949
|
+
n.text = d, X(t, f, "start");
|
|
950
950
|
}, Fn = async (i) => {
|
|
951
951
|
const { api: t, blockId: e, getDepth: n } = i;
|
|
952
952
|
if (n() > 0) {
|
|
@@ -956,14 +956,14 @@ const Pn = (i, t) => {
|
|
|
956
956
|
if (e === void 0)
|
|
957
957
|
return;
|
|
958
958
|
const o = await t.blocks.convert(e, "paragraph", { text: "" });
|
|
959
|
-
|
|
959
|
+
X(t, o, "start");
|
|
960
960
|
}, zn = async (i, t) => {
|
|
961
961
|
const { api: e, blockId: n, data: s, element: o, getContentElement: r, getDepth: l, syncContentFromDOM: a } = i, c = window.getSelection();
|
|
962
962
|
if (!c || !o) return;
|
|
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, f = l();
|
|
967
967
|
if (Tn(h, d) && !c.isCollapsed) {
|
|
968
968
|
t.preventDefault(), h.innerHTML = "", s.text = "";
|
|
969
969
|
const b = document.createRange();
|
|
@@ -972,11 +972,11 @@ const Pn = (i, t) => {
|
|
|
972
972
|
}
|
|
973
973
|
if (!xn(h, d) || (t.preventDefault(), n === void 0))
|
|
974
974
|
return;
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
const b =
|
|
978
|
-
b && (b.style.marginLeft = `${
|
|
979
|
-
}),
|
|
975
|
+
const C = await e.blocks.convert(n, "paragraph", { text: p });
|
|
976
|
+
f > 0 && requestAnimationFrame(() => {
|
|
977
|
+
const b = C.holder;
|
|
978
|
+
b && (b.style.marginLeft = `${f * z}px`, b.setAttribute("data-blok-depth", String(f)));
|
|
979
|
+
}), X(e, C, "start");
|
|
980
980
|
}, Vn = async (i, t) => {
|
|
981
981
|
const { api: e, blockId: n, data: s, syncContentFromDOM: o, getDepth: r } = i, l = e.blocks.getCurrentBlockIndex();
|
|
982
982
|
if (l === 0) return;
|
|
@@ -990,7 +990,7 @@ const Pn = (i, t) => {
|
|
|
990
990
|
const p = await e.blocks.update(n || "", tt(x({}, s), {
|
|
991
991
|
depth: h
|
|
992
992
|
}));
|
|
993
|
-
|
|
993
|
+
X(e, p);
|
|
994
994
|
}, pe = async (i) => {
|
|
995
995
|
const { api: t, blockId: e, data: n, syncContentFromDOM: s, getDepth: o } = i, r = o();
|
|
996
996
|
if (r === 0) return;
|
|
@@ -1000,7 +1000,7 @@ const Pn = (i, t) => {
|
|
|
1000
1000
|
const a = await t.blocks.update(e || "", tt(x({}, n), {
|
|
1001
1001
|
depth: l
|
|
1002
1002
|
}));
|
|
1003
|
-
|
|
1003
|
+
X(t, a);
|
|
1004
1004
|
}, Un = (i) => {
|
|
1005
1005
|
const { data: t, readOnly: e, placeholder: n, itemColor: s, itemSize: o, setupItemPlaceholder: r, onCheckboxChange: l, keydownHandler: a } = i, c = ae({
|
|
1006
1006
|
data: t,
|
|
@@ -1158,7 +1158,7 @@ class ge {
|
|
|
1158
1158
|
if (!t)
|
|
1159
1159
|
return 0;
|
|
1160
1160
|
const e = (o = (s = t.holder) == null ? void 0 : s.querySelector('[role="listitem"]')) == null ? void 0 : o.getAttribute("style"), n = e == null ? void 0 : e.match(/margin-left:\s*(\d+)px/);
|
|
1161
|
-
return n ? Math.round(parseInt(n[1], 10) /
|
|
1161
|
+
return n ? Math.round(parseInt(n[1], 10) / z) : 0;
|
|
1162
1162
|
}
|
|
1163
1163
|
/**
|
|
1164
1164
|
* Get the style of a block by reading from its DOM.
|
|
@@ -1201,7 +1201,7 @@ class ge {
|
|
|
1201
1201
|
return r < n ? e : r > n ? this.findGroupStartRecursive(t - 1, e, n, s) : this.getBlockStyle(o) !== s ? e : this.findGroupStartRecursive(t - 1, t, n, s);
|
|
1202
1202
|
}
|
|
1203
1203
|
}
|
|
1204
|
-
const
|
|
1204
|
+
const pt = { value: !1 };
|
|
1205
1205
|
class Xn {
|
|
1206
1206
|
constructor(t) {
|
|
1207
1207
|
this.blocks = t, this.depthValidator = new ce(t), this.markerCalculator = new ge(t);
|
|
@@ -1256,8 +1256,8 @@ class Xn {
|
|
|
1256
1256
|
* Uses a static flag to deduplicate multiple calls in the same frame.
|
|
1257
1257
|
*/
|
|
1258
1258
|
scheduleUpdateAll() {
|
|
1259
|
-
|
|
1260
|
-
|
|
1259
|
+
pt.value || (pt.value = !0, requestAnimationFrame(() => {
|
|
1260
|
+
pt.value = !1, this.updateAllMarkers();
|
|
1261
1261
|
}));
|
|
1262
1262
|
}
|
|
1263
1263
|
/**
|
|
@@ -1311,10 +1311,10 @@ class Xn {
|
|
|
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
|
|
1317
|
-
return isNaN(
|
|
1314
|
+
const f = n.closest("[data-list-start]"), m = f == null ? void 0 : f.getAttribute("data-list-start");
|
|
1315
|
+
if (!m) return c;
|
|
1316
|
+
const C = parseInt(m, 10);
|
|
1317
|
+
return isNaN(C) ? c : C;
|
|
1318
1318
|
})() : c) + a, p = this.markerCalculator.formatNumber(h, r);
|
|
1319
1319
|
s.textContent = p;
|
|
1320
1320
|
}
|
|
@@ -1535,7 +1535,7 @@ class vo {
|
|
|
1535
1535
|
const t = (o = this._element) == null ? void 0 : o.querySelector("[data-list-marker]");
|
|
1536
1536
|
if (!t)
|
|
1537
1537
|
return;
|
|
1538
|
-
const e = this.getDepth(), n =
|
|
1538
|
+
const e = this.getDepth(), n = Dt(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), s = Ht(n, e, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1539
1539
|
t.textContent = s;
|
|
1540
1540
|
}
|
|
1541
1541
|
updateSiblingListMarkers() {
|
|
@@ -1548,7 +1548,7 @@ class vo {
|
|
|
1548
1548
|
const n = (s = this._element) == null ? void 0 : s.querySelector('[aria-hidden="true"]');
|
|
1549
1549
|
if (n instanceof HTMLElement)
|
|
1550
1550
|
if (e === "ordered") {
|
|
1551
|
-
const o =
|
|
1551
|
+
const o = Dt(this.blockId, t, this._data.style, this.api.blocks, this.markerCalculator), r = Ht(o, t, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1552
1552
|
n.textContent = r;
|
|
1553
1553
|
} else {
|
|
1554
1554
|
const o = On(t, this.markerCalculator);
|
|
@@ -1746,7 +1746,7 @@ const ls = "data-blok-table-add-row", as = "data-blok-table-add-col", _t = 150,
|
|
|
1746
1746
|
], $t = "12";
|
|
1747
1747
|
class ds {
|
|
1748
1748
|
constructor(t) {
|
|
1749
|
-
this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.dragState = null, this.wrapper = t.wrapper, this.grid = t.grid, this.i18n = t.i18n, this.boundAddRowClick = t.onAddRow, this.boundAddColClick = t.onAddColumn, this.onDragStart = t.onDragStart, this.onDragAddRow = t.onDragAddRow, this.onDragRemoveRow = t.onDragRemoveRow, this.onDragAddCol = t.onDragAddCol, this.onDragRemoveCol = t.onDragRemoveCol, this.onDragEnd = t.onDragEnd, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundRowPointerDown = (e) => this.handlePointerDown("row", e), this.boundColPointerDown = (e) => this.handlePointerDown("col", e), this.addRowBtn = this.createAddRowButton(), this.addColBtn = this.createAddColumnButton(), this.wrapper.appendChild(this.addRowBtn), this.grid.appendChild(this.addColBtn), this.syncRowButtonWidth(), this.wrapper.addEventListener("mousemove", this.boundMouseMove), this.wrapper.addEventListener("mouseleave", this.boundMouseLeave), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
|
|
1749
|
+
this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.dragState = null, this.wrapper = t.wrapper, this.grid = t.grid, this.i18n = t.i18n, this.boundAddRowClick = t.onAddRow, this.boundAddColClick = t.onAddColumn, this.onDragStart = t.onDragStart, this.onDragAddRow = t.onDragAddRow, this.onDragRemoveRow = t.onDragRemoveRow, this.onDragAddCol = t.onDragAddCol, this.onDragRemoveCol = t.onDragRemoveCol, this.onDragEnd = t.onDragEnd, this.getNewColumnWidth = t.getNewColumnWidth, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundRowPointerDown = (e) => this.handlePointerDown("row", e), this.boundColPointerDown = (e) => this.handlePointerDown("col", e), this.addRowBtn = this.createAddRowButton(), this.addColBtn = this.createAddColumnButton(), this.wrapper.appendChild(this.addRowBtn), this.grid.appendChild(this.addColBtn), this.syncRowButtonWidth(), this.wrapper.addEventListener("mousemove", this.boundMouseMove), this.wrapper.addEventListener("mouseleave", this.boundMouseLeave), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
|
|
1750
1750
|
}
|
|
1751
1751
|
/**
|
|
1752
1752
|
* Match the add-row button width to the grid's explicit width.
|
|
@@ -1823,6 +1823,8 @@ class ds {
|
|
|
1823
1823
|
const o = this.grid.querySelectorAll("[data-blok-table-row]"), r = o[o.length - 1];
|
|
1824
1824
|
return (r == null ? void 0 : r.offsetHeight) || 30;
|
|
1825
1825
|
}
|
|
1826
|
+
if (this.getNewColumnWidth)
|
|
1827
|
+
return this.getNewColumnWidth() || 100;
|
|
1826
1828
|
const e = this.grid.querySelector("[data-blok-table-row]");
|
|
1827
1829
|
if (!e)
|
|
1828
1830
|
return 100;
|
|
@@ -1999,8 +2001,8 @@ class gs {
|
|
|
1999
2001
|
const o = 1 - 0.5 / e;
|
|
2000
2002
|
t.forEach((r) => {
|
|
2001
2003
|
r.querySelectorAll(`[${u}]`).forEach((p) => {
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
+
const f = p, m = parseFloat(f.style.width) || 100 / e, C = Math.round(m * o * 100) / 100;
|
|
2005
|
+
f.style.width = `${C}%`;
|
|
2004
2006
|
});
|
|
2005
2007
|
const a = Math.round(100 / e / 2 * 100) / 100, c = r.querySelectorAll(`[${u}]`), d = n === void 0 || n >= c.length, h = this.createCell(`${a}%`);
|
|
2006
2008
|
if (!d) {
|
|
@@ -2139,7 +2141,7 @@ class gs {
|
|
|
2139
2141
|
return n.setAttribute(k, ""), e.appendChild(n), e;
|
|
2140
2142
|
}
|
|
2141
2143
|
}
|
|
2142
|
-
const
|
|
2144
|
+
const yt = (i) => typeof i == "object" && i !== null && "blocks" in i, k = "data-blok-table-cell-blocks";
|
|
2143
2145
|
class fs {
|
|
2144
2146
|
constructor(t) {
|
|
2145
2147
|
this._activeCellWithBlocks = null, this.cellsPendingCheck = /* @__PURE__ */ new Set(), this.pendingCheckScheduled = !1, this.removedBlockCells = /* @__PURE__ */ new Map(), this.handleBlockMutation = (e) => {
|
|
@@ -2291,6 +2293,7 @@ class fs {
|
|
|
2291
2293
|
* Initialize all cells with blocks.
|
|
2292
2294
|
* - Empty cells or legacy string cells get a new paragraph block.
|
|
2293
2295
|
* - Cells that already have block references get those blocks mounted.
|
|
2296
|
+
* - If referenced blocks are missing from BlockManager, a fallback paragraph is created.
|
|
2294
2297
|
*/
|
|
2295
2298
|
initializeCells(t) {
|
|
2296
2299
|
const e = this.gridElement.querySelectorAll(`[${g}]`), n = [];
|
|
@@ -2304,15 +2307,16 @@ class fs {
|
|
|
2304
2307
|
if (!h)
|
|
2305
2308
|
return;
|
|
2306
2309
|
const p = h.querySelector(`[${k}]`);
|
|
2307
|
-
if (p)
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
}
|
|
2314
|
-
|
|
2310
|
+
if (!p)
|
|
2311
|
+
return;
|
|
2312
|
+
const f = yt(c) ? this.mountBlocksInCell(p, c.blocks) : [];
|
|
2313
|
+
if (f.length > 0)
|
|
2314
|
+
a.push({ blocks: f });
|
|
2315
|
+
else {
|
|
2316
|
+
const m = typeof c == "string" ? c : "", C = this.api.blocks.insert("paragraph", { text: m }, {}, this.api.blocks.getBlocksCount(), !1);
|
|
2317
|
+
p.appendChild(C.holder), a.push({ blocks: [C.id] });
|
|
2315
2318
|
}
|
|
2319
|
+
this.stripPlaceholders(p);
|
|
2316
2320
|
}), n.push(a);
|
|
2317
2321
|
}), n;
|
|
2318
2322
|
}
|
|
@@ -2328,16 +2332,19 @@ class fs {
|
|
|
2328
2332
|
});
|
|
2329
2333
|
}
|
|
2330
2334
|
/**
|
|
2331
|
-
* Mount existing blocks into a cell container by their IDs
|
|
2335
|
+
* Mount existing blocks into a cell container by their IDs.
|
|
2336
|
+
* Returns the IDs of blocks that were successfully mounted.
|
|
2332
2337
|
*/
|
|
2333
2338
|
mountBlocksInCell(t, e) {
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2339
|
+
const n = [];
|
|
2340
|
+
for (const s of e) {
|
|
2341
|
+
const o = this.api.blocks.getBlockIndex(s);
|
|
2342
|
+
if (o === void 0)
|
|
2337
2343
|
continue;
|
|
2338
|
-
const
|
|
2339
|
-
|
|
2344
|
+
const r = this.api.blocks.getBlockByIndex(o);
|
|
2345
|
+
r && (t.appendChild(r.holder), n.push(s));
|
|
2340
2346
|
}
|
|
2347
|
+
return n;
|
|
2341
2348
|
}
|
|
2342
2349
|
/**
|
|
2343
2350
|
* Move a block's DOM holder into a cell's blocks container.
|
|
@@ -2447,7 +2454,7 @@ class fs {
|
|
|
2447
2454
|
this.gridElement.removeEventListener("click", this.handleCellBlankSpaceClick), this.api.events.off("block changed", this.handleBlockMutation), this._activeCellWithBlocks = null, this.cellsPendingCheck.clear(), this.removedBlockCells.clear();
|
|
2448
2455
|
}
|
|
2449
2456
|
}
|
|
2450
|
-
const
|
|
2457
|
+
const Y = 16, ms = [
|
|
2451
2458
|
[2, 2],
|
|
2452
2459
|
[8, 2],
|
|
2453
2460
|
[2, 7],
|
|
@@ -2477,14 +2484,14 @@ const X = 16, ms = [
|
|
|
2477
2484
|
}
|
|
2478
2485
|
return t;
|
|
2479
2486
|
}, ys = (i, t) => {
|
|
2480
|
-
t === "col" ? Object.assign(i.style, { height: `${
|
|
2487
|
+
t === "col" ? Object.assign(i.style, { height: `${Y}px` }) : Object.assign(i.style, { width: `${Y}px` }), i.classList.add("bg-gray-200"), i.classList.remove("bg-gray-300");
|
|
2481
2488
|
const e = i.querySelector("svg");
|
|
2482
2489
|
e && (e.classList.remove("opacity-0"), e.classList.add("opacity-100"));
|
|
2483
|
-
},
|
|
2490
|
+
}, gt = (i, t, e) => {
|
|
2484
2491
|
t === "col" ? Object.assign(i.style, { height: `${e}px` }) : Object.assign(i.style, { width: `${e}px` }), i.classList.remove("bg-gray-200"), i.classList.add("bg-gray-300");
|
|
2485
2492
|
const n = i.querySelector("svg");
|
|
2486
2493
|
n && (n.classList.add("opacity-0"), n.classList.remove("opacity-100"));
|
|
2487
|
-
},
|
|
2494
|
+
}, ft = "data-blok-table-cell-selected", bs = "2px solid #3b82f6", mt = "data-blok-table-selection-pill", vs = 16, Ss = 20, Gt = 4, ws = [
|
|
2488
2495
|
"absolute",
|
|
2489
2496
|
"z-[3]",
|
|
2490
2497
|
"rounded",
|
|
@@ -2530,7 +2537,7 @@ class Es {
|
|
|
2530
2537
|
if (As(this.grid) || t.button !== 0)
|
|
2531
2538
|
return;
|
|
2532
2539
|
const e = t.target;
|
|
2533
|
-
if (e.closest("[data-blok-table-grip]") || e.closest("[data-blok-table-resize]") || e.closest(`[${
|
|
2540
|
+
if (e.closest("[data-blok-table-grip]") || e.closest("[data-blok-table-resize]") || e.closest(`[${mt}]`))
|
|
2534
2541
|
return;
|
|
2535
2542
|
const n = this.resolveCellCoord(e);
|
|
2536
2543
|
n && (this.hasSelection && this.clearSelection(), this.anchorCell = n, this.isSelecting = !1, document.addEventListener("mousemove", this.boundCancelRectangle, !0), document.addEventListener("pointermove", this.boundPointerMove), document.addEventListener("pointerup", this.boundPointerUp));
|
|
@@ -2566,7 +2573,7 @@ class Es {
|
|
|
2566
2573
|
}
|
|
2567
2574
|
handleClearSelection(t) {
|
|
2568
2575
|
const e = t.target;
|
|
2569
|
-
e instanceof HTMLElement && e.closest(`[${
|
|
2576
|
+
e instanceof HTMLElement && e.closest(`[${mt}]`) || this.pillPopover === null && (document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection());
|
|
2570
2577
|
}
|
|
2571
2578
|
handleKeyDown(t) {
|
|
2572
2579
|
var e;
|
|
@@ -2579,7 +2586,7 @@ class Es {
|
|
|
2579
2586
|
}
|
|
2580
2587
|
restoreModifiedCells() {
|
|
2581
2588
|
this.destroyPillPopover(), this.selectedCells.forEach((t) => {
|
|
2582
|
-
t.removeAttribute(
|
|
2589
|
+
t.removeAttribute(ft);
|
|
2583
2590
|
}), this.pill && (this.pill.remove(), this.pill = null), this.overlay && (this.overlay.remove(), this.overlay = null), this.selectedCells = [];
|
|
2584
2591
|
}
|
|
2585
2592
|
showProgrammaticSelection(t, e, n, s) {
|
|
@@ -2589,25 +2596,25 @@ class Es {
|
|
|
2589
2596
|
});
|
|
2590
2597
|
}
|
|
2591
2598
|
paintSelection() {
|
|
2592
|
-
var I,
|
|
2599
|
+
var I, N;
|
|
2593
2600
|
if (!this.anchorCell || !this.extentCell)
|
|
2594
2601
|
return;
|
|
2595
2602
|
this.selectedCells.forEach((M) => {
|
|
2596
|
-
M.removeAttribute(
|
|
2603
|
+
M.removeAttribute(ft);
|
|
2597
2604
|
}), this.selectedCells = [];
|
|
2598
2605
|
const t = Math.min(this.anchorCell.row, this.extentCell.row), e = Math.max(this.anchorCell.row, this.extentCell.row), n = Math.min(this.anchorCell.col, this.extentCell.col), s = Math.max(this.anchorCell.col, this.extentCell.col), o = this.grid.querySelectorAll(`[${g}]`);
|
|
2599
2606
|
this.selectedCells = this.collectCellsInRange(o, t, e, n, s), this.selectedCells.forEach((M) => {
|
|
2600
|
-
M.setAttribute(
|
|
2607
|
+
M.setAttribute(ft, "");
|
|
2601
2608
|
});
|
|
2602
|
-
const r = (I = o[t]) == null ? void 0 : I.querySelectorAll(`[${u}]`)[n], l = (
|
|
2609
|
+
const r = (I = o[t]) == null ? void 0 : I.querySelectorAll(`[${u}]`)[n], l = (N = o[e]) == null ? void 0 : N.querySelectorAll(`[${u}]`)[s];
|
|
2603
2610
|
if (!r || !l)
|
|
2604
2611
|
return;
|
|
2605
|
-
const a = this.grid.getBoundingClientRect(), c = r.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), p = parseFloat(h.borderTopWidth) || 0,
|
|
2606
|
-
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = bs, 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 = `${b}px`, this.overlay.style.left = `${B}px`, this.overlay.style.width = `${
|
|
2612
|
+
const a = this.grid.getBoundingClientRect(), c = r.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), p = parseFloat(h.borderTopWidth) || 0, f = parseFloat(h.borderLeftWidth) || 0, m = d.right - c.left + 1, C = d.bottom - c.top + 1, b = c.top - a.top - p - 1, B = c.left - a.left - f - 1;
|
|
2613
|
+
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = bs, 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 = `${b}px`, this.overlay.style.left = `${B}px`, this.overlay.style.width = `${m}px`, this.overlay.style.height = `${C}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${B + m - 1}px`, this.pill.style.top = `${b + C / 2}px`;
|
|
2607
2614
|
}
|
|
2608
2615
|
createPill() {
|
|
2609
2616
|
const t = document.createElement("div");
|
|
2610
|
-
t.setAttribute(
|
|
2617
|
+
t.setAttribute(mt, ""), t.setAttribute("contenteditable", "false"), t.className = v(ws), t.style.width = `${Gt}px`, t.style.height = `${Ss}px`, t.style.pointerEvents = "auto", t.style.transform = "translate(-50%, -50%)", t.style.outline = "2px solid white";
|
|
2611
2618
|
const e = fe("vertical");
|
|
2612
2619
|
return e.classList.remove("text-gray-400"), e.classList.add("text-white"), t.appendChild(e), t.addEventListener("mouseenter", () => {
|
|
2613
2620
|
this.pillPopover === null && this.expandPill();
|
|
@@ -2674,13 +2681,13 @@ class Es {
|
|
|
2674
2681
|
return l < 0 ? null : { row: o, col: l };
|
|
2675
2682
|
}
|
|
2676
2683
|
clampExtentToEdge(t) {
|
|
2677
|
-
var c, d, h, p,
|
|
2684
|
+
var c, d, h, p, f, m;
|
|
2678
2685
|
if (!this.anchorCell || !this.isSelecting)
|
|
2679
2686
|
return;
|
|
2680
2687
|
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;
|
|
2681
2688
|
if (s === 0 || o === 0)
|
|
2682
2689
|
return;
|
|
2683
|
-
const r = this.clampAxis(t.clientY, e.top, e.bottom, s, (p = (h = this.extentCell) == null ? void 0 : h.row) != null ? p : this.anchorCell.row), l = this.clampAxis(t.clientX, e.left, e.right, o, (
|
|
2690
|
+
const r = this.clampAxis(t.clientY, e.top, e.bottom, s, (p = (h = this.extentCell) == null ? void 0 : h.row) != null ? p : this.anchorCell.row), l = this.clampAxis(t.clientX, e.left, e.right, o, (m = (f = this.extentCell) == null ? void 0 : f.col) != null ? m : this.anchorCell.col), a = { row: r, col: l };
|
|
2684
2691
|
(!this.extentCell || this.extentCell.row !== a.row || this.extentCell.col !== a.col) && (this.extentCell = a, this.paintSelection());
|
|
2685
2692
|
}
|
|
2686
2693
|
collectCellsInRange(t, e, n, s, o) {
|
|
@@ -2697,7 +2704,7 @@ class Es {
|
|
|
2697
2704
|
return t < e ? 0 : t > n ? s - 1 : o;
|
|
2698
2705
|
}
|
|
2699
2706
|
}
|
|
2700
|
-
const
|
|
2707
|
+
const U = (i) => {
|
|
2701
2708
|
const t = i.querySelector(`[${g}]`);
|
|
2702
2709
|
if (!t)
|
|
2703
2710
|
return [];
|
|
@@ -2766,13 +2773,13 @@ const J = (i) => {
|
|
|
2766
2773
|
return e.splice(t, 1), e.length > 0 ? e : void 0;
|
|
2767
2774
|
}, Is = (i, t, e, n) => {
|
|
2768
2775
|
var l;
|
|
2769
|
-
const s = (l = e.colWidths) != null ? l :
|
|
2776
|
+
const s = (l = e.colWidths) != null ? l : U(i), o = e.initialColWidth !== void 0 ? Math.round(e.initialColWidth / 2 * 100) / 100 : dt(s);
|
|
2770
2777
|
n.addColumn(i, t, s, o);
|
|
2771
2778
|
const r = [...s];
|
|
2772
2779
|
return r.splice(t, 0, o), r;
|
|
2773
|
-
},
|
|
2780
|
+
}, dt = (i) => Math.round(
|
|
2774
2781
|
i.reduce((t, e) => t + e, 0) / i.length / 2 * 100
|
|
2775
|
-
) / 100,
|
|
2782
|
+
) / 100, Ns = (i) => i.length === 0 ? 0 : Math.round(i.reduce((t, e) => t + e, 0) / i.length * 100) / 100, Ds = (i, t, e) => {
|
|
2776
2783
|
var o;
|
|
2777
2784
|
if (!i)
|
|
2778
2785
|
return [];
|
|
@@ -2803,7 +2810,7 @@ const J = (i) => {
|
|
|
2803
2810
|
}), s.deleteBlocks(s.getBlockIdsFromCells(r));
|
|
2804
2811
|
}
|
|
2805
2812
|
return n.deleteColumn(i, t), Bs(e, t);
|
|
2806
|
-
},
|
|
2813
|
+
}, G = (i, t) => {
|
|
2807
2814
|
i.querySelectorAll(`[${u}]`).forEach((n) => {
|
|
2808
2815
|
t == null || t.ensureCellHasBlock(n);
|
|
2809
2816
|
});
|
|
@@ -2822,30 +2829,30 @@ const J = (i) => {
|
|
|
2822
2829
|
if (!h)
|
|
2823
2830
|
return;
|
|
2824
2831
|
const p = h.querySelectorAll("[data-blok-id]").length > 0;
|
|
2825
|
-
if (!(!
|
|
2826
|
-
if (!
|
|
2827
|
-
const
|
|
2832
|
+
if (!(!yt(a) && p)) {
|
|
2833
|
+
if (!yt(a)) {
|
|
2834
|
+
const f = typeof a == "string" ? a : "", m = e.blocks.insert(
|
|
2828
2835
|
"paragraph",
|
|
2829
|
-
{ text:
|
|
2836
|
+
{ text: f },
|
|
2830
2837
|
{},
|
|
2831
2838
|
void 0,
|
|
2832
2839
|
!0
|
|
2833
2840
|
);
|
|
2834
|
-
|
|
2841
|
+
m != null && m.holder && h.appendChild(m.holder);
|
|
2835
2842
|
return;
|
|
2836
2843
|
}
|
|
2837
|
-
for (const
|
|
2838
|
-
const
|
|
2839
|
-
if (
|
|
2844
|
+
for (const f of a.blocks) {
|
|
2845
|
+
const m = e.blocks.getBlockIndex(f);
|
|
2846
|
+
if (m === void 0)
|
|
2840
2847
|
continue;
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2848
|
+
const C = e.blocks.getBlockByIndex(m);
|
|
2849
|
+
C && h.appendChild(C.holder);
|
|
2843
2850
|
}
|
|
2844
2851
|
}
|
|
2845
2852
|
});
|
|
2846
2853
|
});
|
|
2847
2854
|
}, _s = (i, t) => {
|
|
2848
|
-
var l, a, c, d, h, p,
|
|
2855
|
+
var l, a, c, d, h, p, f, m, C, b;
|
|
2849
2856
|
if (!(typeof i == "object" && i !== null && "content" in i))
|
|
2850
2857
|
return {
|
|
2851
2858
|
withHeadings: (l = t.withHeadings) != null ? l : !1,
|
|
@@ -2856,8 +2863,8 @@ const J = (i) => {
|
|
|
2856
2863
|
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;
|
|
2857
2864
|
return {
|
|
2858
2865
|
withHeadings: (p = (h = n.withHeadings) != null ? h : t.withHeadings) != null ? p : !1,
|
|
2859
|
-
withHeadingColumn: (
|
|
2860
|
-
stretched: (
|
|
2866
|
+
withHeadingColumn: (f = n.withHeadingColumn) != null ? f : !1,
|
|
2867
|
+
stretched: (C = (m = n.stretched) != null ? m : t.stretched) != null ? C : !1,
|
|
2861
2868
|
content: (b = n.content) != null ? b : [],
|
|
2862
2869
|
colWidths: r,
|
|
2863
2870
|
initialColWidth: n.initialColWidth
|
|
@@ -2882,7 +2889,7 @@ const J = (i) => {
|
|
|
2882
2889
|
n.forEach((s) => {
|
|
2883
2890
|
s.removeAttribute("data-blok-table-heading");
|
|
2884
2891
|
}), t && n.length > 0 && n[0].setAttribute("data-blok-table-heading", "");
|
|
2885
|
-
},
|
|
2892
|
+
}, V = (i, t) => {
|
|
2886
2893
|
if (!i)
|
|
2887
2894
|
return;
|
|
2888
2895
|
const e = i.firstElementChild;
|
|
@@ -2894,7 +2901,7 @@ const J = (i) => {
|
|
|
2894
2901
|
const r = o.querySelector(`[${u}]`);
|
|
2895
2902
|
r && r.setAttribute("data-blok-table-heading-col", "");
|
|
2896
2903
|
});
|
|
2897
|
-
}, Ft = "data-blok-table-resize", Ms = "data-blok-table-cell", Ws = "data-blok-table-row", $s = 50,
|
|
2904
|
+
}, Ft = "data-blok-table-resize", Ms = "data-blok-table-cell", Ws = "data-blok-table-row", $s = 50, Ct = 16;
|
|
2898
2905
|
class Gs {
|
|
2899
2906
|
constructor(t, e, n, s, o, r = !1) {
|
|
2900
2907
|
this._enabled = !0, this.isDragging = !1, this.dragStartX = 0, this.dragColIndex = -1, this.startColWidth = 0, this.handles = [], this.gridEl = t, this.colWidths = [...e], this.onChange = n, this.onDragStart = s != null ? s : null, this.onDrag = o != null ? o : null, this.needsInitialApply = r, this.boundPointerDown = this.onPointerDown.bind(this), this.boundPointerMove = this.onPointerMove.bind(this), this.boundPointerUp = this.onPointerUp.bind(this), this.gridEl.style.position = "relative", r || this.applyWidths(), this.createHandles(), this.gridEl.addEventListener("pointerdown", this.boundPointerDown);
|
|
@@ -2922,7 +2929,7 @@ class Gs {
|
|
|
2922
2929
|
}
|
|
2923
2930
|
createHandle(t) {
|
|
2924
2931
|
const e = document.createElement("div"), n = this.getHandleLeftPx(t);
|
|
2925
|
-
return e.setAttribute(Ft, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${P}px`, e.style.bottom = "0px", e.style.width = `${
|
|
2932
|
+
return e.setAttribute(Ft, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${P}px`, e.style.bottom = "0px", e.style.width = `${Ct}px`, e.style.left = `${n - Ct / 2}px`, e.style.cursor = "col-resize", e.style.zIndex = "2", e.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", e.style.opacity = "0", e.style.transition = "opacity 150ms ease", e.setAttribute("contenteditable", "false"), e.addEventListener("mouseenter", () => {
|
|
2926
2933
|
this.isDragging || (e.style.opacity = "1");
|
|
2927
2934
|
}), e.addEventListener("mouseleave", () => {
|
|
2928
2935
|
this.isDragging || (e.style.opacity = "0");
|
|
@@ -2934,7 +2941,7 @@ class Gs {
|
|
|
2934
2941
|
updateHandlePositions() {
|
|
2935
2942
|
this.handles.forEach((t, e) => {
|
|
2936
2943
|
const n = this.getHandleLeftPx(e), s = t;
|
|
2937
|
-
s.style.left = `${n -
|
|
2944
|
+
s.style.left = `${n - Ct / 2}px`;
|
|
2938
2945
|
});
|
|
2939
2946
|
}
|
|
2940
2947
|
onPointerDown(t) {
|
|
@@ -2974,7 +2981,7 @@ class Gs {
|
|
|
2974
2981
|
});
|
|
2975
2982
|
}
|
|
2976
2983
|
}
|
|
2977
|
-
const zt = (i, t, e) => (e.grid.addRow(i, t),
|
|
2984
|
+
const zt = (i, t, e) => (e.grid.addRow(i, t), G(i, e.cellBlocks), {
|
|
2978
2985
|
pendingHighlight: { type: "row", index: t },
|
|
2979
2986
|
moveSelection: null,
|
|
2980
2987
|
colWidths: e.data.colWidths,
|
|
@@ -2982,7 +2989,7 @@ const zt = (i, t, e) => (e.grid.addRow(i, t), V(i, e.cellBlocks), {
|
|
|
2982
2989
|
withHeadingColumn: e.data.withHeadingColumn
|
|
2983
2990
|
}), Vt = (i, t, e) => {
|
|
2984
2991
|
const n = Is(i, t, e.data, e.grid);
|
|
2985
|
-
return
|
|
2992
|
+
return G(i, e.cellBlocks), {
|
|
2986
2993
|
pendingHighlight: { type: "col", index: t },
|
|
2987
2994
|
moveSelection: null,
|
|
2988
2995
|
colWidths: n,
|
|
@@ -3322,7 +3329,7 @@ const Xs = [
|
|
|
3322
3329
|
}, to = (i, t) => {
|
|
3323
3330
|
const e = i === 0 ? [
|
|
3324
3331
|
{
|
|
3325
|
-
type:
|
|
3332
|
+
type: F.Html,
|
|
3326
3333
|
element: ye({
|
|
3327
3334
|
icon: Ue,
|
|
3328
3335
|
label: t.i18n.t("tools.table.headerColumn"),
|
|
@@ -3332,7 +3339,7 @@ const Xs = [
|
|
|
3332
3339
|
}
|
|
3333
3340
|
})
|
|
3334
3341
|
},
|
|
3335
|
-
{ type:
|
|
3342
|
+
{ type: F.Separator }
|
|
3336
3343
|
] : [], n = [
|
|
3337
3344
|
{
|
|
3338
3345
|
icon: qe,
|
|
@@ -3351,7 +3358,7 @@ const Xs = [
|
|
|
3351
3358
|
}
|
|
3352
3359
|
}
|
|
3353
3360
|
], s = t.getColumnCount() > 1, o = [
|
|
3354
|
-
{ type:
|
|
3361
|
+
{ type: F.Separator },
|
|
3355
3362
|
{
|
|
3356
3363
|
icon: oe,
|
|
3357
3364
|
title: t.i18n.t("tools.table.deleteColumn"),
|
|
@@ -3367,7 +3374,7 @@ const Xs = [
|
|
|
3367
3374
|
}, eo = (i, t) => {
|
|
3368
3375
|
const e = i === 0 ? [
|
|
3369
3376
|
{
|
|
3370
|
-
type:
|
|
3377
|
+
type: F.Html,
|
|
3371
3378
|
element: ye({
|
|
3372
3379
|
icon: Ke,
|
|
3373
3380
|
label: t.i18n.t("tools.table.headerRow"),
|
|
@@ -3377,7 +3384,7 @@ const Xs = [
|
|
|
3377
3384
|
}
|
|
3378
3385
|
})
|
|
3379
3386
|
},
|
|
3380
|
-
{ type:
|
|
3387
|
+
{ type: F.Separator }
|
|
3381
3388
|
] : [], n = [
|
|
3382
3389
|
{
|
|
3383
3390
|
icon: ze,
|
|
@@ -3396,7 +3403,7 @@ const Xs = [
|
|
|
3396
3403
|
}
|
|
3397
3404
|
}
|
|
3398
3405
|
], s = t.getRowCount() > 1, o = [
|
|
3399
|
-
{ type:
|
|
3406
|
+
{ type: F.Separator },
|
|
3400
3407
|
{
|
|
3401
3408
|
icon: oe,
|
|
3402
3409
|
title: t.i18n.t("tools.table.deleteRow"),
|
|
@@ -3422,7 +3429,7 @@ const Xs = [
|
|
|
3422
3429
|
return l.on(se.Closed, () => {
|
|
3423
3430
|
var a;
|
|
3424
3431
|
s.destroyPopover(), s.applyVisibleClasses(o), s.scheduleHideAll(), (a = s.onGripPopoverClose) == null || a.call(s);
|
|
3425
|
-
}), s.hideAllGripsExcept(o), s.applyActiveClasses(o), i === "col" ? o.style.height = `${
|
|
3432
|
+
}), s.hideAllGripsExcept(o), s.applyActiveClasses(o), i === "col" ? o.style.height = `${Y}px` : o.style.width = `${Y}px`, { popover: l, grip: o };
|
|
3426
3433
|
}, Kt = "data-blok-table-grip", ot = "data-blok-table-grip-col", jt = "data-blok-table-grip-row", so = 150, oo = 24, it = 4, rt = 4, io = 20, lt = [
|
|
3427
3434
|
"absolute",
|
|
3428
3435
|
"z-[3]",
|
|
@@ -3473,7 +3480,7 @@ class ao {
|
|
|
3473
3480
|
*/
|
|
3474
3481
|
setActiveGrip(t, e) {
|
|
3475
3482
|
const n = t === "col" ? this.colGrips[e] : this.rowGrips[e];
|
|
3476
|
-
n && (this.unlockGrip(), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${
|
|
3483
|
+
n && (this.unlockGrip(), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${Y}px` : n.style.width = `${Y}px`, this.lockedGrip = n, requestAnimationFrame(() => {
|
|
3477
3484
|
document.addEventListener("pointerdown", this.boundUnlockGrip);
|
|
3478
3485
|
}));
|
|
3479
3486
|
}
|
|
@@ -3507,7 +3514,7 @@ class ao {
|
|
|
3507
3514
|
return n.style.width = `${s}px`, n.style.height = `${o}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid white", n.appendChild(fe(t === "col" ? "horizontal" : "vertical")), n.addEventListener("pointerdown", this.boundPointerDown), n.addEventListener("mouseenter", () => {
|
|
3508
3515
|
this.isGripInteractionLocked() || ys(n, t);
|
|
3509
3516
|
}), n.addEventListener("mouseleave", () => {
|
|
3510
|
-
this.isGripInteractionLocked() ||
|
|
3517
|
+
this.isGripInteractionLocked() || gt(n, t, r);
|
|
3511
3518
|
}), n;
|
|
3512
3519
|
}
|
|
3513
3520
|
/**
|
|
@@ -3601,7 +3608,7 @@ class ao {
|
|
|
3601
3608
|
}
|
|
3602
3609
|
applyVisibleClasses(t) {
|
|
3603
3610
|
const e = t, n = e.hasAttribute(ot);
|
|
3604
|
-
|
|
3611
|
+
gt(e, n ? "col" : "row", n ? it : rt), this.isInsideTable && (e.style.transition = "none"), e.className = v(lt, ro), e.setAttribute("data-blok-table-grip-visible", ""), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
|
|
3605
3612
|
const r = e.querySelector("svg");
|
|
3606
3613
|
r && (r.classList.remove("text-white"), r.classList.add("text-gray-400"));
|
|
3607
3614
|
}
|
|
@@ -3617,7 +3624,7 @@ class ao {
|
|
|
3617
3624
|
}
|
|
3618
3625
|
applyIdleClasses(t) {
|
|
3619
3626
|
const e = t, n = e.hasAttribute(ot), s = n ? "col" : "row", o = 12, r = n ? it + o : rt + o;
|
|
3620
|
-
this.isInsideTable && (e.style.transition = "none"),
|
|
3627
|
+
this.isInsideTable && (e.style.transition = "none"), gt(e, s, r), e.className = v(lt, Xt), e.removeAttribute("data-blok-table-grip-visible"), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
|
|
3621
3628
|
}
|
|
3622
3629
|
handleDragStateChange(t, e) {
|
|
3623
3630
|
[...this.colGrips, ...this.rowGrips].forEach((n) => {
|
|
@@ -3692,7 +3699,7 @@ const co = 3, ho = 3, uo = [
|
|
|
3692
3699
|
];
|
|
3693
3700
|
class So {
|
|
3694
3701
|
constructor({ data: t, config: e, api: n, readOnly: s, block: o }) {
|
|
3695
|
-
this.resize = null, this.addControls = null, this.rowColControls = null, this.cellBlocks = null, this.cellSelection = null, this.element = null, this.pendingHighlight = null, this.api = n, this.readOnly = s, this.config = e != null ? e : {}, this.data = _s(t, e != null ? e : {}), this.grid = new gs({ readOnly: s }), this.blockId = o == null ? void 0 : o.id;
|
|
3702
|
+
this.resize = null, this.addControls = null, this.rowColControls = null, this.cellBlocks = null, this.cellSelection = null, this.element = null, this.pendingHighlight = null, this.isNewTable = !1, this.api = n, this.readOnly = s, this.config = e != null ? e : {}, this.data = _s(t, e != null ? e : {}), this.grid = new gs({ readOnly: s }), this.blockId = o == null ? void 0 : o.id;
|
|
3696
3703
|
}
|
|
3697
3704
|
static get toolbox() {
|
|
3698
3705
|
return {
|
|
@@ -3727,9 +3734,9 @@ class So {
|
|
|
3727
3734
|
render() {
|
|
3728
3735
|
var o;
|
|
3729
3736
|
const t = document.createElement("div");
|
|
3730
|
-
t.className = v(uo, !this.readOnly && po, this.data.colWidths && Ce), t.setAttribute(E.tool, "table"), this.readOnly && t.setAttribute("data-blok-table-readonly", "");
|
|
3737
|
+
t.className = v(uo, !this.readOnly && po, this.data.colWidths && Ce), t.setAttribute(E.tool, "table"), this.readOnly && t.setAttribute("data-blok-table-readonly", ""), this.isNewTable = this.data.content.length === 0;
|
|
3731
3738
|
const e = this.data.content.length || this.config.rows || co, n = ((o = this.data.content[0]) == null ? void 0 : o.length) || this.config.cols || ho, s = this.grid.createGrid(e, n, this.data.colWidths);
|
|
3732
|
-
return this.data.content.length > 0 && this.grid.fillGrid(s, this.data.content), this.data.colWidths && ct(s, this.data.colWidths), t.appendChild(s), this.element = t, this.data.withHeadings && st(this.element, this.data.withHeadings), this.data.withHeadingColumn &&
|
|
3739
|
+
return this.data.content.length > 0 && this.grid.fillGrid(s, this.data.content), this.data.colWidths && ct(s, this.data.colWidths), t.appendChild(s), this.element = t, this.data.withHeadings && st(this.element, this.data.withHeadings), this.data.withHeadingColumn && V(this.element, this.data.withHeadingColumn), this.readOnly || (this.initCellBlocks(s), Os(s, this.cellBlocks)), t;
|
|
3733
3740
|
}
|
|
3734
3741
|
rendered() {
|
|
3735
3742
|
var e, n, s;
|
|
@@ -3741,11 +3748,14 @@ class So {
|
|
|
3741
3748
|
Ps(t, this.data.content, this.api);
|
|
3742
3749
|
return;
|
|
3743
3750
|
}
|
|
3744
|
-
if (this.data.content = (n = (e = this.cellBlocks) == null ? void 0 : e.initializeCells(this.data.content)) != null ? n : this.data.content, this.data.initialColWidth === void 0) {
|
|
3745
|
-
const o = (s = this.data.colWidths) != null ? s :
|
|
3746
|
-
this.data.initialColWidth = o.length > 0 ?
|
|
3751
|
+
if (this.data.content = (n = (e = this.cellBlocks) == null ? void 0 : e.initializeCells(this.data.content)) != null ? n : this.data.content, this.isNewTable && G(t, this.cellBlocks), this.data.initialColWidth === void 0) {
|
|
3752
|
+
const o = (s = this.data.colWidths) != null ? s : U(t);
|
|
3753
|
+
this.data.initialColWidth = o.length > 0 ? Ns(o) : void 0;
|
|
3754
|
+
}
|
|
3755
|
+
if (this.initResize(t), this.initAddControls(t), this.initRowColControls(t), this.initCellSelection(t), this.isNewTable) {
|
|
3756
|
+
const o = t.querySelector('[contenteditable="true"]');
|
|
3757
|
+
o == null || o.focus();
|
|
3747
3758
|
}
|
|
3748
|
-
this.initResize(t), this.initAddControls(t), this.initRowColControls(t), this.initCellSelection(t);
|
|
3749
3759
|
}
|
|
3750
3760
|
}
|
|
3751
3761
|
save(t) {
|
|
@@ -3764,10 +3774,10 @@ class So {
|
|
|
3764
3774
|
var d, h;
|
|
3765
3775
|
const e = t.detail.data, n = e.querySelectorAll("tr"), s = [];
|
|
3766
3776
|
n.forEach((p) => {
|
|
3767
|
-
const
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
}),
|
|
3777
|
+
const f = p.querySelectorAll("td, th"), m = [];
|
|
3778
|
+
f.forEach((C) => {
|
|
3779
|
+
m.push(C.innerHTML);
|
|
3780
|
+
}), m.length > 0 && s.push(m);
|
|
3771
3781
|
});
|
|
3772
3782
|
const o = e.querySelector("thead") !== null, r = ((d = n[0]) == null ? void 0 : d.querySelector("th")) !== null, l = o || r;
|
|
3773
3783
|
if (this.data = {
|
|
@@ -3797,7 +3807,7 @@ class So {
|
|
|
3797
3807
|
e && (this.data.colWidths = vt(e, t, this.data.colWidths, this.grid, this.cellBlocks));
|
|
3798
3808
|
}
|
|
3799
3809
|
getBlockIdsInRow(t) {
|
|
3800
|
-
return
|
|
3810
|
+
return Ds(this.element, this.cellBlocks, t);
|
|
3801
3811
|
}
|
|
3802
3812
|
getBlockIdsInColumn(t) {
|
|
3803
3813
|
return Hs(this.element, this.cellBlocks, t);
|
|
@@ -3811,21 +3821,26 @@ class So {
|
|
|
3811
3821
|
wrapper: this.element,
|
|
3812
3822
|
grid: t,
|
|
3813
3823
|
i18n: this.api.i18n,
|
|
3824
|
+
getNewColumnWidth: () => {
|
|
3825
|
+
var o;
|
|
3826
|
+
const s = (o = this.data.colWidths) != null ? o : U(t);
|
|
3827
|
+
return this.data.initialColWidth !== void 0 ? Math.round(this.data.initialColWidth / 2 * 100) / 100 : dt(s);
|
|
3828
|
+
},
|
|
3814
3829
|
onAddRow: () => {
|
|
3815
3830
|
var s, o;
|
|
3816
|
-
this.grid.addRow(t),
|
|
3831
|
+
this.grid.addRow(t), G(t, this.cellBlocks), st(this.element, this.data.withHeadings), V(this.element, this.data.withHeadingColumn), this.initResize(t), (s = this.addControls) == null || s.syncRowButtonWidth(), (o = this.rowColControls) == null || o.refresh();
|
|
3817
3832
|
},
|
|
3818
3833
|
onAddColumn: () => {
|
|
3819
3834
|
var r, l, a;
|
|
3820
|
-
const s = (r = this.data.colWidths) != null ? r :
|
|
3821
|
-
this.grid.addColumn(t, void 0, s, o), this.data.colWidths = [...s, o],
|
|
3835
|
+
const s = (r = this.data.colWidths) != null ? r : U(t), o = this.data.initialColWidth !== void 0 ? Math.round(this.data.initialColWidth / 2 * 100) / 100 : dt(s);
|
|
3836
|
+
this.grid.addColumn(t, void 0, s, o), this.data.colWidths = [...s, o], G(t, this.cellBlocks), V(this.element, this.data.withHeadingColumn), this.initResize(t), (l = this.addControls) == null || l.syncRowButtonWidth(), (a = this.rowColControls) == null || a.refresh();
|
|
3822
3837
|
},
|
|
3823
3838
|
onDragStart: () => {
|
|
3824
3839
|
var s, o;
|
|
3825
3840
|
this.resize && (this.resize.enabled = !1), (s = this.rowColControls) == null || s.hideAllGrips(), (o = this.rowColControls) == null || o.setGripsDisplay(!1);
|
|
3826
3841
|
},
|
|
3827
3842
|
onDragAddRow: () => {
|
|
3828
|
-
this.grid.addRow(t),
|
|
3843
|
+
this.grid.addRow(t), G(t, this.cellBlocks), st(this.element, this.data.withHeadings), V(this.element, this.data.withHeadingColumn);
|
|
3829
3844
|
},
|
|
3830
3845
|
onDragRemoveRow: () => {
|
|
3831
3846
|
const s = this.grid.getRowCount(t);
|
|
@@ -3833,8 +3848,8 @@ class So {
|
|
|
3833
3848
|
},
|
|
3834
3849
|
onDragAddCol: () => {
|
|
3835
3850
|
var r;
|
|
3836
|
-
const s = (r = this.data.colWidths) != null ? r :
|
|
3837
|
-
this.grid.addColumn(t, void 0, s, o), this.data.colWidths = [...s, o], ct(t, this.data.colWidths),
|
|
3851
|
+
const s = (r = this.data.colWidths) != null ? r : U(t), o = this.data.initialColWidth !== void 0 ? Math.round(this.data.initialColWidth / 2 * 100) / 100 : dt(s);
|
|
3852
|
+
this.grid.addColumn(t, void 0, s, o), this.data.colWidths = [...s, o], ct(t, this.data.colWidths), G(t, this.cellBlocks), V(this.element, this.data.withHeadingColumn), this.initResize(t), e.addedCols++, this.element && (this.element.scrollLeft = this.element.scrollWidth);
|
|
3838
3853
|
},
|
|
3839
3854
|
onDragRemoveCol: () => {
|
|
3840
3855
|
const s = this.grid.getColumnCount(t);
|
|
@@ -3884,7 +3899,7 @@ class So {
|
|
|
3884
3899
|
e,
|
|
3885
3900
|
{ grid: this.grid, data: this.data, cellBlocks: this.cellBlocks }
|
|
3886
3901
|
);
|
|
3887
|
-
if (this.data.colWidths = n.colWidths, this.data.withHeadings = n.withHeadings, this.data.withHeadingColumn = n.withHeadingColumn, this.pendingHighlight = n.pendingHighlight, st(this.element, this.data.withHeadings),
|
|
3902
|
+
if (this.data.colWidths = n.colWidths, this.data.withHeadings = n.withHeadings, this.data.withHeadingColumn = n.withHeadingColumn, this.pendingHighlight = n.pendingHighlight, st(this.element, this.data.withHeadings), V(this.element, this.data.withHeadingColumn), this.initResize(t), (r = this.addControls) == null || r.syncRowButtonWidth(), (l = this.rowColControls) == null || l.refresh(), !n.moveSelection)
|
|
3888
3903
|
return;
|
|
3889
3904
|
const { type: s, index: o } = n.moveSelection;
|
|
3890
3905
|
s === "row" ? (a = this.cellSelection) == null || a.selectRow(o) : (c = this.cellSelection) == null || c.selectColumn(o), (d = this.rowColControls) == null || d.setActiveGrip(s, o);
|
|
@@ -3892,7 +3907,7 @@ class So {
|
|
|
3892
3907
|
initResize(t) {
|
|
3893
3908
|
var s, o;
|
|
3894
3909
|
(s = this.resize) == null || s.destroy();
|
|
3895
|
-
const e = this.data.colWidths === void 0, n = (o = this.data.colWidths) != null ? o :
|
|
3910
|
+
const e = this.data.colWidths === void 0, n = (o = this.data.colWidths) != null ? o : U(t);
|
|
3896
3911
|
e || qt(this.element), this.resize = new Gs(
|
|
3897
3912
|
t,
|
|
3898
3913
|
n,
|
|
@@ -3941,10 +3956,10 @@ class So {
|
|
|
3941
3956
|
});
|
|
3942
3957
|
}
|
|
3943
3958
|
}
|
|
3944
|
-
const
|
|
3959
|
+
const q = (i) => {
|
|
3945
3960
|
const t = i.tagName;
|
|
3946
3961
|
return t === "B" || t === "STRONG";
|
|
3947
|
-
},
|
|
3962
|
+
}, ut = (i) => !!(i && i.nodeType === Node.ELEMENT_NODE && q(i)), be = (i) => i.textContent.length === 0, D = (i) => i ? i.nodeType === Node.ELEMENT_NODE && q(i) ? _(i) : D(i.parentNode) : null, _ = (i) => {
|
|
3948
3963
|
if (i.tagName === "STRONG")
|
|
3949
3964
|
return i;
|
|
3950
3965
|
const t = document.createElement("strong");
|
|
@@ -4137,21 +4152,21 @@ const G = (i) => {
|
|
|
4137
4152
|
const h = Number(c);
|
|
4138
4153
|
if (!Number.isFinite(h))
|
|
4139
4154
|
return;
|
|
4140
|
-
const p = d,
|
|
4141
|
-
if (
|
|
4155
|
+
const p = d, f = p.textContent;
|
|
4156
|
+
if (f.length <= h)
|
|
4142
4157
|
return;
|
|
4143
|
-
const
|
|
4144
|
-
p.textContent =
|
|
4145
|
-
const b =
|
|
4146
|
-
if (b && !a.hasAttribute(S.LEADING_WHITESPACE) && a.setAttribute(S.LEADING_WHITESPACE, b[0]),
|
|
4158
|
+
const m = f.slice(0, h), C = f.slice(h);
|
|
4159
|
+
p.textContent = m;
|
|
4160
|
+
const b = C.match(/^[\u00A0\s]+/);
|
|
4161
|
+
if (b && !a.hasAttribute(S.LEADING_WHITESPACE) && a.setAttribute(S.LEADING_WHITESPACE, b[0]), C.length === 0)
|
|
4147
4162
|
return;
|
|
4148
|
-
const B = a.textContent, I = B +
|
|
4163
|
+
const B = a.textContent, I = B + C, N = (kt = a.getAttribute(S.LEADING_WHITESPACE)) != null ? kt : "", W = N.length > 0 && B.length === 0 && !I.startsWith(N) ? N + I : I, $ = document.createTextNode(W);
|
|
4149
4164
|
for (; a.firstChild; )
|
|
4150
4165
|
a.removeChild(a.firstChild);
|
|
4151
4166
|
if (a.appendChild($), !(t != null && t.isCollapsed) || !wt(t.focusNode, p))
|
|
4152
4167
|
return;
|
|
4153
|
-
const
|
|
4154
|
-
|
|
4168
|
+
const J = document.createRange(), Ee = $.textContent.length;
|
|
4169
|
+
J.setStart($, Ee), J.collapse(!0), t.removeAllRanges(), t.addRange(J);
|
|
4155
4170
|
});
|
|
4156
4171
|
}
|
|
4157
4172
|
/**
|
|
@@ -4167,19 +4182,19 @@ const G = (i) => {
|
|
|
4167
4182
|
if (!s)
|
|
4168
4183
|
return;
|
|
4169
4184
|
s.querySelectorAll(`strong[${S.COLLAPSED_LENGTH}]`).forEach((l) => {
|
|
4170
|
-
var
|
|
4185
|
+
var N, M;
|
|
4171
4186
|
const a = l.getAttribute(S.COLLAPSED_LENGTH);
|
|
4172
4187
|
if (!a)
|
|
4173
4188
|
return;
|
|
4174
4189
|
const c = Number(a), d = l.textContent;
|
|
4175
4190
|
if (!Number.isFinite(c))
|
|
4176
4191
|
return;
|
|
4177
|
-
const h = d.length > c, p = h ? this.splitCollapsedBoldText(l, c, d) : null,
|
|
4192
|
+
const h = d.length > c, p = h ? this.splitCollapsedBoldText(l, c, d) : null, f = l.getAttribute(S.PREV_LENGTH), m = f ? Number(f) : NaN, C = l.previousSibling, b = (C == null ? void 0 : C.nodeType) === Node.TEXT_NODE ? C : null, B = (N = b == null ? void 0 : b.textContent) != null ? N : "", I = !!(f && Number.isFinite(m) && b && B.length > m);
|
|
4178
4193
|
if (I && b) {
|
|
4179
|
-
const W = B.slice(0,
|
|
4194
|
+
const W = B.slice(0, m), $ = B.slice(m);
|
|
4180
4195
|
b.textContent = W;
|
|
4181
|
-
const
|
|
4182
|
-
(M = l.parentNode) == null || M.insertBefore(
|
|
4196
|
+
const J = document.createTextNode($);
|
|
4197
|
+
(M = l.parentNode) == null || M.insertBefore(J, l.nextSibling);
|
|
4183
4198
|
}
|
|
4184
4199
|
if (I && l.removeAttribute(S.PREV_LENGTH), t != null && t.isCollapsed && p && wt(t.focusNode, l)) {
|
|
4185
4200
|
const W = document.createRange(), $ = p.textContent.length;
|
|
@@ -4243,7 +4258,7 @@ const G = (i) => {
|
|
|
4243
4258
|
const e = t.getRangeAt(0);
|
|
4244
4259
|
if (!e.collapsed)
|
|
4245
4260
|
return;
|
|
4246
|
-
const n =
|
|
4261
|
+
const n = D(e.startContainer);
|
|
4247
4262
|
(n == null ? void 0 : n.getAttribute(S.COLLAPSED_ACTIVE)) !== "true" && (this.moveCaretFromElementContainer(t, e) || this.moveCaretFromTextContainer(t, e));
|
|
4248
4263
|
}
|
|
4249
4264
|
/**
|
|
@@ -4302,7 +4317,7 @@ const G = (i) => {
|
|
|
4302
4317
|
this.setCaret(t, n, o.length);
|
|
4303
4318
|
return;
|
|
4304
4319
|
}
|
|
4305
|
-
const l =
|
|
4320
|
+
const l = D(n);
|
|
4306
4321
|
if (!l || e.startOffset !== n.textContent.length)
|
|
4307
4322
|
return;
|
|
4308
4323
|
const a = this.ensureFollowingTextNode(l, l.nextSibling);
|
|
@@ -4467,12 +4482,12 @@ class R {
|
|
|
4467
4482
|
*/
|
|
4468
4483
|
mergeWithAdjacent(t) {
|
|
4469
4484
|
const e = t.previousSibling;
|
|
4470
|
-
if (e &&
|
|
4485
|
+
if (e && ut(e)) {
|
|
4471
4486
|
this.mergeStrongNodes(e, t);
|
|
4472
4487
|
return;
|
|
4473
4488
|
}
|
|
4474
4489
|
const n = t.nextSibling;
|
|
4475
|
-
n &&
|
|
4490
|
+
n && ut(n) && this.mergeStrongNodes(t, n);
|
|
4476
4491
|
}
|
|
4477
4492
|
/**
|
|
4478
4493
|
* Merge two <strong> elements by moving children from right to left
|
|
@@ -4610,23 +4625,23 @@ const Co = (i, t) => {
|
|
|
4610
4625
|
{
|
|
4611
4626
|
acceptNode: (t) => Co(i, t) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
|
|
4612
4627
|
}
|
|
4613
|
-
),
|
|
4628
|
+
), Z = (i, t) => i ? i.nodeType === Node.ELEMENT_NODE && t(i) ? i : Z(i.parentNode, t) : null, Se = (i, t) => Z(i, t) !== null, we = (i, t, e = {}) => {
|
|
4614
4629
|
if (i.collapsed)
|
|
4615
|
-
return
|
|
4630
|
+
return Z(i.startContainer, t) !== null;
|
|
4616
4631
|
const n = ve(i), s = [];
|
|
4617
4632
|
for (; n.nextNode(); ) {
|
|
4618
4633
|
const o = n.currentNode, r = o.textContent;
|
|
4619
4634
|
e.ignoreWhitespace && r.trim().length === 0 || r.length !== 0 && s.push(o);
|
|
4620
4635
|
}
|
|
4621
|
-
return s.length === 0 ?
|
|
4636
|
+
return s.length === 0 ? Z(i.startContainer, t) !== null : s.every((o) => Se(o, t));
|
|
4622
4637
|
}, Ae = (i, t) => {
|
|
4623
4638
|
const e = /* @__PURE__ */ new Set(), n = ve(i);
|
|
4624
4639
|
for (; n.nextNode(); ) {
|
|
4625
|
-
const s =
|
|
4640
|
+
const s = Z(n.currentNode, t);
|
|
4626
4641
|
s && e.add(s);
|
|
4627
4642
|
}
|
|
4628
4643
|
return Array.from(e);
|
|
4629
|
-
},
|
|
4644
|
+
}, y = class y {
|
|
4630
4645
|
/**
|
|
4631
4646
|
* Sanitizer Rule
|
|
4632
4647
|
* Leave <strong> tags
|
|
@@ -4642,7 +4657,7 @@ const Co = (i, t) => {
|
|
|
4642
4657
|
*
|
|
4643
4658
|
*/
|
|
4644
4659
|
constructor() {
|
|
4645
|
-
typeof document != "undefined" && (
|
|
4660
|
+
typeof document != "undefined" && (y.instances.add(this), y.initializeGlobalListeners());
|
|
4646
4661
|
}
|
|
4647
4662
|
/**
|
|
4648
4663
|
* Ensure global event listeners are registered once per document
|
|
@@ -4654,20 +4669,20 @@ const Co = (i, t) => {
|
|
|
4654
4669
|
return t.hasHandler("bold") || (t.register("bold", {
|
|
4655
4670
|
shortcut: { key: "b", meta: !0 },
|
|
4656
4671
|
onShortcut: (e, n) => {
|
|
4657
|
-
const s =
|
|
4672
|
+
const s = y.instances.values().next().value;
|
|
4658
4673
|
s && s.toggleBold();
|
|
4659
4674
|
},
|
|
4660
4675
|
onSelectionChange: (e) => {
|
|
4661
|
-
|
|
4676
|
+
y.refreshSelectionState("selectionchange");
|
|
4662
4677
|
},
|
|
4663
4678
|
onInput: (e, n) => {
|
|
4664
|
-
|
|
4679
|
+
y.refreshSelectionState("input");
|
|
4665
4680
|
},
|
|
4666
4681
|
onBeforeInput: (e) => e.inputType !== "formatBold" ? !1 : (R.normalizeAroundSelection(window.getSelection()), !0),
|
|
4667
|
-
isRelevant: (e) =>
|
|
4668
|
-
}),
|
|
4682
|
+
isRelevant: (e) => y.isSelectionInsideBlok(e)
|
|
4683
|
+
}), y.guardKeydownListenerRegistered || (document.addEventListener("keydown", (e) => {
|
|
4669
4684
|
A.getInstance().guardBoundaryKeydown(e);
|
|
4670
|
-
}, !0),
|
|
4685
|
+
}, !0), y.guardKeydownListenerRegistered = !0), y.ensureMutationObserver()), !0;
|
|
4671
4686
|
}
|
|
4672
4687
|
/**
|
|
4673
4688
|
* Merge two strong elements by moving children from right to left
|
|
@@ -4744,10 +4759,10 @@ const Co = (i, t) => {
|
|
|
4744
4759
|
if (!n)
|
|
4745
4760
|
return;
|
|
4746
4761
|
const s = document.createElement("span"), o = t.extractContents();
|
|
4747
|
-
s.setAttribute("data-blok-bold-marker", `unwrap-${
|
|
4762
|
+
s.setAttribute("data-blok-bold-marker", `unwrap-${y.markerSequence++}`), s.appendChild(o), this.removeNestedBold(s), t.insertNode(s);
|
|
4748
4763
|
const r = document.createRange();
|
|
4749
4764
|
for (r.selectNodeContents(s), n.removeAllRanges(), n.addRange(r); ; ) {
|
|
4750
|
-
const d =
|
|
4765
|
+
const d = D(s);
|
|
4751
4766
|
if (!d)
|
|
4752
4767
|
break;
|
|
4753
4768
|
this.moveMarkerOutOfBold(s, d);
|
|
@@ -4768,7 +4783,7 @@ const Co = (i, t) => {
|
|
|
4768
4783
|
*/
|
|
4769
4784
|
replaceRangeWithHtml(t, e) {
|
|
4770
4785
|
var l, a;
|
|
4771
|
-
const n =
|
|
4786
|
+
const n = y.createFragmentFromHtml(e), s = (l = n.firstChild) != null ? l : null, o = (a = n.lastChild) != null ? a : null;
|
|
4772
4787
|
if (t.deleteContents(), !s || !o)
|
|
4773
4788
|
return;
|
|
4774
4789
|
t.insertNode(n);
|
|
@@ -4822,7 +4837,7 @@ const Co = (i, t) => {
|
|
|
4822
4837
|
* @param options.ignoreWhitespace - Whether to ignore whitespace-only text nodes
|
|
4823
4838
|
*/
|
|
4824
4839
|
isRangeBold(t, e) {
|
|
4825
|
-
return we(t,
|
|
4840
|
+
return we(t, q, e);
|
|
4826
4841
|
}
|
|
4827
4842
|
/**
|
|
4828
4843
|
* Remove nested bold tags from a root node
|
|
@@ -4854,20 +4869,20 @@ const Co = (i, t) => {
|
|
|
4854
4869
|
*/
|
|
4855
4870
|
findBoldElementFromRangeOrSelection(t, e) {
|
|
4856
4871
|
if (!t)
|
|
4857
|
-
return e ?
|
|
4858
|
-
const n =
|
|
4872
|
+
return e ? D(e.focusNode) : null;
|
|
4873
|
+
const n = D(t.startContainer);
|
|
4859
4874
|
if (n)
|
|
4860
4875
|
return n;
|
|
4861
|
-
const s =
|
|
4862
|
-
return s || (t.startContainer.nodeType === Node.ELEMENT_NODE &&
|
|
4876
|
+
const s = D(t.commonAncestorContainer);
|
|
4877
|
+
return s || (t.startContainer.nodeType === Node.ELEMENT_NODE && q(t.startContainer) ? t.startContainer : null);
|
|
4863
4878
|
}
|
|
4864
4879
|
/**
|
|
4865
4880
|
* Merge adjacent bold elements into a single element
|
|
4866
4881
|
* @param element - The bold element to merge with adjacent elements
|
|
4867
4882
|
*/
|
|
4868
4883
|
mergeAdjacentBold(t) {
|
|
4869
|
-
const e = _(t), n = e.previousSibling, s = n && n.nodeType === Node.ELEMENT_NODE &&
|
|
4870
|
-
return o && o.nodeType === Node.ELEMENT_NODE &&
|
|
4884
|
+
const e = _(t), n = e.previousSibling, s = n && n.nodeType === Node.ELEMENT_NODE && q(n) ? y.mergeStrongNodes(n, e) : e, o = s.nextSibling;
|
|
4885
|
+
return o && o.nodeType === Node.ELEMENT_NODE && q(o) ? y.mergeStrongNodes(s, o) : s;
|
|
4871
4886
|
}
|
|
4872
4887
|
/**
|
|
4873
4888
|
* Toggle bold formatting for a collapsed selection (caret position)
|
|
@@ -4877,10 +4892,10 @@ const Co = (i, t) => {
|
|
|
4877
4892
|
const t = window.getSelection();
|
|
4878
4893
|
if (!t || t.rangeCount === 0)
|
|
4879
4894
|
return;
|
|
4880
|
-
const e = t.getRangeAt(0), n =
|
|
4895
|
+
const e = t.getRangeAt(0), n = D(e.startContainer), s = (() => {
|
|
4881
4896
|
if (n && n.getAttribute(A.ATTR.COLLAPSED_ACTIVE) !== "true")
|
|
4882
4897
|
return A.getInstance().exit(t, n);
|
|
4883
|
-
const o = n != null ? n :
|
|
4898
|
+
const o = n != null ? n : y.getBoundaryBold(e);
|
|
4884
4899
|
return o ? A.getInstance().exit(t, o) : this.startCollapsedBold(e);
|
|
4885
4900
|
})();
|
|
4886
4901
|
document.dispatchEvent(new Event("selectionchange")), s && (t.removeAllRanges(), t.addRange(s)), R.normalizeAroundSelection(t), this.notifySelectionChange();
|
|
@@ -4929,22 +4944,22 @@ const Co = (i, t) => {
|
|
|
4929
4944
|
* Ensure mutation observer is registered to convert legacy <b> tags
|
|
4930
4945
|
*/
|
|
4931
4946
|
static ensureMutationObserver() {
|
|
4932
|
-
if (typeof MutationObserver == "undefined" ||
|
|
4947
|
+
if (typeof MutationObserver == "undefined" || y.mutationObserver)
|
|
4933
4948
|
return;
|
|
4934
4949
|
const t = new MutationObserver((e) => {
|
|
4935
|
-
if (!
|
|
4936
|
-
|
|
4950
|
+
if (!y.isProcessingMutation) {
|
|
4951
|
+
y.isProcessingMutation = !0;
|
|
4937
4952
|
try {
|
|
4938
4953
|
const n = (s) => {
|
|
4939
4954
|
s && new R({ mergeAdjacent: !1, removeEmpty: !1, normalizeWhitespace: !1 }).run(s);
|
|
4940
4955
|
};
|
|
4941
4956
|
e.forEach((s) => {
|
|
4942
4957
|
s.addedNodes.forEach((o) => {
|
|
4943
|
-
n(
|
|
4944
|
-
}), s.type === "characterData" && n(
|
|
4958
|
+
n(y.findBlokScopeFromNode(o));
|
|
4959
|
+
}), s.type === "characterData" && n(y.findBlokScopeFromNode(s.target));
|
|
4945
4960
|
});
|
|
4946
4961
|
} finally {
|
|
4947
|
-
|
|
4962
|
+
y.isProcessingMutation = !1;
|
|
4948
4963
|
}
|
|
4949
4964
|
}
|
|
4950
4965
|
});
|
|
@@ -4952,7 +4967,7 @@ const Co = (i, t) => {
|
|
|
4952
4967
|
subtree: !0,
|
|
4953
4968
|
childList: !0,
|
|
4954
4969
|
characterData: !0
|
|
4955
|
-
}),
|
|
4970
|
+
}), y.mutationObserver = t;
|
|
4956
4971
|
}
|
|
4957
4972
|
/**
|
|
4958
4973
|
* Find the blok scope element from a node for normalization
|
|
@@ -4969,7 +4984,7 @@ const Co = (i, t) => {
|
|
|
4969
4984
|
*/
|
|
4970
4985
|
static getBoundaryBold(t) {
|
|
4971
4986
|
const e = t.startContainer;
|
|
4972
|
-
return e.nodeType === Node.TEXT_NODE ?
|
|
4987
|
+
return e.nodeType === Node.TEXT_NODE ? y.getBoundaryBoldForText(t, e) : e.nodeType === Node.ELEMENT_NODE ? y.getBoundaryBoldForElement(t, e) : null;
|
|
4973
4988
|
}
|
|
4974
4989
|
/**
|
|
4975
4990
|
* Get boundary bold when caret resides inside a text node
|
|
@@ -4979,11 +4994,11 @@ const Co = (i, t) => {
|
|
|
4979
4994
|
static getBoundaryBoldForText(t, e) {
|
|
4980
4995
|
const n = e.textContent.length;
|
|
4981
4996
|
if (t.startOffset === n)
|
|
4982
|
-
return
|
|
4997
|
+
return D(e);
|
|
4983
4998
|
if (t.startOffset !== 0)
|
|
4984
4999
|
return null;
|
|
4985
5000
|
const s = e.previousSibling;
|
|
4986
|
-
return
|
|
5001
|
+
return ut(s) ? s : null;
|
|
4987
5002
|
}
|
|
4988
5003
|
/**
|
|
4989
5004
|
* Get boundary bold when caret container is an element
|
|
@@ -4994,7 +5009,7 @@ const Co = (i, t) => {
|
|
|
4994
5009
|
if (t.startOffset <= 0)
|
|
4995
5010
|
return null;
|
|
4996
5011
|
const n = e.childNodes[t.startOffset - 1];
|
|
4997
|
-
return
|
|
5012
|
+
return ut(n) ? n : null;
|
|
4998
5013
|
}
|
|
4999
5014
|
/**
|
|
5000
5015
|
* Check if a selection is inside the blok
|
|
@@ -5030,15 +5045,15 @@ const Co = (i, t) => {
|
|
|
5030
5045
|
* @param range - The range to search for bold ancestors
|
|
5031
5046
|
*/
|
|
5032
5047
|
collectBoldAncestors(t) {
|
|
5033
|
-
return Ae(t,
|
|
5048
|
+
return Ae(t, q);
|
|
5034
5049
|
}
|
|
5035
5050
|
};
|
|
5036
|
-
|
|
5037
|
-
let Yt =
|
|
5051
|
+
y.isInline = !0, y.title = "Bold", y.titleKey = "bold", y.markerSequence = 0, y.isProcessingMutation = !1, y.instances = /* @__PURE__ */ new Set(), y.guardKeydownListenerRegistered = !1, y.shortcut = "CMD+B";
|
|
5052
|
+
let Yt = y;
|
|
5038
5053
|
const at = (i) => {
|
|
5039
5054
|
const t = i.tagName;
|
|
5040
5055
|
return t === "I" || t === "EM";
|
|
5041
|
-
},
|
|
5056
|
+
}, K = class K {
|
|
5042
5057
|
/**
|
|
5043
5058
|
* Sanitizer Rule
|
|
5044
5059
|
* Leave <i> and <em> tags
|
|
@@ -5161,7 +5176,7 @@ const at = (i) => {
|
|
|
5161
5176
|
* @param node - The node to start searching from
|
|
5162
5177
|
*/
|
|
5163
5178
|
findItalicElement(t) {
|
|
5164
|
-
return
|
|
5179
|
+
return Z(t, at);
|
|
5165
5180
|
}
|
|
5166
5181
|
/**
|
|
5167
5182
|
* Collect all italic ancestor elements within a range
|
|
@@ -5255,9 +5270,9 @@ const at = (i) => {
|
|
|
5255
5270
|
n.insertBefore(l, e.nextSibling), n.insertBefore(t, l);
|
|
5256
5271
|
}
|
|
5257
5272
|
};
|
|
5258
|
-
|
|
5259
|
-
let Zt =
|
|
5260
|
-
const
|
|
5273
|
+
K.isInline = !0, K.title = "Italic", K.titleKey = "italic", K.shortcut = "CMD+I";
|
|
5274
|
+
let Zt = K;
|
|
5275
|
+
const j = class j {
|
|
5261
5276
|
/**
|
|
5262
5277
|
* @param api - Blok API
|
|
5263
5278
|
*/
|
|
@@ -5300,7 +5315,7 @@ const K = class K {
|
|
|
5300
5315
|
width: "200px",
|
|
5301
5316
|
items: [
|
|
5302
5317
|
{
|
|
5303
|
-
type:
|
|
5318
|
+
type: F.Html,
|
|
5304
5319
|
// Input is created in constructor, so it's always available here
|
|
5305
5320
|
element: this.nodes.input
|
|
5306
5321
|
}
|
|
@@ -5485,8 +5500,8 @@ const K = class K {
|
|
|
5485
5500
|
t && t.setAttribute(e, n ? "true" : "false");
|
|
5486
5501
|
}
|
|
5487
5502
|
};
|
|
5488
|
-
|
|
5489
|
-
let Jt =
|
|
5503
|
+
j.isInline = !0, j.title = "Link", j.titleKey = "link", j.shortcut = "CMD+K";
|
|
5504
|
+
let Jt = j;
|
|
5490
5505
|
const wo = {
|
|
5491
5506
|
paragraph: { preserveBlank: !0 },
|
|
5492
5507
|
header: {},
|