@jackuait/blok 0.6.0 → 0.7.0-beta.1
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-BAh1rvUC.mjs → blok-ob9Fwr1L.mjs} +1073 -1117
- package/dist/chunks/{i18next-loader-CHtGO6IK.mjs → i18next-loader-Bu3vFvye.mjs} +1 -1
- package/dist/chunks/{index-DBWWKrDe.mjs → index-CZmRzRIX.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-DduRc0fF.mjs → inline-tool-convert-CvFW2iie.mjs} +514 -412
- package/dist/full.mjs +30 -27
- package/dist/tools.mjs +1102 -775
- package/package.json +1 -1
- package/src/components/constants/data-attributes.ts +7 -0
- package/src/components/icons/index.ts +44 -7
- package/src/components/modules/blockEvents/composers/markdownShortcuts.ts +54 -2
- package/src/components/modules/blockEvents/constants.ts +12 -0
- package/src/components/ui/toolbox.ts +8 -0
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.const.ts +2 -2
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +4 -3
- package/src/components/utils/popover/components/search-input/search-input.const.ts +1 -1
- package/src/components/utils/popover/popover-abstract.ts +3 -2
- package/src/components/utils/popover/popover.const.ts +3 -3
- package/src/full.ts +4 -0
- package/src/stories/Placeholder.stories.ts +7 -2
- package/src/stories/helpers.ts +2 -0
- package/src/styles/main.css +18 -10
- package/src/tools/header/index.ts +203 -25
- package/src/tools/index.ts +3 -1
- package/src/tools/toggle/block-operations.ts +110 -0
- package/src/tools/toggle/constants.ts +49 -0
- package/src/tools/toggle/dom-builder.ts +125 -0
- package/src/tools/toggle/index.ts +280 -0
- package/src/tools/toggle/toggle-keyboard.ts +139 -0
- package/src/tools/toggle/toggle-lifecycle.ts +80 -0
- package/src/tools/toggle/toggle-shortcuts.ts +107 -0
- package/src/tools/toggle/types.ts +21 -0
- package/types/full.d.ts +2 -0
- package/types/tools-entry.d.ts +2 -1
package/dist/tools.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Ye = Object.defineProperty, Xe = Object.defineProperties;
|
|
2
|
+
var Ze = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Gt = Object.getOwnPropertySymbols;
|
|
4
|
+
var Je = Object.prototype.hasOwnProperty, Qe = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Wt = (r, t, e) => t in r ? Ye(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, T = (r, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
Je.call(t, e) && Wt(r, e, t[e]);
|
|
8
|
+
if (Gt)
|
|
9
|
+
for (var e of Gt(t))
|
|
10
|
+
Qe.call(t, e) && Wt(r, e, t[e]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
13
|
-
import { t as w, D,
|
|
14
|
-
import {
|
|
15
|
-
const
|
|
12
|
+
}, V = (r, t) => Xe(r, Ze(t));
|
|
13
|
+
import { t as w, D as B, ay as tn, az as en, aa as nn, aA as on, aB as sn, aC as rn, aD as ln, aE as an, aF as cn, aG as dn, aH as hn, aI as un, aJ as we, aK as ke, aL as Ee, n as pn, o as $t, ah as Ft, af as gn, aM as fn, aN as qt, P as F, aO as Ae, aP as mn, aQ as Cn, X as xe, a1 as Te, aR as bn, aS as yn, aT as vn, ac as Re, aU as Sn, aV as wn, aW as kn, aX as En, aY as An, aZ as xn, O as zt, a_ as Tn, a$ as Vt, b0 as Kt, b1 as Ut, R as Rn, b2 as Bn, x as Ln, b3 as In, K as $, b4 as Dn, b5 as Pn, S as lt, b6 as Hn, l as On, ak as Nn } from "./chunks/inline-tool-convert-CvFW2iie.mjs";
|
|
14
|
+
import { ao as Ii } from "./chunks/inline-tool-convert-CvFW2iie.mjs";
|
|
15
|
+
const Nt = (r) => {
|
|
16
16
|
if (!r || !r.includes("data-blok-fake-background"))
|
|
17
17
|
return r;
|
|
18
18
|
const t = document.createElement("div");
|
|
@@ -24,7 +24,7 @@ const ke = (r) => {
|
|
|
24
24
|
o.removeChild(n);
|
|
25
25
|
}
|
|
26
26
|
}), t.innerHTML;
|
|
27
|
-
},
|
|
27
|
+
}, nt = [
|
|
28
28
|
"empty:before:pointer-events-none",
|
|
29
29
|
"empty:before:text-gray-text",
|
|
30
30
|
"empty:before:cursor-text",
|
|
@@ -33,7 +33,7 @@ const ke = (r) => {
|
|
|
33
33
|
"data-[blok-empty=true]:before:text-gray-text",
|
|
34
34
|
"data-[blok-empty=true]:before:cursor-text",
|
|
35
35
|
"data-[blok-empty=true]:before:content-[attr(data-placeholder)]"
|
|
36
|
-
],
|
|
36
|
+
], _n = [
|
|
37
37
|
"empty:focus:before:pointer-events-none",
|
|
38
38
|
"empty:focus:before:text-gray-text",
|
|
39
39
|
"empty:focus:before:cursor-text",
|
|
@@ -42,7 +42,7 @@ const ke = (r) => {
|
|
|
42
42
|
"[&[data-empty=true]:focus]:before:text-gray-text",
|
|
43
43
|
"[&[data-empty=true]:focus]:before:cursor-text",
|
|
44
44
|
"[&[data-empty=true]:focus]:before:content-[attr(data-blok-placeholder-active)]"
|
|
45
|
-
],
|
|
45
|
+
], Mn = [
|
|
46
46
|
"empty:in-data-[blok-empty=true]:before:pointer-events-none",
|
|
47
47
|
"empty:in-data-[blok-empty=true]:before:text-gray-text",
|
|
48
48
|
"empty:in-data-[blok-empty=true]:before:cursor-text",
|
|
@@ -51,27 +51,27 @@ const ke = (r) => {
|
|
|
51
51
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:text-gray-text",
|
|
52
52
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:cursor-text",
|
|
53
53
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:content-[attr(data-blok-placeholder-active)]"
|
|
54
|
-
],
|
|
54
|
+
], Gn = (r) => {
|
|
55
55
|
const t = r.innerHTML.trim();
|
|
56
56
|
return t === "" || t === "<br>";
|
|
57
|
-
},
|
|
57
|
+
}, Wn = (r) => {
|
|
58
58
|
r.innerHTML === "<br>" && (r.innerHTML = "");
|
|
59
59
|
const t = window.getSelection();
|
|
60
60
|
if (!t) return;
|
|
61
61
|
const e = document.createRange();
|
|
62
62
|
e.selectNodeContents(r), e.collapse(!0), t.removeAllRanges(), t.addRange(e);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
},
|
|
63
|
+
}, $n = (r) => {
|
|
64
|
+
Gn(r) && Wn(r);
|
|
65
|
+
}, wt = (r, t, e = "data-placeholder") => {
|
|
66
66
|
r.setAttribute(e, t != null ? t : "");
|
|
67
|
-
const n = () =>
|
|
67
|
+
const n = () => $n(r);
|
|
68
68
|
r.addEventListener("focus", n), r.addEventListener("input", n);
|
|
69
|
-
},
|
|
69
|
+
}, Fn = (r) => {
|
|
70
70
|
const t = document.createElement("div");
|
|
71
71
|
t.innerHTML = r.trim();
|
|
72
72
|
const e = document.createDocumentFragment();
|
|
73
73
|
return e.append(...Array.from(t.childNodes)), e;
|
|
74
|
-
},
|
|
74
|
+
}, ht = class ht {
|
|
75
75
|
/**
|
|
76
76
|
* Default placeholder for Paragraph Tool
|
|
77
77
|
*
|
|
@@ -91,7 +91,7 @@ const ke = (r) => {
|
|
|
91
91
|
*/
|
|
92
92
|
constructor({ data: t, config: e, api: n, readOnly: o }) {
|
|
93
93
|
var s, i, l;
|
|
94
|
-
this.api = n, this.readOnly = o, this.readOnly || (this.onKeyUp = this.onKeyUp.bind(this)), this._placeholder = (s = e == null ? void 0 : e.placeholder) != null ? s :
|
|
94
|
+
this.api = n, this.readOnly = o, this.readOnly || (this.onKeyUp = this.onKeyUp.bind(this)), this._placeholder = (s = e == null ? void 0 : e.placeholder) != null ? s : ht.DEFAULT_PLACEHOLDER, this._data = t != null ? t : { text: "" }, this._element = null, this._preserveBlank = (i = e == null ? void 0 : e.preserveBlank) != null ? i : !1, this._styles = (l = e == null ? void 0 : e.styles) != null ? l : {};
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Check if text content is empty and set empty string to inner html.
|
|
@@ -118,12 +118,12 @@ const ke = (r) => {
|
|
|
118
118
|
const t = document.createElement("DIV");
|
|
119
119
|
t.className = w(
|
|
120
120
|
this.api.styles.block,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
), t.setAttribute(
|
|
121
|
+
ht.WRAPPER_CLASSES,
|
|
122
|
+
_n,
|
|
123
|
+
Mn
|
|
124
|
+
), t.setAttribute(B.tool, "paragraph"), t.contentEditable = "false";
|
|
125
125
|
const e = this.buildInlineStyles();
|
|
126
|
-
return Object.keys(e).length > 0 && Object.assign(t.style, e), this._data.text ? t.innerHTML = this._data.text : this.readOnly && (t.innerHTML = "<br>"), this.readOnly || (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp),
|
|
126
|
+
return Object.keys(e).length > 0 && Object.assign(t.style, e), this._data.text ? t.innerHTML = this._data.text : this.readOnly && (t.innerHTML = "<br>"), this.readOnly || (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp), wt(t, this.api.i18n.t(this._placeholder), "data-blok-placeholder-active")), t;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Return Tool's view
|
|
@@ -143,7 +143,7 @@ const ke = (r) => {
|
|
|
143
143
|
if (!this._element)
|
|
144
144
|
return;
|
|
145
145
|
this._data.text += t.text;
|
|
146
|
-
const e =
|
|
146
|
+
const e = Fn(t.text);
|
|
147
147
|
this._element.appendChild(e), this._element.normalize();
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
@@ -164,7 +164,7 @@ const ke = (r) => {
|
|
|
164
164
|
*/
|
|
165
165
|
save(t) {
|
|
166
166
|
return {
|
|
167
|
-
text:
|
|
167
|
+
text: Nt(t.innerHTML)
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
@@ -241,14 +241,14 @@ const ke = (r) => {
|
|
|
241
241
|
*/
|
|
242
242
|
static get toolbox() {
|
|
243
243
|
return {
|
|
244
|
-
icon:
|
|
244
|
+
icon: tn,
|
|
245
245
|
title: "Text",
|
|
246
246
|
titleKey: "text",
|
|
247
247
|
searchTerms: ["p", "paragraph", "plain"]
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
|
|
251
|
+
ht.WRAPPER_CLASSES = [
|
|
252
252
|
"leading-[1.6em]",
|
|
253
253
|
"outline-hidden",
|
|
254
254
|
"mt-[2px]",
|
|
@@ -256,8 +256,35 @@ ct.WRAPPER_CLASSES = [
|
|
|
256
256
|
"[&>p:first-of-type]:mt-0",
|
|
257
257
|
"[&>p:last-of-type]:mb-0"
|
|
258
258
|
];
|
|
259
|
-
let
|
|
260
|
-
const
|
|
259
|
+
let jt = ht;
|
|
260
|
+
const _t = "toggle", Yt = "tools.toggle.placeholder", qn = "outline-hidden py-[3px] mt-[2px] mb-px", zn = "outline-hidden pl-0.5 leading-[1.6em] flex-1 min-w-0", Lt = "flex items-start", Be = "flex-shrink-0 w-6 h-6 flex items-center justify-center cursor-pointer select-none rounded hover:bg-black/5 transition-all duration-200 ease-in-out mt-px", It = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.5 2.5L8.5 6L4.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>', W = {
|
|
261
|
+
toggleOpen: "data-blok-toggle-open",
|
|
262
|
+
toggleArrow: "data-blok-toggle-arrow",
|
|
263
|
+
toggleContent: "data-blok-toggle-content"
|
|
264
|
+
}, Vn = (r) => {
|
|
265
|
+
const { data: t, readOnly: e, isOpen: n, keydownHandler: o, onArrowClick: s } = r, i = document.createElement("div");
|
|
266
|
+
i.className = w(qn, Lt), i.setAttribute(B.tool, _t), i.setAttribute(W.toggleOpen, String(n));
|
|
267
|
+
const l = Kn(n, s), a = Un(t, e, o);
|
|
268
|
+
return i.appendChild(l), i.appendChild(a), { wrapper: i, arrowElement: l, contentElement: a };
|
|
269
|
+
}, Kn = (r, t) => {
|
|
270
|
+
const e = document.createElement("div");
|
|
271
|
+
return e.className = Be, e.setAttribute(W.toggleArrow, ""), e.setAttribute("role", "button"), e.setAttribute("tabindex", "-1"), e.setAttribute("aria-label", "Toggle"), e.innerHTML = It, r && (e.style.transform = "rotate(90deg)"), e.addEventListener("click", (n) => {
|
|
272
|
+
n.stopPropagation(), t();
|
|
273
|
+
}), e;
|
|
274
|
+
}, Un = (r, t, e) => {
|
|
275
|
+
const n = document.createElement("div");
|
|
276
|
+
return n.className = zn, n.setAttribute(W.toggleContent, ""), n.contentEditable = t ? "false" : "true", n.innerHTML = r.text, e && n.addEventListener("keydown", e), n;
|
|
277
|
+
}, jn = (r) => {
|
|
278
|
+
const t = Vn(r);
|
|
279
|
+
return t.contentElement && wt(t.contentElement, r.placeholder), t;
|
|
280
|
+
}, Le = (r, t, e) => {
|
|
281
|
+
const { style: n } = r;
|
|
282
|
+
n.transform = e ? "rotate(90deg)" : "", r.setAttribute("aria-label", e ? "Collapse" : "Expand"), t.setAttribute(W.toggleOpen, String(e));
|
|
283
|
+
}, Ie = (r, t, e) => {
|
|
284
|
+
const n = r.blocks.getChildren(t);
|
|
285
|
+
for (const o of n)
|
|
286
|
+
e ? o.holder.classList.remove("hidden") : o.holder.classList.add("hidden");
|
|
287
|
+
}, P = class P {
|
|
261
288
|
/**
|
|
262
289
|
* Render plugin's main Element and fill it with saved data
|
|
263
290
|
*
|
|
@@ -266,9 +293,10 @@ const V = class V {
|
|
|
266
293
|
* @param options.config - user config for Tool
|
|
267
294
|
* @param options.api - Editor API
|
|
268
295
|
* @param options.readOnly - read only mode flag
|
|
296
|
+
* @param options.block - block instance
|
|
269
297
|
*/
|
|
270
|
-
constructor({ data: t, config: e, api: n, readOnly: o }) {
|
|
271
|
-
this.api = n, this.readOnly = o, this._settings = e || {}, this._data = this.normalizeData(t), this._element = this.getTag();
|
|
298
|
+
constructor({ data: t, config: e, api: n, readOnly: o, block: s }) {
|
|
299
|
+
this._arrowElement = null, this._isOpen = !1, this.api = n, this.readOnly = o, this._settings = e || {}, this._data = this.normalizeData(t), this._element = this.getTag(), s && (this.blockId = s.id);
|
|
272
300
|
}
|
|
273
301
|
/**
|
|
274
302
|
* Styles
|
|
@@ -298,11 +326,11 @@ const V = class V {
|
|
|
298
326
|
normalizeData(t) {
|
|
299
327
|
if (!this.isHeaderData(t))
|
|
300
328
|
return { text: "", level: this.defaultLevel.number };
|
|
301
|
-
const e = parseInt(String(t.level)), n = t.level !== void 0 && !isNaN(e)
|
|
302
|
-
return {
|
|
329
|
+
const e = parseInt(String(t.level)), n = t.level !== void 0 && !isNaN(e), o = {
|
|
303
330
|
text: t.text || "",
|
|
304
331
|
level: n ? e : this.defaultLevel.number
|
|
305
332
|
};
|
|
333
|
+
return t.isToggleable === !0 && (o.isToggleable = !0), o;
|
|
306
334
|
}
|
|
307
335
|
/**
|
|
308
336
|
* Return Tool's view
|
|
@@ -312,26 +340,39 @@ const V = class V {
|
|
|
312
340
|
render() {
|
|
313
341
|
return this._element;
|
|
314
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Called after the block is rendered in the DOM.
|
|
345
|
+
* Hides children if the toggle heading is collapsed.
|
|
346
|
+
*/
|
|
347
|
+
rendered() {
|
|
348
|
+
this._data.isToggleable && this.updateChildrenVisibility();
|
|
349
|
+
}
|
|
315
350
|
/**
|
|
316
351
|
* Returns header block tunes config
|
|
317
352
|
*
|
|
318
353
|
* @returns MenuConfig array
|
|
319
354
|
*/
|
|
320
355
|
renderSettings() {
|
|
321
|
-
const t = this._settings._toolboxEntries, e = (t == null ? void 0 : t.length) === 1 && t[0].data === void 0 && (t[0].title === void 0 || t[0].title === "Heading")
|
|
322
|
-
|
|
323
|
-
const o = this.api.i18n.t(n.nameKey), s = o !== n.nameKey ? o : n.name;
|
|
356
|
+
const t = this._settings._toolboxEntries, e = (t == null ? void 0 : t.length) === 1 && t[0].data === void 0 && (t[0].title === void 0 || t[0].title === "Heading"), n = t !== void 0 && t.length > 0 && !e ? this.buildSettingsFromToolboxEntries(t) : this.levels.map((i) => {
|
|
357
|
+
const l = this.api.i18n.t(i.nameKey), a = l !== i.nameKey ? l : i.name;
|
|
324
358
|
return {
|
|
325
|
-
icon:
|
|
326
|
-
title:
|
|
327
|
-
onActivate: () => this.setLevel(
|
|
359
|
+
icon: i.icon,
|
|
360
|
+
title: a,
|
|
361
|
+
onActivate: () => this.setLevel(i.number),
|
|
328
362
|
closeOnActivate: !0,
|
|
329
|
-
isActive: this.currentLevel.number ===
|
|
363
|
+
isActive: this.currentLevel.number === i.number,
|
|
330
364
|
dataset: {
|
|
331
|
-
"blok-header-level": String(
|
|
365
|
+
"blok-header-level": String(i.number)
|
|
332
366
|
}
|
|
333
367
|
};
|
|
334
|
-
});
|
|
368
|
+
}), o = Array.isArray(n) ? n : [n], s = this.api.i18n.t("tools.header.toggleHeading");
|
|
369
|
+
return o.push({
|
|
370
|
+
icon: It,
|
|
371
|
+
title: s !== "tools.header.toggleHeading" ? s : "Toggle heading",
|
|
372
|
+
onActivate: () => this.toggleIsToggleable(),
|
|
373
|
+
closeOnActivate: !0,
|
|
374
|
+
isActive: this._data.isToggleable === !0
|
|
375
|
+
}), o;
|
|
335
376
|
}
|
|
336
377
|
/**
|
|
337
378
|
* Build settings menu items from toolbox entries.
|
|
@@ -344,9 +385,9 @@ const V = class V {
|
|
|
344
385
|
buildSettingsFromToolboxEntries(t) {
|
|
345
386
|
return t.map((e) => {
|
|
346
387
|
var c, d, h, u;
|
|
347
|
-
const n = e.data, o = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, s =
|
|
388
|
+
const n = e.data, o = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, s = P.DEFAULT_LEVELS.find((p) => p.number === o), i = (d = s == null ? void 0 : s.name) != null ? d : `Heading ${o}`, l = this.resolveToolboxEntryTitle(e, i);
|
|
348
389
|
return {
|
|
349
|
-
icon: (u = (h = e.icon) != null ? h : s == null ? void 0 : s.icon) != null ? u :
|
|
390
|
+
icon: (u = (h = e.icon) != null ? h : s == null ? void 0 : s.icon) != null ? u : en,
|
|
350
391
|
title: l,
|
|
351
392
|
onActivate: () => this.setLevel(o),
|
|
352
393
|
closeOnActivate: !0,
|
|
@@ -365,7 +406,7 @@ const V = class V {
|
|
|
365
406
|
* @returns Resolved title string
|
|
366
407
|
*/
|
|
367
408
|
resolveToolboxEntryTitle(t, e) {
|
|
368
|
-
return
|
|
409
|
+
return nn(this.api.i18n, t, e);
|
|
369
410
|
}
|
|
370
411
|
/**
|
|
371
412
|
* Callback for Block's settings buttons
|
|
@@ -375,7 +416,8 @@ const V = class V {
|
|
|
375
416
|
setLevel(t) {
|
|
376
417
|
this.data = {
|
|
377
418
|
level: t,
|
|
378
|
-
text: this.data.text
|
|
419
|
+
text: this.data.text,
|
|
420
|
+
isToggleable: this._data.isToggleable
|
|
379
421
|
};
|
|
380
422
|
}
|
|
381
423
|
/**
|
|
@@ -404,10 +446,11 @@ const V = class V {
|
|
|
404
446
|
* @returns saved data
|
|
405
447
|
*/
|
|
406
448
|
save(t) {
|
|
407
|
-
|
|
449
|
+
const e = {
|
|
408
450
|
text: t.innerHTML,
|
|
409
451
|
level: this.currentLevel.number
|
|
410
452
|
};
|
|
453
|
+
return this._data.isToggleable === !0 && (e.isToggleable = !0), e;
|
|
411
454
|
}
|
|
412
455
|
/**
|
|
413
456
|
* Allow Header to be converted to/from other blocks
|
|
@@ -426,7 +469,8 @@ const V = class V {
|
|
|
426
469
|
static get sanitize() {
|
|
427
470
|
return {
|
|
428
471
|
level: !1,
|
|
429
|
-
text: {}
|
|
472
|
+
text: {},
|
|
473
|
+
isToggleable: !1
|
|
430
474
|
};
|
|
431
475
|
}
|
|
432
476
|
/**
|
|
@@ -457,7 +501,14 @@ const V = class V {
|
|
|
457
501
|
const e = this.getTag();
|
|
458
502
|
e.innerHTML = this._element.innerHTML, this._element.parentNode.replaceChild(e, this._element), this._element = e;
|
|
459
503
|
}
|
|
460
|
-
t.text !== void 0 && (this._element.innerHTML = this._data.text || "")
|
|
504
|
+
if (t.text !== void 0 && (this._element.innerHTML = this._data.text || ""), this._data.isToggleable) {
|
|
505
|
+
if (this._element.setAttribute(W.toggleOpen, String(this._isOpen)), !this._element.querySelector(`[${W.toggleArrow}]`)) {
|
|
506
|
+
const e = this.buildArrow();
|
|
507
|
+
this._arrowElement = e, this._element.prepend(e);
|
|
508
|
+
}
|
|
509
|
+
this._element.className = w(P.BASE_STYLES, this.currentLevel.styles, nt, Lt);
|
|
510
|
+
} else
|
|
511
|
+
this._element.removeAttribute(W.toggleOpen), this._arrowElement = null, this._element.className = w(P.BASE_STYLES, this.currentLevel.styles, nt);
|
|
461
512
|
}
|
|
462
513
|
/**
|
|
463
514
|
* Get tag for target level
|
|
@@ -467,9 +518,49 @@ const V = class V {
|
|
|
467
518
|
*/
|
|
468
519
|
getTag() {
|
|
469
520
|
const t = document.createElement(this.currentLevel.tag);
|
|
470
|
-
t.innerHTML = this._data.text || "", t.className = w(
|
|
521
|
+
t.innerHTML = this._data.text || "", t.className = w(P.BASE_STYLES, this.currentLevel.styles, nt, this._data.isToggleable ? Lt : "");
|
|
471
522
|
const { inlineStyles: e } = this.currentLevel;
|
|
472
|
-
|
|
523
|
+
if (e && Object.assign(t.style, e), t.setAttribute(B.tool, "header"), t.contentEditable = this.readOnly ? "false" : "true", this._data.isToggleable) {
|
|
524
|
+
t.setAttribute(W.toggleOpen, String(this._isOpen));
|
|
525
|
+
const n = this.buildArrow();
|
|
526
|
+
this._arrowElement = n, t.prepend(n);
|
|
527
|
+
}
|
|
528
|
+
return this.readOnly ? t.setAttribute("data-placeholder", this.api.i18n.t(this._settings.placeholder || "")) : wt(t, this.api.i18n.t(this._settings.placeholder || "")), t;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Build the arrow element for toggle heading.
|
|
532
|
+
*
|
|
533
|
+
* @returns The arrow element
|
|
534
|
+
*/
|
|
535
|
+
buildArrow() {
|
|
536
|
+
const t = document.createElement("div");
|
|
537
|
+
return t.className = Be, t.setAttribute(W.toggleArrow, ""), t.setAttribute("role", "button"), t.setAttribute("tabindex", "-1"), t.setAttribute("aria-label", "Expand"), t.contentEditable = "false", t.innerHTML = It, this._isOpen && (t.style.transform = "rotate(90deg)"), t.addEventListener("click", (e) => {
|
|
538
|
+
e.stopPropagation(), this.toggleOpen();
|
|
539
|
+
}), t;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Toggle the isToggleable state on/off.
|
|
543
|
+
* Called from the settings menu.
|
|
544
|
+
*/
|
|
545
|
+
toggleIsToggleable() {
|
|
546
|
+
const t = this._data.isToggleable === !0;
|
|
547
|
+
this.data = {
|
|
548
|
+
level: this._data.level,
|
|
549
|
+
text: this._data.text,
|
|
550
|
+
isToggleable: !t || void 0
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Toggle the open/closed state of the toggle heading.
|
|
555
|
+
*/
|
|
556
|
+
toggleOpen() {
|
|
557
|
+
this._isOpen = !this._isOpen, this._arrowElement && this._element && Le(this._arrowElement, this._element, this._isOpen), this.updateChildrenVisibility();
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Show or hide child blocks based on the toggle's open state.
|
|
561
|
+
*/
|
|
562
|
+
updateChildrenVisibility() {
|
|
563
|
+
this.blockId !== void 0 && Ie(this.api, this.blockId, this._isOpen);
|
|
473
564
|
}
|
|
474
565
|
/**
|
|
475
566
|
* Get current level
|
|
@@ -497,7 +588,7 @@ const V = class V {
|
|
|
497
588
|
* @returns Level array
|
|
498
589
|
*/
|
|
499
590
|
get levels() {
|
|
500
|
-
const t = this._settings.levelOverrides || {}, e =
|
|
591
|
+
const t = this._settings.levelOverrides || {}, e = P.DEFAULT_LEVELS.map((o) => {
|
|
501
592
|
var l;
|
|
502
593
|
const s = t[o.number] || {}, i = {};
|
|
503
594
|
return s.size && (i.fontSize = s.size), s.marginTop && (i.marginTop = s.marginTop), s.marginBottom && (i.marginBottom = s.marginBottom), {
|
|
@@ -554,30 +645,42 @@ const V = class V {
|
|
|
554
645
|
* @returns ToolboxConfig array with entries for H1-H6
|
|
555
646
|
*/
|
|
556
647
|
static get toolbox() {
|
|
557
|
-
|
|
558
|
-
icon:
|
|
559
|
-
title:
|
|
560
|
-
titleKey:
|
|
561
|
-
name: `header-${
|
|
562
|
-
data: { level:
|
|
563
|
-
searchTerms: [`h${
|
|
564
|
-
shortcut: "#".repeat(
|
|
648
|
+
const t = P.DEFAULT_LEVELS.map((o) => ({
|
|
649
|
+
icon: o.icon,
|
|
650
|
+
title: o.name,
|
|
651
|
+
titleKey: o.nameKey,
|
|
652
|
+
name: `header-${o.number}`,
|
|
653
|
+
data: { level: o.number },
|
|
654
|
+
searchTerms: [`h${o.number}`, "title", "header", "heading"],
|
|
655
|
+
shortcut: "#".repeat(o.number)
|
|
656
|
+
})), e = {
|
|
657
|
+
1: un,
|
|
658
|
+
2: hn,
|
|
659
|
+
3: dn
|
|
660
|
+
}, n = P.DEFAULT_LEVELS.filter((o) => o.number <= 3).map((o) => ({
|
|
661
|
+
icon: e[o.number],
|
|
662
|
+
title: `Toggle heading ${o.number}`,
|
|
663
|
+
titleKey: `tools.header.toggleHeading${o.number}`,
|
|
664
|
+
name: `toggle-header-${o.number}`,
|
|
665
|
+
data: { level: o.number, isToggleable: !0 },
|
|
666
|
+
searchTerms: ["toggle", "heading", `h${o.number}`, "collapsible"]
|
|
565
667
|
}));
|
|
668
|
+
return [...t, ...n];
|
|
566
669
|
}
|
|
567
670
|
};
|
|
568
|
-
|
|
569
|
-
{ number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon:
|
|
570
|
-
{ number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon:
|
|
571
|
-
{ number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon:
|
|
572
|
-
{ number: 4, tag: "H4", nameKey: "tools.header.heading4", name: "Heading 4", icon:
|
|
573
|
-
{ number: 5, tag: "H5", nameKey: "tools.header.heading5", name: "Heading 5", icon:
|
|
574
|
-
{ number: 6, tag: "H6", nameKey: "tools.header.heading6", name: "Heading 6", icon:
|
|
671
|
+
P.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!", P.DEFAULT_LEVELS = [
|
|
672
|
+
{ number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon: on, styles: "text-4xl font-bold mt-8 mb-1" },
|
|
673
|
+
{ number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon: sn, styles: "text-3xl font-semibold mt-6 mb-px" },
|
|
674
|
+
{ number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon: rn, styles: "text-2xl font-semibold mt-4 mb-px" },
|
|
675
|
+
{ number: 4, tag: "H4", nameKey: "tools.header.heading4", name: "Heading 4", icon: ln, styles: "text-xl font-semibold mt-3 mb-px" },
|
|
676
|
+
{ number: 5, tag: "H5", nameKey: "tools.header.heading5", name: "Heading 5", icon: an, styles: "text-base font-semibold mt-3 mb-px" },
|
|
677
|
+
{ number: 6, tag: "H6", nameKey: "tools.header.heading6", name: "Heading 6", icon: cn, styles: "text-sm font-semibold mt-3 mb-px" }
|
|
575
678
|
];
|
|
576
|
-
let
|
|
577
|
-
const
|
|
679
|
+
let Xt = P;
|
|
680
|
+
const Q = 24, Yn = "outline-hidden py-[3px] mt-[2px] mb-px", Xn = "outline-hidden pl-0.5 leading-[1.6em]", Zn = "flex items-start pl-0.5", Jn = "mt-1 w-4 mr-2 h-4 cursor-pointer accent-current", Qn = "tools.list.placeholder", L = "list", De = {
|
|
578
681
|
contentContainer: "list-content-container",
|
|
579
682
|
checklistContent: "list-checklist-content"
|
|
580
|
-
},
|
|
683
|
+
}, Pe = (r, t) => {
|
|
581
684
|
const e = r;
|
|
582
685
|
e._placeholder = t, Object.defineProperty(e, "getPlaceholder", {
|
|
583
686
|
value: () => e._placeholder,
|
|
@@ -585,8 +688,8 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
585
688
|
enumerable: !0,
|
|
586
689
|
configurable: !1
|
|
587
690
|
});
|
|
588
|
-
},
|
|
589
|
-
const { data: t, keydownHandler: e, readOnly: n } = r, o =
|
|
691
|
+
}, He = (r) => {
|
|
692
|
+
const { data: t, keydownHandler: e, readOnly: n } = r, o = to(r), s = t.style === "checklist" ? no(r) : eo(r);
|
|
590
693
|
o.appendChild(s), !n && e && o.addEventListener("keydown", e);
|
|
591
694
|
const i = s.querySelector("[data-list-marker]"), l = s.querySelector('input[type="checkbox"]'), a = s.querySelector("[contenteditable]");
|
|
592
695
|
return {
|
|
@@ -595,52 +698,52 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
595
698
|
markerElement: i,
|
|
596
699
|
checkboxElement: l
|
|
597
700
|
};
|
|
598
|
-
},
|
|
701
|
+
}, to = (r) => {
|
|
599
702
|
var n;
|
|
600
703
|
const { data: t } = r, e = document.createElement("div");
|
|
601
|
-
return e.className =
|
|
602
|
-
},
|
|
704
|
+
return e.className = Yn, e.setAttribute(B.tool, L), e.setAttribute("data-list-style", t.style), e.setAttribute("data-list-depth", String((n = t.depth) != null ? n : 0)), t.start !== void 0 && t.start !== 1 && e.setAttribute("data-list-start", String(t.start)), e;
|
|
705
|
+
}, eo = (r) => {
|
|
603
706
|
var c;
|
|
604
707
|
const { data: t, itemColor: e, itemSize: n, placeholder: o } = r, s = document.createElement("div");
|
|
605
|
-
s.setAttribute("role", "listitem"), s.className = w(
|
|
708
|
+
s.setAttribute("role", "listitem"), s.className = w(Xn, "flex", ...nt), e && (s.style.color = e), n && (s.style.fontSize = n);
|
|
606
709
|
const i = (c = t.depth) != null ? c : 0;
|
|
607
|
-
i > 0 && (s.style.marginLeft = `${i *
|
|
608
|
-
const l =
|
|
710
|
+
i > 0 && (s.style.marginLeft = `${i * Q}px`);
|
|
711
|
+
const l = oo(t.style, i);
|
|
609
712
|
l.setAttribute("data-list-marker", "true"), l.setAttribute("data-blok-mutation-free", "true"), s.appendChild(l);
|
|
610
713
|
const a = document.createElement("div");
|
|
611
|
-
return a.className = w("flex-1 min-w-0 outline-hidden", ...
|
|
612
|
-
},
|
|
714
|
+
return a.className = w("flex-1 min-w-0 outline-hidden", ...nt), a.setAttribute("data-blok-testid", De.contentContainer), a.contentEditable = r.readOnly ? "false" : "true", a.innerHTML = t.text, Pe(a, o), s.appendChild(a), s;
|
|
715
|
+
}, no = (r) => {
|
|
613
716
|
var d;
|
|
614
717
|
const { data: t, itemColor: e, itemSize: n, placeholder: o, readOnly: s } = r, i = document.createElement("div");
|
|
615
|
-
i.setAttribute("role", "listitem"), i.className =
|
|
718
|
+
i.setAttribute("role", "listitem"), i.className = Zn, e && (i.style.color = e), n && (i.style.fontSize = n);
|
|
616
719
|
const l = (d = t.depth) != null ? d : 0;
|
|
617
|
-
l > 0 && (i.style.marginLeft = `${l *
|
|
720
|
+
l > 0 && (i.style.marginLeft = `${l * Q}px`);
|
|
618
721
|
const a = document.createElement("input");
|
|
619
|
-
a.type = "checkbox", a.className =
|
|
722
|
+
a.type = "checkbox", a.className = Jn, a.checked = !!t.checked, a.disabled = s;
|
|
620
723
|
const c = document.createElement("div");
|
|
621
724
|
return c.className = w(
|
|
622
725
|
"flex-1 outline-hidden leading-[1.6em]",
|
|
623
726
|
t.checked ? "line-through opacity-60" : "",
|
|
624
|
-
...
|
|
625
|
-
), c.setAttribute("data-blok-testid",
|
|
626
|
-
},
|
|
727
|
+
...nt
|
|
728
|
+
), c.setAttribute("data-blok-testid", De.checklistContent), c.setAttribute("data-checked", String(t.checked)), c.contentEditable = s ? "false" : "true", c.innerHTML = t.text, Pe(c, o), i.appendChild(a), i.appendChild(c), i;
|
|
729
|
+
}, oo = (r, t) => {
|
|
627
730
|
const e = document.createElement("span");
|
|
628
731
|
if (e.className = "shrink-0 select-none", e.setAttribute("aria-hidden", "true"), e.contentEditable = "false", r === "ordered")
|
|
629
732
|
e.textContent = "1.", e.className = w(e.className, "text-right"), e.style.paddingRight = "11px", e.style.minWidth = "fit-content";
|
|
630
733
|
else {
|
|
631
|
-
const n =
|
|
734
|
+
const n = so(t);
|
|
632
735
|
e.textContent = n, e.className = w(e.className, "w-6 text-center flex justify-center"), e.style.paddingLeft = "1px", e.style.paddingRight = "13px", e.style.fontSize = "24px", e.style.fontFamily = "Arial";
|
|
633
736
|
}
|
|
634
737
|
return e;
|
|
635
|
-
},
|
|
738
|
+
}, so = (r) => {
|
|
636
739
|
const t = ["•", "◦", "▪"];
|
|
637
740
|
return t[r % t.length];
|
|
638
|
-
},
|
|
741
|
+
}, io = (r) => {
|
|
639
742
|
const { data: t, readOnly: e, placeholder: n, itemColor: o, itemSize: s, element: i, setupItemPlaceholder: l, onCheckboxChange: a, keydownHandler: c } = r;
|
|
640
743
|
if (!i) return null;
|
|
641
744
|
const d = i.parentNode;
|
|
642
745
|
if (!d) return null;
|
|
643
|
-
const h =
|
|
746
|
+
const h = He({
|
|
644
747
|
data: t,
|
|
645
748
|
readOnly: e,
|
|
646
749
|
placeholder: n,
|
|
@@ -655,26 +758,26 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
655
758
|
});
|
|
656
759
|
}
|
|
657
760
|
return d.replaceChild(h.wrapper, i), h.wrapper;
|
|
658
|
-
},
|
|
761
|
+
}, ro = (r, t, e) => {
|
|
659
762
|
if (!t) return r;
|
|
660
763
|
const n = e(), s = {
|
|
661
|
-
text: n ?
|
|
764
|
+
text: n ? Nt(n.innerHTML) : r.text,
|
|
662
765
|
style: r.style,
|
|
663
766
|
checked: r.checked
|
|
664
767
|
};
|
|
665
768
|
return r.start !== void 0 && r.start !== 1 && (s.start = r.start), r.depth !== void 0 && r.depth > 0 && (s.depth = r.depth), s;
|
|
666
|
-
},
|
|
769
|
+
}, lo = (r, t, e, n, o) => {
|
|
667
770
|
var g, f, m;
|
|
668
771
|
if (!e)
|
|
669
772
|
return { newData: r, inPlace: !1 };
|
|
670
773
|
const s = (g = r.depth) != null ? g : 0, i = (f = t.depth) != null ? f : 0, l = r.style, a = t.style;
|
|
671
774
|
if (l !== a)
|
|
672
775
|
return { newData: r, inPlace: !1 };
|
|
673
|
-
const c = "depth" in t ? t.depth : 0, d =
|
|
776
|
+
const c = "depth" in t ? t.depth : 0, d = V(T(T({}, r), t), {
|
|
674
777
|
depth: c
|
|
675
778
|
}), h = n();
|
|
676
779
|
return h && typeof t.text == "string" && (h.innerHTML = t.text), s !== i ? (o.adjustDepthTo(i), o.updateMarkerForDepth(i, a), { newData: d, inPlace: !0 }) : (a === "checklist" && o.updateCheckboxState((m = t.checked) != null ? m : !1), { newData: d, inPlace: !0 });
|
|
677
|
-
},
|
|
780
|
+
}, ao = (r, t) => {
|
|
678
781
|
const { element: e, getContentElement: n, parseHTML: o, data: s } = r;
|
|
679
782
|
if (!e)
|
|
680
783
|
return;
|
|
@@ -684,13 +787,13 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
684
787
|
const l = o(t.text);
|
|
685
788
|
i.appendChild(l), i.normalize();
|
|
686
789
|
}
|
|
687
|
-
},
|
|
790
|
+
}, co = (r, t, e, n) => r.map((o) => ({
|
|
688
791
|
icon: o.icon,
|
|
689
792
|
title: e(`toolNames.${o.titleKey}`),
|
|
690
793
|
onActivate: () => n(o.style),
|
|
691
794
|
closeOnActivate: !0,
|
|
692
795
|
isActive: t === o.style
|
|
693
|
-
})),
|
|
796
|
+
})), ho = (r) => {
|
|
694
797
|
if (!r)
|
|
695
798
|
return;
|
|
696
799
|
const e = (r.getAttribute("style") || "").match(/margin-left:\s*(\d+)px/);
|
|
@@ -698,7 +801,7 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
698
801
|
return;
|
|
699
802
|
const n = parseInt(e[1], 10);
|
|
700
803
|
return n > 0 ? { left: n } : void 0;
|
|
701
|
-
},
|
|
804
|
+
}, uo = (r) => {
|
|
702
805
|
const t = r.closest("[data-list-depth]");
|
|
703
806
|
if (!t)
|
|
704
807
|
return;
|
|
@@ -706,11 +809,11 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
706
809
|
if (e === null)
|
|
707
810
|
return;
|
|
708
811
|
const n = parseInt(e, 10);
|
|
709
|
-
return n > 0 ? { left: n *
|
|
710
|
-
},
|
|
711
|
-
const t = r.closest('[role="listitem"]') || r.querySelector('[role="listitem"]'), e =
|
|
712
|
-
return e !== void 0 ? e :
|
|
713
|
-
},
|
|
812
|
+
return n > 0 ? { left: n * Q } : void 0;
|
|
813
|
+
}, po = (r) => {
|
|
814
|
+
const t = r.closest('[role="listitem"]') || r.querySelector('[role="listitem"]'), e = ho(t);
|
|
815
|
+
return e !== void 0 ? e : uo(r);
|
|
816
|
+
}, go = (r, t) => {
|
|
714
817
|
const e = document.createRange();
|
|
715
818
|
if (e.setStart(r, 0), e.setEnd(t.startContainer, t.startOffset), !r.lastChild)
|
|
716
819
|
return {
|
|
@@ -719,33 +822,33 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
719
822
|
};
|
|
720
823
|
const n = document.createRange();
|
|
721
824
|
return n.setStart(t.endContainer, t.endOffset), n.setEndAfter(r.lastChild), {
|
|
722
|
-
beforeContent:
|
|
723
|
-
afterContent:
|
|
825
|
+
beforeContent: Zt(e.cloneContents()),
|
|
826
|
+
afterContent: Zt(n.cloneContents())
|
|
724
827
|
};
|
|
725
|
-
},
|
|
828
|
+
}, Zt = (r) => {
|
|
726
829
|
const t = document.createElement("div");
|
|
727
830
|
return t.appendChild(r), t.innerHTML;
|
|
728
|
-
},
|
|
831
|
+
}, fo = (r) => {
|
|
729
832
|
const t = document.createElement("div");
|
|
730
833
|
t.innerHTML = r.trim();
|
|
731
834
|
const e = document.createDocumentFragment();
|
|
732
835
|
return e.append(...Array.from(t.childNodes)), e;
|
|
733
|
-
},
|
|
836
|
+
}, mo = (r, t) => {
|
|
734
837
|
const e = document.createRange();
|
|
735
838
|
return e.selectNodeContents(r), e.setEnd(t.startContainer, t.startOffset), e.toString().length === 0;
|
|
736
|
-
},
|
|
839
|
+
}, Co = (r, t) => {
|
|
737
840
|
const e = document.createRange();
|
|
738
841
|
e.selectNodeContents(r), e.setEnd(t.startContainer, t.startOffset);
|
|
739
842
|
const n = e.toString().length === 0, o = document.createRange();
|
|
740
843
|
o.selectNodeContents(r), o.setStart(t.endContainer, t.endOffset);
|
|
741
844
|
const s = o.toString().length === 0;
|
|
742
845
|
return n && s;
|
|
743
|
-
},
|
|
846
|
+
}, bo = (r) => {
|
|
744
847
|
if (typeof r != "object" || r === null)
|
|
745
848
|
return !1;
|
|
746
849
|
const e = Object.entries(r).find(([n]) => n === "items");
|
|
747
850
|
return e === void 0 ? !1 : Array.isArray(e[1]);
|
|
748
|
-
},
|
|
851
|
+
}, yo = (r) => typeof r == "object" && r !== null, vo = (r) => typeof r == "string" ? r : "", So = (r, t) => r === "unordered" || r === "ordered" || r === "checklist" ? r : t, wo = (r) => !!r, ko = (r, t) => typeof r == "number" ? r : t, Eo = (r, t) => {
|
|
749
852
|
const e = t.defaultStyle || "unordered";
|
|
750
853
|
if (!r || typeof r != "object")
|
|
751
854
|
return {
|
|
@@ -754,18 +857,18 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
754
857
|
checked: !1,
|
|
755
858
|
depth: 0
|
|
756
859
|
};
|
|
757
|
-
if (
|
|
860
|
+
if (bo(r)) {
|
|
758
861
|
const n = r.items[0], o = (n == null ? void 0 : n.content) || "", s = (n == null ? void 0 : n.checked) || !1;
|
|
759
|
-
return
|
|
862
|
+
return T({
|
|
760
863
|
text: o,
|
|
761
864
|
style: r.style || e,
|
|
762
865
|
checked: !!s,
|
|
763
866
|
depth: 0
|
|
764
867
|
}, r.start !== void 0 && r.start !== 1 ? { start: r.start } : {});
|
|
765
868
|
}
|
|
766
|
-
if (
|
|
767
|
-
const n =
|
|
768
|
-
return
|
|
869
|
+
if (yo(r)) {
|
|
870
|
+
const n = vo(r.text), o = So(r.style, e), s = wo(r.checked), i = ko(r.depth, 0), l = r.start, a = typeof l == "number" && l !== void 0 && l !== 1 ? l : void 0;
|
|
871
|
+
return T({
|
|
769
872
|
text: n,
|
|
770
873
|
style: o,
|
|
771
874
|
checked: s,
|
|
@@ -779,7 +882,7 @@ const J = 24, In = "outline-hidden py-[3px] mt-[2px] mb-px", Ln = "outline-hidde
|
|
|
779
882
|
depth: 0
|
|
780
883
|
};
|
|
781
884
|
};
|
|
782
|
-
class
|
|
885
|
+
class Oe {
|
|
783
886
|
constructor(t) {
|
|
784
887
|
this.blocks = t;
|
|
785
888
|
}
|
|
@@ -798,7 +901,7 @@ class Te {
|
|
|
798
901
|
if (t === 0)
|
|
799
902
|
return 0;
|
|
800
903
|
const e = this.blocks.getBlockByIndex(t - 1);
|
|
801
|
-
return !e || e.name !==
|
|
904
|
+
return !e || e.name !== L ? 0 : this.getBlockDepth(e) + 1;
|
|
802
905
|
}
|
|
803
906
|
/**
|
|
804
907
|
* Calculate the target depth for a list item dropped at the given index.
|
|
@@ -811,10 +914,10 @@ class Te {
|
|
|
811
914
|
const { blockIndex: e, currentDepth: n } = t, o = this.getMaxAllowedDepth(e);
|
|
812
915
|
if (n > o)
|
|
813
916
|
return o;
|
|
814
|
-
const s = this.blocks.getBlockByIndex(e + 1), i = s && s.name ===
|
|
917
|
+
const s = this.blocks.getBlockByIndex(e + 1), i = s && s.name === L, l = i ? this.getBlockDepth(s) : 0;
|
|
815
918
|
if (i && l > n && l <= o)
|
|
816
919
|
return l;
|
|
817
|
-
const c = e > 0 ? this.blocks.getBlockByIndex(e - 1) : void 0, d = c && c.name ===
|
|
920
|
+
const c = e > 0 ? this.blocks.getBlockByIndex(e - 1) : void 0, d = c && c.name === L, h = d ? this.getBlockDepth(c) : 0;
|
|
818
921
|
return d && !i && h > n && h <= o ? h : n;
|
|
819
922
|
}
|
|
820
923
|
/**
|
|
@@ -836,10 +939,10 @@ class Te {
|
|
|
836
939
|
if (!t)
|
|
837
940
|
return 0;
|
|
838
941
|
const e = (s = (o = t.holder) == null ? void 0 : o.querySelector('[role="listitem"]')) == null ? void 0 : s.getAttribute("style"), n = e == null ? void 0 : e.match(/margin-left:\s*(\d+)px/);
|
|
839
|
-
return n ? Math.round(parseInt(n[1], 10) /
|
|
942
|
+
return n ? Math.round(parseInt(n[1], 10) / Q) : 0;
|
|
840
943
|
}
|
|
841
944
|
}
|
|
842
|
-
const
|
|
945
|
+
const Ao = (r, t) => {
|
|
843
946
|
if (!r) return null;
|
|
844
947
|
if (t === "checklist") {
|
|
845
948
|
const n = r.querySelector("[contenteditable]");
|
|
@@ -847,15 +950,15 @@ const io = (r, t) => {
|
|
|
847
950
|
}
|
|
848
951
|
const e = r.querySelector('[data-blok-testid="list-content-container"]');
|
|
849
952
|
return e instanceof HTMLElement ? e : null;
|
|
850
|
-
},
|
|
953
|
+
}, xo = (r, t, e) => {
|
|
851
954
|
r && r.setAttribute("data-list-depth", String(e));
|
|
852
955
|
const n = r == null ? void 0 : r.querySelector('[role="listitem"]');
|
|
853
|
-
n instanceof HTMLElement && (n.style.marginLeft = e > 0 ? `${e *
|
|
854
|
-
},
|
|
956
|
+
n instanceof HTMLElement && (n.style.marginLeft = e > 0 ? `${e * Q}px` : ""), t.depth = e;
|
|
957
|
+
}, Ne = (r, t) => t.getBlockDepth(r), _e = (r, t) => t.getBlockStyle(r), To = (r, t) => t.getBulletCharacter(r), Jt = (r, t, e, n, o) => {
|
|
855
958
|
var i;
|
|
856
959
|
const s = r && (i = n.getBlockIndex(r)) != null ? i : n.getCurrentBlockIndex();
|
|
857
960
|
return s <= 0 ? 0 : o.getSiblingIndex(s, t, e);
|
|
858
|
-
},
|
|
961
|
+
}, Ro = (r, t, e, n, o, s) => {
|
|
859
962
|
var a, c;
|
|
860
963
|
if (r === 0)
|
|
861
964
|
return (a = n.start) != null ? a : 1;
|
|
@@ -866,10 +969,10 @@ const io = (r, t) => {
|
|
|
866
969
|
n.style
|
|
867
970
|
);
|
|
868
971
|
return l === null ? 1 : s.getBlockStartValue(l);
|
|
869
|
-
},
|
|
870
|
-
const l =
|
|
972
|
+
}, Qt = (r, t, e, n, o, s) => {
|
|
973
|
+
const l = Ro(r, t, n, e, o, s) + r;
|
|
871
974
|
return s.formatNumber(l, t);
|
|
872
|
-
},
|
|
975
|
+
}, Bo = (r, t, e, n) => n.findGroupStart(r, t, e), Me = (r, t, e, n) => {
|
|
873
976
|
if (!r)
|
|
874
977
|
return;
|
|
875
978
|
const o = r.holder, s = o == null ? void 0 : o.querySelector('[data-list-style="ordered"]');
|
|
@@ -881,9 +984,9 @@ const io = (r, t) => {
|
|
|
881
984
|
const l = t.getBlockIndex(r.id);
|
|
882
985
|
if (l == null)
|
|
883
986
|
return;
|
|
884
|
-
const a =
|
|
987
|
+
const a = Ne(r, e), c = _e(r, n) || "ordered", d = n.getSiblingIndex(l, a, c), u = n.getGroupStartValue(l, a, d, c) + d, p = n.formatNumber(u, a);
|
|
885
988
|
i.textContent = p;
|
|
886
|
-
},
|
|
989
|
+
}, Lo = (r, t, e, n, o, s, i, l) => {
|
|
887
990
|
const a = (c) => {
|
|
888
991
|
if (c >= t)
|
|
889
992
|
return;
|
|
@@ -892,28 +995,28 @@ const io = (r, t) => {
|
|
|
892
995
|
return;
|
|
893
996
|
}
|
|
894
997
|
const d = s.getBlockByIndex(c);
|
|
895
|
-
if (!d || d.name !==
|
|
998
|
+
if (!d || d.name !== L)
|
|
896
999
|
return;
|
|
897
|
-
const h =
|
|
1000
|
+
const h = Ne(d, i);
|
|
898
1001
|
if (h < n)
|
|
899
1002
|
return;
|
|
900
1003
|
if (h > n) {
|
|
901
1004
|
a(c + 1);
|
|
902
1005
|
return;
|
|
903
1006
|
}
|
|
904
|
-
|
|
1007
|
+
_e(d, l) === o && (Me(d, s, i, l), a(c + 1));
|
|
905
1008
|
};
|
|
906
1009
|
a(r);
|
|
907
|
-
},
|
|
1010
|
+
}, Io = (r, t, e) => {
|
|
908
1011
|
const n = r.getBlocksCount();
|
|
909
1012
|
Array.from({ length: n }, (o, s) => s).forEach((o) => {
|
|
910
1013
|
const s = r.getBlockByIndex(o);
|
|
911
|
-
if (!s || s.name !==
|
|
1014
|
+
if (!s || s.name !== L)
|
|
912
1015
|
return;
|
|
913
1016
|
const i = s.holder;
|
|
914
|
-
i != null && i.querySelector('[data-list-style="ordered"]') &&
|
|
1017
|
+
i != null && i.querySelector('[data-list-style="ordered"]') && Me(s, r, t, e);
|
|
915
1018
|
});
|
|
916
|
-
},
|
|
1019
|
+
}, ot = (r, t, e = "end") => {
|
|
917
1020
|
const n = (i) => {
|
|
918
1021
|
const l = t.holder;
|
|
919
1022
|
if (!l) return;
|
|
@@ -929,7 +1032,7 @@ const io = (r, t) => {
|
|
|
929
1032
|
e === "start" ? (d.setStart(a, 0), d.collapse(!0)) : (d.selectNodeContents(a), d.collapse(!1)), c.removeAllRanges(), c.addRange(d), i && r.caret.updateLastCaretAfterPosition();
|
|
930
1033
|
}, o = t.holder;
|
|
931
1034
|
(o == null ? void 0 : o.querySelector('[contenteditable="true"]')) instanceof HTMLElement ? n(!1) : requestAnimationFrame(() => n(!0));
|
|
932
|
-
},
|
|
1035
|
+
}, Do = async (r) => {
|
|
933
1036
|
var g;
|
|
934
1037
|
const { api: t, blockId: e, data: n, element: o, getContentElement: s } = r, i = window.getSelection();
|
|
935
1038
|
if (!i || !o) return;
|
|
@@ -937,25 +1040,25 @@ const io = (r, t) => {
|
|
|
937
1040
|
if (!l) return;
|
|
938
1041
|
const a = l.innerHTML.trim();
|
|
939
1042
|
if (a === "" || a === "<br>") {
|
|
940
|
-
await
|
|
1043
|
+
await Po(r);
|
|
941
1044
|
return;
|
|
942
1045
|
}
|
|
943
|
-
const c = i.getRangeAt(0), { beforeContent: d, afterContent: h } =
|
|
1046
|
+
const c = i.getRangeAt(0), { beforeContent: d, afterContent: h } = go(l, c), u = e && (g = t.blocks.getBlockIndex(e)) != null ? g : t.blocks.getCurrentBlockIndex();
|
|
944
1047
|
if (!e) {
|
|
945
1048
|
l.innerHTML = d, n.text = d;
|
|
946
|
-
const f = t.blocks.insert(
|
|
1049
|
+
const f = t.blocks.insert(L, {
|
|
947
1050
|
text: h,
|
|
948
1051
|
style: n.style,
|
|
949
1052
|
checked: !1,
|
|
950
1053
|
depth: n.depth
|
|
951
1054
|
}, void 0, u + 1, !0);
|
|
952
|
-
|
|
1055
|
+
ot(t, f, "start");
|
|
953
1056
|
return;
|
|
954
1057
|
}
|
|
955
1058
|
const p = t.blocks.splitBlock(
|
|
956
1059
|
e,
|
|
957
1060
|
{ text: d },
|
|
958
|
-
|
|
1061
|
+
L,
|
|
959
1062
|
{
|
|
960
1063
|
text: h,
|
|
961
1064
|
style: n.style,
|
|
@@ -964,63 +1067,63 @@ const io = (r, t) => {
|
|
|
964
1067
|
},
|
|
965
1068
|
u + 1
|
|
966
1069
|
);
|
|
967
|
-
n.text = d,
|
|
968
|
-
},
|
|
1070
|
+
n.text = d, ot(t, p, "start");
|
|
1071
|
+
}, Po = async (r) => {
|
|
969
1072
|
const { api: t, blockId: e, getDepth: n } = r;
|
|
970
1073
|
if (n() > 0) {
|
|
971
|
-
await
|
|
1074
|
+
await Ge(r);
|
|
972
1075
|
return;
|
|
973
1076
|
}
|
|
974
1077
|
if (e === void 0)
|
|
975
1078
|
return;
|
|
976
1079
|
const s = await t.blocks.convert(e, "paragraph", { text: "" });
|
|
977
|
-
|
|
978
|
-
},
|
|
1080
|
+
ot(t, s, "start");
|
|
1081
|
+
}, Ho = async (r, t) => {
|
|
979
1082
|
const { api: e, blockId: n, data: o, element: s, getContentElement: i, getDepth: l, syncContentFromDOM: a } = r, c = window.getSelection();
|
|
980
1083
|
if (!c || !s) return;
|
|
981
1084
|
const d = c.getRangeAt(0), h = i();
|
|
982
1085
|
if (!h) return;
|
|
983
1086
|
a();
|
|
984
1087
|
const u = o.text, p = l();
|
|
985
|
-
if (
|
|
1088
|
+
if (Co(h, d) && !c.isCollapsed) {
|
|
986
1089
|
t.preventDefault(), h.innerHTML = "", o.text = "";
|
|
987
1090
|
const m = document.createRange();
|
|
988
1091
|
m.setStart(h, 0), m.collapse(!0), c.removeAllRanges(), c.addRange(m);
|
|
989
1092
|
return;
|
|
990
1093
|
}
|
|
991
|
-
if (!
|
|
1094
|
+
if (!mo(h, d) || (t.preventDefault(), n === void 0))
|
|
992
1095
|
return;
|
|
993
1096
|
const f = await e.blocks.convert(n, "paragraph", { text: u });
|
|
994
1097
|
p > 0 && requestAnimationFrame(() => {
|
|
995
1098
|
const m = f.holder;
|
|
996
|
-
m && (m.style.marginLeft = `${p *
|
|
997
|
-
}),
|
|
998
|
-
},
|
|
1099
|
+
m && (m.style.marginLeft = `${p * Q}px`, m.setAttribute("data-blok-depth", String(p)));
|
|
1100
|
+
}), ot(e, f, "start");
|
|
1101
|
+
}, Oo = async (r, t) => {
|
|
999
1102
|
const { api: e, blockId: n, data: o, syncContentFromDOM: s, getDepth: i } = r, l = e.blocks.getCurrentBlockIndex();
|
|
1000
1103
|
if (l === 0) return;
|
|
1001
1104
|
const a = e.blocks.getBlockByIndex(l - 1);
|
|
1002
|
-
if (!a || a.name !==
|
|
1105
|
+
if (!a || a.name !== L) return;
|
|
1003
1106
|
const c = i(), d = t.getBlockDepth(a);
|
|
1004
1107
|
if (c > d) return;
|
|
1005
1108
|
s();
|
|
1006
1109
|
const h = c + 1;
|
|
1007
1110
|
o.depth = h;
|
|
1008
|
-
const u = await e.blocks.update(n || "",
|
|
1111
|
+
const u = await e.blocks.update(n || "", V(T({}, o), {
|
|
1009
1112
|
depth: h
|
|
1010
1113
|
}));
|
|
1011
|
-
|
|
1012
|
-
},
|
|
1114
|
+
ot(e, u);
|
|
1115
|
+
}, Ge = async (r) => {
|
|
1013
1116
|
const { api: t, blockId: e, data: n, syncContentFromDOM: o, getDepth: s } = r, i = s();
|
|
1014
1117
|
if (i === 0) return;
|
|
1015
1118
|
o();
|
|
1016
1119
|
const l = i - 1;
|
|
1017
1120
|
n.depth = l;
|
|
1018
|
-
const a = await t.blocks.update(e || "",
|
|
1121
|
+
const a = await t.blocks.update(e || "", V(T({}, n), {
|
|
1019
1122
|
depth: l
|
|
1020
1123
|
}));
|
|
1021
|
-
|
|
1022
|
-
},
|
|
1023
|
-
const { data: t, readOnly: e, placeholder: n, itemColor: o, itemSize: s, setupItemPlaceholder: i, onCheckboxChange: l, keydownHandler: a } = r, c =
|
|
1124
|
+
ot(t, a);
|
|
1125
|
+
}, No = (r) => {
|
|
1126
|
+
const { data: t, readOnly: e, placeholder: n, itemColor: o, itemSize: s, setupItemPlaceholder: i, onCheckboxChange: l, keydownHandler: a } = r, c = He({
|
|
1024
1127
|
data: t,
|
|
1025
1128
|
readOnly: e,
|
|
1026
1129
|
placeholder: n,
|
|
@@ -1035,14 +1138,14 @@ const io = (r, t) => {
|
|
|
1035
1138
|
});
|
|
1036
1139
|
}
|
|
1037
1140
|
return c.wrapper;
|
|
1038
|
-
},
|
|
1141
|
+
}, _o = (r) => {
|
|
1039
1142
|
const t = (e) => {
|
|
1040
1143
|
if (e <= 0) return "";
|
|
1041
1144
|
const n = e - 1;
|
|
1042
1145
|
return t(Math.floor(n / 26)) + String.fromCharCode(97 + n % 26);
|
|
1043
1146
|
};
|
|
1044
1147
|
return t(r);
|
|
1045
|
-
},
|
|
1148
|
+
}, Mo = (r) => {
|
|
1046
1149
|
const t = [
|
|
1047
1150
|
[1e3, "m"],
|
|
1048
1151
|
[900, "cm"],
|
|
@@ -1064,7 +1167,7 @@ const io = (r, t) => {
|
|
|
1064
1167
|
};
|
|
1065
1168
|
return e(r, 0);
|
|
1066
1169
|
};
|
|
1067
|
-
class
|
|
1170
|
+
class We {
|
|
1068
1171
|
constructor(t) {
|
|
1069
1172
|
this.blocks = t;
|
|
1070
1173
|
}
|
|
@@ -1123,7 +1226,7 @@ class De {
|
|
|
1123
1226
|
*/
|
|
1124
1227
|
formatNumber(t, e) {
|
|
1125
1228
|
const n = e % 3;
|
|
1126
|
-
return n === 1 ? `${
|
|
1229
|
+
return n === 1 ? `${_o(t)}.` : n === 2 ? `${Mo(t)}.` : `${t}.`;
|
|
1127
1230
|
}
|
|
1128
1231
|
/**
|
|
1129
1232
|
* Get the start value for a list group.
|
|
@@ -1158,7 +1261,7 @@ class De {
|
|
|
1158
1261
|
if (t < 0 || n <= 0)
|
|
1159
1262
|
return t + 1;
|
|
1160
1263
|
const s = this.blocks.getBlockByIndex(t);
|
|
1161
|
-
if (!s || s.name !==
|
|
1264
|
+
if (!s || s.name !== L)
|
|
1162
1265
|
return t + 1;
|
|
1163
1266
|
const i = this.getBlockDepth(s);
|
|
1164
1267
|
if (i < e)
|
|
@@ -1176,7 +1279,7 @@ class De {
|
|
|
1176
1279
|
if (!t)
|
|
1177
1280
|
return 0;
|
|
1178
1281
|
const e = (s = (o = t.holder) == null ? void 0 : o.querySelector('[role="listitem"]')) == null ? void 0 : s.getAttribute("style"), n = e == null ? void 0 : e.match(/margin-left:\s*(\d+)px/);
|
|
1179
|
-
return n ? Math.round(parseInt(n[1], 10) /
|
|
1282
|
+
return n ? Math.round(parseInt(n[1], 10) / Q) : 0;
|
|
1180
1283
|
}
|
|
1181
1284
|
/**
|
|
1182
1285
|
* Get the style of a block by reading from its DOM.
|
|
@@ -1201,7 +1304,7 @@ class De {
|
|
|
1201
1304
|
if (t < 0)
|
|
1202
1305
|
return 0;
|
|
1203
1306
|
const o = this.blocks.getBlockByIndex(t);
|
|
1204
|
-
if (!o || o.name !==
|
|
1307
|
+
if (!o || o.name !== L)
|
|
1205
1308
|
return 0;
|
|
1206
1309
|
const s = this.getBlockDepth(o);
|
|
1207
1310
|
return s < e ? 0 : s > e ? this.countPrecedingAtDepth(t - 1, e, n) : this.getBlockStyle(o) !== n ? 0 : 1 + this.countPrecedingAtDepth(t - 1, e, n);
|
|
@@ -1213,16 +1316,16 @@ class De {
|
|
|
1213
1316
|
if (t < 0)
|
|
1214
1317
|
return e;
|
|
1215
1318
|
const s = this.blocks.getBlockByIndex(t);
|
|
1216
|
-
if (!s || s.name !==
|
|
1319
|
+
if (!s || s.name !== L)
|
|
1217
1320
|
return e;
|
|
1218
1321
|
const i = this.getBlockDepth(s);
|
|
1219
1322
|
return i < n ? e : i > n ? this.findGroupStartRecursive(t - 1, e, n, o) : this.getBlockStyle(s) !== o ? e : this.findGroupStartRecursive(t - 1, t, n, o);
|
|
1220
1323
|
}
|
|
1221
1324
|
}
|
|
1222
|
-
const
|
|
1223
|
-
class
|
|
1325
|
+
const kt = { value: !1 };
|
|
1326
|
+
class Go {
|
|
1224
1327
|
constructor(t) {
|
|
1225
|
-
this.blocks = t, this.depthValidator = new
|
|
1328
|
+
this.blocks = t, this.depthValidator = new Oe(t), this.markerCalculator = new We(t);
|
|
1226
1329
|
}
|
|
1227
1330
|
/**
|
|
1228
1331
|
* Update this block's marker element with the correct index.
|
|
@@ -1263,7 +1366,7 @@ class vo {
|
|
|
1263
1366
|
const t = this.blocks.getBlocksCount();
|
|
1264
1367
|
for (const e of Array.from({ length: t }, (n, o) => o)) {
|
|
1265
1368
|
const n = this.blocks.getBlockByIndex(e);
|
|
1266
|
-
if (!n || n.name !==
|
|
1369
|
+
if (!n || n.name !== L)
|
|
1267
1370
|
continue;
|
|
1268
1371
|
const o = n.holder;
|
|
1269
1372
|
o != null && o.querySelector('[data-list-style="ordered"]') && this.updateBlockMarker(n);
|
|
@@ -1274,8 +1377,8 @@ class vo {
|
|
|
1274
1377
|
* Uses a static flag to deduplicate multiple calls in the same frame.
|
|
1275
1378
|
*/
|
|
1276
1379
|
scheduleUpdateAll() {
|
|
1277
|
-
|
|
1278
|
-
|
|
1380
|
+
kt.value || (kt.value = !0, requestAnimationFrame(() => {
|
|
1381
|
+
kt.value = !1, this.updateAllMarkers();
|
|
1279
1382
|
}));
|
|
1280
1383
|
}
|
|
1281
1384
|
/**
|
|
@@ -1295,7 +1398,7 @@ class vo {
|
|
|
1295
1398
|
if (l === n)
|
|
1296
1399
|
continue;
|
|
1297
1400
|
const a = this.blocks.getBlockByIndex(l);
|
|
1298
|
-
if (!a || a.name !==
|
|
1401
|
+
if (!a || a.name !== L)
|
|
1299
1402
|
return;
|
|
1300
1403
|
const c = this.depthValidator.getBlockDepth(a);
|
|
1301
1404
|
if (c < o)
|
|
@@ -1337,7 +1440,7 @@ class vo {
|
|
|
1337
1440
|
o.textContent = u;
|
|
1338
1441
|
}
|
|
1339
1442
|
}
|
|
1340
|
-
const
|
|
1443
|
+
const Wo = (r) => r instanceof HTMLElement, $o = /* @__PURE__ */ new Set([
|
|
1341
1444
|
"decimal",
|
|
1342
1445
|
"decimal-leading-zero",
|
|
1343
1446
|
"lower-roman",
|
|
@@ -1368,12 +1471,12 @@ const So = (r) => r instanceof HTMLElement, wo = /* @__PURE__ */ new Set([
|
|
|
1368
1471
|
"telugu",
|
|
1369
1472
|
"thai",
|
|
1370
1473
|
"tibetan"
|
|
1371
|
-
]),
|
|
1474
|
+
]), Fo = /* @__PURE__ */ new Set([
|
|
1372
1475
|
"disc",
|
|
1373
1476
|
"circle",
|
|
1374
1477
|
"square",
|
|
1375
1478
|
"none"
|
|
1376
|
-
]),
|
|
1479
|
+
]), qo = (r) => {
|
|
1377
1480
|
const t = r.getAttribute("data-list-style");
|
|
1378
1481
|
if (t === "ordered") return "ordered";
|
|
1379
1482
|
if (t === "unordered") return "unordered";
|
|
@@ -1382,25 +1485,25 @@ const So = (r) => r instanceof HTMLElement, wo = /* @__PURE__ */ new Set([
|
|
|
1382
1485
|
const n = e.match(/list-style-type\s*:\s*([^;]+)/);
|
|
1383
1486
|
if (!n) return null;
|
|
1384
1487
|
const o = n[1].trim().toLowerCase();
|
|
1385
|
-
return
|
|
1386
|
-
},
|
|
1488
|
+
return $o.has(o) ? "ordered" : Fo.has(o) ? "unordered" : null;
|
|
1489
|
+
}, zo = (r, t) => {
|
|
1387
1490
|
const e = r.parentElement;
|
|
1388
1491
|
if ((e == null ? void 0 : e.tagName) === "OL") return "ordered";
|
|
1389
1492
|
if ((e == null ? void 0 : e.tagName) === "UL")
|
|
1390
1493
|
return r.querySelector('input[type="checkbox"]') ? "checklist" : "unordered";
|
|
1391
|
-
const n =
|
|
1494
|
+
const n = qo(r);
|
|
1392
1495
|
return n || t;
|
|
1393
|
-
},
|
|
1496
|
+
}, Vo = (r) => {
|
|
1394
1497
|
const t = r.innerHTML || r.textContent || "", e = r.querySelector('input[type="checkbox"]'), n = e instanceof HTMLInputElement ? e.checked : !1;
|
|
1395
1498
|
return { text: t, checked: n };
|
|
1396
|
-
},
|
|
1499
|
+
}, Ko = (r) => {
|
|
1397
1500
|
const t = r.getAttribute("aria-level");
|
|
1398
1501
|
if (t) {
|
|
1399
1502
|
const e = parseInt(t, 10);
|
|
1400
1503
|
return Math.max(0, e - 1);
|
|
1401
1504
|
}
|
|
1402
1505
|
return 0;
|
|
1403
|
-
},
|
|
1506
|
+
}, Uo = () => ({
|
|
1404
1507
|
text: {
|
|
1405
1508
|
br: !0,
|
|
1406
1509
|
a: {
|
|
@@ -1411,7 +1514,7 @@ const So = (r) => r instanceof HTMLElement, wo = /* @__PURE__ */ new Set([
|
|
|
1411
1514
|
b: !0,
|
|
1412
1515
|
i: !0
|
|
1413
1516
|
}
|
|
1414
|
-
}),
|
|
1517
|
+
}), jo = () => ({
|
|
1415
1518
|
tags: [
|
|
1416
1519
|
{
|
|
1417
1520
|
li: {
|
|
@@ -1422,35 +1525,35 @@ const So = (r) => r instanceof HTMLElement, wo = /* @__PURE__ */ new Set([
|
|
|
1422
1525
|
}
|
|
1423
1526
|
}
|
|
1424
1527
|
]
|
|
1425
|
-
}),
|
|
1528
|
+
}), Yo = () => ({
|
|
1426
1529
|
export: (r) => r.text,
|
|
1427
1530
|
import: (r) => ({
|
|
1428
1531
|
text: r,
|
|
1429
1532
|
style: "unordered",
|
|
1430
1533
|
checked: !1
|
|
1431
1534
|
})
|
|
1432
|
-
}),
|
|
1535
|
+
}), te = [
|
|
1433
1536
|
{
|
|
1434
1537
|
name: "bulletedList",
|
|
1435
1538
|
titleKey: "bulletedList",
|
|
1436
1539
|
style: "unordered",
|
|
1437
|
-
icon:
|
|
1540
|
+
icon: we
|
|
1438
1541
|
},
|
|
1439
1542
|
{
|
|
1440
1543
|
name: "numberedList",
|
|
1441
1544
|
titleKey: "numberedList",
|
|
1442
1545
|
style: "ordered",
|
|
1443
|
-
icon:
|
|
1546
|
+
icon: ke
|
|
1444
1547
|
},
|
|
1445
1548
|
{
|
|
1446
1549
|
name: "todoList",
|
|
1447
1550
|
titleKey: "todoList",
|
|
1448
1551
|
style: "checklist",
|
|
1449
|
-
icon:
|
|
1552
|
+
icon: Ee
|
|
1450
1553
|
}
|
|
1451
|
-
],
|
|
1554
|
+
], Xo = () => [
|
|
1452
1555
|
{
|
|
1453
|
-
icon:
|
|
1556
|
+
icon: we,
|
|
1454
1557
|
title: "Bulleted list",
|
|
1455
1558
|
titleKey: "bulletedList",
|
|
1456
1559
|
data: { style: "unordered" },
|
|
@@ -1459,7 +1562,7 @@ const So = (r) => r instanceof HTMLElement, wo = /* @__PURE__ */ new Set([
|
|
|
1459
1562
|
shortcut: "-"
|
|
1460
1563
|
},
|
|
1461
1564
|
{
|
|
1462
|
-
icon:
|
|
1565
|
+
icon: ke,
|
|
1463
1566
|
title: "Numbered list",
|
|
1464
1567
|
titleKey: "numberedList",
|
|
1465
1568
|
data: { style: "ordered" },
|
|
@@ -1468,7 +1571,7 @@ const So = (r) => r instanceof HTMLElement, wo = /* @__PURE__ */ new Set([
|
|
|
1468
1571
|
shortcut: "1."
|
|
1469
1572
|
},
|
|
1470
1573
|
{
|
|
1471
|
-
icon:
|
|
1574
|
+
icon: Ee,
|
|
1472
1575
|
title: "To-do list",
|
|
1473
1576
|
titleKey: "todoList",
|
|
1474
1577
|
data: { style: "checklist" },
|
|
@@ -1477,22 +1580,22 @@ const So = (r) => r instanceof HTMLElement, wo = /* @__PURE__ */ new Set([
|
|
|
1477
1580
|
shortcut: "[]"
|
|
1478
1581
|
}
|
|
1479
1582
|
];
|
|
1480
|
-
class
|
|
1583
|
+
class Ei {
|
|
1481
1584
|
constructor({ data: t, config: e, api: n, readOnly: o, block: s }) {
|
|
1482
1585
|
this._element = null, this.handleBlockChanged = (i) => {
|
|
1483
1586
|
var l;
|
|
1484
1587
|
this.isBlockChangedEventPayload(i) && (i.event.type === "block-removed" || i.event.type === "block-added") && ((l = this.markerManager) == null || l.scheduleUpdateAll());
|
|
1485
|
-
}, this.api = n, this.readOnly = o, this._settings = e || {}, this._data = this.normalizeData(t), this.depthValidator = new
|
|
1588
|
+
}, this.api = n, this.readOnly = o, this._settings = e || {}, this._data = this.normalizeData(t), this.depthValidator = new Oe(n.blocks), this.markerCalculator = new We(n.blocks), this.markerManager = this._data.style === "ordered" ? new Go(n.blocks) : null, s && (this.blockId = s.id), this._data.style === "ordered" && this.api.events.on("block changed", this.handleBlockChanged);
|
|
1486
1589
|
}
|
|
1487
1590
|
isBlockChangedEventPayload(t) {
|
|
1488
1591
|
return typeof t == "object" && t !== null && "event" in t && typeof t.event == "object" && t.event !== null && "type" in t.event && typeof t.event.type == "string";
|
|
1489
1592
|
}
|
|
1490
1593
|
normalizeData(t) {
|
|
1491
|
-
return
|
|
1594
|
+
return Eo(t, this._settings);
|
|
1492
1595
|
}
|
|
1493
1596
|
get availableStyles() {
|
|
1494
1597
|
const t = this._settings.styles;
|
|
1495
|
-
return !t || t.length === 0 ?
|
|
1598
|
+
return !t || t.length === 0 ? te : te.filter((e) => t.includes(e.style));
|
|
1496
1599
|
}
|
|
1497
1600
|
get itemColor() {
|
|
1498
1601
|
return this._settings.itemColor;
|
|
@@ -1501,13 +1604,13 @@ class Js {
|
|
|
1501
1604
|
return this._settings.itemSize;
|
|
1502
1605
|
}
|
|
1503
1606
|
get placeholder() {
|
|
1504
|
-
return this.api.i18n.t(
|
|
1607
|
+
return this.api.i18n.t(Qn);
|
|
1505
1608
|
}
|
|
1506
1609
|
setupItemPlaceholder(t) {
|
|
1507
|
-
this.readOnly ||
|
|
1610
|
+
this.readOnly || wt(t, this.placeholder);
|
|
1508
1611
|
}
|
|
1509
1612
|
render() {
|
|
1510
|
-
return this._element =
|
|
1613
|
+
return this._element = No({
|
|
1511
1614
|
data: this._data,
|
|
1512
1615
|
readOnly: this.readOnly,
|
|
1513
1616
|
placeholder: this.placeholder,
|
|
@@ -1537,7 +1640,7 @@ class Js {
|
|
|
1537
1640
|
e !== n && this.adjustDepthTo(n);
|
|
1538
1641
|
}
|
|
1539
1642
|
adjustDepthTo(t) {
|
|
1540
|
-
|
|
1643
|
+
xo(this._element, this._data, t);
|
|
1541
1644
|
}
|
|
1542
1645
|
removed() {
|
|
1543
1646
|
this._data.style === "ordered" && (this.api.events.off("block changed", this.handleBlockChanged), requestAnimationFrame(() => {
|
|
@@ -1545,30 +1648,30 @@ class Js {
|
|
|
1545
1648
|
}));
|
|
1546
1649
|
}
|
|
1547
1650
|
updateAllOrderedListMarkers() {
|
|
1548
|
-
|
|
1651
|
+
Io(this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1549
1652
|
}
|
|
1550
1653
|
updateMarker() {
|
|
1551
1654
|
var s;
|
|
1552
1655
|
const t = (s = this._element) == null ? void 0 : s.querySelector("[data-list-marker]");
|
|
1553
1656
|
if (!t)
|
|
1554
1657
|
return;
|
|
1555
|
-
const e = this.getDepth(), n =
|
|
1658
|
+
const e = this.getDepth(), n = Jt(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), o = Qt(n, e, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1556
1659
|
t.textContent = o;
|
|
1557
1660
|
}
|
|
1558
1661
|
updateSiblingListMarkers() {
|
|
1559
1662
|
var i;
|
|
1560
|
-
const t = this.blockId ? (i = this.api.blocks.getBlockIndex(this.blockId)) != null ? i : this.api.blocks.getCurrentBlockIndex() : this.api.blocks.getCurrentBlockIndex(), e = this.getDepth(), n = this._data.style, o = this.api.blocks.getBlocksCount(), s =
|
|
1561
|
-
|
|
1663
|
+
const t = this.blockId ? (i = this.api.blocks.getBlockIndex(this.blockId)) != null ? i : this.api.blocks.getCurrentBlockIndex() : this.api.blocks.getCurrentBlockIndex(), e = this.getDepth(), n = this._data.style, o = this.api.blocks.getBlocksCount(), s = Bo(t, e, n, this.markerCalculator);
|
|
1664
|
+
Lo(s, o, t, e, n, this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1562
1665
|
}
|
|
1563
1666
|
updateMarkerForDepth(t, e) {
|
|
1564
1667
|
var o;
|
|
1565
1668
|
const n = (o = this._element) == null ? void 0 : o.querySelector('[aria-hidden="true"]');
|
|
1566
1669
|
if (n instanceof HTMLElement)
|
|
1567
1670
|
if (e === "ordered") {
|
|
1568
|
-
const s =
|
|
1671
|
+
const s = Jt(this.blockId, t, this._data.style, this.api.blocks, this.markerCalculator), i = Qt(s, t, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1569
1672
|
n.textContent = i;
|
|
1570
1673
|
} else {
|
|
1571
|
-
const s =
|
|
1674
|
+
const s = To(t, this.markerCalculator);
|
|
1572
1675
|
n.textContent = s;
|
|
1573
1676
|
}
|
|
1574
1677
|
}
|
|
@@ -1608,7 +1711,7 @@ class Js {
|
|
|
1608
1711
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1609
1712
|
getDepth: this.getDepth.bind(this)
|
|
1610
1713
|
};
|
|
1611
|
-
await
|
|
1714
|
+
await Do(t);
|
|
1612
1715
|
}
|
|
1613
1716
|
async handleBackspace(t) {
|
|
1614
1717
|
const e = {
|
|
@@ -1620,7 +1723,7 @@ class Js {
|
|
|
1620
1723
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1621
1724
|
getDepth: this.getDepth.bind(this)
|
|
1622
1725
|
};
|
|
1623
|
-
await
|
|
1726
|
+
await Ho(e, t);
|
|
1624
1727
|
}
|
|
1625
1728
|
async handleIndent() {
|
|
1626
1729
|
const t = {
|
|
@@ -1632,7 +1735,7 @@ class Js {
|
|
|
1632
1735
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1633
1736
|
getDepth: this.getDepth.bind(this)
|
|
1634
1737
|
};
|
|
1635
|
-
await
|
|
1738
|
+
await Oo(t, this.depthValidator);
|
|
1636
1739
|
}
|
|
1637
1740
|
async handleOutdent() {
|
|
1638
1741
|
const t = {
|
|
@@ -1644,7 +1747,7 @@ class Js {
|
|
|
1644
1747
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1645
1748
|
getDepth: this.getDepth.bind(this)
|
|
1646
1749
|
};
|
|
1647
|
-
await
|
|
1750
|
+
await Ge(t);
|
|
1648
1751
|
}
|
|
1649
1752
|
syncContentFromDOM() {
|
|
1650
1753
|
var n;
|
|
@@ -1655,10 +1758,10 @@ class Js {
|
|
|
1655
1758
|
e instanceof HTMLInputElement && (this._data.checked = e.checked);
|
|
1656
1759
|
}
|
|
1657
1760
|
getContentElement() {
|
|
1658
|
-
return
|
|
1761
|
+
return Ao(this._element, this._data.style);
|
|
1659
1762
|
}
|
|
1660
1763
|
renderSettings() {
|
|
1661
|
-
return
|
|
1764
|
+
return co(this.availableStyles, this._data.style, this.api.i18n.t, (t) => this.setStyle(t));
|
|
1662
1765
|
}
|
|
1663
1766
|
setStyle(t) {
|
|
1664
1767
|
const e = this._data.style;
|
|
@@ -1667,7 +1770,7 @@ class Js {
|
|
|
1667
1770
|
});
|
|
1668
1771
|
}
|
|
1669
1772
|
rerender() {
|
|
1670
|
-
const t =
|
|
1773
|
+
const t = io({
|
|
1671
1774
|
data: this._data,
|
|
1672
1775
|
readOnly: this.readOnly,
|
|
1673
1776
|
placeholder: this.placeholder,
|
|
@@ -1686,10 +1789,10 @@ class Js {
|
|
|
1686
1789
|
return typeof t.text == "string";
|
|
1687
1790
|
}
|
|
1688
1791
|
save() {
|
|
1689
|
-
return
|
|
1792
|
+
return ro(this._data, this._element, this.getContentElement.bind(this));
|
|
1690
1793
|
}
|
|
1691
1794
|
setData(t) {
|
|
1692
|
-
const e =
|
|
1795
|
+
const e = lo(
|
|
1693
1796
|
this._data,
|
|
1694
1797
|
t,
|
|
1695
1798
|
this._element,
|
|
@@ -1703,35 +1806,35 @@ class Js {
|
|
|
1703
1806
|
return this._data = e.newData, e.inPlace;
|
|
1704
1807
|
}
|
|
1705
1808
|
merge(t) {
|
|
1706
|
-
|
|
1809
|
+
ao(
|
|
1707
1810
|
{
|
|
1708
1811
|
data: this._data,
|
|
1709
1812
|
element: this._element,
|
|
1710
1813
|
getContentElement: this.getContentElement.bind(this),
|
|
1711
|
-
parseHTML:
|
|
1814
|
+
parseHTML: fo
|
|
1712
1815
|
},
|
|
1713
1816
|
t
|
|
1714
1817
|
);
|
|
1715
1818
|
}
|
|
1716
1819
|
static get conversionConfig() {
|
|
1717
|
-
return
|
|
1820
|
+
return Yo();
|
|
1718
1821
|
}
|
|
1719
1822
|
static get sanitize() {
|
|
1720
|
-
return
|
|
1823
|
+
return Uo();
|
|
1721
1824
|
}
|
|
1722
1825
|
static get pasteConfig() {
|
|
1723
|
-
return
|
|
1826
|
+
return jo();
|
|
1724
1827
|
}
|
|
1725
1828
|
onPaste(t) {
|
|
1726
1829
|
const e = t.detail;
|
|
1727
1830
|
if (!("data" in e)) return;
|
|
1728
1831
|
const n = e.data;
|
|
1729
|
-
if (!
|
|
1832
|
+
if (!Wo(n))
|
|
1730
1833
|
return;
|
|
1731
|
-
const { text: o, checked: s } =
|
|
1834
|
+
const { text: o, checked: s } = Vo(n), i = Ko(n);
|
|
1732
1835
|
this._data = {
|
|
1733
1836
|
text: o,
|
|
1734
|
-
style:
|
|
1837
|
+
style: zo(n, this._data.style),
|
|
1735
1838
|
checked: s,
|
|
1736
1839
|
depth: i
|
|
1737
1840
|
}, this.rerender();
|
|
@@ -1740,19 +1843,19 @@ class Js {
|
|
|
1740
1843
|
return !0;
|
|
1741
1844
|
}
|
|
1742
1845
|
getContentOffset(t) {
|
|
1743
|
-
return
|
|
1846
|
+
return po(t);
|
|
1744
1847
|
}
|
|
1745
1848
|
static get toolbox() {
|
|
1746
|
-
return
|
|
1849
|
+
return Xo();
|
|
1747
1850
|
}
|
|
1748
1851
|
}
|
|
1749
|
-
const
|
|
1852
|
+
const Zo = "data-blok-table-add-row", Jo = "data-blok-table-add-col", ee = 150, Qo = 5, ne = 40, oe = [
|
|
1750
1853
|
"flex",
|
|
1751
1854
|
"items-center",
|
|
1752
1855
|
"justify-center",
|
|
1753
1856
|
"transition-opacity",
|
|
1754
1857
|
"duration-150"
|
|
1755
|
-
],
|
|
1858
|
+
], se = [
|
|
1756
1859
|
"flex",
|
|
1757
1860
|
"items-center",
|
|
1758
1861
|
"justify-center",
|
|
@@ -1760,8 +1863,8 @@ const Do = "data-blok-table-add-row", Po = "data-blok-table-add-col", Xt = 150,
|
|
|
1760
1863
|
"border-gray-300",
|
|
1761
1864
|
"rounded-full",
|
|
1762
1865
|
"group-hover/add:bg-gray-50"
|
|
1763
|
-
],
|
|
1764
|
-
class
|
|
1866
|
+
], ie = "12";
|
|
1867
|
+
class ts {
|
|
1765
1868
|
constructor(t) {
|
|
1766
1869
|
this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.interactive = !0, this.dragState = null, this.wrapper = t.wrapper, this.grid = t.grid, this.i18n = t.i18n, this.boundAddRowClick = t.onAddRow, this.boundAddColClick = t.onAddColumn, this.onDragStart = t.onDragStart, this.onDragAddRow = t.onDragAddRow, this.onDragRemoveRow = t.onDragRemoveRow, this.onDragAddCol = t.onDragAddCol, this.onDragRemoveCol = t.onDragRemoveCol, this.onDragEnd = t.onDragEnd, this.getNewColumnWidth = t.getNewColumnWidth, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.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), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
|
|
1767
1870
|
}
|
|
@@ -1834,7 +1937,7 @@ class No {
|
|
|
1834
1937
|
e === "row" ? this.onDragAddRow() : this.onDragAddCol(), this.dragState.addedCount++;
|
|
1835
1938
|
for (; this.dragState.addedCount > l; )
|
|
1836
1939
|
e === "row" ? this.onDragRemoveRow() : this.onDragRemoveCol(), this.dragState.addedCount--;
|
|
1837
|
-
Math.abs(i) >
|
|
1940
|
+
Math.abs(i) > Qo && !this.dragState.didDrag && (this.dragState.didDrag = !0, document.body.style.cursor = e === "row" ? "row-resize" : "col-resize", pn(), this.onDragStart());
|
|
1838
1941
|
}
|
|
1839
1942
|
handlePointerUp(t) {
|
|
1840
1943
|
if (!this.dragState)
|
|
@@ -1871,7 +1974,7 @@ class No {
|
|
|
1871
1974
|
}
|
|
1872
1975
|
handleMouseMove(t) {
|
|
1873
1976
|
const e = this.grid.getBoundingClientRect(), n = this.grid.parentElement, s = n !== null && n !== this.wrapper ? Math.min(e.right, n.getBoundingClientRect().right) : e.right, i = Math.abs(t.clientY - e.bottom), l = Math.abs(t.clientX - s);
|
|
1874
|
-
i <=
|
|
1977
|
+
i <= ne ? this.showRow() : this.scheduleHideRow(), l <= ne ? this.showCol() : this.scheduleHideCol();
|
|
1875
1978
|
}
|
|
1876
1979
|
handleMouseLeave() {
|
|
1877
1980
|
this.scheduleHideRow(), this.scheduleHideCol();
|
|
@@ -1886,13 +1989,13 @@ class No {
|
|
|
1886
1989
|
var t;
|
|
1887
1990
|
!this.rowVisible || this.rowHideTimeout !== null || ((t = this.dragState) == null ? void 0 : t.axis) === "row" || (this.rowHideTimeout = setTimeout(() => {
|
|
1888
1991
|
this.addRowBtn.style.opacity = "0", this.addRowBtn.style.pointerEvents = "none", this.rowVisible = !1, this.rowHideTimeout = null;
|
|
1889
|
-
},
|
|
1992
|
+
}, ee));
|
|
1890
1993
|
}
|
|
1891
1994
|
scheduleHideCol() {
|
|
1892
1995
|
var t;
|
|
1893
1996
|
!this.colVisible || this.colHideTimeout !== null || ((t = this.dragState) == null ? void 0 : t.axis) === "col" || (this.colHideTimeout = setTimeout(() => {
|
|
1894
1997
|
this.addColBtn.style.opacity = "0", this.addColBtn.style.pointerEvents = "none", this.colVisible = !1, this.colHideTimeout = null;
|
|
1895
|
-
},
|
|
1998
|
+
}, ee));
|
|
1896
1999
|
}
|
|
1897
2000
|
clearRowTimeout() {
|
|
1898
2001
|
this.rowHideTimeout !== null && (clearTimeout(this.rowHideTimeout), this.rowHideTimeout = null);
|
|
@@ -1902,31 +2005,31 @@ class No {
|
|
|
1902
2005
|
}
|
|
1903
2006
|
createAddRowButton() {
|
|
1904
2007
|
const t = document.createElement("div");
|
|
1905
|
-
t.className = w(
|
|
2008
|
+
t.className = w(oe, "group/add", "items-start", "cursor-row-resize"), t.setAttribute(Zo, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.left = "0", t.style.bottom = "-36px", t.style.zIndex = "1", t.style.height = "32px";
|
|
1906
2009
|
const e = document.createElement("div");
|
|
1907
|
-
return e.className = w(
|
|
2010
|
+
return e.className = w(se), e.style.width = "100%", e.style.height = "16px", this.appendIcon(e), t.appendChild(e), $t(t, Ft([
|
|
1908
2011
|
this.i18n.t("tools.table.clickToAddRow"),
|
|
1909
2012
|
this.i18n.t("tools.table.dragToAddRemoveRows")
|
|
1910
2013
|
]), { placement: "bottom", marginTop: -16 }), t;
|
|
1911
2014
|
}
|
|
1912
2015
|
createAddColumnButton() {
|
|
1913
2016
|
const t = document.createElement("div");
|
|
1914
|
-
t.className = w(
|
|
2017
|
+
t.className = w(oe, "group/add", "justify-start", "cursor-col-resize"), t.setAttribute(Jo, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.right = "-36px", t.style.top = "0px", t.style.bottom = "0px", t.style.width = "32px";
|
|
1915
2018
|
const e = document.createElement("div");
|
|
1916
|
-
return e.className = w(
|
|
2019
|
+
return e.className = w(se), e.style.width = "16px", e.style.height = "100%", this.appendIcon(e), t.appendChild(e), $t(t, Ft([
|
|
1917
2020
|
this.i18n.t("tools.table.clickToAddColumn"),
|
|
1918
2021
|
this.i18n.t("tools.table.dragToAddRemoveColumns")
|
|
1919
2022
|
]), { placement: "bottom" }), t;
|
|
1920
2023
|
}
|
|
1921
2024
|
appendIcon(t) {
|
|
1922
|
-
t.insertAdjacentHTML("beforeend",
|
|
2025
|
+
t.insertAdjacentHTML("beforeend", gn);
|
|
1923
2026
|
const e = t.querySelector("svg");
|
|
1924
|
-
e && (e.setAttribute("width",
|
|
2027
|
+
e && (e.setAttribute("width", ie), e.setAttribute("height", ie), e.setAttribute("viewBox", "0 0 24 24"), e.classList.add("text-gray-500", "pointer-events-none"));
|
|
1925
2028
|
}
|
|
1926
2029
|
}
|
|
1927
|
-
const
|
|
2030
|
+
const y = "data-blok-table-row", b = "data-blok-table-cell", q = 1, pt = `${q}px solid #d1d5db`, es = [
|
|
1928
2031
|
"flex"
|
|
1929
|
-
],
|
|
2032
|
+
], ns = [
|
|
1930
2033
|
"py-1",
|
|
1931
2034
|
"px-2",
|
|
1932
2035
|
"min-h-[2em]",
|
|
@@ -1934,11 +2037,11 @@ const b = "data-blok-table-row", y = "data-blok-table-cell", $ = 1, ht = `${$}px
|
|
|
1934
2037
|
"leading-normal",
|
|
1935
2038
|
"text-sm",
|
|
1936
2039
|
"cursor-text"
|
|
1937
|
-
],
|
|
2040
|
+
], os = (r) => {
|
|
1938
2041
|
const t = Math.round(100 / r * 100) / 100;
|
|
1939
2042
|
return Array.from({ length: r }, () => t);
|
|
1940
2043
|
};
|
|
1941
|
-
class
|
|
2044
|
+
class ss {
|
|
1942
2045
|
constructor(t) {
|
|
1943
2046
|
this.readOnly = t.readOnly;
|
|
1944
2047
|
}
|
|
@@ -1947,8 +2050,8 @@ class Go {
|
|
|
1947
2050
|
*/
|
|
1948
2051
|
createGrid(t, e, n) {
|
|
1949
2052
|
const o = document.createElement("div");
|
|
1950
|
-
o.style.borderTop =
|
|
1951
|
-
const s = n != null ? n :
|
|
2053
|
+
o.style.borderTop = pt, o.style.borderLeft = pt;
|
|
2054
|
+
const s = n != null ? n : os(e);
|
|
1952
2055
|
return Array.from({ length: t }).forEach(() => {
|
|
1953
2056
|
o.appendChild(this.createRow(e, s));
|
|
1954
2057
|
}), o;
|
|
@@ -1964,14 +2067,14 @@ class Go {
|
|
|
1964
2067
|
* Otherwise appends at the end.
|
|
1965
2068
|
*/
|
|
1966
2069
|
addRow(t, e) {
|
|
1967
|
-
const n = this.getColumnCount(t), o = this.getRawCellWidths(t), s = this.createRow(n, o), i = t.querySelectorAll(`[${
|
|
2070
|
+
const n = this.getColumnCount(t), o = this.getRawCellWidths(t), s = this.createRow(n, o), i = t.querySelectorAll(`[${y}]`);
|
|
1968
2071
|
return e !== void 0 && e < i.length ? t.insertBefore(s, i[e]) : t.appendChild(s), s;
|
|
1969
2072
|
}
|
|
1970
2073
|
/**
|
|
1971
2074
|
* Delete a row at index
|
|
1972
2075
|
*/
|
|
1973
2076
|
deleteRow(t, e) {
|
|
1974
|
-
const n = t.querySelectorAll(`[${
|
|
2077
|
+
const n = t.querySelectorAll(`[${y}]`);
|
|
1975
2078
|
e < n.length && n[e].remove();
|
|
1976
2079
|
}
|
|
1977
2080
|
/**
|
|
@@ -1983,7 +2086,7 @@ class Go {
|
|
|
1983
2086
|
* existing columns from shrinking when the table is in percent mode.
|
|
1984
2087
|
*/
|
|
1985
2088
|
addColumn(t, e, n, o) {
|
|
1986
|
-
const s = t.querySelectorAll(`[${
|
|
2089
|
+
const s = t.querySelectorAll(`[${y}]`), i = this.getColumnCount(t), l = n !== void 0 && n.length === i, a = l || this.detectWidthUnit(t) === "px";
|
|
1987
2090
|
return l && this.convertToPixelWidths(s, n), a ? (this.addColumnPx(s, i, e, o), !0) : (this.addColumnPercent(s, i, e), !0);
|
|
1988
2091
|
}
|
|
1989
2092
|
/**
|
|
@@ -1991,7 +2094,7 @@ class Go {
|
|
|
1991
2094
|
*/
|
|
1992
2095
|
convertToPixelWidths(t, e) {
|
|
1993
2096
|
t.forEach((n) => {
|
|
1994
|
-
n.querySelectorAll(`[${
|
|
2097
|
+
n.querySelectorAll(`[${b}]`).forEach((s, i) => {
|
|
1995
2098
|
if (i < e.length) {
|
|
1996
2099
|
const l = s;
|
|
1997
2100
|
l.style.width = `${e[i]}px`;
|
|
@@ -2005,7 +2108,7 @@ class Go {
|
|
|
2005
2108
|
addColumnPx(t, e, n, o) {
|
|
2006
2109
|
const s = o != null ? o : this.computeHalfAvgPxWidth(t, e);
|
|
2007
2110
|
t.forEach((i) => {
|
|
2008
|
-
const l = i.querySelectorAll(`[${
|
|
2111
|
+
const l = i.querySelectorAll(`[${b}]`), a = n === void 0 || n >= l.length, c = this.createCell(`${s}px`);
|
|
2009
2112
|
if (!a) {
|
|
2010
2113
|
i.insertBefore(c, l[n]);
|
|
2011
2114
|
return;
|
|
@@ -2014,7 +2117,7 @@ class Go {
|
|
|
2014
2117
|
});
|
|
2015
2118
|
}
|
|
2016
2119
|
computeHalfAvgPxWidth(t, e) {
|
|
2017
|
-
const n = t[0], o = n == null ? void 0 : n.querySelectorAll(`[${
|
|
2120
|
+
const n = t[0], o = n == null ? void 0 : n.querySelectorAll(`[${b}]`), s = Array.from(o != null ? o : []).reduce(
|
|
2018
2121
|
(i, l) => i + (parseFloat(l.style.width) || 0),
|
|
2019
2122
|
0
|
|
2020
2123
|
);
|
|
@@ -2026,11 +2129,11 @@ class Go {
|
|
|
2026
2129
|
addColumnPercent(t, e, n) {
|
|
2027
2130
|
const s = 1 - 0.5 / e;
|
|
2028
2131
|
t.forEach((i) => {
|
|
2029
|
-
i.querySelectorAll(`[${
|
|
2132
|
+
i.querySelectorAll(`[${b}]`).forEach((u) => {
|
|
2030
2133
|
const p = u, g = parseFloat(p.style.width) || 100 / e, f = Math.round(g * s * 100) / 100;
|
|
2031
2134
|
p.style.width = `${f}%`;
|
|
2032
2135
|
});
|
|
2033
|
-
const a = Math.round(100 / e / 2 * 100) / 100, c = i.querySelectorAll(`[${
|
|
2136
|
+
const a = Math.round(100 / e / 2 * 100) / 100, c = i.querySelectorAll(`[${b}]`), d = n === void 0 || n >= c.length, h = this.createCell(`${a}%`);
|
|
2034
2137
|
if (!d) {
|
|
2035
2138
|
i.insertBefore(h, c[n]);
|
|
2036
2139
|
return;
|
|
@@ -2042,8 +2145,8 @@ class Go {
|
|
|
2042
2145
|
* Delete a column at index
|
|
2043
2146
|
*/
|
|
2044
2147
|
deleteColumn(t, e) {
|
|
2045
|
-
t.querySelectorAll(`[${
|
|
2046
|
-
const s = o.querySelectorAll(`[${
|
|
2148
|
+
t.querySelectorAll(`[${y}]`).forEach((o) => {
|
|
2149
|
+
const s = o.querySelectorAll(`[${b}]`);
|
|
2047
2150
|
e >= s.length || s[e].remove();
|
|
2048
2151
|
});
|
|
2049
2152
|
}
|
|
@@ -2054,12 +2157,12 @@ class Go {
|
|
|
2054
2157
|
moveRow(t, e, n) {
|
|
2055
2158
|
if (e === n)
|
|
2056
2159
|
return;
|
|
2057
|
-
const o = Array.from(t.querySelectorAll(`[${
|
|
2160
|
+
const o = Array.from(t.querySelectorAll(`[${y}]`));
|
|
2058
2161
|
if (e >= o.length || n >= o.length)
|
|
2059
2162
|
return;
|
|
2060
2163
|
const s = o[e];
|
|
2061
2164
|
s.remove();
|
|
2062
|
-
const i = Array.from(t.querySelectorAll(`[${
|
|
2165
|
+
const i = Array.from(t.querySelectorAll(`[${y}]`));
|
|
2063
2166
|
n >= i.length ? t.appendChild(s) : t.insertBefore(s, i[n]);
|
|
2064
2167
|
}
|
|
2065
2168
|
/**
|
|
@@ -2069,13 +2172,13 @@ class Go {
|
|
|
2069
2172
|
moveColumn(t, e, n) {
|
|
2070
2173
|
if (e === n)
|
|
2071
2174
|
return;
|
|
2072
|
-
t.querySelectorAll(`[${
|
|
2073
|
-
const i = Array.from(s.querySelectorAll(`[${
|
|
2175
|
+
t.querySelectorAll(`[${y}]`).forEach((s) => {
|
|
2176
|
+
const i = Array.from(s.querySelectorAll(`[${b}]`));
|
|
2074
2177
|
if (e >= i.length || n >= i.length)
|
|
2075
2178
|
return;
|
|
2076
2179
|
const l = i[e];
|
|
2077
2180
|
l.remove();
|
|
2078
|
-
const a = Array.from(s.querySelectorAll(`[${
|
|
2181
|
+
const a = Array.from(s.querySelectorAll(`[${b}]`));
|
|
2079
2182
|
n >= a.length ? s.appendChild(l) : s.insertBefore(l, a[n]);
|
|
2080
2183
|
});
|
|
2081
2184
|
}
|
|
@@ -2083,33 +2186,33 @@ class Go {
|
|
|
2083
2186
|
* Get number of rows
|
|
2084
2187
|
*/
|
|
2085
2188
|
getRowCount(t) {
|
|
2086
|
-
return t.querySelectorAll(`[${
|
|
2189
|
+
return t.querySelectorAll(`[${y}]`).length;
|
|
2087
2190
|
}
|
|
2088
2191
|
/**
|
|
2089
2192
|
* Get number of columns (from first row)
|
|
2090
2193
|
*/
|
|
2091
2194
|
getColumnCount(t) {
|
|
2092
|
-
const e = t.querySelector(`[${
|
|
2093
|
-
return e ? e.querySelectorAll(`[${
|
|
2195
|
+
const e = t.querySelector(`[${y}]`);
|
|
2196
|
+
return e ? e.querySelectorAll(`[${b}]`).length : 0;
|
|
2094
2197
|
}
|
|
2095
2198
|
/**
|
|
2096
2199
|
* Get a specific cell element
|
|
2097
2200
|
*/
|
|
2098
2201
|
getCell(t, e, n) {
|
|
2099
|
-
const o = t.querySelectorAll(`[${
|
|
2202
|
+
const o = t.querySelectorAll(`[${y}]`);
|
|
2100
2203
|
if (e >= o.length)
|
|
2101
2204
|
return null;
|
|
2102
|
-
const s = o[e].querySelectorAll(`[${
|
|
2205
|
+
const s = o[e].querySelectorAll(`[${b}]`);
|
|
2103
2206
|
return n >= s.length ? null : s[n];
|
|
2104
2207
|
}
|
|
2105
2208
|
/**
|
|
2106
2209
|
* Read column widths from the DOM
|
|
2107
2210
|
*/
|
|
2108
2211
|
getColWidths(t) {
|
|
2109
|
-
const e = t.querySelector(`[${
|
|
2212
|
+
const e = t.querySelector(`[${y}]`);
|
|
2110
2213
|
if (!e)
|
|
2111
2214
|
return [];
|
|
2112
|
-
const n = e.querySelectorAll(`[${
|
|
2215
|
+
const n = e.querySelectorAll(`[${b}]`), o = [];
|
|
2113
2216
|
return n.forEach((s) => {
|
|
2114
2217
|
const i = parseFloat(s.style.width);
|
|
2115
2218
|
o.push(isNaN(i) ? 0 : i);
|
|
@@ -2119,20 +2222,20 @@ class Go {
|
|
|
2119
2222
|
* Detect whether cells use 'px' or '%' widths
|
|
2120
2223
|
*/
|
|
2121
2224
|
detectWidthUnit(t) {
|
|
2122
|
-
const e = t.querySelector(`[${
|
|
2225
|
+
const e = t.querySelector(`[${y}]`);
|
|
2123
2226
|
if (!e)
|
|
2124
2227
|
return "%";
|
|
2125
|
-
const n = e.querySelector(`[${
|
|
2228
|
+
const n = e.querySelector(`[${b}]`);
|
|
2126
2229
|
return n && n.style.width.endsWith("px") ? "px" : "%";
|
|
2127
2230
|
}
|
|
2128
2231
|
/**
|
|
2129
2232
|
* Read raw CSS width strings (e.g. "200px", "33.33%") from first row cells
|
|
2130
2233
|
*/
|
|
2131
2234
|
getRawCellWidths(t) {
|
|
2132
|
-
const e = t.querySelector(`[${
|
|
2235
|
+
const e = t.querySelector(`[${y}]`);
|
|
2133
2236
|
if (!e)
|
|
2134
2237
|
return [];
|
|
2135
|
-
const n = e.querySelectorAll(`[${
|
|
2238
|
+
const n = e.querySelectorAll(`[${b}]`);
|
|
2136
2239
|
return Array.from(n).map((o) => o.style.width);
|
|
2137
2240
|
}
|
|
2138
2241
|
/**
|
|
@@ -2140,7 +2243,7 @@ class Go {
|
|
|
2140
2243
|
*/
|
|
2141
2244
|
createRow(t, e) {
|
|
2142
2245
|
const n = document.createElement("div");
|
|
2143
|
-
return n.className = w(
|
|
2246
|
+
return n.className = w(es), n.setAttribute(y, ""), Array.from({ length: t }).forEach((o, s) => {
|
|
2144
2247
|
n.appendChild(this.createCell(e[s]));
|
|
2145
2248
|
}), n;
|
|
2146
2249
|
}
|
|
@@ -2149,13 +2252,13 @@ class Go {
|
|
|
2149
2252
|
*/
|
|
2150
2253
|
createCell(t) {
|
|
2151
2254
|
const e = document.createElement("div");
|
|
2152
|
-
e.className = w(
|
|
2255
|
+
e.className = w(ns), e.style.borderRight = pt, e.style.borderBottom = pt, e.style.flexShrink = "0", e.style.overflow = "hidden", e.style.overflowWrap = "break-word", t !== void 0 && (e.style.width = typeof t == "string" ? t : `${t}%`), e.setAttribute(b, "");
|
|
2153
2256
|
const n = document.createElement("div");
|
|
2154
|
-
return n.setAttribute(
|
|
2257
|
+
return n.setAttribute(D, ""), e.appendChild(n), e;
|
|
2155
2258
|
}
|
|
2156
2259
|
}
|
|
2157
|
-
const
|
|
2158
|
-
class
|
|
2260
|
+
const Z = (r) => typeof r == "object" && r !== null && "blocks" in r, D = "data-blok-table-cell-blocks";
|
|
2261
|
+
class is {
|
|
2159
2262
|
constructor(t) {
|
|
2160
2263
|
var e;
|
|
2161
2264
|
this._activeCellWithBlocks = null, this.cellsPendingCheck = /* @__PURE__ */ new Set(), this.pendingCheckScheduled = !1, this.removedBlockCells = /* @__PURE__ */ new Map(), this.deferredEvents = [], this.handleBlockMutation = (n) => {
|
|
@@ -2180,9 +2283,9 @@ class Wo {
|
|
|
2180
2283
|
this.claimBlockForCell(l.cell, s.target.id), this.syncBlockToModel(l.cell, s.target.id), this.cellsPendingCheck.delete(l.cell);
|
|
2181
2284
|
return;
|
|
2182
2285
|
}
|
|
2183
|
-
const a = s.target.holder, c = a.closest(`[${
|
|
2286
|
+
const a = s.target.holder, c = a.closest(`[${D}]`);
|
|
2184
2287
|
c && this.stripPlaceholders(c);
|
|
2185
|
-
const d = c && !this.model.findCellForBlock(s.target.id) ? c.closest(`[${
|
|
2288
|
+
const d = c && !this.model.findCellForBlock(s.target.id) ? c.closest(`[${b}]`) : null;
|
|
2186
2289
|
if (d && this.syncBlockToModel(d, s.target.id), c)
|
|
2187
2290
|
return;
|
|
2188
2291
|
if (!this.gridElement.contains(a)) {
|
|
@@ -2199,13 +2302,13 @@ class Wo {
|
|
|
2199
2302
|
const o = n.target;
|
|
2200
2303
|
if (!o)
|
|
2201
2304
|
return;
|
|
2202
|
-
const s = o.hasAttribute(
|
|
2305
|
+
const s = o.hasAttribute(b), i = o.hasAttribute(D);
|
|
2203
2306
|
if (!s && !i)
|
|
2204
2307
|
return;
|
|
2205
|
-
const l = s ? o : o.closest(`[${
|
|
2308
|
+
const l = s ? o : o.closest(`[${b}]`);
|
|
2206
2309
|
if (!l)
|
|
2207
2310
|
return;
|
|
2208
|
-
const a = s ? l.querySelector(`[${
|
|
2311
|
+
const a = s ? l.querySelector(`[${D}]`) : o;
|
|
2209
2312
|
if (!a)
|
|
2210
2313
|
return;
|
|
2211
2314
|
const c = a.querySelectorAll("[data-blok-id]"), d = c[c.length - 1];
|
|
@@ -2283,7 +2386,7 @@ class Wo {
|
|
|
2283
2386
|
const n = this.getCell(t.row, t.col);
|
|
2284
2387
|
if (!n)
|
|
2285
2388
|
return;
|
|
2286
|
-
const o = n.querySelector(`[${
|
|
2389
|
+
const o = n.querySelector(`[${D}]`);
|
|
2287
2390
|
if (!o)
|
|
2288
2391
|
return;
|
|
2289
2392
|
const s = o.querySelectorAll('[contenteditable="true"]');
|
|
@@ -2320,30 +2423,30 @@ class Wo {
|
|
|
2320
2423
|
* - If referenced blocks are missing from BlockManager, a fallback paragraph is created.
|
|
2321
2424
|
*/
|
|
2322
2425
|
initializeCells(t) {
|
|
2323
|
-
const e = this.gridElement.querySelectorAll(`[${
|
|
2426
|
+
const e = this.gridElement.querySelectorAll(`[${y}]`), n = [];
|
|
2324
2427
|
return t.forEach((o, s) => {
|
|
2325
2428
|
const i = e[s];
|
|
2326
2429
|
if (!i)
|
|
2327
2430
|
return;
|
|
2328
|
-
const l = i.querySelectorAll(`[${
|
|
2431
|
+
const l = i.querySelectorAll(`[${b}]`), a = [];
|
|
2329
2432
|
o.forEach((c, d) => {
|
|
2330
2433
|
var m;
|
|
2331
2434
|
const h = l[d];
|
|
2332
2435
|
if (!h)
|
|
2333
2436
|
return;
|
|
2334
|
-
const u = h.querySelector(`[${
|
|
2437
|
+
const u = h.querySelector(`[${D}]`);
|
|
2335
2438
|
if (!u)
|
|
2336
2439
|
return;
|
|
2337
|
-
const p =
|
|
2338
|
-
if (
|
|
2339
|
-
a.push(
|
|
2440
|
+
const p = Z(c) && c.blocks.length > 0 ? [...c.blocks] : null, g = p ? this.mountBlocksInCell(u, p) : [], f = {};
|
|
2441
|
+
if (Z(c) && (c.color !== void 0 && (f.color = c.color), c.textColor !== void 0 && (f.textColor = c.textColor)), g.length > 0)
|
|
2442
|
+
a.push(T({ blocks: p != null ? p : g }, f));
|
|
2340
2443
|
else {
|
|
2341
|
-
const C = typeof c == "string" ? c : (m = c.text) != null ? m : "", v = C.split(/<br\s*\/?>/i).map((
|
|
2342
|
-
for (const
|
|
2343
|
-
const
|
|
2344
|
-
u.appendChild(
|
|
2444
|
+
const C = typeof c == "string" ? c : (m = c.text) != null ? m : "", v = C.split(/<br\s*\/?>/i).map((E) => E.trim()).filter(Boolean), k = v.length > 0 ? v : [C], x = [];
|
|
2445
|
+
for (const E of k) {
|
|
2446
|
+
const A = this.api.blocks.insert("paragraph", { text: E }, {}, this.api.blocks.getBlocksCount(), !1);
|
|
2447
|
+
u.appendChild(A.holder), this.api.blocks.setBlockParent(A.id, this.tableBlockId), x.push(A.id);
|
|
2345
2448
|
}
|
|
2346
|
-
a.push(
|
|
2449
|
+
a.push(T({
|
|
2347
2450
|
blocks: p === null ? x : [...p, ...x]
|
|
2348
2451
|
}, f));
|
|
2349
2452
|
}
|
|
@@ -2381,7 +2484,7 @@ class Wo {
|
|
|
2381
2484
|
* Move a block's DOM holder into a cell's blocks container.
|
|
2382
2485
|
*/
|
|
2383
2486
|
claimBlockForCell(t, e) {
|
|
2384
|
-
const n = t.querySelector(`[${
|
|
2487
|
+
const n = t.querySelector(`[${D}]`);
|
|
2385
2488
|
if (!n)
|
|
2386
2489
|
return;
|
|
2387
2490
|
const o = this.api.blocks.getBlockIndex(e);
|
|
@@ -2405,7 +2508,7 @@ class Wo {
|
|
|
2405
2508
|
findCellForAdjacentBlock(t) {
|
|
2406
2509
|
if (t < 0 || t >= this.api.blocks.getBlocksCount())
|
|
2407
2510
|
return null;
|
|
2408
|
-
const e = this.api.blocks.getBlockByIndex(t), n = e == null ? void 0 : e.holder.closest(`[${
|
|
2511
|
+
const e = this.api.blocks.getBlockByIndex(t), n = e == null ? void 0 : e.holder.closest(`[${b}]`);
|
|
2409
2512
|
return n && this.gridElement.contains(n) ? n : null;
|
|
2410
2513
|
}
|
|
2411
2514
|
/**
|
|
@@ -2413,7 +2516,7 @@ class Wo {
|
|
|
2413
2516
|
* If the blocks container is empty, insert an empty paragraph.
|
|
2414
2517
|
*/
|
|
2415
2518
|
ensureCellHasBlock(t) {
|
|
2416
|
-
const e = t.querySelector(`[${
|
|
2519
|
+
const e = t.querySelector(`[${D}]`);
|
|
2417
2520
|
if (!e || e.querySelector("[data-blok-id]") !== null)
|
|
2418
2521
|
return;
|
|
2419
2522
|
const o = this.api.blocks.insert("paragraph", { text: "" }, {}, this.api.blocks.getBlocksCount(), !0);
|
|
@@ -2444,13 +2547,13 @@ class Wo {
|
|
|
2444
2547
|
* Get the row/col position of a cell element within the grid.
|
|
2445
2548
|
*/
|
|
2446
2549
|
getCellPosition(t) {
|
|
2447
|
-
const e = t.closest(`[${
|
|
2550
|
+
const e = t.closest(`[${y}]`);
|
|
2448
2551
|
if (!e)
|
|
2449
2552
|
return null;
|
|
2450
|
-
const o = Array.from(this.gridElement.querySelectorAll(`[${
|
|
2553
|
+
const o = Array.from(this.gridElement.querySelectorAll(`[${y}]`)).indexOf(e);
|
|
2451
2554
|
if (o < 0)
|
|
2452
2555
|
return null;
|
|
2453
|
-
const i = Array.from(e.querySelectorAll(`[${
|
|
2556
|
+
const i = Array.from(e.querySelectorAll(`[${b}]`)).indexOf(t);
|
|
2454
2557
|
return i < 0 ? null : { row: o, col: i };
|
|
2455
2558
|
}
|
|
2456
2559
|
/**
|
|
@@ -2461,7 +2564,7 @@ class Wo {
|
|
|
2461
2564
|
recordRemovedBlockCell(t) {
|
|
2462
2565
|
if (t.index === void 0)
|
|
2463
2566
|
return;
|
|
2464
|
-
const e = t.target.holder.closest(`[${
|
|
2567
|
+
const e = t.target.holder.closest(`[${b}]`);
|
|
2465
2568
|
e && this.gridElement.contains(e) && this.removedBlockCells.set(t.target.id, { cell: e, index: t.index });
|
|
2466
2569
|
}
|
|
2467
2570
|
/**
|
|
@@ -2554,7 +2657,7 @@ class Wo {
|
|
|
2554
2657
|
getBlockIdsFromCells(t) {
|
|
2555
2658
|
const e = [];
|
|
2556
2659
|
return Array.from(t).forEach((o) => {
|
|
2557
|
-
const s = o.querySelector(`[${
|
|
2660
|
+
const s = o.querySelector(`[${D}]`);
|
|
2558
2661
|
s && s.querySelectorAll("[data-blok-id]").forEach((i) => {
|
|
2559
2662
|
const l = i.getAttribute("data-blok-id");
|
|
2560
2663
|
l && e.push(l);
|
|
@@ -2574,7 +2677,7 @@ class Wo {
|
|
|
2574
2677
|
* Called before the table block itself is removed to prevent orphaned cell blocks.
|
|
2575
2678
|
*/
|
|
2576
2679
|
deleteAllBlocks() {
|
|
2577
|
-
const t = this.gridElement.querySelectorAll(`[${
|
|
2680
|
+
const t = this.gridElement.querySelectorAll(`[${b}]`), e = this.getBlockIdsFromCells(t);
|
|
2578
2681
|
this.deleteBlocks(e);
|
|
2579
2682
|
}
|
|
2580
2683
|
/**
|
|
@@ -2601,14 +2704,14 @@ class Wo {
|
|
|
2601
2704
|
this.deferredEvents.length = 0;
|
|
2602
2705
|
}
|
|
2603
2706
|
}
|
|
2604
|
-
function
|
|
2707
|
+
function rs(r, t) {
|
|
2605
2708
|
if (r === t)
|
|
2606
2709
|
return !0;
|
|
2607
|
-
const e =
|
|
2710
|
+
const e = qt(r), n = qt(t);
|
|
2608
2711
|
return e === null || n === null ? !1 : e[0] === n[0] && e[1] === n[1] && e[2] === n[2];
|
|
2609
2712
|
}
|
|
2610
|
-
const
|
|
2611
|
-
function
|
|
2713
|
+
const ls = "flex-1 py-1.5 text-xs text-center rounded-md cursor-pointer border-none transition-colors", as = "#f7f7f5";
|
|
2714
|
+
function $e(r) {
|
|
2612
2715
|
var g;
|
|
2613
2716
|
const { i18n: t, modes: e, testIdPrefix: n, onColorSelect: o } = r, s = (g = r.defaultModeIndex) != null ? g : 0, i = { modeIndex: s, activeColor: null }, l = document.createElement("div");
|
|
2614
2717
|
l.setAttribute("data-blok-testid", `${n}-picker`), l.className = "flex flex-col gap-2 p-2";
|
|
@@ -2624,7 +2727,7 @@ function Pe(r) {
|
|
|
2624
2727
|
const d = () => {
|
|
2625
2728
|
for (const [f, m] of c.entries())
|
|
2626
2729
|
m.className = w(
|
|
2627
|
-
|
|
2730
|
+
ls,
|
|
2628
2731
|
f === i.modeIndex ? "bg-item-hover-bg font-medium" : "bg-transparent hover:bg-item-hover-bg/50"
|
|
2629
2732
|
);
|
|
2630
2733
|
}, h = document.createElement("div");
|
|
@@ -2632,14 +2735,14 @@ function Pe(r) {
|
|
|
2632
2735
|
const u = () => {
|
|
2633
2736
|
h.innerHTML = "";
|
|
2634
2737
|
const f = e[i.modeIndex];
|
|
2635
|
-
for (const m of
|
|
2636
|
-
const C = document.createElement("button"), v = f.presetField === "text" ? m.text : m.bg, k = i.activeColor !== null &&
|
|
2738
|
+
for (const m of fn) {
|
|
2739
|
+
const C = document.createElement("button"), v = f.presetField === "text" ? m.text : m.bg, k = i.activeColor !== null && rs(v, i.activeColor);
|
|
2637
2740
|
C.setAttribute("data-blok-testid", `${n}-swatch-${m.name}`), C.className = w(
|
|
2638
2741
|
"w-8 h-8 rounded-md cursor-pointer border-none",
|
|
2639
2742
|
"flex items-center justify-center text-sm font-semibold",
|
|
2640
2743
|
"transition-shadow ring-inset hover:ring-2 hover:ring-black/10",
|
|
2641
2744
|
k && "ring-2 ring-black/30"
|
|
2642
|
-
), C.textContent = "A", f.presetField === "text" ? (C.style.color = m.text, C.style.backgroundColor =
|
|
2745
|
+
), C.textContent = "A", f.presetField === "text" ? (C.style.color = m.text, C.style.backgroundColor = as) : (C.style.color = "", C.style.backgroundColor = m.bg), C.addEventListener("click", () => {
|
|
2643
2746
|
o(v, f.key);
|
|
2644
2747
|
}), h.appendChild(C);
|
|
2645
2748
|
}
|
|
@@ -2662,7 +2765,7 @@ function Pe(r) {
|
|
|
2662
2765
|
}
|
|
2663
2766
|
};
|
|
2664
2767
|
}
|
|
2665
|
-
const
|
|
2768
|
+
const cs = (r) => ({ element: $e({
|
|
2666
2769
|
i18n: r.i18n,
|
|
2667
2770
|
testIdPrefix: "cell-color",
|
|
2668
2771
|
defaultModeIndex: 1,
|
|
@@ -2673,21 +2776,21 @@ const zo = (r) => ({ element: Pe({
|
|
|
2673
2776
|
onColorSelect: (e, n) => {
|
|
2674
2777
|
r.onColorSelect(e, n);
|
|
2675
2778
|
}
|
|
2676
|
-
}).element }),
|
|
2779
|
+
}).element }), j = 16, ds = [
|
|
2677
2780
|
[2, 2],
|
|
2678
2781
|
[8, 2],
|
|
2679
2782
|
[2, 7],
|
|
2680
2783
|
[8, 7],
|
|
2681
2784
|
[2, 12],
|
|
2682
2785
|
[8, 12]
|
|
2683
|
-
],
|
|
2786
|
+
], hs = [
|
|
2684
2787
|
[2, 2],
|
|
2685
2788
|
[7, 2],
|
|
2686
2789
|
[12, 2],
|
|
2687
2790
|
[2, 8],
|
|
2688
2791
|
[7, 8],
|
|
2689
2792
|
[12, 8]
|
|
2690
|
-
],
|
|
2793
|
+
], Fe = (r) => {
|
|
2691
2794
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg"), e = r === "horizontal";
|
|
2692
2795
|
t.setAttribute("width", e ? "14" : "10"), t.setAttribute("height", e ? "10" : "14"), t.setAttribute("viewBox", e ? "0 0 14 10" : "0 0 10 14"), t.setAttribute("fill", "currentColor"), t.classList.add(
|
|
2693
2796
|
"opacity-0",
|
|
@@ -2696,21 +2799,21 @@ const zo = (r) => ({ element: Pe({
|
|
|
2696
2799
|
"text-gray-400",
|
|
2697
2800
|
"pointer-events-none"
|
|
2698
2801
|
);
|
|
2699
|
-
const n = e ?
|
|
2802
|
+
const n = e ? hs : ds;
|
|
2700
2803
|
for (const [o, s] of n) {
|
|
2701
2804
|
const i = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
2702
2805
|
i.setAttribute("cx", String(o)), i.setAttribute("cy", String(s)), i.setAttribute("r", "1.5"), t.appendChild(i);
|
|
2703
2806
|
}
|
|
2704
2807
|
return t;
|
|
2705
|
-
},
|
|
2706
|
-
t === "col" ? Object.assign(r.style, { height: `${
|
|
2808
|
+
}, us = (r, t) => {
|
|
2809
|
+
t === "col" ? Object.assign(r.style, { height: `${j}px` }) : Object.assign(r.style, { width: `${j}px` }), r.classList.add("bg-gray-200"), r.classList.remove("bg-gray-300");
|
|
2707
2810
|
const e = r.querySelector("svg");
|
|
2708
2811
|
e && (e.classList.remove("opacity-0"), e.classList.add("opacity-100"));
|
|
2709
|
-
},
|
|
2812
|
+
}, Et = (r, t, e) => {
|
|
2710
2813
|
t === "col" ? Object.assign(r.style, { height: `${e}px` }) : Object.assign(r.style, { width: `${e}px` }), r.classList.remove("bg-gray-200"), r.classList.add("bg-gray-300");
|
|
2711
2814
|
const n = r.querySelector("svg");
|
|
2712
2815
|
n && (n.classList.add("opacity-0"), n.classList.remove("opacity-100"));
|
|
2713
|
-
},
|
|
2816
|
+
}, At = "data-blok-table-cell-selected", ps = "2px solid #3b82f6", xt = "data-blok-table-selection-pill", gs = 16, fs = 20, re = 4, ms = [
|
|
2714
2817
|
"absolute",
|
|
2715
2818
|
"z-3",
|
|
2716
2819
|
"rounded-sm",
|
|
@@ -2723,8 +2826,8 @@ const zo = (r) => ({ element: Pe({
|
|
|
2723
2826
|
"overflow-hidden",
|
|
2724
2827
|
"cursor-pointer",
|
|
2725
2828
|
"bg-blue-500"
|
|
2726
|
-
],
|
|
2727
|
-
class
|
|
2829
|
+
], Cs = (r) => r.style.userSelect === "none";
|
|
2830
|
+
class bs {
|
|
2728
2831
|
constructor(t) {
|
|
2729
2832
|
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 = t.grid, this.rectangleSelection = t.rectangleSelection, this.onSelectionActiveChange = t.onSelectionActiveChange, this.onClearContent = t.onClearContent, this.onCopy = t.onCopy, this.onCut = t.onCut, this.onCopyViaButton = t.onCopyViaButton, this.onColorChange = t.onColorChange, this.onSelectionRangeChange = t.onSelectionRangeChange, this.isPopoverOpen = t.isPopoverOpen, this.i18n = t.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);
|
|
2730
2833
|
}
|
|
@@ -2736,14 +2839,14 @@ class Qo {
|
|
|
2736
2839
|
*/
|
|
2737
2840
|
selectRow(t) {
|
|
2738
2841
|
var o, s;
|
|
2739
|
-
const n = (s = (o = this.grid.querySelectorAll(`[${
|
|
2842
|
+
const n = (s = (o = this.grid.querySelectorAll(`[${y}]`)[0]) == null ? void 0 : o.querySelectorAll(`[${b}]`).length) != null ? s : 0;
|
|
2740
2843
|
n !== 0 && this.showProgrammaticSelection(t, 0, t, n - 1);
|
|
2741
2844
|
}
|
|
2742
2845
|
/**
|
|
2743
2846
|
* Programmatically select an entire column.
|
|
2744
2847
|
*/
|
|
2745
2848
|
selectColumn(t) {
|
|
2746
|
-
const n = this.grid.querySelectorAll(`[${
|
|
2849
|
+
const n = this.grid.querySelectorAll(`[${y}]`).length;
|
|
2747
2850
|
n !== 0 && this.showProgrammaticSelection(0, t, n - 1, t);
|
|
2748
2851
|
}
|
|
2749
2852
|
/**
|
|
@@ -2774,10 +2877,10 @@ class Qo {
|
|
|
2774
2877
|
this.anchorCell && t.preventDefault();
|
|
2775
2878
|
}
|
|
2776
2879
|
handlePointerDown(t) {
|
|
2777
|
-
if (
|
|
2880
|
+
if (Cs(this.grid) || t.button !== 0)
|
|
2778
2881
|
return;
|
|
2779
2882
|
const e = t.target;
|
|
2780
|
-
if (e.closest("[data-blok-table-grip]") || e.closest("[data-blok-table-resize]") || e.closest(`[${
|
|
2883
|
+
if (e.closest("[data-blok-table-grip]") || e.closest("[data-blok-table-resize]") || e.closest(`[${xt}]`))
|
|
2781
2884
|
return;
|
|
2782
2885
|
const n = this.resolveCellCoord(e);
|
|
2783
2886
|
if (!n)
|
|
@@ -2819,7 +2922,7 @@ class Qo {
|
|
|
2819
2922
|
}
|
|
2820
2923
|
handleClearSelection(t) {
|
|
2821
2924
|
const e = t.target;
|
|
2822
|
-
e instanceof HTMLElement && e.closest(`[${
|
|
2925
|
+
e instanceof HTMLElement && e.closest(`[${xt}]`) || e instanceof HTMLElement && e.closest("[data-blok-popover-opened]") !== null || (this.pillPopover !== null && this.destroyPillPopover(), document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection());
|
|
2823
2926
|
}
|
|
2824
2927
|
handleKeyDown(t) {
|
|
2825
2928
|
var e;
|
|
@@ -2840,7 +2943,7 @@ class Qo {
|
|
|
2840
2943
|
}
|
|
2841
2944
|
restoreModifiedCells() {
|
|
2842
2945
|
this.destroyPillPopover(), this.disconnectResizeObserver(), this.selectedCells.forEach((t) => {
|
|
2843
|
-
t.removeAttribute(
|
|
2946
|
+
t.removeAttribute(At);
|
|
2844
2947
|
}), this.pill && (this.pill.remove(), this.pill = null), this.overlay && (this.overlay.remove(), this.overlay = null), this.selectedCells = [];
|
|
2845
2948
|
}
|
|
2846
2949
|
showProgrammaticSelection(t, e, n, o) {
|
|
@@ -2852,19 +2955,19 @@ class Qo {
|
|
|
2852
2955
|
if (!this.anchorCell || !this.extentCell)
|
|
2853
2956
|
return;
|
|
2854
2957
|
this.selectedCells.forEach((x) => {
|
|
2855
|
-
x.removeAttribute(
|
|
2958
|
+
x.removeAttribute(At);
|
|
2856
2959
|
}), this.selectedCells = [];
|
|
2857
2960
|
const t = Math.min(this.anchorCell.row, this.extentCell.row), e = Math.max(this.anchorCell.row, this.extentCell.row), n = Math.min(this.anchorCell.col, this.extentCell.col), o = Math.max(this.anchorCell.col, this.extentCell.col);
|
|
2858
2961
|
this.lastPaintedRange = { minRow: t, maxRow: e, minCol: n, maxCol: o };
|
|
2859
|
-
const s = this.grid.querySelectorAll(`[${
|
|
2962
|
+
const s = this.grid.querySelectorAll(`[${y}]`);
|
|
2860
2963
|
this.selectedCells = this.collectCellsInRange(s, t, e, n, o), this.selectedCells.forEach((x) => {
|
|
2861
|
-
x.setAttribute(
|
|
2964
|
+
x.setAttribute(At, "");
|
|
2862
2965
|
});
|
|
2863
|
-
const i = (v = s[t]) == null ? void 0 : v.querySelectorAll(`[${
|
|
2966
|
+
const i = (v = s[t]) == null ? void 0 : v.querySelectorAll(`[${b}]`)[n], l = (k = s[e]) == null ? void 0 : k.querySelectorAll(`[${b}]`)[o];
|
|
2864
2967
|
if (!i || !l)
|
|
2865
2968
|
return;
|
|
2866
2969
|
const a = this.grid.getBoundingClientRect(), c = i.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), u = parseFloat(h.borderTopWidth) || 0, p = parseFloat(h.borderLeftWidth) || 0, g = d.right - c.left + 1, f = d.bottom - c.top + 1, m = c.top - a.top - u - 1, C = c.left - a.left - p - 1;
|
|
2867
|
-
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border =
|
|
2970
|
+
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = ps, 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 = `${m}px`, this.overlay.style.left = `${C}px`, this.overlay.style.width = `${g}px`, this.overlay.style.height = `${f}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${C + g - 1}px`, this.pill.style.top = `${m + f / 2}px`, this.observeCellResizes();
|
|
2868
2971
|
}
|
|
2869
2972
|
/**
|
|
2870
2973
|
* Recalculate overlay and pill positions from the last painted range.
|
|
@@ -2875,7 +2978,7 @@ class Qo {
|
|
|
2875
2978
|
const t = this.lastPaintedRange;
|
|
2876
2979
|
if (!t || !this.overlay)
|
|
2877
2980
|
return;
|
|
2878
|
-
const e = this.grid.querySelectorAll(`[${
|
|
2981
|
+
const e = this.grid.querySelectorAll(`[${y}]`), n = (f = e[t.minRow]) == null ? void 0 : f.querySelectorAll(`[${b}]`)[t.minCol], o = (m = e[t.maxRow]) == null ? void 0 : m.querySelectorAll(`[${b}]`)[t.maxCol];
|
|
2879
2982
|
if (!n || !o)
|
|
2880
2983
|
return;
|
|
2881
2984
|
const s = this.grid.getBoundingClientRect(), i = n.getBoundingClientRect(), l = o.getBoundingClientRect(), a = getComputedStyle(this.grid), c = parseFloat(a.borderTopWidth) || 0, d = parseFloat(a.borderLeftWidth) || 0, h = l.right - i.left + 1, u = l.bottom - i.top + 1, p = i.top - s.top - c - 1, g = i.left - s.left - d - 1;
|
|
@@ -2899,8 +3002,8 @@ class Qo {
|
|
|
2899
3002
|
}
|
|
2900
3003
|
createPill() {
|
|
2901
3004
|
const t = document.createElement("div");
|
|
2902
|
-
t.setAttribute(
|
|
2903
|
-
const e =
|
|
3005
|
+
t.setAttribute(xt, ""), t.setAttribute("contenteditable", "false"), t.className = w(ms), t.style.width = `${re}px`, t.style.height = `${fs}px`, t.style.pointerEvents = "auto", t.style.transform = "translate(-50%, -50%)", t.style.outline = "2px solid white";
|
|
3006
|
+
const e = Fe("vertical");
|
|
2904
3007
|
return e.classList.remove("text-gray-400"), e.classList.add("text-white"), t.appendChild(e), t.addEventListener("mouseenter", () => {
|
|
2905
3008
|
this.pillPopover === null && this.expandPill();
|
|
2906
3009
|
}), t.addEventListener("mouseleave", () => {
|
|
@@ -2913,9 +3016,9 @@ class Qo {
|
|
|
2913
3016
|
if (this.destroyPillPopover(), !this.pill)
|
|
2914
3017
|
return;
|
|
2915
3018
|
this.expandPill();
|
|
2916
|
-
const t =
|
|
3019
|
+
const t = bn === "Meta" ? "⌘C" : "Ctrl+C", e = [];
|
|
2917
3020
|
if (this.onColorChange !== void 0) {
|
|
2918
|
-
const { element: o } =
|
|
3021
|
+
const { element: o } = cs({
|
|
2919
3022
|
i18n: this.i18n,
|
|
2920
3023
|
onColorSelect: (s, i) => {
|
|
2921
3024
|
var l;
|
|
@@ -2923,12 +3026,12 @@ class Qo {
|
|
|
2923
3026
|
}
|
|
2924
3027
|
});
|
|
2925
3028
|
e.push({
|
|
2926
|
-
icon:
|
|
3029
|
+
icon: Ae,
|
|
2927
3030
|
title: this.i18n.t("tools.table.cellColor"),
|
|
2928
3031
|
name: "cellColor",
|
|
2929
3032
|
children: {
|
|
2930
3033
|
items: [{
|
|
2931
|
-
type:
|
|
3034
|
+
type: F.Html,
|
|
2932
3035
|
element: o
|
|
2933
3036
|
}],
|
|
2934
3037
|
isFlippable: !1,
|
|
@@ -2939,7 +3042,7 @@ class Qo {
|
|
|
2939
3042
|
const n = [
|
|
2940
3043
|
...e,
|
|
2941
3044
|
{
|
|
2942
|
-
icon:
|
|
3045
|
+
icon: mn,
|
|
2943
3046
|
title: this.i18n.t("tools.table.copySelection"),
|
|
2944
3047
|
secondaryLabel: t,
|
|
2945
3048
|
closeOnActivate: !0,
|
|
@@ -2949,7 +3052,7 @@ class Qo {
|
|
|
2949
3052
|
}
|
|
2950
3053
|
},
|
|
2951
3054
|
{
|
|
2952
|
-
icon:
|
|
3055
|
+
icon: Cn,
|
|
2953
3056
|
title: this.i18n.t("tools.table.clearSelection"),
|
|
2954
3057
|
secondaryLabel: "Del",
|
|
2955
3058
|
closeOnActivate: !0,
|
|
@@ -2959,25 +3062,25 @@ class Qo {
|
|
|
2959
3062
|
}
|
|
2960
3063
|
}
|
|
2961
3064
|
];
|
|
2962
|
-
this.pillPopover = new
|
|
3065
|
+
this.pillPopover = new xe({
|
|
2963
3066
|
items: n,
|
|
2964
3067
|
trigger: this.pill,
|
|
2965
3068
|
flippable: !0
|
|
2966
|
-
}), this.pillPopover.on(
|
|
3069
|
+
}), this.pillPopover.on(Te.Closed, () => {
|
|
2967
3070
|
this.pillPopover !== null && (this.destroyPillPopover(), this.collapsePill());
|
|
2968
3071
|
}), this.pillPopover.show();
|
|
2969
3072
|
}
|
|
2970
3073
|
expandPill() {
|
|
2971
3074
|
if (!this.pill)
|
|
2972
3075
|
return;
|
|
2973
|
-
this.pill.style.width = `${
|
|
3076
|
+
this.pill.style.width = `${gs}px`;
|
|
2974
3077
|
const t = this.pill.querySelector("svg");
|
|
2975
3078
|
t && (t.classList.remove("opacity-0"), t.classList.add("opacity-100"));
|
|
2976
3079
|
}
|
|
2977
3080
|
collapsePill() {
|
|
2978
3081
|
if (!this.pill)
|
|
2979
3082
|
return;
|
|
2980
|
-
this.pill.style.width = `${
|
|
3083
|
+
this.pill.style.width = `${re}px`;
|
|
2981
3084
|
const t = this.pill.querySelector("svg");
|
|
2982
3085
|
t && (t.classList.add("opacity-0"), t.classList.remove("opacity-100"));
|
|
2983
3086
|
}
|
|
@@ -2988,23 +3091,23 @@ class Qo {
|
|
|
2988
3091
|
}
|
|
2989
3092
|
}
|
|
2990
3093
|
resolveCellCoord(t) {
|
|
2991
|
-
const e = t.closest(`[${
|
|
3094
|
+
const e = t.closest(`[${b}]`);
|
|
2992
3095
|
if (!e)
|
|
2993
3096
|
return null;
|
|
2994
|
-
const n = e.closest(`[${
|
|
3097
|
+
const n = e.closest(`[${y}]`);
|
|
2995
3098
|
if (!n || !this.grid.contains(n))
|
|
2996
3099
|
return null;
|
|
2997
|
-
const s = Array.from(this.grid.querySelectorAll(`[${
|
|
3100
|
+
const s = Array.from(this.grid.querySelectorAll(`[${y}]`)).indexOf(n);
|
|
2998
3101
|
if (s < 0)
|
|
2999
3102
|
return null;
|
|
3000
|
-
const l = Array.from(n.querySelectorAll(`[${
|
|
3103
|
+
const l = Array.from(n.querySelectorAll(`[${b}]`)).indexOf(e);
|
|
3001
3104
|
return l < 0 ? null : { row: s, col: l };
|
|
3002
3105
|
}
|
|
3003
3106
|
clampExtentToEdge(t) {
|
|
3004
3107
|
var c, d, h, u, p, g;
|
|
3005
3108
|
if (!this.anchorCell || !this.isSelecting)
|
|
3006
3109
|
return;
|
|
3007
|
-
const e = this.grid.getBoundingClientRect(), n = this.grid.querySelectorAll(`[${
|
|
3110
|
+
const e = this.grid.getBoundingClientRect(), n = this.grid.querySelectorAll(`[${y}]`), o = n.length, s = (d = (c = n[0]) == null ? void 0 : c.querySelectorAll(`[${b}]`).length) != null ? d : 0;
|
|
3008
3111
|
if (o === 0 || s === 0)
|
|
3009
3112
|
return;
|
|
3010
3113
|
const i = this.clampAxis(t.clientY, e.top, e.bottom, o, (u = (h = this.extentCell) == null ? void 0 : h.row) != null ? u : this.anchorCell.row), l = this.clampAxis(t.clientX, e.left, e.right, s, (g = (p = this.extentCell) == null ? void 0 : p.col) != null ? g : this.anchorCell.col), a = { row: i, col: l };
|
|
@@ -3012,7 +3115,7 @@ class Qo {
|
|
|
3012
3115
|
}
|
|
3013
3116
|
collectCellsInRange(t, e, n, o, s) {
|
|
3014
3117
|
return Array.from(t).slice(e, n + 1).flatMap((i) => {
|
|
3015
|
-
const l = i.querySelectorAll(`[${
|
|
3118
|
+
const l = i.querySelectorAll(`[${b}]`);
|
|
3016
3119
|
return Array.from(l).slice(o, s + 1).filter((a) => a instanceof HTMLElement);
|
|
3017
3120
|
});
|
|
3018
3121
|
}
|
|
@@ -3024,51 +3127,51 @@ class Qo {
|
|
|
3024
3127
|
return t < e ? 0 : t > n ? o - 1 : s;
|
|
3025
3128
|
}
|
|
3026
3129
|
}
|
|
3027
|
-
const
|
|
3028
|
-
const t = r.querySelector(`[${
|
|
3130
|
+
const Y = (r) => {
|
|
3131
|
+
const t = r.querySelector(`[${y}]`);
|
|
3029
3132
|
if (!t)
|
|
3030
3133
|
return [];
|
|
3031
|
-
const e = t.querySelectorAll(`[${
|
|
3134
|
+
const e = t.querySelectorAll(`[${b}]`);
|
|
3032
3135
|
return Array.from(e).map(
|
|
3033
3136
|
(n) => n.getBoundingClientRect().width
|
|
3034
3137
|
);
|
|
3035
|
-
},
|
|
3138
|
+
}, vt = (r, t) => {
|
|
3036
3139
|
const e = t.reduce((s, i) => s + i, 0), n = r;
|
|
3037
|
-
n.style.width = `${e +
|
|
3038
|
-
s.querySelectorAll(`[${
|
|
3140
|
+
n.style.width = `${e + q}px`, r.querySelectorAll(`[${y}]`).forEach((s) => {
|
|
3141
|
+
s.querySelectorAll(`[${b}]`).forEach((l, a) => {
|
|
3039
3142
|
if (a < t.length) {
|
|
3040
3143
|
const c = l;
|
|
3041
3144
|
c.style.width = `${t[a]}px`;
|
|
3042
3145
|
}
|
|
3043
3146
|
});
|
|
3044
3147
|
});
|
|
3045
|
-
},
|
|
3046
|
-
const e = Array.from(r.querySelectorAll(`[${
|
|
3148
|
+
}, Dt = (r, t) => {
|
|
3149
|
+
const e = Array.from(r.querySelectorAll(`[${y}]`)), n = e.findIndex((i) => Array.from(i.querySelectorAll(`[${b}]`)).includes(t));
|
|
3047
3150
|
if (n === -1)
|
|
3048
3151
|
return null;
|
|
3049
|
-
const s = Array.from(e[n].querySelectorAll(`[${
|
|
3152
|
+
const s = Array.from(e[n].querySelectorAll(`[${b}]`)).indexOf(t);
|
|
3050
3153
|
return { row: n, col: s };
|
|
3051
|
-
},
|
|
3154
|
+
}, qe = (r) => {
|
|
3052
3155
|
var e;
|
|
3053
|
-
const t = r.querySelector(`[${
|
|
3156
|
+
const t = r.querySelector(`[${D}]`);
|
|
3054
3157
|
return t ? ((e = t.textContent) != null ? e : "").trim().length === 0 : !0;
|
|
3055
|
-
},
|
|
3056
|
-
const n = r.querySelectorAll(`[${
|
|
3158
|
+
}, ys = (r, t) => {
|
|
3159
|
+
const n = r.querySelectorAll(`[${y}]`)[t];
|
|
3057
3160
|
if (!n)
|
|
3058
3161
|
return !0;
|
|
3059
|
-
const o = n.querySelectorAll(`[${
|
|
3060
|
-
return Array.from(o).every((s) =>
|
|
3061
|
-
},
|
|
3062
|
-
const e = r.querySelectorAll(`[${
|
|
3162
|
+
const o = n.querySelectorAll(`[${b}]`);
|
|
3163
|
+
return Array.from(o).every((s) => qe(s));
|
|
3164
|
+
}, vs = (r, t) => {
|
|
3165
|
+
const e = r.querySelectorAll(`[${y}]`);
|
|
3063
3166
|
return Array.from(e).every((n) => {
|
|
3064
|
-
const s = n.querySelectorAll(`[${
|
|
3065
|
-
return !s ||
|
|
3167
|
+
const s = n.querySelectorAll(`[${b}]`)[t];
|
|
3168
|
+
return !s || qe(s);
|
|
3066
3169
|
});
|
|
3067
|
-
},
|
|
3068
|
-
const t = r.querySelectorAll(`[${
|
|
3170
|
+
}, Ss = (r) => {
|
|
3171
|
+
const t = r.querySelectorAll(`[${y}]`), e = t[0];
|
|
3069
3172
|
if (!e)
|
|
3070
3173
|
return;
|
|
3071
|
-
const n = e.querySelectorAll(`[${
|
|
3174
|
+
const n = e.querySelectorAll(`[${b}]`), o = Array.from(n).reduce(
|
|
3072
3175
|
(i, l) => i + (parseFloat(l.style.width) || 0),
|
|
3073
3176
|
0
|
|
3074
3177
|
);
|
|
@@ -3076,65 +3179,65 @@ const j = (r) => {
|
|
|
3076
3179
|
return;
|
|
3077
3180
|
const s = 100 / o;
|
|
3078
3181
|
t.forEach((i) => {
|
|
3079
|
-
i.querySelectorAll(`[${
|
|
3182
|
+
i.querySelectorAll(`[${b}]`).forEach((a) => {
|
|
3080
3183
|
const c = a, d = parseFloat(c.style.width) || 0;
|
|
3081
3184
|
c.style.width = `${Math.round(d * s * 100) / 100}%`;
|
|
3082
3185
|
});
|
|
3083
3186
|
});
|
|
3084
|
-
},
|
|
3187
|
+
}, ws = (r, t, e) => {
|
|
3085
3188
|
if (!r)
|
|
3086
3189
|
return r;
|
|
3087
3190
|
const n = [...r], [o] = n.splice(t, 1);
|
|
3088
3191
|
return n.splice(e, 0, o), n;
|
|
3089
|
-
},
|
|
3192
|
+
}, ks = (r, t) => {
|
|
3090
3193
|
if (!r)
|
|
3091
3194
|
return r;
|
|
3092
3195
|
const e = [...r];
|
|
3093
3196
|
return e.splice(t, 1), e.length > 0 ? e : void 0;
|
|
3094
|
-
},
|
|
3095
|
-
const s = e != null ? e :
|
|
3197
|
+
}, Es = (r, t, e, n, o) => {
|
|
3198
|
+
const s = e != null ? e : Y(r), i = n !== void 0 ? Math.round(n / 2 * 100) / 100 : at(s);
|
|
3096
3199
|
o.addColumn(r, t, s, i);
|
|
3097
3200
|
const l = [...s];
|
|
3098
3201
|
return l.splice(t, 0, i), l;
|
|
3099
|
-
},
|
|
3202
|
+
}, at = (r) => Math.round(
|
|
3100
3203
|
r.reduce((t, e) => t + e, 0) / r.length / 2 * 100
|
|
3101
|
-
) / 100,
|
|
3204
|
+
) / 100, As = (r) => r.length === 0 ? 0 : Math.round(r.reduce((t, e) => t + e, 0) / r.length * 100) / 100, xs = (r, t, e) => {
|
|
3102
3205
|
var s;
|
|
3103
3206
|
if (!r)
|
|
3104
3207
|
return [];
|
|
3105
|
-
const o = r.querySelectorAll(`[${
|
|
3106
|
-
return o ? (s = t == null ? void 0 : t.getBlockIdsFromCells(o.querySelectorAll(`[${
|
|
3107
|
-
},
|
|
3208
|
+
const o = r.querySelectorAll(`[${y}]`)[e];
|
|
3209
|
+
return o ? (s = t == null ? void 0 : t.getBlockIdsFromCells(o.querySelectorAll(`[${b}]`))) != null ? s : [] : [];
|
|
3210
|
+
}, Ts = (r, t, e) => {
|
|
3108
3211
|
var s;
|
|
3109
3212
|
if (!r)
|
|
3110
3213
|
return [];
|
|
3111
|
-
const n = r.querySelectorAll(`[${
|
|
3214
|
+
const n = r.querySelectorAll(`[${y}]`), o = [];
|
|
3112
3215
|
return n.forEach((i) => {
|
|
3113
|
-
const l = i.querySelectorAll(`[${
|
|
3216
|
+
const l = i.querySelectorAll(`[${b}]`);
|
|
3114
3217
|
e < l.length && o.push(l[e]);
|
|
3115
3218
|
}), (s = t == null ? void 0 : t.getBlockIdsFromCells(o)) != null ? s : [];
|
|
3116
|
-
},
|
|
3117
|
-
r.querySelectorAll(`[${
|
|
3219
|
+
}, _ = (r, t) => {
|
|
3220
|
+
r.querySelectorAll(`[${b}]`).forEach((n) => {
|
|
3118
3221
|
t == null || t.ensureCellHasBlock(n);
|
|
3119
3222
|
});
|
|
3120
|
-
},
|
|
3121
|
-
const o = r.querySelectorAll(`[${
|
|
3223
|
+
}, Rs = (r, t, e, n) => {
|
|
3224
|
+
const o = r.querySelectorAll(`[${y}]`);
|
|
3122
3225
|
t.forEach((s, i) => {
|
|
3123
3226
|
const l = o[i];
|
|
3124
3227
|
if (!l)
|
|
3125
3228
|
return;
|
|
3126
|
-
const a = l.querySelectorAll(`[${
|
|
3229
|
+
const a = l.querySelectorAll(`[${b}]`);
|
|
3127
3230
|
s.forEach((c, d) => {
|
|
3128
3231
|
var g;
|
|
3129
3232
|
const h = a[d];
|
|
3130
3233
|
if (!h)
|
|
3131
3234
|
return;
|
|
3132
|
-
const u = h.querySelector(`[${
|
|
3235
|
+
const u = h.querySelector(`[${D}]`);
|
|
3133
3236
|
if (!u)
|
|
3134
3237
|
return;
|
|
3135
3238
|
const p = u.querySelectorAll("[data-blok-id]").length > 0;
|
|
3136
|
-
if (!(!
|
|
3137
|
-
if (!
|
|
3239
|
+
if (!(!Z(c) && p)) {
|
|
3240
|
+
if (!Z(c)) {
|
|
3138
3241
|
u.textContent = c;
|
|
3139
3242
|
return;
|
|
3140
3243
|
}
|
|
@@ -3154,7 +3257,7 @@ const j = (r) => {
|
|
|
3154
3257
|
}
|
|
3155
3258
|
});
|
|
3156
3259
|
});
|
|
3157
|
-
},
|
|
3260
|
+
}, le = (r, t) => {
|
|
3158
3261
|
var l, a, c, d, h, u, p, g, f, m;
|
|
3159
3262
|
if (!(typeof r == "object" && r !== null && "content" in r))
|
|
3160
3263
|
return {
|
|
@@ -3172,47 +3275,47 @@ const j = (r) => {
|
|
|
3172
3275
|
colWidths: i,
|
|
3173
3276
|
initialColWidth: n.initialColWidth
|
|
3174
3277
|
};
|
|
3175
|
-
},
|
|
3278
|
+
}, Bs = (r, t) => {
|
|
3176
3279
|
r.addEventListener("keydown", (e) => {
|
|
3177
|
-
const o = e.target.closest(`[${
|
|
3280
|
+
const o = e.target.closest(`[${b}]`);
|
|
3178
3281
|
if (!o)
|
|
3179
3282
|
return;
|
|
3180
|
-
const s =
|
|
3283
|
+
const s = Dt(r, o);
|
|
3181
3284
|
s && (t == null || t.handleKeyDown(e, s));
|
|
3182
3285
|
});
|
|
3183
|
-
},
|
|
3184
|
-
r == null || r.classList.add(...
|
|
3185
|
-
},
|
|
3286
|
+
}, ze = ["overflow-x-auto", "overflow-y-hidden"], ae = (r) => {
|
|
3287
|
+
r == null || r.classList.add(...ze);
|
|
3288
|
+
}, it = (r, t) => {
|
|
3186
3289
|
if (!r)
|
|
3187
3290
|
return;
|
|
3188
|
-
const e = r.querySelectorAll(`[${
|
|
3291
|
+
const e = r.querySelectorAll(`[${y}]`);
|
|
3189
3292
|
e.forEach((n) => {
|
|
3190
3293
|
n.removeAttribute("data-blok-table-heading");
|
|
3191
3294
|
}), t && e.length > 0 && e[0].setAttribute("data-blok-table-heading", "");
|
|
3192
|
-
},
|
|
3193
|
-
const e = r.querySelectorAll(`[${
|
|
3295
|
+
}, rt = (r, t) => {
|
|
3296
|
+
const e = r.querySelectorAll(`[${y}]`);
|
|
3194
3297
|
t.forEach((n, o) => {
|
|
3195
3298
|
if (o >= e.length)
|
|
3196
3299
|
return;
|
|
3197
|
-
const s = e[o].querySelectorAll(`[${
|
|
3300
|
+
const s = e[o].querySelectorAll(`[${b}]`);
|
|
3198
3301
|
n.forEach((i, l) => {
|
|
3199
3302
|
if (l >= s.length)
|
|
3200
3303
|
return;
|
|
3201
3304
|
const a = s[l];
|
|
3202
|
-
|
|
3305
|
+
Z(i) && i.color ? a.style.backgroundColor = i.color : a.style.backgroundColor = "", Z(i) && i.textColor ? a.style.color = i.textColor : a.style.color = "";
|
|
3203
3306
|
});
|
|
3204
3307
|
});
|
|
3205
|
-
},
|
|
3308
|
+
}, K = (r, t) => {
|
|
3206
3309
|
if (!r)
|
|
3207
3310
|
return;
|
|
3208
|
-
r.querySelectorAll(`[${
|
|
3311
|
+
r.querySelectorAll(`[${b}]`).forEach((n) => {
|
|
3209
3312
|
n.removeAttribute("data-blok-table-heading-col");
|
|
3210
|
-
}), t && r.querySelectorAll(`[${
|
|
3211
|
-
const s = o.querySelector(`[${
|
|
3313
|
+
}), t && r.querySelectorAll(`[${y}]`).forEach((o) => {
|
|
3314
|
+
const s = o.querySelector(`[${b}]`);
|
|
3212
3315
|
s && s.setAttribute("data-blok-table-heading-col", "");
|
|
3213
3316
|
});
|
|
3214
|
-
},
|
|
3215
|
-
class
|
|
3317
|
+
}, gt = (r) => !!(/^#[0-9a-f]{3,4}$/i.test(r) || /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(r) || /^rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*(,\s*[\d.]+\s*)?\)$/i.test(r) || /^hsla?\(\s*[\d.]+\s*,\s*[\d.]+%\s*,\s*[\d.]+%\s*(,\s*[\d.]+\s*)?\)$/i.test(r) || r === "transparent");
|
|
3318
|
+
class Ls {
|
|
3216
3319
|
constructor(t) {
|
|
3217
3320
|
var e, n, o;
|
|
3218
3321
|
this.withHeadingsValue = (e = t == null ? void 0 : t.withHeadings) != null ? e : !1, this.withHeadingColumnValue = (n = t == null ? void 0 : t.withHeadingColumn) != null ? n : !1, this.stretchedValue = (o = t == null ? void 0 : t.stretched) != null ? o : !1, this.colWidthsValue = t != null && t.colWidths ? [...t.colWidths] : void 0, this.initialColWidthValue = t == null ? void 0 : t.initialColWidth, this.contentGrid = this.normalizeContent(t == null ? void 0 : t.content), this.blockCellMap = /* @__PURE__ */ new Map(), this.rebuildBlockCellMap();
|
|
@@ -3311,7 +3414,7 @@ class hs {
|
|
|
3311
3414
|
* Set the background color for a cell. Pass undefined to remove.
|
|
3312
3415
|
*/
|
|
3313
3416
|
setCellColor(t, e, n) {
|
|
3314
|
-
this.isInBounds(t, e) && (n === void 0 ? delete this.contentGrid[t][e].color :
|
|
3417
|
+
this.isInBounds(t, e) && (n === void 0 ? delete this.contentGrid[t][e].color : gt(n) && (this.contentGrid[t][e].color = n));
|
|
3315
3418
|
}
|
|
3316
3419
|
/**
|
|
3317
3420
|
* Get the background color for a cell, or undefined if none set.
|
|
@@ -3324,7 +3427,7 @@ class hs {
|
|
|
3324
3427
|
* Set the text color for a cell. Pass undefined to remove.
|
|
3325
3428
|
*/
|
|
3326
3429
|
setCellTextColor(t, e, n) {
|
|
3327
|
-
this.isInBounds(t, e) && (n === void 0 ? delete this.contentGrid[t][e].textColor :
|
|
3430
|
+
this.isInBounds(t, e) && (n === void 0 ? delete this.contentGrid[t][e].textColor : gt(n) && (this.contentGrid[t][e].textColor = n));
|
|
3328
3431
|
}
|
|
3329
3432
|
/**
|
|
3330
3433
|
* Get the text color for a cell, or undefined if none set.
|
|
@@ -3501,9 +3604,9 @@ class hs {
|
|
|
3501
3604
|
* Normalize a single cell: legacy strings become empty blocks arrays.
|
|
3502
3605
|
*/
|
|
3503
3606
|
normalizeCell(t) {
|
|
3504
|
-
if (
|
|
3607
|
+
if (Z(t)) {
|
|
3505
3608
|
const e = { blocks: [...t.blocks] };
|
|
3506
|
-
return t.color !== void 0 &&
|
|
3609
|
+
return t.color !== void 0 && gt(t.color) && (e.color = t.color), t.textColor !== void 0 && gt(t.textColor) && (e.textColor = t.textColor), e;
|
|
3507
3610
|
}
|
|
3508
3611
|
return { blocks: [] };
|
|
3509
3612
|
}
|
|
@@ -3541,8 +3644,8 @@ class hs {
|
|
|
3541
3644
|
return e;
|
|
3542
3645
|
}
|
|
3543
3646
|
}
|
|
3544
|
-
const
|
|
3545
|
-
class
|
|
3647
|
+
const ce = "data-blok-table-resize", Is = "data-blok-table-cell", Ds = "data-blok-table-row", Ps = 50, Tt = 16;
|
|
3648
|
+
class Hs {
|
|
3546
3649
|
constructor(t, e, n, o, s, i = !1) {
|
|
3547
3650
|
this._enabled = !0, this.isDragging = !1, this.dragStartX = 0, this.dragColIndex = -1, this.startColWidth = 0, this.dragRowCells = null, this.handles = [], this.gridEl = t, this.colWidths = [...e], this.onChange = n, this.onDragStart = o != null ? o : null, this.onDrag = s != null ? s : null, this.needsInitialApply = i, this.boundPointerDown = this.onPointerDown.bind(this), this.boundPointerMove = this.onPointerMove.bind(this), this.boundPointerUp = this.onPointerUp.bind(this), this.gridEl.style.position = "relative", i || this.applyWidths(), this.createHandles(), this.gridEl.addEventListener("pointerdown", this.boundPointerDown);
|
|
3548
3651
|
}
|
|
@@ -3569,7 +3672,7 @@ class fs {
|
|
|
3569
3672
|
}
|
|
3570
3673
|
createHandle(t) {
|
|
3571
3674
|
const e = document.createElement("div"), n = this.getHandleLeftPx(t);
|
|
3572
|
-
return e.setAttribute(
|
|
3675
|
+
return e.setAttribute(ce, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${q}px`, e.style.bottom = "0px", e.style.width = `${Tt}px`, e.style.left = `${n - Tt / 2}px`, e.style.cursor = "col-resize", e.style.zIndex = "2", e.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", e.style.opacity = "0", e.style.transition = "opacity 150ms ease", e.setAttribute("contenteditable", "false"), e.addEventListener("mouseenter", () => {
|
|
3573
3676
|
this.isDragging || (e.style.opacity = "1");
|
|
3574
3677
|
}), e.addEventListener("mouseleave", () => {
|
|
3575
3678
|
this.isDragging || (e.style.opacity = "0");
|
|
@@ -3581,7 +3684,7 @@ class fs {
|
|
|
3581
3684
|
updateHandlePositions() {
|
|
3582
3685
|
this.handles.forEach((t, e) => {
|
|
3583
3686
|
const n = this.getHandleLeftPx(e), o = t;
|
|
3584
|
-
o.style.left = `${n -
|
|
3687
|
+
o.style.left = `${n - Tt / 2}px`;
|
|
3585
3688
|
});
|
|
3586
3689
|
}
|
|
3587
3690
|
onPointerDown(t) {
|
|
@@ -3589,7 +3692,7 @@ class fs {
|
|
|
3589
3692
|
if (!this._enabled)
|
|
3590
3693
|
return;
|
|
3591
3694
|
const e = t.target;
|
|
3592
|
-
if (!e.hasAttribute(
|
|
3695
|
+
if (!e.hasAttribute(ce))
|
|
3593
3696
|
return;
|
|
3594
3697
|
t.preventDefault(), this.needsInitialApply && (this.applyWidths(), this.updateHandlePositions(), this.needsInitialApply = !1);
|
|
3595
3698
|
const n = e.getAttribute("data-col");
|
|
@@ -3599,7 +3702,7 @@ class fs {
|
|
|
3599
3702
|
var s, i;
|
|
3600
3703
|
if (!this.isDragging)
|
|
3601
3704
|
return;
|
|
3602
|
-
const e = t.clientX - this.dragStartX, n = this.startColWidth + e, o = Math.max(
|
|
3705
|
+
const e = t.clientX - this.dragStartX, n = this.startColWidth + e, o = Math.max(Ps, n);
|
|
3603
3706
|
this.colWidths[this.dragColIndex] = o, this.applyWidths((s = this.dragRowCells) != null ? s : void 0), this.updateHandlePositions(), (i = this.onDrag) == null || i.call(this);
|
|
3604
3707
|
}
|
|
3605
3708
|
onPointerUp() {
|
|
@@ -3610,46 +3713,46 @@ class fs {
|
|
|
3610
3713
|
t && (t.style.opacity = "0"), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), this.dragRowCells = null, this.onChange([...this.colWidths]);
|
|
3611
3714
|
}
|
|
3612
3715
|
resolveRowCells() {
|
|
3613
|
-
const t = this.gridEl.querySelectorAll(`[${
|
|
3614
|
-
return Array.from(t, (e) => Array.from(e.querySelectorAll(`[${
|
|
3716
|
+
const t = this.gridEl.querySelectorAll(`[${Ds}]`);
|
|
3717
|
+
return Array.from(t, (e) => Array.from(e.querySelectorAll(`[${Is}]`)));
|
|
3615
3718
|
}
|
|
3616
3719
|
applyWidths(t = this.resolveRowCells()) {
|
|
3617
3720
|
const e = this.colWidths.reduce((n, o) => n + o, 0);
|
|
3618
|
-
this.gridEl.style.width = `${e +
|
|
3721
|
+
this.gridEl.style.width = `${e + q}px`, t.forEach((n) => {
|
|
3619
3722
|
n.forEach((o, s) => {
|
|
3620
3723
|
s < this.colWidths.length && o.style.setProperty("width", `${this.colWidths[s]}px`);
|
|
3621
3724
|
});
|
|
3622
3725
|
});
|
|
3623
3726
|
}
|
|
3624
3727
|
}
|
|
3625
|
-
const
|
|
3728
|
+
const de = (r, t, e) => (e.grid.addRow(r, t), _(r, e.cellBlocks), {
|
|
3626
3729
|
pendingHighlight: { type: "row", index: t },
|
|
3627
3730
|
moveSelection: null,
|
|
3628
3731
|
colWidths: e.data.colWidths,
|
|
3629
3732
|
withHeadings: e.data.withHeadings,
|
|
3630
3733
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3631
|
-
}),
|
|
3632
|
-
const n =
|
|
3633
|
-
return
|
|
3734
|
+
}), he = (r, t, e) => {
|
|
3735
|
+
const n = Es(r, t, e.data.colWidths, e.data.initialColWidth, e.grid);
|
|
3736
|
+
return _(r, e.cellBlocks), {
|
|
3634
3737
|
pendingHighlight: { type: "col", index: t },
|
|
3635
3738
|
moveSelection: null,
|
|
3636
3739
|
colWidths: n,
|
|
3637
3740
|
withHeadings: e.data.withHeadings,
|
|
3638
3741
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3639
3742
|
};
|
|
3640
|
-
},
|
|
3743
|
+
}, Os = (r, t, e, n) => (n.grid.moveRow(r, t, e), {
|
|
3641
3744
|
pendingHighlight: null,
|
|
3642
3745
|
moveSelection: { type: "row", index: e },
|
|
3643
3746
|
colWidths: n.data.colWidths,
|
|
3644
3747
|
withHeadings: n.data.withHeadings,
|
|
3645
3748
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3646
|
-
}),
|
|
3749
|
+
}), Ns = (r, t, e, n) => (n.grid.moveColumn(r, t, e), {
|
|
3647
3750
|
pendingHighlight: null,
|
|
3648
3751
|
moveSelection: { type: "col", index: e },
|
|
3649
|
-
colWidths:
|
|
3752
|
+
colWidths: ws(n.data.colWidths, t, e),
|
|
3650
3753
|
withHeadings: n.data.withHeadings,
|
|
3651
3754
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3652
|
-
}),
|
|
3755
|
+
}), _s = (r, t, e) => {
|
|
3653
3756
|
var s, i;
|
|
3654
3757
|
(i = e.cellBlocks) == null || i.deleteBlocks((s = e.blocksToDelete) != null ? s : []), e.grid.deleteRow(r, t);
|
|
3655
3758
|
const n = e.grid.getRowCount(r);
|
|
@@ -3660,11 +3763,11 @@ const se = (r, t, e) => (e.grid.addRow(r, t), O(r, e.cellBlocks), {
|
|
|
3660
3763
|
withHeadings: e.data.withHeadings,
|
|
3661
3764
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3662
3765
|
};
|
|
3663
|
-
},
|
|
3766
|
+
}, Ms = (r, t, e) => {
|
|
3664
3767
|
var i, l;
|
|
3665
3768
|
(l = e.cellBlocks) == null || l.deleteBlocks((i = e.blocksToDelete) != null ? i : []), e.grid.deleteColumn(r, t);
|
|
3666
|
-
const n =
|
|
3667
|
-
n ?
|
|
3769
|
+
const n = ks(e.data.colWidths, t);
|
|
3770
|
+
n ? vt(r, n) : Ss(r);
|
|
3668
3771
|
const o = e.grid.getColumnCount(r);
|
|
3669
3772
|
return {
|
|
3670
3773
|
pendingHighlight: { type: "col", index: t < o ? t : t - 1 },
|
|
@@ -3673,24 +3776,24 @@ const se = (r, t, e) => (e.grid.addRow(r, t), O(r, e.cellBlocks), {
|
|
|
3673
3776
|
withHeadings: e.data.withHeadings,
|
|
3674
3777
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3675
3778
|
};
|
|
3676
|
-
},
|
|
3779
|
+
}, Gs = (r, t, e) => {
|
|
3677
3780
|
switch (t.type) {
|
|
3678
3781
|
case "insert-row-above":
|
|
3679
|
-
return
|
|
3782
|
+
return de(r, t.index, e);
|
|
3680
3783
|
case "insert-row-below":
|
|
3681
|
-
return
|
|
3784
|
+
return de(r, t.index + 1, e);
|
|
3682
3785
|
case "insert-col-left":
|
|
3683
|
-
return
|
|
3786
|
+
return he(r, t.index, e);
|
|
3684
3787
|
case "insert-col-right":
|
|
3685
|
-
return
|
|
3788
|
+
return he(r, t.index + 1, e);
|
|
3686
3789
|
case "move-row":
|
|
3687
|
-
return
|
|
3790
|
+
return Os(r, t.fromIndex, t.toIndex, e);
|
|
3688
3791
|
case "move-col":
|
|
3689
|
-
return
|
|
3792
|
+
return Ns(r, t.fromIndex, t.toIndex, e);
|
|
3690
3793
|
case "delete-row":
|
|
3691
|
-
return
|
|
3794
|
+
return _s(r, t.index, e);
|
|
3692
3795
|
case "delete-col":
|
|
3693
|
-
return
|
|
3796
|
+
return Ms(r, t.index, e);
|
|
3694
3797
|
case "toggle-heading":
|
|
3695
3798
|
return {
|
|
3696
3799
|
pendingHighlight: { type: "row", index: 0 },
|
|
@@ -3708,9 +3811,9 @@ const se = (r, t, e) => (e.grid.addRow(r, t), O(r, e.cellBlocks), {
|
|
|
3708
3811
|
withHeadingColumn: !e.data.withHeadingColumn
|
|
3709
3812
|
};
|
|
3710
3813
|
}
|
|
3711
|
-
},
|
|
3712
|
-
const t = r.querySelector(`[${
|
|
3713
|
-
return t ? Array.from(t.querySelectorAll(`[${
|
|
3814
|
+
}, ue = 10, Ws = "data-blok-table-drag-ghost", Pt = (r) => {
|
|
3815
|
+
const t = r.querySelector(`[${y}]`);
|
|
3816
|
+
return t ? Array.from(t.querySelectorAll(`[${b}]`)).reduce(
|
|
3714
3817
|
(n, o) => {
|
|
3715
3818
|
const s = n[n.length - 1];
|
|
3716
3819
|
return [...n, s + o.offsetWidth];
|
|
@@ -3718,7 +3821,7 @@ const se = (r, t, e) => (e.grid.addRow(r, t), O(r, e.cellBlocks), {
|
|
|
3718
3821
|
[0]
|
|
3719
3822
|
) : [0];
|
|
3720
3823
|
};
|
|
3721
|
-
class
|
|
3824
|
+
class $s {
|
|
3722
3825
|
constructor(t) {
|
|
3723
3826
|
var e;
|
|
3724
3827
|
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 = t.grid, this.onAction = t.onAction, this.onDragStateChange = (e = t.onDragStateChange) != null ? e : null, this.boundDocPointerMove = this.handleDocPointerMove.bind(this), this.boundDocPointerUp = this.handleDocPointerUp.bind(this), this.boundDocPointerCancel = this.handleDocPointerCancel.bind(this);
|
|
@@ -3742,7 +3845,7 @@ class ws {
|
|
|
3742
3845
|
}
|
|
3743
3846
|
handleDocPointerMove(t) {
|
|
3744
3847
|
const e = Math.abs(t.clientX - this.dragStartX), n = Math.abs(t.clientY - this.dragStartY);
|
|
3745
|
-
!this.isDragging && (e >
|
|
3848
|
+
!this.isDragging && (e > ue || n > ue) && (this.isDragging = !0, this.startDrag()), this.isDragging && (this.updateDragIndicator(t), this.updateGhostPosition(t));
|
|
3746
3849
|
}
|
|
3747
3850
|
handleDocPointerUp(t) {
|
|
3748
3851
|
var e, n;
|
|
@@ -3761,7 +3864,7 @@ class ws {
|
|
|
3761
3864
|
this.grid.style.userSelect = "none", document.body.style.cursor = "grabbing", (t = this.onDragStateChange) == null || t.call(this, !0, this.dragType), this.highlightSourceCells(), this.createDropIndicator(), this.createGhost();
|
|
3762
3865
|
}
|
|
3763
3866
|
highlightSourceCells() {
|
|
3764
|
-
const t = this.grid.querySelectorAll(`[${
|
|
3867
|
+
const t = this.grid.querySelectorAll(`[${y}]`);
|
|
3765
3868
|
if (this.dragType === "row") {
|
|
3766
3869
|
this.highlightRowCells(t);
|
|
3767
3870
|
return;
|
|
@@ -3772,14 +3875,14 @@ class ws {
|
|
|
3772
3875
|
const e = t[this.dragFromIndex];
|
|
3773
3876
|
if (!e)
|
|
3774
3877
|
return;
|
|
3775
|
-
e.querySelectorAll(`[${
|
|
3878
|
+
e.querySelectorAll(`[${b}]`).forEach((o) => {
|
|
3776
3879
|
const s = o;
|
|
3777
3880
|
s.style.backgroundColor = "#f3f4f6", s.style.opacity = "0.7", this.dragOverlayCells.push(s);
|
|
3778
3881
|
});
|
|
3779
3882
|
}
|
|
3780
3883
|
highlightColumnCells(t) {
|
|
3781
3884
|
t.forEach((e) => {
|
|
3782
|
-
const n = e.querySelectorAll(`[${
|
|
3885
|
+
const n = e.querySelectorAll(`[${b}]`);
|
|
3783
3886
|
if (this.dragFromIndex >= n.length)
|
|
3784
3887
|
return;
|
|
3785
3888
|
const o = n[this.dragFromIndex];
|
|
@@ -3790,10 +3893,10 @@ class ws {
|
|
|
3790
3893
|
this.dropIndicator = document.createElement("div");
|
|
3791
3894
|
const t = this.dropIndicator.style;
|
|
3792
3895
|
if (t.position = "absolute", t.backgroundColor = "#3b82f6", t.borderRadius = "1.5px", t.zIndex = "5", t.pointerEvents = "none", this.dropIndicator.setAttribute("contenteditable", "false"), this.dragType === "row")
|
|
3793
|
-
t.height = "3px", t.left = `${
|
|
3896
|
+
t.height = "3px", t.left = `${-q}px`, t.right = "0", t.transition = "top 100ms ease";
|
|
3794
3897
|
else {
|
|
3795
|
-
const e = this.grid.querySelectorAll(`[${
|
|
3796
|
-
t.width = "3px", t.top = `${
|
|
3898
|
+
const e = this.grid.querySelectorAll(`[${y}]`), n = e[e.length - 1], o = n ? n.offsetTop + n.offsetHeight : 0;
|
|
3899
|
+
t.width = "3px", t.top = `${-q}px`, t.height = `${o + q}px`, t.transition = "left 100ms ease";
|
|
3797
3900
|
}
|
|
3798
3901
|
this.grid.appendChild(this.dropIndicator);
|
|
3799
3902
|
}
|
|
@@ -3817,7 +3920,7 @@ class ws {
|
|
|
3817
3920
|
var i;
|
|
3818
3921
|
if (!this.dropIndicator)
|
|
3819
3922
|
return;
|
|
3820
|
-
const n = t.clientX - e.left, o = this.getColDropIndex(n), s =
|
|
3923
|
+
const n = t.clientX - e.left, o = this.getColDropIndex(n), s = Pt(this.grid);
|
|
3821
3924
|
this.dropIndicator.style.left = `${((i = s[o]) != null ? i : 0) - 1.5}px`;
|
|
3822
3925
|
}
|
|
3823
3926
|
finishDrag(t) {
|
|
@@ -3838,7 +3941,7 @@ class ws {
|
|
|
3838
3941
|
}
|
|
3839
3942
|
createGhost() {
|
|
3840
3943
|
const t = document.createElement("div");
|
|
3841
|
-
t.setAttribute(
|
|
3944
|
+
t.setAttribute(Ws, ""), t.setAttribute("contenteditable", "false");
|
|
3842
3945
|
const e = t.style;
|
|
3843
3946
|
e.position = "fixed", e.pointerEvents = "none", e.opacity = "0.5", e.zIndex = "50", e.borderRadius = "4px", e.overflow = "hidden", e.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", this.ghostEl = t;
|
|
3844
3947
|
const n = this.getSourceRect();
|
|
@@ -3849,25 +3952,25 @@ class ws {
|
|
|
3849
3952
|
}
|
|
3850
3953
|
getRowSourceRect() {
|
|
3851
3954
|
var n;
|
|
3852
|
-
const e = this.grid.querySelectorAll(`[${
|
|
3955
|
+
const e = this.grid.querySelectorAll(`[${y}]`)[this.dragFromIndex];
|
|
3853
3956
|
return (n = e == null ? void 0 : e.getBoundingClientRect()) != null ? n : null;
|
|
3854
3957
|
}
|
|
3855
3958
|
getColSourceRect() {
|
|
3856
|
-
const t = this.grid.querySelectorAll(`[${
|
|
3959
|
+
const t = this.grid.querySelectorAll(`[${y}]`), e = t[0], n = t[t.length - 1];
|
|
3857
3960
|
if (!e || !n)
|
|
3858
3961
|
return null;
|
|
3859
|
-
const o = e.querySelectorAll(`[${
|
|
3962
|
+
const o = e.querySelectorAll(`[${b}]`)[this.dragFromIndex], s = n.querySelectorAll(`[${b}]`)[this.dragFromIndex];
|
|
3860
3963
|
if (!o || !s)
|
|
3861
3964
|
return null;
|
|
3862
3965
|
const i = o.getBoundingClientRect(), l = s.getBoundingClientRect();
|
|
3863
3966
|
return new DOMRect(i.left, i.top, i.width, l.bottom - i.top);
|
|
3864
3967
|
}
|
|
3865
3968
|
buildRowGhost() {
|
|
3866
|
-
const e = this.grid.querySelectorAll(`[${
|
|
3969
|
+
const e = this.grid.querySelectorAll(`[${y}]`)[this.dragFromIndex];
|
|
3867
3970
|
if (!e || !this.ghostEl)
|
|
3868
3971
|
return;
|
|
3869
3972
|
const n = this.ghostEl.style;
|
|
3870
|
-
n.display = "flex", n.height = `${e.offsetHeight}px`, e.querySelectorAll(`[${
|
|
3973
|
+
n.display = "flex", n.height = `${e.offsetHeight}px`, e.querySelectorAll(`[${b}]`).forEach((s) => {
|
|
3871
3974
|
var a;
|
|
3872
3975
|
const i = s, l = i.cloneNode(!0);
|
|
3873
3976
|
l.style.width = `${i.offsetWidth}px`, l.style.flexShrink = "0", l.removeAttribute("contenteditable"), (a = this.ghostEl) == null || a.appendChild(l);
|
|
@@ -3876,10 +3979,10 @@ class ws {
|
|
|
3876
3979
|
buildColumnGhost() {
|
|
3877
3980
|
if (!this.ghostEl)
|
|
3878
3981
|
return;
|
|
3879
|
-
const t = this.grid.querySelectorAll(`[${
|
|
3982
|
+
const t = this.grid.querySelectorAll(`[${y}]`), e = this.ghostEl.style;
|
|
3880
3983
|
e.display = "flex", e.flexDirection = "column", t.forEach((n) => {
|
|
3881
3984
|
var l;
|
|
3882
|
-
const o = n.querySelectorAll(`[${
|
|
3985
|
+
const o = n.querySelectorAll(`[${b}]`);
|
|
3883
3986
|
if (this.dragFromIndex >= o.length)
|
|
3884
3987
|
return;
|
|
3885
3988
|
const s = o[this.dragFromIndex], i = s.cloneNode(!0);
|
|
@@ -3893,7 +3996,7 @@ class ws {
|
|
|
3893
3996
|
this.dragType === "row" && (e.top = `${t.clientY - this.ghostOffsetY}px`), this.dragType === "col" && (e.left = `${t.clientX - this.ghostOffsetX}px`);
|
|
3894
3997
|
}
|
|
3895
3998
|
getRowDropIndex(t) {
|
|
3896
|
-
const e = Array.from(this.grid.querySelectorAll(`[${
|
|
3999
|
+
const e = Array.from(this.grid.querySelectorAll(`[${y}]`)), n = e.map((i) => i.offsetTop);
|
|
3897
4000
|
if (e.length > 0) {
|
|
3898
4001
|
const i = e[e.length - 1];
|
|
3899
4002
|
n.push(i.offsetTop + i.offsetHeight);
|
|
@@ -3902,7 +4005,7 @@ class ws {
|
|
|
3902
4005
|
return o.indexOf(s);
|
|
3903
4006
|
}
|
|
3904
4007
|
getRowDropTopPx(t) {
|
|
3905
|
-
const e = this.grid.querySelectorAll(`[${
|
|
4008
|
+
const e = this.grid.querySelectorAll(`[${y}]`);
|
|
3906
4009
|
if (t < e.length)
|
|
3907
4010
|
return e[t].offsetTop;
|
|
3908
4011
|
if (e.length > 0) {
|
|
@@ -3912,11 +4015,11 @@ class ws {
|
|
|
3912
4015
|
return 0;
|
|
3913
4016
|
}
|
|
3914
4017
|
getColDropIndex(t) {
|
|
3915
|
-
const n =
|
|
4018
|
+
const n = Pt(this.grid).map((s) => Math.abs(t - s)), o = Math.min(...n);
|
|
3916
4019
|
return n.indexOf(o);
|
|
3917
4020
|
}
|
|
3918
4021
|
}
|
|
3919
|
-
const
|
|
4022
|
+
const Fs = [
|
|
3920
4023
|
"flex",
|
|
3921
4024
|
"items-center",
|
|
3922
4025
|
"select-none",
|
|
@@ -3928,7 +4031,7 @@ const ks = [
|
|
|
3928
4031
|
"mb-px",
|
|
3929
4032
|
"cursor-pointer",
|
|
3930
4033
|
"can-hover:hover:bg-item-hover-bg"
|
|
3931
|
-
],
|
|
4034
|
+
], qs = [
|
|
3932
4035
|
"flex",
|
|
3933
4036
|
"items-center",
|
|
3934
4037
|
"justify-center",
|
|
@@ -3937,13 +4040,13 @@ const ks = [
|
|
|
3937
4040
|
"mr-2",
|
|
3938
4041
|
"[&_svg]:w-icon",
|
|
3939
4042
|
"[&_svg]:h-icon"
|
|
3940
|
-
],
|
|
4043
|
+
], zs = [
|
|
3941
4044
|
"mr-auto",
|
|
3942
4045
|
"truncate",
|
|
3943
4046
|
"text-sm",
|
|
3944
4047
|
"font-medium",
|
|
3945
4048
|
"leading-5"
|
|
3946
|
-
],
|
|
4049
|
+
], Vs = [
|
|
3947
4050
|
"relative",
|
|
3948
4051
|
"w-[34px]",
|
|
3949
4052
|
"h-[20px]",
|
|
@@ -3951,7 +4054,7 @@ const ks = [
|
|
|
3951
4054
|
"transition-colors",
|
|
3952
4055
|
"duration-200",
|
|
3953
4056
|
"shrink-0"
|
|
3954
|
-
],
|
|
4057
|
+
], Ks = [
|
|
3955
4058
|
"absolute",
|
|
3956
4059
|
"top-[2px]",
|
|
3957
4060
|
"w-4",
|
|
@@ -3961,29 +4064,29 @@ const ks = [
|
|
|
3961
4064
|
"shadow-xs",
|
|
3962
4065
|
"transition-[left]",
|
|
3963
4066
|
"duration-200"
|
|
3964
|
-
],
|
|
4067
|
+
], Ve = (r) => {
|
|
3965
4068
|
const { icon: t, label: e, isActive: n, onToggle: o } = r, s = { active: n }, i = document.createElement("div");
|
|
3966
|
-
i.className = w(
|
|
4069
|
+
i.className = w(Fs);
|
|
3967
4070
|
const l = document.createElement("div");
|
|
3968
|
-
l.className = w(
|
|
4071
|
+
l.className = w(qs), l.innerHTML = t, i.appendChild(l);
|
|
3969
4072
|
const a = document.createElement("span");
|
|
3970
|
-
a.className = w(
|
|
4073
|
+
a.className = w(zs), a.textContent = e, i.appendChild(a);
|
|
3971
4074
|
const c = document.createElement("div");
|
|
3972
|
-
c.className = w(
|
|
4075
|
+
c.className = w(Vs);
|
|
3973
4076
|
const d = document.createElement("div");
|
|
3974
|
-
d.className = w(
|
|
4077
|
+
d.className = w(Ks), c.appendChild(d), i.appendChild(c);
|
|
3975
4078
|
const h = () => {
|
|
3976
4079
|
c.style.backgroundColor = s.active ? "#3b82f6" : "#d1d5db", d.style.left = s.active ? "16px" : "2px";
|
|
3977
4080
|
};
|
|
3978
4081
|
return h(), i.addEventListener("click", (u) => {
|
|
3979
4082
|
u.stopPropagation(), s.active = !s.active, h(), o(s.active);
|
|
3980
4083
|
}), i;
|
|
3981
|
-
},
|
|
4084
|
+
}, Us = (r, t) => {
|
|
3982
4085
|
const e = r === 0 ? [
|
|
3983
4086
|
{
|
|
3984
|
-
type:
|
|
3985
|
-
element:
|
|
3986
|
-
icon:
|
|
4087
|
+
type: F.Html,
|
|
4088
|
+
element: Ve({
|
|
4089
|
+
icon: kn,
|
|
3987
4090
|
label: t.i18n.t("tools.table.headerColumn"),
|
|
3988
4091
|
isActive: t.isHeadingColumn(),
|
|
3989
4092
|
onToggle: () => {
|
|
@@ -3991,10 +4094,10 @@ const ks = [
|
|
|
3991
4094
|
}
|
|
3992
4095
|
})
|
|
3993
4096
|
},
|
|
3994
|
-
{ type:
|
|
4097
|
+
{ type: F.Separator }
|
|
3995
4098
|
] : [], n = [
|
|
3996
4099
|
{
|
|
3997
|
-
icon:
|
|
4100
|
+
icon: yn,
|
|
3998
4101
|
title: t.i18n.t("tools.table.insertColumnLeft"),
|
|
3999
4102
|
closeOnActivate: !0,
|
|
4000
4103
|
onActivate: () => {
|
|
@@ -4002,7 +4105,7 @@ const ks = [
|
|
|
4002
4105
|
}
|
|
4003
4106
|
},
|
|
4004
4107
|
{
|
|
4005
|
-
icon:
|
|
4108
|
+
icon: vn,
|
|
4006
4109
|
title: t.i18n.t("tools.table.insertColumnRight"),
|
|
4007
4110
|
closeOnActivate: !0,
|
|
4008
4111
|
onActivate: () => {
|
|
@@ -4010,9 +4113,9 @@ const ks = [
|
|
|
4010
4113
|
}
|
|
4011
4114
|
}
|
|
4012
4115
|
], o = t.getColumnCount() > 1, s = [
|
|
4013
|
-
{ type:
|
|
4116
|
+
{ type: F.Separator },
|
|
4014
4117
|
{
|
|
4015
|
-
icon:
|
|
4118
|
+
icon: Re,
|
|
4016
4119
|
title: t.i18n.t("tools.table.deleteColumn"),
|
|
4017
4120
|
isDestructive: !0,
|
|
4018
4121
|
isDisabled: !o,
|
|
@@ -4023,12 +4126,12 @@ const ks = [
|
|
|
4023
4126
|
}
|
|
4024
4127
|
];
|
|
4025
4128
|
return [...e, ...n, ...s];
|
|
4026
|
-
},
|
|
4129
|
+
}, js = (r, t) => {
|
|
4027
4130
|
const e = r === 0 ? [
|
|
4028
4131
|
{
|
|
4029
|
-
type:
|
|
4030
|
-
element:
|
|
4031
|
-
icon:
|
|
4132
|
+
type: F.Html,
|
|
4133
|
+
element: Ve({
|
|
4134
|
+
icon: En,
|
|
4032
4135
|
label: t.i18n.t("tools.table.headerRow"),
|
|
4033
4136
|
isActive: t.isHeadingRow(),
|
|
4034
4137
|
onToggle: () => {
|
|
@@ -4036,10 +4139,10 @@ const ks = [
|
|
|
4036
4139
|
}
|
|
4037
4140
|
})
|
|
4038
4141
|
},
|
|
4039
|
-
{ type:
|
|
4142
|
+
{ type: F.Separator }
|
|
4040
4143
|
] : [], n = [
|
|
4041
4144
|
{
|
|
4042
|
-
icon:
|
|
4145
|
+
icon: Sn,
|
|
4043
4146
|
title: t.i18n.t("tools.table.insertRowAbove"),
|
|
4044
4147
|
closeOnActivate: !0,
|
|
4045
4148
|
onActivate: () => {
|
|
@@ -4047,7 +4150,7 @@ const ks = [
|
|
|
4047
4150
|
}
|
|
4048
4151
|
},
|
|
4049
4152
|
{
|
|
4050
|
-
icon:
|
|
4153
|
+
icon: wn,
|
|
4051
4154
|
title: t.i18n.t("tools.table.insertRowBelow"),
|
|
4052
4155
|
closeOnActivate: !0,
|
|
4053
4156
|
onActivate: () => {
|
|
@@ -4055,9 +4158,9 @@ const ks = [
|
|
|
4055
4158
|
}
|
|
4056
4159
|
}
|
|
4057
4160
|
], o = t.getRowCount() > 1, s = [
|
|
4058
|
-
{ type:
|
|
4161
|
+
{ type: F.Separator },
|
|
4059
4162
|
{
|
|
4060
|
-
icon:
|
|
4163
|
+
icon: Re,
|
|
4061
4164
|
title: t.i18n.t("tools.table.deleteRow"),
|
|
4062
4165
|
isDestructive: !0,
|
|
4063
4166
|
isDisabled: !o,
|
|
@@ -4068,21 +4171,21 @@ const ks = [
|
|
|
4068
4171
|
}
|
|
4069
4172
|
];
|
|
4070
4173
|
return [...e, ...n, ...s];
|
|
4071
|
-
},
|
|
4174
|
+
}, Ys = (r, t, e, n, o) => {
|
|
4072
4175
|
o.destroyPopover(), o.clearHideTimeout();
|
|
4073
4176
|
const s = r === "col" ? e.col[t] : e.row[t];
|
|
4074
4177
|
if (!s)
|
|
4075
4178
|
return { popover: null, grip: null };
|
|
4076
|
-
const i = r === "col" ?
|
|
4179
|
+
const i = r === "col" ? Us(t, n) : js(t, n), l = new xe({
|
|
4077
4180
|
items: i,
|
|
4078
4181
|
trigger: s,
|
|
4079
4182
|
flippable: !0
|
|
4080
4183
|
});
|
|
4081
|
-
return l.on(
|
|
4184
|
+
return l.on(Te.Closed, () => {
|
|
4082
4185
|
var a;
|
|
4083
4186
|
o.destroyPopover(), o.applyVisibleClasses(s), o.scheduleHideAll(), (a = o.onGripPopoverClose) == null || a.call(o);
|
|
4084
|
-
}), o.hideAllGripsExcept(s), o.applyActiveClasses(s), r === "col" ? s.style.height = `${
|
|
4085
|
-
},
|
|
4187
|
+
}), o.hideAllGripsExcept(s), o.applyActiveClasses(s), r === "col" ? s.style.height = `${j}px` : s.style.width = `${j}px`, { popover: l, grip: s };
|
|
4188
|
+
}, pe = "data-blok-table-grip", ft = "data-blok-table-grip-col", ge = "data-blok-table-grip-row", Xs = 150, Zs = 24, mt = 4, Ct = 4, Js = 20, bt = [
|
|
4086
4189
|
"absolute",
|
|
4087
4190
|
"z-3",
|
|
4088
4191
|
"rounded-sm",
|
|
@@ -4095,23 +4198,23 @@ const ks = [
|
|
|
4095
4198
|
"items-center",
|
|
4096
4199
|
"justify-center",
|
|
4097
4200
|
"overflow-hidden"
|
|
4098
|
-
],
|
|
4201
|
+
], fe = [
|
|
4099
4202
|
"bg-gray-300",
|
|
4100
4203
|
"opacity-0",
|
|
4101
4204
|
"pointer-events-none"
|
|
4102
|
-
],
|
|
4205
|
+
], Qs = [
|
|
4103
4206
|
"bg-gray-300",
|
|
4104
4207
|
"opacity-100",
|
|
4105
4208
|
"pointer-events-auto"
|
|
4106
|
-
],
|
|
4209
|
+
], ti = [
|
|
4107
4210
|
"bg-blue-500",
|
|
4108
4211
|
"text-white",
|
|
4109
4212
|
"opacity-100",
|
|
4110
4213
|
"pointer-events-auto"
|
|
4111
4214
|
];
|
|
4112
|
-
class
|
|
4215
|
+
class ei {
|
|
4113
4216
|
constructor(t) {
|
|
4114
|
-
this.colGrips = [], this.rowGrips = [], this.popoverState = { popover: null, grip: null }, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.boundScrollHandler = null, this.grid = t.grid, this.overlay = t.overlay, this.scrollContainer = t.scrollContainer, this.getColumnCount = t.getColumnCount, this.getRowCount = t.getRowCount, this.isHeadingRow = t.isHeadingRow, this.isHeadingColumn = t.isHeadingColumn, this.onAction = t.onAction, this.onGripClick = t.onGripClick, this.onGripPopoverClose = t.onGripPopoverClose, this.i18n = t.i18n, this.drag = new
|
|
4217
|
+
this.colGrips = [], this.rowGrips = [], this.popoverState = { popover: null, grip: null }, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.boundScrollHandler = null, this.grid = t.grid, this.overlay = t.overlay, this.scrollContainer = t.scrollContainer, this.getColumnCount = t.getColumnCount, this.getRowCount = t.getRowCount, this.isHeadingRow = t.isHeadingRow, this.isHeadingColumn = t.isHeadingColumn, this.onAction = t.onAction, this.onGripClick = t.onGripClick, this.onGripPopoverClose = t.onGripPopoverClose, this.i18n = t.i18n, this.drag = new $s({
|
|
4115
4218
|
grid: this.grid,
|
|
4116
4219
|
onAction: this.onAction,
|
|
4117
4220
|
onDragStateChange: (e, n) => {
|
|
@@ -4130,7 +4233,7 @@ class Os {
|
|
|
4130
4233
|
if (this.destroyGrips(), this.createGrips(), !t)
|
|
4131
4234
|
return;
|
|
4132
4235
|
const e = t.type === "col" ? this.colGrips[t.index] : this.rowGrips[t.index];
|
|
4133
|
-
e && (this.popoverState.grip = e, this.hideAllGripsExcept(e), this.applyActiveClasses(e), t.type === "col" ? e.style.height = `${
|
|
4236
|
+
e && (this.popoverState.grip = e, this.hideAllGripsExcept(e), this.applyActiveClasses(e), t.type === "col" ? e.style.height = `${j}px` : e.style.width = `${j}px`);
|
|
4134
4237
|
}
|
|
4135
4238
|
/**
|
|
4136
4239
|
* Set a specific grip to active (blue) state without opening the popover.
|
|
@@ -4138,11 +4241,11 @@ class Os {
|
|
|
4138
4241
|
*/
|
|
4139
4242
|
setActiveGrip(t, e) {
|
|
4140
4243
|
const n = t === "col" ? this.colGrips[e] : this.rowGrips[e];
|
|
4141
|
-
n && (this.unlockGrip(), this.clearHideTimeout(), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${
|
|
4244
|
+
n && (this.unlockGrip(), this.clearHideTimeout(), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${j}px` : n.style.width = `${j}px`, this.lockedGrip = n, document.addEventListener("pointerdown", this.boundUnlockGrip));
|
|
4142
4245
|
}
|
|
4143
4246
|
handleUnlockGrip(t) {
|
|
4144
4247
|
document.removeEventListener("pointerdown", this.boundUnlockGrip), this.lockedGrip && (this.applyIdleClasses(this.lockedGrip), this.lockedGrip = null);
|
|
4145
|
-
const e = t.target instanceof HTMLElement ? t.target : null, n = e == null ? void 0 : e.closest(`[${
|
|
4248
|
+
const e = t.target instanceof HTMLElement ? t.target : null, n = e == null ? void 0 : e.closest(`[${b}]`);
|
|
4146
4249
|
if (n) {
|
|
4147
4250
|
const o = this.getCellPosition(n);
|
|
4148
4251
|
o && (this.clearHideTimeout(), this.showColGrip(o.col), this.showRowGrip(o.row), this.isInsideTable = !0);
|
|
@@ -4192,12 +4295,12 @@ class Os {
|
|
|
4192
4295
|
}
|
|
4193
4296
|
createGripElement(t, e) {
|
|
4194
4297
|
const n = document.createElement("div");
|
|
4195
|
-
n.className = w(
|
|
4196
|
-
const o = t === "col" ?
|
|
4197
|
-
return n.style.width = `${o}px`, n.style.height = `${s}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid white", n.appendChild(
|
|
4198
|
-
this.overlay && this.clearHideTimeout(), this.isGripInteractionLocked() ||
|
|
4298
|
+
n.className = w(bt, fe), n.setAttribute(pe, ""), n.setAttribute(t === "col" ? ft : ge, String(e)), n.setAttribute("contenteditable", "false");
|
|
4299
|
+
const o = t === "col" ? Zs : Ct, s = t === "col" ? mt : Js, i = t === "col" ? mt : Ct;
|
|
4300
|
+
return n.style.width = `${o}px`, n.style.height = `${s}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid white", n.appendChild(Fe(t === "col" ? "horizontal" : "vertical")), n.addEventListener("pointerdown", this.boundPointerDown), n.addEventListener("mouseenter", () => {
|
|
4301
|
+
this.overlay && this.clearHideTimeout(), this.isGripInteractionLocked() || us(n, t);
|
|
4199
4302
|
}), n.addEventListener("mouseleave", () => {
|
|
4200
|
-
this.isGripInteractionLocked() || (
|
|
4303
|
+
this.isGripInteractionLocked() || (Et(n, t, i), this.overlay && this.scheduleHideAll());
|
|
4201
4304
|
}), n;
|
|
4202
4305
|
}
|
|
4203
4306
|
/**
|
|
@@ -4205,20 +4308,20 @@ class Os {
|
|
|
4205
4308
|
* Called after resize or structural changes.
|
|
4206
4309
|
*/
|
|
4207
4310
|
positionGrips() {
|
|
4208
|
-
const t = this.grid.querySelectorAll(`[${
|
|
4311
|
+
const t = this.grid.querySelectorAll(`[${y}]`);
|
|
4209
4312
|
if (!t[0])
|
|
4210
4313
|
return;
|
|
4211
|
-
const n =
|
|
4314
|
+
const n = Pt(this.grid), o = this.overlay && this.scrollContainer ? this.scrollContainer.scrollLeft : 0, s = this.overlay && this.scrollContainer ? this.scrollContainer.clientWidth : 1 / 0;
|
|
4212
4315
|
this.colGrips.forEach((i, l) => {
|
|
4213
4316
|
if (l + 1 >= n.length)
|
|
4214
4317
|
return;
|
|
4215
4318
|
const c = (n[l] + n[l + 1]) / 2 - o, d = i.style;
|
|
4216
|
-
d.top = `${
|
|
4319
|
+
d.top = `${-q / 2}px`, d.left = `${c}px`, this.overlay && (d.visibility = c < 0 || c > s ? "hidden" : "");
|
|
4217
4320
|
}), this.rowGrips.forEach((i, l) => {
|
|
4218
4321
|
if (l >= t.length)
|
|
4219
4322
|
return;
|
|
4220
4323
|
const a = t[l], c = a.offsetTop + a.offsetHeight / 2, d = i.style;
|
|
4221
|
-
d.left = `${
|
|
4324
|
+
d.left = `${-q / 2}px`, d.top = `${c}px`;
|
|
4222
4325
|
});
|
|
4223
4326
|
}
|
|
4224
4327
|
/**
|
|
@@ -4228,7 +4331,7 @@ class Os {
|
|
|
4228
4331
|
var e;
|
|
4229
4332
|
(e = this.rowResizeObserver) == null || e.disconnect(), this.rowResizeObserver = new ResizeObserver(() => {
|
|
4230
4333
|
this.positionGrips();
|
|
4231
|
-
}), this.grid.querySelectorAll(`[${
|
|
4334
|
+
}), this.grid.querySelectorAll(`[${y}]`).forEach((n) => {
|
|
4232
4335
|
var o;
|
|
4233
4336
|
(o = this.rowResizeObserver) == null || o.observe(n);
|
|
4234
4337
|
});
|
|
@@ -4239,7 +4342,7 @@ class Os {
|
|
|
4239
4342
|
handleMouseOver(t) {
|
|
4240
4343
|
if (this.isGripInteractionLocked())
|
|
4241
4344
|
return;
|
|
4242
|
-
const n = t.target.closest(`[${
|
|
4345
|
+
const n = t.target.closest(`[${b}]`);
|
|
4243
4346
|
if (!n)
|
|
4244
4347
|
return;
|
|
4245
4348
|
this.clearHideTimeout();
|
|
@@ -4250,13 +4353,13 @@ class Os {
|
|
|
4250
4353
|
this.isGripInteractionLocked() || this.scheduleHideAll();
|
|
4251
4354
|
}
|
|
4252
4355
|
getCellPosition(t) {
|
|
4253
|
-
const e = t.closest(`[${
|
|
4356
|
+
const e = t.closest(`[${y}]`);
|
|
4254
4357
|
if (!e)
|
|
4255
4358
|
return null;
|
|
4256
|
-
const o = Array.from(this.grid.querySelectorAll(`[${
|
|
4359
|
+
const o = Array.from(this.grid.querySelectorAll(`[${y}]`)).indexOf(e);
|
|
4257
4360
|
if (o < 0)
|
|
4258
4361
|
return null;
|
|
4259
|
-
const i = Array.from(e.querySelectorAll(`[${
|
|
4362
|
+
const i = Array.from(e.querySelectorAll(`[${b}]`)).indexOf(t);
|
|
4260
4363
|
return i < 0 ? null : { row: o, col: i };
|
|
4261
4364
|
}
|
|
4262
4365
|
/**
|
|
@@ -4290,13 +4393,13 @@ class Os {
|
|
|
4290
4393
|
this.activeRowGripIndex >= 0 && this.activeRowGripIndex < this.rowGrips.length && this.applyIdleClasses(this.rowGrips[this.activeRowGripIndex]), this.activeRowGripIndex = -1;
|
|
4291
4394
|
}
|
|
4292
4395
|
applyVisibleClasses(t) {
|
|
4293
|
-
const e = t, n = e.hasAttribute(
|
|
4294
|
-
|
|
4396
|
+
const e = t, n = e.hasAttribute(ft);
|
|
4397
|
+
Et(e, n ? "col" : "row", n ? mt : Ct), this.isInsideTable && (e.style.transition = "none"), e.className = w(bt, Qs), e.setAttribute("data-blok-table-grip-visible", ""), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
|
|
4295
4398
|
const i = e.querySelector("svg");
|
|
4296
4399
|
i && (i.classList.remove("text-white"), i.classList.add("text-gray-400"));
|
|
4297
4400
|
}
|
|
4298
4401
|
applyActiveClasses(t) {
|
|
4299
|
-
Object.assign(t, { className: w(
|
|
4402
|
+
Object.assign(t, { className: w(bt, ti) }), t.setAttribute("data-blok-table-grip-visible", "");
|
|
4300
4403
|
const e = t.querySelector("svg");
|
|
4301
4404
|
e && (e.classList.remove("text-gray-400", "opacity-0"), e.classList.add("text-white", "opacity-100"));
|
|
4302
4405
|
}
|
|
@@ -4306,8 +4409,8 @@ class Os {
|
|
|
4306
4409
|
});
|
|
4307
4410
|
}
|
|
4308
4411
|
applyIdleClasses(t) {
|
|
4309
|
-
const e = t, n = e.hasAttribute(
|
|
4310
|
-
this.isInsideTable && (e.style.transition = "none"),
|
|
4412
|
+
const e = t, n = e.hasAttribute(ft), o = n ? "col" : "row", s = 12, i = n ? mt + s : Ct + s;
|
|
4413
|
+
this.isInsideTable && (e.style.transition = "none"), Et(e, o, i), e.className = w(bt, fe), e.removeAttribute("data-blok-table-grip-visible"), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
|
|
4311
4414
|
}
|
|
4312
4415
|
handleDragStateChange(t, e) {
|
|
4313
4416
|
[...this.colGrips, ...this.rowGrips].forEach((n) => {
|
|
@@ -4318,14 +4421,14 @@ class Os {
|
|
|
4318
4421
|
scheduleHideAll() {
|
|
4319
4422
|
this.hideTimeout = setTimeout(() => {
|
|
4320
4423
|
this.hideColGrip(), this.hideRowGrip(), this.isInsideTable = !1, this.hideTimeout = null;
|
|
4321
|
-
},
|
|
4424
|
+
}, Xs);
|
|
4322
4425
|
}
|
|
4323
4426
|
clearHideTimeout() {
|
|
4324
4427
|
this.hideTimeout !== null && (clearTimeout(this.hideTimeout), this.hideTimeout = null);
|
|
4325
4428
|
}
|
|
4326
4429
|
// ── Click / Drag discrimination ──────────────────────────────
|
|
4327
4430
|
handlePointerDown(t) {
|
|
4328
|
-
const n = t.target.closest(`[${
|
|
4431
|
+
const n = t.target.closest(`[${pe}]`);
|
|
4329
4432
|
if (!n)
|
|
4330
4433
|
return;
|
|
4331
4434
|
t.preventDefault(), t.stopPropagation();
|
|
@@ -4335,16 +4438,16 @@ class Os {
|
|
|
4335
4438
|
});
|
|
4336
4439
|
}
|
|
4337
4440
|
detectGripType(t) {
|
|
4338
|
-
const e = t.getAttribute(
|
|
4441
|
+
const e = t.getAttribute(ft);
|
|
4339
4442
|
if (e !== null)
|
|
4340
4443
|
return { type: "col", index: Number(e) };
|
|
4341
|
-
const n = t.getAttribute(
|
|
4444
|
+
const n = t.getAttribute(ge);
|
|
4342
4445
|
return n !== null ? { type: "row", index: Number(n) } : null;
|
|
4343
4446
|
}
|
|
4344
4447
|
// ── Popover menus ────────────────────────────────────────────
|
|
4345
4448
|
openPopover(t, e) {
|
|
4346
4449
|
var n, o;
|
|
4347
|
-
this.popoverState =
|
|
4450
|
+
this.popoverState = Ys(
|
|
4348
4451
|
t,
|
|
4349
4452
|
e,
|
|
4350
4453
|
{ col: this.colGrips, row: this.rowGrips },
|
|
@@ -4374,7 +4477,7 @@ class Os {
|
|
|
4374
4477
|
}
|
|
4375
4478
|
}
|
|
4376
4479
|
}
|
|
4377
|
-
const
|
|
4480
|
+
const ni = "data-blok-table-haze", me = "data-blok-table-haze-visible", Rt = 1, oi = [
|
|
4378
4481
|
"absolute",
|
|
4379
4482
|
"top-0",
|
|
4380
4483
|
"bottom-0",
|
|
@@ -4384,18 +4487,18 @@ const Ms = "data-blok-table-haze", de = "data-blok-table-haze-visible", xt = 1,
|
|
|
4384
4487
|
"transition-opacity",
|
|
4385
4488
|
"duration-150",
|
|
4386
4489
|
"z-1"
|
|
4387
|
-
],
|
|
4490
|
+
], si = [
|
|
4388
4491
|
"left-0",
|
|
4389
4492
|
"bg-linear-to-r",
|
|
4390
4493
|
"from-white/80",
|
|
4391
4494
|
"to-transparent"
|
|
4392
|
-
],
|
|
4495
|
+
], ii = [
|
|
4393
4496
|
"right-5",
|
|
4394
4497
|
"bg-linear-to-l",
|
|
4395
4498
|
"from-white/80",
|
|
4396
4499
|
"to-transparent"
|
|
4397
4500
|
];
|
|
4398
|
-
class
|
|
4501
|
+
class ri {
|
|
4399
4502
|
constructor() {
|
|
4400
4503
|
this.leftHaze = null, this.rightHaze = null, this.scrollContainer = null, this.boundOnScroll = null, this.ticking = !1;
|
|
4401
4504
|
}
|
|
@@ -4427,7 +4530,7 @@ class $s {
|
|
|
4427
4530
|
}
|
|
4428
4531
|
createHazeElement(t) {
|
|
4429
4532
|
const e = document.createElement("div");
|
|
4430
|
-
return e.setAttribute(
|
|
4533
|
+
return e.setAttribute(ni, t), e.setAttribute("aria-hidden", "true"), e.classList.add(...oi, ...t === "left" ? si : ii), e;
|
|
4431
4534
|
}
|
|
4432
4535
|
syncVisibility() {
|
|
4433
4536
|
const t = this.scrollContainer;
|
|
@@ -4439,16 +4542,16 @@ class $s {
|
|
|
4439
4542
|
return;
|
|
4440
4543
|
}
|
|
4441
4544
|
const { scrollLeft: o, scrollWidth: s, clientWidth: i } = t, l = s - i;
|
|
4442
|
-
this.setVisible(this.leftHaze, o >
|
|
4545
|
+
this.setVisible(this.leftHaze, o > Rt), this.setVisible(this.rightHaze, l > Rt && o < l - Rt);
|
|
4443
4546
|
}
|
|
4444
4547
|
setVisible(t, e) {
|
|
4445
|
-
t && (e ? t.setAttribute(
|
|
4548
|
+
t && (e ? t.setAttribute(me, "") : t.removeAttribute(me));
|
|
4446
4549
|
}
|
|
4447
4550
|
}
|
|
4448
|
-
const
|
|
4551
|
+
const li = 3, ai = 3, ci = [
|
|
4449
4552
|
"my-2",
|
|
4450
4553
|
"pr-5"
|
|
4451
|
-
],
|
|
4554
|
+
], di = [
|
|
4452
4555
|
"relative",
|
|
4453
4556
|
'after:content-[""]',
|
|
4454
4557
|
"after:absolute",
|
|
@@ -4457,11 +4560,11 @@ const Fs = 3, qs = 3, zs = [
|
|
|
4457
4560
|
"after:right-0",
|
|
4458
4561
|
"after:h-10"
|
|
4459
4562
|
];
|
|
4460
|
-
class
|
|
4563
|
+
class Ai {
|
|
4461
4564
|
constructor({ data: t, config: e, api: n, readOnly: o, block: s }) {
|
|
4462
4565
|
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 = o, this.config = e != null ? e : {};
|
|
4463
|
-
const i =
|
|
4464
|
-
this.initialContent = i.content, this.grid = new
|
|
4566
|
+
const i = le(t, this.config);
|
|
4567
|
+
this.initialContent = i.content, this.grid = new ss({ readOnly: o }), this.model = new Ls(i), this.blockId = s == null ? void 0 : s.id, this.config.restrictedTools !== void 0 && (this.unregisterRestrictedTools = An(this.config.restrictedTools));
|
|
4465
4568
|
}
|
|
4466
4569
|
/**
|
|
4467
4570
|
* Execute a function within a structural operation lock.
|
|
@@ -4517,7 +4620,7 @@ class Qs {
|
|
|
4517
4620
|
}
|
|
4518
4621
|
static get toolbox() {
|
|
4519
4622
|
return {
|
|
4520
|
-
icon:
|
|
4623
|
+
icon: xn,
|
|
4521
4624
|
title: "Table",
|
|
4522
4625
|
titleKey: "tools.table.title",
|
|
4523
4626
|
searchTerms: ["table", "grid", "spreadsheet"]
|
|
@@ -4560,15 +4663,15 @@ class Qs {
|
|
|
4560
4663
|
render() {
|
|
4561
4664
|
var s, i, l, a, c, d, h;
|
|
4562
4665
|
const t = document.createElement("div");
|
|
4563
|
-
t.className = w(
|
|
4564
|
-
const e = ((l = this.initialContent) == null ? void 0 : l.length) || this.config.rows ||
|
|
4666
|
+
t.className = w(ci, !this.readOnly && di), t.setAttribute(B.tool, "table"), this.readOnly && t.setAttribute("data-blok-table-readonly", ""), this.isNewTable = ((i = (s = this.initialContent) == null ? void 0 : s.length) != null ? i : 0) === 0;
|
|
4667
|
+
const e = ((l = this.initialContent) == null ? void 0 : l.length) || this.config.rows || li, n = ((a = this.initialContent) == null ? void 0 : a.reduce((u, p) => {
|
|
4565
4668
|
var g;
|
|
4566
4669
|
return Math.max(u, (g = p == null ? void 0 : p.length) != null ? g : 0);
|
|
4567
|
-
}, 0)) || this.config.cols ||
|
|
4568
|
-
if (((d = (c = this.initialContent) == null ? void 0 : c.length) != null ? d : 0) > 0 && this.grid.fillGrid(o, (h = this.initialContent) != null ? h : []), this.model.colWidths &&
|
|
4670
|
+
}, 0)) || this.config.cols || ai, o = this.grid.createGrid(e, n, this.model.colWidths);
|
|
4671
|
+
if (((d = (c = this.initialContent) == null ? void 0 : c.length) != null ? d : 0) > 0 && this.grid.fillGrid(o, (h = this.initialContent) != null ? h : []), this.model.colWidths && vt(o, this.model.colWidths), this.gridElement = o, this.model.colWidths || !this.readOnly) {
|
|
4569
4672
|
const u = document.createElement("div");
|
|
4570
4673
|
u.setAttribute("data-blok-table-scroll", "");
|
|
4571
|
-
const p = this.model.colWidths ?
|
|
4674
|
+
const p = this.model.colWidths ? ze : [];
|
|
4572
4675
|
u.classList.add(...p), u.appendChild(o), t.appendChild(u), this.scrollContainer = u;
|
|
4573
4676
|
} else
|
|
4574
4677
|
t.appendChild(o), this.scrollContainer = null;
|
|
@@ -4576,7 +4679,7 @@ class Qs {
|
|
|
4576
4679
|
const u = document.createElement("div");
|
|
4577
4680
|
u.setAttribute("data-blok-table-grip-overlay", ""), u.style.position = "absolute", u.style.inset = "0", u.style.pointerEvents = "none", u.style.zIndex = "3", t.appendChild(u), this.gripOverlay = u;
|
|
4578
4681
|
}
|
|
4579
|
-
return this.element = t, this.model.withHeadings &&
|
|
4682
|
+
return this.element = t, this.model.withHeadings && it(this.gridElement, this.model.withHeadings), this.model.withHeadingColumn && K(this.gridElement, this.model.withHeadingColumn), this.readOnly || (this.initCellBlocks(o), Bs(o, this.cellBlocks)), t;
|
|
4580
4683
|
}
|
|
4581
4684
|
rendered() {
|
|
4582
4685
|
var n, o;
|
|
@@ -4587,23 +4690,23 @@ class Qs {
|
|
|
4587
4690
|
return;
|
|
4588
4691
|
const e = this.initialContent;
|
|
4589
4692
|
if (this.initialContent = null, this.readOnly) {
|
|
4590
|
-
|
|
4693
|
+
Rs(t, e, this.api, (n = this.blockId) != null ? n : ""), rt(t, this.model.snapshot().content), this.initScrollHaze();
|
|
4591
4694
|
return;
|
|
4592
4695
|
}
|
|
4593
4696
|
if (this.runTransactedStructuralOp(() => {
|
|
4594
4697
|
var l, a;
|
|
4595
|
-
const s = (a = (l = this.cellBlocks) == null ? void 0 : l.initializeCells(e)) != null ? a : e, i = this.isNewTable && s.length === 0 ? Array.from(t.querySelectorAll(`[${
|
|
4596
|
-
const d = c.querySelectorAll(`[${
|
|
4698
|
+
const s = (a = (l = this.cellBlocks) == null ? void 0 : l.initializeCells(e)) != null ? a : e, i = this.isNewTable && s.length === 0 ? Array.from(t.querySelectorAll(`[${y}]`), (c) => {
|
|
4699
|
+
const d = c.querySelectorAll(`[${b}]`).length;
|
|
4597
4700
|
return Array.from({ length: d }, () => ({ blocks: [] }));
|
|
4598
4701
|
}) : s;
|
|
4599
|
-
this.model.replaceAll(
|
|
4702
|
+
this.model.replaceAll(V(T({}, this.model.snapshot()), {
|
|
4600
4703
|
content: i
|
|
4601
|
-
})), this.isNewTable &&
|
|
4704
|
+
})), this.isNewTable && _(t, this.cellBlocks);
|
|
4602
4705
|
}, !0), this.model.initialColWidth === void 0) {
|
|
4603
|
-
const s = (o = this.model.colWidths) != null ? o :
|
|
4604
|
-
this.model.setInitialColWidth(s.length > 0 ?
|
|
4706
|
+
const s = (o = this.model.colWidths) != null ? o : Y(t);
|
|
4707
|
+
this.model.setInitialColWidth(s.length > 0 ? As(s) : void 0);
|
|
4605
4708
|
}
|
|
4606
|
-
if (this.initSubsystems(t),
|
|
4709
|
+
if (this.initSubsystems(t), rt(t, this.model.snapshot().content), this.isNewTable) {
|
|
4607
4710
|
const s = t.querySelector('[contenteditable="true"]');
|
|
4608
4711
|
s == null || s.focus();
|
|
4609
4712
|
}
|
|
@@ -4621,8 +4724,8 @@ class Qs {
|
|
|
4621
4724
|
setData(t) {
|
|
4622
4725
|
var c, d, h, u, p;
|
|
4623
4726
|
this.setDataGeneration++;
|
|
4624
|
-
const e = this.setDataGeneration, n =
|
|
4625
|
-
|
|
4727
|
+
const e = this.setDataGeneration, n = le(
|
|
4728
|
+
T(T({}, this.model.snapshot()), t),
|
|
4626
4729
|
this.config
|
|
4627
4730
|
);
|
|
4628
4731
|
this.initialContent = n.content, this.model.replaceAll(n), this.api.blocks.isSyncingFromYjs || this.runStructuralOp(() => {
|
|
@@ -4639,7 +4742,7 @@ class Qs {
|
|
|
4639
4742
|
const a = this.gridElement;
|
|
4640
4743
|
if (a) {
|
|
4641
4744
|
if (this.readOnly) {
|
|
4642
|
-
|
|
4745
|
+
rt(a, this.model.snapshot().content);
|
|
4643
4746
|
return;
|
|
4644
4747
|
}
|
|
4645
4748
|
e === this.setDataGeneration && (this.runStructuralOp(() => {
|
|
@@ -4647,20 +4750,20 @@ class Qs {
|
|
|
4647
4750
|
const g = (v = (C = (m = this.cellBlocks) == null ? void 0 : m.initializeCells((f = this.initialContent) != null ? f : [])) != null ? C : this.initialContent) != null ? v : [];
|
|
4648
4751
|
if (e === this.setDataGeneration) {
|
|
4649
4752
|
if (this.api.blocks.isSyncingFromYjs && g.length === 0 && a) {
|
|
4650
|
-
const k = Array.from(a.querySelectorAll(`[${
|
|
4651
|
-
const
|
|
4652
|
-
return Array.from({ length:
|
|
4753
|
+
const k = Array.from(a.querySelectorAll(`[${y}]`), (x) => {
|
|
4754
|
+
const E = x.querySelectorAll(`[${b}]`).length;
|
|
4755
|
+
return Array.from({ length: E }, () => ({ blocks: [] }));
|
|
4653
4756
|
});
|
|
4654
|
-
this.model.replaceAll(
|
|
4757
|
+
this.model.replaceAll(V(T({}, this.model.snapshot()), {
|
|
4655
4758
|
content: k
|
|
4656
|
-
})),
|
|
4759
|
+
})), _(a, this.cellBlocks);
|
|
4657
4760
|
} else
|
|
4658
|
-
this.model.replaceAll(
|
|
4761
|
+
this.model.replaceAll(V(T({}, this.model.snapshot()), {
|
|
4659
4762
|
content: g
|
|
4660
4763
|
}));
|
|
4661
4764
|
this.initialContent = null;
|
|
4662
4765
|
}
|
|
4663
|
-
}, !0), e === this.setDataGeneration && (this.initSubsystems(a), s !== null && this.cellSelection !== null && this.cellSelection.selectRange(s), i !== null && this.rowColControls !== null && this.rowColControls.restoreVisibleGrips(i.col, i.row),
|
|
4766
|
+
}, !0), e === this.setDataGeneration && (this.initSubsystems(a), s !== null && this.cellSelection !== null && this.cellSelection.selectRange(s), i !== null && this.rowColControls !== null && this.rowColControls.restoreVisibleGrips(i.col, i.row), rt(a, this.model.snapshot().content)));
|
|
4664
4767
|
}
|
|
4665
4768
|
}
|
|
4666
4769
|
onPaste(t) {
|
|
@@ -4671,10 +4774,10 @@ class Qs {
|
|
|
4671
4774
|
f.forEach((v) => {
|
|
4672
4775
|
var N;
|
|
4673
4776
|
m.push(v.innerHTML);
|
|
4674
|
-
const k = (N = v.getAttribute("style")) != null ? N : "", x = {},
|
|
4675
|
-
|
|
4676
|
-
const
|
|
4677
|
-
|
|
4777
|
+
const k = (N = v.getAttribute("style")) != null ? N : "", x = {}, E = /background-color\s*:\s*([^;]+)/i.exec(k);
|
|
4778
|
+
E != null && E[1] && (x.color = zt(E[1].trim(), "bg"));
|
|
4779
|
+
const A = new RegExp("(?<![a-z-])color\\s*:\\s*([^;]+)", "i").exec(k);
|
|
4780
|
+
A != null && A[1] && !Tn(A[1].trim()) && (x.textColor = zt(A[1].trim(), "text")), C.push(x);
|
|
4678
4781
|
}), m.length > 0 && (o.push(m), s.push(C));
|
|
4679
4782
|
});
|
|
4680
4783
|
const i = e.querySelector("thead") !== null, l = ((u = n[0]) == null ? void 0 : u.querySelector("th")) !== null, a = i || l;
|
|
@@ -4691,14 +4794,14 @@ class Qs {
|
|
|
4691
4794
|
!this.readOnly && h && (this.runStructuralOp(() => {
|
|
4692
4795
|
var f, m, C, v;
|
|
4693
4796
|
const g = (v = (C = (m = this.cellBlocks) == null ? void 0 : m.initializeCells((f = this.initialContent) != null ? f : [])) != null ? C : this.initialContent) != null ? v : [];
|
|
4694
|
-
this.model.replaceAll(
|
|
4797
|
+
this.model.replaceAll(V(T({}, this.model.snapshot()), {
|
|
4695
4798
|
content: g
|
|
4696
4799
|
})), this.initialContent = null, s.forEach((k, x) => {
|
|
4697
|
-
k.forEach((
|
|
4698
|
-
|
|
4800
|
+
k.forEach((E, A) => {
|
|
4801
|
+
E.color !== void 0 && this.model.setCellColor(x, A, E.color), E.textColor !== void 0 && this.model.setCellTextColor(x, A, E.textColor);
|
|
4699
4802
|
});
|
|
4700
4803
|
});
|
|
4701
|
-
}, !0), this.initSubsystems(h),
|
|
4804
|
+
}, !0), this.initSubsystems(h), rt(h, this.model.snapshot().content));
|
|
4702
4805
|
}
|
|
4703
4806
|
destroy() {
|
|
4704
4807
|
var t, e, n;
|
|
@@ -4721,36 +4824,36 @@ class Qs {
|
|
|
4721
4824
|
});
|
|
4722
4825
|
}
|
|
4723
4826
|
getBlockIdsInRow(t) {
|
|
4724
|
-
return
|
|
4827
|
+
return xs(this.element, this.cellBlocks, t);
|
|
4725
4828
|
}
|
|
4726
4829
|
getBlockIdsInColumn(t) {
|
|
4727
|
-
return
|
|
4830
|
+
return Ts(this.element, this.cellBlocks, t);
|
|
4728
4831
|
}
|
|
4729
4832
|
initAddControls(t) {
|
|
4730
4833
|
var n;
|
|
4731
4834
|
if ((n = this.addControls) == null || n.destroy(), !this.element)
|
|
4732
4835
|
return;
|
|
4733
4836
|
const e = { addedCols: 0 };
|
|
4734
|
-
this.addControls = new
|
|
4837
|
+
this.addControls = new ts({
|
|
4735
4838
|
wrapper: this.element,
|
|
4736
4839
|
grid: t,
|
|
4737
4840
|
i18n: this.api.i18n,
|
|
4738
4841
|
getNewColumnWidth: () => {
|
|
4739
4842
|
var s;
|
|
4740
|
-
const o = (s = this.model.colWidths) != null ? s :
|
|
4741
|
-
return this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 :
|
|
4843
|
+
const o = (s = this.model.colWidths) != null ? s : Y(t);
|
|
4844
|
+
return this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : at(o);
|
|
4742
4845
|
},
|
|
4743
4846
|
onAddRow: () => {
|
|
4744
4847
|
this.runTransactedStructuralOp(() => {
|
|
4745
4848
|
var o, s;
|
|
4746
|
-
this.grid.addRow(t), this.model.addRow(),
|
|
4849
|
+
this.grid.addRow(t), this.model.addRow(), _(t, this.cellBlocks), it(this.gridElement, this.model.withHeadings), K(this.gridElement, this.model.withHeadingColumn), this.initResize(t), (o = this.addControls) == null || o.syncRowButtonWidth(), (s = this.rowColControls) == null || s.refresh();
|
|
4747
4850
|
});
|
|
4748
4851
|
},
|
|
4749
4852
|
onAddColumn: () => {
|
|
4750
4853
|
this.runTransactedStructuralOp(() => {
|
|
4751
4854
|
var i, l, a;
|
|
4752
|
-
const o = (i = this.model.colWidths) != null ? i :
|
|
4753
|
-
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths([...o, s]),
|
|
4855
|
+
const o = (i = this.model.colWidths) != null ? i : Y(t), s = this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : at(o);
|
|
4856
|
+
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths([...o, s]), _(t, this.cellBlocks), K(this.gridElement, this.model.withHeadingColumn), this.initResize(t), (l = this.addControls) == null || l.syncRowButtonWidth(), (a = this.rowColControls) == null || a.refresh(), this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth);
|
|
4754
4857
|
});
|
|
4755
4858
|
},
|
|
4756
4859
|
onDragStart: () => {
|
|
@@ -4759,14 +4862,14 @@ class Qs {
|
|
|
4759
4862
|
},
|
|
4760
4863
|
onDragAddRow: () => {
|
|
4761
4864
|
this.runTransactedStructuralOp(() => {
|
|
4762
|
-
this.grid.addRow(t), this.model.addRow(),
|
|
4865
|
+
this.grid.addRow(t), this.model.addRow(), _(t, this.cellBlocks), it(this.gridElement, this.model.withHeadings), K(this.gridElement, this.model.withHeadingColumn);
|
|
4763
4866
|
});
|
|
4764
4867
|
},
|
|
4765
4868
|
onDragRemoveRow: () => {
|
|
4766
4869
|
this.runTransactedStructuralOp(() => {
|
|
4767
4870
|
var s;
|
|
4768
4871
|
const o = this.grid.getRowCount(t);
|
|
4769
|
-
if (o > 1 &&
|
|
4872
|
+
if (o > 1 && ys(t, o - 1)) {
|
|
4770
4873
|
const { blocksToDelete: i } = this.model.deleteRow(o - 1);
|
|
4771
4874
|
(s = this.cellBlocks) == null || s.deleteBlocks(i), this.grid.deleteRow(t, o - 1);
|
|
4772
4875
|
}
|
|
@@ -4775,20 +4878,20 @@ class Qs {
|
|
|
4775
4878
|
onDragAddCol: () => {
|
|
4776
4879
|
this.runTransactedStructuralOp(() => {
|
|
4777
4880
|
var l;
|
|
4778
|
-
const o = (l = this.model.colWidths) != null ? l :
|
|
4779
|
-
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths(i),
|
|
4881
|
+
const o = (l = this.model.colWidths) != null ? l : Y(t), s = this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : at(o), i = [...o, s];
|
|
4882
|
+
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths(i), vt(t, i), _(t, this.cellBlocks), K(this.gridElement, this.model.withHeadingColumn), this.initResize(t), e.addedCols++, this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth);
|
|
4780
4883
|
});
|
|
4781
4884
|
},
|
|
4782
4885
|
onDragRemoveCol: () => {
|
|
4783
4886
|
this.runTransactedStructuralOp(() => {
|
|
4784
4887
|
var l;
|
|
4785
4888
|
const o = this.grid.getColumnCount(t);
|
|
4786
|
-
if (o <= 1 || !
|
|
4889
|
+
if (o <= 1 || !vs(t, o - 1))
|
|
4787
4890
|
return;
|
|
4788
4891
|
const { blocksToDelete: s } = this.model.deleteColumn(o - 1);
|
|
4789
4892
|
(l = this.cellBlocks) == null || l.deleteBlocks(s), this.grid.deleteColumn(t, o - 1);
|
|
4790
4893
|
const i = this.model.colWidths;
|
|
4791
|
-
i &&
|
|
4894
|
+
i && vt(t, i), this.initResize(t), e.addedCols--;
|
|
4792
4895
|
});
|
|
4793
4896
|
},
|
|
4794
4897
|
onDragEnd: () => {
|
|
@@ -4799,7 +4902,7 @@ class Qs {
|
|
|
4799
4902
|
}
|
|
4800
4903
|
initRowColControls(t) {
|
|
4801
4904
|
var e, n, o;
|
|
4802
|
-
(e = this.rowColControls) == null || e.destroy(), this.element && (this.rowColControls = new
|
|
4905
|
+
(e = this.rowColControls) == null || e.destroy(), this.element && (this.rowColControls = new ei({
|
|
4803
4906
|
grid: t,
|
|
4804
4907
|
overlay: (n = this.gripOverlay) != null ? n : void 0,
|
|
4805
4908
|
scrollContainer: (o = this.scrollContainer) != null ? o : void 0,
|
|
@@ -4836,7 +4939,7 @@ class Qs {
|
|
|
4836
4939
|
var d, h, u, p, g;
|
|
4837
4940
|
if (n !== this.setDataGeneration || this.gridElement !== t)
|
|
4838
4941
|
return;
|
|
4839
|
-
const o = this.model.colWidths, { blocksToDelete: s } = this.syncModelForAction(e), i =
|
|
4942
|
+
const o = this.model.colWidths, { blocksToDelete: s } = this.syncModelForAction(e), i = Gs(
|
|
4840
4943
|
t,
|
|
4841
4944
|
e,
|
|
4842
4945
|
{
|
|
@@ -4851,7 +4954,7 @@ class Qs {
|
|
|
4851
4954
|
blocksToDelete: s
|
|
4852
4955
|
}
|
|
4853
4956
|
);
|
|
4854
|
-
if (n !== this.setDataGeneration || this.gridElement !== t || (this.model.setColWidths(i.colWidths), this.model.setWithHeadings(i.withHeadings), this.model.setWithHeadingColumn(i.withHeadingColumn), this.pendingHighlight = i.pendingHighlight,
|
|
4957
|
+
if (n !== this.setDataGeneration || this.gridElement !== t || (this.model.setColWidths(i.colWidths), this.model.setWithHeadings(i.withHeadings), this.model.setWithHeadingColumn(i.withHeadingColumn), this.pendingHighlight = i.pendingHighlight, it(this.gridElement, this.model.withHeadings), K(this.gridElement, this.model.withHeadingColumn), this.initResize(t), (d = this.addControls) == null || d.syncRowButtonWidth(), e.type === "toggle-heading" || e.type === "toggle-heading-column" || (h = this.rowColControls) == null || h.refresh(), !i.moveSelection))
|
|
4855
4958
|
return;
|
|
4856
4959
|
const { type: a, index: c } = i.moveSelection;
|
|
4857
4960
|
a === "row" ? (u = this.cellSelection) == null || u.selectRow(c) : (p = this.cellSelection) == null || p.selectColumn(c), (g = this.rowColControls) == null || g.setActiveGrip(a, c);
|
|
@@ -4887,13 +4990,13 @@ class Qs {
|
|
|
4887
4990
|
initResize(t) {
|
|
4888
4991
|
var o, s;
|
|
4889
4992
|
(o = this.resize) == null || o.destroy();
|
|
4890
|
-
const e = this.model.colWidths === void 0, n = (s = this.model.colWidths) != null ? s :
|
|
4891
|
-
e ||
|
|
4993
|
+
const e = this.model.colWidths === void 0, n = (s = this.model.colWidths) != null ? s : Y(t);
|
|
4994
|
+
e || ae(this.ensureScrollContainer()), this.resize = new Hs(
|
|
4892
4995
|
t,
|
|
4893
4996
|
n,
|
|
4894
4997
|
(i) => {
|
|
4895
4998
|
var l, a, c;
|
|
4896
|
-
this.model.setColWidths(i),
|
|
4999
|
+
this.model.setColWidths(i), ae(this.ensureScrollContainer()), (l = this.rowColControls) == null || l.positionGrips(), (a = this.addControls) == null || a.syncRowButtonWidth(), (c = this.scrollHaze) == null || c.update();
|
|
4897
5000
|
},
|
|
4898
5001
|
() => {
|
|
4899
5002
|
var i;
|
|
@@ -4908,7 +5011,7 @@ class Qs {
|
|
|
4908
5011
|
}
|
|
4909
5012
|
initCellBlocks(t) {
|
|
4910
5013
|
var e;
|
|
4911
|
-
this.cellBlocks = new
|
|
5014
|
+
this.cellBlocks = new is({
|
|
4912
5015
|
api: this.api,
|
|
4913
5016
|
gridElement: t,
|
|
4914
5017
|
tableBlockId: (e = this.blockId) != null ? e : "",
|
|
@@ -4920,14 +5023,14 @@ class Qs {
|
|
|
4920
5023
|
const n = this.collectCellBlockData(t);
|
|
4921
5024
|
if (n.length === 0)
|
|
4922
5025
|
return;
|
|
4923
|
-
const o =
|
|
4924
|
-
e.setData("text/html",
|
|
5026
|
+
const o = Vt(n);
|
|
5027
|
+
e.setData("text/html", Kt(o)), e.setData("text/plain", Ut(o));
|
|
4925
5028
|
}
|
|
4926
5029
|
handleCellCopyViaButton(t) {
|
|
4927
5030
|
const e = this.collectCellBlockData(t);
|
|
4928
5031
|
if (e.length === 0)
|
|
4929
5032
|
return;
|
|
4930
|
-
const n =
|
|
5033
|
+
const n = Vt(e), o = Kt(n), s = Ut(n), i = new Blob([o], { type: "text/html" }), l = new Blob([s], { type: "text/plain" });
|
|
4931
5034
|
navigator.clipboard.write([
|
|
4932
5035
|
new ClipboardItem({
|
|
4933
5036
|
"text/html": i,
|
|
@@ -4939,7 +5042,7 @@ class Qs {
|
|
|
4939
5042
|
const o = this.gridElement;
|
|
4940
5043
|
o && this.runTransactedStructuralOp(() => {
|
|
4941
5044
|
for (const s of t) {
|
|
4942
|
-
const i =
|
|
5045
|
+
const i = Dt(o, s);
|
|
4943
5046
|
i && (n === "backgroundColor" ? (this.model.setCellColor(i.row, i.col, e != null ? e : void 0), s.style.backgroundColor = e != null ? e : "") : (this.model.setCellTextColor(i.row, i.col, e != null ? e : void 0), s.style.color = e != null ? e : ""));
|
|
4944
5047
|
}
|
|
4945
5048
|
});
|
|
@@ -4948,13 +5051,13 @@ class Qs {
|
|
|
4948
5051
|
const e = this.gridElement;
|
|
4949
5052
|
if (!e)
|
|
4950
5053
|
return [];
|
|
4951
|
-
const n = Array.from(e.querySelectorAll(`[${
|
|
5054
|
+
const n = Array.from(e.querySelectorAll(`[${y}]`));
|
|
4952
5055
|
return t.map((o) => {
|
|
4953
5056
|
var g;
|
|
4954
|
-
const s = o.closest(`[${
|
|
5057
|
+
const s = o.closest(`[${y}]`);
|
|
4955
5058
|
if (!s)
|
|
4956
5059
|
return null;
|
|
4957
|
-
const i = n.indexOf(s), a = Array.from(s.querySelectorAll(`[${
|
|
5060
|
+
const i = n.indexOf(s), a = Array.from(s.querySelectorAll(`[${b}]`)).indexOf(o), c = o.querySelector(`[${D}]`), d = [];
|
|
4958
5061
|
if (!c)
|
|
4959
5062
|
return { row: i, col: a, blocks: d };
|
|
4960
5063
|
c.querySelectorAll("[data-blok-id]").forEach((f) => {
|
|
@@ -4965,7 +5068,7 @@ class Qs {
|
|
|
4965
5068
|
if (C === void 0)
|
|
4966
5069
|
return;
|
|
4967
5070
|
const v = this.api.blocks.getBlockByIndex(C);
|
|
4968
|
-
v && d.push(
|
|
5071
|
+
v && d.push(T({
|
|
4969
5072
|
tool: v.name,
|
|
4970
5073
|
data: v.preservedData
|
|
4971
5074
|
}, Object.keys(v.preservedTunes).length > 0 ? { tunes: v.preservedTunes } : {}));
|
|
@@ -4976,7 +5079,7 @@ class Qs {
|
|
|
4976
5079
|
data: { text: h }
|
|
4977
5080
|
});
|
|
4978
5081
|
const u = this.model.getCellColor(i, a), p = this.model.getCellTextColor(i, a);
|
|
4979
|
-
return
|
|
5082
|
+
return T(T({
|
|
4980
5083
|
row: i,
|
|
4981
5084
|
col: a,
|
|
4982
5085
|
blocks: d
|
|
@@ -4987,7 +5090,7 @@ class Qs {
|
|
|
4987
5090
|
var n;
|
|
4988
5091
|
(n = this.cellSelection) == null || n.destroy();
|
|
4989
5092
|
const e = this.api.rectangleSelection;
|
|
4990
|
-
this.cellSelection = new
|
|
5093
|
+
this.cellSelection = new bs({
|
|
4991
5094
|
grid: t,
|
|
4992
5095
|
rectangleSelection: e,
|
|
4993
5096
|
// Pass reference
|
|
@@ -5012,7 +5115,7 @@ class Qs {
|
|
|
5012
5115
|
const l = this.gridElement;
|
|
5013
5116
|
if (l)
|
|
5014
5117
|
for (const a of o) {
|
|
5015
|
-
const c =
|
|
5118
|
+
const c = Dt(l, a);
|
|
5016
5119
|
c && (this.model.setCellColor(c.row, c.col, void 0), this.model.setCellTextColor(c.row, c.col, void 0), a.style.backgroundColor = "", a.style.color = "");
|
|
5017
5120
|
}
|
|
5018
5121
|
});
|
|
@@ -5033,7 +5136,7 @@ class Qs {
|
|
|
5033
5136
|
}
|
|
5034
5137
|
initScrollHaze() {
|
|
5035
5138
|
var t;
|
|
5036
|
-
(t = this.scrollHaze) == null || t.destroy(), !(!this.element || !this.scrollContainer) && (this.scrollHaze = new
|
|
5139
|
+
(t = this.scrollHaze) == null || t.destroy(), !(!this.element || !this.scrollContainer) && (this.scrollHaze = new ri(), this.scrollHaze.init(this.element, this.scrollContainer));
|
|
5037
5140
|
}
|
|
5038
5141
|
initGridPasteListener(t) {
|
|
5039
5142
|
t.addEventListener("paste", (e) => {
|
|
@@ -5043,47 +5146,47 @@ class Qs {
|
|
|
5043
5146
|
handleGridPaste(t, e) {
|
|
5044
5147
|
if (this.readOnly || !t.clipboardData || t.defaultPrevented)
|
|
5045
5148
|
return;
|
|
5046
|
-
const n = t.clipboardData.getData("text/html"), o =
|
|
5149
|
+
const n = t.clipboardData.getData("text/html"), o = Rn(n), s = o === null ? Bn(n) : null, i = o != null ? o : s;
|
|
5047
5150
|
if (!i || s !== null && new DOMParser().parseFromString(n, "text/html").querySelectorAll("table").length > 1)
|
|
5048
5151
|
return;
|
|
5049
5152
|
const l = document.activeElement;
|
|
5050
5153
|
if (!l)
|
|
5051
5154
|
return;
|
|
5052
|
-
const a = l.closest(`[${
|
|
5155
|
+
const a = l.closest(`[${b}]`);
|
|
5053
5156
|
if (!a || !e.contains(a))
|
|
5054
5157
|
return;
|
|
5055
|
-
const c = a.closest(`[${
|
|
5158
|
+
const c = a.closest(`[${y}]`);
|
|
5056
5159
|
if (!c)
|
|
5057
5160
|
return;
|
|
5058
5161
|
t.preventDefault(), t.stopPropagation();
|
|
5059
|
-
const h = Array.from(e.querySelectorAll(`[${
|
|
5162
|
+
const h = Array.from(e.querySelectorAll(`[${y}]`)).indexOf(c), p = Array.from(c.querySelectorAll(`[${b}]`)).indexOf(a);
|
|
5060
5163
|
this.pastePayloadIntoCells(e, i, h, p);
|
|
5061
5164
|
}
|
|
5062
5165
|
pastePayloadIntoCells(t, e, n, o) {
|
|
5063
5166
|
this.runTransactedStructuralOp(() => {
|
|
5064
5167
|
var h, u;
|
|
5065
5168
|
this.expandGridForPaste(t, n + e.rows, o + e.cols);
|
|
5066
|
-
const d = t.querySelectorAll(`[${
|
|
5169
|
+
const d = t.querySelectorAll(`[${y}]`);
|
|
5067
5170
|
Array.from({ length: e.rows }, (p, g) => g).forEach((p) => {
|
|
5068
5171
|
const g = d[n + p];
|
|
5069
5172
|
if (!g)
|
|
5070
5173
|
return;
|
|
5071
|
-
const f = g.querySelectorAll(`[${
|
|
5174
|
+
const f = g.querySelectorAll(`[${b}]`);
|
|
5072
5175
|
Array.from({ length: e.cols }, (m, C) => C).forEach((m) => {
|
|
5073
|
-
var v, k, x,
|
|
5176
|
+
var v, k, x, E;
|
|
5074
5177
|
const C = f[o + m];
|
|
5075
5178
|
if (C) {
|
|
5076
|
-
const
|
|
5077
|
-
this.pasteCellPayload(C,
|
|
5179
|
+
const A = e.cells[p][m];
|
|
5180
|
+
this.pasteCellPayload(C, A);
|
|
5078
5181
|
const N = (k = (v = this.cellBlocks) == null ? void 0 : v.getBlockIdsFromCells([C])) != null ? k : [];
|
|
5079
5182
|
this.model.setCellBlocks(n + p, o + m, N);
|
|
5080
|
-
const
|
|
5081
|
-
this.model.setCellColor(
|
|
5183
|
+
const ut = n + p, st = o + m;
|
|
5184
|
+
this.model.setCellColor(ut, st, A.color), C.style.backgroundColor = (x = A.color) != null ? x : "", this.model.setCellTextColor(ut, st, A.textColor), C.style.color = (E = A.textColor) != null ? E : "";
|
|
5082
5185
|
}
|
|
5083
5186
|
});
|
|
5084
5187
|
}), this.initResize(t), (h = this.addControls) == null || h.syncRowButtonWidth(), (u = this.rowColControls) == null || u.refresh();
|
|
5085
5188
|
});
|
|
5086
|
-
const i = t.querySelectorAll(`[${
|
|
5189
|
+
const i = t.querySelectorAll(`[${y}]`)[n + e.rows - 1], l = i == null ? void 0 : i.querySelectorAll(`[${b}]`)[o + e.cols - 1];
|
|
5087
5190
|
if (!l || !this.cellBlocks || !this.api.caret)
|
|
5088
5191
|
return;
|
|
5089
5192
|
const a = this.cellBlocks.getBlockIdsFromCells([l]), c = a[a.length - 1];
|
|
@@ -5095,11 +5198,11 @@ class Qs {
|
|
|
5095
5198
|
expandGridForPaste(t, e, n) {
|
|
5096
5199
|
const o = this.grid.getRowCount(t), s = this.grid.getColumnCount(t);
|
|
5097
5200
|
Array.from({ length: Math.max(0, e - o) }).forEach(() => {
|
|
5098
|
-
this.grid.addRow(t), this.model.addRow(),
|
|
5201
|
+
this.grid.addRow(t), this.model.addRow(), _(t, this.cellBlocks), it(this.gridElement, this.model.withHeadings), K(this.gridElement, this.model.withHeadingColumn);
|
|
5099
5202
|
}), Array.from({ length: Math.max(0, n - s) }).forEach(() => {
|
|
5100
5203
|
var a;
|
|
5101
|
-
const i = (a = this.model.colWidths) != null ? a :
|
|
5102
|
-
this.grid.addColumn(t, void 0, i, l), this.model.addColumn(void 0, l), this.model.setColWidths([...i, l]),
|
|
5204
|
+
const i = (a = this.model.colWidths) != null ? a : Y(t), l = this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : at(i);
|
|
5205
|
+
this.grid.addColumn(t, void 0, i, l), this.model.addColumn(void 0, l), this.model.setColWidths([...i, l]), _(t, this.cellBlocks), K(this.gridElement, this.model.withHeadingColumn);
|
|
5103
5206
|
});
|
|
5104
5207
|
}
|
|
5105
5208
|
/**
|
|
@@ -5111,7 +5214,7 @@ class Qs {
|
|
|
5111
5214
|
const i = this.cellBlocks.getBlockIdsFromCells([t]);
|
|
5112
5215
|
this.cellBlocks.deleteBlocks(i);
|
|
5113
5216
|
}
|
|
5114
|
-
const n = t.querySelector(`[${
|
|
5217
|
+
const n = t.querySelector(`[${D}]`);
|
|
5115
5218
|
if (n) {
|
|
5116
5219
|
if (e.blocks.length === 0) {
|
|
5117
5220
|
(o = this.cellBlocks) == null || o.ensureCellHasBlock(t);
|
|
@@ -5130,10 +5233,232 @@ class Qs {
|
|
|
5130
5233
|
}
|
|
5131
5234
|
}
|
|
5132
5235
|
}
|
|
5236
|
+
const hi = (r) => {
|
|
5237
|
+
const t = document.createElement("div");
|
|
5238
|
+
t.innerHTML = r.trim();
|
|
5239
|
+
const e = document.createDocumentFragment();
|
|
5240
|
+
return e.append(...Array.from(t.childNodes)), e;
|
|
5241
|
+
}, ui = (r, t, e) => {
|
|
5242
|
+
if (!t) return r;
|
|
5243
|
+
const n = e();
|
|
5244
|
+
return { text: n ? Nt(n.innerHTML) : r.text };
|
|
5245
|
+
}, pi = (r, t) => {
|
|
5246
|
+
const { data: e, getContentElement: n } = r;
|
|
5247
|
+
e.text += t.text;
|
|
5248
|
+
const o = n();
|
|
5249
|
+
if (o && t.text) {
|
|
5250
|
+
const s = r.parseHTML(t.text);
|
|
5251
|
+
o.appendChild(s), o.normalize();
|
|
5252
|
+
}
|
|
5253
|
+
}, gi = (r, t, e) => {
|
|
5254
|
+
const n = e();
|
|
5255
|
+
if (!n)
|
|
5256
|
+
return { newData: r, inPlace: !1 };
|
|
5257
|
+
const o = T(T({}, r), t);
|
|
5258
|
+
return typeof t.text == "string" && (n.innerHTML = t.text), { newData: o, inPlace: !0 };
|
|
5259
|
+
}, fi = async (r) => {
|
|
5260
|
+
var u;
|
|
5261
|
+
const { api: t, blockId: e, data: n, getContentElement: o, syncContentFromDOM: s } = r;
|
|
5262
|
+
if (s(), e === void 0)
|
|
5263
|
+
return;
|
|
5264
|
+
const i = o(), l = window.getSelection();
|
|
5265
|
+
if (!i || !l || l.rangeCount === 0)
|
|
5266
|
+
return;
|
|
5267
|
+
const a = l.getRangeAt(0), { beforeContent: c, afterContent: d } = Ci(i, a), h = (u = t.blocks.getBlockIndex(e)) != null ? u : t.blocks.getCurrentBlockIndex();
|
|
5268
|
+
t.blocks.splitBlock(
|
|
5269
|
+
e,
|
|
5270
|
+
{ text: c },
|
|
5271
|
+
_t,
|
|
5272
|
+
{ text: d },
|
|
5273
|
+
h + 1
|
|
5274
|
+
), n.text = c;
|
|
5275
|
+
}, mi = async (r, t) => {
|
|
5276
|
+
const { api: e, blockId: n, data: o, getContentElement: s } = r;
|
|
5277
|
+
if (n === void 0)
|
|
5278
|
+
return;
|
|
5279
|
+
const i = s();
|
|
5280
|
+
if (!i || !Ln(i))
|
|
5281
|
+
return;
|
|
5282
|
+
const l = o.text;
|
|
5283
|
+
l === "" && (t.preventDefault(), await e.blocks.convert(n, "paragraph", { text: l }));
|
|
5284
|
+
}, Ci = (r, t) => {
|
|
5285
|
+
if (!r.lastChild)
|
|
5286
|
+
return { beforeContent: "", afterContent: "" };
|
|
5287
|
+
const e = document.createRange();
|
|
5288
|
+
e.setStart(r, 0), e.setEnd(t.startContainer, t.startOffset);
|
|
5289
|
+
const n = document.createRange();
|
|
5290
|
+
n.setStart(t.endContainer, t.endOffset), n.setEndAfter(r.lastChild);
|
|
5291
|
+
const o = document.createElement("div");
|
|
5292
|
+
o.appendChild(e.cloneContents());
|
|
5293
|
+
const s = document.createElement("div");
|
|
5294
|
+
return s.appendChild(n.cloneContents()), {
|
|
5295
|
+
beforeContent: o.innerHTML,
|
|
5296
|
+
afterContent: s.innerHTML
|
|
5297
|
+
};
|
|
5298
|
+
};
|
|
5299
|
+
class xi {
|
|
5300
|
+
constructor({ data: t, config: e, api: n, readOnly: o, block: s }) {
|
|
5301
|
+
this._element = null, this._contentElement = null, this._arrowElement = null, this._isOpen = !1, this.api = n, this.readOnly = o, this._settings = e || {}, this._data = this.normalizeData(t), s && (this.blockId = s.id);
|
|
5302
|
+
}
|
|
5303
|
+
normalizeData(t) {
|
|
5304
|
+
return typeof t == "object" && t !== null && "text" in t ? {
|
|
5305
|
+
text: typeof t.text == "string" ? t.text : ""
|
|
5306
|
+
} : { text: "" };
|
|
5307
|
+
}
|
|
5308
|
+
get placeholder() {
|
|
5309
|
+
if (this._settings.placeholder)
|
|
5310
|
+
return this._settings.placeholder;
|
|
5311
|
+
const t = this.api.i18n.t(Yt);
|
|
5312
|
+
return t !== Yt ? t : "Toggle";
|
|
5313
|
+
}
|
|
5314
|
+
render() {
|
|
5315
|
+
const t = jn({
|
|
5316
|
+
data: this._data,
|
|
5317
|
+
readOnly: this.readOnly,
|
|
5318
|
+
isOpen: this._isOpen,
|
|
5319
|
+
placeholder: this.placeholder,
|
|
5320
|
+
keydownHandler: this.readOnly ? null : this.handleKeyDown.bind(this),
|
|
5321
|
+
onArrowClick: () => this.toggleOpen()
|
|
5322
|
+
});
|
|
5323
|
+
return this._element = t.wrapper, this._contentElement = t.contentElement, this._arrowElement = t.arrowElement, this._element;
|
|
5324
|
+
}
|
|
5325
|
+
rendered() {
|
|
5326
|
+
this.updateChildrenVisibility();
|
|
5327
|
+
}
|
|
5328
|
+
save() {
|
|
5329
|
+
return ui(this._data, this._element, this.getContentElement.bind(this));
|
|
5330
|
+
}
|
|
5331
|
+
validate(t) {
|
|
5332
|
+
return !0;
|
|
5333
|
+
}
|
|
5334
|
+
merge(t) {
|
|
5335
|
+
pi(
|
|
5336
|
+
{
|
|
5337
|
+
data: this._data,
|
|
5338
|
+
getContentElement: this.getContentElement.bind(this),
|
|
5339
|
+
parseHTML: hi
|
|
5340
|
+
},
|
|
5341
|
+
t
|
|
5342
|
+
);
|
|
5343
|
+
}
|
|
5344
|
+
setData(t) {
|
|
5345
|
+
const e = gi(
|
|
5346
|
+
this._data,
|
|
5347
|
+
t,
|
|
5348
|
+
this.getContentElement.bind(this)
|
|
5349
|
+
);
|
|
5350
|
+
return this._data = e.newData, e.inPlace;
|
|
5351
|
+
}
|
|
5352
|
+
renderSettings() {
|
|
5353
|
+
return [];
|
|
5354
|
+
}
|
|
5355
|
+
/**
|
|
5356
|
+
* Expand the toggle (no-op if already expanded).
|
|
5357
|
+
* Can be called externally via block.call('expand').
|
|
5358
|
+
*/
|
|
5359
|
+
expand() {
|
|
5360
|
+
this._isOpen || this.setOpenState(!0);
|
|
5361
|
+
}
|
|
5362
|
+
/**
|
|
5363
|
+
* Collapse the toggle (no-op if already collapsed).
|
|
5364
|
+
* Can be called externally via block.call('collapse').
|
|
5365
|
+
*/
|
|
5366
|
+
collapse() {
|
|
5367
|
+
this._isOpen && this.setOpenState(!1);
|
|
5368
|
+
}
|
|
5369
|
+
getContentElement() {
|
|
5370
|
+
return this._contentElement;
|
|
5371
|
+
}
|
|
5372
|
+
setOpenState(t) {
|
|
5373
|
+
this._isOpen = t, this._arrowElement && this._element && Le(this._arrowElement, this._element, this._isOpen), this.updateChildrenVisibility();
|
|
5374
|
+
}
|
|
5375
|
+
toggleOpen() {
|
|
5376
|
+
this.setOpenState(!this._isOpen);
|
|
5377
|
+
}
|
|
5378
|
+
updateChildrenVisibility() {
|
|
5379
|
+
this.blockId !== void 0 && Ie(this.api, this.blockId, this._isOpen);
|
|
5380
|
+
}
|
|
5381
|
+
handleKeyDown(t) {
|
|
5382
|
+
if (t.key === "Enter" && !t.shiftKey) {
|
|
5383
|
+
t.preventDefault(), this.handleEnter();
|
|
5384
|
+
return;
|
|
5385
|
+
}
|
|
5386
|
+
t.key === "Backspace" && this.handleBackspace(t);
|
|
5387
|
+
}
|
|
5388
|
+
createKeyboardContext() {
|
|
5389
|
+
return {
|
|
5390
|
+
api: this.api,
|
|
5391
|
+
blockId: this.blockId,
|
|
5392
|
+
data: this._data,
|
|
5393
|
+
element: this._element,
|
|
5394
|
+
getContentElement: this.getContentElement.bind(this),
|
|
5395
|
+
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
5396
|
+
isOpen: this._isOpen,
|
|
5397
|
+
setOpen: (t) => {
|
|
5398
|
+
this._isOpen = t;
|
|
5399
|
+
}
|
|
5400
|
+
};
|
|
5401
|
+
}
|
|
5402
|
+
async handleEnter() {
|
|
5403
|
+
await fi(this.createKeyboardContext());
|
|
5404
|
+
}
|
|
5405
|
+
async handleBackspace(t) {
|
|
5406
|
+
await mi(this.createKeyboardContext(), t);
|
|
5407
|
+
}
|
|
5408
|
+
syncContentFromDOM() {
|
|
5409
|
+
const t = this.getContentElement();
|
|
5410
|
+
t && (this._data.text = t.innerHTML);
|
|
5411
|
+
}
|
|
5412
|
+
static get shortcut() {
|
|
5413
|
+
return "CMD+ALT+7";
|
|
5414
|
+
}
|
|
5415
|
+
static get toolbox() {
|
|
5416
|
+
return {
|
|
5417
|
+
icon: In,
|
|
5418
|
+
title: "Toggle list",
|
|
5419
|
+
titleKey: "toggleList",
|
|
5420
|
+
name: _t,
|
|
5421
|
+
searchTerms: ["toggle", "collapse", "expand", "accordion"]
|
|
5422
|
+
};
|
|
5423
|
+
}
|
|
5424
|
+
static get conversionConfig() {
|
|
5425
|
+
return {
|
|
5426
|
+
export: "text",
|
|
5427
|
+
import: "text"
|
|
5428
|
+
};
|
|
5429
|
+
}
|
|
5430
|
+
static get sanitize() {
|
|
5431
|
+
return {
|
|
5432
|
+
text: {
|
|
5433
|
+
br: !0,
|
|
5434
|
+
a: {
|
|
5435
|
+
href: !0,
|
|
5436
|
+
target: "_blank",
|
|
5437
|
+
rel: "nofollow"
|
|
5438
|
+
},
|
|
5439
|
+
b: !0,
|
|
5440
|
+
i: !0,
|
|
5441
|
+
mark: {
|
|
5442
|
+
class: !0,
|
|
5443
|
+
style: !0
|
|
5444
|
+
},
|
|
5445
|
+
code: !0
|
|
5446
|
+
}
|
|
5447
|
+
};
|
|
5448
|
+
}
|
|
5449
|
+
static get pasteConfig() {
|
|
5450
|
+
return {
|
|
5451
|
+
tags: ["DETAILS"]
|
|
5452
|
+
};
|
|
5453
|
+
}
|
|
5454
|
+
static get isReadOnlySupported() {
|
|
5455
|
+
return !0;
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5133
5458
|
const X = (r) => {
|
|
5134
5459
|
const t = r.tagName;
|
|
5135
5460
|
return t === "B" || t === "STRONG";
|
|
5136
|
-
},
|
|
5461
|
+
}, St = (r) => !!(r && r.nodeType === Node.ELEMENT_NODE && X(r)), Ke = (r) => r.textContent.length === 0, G = (r) => r ? r.nodeType === Node.ELEMENT_NODE && X(r) ? z(r) : G(r.parentNode) : null, z = (r) => {
|
|
5137
5462
|
if (r.tagName === "STRONG")
|
|
5138
5463
|
return r;
|
|
5139
5464
|
const t = document.createElement("strong");
|
|
@@ -5142,7 +5467,7 @@ const X = (r) => {
|
|
|
5142
5467
|
}); r.firstChild; )
|
|
5143
5468
|
t.appendChild(r.firstChild);
|
|
5144
5469
|
return r.replaceWith(t), t;
|
|
5145
|
-
},
|
|
5470
|
+
}, bi = (r) => {
|
|
5146
5471
|
const t = r.nextSibling;
|
|
5147
5472
|
if ((t == null ? void 0 : t.nodeType) === Node.TEXT_NODE)
|
|
5148
5473
|
return t;
|
|
@@ -5151,15 +5476,15 @@ const X = (r) => {
|
|
|
5151
5476
|
return null;
|
|
5152
5477
|
const n = r.ownerDocument.createTextNode("");
|
|
5153
5478
|
return e.insertBefore(n, t), n;
|
|
5154
|
-
},
|
|
5479
|
+
}, yi = (r) => {
|
|
5155
5480
|
if (!r.boldElement.isConnected)
|
|
5156
5481
|
return null;
|
|
5157
|
-
const t =
|
|
5482
|
+
const t = z(r.boldElement), e = r.boundary, o = e.isConnected && e.previousSibling === t ? e : bi(t);
|
|
5158
5483
|
return o ? {
|
|
5159
5484
|
boundary: o,
|
|
5160
5485
|
boldElement: t
|
|
5161
5486
|
} : null;
|
|
5162
|
-
},
|
|
5487
|
+
}, Ht = (r, t) => r ? r === t || t.contains(r) : !1, R = {
|
|
5163
5488
|
COLLAPSED_LENGTH: "data-blok-bold-collapsed-length",
|
|
5164
5489
|
COLLAPSED_ACTIVE: "data-blok-bold-collapsed-active",
|
|
5165
5490
|
PREV_LENGTH: "data-blok-bold-prev-length",
|
|
@@ -5192,13 +5517,13 @@ const X = (r) => {
|
|
|
5192
5517
|
* @param element - The element to check
|
|
5193
5518
|
*/
|
|
5194
5519
|
isActivePlaceholder(t) {
|
|
5195
|
-
return t.getAttribute(
|
|
5520
|
+
return t.getAttribute(R.COLLAPSED_ACTIVE) === "true" || t.hasAttribute(R.COLLAPSED_LENGTH);
|
|
5196
5521
|
}
|
|
5197
5522
|
/**
|
|
5198
5523
|
* Get the ATTR constants for external use
|
|
5199
5524
|
*/
|
|
5200
5525
|
static get ATTR() {
|
|
5201
|
-
return
|
|
5526
|
+
return R;
|
|
5202
5527
|
}
|
|
5203
5528
|
/**
|
|
5204
5529
|
* Enter collapsed bold mode by inserting an empty <strong> for typing
|
|
@@ -5209,7 +5534,7 @@ const X = (r) => {
|
|
|
5209
5534
|
if (!t.collapsed)
|
|
5210
5535
|
return;
|
|
5211
5536
|
const n = document.createElement("strong"), o = document.createTextNode("");
|
|
5212
|
-
n.appendChild(o), n.setAttribute(
|
|
5537
|
+
n.appendChild(o), n.setAttribute(R.COLLAPSED_ACTIVE, "true");
|
|
5213
5538
|
const s = t.startContainer, i = t.startOffset;
|
|
5214
5539
|
if (!(s.nodeType === Node.TEXT_NODE ? this.insertCollapsedBoldIntoText(s, n, i) : s.nodeType === Node.ELEMENT_NODE ? (this.insertCollapsedBoldIntoElement(s, n, i), !0) : !1))
|
|
5215
5540
|
return;
|
|
@@ -5231,7 +5556,7 @@ const X = (r) => {
|
|
|
5231
5556
|
const s = t.textContent, i = s.slice(0, n), l = s.slice(n);
|
|
5232
5557
|
t.textContent = i;
|
|
5233
5558
|
const a = l.length ? document.createTextNode(l) : null;
|
|
5234
|
-
return a && o.insertBefore(a, t.nextSibling), o.insertBefore(e, a != null ? a : t.nextSibling), e.setAttribute(
|
|
5559
|
+
return a && o.insertBefore(a, t.nextSibling), o.insertBefore(e, a != null ? a : t.nextSibling), e.setAttribute(R.PREV_LENGTH, i.length.toString()), !0;
|
|
5235
5560
|
}
|
|
5236
5561
|
/**
|
|
5237
5562
|
* Insert a collapsed bold wrapper directly into an element container
|
|
@@ -5239,7 +5564,7 @@ const X = (r) => {
|
|
|
5239
5564
|
insertCollapsedBoldIntoElement(t, e, n) {
|
|
5240
5565
|
var s;
|
|
5241
5566
|
const o = (s = t.childNodes[n]) != null ? s : null;
|
|
5242
|
-
t.insertBefore(e, o), e.setAttribute(
|
|
5567
|
+
t.insertBefore(e, o), e.setAttribute(R.PREV_LENGTH, "0");
|
|
5243
5568
|
}
|
|
5244
5569
|
/**
|
|
5245
5570
|
* Exit a collapsed bold selection by moving caret outside the bold element
|
|
@@ -5247,16 +5572,16 @@ const X = (r) => {
|
|
|
5247
5572
|
* @param boldElement - The bold element to exit from
|
|
5248
5573
|
*/
|
|
5249
5574
|
exit(t, e) {
|
|
5250
|
-
const n =
|
|
5575
|
+
const n = z(e), o = n.parentNode;
|
|
5251
5576
|
if (o)
|
|
5252
|
-
return
|
|
5577
|
+
return Ke(n) ? this.removeEmptyBoldElement(t, n, o) : this.exitBoldWithContent(t, n, o);
|
|
5253
5578
|
}
|
|
5254
5579
|
removeEmptyBoldElement(t, e, n) {
|
|
5255
5580
|
const o = document.createRange();
|
|
5256
5581
|
return o.setStartBefore(e), o.collapse(!0), n.removeChild(e), t.removeAllRanges(), t.addRange(o), o;
|
|
5257
5582
|
}
|
|
5258
5583
|
exitBoldWithContent(t, e, n) {
|
|
5259
|
-
e.setAttribute(
|
|
5584
|
+
e.setAttribute(R.COLLAPSED_LENGTH, e.textContent.length.toString()), e.removeAttribute(R.PREV_LENGTH), e.removeAttribute(R.COLLAPSED_ACTIVE), e.removeAttribute(R.LEADING_WHITESPACE);
|
|
5260
5585
|
const o = e.nextSibling, s = !o || o.nodeType !== Node.TEXT_NODE, i = s ? document.createTextNode("") : null;
|
|
5261
5586
|
i && n.insertBefore(i, o);
|
|
5262
5587
|
const l = i != null ? i : o;
|
|
@@ -5277,7 +5602,7 @@ const X = (r) => {
|
|
|
5277
5602
|
maintain() {
|
|
5278
5603
|
if (typeof document != "undefined")
|
|
5279
5604
|
for (const t of Array.from(this.records)) {
|
|
5280
|
-
const e =
|
|
5605
|
+
const e = yi(t);
|
|
5281
5606
|
if (!e) {
|
|
5282
5607
|
this.records.delete(t);
|
|
5283
5608
|
continue;
|
|
@@ -5314,13 +5639,13 @@ const X = (r) => {
|
|
|
5314
5639
|
*/
|
|
5315
5640
|
synchronize(t) {
|
|
5316
5641
|
var i, l;
|
|
5317
|
-
const e = (i = t == null ? void 0 : t.anchorNode) != null ? i : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = (l = n == null ? void 0 : n.closest(
|
|
5642
|
+
const e = (i = t == null ? void 0 : t.anchorNode) != null ? i : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = (l = n == null ? void 0 : n.closest($(B.editor))) != null ? l : n == null ? void 0 : n.ownerDocument;
|
|
5318
5643
|
if (!o)
|
|
5319
5644
|
return;
|
|
5320
|
-
const s = `strong[${
|
|
5645
|
+
const s = `strong[${R.COLLAPSED_ACTIVE}="true"]`;
|
|
5321
5646
|
o.querySelectorAll(s).forEach((a) => {
|
|
5322
|
-
var
|
|
5323
|
-
const c = a.getAttribute(
|
|
5647
|
+
var st;
|
|
5648
|
+
const c = a.getAttribute(R.PREV_LENGTH), d = a.previousSibling;
|
|
5324
5649
|
if (!c || !d || d.nodeType !== Node.TEXT_NODE)
|
|
5325
5650
|
return;
|
|
5326
5651
|
const h = Number(c);
|
|
@@ -5332,15 +5657,15 @@ const X = (r) => {
|
|
|
5332
5657
|
const g = p.slice(0, h), f = p.slice(h);
|
|
5333
5658
|
u.textContent = g;
|
|
5334
5659
|
const m = f.match(/^[\u00A0\s]+/);
|
|
5335
|
-
if (m && !a.hasAttribute(
|
|
5660
|
+
if (m && !a.hasAttribute(R.LEADING_WHITESPACE) && a.setAttribute(R.LEADING_WHITESPACE, m[0]), f.length === 0)
|
|
5336
5661
|
return;
|
|
5337
|
-
const C = a.textContent, v = C + f, k = (
|
|
5662
|
+
const C = a.textContent, v = C + f, k = (st = a.getAttribute(R.LEADING_WHITESPACE)) != null ? st : "", E = k.length > 0 && C.length === 0 && !v.startsWith(k) ? k + v : v, A = document.createTextNode(E);
|
|
5338
5663
|
for (; a.firstChild; )
|
|
5339
5664
|
a.removeChild(a.firstChild);
|
|
5340
|
-
if (a.appendChild(
|
|
5665
|
+
if (a.appendChild(A), !(t != null && t.isCollapsed) || !Ht(t.focusNode, u))
|
|
5341
5666
|
return;
|
|
5342
|
-
const N = document.createRange(),
|
|
5343
|
-
N.setStart(
|
|
5667
|
+
const N = document.createRange(), ut = A.textContent.length;
|
|
5668
|
+
N.setStart(A, ut), N.collapse(!0), t.removeAllRanges(), t.addRange(N);
|
|
5344
5669
|
});
|
|
5345
5670
|
}
|
|
5346
5671
|
/**
|
|
@@ -5352,29 +5677,29 @@ const X = (r) => {
|
|
|
5352
5677
|
const e = (i = t == null ? void 0 : t.anchorNode) != null ? i : t == null ? void 0 : t.focusNode;
|
|
5353
5678
|
if (!e)
|
|
5354
5679
|
return;
|
|
5355
|
-
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, o = n == null ? void 0 : n.closest(
|
|
5680
|
+
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, o = n == null ? void 0 : n.closest($(B.editor));
|
|
5356
5681
|
if (!o)
|
|
5357
5682
|
return;
|
|
5358
|
-
o.querySelectorAll(`strong[${
|
|
5683
|
+
o.querySelectorAll(`strong[${R.COLLAPSED_LENGTH}]`).forEach((l) => {
|
|
5359
5684
|
var k, x;
|
|
5360
|
-
const a = l.getAttribute(
|
|
5685
|
+
const a = l.getAttribute(R.COLLAPSED_LENGTH);
|
|
5361
5686
|
if (!a)
|
|
5362
5687
|
return;
|
|
5363
5688
|
const c = Number(a), d = l.textContent;
|
|
5364
5689
|
if (!Number.isFinite(c))
|
|
5365
5690
|
return;
|
|
5366
|
-
const h = d.length > c, u = h ? this.splitCollapsedBoldText(l, c, d) : null, p = l.getAttribute(
|
|
5691
|
+
const h = d.length > c, u = h ? this.splitCollapsedBoldText(l, c, d) : null, p = l.getAttribute(R.PREV_LENGTH), g = p ? Number(p) : NaN, f = l.previousSibling, m = (f == null ? void 0 : f.nodeType) === Node.TEXT_NODE ? f : null, C = (k = m == null ? void 0 : m.textContent) != null ? k : "", v = !!(p && Number.isFinite(g) && m && C.length > g);
|
|
5367
5692
|
if (v && m) {
|
|
5368
|
-
const
|
|
5369
|
-
m.textContent =
|
|
5370
|
-
const N = document.createTextNode(
|
|
5693
|
+
const E = C.slice(0, g), A = C.slice(g);
|
|
5694
|
+
m.textContent = E;
|
|
5695
|
+
const N = document.createTextNode(A);
|
|
5371
5696
|
(x = l.parentNode) == null || x.insertBefore(N, l.nextSibling);
|
|
5372
5697
|
}
|
|
5373
|
-
if (v && l.removeAttribute(
|
|
5374
|
-
const
|
|
5375
|
-
|
|
5698
|
+
if (v && l.removeAttribute(R.PREV_LENGTH), t != null && t.isCollapsed && u && Ht(t.focusNode, l)) {
|
|
5699
|
+
const E = document.createRange(), A = u.textContent.length;
|
|
5700
|
+
E.setStart(u, A), E.collapse(!0), t.removeAllRanges(), t.addRange(E);
|
|
5376
5701
|
}
|
|
5377
|
-
h && l.removeAttribute(
|
|
5702
|
+
h && l.removeAttribute(R.COLLAPSED_LENGTH);
|
|
5378
5703
|
});
|
|
5379
5704
|
}
|
|
5380
5705
|
/**
|
|
@@ -5432,8 +5757,8 @@ const X = (r) => {
|
|
|
5432
5757
|
const e = t.getRangeAt(0);
|
|
5433
5758
|
if (!e.collapsed)
|
|
5434
5759
|
return;
|
|
5435
|
-
const n =
|
|
5436
|
-
(n == null ? void 0 : n.getAttribute(
|
|
5760
|
+
const n = G(e.startContainer);
|
|
5761
|
+
(n == null ? void 0 : n.getAttribute(R.COLLAPSED_ACTIVE)) !== "true" && (this.moveCaretFromElementContainer(t, e) || this.moveCaretFromTextContainer(t, e));
|
|
5437
5762
|
}
|
|
5438
5763
|
/**
|
|
5439
5764
|
* Adjust caret when selection container is an element adjacent to bold content
|
|
@@ -5491,7 +5816,7 @@ const X = (r) => {
|
|
|
5491
5816
|
this.setCaret(t, n, s.length);
|
|
5492
5817
|
return;
|
|
5493
5818
|
}
|
|
5494
|
-
const l =
|
|
5819
|
+
const l = G(n);
|
|
5495
5820
|
if (!l || e.startOffset !== n.textContent.length)
|
|
5496
5821
|
return;
|
|
5497
5822
|
const a = this.ensureFollowingTextNode(l, l.nextSibling);
|
|
@@ -5539,20 +5864,20 @@ const X = (r) => {
|
|
|
5539
5864
|
};
|
|
5540
5865
|
M.instance = null;
|
|
5541
5866
|
let I = M;
|
|
5542
|
-
const
|
|
5867
|
+
const vi = {
|
|
5543
5868
|
convertLegacyTags: !0,
|
|
5544
5869
|
normalizeWhitespace: !0,
|
|
5545
5870
|
removeEmpty: !0,
|
|
5546
5871
|
mergeAdjacent: !0,
|
|
5547
5872
|
preserveNode: null
|
|
5548
5873
|
};
|
|
5549
|
-
class
|
|
5874
|
+
class O {
|
|
5550
5875
|
/**
|
|
5551
5876
|
* Create a new normalization pass with specified options
|
|
5552
5877
|
* @param options - Configuration for the normalization pass
|
|
5553
5878
|
*/
|
|
5554
5879
|
constructor(t) {
|
|
5555
|
-
this.options =
|
|
5880
|
+
this.options = T(T({}, vi), t);
|
|
5556
5881
|
}
|
|
5557
5882
|
/**
|
|
5558
5883
|
* Run normalization on a scoped element
|
|
@@ -5570,10 +5895,10 @@ class H {
|
|
|
5570
5895
|
* @param options - Optional normalization configuration
|
|
5571
5896
|
*/
|
|
5572
5897
|
static normalizeAroundSelection(t, e) {
|
|
5573
|
-
const n =
|
|
5898
|
+
const n = O.findScopeFromSelection(t);
|
|
5574
5899
|
if (!n)
|
|
5575
5900
|
return;
|
|
5576
|
-
new
|
|
5901
|
+
new O(e).run(n);
|
|
5577
5902
|
}
|
|
5578
5903
|
/**
|
|
5579
5904
|
* Phase 1: Traverse the scope and normalize text nodes while collecting elements
|
|
@@ -5618,7 +5943,7 @@ class H {
|
|
|
5618
5943
|
processCollectedElements(t, e) {
|
|
5619
5944
|
this.options.convertLegacyTags && t.forEach((n) => {
|
|
5620
5945
|
if (n.isConnected) {
|
|
5621
|
-
const o =
|
|
5946
|
+
const o = z(n);
|
|
5622
5947
|
e.push(o);
|
|
5623
5948
|
}
|
|
5624
5949
|
}), e.forEach((n) => {
|
|
@@ -5648,7 +5973,7 @@ class H {
|
|
|
5648
5973
|
* @returns true if the element is empty and doesn't contain the preserved node
|
|
5649
5974
|
*/
|
|
5650
5975
|
isEmptyAndSafe(t) {
|
|
5651
|
-
return !(t.textContent.length === 0) || I.getInstance().isActivePlaceholder(t) ? !1 : !(this.options.preserveNode &&
|
|
5976
|
+
return !(t.textContent.length === 0) || I.getInstance().isActivePlaceholder(t) ? !1 : !(this.options.preserveNode && Ht(this.options.preserveNode, t));
|
|
5652
5977
|
}
|
|
5653
5978
|
/**
|
|
5654
5979
|
* Merge a <strong> element with adjacent <strong> siblings
|
|
@@ -5656,12 +5981,12 @@ class H {
|
|
|
5656
5981
|
*/
|
|
5657
5982
|
mergeWithAdjacent(t) {
|
|
5658
5983
|
const e = t.previousSibling;
|
|
5659
|
-
if (e &&
|
|
5984
|
+
if (e && St(e)) {
|
|
5660
5985
|
this.mergeStrongNodes(e, t);
|
|
5661
5986
|
return;
|
|
5662
5987
|
}
|
|
5663
5988
|
const n = t.nextSibling;
|
|
5664
|
-
n &&
|
|
5989
|
+
n && St(n) && this.mergeStrongNodes(t, n);
|
|
5665
5990
|
}
|
|
5666
5991
|
/**
|
|
5667
5992
|
* Merge two <strong> elements by moving children from right to left
|
|
@@ -5669,7 +5994,7 @@ class H {
|
|
|
5669
5994
|
* @param right - The right strong element to merge from
|
|
5670
5995
|
*/
|
|
5671
5996
|
mergeStrongNodes(t, e) {
|
|
5672
|
-
const n =
|
|
5997
|
+
const n = z(t), o = z(e);
|
|
5673
5998
|
for (; o.firstChild; )
|
|
5674
5999
|
n.appendChild(o.firstChild);
|
|
5675
6000
|
o.remove();
|
|
@@ -5687,11 +6012,11 @@ class H {
|
|
|
5687
6012
|
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5688
6013
|
if (!n)
|
|
5689
6014
|
return null;
|
|
5690
|
-
const o = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest(
|
|
5691
|
-
return o || n.closest(
|
|
6015
|
+
const o = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest($(B.elementContent));
|
|
6016
|
+
return o || n.closest($(B.editor));
|
|
5692
6017
|
}
|
|
5693
6018
|
}
|
|
5694
|
-
const
|
|
6019
|
+
const H = class H {
|
|
5695
6020
|
constructor() {
|
|
5696
6021
|
this.handlers = /* @__PURE__ */ new Map(), this.listenersRegistered = !1, this.handleSelectionChange = () => {
|
|
5697
6022
|
const t = this.getSelection();
|
|
@@ -5724,13 +6049,13 @@ const P = class P {
|
|
|
5724
6049
|
* Get the singleton instance
|
|
5725
6050
|
*/
|
|
5726
6051
|
static getInstance() {
|
|
5727
|
-
return
|
|
6052
|
+
return H.instance || (H.instance = new H()), H.instance;
|
|
5728
6053
|
}
|
|
5729
6054
|
/**
|
|
5730
6055
|
* Reset the singleton instance (for testing)
|
|
5731
6056
|
*/
|
|
5732
6057
|
static reset() {
|
|
5733
|
-
|
|
6058
|
+
H.instance && (H.instance.removeListeners(), H.instance.handlers.clear()), H.instance = null;
|
|
5734
6059
|
}
|
|
5735
6060
|
/**
|
|
5736
6061
|
* Register a handler for an inline tool
|
|
@@ -5782,9 +6107,9 @@ const P = class P {
|
|
|
5782
6107
|
return !(e.meta && !s || e.ctrl && !t.ctrlKey);
|
|
5783
6108
|
}
|
|
5784
6109
|
};
|
|
5785
|
-
|
|
5786
|
-
let
|
|
5787
|
-
const
|
|
6110
|
+
H.instance = null;
|
|
6111
|
+
let Ot = H;
|
|
6112
|
+
const Si = (r, t) => {
|
|
5788
6113
|
try {
|
|
5789
6114
|
return r.intersectsNode(t);
|
|
5790
6115
|
} catch (e) {
|
|
@@ -5793,25 +6118,25 @@ const Xs = (r, t) => {
|
|
|
5793
6118
|
const o = r.compareBoundaryPoints(Range.END_TO_START, n) > 0, s = r.compareBoundaryPoints(Range.START_TO_END, n) < 0;
|
|
5794
6119
|
return o && s;
|
|
5795
6120
|
}
|
|
5796
|
-
},
|
|
6121
|
+
}, Ue = (r) => document.createTreeWalker(
|
|
5797
6122
|
r.commonAncestorContainer,
|
|
5798
6123
|
NodeFilter.SHOW_TEXT,
|
|
5799
6124
|
{
|
|
5800
|
-
acceptNode: (t) =>
|
|
6125
|
+
acceptNode: (t) => Si(r, t) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
|
|
5801
6126
|
}
|
|
5802
|
-
),
|
|
6127
|
+
), J = (r, t, e) => !r || r === e ? null : r.nodeType === Node.ELEMENT_NODE && t(r) ? r : J(r.parentNode, t, e), je = (r, t) => J(r, t) !== null, Mt = (r, t, e = {}) => {
|
|
5803
6128
|
if (r.collapsed)
|
|
5804
|
-
return
|
|
5805
|
-
const n =
|
|
6129
|
+
return J(r.startContainer, t) !== null;
|
|
6130
|
+
const n = Ue(r), o = [];
|
|
5806
6131
|
for (; n.nextNode(); ) {
|
|
5807
6132
|
const s = n.currentNode, i = s.textContent;
|
|
5808
6133
|
e.ignoreWhitespace && i.trim().length === 0 || i.length !== 0 && o.push(s);
|
|
5809
6134
|
}
|
|
5810
|
-
return o.length === 0 ?
|
|
5811
|
-
},
|
|
5812
|
-
const e = /* @__PURE__ */ new Set(), n =
|
|
6135
|
+
return o.length === 0 ? J(r.startContainer, t) !== null : o.every((s) => je(s, t));
|
|
6136
|
+
}, dt = (r, t) => {
|
|
6137
|
+
const e = /* @__PURE__ */ new Set(), n = Ue(r);
|
|
5813
6138
|
for (; n.nextNode(); ) {
|
|
5814
|
-
const o =
|
|
6139
|
+
const o = J(n.currentNode, t);
|
|
5815
6140
|
o && e.add(o);
|
|
5816
6141
|
}
|
|
5817
6142
|
return Array.from(e);
|
|
@@ -5839,7 +6164,7 @@ const Xs = (r, t) => {
|
|
|
5839
6164
|
static initializeGlobalListeners() {
|
|
5840
6165
|
if (typeof document == "undefined")
|
|
5841
6166
|
return !1;
|
|
5842
|
-
const t =
|
|
6167
|
+
const t = Ot.getInstance();
|
|
5843
6168
|
return t.hasHandler("bold") || (t.register("bold", {
|
|
5844
6169
|
shortcut: { key: "b", meta: !0 },
|
|
5845
6170
|
onShortcut: (e, n) => {
|
|
@@ -5852,7 +6177,7 @@ const Xs = (r, t) => {
|
|
|
5852
6177
|
onInput: (e, n) => {
|
|
5853
6178
|
S.refreshSelectionState("input");
|
|
5854
6179
|
},
|
|
5855
|
-
onBeforeInput: (e) => e.inputType !== "formatBold" ? !1 : (
|
|
6180
|
+
onBeforeInput: (e) => e.inputType !== "formatBold" ? !1 : (O.normalizeAroundSelection(window.getSelection()), !0),
|
|
5856
6181
|
isRelevant: (e) => S.isSelectionInsideBlok(e)
|
|
5857
6182
|
}), S.guardKeydownListenerRegistered || (document.addEventListener("keydown", (e) => {
|
|
5858
6183
|
I.getInstance().guardBoundaryKeydown(e);
|
|
@@ -5864,7 +6189,7 @@ const Xs = (r, t) => {
|
|
|
5864
6189
|
* @param right - The right strong element to merge from
|
|
5865
6190
|
*/
|
|
5866
6191
|
static mergeStrongNodes(t, e) {
|
|
5867
|
-
const n =
|
|
6192
|
+
const n = z(t), o = z(e);
|
|
5868
6193
|
for (; o.firstChild; )
|
|
5869
6194
|
n.appendChild(o.firstChild);
|
|
5870
6195
|
return o.remove(), n;
|
|
@@ -5874,7 +6199,7 @@ const Xs = (r, t) => {
|
|
|
5874
6199
|
*/
|
|
5875
6200
|
render() {
|
|
5876
6201
|
return {
|
|
5877
|
-
icon:
|
|
6202
|
+
icon: Dn,
|
|
5878
6203
|
name: "bold",
|
|
5879
6204
|
onActivate: () => {
|
|
5880
6205
|
this.toggleBold();
|
|
@@ -5918,11 +6243,11 @@ const Xs = (r, t) => {
|
|
|
5918
6243
|
o && n && (o.removeAllRanges(), o.addRange(n));
|
|
5919
6244
|
const s = this.findBoldElementFromRangeOrSelection(n, o);
|
|
5920
6245
|
if (!s) {
|
|
5921
|
-
|
|
6246
|
+
O.normalizeAroundSelection(o), this.notifySelectionChange();
|
|
5922
6247
|
return;
|
|
5923
6248
|
}
|
|
5924
6249
|
const i = this.mergeAdjacentBold(s);
|
|
5925
|
-
this.selectElementContents(i),
|
|
6250
|
+
this.selectElementContents(i), O.normalizeAroundSelection(o), this.notifySelectionChange();
|
|
5926
6251
|
}
|
|
5927
6252
|
/**
|
|
5928
6253
|
* Remove bold tags (<strong>) while preserving content
|
|
@@ -5936,7 +6261,7 @@ const Xs = (r, t) => {
|
|
|
5936
6261
|
o.setAttribute("data-blok-bold-marker", `unwrap-${S.markerSequence++}`), o.appendChild(s), this.removeNestedBold(o), t.insertNode(o);
|
|
5937
6262
|
const i = document.createRange();
|
|
5938
6263
|
for (i.selectNodeContents(o), n.removeAllRanges(), n.addRange(i); ; ) {
|
|
5939
|
-
const d =
|
|
6264
|
+
const d = G(o);
|
|
5940
6265
|
if (!d)
|
|
5941
6266
|
break;
|
|
5942
6267
|
this.moveMarkerOutOfBold(o, d);
|
|
@@ -5945,8 +6270,8 @@ const Xs = (r, t) => {
|
|
|
5945
6270
|
this.unwrapElement(o), l && a && (() => {
|
|
5946
6271
|
const d = document.createRange();
|
|
5947
6272
|
return d.setStartBefore(l), d.setEndAfter(a), n.removeAllRanges(), n.addRange(d), d;
|
|
5948
|
-
})() || n.removeAllRanges(),
|
|
5949
|
-
|
|
6273
|
+
})() || n.removeAllRanges(), O.normalizeAroundSelection(n), e.forEach((d) => {
|
|
6274
|
+
Ke(d) && d.remove();
|
|
5950
6275
|
}), this.notifySelectionChange();
|
|
5951
6276
|
}
|
|
5952
6277
|
/**
|
|
@@ -6011,7 +6336,7 @@ const Xs = (r, t) => {
|
|
|
6011
6336
|
* @param options.ignoreWhitespace - Whether to ignore whitespace-only text nodes
|
|
6012
6337
|
*/
|
|
6013
6338
|
isRangeBold(t, e) {
|
|
6014
|
-
return
|
|
6339
|
+
return Mt(t, X, e);
|
|
6015
6340
|
}
|
|
6016
6341
|
/**
|
|
6017
6342
|
* Remove nested bold tags from a root node
|
|
@@ -6043,11 +6368,11 @@ const Xs = (r, t) => {
|
|
|
6043
6368
|
*/
|
|
6044
6369
|
findBoldElementFromRangeOrSelection(t, e) {
|
|
6045
6370
|
if (!t)
|
|
6046
|
-
return e ?
|
|
6047
|
-
const n =
|
|
6371
|
+
return e ? G(e.focusNode) : null;
|
|
6372
|
+
const n = G(t.startContainer);
|
|
6048
6373
|
if (n)
|
|
6049
6374
|
return n;
|
|
6050
|
-
const o =
|
|
6375
|
+
const o = G(t.commonAncestorContainer);
|
|
6051
6376
|
return o || (t.startContainer.nodeType === Node.ELEMENT_NODE && X(t.startContainer) ? t.startContainer : null);
|
|
6052
6377
|
}
|
|
6053
6378
|
/**
|
|
@@ -6055,7 +6380,7 @@ const Xs = (r, t) => {
|
|
|
6055
6380
|
* @param element - The bold element to merge with adjacent elements
|
|
6056
6381
|
*/
|
|
6057
6382
|
mergeAdjacentBold(t) {
|
|
6058
|
-
const e =
|
|
6383
|
+
const e = z(t), n = e.previousSibling, o = n && n.nodeType === Node.ELEMENT_NODE && X(n) ? S.mergeStrongNodes(n, e) : e, s = o.nextSibling;
|
|
6059
6384
|
return s && s.nodeType === Node.ELEMENT_NODE && X(s) ? S.mergeStrongNodes(o, s) : o;
|
|
6060
6385
|
}
|
|
6061
6386
|
/**
|
|
@@ -6066,13 +6391,13 @@ const Xs = (r, t) => {
|
|
|
6066
6391
|
const t = window.getSelection();
|
|
6067
6392
|
if (!t || t.rangeCount === 0)
|
|
6068
6393
|
return;
|
|
6069
|
-
const e = t.getRangeAt(0), n =
|
|
6394
|
+
const e = t.getRangeAt(0), n = G(e.startContainer), o = (() => {
|
|
6070
6395
|
if (n && n.getAttribute(I.ATTR.COLLAPSED_ACTIVE) !== "true")
|
|
6071
6396
|
return I.getInstance().exit(t, n);
|
|
6072
6397
|
const s = n != null ? n : S.getBoundaryBold(e);
|
|
6073
6398
|
return s ? I.getInstance().exit(t, s) : this.startCollapsedBold(e);
|
|
6074
6399
|
})();
|
|
6075
|
-
document.dispatchEvent(new Event("selectionchange")), o && (t.removeAllRanges(), t.addRange(o)),
|
|
6400
|
+
document.dispatchEvent(new Event("selectionchange")), o && (t.removeAllRanges(), t.addRange(o)), O.normalizeAroundSelection(t), this.notifySelectionChange();
|
|
6076
6401
|
}
|
|
6077
6402
|
/**
|
|
6078
6403
|
* Insert a bold wrapper at the caret so newly typed text becomes bold
|
|
@@ -6080,7 +6405,7 @@ const Xs = (r, t) => {
|
|
|
6080
6405
|
*/
|
|
6081
6406
|
startCollapsedBold(t) {
|
|
6082
6407
|
const n = I.getInstance().enter(t, (s) => this.mergeAdjacentBold(s)), o = window.getSelection();
|
|
6083
|
-
return
|
|
6408
|
+
return O.normalizeAroundSelection(o), o && n && (o.removeAllRanges(), o.addRange(n)), this.notifySelectionChange(), n;
|
|
6084
6409
|
}
|
|
6085
6410
|
/**
|
|
6086
6411
|
* Notify listeners that the selection state has changed
|
|
@@ -6095,7 +6420,7 @@ const Xs = (r, t) => {
|
|
|
6095
6420
|
const t = window.getSelection();
|
|
6096
6421
|
if (!t)
|
|
6097
6422
|
return;
|
|
6098
|
-
const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = n == null ? void 0 : n.closest(
|
|
6423
|
+
const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = n == null ? void 0 : n.closest($(B.editor));
|
|
6099
6424
|
if (!o)
|
|
6100
6425
|
return;
|
|
6101
6426
|
const s = o.querySelector("[data-blok-testid=inline-toolbar]");
|
|
@@ -6112,7 +6437,7 @@ const Xs = (r, t) => {
|
|
|
6112
6437
|
*/
|
|
6113
6438
|
static refreshSelectionState(t) {
|
|
6114
6439
|
const e = window.getSelection();
|
|
6115
|
-
I.getInstance().enforceLengths(e), I.getInstance().maintain(), I.getInstance().synchronize(e),
|
|
6440
|
+
I.getInstance().enforceLengths(e), I.getInstance().maintain(), I.getInstance().synchronize(e), O.normalizeAroundSelection(e, { normalizeWhitespace: !1 }), t === "input" && e && I.getInstance().moveCaretAfterBoundaryBold(e);
|
|
6116
6441
|
}
|
|
6117
6442
|
/**
|
|
6118
6443
|
* Ensure mutation observer is registered to convert legacy <b> tags
|
|
@@ -6125,7 +6450,7 @@ const Xs = (r, t) => {
|
|
|
6125
6450
|
S.isProcessingMutation = !0;
|
|
6126
6451
|
try {
|
|
6127
6452
|
const n = (o) => {
|
|
6128
|
-
o && new
|
|
6453
|
+
o && new O({ mergeAdjacent: !1, removeEmpty: !1, normalizeWhitespace: !1 }).run(o);
|
|
6129
6454
|
};
|
|
6130
6455
|
e.forEach((o) => {
|
|
6131
6456
|
o.addedNodes.forEach((s) => {
|
|
@@ -6150,7 +6475,7 @@ const Xs = (r, t) => {
|
|
|
6150
6475
|
*/
|
|
6151
6476
|
static findBlokScopeFromNode(t) {
|
|
6152
6477
|
const e = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
6153
|
-
return !e || typeof e.closest != "function" ? null : e.closest(`${
|
|
6478
|
+
return !e || typeof e.closest != "function" ? null : e.closest(`${$(B.interface)}, ${$(B.editor)}`);
|
|
6154
6479
|
}
|
|
6155
6480
|
/**
|
|
6156
6481
|
* Get a bold element at the boundary of a collapsed range
|
|
@@ -6168,11 +6493,11 @@ const Xs = (r, t) => {
|
|
|
6168
6493
|
static getBoundaryBoldForText(t, e) {
|
|
6169
6494
|
const n = e.textContent.length;
|
|
6170
6495
|
if (t.startOffset === n)
|
|
6171
|
-
return
|
|
6496
|
+
return G(e);
|
|
6172
6497
|
if (t.startOffset !== 0)
|
|
6173
6498
|
return null;
|
|
6174
6499
|
const o = e.previousSibling;
|
|
6175
|
-
return
|
|
6500
|
+
return St(o) ? o : null;
|
|
6176
6501
|
}
|
|
6177
6502
|
/**
|
|
6178
6503
|
* Get boundary bold when caret container is an element
|
|
@@ -6183,7 +6508,7 @@ const Xs = (r, t) => {
|
|
|
6183
6508
|
if (t.startOffset <= 0)
|
|
6184
6509
|
return null;
|
|
6185
6510
|
const n = e.childNodes[t.startOffset - 1];
|
|
6186
|
-
return
|
|
6511
|
+
return St(n) ? n : null;
|
|
6187
6512
|
}
|
|
6188
6513
|
/**
|
|
6189
6514
|
* Check if a selection is inside the blok
|
|
@@ -6194,7 +6519,7 @@ const Xs = (r, t) => {
|
|
|
6194
6519
|
if (!e)
|
|
6195
6520
|
return !1;
|
|
6196
6521
|
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
6197
|
-
return !!(n != null && n.closest(
|
|
6522
|
+
return !!(n != null && n.closest($(B.editor)));
|
|
6198
6523
|
}
|
|
6199
6524
|
/**
|
|
6200
6525
|
* Get HTML content of a range with bold tags removed
|
|
@@ -6219,15 +6544,15 @@ const Xs = (r, t) => {
|
|
|
6219
6544
|
* @param range - The range to search for bold ancestors
|
|
6220
6545
|
*/
|
|
6221
6546
|
collectBoldAncestors(t) {
|
|
6222
|
-
return
|
|
6547
|
+
return dt(t, X);
|
|
6223
6548
|
}
|
|
6224
6549
|
};
|
|
6225
6550
|
S.isInline = !0, S.title = "Bold", S.titleKey = "bold", S.markerSequence = 0, S.isProcessingMutation = !1, S.instances = /* @__PURE__ */ new Set(), S.guardKeydownListenerRegistered = !1, S.shortcut = "CMD+B";
|
|
6226
|
-
let
|
|
6227
|
-
const
|
|
6551
|
+
let Ce = S;
|
|
6552
|
+
const yt = (r) => {
|
|
6228
6553
|
const t = r.tagName;
|
|
6229
6554
|
return t === "I" || t === "EM";
|
|
6230
|
-
},
|
|
6555
|
+
}, tt = class tt {
|
|
6231
6556
|
/**
|
|
6232
6557
|
* Sanitizer Rule
|
|
6233
6558
|
* Leave <i> and <em> tags
|
|
@@ -6244,7 +6569,7 @@ const Ct = (r) => {
|
|
|
6244
6569
|
*/
|
|
6245
6570
|
render() {
|
|
6246
6571
|
return {
|
|
6247
|
-
icon:
|
|
6572
|
+
icon: Pn,
|
|
6248
6573
|
name: "italic",
|
|
6249
6574
|
onActivate: () => {
|
|
6250
6575
|
this.toggleItalic();
|
|
@@ -6303,7 +6628,7 @@ const Ct = (r) => {
|
|
|
6303
6628
|
* @param options - Options for checking italic status
|
|
6304
6629
|
*/
|
|
6305
6630
|
isRangeItalic(t, e) {
|
|
6306
|
-
return
|
|
6631
|
+
return Mt(t, yt, e);
|
|
6307
6632
|
}
|
|
6308
6633
|
/**
|
|
6309
6634
|
* Wrap selection with <i> tag
|
|
@@ -6343,21 +6668,21 @@ const Ct = (r) => {
|
|
|
6343
6668
|
* @param node - The node to check
|
|
6344
6669
|
*/
|
|
6345
6670
|
hasItalicParent(t) {
|
|
6346
|
-
return
|
|
6671
|
+
return je(t, yt);
|
|
6347
6672
|
}
|
|
6348
6673
|
/**
|
|
6349
6674
|
* Find an italic element in the parent chain
|
|
6350
6675
|
* @param node - The node to start searching from
|
|
6351
6676
|
*/
|
|
6352
6677
|
findItalicElement(t) {
|
|
6353
|
-
return
|
|
6678
|
+
return J(t, yt);
|
|
6354
6679
|
}
|
|
6355
6680
|
/**
|
|
6356
6681
|
* Collect all italic ancestor elements within a range
|
|
6357
6682
|
* @param range - The range to search for italic ancestors
|
|
6358
6683
|
*/
|
|
6359
6684
|
collectItalicAncestors(t) {
|
|
6360
|
-
return
|
|
6685
|
+
return dt(t, yt);
|
|
6361
6686
|
}
|
|
6362
6687
|
/**
|
|
6363
6688
|
* Get HTML content of a range with italic tags removed
|
|
@@ -6444,9 +6769,9 @@ const Ct = (r) => {
|
|
|
6444
6769
|
n.insertBefore(l, e.nextSibling), n.insertBefore(t, l);
|
|
6445
6770
|
}
|
|
6446
6771
|
};
|
|
6447
|
-
|
|
6448
|
-
let
|
|
6449
|
-
const
|
|
6772
|
+
tt.isInline = !0, tt.title = "Italic", tt.titleKey = "italic", tt.shortcut = "CMD+I";
|
|
6773
|
+
let be = tt;
|
|
6774
|
+
const et = class et {
|
|
6450
6775
|
/**
|
|
6451
6776
|
* @param api - Blok API
|
|
6452
6777
|
*/
|
|
@@ -6460,7 +6785,7 @@ const tt = class tt {
|
|
|
6460
6785
|
button: null
|
|
6461
6786
|
}, this.inputOpened = !1, this.unlinkAvailable = !1, this.handleButtonClick = (e) => {
|
|
6462
6787
|
!this.inputOpened || !this.unlinkAvailable || (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), this.restoreSelection(), this.unlink(), this.inlineToolbar.close());
|
|
6463
|
-
}, this.toolbar = t.toolbar, this.inlineToolbar = t.inlineToolbar, this.notifier = t.notifier, this.i18n = t.i18n, this.selection = new
|
|
6788
|
+
}, this.toolbar = t.toolbar, this.inlineToolbar = t.inlineToolbar, this.notifier = t.notifier, this.i18n = t.i18n, this.selection = new lt(), this.nodes.input = this.createInput();
|
|
6464
6789
|
}
|
|
6465
6790
|
/**
|
|
6466
6791
|
* Sanitizer Rule
|
|
@@ -6481,7 +6806,7 @@ const tt = class tt {
|
|
|
6481
6806
|
*/
|
|
6482
6807
|
render() {
|
|
6483
6808
|
return {
|
|
6484
|
-
icon:
|
|
6809
|
+
icon: Hn,
|
|
6485
6810
|
name: "link",
|
|
6486
6811
|
isActive: () => !!this.selection.findParentTag("A"),
|
|
6487
6812
|
children: {
|
|
@@ -6489,7 +6814,7 @@ const tt = class tt {
|
|
|
6489
6814
|
width: "200px",
|
|
6490
6815
|
items: [
|
|
6491
6816
|
{
|
|
6492
|
-
type:
|
|
6817
|
+
type: F.Html,
|
|
6493
6818
|
// Input is created in constructor, so it's always available here
|
|
6494
6819
|
element: this.nodes.input
|
|
6495
6820
|
}
|
|
@@ -6540,7 +6865,7 @@ const tt = class tt {
|
|
|
6540
6865
|
*/
|
|
6541
6866
|
getButtonElement() {
|
|
6542
6867
|
const t = document.querySelector(
|
|
6543
|
-
`${
|
|
6868
|
+
`${$(B.interface, Nn)} [data-blok-item-name="link"]`
|
|
6544
6869
|
);
|
|
6545
6870
|
return t && t !== this.nodes.button && (t.addEventListener("click", this.handleButtonClick, !0), this.nodes.button = t), t;
|
|
6546
6871
|
}
|
|
@@ -6567,7 +6892,7 @@ const tt = class tt {
|
|
|
6567
6892
|
* Restore selection after closing actions
|
|
6568
6893
|
*/
|
|
6569
6894
|
restoreSelection() {
|
|
6570
|
-
const t = new
|
|
6895
|
+
const t = new lt(), e = lt.isAtBlok;
|
|
6571
6896
|
if (e && t.save(), this.selection.removeFakeBackground(), this.selection.restore(), !e && this.selection.savedSelectionRange) {
|
|
6572
6897
|
const s = this.selection.savedSelectionRange.commonAncestorContainer, i = s.nodeType === Node.ELEMENT_NODE ? s : s.parentElement;
|
|
6573
6898
|
i == null || i.focus();
|
|
@@ -6597,7 +6922,7 @@ const tt = class tt {
|
|
|
6597
6922
|
this.notifier.show({
|
|
6598
6923
|
message: this.i18n.t("tools.link.invalidLink"),
|
|
6599
6924
|
style: "error"
|
|
6600
|
-
}),
|
|
6925
|
+
}), On("Incorrect Link pasted", "warn", e);
|
|
6601
6926
|
return;
|
|
6602
6927
|
}
|
|
6603
6928
|
const n = this.prepareLink(e);
|
|
@@ -6640,7 +6965,7 @@ const tt = class tt {
|
|
|
6640
6965
|
this.selection.expandToTag(e), e.href = t, e.target = "_blank", e.rel = "nofollow";
|
|
6641
6966
|
return;
|
|
6642
6967
|
}
|
|
6643
|
-
const n =
|
|
6968
|
+
const n = lt.range;
|
|
6644
6969
|
if (!n)
|
|
6645
6970
|
return;
|
|
6646
6971
|
const o = document.createElement("a");
|
|
@@ -6674,9 +6999,9 @@ const tt = class tt {
|
|
|
6674
6999
|
t && t.setAttribute(e, n ? "true" : "false");
|
|
6675
7000
|
}
|
|
6676
7001
|
};
|
|
6677
|
-
|
|
6678
|
-
let
|
|
6679
|
-
const
|
|
7002
|
+
et.isInline = !0, et.title = "Link", et.titleKey = "link", et.shortcut = "CMD+K";
|
|
7003
|
+
let ye = et;
|
|
7004
|
+
const ct = (r) => r.tagName === "MARK", Bt = (r) => J(r, ct), ve = {
|
|
6680
7005
|
color: "background-color",
|
|
6681
7006
|
"background-color": "color"
|
|
6682
7007
|
}, U = class U {
|
|
@@ -6684,7 +7009,7 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
6684
7009
|
* @param options - Inline tool constructor options with API
|
|
6685
7010
|
*/
|
|
6686
7011
|
constructor({ api: t }) {
|
|
6687
|
-
this.colorMode = "color", this.i18n = t.i18n, this.inlineToolbar = t.inlineToolbar, this.selection = new
|
|
7012
|
+
this.colorMode = "color", this.i18n = t.i18n, this.inlineToolbar = t.inlineToolbar, this.selection = new lt(), this.picker = $e({
|
|
6688
7013
|
i18n: this.i18n,
|
|
6689
7014
|
testIdPrefix: "marker",
|
|
6690
7015
|
defaultModeIndex: 0,
|
|
@@ -6718,21 +7043,21 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
6718
7043
|
*/
|
|
6719
7044
|
render() {
|
|
6720
7045
|
return {
|
|
6721
|
-
icon:
|
|
7046
|
+
icon: Ae,
|
|
6722
7047
|
name: "marker",
|
|
6723
7048
|
isActive: () => {
|
|
6724
7049
|
const t = window.getSelection();
|
|
6725
7050
|
if (!t || t.rangeCount === 0)
|
|
6726
7051
|
return !1;
|
|
6727
7052
|
const e = t.getRangeAt(0);
|
|
6728
|
-
return
|
|
7053
|
+
return Mt(e, ct, { ignoreWhitespace: !0 });
|
|
6729
7054
|
},
|
|
6730
7055
|
children: {
|
|
6731
7056
|
hideChevron: !0,
|
|
6732
7057
|
width: "200px",
|
|
6733
7058
|
items: [
|
|
6734
7059
|
{
|
|
6735
|
-
type:
|
|
7060
|
+
type: F.Html,
|
|
6736
7061
|
element: this.picker.element
|
|
6737
7062
|
}
|
|
6738
7063
|
],
|
|
@@ -6784,10 +7109,10 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
6784
7109
|
const e = window.getSelection();
|
|
6785
7110
|
if (!e || e.rangeCount === 0)
|
|
6786
7111
|
return;
|
|
6787
|
-
const n = e.getRangeAt(0), o = n.startContainer, s = n.startOffset, i = n.endContainer, l = n.endOffset, a = n.toString(), c = n.commonAncestorContainer, d = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement, h = d != null && d.closest("mark") && (m = (f = d.closest("mark")) == null ? void 0 : f.parentElement) != null ? m : d, u =
|
|
7112
|
+
const n = e.getRangeAt(0), o = n.startContainer, s = n.startOffset, i = n.endContainer, l = n.endOffset, a = n.toString(), c = n.commonAncestorContainer, d = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement, h = d != null && d.closest("mark") && (m = (f = d.closest("mark")) == null ? void 0 : f.parentElement) != null ? m : d, u = dt(n, ct);
|
|
6788
7113
|
for (const C of u) {
|
|
6789
7114
|
C.style.removeProperty(t);
|
|
6790
|
-
const v =
|
|
7115
|
+
const v = ve[t], k = C.style.getPropertyValue(v);
|
|
6791
7116
|
k !== "" && k !== "transparent" ? this.ensureTransparentBg(C) : this.unwrapElement(C);
|
|
6792
7117
|
}
|
|
6793
7118
|
const p = o.isConnected, g = i.isConnected;
|
|
@@ -6824,7 +7149,7 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
6824
7149
|
const t = window.getSelection();
|
|
6825
7150
|
if (!t || t.rangeCount === 0)
|
|
6826
7151
|
return null;
|
|
6827
|
-
const e = t.getRangeAt(0), n =
|
|
7152
|
+
const e = t.getRangeAt(0), n = Bt(e.startContainer);
|
|
6828
7153
|
if (!n)
|
|
6829
7154
|
return null;
|
|
6830
7155
|
const o = n.style.getPropertyValue("color");
|
|
@@ -6844,7 +7169,7 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
6844
7169
|
* @param range - The range to check
|
|
6845
7170
|
*/
|
|
6846
7171
|
findContainingMark(t) {
|
|
6847
|
-
const e =
|
|
7172
|
+
const e = Bt(t.startContainer), n = Bt(t.endContainer);
|
|
6848
7173
|
return e && e === n ? e : null;
|
|
6849
7174
|
}
|
|
6850
7175
|
/**
|
|
@@ -6853,10 +7178,10 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
6853
7178
|
* @param mode - The style property to remove
|
|
6854
7179
|
*/
|
|
6855
7180
|
removeNestedMarkStyle(t, e) {
|
|
6856
|
-
const n =
|
|
7181
|
+
const n = dt(t, ct);
|
|
6857
7182
|
for (const o of n) {
|
|
6858
7183
|
o.style.removeProperty(e);
|
|
6859
|
-
const s =
|
|
7184
|
+
const s = ve[e], i = o.style.getPropertyValue(s);
|
|
6860
7185
|
i !== "" && i !== "transparent" ? this.ensureTransparentBg(o) : this.unwrapElement(o);
|
|
6861
7186
|
}
|
|
6862
7187
|
}
|
|
@@ -6902,7 +7227,7 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
6902
7227
|
* @param range - The selection range
|
|
6903
7228
|
*/
|
|
6904
7229
|
splitMarksAtBoundaries(t) {
|
|
6905
|
-
const e =
|
|
7230
|
+
const e = dt(t, ct);
|
|
6906
7231
|
for (const n of e) {
|
|
6907
7232
|
const o = document.createRange();
|
|
6908
7233
|
o.selectNodeContents(n);
|
|
@@ -7003,28 +7328,30 @@ const lt = (r) => r.tagName === "MARK", Tt = (r) => Z(r, lt), ge = {
|
|
|
7003
7328
|
}
|
|
7004
7329
|
};
|
|
7005
7330
|
U.isInline = !0, U.title = "Color", U.titleKey = "marker", U.shortcut = "CMD+SHIFT+H", U.ALLOWED_STYLE_PROPS = /* @__PURE__ */ new Set(["color", "background-color"]);
|
|
7006
|
-
let
|
|
7007
|
-
const
|
|
7331
|
+
let Se = U;
|
|
7332
|
+
const Ti = {
|
|
7008
7333
|
paragraph: { preserveBlank: !0 },
|
|
7009
7334
|
header: {},
|
|
7010
7335
|
list: {},
|
|
7011
|
-
table: {}
|
|
7012
|
-
|
|
7336
|
+
table: {},
|
|
7337
|
+
toggle: {}
|
|
7338
|
+
}, Ri = {
|
|
7013
7339
|
bold: {},
|
|
7014
7340
|
italic: {},
|
|
7015
7341
|
link: {},
|
|
7016
7342
|
marker: {}
|
|
7017
7343
|
};
|
|
7018
7344
|
export {
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7345
|
+
Ce as Bold,
|
|
7346
|
+
Ii as Convert,
|
|
7347
|
+
Xt as Header,
|
|
7348
|
+
be as Italic,
|
|
7349
|
+
ye as Link,
|
|
7350
|
+
Ei as List,
|
|
7351
|
+
Se as Marker,
|
|
7352
|
+
jt as Paragraph,
|
|
7353
|
+
Ai as Table,
|
|
7354
|
+
xi as Toggle,
|
|
7355
|
+
Ti as defaultBlockTools,
|
|
7356
|
+
Ri as defaultInlineTools
|
|
7030
7357
|
};
|