@jackuait/blok 0.7.3-beta.3 → 0.7.3
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-CdxHhr5i.mjs → blok-BmlbETK7.mjs} +2119 -2013
- package/dist/chunks/{constants-C_H9o9Ao.mjs → constants-WhLyFkza.mjs} +260 -223
- package/dist/chunks/{i18next-loader-D5HxE5ZQ.mjs → i18next-loader-CZARkla1.mjs} +1 -1
- package/dist/chunks/{lightweight-i18n-Safdy0ua.mjs → lightweight-i18n-BQa0F2X6.mjs} +9 -0
- package/dist/chunks/{tools-B0YXCZFW.mjs → tools-BCb5bMO3.mjs} +973 -843
- package/dist/full.mjs +3 -3
- package/dist/locales.mjs +9 -0
- package/dist/react.mjs +2 -2
- package/dist/tools.mjs +2 -2
- package/package.json +1 -1
- package/src/components/block/style-manager.ts +1 -1
- package/src/components/blocks.ts +26 -54
- package/src/components/constants/data-attributes.ts +0 -2
- package/src/components/i18n/locales/en/messages.json +9 -0
- package/src/components/icons/index.ts +34 -6
- package/src/components/inline-tools/inline-tool-link.ts +202 -5
- package/src/components/inline-tools/inline-tool-marker.ts +166 -23
- package/src/components/inline-tools/utils/formatting-range-utils.ts +10 -1
- package/src/components/modules/blockManager/blockManager.ts +2 -2
- package/src/components/modules/blockManager/operations.ts +2 -2
- package/src/components/modules/blockManager/repository.ts +1 -9
- package/src/components/modules/blockManager/types.ts +1 -1
- package/src/components/modules/drag/operations/DragOperations.ts +45 -6
- package/src/components/modules/paste/google-docs-preprocessor.ts +69 -2
- package/src/components/modules/paste/handlers/blok-data-handler.ts +96 -19
- package/src/components/modules/renderer.ts +2 -0
- package/src/components/modules/toolbar/blockSettings.ts +1 -1
- package/src/components/modules/toolbar/index.ts +21 -0
- package/src/components/modules/toolbar/plus-button.ts +15 -5
- package/src/components/selection/fake-background/index.ts +9 -10
- package/src/components/shared/color-picker.ts +108 -95
- package/src/components/shared/color-presets.ts +30 -2
- package/src/components/ui/toolbox.ts +36 -7
- package/src/components/utils/color-mapping.ts +43 -1
- package/src/components/utils/color-migration.ts +37 -0
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.const.ts +4 -3
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +5 -39
- package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.const.ts +2 -2
- package/src/components/utils/popover/components/popover-item/popover-item.ts +11 -0
- package/src/components/utils/popover/components/search-input/search-input.const.ts +2 -3
- package/src/components/utils/popover/components/search-input/search-input.ts +1 -32
- package/src/components/utils/popover/popover-abstract.ts +2 -4
- package/src/components/utils/popover/popover-desktop.ts +1 -16
- package/src/components/utils/popover/popover-inline.ts +1 -2
- package/src/components/utils/popover/popover-mobile.ts +2 -2
- package/src/components/utils/popover/popover.const.ts +1 -1
- package/src/stories/Table.stories.ts +15 -9
- package/src/styles/main.css +312 -14
- package/src/tools/header/index.ts +5 -5
- package/src/tools/list/constants.ts +11 -4
- package/src/tools/list/depth-validator.ts +13 -1
- package/src/tools/list/dom-builder.ts +5 -3
- package/src/tools/list/index.ts +3 -2
- package/src/tools/paragraph/index.ts +2 -2
- package/src/tools/table/table-cell-color-picker.ts +1 -1
- package/src/tools/table/table-cell-selection.ts +1 -2
- package/src/tools/table/table-core.ts +2 -2
- package/src/tools/table/table-grip-visuals.ts +13 -5
- package/src/tools/table/table-heading-toggle.ts +15 -9
- package/src/tools/table/table-row-col-controls.ts +17 -11
- package/src/tools/table/table-row-col-drag.ts +26 -3
- package/src/tools/toggle/constants.ts +5 -5
- package/src/tools/toggle/index.ts +1 -1
- package/types/tools/hook-events.d.ts +6 -0
- package/types/tools/toggle.d.ts +23 -0
- package/types/tools-entry.d.ts +3 -0
- package/types/utils/popover/popover-item.d.ts +6 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as e, A as t,
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as
|
|
1
|
+
import { $ as e, A as t, An as n, B as r, D as i, F as a, Ft as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, Ot as h, P as g, Pt as _, R as ee, Rt as te, U as ne, V as re, W as ie, X as ae, Y as oe, Z as se, _t as ce, a as le, at as ue, bt as de, c as fe, d as pe, dt as me, en as he, f as ge, ft as _e, g as ve, gt as ye, h as be, ht as xe, i as Se, it as Ce, j as we, jn as v, jt as Te, k as Ee, kt as De, l as Oe, lt as ke, mt as Ae, n as je, nt as Me, o as Ne, ot as Pe, p as Fe, pt as Ie, q as Le, r as Re, rt as ze, s as Be, st as Ve, t as He, tt as Ue, u as y, ut as We, v as Ge, vt as Ke, wn as qe, wt as Je, xt as Ye, yt as Xe, z as Ze, zt as Qe } from "./constants-WhLyFkza.mjs";
|
|
2
|
+
import { t as b } from "./objectSpread2-CyPxu8-u.mjs";
|
|
3
|
+
import { n as x } from "./tw-DmW6-pCY.mjs";
|
|
4
4
|
//#region src/components/utils/html.ts
|
|
5
|
-
var
|
|
5
|
+
var $e = (e) => {
|
|
6
6
|
if (!e || !e.includes("data-blok-fake-background")) return e;
|
|
7
7
|
let t = document.createElement("div");
|
|
8
8
|
return t.innerHTML = e, t.querySelectorAll("[data-blok-fake-background=\"true\"]").forEach((e) => {
|
|
@@ -12,7 +12,7 @@ var Ge = (e) => {
|
|
|
12
12
|
t.removeChild(e);
|
|
13
13
|
}
|
|
14
14
|
}), t.innerHTML;
|
|
15
|
-
},
|
|
15
|
+
}, S = [
|
|
16
16
|
"empty:before:pointer-events-none",
|
|
17
17
|
"empty:before:text-gray-text",
|
|
18
18
|
"empty:before:cursor-text",
|
|
@@ -21,7 +21,7 @@ var Ge = (e) => {
|
|
|
21
21
|
"data-[blok-empty=true]:before:text-gray-text",
|
|
22
22
|
"data-[blok-empty=true]:before:cursor-text",
|
|
23
23
|
"data-[blok-empty=true]:before:content-[attr(data-placeholder)]"
|
|
24
|
-
],
|
|
24
|
+
], et = [
|
|
25
25
|
"empty:before:pointer-events-none",
|
|
26
26
|
"empty:before:text-gray-text",
|
|
27
27
|
"empty:before:cursor-text",
|
|
@@ -30,7 +30,7 @@ var Ge = (e) => {
|
|
|
30
30
|
"data-[empty=true]:before:text-gray-text",
|
|
31
31
|
"data-[empty=true]:before:cursor-text",
|
|
32
32
|
"data-[empty=true]:before:content-[attr(data-blok-placeholder-active)]"
|
|
33
|
-
],
|
|
33
|
+
], tt = [
|
|
34
34
|
"empty:focus:before:pointer-events-none",
|
|
35
35
|
"empty:focus:before:text-gray-text",
|
|
36
36
|
"empty:focus:before:cursor-text",
|
|
@@ -39,7 +39,7 @@ var Ge = (e) => {
|
|
|
39
39
|
"[&[data-empty=true]:focus]:before:text-gray-text",
|
|
40
40
|
"[&[data-empty=true]:focus]:before:cursor-text",
|
|
41
41
|
"[&[data-empty=true]:focus]:before:content-[attr(data-blok-placeholder-active)]"
|
|
42
|
-
],
|
|
42
|
+
], nt = [
|
|
43
43
|
"empty:in-data-[blok-empty=true]:before:pointer-events-none",
|
|
44
44
|
"empty:in-data-[blok-empty=true]:before:text-gray-text",
|
|
45
45
|
"empty:in-data-[blok-empty=true]:before:cursor-text",
|
|
@@ -48,31 +48,31 @@ var Ge = (e) => {
|
|
|
48
48
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:text-gray-text",
|
|
49
49
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:cursor-text",
|
|
50
50
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:content-[attr(data-blok-placeholder-active)]"
|
|
51
|
-
],
|
|
51
|
+
], rt = (e) => {
|
|
52
52
|
let t = e.innerHTML.trim();
|
|
53
53
|
return t === "" || t === "<br>";
|
|
54
|
-
},
|
|
54
|
+
}, it = (e) => {
|
|
55
55
|
e.innerHTML === "<br>" && (e.innerHTML = "");
|
|
56
56
|
let t = window.getSelection();
|
|
57
57
|
if (!t) return;
|
|
58
58
|
let n = document.createRange();
|
|
59
59
|
n.selectNodeContents(e), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
e.setAttribute(n, t == null ? "" : t), e.addEventListener("focus", () =>
|
|
64
|
-
},
|
|
60
|
+
}, at = (e) => {
|
|
61
|
+
rt(e) && it(e);
|
|
62
|
+
}, ot = (e, t, n = "data-placeholder") => {
|
|
63
|
+
e.setAttribute(n, t == null ? "" : t), e.addEventListener("focus", () => at(e));
|
|
64
|
+
}, st, ct = (e) => {
|
|
65
65
|
let t = document.createElement("div");
|
|
66
66
|
t.innerHTML = e.trim();
|
|
67
67
|
let n = document.createDocumentFragment();
|
|
68
68
|
return n.append(...Array.from(t.childNodes)), n;
|
|
69
|
-
},
|
|
69
|
+
}, lt = class e {
|
|
70
70
|
static get DEFAULT_PLACEHOLDER() {
|
|
71
71
|
return "tools.paragraph.placeholder";
|
|
72
72
|
}
|
|
73
|
-
constructor({ data:
|
|
73
|
+
constructor({ data: t, config: n, api: r, readOnly: i }) {
|
|
74
74
|
var a, o, s;
|
|
75
|
-
this.api = r, this.readOnly = i, this.readOnly || (this.onKeyUp = this.onKeyUp.bind(this)), this._placeholder = (a = n == null ? void 0 : n.placeholder) == null ?
|
|
75
|
+
this.api = r, this.readOnly = i, this.readOnly || (this.onKeyUp = this.onKeyUp.bind(this)), this._placeholder = (a = n == null ? void 0 : n.placeholder) == null ? e.DEFAULT_PLACEHOLDER : a, this._data = t == null ? { text: "" } : t, this._element = null, this._preserveBlank = (o = n == null ? void 0 : n.preserveBlank) == null ? !1 : o, this._styles = (s = n == null ? void 0 : n.styles) == null ? {} : s;
|
|
76
76
|
}
|
|
77
77
|
onKeyUp(e) {
|
|
78
78
|
if (e.code !== "Backspace" && e.code !== "Delete" || !this._element) return;
|
|
@@ -84,10 +84,10 @@ var Ge = (e) => {
|
|
|
84
84
|
return this._styles.size && (e.fontSize = this._styles.size), this._styles.lineHeight && (e.lineHeight = this._styles.lineHeight), this._styles.marginTop && (e.marginTop = this._styles.marginTop), this._styles.marginBottom && (e.marginBottom = this._styles.marginBottom), e;
|
|
85
85
|
}
|
|
86
86
|
drawView() {
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
let
|
|
90
|
-
return Object.keys(
|
|
87
|
+
let t = document.createElement("DIV");
|
|
88
|
+
t.className = x(this.api.styles.block, e.WRAPPER_CLASSES, tt, nt), t.setAttribute(n.tool, "paragraph"), t.contentEditable = "false";
|
|
89
|
+
let r = this.buildInlineStyles();
|
|
90
|
+
return Object.keys(r).length > 0 && Object.assign(t.style, r), this._data.text ? t.innerHTML = this._data.text : this.readOnly && (t.innerHTML = "<br>"), this.readOnly || (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp), ot(t, this.api.i18n.t(this._placeholder), "data-blok-placeholder-active")), t;
|
|
91
91
|
}
|
|
92
92
|
render() {
|
|
93
93
|
return this._element = this.drawView(), this._element;
|
|
@@ -95,14 +95,14 @@ var Ge = (e) => {
|
|
|
95
95
|
merge(e) {
|
|
96
96
|
if (!this._element) return;
|
|
97
97
|
this._data.text += e.text;
|
|
98
|
-
let t =
|
|
98
|
+
let t = ct(e.text);
|
|
99
99
|
this._element.appendChild(t), this._element.normalize();
|
|
100
100
|
}
|
|
101
101
|
validate(e) {
|
|
102
102
|
return !(e.text.trim() === "" && !this._preserveBlank);
|
|
103
103
|
}
|
|
104
104
|
save(e) {
|
|
105
|
-
return { text:
|
|
105
|
+
return { text: $e(e.innerHTML) };
|
|
106
106
|
}
|
|
107
107
|
onPaste(e) {
|
|
108
108
|
let t = e.detail;
|
|
@@ -134,7 +134,7 @@ var Ge = (e) => {
|
|
|
134
134
|
}
|
|
135
135
|
static get toolbox() {
|
|
136
136
|
return {
|
|
137
|
-
icon:
|
|
137
|
+
icon: Me,
|
|
138
138
|
title: "Text",
|
|
139
139
|
titleKey: "text",
|
|
140
140
|
searchTerms: [
|
|
@@ -145,64 +145,64 @@ var Ge = (e) => {
|
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
|
|
149
|
-
"leading-[1.
|
|
148
|
+
st = lt, st.WRAPPER_CLASSES = [
|
|
149
|
+
"leading-[1.5]",
|
|
150
150
|
"outline-hidden",
|
|
151
|
-
"mt-
|
|
151
|
+
"mt-px",
|
|
152
152
|
"mb-px",
|
|
153
153
|
"[&>p:first-of-type]:mt-0",
|
|
154
154
|
"[&>p:last-of-type]:mb-0"
|
|
155
155
|
];
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/tools/toggle/dom-builder.ts
|
|
158
|
-
var
|
|
159
|
-
let { data: t, readOnly:
|
|
160
|
-
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
let
|
|
166
|
-
return
|
|
167
|
-
wrapper:
|
|
168
|
-
arrowElement:
|
|
169
|
-
contentElement:
|
|
170
|
-
bodyPlaceholderElement:
|
|
171
|
-
childContainerElement:
|
|
158
|
+
var ut = (e) => {
|
|
159
|
+
let { data: t, readOnly: r, isOpen: i, keydownHandler: a, onArrowClick: o, onBodyPlaceholderClick: s } = e, c = document.createElement("div");
|
|
160
|
+
c.className = le, c.setAttribute(n.tool, Fe), c.setAttribute(y.toggleOpen, String(i));
|
|
161
|
+
let l = document.createElement("div");
|
|
162
|
+
l.className = ge;
|
|
163
|
+
let u = dt(i, o, {}, e.ariaLabels), d = pt(t, r, a);
|
|
164
|
+
l.appendChild(u), l.appendChild(d);
|
|
165
|
+
let f = ft(s, e.bodyPlaceholderText), p = document.createElement("div");
|
|
166
|
+
return p.className = pe, p.setAttribute(y.toggleChildren, ""), p.setAttribute("data-blok-mutation-free", "true"), p.id = `toggle-children-${Date.now()}-${Math.random().toString(36).slice(2)}`, u.setAttribute("aria-controls", p.id), c.appendChild(l), c.appendChild(f), c.appendChild(p), {
|
|
167
|
+
wrapper: c,
|
|
168
|
+
arrowElement: u,
|
|
169
|
+
contentElement: d,
|
|
170
|
+
bodyPlaceholderElement: f,
|
|
171
|
+
childContainerElement: p
|
|
172
172
|
};
|
|
173
|
-
},
|
|
173
|
+
}, dt = (e, t, r = {}, i = {
|
|
174
174
|
collapse: "Collapse",
|
|
175
175
|
expand: "Expand"
|
|
176
176
|
}) => {
|
|
177
|
-
let
|
|
178
|
-
|
|
179
|
-
let
|
|
180
|
-
return
|
|
177
|
+
let a = document.createElement("span");
|
|
178
|
+
a.className = Se, a.setAttribute(y.toggleArrow, ""), a.setAttribute(n.mutationFree, "true"), a.setAttribute("role", "button"), a.setAttribute("tabindex", "0"), a.setAttribute("aria-label", e ? i.collapse : i.expand), a.setAttribute("aria-expanded", String(e)), r.contentEditableFalse === !0 && (a.contentEditable = "false"), a.innerHTML = Re;
|
|
179
|
+
let o = a.querySelector("svg");
|
|
180
|
+
return o && (o.style.transition = "transform 200ms ease-in-out", e && (o.style.transform = "rotate(90deg)")), t && (a.addEventListener("click", (e) => {
|
|
181
181
|
e.stopPropagation(), t();
|
|
182
|
-
}),
|
|
182
|
+
}), a.addEventListener("keydown", (e) => {
|
|
183
183
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), t());
|
|
184
|
-
})),
|
|
185
|
-
},
|
|
184
|
+
})), a;
|
|
185
|
+
}, ft = (e, t) => {
|
|
186
186
|
let n = document.createElement("div");
|
|
187
|
-
return n.className =
|
|
188
|
-
},
|
|
187
|
+
return n.className = Be, n.setAttribute(y.toggleBodyPlaceholder, ""), n.setAttribute("data-blok-mutation-free", "true"), n.textContent = t, e && n.addEventListener("click", e), n;
|
|
188
|
+
}, pt = (e, t, n) => {
|
|
189
189
|
let r = document.createElement("div");
|
|
190
|
-
return r.className =
|
|
191
|
-
},
|
|
192
|
-
let t =
|
|
193
|
-
return t.contentElement &&
|
|
194
|
-
},
|
|
190
|
+
return r.className = x(fe, et, nt), r.setAttribute(y.toggleContent, ""), r.contentEditable = t ? "false" : "true", r.innerHTML = e.text, n && r.addEventListener("keydown", n), r;
|
|
191
|
+
}, mt = (e) => {
|
|
192
|
+
let t = ut(e);
|
|
193
|
+
return t.contentElement && ot(t.contentElement, e.placeholder, "data-blok-placeholder-active"), t;
|
|
194
|
+
}, C = (e, t, n, r = {
|
|
195
195
|
collapse: "Collapse",
|
|
196
196
|
expand: "Expand"
|
|
197
197
|
}) => {
|
|
198
198
|
let i = e.querySelector("svg");
|
|
199
|
-
i && (i.style.transform = n ? "rotate(90deg)" : ""), e.setAttribute("aria-label", n ? r.collapse : r.expand), e.setAttribute("aria-expanded", String(n)), t.setAttribute(
|
|
200
|
-
},
|
|
199
|
+
i && (i.style.transform = n ? "rotate(90deg)" : ""), e.setAttribute("aria-label", n ? r.collapse : r.expand), e.setAttribute("aria-expanded", String(n)), t.setAttribute(y.toggleOpen, String(n));
|
|
200
|
+
}, ht = (e, t, n, r, i) => {
|
|
201
201
|
let a = e.blocks.getChildren(t);
|
|
202
202
|
!n && r && i && r.contains(document.activeElement) && i.focus();
|
|
203
203
|
for (let e of a) r && e.holder.parentElement !== r && r.appendChild(e.holder), n ? e.holder.classList.remove("hidden") : e.holder.classList.add("hidden");
|
|
204
204
|
r && (n ? r.removeAttribute("aria-hidden") : r.setAttribute("aria-hidden", "true"));
|
|
205
|
-
},
|
|
205
|
+
}, gt = (e, t, n, r, i) => {
|
|
206
206
|
if (e === null) return;
|
|
207
207
|
if (i) {
|
|
208
208
|
e.classList.add("hidden");
|
|
@@ -210,27 +210,27 @@ var nt = (e) => {
|
|
|
210
210
|
}
|
|
211
211
|
let a = t.blocks.getChildren(n);
|
|
212
212
|
r && a.length === 0 ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
213
|
-
},
|
|
213
|
+
}, _t = async (e) => {
|
|
214
214
|
var t;
|
|
215
215
|
let { api: n, blockId: r, data: i, getContentElement: a, syncContentFromDOM: o, isOpen: s } = e;
|
|
216
216
|
if (o(), r === void 0) return;
|
|
217
217
|
let c = a(), l = window.getSelection();
|
|
218
218
|
if (!c || !l || l.rangeCount === 0) return;
|
|
219
|
-
let { beforeContent: u, afterContent: d } =
|
|
219
|
+
let { beforeContent: u, afterContent: d } = yt(c, l.getRangeAt(0)), f = (t = n.blocks.getBlockIndex(r)) == null ? n.blocks.getCurrentBlockIndex() : t;
|
|
220
220
|
if (s && d === "") {
|
|
221
221
|
let e = n.blocks.insertInsideParent(r, f + 1);
|
|
222
222
|
n.caret.setToBlock(e.id, "start");
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
|
-
n.blocks.splitBlock(r, { text: u },
|
|
226
|
-
},
|
|
225
|
+
n.blocks.splitBlock(r, { text: u }, Fe, { text: d }, f + 1), i.text = u;
|
|
226
|
+
}, vt = async (e, t) => {
|
|
227
227
|
let { api: n, blockId: r, data: i, getContentElement: a, syncContentFromDOM: o } = e;
|
|
228
228
|
if (o(), r === void 0) return;
|
|
229
229
|
let s = a();
|
|
230
|
-
if (!s || !
|
|
230
|
+
if (!s || !Je(s)) return;
|
|
231
231
|
let c = i.text;
|
|
232
232
|
c === "" && (t.preventDefault(), await n.blocks.convert(r, "paragraph", { text: c }));
|
|
233
|
-
},
|
|
233
|
+
}, yt = (e, t) => {
|
|
234
234
|
if (!e.lastChild) return {
|
|
235
235
|
beforeContent: "",
|
|
236
236
|
afterContent: ""
|
|
@@ -246,13 +246,13 @@ var nt = (e) => {
|
|
|
246
246
|
beforeContent: i.innerHTML,
|
|
247
247
|
afterContent: a.innerHTML
|
|
248
248
|
};
|
|
249
|
-
},
|
|
249
|
+
}, bt = async (e) => {
|
|
250
250
|
var t;
|
|
251
251
|
let { api: n, blockId: r, getContentElement: i, syncContentFromDOM: a, isOpen: o, currentLevel: s } = e;
|
|
252
252
|
if (a(), r === void 0) return;
|
|
253
253
|
let c = i(), l = window.getSelection();
|
|
254
254
|
if (!c || !l || l.rangeCount === 0) return;
|
|
255
|
-
let { beforeContent: u, afterContent: d } =
|
|
255
|
+
let { beforeContent: u, afterContent: d } = yt(c, l.getRangeAt(0)), f = (t = n.blocks.getBlockIndex(r)) == null ? n.blocks.getCurrentBlockIndex() : t;
|
|
256
256
|
if (o && d === "") {
|
|
257
257
|
let e = n.blocks.insertInsideParent(r, f + 1);
|
|
258
258
|
n.caret.setToBlock(e.id, "start");
|
|
@@ -267,17 +267,17 @@ var nt = (e) => {
|
|
|
267
267
|
level: s,
|
|
268
268
|
isToggleable: !0
|
|
269
269
|
}, f + 1);
|
|
270
|
-
},
|
|
270
|
+
}, xt = async (e, t) => {
|
|
271
271
|
let { api: n, blockId: r, getText: i, getContentElement: a, syncContentFromDOM: o, currentLevel: s } = e;
|
|
272
272
|
if (o(), r === void 0) return;
|
|
273
273
|
let c = a();
|
|
274
|
-
if (!c || !
|
|
274
|
+
if (!c || !Je(c)) return;
|
|
275
275
|
let l = i();
|
|
276
276
|
l === "" && (t.preventDefault(), await n.blocks.convert(r, "header", {
|
|
277
277
|
text: l,
|
|
278
278
|
level: s
|
|
279
279
|
}));
|
|
280
|
-
},
|
|
280
|
+
}, St, Ct = class e {
|
|
281
281
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
282
282
|
var a;
|
|
283
283
|
this._arrowElement = null, this._wrapper = null, this._headerRow = null, this._childContainerElement = null, this._bodyPlaceholderElement = null, this.handleKeyDown = (e) => {
|
|
@@ -285,7 +285,7 @@ var nt = (e) => {
|
|
|
285
285
|
e.preventDefault(), this.handleEnter();
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
e.key === "Backspace" &&
|
|
288
|
+
e.key === "Backspace" && xt(this.createKeyboardContext(), e);
|
|
289
289
|
}, this.handleBlockChanged = (e) => {
|
|
290
290
|
this.isBlockChangedPayload(e) && (e.event.type === "block-removed" || e.event.type === "block-added") && this.updateBodyPlaceholderVisibility();
|
|
291
291
|
}, this.api = n, this.readOnly = r, this._settings = t || {}, this._data = this.normalizeData(e), this._isOpen = (a = this._data.isOpen) == null ? !r : a, this._element = this.getTag(), i && (this.blockId = i.id), !r && this._data.isToggleable && this.api.events.on("block changed", this.handleBlockChanged);
|
|
@@ -311,7 +311,7 @@ var nt = (e) => {
|
|
|
311
311
|
if (e.isToggleable === !0 && (r.isToggleable = !0), typeof e.isOpen == "boolean" && (r.isOpen = e.isOpen), r.text) {
|
|
312
312
|
let e = document.createElement("div");
|
|
313
313
|
e.innerHTML = r.text;
|
|
314
|
-
let t = e.querySelector(`[${
|
|
314
|
+
let t = e.querySelector(`[${y.toggleArrow}]`);
|
|
315
315
|
t && (t.remove(), r.text = e.innerHTML);
|
|
316
316
|
}
|
|
317
317
|
return r;
|
|
@@ -326,13 +326,13 @@ var nt = (e) => {
|
|
|
326
326
|
this.api.events.off("block changed", this.handleBlockChanged), this._element.removeEventListener("keydown", this.handleKeyDown);
|
|
327
327
|
}
|
|
328
328
|
expand() {
|
|
329
|
-
!this._data.isToggleable || this._isOpen || (this._isOpen = !0, this._arrowElement && this._element &&
|
|
329
|
+
!this._data.isToggleable || this._isOpen || (this._isOpen = !0, this._arrowElement && this._element && C(this._arrowElement, this._element, this._isOpen, {
|
|
330
330
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
331
331
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
332
332
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility());
|
|
333
333
|
}
|
|
334
334
|
collapse() {
|
|
335
|
-
!this._data.isToggleable || !this._isOpen || (this._isOpen = !1, this._arrowElement && this._element &&
|
|
335
|
+
!this._data.isToggleable || !this._isOpen || (this._isOpen = !1, this._arrowElement && this._element && C(this._arrowElement, this._element, this._isOpen, {
|
|
336
336
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
337
337
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
338
338
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility());
|
|
@@ -360,14 +360,14 @@ var nt = (e) => {
|
|
|
360
360
|
merge(e) {
|
|
361
361
|
let t = document.createElement("div");
|
|
362
362
|
t.innerHTML = e.text;
|
|
363
|
-
let n = t.querySelector(`[${
|
|
363
|
+
let n = t.querySelector(`[${y.toggleArrow}]`);
|
|
364
364
|
n && n.remove(), this._element.insertAdjacentHTML("beforeend", t.innerHTML);
|
|
365
365
|
}
|
|
366
366
|
validate(e) {
|
|
367
367
|
return typeof e.text == "string";
|
|
368
368
|
}
|
|
369
369
|
setData(e) {
|
|
370
|
-
return this._data = this.normalizeData(e), typeof e.text == "string" && (this._element.innerHTML = e.text), this._data.isToggleable && typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen, this._arrowElement && this._element &&
|
|
370
|
+
return this._data = this.normalizeData(e), typeof e.text == "string" && (this._element.innerHTML = e.text), this._data.isToggleable && typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen, this._arrowElement && this._element && C(this._arrowElement, this._element, this._isOpen, {
|
|
371
371
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
372
372
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
373
373
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility()), !0;
|
|
@@ -406,13 +406,13 @@ var nt = (e) => {
|
|
|
406
406
|
e.innerHTML = this._element.innerHTML, this._element.parentNode.replaceChild(e, this._element), this._element = e;
|
|
407
407
|
}
|
|
408
408
|
if (t.text !== void 0 && (this._element.innerHTML = this._data.text || ""), this._data.isToggleable) {
|
|
409
|
-
if (this._element.setAttribute(
|
|
410
|
-
else if (!this._wrapper.querySelector(`[${
|
|
409
|
+
if (this._element.setAttribute(y.toggleOpen, String(this._isOpen)), this._element.className = x(e.BASE_STYLES, this.currentLevel.styles, S, "pl-8"), !this._wrapper) this.createToggleWrapper();
|
|
410
|
+
else if (!this._wrapper.querySelector(`[${y.toggleArrow}]`)) {
|
|
411
411
|
var n;
|
|
412
412
|
let e = this.buildArrow();
|
|
413
413
|
this._arrowElement = e, ((n = this._headerRow) == null ? this._wrapper : n).prepend(e);
|
|
414
414
|
}
|
|
415
|
-
} else if (this._element.removeAttribute(
|
|
415
|
+
} else if (this._element.removeAttribute(y.toggleOpen), this._element.className = x(e.BASE_STYLES, this.currentLevel.styles, S), this._arrowElement = null, this._wrapper) {
|
|
416
416
|
let e = this._wrapper.parentNode;
|
|
417
417
|
e && e.replaceChild(this._element, this._wrapper), this._wrapper = null, this._headerRow = null;
|
|
418
418
|
}
|
|
@@ -422,14 +422,14 @@ var nt = (e) => {
|
|
|
422
422
|
}
|
|
423
423
|
getTag() {
|
|
424
424
|
let t = document.createElement(this.currentLevel.tag);
|
|
425
|
-
t.innerHTML = this._data.text || "", t.className =
|
|
426
|
-
let { inlineStyles:
|
|
427
|
-
|
|
428
|
-
let
|
|
429
|
-
return this.readOnly ? t.setAttribute("data-placeholder",
|
|
425
|
+
t.innerHTML = this._data.text || "", t.className = x(e.BASE_STYLES, this.currentLevel.styles, S, this._data.isToggleable ? "pl-8" : "");
|
|
426
|
+
let { inlineStyles: r } = this.currentLevel;
|
|
427
|
+
r && Object.assign(t.style, r), t.setAttribute(n.tool, "header"), t.contentEditable = this.readOnly ? "false" : "true", this._data.isToggleable && t.setAttribute(y.toggleOpen, String(this._isOpen));
|
|
428
|
+
let i = this.api.i18n.t(this.currentLevel.nameKey), a = this.resolvePlaceholderText(i);
|
|
429
|
+
return this.readOnly ? t.setAttribute("data-placeholder", a) : ot(t, a), !this.readOnly && this._data.isToggleable && t.addEventListener("keydown", this.handleKeyDown), t;
|
|
430
430
|
}
|
|
431
431
|
buildArrow() {
|
|
432
|
-
let e =
|
|
432
|
+
let e = dt(this._isOpen, () => this.toggleOpen(), {}, {
|
|
433
433
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
434
434
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
435
435
|
});
|
|
@@ -441,9 +441,9 @@ var nt = (e) => {
|
|
|
441
441
|
let n = this.buildArrow();
|
|
442
442
|
this._arrowElement = n, t.appendChild(n), t.appendChild(this._element), e.appendChild(t);
|
|
443
443
|
let r = document.createElement("div");
|
|
444
|
-
r.className =
|
|
444
|
+
r.className = Be, r.setAttribute(y.toggleBodyPlaceholder, ""), r.setAttribute("data-blok-mutation-free", "true"), r.textContent = this.api.i18n.t("tools.toggle.bodyPlaceholder"), this.readOnly || r.addEventListener("click", () => this.handleBodyPlaceholderClick()), this._bodyPlaceholderElement = r, e.appendChild(r);
|
|
445
445
|
let i = document.createElement("div");
|
|
446
|
-
return i.className =
|
|
446
|
+
return i.className = pe, i.setAttribute(y.toggleChildren, ""), i.setAttribute("data-blok-mutation-free", "true"), this._childContainerElement = i, e.appendChild(i), e;
|
|
447
447
|
}
|
|
448
448
|
createToggleWrapper() {
|
|
449
449
|
let e = this._element.parentNode;
|
|
@@ -468,19 +468,19 @@ var nt = (e) => {
|
|
|
468
468
|
}
|
|
469
469
|
async handleEnter() {
|
|
470
470
|
var e = this;
|
|
471
|
-
await
|
|
471
|
+
await bt(e.createKeyboardContext()), e.updateChildrenVisibility(), e.updateBodyPlaceholderVisibility();
|
|
472
472
|
}
|
|
473
473
|
toggleOpen() {
|
|
474
|
-
this._isOpen = !this._isOpen, this._arrowElement && this._element &&
|
|
474
|
+
this._isOpen = !this._isOpen, this._arrowElement && this._element && C(this._arrowElement, this._element, this._isOpen, {
|
|
475
475
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
476
476
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
477
477
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility();
|
|
478
478
|
}
|
|
479
479
|
updateChildrenVisibility() {
|
|
480
|
-
this.blockId !== void 0 &&
|
|
480
|
+
this.blockId !== void 0 && ht(this.api, this.blockId, this._isOpen, this._childContainerElement, this._arrowElement);
|
|
481
481
|
}
|
|
482
482
|
updateBodyPlaceholderVisibility() {
|
|
483
|
-
this.blockId !== void 0 &&
|
|
483
|
+
this.blockId !== void 0 && gt(this._bodyPlaceholderElement, this.api, this.blockId, this._isOpen, this.readOnly);
|
|
484
484
|
}
|
|
485
485
|
handleBodyPlaceholderClick() {
|
|
486
486
|
var e;
|
|
@@ -558,9 +558,9 @@ var nt = (e) => {
|
|
|
558
558
|
],
|
|
559
559
|
shortcut: "#".repeat(e.number)
|
|
560
560
|
})), n = {
|
|
561
|
-
1:
|
|
562
|
-
2:
|
|
563
|
-
3:
|
|
561
|
+
1: ze,
|
|
562
|
+
2: Ce,
|
|
563
|
+
3: ue
|
|
564
564
|
}, r = e.DEFAULT_LEVELS.filter((e) => e.number <= 3).map((e) => ({
|
|
565
565
|
icon: n[e.number],
|
|
566
566
|
title: `Toggle heading ${e.number}`,
|
|
@@ -581,45 +581,45 @@ var nt = (e) => {
|
|
|
581
581
|
return [...t, ...r];
|
|
582
582
|
}
|
|
583
583
|
};
|
|
584
|
-
|
|
584
|
+
St = Ct, St.BASE_STYLES = "py-[3px] px-[2px] m-0 leading-[1.3]! outline-hidden [&_p]:p-0! [&_p]:m-0! [&_div]:p-0! [&_div]:m-0!", St.DEFAULT_LEVELS = [
|
|
585
585
|
{
|
|
586
586
|
number: 1,
|
|
587
587
|
tag: "H1",
|
|
588
588
|
nameKey: "tools.header.heading1",
|
|
589
589
|
name: "Heading 1",
|
|
590
|
-
icon:
|
|
591
|
-
styles: "text-
|
|
590
|
+
icon: p,
|
|
591
|
+
styles: "text-3xl font-semibold mt-8 mb-px"
|
|
592
592
|
},
|
|
593
593
|
{
|
|
594
594
|
number: 2,
|
|
595
595
|
tag: "H2",
|
|
596
596
|
nameKey: "tools.header.heading2",
|
|
597
597
|
name: "Heading 2",
|
|
598
|
-
icon:
|
|
599
|
-
styles: "text-
|
|
598
|
+
icon: m,
|
|
599
|
+
styles: "text-2xl font-semibold mt-[26px] mb-px"
|
|
600
600
|
},
|
|
601
601
|
{
|
|
602
602
|
number: 3,
|
|
603
603
|
tag: "H3",
|
|
604
604
|
nameKey: "tools.header.heading3",
|
|
605
605
|
name: "Heading 3",
|
|
606
|
-
icon:
|
|
607
|
-
styles: "text-
|
|
606
|
+
icon: g,
|
|
607
|
+
styles: "text-xl font-semibold mt-5 mb-px"
|
|
608
608
|
},
|
|
609
609
|
{
|
|
610
610
|
number: 4,
|
|
611
611
|
tag: "H4",
|
|
612
612
|
nameKey: "tools.header.heading4",
|
|
613
613
|
name: "Heading 4",
|
|
614
|
-
icon:
|
|
615
|
-
styles: "text-
|
|
614
|
+
icon: a,
|
|
615
|
+
styles: "text-lg font-semibold mt-3 mb-px"
|
|
616
616
|
},
|
|
617
617
|
{
|
|
618
618
|
number: 5,
|
|
619
619
|
tag: "H5",
|
|
620
620
|
nameKey: "tools.header.heading5",
|
|
621
621
|
name: "Heading 5",
|
|
622
|
-
icon:
|
|
622
|
+
icon: l,
|
|
623
623
|
styles: "text-base font-semibold mt-3 mb-px"
|
|
624
624
|
},
|
|
625
625
|
{
|
|
@@ -627,16 +627,16 @@ mt = ht, mt.BASE_STYLES = "py-[3px] px-[2px] m-0 leading-[1.3]! outline-hidden [
|
|
|
627
627
|
tag: "H6",
|
|
628
628
|
nameKey: "tools.header.heading6",
|
|
629
629
|
name: "Heading 6",
|
|
630
|
-
icon:
|
|
630
|
+
icon: f,
|
|
631
631
|
styles: "text-sm font-semibold mt-3 mb-px"
|
|
632
632
|
}
|
|
633
633
|
];
|
|
634
634
|
//#endregion
|
|
635
635
|
//#region src/tools/list/constants.ts
|
|
636
|
-
var
|
|
636
|
+
var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 leading-[1.5] items-center", Et = "flex items-start pl-0.5", Dt = "mt-0.5 w-5 mr-2 h-5 cursor-pointer accent-current", Ot = "tools.list.placeholder", kt = "list", At = {
|
|
637
637
|
contentContainer: "list-content-container",
|
|
638
638
|
checklistContent: "list-checklist-content"
|
|
639
|
-
},
|
|
639
|
+
}, jt = (e, t) => {
|
|
640
640
|
let n = e;
|
|
641
641
|
n._placeholder = t, Object.defineProperty(n, "getPlaceholder", {
|
|
642
642
|
value: () => n._placeholder,
|
|
@@ -644,8 +644,8 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
644
644
|
enumerable: !0,
|
|
645
645
|
configurable: !1
|
|
646
646
|
});
|
|
647
|
-
},
|
|
648
|
-
let { data: t, keydownHandler: n, readOnly: r } = e, i =
|
|
647
|
+
}, Mt = (e) => {
|
|
648
|
+
let { data: t, keydownHandler: n, readOnly: r } = e, i = Nt(e), a = t.style === "checklist" ? Ft(e) : Pt(e);
|
|
649
649
|
i.appendChild(a), !r && n && i.addEventListener("keydown", n);
|
|
650
650
|
let o = a.querySelector("[data-list-marker]"), s = a.querySelector("input[type=\"checkbox\"]"), c = a.querySelector("[contenteditable]");
|
|
651
651
|
return {
|
|
@@ -654,46 +654,49 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
654
654
|
markerElement: o,
|
|
655
655
|
checkboxElement: s
|
|
656
656
|
};
|
|
657
|
-
},
|
|
657
|
+
}, Nt = (e) => {
|
|
658
658
|
var t;
|
|
659
|
-
let { data:
|
|
660
|
-
return
|
|
661
|
-
},
|
|
659
|
+
let { data: r } = e, i = document.createElement("div");
|
|
660
|
+
return i.className = wt, i.setAttribute(n.tool, kt), i.setAttribute("data-list-style", r.style), i.setAttribute("data-list-depth", String((t = r.depth) == null ? 0 : t)), r.start !== void 0 && r.start !== 1 && i.setAttribute("data-list-start", String(r.start)), i;
|
|
661
|
+
}, Pt = (e) => {
|
|
662
662
|
var t;
|
|
663
663
|
let { data: n, itemColor: r, itemSize: i, placeholder: a } = e, o = document.createElement("div");
|
|
664
|
-
o.setAttribute("role", "listitem"), o.className =
|
|
664
|
+
o.setAttribute("role", "listitem"), o.className = x(Tt, "flex", ...S), r && (o.style.color = r), i && (o.style.fontSize = i);
|
|
665
665
|
let s = (t = n.depth) == null ? 0 : t;
|
|
666
|
-
s > 0
|
|
667
|
-
|
|
666
|
+
if (s > 0) {
|
|
667
|
+
let e = n.style === "ordered" ? 26 : 27;
|
|
668
|
+
o.style.marginLeft = `${s * e}px`;
|
|
669
|
+
}
|
|
670
|
+
let c = It(n.style, s);
|
|
668
671
|
c.setAttribute("data-list-marker", "true"), c.setAttribute("data-blok-mutation-free", "true"), o.appendChild(c);
|
|
669
672
|
let l = document.createElement("div");
|
|
670
|
-
return l.className =
|
|
671
|
-
},
|
|
673
|
+
return l.className = x("flex-1 min-w-0 outline-hidden", ...S), l.setAttribute("data-blok-testid", At.contentContainer), l.contentEditable = e.readOnly ? "false" : "true", l.innerHTML = n.text, jt(l, a), o.appendChild(l), o;
|
|
674
|
+
}, Ft = (e) => {
|
|
672
675
|
var t;
|
|
673
676
|
let { data: n, itemColor: r, itemSize: i, placeholder: a, readOnly: o } = e, s = document.createElement("div");
|
|
674
|
-
s.setAttribute("role", "listitem"), s.className =
|
|
677
|
+
s.setAttribute("role", "listitem"), s.className = Et, r && (s.style.color = r), i && (s.style.fontSize = i);
|
|
675
678
|
let c = (t = n.depth) == null ? 0 : t;
|
|
676
|
-
c > 0 && (s.style.marginLeft = `${c *
|
|
679
|
+
c > 0 && (s.style.marginLeft = `${c * 27}px`);
|
|
677
680
|
let l = document.createElement("input");
|
|
678
|
-
l.type = "checkbox", l.className =
|
|
681
|
+
l.type = "checkbox", l.className = Dt, l.checked = !!n.checked, l.disabled = o;
|
|
679
682
|
let u = document.createElement("div");
|
|
680
|
-
return u.className =
|
|
681
|
-
},
|
|
683
|
+
return u.className = x("flex-1 outline-hidden leading-[1.5]", n.checked ? "line-through opacity-60" : "", ...S), u.setAttribute("data-blok-testid", At.checklistContent), u.setAttribute("data-checked", String(n.checked)), u.contentEditable = o ? "false" : "true", u.innerHTML = n.text, jt(u, a), s.appendChild(l), s.appendChild(u), s;
|
|
684
|
+
}, It = (e, t) => {
|
|
682
685
|
let n = document.createElement("span");
|
|
683
|
-
return n.className = "shrink-0 select-none", n.setAttribute("aria-hidden", "true"), n.contentEditable = "false", e === "ordered" ? (n.textContent = "1.", n.className =
|
|
684
|
-
},
|
|
686
|
+
return n.className = "shrink-0 select-none", n.setAttribute("aria-hidden", "true"), n.contentEditable = "false", e === "ordered" ? (n.textContent = "1.", n.className = x(n.className, "text-right"), n.style.paddingRight = "11px", n.style.minWidth = "fit-content") : (n.textContent = Lt(t), n.className = x(n.className, "w-6 text-center flex justify-center"), n.style.paddingLeft = "1px", n.style.paddingRight = "13px", n.style.fontSize = "24px", n.style.fontFamily = "Arial"), n;
|
|
687
|
+
}, Lt = (e) => {
|
|
685
688
|
let t = [
|
|
686
689
|
"•",
|
|
687
690
|
"◦",
|
|
688
691
|
"▪"
|
|
689
692
|
];
|
|
690
693
|
return t[e % t.length];
|
|
691
|
-
},
|
|
694
|
+
}, Rt = (e) => {
|
|
692
695
|
let { data: t, readOnly: n, placeholder: r, itemColor: i, itemSize: a, element: o, setupItemPlaceholder: s, onCheckboxChange: c, keydownHandler: l } = e;
|
|
693
696
|
if (!o) return null;
|
|
694
697
|
let u = o.parentNode;
|
|
695
698
|
if (!u) return null;
|
|
696
|
-
let d =
|
|
699
|
+
let d = Mt({
|
|
697
700
|
data: t,
|
|
698
701
|
readOnly: n,
|
|
699
702
|
placeholder: r,
|
|
@@ -708,14 +711,14 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
708
711
|
});
|
|
709
712
|
}
|
|
710
713
|
return u.replaceChild(d.wrapper, o), d.wrapper;
|
|
711
|
-
},
|
|
714
|
+
}, zt = (e, t, n) => {
|
|
712
715
|
if (!t) return e;
|
|
713
|
-
let r = n(), i =
|
|
714
|
-
text: r ?
|
|
716
|
+
let r = n(), i = b({
|
|
717
|
+
text: r ? $e(r.innerHTML) : e.text,
|
|
715
718
|
style: e.style
|
|
716
719
|
}, e.style === "checklist" ? { checked: !!e.checked } : {});
|
|
717
720
|
return e.start !== void 0 && e.start !== 1 && (i.start = e.start), e.depth !== void 0 && e.depth > 0 && (i.depth = e.depth), i;
|
|
718
|
-
},
|
|
721
|
+
}, Bt = (e, t, n, r, i) => {
|
|
719
722
|
var a, o;
|
|
720
723
|
if (!n) return {
|
|
721
724
|
newData: e,
|
|
@@ -726,7 +729,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
726
729
|
newData: e,
|
|
727
730
|
inPlace: !1
|
|
728
731
|
};
|
|
729
|
-
let d = "depth" in t ? t.depth : 0, f =
|
|
732
|
+
let d = "depth" in t ? t.depth : 0, f = b(b(b({}, e), t), {}, { depth: d }), p = r();
|
|
730
733
|
if (p && typeof t.text == "string" && (p.innerHTML = t.text), s !== c) return i.adjustDepthTo(c), i.updateMarkerForDepth(c, u), {
|
|
731
734
|
newData: f,
|
|
732
735
|
inPlace: !0
|
|
@@ -739,7 +742,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
739
742
|
newData: f,
|
|
740
743
|
inPlace: !0
|
|
741
744
|
};
|
|
742
|
-
},
|
|
745
|
+
}, Vt = (e, t) => {
|
|
743
746
|
let { element: n, getContentElement: r, parseHTML: i, data: a } = e;
|
|
744
747
|
if (!n) return;
|
|
745
748
|
a.text += t.text;
|
|
@@ -748,29 +751,29 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
748
751
|
let e = i(t.text);
|
|
749
752
|
o.appendChild(e), o.normalize();
|
|
750
753
|
}
|
|
751
|
-
},
|
|
754
|
+
}, Ht = (e, t, n, r) => e.map((e) => ({
|
|
752
755
|
icon: e.icon,
|
|
753
756
|
title: n(`toolNames.${e.titleKey}`),
|
|
754
757
|
onActivate: () => r(e.style),
|
|
755
758
|
closeOnActivate: !0,
|
|
756
759
|
isActive: t === e.style
|
|
757
|
-
})),
|
|
760
|
+
})), Ut = (e) => {
|
|
758
761
|
if (!e) return;
|
|
759
762
|
let t = (e.getAttribute("style") || "").match(/margin-left:\s*(\d+)px/);
|
|
760
763
|
if (!t) return;
|
|
761
764
|
let n = parseInt(t[1], 10);
|
|
762
765
|
return n > 0 ? { left: n } : void 0;
|
|
763
|
-
},
|
|
766
|
+
}, Wt = (e) => {
|
|
764
767
|
let t = e.closest("[data-list-depth]");
|
|
765
768
|
if (!t) return;
|
|
766
769
|
let n = t.getAttribute("data-list-depth");
|
|
767
770
|
if (n === null) return;
|
|
768
771
|
let r = parseInt(n, 10);
|
|
769
|
-
return r > 0 ? { left: r *
|
|
770
|
-
},
|
|
771
|
-
let t =
|
|
772
|
-
return t === void 0 ?
|
|
773
|
-
},
|
|
772
|
+
return r > 0 ? { left: r * 27 } : void 0;
|
|
773
|
+
}, Gt = (e) => {
|
|
774
|
+
let t = Ut(e.closest("[role=\"listitem\"]") || e.querySelector("[role=\"listitem\"]"));
|
|
775
|
+
return t === void 0 ? Wt(e) : t;
|
|
776
|
+
}, Kt = (e, t) => {
|
|
774
777
|
let n = document.createRange();
|
|
775
778
|
if (n.setStart(e, 0), n.setEnd(t.startContainer, t.startOffset), !e.lastChild) return {
|
|
776
779
|
beforeContent: "",
|
|
@@ -778,32 +781,32 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
778
781
|
};
|
|
779
782
|
let r = document.createRange();
|
|
780
783
|
return r.setStart(t.endContainer, t.endOffset), r.setEndAfter(e.lastChild), {
|
|
781
|
-
beforeContent:
|
|
782
|
-
afterContent:
|
|
784
|
+
beforeContent: qt(n.cloneContents()),
|
|
785
|
+
afterContent: qt(r.cloneContents())
|
|
783
786
|
};
|
|
784
|
-
},
|
|
787
|
+
}, qt = (e) => {
|
|
785
788
|
let t = document.createElement("div");
|
|
786
789
|
return t.appendChild(e), t.innerHTML;
|
|
787
|
-
},
|
|
790
|
+
}, Jt = (e) => {
|
|
788
791
|
let t = document.createElement("div");
|
|
789
792
|
t.innerHTML = e.trim();
|
|
790
793
|
let n = document.createDocumentFragment();
|
|
791
794
|
return n.append(...Array.from(t.childNodes)), n;
|
|
792
|
-
},
|
|
795
|
+
}, Yt = (e, t) => {
|
|
793
796
|
let n = document.createRange();
|
|
794
797
|
return n.selectNodeContents(e), n.setEnd(t.startContainer, t.startOffset), n.toString().length === 0;
|
|
795
|
-
},
|
|
798
|
+
}, Xt = (e, t) => {
|
|
796
799
|
let n = document.createRange();
|
|
797
800
|
n.selectNodeContents(e), n.setEnd(t.startContainer, t.startOffset);
|
|
798
801
|
let r = n.toString().length === 0, i = document.createRange();
|
|
799
802
|
i.selectNodeContents(e), i.setStart(t.endContainer, t.endOffset);
|
|
800
803
|
let a = i.toString().length === 0;
|
|
801
804
|
return r && a;
|
|
802
|
-
},
|
|
805
|
+
}, Zt = (e) => {
|
|
803
806
|
if (typeof e != "object" || !e) return !1;
|
|
804
807
|
let t = Object.entries(e).find(([e]) => e === "items");
|
|
805
808
|
return t === void 0 ? !1 : Array.isArray(t[1]);
|
|
806
|
-
},
|
|
809
|
+
}, Qt = (e) => typeof e == "object" && !!e, $t = (e) => typeof e == "string" ? e : "", en = (e, t) => e === "unordered" || e === "ordered" || e === "checklist" ? e : t, tn = (e) => !!e, nn = (e, t) => typeof e == "number" ? e : t, rn = (e, t) => {
|
|
807
810
|
let n = t.defaultStyle || "unordered";
|
|
808
811
|
if (!e || typeof e != "object") return {
|
|
809
812
|
text: "",
|
|
@@ -811,18 +814,18 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
811
814
|
checked: !1,
|
|
812
815
|
depth: 0
|
|
813
816
|
};
|
|
814
|
-
if (
|
|
817
|
+
if (Zt(e)) {
|
|
815
818
|
let t = e.items[0], r = (t == null ? void 0 : t.content) || "", i = (t == null ? void 0 : t.checked) || !1;
|
|
816
|
-
return
|
|
819
|
+
return b({
|
|
817
820
|
text: r,
|
|
818
821
|
style: e.style || n,
|
|
819
822
|
checked: !!i,
|
|
820
823
|
depth: 0
|
|
821
824
|
}, e.start !== void 0 && e.start !== 1 ? { start: e.start } : {});
|
|
822
825
|
}
|
|
823
|
-
if (
|
|
824
|
-
let t =
|
|
825
|
-
return
|
|
826
|
+
if (Qt(e)) {
|
|
827
|
+
let t = $t(e.text), r = en(e.style, n), i = tn(e.checked), a = nn(e.depth, 0), o = e.start, s = typeof o == "number" && o !== void 0 && o !== 1 ? o : void 0;
|
|
828
|
+
return b({
|
|
826
829
|
text: t,
|
|
827
830
|
style: r,
|
|
828
831
|
checked: i,
|
|
@@ -835,7 +838,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
835
838
|
checked: !1,
|
|
836
839
|
depth: 0
|
|
837
840
|
};
|
|
838
|
-
},
|
|
841
|
+
}, an = class {
|
|
839
842
|
constructor(e) {
|
|
840
843
|
this.blocks = e;
|
|
841
844
|
}
|
|
@@ -845,12 +848,13 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
845
848
|
return !t || t.name !== "list" ? 0 : this.getBlockDepth(t) + 1;
|
|
846
849
|
}
|
|
847
850
|
getTargetDepthForMove(e) {
|
|
848
|
-
let { blockIndex: t, currentDepth: n } = e,
|
|
849
|
-
if (n >
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
851
|
+
let { blockIndex: t, currentDepth: n, skipDepthPromotion: r } = e, i = this.getMaxAllowedDepth(t);
|
|
852
|
+
if (n > i) return i;
|
|
853
|
+
if (r) return n;
|
|
854
|
+
let a = this.blocks.getBlockByIndex(t + 1), o = a && a.name === "list", s = o ? this.getBlockDepth(a) : 0;
|
|
855
|
+
if (o && s > n && s <= i) return s;
|
|
856
|
+
let c = t > 0 ? this.blocks.getBlockByIndex(t - 1) : void 0, l = c && c.name === "list", u = l ? this.getBlockDepth(c) : 0;
|
|
857
|
+
return l && !o && u > n && u <= i ? u : n;
|
|
854
858
|
}
|
|
855
859
|
isValidDepth(e, t) {
|
|
856
860
|
let n = this.getMaxAllowedDepth(e);
|
|
@@ -860,9 +864,9 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
860
864
|
var t;
|
|
861
865
|
if (!e) return 0;
|
|
862
866
|
let n = (t = e.holder) == null || (t = t.querySelector("[role=\"listitem\"]")) == null ? void 0 : t.getAttribute("style"), r = n == null ? void 0 : n.match(/margin-left:\s*(\d+)px/);
|
|
863
|
-
return r ? Math.round(parseInt(r[1], 10) /
|
|
867
|
+
return r ? Math.round(parseInt(r[1], 10) / 27) : 0;
|
|
864
868
|
}
|
|
865
|
-
},
|
|
869
|
+
}, on = (e, t) => {
|
|
866
870
|
if (!e) return null;
|
|
867
871
|
if (t === "checklist") {
|
|
868
872
|
let t = e.querySelector("[contenteditable]");
|
|
@@ -870,15 +874,15 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
870
874
|
}
|
|
871
875
|
let n = e.querySelector("[data-blok-testid=\"list-content-container\"]");
|
|
872
876
|
return n instanceof HTMLElement ? n : null;
|
|
873
|
-
},
|
|
877
|
+
}, sn = (e, t, n) => {
|
|
874
878
|
e && e.setAttribute("data-list-depth", String(n));
|
|
875
879
|
let r = e == null ? void 0 : e.querySelector("[role=\"listitem\"]");
|
|
876
|
-
r instanceof HTMLElement && (r.style.marginLeft = n > 0 ? `${n *
|
|
877
|
-
},
|
|
880
|
+
r instanceof HTMLElement && (r.style.marginLeft = n > 0 ? `${n * 27}px` : ""), t.depth = n;
|
|
881
|
+
}, cn = (e, t) => t.getBlockDepth(e), ln = (e, t) => t.getBlockStyle(e), un = (e, t) => t.getBulletCharacter(e), dn = (e, t, n, r, i) => {
|
|
878
882
|
var a;
|
|
879
883
|
let o = e ? (a = r.getBlockIndex(e)) == null ? r.getCurrentBlockIndex() : a : r.getCurrentBlockIndex();
|
|
880
884
|
return o <= 0 ? 0 : i.getSiblingIndex(o, t, n);
|
|
881
|
-
},
|
|
885
|
+
}, fn = (e, t, n, r, i, a) => {
|
|
882
886
|
var o;
|
|
883
887
|
if (e === 0) {
|
|
884
888
|
var s;
|
|
@@ -886,10 +890,10 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
886
890
|
}
|
|
887
891
|
let c = n ? (o = i.getBlockIndex(n)) == null ? i.getCurrentBlockIndex() : o : i.getCurrentBlockIndex(), l = a.findFirstItemIndex(c - 1, t, e, r.style);
|
|
888
892
|
return l === null ? 1 : a.getBlockStartValue(l);
|
|
889
|
-
},
|
|
890
|
-
let o =
|
|
893
|
+
}, pn = (e, t, n, r, i, a) => {
|
|
894
|
+
let o = fn(e, t, r, n, i, a) + e;
|
|
891
895
|
return a.formatNumber(o, t);
|
|
892
|
-
},
|
|
896
|
+
}, mn = (e, t, n, r) => r.findGroupStart(e, t, n), hn = (e, t, n, r) => {
|
|
893
897
|
if (!e) return;
|
|
894
898
|
let i = e.holder, a = i == null ? void 0 : i.querySelector("[data-list-style=\"ordered\"]");
|
|
895
899
|
if (!a) return;
|
|
@@ -897,9 +901,9 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
897
901
|
if (!o) return;
|
|
898
902
|
let s = t.getBlockIndex(e.id);
|
|
899
903
|
if (s == null) return;
|
|
900
|
-
let c =
|
|
904
|
+
let c = cn(e, n), l = ln(e, r) || "ordered", u = r.getSiblingIndex(s, c, l), d = r.getGroupStartValue(s, c, u, l) + u;
|
|
901
905
|
o.textContent = r.formatNumber(d, c);
|
|
902
|
-
},
|
|
906
|
+
}, gn = (e, t, n, r, i, a, o, s) => {
|
|
903
907
|
let c = (e) => {
|
|
904
908
|
if (e >= t) return;
|
|
905
909
|
if (e === n) {
|
|
@@ -908,25 +912,25 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
908
912
|
}
|
|
909
913
|
let l = a.getBlockByIndex(e);
|
|
910
914
|
if (!l || l.name !== "list") return;
|
|
911
|
-
let u =
|
|
915
|
+
let u = cn(l, o);
|
|
912
916
|
if (!(u < r)) {
|
|
913
917
|
if (u > r) {
|
|
914
918
|
c(e + 1);
|
|
915
919
|
return;
|
|
916
920
|
}
|
|
917
|
-
|
|
921
|
+
ln(l, s) === i && (hn(l, a, o, s), c(e + 1));
|
|
918
922
|
}
|
|
919
923
|
};
|
|
920
924
|
c(e);
|
|
921
|
-
},
|
|
925
|
+
}, _n = (e, t, n) => {
|
|
922
926
|
let r = e.getBlocksCount();
|
|
923
927
|
Array.from({ length: r }, (e, t) => t).forEach((r) => {
|
|
924
928
|
let i = e.getBlockByIndex(r);
|
|
925
929
|
if (!i || i.name !== "list") return;
|
|
926
930
|
let a = i.holder;
|
|
927
|
-
a != null && a.querySelector("[data-list-style=\"ordered\"]") &&
|
|
931
|
+
a != null && a.querySelector("[data-list-style=\"ordered\"]") && hn(i, e, t, n);
|
|
928
932
|
});
|
|
929
|
-
},
|
|
933
|
+
}, w = (e, t, n = "end") => {
|
|
930
934
|
let r = () => {
|
|
931
935
|
let r = t.holder;
|
|
932
936
|
if (!r) return;
|
|
@@ -942,7 +946,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
942
946
|
n === "start" ? (o.setStart(i, 0), o.collapse(!0)) : (o.selectNodeContents(i), o.collapse(!1)), a.removeAllRanges(), a.addRange(o), e.caret.updateLastCaretAfterPosition();
|
|
943
947
|
}, i = t.holder;
|
|
944
948
|
(i == null ? void 0 : i.querySelector("[contenteditable=\"true\"]")) instanceof HTMLElement ? r() : requestAnimationFrame(() => r());
|
|
945
|
-
},
|
|
949
|
+
}, vn = async (e) => {
|
|
946
950
|
var t;
|
|
947
951
|
let { api: n, blockId: r, data: i, element: a, getContentElement: o } = e, s = window.getSelection();
|
|
948
952
|
if (!s || !a) return;
|
|
@@ -950,49 +954,49 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
950
954
|
if (!c) return;
|
|
951
955
|
let l = c.innerHTML.trim();
|
|
952
956
|
if (l === "" || l === "<br>") {
|
|
953
|
-
await
|
|
957
|
+
await yn(e);
|
|
954
958
|
return;
|
|
955
959
|
}
|
|
956
|
-
let { beforeContent: u, afterContent: d } =
|
|
960
|
+
let { beforeContent: u, afterContent: d } = Kt(c, s.getRangeAt(0)), f = r ? (t = n.blocks.getBlockIndex(r)) == null ? n.blocks.getCurrentBlockIndex() : t : n.blocks.getCurrentBlockIndex();
|
|
957
961
|
if (!r) {
|
|
958
|
-
c.innerHTML = u, i.text = u,
|
|
962
|
+
c.innerHTML = u, i.text = u, w(n, n.blocks.insert(kt, b(b({
|
|
959
963
|
text: d,
|
|
960
964
|
style: i.style
|
|
961
965
|
}, i.style === "checklist" ? { checked: !!i.checked } : {}), {}, { depth: i.depth }), void 0, f + 1, !0), "start");
|
|
962
966
|
return;
|
|
963
967
|
}
|
|
964
|
-
let p = n.blocks.splitBlock(r, { text: u },
|
|
968
|
+
let p = n.blocks.splitBlock(r, { text: u }, kt, b(b({
|
|
965
969
|
text: d,
|
|
966
970
|
style: i.style
|
|
967
971
|
}, i.style === "checklist" ? { checked: !!i.checked } : {}), {}, { depth: i.depth }), f + 1);
|
|
968
|
-
i.text = u,
|
|
969
|
-
},
|
|
972
|
+
i.text = u, w(n, p, "start");
|
|
973
|
+
}, yn = async (e) => {
|
|
970
974
|
let { api: t, blockId: n, getDepth: r } = e;
|
|
971
975
|
if (r() > 0) {
|
|
972
|
-
await
|
|
976
|
+
await Sn(e);
|
|
973
977
|
return;
|
|
974
978
|
}
|
|
975
|
-
n !== void 0 &&
|
|
976
|
-
},
|
|
979
|
+
n !== void 0 && w(t, await t.blocks.convert(n, "paragraph", { text: "" }), "start");
|
|
980
|
+
}, bn = async (e, t) => {
|
|
977
981
|
let { api: n, blockId: r, data: i, element: a, getContentElement: o, getDepth: s, syncContentFromDOM: c } = e, l = window.getSelection();
|
|
978
982
|
if (!l || !a) return;
|
|
979
983
|
let u = l.getRangeAt(0), d = o();
|
|
980
984
|
if (!d) return;
|
|
981
985
|
c();
|
|
982
986
|
let f = i.text, p = s();
|
|
983
|
-
if (
|
|
987
|
+
if (Xt(d, u) && !l.isCollapsed) {
|
|
984
988
|
t.preventDefault(), d.innerHTML = "", i.text = "";
|
|
985
989
|
let e = document.createRange();
|
|
986
990
|
e.setStart(d, 0), e.collapse(!0), l.removeAllRanges(), l.addRange(e);
|
|
987
991
|
return;
|
|
988
992
|
}
|
|
989
|
-
if (!
|
|
993
|
+
if (!Yt(d, u) || (t.preventDefault(), r === void 0)) return;
|
|
990
994
|
let m = await n.blocks.convert(r, "paragraph", { text: f });
|
|
991
995
|
p > 0 && requestAnimationFrame(() => {
|
|
992
996
|
let e = m.holder;
|
|
993
|
-
e && (e.style.marginLeft = `${p *
|
|
994
|
-
}),
|
|
995
|
-
},
|
|
997
|
+
e && (e.style.marginLeft = `${p * 27}px`, e.setAttribute("data-blok-depth", String(p)));
|
|
998
|
+
}), w(n, m, "start");
|
|
999
|
+
}, xn = async (e, t) => {
|
|
996
1000
|
let { api: n, blockId: r, data: i, syncContentFromDOM: a, getDepth: o } = e, s = n.blocks.getCurrentBlockIndex();
|
|
997
1001
|
if (s === 0) return;
|
|
998
1002
|
let c = n.blocks.getBlockByIndex(s - 1);
|
|
@@ -1001,15 +1005,15 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1001
1005
|
if (l > t.getBlockDepth(c)) return;
|
|
1002
1006
|
a();
|
|
1003
1007
|
let u = l + 1;
|
|
1004
|
-
i.depth = u,
|
|
1005
|
-
},
|
|
1008
|
+
i.depth = u, w(n, await n.blocks.update(r || "", b(b({}, i), {}, { depth: u })));
|
|
1009
|
+
}, Sn = async (e) => {
|
|
1006
1010
|
let { api: t, blockId: n, data: r, syncContentFromDOM: i, getDepth: a } = e, o = a();
|
|
1007
1011
|
if (o === 0) return;
|
|
1008
1012
|
i();
|
|
1009
1013
|
let s = o - 1;
|
|
1010
|
-
r.depth = s,
|
|
1011
|
-
},
|
|
1012
|
-
let { data: t, readOnly: n, placeholder: r, itemColor: i, itemSize: a, setupItemPlaceholder: o, onCheckboxChange: s, keydownHandler: c } = e, l =
|
|
1014
|
+
r.depth = s, w(t, await t.blocks.update(n || "", b(b({}, r), {}, { depth: s })));
|
|
1015
|
+
}, Cn = (e) => {
|
|
1016
|
+
let { data: t, readOnly: n, placeholder: r, itemColor: i, itemSize: a, setupItemPlaceholder: o, onCheckboxChange: s, keydownHandler: c } = e, l = Mt({
|
|
1013
1017
|
data: t,
|
|
1014
1018
|
readOnly: n,
|
|
1015
1019
|
placeholder: r,
|
|
@@ -1024,14 +1028,14 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1024
1028
|
});
|
|
1025
1029
|
}
|
|
1026
1030
|
return l.wrapper;
|
|
1027
|
-
},
|
|
1031
|
+
}, wn = (e) => {
|
|
1028
1032
|
let t = (e) => {
|
|
1029
1033
|
if (e <= 0) return "";
|
|
1030
1034
|
let n = e - 1;
|
|
1031
1035
|
return t(Math.floor(n / 26)) + String.fromCharCode(97 + n % 26);
|
|
1032
1036
|
};
|
|
1033
1037
|
return t(e);
|
|
1034
|
-
},
|
|
1038
|
+
}, Tn = (e) => {
|
|
1035
1039
|
let t = [
|
|
1036
1040
|
[1e3, "m"],
|
|
1037
1041
|
[900, "cm"],
|
|
@@ -1052,7 +1056,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1052
1056
|
return e >= i ? a + n(e - i, r) : n(e, r + 1);
|
|
1053
1057
|
};
|
|
1054
1058
|
return n(e, 0);
|
|
1055
|
-
},
|
|
1059
|
+
}, En = class {
|
|
1056
1060
|
constructor(e) {
|
|
1057
1061
|
this.blocks = e;
|
|
1058
1062
|
}
|
|
@@ -1078,7 +1082,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1078
1082
|
}
|
|
1079
1083
|
formatNumber(e, t) {
|
|
1080
1084
|
let n = t % 3;
|
|
1081
|
-
return n === 1 ? `${
|
|
1085
|
+
return n === 1 ? `${wn(e)}.` : n === 2 ? `${Tn(e)}.` : `${e}.`;
|
|
1082
1086
|
}
|
|
1083
1087
|
getGroupStartValue(e, t, n, r) {
|
|
1084
1088
|
if (n === 0) return this.getBlockStartValue(e);
|
|
@@ -1108,7 +1112,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1108
1112
|
var t;
|
|
1109
1113
|
if (!e) return 0;
|
|
1110
1114
|
let n = (t = e.holder) == null || (t = t.querySelector("[role=\"listitem\"]")) == null ? void 0 : t.getAttribute("style"), r = n == null ? void 0 : n.match(/margin-left:\s*(\d+)px/);
|
|
1111
|
-
return r ? Math.round(parseInt(r[1], 10) /
|
|
1115
|
+
return r ? Math.round(parseInt(r[1], 10) / 27) : 0;
|
|
1112
1116
|
}
|
|
1113
1117
|
getBlockStyle(e) {
|
|
1114
1118
|
var t;
|
|
@@ -1133,9 +1137,9 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1133
1137
|
let a = this.getBlockDepth(i);
|
|
1134
1138
|
return a < n ? t : a > n ? this.findGroupStartRecursive(e - 1, t, n, r) : this.getBlockStyle(i) === r ? this.findGroupStartRecursive(e - 1, e, n, r) : t;
|
|
1135
1139
|
}
|
|
1136
|
-
},
|
|
1140
|
+
}, Dn = { value: !1 }, On = class {
|
|
1137
1141
|
constructor(e) {
|
|
1138
|
-
this.blocks = e, this.depthValidator = new
|
|
1142
|
+
this.blocks = e, this.depthValidator = new an(e), this.markerCalculator = new En(e);
|
|
1139
1143
|
}
|
|
1140
1144
|
updateMarker(e, t, n) {
|
|
1141
1145
|
let r = e.querySelector("[data-list-marker]");
|
|
@@ -1162,8 +1166,8 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1162
1166
|
}
|
|
1163
1167
|
}
|
|
1164
1168
|
scheduleUpdateAll() {
|
|
1165
|
-
|
|
1166
|
-
|
|
1169
|
+
Dn.value || (Dn.value = !0, requestAnimationFrame(() => {
|
|
1170
|
+
Dn.value = !1, this.updateAllMarkers();
|
|
1167
1171
|
}));
|
|
1168
1172
|
}
|
|
1169
1173
|
findListGroupStartIndex(e, t, n) {
|
|
@@ -1202,12 +1206,12 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1202
1206
|
})() : c) + s;
|
|
1203
1207
|
r.textContent = this.markerCalculator.formatNumber(l, a);
|
|
1204
1208
|
}
|
|
1205
|
-
},
|
|
1209
|
+
}, kn = (e) => e instanceof HTMLElement, An = new Set(/* @__PURE__ */ "decimal.decimal-leading-zero.lower-roman.upper-roman.lower-greek.lower-latin.upper-latin.lower-alpha.upper-alpha.arabic-indic.armenian.bengali.cambodian.cjk-decimal.devanagari.georgian.gujarati.gurmukhi.hebrew.kannada.khmer.lao.malayalam.mongolian.myanmar.oriya.persian.telugu.thai.tibetan".split(".")), jn = new Set([
|
|
1206
1210
|
"disc",
|
|
1207
1211
|
"circle",
|
|
1208
1212
|
"square",
|
|
1209
1213
|
"none"
|
|
1210
|
-
]),
|
|
1214
|
+
]), Mn = (e) => {
|
|
1211
1215
|
let t = e.getAttribute("data-list-style");
|
|
1212
1216
|
if (t === "ordered") return "ordered";
|
|
1213
1217
|
if (t === "unordered") return "unordered";
|
|
@@ -1216,24 +1220,24 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1216
1220
|
let r = n.match(/list-style-type\s*:\s*([^;]+)/);
|
|
1217
1221
|
if (!r) return null;
|
|
1218
1222
|
let i = r[1].trim().toLowerCase();
|
|
1219
|
-
return
|
|
1220
|
-
},
|
|
1223
|
+
return An.has(i) ? "ordered" : jn.has(i) ? "unordered" : null;
|
|
1224
|
+
}, Nn = (e, t) => {
|
|
1221
1225
|
let n = e.parentElement;
|
|
1222
|
-
return (n == null ? void 0 : n.tagName) === "OL" ? "ordered" : (n == null ? void 0 : n.tagName) === "UL" ? e.querySelector("input[type=\"checkbox\"]") ? "checklist" : "unordered" :
|
|
1223
|
-
},
|
|
1226
|
+
return (n == null ? void 0 : n.tagName) === "OL" ? "ordered" : (n == null ? void 0 : n.tagName) === "UL" ? e.querySelector("input[type=\"checkbox\"]") ? "checklist" : "unordered" : Mn(e) || t;
|
|
1227
|
+
}, Pn = (e) => {
|
|
1224
1228
|
let t = e.innerHTML || e.textContent || "", n = e.querySelector("input[type=\"checkbox\"]");
|
|
1225
1229
|
return {
|
|
1226
1230
|
text: t,
|
|
1227
1231
|
checked: n instanceof HTMLInputElement ? n.checked : !1
|
|
1228
1232
|
};
|
|
1229
|
-
},
|
|
1233
|
+
}, Fn = (e) => {
|
|
1230
1234
|
let t = e.getAttribute("aria-level");
|
|
1231
1235
|
if (t) {
|
|
1232
1236
|
let e = parseInt(t, 10);
|
|
1233
1237
|
return Math.max(0, e - 1);
|
|
1234
1238
|
}
|
|
1235
1239
|
return 0;
|
|
1236
|
-
},
|
|
1240
|
+
}, In = () => ({ text: {
|
|
1237
1241
|
br: !0,
|
|
1238
1242
|
a: {
|
|
1239
1243
|
href: !0,
|
|
@@ -1242,38 +1246,38 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1242
1246
|
},
|
|
1243
1247
|
b: !0,
|
|
1244
1248
|
i: !0
|
|
1245
|
-
} }),
|
|
1249
|
+
} }), Ln = () => ({ tags: [{ li: {
|
|
1246
1250
|
style: !0,
|
|
1247
1251
|
"aria-level": !0
|
|
1248
|
-
} }] }),
|
|
1252
|
+
} }] }), Rn = () => ({
|
|
1249
1253
|
export: (e) => e.text,
|
|
1250
1254
|
import: (e) => ({
|
|
1251
1255
|
text: e,
|
|
1252
1256
|
style: "unordered",
|
|
1253
1257
|
checked: !1
|
|
1254
1258
|
})
|
|
1255
|
-
}),
|
|
1259
|
+
}), zn = [
|
|
1256
1260
|
{
|
|
1257
1261
|
name: "bulletedList",
|
|
1258
1262
|
titleKey: "bulletedList",
|
|
1259
1263
|
style: "unordered",
|
|
1260
|
-
icon:
|
|
1264
|
+
icon: Le
|
|
1261
1265
|
},
|
|
1262
1266
|
{
|
|
1263
1267
|
name: "numberedList",
|
|
1264
1268
|
titleKey: "numberedList",
|
|
1265
1269
|
style: "ordered",
|
|
1266
|
-
icon:
|
|
1270
|
+
icon: oe
|
|
1267
1271
|
},
|
|
1268
1272
|
{
|
|
1269
1273
|
name: "todoList",
|
|
1270
1274
|
titleKey: "todoList",
|
|
1271
1275
|
style: "checklist",
|
|
1272
|
-
icon:
|
|
1276
|
+
icon: u
|
|
1273
1277
|
}
|
|
1274
|
-
],
|
|
1278
|
+
], Bn = () => [
|
|
1275
1279
|
{
|
|
1276
|
-
icon:
|
|
1280
|
+
icon: Le,
|
|
1277
1281
|
title: "Bulleted list",
|
|
1278
1282
|
titleKey: "bulletedList",
|
|
1279
1283
|
data: { style: "unordered" },
|
|
@@ -1287,7 +1291,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1287
1291
|
shortcut: "-"
|
|
1288
1292
|
},
|
|
1289
1293
|
{
|
|
1290
|
-
icon:
|
|
1294
|
+
icon: oe,
|
|
1291
1295
|
title: "Numbered list",
|
|
1292
1296
|
titleKey: "numberedList",
|
|
1293
1297
|
data: { style: "ordered" },
|
|
@@ -1301,7 +1305,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1301
1305
|
shortcut: "1."
|
|
1302
1306
|
},
|
|
1303
1307
|
{
|
|
1304
|
-
icon:
|
|
1308
|
+
icon: u,
|
|
1305
1309
|
title: "To-do list",
|
|
1306
1310
|
titleKey: "todoList",
|
|
1307
1311
|
data: { style: "checklist" },
|
|
@@ -1315,24 +1319,24 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1315
1319
|
],
|
|
1316
1320
|
shortcut: "[]"
|
|
1317
1321
|
}
|
|
1318
|
-
],
|
|
1322
|
+
], Vn = class {
|
|
1319
1323
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
1320
1324
|
this._element = null, this.handleBlockChanged = (e) => {
|
|
1321
1325
|
if (this.isBlockChangedEventPayload(e) && (e.event.type === "block-removed" || e.event.type === "block-added")) {
|
|
1322
1326
|
var t;
|
|
1323
1327
|
(t = this.markerManager) == null || t.scheduleUpdateAll();
|
|
1324
1328
|
}
|
|
1325
|
-
}, this.api = n, this.readOnly = r, this._settings = t || {}, this._data = this.normalizeData(e), this.depthValidator = new
|
|
1329
|
+
}, this.api = n, this.readOnly = r, this._settings = t || {}, this._data = this.normalizeData(e), this.depthValidator = new an(n.blocks), this.markerCalculator = new En(n.blocks), this.markerManager = this._data.style === "ordered" ? new On(n.blocks) : null, i && (this.blockId = i.id), this._data.style === "ordered" && this.api.events.on("block changed", this.handleBlockChanged);
|
|
1326
1330
|
}
|
|
1327
1331
|
isBlockChangedEventPayload(e) {
|
|
1328
1332
|
return typeof e == "object" && !!e && "event" in e && typeof e.event == "object" && e.event !== null && "type" in e.event && typeof e.event.type == "string";
|
|
1329
1333
|
}
|
|
1330
1334
|
normalizeData(e) {
|
|
1331
|
-
return
|
|
1335
|
+
return rn(e, this._settings);
|
|
1332
1336
|
}
|
|
1333
1337
|
get availableStyles() {
|
|
1334
1338
|
let e = this._settings.styles;
|
|
1335
|
-
return !e || e.length === 0 ?
|
|
1339
|
+
return !e || e.length === 0 ? zn : zn.filter((t) => e.includes(t.style));
|
|
1336
1340
|
}
|
|
1337
1341
|
get itemColor() {
|
|
1338
1342
|
return this._settings.itemColor;
|
|
@@ -1341,13 +1345,13 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1341
1345
|
return this._settings.itemSize;
|
|
1342
1346
|
}
|
|
1343
1347
|
get placeholder() {
|
|
1344
|
-
return this.api.i18n.t(
|
|
1348
|
+
return this.api.i18n.t(Ot);
|
|
1345
1349
|
}
|
|
1346
1350
|
setupItemPlaceholder(e) {
|
|
1347
|
-
this.readOnly ||
|
|
1351
|
+
this.readOnly || ot(e, this.placeholder);
|
|
1348
1352
|
}
|
|
1349
1353
|
render() {
|
|
1350
|
-
return this._element =
|
|
1354
|
+
return this._element = Cn({
|
|
1351
1355
|
data: this._data,
|
|
1352
1356
|
readOnly: this.readOnly,
|
|
1353
1357
|
placeholder: this.placeholder,
|
|
@@ -1364,44 +1368,45 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1364
1368
|
this.updateMarkersAfterPositionChange();
|
|
1365
1369
|
}
|
|
1366
1370
|
moved(e) {
|
|
1367
|
-
this.validateAndAdjustDepthAfterMove(e.toIndex), this.updateMarkersAfterPositionChange();
|
|
1371
|
+
this.validateAndAdjustDepthAfterMove(e.toIndex, e.isGroupMove), this.updateMarkersAfterPositionChange();
|
|
1368
1372
|
}
|
|
1369
1373
|
updateMarkersAfterPositionChange() {
|
|
1370
1374
|
this._data.style !== "ordered" || !this._element || (this.updateMarker(), this.updateSiblingListMarkers());
|
|
1371
1375
|
}
|
|
1372
|
-
validateAndAdjustDepthAfterMove(e) {
|
|
1373
|
-
let
|
|
1376
|
+
validateAndAdjustDepthAfterMove(e, t) {
|
|
1377
|
+
let n = this.getDepth(), r = this.depthValidator.getTargetDepthForMove({
|
|
1374
1378
|
blockIndex: e,
|
|
1375
|
-
currentDepth:
|
|
1379
|
+
currentDepth: n,
|
|
1380
|
+
skipDepthPromotion: t
|
|
1376
1381
|
});
|
|
1377
|
-
|
|
1382
|
+
n !== r && this.adjustDepthTo(r);
|
|
1378
1383
|
}
|
|
1379
1384
|
adjustDepthTo(e) {
|
|
1380
|
-
|
|
1385
|
+
sn(this._element, this._data, e);
|
|
1381
1386
|
}
|
|
1382
1387
|
removed() {
|
|
1383
1388
|
var e;
|
|
1384
1389
|
this._data.style === "ordered" && (this.api.events.off("block changed", this.handleBlockChanged), (e = this.markerManager) == null || e.scheduleUpdateAll());
|
|
1385
1390
|
}
|
|
1386
1391
|
updateAllOrderedListMarkers() {
|
|
1387
|
-
|
|
1392
|
+
_n(this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1388
1393
|
}
|
|
1389
1394
|
updateMarker() {
|
|
1390
1395
|
var e;
|
|
1391
1396
|
let t = (e = this._element) == null ? void 0 : e.querySelector("[data-list-marker]");
|
|
1392
1397
|
if (!t) return;
|
|
1393
1398
|
let n = this.getDepth();
|
|
1394
|
-
t.textContent =
|
|
1399
|
+
t.textContent = pn(dn(this.blockId, n, this._data.style, this.api.blocks, this.markerCalculator), n, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1395
1400
|
}
|
|
1396
1401
|
updateSiblingListMarkers() {
|
|
1397
1402
|
var e;
|
|
1398
1403
|
let t = this.blockId ? (e = this.api.blocks.getBlockIndex(this.blockId)) == null ? this.api.blocks.getCurrentBlockIndex() : e : this.api.blocks.getCurrentBlockIndex(), n = this.getDepth(), r = this._data.style, i = this.api.blocks.getBlocksCount();
|
|
1399
|
-
|
|
1404
|
+
gn(mn(t, n, r, this.markerCalculator), i, t, n, r, this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1400
1405
|
}
|
|
1401
1406
|
updateMarkerForDepth(e, t) {
|
|
1402
1407
|
var n;
|
|
1403
1408
|
let r = (n = this._element) == null ? void 0 : n.querySelector("[aria-hidden=\"true\"]");
|
|
1404
|
-
r instanceof HTMLElement && (t === "ordered" ? r.textContent =
|
|
1409
|
+
r instanceof HTMLElement && (t === "ordered" ? r.textContent = pn(dn(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), e, this._data, this.blockId, this.api.blocks, this.markerCalculator) : r.textContent = un(e, this.markerCalculator));
|
|
1405
1410
|
}
|
|
1406
1411
|
updateCheckboxState(e) {
|
|
1407
1412
|
var t;
|
|
@@ -1431,7 +1436,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1431
1436
|
}
|
|
1432
1437
|
async handleEnter() {
|
|
1433
1438
|
var e = this;
|
|
1434
|
-
await
|
|
1439
|
+
await vn({
|
|
1435
1440
|
api: e.api,
|
|
1436
1441
|
blockId: e.blockId,
|
|
1437
1442
|
data: e._data,
|
|
@@ -1443,7 +1448,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1443
1448
|
}
|
|
1444
1449
|
async handleBackspace(e) {
|
|
1445
1450
|
var t = this;
|
|
1446
|
-
await
|
|
1451
|
+
await bn({
|
|
1447
1452
|
api: t.api,
|
|
1448
1453
|
blockId: t.blockId,
|
|
1449
1454
|
data: t._data,
|
|
@@ -1455,7 +1460,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1455
1460
|
}
|
|
1456
1461
|
async handleIndent() {
|
|
1457
1462
|
var e = this;
|
|
1458
|
-
await
|
|
1463
|
+
await xn({
|
|
1459
1464
|
api: e.api,
|
|
1460
1465
|
blockId: e.blockId,
|
|
1461
1466
|
data: e._data,
|
|
@@ -1467,7 +1472,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1467
1472
|
}
|
|
1468
1473
|
async handleOutdent() {
|
|
1469
1474
|
var e = this;
|
|
1470
|
-
await
|
|
1475
|
+
await Sn({
|
|
1471
1476
|
api: e.api,
|
|
1472
1477
|
blockId: e.blockId,
|
|
1473
1478
|
data: e._data,
|
|
@@ -1485,10 +1490,10 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1485
1490
|
n instanceof HTMLInputElement && (this._data.checked = n.checked);
|
|
1486
1491
|
}
|
|
1487
1492
|
getContentElement() {
|
|
1488
|
-
return
|
|
1493
|
+
return on(this._element, this._data.style);
|
|
1489
1494
|
}
|
|
1490
1495
|
renderSettings() {
|
|
1491
|
-
return
|
|
1496
|
+
return Ht(this.availableStyles, this._data.style, this.api.i18n.t, (e) => this.setStyle(e));
|
|
1492
1497
|
}
|
|
1493
1498
|
setStyle(e) {
|
|
1494
1499
|
let t = this._data.style;
|
|
@@ -1498,7 +1503,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1498
1503
|
}
|
|
1499
1504
|
}
|
|
1500
1505
|
rerender() {
|
|
1501
|
-
let e =
|
|
1506
|
+
let e = Rt({
|
|
1502
1507
|
data: this._data,
|
|
1503
1508
|
readOnly: this.readOnly,
|
|
1504
1509
|
placeholder: this.placeholder,
|
|
@@ -1517,10 +1522,10 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1517
1522
|
return typeof e.text == "string";
|
|
1518
1523
|
}
|
|
1519
1524
|
save() {
|
|
1520
|
-
return
|
|
1525
|
+
return zt(this._data, this._element, this.getContentElement.bind(this));
|
|
1521
1526
|
}
|
|
1522
1527
|
setData(e) {
|
|
1523
|
-
let t =
|
|
1528
|
+
let t = Bt(this._data, e, this._element, this.getContentElement.bind(this), {
|
|
1524
1529
|
adjustDepthTo: this.adjustDepthTo.bind(this),
|
|
1525
1530
|
updateMarkerForDepth: this.updateMarkerForDepth.bind(this),
|
|
1526
1531
|
updateCheckboxState: this.updateCheckboxState.bind(this)
|
|
@@ -1528,31 +1533,31 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1528
1533
|
return this._data = t.newData, t.inPlace;
|
|
1529
1534
|
}
|
|
1530
1535
|
merge(e) {
|
|
1531
|
-
|
|
1536
|
+
Vt({
|
|
1532
1537
|
data: this._data,
|
|
1533
1538
|
element: this._element,
|
|
1534
1539
|
getContentElement: this.getContentElement.bind(this),
|
|
1535
|
-
parseHTML:
|
|
1540
|
+
parseHTML: Jt
|
|
1536
1541
|
}, e);
|
|
1537
1542
|
}
|
|
1538
1543
|
static get conversionConfig() {
|
|
1539
|
-
return
|
|
1544
|
+
return Rn();
|
|
1540
1545
|
}
|
|
1541
1546
|
static get sanitize() {
|
|
1542
|
-
return
|
|
1547
|
+
return In();
|
|
1543
1548
|
}
|
|
1544
1549
|
static get pasteConfig() {
|
|
1545
|
-
return
|
|
1550
|
+
return Ln();
|
|
1546
1551
|
}
|
|
1547
1552
|
onPaste(e) {
|
|
1548
1553
|
let t = e.detail;
|
|
1549
1554
|
if (!("data" in t)) return;
|
|
1550
1555
|
let n = t.data;
|
|
1551
|
-
if (!
|
|
1552
|
-
let { text: r, checked: i } =
|
|
1556
|
+
if (!kn(n)) return;
|
|
1557
|
+
let { text: r, checked: i } = Pn(n), a = Fn(n);
|
|
1553
1558
|
this._data = {
|
|
1554
1559
|
text: r,
|
|
1555
|
-
style:
|
|
1560
|
+
style: Nn(n, this._data.style),
|
|
1556
1561
|
checked: i,
|
|
1557
1562
|
depth: a
|
|
1558
1563
|
}, this.rerender();
|
|
@@ -1561,18 +1566,18 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1561
1566
|
return !0;
|
|
1562
1567
|
}
|
|
1563
1568
|
getContentOffset(e) {
|
|
1564
|
-
return
|
|
1569
|
+
return Gt(e);
|
|
1565
1570
|
}
|
|
1566
1571
|
static get toolbox() {
|
|
1567
|
-
return
|
|
1572
|
+
return Bn();
|
|
1568
1573
|
}
|
|
1569
|
-
},
|
|
1574
|
+
}, Hn = "data-blok-table-add-row", Un = "data-blok-table-add-col", Wn = 150, Gn = 5, Kn = 40, qn = [
|
|
1570
1575
|
"flex",
|
|
1571
1576
|
"items-center",
|
|
1572
1577
|
"justify-center",
|
|
1573
1578
|
"transition-opacity",
|
|
1574
1579
|
"duration-150"
|
|
1575
|
-
],
|
|
1580
|
+
], Jn = [
|
|
1576
1581
|
"flex",
|
|
1577
1582
|
"items-center",
|
|
1578
1583
|
"justify-center",
|
|
@@ -1580,7 +1585,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1580
1585
|
"border-gray-300",
|
|
1581
1586
|
"rounded-full",
|
|
1582
1587
|
"group-hover/add:bg-gray-50"
|
|
1583
|
-
],
|
|
1588
|
+
], Yn = "12", Xn = class {
|
|
1584
1589
|
constructor(e) {
|
|
1585
1590
|
this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.interactive = !0, this.dragState = null, this.scrollContainer = null, this.boundScrollHandler = null, this.scrollContainerResizeObserver = null, this.wrapper = e.wrapper, this.grid = e.grid, this.i18n = e.i18n, this.boundAddRowClick = e.onAddRow, this.boundAddColClick = e.onAddColumn, this.onDragStart = e.onDragStart, this.onDragAddRow = e.onDragAddRow, this.onDragRemoveRow = e.onDragRemoveRow, this.onDragAddCol = e.onDragAddCol, this.onDragRemoveCol = e.onDragRemoveCol, this.onDragEnd = e.onDragEnd, this.getNewColumnWidth = e.getNewColumnWidth, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundDocumentMouseMove = this.handleDocumentMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundPointerCancel = this.handlePointerCancel.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.wrapper.appendChild(this.addColBtn), this.syncRowButtonWidth(), this.wrapper.addEventListener("mousemove", this.boundMouseMove), this.wrapper.addEventListener("mouseleave", this.boundMouseLeave), document.addEventListener("mousemove", this.boundDocumentMouseMove), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
|
|
1586
1591
|
}
|
|
@@ -1656,7 +1661,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1656
1661
|
let { axis: t, startPos: n, unitSize: r } = this.dragState, i = (t === "row" ? e.clientY : e.clientX) - n, a = Math.floor(i / r);
|
|
1657
1662
|
for (; this.dragState.addedCount < a;) t === "row" ? this.onDragAddRow() : this.onDragAddCol(), this.dragState.addedCount++;
|
|
1658
1663
|
for (; this.dragState.addedCount > a;) t === "row" ? this.onDragRemoveRow() : this.onDragRemoveCol(), this.dragState.addedCount--;
|
|
1659
|
-
Math.abs(i) >
|
|
1664
|
+
Math.abs(i) > Gn && !this.dragState.didDrag && (this.dragState.didDrag = !0, document.body.style.cursor = t === "row" ? "row-resize" : "col-resize", h(), this.onDragStart());
|
|
1660
1665
|
}
|
|
1661
1666
|
handlePointerUp(e) {
|
|
1662
1667
|
if (!this.dragState) return;
|
|
@@ -1685,14 +1690,14 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1685
1690
|
}
|
|
1686
1691
|
handleMouseMove(e) {
|
|
1687
1692
|
let t = this.grid.getBoundingClientRect(), n = this.grid.parentElement, r = n !== null && n !== this.wrapper ? Math.min(t.right, n.getBoundingClientRect().right) : t.right, i = Math.abs(e.clientY - t.bottom), a = Math.abs(e.clientX - r);
|
|
1688
|
-
i <=
|
|
1693
|
+
i <= Kn ? this.showRow() : this.scheduleHideRow(), a <= Kn ? this.showCol() : this.scheduleHideCol();
|
|
1689
1694
|
}
|
|
1690
1695
|
handleMouseLeave() {
|
|
1691
1696
|
this.scheduleHideRow(), this.scheduleHideCol();
|
|
1692
1697
|
}
|
|
1693
1698
|
handleDocumentMouseMove(e) {
|
|
1694
1699
|
if (this.wrapper.contains(e.target)) return;
|
|
1695
|
-
let t = this.grid.getBoundingClientRect(), n =
|
|
1700
|
+
let t = this.grid.getBoundingClientRect(), n = Kn;
|
|
1696
1701
|
e.clientX >= t.left - n && e.clientX <= t.right + n && e.clientY >= t.top - n && e.clientY <= t.bottom + n && this.handleMouseMove(e);
|
|
1697
1702
|
}
|
|
1698
1703
|
showRow() {
|
|
@@ -1705,13 +1710,13 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1705
1710
|
var e;
|
|
1706
1711
|
!this.rowVisible || this.rowHideTimeout !== null || ((e = this.dragState) == null ? void 0 : e.axis) === "row" || (this.rowHideTimeout = setTimeout(() => {
|
|
1707
1712
|
this.addRowBtn.style.opacity = "0", this.addRowBtn.style.pointerEvents = "none", this.rowVisible = !1, this.rowHideTimeout = null;
|
|
1708
|
-
},
|
|
1713
|
+
}, Wn));
|
|
1709
1714
|
}
|
|
1710
1715
|
scheduleHideCol() {
|
|
1711
1716
|
var e;
|
|
1712
1717
|
!this.colVisible || this.colHideTimeout !== null || ((e = this.dragState) == null ? void 0 : e.axis) === "col" || (this.colHideTimeout = setTimeout(() => {
|
|
1713
1718
|
this.addColBtn.style.opacity = "0", this.addColBtn.style.pointerEvents = "none", this.colVisible = !1, this.colHideTimeout = null;
|
|
1714
|
-
},
|
|
1719
|
+
}, Wn));
|
|
1715
1720
|
}
|
|
1716
1721
|
clearRowTimeout() {
|
|
1717
1722
|
this.rowHideTimeout !== null && (clearTimeout(this.rowHideTimeout), this.rowHideTimeout = null);
|
|
@@ -1721,63 +1726,63 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1721
1726
|
}
|
|
1722
1727
|
createAddRowButton() {
|
|
1723
1728
|
let e = document.createElement("div");
|
|
1724
|
-
e.className =
|
|
1729
|
+
e.className = x(qn, "group/add", "items-start", "cursor-row-resize"), e.setAttribute(Hn, ""), e.setAttribute("contenteditable", "false"), e.style.opacity = "0", e.style.pointerEvents = "none", e.style.position = "absolute", e.style.left = "0", e.style.bottom = "-36px", e.style.zIndex = "1", e.style.height = "32px";
|
|
1725
1730
|
let t = document.createElement("div");
|
|
1726
|
-
return t.className =
|
|
1731
|
+
return t.className = x(Jn), t.style.width = "100%", t.style.height = "16px", this.appendIcon(t), e.appendChild(t), De(e, be([this.i18n.t("tools.table.clickToAddRow"), this.i18n.t("tools.table.dragToAddRemoveRows")]), {
|
|
1727
1732
|
placement: "bottom",
|
|
1728
1733
|
marginTop: -16
|
|
1729
1734
|
}), e;
|
|
1730
1735
|
}
|
|
1731
1736
|
createAddColumnButton() {
|
|
1732
1737
|
let e = document.createElement("div");
|
|
1733
|
-
e.className =
|
|
1738
|
+
e.className = x(qn, "group/add", "justify-start", "cursor-col-resize"), e.setAttribute(Un, ""), e.setAttribute("contenteditable", "false"), e.style.opacity = "0", e.style.pointerEvents = "none", e.style.position = "absolute", e.style.right = "-36px", e.style.top = "0px", e.style.bottom = "0px", e.style.width = "32px";
|
|
1734
1739
|
let t = document.createElement("div");
|
|
1735
|
-
return t.className =
|
|
1740
|
+
return t.className = x(Jn), t.style.width = "16px", t.style.height = "100%", this.appendIcon(t), e.appendChild(t), De(e, be([this.i18n.t("tools.table.clickToAddColumn"), this.i18n.t("tools.table.dragToAddRemoveColumns")]), { placement: "bottom" }), e;
|
|
1736
1741
|
}
|
|
1737
|
-
appendIcon(
|
|
1738
|
-
|
|
1739
|
-
let
|
|
1740
|
-
|
|
1742
|
+
appendIcon(t) {
|
|
1743
|
+
t.insertAdjacentHTML("beforeend", e);
|
|
1744
|
+
let n = t.querySelector("svg");
|
|
1745
|
+
n && (n.setAttribute("width", Yn), n.setAttribute("height", Yn), n.setAttribute("viewBox", "0 0 24 24"), n.classList.add("text-gray-500", "pointer-events-none"));
|
|
1741
1746
|
}
|
|
1742
|
-
},
|
|
1747
|
+
}, T = "data-blok-table-row", E = "data-blok-table-cell", Zn = "1px solid var(--blok-table-border)", Qn = ["flex"], $n = [
|
|
1743
1748
|
"py-1",
|
|
1744
1749
|
"px-2",
|
|
1745
1750
|
"min-h-[2em]",
|
|
1746
1751
|
"outline-hidden",
|
|
1747
|
-
"leading-
|
|
1752
|
+
"leading-none",
|
|
1748
1753
|
"text-sm",
|
|
1749
1754
|
"cursor-text"
|
|
1750
|
-
],
|
|
1755
|
+
], er = (e) => {
|
|
1751
1756
|
let t = Math.round(100 / e * 100) / 100;
|
|
1752
1757
|
return Array.from({ length: e }, () => t);
|
|
1753
|
-
},
|
|
1758
|
+
}, tr = class {
|
|
1754
1759
|
constructor(e) {
|
|
1755
1760
|
this.readOnly = e.readOnly;
|
|
1756
1761
|
}
|
|
1757
1762
|
createGrid(e, t, n) {
|
|
1758
1763
|
let r = document.createElement("div");
|
|
1759
|
-
r.style.borderTop =
|
|
1760
|
-
let i = n == null ?
|
|
1764
|
+
r.style.borderTop = Zn, r.style.borderLeft = Zn;
|
|
1765
|
+
let i = n == null ? er(t) : n;
|
|
1761
1766
|
return Array.from({ length: e }).forEach(() => {
|
|
1762
1767
|
r.appendChild(this.createRow(t, i));
|
|
1763
1768
|
}), r;
|
|
1764
1769
|
}
|
|
1765
1770
|
fillGrid(e, t) {}
|
|
1766
1771
|
addRow(e, t) {
|
|
1767
|
-
let n = this.getColumnCount(e), r = this.getRawCellWidths(e), i = this.createRow(n, r), a = e.querySelectorAll(`[${
|
|
1772
|
+
let n = this.getColumnCount(e), r = this.getRawCellWidths(e), i = this.createRow(n, r), a = e.querySelectorAll(`[${T}]`);
|
|
1768
1773
|
return t !== void 0 && t < a.length ? e.insertBefore(i, a[t]) : e.appendChild(i), i;
|
|
1769
1774
|
}
|
|
1770
1775
|
deleteRow(e, t) {
|
|
1771
|
-
let n = e.querySelectorAll(`[${
|
|
1776
|
+
let n = e.querySelectorAll(`[${T}]`);
|
|
1772
1777
|
t < n.length && n[t].remove();
|
|
1773
1778
|
}
|
|
1774
1779
|
addColumn(e, t, n, r) {
|
|
1775
|
-
let i = e.querySelectorAll(`[${
|
|
1780
|
+
let i = e.querySelectorAll(`[${T}]`), a = this.getColumnCount(e), o = n !== void 0 && n.length === a, s = o || this.detectWidthUnit(e) === "px";
|
|
1776
1781
|
return o && this.convertToPixelWidths(i, n), s ? (this.addColumnPx(i, a, t, r), !0) : (this.addColumnPercent(i, a, t), !0);
|
|
1777
1782
|
}
|
|
1778
1783
|
convertToPixelWidths(e, t) {
|
|
1779
1784
|
e.forEach((e) => {
|
|
1780
|
-
e.querySelectorAll(`[${
|
|
1785
|
+
e.querySelectorAll(`[${E}]`).forEach((e, n) => {
|
|
1781
1786
|
if (n < t.length) {
|
|
1782
1787
|
let r = e;
|
|
1783
1788
|
r.style.width = `${t[n]}px`;
|
|
@@ -1788,7 +1793,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1788
1793
|
addColumnPx(e, t, n, r) {
|
|
1789
1794
|
let i = r == null ? this.computeHalfAvgPxWidth(e, t) : r;
|
|
1790
1795
|
e.forEach((e) => {
|
|
1791
|
-
let t = e.querySelectorAll(`[${
|
|
1796
|
+
let t = e.querySelectorAll(`[${E}]`), r = n === void 0 || n >= t.length, a = this.createCell(`${i}px`);
|
|
1792
1797
|
if (!r) {
|
|
1793
1798
|
e.insertBefore(a, t[n]);
|
|
1794
1799
|
return;
|
|
@@ -1797,17 +1802,17 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1797
1802
|
});
|
|
1798
1803
|
}
|
|
1799
1804
|
computeHalfAvgPxWidth(e, t) {
|
|
1800
|
-
let n = e[0], r = n == null ? void 0 : n.querySelectorAll(`[${
|
|
1805
|
+
let n = e[0], r = n == null ? void 0 : n.querySelectorAll(`[${E}]`), i = Array.from(r == null ? [] : r).reduce((e, t) => e + (parseFloat(t.style.width) || 0), 0);
|
|
1801
1806
|
return t > 0 ? Math.round(i / t / 2 * 100) / 100 : 0;
|
|
1802
1807
|
}
|
|
1803
1808
|
addColumnPercent(e, t, n) {
|
|
1804
1809
|
let r = 1 - .5 / t;
|
|
1805
1810
|
e.forEach((e) => {
|
|
1806
|
-
e.querySelectorAll(`[${
|
|
1811
|
+
e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
1807
1812
|
let n = e, i = parseFloat(n.style.width) || 100 / t, a = Math.round(i * r * 100) / 100;
|
|
1808
1813
|
n.style.width = `${a}%`;
|
|
1809
1814
|
});
|
|
1810
|
-
let i = Math.round(100 / t / 2 * 100) / 100, a = e.querySelectorAll(`[${
|
|
1815
|
+
let i = Math.round(100 / t / 2 * 100) / 100, a = e.querySelectorAll(`[${E}]`), o = n === void 0 || n >= a.length, s = this.createCell(`${i}%`);
|
|
1811
1816
|
if (!o) {
|
|
1812
1817
|
e.insertBefore(s, a[n]);
|
|
1813
1818
|
return;
|
|
@@ -1816,77 +1821,77 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1816
1821
|
});
|
|
1817
1822
|
}
|
|
1818
1823
|
deleteColumn(e, t) {
|
|
1819
|
-
e.querySelectorAll(`[${
|
|
1820
|
-
let n = e.querySelectorAll(`[${
|
|
1824
|
+
e.querySelectorAll(`[${T}]`).forEach((e) => {
|
|
1825
|
+
let n = e.querySelectorAll(`[${E}]`);
|
|
1821
1826
|
t >= n.length || n[t].remove();
|
|
1822
1827
|
});
|
|
1823
1828
|
}
|
|
1824
1829
|
moveRow(e, t, n) {
|
|
1825
1830
|
if (t === n) return;
|
|
1826
|
-
let r = Array.from(e.querySelectorAll(`[${
|
|
1831
|
+
let r = Array.from(e.querySelectorAll(`[${T}]`));
|
|
1827
1832
|
if (t >= r.length || n >= r.length) return;
|
|
1828
1833
|
let i = r[t];
|
|
1829
1834
|
i.remove();
|
|
1830
|
-
let a = Array.from(e.querySelectorAll(`[${
|
|
1835
|
+
let a = Array.from(e.querySelectorAll(`[${T}]`));
|
|
1831
1836
|
n >= a.length ? e.appendChild(i) : e.insertBefore(i, a[n]);
|
|
1832
1837
|
}
|
|
1833
1838
|
moveColumn(e, t, n) {
|
|
1834
|
-
t !== n && e.querySelectorAll(`[${
|
|
1835
|
-
let r = Array.from(e.querySelectorAll(`[${
|
|
1839
|
+
t !== n && e.querySelectorAll(`[${T}]`).forEach((e) => {
|
|
1840
|
+
let r = Array.from(e.querySelectorAll(`[${E}]`));
|
|
1836
1841
|
if (t >= r.length || n >= r.length) return;
|
|
1837
1842
|
let i = r[t];
|
|
1838
1843
|
i.remove();
|
|
1839
|
-
let a = Array.from(e.querySelectorAll(`[${
|
|
1844
|
+
let a = Array.from(e.querySelectorAll(`[${E}]`));
|
|
1840
1845
|
n >= a.length ? e.appendChild(i) : e.insertBefore(i, a[n]);
|
|
1841
1846
|
});
|
|
1842
1847
|
}
|
|
1843
1848
|
getRowCount(e) {
|
|
1844
|
-
return e.querySelectorAll(`[${
|
|
1849
|
+
return e.querySelectorAll(`[${T}]`).length;
|
|
1845
1850
|
}
|
|
1846
1851
|
getColumnCount(e) {
|
|
1847
|
-
let t = e.querySelector(`[${
|
|
1848
|
-
return t ? t.querySelectorAll(`[${
|
|
1852
|
+
let t = e.querySelector(`[${T}]`);
|
|
1853
|
+
return t ? t.querySelectorAll(`[${E}]`).length : 0;
|
|
1849
1854
|
}
|
|
1850
1855
|
getCell(e, t, n) {
|
|
1851
|
-
let r = e.querySelectorAll(`[${
|
|
1856
|
+
let r = e.querySelectorAll(`[${T}]`);
|
|
1852
1857
|
if (t >= r.length) return null;
|
|
1853
|
-
let i = r[t].querySelectorAll(`[${
|
|
1858
|
+
let i = r[t].querySelectorAll(`[${E}]`);
|
|
1854
1859
|
return n >= i.length ? null : i[n];
|
|
1855
1860
|
}
|
|
1856
1861
|
getColWidths(e) {
|
|
1857
|
-
let t = e.querySelector(`[${
|
|
1862
|
+
let t = e.querySelector(`[${T}]`);
|
|
1858
1863
|
if (!t) return [];
|
|
1859
|
-
let n = t.querySelectorAll(`[${
|
|
1864
|
+
let n = t.querySelectorAll(`[${E}]`), r = [];
|
|
1860
1865
|
return n.forEach((e) => {
|
|
1861
1866
|
let t = parseFloat(e.style.width);
|
|
1862
1867
|
r.push(isNaN(t) ? 0 : t);
|
|
1863
1868
|
}), r;
|
|
1864
1869
|
}
|
|
1865
1870
|
detectWidthUnit(e) {
|
|
1866
|
-
let t = e.querySelector(`[${
|
|
1871
|
+
let t = e.querySelector(`[${T}]`);
|
|
1867
1872
|
if (!t) return "%";
|
|
1868
|
-
let n = t.querySelector(`[${
|
|
1873
|
+
let n = t.querySelector(`[${E}]`);
|
|
1869
1874
|
return n && n.style.width.endsWith("px") ? "px" : "%";
|
|
1870
1875
|
}
|
|
1871
1876
|
getRawCellWidths(e) {
|
|
1872
|
-
let t = e.querySelector(`[${
|
|
1877
|
+
let t = e.querySelector(`[${T}]`);
|
|
1873
1878
|
if (!t) return [];
|
|
1874
|
-
let n = t.querySelectorAll(`[${
|
|
1879
|
+
let n = t.querySelectorAll(`[${E}]`);
|
|
1875
1880
|
return Array.from(n).map((e) => e.style.width);
|
|
1876
1881
|
}
|
|
1877
1882
|
createRow(e, t) {
|
|
1878
1883
|
let n = document.createElement("div");
|
|
1879
|
-
return n.className =
|
|
1884
|
+
return n.className = x(Qn), n.setAttribute(T, ""), Array.from({ length: e }).forEach((e, r) => {
|
|
1880
1885
|
n.appendChild(this.createCell(t[r]));
|
|
1881
1886
|
}), n;
|
|
1882
1887
|
}
|
|
1883
1888
|
createCell(e) {
|
|
1884
1889
|
let t = document.createElement("div");
|
|
1885
|
-
t.className =
|
|
1890
|
+
t.className = x($n), t.style.borderRight = Zn, t.style.borderBottom = Zn, t.style.flexShrink = "0", t.style.overflow = "hidden", t.style.overflowWrap = "break-word", e !== void 0 && (t.style.width = typeof e == "string" ? e : `${e}%`), t.setAttribute(E, "");
|
|
1886
1891
|
let n = document.createElement("div");
|
|
1887
|
-
return n.setAttribute(
|
|
1892
|
+
return n.setAttribute(O, ""), t.appendChild(n), t;
|
|
1888
1893
|
}
|
|
1889
|
-
},
|
|
1894
|
+
}, D = (e) => typeof e == "object" && !!e && "blocks" in e, O = "data-blok-table-cell-blocks", nr = class {
|
|
1890
1895
|
constructor(e) {
|
|
1891
1896
|
var t;
|
|
1892
1897
|
this._activeCellWithBlocks = null, this.cellsPendingCheck = /* @__PURE__ */ new Set(), this.pendingCheckScheduled = !1, this.removedBlockCells = /* @__PURE__ */ new Map(), this.deferredEvents = [], this.isExitingTable = !1, this.handleBlockMutation = (e) => {
|
|
@@ -1908,9 +1913,9 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1908
1913
|
this.claimBlockForCell(i.cell, n.target.id), this.syncBlockToModel(i.cell, n.target.id), this.cellsPendingCheck.delete(i.cell);
|
|
1909
1914
|
return;
|
|
1910
1915
|
}
|
|
1911
|
-
let a = n.target.holder, o = a.closest(`[${
|
|
1916
|
+
let a = n.target.holder, o = a.closest(`[${O}]`);
|
|
1912
1917
|
o && this.stripPlaceholders(o);
|
|
1913
|
-
let s = o && !this.model.findCellForBlock(n.target.id) ? o.closest(`[${
|
|
1918
|
+
let s = o && !this.model.findCellForBlock(n.target.id) ? o.closest(`[${E}]`) : null;
|
|
1914
1919
|
if (s && this.syncBlockToModel(s, n.target.id), o) return;
|
|
1915
1920
|
if (!this.gridElement.contains(a)) {
|
|
1916
1921
|
let e = this.api.blocks.getCurrentBlockIndex(), t = e >= 0 ? this.api.blocks.getBlockByIndex(e) : null;
|
|
@@ -1924,11 +1929,11 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
1924
1929
|
}, this.handleCellBlankSpaceClick = (e) => {
|
|
1925
1930
|
let t = e.target;
|
|
1926
1931
|
if (!t) return;
|
|
1927
|
-
let n = t.hasAttribute(
|
|
1932
|
+
let n = t.hasAttribute(E), r = t.hasAttribute(O);
|
|
1928
1933
|
if (!n && !r) return;
|
|
1929
|
-
let i = n ? t : t.closest(`[${
|
|
1934
|
+
let i = n ? t : t.closest(`[${E}]`);
|
|
1930
1935
|
if (!i) return;
|
|
1931
|
-
let a = n ? i.querySelector(`[${
|
|
1936
|
+
let a = n ? i.querySelector(`[${O}]`) : t;
|
|
1932
1937
|
if (!a) return;
|
|
1933
1938
|
let o = a.querySelectorAll("[data-blok-id]"), s = o[o.length - 1];
|
|
1934
1939
|
if (!s) return;
|
|
@@ -2026,7 +2031,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2026
2031
|
this.clearActiveCellWithBlocks();
|
|
2027
2032
|
let r = this.getCell(e.row, e.col);
|
|
2028
2033
|
if (!r) return;
|
|
2029
|
-
let i = r.querySelector(`[${
|
|
2034
|
+
let i = r.querySelector(`[${O}]`);
|
|
2030
2035
|
if (!i) return;
|
|
2031
2036
|
let a = i.querySelectorAll("[contenteditable=\"true\"]");
|
|
2032
2037
|
a.length !== 0 && ((t ? a[a.length - 1] : a[0]).focus(), (n = this.onNavigateToCell) == null || n.call(this, e));
|
|
@@ -2045,18 +2050,18 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2045
2050
|
return r ? (n = r.querySelectorAll("[data-blok-table-cell]")[t]) == null ? null : n : null;
|
|
2046
2051
|
}
|
|
2047
2052
|
initializeCells(e) {
|
|
2048
|
-
let t = this.gridElement.querySelectorAll(`[${
|
|
2053
|
+
let t = this.gridElement.querySelectorAll(`[${T}]`), n = [];
|
|
2049
2054
|
return e.forEach((e, r) => {
|
|
2050
2055
|
let i = t[r];
|
|
2051
2056
|
if (!i) return;
|
|
2052
|
-
let a = i.querySelectorAll(`[${
|
|
2057
|
+
let a = i.querySelectorAll(`[${E}]`), o = [];
|
|
2053
2058
|
e.forEach((e, t) => {
|
|
2054
2059
|
let n = a[t];
|
|
2055
2060
|
if (!n) return;
|
|
2056
|
-
let r = n.querySelector(`[${
|
|
2061
|
+
let r = n.querySelector(`[${O}]`);
|
|
2057
2062
|
if (!r) return;
|
|
2058
|
-
let i =
|
|
2059
|
-
if (
|
|
2063
|
+
let i = D(e) && e.blocks.length > 0 ? [...e.blocks] : null, s = i ? this.mountBlocksInCell(r, i) : [], c = {};
|
|
2064
|
+
if (D(e) && (e.color !== void 0 && (c.color = e.color), e.textColor !== void 0 && (c.textColor = e.textColor)), s.length > 0) o.push(b({ blocks: i == null ? s : i }, c));
|
|
2060
2065
|
else {
|
|
2061
2066
|
var l;
|
|
2062
2067
|
let t = typeof e == "string" ? e : (l = e.text) == null ? "" : l, n = t.split(/<br\s*\/?>/i).map((e) => e.trim()).filter(Boolean), a = n.length > 0 ? n : [t], s = [];
|
|
@@ -2064,7 +2069,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2064
2069
|
let t = this.api.blocks.insert("paragraph", { text: e }, {}, this.api.blocks.getBlocksCount(), !1);
|
|
2065
2070
|
r.appendChild(t.holder), this.api.blocks.setBlockParent(t.id, this.tableBlockId), s.push(t.id);
|
|
2066
2071
|
}
|
|
2067
|
-
o.push(
|
|
2072
|
+
o.push(b({ blocks: i === null ? s : [...i, ...s] }, c));
|
|
2068
2073
|
}
|
|
2069
2074
|
this.stripPlaceholders(r);
|
|
2070
2075
|
}), n.push(o);
|
|
@@ -2089,7 +2094,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2089
2094
|
}
|
|
2090
2095
|
claimBlockForCell(e, t) {
|
|
2091
2096
|
var n, r;
|
|
2092
|
-
let i = e.querySelector(`[${
|
|
2097
|
+
let i = e.querySelector(`[${O}]`);
|
|
2093
2098
|
if (!i) return;
|
|
2094
2099
|
let a = this.api.blocks.getBlockIndex(t);
|
|
2095
2100
|
if (a === void 0) return;
|
|
@@ -2103,12 +2108,12 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2103
2108
|
}
|
|
2104
2109
|
findCellForAdjacentBlock(e) {
|
|
2105
2110
|
if (e < 0 || e >= this.api.blocks.getBlocksCount()) return null;
|
|
2106
|
-
let t = this.api.blocks.getBlockByIndex(e), n = t == null ? void 0 : t.holder.closest(`[${
|
|
2111
|
+
let t = this.api.blocks.getBlockByIndex(e), n = t == null ? void 0 : t.holder.closest(`[${E}]`);
|
|
2107
2112
|
return n && this.gridElement.contains(n) ? n : null;
|
|
2108
2113
|
}
|
|
2109
2114
|
ensureCellHasBlock(e) {
|
|
2110
2115
|
var t, n;
|
|
2111
|
-
let r = e.querySelector(`[${
|
|
2116
|
+
let r = e.querySelector(`[${O}]`);
|
|
2112
2117
|
r && r.querySelector("[data-blok-id]") === null && ((t = (n = this.api.blocks).transactWithoutCapture) == null || t.call(n, () => {
|
|
2113
2118
|
let t = this.api.blocks.insert("paragraph", { text: "" }, {}, this.api.blocks.getBlocksCount(), !0);
|
|
2114
2119
|
r.appendChild(t.holder), this.api.blocks.setBlockParent(t.id, this.tableBlockId), this.syncBlockToModel(e, t.id), this.stripPlaceholders(r);
|
|
@@ -2130,11 +2135,11 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2130
2135
|
n && this.model.addBlockToCell(n.row, n.col, t);
|
|
2131
2136
|
}
|
|
2132
2137
|
getCellPosition(e) {
|
|
2133
|
-
let t = e.closest(`[${
|
|
2138
|
+
let t = e.closest(`[${T}]`);
|
|
2134
2139
|
if (!t) return null;
|
|
2135
|
-
let n = Array.from(this.gridElement.querySelectorAll(`[${
|
|
2140
|
+
let n = Array.from(this.gridElement.querySelectorAll(`[${T}]`)).indexOf(t);
|
|
2136
2141
|
if (n < 0) return null;
|
|
2137
|
-
let r = Array.from(t.querySelectorAll(`[${
|
|
2142
|
+
let r = Array.from(t.querySelectorAll(`[${E}]`)).indexOf(e);
|
|
2138
2143
|
return r < 0 ? null : {
|
|
2139
2144
|
row: n,
|
|
2140
2145
|
col: r
|
|
@@ -2142,7 +2147,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2142
2147
|
}
|
|
2143
2148
|
recordRemovedBlockCell(e) {
|
|
2144
2149
|
if (e.index === void 0) return;
|
|
2145
|
-
let t = e.target.holder.closest(`[${
|
|
2150
|
+
let t = e.target.holder.closest(`[${E}]`);
|
|
2146
2151
|
t && this.gridElement.contains(t) && this.removedBlockCells.set(e.target.id, {
|
|
2147
2152
|
cell: t,
|
|
2148
2153
|
index: e.index
|
|
@@ -2190,7 +2195,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2190
2195
|
getBlockIdsFromCells(e) {
|
|
2191
2196
|
let t = [];
|
|
2192
2197
|
return Array.from(e).forEach((e) => {
|
|
2193
|
-
let n = e.querySelector(`[${
|
|
2198
|
+
let n = e.querySelector(`[${O}]`);
|
|
2194
2199
|
n && n.querySelectorAll("[data-blok-id]").forEach((e) => {
|
|
2195
2200
|
let n = e.getAttribute("data-blok-id");
|
|
2196
2201
|
n && t.push(n);
|
|
@@ -2203,7 +2208,7 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2203
2208
|
});
|
|
2204
2209
|
}
|
|
2205
2210
|
deleteAllBlocks() {
|
|
2206
|
-
let e = this.gridElement.querySelectorAll(`[${
|
|
2211
|
+
let e = this.gridElement.querySelectorAll(`[${E}]`), t = this.getBlockIdsFromCells(e);
|
|
2207
2212
|
this.deleteBlocks(t);
|
|
2208
2213
|
}
|
|
2209
2214
|
destroy() {
|
|
@@ -2220,106 +2225,111 @@ var gt = "outline-hidden py-[3px] mt-[2px] mb-px", _t = "outline-hidden pl-0.5 l
|
|
|
2220
2225
|
};
|
|
2221
2226
|
//#endregion
|
|
2222
2227
|
//#region src/components/shared/color-picker.ts
|
|
2223
|
-
function
|
|
2228
|
+
function rr() {
|
|
2229
|
+
var e, t;
|
|
2230
|
+
let n = document.documentElement.getAttribute("data-blok-theme");
|
|
2231
|
+
return n === "dark" ? de : n === "light" ? Xe : typeof window < "u" && (e = (t = window).matchMedia) != null && e.call(t, "(prefers-color-scheme: dark)").matches ? de : Xe;
|
|
2232
|
+
}
|
|
2233
|
+
function ir(e, t) {
|
|
2224
2234
|
if (e === t) return !0;
|
|
2225
|
-
let n =
|
|
2235
|
+
let n = Ke(e), r = Ke(t);
|
|
2226
2236
|
return n === null || r === null ? !1 : n[0] === r[0] && n[1] === r[1] && n[2] === r[2];
|
|
2227
2237
|
}
|
|
2228
|
-
var
|
|
2229
|
-
function
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
let r = document.createElement("button");
|
|
2241
|
-
r.setAttribute("data-blok-testid", `${i}-tab-${e.key}`), r.textContent = n.t(e.labelKey), r.addEventListener("click", () => {
|
|
2242
|
-
s.modeIndex = t, d(), p();
|
|
2243
|
-
}), u.push(r), l.appendChild(r);
|
|
2238
|
+
var ar = "var(--blok-swatch-neutral-bg)";
|
|
2239
|
+
function or(e) {
|
|
2240
|
+
let { i18n: t, modes: n, testIdPrefix: r, onColorSelect: i } = e, a = { activeColors: Object.fromEntries(n.map((e) => [e.key, null])) }, o = document.createElement("div");
|
|
2241
|
+
o.setAttribute("data-blok-testid", `${r}-picker`), o.className = "flex flex-col gap-3 p-2";
|
|
2242
|
+
let s = [];
|
|
2243
|
+
n.forEach((e) => {
|
|
2244
|
+
let n = document.createElement("div");
|
|
2245
|
+
n.setAttribute("data-blok-testid", `${r}-section-${e.key}`), n.className = "flex flex-col gap-1";
|
|
2246
|
+
let i = document.createElement("div");
|
|
2247
|
+
i.className = "text-xs font-medium text-text-primary/60 px-0.5", i.textContent = t.t(e.labelKey);
|
|
2248
|
+
let a = document.createElement("div");
|
|
2249
|
+
a.className = "grid gap-1", a.style.gridTemplateColumns = "repeat(5, 2.25rem)", s.push(a), n.appendChild(i), n.appendChild(a), o.appendChild(n);
|
|
2244
2250
|
});
|
|
2245
|
-
let
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
for (let
|
|
2253
|
-
let n = document.createElement("button"),
|
|
2254
|
-
n.setAttribute("data-blok-testid", `${
|
|
2255
|
-
a
|
|
2256
|
-
}),
|
|
2251
|
+
let c = (e) => {
|
|
2252
|
+
let o = s[e], c = n[e], l = rr();
|
|
2253
|
+
o.innerHTML = "";
|
|
2254
|
+
let u = a.activeColors[c.key], d = document.createElement("button"), f = u === null;
|
|
2255
|
+
d.setAttribute("data-blok-testid", `${r}-swatch-${c.key}-default`), d.className = x("w-9 h-9 rounded-md cursor-pointer border-none outline-hidden", "flex items-center justify-center text-sm font-semibold", "transition-[box-shadow,transform] ring-inset hover:ring-2 hover:ring-swatch-ring-hover active:scale-90", f && "ring-2 ring-swatch-ring-hover"), d.textContent = c.presetField === "text" ? "A" : "", c.presetField === "text" && (d.style.color = "var(--blok-text-primary)"), d.style.backgroundColor = ar, d.addEventListener("click", () => {
|
|
2256
|
+
i(null, c.key);
|
|
2257
|
+
}), De(d, `${t.t("tools.marker.default")} ${t.t(c.labelKey).toLowerCase()}`, { placement: "top" }), o.appendChild(d);
|
|
2258
|
+
for (let e of l) {
|
|
2259
|
+
let n = document.createElement("button"), a = c.presetField === "text" ? e.text : e.bg, s = u !== null && ir(a, u);
|
|
2260
|
+
n.setAttribute("data-blok-testid", `${r}-swatch-${c.key}-${e.name}`), n.className = x("w-9 h-9 rounded-md cursor-pointer border-none outline-hidden", "flex items-center justify-center text-sm font-semibold", "transition-[box-shadow,transform] ring-inset hover:ring-2 hover:ring-swatch-ring-hover active:scale-90", s && "ring-2 ring-swatch-ring-hover"), n.textContent = c.presetField === "text" ? "A" : "", c.presetField === "text" ? (n.style.color = e.text, n.style.backgroundColor = ar) : (n.style.color = l === de ? e.text : "#37352f", n.style.backgroundColor = e.bg), n.addEventListener("click", () => {
|
|
2261
|
+
i(a, c.key);
|
|
2262
|
+
}), De(n, `${t.t("tools.colorPicker.color." + e.name)} ${t.t(c.labelKey).toLowerCase()}`, { placement: "top" }), o.appendChild(n);
|
|
2257
2263
|
}
|
|
2258
|
-
},
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
element:
|
|
2264
|
+
}, l = () => {
|
|
2265
|
+
n.forEach((e, t) => c(t));
|
|
2266
|
+
};
|
|
2267
|
+
return l(), {
|
|
2268
|
+
element: o,
|
|
2263
2269
|
setActiveColor: (e, t) => {
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
n !== -1 && (s.modeIndex = n, d()), p();
|
|
2270
|
+
let r = n.findIndex((e) => e.key === t);
|
|
2271
|
+
r !== -1 && (a.activeColors[t] = e, c(r));
|
|
2267
2272
|
},
|
|
2268
2273
|
reset: () => {
|
|
2269
|
-
|
|
2274
|
+
for (let e of n) a.activeColors[e.key] = null;
|
|
2275
|
+
l();
|
|
2270
2276
|
}
|
|
2271
2277
|
};
|
|
2272
2278
|
}
|
|
2273
2279
|
//#endregion
|
|
2274
2280
|
//#region src/tools/table/table-cell-color-picker.ts
|
|
2275
|
-
var
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
})
|
|
2281
|
+
var sr = (e) => {
|
|
2282
|
+
let t = or({
|
|
2283
|
+
i18n: e.i18n,
|
|
2284
|
+
testIdPrefix: "cell-color",
|
|
2285
|
+
modes: [{
|
|
2286
|
+
key: "textColor",
|
|
2287
|
+
labelKey: "tools.marker.textColor",
|
|
2288
|
+
presetField: "text"
|
|
2289
|
+
}, {
|
|
2290
|
+
key: "backgroundColor",
|
|
2291
|
+
labelKey: "tools.marker.background",
|
|
2292
|
+
presetField: "bg"
|
|
2293
|
+
}],
|
|
2294
|
+
onColorSelect: (n, r) => {
|
|
2295
|
+
t.setActiveColor(n, r), e.onColorSelect(n, r);
|
|
2296
|
+
}
|
|
2297
|
+
});
|
|
2298
|
+
return { element: t.element };
|
|
2299
|
+
}, cr = (e, t, n) => {
|
|
2300
|
+
t === "col" ? Object.assign(e.style, { height: `${n}px` }) : Object.assign(e.style, { width: `${n}px` });
|
|
2301
|
+
}, lr = [
|
|
2292
2302
|
[2, 2],
|
|
2293
2303
|
[8, 2],
|
|
2294
2304
|
[2, 7],
|
|
2295
2305
|
[8, 7],
|
|
2296
2306
|
[2, 12],
|
|
2297
2307
|
[8, 12]
|
|
2298
|
-
],
|
|
2308
|
+
], ur = [
|
|
2299
2309
|
[2, 2],
|
|
2300
2310
|
[7, 2],
|
|
2301
2311
|
[12, 2],
|
|
2302
2312
|
[2, 8],
|
|
2303
2313
|
[7, 8],
|
|
2304
2314
|
[12, 8]
|
|
2305
|
-
],
|
|
2315
|
+
], dr = (e) => {
|
|
2306
2316
|
let t = document.createElementNS("http://www.w3.org/2000/svg", "svg"), n = e === "horizontal";
|
|
2307
2317
|
t.setAttribute("width", n ? "14" : "10"), t.setAttribute("height", n ? "10" : "14"), t.setAttribute("viewBox", n ? "0 0 14 10" : "0 0 10 14"), t.setAttribute("fill", "currentColor"), t.classList.add("opacity-0", "transition-opacity", "duration-150", "text-gray-400", "pointer-events-none");
|
|
2308
|
-
let r = n ?
|
|
2318
|
+
let r = n ? ur : lr;
|
|
2309
2319
|
for (let [e, n] of r) {
|
|
2310
2320
|
let r = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
2311
2321
|
r.setAttribute("cx", String(e)), r.setAttribute("cy", String(n)), r.setAttribute("r", "1.5"), t.appendChild(r);
|
|
2312
2322
|
}
|
|
2313
2323
|
return t;
|
|
2314
|
-
},
|
|
2324
|
+
}, fr = (e, t) => {
|
|
2315
2325
|
t === "col" ? Object.assign(e.style, { height: "16px" }) : Object.assign(e.style, { width: "16px" }), e.classList.add("bg-gray-200"), e.classList.remove("bg-gray-300");
|
|
2316
2326
|
let n = e.querySelector("svg");
|
|
2317
2327
|
n && (n.classList.remove("opacity-0"), n.classList.add("opacity-100"));
|
|
2318
|
-
},
|
|
2319
|
-
|
|
2328
|
+
}, pr = (e, t, n) => {
|
|
2329
|
+
cr(e, t, n), e.classList.remove("bg-gray-200"), e.classList.add("bg-gray-300");
|
|
2320
2330
|
let r = e.querySelector("svg");
|
|
2321
2331
|
r && (r.classList.add("opacity-0"), r.classList.remove("opacity-100"));
|
|
2322
|
-
},
|
|
2332
|
+
}, mr = "data-blok-table-cell-selected", hr = "2px solid #3b82f6", gr = "data-blok-table-selection-pill", _r = 16, vr = 20, yr = 4, br = [
|
|
2323
2333
|
"absolute",
|
|
2324
2334
|
"z-3",
|
|
2325
2335
|
"rounded-sm",
|
|
@@ -2332,7 +2342,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2332
2342
|
"overflow-hidden",
|
|
2333
2343
|
"cursor-pointer",
|
|
2334
2344
|
"bg-blue-500"
|
|
2335
|
-
],
|
|
2345
|
+
], xr = (e) => e.style.userSelect === "none", Sr = class {
|
|
2336
2346
|
constructor(e) {
|
|
2337
2347
|
this.anchorCell = null, this.extentCell = null, this.isSelecting = !1, this.hasSelection = !1, this.selectedCells = [], this.overlay = null, this.pill = null, this.pillPopover = null, this.resizeObserver = null, this.lastPaintedRange = null, this.grid = e.grid, this.rectangleSelection = e.rectangleSelection, this.onSelectionActiveChange = e.onSelectionActiveChange, this.onClearContent = e.onClearContent, this.onCopy = e.onCopy, this.onCut = e.onCut, this.onCopyViaButton = e.onCopyViaButton, this.onColorChange = e.onColorChange, this.onSelectionRangeChange = e.onSelectionRangeChange, this.onPointerDragActiveChange = e.onPointerDragActiveChange, this.isPopoverOpen = e.isPopoverOpen, this.i18n = e.i18n, this.grid.style.position = "relative", this.boundPointerDown = this.handlePointerDown.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundClearSelection = this.handleClearSelection.bind(this), this.boundCancelRectangle = this.handleCancelRectangle.bind(this), this.boundKeyDown = this.handleKeyDown.bind(this), this.boundCopyHandler = this.handleCopy.bind(this), this.boundCutHandler = this.handleCut.bind(this), this.boundPreventDragStart = this.handleDragStart.bind(this), this.grid.addEventListener("pointerdown", this.boundPointerDown), this.grid.addEventListener("dragstart", this.boundPreventDragStart), document.addEventListener("keydown", this.boundKeyDown), document.addEventListener("copy", this.boundCopyHandler), document.addEventListener("cut", this.boundCutHandler);
|
|
2338
2348
|
}
|
|
@@ -2349,7 +2359,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2349
2359
|
r !== 0 && this.showProgrammaticSelection(e, 0, e, r - 1);
|
|
2350
2360
|
}
|
|
2351
2361
|
selectColumn(e) {
|
|
2352
|
-
let t = this.grid.querySelectorAll(`[${
|
|
2362
|
+
let t = this.grid.querySelectorAll(`[${T}]`).length;
|
|
2353
2363
|
t !== 0 && this.showProgrammaticSelection(0, e, t - 1, e);
|
|
2354
2364
|
}
|
|
2355
2365
|
clearActiveSelection() {
|
|
@@ -2366,9 +2376,9 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2366
2376
|
}
|
|
2367
2377
|
handlePointerDown(e) {
|
|
2368
2378
|
var t;
|
|
2369
|
-
if (
|
|
2379
|
+
if (xr(this.grid) || e.button !== 0) return;
|
|
2370
2380
|
let n = e.target;
|
|
2371
|
-
if (n.closest("[data-blok-table-grip]") || n.closest("[data-blok-table-resize]") || n.closest(`[${
|
|
2381
|
+
if (n.closest("[data-blok-table-grip]") || n.closest("[data-blok-table-resize]") || n.closest(`[${gr}]`)) return;
|
|
2372
2382
|
let r = this.resolveCellCoord(n);
|
|
2373
2383
|
r && (this.hasSelection && this.lastPaintedRange !== null && this.lastPaintedRange.minRow === r.row && this.lastPaintedRange.maxRow === r.row && this.lastPaintedRange.minCol === r.col && this.lastPaintedRange.maxCol === r.col ? document.removeEventListener("pointerdown", this.boundClearSelection) : this.hasSelection && this.clearSelection(), this.anchorCell = r, this.isSelecting = !1, (t = this.onPointerDragActiveChange) == null || t.call(this, !0), document.addEventListener("mousemove", this.boundCancelRectangle, !0), document.addEventListener("pointermove", this.boundPointerMove), document.addEventListener("pointerup", this.boundPointerUp), document.addEventListener("pointercancel", this.boundPointerUp));
|
|
2374
2384
|
}
|
|
@@ -2410,7 +2420,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2410
2420
|
}
|
|
2411
2421
|
handleClearSelection(e) {
|
|
2412
2422
|
let t = e.target;
|
|
2413
|
-
t instanceof HTMLElement && t.closest(`[${
|
|
2423
|
+
t instanceof HTMLElement && t.closest(`[${gr}]`) || t instanceof HTMLElement && t.closest("[data-blok-popover-opened]") !== null || (this.pillPopover !== null && this.destroyPillPopover(), document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection());
|
|
2414
2424
|
}
|
|
2415
2425
|
handleKeyDown(e) {
|
|
2416
2426
|
var t;
|
|
@@ -2433,7 +2443,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2433
2443
|
}
|
|
2434
2444
|
restoreModifiedCells() {
|
|
2435
2445
|
this.destroyPillPopover(), this.disconnectResizeObserver(), this.selectedCells.forEach((e) => {
|
|
2436
|
-
e.removeAttribute(
|
|
2446
|
+
e.removeAttribute(mr);
|
|
2437
2447
|
}), this.pill && (this.pill.remove(), this.pill = null), this.overlay && (this.overlay.remove(), this.overlay = null), this.selectedCells = [];
|
|
2438
2448
|
}
|
|
2439
2449
|
showProgrammaticSelection(e, t, n, r) {
|
|
@@ -2454,7 +2464,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2454
2464
|
var e, t;
|
|
2455
2465
|
if (!this.anchorCell || !this.extentCell) return;
|
|
2456
2466
|
this.selectedCells.forEach((e) => {
|
|
2457
|
-
e.removeAttribute(
|
|
2467
|
+
e.removeAttribute(mr);
|
|
2458
2468
|
}), this.selectedCells = [];
|
|
2459
2469
|
let n = Math.min(this.anchorCell.row, this.extentCell.row), r = Math.max(this.anchorCell.row, this.extentCell.row), i = Math.min(this.anchorCell.col, this.extentCell.col), a = Math.max(this.anchorCell.col, this.extentCell.col);
|
|
2460
2470
|
this.lastPaintedRange = {
|
|
@@ -2463,20 +2473,20 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2463
2473
|
minCol: i,
|
|
2464
2474
|
maxCol: a
|
|
2465
2475
|
};
|
|
2466
|
-
let o = this.grid.querySelectorAll(`[${
|
|
2476
|
+
let o = this.grid.querySelectorAll(`[${T}]`);
|
|
2467
2477
|
this.selectedCells = this.collectCellsInRange(o, n, r, i, a), this.selectedCells.forEach((e) => {
|
|
2468
|
-
e.setAttribute(
|
|
2478
|
+
e.setAttribute(mr, "");
|
|
2469
2479
|
});
|
|
2470
|
-
let s = (e = o[n]) == null ? void 0 : e.querySelectorAll(`[${
|
|
2480
|
+
let s = (e = o[n]) == null ? void 0 : e.querySelectorAll(`[${E}]`)[i], c = (t = o[r]) == null ? void 0 : t.querySelectorAll(`[${E}]`)[a];
|
|
2471
2481
|
if (!s || !c) return;
|
|
2472
2482
|
let l = this.grid.getBoundingClientRect(), u = s.getBoundingClientRect(), d = c.getBoundingClientRect(), f = getComputedStyle(this.grid), p = parseFloat(f.borderTopWidth) || 0, m = parseFloat(f.borderLeftWidth) || 0, h = d.right - u.left + 1, g = d.bottom - u.top + 1, _ = u.top - l.top - p - 1, ee = u.left - l.left - m - 1;
|
|
2473
|
-
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border =
|
|
2483
|
+
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = hr, 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 = `${_}px`, this.overlay.style.left = `${ee}px`, this.overlay.style.width = `${h}px`, this.overlay.style.height = `${g}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${ee + h - 1}px`, this.pill.style.top = `${_ + g / 2}px`, this.observeCellResizes();
|
|
2474
2484
|
}
|
|
2475
2485
|
repositionOverlay() {
|
|
2476
2486
|
var e, t;
|
|
2477
2487
|
let n = this.lastPaintedRange;
|
|
2478
2488
|
if (!n || !this.overlay) return;
|
|
2479
|
-
let r = this.grid.querySelectorAll(`[${
|
|
2489
|
+
let r = this.grid.querySelectorAll(`[${T}]`), i = (e = r[n.minRow]) == null ? void 0 : e.querySelectorAll(`[${E}]`)[n.minCol], a = (t = r[n.maxRow]) == null ? void 0 : t.querySelectorAll(`[${E}]`)[n.maxCol];
|
|
2480
2490
|
if (!i || !a) return;
|
|
2481
2491
|
let o = this.grid.getBoundingClientRect(), s = i.getBoundingClientRect(), c = a.getBoundingClientRect(), l = getComputedStyle(this.grid), u = parseFloat(l.borderTopWidth) || 0, d = parseFloat(l.borderLeftWidth) || 0, f = c.right - s.left + 1, p = c.bottom - s.top + 1, m = s.top - o.top - u - 1, h = s.left - o.left - d - 1;
|
|
2482
2492
|
this.overlay.style.top = `${m}px`, this.overlay.style.left = `${h}px`, this.overlay.style.width = `${f}px`, this.overlay.style.height = `${p}px`, this.pill && (this.pill.style.left = `${h + f - 1}px`, this.pill.style.top = `${m + p / 2}px`);
|
|
@@ -2494,8 +2504,8 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2494
2504
|
}
|
|
2495
2505
|
createPill() {
|
|
2496
2506
|
let e = document.createElement("div");
|
|
2497
|
-
e.setAttribute(
|
|
2498
|
-
let t =
|
|
2507
|
+
e.setAttribute(gr, ""), e.setAttribute("contenteditable", "false"), e.className = x(br), e.style.width = `${yr}px`, e.style.height = `${vr}px`, e.style.pointerEvents = "auto", e.style.transform = "translate(-50%, -50%)", e.style.outline = "2px solid var(--blok-table-grip-outline, transparent)";
|
|
2508
|
+
let t = dr("vertical");
|
|
2499
2509
|
return t.classList.remove("text-gray-400"), t.classList.add("text-white"), e.appendChild(t), e.addEventListener("mouseenter", () => {
|
|
2500
2510
|
this.pillPopover === null && this.expandPill();
|
|
2501
2511
|
}), e.addEventListener("mouseleave", () => {
|
|
@@ -2507,9 +2517,9 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2507
2517
|
openPillPopover() {
|
|
2508
2518
|
if (this.destroyPillPopover(), !this.pill) return;
|
|
2509
2519
|
this.expandPill();
|
|
2510
|
-
let e =
|
|
2520
|
+
let e = Qe === "Meta" ? "⌘C" : "Ctrl+C", n = [];
|
|
2511
2521
|
if (this.onColorChange !== void 0) {
|
|
2512
|
-
let { element: e } =
|
|
2522
|
+
let { element: e } = sr({
|
|
2513
2523
|
i18n: this.i18n,
|
|
2514
2524
|
onColorSelect: (e, t) => {
|
|
2515
2525
|
var n;
|
|
@@ -2517,7 +2527,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2517
2527
|
}
|
|
2518
2528
|
});
|
|
2519
2529
|
n.push({
|
|
2520
|
-
icon:
|
|
2530
|
+
icon: se,
|
|
2521
2531
|
title: this.i18n.t("tools.table.cellColor"),
|
|
2522
2532
|
name: "cellColor",
|
|
2523
2533
|
children: {
|
|
@@ -2525,16 +2535,15 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2525
2535
|
type: _.Html,
|
|
2526
2536
|
element: e
|
|
2527
2537
|
}],
|
|
2528
|
-
isFlippable: !1
|
|
2529
|
-
width: "12.5rem"
|
|
2538
|
+
isFlippable: !1
|
|
2530
2539
|
}
|
|
2531
2540
|
});
|
|
2532
2541
|
}
|
|
2533
|
-
this.pillPopover = new
|
|
2542
|
+
this.pillPopover = new ve({
|
|
2534
2543
|
items: [
|
|
2535
2544
|
...n,
|
|
2536
2545
|
{
|
|
2537
|
-
icon:
|
|
2546
|
+
icon: Ee,
|
|
2538
2547
|
title: this.i18n.t("tools.table.copySelection"),
|
|
2539
2548
|
secondaryLabel: e,
|
|
2540
2549
|
closeOnActivate: !0,
|
|
@@ -2556,19 +2565,19 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2556
2565
|
],
|
|
2557
2566
|
trigger: this.pill,
|
|
2558
2567
|
flippable: !0
|
|
2559
|
-
}), this.pillPopover.on(
|
|
2568
|
+
}), this.pillPopover.on(Ge.Closed, () => {
|
|
2560
2569
|
this.pillPopover !== null && (this.destroyPillPopover(), this.collapsePill());
|
|
2561
2570
|
}), this.pillPopover.show();
|
|
2562
2571
|
}
|
|
2563
2572
|
expandPill() {
|
|
2564
2573
|
if (!this.pill) return;
|
|
2565
|
-
this.pill.style.width = `${
|
|
2574
|
+
this.pill.style.width = `${_r}px`;
|
|
2566
2575
|
let e = this.pill.querySelector("svg");
|
|
2567
2576
|
e && (e.classList.remove("opacity-0"), e.classList.add("opacity-100"));
|
|
2568
2577
|
}
|
|
2569
2578
|
collapsePill() {
|
|
2570
2579
|
if (!this.pill) return;
|
|
2571
|
-
this.pill.style.width = `${
|
|
2580
|
+
this.pill.style.width = `${yr}px`;
|
|
2572
2581
|
let e = this.pill.querySelector("svg");
|
|
2573
2582
|
e && (e.classList.add("opacity-0"), e.classList.remove("opacity-100"));
|
|
2574
2583
|
}
|
|
@@ -2579,13 +2588,13 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2579
2588
|
}
|
|
2580
2589
|
}
|
|
2581
2590
|
resolveCellCoord(e) {
|
|
2582
|
-
let t = e.closest(`[${
|
|
2591
|
+
let t = e.closest(`[${E}]`);
|
|
2583
2592
|
if (!t) return null;
|
|
2584
|
-
let n = t.closest(`[${
|
|
2593
|
+
let n = t.closest(`[${T}]`);
|
|
2585
2594
|
if (!n || !this.grid.contains(n)) return null;
|
|
2586
|
-
let r = Array.from(this.grid.querySelectorAll(`[${
|
|
2595
|
+
let r = Array.from(this.grid.querySelectorAll(`[${T}]`)).indexOf(n);
|
|
2587
2596
|
if (r < 0) return null;
|
|
2588
|
-
let i = Array.from(n.querySelectorAll(`[${
|
|
2597
|
+
let i = Array.from(n.querySelectorAll(`[${E}]`)).indexOf(t);
|
|
2589
2598
|
return i < 0 ? null : {
|
|
2590
2599
|
row: r,
|
|
2591
2600
|
col: i
|
|
@@ -2594,7 +2603,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2594
2603
|
clampExtentToEdge(e) {
|
|
2595
2604
|
var t, n, r, i, a, o;
|
|
2596
2605
|
if (!this.anchorCell || !this.isSelecting) return;
|
|
2597
|
-
let s = this.grid.getBoundingClientRect(), c = this.grid.querySelectorAll(`[${
|
|
2606
|
+
let s = this.grid.getBoundingClientRect(), c = this.grid.querySelectorAll(`[${T}]`), l = c.length, u = (t = (n = c[0]) == null ? void 0 : n.querySelectorAll("[data-blok-table-cell]").length) == null ? 0 : t;
|
|
2598
2607
|
if (l === 0 || u === 0) return;
|
|
2599
2608
|
let d = {
|
|
2600
2609
|
row: this.clampAxis(e.clientY, s.top, s.bottom, l, (r = (i = this.extentCell) == null ? void 0 : i.row) == null ? this.anchorCell.row : r),
|
|
@@ -2604,106 +2613,106 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2604
2613
|
}
|
|
2605
2614
|
collectCellsInRange(e, t, n, r, i) {
|
|
2606
2615
|
return Array.from(e).slice(t, n + 1).flatMap((e) => {
|
|
2607
|
-
let t = e.querySelectorAll(`[${
|
|
2616
|
+
let t = e.querySelectorAll(`[${E}]`);
|
|
2608
2617
|
return Array.from(t).slice(r, i + 1).filter((e) => e instanceof HTMLElement);
|
|
2609
2618
|
});
|
|
2610
2619
|
}
|
|
2611
2620
|
clampAxis(e, t, n, r, i) {
|
|
2612
2621
|
return e < t ? 0 : e > n ? r - 1 : i;
|
|
2613
2622
|
}
|
|
2614
|
-
},
|
|
2615
|
-
let t = e.querySelector(`[${
|
|
2623
|
+
}, k = (e) => {
|
|
2624
|
+
let t = e.querySelector(`[${T}]`);
|
|
2616
2625
|
if (!t) return [];
|
|
2617
|
-
let n = t.querySelectorAll(`[${
|
|
2626
|
+
let n = t.querySelectorAll(`[${E}]`);
|
|
2618
2627
|
return Array.from(n).map((e) => e.getBoundingClientRect().width);
|
|
2619
|
-
},
|
|
2628
|
+
}, A = (e, t) => {
|
|
2620
2629
|
let n = t.reduce((e, t) => e + t, 0), r = e;
|
|
2621
|
-
r.style.width = `${n + 1}px`, e.querySelectorAll(`[${
|
|
2622
|
-
e.querySelectorAll(`[${
|
|
2630
|
+
r.style.width = `${n + 1}px`, e.querySelectorAll(`[${T}]`).forEach((e) => {
|
|
2631
|
+
e.querySelectorAll(`[${E}]`).forEach((e, n) => {
|
|
2623
2632
|
if (n < t.length) {
|
|
2624
2633
|
let r = e;
|
|
2625
2634
|
r.style.width = `${t[n]}px`;
|
|
2626
2635
|
}
|
|
2627
2636
|
});
|
|
2628
2637
|
});
|
|
2629
|
-
},
|
|
2630
|
-
let n = Array.from(e.querySelectorAll(`[${
|
|
2638
|
+
}, Cr = (e, t) => {
|
|
2639
|
+
let n = Array.from(e.querySelectorAll(`[${T}]`)), r = n.findIndex((e) => Array.from(e.querySelectorAll(`[${E}]`)).includes(t));
|
|
2631
2640
|
return r === -1 ? null : {
|
|
2632
2641
|
row: r,
|
|
2633
|
-
col: Array.from(n[r].querySelectorAll(`[${
|
|
2642
|
+
col: Array.from(n[r].querySelectorAll(`[${E}]`)).indexOf(t)
|
|
2634
2643
|
};
|
|
2635
|
-
},
|
|
2644
|
+
}, wr = (e) => {
|
|
2636
2645
|
var t;
|
|
2637
|
-
let n = e.querySelector(`[${
|
|
2646
|
+
let n = e.querySelector(`[${O}]`);
|
|
2638
2647
|
return n ? ((t = n.textContent) == null ? "" : t).trim().length === 0 : !0;
|
|
2639
|
-
},
|
|
2640
|
-
let n = e.querySelectorAll(`[${
|
|
2648
|
+
}, Tr = (e, t) => {
|
|
2649
|
+
let n = e.querySelectorAll(`[${T}]`)[t];
|
|
2641
2650
|
if (!n) return !0;
|
|
2642
|
-
let r = n.querySelectorAll(`[${
|
|
2643
|
-
return Array.from(r).every((e) =>
|
|
2644
|
-
},
|
|
2645
|
-
let n = e.querySelectorAll(`[${
|
|
2651
|
+
let r = n.querySelectorAll(`[${E}]`);
|
|
2652
|
+
return Array.from(r).every((e) => wr(e));
|
|
2653
|
+
}, Er = (e, t) => {
|
|
2654
|
+
let n = e.querySelectorAll(`[${T}]`);
|
|
2646
2655
|
return Array.from(n).every((e) => {
|
|
2647
|
-
let n = e.querySelectorAll(`[${
|
|
2648
|
-
return !n ||
|
|
2656
|
+
let n = e.querySelectorAll(`[${E}]`)[t];
|
|
2657
|
+
return !n || wr(n);
|
|
2649
2658
|
});
|
|
2650
|
-
},
|
|
2651
|
-
let t = e.querySelectorAll(`[${
|
|
2659
|
+
}, Dr = (e) => {
|
|
2660
|
+
let t = e.querySelectorAll(`[${T}]`), n = t[0];
|
|
2652
2661
|
if (!n) return;
|
|
2653
|
-
let r = n.querySelectorAll(`[${
|
|
2662
|
+
let r = n.querySelectorAll(`[${E}]`), i = Array.from(r).reduce((e, t) => e + (parseFloat(t.style.width) || 0), 0);
|
|
2654
2663
|
if (i <= 0) return;
|
|
2655
2664
|
let a = 100 / i;
|
|
2656
2665
|
t.forEach((e) => {
|
|
2657
|
-
e.querySelectorAll(`[${
|
|
2666
|
+
e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
2658
2667
|
let t = e, n = parseFloat(t.style.width) || 0;
|
|
2659
2668
|
t.style.width = `${Math.round(n * a * 100) / 100}%`;
|
|
2660
2669
|
});
|
|
2661
2670
|
});
|
|
2662
|
-
},
|
|
2671
|
+
}, Or = (e, t, n) => {
|
|
2663
2672
|
if (!e) return e;
|
|
2664
2673
|
let r = [...e], [i] = r.splice(t, 1);
|
|
2665
2674
|
return r.splice(n, 0, i), r;
|
|
2666
|
-
},
|
|
2675
|
+
}, kr = (e, t) => {
|
|
2667
2676
|
if (!e) return e;
|
|
2668
2677
|
let n = [...e];
|
|
2669
2678
|
return n.splice(t, 1), n.length > 0 ? n : void 0;
|
|
2670
|
-
},
|
|
2671
|
-
let a = n == null ?
|
|
2679
|
+
}, Ar = (e, t, n, r, i) => {
|
|
2680
|
+
let a = n == null ? k(e) : n, o = r === void 0 ? j(a) : Math.round(r / 2 * 100) / 100;
|
|
2672
2681
|
i.addColumn(e, t, a, o);
|
|
2673
2682
|
let s = [...a];
|
|
2674
2683
|
return s.splice(t, 0, o), s;
|
|
2675
|
-
},
|
|
2684
|
+
}, j = (e) => Math.round(e.reduce((e, t) => e + t, 0) / e.length / 2 * 100) / 100, jr = (e) => e.length === 0 ? 0 : Math.round(e.reduce((e, t) => e + t, 0) / e.length * 100) / 100, Mr = (e, t, n) => {
|
|
2676
2685
|
var r;
|
|
2677
2686
|
if (!e) return [];
|
|
2678
|
-
let i = e.querySelectorAll(`[${
|
|
2687
|
+
let i = e.querySelectorAll(`[${T}]`)[n];
|
|
2679
2688
|
return i ? (r = t == null ? void 0 : t.getBlockIdsFromCells(i.querySelectorAll("[data-blok-table-cell]"))) == null ? [] : r : [];
|
|
2680
|
-
},
|
|
2689
|
+
}, Nr = (e, t, n) => {
|
|
2681
2690
|
var r;
|
|
2682
2691
|
if (!e) return [];
|
|
2683
|
-
let i = e.querySelectorAll(`[${
|
|
2692
|
+
let i = e.querySelectorAll(`[${T}]`), a = [];
|
|
2684
2693
|
return i.forEach((e) => {
|
|
2685
|
-
let t = e.querySelectorAll(`[${
|
|
2694
|
+
let t = e.querySelectorAll(`[${E}]`);
|
|
2686
2695
|
n < t.length && a.push(t[n]);
|
|
2687
2696
|
}), (r = t == null ? void 0 : t.getBlockIdsFromCells(a)) == null ? [] : r;
|
|
2688
|
-
},
|
|
2689
|
-
e.querySelectorAll(`[${
|
|
2697
|
+
}, M = (e, t) => {
|
|
2698
|
+
e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
2690
2699
|
t == null || t.ensureCellHasBlock(e);
|
|
2691
2700
|
});
|
|
2692
|
-
},
|
|
2693
|
-
let i = e.querySelectorAll(`[${
|
|
2701
|
+
}, Pr = (e, t, n, r) => {
|
|
2702
|
+
let i = e.querySelectorAll(`[${T}]`);
|
|
2694
2703
|
t.forEach((e, t) => {
|
|
2695
2704
|
let r = i[t];
|
|
2696
2705
|
if (!r) return;
|
|
2697
|
-
let a = r.querySelectorAll(`[${
|
|
2706
|
+
let a = r.querySelectorAll(`[${E}]`);
|
|
2698
2707
|
e.forEach((e, t) => {
|
|
2699
2708
|
var r;
|
|
2700
2709
|
let i = a[t];
|
|
2701
2710
|
if (!i) return;
|
|
2702
|
-
let o = i.querySelector(`[${
|
|
2711
|
+
let o = i.querySelector(`[${O}]`);
|
|
2703
2712
|
if (!o) return;
|
|
2704
2713
|
let s = o.querySelectorAll("[data-blok-id]").length > 0;
|
|
2705
|
-
if (!(!
|
|
2706
|
-
if (!
|
|
2714
|
+
if (!(!D(e) && s)) {
|
|
2715
|
+
if (!D(e)) {
|
|
2707
2716
|
o.innerHTML = e;
|
|
2708
2717
|
return;
|
|
2709
2718
|
}
|
|
@@ -2722,7 +2731,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2722
2731
|
}
|
|
2723
2732
|
});
|
|
2724
2733
|
});
|
|
2725
|
-
},
|
|
2734
|
+
}, Fr = (e, t) => {
|
|
2726
2735
|
var n, r, i, a, o, s, c;
|
|
2727
2736
|
if (!(typeof e == "object" && e && "content" in e)) {
|
|
2728
2737
|
var l, u;
|
|
@@ -2742,40 +2751,40 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2742
2751
|
colWidths: m,
|
|
2743
2752
|
initialColWidth: d.initialColWidth
|
|
2744
2753
|
};
|
|
2745
|
-
},
|
|
2754
|
+
}, Ir = (e, t) => {
|
|
2746
2755
|
e.addEventListener("keydown", (n) => {
|
|
2747
|
-
let r = n.target.closest(`[${
|
|
2756
|
+
let r = n.target.closest(`[${E}]`);
|
|
2748
2757
|
if (!r) return;
|
|
2749
|
-
let i =
|
|
2758
|
+
let i = Cr(e, r);
|
|
2750
2759
|
i && (t == null || t.handleKeyDown(n, i));
|
|
2751
2760
|
});
|
|
2752
|
-
},
|
|
2753
|
-
e == null || e.classList.add(...
|
|
2754
|
-
},
|
|
2761
|
+
}, Lr = ["overflow-x-auto", "overflow-y-hidden"], Rr = (e) => {
|
|
2762
|
+
e == null || e.classList.add(...Lr);
|
|
2763
|
+
}, N = (e, t) => {
|
|
2755
2764
|
if (!e) return;
|
|
2756
|
-
let n = e.querySelectorAll(`[${
|
|
2765
|
+
let n = e.querySelectorAll(`[${T}]`);
|
|
2757
2766
|
n.forEach((e) => {
|
|
2758
2767
|
e.removeAttribute("data-blok-table-heading");
|
|
2759
2768
|
}), t && n.length > 0 && n[0].setAttribute("data-blok-table-heading", "");
|
|
2760
|
-
},
|
|
2761
|
-
let n = e.querySelectorAll(`[${
|
|
2769
|
+
}, P = (e, t) => {
|
|
2770
|
+
let n = e.querySelectorAll(`[${T}]`);
|
|
2762
2771
|
t.forEach((e, t) => {
|
|
2763
2772
|
if (t >= n.length) return;
|
|
2764
|
-
let r = n[t].querySelectorAll(`[${
|
|
2773
|
+
let r = n[t].querySelectorAll(`[${E}]`);
|
|
2765
2774
|
e.forEach((e, t) => {
|
|
2766
2775
|
if (t >= r.length) return;
|
|
2767
2776
|
let n = r[t];
|
|
2768
|
-
|
|
2777
|
+
D(e) && e.color ? n.style.backgroundColor = e.color : n.style.backgroundColor = "", D(e) && e.textColor ? n.style.color = e.textColor : n.style.color = "";
|
|
2769
2778
|
});
|
|
2770
2779
|
});
|
|
2771
|
-
},
|
|
2772
|
-
e && (e.querySelectorAll(`[${
|
|
2780
|
+
}, F = (e, t) => {
|
|
2781
|
+
e && (e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
2773
2782
|
e.removeAttribute("data-blok-table-heading-col");
|
|
2774
|
-
}), t && e.querySelectorAll(`[${
|
|
2775
|
-
let t = e.querySelector(`[${
|
|
2783
|
+
}), t && e.querySelectorAll(`[${T}]`).forEach((e) => {
|
|
2784
|
+
let t = e.querySelector(`[${E}]`);
|
|
2776
2785
|
t && t.setAttribute("data-blok-table-heading-col", "");
|
|
2777
2786
|
}));
|
|
2778
|
-
},
|
|
2787
|
+
}, I = (e) => !!(/^#[0-9a-f]{3,4}$/i.test(e) || /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e) || /^rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*(,\s*[\d.]+\s*)?\)$/i.test(e) || /^hsla?\(\s*[\d.]+\s*,\s*[\d.]+%\s*,\s*[\d.]+%\s*(,\s*[\d.]+\s*)?\)$/i.test(e) || e === "transparent"), zr = class {
|
|
2779
2788
|
constructor(e) {
|
|
2780
2789
|
var t, n, r;
|
|
2781
2790
|
this.withHeadingsValue = (t = e == null ? void 0 : e.withHeadings) == null ? !1 : t, this.withHeadingColumnValue = (n = e == null ? void 0 : e.withHeadingColumn) == null ? !1 : n, this.stretchedValue = (r = e == null ? void 0 : e.stretched) == null ? !1 : r, this.colWidthsValue = e != null && e.colWidths ? [...e.colWidths] : void 0, this.initialColWidthValue = e == null ? void 0 : e.initialColWidth, this.contentGrid = this.normalizeContent(e == null ? void 0 : e.content), this.blockCellMap = /* @__PURE__ */ new Map(), this.rebuildBlockCellMap();
|
|
@@ -2848,13 +2857,13 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2848
2857
|
return this.isInBounds(e, t) ? [...this.contentGrid[e][t].blocks] : [];
|
|
2849
2858
|
}
|
|
2850
2859
|
setCellColor(e, t, n) {
|
|
2851
|
-
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].color :
|
|
2860
|
+
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].color : I(n) && (this.contentGrid[e][t].color = n));
|
|
2852
2861
|
}
|
|
2853
2862
|
getCellColor(e, t) {
|
|
2854
2863
|
if (this.isInBounds(e, t)) return this.contentGrid[e][t].color;
|
|
2855
2864
|
}
|
|
2856
2865
|
setCellTextColor(e, t, n) {
|
|
2857
|
-
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].textColor :
|
|
2866
|
+
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].textColor : I(n) && (this.contentGrid[e][t].textColor = n));
|
|
2858
2867
|
}
|
|
2859
2868
|
getCellTextColor(e, t) {
|
|
2860
2869
|
if (this.isInBounds(e, t)) return this.contentGrid[e][t].textColor;
|
|
@@ -2992,9 +3001,9 @@ var Qn = (e) => ({ element: Zn({
|
|
|
2992
3001
|
return !e || !Array.isArray(e) ? [] : e.map((e) => (e == null ? [] : e).map((e) => this.normalizeCell(e)));
|
|
2993
3002
|
}
|
|
2994
3003
|
normalizeCell(e) {
|
|
2995
|
-
if (
|
|
3004
|
+
if (D(e)) {
|
|
2996
3005
|
let t = { blocks: [...e.blocks] };
|
|
2997
|
-
return e.color !== void 0 &&
|
|
3006
|
+
return e.color !== void 0 && I(e.color) && (t.color = e.color), e.textColor !== void 0 && I(e.textColor) && (t.textColor = e.textColor), t;
|
|
2998
3007
|
}
|
|
2999
3008
|
return { blocks: [] };
|
|
3000
3009
|
}
|
|
@@ -3027,7 +3036,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3027
3036
|
for (let n of this.contentGrid) e < n.length && t.push(...n[e].blocks);
|
|
3028
3037
|
return t;
|
|
3029
3038
|
}
|
|
3030
|
-
},
|
|
3039
|
+
}, Br = "data-blok-table-resize", Vr = "data-blok-table-cell", Hr = "data-blok-table-row", Ur = 50, Wr = 16, Gr = class {
|
|
3031
3040
|
get enabled() {
|
|
3032
3041
|
return this._enabled;
|
|
3033
3042
|
}
|
|
@@ -3054,7 +3063,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3054
3063
|
}
|
|
3055
3064
|
createHandle(e) {
|
|
3056
3065
|
let t = document.createElement("div"), n = this.getHandleLeftPx(e);
|
|
3057
|
-
return t.setAttribute(
|
|
3066
|
+
return t.setAttribute(Br, ""), t.setAttribute("data-col", String(e)), t.style.position = "absolute", t.style.top = "-1px", t.style.bottom = "0px", t.style.width = `${Wr}px`, t.style.left = `${n - Wr / 2}px`, t.style.cursor = "col-resize", t.style.zIndex = "2", t.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", t.style.opacity = "0", t.style.transition = "opacity 150ms ease", t.setAttribute("contenteditable", "false"), t.addEventListener("mouseenter", () => {
|
|
3058
3067
|
this.isDragging || (t.style.opacity = "1");
|
|
3059
3068
|
}), t.addEventListener("mouseleave", () => {
|
|
3060
3069
|
this.isDragging || (t.style.opacity = "0");
|
|
@@ -3066,14 +3075,14 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3066
3075
|
updateHandlePositions() {
|
|
3067
3076
|
this.handles.forEach((e, t) => {
|
|
3068
3077
|
let n = this.getHandleLeftPx(t), r = e;
|
|
3069
|
-
r.style.left = `${n -
|
|
3078
|
+
r.style.left = `${n - Wr / 2}px`;
|
|
3070
3079
|
});
|
|
3071
3080
|
}
|
|
3072
3081
|
onPointerDown(e) {
|
|
3073
3082
|
var t;
|
|
3074
3083
|
if (!this._enabled) return;
|
|
3075
3084
|
let n = e.target;
|
|
3076
|
-
if (!n.hasAttribute(
|
|
3085
|
+
if (!n.hasAttribute(Br)) return;
|
|
3077
3086
|
e.preventDefault(), this.needsInitialApply && (this.applyWidths(), this.updateHandlePositions(), this.needsInitialApply = !1);
|
|
3078
3087
|
let r = n.getAttribute("data-col");
|
|
3079
3088
|
r !== null && (this.dragColIndex = Number(r), this.isDragging = !0, this.dragStartX = e.clientX, this.startColWidth = this.colWidths[this.dragColIndex], this.dragRowCells = this.resolveRowCells(), (t = this.onDragStart) == null || t.call(this), this.gridEl.style.userSelect = "none", n.style.opacity = "1", n.setPointerCapture && n.setPointerCapture(e.pointerId), document.addEventListener("pointermove", this.boundPointerMove), document.addEventListener("pointerup", this.boundPointerUp));
|
|
@@ -3081,7 +3090,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3081
3090
|
onPointerMove(e) {
|
|
3082
3091
|
var t, n;
|
|
3083
3092
|
if (!this.isDragging) return;
|
|
3084
|
-
let r = e.clientX - this.dragStartX, i = this.startColWidth + r, a = Math.max(
|
|
3093
|
+
let r = e.clientX - this.dragStartX, i = this.startColWidth + r, a = Math.max(Ur, i);
|
|
3085
3094
|
this.colWidths[this.dragColIndex] = a, this.applyWidths((t = this.dragRowCells) == null ? void 0 : t), this.updateHandlePositions(), (n = this.onDrag) == null || n.call(this);
|
|
3086
3095
|
}
|
|
3087
3096
|
onPointerUp() {
|
|
@@ -3091,8 +3100,8 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3091
3100
|
e && (e.style.opacity = "0"), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), this.dragRowCells = null, this.onChange([...this.colWidths]);
|
|
3092
3101
|
}
|
|
3093
3102
|
resolveRowCells() {
|
|
3094
|
-
let e = this.gridEl.querySelectorAll(`[${
|
|
3095
|
-
return Array.from(e, (e) => Array.from(e.querySelectorAll(`[${
|
|
3103
|
+
let e = this.gridEl.querySelectorAll(`[${Hr}]`);
|
|
3104
|
+
return Array.from(e, (e) => Array.from(e.querySelectorAll(`[${Vr}]`)));
|
|
3096
3105
|
}
|
|
3097
3106
|
applyWidths(e = this.resolveRowCells()) {
|
|
3098
3107
|
let t = this.colWidths.reduce((e, t) => e + t, 0);
|
|
@@ -3102,7 +3111,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3102
3111
|
});
|
|
3103
3112
|
});
|
|
3104
3113
|
}
|
|
3105
|
-
},
|
|
3114
|
+
}, Kr = (e, t, n) => (n.grid.addRow(e, t), M(e, n.cellBlocks), {
|
|
3106
3115
|
pendingHighlight: {
|
|
3107
3116
|
type: "row",
|
|
3108
3117
|
index: t
|
|
@@ -3111,9 +3120,9 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3111
3120
|
colWidths: n.data.colWidths,
|
|
3112
3121
|
withHeadings: n.data.withHeadings,
|
|
3113
3122
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3114
|
-
}),
|
|
3115
|
-
let r =
|
|
3116
|
-
return
|
|
3123
|
+
}), qr = (e, t, n) => {
|
|
3124
|
+
let r = Ar(e, t, n.data.colWidths, n.data.initialColWidth, n.grid);
|
|
3125
|
+
return M(e, n.cellBlocks), {
|
|
3117
3126
|
pendingHighlight: {
|
|
3118
3127
|
type: "col",
|
|
3119
3128
|
index: t
|
|
@@ -3123,7 +3132,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3123
3132
|
withHeadings: n.data.withHeadings,
|
|
3124
3133
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3125
3134
|
};
|
|
3126
|
-
},
|
|
3135
|
+
}, Jr = (e, t, n, r) => (r.grid.moveRow(e, t, n), {
|
|
3127
3136
|
pendingHighlight: null,
|
|
3128
3137
|
moveSelection: {
|
|
3129
3138
|
type: "row",
|
|
@@ -3132,16 +3141,16 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3132
3141
|
colWidths: r.data.colWidths,
|
|
3133
3142
|
withHeadings: r.data.withHeadings,
|
|
3134
3143
|
withHeadingColumn: r.data.withHeadingColumn
|
|
3135
|
-
}),
|
|
3144
|
+
}), Yr = (e, t, n, r) => (r.grid.moveColumn(e, t, n), {
|
|
3136
3145
|
pendingHighlight: null,
|
|
3137
3146
|
moveSelection: {
|
|
3138
3147
|
type: "col",
|
|
3139
3148
|
index: n
|
|
3140
3149
|
},
|
|
3141
|
-
colWidths:
|
|
3150
|
+
colWidths: Or(r.data.colWidths, t, n),
|
|
3142
3151
|
withHeadings: r.data.withHeadings,
|
|
3143
3152
|
withHeadingColumn: r.data.withHeadingColumn
|
|
3144
|
-
}),
|
|
3153
|
+
}), Xr = (e, t, n) => {
|
|
3145
3154
|
var r, i;
|
|
3146
3155
|
return (r = n.cellBlocks) == null || r.deleteBlocks((i = n.blocksToDelete) == null ? [] : i), n.grid.deleteRow(e, t), {
|
|
3147
3156
|
pendingHighlight: {
|
|
@@ -3153,11 +3162,11 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3153
3162
|
withHeadings: n.data.withHeadings,
|
|
3154
3163
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3155
3164
|
};
|
|
3156
|
-
},
|
|
3165
|
+
}, Zr = (e, t, n) => {
|
|
3157
3166
|
var r, i;
|
|
3158
3167
|
(r = n.cellBlocks) == null || r.deleteBlocks((i = n.blocksToDelete) == null ? [] : i), n.grid.deleteColumn(e, t);
|
|
3159
|
-
let a =
|
|
3160
|
-
return a ?
|
|
3168
|
+
let a = kr(n.data.colWidths, t);
|
|
3169
|
+
return a ? A(e, a) : Dr(e), {
|
|
3161
3170
|
pendingHighlight: {
|
|
3162
3171
|
type: "col",
|
|
3163
3172
|
index: t < n.grid.getColumnCount(e) ? t : t - 1
|
|
@@ -3167,16 +3176,16 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3167
3176
|
withHeadings: n.data.withHeadings,
|
|
3168
3177
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3169
3178
|
};
|
|
3170
|
-
},
|
|
3179
|
+
}, Qr = (e, t, n) => {
|
|
3171
3180
|
switch (t.type) {
|
|
3172
|
-
case "insert-row-above": return
|
|
3173
|
-
case "insert-row-below": return
|
|
3174
|
-
case "insert-col-left": return
|
|
3175
|
-
case "insert-col-right": return
|
|
3176
|
-
case "move-row": return
|
|
3177
|
-
case "move-col": return
|
|
3178
|
-
case "delete-row": return
|
|
3179
|
-
case "delete-col": return
|
|
3181
|
+
case "insert-row-above": return Kr(e, t.index, n);
|
|
3182
|
+
case "insert-row-below": return Kr(e, t.index + 1, n);
|
|
3183
|
+
case "insert-col-left": return qr(e, t.index, n);
|
|
3184
|
+
case "insert-col-right": return qr(e, t.index + 1, n);
|
|
3185
|
+
case "move-row": return Jr(e, t.fromIndex, t.toIndex, n);
|
|
3186
|
+
case "move-col": return Yr(e, t.fromIndex, t.toIndex, n);
|
|
3187
|
+
case "delete-row": return Xr(e, t.index, n);
|
|
3188
|
+
case "delete-col": return Zr(e, t.index, n);
|
|
3180
3189
|
case "toggle-heading": return {
|
|
3181
3190
|
pendingHighlight: {
|
|
3182
3191
|
type: "row",
|
|
@@ -3198,13 +3207,13 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3198
3207
|
withHeadingColumn: !n.data.withHeadingColumn
|
|
3199
3208
|
};
|
|
3200
3209
|
}
|
|
3201
|
-
},
|
|
3202
|
-
let t = e.querySelector(`[${
|
|
3203
|
-
return t ? Array.from(t.querySelectorAll(`[${
|
|
3210
|
+
}, $r = 10, ei = "data-blok-table-drag-ghost", ti = (e) => {
|
|
3211
|
+
let t = e.querySelector(`[${T}]`);
|
|
3212
|
+
return t ? Array.from(t.querySelectorAll(`[${E}]`)).reduce((e, t) => {
|
|
3204
3213
|
let n = e[e.length - 1];
|
|
3205
3214
|
return [...e, n + t.offsetWidth];
|
|
3206
3215
|
}, [0]) : [0];
|
|
3207
|
-
},
|
|
3216
|
+
}, ni = class {
|
|
3208
3217
|
constructor(e) {
|
|
3209
3218
|
var t;
|
|
3210
3219
|
this.isDragging = !1, this.dragType = null, this.dragFromIndex = -1, this.dragStartX = 0, this.dragStartY = 0, this.dropIndicator = null, this.dragOverlayCells = [], this.ghostEl = null, this.ghostOffsetX = 0, this.ghostOffsetY = 0, this.resolveTracking = null, this.grid = e.grid, this.onAction = e.onAction, this.onDragStateChange = (t = e.onDragStateChange) == null ? null : t, this.boundDocPointerMove = this.handleDocPointerMove.bind(this), this.boundDocPointerUp = this.handleDocPointerUp.bind(this), this.boundDocPointerCancel = this.handleDocPointerCancel.bind(this);
|
|
@@ -3223,7 +3232,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3223
3232
|
}
|
|
3224
3233
|
handleDocPointerMove(e) {
|
|
3225
3234
|
let t = Math.abs(e.clientX - this.dragStartX), n = Math.abs(e.clientY - this.dragStartY);
|
|
3226
|
-
!this.isDragging && (t >
|
|
3235
|
+
!this.isDragging && (t > $r || n > $r) && (this.isDragging = !0, this.startDrag()), this.isDragging && (this.updateDragIndicator(e), this.updateGhostPosition(e));
|
|
3227
3236
|
}
|
|
3228
3237
|
handleDocPointerUp(e) {
|
|
3229
3238
|
if (document.removeEventListener("pointermove", this.boundDocPointerMove), document.removeEventListener("pointerup", this.boundDocPointerUp), document.removeEventListener("pointercancel", this.boundDocPointerCancel), this.isDragging) {
|
|
@@ -3244,7 +3253,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3244
3253
|
this.grid.style.userSelect = "none", document.body.style.cursor = "grabbing", (e = this.onDragStateChange) == null || e.call(this, !0, this.dragType), this.highlightSourceCells(), this.createDropIndicator(), this.createGhost();
|
|
3245
3254
|
}
|
|
3246
3255
|
highlightSourceCells() {
|
|
3247
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3256
|
+
let e = this.grid.querySelectorAll(`[${T}]`);
|
|
3248
3257
|
if (this.dragType === "row") {
|
|
3249
3258
|
this.highlightRowCells(e);
|
|
3250
3259
|
return;
|
|
@@ -3253,25 +3262,36 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3253
3262
|
}
|
|
3254
3263
|
highlightRowCells(e) {
|
|
3255
3264
|
let t = e[this.dragFromIndex];
|
|
3256
|
-
|
|
3265
|
+
if (!t) return;
|
|
3266
|
+
let n = this.getDragSourceBg();
|
|
3267
|
+
t.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
3257
3268
|
let t = e;
|
|
3258
|
-
t.style.backgroundColor =
|
|
3269
|
+
t.style.backgroundColor = n, t.style.opacity = "0.7", this.dragOverlayCells.push(t);
|
|
3259
3270
|
});
|
|
3260
3271
|
}
|
|
3261
3272
|
highlightColumnCells(e) {
|
|
3273
|
+
let t = this.getDragSourceBg();
|
|
3262
3274
|
e.forEach((e) => {
|
|
3263
|
-
let
|
|
3264
|
-
if (this.dragFromIndex >=
|
|
3265
|
-
let
|
|
3266
|
-
|
|
3275
|
+
let n = e.querySelectorAll(`[${E}]`);
|
|
3276
|
+
if (this.dragFromIndex >= n.length) return;
|
|
3277
|
+
let r = n[this.dragFromIndex];
|
|
3278
|
+
r.style.backgroundColor = t, r.style.opacity = "0.7", this.dragOverlayCells.push(r);
|
|
3267
3279
|
});
|
|
3268
3280
|
}
|
|
3281
|
+
getDragSourceBg() {
|
|
3282
|
+
return getComputedStyle(this.grid).getPropertyValue("--blok-table-drag-source-bg").trim() || "#f3f4f6";
|
|
3283
|
+
}
|
|
3284
|
+
isDarkMode() {
|
|
3285
|
+
var e, t, n;
|
|
3286
|
+
let r = document.documentElement.getAttribute("data-blok-theme");
|
|
3287
|
+
return r === "dark" ? !0 : r === "light" || (e = (t = (n = window).matchMedia) == null ? void 0 : t.call(n, "(prefers-color-scheme: dark)").matches) == null ? !1 : e;
|
|
3288
|
+
}
|
|
3269
3289
|
createDropIndicator() {
|
|
3270
3290
|
this.dropIndicator = document.createElement("div");
|
|
3271
3291
|
let e = this.dropIndicator.style;
|
|
3272
3292
|
if (e.position = "absolute", e.backgroundColor = "#3b82f6", e.borderRadius = "1.5px", e.zIndex = "5", e.pointerEvents = "none", this.dropIndicator.setAttribute("contenteditable", "false"), this.dragType === "row") e.height = "3px", e.left = "-1px", e.right = "0", e.transition = "top 100ms ease";
|
|
3273
3293
|
else {
|
|
3274
|
-
let t = this.grid.querySelectorAll(`[${
|
|
3294
|
+
let t = this.grid.querySelectorAll(`[${T}]`), n = t[t.length - 1], r = n ? n.offsetTop + n.offsetHeight : 0;
|
|
3275
3295
|
e.width = "3px", e.top = "-1px", e.height = `${r + 1}px`, e.transition = "left 100ms ease";
|
|
3276
3296
|
}
|
|
3277
3297
|
this.grid.appendChild(this.dropIndicator);
|
|
@@ -3293,7 +3313,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3293
3313
|
updateColIndicator(e, t) {
|
|
3294
3314
|
var n;
|
|
3295
3315
|
if (!this.dropIndicator) return;
|
|
3296
|
-
let r = e.clientX - t.left, i = this.getColDropIndex(r), a =
|
|
3316
|
+
let r = e.clientX - t.left, i = this.getColDropIndex(r), a = ti(this.grid);
|
|
3297
3317
|
this.dropIndicator.style.left = `${((n = a[i]) == null ? 0 : n) - 1.5}px`;
|
|
3298
3318
|
}
|
|
3299
3319
|
finishDrag(e) {
|
|
@@ -3322,9 +3342,9 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3322
3342
|
}
|
|
3323
3343
|
createGhost() {
|
|
3324
3344
|
let e = document.createElement("div");
|
|
3325
|
-
e.setAttribute(
|
|
3345
|
+
e.setAttribute(ei, ""), e.setAttribute("contenteditable", "false");
|
|
3326
3346
|
let t = e.style;
|
|
3327
|
-
t.position = "fixed", t.pointerEvents = "none", t.opacity = "0.5", t.zIndex = "50", t.borderRadius = "4px", t.overflow = "hidden", t.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", this.ghostEl = e;
|
|
3347
|
+
t.position = "fixed", t.pointerEvents = "none", t.opacity = "0.5", t.zIndex = "50", t.borderRadius = "4px", t.overflow = "hidden", t.boxShadow = this.isDarkMode() ? "0 8px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08)" : "0 4px 12px rgba(0, 0, 0, 0.15)", this.ghostEl = e;
|
|
3328
3348
|
let n = this.getSourceRect();
|
|
3329
3349
|
this.dragType === "row" && this.buildRowGhost(), this.dragType === "col" && this.buildColumnGhost(), document.body.appendChild(e), n && (t.left = `${n.left}px`, t.top = `${n.top}px`, this.ghostOffsetX = this.dragStartX - n.left, this.ghostOffsetY = this.dragStartY - n.top);
|
|
3330
3350
|
}
|
|
@@ -3333,22 +3353,22 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3333
3353
|
}
|
|
3334
3354
|
getRowSourceRect() {
|
|
3335
3355
|
var e;
|
|
3336
|
-
let t = this.grid.querySelectorAll(`[${
|
|
3356
|
+
let t = this.grid.querySelectorAll(`[${T}]`)[this.dragFromIndex];
|
|
3337
3357
|
return (e = t == null ? void 0 : t.getBoundingClientRect()) == null ? null : e;
|
|
3338
3358
|
}
|
|
3339
3359
|
getColSourceRect() {
|
|
3340
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3360
|
+
let e = this.grid.querySelectorAll(`[${T}]`), t = e[0], n = e[e.length - 1];
|
|
3341
3361
|
if (!t || !n) return null;
|
|
3342
|
-
let r = t.querySelectorAll(`[${
|
|
3362
|
+
let r = t.querySelectorAll(`[${E}]`)[this.dragFromIndex], i = n.querySelectorAll(`[${E}]`)[this.dragFromIndex];
|
|
3343
3363
|
if (!r || !i) return null;
|
|
3344
3364
|
let a = r.getBoundingClientRect(), o = i.getBoundingClientRect();
|
|
3345
3365
|
return new DOMRect(a.left, a.top, a.width, o.bottom - a.top);
|
|
3346
3366
|
}
|
|
3347
3367
|
buildRowGhost() {
|
|
3348
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3368
|
+
let e = this.grid.querySelectorAll(`[${T}]`)[this.dragFromIndex];
|
|
3349
3369
|
if (!e || !this.ghostEl) return;
|
|
3350
3370
|
let t = this.ghostEl.style;
|
|
3351
|
-
t.display = "flex", t.height = `${e.offsetHeight}px`, e.querySelectorAll(`[${
|
|
3371
|
+
t.display = "flex", t.height = `${e.offsetHeight}px`, e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
3352
3372
|
var t;
|
|
3353
3373
|
let n = e, r = n.cloneNode(!0);
|
|
3354
3374
|
r.style.width = `${n.offsetWidth}px`, r.style.flexShrink = "0", r.removeAttribute("contenteditable"), (t = this.ghostEl) == null || t.appendChild(r);
|
|
@@ -3356,10 +3376,10 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3356
3376
|
}
|
|
3357
3377
|
buildColumnGhost() {
|
|
3358
3378
|
if (!this.ghostEl) return;
|
|
3359
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3379
|
+
let e = this.grid.querySelectorAll(`[${T}]`), t = this.ghostEl.style;
|
|
3360
3380
|
t.display = "flex", t.flexDirection = "column", e.forEach((e) => {
|
|
3361
3381
|
var t;
|
|
3362
|
-
let n = e.querySelectorAll(`[${
|
|
3382
|
+
let n = e.querySelectorAll(`[${E}]`);
|
|
3363
3383
|
if (this.dragFromIndex >= n.length) return;
|
|
3364
3384
|
let r = n[this.dragFromIndex], i = r.cloneNode(!0);
|
|
3365
3385
|
i.style.width = `${r.offsetWidth}px`, i.style.height = `${r.offsetHeight}px`, i.removeAttribute("contenteditable"), (t = this.ghostEl) == null || t.appendChild(i);
|
|
@@ -3371,7 +3391,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3371
3391
|
this.dragType === "row" && (t.top = `${e.clientY - this.ghostOffsetY}px`), this.dragType === "col" && (t.left = `${e.clientX - this.ghostOffsetX}px`);
|
|
3372
3392
|
}
|
|
3373
3393
|
getRowDropIndex(e) {
|
|
3374
|
-
let t = Array.from(this.grid.querySelectorAll(`[${
|
|
3394
|
+
let t = Array.from(this.grid.querySelectorAll(`[${T}]`)), n = t.map((e) => e.offsetTop);
|
|
3375
3395
|
if (t.length > 0) {
|
|
3376
3396
|
let e = t[t.length - 1];
|
|
3377
3397
|
n.push(e.offsetTop + e.offsetHeight);
|
|
@@ -3380,7 +3400,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3380
3400
|
return r.indexOf(i);
|
|
3381
3401
|
}
|
|
3382
3402
|
getRowDropTopPx(e) {
|
|
3383
|
-
let t = this.grid.querySelectorAll(`[${
|
|
3403
|
+
let t = this.grid.querySelectorAll(`[${T}]`);
|
|
3384
3404
|
if (e < t.length) return t[e].offsetTop;
|
|
3385
3405
|
if (t.length > 0) {
|
|
3386
3406
|
let e = t[t.length - 1];
|
|
@@ -3389,10 +3409,10 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3389
3409
|
return 0;
|
|
3390
3410
|
}
|
|
3391
3411
|
getColDropIndex(e) {
|
|
3392
|
-
let t =
|
|
3412
|
+
let t = ti(this.grid).map((t) => Math.abs(e - t)), n = Math.min(...t);
|
|
3393
3413
|
return t.indexOf(n);
|
|
3394
3414
|
}
|
|
3395
|
-
},
|
|
3415
|
+
}, ri = [
|
|
3396
3416
|
"flex",
|
|
3397
3417
|
"items-center",
|
|
3398
3418
|
"select-none",
|
|
@@ -3404,7 +3424,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3404
3424
|
"mb-px",
|
|
3405
3425
|
"cursor-pointer",
|
|
3406
3426
|
"can-hover:hover:bg-item-hover-bg"
|
|
3407
|
-
],
|
|
3427
|
+
], ii = [
|
|
3408
3428
|
"flex",
|
|
3409
3429
|
"items-center",
|
|
3410
3430
|
"justify-center",
|
|
@@ -3413,52 +3433,54 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3413
3433
|
"mr-2",
|
|
3414
3434
|
"[&_svg]:w-icon",
|
|
3415
3435
|
"[&_svg]:h-icon"
|
|
3416
|
-
],
|
|
3436
|
+
], ai = [
|
|
3417
3437
|
"mr-auto",
|
|
3418
3438
|
"truncate",
|
|
3419
3439
|
"text-sm",
|
|
3420
3440
|
"font-medium",
|
|
3421
3441
|
"leading-5"
|
|
3422
|
-
],
|
|
3442
|
+
], oi = [
|
|
3423
3443
|
"relative",
|
|
3424
|
-
"w-[
|
|
3425
|
-
"h-[
|
|
3444
|
+
"w-[30px]",
|
|
3445
|
+
"h-[18px]",
|
|
3426
3446
|
"rounded-full",
|
|
3427
3447
|
"transition-colors",
|
|
3428
|
-
"duration-
|
|
3429
|
-
"
|
|
3430
|
-
|
|
3448
|
+
"duration-[180ms]",
|
|
3449
|
+
"ease-out",
|
|
3450
|
+
"shrink-0",
|
|
3451
|
+
"ml-2"
|
|
3452
|
+
], si = [
|
|
3431
3453
|
"absolute",
|
|
3432
3454
|
"top-[2px]",
|
|
3433
|
-
"w-
|
|
3434
|
-
"h-
|
|
3455
|
+
"w-[14px]",
|
|
3456
|
+
"h-[14px]",
|
|
3435
3457
|
"rounded-full",
|
|
3436
3458
|
"bg-white",
|
|
3437
|
-
"shadow-xs",
|
|
3438
3459
|
"transition-[left]",
|
|
3439
|
-
"duration-
|
|
3440
|
-
|
|
3460
|
+
"duration-[220ms]",
|
|
3461
|
+
"[transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)]"
|
|
3462
|
+
], ci = (e) => {
|
|
3441
3463
|
let { icon: t, label: n, isActive: r, onToggle: i } = e, a = { active: r }, o = document.createElement("div");
|
|
3442
|
-
o.className =
|
|
3464
|
+
o.className = x(ri);
|
|
3443
3465
|
let s = document.createElement("div");
|
|
3444
|
-
s.className =
|
|
3466
|
+
s.className = x(ii), s.innerHTML = t, o.appendChild(s);
|
|
3445
3467
|
let c = document.createElement("span");
|
|
3446
|
-
c.className =
|
|
3468
|
+
c.className = x(ai), c.textContent = n, o.appendChild(c);
|
|
3447
3469
|
let l = document.createElement("div");
|
|
3448
|
-
l.className =
|
|
3470
|
+
l.className = x(oi);
|
|
3449
3471
|
let u = document.createElement("div");
|
|
3450
|
-
u.className =
|
|
3472
|
+
u.className = x(si), l.appendChild(u), o.appendChild(l);
|
|
3451
3473
|
let d = () => {
|
|
3452
|
-
l.style.backgroundColor = a.active ? "
|
|
3474
|
+
l.style.backgroundColor = a.active ? "var(--blok-toggle-on-bg)" : "var(--blok-toggle-off-bg)", u.style.left = a.active ? "14px" : "2px", u.style.backgroundColor = a.active ? "var(--blok-toggle-thumb-on-bg)" : "", u.style.boxShadow = a.active ? "0 1px 3px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.04)" : "0 1px 3px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.06)";
|
|
3453
3475
|
};
|
|
3454
3476
|
return d(), o.addEventListener("click", (e) => {
|
|
3455
3477
|
e.stopPropagation(), a.active = !a.active, d(), i(a.active);
|
|
3456
3478
|
}), o;
|
|
3457
|
-
},
|
|
3479
|
+
}, li = (e, t) => {
|
|
3458
3480
|
let n = e === 0 ? [{
|
|
3459
3481
|
type: _.Html,
|
|
3460
|
-
element:
|
|
3461
|
-
icon:
|
|
3482
|
+
element: ci({
|
|
3483
|
+
icon: Ze,
|
|
3462
3484
|
label: t.i18n.t("tools.table.headerColumn"),
|
|
3463
3485
|
isActive: t.isHeadingColumn(),
|
|
3464
3486
|
onToggle: () => {
|
|
@@ -3466,7 +3488,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3466
3488
|
}
|
|
3467
3489
|
})
|
|
3468
3490
|
}, { type: _.Separator }] : [], r = [{
|
|
3469
|
-
icon:
|
|
3491
|
+
icon: ne,
|
|
3470
3492
|
title: t.i18n.t("tools.table.insertColumnLeft"),
|
|
3471
3493
|
closeOnActivate: !0,
|
|
3472
3494
|
onActivate: () => {
|
|
@@ -3476,7 +3498,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3476
3498
|
});
|
|
3477
3499
|
}
|
|
3478
3500
|
}, {
|
|
3479
|
-
icon:
|
|
3501
|
+
icon: ie,
|
|
3480
3502
|
title: t.i18n.t("tools.table.insertColumnRight"),
|
|
3481
3503
|
closeOnActivate: !0,
|
|
3482
3504
|
onActivate: () => {
|
|
@@ -3486,7 +3508,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3486
3508
|
});
|
|
3487
3509
|
}
|
|
3488
3510
|
}], i = t.getColumnCount() > 1, a = [{ type: _.Separator }, {
|
|
3489
|
-
icon:
|
|
3511
|
+
icon: Ve,
|
|
3490
3512
|
title: t.i18n.t("tools.table.deleteColumn"),
|
|
3491
3513
|
isDestructive: !0,
|
|
3492
3514
|
isDisabled: !i,
|
|
@@ -3503,11 +3525,11 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3503
3525
|
...r,
|
|
3504
3526
|
...a
|
|
3505
3527
|
];
|
|
3506
|
-
},
|
|
3507
|
-
let
|
|
3528
|
+
}, ui = (e, t) => {
|
|
3529
|
+
let n = e === 0 ? [{
|
|
3508
3530
|
type: _.Html,
|
|
3509
|
-
element:
|
|
3510
|
-
icon:
|
|
3531
|
+
element: ci({
|
|
3532
|
+
icon: r,
|
|
3511
3533
|
label: t.i18n.t("tools.table.headerRow"),
|
|
3512
3534
|
isActive: t.isHeadingRow(),
|
|
3513
3535
|
onToggle: () => {
|
|
@@ -3515,7 +3537,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3515
3537
|
}
|
|
3516
3538
|
})
|
|
3517
3539
|
}, { type: _.Separator }] : [], i = [{
|
|
3518
|
-
icon:
|
|
3540
|
+
icon: re,
|
|
3519
3541
|
title: t.i18n.t("tools.table.insertRowAbove"),
|
|
3520
3542
|
closeOnActivate: !0,
|
|
3521
3543
|
onActivate: () => {
|
|
@@ -3525,7 +3547,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3525
3547
|
});
|
|
3526
3548
|
}
|
|
3527
3549
|
}, {
|
|
3528
|
-
icon:
|
|
3550
|
+
icon: c,
|
|
3529
3551
|
title: t.i18n.t("tools.table.insertRowBelow"),
|
|
3530
3552
|
closeOnActivate: !0,
|
|
3531
3553
|
onActivate: () => {
|
|
@@ -3535,7 +3557,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3535
3557
|
});
|
|
3536
3558
|
}
|
|
3537
3559
|
}], a = t.getRowCount() > 1, o = [{ type: _.Separator }, {
|
|
3538
|
-
icon:
|
|
3560
|
+
icon: Ve,
|
|
3539
3561
|
title: t.i18n.t("tools.table.deleteRow"),
|
|
3540
3562
|
isDestructive: !0,
|
|
3541
3563
|
isDisabled: !a,
|
|
@@ -3548,30 +3570,30 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3548
3570
|
}
|
|
3549
3571
|
}];
|
|
3550
3572
|
return [
|
|
3551
|
-
...
|
|
3573
|
+
...n,
|
|
3552
3574
|
...i,
|
|
3553
3575
|
...o
|
|
3554
3576
|
];
|
|
3555
|
-
},
|
|
3577
|
+
}, di = (e, t, n, r, i) => {
|
|
3556
3578
|
i.destroyPopover(), i.clearHideTimeout();
|
|
3557
3579
|
let a = e === "col" ? n.col[t] : n.row[t];
|
|
3558
3580
|
if (!a) return {
|
|
3559
3581
|
popover: null,
|
|
3560
3582
|
grip: null
|
|
3561
3583
|
};
|
|
3562
|
-
let o = new
|
|
3563
|
-
items: e === "col" ?
|
|
3584
|
+
let o = new ve({
|
|
3585
|
+
items: e === "col" ? li(t, r) : ui(t, r),
|
|
3564
3586
|
trigger: a,
|
|
3565
3587
|
flippable: !0
|
|
3566
3588
|
});
|
|
3567
|
-
return o.on(
|
|
3589
|
+
return o.on(Ge.Closed, () => {
|
|
3568
3590
|
var e;
|
|
3569
3591
|
i.destroyPopover(), i.applyVisibleClasses(a), i.scheduleHideAll(), (e = i.onGripPopoverClose) == null || e.call(i);
|
|
3570
3592
|
}), i.hideAllGripsExcept(a), i.applyActiveClasses(a), e === "col" ? a.style.height = "16px" : a.style.width = "16px", {
|
|
3571
3593
|
popover: o,
|
|
3572
3594
|
grip: a
|
|
3573
3595
|
};
|
|
3574
|
-
},
|
|
3596
|
+
}, fi = "data-blok-table-grip", L = "data-blok-table-grip-col", pi = "data-blok-table-grip-row", mi = 150, hi = 24, R = 4, z = 4, gi = 20, B = [
|
|
3575
3597
|
"absolute",
|
|
3576
3598
|
"z-3",
|
|
3577
3599
|
"rounded-sm",
|
|
@@ -3584,25 +3606,25 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3584
3606
|
"items-center",
|
|
3585
3607
|
"justify-center",
|
|
3586
3608
|
"overflow-hidden"
|
|
3587
|
-
],
|
|
3609
|
+
], _i = [
|
|
3588
3610
|
"bg-gray-300",
|
|
3589
3611
|
"opacity-0",
|
|
3590
3612
|
"pointer-events-none"
|
|
3591
|
-
],
|
|
3613
|
+
], vi = [
|
|
3592
3614
|
"bg-gray-300",
|
|
3593
3615
|
"opacity-100",
|
|
3594
3616
|
"pointer-events-auto"
|
|
3595
|
-
],
|
|
3617
|
+
], yi = [
|
|
3596
3618
|
"bg-blue-500",
|
|
3597
3619
|
"text-white",
|
|
3598
3620
|
"opacity-100",
|
|
3599
3621
|
"pointer-events-auto"
|
|
3600
|
-
],
|
|
3622
|
+
], bi = class {
|
|
3601
3623
|
constructor(e) {
|
|
3602
3624
|
this.colGrips = [], this.rowGrips = [], this.popoverState = {
|
|
3603
3625
|
popover: null,
|
|
3604
3626
|
grip: null
|
|
3605
|
-
}, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.boundScrollHandler = null, this.grid = e.grid, this.overlay = e.overlay, this.scrollContainer = e.scrollContainer, this.getColumnCount = e.getColumnCount, this.getRowCount = e.getRowCount, this.isHeadingRow = e.isHeadingRow, this.isHeadingColumn = e.isHeadingColumn, this.onAction = e.onAction, this.onGripClick = e.onGripClick, this.onGripPopoverClose = e.onGripPopoverClose, this.i18n = e.i18n, this.drag = new
|
|
3627
|
+
}, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.boundScrollHandler = null, this.grid = e.grid, this.overlay = e.overlay, this.scrollContainer = e.scrollContainer, this.getColumnCount = e.getColumnCount, this.getRowCount = e.getRowCount, this.isHeadingRow = e.isHeadingRow, this.isHeadingColumn = e.isHeadingColumn, this.onAction = e.onAction, this.onGripClick = e.onGripClick, this.onGripPopoverClose = e.onGripPopoverClose, this.i18n = e.i18n, this.drag = new ni({
|
|
3606
3628
|
grid: this.grid,
|
|
3607
3629
|
onAction: this.onAction,
|
|
3608
3630
|
onDragStateChange: (t, n) => {
|
|
@@ -3623,7 +3645,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3623
3645
|
}
|
|
3624
3646
|
handleUnlockGrip(e) {
|
|
3625
3647
|
document.removeEventListener("pointerdown", this.boundUnlockGrip), this.lockedGrip && (this.applyIdleClasses(this.lockedGrip), this.lockedGrip = null);
|
|
3626
|
-
let t = e.target instanceof HTMLElement ? e.target : null, n = t == null ? void 0 : t.closest(`[${
|
|
3648
|
+
let t = e.target instanceof HTMLElement ? e.target : null, n = t == null ? void 0 : t.closest(`[${E}]`);
|
|
3627
3649
|
if (n) {
|
|
3628
3650
|
let e = this.getCellPosition(n);
|
|
3629
3651
|
e && (this.clearHideTimeout(), this.showColGrip(e.col), this.showRowGrip(e.row), this.isInsideTable = !0);
|
|
@@ -3670,18 +3692,18 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3670
3692
|
}
|
|
3671
3693
|
createGripElement(e, t) {
|
|
3672
3694
|
let n = document.createElement("div");
|
|
3673
|
-
n.className =
|
|
3674
|
-
let r = e === "col" ?
|
|
3675
|
-
return n.style.width = `${r}px`, n.style.height = `${i}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid
|
|
3676
|
-
this.overlay && this.clearHideTimeout(), this.isGripInteractionLocked() ||
|
|
3695
|
+
n.className = x(B, _i), n.setAttribute(fi, ""), n.setAttribute(e === "col" ? L : pi, String(t)), n.setAttribute("contenteditable", "false");
|
|
3696
|
+
let r = e === "col" ? hi : z, i = e === "col" ? R : gi, a = e === "col" ? R : z;
|
|
3697
|
+
return n.style.width = `${r}px`, n.style.height = `${i}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid var(--blok-table-grip-outline, transparent)", n.appendChild(dr(e === "col" ? "horizontal" : "vertical")), n.addEventListener("pointerdown", this.boundPointerDown), n.addEventListener("mouseenter", () => {
|
|
3698
|
+
this.overlay && this.clearHideTimeout(), this.isGripInteractionLocked() || fr(n, e);
|
|
3677
3699
|
}), n.addEventListener("mouseleave", () => {
|
|
3678
|
-
this.isGripInteractionLocked() || (
|
|
3700
|
+
this.isGripInteractionLocked() || (pr(n, e, a), this.overlay && this.scheduleHideAll());
|
|
3679
3701
|
}), n;
|
|
3680
3702
|
}
|
|
3681
3703
|
positionGrips() {
|
|
3682
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3704
|
+
let e = this.grid.querySelectorAll(`[${T}]`);
|
|
3683
3705
|
if (!e[0]) return;
|
|
3684
|
-
let t =
|
|
3706
|
+
let t = ti(this.grid), n = this.overlay && this.scrollContainer ? this.scrollContainer.scrollLeft : 0, r = this.overlay && this.scrollContainer ? this.scrollContainer.clientWidth : Infinity;
|
|
3685
3707
|
this.colGrips.forEach((e, i) => {
|
|
3686
3708
|
if (i + 1 >= t.length) return;
|
|
3687
3709
|
let a = (t[i] + t[i + 1]) / 2 - n, o = e.style;
|
|
@@ -3696,7 +3718,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3696
3718
|
var e;
|
|
3697
3719
|
(e = this.rowResizeObserver) == null || e.disconnect(), this.rowResizeObserver = new ResizeObserver(() => {
|
|
3698
3720
|
this.positionGrips();
|
|
3699
|
-
}), this.grid.querySelectorAll(`[${
|
|
3721
|
+
}), this.grid.querySelectorAll(`[${T}]`).forEach((e) => {
|
|
3700
3722
|
var t;
|
|
3701
3723
|
(t = this.rowResizeObserver) == null || t.observe(e);
|
|
3702
3724
|
});
|
|
@@ -3706,7 +3728,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3706
3728
|
}
|
|
3707
3729
|
handleMouseOver(e) {
|
|
3708
3730
|
if (this.isGripInteractionLocked()) return;
|
|
3709
|
-
let t = e.target.closest(`[${
|
|
3731
|
+
let t = e.target.closest(`[${E}]`);
|
|
3710
3732
|
if (!t) return;
|
|
3711
3733
|
this.clearHideTimeout();
|
|
3712
3734
|
let n = this.getCellPosition(t);
|
|
@@ -3716,11 +3738,11 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3716
3738
|
this.isGripInteractionLocked() || this.scheduleHideAll();
|
|
3717
3739
|
}
|
|
3718
3740
|
getCellPosition(e) {
|
|
3719
|
-
let t = e.closest(`[${
|
|
3741
|
+
let t = e.closest(`[${T}]`);
|
|
3720
3742
|
if (!t) return null;
|
|
3721
|
-
let n = Array.from(this.grid.querySelectorAll(`[${
|
|
3743
|
+
let n = Array.from(this.grid.querySelectorAll(`[${T}]`)).indexOf(t);
|
|
3722
3744
|
if (n < 0) return null;
|
|
3723
|
-
let r = Array.from(t.querySelectorAll(`[${
|
|
3745
|
+
let r = Array.from(t.querySelectorAll(`[${E}]`)).indexOf(e);
|
|
3724
3746
|
return r < 0 ? null : {
|
|
3725
3747
|
row: n,
|
|
3726
3748
|
col: r
|
|
@@ -3749,13 +3771,13 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3749
3771
|
this.activeRowGripIndex >= 0 && this.activeRowGripIndex < this.rowGrips.length && this.applyIdleClasses(this.rowGrips[this.activeRowGripIndex]), this.activeRowGripIndex = -1;
|
|
3750
3772
|
}
|
|
3751
3773
|
applyVisibleClasses(e) {
|
|
3752
|
-
let t = e, n = t.hasAttribute(
|
|
3753
|
-
|
|
3774
|
+
let t = e, n = t.hasAttribute(L);
|
|
3775
|
+
cr(t, n ? "col" : "row", n ? R : z), this.isInsideTable && (t.style.transition = "none"), t.className = x(B, vi), t.setAttribute("data-blok-table-grip-visible", ""), this.isInsideTable && (t.offsetHeight, t.style.transition = "");
|
|
3754
3776
|
let r = t.querySelector("svg");
|
|
3755
|
-
r && (r.classList.remove("text-white"), r.classList.add("text-gray-400"));
|
|
3777
|
+
r && (r.classList.remove("text-white", "opacity-100"), r.classList.add("text-gray-400", "opacity-0"));
|
|
3756
3778
|
}
|
|
3757
3779
|
applyActiveClasses(e) {
|
|
3758
|
-
Object.assign(e, { className:
|
|
3780
|
+
Object.assign(e, { className: x(B, yi) }), e.setAttribute("data-blok-table-grip-visible", "");
|
|
3759
3781
|
let t = e.querySelector("svg");
|
|
3760
3782
|
t && (t.classList.remove("text-gray-400", "opacity-0"), t.classList.add("text-white", "opacity-100"));
|
|
3761
3783
|
}
|
|
@@ -3765,8 +3787,10 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3765
3787
|
});
|
|
3766
3788
|
}
|
|
3767
3789
|
applyIdleClasses(e) {
|
|
3768
|
-
let t = e, n = t.hasAttribute(
|
|
3769
|
-
this.isInsideTable && (t.style.transition = "none"),
|
|
3790
|
+
let t = e, n = t.hasAttribute(L), r = n ? "col" : "row", i = n ? R + 12 : z + 12;
|
|
3791
|
+
this.isInsideTable && (t.style.transition = "none"), cr(t, r, i), t.className = x(B, _i), t.removeAttribute("data-blok-table-grip-visible");
|
|
3792
|
+
let a = t.querySelector("svg");
|
|
3793
|
+
a && (a.classList.add("opacity-0"), a.classList.remove("opacity-100")), this.isInsideTable && (t.offsetHeight, t.style.transition = "");
|
|
3770
3794
|
}
|
|
3771
3795
|
handleDragStateChange(e, t) {
|
|
3772
3796
|
[...this.colGrips, ...this.rowGrips].forEach((t) => {
|
|
@@ -3777,13 +3801,13 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3777
3801
|
scheduleHideAll() {
|
|
3778
3802
|
this.hideTimeout = setTimeout(() => {
|
|
3779
3803
|
this.hideColGrip(), this.hideRowGrip(), this.isInsideTable = !1, this.hideTimeout = null;
|
|
3780
|
-
},
|
|
3804
|
+
}, mi);
|
|
3781
3805
|
}
|
|
3782
3806
|
clearHideTimeout() {
|
|
3783
3807
|
this.hideTimeout !== null && (clearTimeout(this.hideTimeout), this.hideTimeout = null);
|
|
3784
3808
|
}
|
|
3785
3809
|
handlePointerDown(e) {
|
|
3786
|
-
let t = e.target.closest(`[${
|
|
3810
|
+
let t = e.target.closest(`[${fi}]`);
|
|
3787
3811
|
if (!t) return;
|
|
3788
3812
|
e.preventDefault(), e.stopPropagation();
|
|
3789
3813
|
let n = this.detectGripType(t);
|
|
@@ -3792,12 +3816,12 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3792
3816
|
});
|
|
3793
3817
|
}
|
|
3794
3818
|
detectGripType(e) {
|
|
3795
|
-
let t = e.getAttribute(
|
|
3819
|
+
let t = e.getAttribute(L);
|
|
3796
3820
|
if (t !== null) return {
|
|
3797
3821
|
type: "col",
|
|
3798
3822
|
index: Number(t)
|
|
3799
3823
|
};
|
|
3800
|
-
let n = e.getAttribute(
|
|
3824
|
+
let n = e.getAttribute(pi);
|
|
3801
3825
|
return n === null ? null : {
|
|
3802
3826
|
type: "row",
|
|
3803
3827
|
index: Number(n)
|
|
@@ -3805,7 +3829,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3805
3829
|
}
|
|
3806
3830
|
openPopover(e, t) {
|
|
3807
3831
|
var n, r;
|
|
3808
|
-
this.popoverState =
|
|
3832
|
+
this.popoverState = di(e, t, {
|
|
3809
3833
|
col: this.colGrips,
|
|
3810
3834
|
row: this.rowGrips
|
|
3811
3835
|
}, {
|
|
@@ -3834,7 +3858,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3834
3858
|
}, e.destroy();
|
|
3835
3859
|
}
|
|
3836
3860
|
}
|
|
3837
|
-
},
|
|
3861
|
+
}, xi = "data-blok-table-haze", Si = "data-blok-table-haze-visible", Ci = 1, wi = [
|
|
3838
3862
|
"absolute",
|
|
3839
3863
|
"top-0",
|
|
3840
3864
|
"bottom-0",
|
|
@@ -3844,17 +3868,17 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3844
3868
|
"transition-opacity",
|
|
3845
3869
|
"duration-150",
|
|
3846
3870
|
"z-1"
|
|
3847
|
-
],
|
|
3871
|
+
], Ti = [
|
|
3848
3872
|
"left-0",
|
|
3849
3873
|
"bg-linear-to-r",
|
|
3850
3874
|
"from-white/80",
|
|
3851
3875
|
"to-transparent"
|
|
3852
|
-
],
|
|
3876
|
+
], Ei = [
|
|
3853
3877
|
"right-5",
|
|
3854
3878
|
"bg-linear-to-l",
|
|
3855
3879
|
"from-white/80",
|
|
3856
3880
|
"to-transparent"
|
|
3857
|
-
],
|
|
3881
|
+
], Di = class {
|
|
3858
3882
|
constructor() {
|
|
3859
3883
|
this.leftHaze = null, this.rightHaze = null, this.scrollContainer = null, this.boundOnScroll = null, this.ticking = !1;
|
|
3860
3884
|
}
|
|
@@ -3874,7 +3898,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3874
3898
|
}
|
|
3875
3899
|
createHazeElement(e) {
|
|
3876
3900
|
let t = document.createElement("div");
|
|
3877
|
-
return t.setAttribute(
|
|
3901
|
+
return t.setAttribute(xi, e), t.setAttribute("aria-hidden", "true"), t.classList.add(...wi, ...e === "left" ? Ti : Ei), t;
|
|
3878
3902
|
}
|
|
3879
3903
|
syncVisibility() {
|
|
3880
3904
|
let e = this.scrollContainer;
|
|
@@ -3885,12 +3909,12 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3885
3909
|
return;
|
|
3886
3910
|
}
|
|
3887
3911
|
let { scrollLeft: n, scrollWidth: r, clientWidth: i } = e, a = r - i;
|
|
3888
|
-
this.setVisible(this.leftHaze, n >
|
|
3912
|
+
this.setVisible(this.leftHaze, n > Ci), this.setVisible(this.rightHaze, a > Ci && n < a - Ci);
|
|
3889
3913
|
}
|
|
3890
3914
|
setVisible(e, t) {
|
|
3891
|
-
e && (t ? e.setAttribute(
|
|
3915
|
+
e && (t ? e.setAttribute(Si, "") : e.removeAttribute(Si));
|
|
3892
3916
|
}
|
|
3893
|
-
},
|
|
3917
|
+
}, Oi = 3, ki = 3, Ai = ["my-2", "pr-5"], ji = [
|
|
3894
3918
|
"relative",
|
|
3895
3919
|
"after:content-[\"\"]",
|
|
3896
3920
|
"after:absolute",
|
|
@@ -3899,11 +3923,11 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3899
3923
|
"after:right-0",
|
|
3900
3924
|
"after:h-10",
|
|
3901
3925
|
"after:pointer-events-none"
|
|
3902
|
-
],
|
|
3926
|
+
], Mi = class {
|
|
3903
3927
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
3904
3928
|
this.initialContent = null, this.resize = null, this.addControls = null, this.rowColControls = null, this.cellBlocks = null, this.cellSelection = null, this.scrollHaze = null, this.element = null, this.gridElement = null, this.scrollContainer = null, this.gripOverlay = null, this.pendingHighlight = null, this.isNewTable = !1, this.unregisterRestrictedTools = null, this.setDataGeneration = 0, this.structuralOpDepth = 0, this.api = n, this.readOnly = r, this.config = t == null ? {} : t;
|
|
3905
|
-
let a =
|
|
3906
|
-
this.initialContent = a.content, this.grid = new
|
|
3929
|
+
let a = Fr(e, this.config);
|
|
3930
|
+
this.initialContent = a.content, this.grid = new tr({ readOnly: r }), this.model = new zr(a), this.blockId = i == null ? void 0 : i.id, this.config.restrictedTools !== void 0 && (this.unregisterRestrictedTools = he(this.config.restrictedTools));
|
|
3907
3931
|
}
|
|
3908
3932
|
runStructuralOp(e, t = !1) {
|
|
3909
3933
|
this.structuralOpDepth++;
|
|
@@ -3938,7 +3962,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3938
3962
|
}
|
|
3939
3963
|
static get toolbox() {
|
|
3940
3964
|
return {
|
|
3941
|
-
icon:
|
|
3965
|
+
icon: Ue,
|
|
3942
3966
|
title: "Table",
|
|
3943
3967
|
titleKey: "tools.table.title",
|
|
3944
3968
|
searchTerms: [
|
|
@@ -3971,7 +3995,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3971
3995
|
em: !0,
|
|
3972
3996
|
mark: (e) => {
|
|
3973
3997
|
let t = e.style, n = Array.from({ length: t.length }, (e, n) => t.item(n));
|
|
3974
|
-
for (let e of n)
|
|
3998
|
+
for (let e of n) ke.has(e) || t.removeProperty(e);
|
|
3975
3999
|
return t.length > 0 ? { style: !0 } : {};
|
|
3976
4000
|
},
|
|
3977
4001
|
a: { href: !0 },
|
|
@@ -3990,28 +4014,28 @@ var Qn = (e) => ({ element: Zn({
|
|
|
3990
4014
|
return n && this.element && (this.element.insertBefore(t, n), t.appendChild(n)), this.scrollContainer = t, (e = this.addControls) == null || e.attachScrollContainer(t), t;
|
|
3991
4015
|
}
|
|
3992
4016
|
render() {
|
|
3993
|
-
var e, t,
|
|
3994
|
-
let
|
|
3995
|
-
|
|
3996
|
-
let
|
|
4017
|
+
var e, t, r, i, a, o;
|
|
4018
|
+
let s = document.createElement("div");
|
|
4019
|
+
s.className = x(Ai, !this.readOnly && ji), s.setAttribute(n.tool, "table"), this.readOnly && s.setAttribute("data-blok-table-readonly", ""), this.isNewTable = ((e = (t = this.initialContent) == null ? void 0 : t.length) == null ? 0 : e) === 0;
|
|
4020
|
+
let c = ((r = this.initialContent) == null ? void 0 : r.length) || this.config.rows || Oi, l = ((i = this.initialContent) == null ? void 0 : i.reduce((e, t) => {
|
|
3997
4021
|
var n;
|
|
3998
4022
|
return Math.max(e, (n = t == null ? void 0 : t.length) == null ? 0 : n);
|
|
3999
|
-
}, 0)) || this.config.cols ||
|
|
4000
|
-
if (((
|
|
4001
|
-
var
|
|
4002
|
-
this.grid.fillGrid(
|
|
4023
|
+
}, 0)) || this.config.cols || ki, u = this.grid.createGrid(c, l, this.model.colWidths);
|
|
4024
|
+
if (((a = (o = this.initialContent) == null ? void 0 : o.length) == null ? 0 : a) > 0) {
|
|
4025
|
+
var d;
|
|
4026
|
+
this.grid.fillGrid(u, (d = this.initialContent) == null ? [] : d);
|
|
4003
4027
|
}
|
|
4004
|
-
if (this.model.colWidths &&
|
|
4028
|
+
if (this.model.colWidths && A(u, this.model.colWidths), this.gridElement = u, this.model.colWidths || !this.readOnly) {
|
|
4005
4029
|
let e = document.createElement("div");
|
|
4006
4030
|
e.setAttribute("data-blok-table-scroll", "");
|
|
4007
|
-
let t = this.model.colWidths ?
|
|
4008
|
-
e.classList.add(...t), e.appendChild(
|
|
4009
|
-
} else
|
|
4031
|
+
let t = this.model.colWidths ? Lr : [];
|
|
4032
|
+
e.classList.add(...t), e.appendChild(u), s.appendChild(e), this.scrollContainer = e;
|
|
4033
|
+
} else s.appendChild(u), this.scrollContainer = null;
|
|
4010
4034
|
if (!this.readOnly) {
|
|
4011
4035
|
let e = document.createElement("div");
|
|
4012
|
-
e.setAttribute("data-blok-table-grip-overlay", ""), e.style.position = "absolute", e.style.inset = "0", e.style.pointerEvents = "none", e.style.zIndex = "3",
|
|
4036
|
+
e.setAttribute("data-blok-table-grip-overlay", ""), e.style.position = "absolute", e.style.inset = "0", e.style.pointerEvents = "none", e.style.zIndex = "3", s.appendChild(e), this.gripOverlay = e;
|
|
4013
4037
|
}
|
|
4014
|
-
return this.element =
|
|
4038
|
+
return this.element = s, this.model.withHeadings && N(this.gridElement, this.model.withHeadings), this.model.withHeadingColumn && F(this.gridElement, this.model.withHeadingColumn), this.readOnly || (this.initCellBlocks(u), Ir(u, this.cellBlocks)), s;
|
|
4015
4039
|
}
|
|
4016
4040
|
rendered() {
|
|
4017
4041
|
if (!this.element || this.initialContent === null) return;
|
|
@@ -4020,22 +4044,22 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4020
4044
|
let t = this.initialContent;
|
|
4021
4045
|
if (this.initialContent = null, this.readOnly) {
|
|
4022
4046
|
var n;
|
|
4023
|
-
|
|
4047
|
+
Pr(e, t, this.api, (n = this.blockId) == null ? "" : n), P(e, this.model.snapshot().content), this.initScrollHaze();
|
|
4024
4048
|
return;
|
|
4025
4049
|
}
|
|
4026
4050
|
if (this.runTransactedStructuralOp(() => {
|
|
4027
4051
|
var n, r;
|
|
4028
|
-
let i = (n = (r = this.cellBlocks) == null ? void 0 : r.initializeCells(t)) == null ? t : n, a = this.isNewTable && i.length === 0 ? Array.from(e.querySelectorAll(`[${
|
|
4029
|
-
let t = e.querySelectorAll(`[${
|
|
4052
|
+
let i = (n = (r = this.cellBlocks) == null ? void 0 : r.initializeCells(t)) == null ? t : n, a = this.isNewTable && i.length === 0 ? Array.from(e.querySelectorAll(`[${T}]`), (e) => {
|
|
4053
|
+
let t = e.querySelectorAll(`[${E}]`).length;
|
|
4030
4054
|
return Array.from({ length: t }, () => ({ blocks: [] }));
|
|
4031
4055
|
}) : i;
|
|
4032
|
-
this.model.replaceAll(
|
|
4056
|
+
this.model.replaceAll(b(b({}, this.model.snapshot()), {}, { content: a })), this.isNewTable && M(e, this.cellBlocks), this.removeGhostChildren();
|
|
4033
4057
|
}, !0), this.model.initialColWidth === void 0) {
|
|
4034
4058
|
var r;
|
|
4035
|
-
let t = (r = this.model.colWidths) == null ?
|
|
4036
|
-
this.model.setInitialColWidth(t.length > 0 ?
|
|
4059
|
+
let t = (r = this.model.colWidths) == null ? k(e) : r;
|
|
4060
|
+
this.model.setInitialColWidth(t.length > 0 ? jr(t) : void 0);
|
|
4037
4061
|
}
|
|
4038
|
-
if (this.initSubsystems(e),
|
|
4062
|
+
if (this.initSubsystems(e), P(e, this.model.snapshot().content), this.isNewTable) {
|
|
4039
4063
|
var i;
|
|
4040
4064
|
(i = this.cellSelection) == null || i.selectRange({
|
|
4041
4065
|
minRow: 0,
|
|
@@ -4063,7 +4087,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4063
4087
|
setData(e) {
|
|
4064
4088
|
var t, n, r, i, a;
|
|
4065
4089
|
this.setDataGeneration++;
|
|
4066
|
-
let o = this.setDataGeneration, s =
|
|
4090
|
+
let o = this.setDataGeneration, s = Fr(b(b({}, this.model.snapshot()), e), this.config);
|
|
4067
4091
|
this.initialContent = s.content, this.model.replaceAll(s), this.api.blocks.isSyncingFromYjs || this.runStructuralOp(() => {
|
|
4068
4092
|
var e;
|
|
4069
4093
|
(e = this.cellBlocks) == null || e.deleteAllBlocks();
|
|
@@ -4077,7 +4101,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4077
4101
|
let f = this.gridElement;
|
|
4078
4102
|
if (f) {
|
|
4079
4103
|
if (this.readOnly) {
|
|
4080
|
-
|
|
4104
|
+
P(f, this.model.snapshot().content);
|
|
4081
4105
|
return;
|
|
4082
4106
|
}
|
|
4083
4107
|
o === this.setDataGeneration && (this.runStructuralOp(() => {
|
|
@@ -4085,15 +4109,15 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4085
4109
|
let i = (e = (t = (n = this.cellBlocks) == null ? void 0 : n.initializeCells((r = this.initialContent) == null ? [] : r)) == null ? this.initialContent : t) == null ? [] : e;
|
|
4086
4110
|
if (o === this.setDataGeneration) {
|
|
4087
4111
|
if (this.api.blocks.isSyncingFromYjs && i.length === 0 && f) {
|
|
4088
|
-
let e = Array.from(f.querySelectorAll(`[${
|
|
4089
|
-
let t = e.querySelectorAll(`[${
|
|
4112
|
+
let e = Array.from(f.querySelectorAll(`[${T}]`), (e) => {
|
|
4113
|
+
let t = e.querySelectorAll(`[${E}]`).length;
|
|
4090
4114
|
return Array.from({ length: t }, () => ({ blocks: [] }));
|
|
4091
4115
|
});
|
|
4092
|
-
this.model.replaceAll(
|
|
4093
|
-
} else this.model.replaceAll(
|
|
4116
|
+
this.model.replaceAll(b(b({}, this.model.snapshot()), {}, { content: e })), M(f, this.cellBlocks);
|
|
4117
|
+
} else this.model.replaceAll(b(b({}, this.model.snapshot()), {}, { content: i }));
|
|
4094
4118
|
this.initialContent = null;
|
|
4095
4119
|
}
|
|
4096
|
-
}, !0), o === this.setDataGeneration && (this.initSubsystems(f), l !== null && this.cellSelection !== null && this.cellSelection.selectRange(l), u !== null && this.rowColControls !== null && this.rowColControls.restoreVisibleGrips(u.col, u.row),
|
|
4120
|
+
}, !0), o === this.setDataGeneration && (this.initSubsystems(f), l !== null && this.cellSelection !== null && this.cellSelection.selectRange(l), u !== null && this.rowColControls !== null && this.rowColControls.restoreVisibleGrips(u.col, u.row), P(f, this.model.snapshot().content)));
|
|
4097
4121
|
}
|
|
4098
4122
|
}
|
|
4099
4123
|
onPaste(e) {
|
|
@@ -4105,9 +4129,9 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4105
4129
|
var t;
|
|
4106
4130
|
n.push(e.innerHTML);
|
|
4107
4131
|
let i = (t = e.getAttribute("style")) == null ? "" : t, a = {}, o = /background-color\s*:\s*([^;]+)/i.exec(i);
|
|
4108
|
-
o != null && o[1] && (a.color =
|
|
4132
|
+
o != null && o[1] && (a.color = ye(o[1].trim(), "bg"));
|
|
4109
4133
|
let s = (/* @__PURE__ */ RegExp("(?<![a-z-])color\\s*:\\s*([^;]+)", "i")).exec(i);
|
|
4110
|
-
s != null && s[1] && !
|
|
4134
|
+
s != null && s[1] && !_e(s[1].trim()) && (a.textColor = ye(s[1].trim(), "text")), r.push(a);
|
|
4111
4135
|
}), n.length > 0 && (a.push(n), o.push(r));
|
|
4112
4136
|
});
|
|
4113
4137
|
let s = r.querySelector("thead") !== null, c = ((t = i[0]) == null ? void 0 : t.querySelector("th")) !== null, l = s || c;
|
|
@@ -4123,12 +4147,12 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4123
4147
|
!this.readOnly && f && (this.runStructuralOp(() => {
|
|
4124
4148
|
var e, t, n, r;
|
|
4125
4149
|
let i = (e = (t = (n = this.cellBlocks) == null ? void 0 : n.initializeCells((r = this.initialContent) == null ? [] : r)) == null ? this.initialContent : t) == null ? [] : e;
|
|
4126
|
-
this.model.replaceAll(
|
|
4150
|
+
this.model.replaceAll(b(b({}, this.model.snapshot()), {}, { content: i })), this.initialContent = null, o.forEach((e, t) => {
|
|
4127
4151
|
e.forEach((e, n) => {
|
|
4128
4152
|
e.color !== void 0 && this.model.setCellColor(t, n, e.color), e.textColor !== void 0 && this.model.setCellTextColor(t, n, e.textColor);
|
|
4129
4153
|
});
|
|
4130
4154
|
});
|
|
4131
|
-
}, !0), this.initSubsystems(f),
|
|
4155
|
+
}, !0), this.initSubsystems(f), P(f, this.model.snapshot().content));
|
|
4132
4156
|
}
|
|
4133
4157
|
destroy() {
|
|
4134
4158
|
var e, t;
|
|
@@ -4155,35 +4179,35 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4155
4179
|
});
|
|
4156
4180
|
}
|
|
4157
4181
|
getBlockIdsInRow(e) {
|
|
4158
|
-
return
|
|
4182
|
+
return Mr(this.element, this.cellBlocks, e);
|
|
4159
4183
|
}
|
|
4160
4184
|
getBlockIdsInColumn(e) {
|
|
4161
|
-
return
|
|
4185
|
+
return Nr(this.element, this.cellBlocks, e);
|
|
4162
4186
|
}
|
|
4163
4187
|
initAddControls(e) {
|
|
4164
4188
|
var t;
|
|
4165
4189
|
if ((t = this.addControls) == null || t.destroy(), !this.element) return;
|
|
4166
4190
|
let n = { addedCols: 0 };
|
|
4167
|
-
this.addControls = new
|
|
4191
|
+
this.addControls = new Xn({
|
|
4168
4192
|
wrapper: this.element,
|
|
4169
4193
|
grid: e,
|
|
4170
4194
|
i18n: this.api.i18n,
|
|
4171
4195
|
getNewColumnWidth: () => {
|
|
4172
4196
|
var t;
|
|
4173
|
-
let n = (t = this.model.colWidths) == null ?
|
|
4174
|
-
return this.model.initialColWidth === void 0 ?
|
|
4197
|
+
let n = (t = this.model.colWidths) == null ? k(e) : t;
|
|
4198
|
+
return this.model.initialColWidth === void 0 ? j(n) : Math.round(this.model.initialColWidth / 2 * 100) / 100;
|
|
4175
4199
|
},
|
|
4176
4200
|
onAddRow: () => {
|
|
4177
4201
|
this.runTransactedStructuralOp(() => {
|
|
4178
4202
|
var t, n;
|
|
4179
|
-
this.grid.addRow(e), this.model.addRow(),
|
|
4203
|
+
this.grid.addRow(e), this.model.addRow(), M(e, this.cellBlocks), N(this.gridElement, this.model.withHeadings), F(this.gridElement, this.model.withHeadingColumn), this.initResize(e), (t = this.addControls) == null || t.syncRowButtonWidth(), (n = this.rowColControls) == null || n.refresh();
|
|
4180
4204
|
});
|
|
4181
4205
|
},
|
|
4182
4206
|
onAddColumn: () => {
|
|
4183
4207
|
this.runTransactedStructuralOp(() => {
|
|
4184
4208
|
var t, n, r;
|
|
4185
|
-
let i = (t = this.model.colWidths) == null ?
|
|
4186
|
-
this.grid.addColumn(e, void 0, i, a), this.model.addColumn(void 0, a), this.model.setColWidths([...i, a]),
|
|
4209
|
+
let i = (t = this.model.colWidths) == null ? k(e) : t, a = this.model.initialColWidth === void 0 ? j(i) : Math.round(this.model.initialColWidth / 2 * 100) / 100;
|
|
4210
|
+
this.grid.addColumn(e, void 0, i, a), this.model.addColumn(void 0, a), this.model.setColWidths([...i, a]), M(e, this.cellBlocks), F(this.gridElement, this.model.withHeadingColumn), this.initResize(e), (n = this.rowColControls) == null || n.refresh(), this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth), (r = this.addControls) == null || r.syncRowButtonWidth();
|
|
4187
4211
|
});
|
|
4188
4212
|
},
|
|
4189
4213
|
onDragStart: () => {
|
|
@@ -4192,13 +4216,13 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4192
4216
|
},
|
|
4193
4217
|
onDragAddRow: () => {
|
|
4194
4218
|
this.runTransactedStructuralOp(() => {
|
|
4195
|
-
this.grid.addRow(e), this.model.addRow(),
|
|
4219
|
+
this.grid.addRow(e), this.model.addRow(), M(e, this.cellBlocks), N(this.gridElement, this.model.withHeadings), F(this.gridElement, this.model.withHeadingColumn);
|
|
4196
4220
|
});
|
|
4197
4221
|
},
|
|
4198
4222
|
onDragRemoveRow: () => {
|
|
4199
4223
|
this.runTransactedStructuralOp(() => {
|
|
4200
4224
|
let t = this.grid.getRowCount(e);
|
|
4201
|
-
if (t > 1 &&
|
|
4225
|
+
if (t > 1 && Tr(e, t - 1)) {
|
|
4202
4226
|
var n;
|
|
4203
4227
|
let { blocksToDelete: r } = this.model.deleteRow(t - 1);
|
|
4204
4228
|
(n = this.cellBlocks) == null || n.deleteBlocks(r), this.grid.deleteRow(e, t - 1);
|
|
@@ -4208,19 +4232,19 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4208
4232
|
onDragAddCol: () => {
|
|
4209
4233
|
this.runTransactedStructuralOp(() => {
|
|
4210
4234
|
var t;
|
|
4211
|
-
let r = (t = this.model.colWidths) == null ?
|
|
4212
|
-
this.grid.addColumn(e, void 0, r, i), this.model.addColumn(void 0, i), this.model.setColWidths(a),
|
|
4235
|
+
let r = (t = this.model.colWidths) == null ? k(e) : t, i = this.model.initialColWidth === void 0 ? j(r) : Math.round(this.model.initialColWidth / 2 * 100) / 100, a = [...r, i];
|
|
4236
|
+
this.grid.addColumn(e, void 0, r, i), this.model.addColumn(void 0, i), this.model.setColWidths(a), A(e, a), M(e, this.cellBlocks), F(this.gridElement, this.model.withHeadingColumn), this.initResize(e), n.addedCols++, this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth);
|
|
4213
4237
|
});
|
|
4214
4238
|
},
|
|
4215
4239
|
onDragRemoveCol: () => {
|
|
4216
4240
|
this.runTransactedStructuralOp(() => {
|
|
4217
4241
|
var t;
|
|
4218
4242
|
let r = this.grid.getColumnCount(e);
|
|
4219
|
-
if (r <= 1 || !
|
|
4243
|
+
if (r <= 1 || !Er(e, r - 1)) return;
|
|
4220
4244
|
let { blocksToDelete: i } = this.model.deleteColumn(r - 1);
|
|
4221
4245
|
(t = this.cellBlocks) == null || t.deleteBlocks(i), this.grid.deleteColumn(e, r - 1);
|
|
4222
4246
|
let a = this.model.colWidths;
|
|
4223
|
-
a &&
|
|
4247
|
+
a && A(e, a), this.initResize(e), n.addedCols--;
|
|
4224
4248
|
});
|
|
4225
4249
|
},
|
|
4226
4250
|
onDragEnd: () => {
|
|
@@ -4231,7 +4255,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4231
4255
|
}
|
|
4232
4256
|
initRowColControls(e) {
|
|
4233
4257
|
var t, n, r;
|
|
4234
|
-
(t = this.rowColControls) == null || t.destroy(), this.element && (this.rowColControls = new
|
|
4258
|
+
(t = this.rowColControls) == null || t.destroy(), this.element && (this.rowColControls = new bi({
|
|
4235
4259
|
grid: e,
|
|
4236
4260
|
overlay: (n = this.gripOverlay) == null ? void 0 : n,
|
|
4237
4261
|
scrollContainer: (r = this.scrollContainer) == null ? void 0 : r,
|
|
@@ -4279,7 +4303,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4279
4303
|
this.runTransactedStructuralOp(() => {
|
|
4280
4304
|
var r, i;
|
|
4281
4305
|
if (n !== this.setDataGeneration || this.gridElement !== e) return;
|
|
4282
|
-
let a = this.model.colWidths, { blocksToDelete: o } = this.syncModelForAction(t), s =
|
|
4306
|
+
let a = this.model.colWidths, { blocksToDelete: o } = this.syncModelForAction(t), s = Qr(e, t, {
|
|
4283
4307
|
grid: this.grid,
|
|
4284
4308
|
data: {
|
|
4285
4309
|
colWidths: a,
|
|
@@ -4291,7 +4315,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4291
4315
|
blocksToDelete: o
|
|
4292
4316
|
});
|
|
4293
4317
|
if (n !== this.setDataGeneration || this.gridElement !== e) return;
|
|
4294
|
-
if (this.model.setColWidths(s.colWidths), this.model.setWithHeadings(s.withHeadings), this.model.setWithHeadingColumn(s.withHeadingColumn), this.pendingHighlight = s.pendingHighlight,
|
|
4318
|
+
if (this.model.setColWidths(s.colWidths), this.model.setWithHeadings(s.withHeadings), this.model.setWithHeadingColumn(s.withHeadingColumn), this.pendingHighlight = s.pendingHighlight, N(this.gridElement, this.model.withHeadings), F(this.gridElement, this.model.withHeadingColumn), this.initResize(e), (r = this.addControls) == null || r.syncRowButtonWidth(), !(t.type === "toggle-heading" || t.type === "toggle-heading-column")) {
|
|
4295
4319
|
var c;
|
|
4296
4320
|
(c = this.rowColControls) == null || c.refresh();
|
|
4297
4321
|
}
|
|
@@ -4337,10 +4361,10 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4337
4361
|
initResize(e) {
|
|
4338
4362
|
var t, n;
|
|
4339
4363
|
(t = this.resize) == null || t.destroy();
|
|
4340
|
-
let r = this.model.colWidths === void 0, i = (n = this.model.colWidths) == null ?
|
|
4341
|
-
r ||
|
|
4364
|
+
let r = this.model.colWidths === void 0, i = (n = this.model.colWidths) == null ? k(e) : n;
|
|
4365
|
+
r || Rr(this.ensureScrollContainer()), this.resize = new Gr(e, i, (e) => {
|
|
4342
4366
|
var t, n, r;
|
|
4343
|
-
this.model.setColWidths(e),
|
|
4367
|
+
this.model.setColWidths(e), Rr(this.ensureScrollContainer()), (t = this.rowColControls) == null || t.positionGrips(), (n = this.addControls) == null || n.syncRowButtonWidth(), (r = this.scrollHaze) == null || r.update();
|
|
4344
4368
|
}, () => {
|
|
4345
4369
|
var e;
|
|
4346
4370
|
(e = this.rowColControls) == null || e.hideAllGrips();
|
|
@@ -4351,7 +4375,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4351
4375
|
}
|
|
4352
4376
|
initCellBlocks(e) {
|
|
4353
4377
|
var t;
|
|
4354
|
-
this.cellBlocks = new
|
|
4378
|
+
this.cellBlocks = new nr({
|
|
4355
4379
|
api: this.api,
|
|
4356
4380
|
gridElement: e,
|
|
4357
4381
|
tableBlockId: (t = this.blockId) == null ? "" : t,
|
|
@@ -4362,13 +4386,13 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4362
4386
|
handleCellCopy(e, t) {
|
|
4363
4387
|
let n = this.collectCellBlockData(e);
|
|
4364
4388
|
if (n.length === 0) return;
|
|
4365
|
-
let r =
|
|
4366
|
-
t.setData("text/html",
|
|
4389
|
+
let r = xe(n);
|
|
4390
|
+
t.setData("text/html", We(r)), t.setData("text/plain", me(r));
|
|
4367
4391
|
}
|
|
4368
4392
|
handleCellCopyViaButton(e) {
|
|
4369
4393
|
let t = this.collectCellBlockData(e);
|
|
4370
4394
|
if (t.length === 0) return;
|
|
4371
|
-
let n =
|
|
4395
|
+
let n = xe(t), r = We(n), i = me(n), a = new Blob([r], { type: "text/html" }), o = new Blob([i], { type: "text/plain" });
|
|
4372
4396
|
navigator.clipboard.write([new ClipboardItem({
|
|
4373
4397
|
"text/html": a,
|
|
4374
4398
|
"text/plain": o
|
|
@@ -4378,7 +4402,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4378
4402
|
let r = this.gridElement;
|
|
4379
4403
|
r && this.runTransactedStructuralOp(() => {
|
|
4380
4404
|
for (let i of e) {
|
|
4381
|
-
let e =
|
|
4405
|
+
let e = Cr(r, i);
|
|
4382
4406
|
e && (n === "backgroundColor" ? (this.model.setCellColor(e.row, e.col, t == null ? void 0 : t), i.style.backgroundColor = t == null ? "" : t) : (this.model.setCellTextColor(e.row, e.col, t == null ? void 0 : t), i.style.color = t == null ? "" : t));
|
|
4383
4407
|
}
|
|
4384
4408
|
});
|
|
@@ -4386,12 +4410,12 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4386
4410
|
collectCellBlockData(e) {
|
|
4387
4411
|
let t = this.gridElement;
|
|
4388
4412
|
if (!t) return [];
|
|
4389
|
-
let n = Array.from(t.querySelectorAll(`[${
|
|
4413
|
+
let n = Array.from(t.querySelectorAll(`[${T}]`));
|
|
4390
4414
|
return e.map((e) => {
|
|
4391
4415
|
var t;
|
|
4392
|
-
let r = e.closest(`[${
|
|
4416
|
+
let r = e.closest(`[${T}]`);
|
|
4393
4417
|
if (!r) return null;
|
|
4394
|
-
let i = n.indexOf(r), a = Array.from(r.querySelectorAll(`[${
|
|
4418
|
+
let i = n.indexOf(r), a = Array.from(r.querySelectorAll(`[${E}]`)).indexOf(e), o = e.querySelector(`[${O}]`), s = [];
|
|
4395
4419
|
if (!o) return {
|
|
4396
4420
|
row: i,
|
|
4397
4421
|
col: a,
|
|
@@ -4403,7 +4427,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4403
4427
|
let n = this.api.blocks.getBlockIndex(t);
|
|
4404
4428
|
if (n === void 0) return;
|
|
4405
4429
|
let r = this.api.blocks.getBlockByIndex(n);
|
|
4406
|
-
r && s.push(
|
|
4430
|
+
r && s.push(b({
|
|
4407
4431
|
tool: r.name,
|
|
4408
4432
|
data: r.preservedData
|
|
4409
4433
|
}, Object.keys(r.preservedTunes).length > 0 ? { tunes: r.preservedTunes } : {}));
|
|
@@ -4414,7 +4438,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4414
4438
|
data: { text: c }
|
|
4415
4439
|
});
|
|
4416
4440
|
let l = this.model.getCellColor(i, a), u = this.model.getCellTextColor(i, a);
|
|
4417
|
-
return
|
|
4441
|
+
return b(b({
|
|
4418
4442
|
row: i,
|
|
4419
4443
|
col: a,
|
|
4420
4444
|
blocks: s
|
|
@@ -4425,7 +4449,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4425
4449
|
var t;
|
|
4426
4450
|
(t = this.cellSelection) == null || t.destroy();
|
|
4427
4451
|
let n = this.api.rectangleSelection;
|
|
4428
|
-
this.cellSelection = new
|
|
4452
|
+
this.cellSelection = new Sr({
|
|
4429
4453
|
grid: e,
|
|
4430
4454
|
rectangleSelection: n,
|
|
4431
4455
|
i18n: this.api.i18n,
|
|
@@ -4452,7 +4476,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4452
4476
|
t.deleteBlocks(n);
|
|
4453
4477
|
let r = this.gridElement;
|
|
4454
4478
|
if (r) for (let t of e) {
|
|
4455
|
-
let e =
|
|
4479
|
+
let e = Cr(r, t);
|
|
4456
4480
|
e && (this.model.setCellColor(e.row, e.col, void 0), this.model.setCellTextColor(e.row, e.col, void 0), t.style.backgroundColor = "", t.style.color = "");
|
|
4457
4481
|
}
|
|
4458
4482
|
});
|
|
@@ -4473,7 +4497,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4473
4497
|
}
|
|
4474
4498
|
initScrollHaze() {
|
|
4475
4499
|
var e;
|
|
4476
|
-
(e = this.scrollHaze) == null || e.destroy(), !(!this.element || !this.scrollContainer) && (this.scrollHaze = new
|
|
4500
|
+
(e = this.scrollHaze) == null || e.destroy(), !(!this.element || !this.scrollContainer) && (this.scrollHaze = new Di(), this.scrollHaze.init(this.element, this.scrollContainer));
|
|
4477
4501
|
}
|
|
4478
4502
|
initGridPasteListener(e) {
|
|
4479
4503
|
e.addEventListener("paste", (t) => {
|
|
@@ -4482,20 +4506,20 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4482
4506
|
}
|
|
4483
4507
|
handleGridPaste(e, t) {
|
|
4484
4508
|
if (this.readOnly || !e.clipboardData || e.defaultPrevented) return;
|
|
4485
|
-
let n = e.clipboardData.getData("text/html"), r =
|
|
4509
|
+
let n = e.clipboardData.getData("text/html"), r = Ie(n), i = r === null ? Ae(n) : null, a = r == null ? i : r;
|
|
4486
4510
|
if (!a || i !== null && new DOMParser().parseFromString(n, "text/html").querySelectorAll("table").length > 1) return;
|
|
4487
4511
|
let o = document.activeElement;
|
|
4488
4512
|
if (!o) return;
|
|
4489
|
-
let s = o.closest(`[${
|
|
4513
|
+
let s = o.closest(`[${E}]`);
|
|
4490
4514
|
if (!s || !t.contains(s)) return;
|
|
4491
|
-
let c = s.closest(`[${
|
|
4515
|
+
let c = s.closest(`[${T}]`);
|
|
4492
4516
|
if (!c) return;
|
|
4493
4517
|
if (a.rows === 1 && a.cols === 1) {
|
|
4494
4518
|
e.preventDefault(), e.stopPropagation(), this.insertSingleCellPayloadInline(a.cells[0][0]);
|
|
4495
4519
|
return;
|
|
4496
4520
|
}
|
|
4497
4521
|
e.preventDefault(), e.stopPropagation();
|
|
4498
|
-
let l = Array.from(t.querySelectorAll(`[${
|
|
4522
|
+
let l = Array.from(t.querySelectorAll(`[${T}]`)).indexOf(c), u = Array.from(c.querySelectorAll(`[${E}]`)).indexOf(s);
|
|
4499
4523
|
this.pastePayloadIntoCells(t, a, l, u);
|
|
4500
4524
|
}
|
|
4501
4525
|
insertSingleCellPayloadInline(e) {
|
|
@@ -4516,11 +4540,11 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4516
4540
|
this.runTransactedStructuralOp(() => {
|
|
4517
4541
|
var i, a;
|
|
4518
4542
|
this.expandGridForPaste(e, n + t.rows, r + t.cols);
|
|
4519
|
-
let o = e.querySelectorAll(`[${
|
|
4543
|
+
let o = e.querySelectorAll(`[${T}]`);
|
|
4520
4544
|
Array.from({ length: t.rows }, (e, t) => t).forEach((e) => {
|
|
4521
4545
|
let i = o[n + e];
|
|
4522
4546
|
if (!i) return;
|
|
4523
|
-
let a = i.querySelectorAll(`[${
|
|
4547
|
+
let a = i.querySelectorAll(`[${E}]`);
|
|
4524
4548
|
Array.from({ length: t.cols }, (e, t) => t).forEach((i) => {
|
|
4525
4549
|
let o = a[r + i];
|
|
4526
4550
|
if (o) {
|
|
@@ -4535,7 +4559,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4535
4559
|
});
|
|
4536
4560
|
}), this.initResize(e), (i = this.addControls) == null || i.syncRowButtonWidth(), (a = this.rowColControls) == null || a.refresh();
|
|
4537
4561
|
});
|
|
4538
|
-
let i = e.querySelectorAll(`[${
|
|
4562
|
+
let i = e.querySelectorAll(`[${T}]`)[n + t.rows - 1], a = i == null ? void 0 : i.querySelectorAll(`[${E}]`)[r + t.cols - 1];
|
|
4539
4563
|
if (!a || !this.cellBlocks || !this.api.caret) return;
|
|
4540
4564
|
let o = this.cellBlocks.getBlockIdsFromCells([a]), s = o[o.length - 1];
|
|
4541
4565
|
s !== void 0 && this.api.caret.setToBlock(s, "end");
|
|
@@ -4543,11 +4567,11 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4543
4567
|
expandGridForPaste(e, t, n) {
|
|
4544
4568
|
let r = this.grid.getRowCount(e), i = this.grid.getColumnCount(e);
|
|
4545
4569
|
Array.from({ length: Math.max(0, t - r) }).forEach(() => {
|
|
4546
|
-
this.grid.addRow(e), this.model.addRow(),
|
|
4570
|
+
this.grid.addRow(e), this.model.addRow(), M(e, this.cellBlocks), N(this.gridElement, this.model.withHeadings), F(this.gridElement, this.model.withHeadingColumn);
|
|
4547
4571
|
}), Array.from({ length: Math.max(0, n - i) }).forEach(() => {
|
|
4548
4572
|
var t;
|
|
4549
|
-
let n = (t = this.model.colWidths) == null ?
|
|
4550
|
-
this.grid.addColumn(e, void 0, n, r), this.model.addColumn(void 0, r), this.model.setColWidths([...n, r]),
|
|
4573
|
+
let n = (t = this.model.colWidths) == null ? k(e) : t, r = this.model.initialColWidth === void 0 ? j(n) : Math.round(this.model.initialColWidth / 2 * 100) / 100;
|
|
4574
|
+
this.grid.addColumn(e, void 0, n, r), this.model.addColumn(void 0, r), this.model.setColWidths([...n, r]), M(e, this.cellBlocks), F(this.gridElement, this.model.withHeadingColumn);
|
|
4551
4575
|
});
|
|
4552
4576
|
}
|
|
4553
4577
|
pasteCellPayload(e, t) {
|
|
@@ -4555,7 +4579,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4555
4579
|
let t = this.cellBlocks.getBlockIdsFromCells([e]);
|
|
4556
4580
|
this.cellBlocks.deleteBlocks(t);
|
|
4557
4581
|
}
|
|
4558
|
-
let n = e.querySelector(`[${
|
|
4582
|
+
let n = e.querySelector(`[${O}]`);
|
|
4559
4583
|
if (n) {
|
|
4560
4584
|
if (t.blocks.length === 0) {
|
|
4561
4585
|
var r;
|
|
@@ -4569,19 +4593,19 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4569
4593
|
}
|
|
4570
4594
|
}
|
|
4571
4595
|
}
|
|
4572
|
-
},
|
|
4596
|
+
}, Ni = (e) => {
|
|
4573
4597
|
let t = document.createElement("div");
|
|
4574
4598
|
t.innerHTML = e.trim();
|
|
4575
4599
|
let n = document.createDocumentFragment();
|
|
4576
4600
|
return n.append(...Array.from(t.childNodes)), n;
|
|
4577
|
-
},
|
|
4601
|
+
}, Pi = (e, t, n, r) => {
|
|
4578
4602
|
if (!t) return e;
|
|
4579
4603
|
let i = n();
|
|
4580
4604
|
return {
|
|
4581
|
-
text: i ?
|
|
4605
|
+
text: i ? $e(i.innerHTML) : e.text,
|
|
4582
4606
|
isOpen: r
|
|
4583
4607
|
};
|
|
4584
|
-
},
|
|
4608
|
+
}, Fi = (e, t) => {
|
|
4585
4609
|
let { data: n, getContentElement: r } = e;
|
|
4586
4610
|
n.text += t.text;
|
|
4587
4611
|
let i = r();
|
|
@@ -4589,18 +4613,18 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4589
4613
|
let n = e.parseHTML(t.text);
|
|
4590
4614
|
i.appendChild(n), i.normalize();
|
|
4591
4615
|
}
|
|
4592
|
-
},
|
|
4616
|
+
}, Ii = (e, t, n) => {
|
|
4593
4617
|
let r = n();
|
|
4594
4618
|
if (!r) return {
|
|
4595
4619
|
newData: e,
|
|
4596
4620
|
inPlace: !1
|
|
4597
4621
|
};
|
|
4598
|
-
let i =
|
|
4622
|
+
let i = b(b({}, e), t);
|
|
4599
4623
|
return typeof t.text == "string" && (r.innerHTML = t.text), {
|
|
4600
4624
|
newData: i,
|
|
4601
4625
|
inPlace: !0
|
|
4602
4626
|
};
|
|
4603
|
-
},
|
|
4627
|
+
}, Li = class e {
|
|
4604
4628
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
4605
4629
|
var a;
|
|
4606
4630
|
this._element = null, this._contentElement = null, this._arrowElement = null, this._bodyPlaceholderElement = null, this._childContainerElement = null, this.handleBlockChanged = (e) => {
|
|
@@ -4620,22 +4644,22 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4620
4644
|
}
|
|
4621
4645
|
get placeholder() {
|
|
4622
4646
|
if (this._settings.placeholder) return this._settings.placeholder;
|
|
4623
|
-
let e = this.api.i18n.t(
|
|
4647
|
+
let e = this.api.i18n.t(Oe);
|
|
4624
4648
|
return e === "tools.toggle.placeholder" ? "Toggle" : e;
|
|
4625
4649
|
}
|
|
4626
4650
|
render() {
|
|
4627
|
-
let e =
|
|
4651
|
+
let e = mt({
|
|
4628
4652
|
data: this._data,
|
|
4629
4653
|
readOnly: this.readOnly,
|
|
4630
4654
|
isOpen: this._isOpen,
|
|
4631
4655
|
placeholder: this.placeholder,
|
|
4632
4656
|
keydownHandler: this.readOnly ? null : this.handleKeyDown.bind(this),
|
|
4633
|
-
onArrowClick:
|
|
4657
|
+
onArrowClick: () => this.toggleOpen(),
|
|
4634
4658
|
onBodyPlaceholderClick: this.readOnly ? null : () => this.handleBodyPlaceholderClick(),
|
|
4635
|
-
bodyPlaceholderText: this.api.i18n.t(
|
|
4659
|
+
bodyPlaceholderText: this.api.i18n.t(Ne),
|
|
4636
4660
|
ariaLabels: {
|
|
4637
|
-
collapse: this.api.i18n.t(
|
|
4638
|
-
expand: this.api.i18n.t(
|
|
4661
|
+
collapse: this.api.i18n.t(He),
|
|
4662
|
+
expand: this.api.i18n.t(je)
|
|
4639
4663
|
}
|
|
4640
4664
|
});
|
|
4641
4665
|
return this._element = e.wrapper, this._contentElement = e.contentElement, this._arrowElement = e.arrowElement, this._bodyPlaceholderElement = e.bodyPlaceholderElement, this._childContainerElement = e.childContainerElement, this._element;
|
|
@@ -4644,31 +4668,31 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4644
4668
|
this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility();
|
|
4645
4669
|
}
|
|
4646
4670
|
save() {
|
|
4647
|
-
return
|
|
4671
|
+
return Pi(this._data, this._element, this.getContentElement.bind(this), this._isOpen);
|
|
4648
4672
|
}
|
|
4649
4673
|
validate(e) {
|
|
4650
4674
|
return !0;
|
|
4651
4675
|
}
|
|
4652
4676
|
merge(e) {
|
|
4653
|
-
|
|
4677
|
+
Fi({
|
|
4654
4678
|
data: this._data,
|
|
4655
4679
|
getContentElement: this.getContentElement.bind(this),
|
|
4656
|
-
parseHTML:
|
|
4680
|
+
parseHTML: Ni
|
|
4657
4681
|
}, e);
|
|
4658
4682
|
}
|
|
4659
4683
|
onPaste(t) {
|
|
4660
4684
|
let n = t.detail;
|
|
4661
4685
|
if (!("data" in n)) return;
|
|
4662
|
-
let r = n.data, i = r.querySelector("summary"), a =
|
|
4686
|
+
let r = n.data, i = r.querySelector("summary"), a = Te(i === null ? r.innerHTML : i.innerHTML, e.sanitize.text);
|
|
4663
4687
|
this._data = { text: a };
|
|
4664
4688
|
let o = this.getContentElement();
|
|
4665
4689
|
o !== null && (o.innerHTML = a);
|
|
4666
4690
|
}
|
|
4667
4691
|
setData(e) {
|
|
4668
|
-
let t =
|
|
4669
|
-
return this._data = t.newData, typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen), this._arrowElement && this._element &&
|
|
4670
|
-
collapse: this.api.i18n.t(
|
|
4671
|
-
expand: this.api.i18n.t(
|
|
4692
|
+
let t = Ii(this._data, e, this.getContentElement.bind(this));
|
|
4693
|
+
return this._data = t.newData, typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen), this._arrowElement && this._element && C(this._arrowElement, this._element, this._isOpen, {
|
|
4694
|
+
collapse: this.api.i18n.t(He),
|
|
4695
|
+
expand: this.api.i18n.t(je)
|
|
4672
4696
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility(), t.inPlace;
|
|
4673
4697
|
}
|
|
4674
4698
|
renderSettings() {
|
|
@@ -4690,19 +4714,19 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4690
4714
|
return this._contentElement;
|
|
4691
4715
|
}
|
|
4692
4716
|
setOpenState(e) {
|
|
4693
|
-
this._isOpen = e, this._arrowElement && this._element &&
|
|
4694
|
-
collapse: this.api.i18n.t(
|
|
4695
|
-
expand: this.api.i18n.t(
|
|
4717
|
+
this._isOpen = e, this._arrowElement && this._element && C(this._arrowElement, this._element, this._isOpen, {
|
|
4718
|
+
collapse: this.api.i18n.t(He),
|
|
4719
|
+
expand: this.api.i18n.t(je)
|
|
4696
4720
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility();
|
|
4697
4721
|
}
|
|
4698
4722
|
toggleOpen() {
|
|
4699
4723
|
this.setOpenState(!this._isOpen);
|
|
4700
4724
|
}
|
|
4701
4725
|
updateChildrenVisibility() {
|
|
4702
|
-
this.blockId !== void 0 &&
|
|
4726
|
+
this.blockId !== void 0 && ht(this.api, this.blockId, this._isOpen, this._childContainerElement, this._arrowElement);
|
|
4703
4727
|
}
|
|
4704
4728
|
updateBodyPlaceholderVisibility() {
|
|
4705
|
-
this.blockId !== void 0 &&
|
|
4729
|
+
this.blockId !== void 0 && gt(this._bodyPlaceholderElement, this.api, this.blockId, this._isOpen, this.readOnly);
|
|
4706
4730
|
}
|
|
4707
4731
|
handleBodyPlaceholderClick() {
|
|
4708
4732
|
var e;
|
|
@@ -4738,10 +4762,10 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4738
4762
|
}
|
|
4739
4763
|
async handleEnter() {
|
|
4740
4764
|
var e = this;
|
|
4741
|
-
await
|
|
4765
|
+
await _t(e.createKeyboardContext()), e.updateBodyPlaceholderVisibility();
|
|
4742
4766
|
}
|
|
4743
4767
|
async handleBackspace(e) {
|
|
4744
|
-
await
|
|
4768
|
+
await vt(this.createKeyboardContext(), e);
|
|
4745
4769
|
}
|
|
4746
4770
|
syncContentFromDOM() {
|
|
4747
4771
|
let e = this.getContentElement();
|
|
@@ -4749,10 +4773,10 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4749
4773
|
}
|
|
4750
4774
|
static get toolbox() {
|
|
4751
4775
|
return {
|
|
4752
|
-
icon:
|
|
4776
|
+
icon: Pe,
|
|
4753
4777
|
title: "Toggle list",
|
|
4754
4778
|
titleKey: "toggleList",
|
|
4755
|
-
name:
|
|
4779
|
+
name: Fe,
|
|
4756
4780
|
searchTerms: [
|
|
4757
4781
|
"toggle",
|
|
4758
4782
|
"collapse",
|
|
@@ -4794,28 +4818,28 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4794
4818
|
}, V = (e) => {
|
|
4795
4819
|
let t = e.tagName;
|
|
4796
4820
|
return t === "B" || t === "STRONG";
|
|
4797
|
-
},
|
|
4821
|
+
}, Ri = (e) => !!(e && e.nodeType === Node.ELEMENT_NODE && V(e)), zi = (e) => e.textContent.length === 0, H = (e) => e ? e.nodeType === Node.ELEMENT_NODE && V(e) ? U(e) : H(e.parentNode) : null, U = (e) => {
|
|
4798
4822
|
if (e.tagName === "STRONG") return e;
|
|
4799
4823
|
let t = document.createElement("strong");
|
|
4800
4824
|
for (e.hasAttributes() && Array.from(e.attributes).forEach((e) => {
|
|
4801
4825
|
t.setAttribute(e.name, e.value);
|
|
4802
4826
|
}); e.firstChild;) t.appendChild(e.firstChild);
|
|
4803
4827
|
return e.replaceWith(t), t;
|
|
4804
|
-
},
|
|
4828
|
+
}, Bi = (e) => {
|
|
4805
4829
|
let t = e.nextSibling;
|
|
4806
4830
|
if ((t == null ? void 0 : t.nodeType) === Node.TEXT_NODE) return t;
|
|
4807
4831
|
let n = e.parentNode;
|
|
4808
4832
|
if (!n) return null;
|
|
4809
4833
|
let r = e.ownerDocument.createTextNode("");
|
|
4810
4834
|
return n.insertBefore(r, t), r;
|
|
4811
|
-
},
|
|
4835
|
+
}, Vi = (e) => {
|
|
4812
4836
|
if (!e.boldElement.isConnected) return null;
|
|
4813
|
-
let t = U(e.boldElement), n = e.boundary, r = n.isConnected && n.previousSibling === t ? n :
|
|
4837
|
+
let t = U(e.boldElement), n = e.boundary, r = n.isConnected && n.previousSibling === t ? n : Bi(t);
|
|
4814
4838
|
return r ? {
|
|
4815
4839
|
boundary: r,
|
|
4816
4840
|
boldElement: t
|
|
4817
4841
|
} : null;
|
|
4818
|
-
},
|
|
4842
|
+
}, Hi = (e, t) => e ? e === t || t.contains(e) : !1, Ui, W = {
|
|
4819
4843
|
COLLAPSED_LENGTH: "data-blok-bold-collapsed-length",
|
|
4820
4844
|
COLLAPSED_ACTIVE: "data-blok-bold-collapsed-active",
|
|
4821
4845
|
PREV_LENGTH: "data-blok-bold-prev-length",
|
|
@@ -4868,7 +4892,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4868
4892
|
}
|
|
4869
4893
|
exit(e, t) {
|
|
4870
4894
|
let n = U(t), r = n.parentNode;
|
|
4871
|
-
if (r) return
|
|
4895
|
+
if (r) return zi(n) ? this.removeEmptyBoldElement(e, n, r) : this.exitBoldWithContent(e, n, r);
|
|
4872
4896
|
}
|
|
4873
4897
|
removeEmptyBoldElement(e, t, n) {
|
|
4874
4898
|
let r = document.createRange();
|
|
@@ -4892,7 +4916,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4892
4916
|
}
|
|
4893
4917
|
maintain() {
|
|
4894
4918
|
if (!(typeof document > "u")) for (let e of Array.from(this.records)) {
|
|
4895
|
-
let t =
|
|
4919
|
+
let t = Vi(e);
|
|
4896
4920
|
if (!t) {
|
|
4897
4921
|
this.records.delete(e);
|
|
4898
4922
|
continue;
|
|
@@ -4924,11 +4948,11 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4924
4948
|
c && this.records.delete(e);
|
|
4925
4949
|
}
|
|
4926
4950
|
synchronize(e) {
|
|
4927
|
-
var t,
|
|
4928
|
-
let
|
|
4929
|
-
if (!
|
|
4930
|
-
let
|
|
4931
|
-
|
|
4951
|
+
var t, r;
|
|
4952
|
+
let i = (t = e == null ? void 0 : e.anchorNode) == null ? e == null ? void 0 : e.focusNode : t, a = i && i.nodeType === Node.ELEMENT_NODE ? i : i == null ? void 0 : i.parentElement, o = (r = a == null ? void 0 : a.closest(v(n.editor))) == null ? a == null ? void 0 : a.ownerDocument : r;
|
|
4953
|
+
if (!o) return;
|
|
4954
|
+
let s = `strong[${W.COLLAPSED_ACTIVE}="true"]`;
|
|
4955
|
+
o.querySelectorAll(s).forEach((t) => {
|
|
4932
4956
|
var n;
|
|
4933
4957
|
let r = t.getAttribute(W.PREV_LENGTH), i = t.previousSibling;
|
|
4934
4958
|
if (!r || !i || i.nodeType !== Node.TEXT_NODE) return;
|
|
@@ -4942,17 +4966,17 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4942
4966
|
if (u && !t.hasAttribute(W.LEADING_WHITESPACE) && t.setAttribute(W.LEADING_WHITESPACE, u[0]), l.length === 0) return;
|
|
4943
4967
|
let d = t.textContent, f = d + l, p = (n = t.getAttribute(W.LEADING_WHITESPACE)) == null ? "" : n, m = p.length > 0 && d.length === 0 && !f.startsWith(p) ? p + f : f, h = document.createTextNode(m);
|
|
4944
4968
|
for (; t.firstChild;) t.removeChild(t.firstChild);
|
|
4945
|
-
if (t.appendChild(h), !(e != null && e.isCollapsed) || !
|
|
4969
|
+
if (t.appendChild(h), !(e != null && e.isCollapsed) || !Hi(e.focusNode, o)) return;
|
|
4946
4970
|
let g = document.createRange(), _ = h.textContent.length;
|
|
4947
4971
|
g.setStart(h, _), g.collapse(!0), e.removeAllRanges(), e.addRange(g);
|
|
4948
4972
|
});
|
|
4949
4973
|
}
|
|
4950
4974
|
enforceLengths(e) {
|
|
4951
4975
|
var t;
|
|
4952
|
-
let
|
|
4953
|
-
if (!
|
|
4954
|
-
let
|
|
4955
|
-
|
|
4976
|
+
let r = (t = e == null ? void 0 : e.anchorNode) == null ? e == null ? void 0 : e.focusNode : t;
|
|
4977
|
+
if (!r) return;
|
|
4978
|
+
let i = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement, a = i == null ? void 0 : i.closest(v(n.editor));
|
|
4979
|
+
a && a.querySelectorAll(`strong[${W.COLLAPSED_LENGTH}]`).forEach((t) => {
|
|
4956
4980
|
var n;
|
|
4957
4981
|
let r = t.getAttribute(W.COLLAPSED_LENGTH);
|
|
4958
4982
|
if (!r) return;
|
|
@@ -4966,7 +4990,7 @@ var Qn = (e) => ({ element: Zn({
|
|
|
4966
4990
|
let r = document.createTextNode(n);
|
|
4967
4991
|
(m = t.parentNode) == null || m.insertBefore(r, t.nextSibling);
|
|
4968
4992
|
}
|
|
4969
|
-
if (p && t.removeAttribute(W.PREV_LENGTH), e != null && e.isCollapsed && s &&
|
|
4993
|
+
if (p && t.removeAttribute(W.PREV_LENGTH), e != null && e.isCollapsed && s && Hi(e.focusNode, t)) {
|
|
4970
4994
|
let t = document.createRange(), n = s.textContent.length;
|
|
4971
4995
|
t.setStart(s, n), t.collapse(!0), e.removeAllRanges(), e.addRange(t);
|
|
4972
4996
|
}
|
|
@@ -5060,10 +5084,10 @@ var Qn = (e) => ({ element: Zn({
|
|
|
5060
5084
|
return t.tagName === "STRONG" || t.tagName === "B";
|
|
5061
5085
|
}
|
|
5062
5086
|
};
|
|
5063
|
-
|
|
5087
|
+
Ui = G, Ui.instance = null;
|
|
5064
5088
|
//#endregion
|
|
5065
5089
|
//#region src/components/inline-tools/services/bold-normalization-pass.ts
|
|
5066
|
-
var
|
|
5090
|
+
var Wi = {
|
|
5067
5091
|
convertLegacyTags: !0,
|
|
5068
5092
|
normalizeWhitespace: !0,
|
|
5069
5093
|
removeEmpty: !0,
|
|
@@ -5071,7 +5095,7 @@ var Li = {
|
|
|
5071
5095
|
preserveNode: null
|
|
5072
5096
|
}, K = class e {
|
|
5073
5097
|
constructor(e) {
|
|
5074
|
-
this.options =
|
|
5098
|
+
this.options = b(b({}, Wi), e);
|
|
5075
5099
|
}
|
|
5076
5100
|
run(e) {
|
|
5077
5101
|
if (typeof document > "u") return;
|
|
@@ -5124,16 +5148,16 @@ var Li = {
|
|
|
5124
5148
|
t.includes("\xA0") && (e.textContent = t.replace(/\u00A0/g, " "));
|
|
5125
5149
|
}
|
|
5126
5150
|
isEmptyAndSafe(e) {
|
|
5127
|
-
return e.textContent.length !== 0 || G.getInstance().isActivePlaceholder(e) ? !1 : !(this.options.preserveNode &&
|
|
5151
|
+
return e.textContent.length !== 0 || G.getInstance().isActivePlaceholder(e) ? !1 : !(this.options.preserveNode && Hi(this.options.preserveNode, e));
|
|
5128
5152
|
}
|
|
5129
5153
|
mergeWithAdjacent(e) {
|
|
5130
5154
|
let t = e.previousSibling;
|
|
5131
|
-
if (t &&
|
|
5155
|
+
if (t && Ri(t)) {
|
|
5132
5156
|
this.mergeStrongNodes(t, e);
|
|
5133
5157
|
return;
|
|
5134
5158
|
}
|
|
5135
5159
|
let n = e.nextSibling;
|
|
5136
|
-
n &&
|
|
5160
|
+
n && Ri(n) && this.mergeStrongNodes(e, n);
|
|
5137
5161
|
}
|
|
5138
5162
|
mergeStrongNodes(e, t) {
|
|
5139
5163
|
let n = U(e), r = U(t);
|
|
@@ -5141,13 +5165,13 @@ var Li = {
|
|
|
5141
5165
|
r.remove();
|
|
5142
5166
|
}
|
|
5143
5167
|
static findScopeFromSelection(e) {
|
|
5144
|
-
var t,
|
|
5145
|
-
let
|
|
5146
|
-
if (!
|
|
5147
|
-
let
|
|
5148
|
-
return
|
|
5168
|
+
var t, r;
|
|
5169
|
+
let i = (t = e == null ? void 0 : e.anchorNode) == null ? e == null ? void 0 : e.focusNode : t;
|
|
5170
|
+
if (!i) return null;
|
|
5171
|
+
let a = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement;
|
|
5172
|
+
return a ? ((r = a.closest("[data-blok-component=\"paragraph\"]")) == null ? a.closest(v(n.elementContent)) : r) || a.closest(v(n.editor)) : null;
|
|
5149
5173
|
}
|
|
5150
|
-
},
|
|
5174
|
+
}, Gi, Ki = class e {
|
|
5151
5175
|
constructor() {
|
|
5152
5176
|
this.handlers = /* @__PURE__ */ new Map(), this.listenersRegistered = !1, this.handleSelectionChange = () => {
|
|
5153
5177
|
let e = this.getSelection();
|
|
@@ -5204,10 +5228,10 @@ var Li = {
|
|
|
5204
5228
|
return !(t.meta && !n || t.ctrl && !e.ctrlKey);
|
|
5205
5229
|
}
|
|
5206
5230
|
};
|
|
5207
|
-
|
|
5231
|
+
Gi = Ki, Gi.instance = null;
|
|
5208
5232
|
//#endregion
|
|
5209
5233
|
//#region src/components/inline-tools/utils/formatting-range-utils.ts
|
|
5210
|
-
var
|
|
5234
|
+
var qi = (e, t) => {
|
|
5211
5235
|
try {
|
|
5212
5236
|
return e.intersectsNode(t);
|
|
5213
5237
|
} catch (n) {
|
|
@@ -5216,22 +5240,26 @@ var Bi = (e, t) => {
|
|
|
5216
5240
|
let i = e.compareBoundaryPoints(Range.END_TO_START, r) > 0, a = e.compareBoundaryPoints(Range.START_TO_END, r) < 0;
|
|
5217
5241
|
return i && a;
|
|
5218
5242
|
}
|
|
5219
|
-
},
|
|
5243
|
+
}, Ji = (e) => {
|
|
5244
|
+
var t;
|
|
5245
|
+
let n = e.commonAncestorContainer, r = n.nodeType === Node.TEXT_NODE ? (t = n.parentNode) == null ? n : t : n;
|
|
5246
|
+
return document.createTreeWalker(r, NodeFilter.SHOW_TEXT, { acceptNode: (t) => qi(e, t) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT });
|
|
5247
|
+
}, q = (e, t, n) => !e || e === n ? null : e.nodeType === Node.ELEMENT_NODE && t(e) ? e : q(e.parentNode, t, n), Yi = (e, t) => q(e, t) !== null, Xi = (e, t, n = {}) => {
|
|
5220
5248
|
if (e.collapsed) return q(e.startContainer, t) !== null;
|
|
5221
|
-
let r =
|
|
5249
|
+
let r = Ji(e), i = [];
|
|
5222
5250
|
for (; r.nextNode();) {
|
|
5223
5251
|
let e = r.currentNode, t = e.textContent;
|
|
5224
5252
|
n.ignoreWhitespace && t.trim().length === 0 || t.length !== 0 && i.push(e);
|
|
5225
5253
|
}
|
|
5226
|
-
return i.length === 0 ? q(e.startContainer, t) !== null : i.every((e) =>
|
|
5254
|
+
return i.length === 0 ? q(e.startContainer, t) !== null : i.every((e) => Yi(e, t));
|
|
5227
5255
|
}, J = (e, t) => {
|
|
5228
|
-
let n = /* @__PURE__ */ new Set(), r =
|
|
5256
|
+
let n = /* @__PURE__ */ new Set(), r = Ji(e);
|
|
5229
5257
|
for (; r.nextNode();) {
|
|
5230
5258
|
let e = q(r.currentNode, t);
|
|
5231
5259
|
e && n.add(e);
|
|
5232
5260
|
}
|
|
5233
5261
|
return Array.from(n);
|
|
5234
|
-
}, Y,
|
|
5262
|
+
}, Y, Zi = class e {
|
|
5235
5263
|
static get sanitize() {
|
|
5236
5264
|
return {
|
|
5237
5265
|
strong: {},
|
|
@@ -5243,7 +5271,7 @@ var Bi = (e, t) => {
|
|
|
5243
5271
|
}
|
|
5244
5272
|
static initializeGlobalListeners() {
|
|
5245
5273
|
if (typeof document > "u") return !1;
|
|
5246
|
-
let t =
|
|
5274
|
+
let t = Ki.getInstance();
|
|
5247
5275
|
return t.hasHandler("bold") ? !0 : (t.register("bold", {
|
|
5248
5276
|
shortcut: {
|
|
5249
5277
|
key: "b",
|
|
@@ -5325,7 +5353,7 @@ var Bi = (e, t) => {
|
|
|
5325
5353
|
let e = document.createRange();
|
|
5326
5354
|
return e.setStartBefore(s), e.setEndAfter(c), r.removeAllRanges(), r.addRange(e), e;
|
|
5327
5355
|
})() || r.removeAllRanges(), K.normalizeAroundSelection(r), n.forEach((e) => {
|
|
5328
|
-
|
|
5356
|
+
zi(e) && e.remove();
|
|
5329
5357
|
}), this.notifySelectionChange();
|
|
5330
5358
|
}
|
|
5331
5359
|
replaceRangeWithHtml(t, n) {
|
|
@@ -5365,7 +5393,7 @@ var Bi = (e, t) => {
|
|
|
5365
5393
|
n.selectNodeContents(e), t.removeAllRanges(), t.addRange(n);
|
|
5366
5394
|
}
|
|
5367
5395
|
isRangeBold(e, t) {
|
|
5368
|
-
return
|
|
5396
|
+
return Xi(e, V, t);
|
|
5369
5397
|
}
|
|
5370
5398
|
removeNestedBold(e) {
|
|
5371
5399
|
e.querySelectorAll("b,strong").forEach((e) => {
|
|
@@ -5408,12 +5436,12 @@ var Bi = (e, t) => {
|
|
|
5408
5436
|
updateToolbarButtonState() {
|
|
5409
5437
|
let e = window.getSelection();
|
|
5410
5438
|
if (!e) return;
|
|
5411
|
-
let t = e.anchorNode,
|
|
5412
|
-
if (!
|
|
5413
|
-
let
|
|
5414
|
-
if (!(
|
|
5415
|
-
let
|
|
5416
|
-
|
|
5439
|
+
let t = e.anchorNode, r = (t == null ? void 0 : t.nodeType) === Node.ELEMENT_NODE ? t : t == null ? void 0 : t.parentElement, i = r == null ? void 0 : r.closest(v(n.editor));
|
|
5440
|
+
if (!i) return;
|
|
5441
|
+
let a = i.querySelector("[data-blok-testid=inline-toolbar]");
|
|
5442
|
+
if (!(a instanceof HTMLElement)) return;
|
|
5443
|
+
let o = a.querySelector("[data-blok-item-name=\"bold\"]");
|
|
5444
|
+
o instanceof HTMLElement && (this.isSelectionVisuallyBold(e) ? o.setAttribute("data-blok-popover-item-active", "true") : o.removeAttribute("data-blok-popover-item-active"));
|
|
5417
5445
|
}
|
|
5418
5446
|
static refreshSelectionState(e) {
|
|
5419
5447
|
let t = window.getSelection();
|
|
@@ -5450,7 +5478,7 @@ var Bi = (e, t) => {
|
|
|
5450
5478
|
}
|
|
5451
5479
|
static findBlokScopeFromNode(e) {
|
|
5452
5480
|
let t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5453
|
-
return !t || typeof t.closest != "function" ? null : t.closest(`${v(
|
|
5481
|
+
return !t || typeof t.closest != "function" ? null : t.closest(`${v(n.interface)}, ${v(n.editor)}`);
|
|
5454
5482
|
}
|
|
5455
5483
|
static getBoundaryBold(t) {
|
|
5456
5484
|
let n = t.startContainer;
|
|
@@ -5461,18 +5489,18 @@ var Bi = (e, t) => {
|
|
|
5461
5489
|
if (e.startOffset === n) return H(t);
|
|
5462
5490
|
if (e.startOffset !== 0) return null;
|
|
5463
5491
|
let r = t.previousSibling;
|
|
5464
|
-
return
|
|
5492
|
+
return Ri(r) ? r : null;
|
|
5465
5493
|
}
|
|
5466
5494
|
static getBoundaryBoldForElement(e, t) {
|
|
5467
5495
|
if (e.startOffset <= 0) return null;
|
|
5468
5496
|
let n = t.childNodes[e.startOffset - 1];
|
|
5469
|
-
return
|
|
5497
|
+
return Ri(n) ? n : null;
|
|
5470
5498
|
}
|
|
5471
5499
|
static isSelectionInsideBlok(e) {
|
|
5472
5500
|
let t = e.anchorNode;
|
|
5473
5501
|
if (!t) return !1;
|
|
5474
|
-
let
|
|
5475
|
-
return !!(
|
|
5502
|
+
let r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
5503
|
+
return !!(r != null && r.closest(v(n.editor)));
|
|
5476
5504
|
}
|
|
5477
5505
|
getRangeHtmlWithoutBold(e) {
|
|
5478
5506
|
let t = e.cloneContents();
|
|
@@ -5488,13 +5516,13 @@ var Bi = (e, t) => {
|
|
|
5488
5516
|
return J(e, V);
|
|
5489
5517
|
}
|
|
5490
5518
|
};
|
|
5491
|
-
Y =
|
|
5519
|
+
Y = Zi, 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";
|
|
5492
5520
|
//#endregion
|
|
5493
5521
|
//#region src/components/inline-tools/inline-tool-italic.ts
|
|
5494
|
-
var X,
|
|
5522
|
+
var X, Qi = (e) => {
|
|
5495
5523
|
let t = e.tagName;
|
|
5496
5524
|
return t === "I" || t === "EM";
|
|
5497
|
-
},
|
|
5525
|
+
}, $i = class {
|
|
5498
5526
|
static get sanitize() {
|
|
5499
5527
|
return {
|
|
5500
5528
|
i: {},
|
|
@@ -5503,7 +5531,7 @@ var X, Gi = (e) => {
|
|
|
5503
5531
|
}
|
|
5504
5532
|
render() {
|
|
5505
5533
|
return {
|
|
5506
|
-
icon:
|
|
5534
|
+
icon: s,
|
|
5507
5535
|
name: "italic",
|
|
5508
5536
|
onActivate: () => {
|
|
5509
5537
|
this.toggleItalic();
|
|
@@ -5543,7 +5571,7 @@ var X, Gi = (e) => {
|
|
|
5543
5571
|
return this.isRangeItalic(t, { ignoreWhitespace: !0 });
|
|
5544
5572
|
}
|
|
5545
5573
|
isRangeItalic(e, t) {
|
|
5546
|
-
return
|
|
5574
|
+
return Xi(e, Qi, t);
|
|
5547
5575
|
}
|
|
5548
5576
|
wrapWithItalic(e) {
|
|
5549
5577
|
let t = this.getRangeHtmlWithoutItalic(e), n = this.replaceRangeWithHtml(e, `<i>${t}</i>`), r = window.getSelection();
|
|
@@ -5569,13 +5597,13 @@ var X, Gi = (e) => {
|
|
|
5569
5597
|
});
|
|
5570
5598
|
}
|
|
5571
5599
|
hasItalicParent(e) {
|
|
5572
|
-
return
|
|
5600
|
+
return Yi(e, Qi);
|
|
5573
5601
|
}
|
|
5574
5602
|
findItalicElement(e) {
|
|
5575
|
-
return q(e,
|
|
5603
|
+
return q(e, Qi);
|
|
5576
5604
|
}
|
|
5577
5605
|
collectItalicAncestors(e) {
|
|
5578
|
-
return J(e,
|
|
5606
|
+
return J(e, Qi);
|
|
5579
5607
|
}
|
|
5580
5608
|
getRangeHtmlWithoutItalic(e) {
|
|
5581
5609
|
let t = e.cloneContents();
|
|
@@ -5632,10 +5660,10 @@ var X, Gi = (e) => {
|
|
|
5632
5660
|
n.insertBefore(r, t.nextSibling), n.insertBefore(e, r);
|
|
5633
5661
|
}
|
|
5634
5662
|
};
|
|
5635
|
-
X =
|
|
5663
|
+
X = $i, X.isInline = !0, X.title = "Italic", X.titleKey = "italic", X.shortcut = "CMD+I";
|
|
5636
5664
|
//#endregion
|
|
5637
5665
|
//#region src/components/inline-tools/inline-tool-link.ts
|
|
5638
|
-
var Z,
|
|
5666
|
+
var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text-left cursor-pointer can-hover:hover:bg-item-hover-bg transition-colors", ta = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text-left pointer-events-none", na = class {
|
|
5639
5667
|
static get sanitize() {
|
|
5640
5668
|
return { a: {
|
|
5641
5669
|
href: !0,
|
|
@@ -5644,28 +5672,29 @@ var Z, qi = class {
|
|
|
5644
5672
|
} };
|
|
5645
5673
|
}
|
|
5646
5674
|
constructor({ api: e }) {
|
|
5647
|
-
this.INPUT_BASE_CLASSES = "hidden w-
|
|
5675
|
+
this.INPUT_BASE_CLASSES = "hidden w-[200px] m-0 px-2 py-1 text-sm leading-[22px] font-medium text-text-primary bg-item-hover-bg border border-link-input-border rounded-lg! outline-hidden box-border appearance-none font-[inherit] placeholder:text-gray-text mobile:text-[15px] mobile:font-medium", this.DATA_ATTRIBUTES = {
|
|
5648
5676
|
buttonActive: "data-blok-link-tool-active",
|
|
5649
5677
|
buttonUnlink: "data-blok-link-tool-unlink",
|
|
5650
5678
|
inputOpened: "data-blok-link-tool-input-opened"
|
|
5651
5679
|
}, this.nodes = {
|
|
5652
5680
|
input: null,
|
|
5681
|
+
inputWrapper: null,
|
|
5682
|
+
suggestion: null,
|
|
5653
5683
|
button: null
|
|
5654
5684
|
}, this.inputOpened = !1, this.unlinkAvailable = !1, this.handleButtonClick = (e) => {
|
|
5655
5685
|
!this.inputOpened || !this.unlinkAvailable || (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), this.restoreSelection(), this.unlink(), this.inlineToolbar.close());
|
|
5656
|
-
}, this.toolbar = e.toolbar, this.inlineToolbar = e.inlineToolbar, this.notifier = e.notifier, this.i18n = e.i18n, this.selection = new
|
|
5686
|
+
}, this.toolbar = e.toolbar, this.inlineToolbar = e.inlineToolbar, this.notifier = e.notifier, this.i18n = e.i18n, this.selection = new o(), this.nodes.input = this.createInput(), this.nodes.suggestion = this.createSuggestion(), this.nodes.inputWrapper = document.createElement("div"), this.nodes.inputWrapper.append(this.nodes.input, this.nodes.suggestion);
|
|
5657
5687
|
}
|
|
5658
5688
|
render() {
|
|
5659
5689
|
return {
|
|
5660
|
-
icon:
|
|
5690
|
+
icon: d,
|
|
5661
5691
|
name: "link",
|
|
5662
5692
|
isActive: () => !!this.selection.findParentTag("A"),
|
|
5663
5693
|
children: {
|
|
5664
5694
|
hideChevron: !0,
|
|
5665
|
-
width: "200px",
|
|
5666
5695
|
items: [{
|
|
5667
5696
|
type: _.Html,
|
|
5668
|
-
element: this.nodes.
|
|
5697
|
+
element: this.nodes.inputWrapper
|
|
5669
5698
|
}],
|
|
5670
5699
|
onOpen: () => {
|
|
5671
5700
|
this.openActions(!0);
|
|
@@ -5680,8 +5709,69 @@ var Z, qi = class {
|
|
|
5680
5709
|
let e = document.createElement("input");
|
|
5681
5710
|
return e.placeholder = this.i18n.t("tools.link.addLink"), e.enterKeyHint = "done", e.className = this.INPUT_BASE_CLASSES, e.setAttribute("data-blok-testid", "inline-tool-input"), this.setBooleanStateAttribute(e, this.DATA_ATTRIBUTES.inputOpened, !1), e.addEventListener("keydown", (e) => {
|
|
5682
5711
|
e.key === "Enter" && this.enterPressed(e);
|
|
5712
|
+
}), e.addEventListener("paste", () => {
|
|
5713
|
+
requestAnimationFrame(() => {
|
|
5714
|
+
this.updateSuggestion(e.value);
|
|
5715
|
+
});
|
|
5716
|
+
}), e.addEventListener("input", () => {
|
|
5717
|
+
this.updateSuggestion(e.value);
|
|
5683
5718
|
}), e;
|
|
5684
5719
|
}
|
|
5720
|
+
createSuggestion() {
|
|
5721
|
+
let e = document.createElement("div");
|
|
5722
|
+
e.className = "hidden", e.setAttribute("data-link-suggestion", "");
|
|
5723
|
+
let t = document.createElement("div");
|
|
5724
|
+
t.className = "mt-1 mb-0.5 h-px bg-link-input-border";
|
|
5725
|
+
let n = document.createElement("button");
|
|
5726
|
+
n.type = "button", n.className = ea, n.setAttribute("data-link-suggestion-row", "");
|
|
5727
|
+
let r = document.createElement("span");
|
|
5728
|
+
r.className = "text-gray-text shrink-0 flex [&>svg]:size-7", r.setAttribute("data-link-suggestion-icon", "");
|
|
5729
|
+
let i = document.createElement("span");
|
|
5730
|
+
i.className = "flex-1 min-w-0";
|
|
5731
|
+
let a = document.createElement("span");
|
|
5732
|
+
a.className = "block text-xs font-medium text-text-primary truncate", a.setAttribute("data-link-suggestion-url", "");
|
|
5733
|
+
let o = document.createElement("span");
|
|
5734
|
+
return o.className = "block text-[10.5px] text-gray-text leading-tight mt-px", o.setAttribute("data-link-suggestion-type", ""), i.append(a, o), n.append(r, i), e.append(t, n), n.addEventListener("mousedown", (e) => e.preventDefault()), n.addEventListener("click", () => this.confirmLink()), e;
|
|
5735
|
+
}
|
|
5736
|
+
updateSuggestion(e) {
|
|
5737
|
+
if (!this.nodes.suggestion) return;
|
|
5738
|
+
let t = e.trim();
|
|
5739
|
+
if (!t) {
|
|
5740
|
+
this.nodes.suggestion.classList.add("hidden");
|
|
5741
|
+
return;
|
|
5742
|
+
}
|
|
5743
|
+
let n = this.isLinkComplete(t), { icon: r, label: i } = this.getLinkTypeInfo(t), a = this.nodes.suggestion.querySelector("[data-link-suggestion-icon]"), o = this.nodes.suggestion.querySelector("[data-link-suggestion-url]"), s = this.nodes.suggestion.querySelector("[data-link-suggestion-type]"), c = this.nodes.suggestion.querySelector("[data-link-suggestion-row]");
|
|
5744
|
+
a && (a.innerHTML = r, a.className = `${n ? "text-gray-text" : "text-gray-text opacity-40"} shrink-0 flex [&>svg]:size-7`), o && (o.textContent = t, o.className = `block text-xs font-medium truncate ${n ? "text-text-primary" : "text-gray-text"}`), s && (s.textContent = n ? i : "Keep typing to add a link", s.className = "block text-[10.5px] text-gray-text leading-tight mt-px"), c && (c.className = n ? ea : ta), this.nodes.suggestion.classList.remove("hidden");
|
|
5745
|
+
}
|
|
5746
|
+
isLinkComplete(e) {
|
|
5747
|
+
return /^https?:\/\//i.test(e) ? e.replace(/^https?:\/\//i, "").length > 0 : /^\w+:\/\//.test(e) ? e.replace(/^\w+:\/\//, "").length > 0 : /^\w+:/.test(e) ? e.slice(e.indexOf(":") + 1).length > 0 : e.startsWith("//") ? e.slice(2).length > 0 : e.startsWith("#") ? e.length > 1 : e.startsWith("/") ? !0 : /\.[a-zA-Z]{2,}/.test(e) || /^\d{1,3}(\.\d{1,3}){3}/.test(e);
|
|
5748
|
+
}
|
|
5749
|
+
getLinkTypeInfo(e) {
|
|
5750
|
+
return e.startsWith("mailto:") ? {
|
|
5751
|
+
icon: ae,
|
|
5752
|
+
label: "Email address"
|
|
5753
|
+
} : e.startsWith("#") ? {
|
|
5754
|
+
icon: ee,
|
|
5755
|
+
label: "Jump to section"
|
|
5756
|
+
} : {
|
|
5757
|
+
icon: we,
|
|
5758
|
+
label: "Link to web page"
|
|
5759
|
+
};
|
|
5760
|
+
}
|
|
5761
|
+
confirmLink() {
|
|
5762
|
+
if (!this.nodes.input) return;
|
|
5763
|
+
let e = this.nodes.input.value || "";
|
|
5764
|
+
if (!e.trim() || !this.isLinkComplete(e.trim())) return;
|
|
5765
|
+
if (!this.validateURL(e)) {
|
|
5766
|
+
this.notifier.show({
|
|
5767
|
+
message: this.i18n.t("tools.link.invalidLink"),
|
|
5768
|
+
style: "error"
|
|
5769
|
+
});
|
|
5770
|
+
return;
|
|
5771
|
+
}
|
|
5772
|
+
let t = this.prepareLink(e);
|
|
5773
|
+
this.selection.removeFakeBackground(), this.selection.restore(), this.insertLink(t), this.selection.collapseToEnd(), this.inlineToolbar.close();
|
|
5774
|
+
}
|
|
5685
5775
|
openActions(e = !1) {
|
|
5686
5776
|
if (!this.nodes.input) return;
|
|
5687
5777
|
let t = this.selection.findParentTag("A"), n = !!t;
|
|
@@ -5689,7 +5779,7 @@ var Z, qi = class {
|
|
|
5689
5779
|
let e = t.getAttribute("href");
|
|
5690
5780
|
this.nodes.input.value = e === null ? "" : e;
|
|
5691
5781
|
} else this.nodes.input.value = "";
|
|
5692
|
-
this.nodes.input.className =
|
|
5782
|
+
this.updateSuggestion(this.nodes.input.value), this.nodes.input.className = x(this.INPUT_BASE_CLASSES, "block"), this.setBooleanStateAttribute(this.nodes.input, this.DATA_ATTRIBUTES.inputOpened, !0), this.selection.setFakeBackground(), this.selection.save(), e && this.focusInputWithRetry(), this.inputOpened = !0;
|
|
5693
5783
|
}
|
|
5694
5784
|
focusInputWithRetry() {
|
|
5695
5785
|
this.nodes.input && (this.nodes.input.focus(), !(typeof window > "u" || typeof document > "u") && window.setTimeout(() => {
|
|
@@ -5700,7 +5790,7 @@ var Z, qi = class {
|
|
|
5700
5790
|
}, 0));
|
|
5701
5791
|
}
|
|
5702
5792
|
getButtonElement() {
|
|
5703
|
-
let e = document.querySelector(`${v(
|
|
5793
|
+
let e = document.querySelector(`${v(n.interface, te)} [data-blok-item-name="link"]`);
|
|
5704
5794
|
return e && e !== this.nodes.button && (e.addEventListener("click", this.handleButtonClick, !0), this.nodes.button = e), e;
|
|
5705
5795
|
}
|
|
5706
5796
|
updateButtonStateAttributes(e) {
|
|
@@ -5710,10 +5800,11 @@ var Z, qi = class {
|
|
|
5710
5800
|
this.setBooleanStateAttribute(t, this.DATA_ATTRIBUTES.buttonActive, n), this.setBooleanStateAttribute(t, this.DATA_ATTRIBUTES.buttonUnlink, n);
|
|
5711
5801
|
}
|
|
5712
5802
|
closeActions(e = !0) {
|
|
5713
|
-
|
|
5803
|
+
var t;
|
|
5804
|
+
(this.selection.isFakeBackgroundEnabled || e && this.selection.savedSelectionRange) && this.restoreSelection(), this.nodes.input && (this.nodes.input.className = this.INPUT_BASE_CLASSES, this.setBooleanStateAttribute(this.nodes.input, this.DATA_ATTRIBUTES.inputOpened, !1), this.nodes.input.value = "", (t = this.nodes.suggestion) == null || t.classList.add("hidden"), this.updateButtonStateAttributes(!1), this.unlinkAvailable = !1, e && this.selection.clearSaved(), this.inputOpened = !1);
|
|
5714
5805
|
}
|
|
5715
5806
|
restoreSelection() {
|
|
5716
|
-
let e = new
|
|
5807
|
+
let e = new o(), t = o.isAtBlok;
|
|
5717
5808
|
if (t && e.save(), this.selection.removeFakeBackground(), this.selection.restore(), !t && this.selection.savedSelectionRange) {
|
|
5718
5809
|
let e = this.selection.savedSelectionRange.commonAncestorContainer, t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5719
5810
|
t == null || t.focus();
|
|
@@ -5737,7 +5828,7 @@ var Z, qi = class {
|
|
|
5737
5828
|
this.notifier.show({
|
|
5738
5829
|
message: this.i18n.t("tools.link.invalidLink"),
|
|
5739
5830
|
style: "error"
|
|
5740
|
-
}),
|
|
5831
|
+
}), qe("Incorrect Link pasted", "warn", t);
|
|
5741
5832
|
return;
|
|
5742
5833
|
}
|
|
5743
5834
|
let n = this.prepareLink(t);
|
|
@@ -5760,7 +5851,7 @@ var Z, qi = class {
|
|
|
5760
5851
|
this.selection.expandToTag(t), t.href = e, t.target = "_blank", t.rel = "nofollow";
|
|
5761
5852
|
return;
|
|
5762
5853
|
}
|
|
5763
|
-
let n =
|
|
5854
|
+
let n = o.range;
|
|
5764
5855
|
if (!n) return;
|
|
5765
5856
|
let r = document.createElement("a");
|
|
5766
5857
|
r.href = e, r.target = "_blank", r.rel = "nofollow", r.appendChild(n.extractContents()), n.insertNode(r), this.selection.expandToTag(r);
|
|
@@ -5779,13 +5870,13 @@ var Z, qi = class {
|
|
|
5779
5870
|
e && e.setAttribute(t, n ? "true" : "false");
|
|
5780
5871
|
}
|
|
5781
5872
|
};
|
|
5782
|
-
Z =
|
|
5873
|
+
Z = na, Z.isInline = !0, Z.title = "Link", Z.titleKey = "link", Z.shortcut = "CMD+K";
|
|
5783
5874
|
//#endregion
|
|
5784
5875
|
//#region src/components/inline-tools/utils/marker-dom-utils.ts
|
|
5785
|
-
var Q = (e) => e.tagName === "MARK",
|
|
5876
|
+
var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
5786
5877
|
color: "background-color",
|
|
5787
5878
|
"background-color": "color"
|
|
5788
|
-
},
|
|
5879
|
+
}, aa = class e {
|
|
5789
5880
|
static get sanitize() {
|
|
5790
5881
|
return { mark: (t) => {
|
|
5791
5882
|
let n = t.style, r = Array.from({ length: n.length }, (e, t) => n.item(t));
|
|
@@ -5794,10 +5885,9 @@ var Q = (e) => e.tagName === "MARK", Ji = (e) => q(e, Q), $, Yi = {
|
|
|
5794
5885
|
} };
|
|
5795
5886
|
}
|
|
5796
5887
|
constructor({ api: e }) {
|
|
5797
|
-
this.colorMode = "color", this.i18n = e.i18n, this.inlineToolbar = e.inlineToolbar, this.selection = new
|
|
5888
|
+
this.colorMode = "color", this.activeTextColor = null, this.activeBgColor = null, this.i18n = e.i18n, this.inlineToolbar = e.inlineToolbar, this.selection = new o(), this.picker = or({
|
|
5798
5889
|
i18n: this.i18n,
|
|
5799
5890
|
testIdPrefix: "marker",
|
|
5800
|
-
defaultModeIndex: 0,
|
|
5801
5891
|
modes: [{
|
|
5802
5892
|
key: "color",
|
|
5803
5893
|
labelKey: "tools.marker.textColor",
|
|
@@ -5808,21 +5898,26 @@ var Q = (e) => e.tagName === "MARK", Ji = (e) => q(e, Q), $, Yi = {
|
|
|
5808
5898
|
presetField: "bg"
|
|
5809
5899
|
}],
|
|
5810
5900
|
onColorSelect: (e, t) => {
|
|
5811
|
-
this.colorMode = t, e === null ? this.removeColor(this.colorMode) : this.applyColor(this.colorMode, e), this.selection.setFakeBackground(), this.selection.save();
|
|
5901
|
+
this.colorMode = t, e === null ? this.removeColor(this.colorMode) : this.applyColor(this.colorMode, e), t === "color" ? this.activeTextColor = e : this.activeBgColor = e, this.picker.setActiveColor(e, t), this.updateToolbarColors(this.activeTextColor, this.activeBgColor), this.selection.setFakeBackground(), this.selection.save();
|
|
5812
5902
|
}
|
|
5813
5903
|
});
|
|
5814
5904
|
}
|
|
5815
5905
|
render() {
|
|
5816
5906
|
return {
|
|
5817
|
-
icon:
|
|
5907
|
+
icon: se,
|
|
5818
5908
|
name: "marker",
|
|
5819
5909
|
isActive: () => {
|
|
5820
5910
|
let e = window.getSelection();
|
|
5821
|
-
|
|
5911
|
+
if (!e || e.rangeCount === 0) return !1;
|
|
5912
|
+
let t = e.getRangeAt(0), n = Xi(t, Q, { ignoreWhitespace: !0 });
|
|
5913
|
+
if (n) {
|
|
5914
|
+
let e = this.detectBothSelectionColors(t);
|
|
5915
|
+
this.updateToolbarColors(e.text, e.bg);
|
|
5916
|
+
}
|
|
5917
|
+
return n;
|
|
5822
5918
|
},
|
|
5823
5919
|
children: {
|
|
5824
5920
|
hideChevron: !0,
|
|
5825
|
-
width: "200px",
|
|
5826
5921
|
items: [{
|
|
5827
5922
|
type: _.Html,
|
|
5828
5923
|
element: this.picker.element
|
|
@@ -5842,31 +5937,33 @@ var Q = (e) => e.tagName === "MARK", Ji = (e) => q(e, Q), $, Yi = {
|
|
|
5842
5937
|
if (!n || n.rangeCount === 0) return;
|
|
5843
5938
|
let r = n.getRangeAt(0);
|
|
5844
5939
|
if (r.collapsed) return;
|
|
5845
|
-
let i = this.findContainingMark(r);
|
|
5846
|
-
if (
|
|
5847
|
-
let
|
|
5848
|
-
if (
|
|
5849
|
-
|
|
5940
|
+
let i = this.resolveToVar(t, e), a = this.findContainingMark(r);
|
|
5941
|
+
if (a) {
|
|
5942
|
+
let t = document.createRange();
|
|
5943
|
+
if (t.selectNodeContents(a), r.compareBoundaryPoints(Range.START_TO_START, t) <= 0 && r.compareBoundaryPoints(Range.END_TO_END, t) >= 0) {
|
|
5944
|
+
a.style.setProperty(e, i), this.ensureTransparentBg(a);
|
|
5850
5945
|
return;
|
|
5851
5946
|
}
|
|
5852
|
-
this.splitMarkAroundRange(
|
|
5947
|
+
this.splitMarkAroundRange(a, r, e, i);
|
|
5853
5948
|
return;
|
|
5854
5949
|
}
|
|
5855
5950
|
this.splitMarksAtBoundaries(r), this.removeNestedMarkStyle(r, e);
|
|
5856
|
-
let
|
|
5857
|
-
|
|
5858
|
-
let
|
|
5859
|
-
|
|
5951
|
+
let o = document.createElement("mark");
|
|
5952
|
+
o.style.setProperty(e, i), this.ensureTransparentBg(o), o.appendChild(r.extractContents()), r.insertNode(o), n.removeAllRanges();
|
|
5953
|
+
let s = document.createRange();
|
|
5954
|
+
s.selectNodeContents(o), n.addRange(s);
|
|
5860
5955
|
}
|
|
5861
5956
|
removeColor(e) {
|
|
5862
5957
|
var t, n;
|
|
5863
5958
|
this.restoreSelectionIfSaved();
|
|
5864
5959
|
let r = window.getSelection();
|
|
5865
5960
|
if (!r || r.rangeCount === 0) return;
|
|
5866
|
-
let i = r.getRangeAt(0), a = i.startContainer, o = i.startOffset, s = i.endContainer, c = i.endOffset, l = i.toString(), u = i.commonAncestorContainer, d = u.nodeType === Node.ELEMENT_NODE ? u : u.parentElement, f = d != null && d.closest("mark") ? (t = (n = d.closest("mark")) == null ? void 0 : n.parentElement) == null ? d : t : d
|
|
5961
|
+
let i = r.getRangeAt(0), a = i.startContainer, o = i.startOffset, s = i.endContainer, c = i.endOffset, l = i.toString(), u = i.commonAncestorContainer, d = u.nodeType === Node.ELEMENT_NODE ? u : u.parentElement, f = d != null && d.closest("mark") ? (t = (n = d.closest("mark")) == null ? void 0 : n.parentElement) == null ? d : t : d;
|
|
5962
|
+
this.splitMarksAtBoundaries(i);
|
|
5963
|
+
let p = J(i, Q);
|
|
5867
5964
|
for (let t of p) {
|
|
5868
5965
|
t.style.removeProperty(e);
|
|
5869
|
-
let n =
|
|
5966
|
+
let n = ia[e], r = t.style.getPropertyValue(n);
|
|
5870
5967
|
r !== "" && r !== "transparent" ? this.ensureTransparentBg(t) : this.unwrapElement(t);
|
|
5871
5968
|
}
|
|
5872
5969
|
let m = a.isConnected, h = s.isConnected;
|
|
@@ -5879,41 +5976,69 @@ var Q = (e) => e.tagName === "MARK", Ji = (e) => q(e, Q), $, Yi = {
|
|
|
5879
5976
|
else this.restoreSelectionByText(r, f, l);
|
|
5880
5977
|
}
|
|
5881
5978
|
onPickerOpen() {
|
|
5882
|
-
this.picker.reset();
|
|
5883
|
-
let e = this.
|
|
5884
|
-
e && this.picker.setActiveColor(e.
|
|
5979
|
+
this.activeTextColor = null, this.activeBgColor = null, this.picker.reset();
|
|
5980
|
+
let e = this.detectBothSelectionComputedColors();
|
|
5981
|
+
e.text !== null && (this.picker.setActiveColor(e.text, "color"), this.activeTextColor = e.text), e.bg !== null && (this.picker.setActiveColor(e.bg, "background-color"), this.activeBgColor = e.bg), this.updateToolbarColors(this.activeTextColor, this.activeBgColor), this.selection.setFakeBackground(), this.selection.save();
|
|
5982
|
+
}
|
|
5983
|
+
updateToolbarColors(e, t) {
|
|
5984
|
+
let n = document.querySelector("[data-blok-item-name=\"marker\"]");
|
|
5985
|
+
if (!n) return;
|
|
5986
|
+
e === null ? t === null ? n.style.removeProperty("color") : n.style.setProperty("color", "var(--blok-text-primary)") : n.style.setProperty("color", e);
|
|
5987
|
+
let r = n.querySelector("svg rect");
|
|
5988
|
+
t === null ? e === null ? (r && (r.style.fill = ""), n.style.removeProperty("background-color")) : (r && (r.style.fill = "var(--blok-swatch-neutral-bg)"), n.style.setProperty("background-color", "transparent")) : (r && (r.style.fill = t), n.style.setProperty("background-color", "transparent"));
|
|
5885
5989
|
}
|
|
5886
5990
|
onPickerClose() {
|
|
5887
5991
|
this.selection.removeFakeBackground(), this.selection.savedSelectionRange && this.selection.restore(), this.selection.clearSaved();
|
|
5888
5992
|
}
|
|
5889
|
-
|
|
5993
|
+
detectBothSelectionColors(e) {
|
|
5994
|
+
let t = ra(e.startContainer);
|
|
5995
|
+
if (!t) return {
|
|
5996
|
+
text: null,
|
|
5997
|
+
bg: null
|
|
5998
|
+
};
|
|
5999
|
+
let n = (e) => {
|
|
6000
|
+
let n = t.style.getPropertyValue(e);
|
|
6001
|
+
return n && n !== "transparent" ? n : null;
|
|
6002
|
+
};
|
|
6003
|
+
return {
|
|
6004
|
+
text: n("color"),
|
|
6005
|
+
bg: n("background-color")
|
|
6006
|
+
};
|
|
6007
|
+
}
|
|
6008
|
+
detectBothSelectionComputedColors() {
|
|
5890
6009
|
let e = window.getSelection();
|
|
5891
|
-
if (!e || e.rangeCount === 0) return
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
6010
|
+
if (!e || e.rangeCount === 0) return {
|
|
6011
|
+
text: null,
|
|
6012
|
+
bg: null
|
|
6013
|
+
};
|
|
6014
|
+
let t = ra(e.getRangeAt(0).startContainer);
|
|
6015
|
+
if (!t) return {
|
|
6016
|
+
text: null,
|
|
6017
|
+
bg: null
|
|
6018
|
+
};
|
|
6019
|
+
let n = window.getComputedStyle(t), r = (e) => {
|
|
6020
|
+
let r = t.style.getPropertyValue(e);
|
|
6021
|
+
if (!r || r === "transparent") return null;
|
|
6022
|
+
let i = n.getPropertyValue(e);
|
|
6023
|
+
return i && i !== "transparent" ? i : null;
|
|
6024
|
+
};
|
|
6025
|
+
return {
|
|
6026
|
+
text: r("color"),
|
|
6027
|
+
bg: r("background-color")
|
|
5898
6028
|
};
|
|
5899
|
-
let r = t.style.getPropertyValue("background-color");
|
|
5900
|
-
return r && r !== "transparent" ? {
|
|
5901
|
-
value: r,
|
|
5902
|
-
mode: "background-color"
|
|
5903
|
-
} : null;
|
|
5904
6029
|
}
|
|
5905
6030
|
restoreSelectionIfSaved() {
|
|
5906
6031
|
this.selection.savedSelectionRange && (this.selection.removeFakeBackground(), this.selection.restore(), this.selection.clearSaved());
|
|
5907
6032
|
}
|
|
5908
6033
|
findContainingMark(e) {
|
|
5909
|
-
let t =
|
|
6034
|
+
let t = ra(e.startContainer), n = ra(e.endContainer);
|
|
5910
6035
|
return t && t === n ? t : null;
|
|
5911
6036
|
}
|
|
5912
6037
|
removeNestedMarkStyle(e, t) {
|
|
5913
6038
|
let n = J(e, Q);
|
|
5914
6039
|
for (let e of n) {
|
|
5915
6040
|
e.style.removeProperty(t);
|
|
5916
|
-
let n =
|
|
6041
|
+
let n = ia[t], r = e.style.getPropertyValue(n);
|
|
5917
6042
|
r !== "" && r !== "transparent" ? this.ensureTransparentBg(e) : this.unwrapElement(e);
|
|
5918
6043
|
}
|
|
5919
6044
|
}
|
|
@@ -6007,21 +6132,26 @@ var Q = (e) => e.tagName === "MARK", Ji = (e) => q(e, Q), $, Yi = {
|
|
|
6007
6132
|
ensureTransparentBg(e) {
|
|
6008
6133
|
e.style.getPropertyValue("color") && !e.style.getPropertyValue("background-color") && e.style.setProperty("background-color", "transparent");
|
|
6009
6134
|
}
|
|
6135
|
+
resolveToVar(e, t) {
|
|
6136
|
+
if (e.startsWith("var(")) return e;
|
|
6137
|
+
let n = t === "color" ? "text" : "bg", r = ce(e, n);
|
|
6138
|
+
return r === null ? e : Ye(r, n);
|
|
6139
|
+
}
|
|
6010
6140
|
};
|
|
6011
|
-
$ =
|
|
6141
|
+
$ = aa, $.isInline = !0, $.title = "Color", $.titleKey = "marker", $.shortcut = "CMD+SHIFT+H", $.ALLOWED_STYLE_PROPS = new Set(["color", "background-color"]);
|
|
6012
6142
|
//#endregion
|
|
6013
6143
|
//#region src/tools/index.ts
|
|
6014
|
-
var
|
|
6144
|
+
var oa = {
|
|
6015
6145
|
paragraph: { preserveBlank: !0 },
|
|
6016
6146
|
header: {},
|
|
6017
6147
|
list: {},
|
|
6018
6148
|
table: {},
|
|
6019
6149
|
toggle: {}
|
|
6020
|
-
},
|
|
6150
|
+
}, sa = {
|
|
6021
6151
|
bold: {},
|
|
6022
6152
|
italic: {},
|
|
6023
6153
|
link: {},
|
|
6024
6154
|
marker: {}
|
|
6025
6155
|
};
|
|
6026
6156
|
//#endregion
|
|
6027
|
-
export {
|
|
6157
|
+
export { $i as a, Mi as c, lt as d, na as i, Vn as l, sa as n, Zi as o, aa as r, Li as s, oa as t, Ct as u };
|