@fileverse-dev/ddoc 1.1.7 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/dist/index.es.js +120 -108
- package/dist/index.umd.js +1 -1
- package/dist/packages/ddoc/ddoc-editor.d.ts +1 -1
- package/dist/packages/ddoc/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -37,6 +37,7 @@ The `DdocProps` interface is a TypeScript interface that defines the properties
|
|
37
37
|
| `enableCollaboration` (optional) | `boolean` | Optional property to enable collaboration
|
38
38
|
| `collaborationId` (optional) | `string` | When using enableCollaboration, you need to provide collaborationId, it can be uuid of doc |
|
39
39
|
| `toggleCollaboration` (optional) | `(flag: boolean) => void` | Function to toggle collaboration mode with a boolean flag |
|
40
|
+
| `onAutoSave` (optional) | `(flag:boolean) => void` | Function which expose the current editor state every 10 seconds |
|
40
41
|
|
41
42
|
## Data Interface
|
42
43
|
|
package/dist/index.es.js
CHANGED
@@ -2,7 +2,7 @@ var bw = Object.defineProperty;
|
|
2
2
|
var vw = (n, e, t) => e in n ? bw(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
3
3
|
var sr = (n, e, t) => (vw(n, typeof e != "symbol" ? e + "" : e, t), t);
|
4
4
|
import * as oe from "react";
|
5
|
-
import Oe, { forwardRef as ut, createContext as ms, useContext as qo, useRef as Re, useState as xe, useEffect as
|
5
|
+
import Oe, { forwardRef as ut, createContext as ms, useContext as qo, useRef as Re, useState as xe, useEffect as ke, createElement as Be, useCallback as Ot, useLayoutEffect as dc, useMemo as Ir, Children as rs, isValidElement as Zl, cloneElement as Ko, Fragment as ww, useReducer as xw } from "react";
|
6
6
|
import * as kw from "react-dom";
|
7
7
|
import Cw, { flushSync as sf, createPortal as Sw } from "react-dom";
|
8
8
|
var Ln = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
@@ -140,9 +140,9 @@ function Tw() {
|
|
140
140
|
return null;
|
141
141
|
}
|
142
142
|
var H = Object.assign, z = 0, K, J, re, Z, ve, Pe, $e;
|
143
|
-
function
|
143
|
+
function Ce() {
|
144
144
|
}
|
145
|
-
|
145
|
+
Ce.__reactDisabledLog = !0;
|
146
146
|
function me() {
|
147
147
|
{
|
148
148
|
if (z === 0) {
|
@@ -150,7 +150,7 @@ function Tw() {
|
|
150
150
|
var D = {
|
151
151
|
configurable: !0,
|
152
152
|
enumerable: !0,
|
153
|
-
value:
|
153
|
+
value: Ce,
|
154
154
|
writable: !0
|
155
155
|
};
|
156
156
|
Object.defineProperties(console, {
|
@@ -268,17 +268,17 @@ function Tw() {
|
|
268
268
|
}
|
269
269
|
} catch (Ut) {
|
270
270
|
if (Ut && de && typeof Ut.stack == "string") {
|
271
|
-
for (var
|
271
|
+
for (var Se = Ut.stack.split(`
|
272
272
|
`), Ft = de.stack.split(`
|
273
|
-
`), at =
|
273
|
+
`), at = Se.length - 1, ft = Ft.length - 1; at >= 1 && ft >= 0 && Se[at] !== Ft[ft]; )
|
274
274
|
ft--;
|
275
275
|
for (; at >= 1 && ft >= 0; at--, ft--)
|
276
|
-
if (
|
276
|
+
if (Se[at] !== Ft[ft]) {
|
277
277
|
if (at !== 1 || ft !== 1)
|
278
278
|
do
|
279
|
-
if (at--, ft--, ft < 0 ||
|
279
|
+
if (at--, ft--, ft < 0 || Se[at] !== Ft[ft]) {
|
280
280
|
var an = `
|
281
|
-
` +
|
281
|
+
` + Se[at].replace(" at new ", " at ");
|
282
282
|
return D.displayName && an.includes("<anonymous>") && (an = an.replace("<anonymous>", D.displayName)), typeof D == "function" && Ye.set(D, an), an;
|
283
283
|
}
|
284
284
|
while (at >= 1 && ft >= 0);
|
@@ -340,17 +340,17 @@ function Tw() {
|
|
340
340
|
var He = Function.call.bind($);
|
341
341
|
for (var Ae in D)
|
342
342
|
if (He(D, Ae)) {
|
343
|
-
var
|
343
|
+
var Se = void 0;
|
344
344
|
try {
|
345
345
|
if (typeof D[Ae] != "function") {
|
346
346
|
var Ft = Error((de || "React class") + ": " + X + " type `" + Ae + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof D[Ae] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
347
347
|
throw Ft.name = "Invariant Violation", Ft;
|
348
348
|
}
|
349
|
-
|
349
|
+
Se = D[Ae](q, Ae, de, X, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
350
350
|
} catch (at) {
|
351
|
-
|
351
|
+
Se = at;
|
352
352
|
}
|
353
|
-
|
353
|
+
Se && !(Se instanceof Error) && (M(Ie), S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", de || "React class", X, Ae, typeof Se), M(null)), Se instanceof Error && !(Se.message in W) && (W[Se.message] = !0, M(Ie), S("Failed %s type: %s", X, Se.message), M(null));
|
354
354
|
}
|
355
355
|
}
|
356
356
|
}
|
@@ -430,7 +430,7 @@ function Tw() {
|
|
430
430
|
}
|
431
431
|
}
|
432
432
|
var De = function(D, q, X, de, Ie, He, Ae) {
|
433
|
-
var
|
433
|
+
var Se = {
|
434
434
|
// This tag allows us to uniquely identify this as a React Element
|
435
435
|
$$typeof: e,
|
436
436
|
// Built-in properties that belong on the element
|
@@ -441,27 +441,27 @@ function Tw() {
|
|
441
441
|
// Record the component responsible for creating this element.
|
442
442
|
_owner: He
|
443
443
|
};
|
444
|
-
return
|
444
|
+
return Se._store = {}, Object.defineProperty(Se._store, "validated", {
|
445
445
|
configurable: !1,
|
446
446
|
enumerable: !1,
|
447
447
|
writable: !0,
|
448
448
|
value: !1
|
449
|
-
}), Object.defineProperty(
|
449
|
+
}), Object.defineProperty(Se, "_self", {
|
450
450
|
configurable: !1,
|
451
451
|
enumerable: !1,
|
452
452
|
writable: !1,
|
453
453
|
value: de
|
454
|
-
}), Object.defineProperty(
|
454
|
+
}), Object.defineProperty(Se, "_source", {
|
455
455
|
configurable: !1,
|
456
456
|
enumerable: !1,
|
457
457
|
writable: !1,
|
458
458
|
value: Ie
|
459
|
-
}), Object.freeze && (Object.freeze(
|
459
|
+
}), Object.freeze && (Object.freeze(Se.props), Object.freeze(Se)), Se;
|
460
460
|
};
|
461
461
|
function Ee(D, q, X, de, Ie) {
|
462
462
|
{
|
463
|
-
var He, Ae = {},
|
464
|
-
X !== void 0 && (te(X),
|
463
|
+
var He, Ae = {}, Se = null, Ft = null;
|
464
|
+
X !== void 0 && (te(X), Se = "" + X), Dn(q) && (te(q.key), Se = "" + q.key), xn(q) && (Ft = q.ref, V(q, Ie));
|
465
465
|
for (He in q)
|
466
466
|
$.call(q, He) && !Ne.hasOwnProperty(He) && (Ae[He] = q[He]);
|
467
467
|
if (D && D.defaultProps) {
|
@@ -469,11 +469,11 @@ function Tw() {
|
|
469
469
|
for (He in at)
|
470
470
|
Ae[He] === void 0 && (Ae[He] = at[He]);
|
471
471
|
}
|
472
|
-
if (
|
472
|
+
if (Se || Ft) {
|
473
473
|
var ft = typeof D == "function" ? D.displayName || D.name || "Unknown" : D;
|
474
|
-
|
474
|
+
Se && Q(Ae, ft), Ft && se(Ae, ft);
|
475
475
|
}
|
476
|
-
return De(D,
|
476
|
+
return De(D, Se, Ft, Ie, de, ue.current, Ae);
|
477
477
|
}
|
478
478
|
}
|
479
479
|
var mt = w.ReactCurrentOwner, Pt = w.ReactDebugCurrentFrame;
|
@@ -591,12 +591,12 @@ Check the top-level render call using <` + X + ">.");
|
|
591
591
|
{
|
592
592
|
var Ae = A(D);
|
593
593
|
if (!Ae) {
|
594
|
-
var
|
595
|
-
(D === void 0 || typeof D == "object" && D !== null && Object.keys(D).length === 0) && (
|
594
|
+
var Se = "";
|
595
|
+
(D === void 0 || typeof D == "object" && D !== null && Object.keys(D).length === 0) && (Se += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
596
596
|
var Ft = $i();
|
597
|
-
Ft ?
|
597
|
+
Ft ? Se += Ft : Se += Bi();
|
598
598
|
var at;
|
599
|
-
D === null ? at = "null" : k(D) ? at = "array" : D !== void 0 && D.$$typeof === e ? (at = "<" + (B(D.type) || "Unknown") + " />",
|
599
|
+
D === null ? at = "null" : k(D) ? at = "array" : D !== void 0 && D.$$typeof === e ? (at = "<" + (B(D.type) || "Unknown") + " />", Se = " Did you accidentally export a JSX literal instead of a component?") : at = typeof D, S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", at, Se);
|
600
600
|
}
|
601
601
|
var ft = Ee(D, q, X, Ie, He);
|
602
602
|
if (ft == null)
|
@@ -13078,8 +13078,8 @@ function fE(n) {
|
|
13078
13078
|
if (Fe)
|
13079
13079
|
return O = Fe, "break";
|
13080
13080
|
}, $e = ve; $e > 0; $e--) {
|
13081
|
-
var
|
13082
|
-
if (
|
13081
|
+
var Ce = Pe($e);
|
13082
|
+
if (Ce === "break")
|
13083
13083
|
break;
|
13084
13084
|
}
|
13085
13085
|
e.placement !== O && (e.modifiersData[r]._skip = !0, e.placement = O, e.reset = !0);
|
@@ -13198,7 +13198,7 @@ function kE(n) {
|
|
13198
13198
|
};
|
13199
13199
|
if (E) {
|
13200
13200
|
if (s) {
|
13201
|
-
var B, H = y === "y" ? Jt : Gt, z = y === "y" ? bn : vn, K = y === "y" ? "height" : "width", J = E[y], re = J + v[H], Z = J - v[z], ve = h ? -R[K] / 2 : 0, Pe = S === xs ? T[K] : R[K], $e = S === xs ? -R[K] : -T[K],
|
13201
|
+
var B, H = y === "y" ? Jt : Gt, z = y === "y" ? bn : vn, K = y === "y" ? "height" : "width", J = E[y], re = J + v[H], Z = J - v[z], ve = h ? -R[K] / 2 : 0, Pe = S === xs ? T[K] : R[K], $e = S === xs ? -R[K] : -T[K], Ce = e.elements.arrow, me = h && Ce ? Nf(Ce) : {
|
13202
13202
|
width: 0,
|
13203
13203
|
height: 0
|
13204
13204
|
}, Le = e.modifiersData["arrow#persistent"] ? e.modifiersData["arrow#persistent"].padding : My(), Fe = Le[H], nt = Le[z], rt = io(0, T[K], me[K]), Ge = x ? T[K] / 2 - ve - rt - Fe - A.mainAxis : Pe - rt - Fe - A.mainAxis, Ye = x ? -T[K] / 2 + ve + rt + nt + A.mainAxis : $e + rt + nt + A.mainAxis, Nt = e.elements.arrow && el(e.elements.arrow), yt = Nt ? y === "y" ? Nt.clientTop || 0 : Nt.clientLeft || 0 : 0, lt = (B = N == null ? void 0 : N[y]) != null ? B : 0, dt = J + Ge - lt - yt, F = J + Ye - lt, $ = io(h ? fa(re, dt) : re, J, h ? gi(Z, F) : Z);
|
@@ -13897,7 +13897,7 @@ function aT(n, e) {
|
|
13897
13897
|
}
|
13898
13898
|
}
|
13899
13899
|
}
|
13900
|
-
function
|
13900
|
+
function Ce() {
|
13901
13901
|
a = !0;
|
13902
13902
|
}
|
13903
13903
|
function me() {
|
@@ -13905,11 +13905,11 @@ function aT(n, e) {
|
|
13905
13905
|
}
|
13906
13906
|
function Le() {
|
13907
13907
|
var V = H();
|
13908
|
-
V.addEventListener("mousedown", $e, !0), V.addEventListener("touchend", $e, ri), V.addEventListener("touchstart", me, ri), V.addEventListener("touchmove",
|
13908
|
+
V.addEventListener("mousedown", $e, !0), V.addEventListener("touchend", $e, ri), V.addEventListener("touchstart", me, ri), V.addEventListener("touchmove", Ce, ri);
|
13909
13909
|
}
|
13910
13910
|
function Fe() {
|
13911
13911
|
var V = H();
|
13912
|
-
V.removeEventListener("mousedown", $e, !0), V.removeEventListener("touchend", $e, ri), V.removeEventListener("touchstart", me, ri), V.removeEventListener("touchmove",
|
13912
|
+
V.removeEventListener("mousedown", $e, !0), V.removeEventListener("touchend", $e, ri), V.removeEventListener("touchstart", me, ri), V.removeEventListener("touchmove", Ce, ri);
|
13913
13913
|
}
|
13914
13914
|
function nt(V, Q) {
|
13915
13915
|
Ge(V, function() {
|
@@ -14448,9 +14448,9 @@ class gT extends TS {
|
|
14448
14448
|
}
|
14449
14449
|
const yT = (n = {}, e = []) => {
|
14450
14450
|
const t = Re(null), [, r] = xe({}), { onBeforeCreate: i, onBlur: s, onCreate: o, onDestroy: l, onFocus: a, onSelectionUpdate: c, onTransaction: u, onUpdate: d } = n, f = Re(i), h = Re(s), p = Re(o), g = Re(l), v = Re(a), w = Re(c), S = Re(u), x = Re(d);
|
14451
|
-
return
|
14451
|
+
return ke(() => {
|
14452
14452
|
t.current && (i && (t.current.off("beforeCreate", f.current), t.current.on("beforeCreate", i), f.current = i), s && (t.current.off("blur", h.current), t.current.on("blur", s), h.current = s), o && (t.current.off("create", p.current), t.current.on("create", o), p.current = o), l && (t.current.off("destroy", g.current), t.current.on("destroy", l), g.current = l), a && (t.current.off("focus", v.current), t.current.on("focus", a), v.current = a), c && (t.current.off("selectionUpdate", w.current), t.current.on("selectionUpdate", c), w.current = c), u && (t.current.off("transaction", S.current), t.current.on("transaction", u), S.current = u), d && (t.current.off("update", x.current), t.current.on("update", d), x.current = d));
|
14453
|
-
}, [i, s, o, l, a, c, u, d, t.current]),
|
14453
|
+
}, [i, s, o, l, a, c, u, d, t.current]), ke(() => {
|
14454
14454
|
let y = !0;
|
14455
14455
|
const C = new gT(n);
|
14456
14456
|
return t.current = C, t.current.on("transaction", () => {
|
@@ -14469,7 +14469,7 @@ const yT = (n = {}, e = []) => {
|
|
14469
14469
|
Wy.Consumer;
|
14470
14470
|
const bT = () => qo(Wy), qy = (n) => {
|
14471
14471
|
const [e, t] = xe(null), { editor: r } = bT();
|
14472
|
-
return
|
14472
|
+
return ke(() => {
|
14473
14473
|
var i;
|
14474
14474
|
if (!e || !((i = n.editor) === null || i === void 0) && i.isDestroyed || r != null && r.isDestroyed)
|
14475
14475
|
return;
|
@@ -15325,7 +15325,7 @@ function qT(n) {
|
|
15325
15325
|
/* NONE */
|
15326
15326
|
);
|
15327
15327
|
};
|
15328
|
-
return
|
15328
|
+
return ke(() => (document.addEventListener("click", i, !0), () => {
|
15329
15329
|
document.removeEventListener("click", i, !0);
|
15330
15330
|
}), []), { ref: r, toolVisibilty: e, setToolVisibility: t };
|
15331
15331
|
}
|
@@ -23128,7 +23128,7 @@ var j1 = { exports: {} };
|
|
23128
23128
|
P += a(L[j] + 256 * L[j + 1]);
|
23129
23129
|
return P;
|
23130
23130
|
}
|
23131
|
-
function
|
23131
|
+
function Ce(m, b, k) {
|
23132
23132
|
if (m % 1 != 0 || 0 > m)
|
23133
23133
|
throw new RangeError("offset is not uint");
|
23134
23134
|
if (m + b > k)
|
@@ -23403,57 +23403,57 @@ var j1 = { exports: {} };
|
|
23403
23403
|
var L = this.subarray(m, b);
|
23404
23404
|
return L.__proto__ = d.prototype, L;
|
23405
23405
|
}, d.prototype.readUIntLE = function(m, b, k) {
|
23406
|
-
m >>>= 0, b >>>= 0, k ||
|
23406
|
+
m >>>= 0, b >>>= 0, k || Ce(m, b, this.length);
|
23407
23407
|
for (var L = this[m], P = 1, j = 0; ++j < b && (P *= 256); )
|
23408
23408
|
L += this[m + j] * P;
|
23409
23409
|
return L;
|
23410
23410
|
}, d.prototype.readUIntBE = function(m, b, k) {
|
23411
|
-
m >>>= 0, b >>>= 0, k ||
|
23411
|
+
m >>>= 0, b >>>= 0, k || Ce(m, b, this.length);
|
23412
23412
|
for (var L = this[m + --b], P = 1; 0 < b && (P *= 256); )
|
23413
23413
|
L += this[m + --b] * P;
|
23414
23414
|
return L;
|
23415
23415
|
}, d.prototype.readUInt8 = function(m, b) {
|
23416
|
-
return m >>>= 0, b ||
|
23416
|
+
return m >>>= 0, b || Ce(m, 1, this.length), this[m];
|
23417
23417
|
}, d.prototype.readUInt16LE = function(m, b) {
|
23418
|
-
return m >>>= 0, b ||
|
23418
|
+
return m >>>= 0, b || Ce(m, 2, this.length), this[m] | this[m + 1] << 8;
|
23419
23419
|
}, d.prototype.readUInt16BE = function(m, b) {
|
23420
|
-
return m >>>= 0, b ||
|
23420
|
+
return m >>>= 0, b || Ce(m, 2, this.length), this[m] << 8 | this[m + 1];
|
23421
23421
|
}, d.prototype.readUInt32LE = function(m, b) {
|
23422
|
-
return m >>>= 0, b ||
|
23422
|
+
return m >>>= 0, b || Ce(m, 4, this.length), (this[m] | this[m + 1] << 8 | this[m + 2] << 16) + 16777216 * this[m + 3];
|
23423
23423
|
}, d.prototype.readUInt32BE = function(m, b) {
|
23424
|
-
return m >>>= 0, b ||
|
23424
|
+
return m >>>= 0, b || Ce(m, 4, this.length), 16777216 * this[m] + (this[m + 1] << 16 | this[m + 2] << 8 | this[m + 3]);
|
23425
23425
|
}, d.prototype.readIntLE = function(m, b, k) {
|
23426
|
-
m >>>= 0, b >>>= 0, k ||
|
23426
|
+
m >>>= 0, b >>>= 0, k || Ce(m, b, this.length);
|
23427
23427
|
for (var L = this[m], P = 1, j = 0; ++j < b && (P *= 256); )
|
23428
23428
|
L += this[m + j] * P;
|
23429
23429
|
return P *= 128, L >= P && (L -= i(2, 8 * b)), L;
|
23430
23430
|
}, d.prototype.readIntBE = function(m, b, k) {
|
23431
|
-
m >>>= 0, b >>>= 0, k ||
|
23431
|
+
m >>>= 0, b >>>= 0, k || Ce(m, b, this.length);
|
23432
23432
|
for (var L = b, P = 1, j = this[m + --L]; 0 < L && (P *= 256); )
|
23433
23433
|
j += this[m + --L] * P;
|
23434
23434
|
return P *= 128, j >= P && (j -= i(2, 8 * b)), j;
|
23435
23435
|
}, d.prototype.readInt8 = function(m, b) {
|
23436
|
-
return m >>>= 0, b ||
|
23436
|
+
return m >>>= 0, b || Ce(m, 1, this.length), 128 & this[m] ? -1 * (255 - this[m] + 1) : this[m];
|
23437
23437
|
}, d.prototype.readInt16LE = function(m, b) {
|
23438
|
-
m >>>= 0, b ||
|
23438
|
+
m >>>= 0, b || Ce(m, 2, this.length);
|
23439
23439
|
var k = this[m] | this[m + 1] << 8;
|
23440
23440
|
return 32768 & k ? 4294901760 | k : k;
|
23441
23441
|
}, d.prototype.readInt16BE = function(m, b) {
|
23442
|
-
m >>>= 0, b ||
|
23442
|
+
m >>>= 0, b || Ce(m, 2, this.length);
|
23443
23443
|
var k = this[m + 1] | this[m] << 8;
|
23444
23444
|
return 32768 & k ? 4294901760 | k : k;
|
23445
23445
|
}, d.prototype.readInt32LE = function(m, b) {
|
23446
|
-
return m >>>= 0, b ||
|
23446
|
+
return m >>>= 0, b || Ce(m, 4, this.length), this[m] | this[m + 1] << 8 | this[m + 2] << 16 | this[m + 3] << 24;
|
23447
23447
|
}, d.prototype.readInt32BE = function(m, b) {
|
23448
|
-
return m >>>= 0, b ||
|
23448
|
+
return m >>>= 0, b || Ce(m, 4, this.length), this[m] << 24 | this[m + 1] << 16 | this[m + 2] << 8 | this[m + 3];
|
23449
23449
|
}, d.prototype.readFloatLE = function(m, b) {
|
23450
|
-
return m >>>= 0, b ||
|
23450
|
+
return m >>>= 0, b || Ce(m, 4, this.length), ee.read(this, m, !0, 23, 4);
|
23451
23451
|
}, d.prototype.readFloatBE = function(m, b) {
|
23452
|
-
return m >>>= 0, b ||
|
23452
|
+
return m >>>= 0, b || Ce(m, 4, this.length), ee.read(this, m, !1, 23, 4);
|
23453
23453
|
}, d.prototype.readDoubleLE = function(m, b) {
|
23454
|
-
return m >>>= 0, b ||
|
23454
|
+
return m >>>= 0, b || Ce(m, 8, this.length), ee.read(this, m, !0, 52, 8);
|
23455
23455
|
}, d.prototype.readDoubleBE = function(m, b) {
|
23456
|
-
return m >>>= 0, b ||
|
23456
|
+
return m >>>= 0, b || Ce(m, 8, this.length), ee.read(this, m, !1, 52, 8);
|
23457
23457
|
}, d.prototype.writeUIntLE = function(m, b, k, L) {
|
23458
23458
|
if (m = +m, b >>>= 0, k >>>= 0, !L) {
|
23459
23459
|
var P = i(2, 8 * k) - 1;
|
@@ -24204,7 +24204,7 @@ Use Chrome, Firefox or Internet Explorer 11`);
|
|
24204
24204
|
return $e.from(M);
|
24205
24205
|
}
|
24206
24206
|
function u(M) {
|
24207
|
-
return $e.isBuffer(M) || M instanceof
|
24207
|
+
return $e.isBuffer(M) || M instanceof Ce;
|
24208
24208
|
}
|
24209
24209
|
function d(M, m, b) {
|
24210
24210
|
return typeof M.prependListener == "function" ? M.prependListener(m, b) : void (M._events && M._events[m] ? Array.isArray(M._events[m]) ? M._events[m].unshift(b) : M._events[m] = [b, M._events[m]] : M.on(m, b));
|
@@ -24335,7 +24335,7 @@ Use Chrome, Firefox or Internet Explorer 11`);
|
|
24335
24335
|
s("events").EventEmitter;
|
24336
24336
|
var ve = function(M, m) {
|
24337
24337
|
return M.listeners(m).length;
|
24338
|
-
}, Pe = s("./internal/streams/stream"), $e = s("buffer").Buffer,
|
24338
|
+
}, Pe = s("./internal/streams/stream"), $e = s("buffer").Buffer, Ce = a.Uint8Array || function() {
|
24339
24339
|
}, me = s("util");
|
24340
24340
|
Z = me && me.debuglog ? me.debuglog("stream") : function() {
|
24341
24341
|
};
|
@@ -24557,7 +24557,7 @@ Use Chrome, Firefox or Internet Explorer 11`);
|
|
24557
24557
|
function f() {
|
24558
24558
|
}
|
24559
24559
|
function h(F, $, W) {
|
24560
|
-
K = K || s("./_stream_duplex"), F = F || {}, typeof W != "boolean" && (W = $ instanceof K), this.objectMode = !!F.objectMode, W && (this.objectMode = this.objectMode || !!F.writableObjectMode), this.highWaterMark =
|
24560
|
+
K = K || s("./_stream_duplex"), F = F || {}, typeof W != "boolean" && (W = $ instanceof K), this.objectMode = !!F.objectMode, W && (this.objectMode = this.objectMode || !!F.writableObjectMode), this.highWaterMark = Ce(this, F, "writableHighWaterMark", W), this.finalCalled = !1, this.needDrain = !1, this.ending = !1, this.ended = !1, this.finished = !1, this.destroyed = !1;
|
24561
24561
|
var ee = F.decodeStrings === !1;
|
24562
24562
|
this.decodeStrings = !ee, this.defaultEncoding = F.defaultEncoding || "utf8", this.length = 0, this.writing = !1, this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(M) {
|
24563
24563
|
E($, M);
|
@@ -24673,7 +24673,7 @@ Use Chrome, Firefox or Internet Explorer 11`);
|
|
24673
24673
|
var K;
|
24674
24674
|
p.WritableState = h;
|
24675
24675
|
var J = { deprecate: s("util-deprecate") }, re = s("./internal/streams/stream"), Z = s("buffer").Buffer, ve = a.Uint8Array || function() {
|
24676
|
-
}, Pe = s("./internal/streams/destroy"), $e = s("./internal/streams/state"),
|
24676
|
+
}, Pe = s("./internal/streams/destroy"), $e = s("./internal/streams/state"), Ce = $e.getHighWaterMark, me = s("../errors").codes, Le = me.ERR_INVALID_ARG_TYPE, Fe = me.ERR_METHOD_NOT_IMPLEMENTED, nt = me.ERR_MULTIPLE_CALLBACK, rt = me.ERR_STREAM_CANNOT_PIPE, Ge = me.ERR_STREAM_DESTROYED, Ye = me.ERR_STREAM_NULL_VALUES, Nt = me.ERR_STREAM_WRITE_AFTER_END, yt = me.ERR_UNKNOWN_ENCODING, lt = Pe.errorOrDestroy;
|
24677
24677
|
s("inherits")(p, re), h.prototype.getBuffer = function() {
|
24678
24678
|
for (var F = this.bufferedRequest, $ = []; F; )
|
24679
24679
|
$.push(F), F = F.next;
|
@@ -30201,7 +30201,7 @@ const j_ = Je.create({
|
|
30201
30201
|
},
|
30202
30202
|
[e, t, n]
|
30203
30203
|
);
|
30204
|
-
|
30204
|
+
ke(() => {
|
30205
30205
|
const l = ["ArrowUp", "ArrowDown", "Enter"], a = (c) => {
|
30206
30206
|
if (l.includes(c.key))
|
30207
30207
|
return c.preventDefault(), c.key === "ArrowUp" ? (i((r + n.length - 1) % n.length), !0) : c.key === "ArrowDown" ? (i((r + 1) % n.length), !0) : c.key === "Enter" ? (s(r), !0) : !1;
|
@@ -30209,7 +30209,7 @@ const j_ = Je.create({
|
|
30209
30209
|
return document.addEventListener("keydown", a), () => {
|
30210
30210
|
document.removeEventListener("keydown", a);
|
30211
30211
|
};
|
30212
|
-
}, [n, r, i, s]),
|
30212
|
+
}, [n, r, i, s]), ke(() => {
|
30213
30213
|
i(0);
|
30214
30214
|
}, [n]);
|
30215
30215
|
const o = Re(null);
|
@@ -30410,7 +30410,7 @@ const gv = ({
|
|
30410
30410
|
}, w = (I) => {
|
30411
30411
|
qi = I;
|
30412
30412
|
};
|
30413
|
-
|
30413
|
+
ke(() => {
|
30414
30414
|
v();
|
30415
30415
|
}, []);
|
30416
30416
|
const S = ({ width: I, height: B }) => I < 200 || B < 200, x = (I) => {
|
@@ -30448,7 +30448,7 @@ const gv = ({
|
|
30448
30448
|
E(z, Math.abs(H)), qi = B;
|
30449
30449
|
});
|
30450
30450
|
}, [R, O] = xe(), [A, N] = xe();
|
30451
|
-
return
|
30451
|
+
return ke(() => {
|
30452
30452
|
s(n.attrs["media-type"]), g(), O(n.attrs.dataFloat), N(n.attrs.dataAlign);
|
30453
30453
|
}, [n.attrs]), /* @__PURE__ */ _.jsx(
|
30454
30454
|
tl,
|
@@ -30627,7 +30627,7 @@ var X_ = "https://platform.twitter.com/widgets.js", Du = "createTweet", Q_ = fun
|
|
30627
30627
|
};
|
30628
30628
|
const eN = ({ node: n, editor: e }) => {
|
30629
30629
|
const [t, r] = xe(!0);
|
30630
|
-
return
|
30630
|
+
return ke(() => {
|
30631
30631
|
e == null || e.chain().focus();
|
30632
30632
|
}, []), /* @__PURE__ */ _.jsx(
|
30633
30633
|
tl,
|
@@ -31076,7 +31076,7 @@ const dN = [
|
|
31076
31076
|
], js = dN.reduce((n, e) => {
|
31077
31077
|
const t = /* @__PURE__ */ ut((r, i) => {
|
31078
31078
|
const { asChild: s, ...o } = r, l = s ? Th : e;
|
31079
|
-
return
|
31079
|
+
return ke(() => {
|
31080
31080
|
window[Symbol.for("radix-ui")] = !0;
|
31081
31081
|
}, []), /* @__PURE__ */ Be(l, _t({}, o, {
|
31082
31082
|
ref: i
|
@@ -31094,7 +31094,7 @@ function fN(n, e) {
|
|
31094
31094
|
}
|
31095
31095
|
function Jr(n) {
|
31096
31096
|
const e = Re(n);
|
31097
|
-
return
|
31097
|
+
return ke(() => {
|
31098
31098
|
e.current = n;
|
31099
31099
|
}), Ir(
|
31100
31100
|
() => (...t) => {
|
@@ -31106,7 +31106,7 @@ function Jr(n) {
|
|
31106
31106
|
}
|
31107
31107
|
function hN(n, e = globalThis == null ? void 0 : globalThis.document) {
|
31108
31108
|
const t = Jr(n);
|
31109
|
-
|
31109
|
+
ke(() => {
|
31110
31110
|
const r = (i) => {
|
31111
31111
|
i.key === "Escape" && t(i);
|
31112
31112
|
};
|
@@ -31146,7 +31146,7 @@ const gN = /* @__PURE__ */ ms({
|
|
31146
31146
|
}, h);
|
31147
31147
|
return hN((R) => {
|
31148
31148
|
x === u.layers.size - 1 && (i == null || i(R), !R.defaultPrevented && a && (R.preventDefault(), a()));
|
31149
|
-
}, h),
|
31149
|
+
}, h), ke(() => {
|
31150
31150
|
if (d)
|
31151
31151
|
return r && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (fg = h.body.style.pointerEvents, h.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(d)), u.layers.add(d), hg(), () => {
|
31152
31152
|
r && u.layersWithOutsidePointerEventsDisabled.size === 1 && (h.body.style.pointerEvents = fg);
|
@@ -31156,12 +31156,12 @@ const gN = /* @__PURE__ */ ms({
|
|
31156
31156
|
h,
|
31157
31157
|
r,
|
31158
31158
|
u
|
31159
|
-
]),
|
31159
|
+
]), ke(() => () => {
|
31160
31160
|
d && (u.layers.delete(d), u.layersWithOutsidePointerEventsDisabled.delete(d), hg());
|
31161
31161
|
}, [
|
31162
31162
|
d,
|
31163
31163
|
u
|
31164
|
-
]),
|
31164
|
+
]), ke(() => {
|
31165
31165
|
const R = () => p({});
|
31166
31166
|
return document.addEventListener(Jd, R), () => document.removeEventListener(Jd, R);
|
31167
31167
|
}, []), /* @__PURE__ */ Be(js.div, _t({}, c, {
|
@@ -31178,7 +31178,7 @@ const gN = /* @__PURE__ */ ms({
|
|
31178
31178
|
function bN(n, e = globalThis == null ? void 0 : globalThis.document) {
|
31179
31179
|
const t = Jr(n), r = Re(!1), i = Re(() => {
|
31180
31180
|
});
|
31181
|
-
return
|
31181
|
+
return ke(() => {
|
31182
31182
|
const s = (l) => {
|
31183
31183
|
if (l.target && !r.current) {
|
31184
31184
|
let c = function() {
|
@@ -31211,7 +31211,7 @@ function bN(n, e = globalThis == null ? void 0 : globalThis.document) {
|
|
31211
31211
|
}
|
31212
31212
|
function vN(n, e = globalThis == null ? void 0 : globalThis.document) {
|
31213
31213
|
const t = Jr(n), r = Re(!1);
|
31214
|
-
return
|
31214
|
+
return ke(() => {
|
31215
31215
|
const i = (s) => {
|
31216
31216
|
s.target && !r.current && wv(mN, t, {
|
31217
31217
|
originalEvent: s
|
@@ -31244,7 +31244,7 @@ function wv(n, e, t, { discrete: r }) {
|
|
31244
31244
|
}
|
31245
31245
|
let Lu = 0;
|
31246
31246
|
function wN() {
|
31247
|
-
|
31247
|
+
ke(() => {
|
31248
31248
|
var n, e;
|
31249
31249
|
const t = document.querySelectorAll("[data-radix-focus-guard]");
|
31250
31250
|
return document.body.insertAdjacentElement("afterbegin", (n = t[0]) !== null && n !== void 0 ? n : pg()), document.body.insertAdjacentElement("beforeend", (e = t[1]) !== null && e !== void 0 ? e : pg()), Lu++, () => {
|
@@ -31274,7 +31274,7 @@ const Iu = "focusScope.autoFocusOnMount", Pu = "focusScope.autoFocusOnUnmount",
|
|
31274
31274
|
this.paused = !1;
|
31275
31275
|
}
|
31276
31276
|
}).current;
|
31277
|
-
|
31277
|
+
ke(() => {
|
31278
31278
|
if (r) {
|
31279
31279
|
let g = function(x) {
|
31280
31280
|
if (h.paused || !l)
|
@@ -31308,7 +31308,7 @@ const Iu = "focusScope.autoFocusOnMount", Pu = "focusScope.autoFocusOnUnmount",
|
|
31308
31308
|
r,
|
31309
31309
|
l,
|
31310
31310
|
h.paused
|
31311
|
-
]),
|
31311
|
+
]), ke(() => {
|
31312
31312
|
if (l) {
|
31313
31313
|
yg.add(h);
|
31314
31314
|
const g = document.activeElement;
|
@@ -32513,7 +32513,7 @@ const hD = UN, pD = WN, mD = HN, gD = KN, yD = VN, Eg = jN, bD = qN, vD = (n, e,
|
|
32513
32513
|
platform: s
|
32514
32514
|
});
|
32515
32515
|
};
|
32516
|
-
var Kl = typeof document < "u" ? dc :
|
32516
|
+
var Kl = typeof document < "u" ? dc : ke;
|
32517
32517
|
function uc(n, e) {
|
32518
32518
|
if (n === e)
|
32519
32519
|
return !0;
|
@@ -32740,7 +32740,7 @@ const _v = "Popper", [Nv, Dv] = vv(_v), [RD, Lv] = Nv(_v), _D = (n) => {
|
|
32740
32740
|
}, t);
|
32741
32741
|
}, ND = "PopperAnchor", DD = /* @__PURE__ */ ut((n, e) => {
|
32742
32742
|
const { __scopePopper: t, virtualRef: r, ...i } = n, s = Lv(ND, t), o = Re(null), l = Pi(e, o);
|
32743
|
-
return
|
32743
|
+
return ke(() => {
|
32744
32744
|
s.onAnchorChange((r == null ? void 0 : r.current) || o.current);
|
32745
32745
|
}), r ? null : /* @__PURE__ */ Be(js.div, _t({}, i, {
|
32746
32746
|
ref: l
|
@@ -32763,7 +32763,7 @@ const _v = "Popper", [Nv, Dv] = vv(_v), [RD, Lv] = Nv(_v), _D = (n) => {
|
|
32763
32763
|
boundary: Z.filter(PD),
|
32764
32764
|
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
32765
32765
|
altBoundary: ve
|
32766
|
-
}, { refs: $e, floatingStyles:
|
32766
|
+
}, { refs: $e, floatingStyles: Ce, placement: me, isPositioned: Le, middlewareData: Fe } = wD({
|
32767
32767
|
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
32768
32768
|
strategy: "fixed",
|
32769
32769
|
placement: J,
|
@@ -32823,8 +32823,8 @@ const _v = "Popper", [Nv, Dv] = vv(_v), [RD, Lv] = Nv(_v), _D = (n) => {
|
|
32823
32823
|
ref: $e.setFloating,
|
32824
32824
|
"data-radix-popper-content-wrapper": "",
|
32825
32825
|
style: {
|
32826
|
-
...
|
32827
|
-
transform: Le ?
|
32826
|
+
...Ce,
|
32827
|
+
transform: Le ? Ce.transform : "translate(0, -200%)",
|
32828
32828
|
// keep off the page when measuring
|
32829
32829
|
minWidth: "max-content",
|
32830
32830
|
zIndex: lt,
|
@@ -32915,7 +32915,7 @@ function VD(n) {
|
|
32915
32915
|
MOUNT: "mounted"
|
32916
32916
|
}
|
32917
32917
|
});
|
32918
|
-
return
|
32918
|
+
return ke(() => {
|
32919
32919
|
const c = El(r.current);
|
32920
32920
|
s.current = l === "mounted" ? c : "none";
|
32921
32921
|
}, [
|
@@ -32984,7 +32984,7 @@ function zD({ prop: n, defaultProp: e, onChange: t = () => {
|
|
32984
32984
|
}
|
32985
32985
|
function UD({ defaultProp: n, onChange: e }) {
|
32986
32986
|
const t = xe(n), [r] = t, i = Re(r), s = Jr(e);
|
32987
|
-
return
|
32987
|
+
return ke(() => {
|
32988
32988
|
i.current !== r && (s(r), i.current = r);
|
32989
32989
|
}, [
|
32990
32990
|
r,
|
@@ -33566,7 +33566,7 @@ const Kv = "Popover", [Jv, x4] = vv(Kv, [
|
|
33566
33566
|
})));
|
33567
33567
|
}), F5 = /* @__PURE__ */ ut((n, e) => {
|
33568
33568
|
const t = Us(Uo, n.__scopePopover), r = Re(null), i = Pi(e, r), s = Re(!1);
|
33569
|
-
return
|
33569
|
+
return ke(() => {
|
33570
33570
|
const o = r.current;
|
33571
33571
|
if (o)
|
33572
33572
|
return JD(o);
|
@@ -33802,7 +33802,7 @@ const H5 = _5, V5 = D5, z5 = P5, Rl = j5, _l = ({
|
|
33802
33802
|
return;
|
33803
33803
|
}
|
33804
33804
|
}, 1e3);
|
33805
|
-
return
|
33805
|
+
return ke(() => {
|
33806
33806
|
u && R();
|
33807
33807
|
}, [u]), /* @__PURE__ */ _.jsxs(
|
33808
33808
|
tl,
|
@@ -35799,7 +35799,7 @@ function YL(n, e) {
|
|
35799
35799
|
})
|
35800
35800
|
});
|
35801
35801
|
}
|
35802
|
-
var zu = ow ? dc :
|
35802
|
+
var zu = ow ? dc : ke;
|
35803
35803
|
function ZL(n) {
|
35804
35804
|
var e = Re();
|
35805
35805
|
return e.current || (e.current = typeof n == "function" ? n() : n), e.current;
|
@@ -36069,7 +36069,7 @@ const n4 = [
|
|
36069
36069
|
const { from: u, to: d } = r.state.selection, f = e(), h = f + n.nodeSize;
|
36070
36070
|
s(f <= u && d <= h);
|
36071
36071
|
};
|
36072
|
-
|
36072
|
+
ke(() => (r.on("selectionUpdate", a), setTimeout(a, 100), () => {
|
36073
36073
|
r.off("selectionUpdate", a);
|
36074
36074
|
}));
|
36075
36075
|
const c = () => {
|
@@ -36453,13 +36453,13 @@ const c4 = Je.create({
|
|
36453
36453
|
break;
|
36454
36454
|
}
|
36455
36455
|
}, 500);
|
36456
|
-
|
36456
|
+
ke(() => {
|
36457
36457
|
r && f();
|
36458
|
-
}, [r]),
|
36458
|
+
}, [r]), ke(() => {
|
36459
36459
|
e == null || e.chain().focus();
|
36460
36460
|
}, []);
|
36461
36461
|
const h = Re(null);
|
36462
|
-
return
|
36462
|
+
return ke(() => {
|
36463
36463
|
var p;
|
36464
36464
|
(p = h.current) == null || p.focus();
|
36465
36465
|
}, []), /* @__PURE__ */ _.jsx(
|
@@ -36692,7 +36692,7 @@ const c4 = Je.create({
|
|
36692
36692
|
document: o
|
36693
36693
|
})
|
36694
36694
|
];
|
36695
|
-
|
36695
|
+
ke(() => {
|
36696
36696
|
if (r && t) {
|
36697
36697
|
const f = new _R(
|
36698
36698
|
r || "default-room",
|
@@ -36707,7 +36707,7 @@ const c4 = Je.create({
|
|
36707
36707
|
f.destroy(), o.destroy();
|
36708
36708
|
};
|
36709
36709
|
}
|
36710
|
-
}, [r, o]),
|
36710
|
+
}, [r, o]), ke(() => {
|
36711
36711
|
t && r && (a.some(
|
36712
36712
|
(h) => h.name === "collaborationCursor"
|
36713
36713
|
) || a.push(
|
@@ -36730,11 +36730,11 @@ const c4 = Je.create({
|
|
36730
36730
|
var h;
|
36731
36731
|
(h = u.current) != null && h.contains(f.target) || c == null || c.chain().focus().run();
|
36732
36732
|
};
|
36733
|
-
return
|
36733
|
+
return ke(() => {
|
36734
36734
|
c == null || c.chain().focus();
|
36735
|
-
}, []),
|
36735
|
+
}, []), ke(() => {
|
36736
36736
|
c == null || c.setEditable(!n);
|
36737
|
-
}, [n]),
|
36737
|
+
}, [n]), ke(() => {
|
36738
36738
|
e && c && (c == null || c.commands.setContent(e.editorJSONData), s(e.metaData));
|
36739
36739
|
}, [e, c]), {
|
36740
36740
|
editor: c,
|
@@ -36749,9 +36749,11 @@ const c4 = Je.create({
|
|
36749
36749
|
data: t,
|
36750
36750
|
togglePreviewMode: r,
|
36751
36751
|
enableCollaboration: i,
|
36752
|
-
collaborationId: s
|
36752
|
+
collaborationId: s,
|
36753
|
+
onAutoSave: o
|
36754
|
+
// Add this line
|
36753
36755
|
}) => {
|
36754
|
-
const { editor:
|
36756
|
+
const { editor: l, pluginMetaData: a, focusEditor: c, setPluginMetaData: u, ref: d } = h4({
|
36755
36757
|
isPreviewMode: n,
|
36756
36758
|
data: t,
|
36757
36759
|
enableCollaboration: i,
|
@@ -36759,17 +36761,27 @@ const c4 = Je.create({
|
|
36759
36761
|
onPublish: e,
|
36760
36762
|
togglePreviewMode: r
|
36761
36763
|
});
|
36762
|
-
return
|
36764
|
+
return ke(() => {
|
36765
|
+
if (l && o) {
|
36766
|
+
const f = setInterval(() => {
|
36767
|
+
o({
|
36768
|
+
metaData: a,
|
36769
|
+
editorJSONData: l.getJSON()
|
36770
|
+
});
|
36771
|
+
}, 1e4);
|
36772
|
+
return () => clearInterval(f);
|
36773
|
+
}
|
36774
|
+
}, [l, o, a]), l ? /* @__PURE__ */ _.jsx("div", { "data-cy": "single-webpage", className: "bg-[#f9fbfd]", children: /* @__PURE__ */ _.jsx("div", { className: "h-full flex flex-col overflow-scroll no-scrollbar", children: /* @__PURE__ */ _.jsxs("div", { className: "w-full h-screen", children: [
|
36763
36775
|
/* @__PURE__ */ _.jsx("div", { className: "h-fit relative bg-[#ffffff]", children: /* @__PURE__ */ _.jsxs("div", { className: "flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16", children: [
|
36764
36776
|
/* @__PURE__ */ _.jsx("div", { className: "grow", children: /* @__PURE__ */ _.jsx(
|
36765
36777
|
Mw,
|
36766
36778
|
{
|
36767
36779
|
isPreviewMode: n,
|
36768
|
-
metaData:
|
36769
|
-
setMetaData:
|
36780
|
+
metaData: a,
|
36781
|
+
setMetaData: u
|
36770
36782
|
}
|
36771
36783
|
) }),
|
36772
|
-
!n && /* @__PURE__ */ _.jsx("div", { className: "grow relative", children: /* @__PURE__ */ _.jsx(CA, { editor:
|
36784
|
+
!n && /* @__PURE__ */ _.jsx("div", { className: "grow relative", children: /* @__PURE__ */ _.jsx(CA, { editor: l }) }),
|
36773
36785
|
/* @__PURE__ */ _.jsx("div", { children: /* @__PURE__ */ _.jsxs(ya, { onClick: () => r(n), children: [
|
36774
36786
|
n ? /* @__PURE__ */ _.jsx(PT, { size: 14 }) : /* @__PURE__ */ _.jsx($T, { size: 14 }),
|
36775
36787
|
" ",
|
@@ -36779,8 +36791,8 @@ const c4 = Je.create({
|
|
36779
36791
|
ya,
|
36780
36792
|
{
|
36781
36793
|
onClick: () => e({
|
36782
|
-
metaData:
|
36783
|
-
editorJSONData:
|
36794
|
+
metaData: a,
|
36795
|
+
editorJSONData: l.getJSON()
|
36784
36796
|
}),
|
36785
36797
|
children: [
|
36786
36798
|
/* @__PURE__ */ _.jsx(jT, { size: 14 }),
|
@@ -36792,14 +36804,14 @@ const c4 = Je.create({
|
|
36792
36804
|
/* @__PURE__ */ _.jsx("main", { className: "h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2", children: /* @__PURE__ */ _.jsx(
|
36793
36805
|
"div",
|
36794
36806
|
{
|
36795
|
-
onClick:
|
36807
|
+
onClick: c,
|
36796
36808
|
className: "w-full flex justify-center relative",
|
36797
|
-
children: /* @__PURE__ */ _.jsx("div", { className: "p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]", children: /* @__PURE__ */ _.jsxs("div", { ref:
|
36809
|
+
children: /* @__PURE__ */ _.jsx("div", { className: "p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]", children: /* @__PURE__ */ _.jsxs("div", { ref: d, className: "w-full pt-4 h-full", children: [
|
36798
36810
|
!n && /* @__PURE__ */ _.jsxs("div", { children: [
|
36799
|
-
/* @__PURE__ */ _.jsx(pA, { editor:
|
36800
|
-
/* @__PURE__ */ _.jsx(xA, { editor:
|
36811
|
+
/* @__PURE__ */ _.jsx(pA, { editor: l }),
|
36812
|
+
/* @__PURE__ */ _.jsx(xA, { editor: l, appendTo: d })
|
36801
36813
|
] }),
|
36802
|
-
/* @__PURE__ */ _.jsx(kA, { isPreviewMode: n, children: /* @__PURE__ */ _.jsx(mT, { editor:
|
36814
|
+
/* @__PURE__ */ _.jsx(kA, { isPreviewMode: n, children: /* @__PURE__ */ _.jsx(mT, { editor: l }) })
|
36803
36815
|
] }) })
|
36804
36816
|
}
|
36805
36817
|
) })
|
package/dist/index.umd.js
CHANGED
@@ -371,4 +371,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_proc
|
|
371
371
|
.block-interactivity-`.concat(n,` {pointer-events: none;}
|
372
372
|
.allow-interactivity-`).concat(n,` {pointer-events: all;}
|
373
373
|
`)},BR=0,_s=[];function $R(n){var e=le.useRef([]),t=le.useRef([0,0]),r=le.useRef(),i=le.useState(BR++)[0],s=le.useState(function(){return ov()})[0],o=le.useRef(n);le.useEffect(function(){o.current=n},[n]),le.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(i));var g=oR([n.lockRef.current],(n.shards||[]).map(hv),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[n.inert,n.lockRef.current,n.shards]);var l=le.useCallback(function(g,v){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var w=Cc(g),S=t.current,x="deltaX"in g?g.deltaX:S[0]-w[0],y="deltaY"in g?g.deltaY:S[1]-w[1],k,E=g.target,T=Math.abs(x)>Math.abs(y)?"h":"v";if("touches"in g&&T==="h"&&E.type==="range")return!1;var N=cv(T,E);if(!N)return!0;if(N?k=T:(k=T==="v"?"h":"v",N=cv(T,E)),!N)return!1;if(!r.current&&"changedTouches"in g&&(x||y)&&(r.current=k),!k)return!0;var _=r.current||k;return IR(_,v,g,_==="h"?x:y,!0)},[]),a=le.useCallback(function(g){var v=g;if(!(!_s.length||_s[_s.length-1]!==s)){var w="deltaY"in v?fv(v):Cc(v),S=e.current.filter(function(k){return k.name===v.type&&k.target===v.target&&PR(k.delta,w)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var x=(o.current.shards||[]).map(hv).filter(Boolean).filter(function(k){return k.contains(v.target)}),y=x.length>0?l(v,x[0]):!o.current.noIsolation;y&&v.cancelable&&v.preventDefault()}}},[]),c=le.useCallback(function(g,v,w,S){var x={name:g,delta:v,target:w,should:S};e.current.push(x),setTimeout(function(){e.current=e.current.filter(function(y){return y!==x})},1)},[]),u=le.useCallback(function(g){t.current=Cc(g),r.current=void 0},[]),d=le.useCallback(function(g){c(g.type,fv(g),g.target,l(g,n.lockRef.current))},[]),f=le.useCallback(function(g){c(g.type,Cc(g),g.target,l(g,n.lockRef.current))},[]);le.useEffect(function(){return _s.push(s),n.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",a,Os),document.addEventListener("touchmove",a,Os),document.addEventListener("touchstart",u,Os),function(){_s=_s.filter(function(g){return g!==s}),document.removeEventListener("wheel",a,Os),document.removeEventListener("touchmove",a,Os),document.removeEventListener("touchstart",u,Os)}},[]);var h=n.removeScrollBar,p=n.inert;return le.createElement(le.Fragment,null,p?le.createElement(s,{styles:FR(i)}):null,h?le.createElement(MR,{gapMode:"margin"}):null)}const jR=mR(sv,$R);var pv=le.forwardRef(function(n,e){return le.createElement(wc,Zn({},n,{ref:e,sideCar:jR}))});pv.classNames=wc.classNames;const mv="Popover",[gv,o4]=v1(mv,[G1]),oh=G1(),[HR,Ns]=gv(mv),VR=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=n,l=oh(e),a=O.useRef(null),[c,u]=O.useState(!1),[d=!1,f]=eR({prop:r,defaultProp:i,onChange:s});return O.createElement(GD,l,O.createElement(HR,{scope:e,contentId:FN(),triggerRef:a,open:d,onOpenChange:f,onOpenToggle:O.useCallback(()=>f(h=>!h),[f]),hasCustomAnchor:c,onCustomAnchorAdd:O.useCallback(()=>u(!0),[]),onCustomAnchorRemove:O.useCallback(()=>u(!1),[]),modal:o},t))},zR="PopoverTrigger",UR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(zR,t),s=oh(t),o=Ai(e,i.triggerRef),l=O.createElement(Mi.button,dt({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":bv(i.open)},r,{ref:o,onClick:Ur(n.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?l:O.createElement(YD,dt({asChild:!0},s),l)}),WR="PopoverPortal",[l4,qR]=gv(WR,{forceMount:void 0}),Yo="PopoverContent",KR=O.forwardRef((n,e)=>{const t=qR(Yo,n.__scopePopover),{forceMount:r=t.forceMount,...i}=n,s=Ns(Yo,n.__scopePopover);return O.createElement(ev,{present:r||s.open},s.modal?O.createElement(JR,dt({},i,{ref:e})):O.createElement(GR,dt({},i,{ref:e})))}),JR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(null),i=Ai(e,r),s=O.useRef(!1);return O.useEffect(()=>{const o=r.current;if(o)return sR(o)},[]),O.createElement(pv,{as:$f,allowPinchZoom:!0},O.createElement(yv,dt({},n,{ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ur(n.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=t.triggerRef.current)===null||l===void 0||l.focus()}),onPointerDownOutside:Ur(n.onPointerDownOutside,o=>{const l=o.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0,c=l.button===2||a;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ur(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})))}),GR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(!1),i=O.useRef(!1);return O.createElement(yv,dt({},n,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o;if((o=n.onCloseAutoFocus)===null||o===void 0||o.call(n,s),!s.defaultPrevented){var l;r.current||(l=t.triggerRef.current)===null||l===void 0||l.focus(),s.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:s=>{var o,l;(o=n.onInteractOutside)===null||o===void 0||o.call(n,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((l=t.triggerRef.current)===null||l===void 0?void 0:l.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}}))}),yv=O.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=n,f=Ns(Yo,t),h=oh(t);return AN(),O.createElement(MN,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s},O.createElement(SN,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},O.createElement(ZD,dt({"data-state":bv(f.open),role:"dialog",id:f.contentId},h,d,{ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))}),YR="PopoverClose",ZR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(YR,t);return O.createElement(Mi.button,dt({type:"button"},r,{ref:e,onClick:Ur(n.onClick,()=>i.onOpenChange(!1))}))});function bv(n){return n?"open":"closed"}const XR=VR,QR=UR,e5=KR,kc=ZR,Sc=({children:n,isActive:e,onClick:t,disabled:r,className:i})=>{const s=Fe("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",i);return D.jsx("button",{className:s,disabled:r,onClick:t,children:n})},t5=(n,e,t)=>{const r=O.useCallback(()=>{const l=n.chain();l.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&l.setParagraph(),l.run()},[n,t,e==null?void 0:e.type.name]),i=O.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:l}=n.state.selection,a=l.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),a.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),s=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:i,copyNodeToClipboard:s,deleteNode:o}},n5=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[i,s]=O.useState(!1),o=t5(t,n,e()),l=Ul(),a=["https://twitter.com","https://x.com"],c=O.useMemo(()=>{const{content:_}=n.content;return _[0].type.name==="table"},[n.content]),u=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[0])==null?void 0:A.text},[n.content]),d=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[1])==null?void 0:A.text},[n.content]),f=O.useMemo(()=>{const{content:_}=n.content;return _[0].content.content.find(A=>{var R;return(R=A==null?void 0:A.text)==null?void 0:R.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let _=u;if(u.includes("<iframe"))_=d;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://www.youtube.com/embed/${V[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://player.vimeo.com/video/${V[1]}`);break}default:return}const A=640,R=360,P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===0?P:P+1,to:$}).setIframe({src:_,width:A,height:R}).run())},p=_=>{const A=_.match(/\/status\/([0-9]*)/);return A&&A.length>0?A[1]:null},g=()=>{if(!u)return;let _=u;const A=a.some(V=>u.includes(V)),R=p(u);A&&R?_=R:f&&(_=p(f.text));const P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===2?P:P+1,to:$}).setTweetEmbed({tweetId:_}).run())},v=()=>{const _=e()+n.nodeSize;t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},w=()=>{const _=e();t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},S=()=>{r()},x=_=>{_.altKey?k():y()},y=()=>{v()},k=()=>{w()},E=_=>{_.altKey&&S()},N=y1(()=>{if(a.some(_=>u.includes(_))||f!=null&&f.text){g();return}else{h();return}},1e3);return O.useEffect(()=>{u&&N()},[u]),D.jsxs(bo,{as:"div",className:Fe("flex gap-2 group w-full relative justify-center items-start",l&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[D.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[D.jsx(T0,{content:D.jsxs("div",{className:"flex flex-col w-40",children:[D.jsx("div",{className:"text-xs",children:"Click to add below"}),D.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:x,children:D.jsx(rT,{size:18})})}),D.jsxs(XR,{open:i,onOpenChange:s,children:[D.jsx(QR,{asChild:!0,children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:E,children:D.jsx(YE,{size:18})})}),D.jsx(e5,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:D.jsxs(ld,{className:"p-2 flex flex-col min-w-[16rem]",children:[D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.resetTextFormatting,children:[D.jsx(iT,{size:18}),"Clear formatting"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.copyNodeToClipboard,children:[D.jsx(qE,{size:18}),"Copy to clipboard"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.duplicateNode,children:[D.jsx(JE,{size:18}),"Duplicate"]})}),D.jsx(vo.Divider,{horizontal:!0}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[D.jsx(cT,{size:18}),"Delete"]})})]})})]})]}),D.jsx(Kg,{className:Fe("node-view-content w-full",{"is-table min-w-auto":c})})]})},r5=Ve.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",xe(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,i=n!==void 0||n!==null?r:n;return t().insertContentAt(i,{type:this.name,content:[{type:"paragraph"}]}).focus(i+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;const o=[];if(e.doc.nodesBetween(r,i,a=>{if(a.type.name===this.name){const c=e.schema.nodes.listItem.create(null,a.content);c&&o.push(c)}}),o.length===0)return!1;const l=e.schema.nodes[n].create(null,o);return l?(s=s.replaceRangeWith(r,i,l),t(s),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;return e.doc.nodesBetween(r,i,(o,l)=>{if(o.type.name===n){const a=e.schema.nodes[this.name].create(null,o.content);s=s.insert(l,a)}}),t(s),!0}}},addNodeView(){return hi(n5)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:i}=n.state,s=e.node(e.depth-1);if((s==null?void 0:s.type.name)!=="dBlock")return!1;let o=-1,l="";i.descendants((u,d)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[f,h]=[d,d+u.nodeSize];return f<=t&&r<=h&&(o=h,l=u.type.name),!1});const a=(c=i.slice(t,o))==null?void 0:c.toJSON().content;try{return l==="codeBlock"?n.chain().insertContentAt({from:t,to:o},`
|
374
|
-
`).focus(o+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let lh,ah;if(typeof WeakMap<"u"){let n=new WeakMap;lh=e=>n.get(e),ah=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;lh=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},ah=(r,i)=>(t==e&&(t=0),n[t++]=r,n[t++]=i)}class Ds{constructor(e,t,r,i){this.left=e,this.top=t,this.right=r,this.bottom=i}}class et{constructor(e,t,r,i){this.width=e,this.height=t,this.map=r,this.problems=i}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let i=t%this.width,s=t/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[t+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new Ds(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return t=="horiz"?(r<0?i==0:s==this.width)?null:this.map[o*this.width+(r<0?i-1:s)]:(r<0?o==0:l==this.height)?null:this.map[i+this.width*(r<0?o-1:l)]}rectBetween(e,t){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new Ds(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let i=e.top;i<e.bottom;i++)for(let s=e.left;s<e.right;s++){let o=i*this.width+s,l=this.map[o];r[l]||(r[l]=!0,(s!=e.left||!s||this.map[o-1]!=l)&&(i!=e.top||!i||this.map[o-this.width]!=l)&&t.push(l))}return t}positionAt(e,t,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=t+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<s;)l++;return l==a?o-1:this.map[l]}s=o}}static get(e){return lh(e)||ah(e,i5(e))}}function i5(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=s5(n),t=n.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;let g=d.child(p),{colspan:v,rowspan:w,colwidth:S}=g.attrs;for(let x=0;x<w;x++){if(x+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-x});break}let y=i+x*e;for(let k=0;k<v;k++){r[y+k]==0?r[y+k]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-k});let E=S&&S[k];if(E){let T=(y+k)%e*2,N=o[T];N==null||N!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):N==E&&o[T+1]++}}}i+=v,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}let l=new et(e,t,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&o5(l,o,n),l}function s5(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let i=n.child(r),s=0;if(t)for(let o=0;o<r;o++){let l=n.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){let l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function o5(n,e,t){n.problems||(n.problems=[]);for(let r=0,i={};r<n.map.length;r++){let s=n.map[r];if(i[s])continue;i[s]=!0;let o=t.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=l5(o.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function l5(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Mt(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Rs(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function a5(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Tn(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ec(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Rs(e.$head)||c5(e.$head)}function c5(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ch(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function u5(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function uh(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vv(n,e,t){let r=n.start(-1),s=et.get(n.node(-1)).nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function wt(n,e,t){let r={};for(let i in n)r[i]=n[i];return r[e]=t,r}function _i(n,e,t=1){let r=wt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function wv(n,e,t=1){let r=wt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function d5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}class Se extends ue{constructor(e,t=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new Jc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ch(r)&&ch(i)&&uh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Se.rowSelection(r,i):s&&this.isColSelection()?Se.colSelection(r,i):new Se(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=et.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){let c=[];for(let u=a*t.width+i.left,d=i.left;d<i.right;d++,u++){let f=t.map[u];if(!s[f]){s[f]=!0;let h=t.findCell(f),p=e.nodeAt(f),g=i.left-h.left,v=h.right-i.right;if(g>0||v>0){let w=p.attrs;g>0&&(w=_i(w,0,g)),v>0&&(w=_i(w,w.colspan-v,v)),h.left<i.left?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){let w=wt(p.attrs,"rowspan",Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top));h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}}o.push(e.child(a).copy(W.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Y(W.from(l),1,1)}replace(e,t=Y.empty){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?Y.empty:t)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new Y(W.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=et.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.top<=o.top?(s.top>0&&(e=l.resolve(i+r.map[s.left])),o.bottom<r.height&&(t=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=l.resolve(i+r.map[o.left])),s.bottom<r.height&&(e=l.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new Se(e,t)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),i=e.colCount(this.$headCell.pos-t);if(Math.min(r,i)>0)return!1;let s=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,o)==e.width}eq(e){return e instanceof Se&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.left<=o.left?(s.left>0&&(e=l.resolve(i+r.map[s.top*r.width])),o.right<r.width&&(t=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=l.resolve(i+r.map[o.top*r.width])),s.right<r.width&&(e=l.resolve(i+r.map[r.width*(s.top+1)-1]))),new Se(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Se(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Se(e.resolve(t),e.resolve(r))}getBookmark(){return new dh(this.$anchorCell.pos,this.$headCell.pos)}}Se.prototype.visible=!1,ue.jsonID("cell",Se);class dh{constructor(e,t){this.anchor=e,this.head=t}map(e){return new dh(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&uh(t,r)?new Se(t,r):ue.near(r,1)}}function f5(n){if(!(n.selection instanceof Se))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(ut.node(r,r+t.nodeSize,{class:"selectedCell"}))}),He.create(n.doc,e)}function h5({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function p5({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){let s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){let s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function m5(n,e,t){let r=(e||n).selection,i=(e||n).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Se.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Se.rowSelection(l,l)}else if(!t){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Se.create(i,a+1,c)}}else r instanceof ce&&h5(r)?s=ce.create(i,r.from):r instanceof ce&&p5(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}function g5(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let i=e.firstChild,s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=fh(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?fh(Mt(o).row,new Y(e,t,r)).content:e);else return null;return y5(o,l)}function y5(n,e){let t=[];for(let i=0;i<e.length;i++){let s=e[i];for(let o=s.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(W.empty),t[i]<r){let s=Mt(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function fh(n,e){let t=n.createAndFill();return new qc(t).replace(0,t.content.size,e).doc}function b5({width:n,height:e,rows:t},r,i){if(n!=r){let s=[],o=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(_i(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}o.push(W.from(c))}t=o,n=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>i&&(d=d.type.create(wt(d.attrs,"rowspan",Math.max(1,i-d.attrs.rowspan)),d.content)),a.push(d)}s.push(W.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function v5(n,e,t,r,i,s,o){let l=n.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let v=e.width;v<i;v++)p.push(g);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(s>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,i);p++){let v=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==a.header_cell;d.push(v?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,W.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function xv(n,e,t,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function Cv(n,e,t,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function kv(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=n.tr,f=0;function h(){s=t?d.doc.nodeAt(t-1):d.doc,o=et.get(s),f=d.mapping.maps.length}v5(d,o,s,t,c,u,f)&&h(),xv(d,o,s,t,a,c,l,f)&&h(),xv(d,o,s,t,a,c,u,f)&&h(),Cv(d,o,s,t,l,u,a,f)&&h(),Cv(d,o,s,t,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=o.positionAt(p,a,s),v=o.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(g+t),d.mapping.slice(f).map(v+t),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Se(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(u-1,c-1,s)))),e(d)}const w5=ku({ArrowLeft:Ac("horiz",-1),ArrowRight:Ac("horiz",1),ArrowUp:Ac("vert",-1),ArrowDown:Ac("vert",1),"Shift-ArrowLeft":Mc("horiz",-1),"Shift-ArrowRight":Mc("horiz",1),"Shift-ArrowUp":Mc("vert",-1),"Shift-ArrowDown":Mc("vert",1),Backspace:Oc,"Mod-Backspace":Oc,Delete:Oc,"Mod-Delete":Oc});function Tc(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Ac(n,e){return(t,r,i)=>{let s=t.selection;if(s instanceof Se)return Tc(t,r,ue.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;let o=Sv(i,n,e);if(o==null)return!1;if(n=="horiz")return Tc(t,r,ue.near(t.doc.resolve(s.head+e),e));{let l=t.doc.resolve(o),a=vv(l,n,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(t.doc.resolve(l.before(-1)),-1):c=ue.near(t.doc.resolve(l.after(-1)),1),Tc(t,r,c)}}}function Mc(n,e){return(t,r,i)=>{let s=t.selection;if(!(s instanceof Se)){let l=Sv(i,n,e);if(l==null)return!1;s=new Se(t.doc.resolve(l))}let o=vv(s.$headCell,n,e);return o?Tc(t,r,new Se(s.$anchorCell,o)):!1}}function Oc(n,e){let t=n.selection;if(!(t instanceof Se))return!1;if(e){let r=n.tr,i=Mt(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new Y(i,0,0))}),r.docChanged&&e(r)}return!0}function x5(n,e){let t=n.state.doc,r=Rs(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Se(r))),!0):!1}function C5(n,e,t){if(!Tn(n.state))return!1;let r=g5(t),i=n.state.selection;if(i instanceof Se){r||(r={width:1,height:1,rows:[W.from(fh(Mt(n.state.schema).cell,t))]});let s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=et.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=b5(r,l.right-l.left,l.bottom-l.top),kv(n.state,n.dispatch,o,l,r),!0}else if(r){let s=Ec(n.state),o=s.start(-1);return kv(n.state,n.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function k5(n,e){if(e.ctrlKey||e.metaKey)return;let t=Ev(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof Se)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=Rs(n.state.selection.$anchor))!=null&&hh(n,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!t)return;function i(l,a){let c=hh(n,a),u=Gr.getState(n.state)==null;if(!c||!uh(l,c))if(u)c=l;else return;let d=new Se(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",o),Gr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Ev(n,l.target)!=t&&(c=hh(n,e),!c))return s();c&&i(c,l)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",o)}function Sv(n,e,t){if(!(n.state.selection instanceof ce))return null;let{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){let l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ev(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function hh(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Rs(n.state.doc.resolve(t.pos)):null}const S5=new We("fix-tables");function Tv(n,e,t,r){let i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){let a=e.child(o);for(let c=l,u=Math.min(i,o+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?Tv(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Av(n,e){let t,r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=E5(n,i,s,t))};return e?e.doc!=n.doc&&Tv(e.doc,n.doc,0,r):n.doc.descendants(r),t}function E5(n,e,t,r){let i=et.get(e);if(!i.problems)return r;r||(r=n.tr);let s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){let c=i.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,_i(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"colwidth",c.colwidth))}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<i.height;a++){let u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let v=0;v<f;v++)p.push(Mt(n.schema)[h].createAndFill());let g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(S5,{fixTables:!0})}function Xn(n){let e=n.selection,t=Ec(n),r=t.node(-1),i=t.start(-1),s=et.get(r),o;return e instanceof Se?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(t.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function Mv(n,{map:e,tableStart:t,table:r},i){let s=i>0?-1:0;d5(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,wv(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=s==null?Mt(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function T5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.left))}return!0}function A5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.right))}return!0}function M5(n,{map:e,table:t,tableStart:r},i){let s=n.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=t.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=n.mapping.slice(s).map(r+a);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function O5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;M5(r,t,i),i!=t.left;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(e.nodeAt(n.map[i+t*n.width]).type!=r)return!1;return!0}function Ov(n,{map:e,tableStart:t,table:r},i){let s=t;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;_5(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let a=0,c=e.width*i;a<e.width;a++,c++)if(i>0&&i<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,wt(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Mt(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;o.push(u.createAndFill())}return n.insert(s,Mt(r.type.schema).row.create(null,o)),n}function N5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.top))}return!0}function D5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.bottom))}return!0}function R5(n,{map:e,table:t,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=t.child(a).nodeSize;let o=s+t.child(i).nodeSize,l=n.mapping.maps.length;n.delete(s+r,o+r);for(let a=0,c=i*e.width;a<e.width;a++,c++){let u=e.map[c];if(i>0&&u==e.map[c-e.width]){let d=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,wt(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(i<e.width&&u==e.map[c+e.width]){let d=t.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function L5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;R5(r,t,i),i!=t.top;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _v(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function I5({width:n,height:e,map:t},r){let i=r.top*n+r.left,s=i,o=(r.bottom-1)*n+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[o]==t[o+n])return!0;i++,o++}return!1}function Nv(n,e){let t=n.selection;if(!(t instanceof Se)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xn(n),{map:i}=r;if(I5(i,r))return!1;if(e){let s=n.tr,o={},l=W.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=i.map[u*i.width+d],h=r.table.nodeAt(f);if(!o[f])if(o[f]=!0,a==null)a=f,c=h;else{_v(h)||(l=l.append(h.content));let p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(s.setNodeMarkup(a+r.tableStart,null,wt(wv(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=_v(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Se(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Dv(n,e){const t=Mt(n.schema);return P5(({node:r})=>t[r.type.spec.tableRole])(n,e)}function P5(n){return(e,t)=>{let r=e.selection,i,s;if(r instanceof Se){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=a5(r.$from),!i)return!1;s=Rs(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let o=i.attrs,l=[],a=o.colwidth;o.rowspan>1&&(o=wt(o,"rowspan",1)),o.colspan>1&&(o=wt(o,"colspan",1));let c=Xn(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?wt(o,"colwidth",a&&a[f]?[a[f]]:null):o);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=i.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),n({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,n({node:i,row:c.top,col:c.left}),l[0]),r instanceof Se&&u.setSelection(new Se(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function F5(n,e){return function(t,r){if(!Tn(t))return!1;let i=Ec(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){let s=t.tr;t.selection instanceof Se?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,n,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,n,e)),r(s)}return!0}}function B5(n){return function(e,t){if(!Tn(e))return!1;if(t){let r=Mt(e.schema),i=Xn(e),s=e.tr,o=i.map.cellsInRect(n=="column"?new Ds(i.left,0,i.right,i.map.height):n=="row"?new Ds(0,i.top,i.map.width,i.bottom):i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Rv(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Zo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?B5(n):function(t,r){if(!Tn(t))return!1;if(r){let i=Mt(t.schema),s=Xn(t),o=t.tr,l=Rv("row",s,i),a=Rv("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new Ds(0,u,1,s.map.height):n=="row"?new Ds(u,0,s.map.width,1):s,f=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}Zo("row",{useDeprecatedLogic:!0}),Zo("column",{useDeprecatedLogic:!0});let $5=Zo("cell",{useDeprecatedLogic:!0});function j5(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){let s=n.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){let s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Lv(n){return function(e,t){if(!Tn(e))return!1;let r=j5(Ec(e),n);if(r!=null){if(t){let i=e.doc.resolve(r);t(e.tr.setSelection(ce.between(i,u5(i))).scrollIntoView())}return!0}}}function H5(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let V5=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ph(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ph(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ph(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild,c=n.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let g=i==d?s:h&&h[p],v=g?g+"px":"";o+=g||r,g||(l=!1),a?(a.style.width!=v&&(a.style.width=v),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=v}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function z5({handleWidth:n=5,cellMinWidth:e=25,View:t=V5,lastColumnResizable:r=!0}={}){return new je({key:mn,state:{init(s,o){return this.spec.props.nodeViews[Mt(o.schema).table.name]=(l,a)=>new t(l,e,a),new Xo(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes(s){return mn.getState(s).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(s,o){U5(s,o,n,e,r)},mouseleave(s){W5(s)},mousedown(s,o){q5(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return X5(s,o.activeHandle)},nodeViews:{}}})}class Xo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new Xo(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Xo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);ch(e.doc.resolve(i))||(i=null),t=new Xo(i,t.dragging)}return t}}function U5(n,e,t,r,i){let s=mn.getState(n.state);if(!s.dragging){let o=J5(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=t?l=Iv(n,e,"left"):c-e.clientX<=t&&(l=Iv(n,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=n.state.doc.resolve(l),c=a.node(-1),u=et.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Fv(n,l)}}}function W5(n){let e=mn.getState(n.state);e.activeHandle>-1&&!e.dragging&&Fv(n,-1)}function q5(n,e,t){let r=mn.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let i=n.state.doc.nodeAt(r.activeHandle),s=K5(n,r.activeHandle,i.attrs);n.dispatch(n.state.tr.setMeta(mn,{setDragging:{startX:e.clientX,startWidth:s}}));function o(a){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",l);let c=mn.getState(n.state);c.dragging&&(G5(n,c.activeHandle,Pv(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(n.state),u=Pv(c.dragging,a,t);Y5(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function K5(n,e,{colspan:t,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=n.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function J5(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Iv(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Rs(n.state.doc.resolve(i));if(!s)return-1;if(t=="right")return s.pos;let o=et.get(s.node(-1)),l=s.start(-1),a=o.map.indexOf(s.pos-l);return a%o.width==0?-1:l+o.map[a-1]}function Pv(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Fv(n,e){n.dispatch(n.state.tr.setMeta(mn,{setHandle:e}))}function G5(n,e,t){let r=n.state.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){let u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;let d=s.map[u],{attrs:f}=i.nodeAt(d),h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;let p=f.colwidth?f.colwidth.slice():Z5(f.colspan);p[h]=t,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function Y5(n,e,t,r){let i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=et.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=n.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;ph(s,a.firstChild,a,r,l,t)}function Z5(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function X5(n,e){let t=[],r=n.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){let c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c-1]!=s.map[c-1-s.width])){let u=s.map[c],d=o+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push(ut.widget(d,f))}}return He.create(n.doc,t)}function Q5({allowTableNodeSelection:n=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,t){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:f5,handleDOMEvents:{mousedown:k5},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:x5,handleKeyDown:w5,handlePaste:C5},appendTransaction(e,t,r){return m5(r,Av(r,t),n)}})}function Bv(n,e,t,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const v=i===f?s:p&&p[g],w=v?`${v}px`:"";o+=v||r,v||(l=!1),a?(a.style.width!==w&&(a.style.width=w),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=w}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class eL{constructor(e,t){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Bv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Bv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $v(n,e){return n.createAndFill()}function tL(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function nL(n,e,t,r,i){const s=tL(n),o=[],l=[];for(let c=0;c<t;c+=1){const u=$v(s.cell);if(u&&l.push(u),r){const d=$v(s.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function rL(n){return n instanceof Se}const _c=({editor:n})=>{const{selection:e}=n.state;if(!rL(e))return!1;let t=0;const r=Ru(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},iL=Ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:eL,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",xe(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=nL(s.schema,n,e,t);if(i){const a=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,l).scrollIntoView().setSelection(ce.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>T5(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>A5(n,e),deleteColumn:()=>({state:n,dispatch:e})=>O5(n,e),addRowBefore:()=>({state:n,dispatch:e})=>N5(n,e),addRowAfter:()=>({state:n,dispatch:e})=>D5(n,e),deleteRow:()=>({state:n,dispatch:e})=>L5(n,e),deleteTable:()=>({state:n,dispatch:e})=>H5(n,e),mergeCells:()=>({state:n,dispatch:e})=>Nv(n,e),splitCell:()=>({state:n,dispatch:e})=>Dv(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Zo("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Zo("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>$5(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Nv(n,e)?!0:Dv(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>F5(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Lv(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Lv(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Av(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Se.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:_c,"Mod-Backspace":_c,Delete:_c,"Mod-Delete":_c}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[z5({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Q5({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ge(re(n,"tableRole",e))}}});function jv(n,e){if(n==null)return{};var t={},r=Object.keys(n),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(t[i]=n[i]);return t}var Hv=typeof window<"u"&&typeof document<"u";function mh(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Vv(){return Hv&&document.createElement("div")}function sL(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function zv(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!zv(n[t],e[t]))return!1}else return!1;return!0}else return!1}function oL(n){var e=[];return n.forEach(function(t){e.find(function(r){return zv(t,r)})||e.push(t)}),e}function lL(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:oL([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var gh=Hv?O.useLayoutEffect:O.useEffect;function aL(n){var e=O.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Uv(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var cL={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function i(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}Uv(t,"add",e.props.className)}function s(){r()&&Uv(t,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function uL(n){function e(t){var r=t.children,i=t.content,s=t.visible,o=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=jv(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=s!==void 0,g=o!==void 0,v=O.useState(!1),w=v[0],S=v[1],x=O.useState({}),y=x[0],k=x[1],E=O.useState(),T=E[0],N=E[1],_=aL(function(){return{container:Vv(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:_.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(V){A[V]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+V+"` prop in","controlled mode (`visible` prop)"].join(" "))}),A.trigger="manual",A.hideOnClick=!1),g&&(u=!0);var R=A,P=A.plugins||[];l&&(R=Object.assign({},A,{plugins:g&&o.data!=null?[].concat(P,[{fn:function(){return{onTrigger:function(J,G){var ie=o.data.children.find(function(X){var we=X.instance;return we.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,N(ie.content)}}}}]):P,render:function(){return{popper:_.container}}}));var $=[a].concat(r?[r.type]:[]);return gh(function(){var V=a;a&&a.hasOwnProperty("current")&&(V=a.current);var U=n(V||_.ref||Vv(),Object.assign({},R,{plugins:[cL].concat(A.plugins||[])}));return _.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),gh(function(){var V;if(_.renders===1){_.renders++;return}var U=_.instance;U.setProps(lL(U.props,R)),(V=U.popperInstance)==null||V.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N})}),gh(function(){var V;if(l){var U=_.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((V=U.props.popperOptions)==null?void 0:V.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,X=G.state,we=(ie=X.modifiersData)==null?void 0:ie.hide;(y.placement!==X.placement||y.referenceHidden!==(we==null?void 0:we.isReferenceHidden)||y.escaped!==(we==null?void 0:we.hasPopperEscaped))&&k({placement:X.placement,referenceHidden:we==null?void 0:we.isReferenceHidden,escaped:we==null?void 0:we.hasPopperEscaped}),X.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat($)),O.createElement(O.Fragment,null,r?O.cloneElement(r,{ref:function(U){_.ref=U,mh(r.ref,U)}}):null,w&&nn.createPortal(l?l(sL(y),T,_.instance):i,_.container))}return e}var dL=function(n,e){return O.forwardRef(function(r,i){var s=r.children,o=jv(r,["children"]);return O.createElement(n,Object.assign({},e,o),s?O.cloneElement(s,{ref:function(a){mh(i,a),mh(s.ref,a)}}):null)})},fL=dL(uL(fi));const hL=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],Wv=({node:n,getPos:e,selected:t,editor:r})=>{const[i,s]=O.useState(!1),o=Ul(),l=O.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.nodeSize;s(f<=u&&d<=h)};O.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return D.jsxs(bo,{className:"group",children:[D.jsx(Kg,{as:"span"}),(i||t)&&D.jsx(fL,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:D.jsx("article",{className:"dropdown",contentEditable:!1,children:D.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:hL.map(u=>D.jsx("li",{children:D.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[D.jsx("span",{children:u.icon}),D.jsx("span",{children:u.name})]})},u.name))})}),children:D.jsx("label",{tabIndex:0,className:Fe("trigger-button",{hidden:o}),contentEditable:!1,children:D.jsx(GE,{fontSize:"small"})})})]})},pL=Ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"td",className:"relative"})}}),mL=Ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"th",className:"relative"})}}),qv=n=>(n.stopPropagation(),n.preventDefault(),n),gL=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},Kv=function(n){return!n||n===document.body?document.body:gL(n)?n:Kv(n.parentNode)},yh=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),t&&Object.entries(t).forEach(([i,s])=>r.addEventListener(i,s)),r},yL=Ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),i=Kv(n.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=n.state.doc.resolve(w),x=new se(S);n.view.dispatch(n.state.tr.setSelection(x))}},l=()=>{s=!0},a=()=>{s=!1},c=yh("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:w=>{w&&qv(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=yh("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&qv(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=yh("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const w=h.getBoundingClientRect(),S=JSON.stringify(w);p!==S&&(c.style.top=`${w.top+document.documentElement.scrollTop}px`,c.style.left=`${w.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${w.height+1}px`,p=S)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),bL=[iL.configure({resizable:!0}),pL,mL,yL],vL=Hb.extend({content:"(dBlock|columns)+"});function Jv({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const wL=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new je({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!Jv({node:i,types:e})},apply:(t,r)=>{var s,o,l;if(!t.docChanged)return r;const i=(l=(o=(s=t.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!Jv({node:i,types:e})}}})]}}),xL=({node:n,editor:e,getPos:t})=>{const[r,i]=O.useState(""),s=Ul(),o=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return D.jsx(f0,{});case"iframe":return D.jsx(h0,{});default:return D.jsx(aT,{})}},a=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const x=r.match(/src="([^"]*)"/);x&&x.length>0&&(p=x[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://www.youtube.com/embed/${x[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://player.vimeo.com/video/${x[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,v=360,w=t(),S=w+n.nodeSize;p&&(e==null||e.chain().focus(w).deleteRange({from:w,to:S}).setIframe({src:p,width:g,height:v}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(y=>r.includes(y)),v=r.match(/\/status\/([0-9]*)/),w=v&&v.length>0;if(g&&w)p=v[1];else{alert("invalid url");return}const S=t(),x=S+n.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:x}).setTweetEmbed({tweetId:p}).run())},f=y1(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);O.useEffect(()=>{r&&f()},[r]),O.useEffect(()=>{e==null||e.chain().focus()},[]);const h=O.useRef(null);return O.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&D.jsxs("div",{className:"relative w-full",children:[D.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),D.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>i(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},CL=Ve.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return hi(xL)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",xe(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),kL=[h_,d_.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),p_.configure({types:["heading","paragraph"]}),tN,F_.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),B_.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),H_.configure({multicolor:!0}),eN,W_.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),f_,iN,V_.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),U_.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Vb.configure({width:3,color:"#d1d5db"}),zb,r5,wL,vL,...bL,hN.configure({uploadFn:AT}),rN,sN,cN,CL.extend({addInputRules(){return[Gv(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),Gv(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),nN],Gv=(n,e,t)=>new io({find:n,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,t.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Yv=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],SL=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r})=>{const[i,s]=O.useState({plugin:{title:"Untitled"}}),[o]=O.useState(new as),l=O.useRef(null),a=[...kL,p3.configure({document:o})];O.useEffect(()=>{if(r&&t){const f=new HO(r||"default-room",o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});return l.current=f,()=>{f.destroy(),o.destroy()}}},[r,o]),O.useEffect(()=>{t&&r&&(a.some(h=>h.name==="collaborationCursor")||a.push(m3.configure({provider:l.current,user:{color:Yv[Math.floor(Math.random()*Yv.length)]}})))},[l.current]);const c=FE({extensions:a,editorProps:VO,autofocus:"start"}),u=O.useRef(null),d=f=>{var h;(h=u.current)!=null&&h.contains(f.target)||c==null||c.chain().focus().run()};return O.useEffect(()=>{c==null||c.chain().focus()},[]),O.useEffect(()=>{c==null||c.setEditable(!n)},[n]),O.useEffect(()=>{e&&c&&(c==null||c.commands.setContent(e.editorJSONData),s(e.metaData))},[e,c]),{editor:c,pluginMetaData:i,setPluginMetaData:s,focusEditor:d,ref:u}},EL=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r,enableCollaboration:i,collaborationId:s})=>{const{editor:o,pluginMetaData:l,focusEditor:a,setPluginMetaData:c,ref:u}=SL({isPreviewMode:n,data:t,enableCollaboration:i,collaborationId:s,onPublish:e,togglePreviewMode:r});return o?D.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f9fbfd]",children:D.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:D.jsxs("div",{className:"w-full h-screen",children:[D.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:D.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[D.jsx("div",{className:"grow",children:D.jsx(iw,{isPreviewMode:n,metaData:l,setMetaData:c})}),!n&&D.jsx("div",{className:"grow relative",children:D.jsx(zT,{editor:o})}),D.jsx("div",{children:D.jsxs(zl,{onClick:()=>r(n),children:[n?D.jsx(nT,{size:14}):D.jsx(sT,{size:14})," ",n?"Edit":"Preview"]})}),e&&D.jsx("div",{children:D.jsxs(zl,{onClick:()=>e({metaData:l,editorJSONData:o.getJSON()}),children:[D.jsx(oT,{size:14})," Share"]})})]})}),D.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:D.jsx("div",{onClick:a,className:"w-full flex justify-center relative",children:D.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]",children:D.jsxs("div",{ref:u,className:"w-full pt-4 h-full",children:[!n&&D.jsxs("div",{children:[D.jsx(LT,{editor:o}),D.jsx(HT,{editor:o,appendTo:u})]}),D.jsx(VT,{isPreviewMode:n,children:D.jsx(IE,{editor:o})})]})})})})]})})}):D.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[D.jsx(N0,{}),D.jsx("p",{children:"Loading Editor..."})]})};Bt.DdocEditor=EL,Object.defineProperty(Bt,Symbol.toStringTag,{value:"Module"})});
|
374
|
+
`).focus(o+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let lh,ah;if(typeof WeakMap<"u"){let n=new WeakMap;lh=e=>n.get(e),ah=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;lh=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},ah=(r,i)=>(t==e&&(t=0),n[t++]=r,n[t++]=i)}class Ds{constructor(e,t,r,i){this.left=e,this.top=t,this.right=r,this.bottom=i}}class et{constructor(e,t,r,i){this.width=e,this.height=t,this.map=r,this.problems=i}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let i=t%this.width,s=t/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[t+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new Ds(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return t=="horiz"?(r<0?i==0:s==this.width)?null:this.map[o*this.width+(r<0?i-1:s)]:(r<0?o==0:l==this.height)?null:this.map[i+this.width*(r<0?o-1:l)]}rectBetween(e,t){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new Ds(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let i=e.top;i<e.bottom;i++)for(let s=e.left;s<e.right;s++){let o=i*this.width+s,l=this.map[o];r[l]||(r[l]=!0,(s!=e.left||!s||this.map[o-1]!=l)&&(i!=e.top||!i||this.map[o-this.width]!=l)&&t.push(l))}return t}positionAt(e,t,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=t+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<s;)l++;return l==a?o-1:this.map[l]}s=o}}static get(e){return lh(e)||ah(e,i5(e))}}function i5(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=s5(n),t=n.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;let g=d.child(p),{colspan:v,rowspan:w,colwidth:S}=g.attrs;for(let x=0;x<w;x++){if(x+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-x});break}let y=i+x*e;for(let k=0;k<v;k++){r[y+k]==0?r[y+k]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-k});let E=S&&S[k];if(E){let T=(y+k)%e*2,N=o[T];N==null||N!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):N==E&&o[T+1]++}}}i+=v,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}let l=new et(e,t,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&o5(l,o,n),l}function s5(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let i=n.child(r),s=0;if(t)for(let o=0;o<r;o++){let l=n.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){let l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function o5(n,e,t){n.problems||(n.problems=[]);for(let r=0,i={};r<n.map.length;r++){let s=n.map[r];if(i[s])continue;i[s]=!0;let o=t.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=l5(o.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function l5(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Mt(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Rs(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function a5(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Tn(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ec(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Rs(e.$head)||c5(e.$head)}function c5(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ch(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function u5(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function uh(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vv(n,e,t){let r=n.start(-1),s=et.get(n.node(-1)).nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function wt(n,e,t){let r={};for(let i in n)r[i]=n[i];return r[e]=t,r}function _i(n,e,t=1){let r=wt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function wv(n,e,t=1){let r=wt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function d5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}class Se extends ue{constructor(e,t=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new Jc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ch(r)&&ch(i)&&uh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Se.rowSelection(r,i):s&&this.isColSelection()?Se.colSelection(r,i):new Se(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=et.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){let c=[];for(let u=a*t.width+i.left,d=i.left;d<i.right;d++,u++){let f=t.map[u];if(!s[f]){s[f]=!0;let h=t.findCell(f),p=e.nodeAt(f),g=i.left-h.left,v=h.right-i.right;if(g>0||v>0){let w=p.attrs;g>0&&(w=_i(w,0,g)),v>0&&(w=_i(w,w.colspan-v,v)),h.left<i.left?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){let w=wt(p.attrs,"rowspan",Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top));h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}}o.push(e.child(a).copy(W.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Y(W.from(l),1,1)}replace(e,t=Y.empty){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?Y.empty:t)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new Y(W.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=et.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.top<=o.top?(s.top>0&&(e=l.resolve(i+r.map[s.left])),o.bottom<r.height&&(t=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=l.resolve(i+r.map[o.left])),s.bottom<r.height&&(e=l.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new Se(e,t)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),i=e.colCount(this.$headCell.pos-t);if(Math.min(r,i)>0)return!1;let s=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,o)==e.width}eq(e){return e instanceof Se&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.left<=o.left?(s.left>0&&(e=l.resolve(i+r.map[s.top*r.width])),o.right<r.width&&(t=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=l.resolve(i+r.map[o.top*r.width])),s.right<r.width&&(e=l.resolve(i+r.map[r.width*(s.top+1)-1]))),new Se(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Se(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Se(e.resolve(t),e.resolve(r))}getBookmark(){return new dh(this.$anchorCell.pos,this.$headCell.pos)}}Se.prototype.visible=!1,ue.jsonID("cell",Se);class dh{constructor(e,t){this.anchor=e,this.head=t}map(e){return new dh(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&uh(t,r)?new Se(t,r):ue.near(r,1)}}function f5(n){if(!(n.selection instanceof Se))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(ut.node(r,r+t.nodeSize,{class:"selectedCell"}))}),He.create(n.doc,e)}function h5({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function p5({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){let s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){let s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function m5(n,e,t){let r=(e||n).selection,i=(e||n).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Se.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Se.rowSelection(l,l)}else if(!t){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Se.create(i,a+1,c)}}else r instanceof ce&&h5(r)?s=ce.create(i,r.from):r instanceof ce&&p5(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}function g5(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let i=e.firstChild,s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=fh(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?fh(Mt(o).row,new Y(e,t,r)).content:e);else return null;return y5(o,l)}function y5(n,e){let t=[];for(let i=0;i<e.length;i++){let s=e[i];for(let o=s.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(W.empty),t[i]<r){let s=Mt(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function fh(n,e){let t=n.createAndFill();return new qc(t).replace(0,t.content.size,e).doc}function b5({width:n,height:e,rows:t},r,i){if(n!=r){let s=[],o=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(_i(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}o.push(W.from(c))}t=o,n=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>i&&(d=d.type.create(wt(d.attrs,"rowspan",Math.max(1,i-d.attrs.rowspan)),d.content)),a.push(d)}s.push(W.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function v5(n,e,t,r,i,s,o){let l=n.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let v=e.width;v<i;v++)p.push(g);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(s>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,i);p++){let v=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==a.header_cell;d.push(v?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,W.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function xv(n,e,t,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function Cv(n,e,t,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function kv(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=n.tr,f=0;function h(){s=t?d.doc.nodeAt(t-1):d.doc,o=et.get(s),f=d.mapping.maps.length}v5(d,o,s,t,c,u,f)&&h(),xv(d,o,s,t,a,c,l,f)&&h(),xv(d,o,s,t,a,c,u,f)&&h(),Cv(d,o,s,t,l,u,a,f)&&h(),Cv(d,o,s,t,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=o.positionAt(p,a,s),v=o.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(g+t),d.mapping.slice(f).map(v+t),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Se(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(u-1,c-1,s)))),e(d)}const w5=ku({ArrowLeft:Ac("horiz",-1),ArrowRight:Ac("horiz",1),ArrowUp:Ac("vert",-1),ArrowDown:Ac("vert",1),"Shift-ArrowLeft":Mc("horiz",-1),"Shift-ArrowRight":Mc("horiz",1),"Shift-ArrowUp":Mc("vert",-1),"Shift-ArrowDown":Mc("vert",1),Backspace:Oc,"Mod-Backspace":Oc,Delete:Oc,"Mod-Delete":Oc});function Tc(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Ac(n,e){return(t,r,i)=>{let s=t.selection;if(s instanceof Se)return Tc(t,r,ue.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;let o=Sv(i,n,e);if(o==null)return!1;if(n=="horiz")return Tc(t,r,ue.near(t.doc.resolve(s.head+e),e));{let l=t.doc.resolve(o),a=vv(l,n,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(t.doc.resolve(l.before(-1)),-1):c=ue.near(t.doc.resolve(l.after(-1)),1),Tc(t,r,c)}}}function Mc(n,e){return(t,r,i)=>{let s=t.selection;if(!(s instanceof Se)){let l=Sv(i,n,e);if(l==null)return!1;s=new Se(t.doc.resolve(l))}let o=vv(s.$headCell,n,e);return o?Tc(t,r,new Se(s.$anchorCell,o)):!1}}function Oc(n,e){let t=n.selection;if(!(t instanceof Se))return!1;if(e){let r=n.tr,i=Mt(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new Y(i,0,0))}),r.docChanged&&e(r)}return!0}function x5(n,e){let t=n.state.doc,r=Rs(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Se(r))),!0):!1}function C5(n,e,t){if(!Tn(n.state))return!1;let r=g5(t),i=n.state.selection;if(i instanceof Se){r||(r={width:1,height:1,rows:[W.from(fh(Mt(n.state.schema).cell,t))]});let s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=et.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=b5(r,l.right-l.left,l.bottom-l.top),kv(n.state,n.dispatch,o,l,r),!0}else if(r){let s=Ec(n.state),o=s.start(-1);return kv(n.state,n.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function k5(n,e){if(e.ctrlKey||e.metaKey)return;let t=Ev(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof Se)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=Rs(n.state.selection.$anchor))!=null&&hh(n,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!t)return;function i(l,a){let c=hh(n,a),u=Gr.getState(n.state)==null;if(!c||!uh(l,c))if(u)c=l;else return;let d=new Se(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",o),Gr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Ev(n,l.target)!=t&&(c=hh(n,e),!c))return s();c&&i(c,l)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",o)}function Sv(n,e,t){if(!(n.state.selection instanceof ce))return null;let{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){let l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ev(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function hh(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Rs(n.state.doc.resolve(t.pos)):null}const S5=new We("fix-tables");function Tv(n,e,t,r){let i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){let a=e.child(o);for(let c=l,u=Math.min(i,o+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?Tv(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Av(n,e){let t,r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=E5(n,i,s,t))};return e?e.doc!=n.doc&&Tv(e.doc,n.doc,0,r):n.doc.descendants(r),t}function E5(n,e,t,r){let i=et.get(e);if(!i.problems)return r;r||(r=n.tr);let s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){let c=i.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,_i(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"colwidth",c.colwidth))}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<i.height;a++){let u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let v=0;v<f;v++)p.push(Mt(n.schema)[h].createAndFill());let g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(S5,{fixTables:!0})}function Xn(n){let e=n.selection,t=Ec(n),r=t.node(-1),i=t.start(-1),s=et.get(r),o;return e instanceof Se?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(t.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function Mv(n,{map:e,tableStart:t,table:r},i){let s=i>0?-1:0;d5(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,wv(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=s==null?Mt(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function T5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.left))}return!0}function A5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.right))}return!0}function M5(n,{map:e,table:t,tableStart:r},i){let s=n.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=t.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=n.mapping.slice(s).map(r+a);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function O5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;M5(r,t,i),i!=t.left;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(e.nodeAt(n.map[i+t*n.width]).type!=r)return!1;return!0}function Ov(n,{map:e,tableStart:t,table:r},i){let s=t;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;_5(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let a=0,c=e.width*i;a<e.width;a++,c++)if(i>0&&i<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,wt(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Mt(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;o.push(u.createAndFill())}return n.insert(s,Mt(r.type.schema).row.create(null,o)),n}function N5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.top))}return!0}function D5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.bottom))}return!0}function R5(n,{map:e,table:t,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=t.child(a).nodeSize;let o=s+t.child(i).nodeSize,l=n.mapping.maps.length;n.delete(s+r,o+r);for(let a=0,c=i*e.width;a<e.width;a++,c++){let u=e.map[c];if(i>0&&u==e.map[c-e.width]){let d=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,wt(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(i<e.width&&u==e.map[c+e.width]){let d=t.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function L5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;R5(r,t,i),i!=t.top;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _v(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function I5({width:n,height:e,map:t},r){let i=r.top*n+r.left,s=i,o=(r.bottom-1)*n+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[o]==t[o+n])return!0;i++,o++}return!1}function Nv(n,e){let t=n.selection;if(!(t instanceof Se)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xn(n),{map:i}=r;if(I5(i,r))return!1;if(e){let s=n.tr,o={},l=W.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=i.map[u*i.width+d],h=r.table.nodeAt(f);if(!o[f])if(o[f]=!0,a==null)a=f,c=h;else{_v(h)||(l=l.append(h.content));let p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(s.setNodeMarkup(a+r.tableStart,null,wt(wv(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=_v(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Se(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Dv(n,e){const t=Mt(n.schema);return P5(({node:r})=>t[r.type.spec.tableRole])(n,e)}function P5(n){return(e,t)=>{let r=e.selection,i,s;if(r instanceof Se){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=a5(r.$from),!i)return!1;s=Rs(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let o=i.attrs,l=[],a=o.colwidth;o.rowspan>1&&(o=wt(o,"rowspan",1)),o.colspan>1&&(o=wt(o,"colspan",1));let c=Xn(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?wt(o,"colwidth",a&&a[f]?[a[f]]:null):o);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=i.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),n({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,n({node:i,row:c.top,col:c.left}),l[0]),r instanceof Se&&u.setSelection(new Se(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function F5(n,e){return function(t,r){if(!Tn(t))return!1;let i=Ec(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){let s=t.tr;t.selection instanceof Se?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,n,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,n,e)),r(s)}return!0}}function B5(n){return function(e,t){if(!Tn(e))return!1;if(t){let r=Mt(e.schema),i=Xn(e),s=e.tr,o=i.map.cellsInRect(n=="column"?new Ds(i.left,0,i.right,i.map.height):n=="row"?new Ds(0,i.top,i.map.width,i.bottom):i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Rv(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Zo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?B5(n):function(t,r){if(!Tn(t))return!1;if(r){let i=Mt(t.schema),s=Xn(t),o=t.tr,l=Rv("row",s,i),a=Rv("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new Ds(0,u,1,s.map.height):n=="row"?new Ds(u,0,s.map.width,1):s,f=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}Zo("row",{useDeprecatedLogic:!0}),Zo("column",{useDeprecatedLogic:!0});let $5=Zo("cell",{useDeprecatedLogic:!0});function j5(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){let s=n.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){let s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Lv(n){return function(e,t){if(!Tn(e))return!1;let r=j5(Ec(e),n);if(r!=null){if(t){let i=e.doc.resolve(r);t(e.tr.setSelection(ce.between(i,u5(i))).scrollIntoView())}return!0}}}function H5(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let V5=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ph(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ph(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ph(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild,c=n.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let g=i==d?s:h&&h[p],v=g?g+"px":"";o+=g||r,g||(l=!1),a?(a.style.width!=v&&(a.style.width=v),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=v}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function z5({handleWidth:n=5,cellMinWidth:e=25,View:t=V5,lastColumnResizable:r=!0}={}){return new je({key:mn,state:{init(s,o){return this.spec.props.nodeViews[Mt(o.schema).table.name]=(l,a)=>new t(l,e,a),new Xo(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes(s){return mn.getState(s).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(s,o){U5(s,o,n,e,r)},mouseleave(s){W5(s)},mousedown(s,o){q5(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return X5(s,o.activeHandle)},nodeViews:{}}})}class Xo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new Xo(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Xo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);ch(e.doc.resolve(i))||(i=null),t=new Xo(i,t.dragging)}return t}}function U5(n,e,t,r,i){let s=mn.getState(n.state);if(!s.dragging){let o=J5(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=t?l=Iv(n,e,"left"):c-e.clientX<=t&&(l=Iv(n,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=n.state.doc.resolve(l),c=a.node(-1),u=et.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Fv(n,l)}}}function W5(n){let e=mn.getState(n.state);e.activeHandle>-1&&!e.dragging&&Fv(n,-1)}function q5(n,e,t){let r=mn.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let i=n.state.doc.nodeAt(r.activeHandle),s=K5(n,r.activeHandle,i.attrs);n.dispatch(n.state.tr.setMeta(mn,{setDragging:{startX:e.clientX,startWidth:s}}));function o(a){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",l);let c=mn.getState(n.state);c.dragging&&(G5(n,c.activeHandle,Pv(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(n.state),u=Pv(c.dragging,a,t);Y5(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function K5(n,e,{colspan:t,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=n.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function J5(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Iv(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Rs(n.state.doc.resolve(i));if(!s)return-1;if(t=="right")return s.pos;let o=et.get(s.node(-1)),l=s.start(-1),a=o.map.indexOf(s.pos-l);return a%o.width==0?-1:l+o.map[a-1]}function Pv(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Fv(n,e){n.dispatch(n.state.tr.setMeta(mn,{setHandle:e}))}function G5(n,e,t){let r=n.state.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){let u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;let d=s.map[u],{attrs:f}=i.nodeAt(d),h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;let p=f.colwidth?f.colwidth.slice():Z5(f.colspan);p[h]=t,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function Y5(n,e,t,r){let i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=et.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=n.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;ph(s,a.firstChild,a,r,l,t)}function Z5(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function X5(n,e){let t=[],r=n.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){let c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c-1]!=s.map[c-1-s.width])){let u=s.map[c],d=o+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push(ut.widget(d,f))}}return He.create(n.doc,t)}function Q5({allowTableNodeSelection:n=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,t){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:f5,handleDOMEvents:{mousedown:k5},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:x5,handleKeyDown:w5,handlePaste:C5},appendTransaction(e,t,r){return m5(r,Av(r,t),n)}})}function Bv(n,e,t,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const v=i===f?s:p&&p[g],w=v?`${v}px`:"";o+=v||r,v||(l=!1),a?(a.style.width!==w&&(a.style.width=w),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=w}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class eL{constructor(e,t){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Bv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Bv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $v(n,e){return n.createAndFill()}function tL(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function nL(n,e,t,r,i){const s=tL(n),o=[],l=[];for(let c=0;c<t;c+=1){const u=$v(s.cell);if(u&&l.push(u),r){const d=$v(s.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function rL(n){return n instanceof Se}const _c=({editor:n})=>{const{selection:e}=n.state;if(!rL(e))return!1;let t=0;const r=Ru(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},iL=Ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:eL,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",xe(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=nL(s.schema,n,e,t);if(i){const a=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,l).scrollIntoView().setSelection(ce.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>T5(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>A5(n,e),deleteColumn:()=>({state:n,dispatch:e})=>O5(n,e),addRowBefore:()=>({state:n,dispatch:e})=>N5(n,e),addRowAfter:()=>({state:n,dispatch:e})=>D5(n,e),deleteRow:()=>({state:n,dispatch:e})=>L5(n,e),deleteTable:()=>({state:n,dispatch:e})=>H5(n,e),mergeCells:()=>({state:n,dispatch:e})=>Nv(n,e),splitCell:()=>({state:n,dispatch:e})=>Dv(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Zo("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Zo("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>$5(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Nv(n,e)?!0:Dv(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>F5(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Lv(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Lv(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Av(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Se.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:_c,"Mod-Backspace":_c,Delete:_c,"Mod-Delete":_c}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[z5({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Q5({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ge(re(n,"tableRole",e))}}});function jv(n,e){if(n==null)return{};var t={},r=Object.keys(n),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(t[i]=n[i]);return t}var Hv=typeof window<"u"&&typeof document<"u";function mh(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Vv(){return Hv&&document.createElement("div")}function sL(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function zv(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!zv(n[t],e[t]))return!1}else return!1;return!0}else return!1}function oL(n){var e=[];return n.forEach(function(t){e.find(function(r){return zv(t,r)})||e.push(t)}),e}function lL(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:oL([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var gh=Hv?O.useLayoutEffect:O.useEffect;function aL(n){var e=O.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Uv(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var cL={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function i(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}Uv(t,"add",e.props.className)}function s(){r()&&Uv(t,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function uL(n){function e(t){var r=t.children,i=t.content,s=t.visible,o=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=jv(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=s!==void 0,g=o!==void 0,v=O.useState(!1),w=v[0],S=v[1],x=O.useState({}),y=x[0],k=x[1],E=O.useState(),T=E[0],N=E[1],_=aL(function(){return{container:Vv(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:_.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(V){A[V]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+V+"` prop in","controlled mode (`visible` prop)"].join(" "))}),A.trigger="manual",A.hideOnClick=!1),g&&(u=!0);var R=A,P=A.plugins||[];l&&(R=Object.assign({},A,{plugins:g&&o.data!=null?[].concat(P,[{fn:function(){return{onTrigger:function(J,G){var ie=o.data.children.find(function(X){var we=X.instance;return we.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,N(ie.content)}}}}]):P,render:function(){return{popper:_.container}}}));var $=[a].concat(r?[r.type]:[]);return gh(function(){var V=a;a&&a.hasOwnProperty("current")&&(V=a.current);var U=n(V||_.ref||Vv(),Object.assign({},R,{plugins:[cL].concat(A.plugins||[])}));return _.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),gh(function(){var V;if(_.renders===1){_.renders++;return}var U=_.instance;U.setProps(lL(U.props,R)),(V=U.popperInstance)==null||V.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N})}),gh(function(){var V;if(l){var U=_.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((V=U.props.popperOptions)==null?void 0:V.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,X=G.state,we=(ie=X.modifiersData)==null?void 0:ie.hide;(y.placement!==X.placement||y.referenceHidden!==(we==null?void 0:we.isReferenceHidden)||y.escaped!==(we==null?void 0:we.hasPopperEscaped))&&k({placement:X.placement,referenceHidden:we==null?void 0:we.isReferenceHidden,escaped:we==null?void 0:we.hasPopperEscaped}),X.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat($)),O.createElement(O.Fragment,null,r?O.cloneElement(r,{ref:function(U){_.ref=U,mh(r.ref,U)}}):null,w&&nn.createPortal(l?l(sL(y),T,_.instance):i,_.container))}return e}var dL=function(n,e){return O.forwardRef(function(r,i){var s=r.children,o=jv(r,["children"]);return O.createElement(n,Object.assign({},e,o),s?O.cloneElement(s,{ref:function(a){mh(i,a),mh(s.ref,a)}}):null)})},fL=dL(uL(fi));const hL=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],Wv=({node:n,getPos:e,selected:t,editor:r})=>{const[i,s]=O.useState(!1),o=Ul(),l=O.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.nodeSize;s(f<=u&&d<=h)};O.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return D.jsxs(bo,{className:"group",children:[D.jsx(Kg,{as:"span"}),(i||t)&&D.jsx(fL,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:D.jsx("article",{className:"dropdown",contentEditable:!1,children:D.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:hL.map(u=>D.jsx("li",{children:D.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[D.jsx("span",{children:u.icon}),D.jsx("span",{children:u.name})]})},u.name))})}),children:D.jsx("label",{tabIndex:0,className:Fe("trigger-button",{hidden:o}),contentEditable:!1,children:D.jsx(GE,{fontSize:"small"})})})]})},pL=Ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"td",className:"relative"})}}),mL=Ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"th",className:"relative"})}}),qv=n=>(n.stopPropagation(),n.preventDefault(),n),gL=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},Kv=function(n){return!n||n===document.body?document.body:gL(n)?n:Kv(n.parentNode)},yh=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),t&&Object.entries(t).forEach(([i,s])=>r.addEventListener(i,s)),r},yL=Ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),i=Kv(n.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=n.state.doc.resolve(w),x=new se(S);n.view.dispatch(n.state.tr.setSelection(x))}},l=()=>{s=!0},a=()=>{s=!1},c=yh("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:w=>{w&&qv(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=yh("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&qv(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=yh("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const w=h.getBoundingClientRect(),S=JSON.stringify(w);p!==S&&(c.style.top=`${w.top+document.documentElement.scrollTop}px`,c.style.left=`${w.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${w.height+1}px`,p=S)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),bL=[iL.configure({resizable:!0}),pL,mL,yL],vL=Hb.extend({content:"(dBlock|columns)+"});function Jv({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const wL=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new je({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!Jv({node:i,types:e})},apply:(t,r)=>{var s,o,l;if(!t.docChanged)return r;const i=(l=(o=(s=t.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!Jv({node:i,types:e})}}})]}}),xL=({node:n,editor:e,getPos:t})=>{const[r,i]=O.useState(""),s=Ul(),o=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return D.jsx(f0,{});case"iframe":return D.jsx(h0,{});default:return D.jsx(aT,{})}},a=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const x=r.match(/src="([^"]*)"/);x&&x.length>0&&(p=x[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://www.youtube.com/embed/${x[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://player.vimeo.com/video/${x[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,v=360,w=t(),S=w+n.nodeSize;p&&(e==null||e.chain().focus(w).deleteRange({from:w,to:S}).setIframe({src:p,width:g,height:v}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(y=>r.includes(y)),v=r.match(/\/status\/([0-9]*)/),w=v&&v.length>0;if(g&&w)p=v[1];else{alert("invalid url");return}const S=t(),x=S+n.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:x}).setTweetEmbed({tweetId:p}).run())},f=y1(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);O.useEffect(()=>{r&&f()},[r]),O.useEffect(()=>{e==null||e.chain().focus()},[]);const h=O.useRef(null);return O.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&D.jsxs("div",{className:"relative w-full",children:[D.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),D.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>i(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},CL=Ve.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return hi(xL)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",xe(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),kL=[h_,d_.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),p_.configure({types:["heading","paragraph"]}),tN,F_.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),B_.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),H_.configure({multicolor:!0}),eN,W_.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),f_,iN,V_.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),U_.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Vb.configure({width:3,color:"#d1d5db"}),zb,r5,wL,vL,...bL,hN.configure({uploadFn:AT}),rN,sN,cN,CL.extend({addInputRules(){return[Gv(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),Gv(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),nN],Gv=(n,e,t)=>new io({find:n,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,t.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Yv=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],SL=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r})=>{const[i,s]=O.useState({plugin:{title:"Untitled"}}),[o]=O.useState(new as),l=O.useRef(null),a=[...kL,p3.configure({document:o})];O.useEffect(()=>{if(r&&t){const f=new HO(r||"default-room",o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});return l.current=f,()=>{f.destroy(),o.destroy()}}},[r,o]),O.useEffect(()=>{t&&r&&(a.some(h=>h.name==="collaborationCursor")||a.push(m3.configure({provider:l.current,user:{color:Yv[Math.floor(Math.random()*Yv.length)]}})))},[l.current]);const c=FE({extensions:a,editorProps:VO,autofocus:"start"}),u=O.useRef(null),d=f=>{var h;(h=u.current)!=null&&h.contains(f.target)||c==null||c.chain().focus().run()};return O.useEffect(()=>{c==null||c.chain().focus()},[]),O.useEffect(()=>{c==null||c.setEditable(!n)},[n]),O.useEffect(()=>{e&&c&&(c==null||c.commands.setContent(e.editorJSONData),s(e.metaData))},[e,c]),{editor:c,pluginMetaData:i,setPluginMetaData:s,focusEditor:d,ref:u}},EL=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r,enableCollaboration:i,collaborationId:s,onAutoSave:o})=>{const{editor:l,pluginMetaData:a,focusEditor:c,setPluginMetaData:u,ref:d}=SL({isPreviewMode:n,data:t,enableCollaboration:i,collaborationId:s,onPublish:e,togglePreviewMode:r});return O.useEffect(()=>{if(l&&o){const f=setInterval(()=>{o({metaData:a,editorJSONData:l.getJSON()})},1e4);return()=>clearInterval(f)}},[l,o,a]),l?D.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f9fbfd]",children:D.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:D.jsxs("div",{className:"w-full h-screen",children:[D.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:D.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[D.jsx("div",{className:"grow",children:D.jsx(iw,{isPreviewMode:n,metaData:a,setMetaData:u})}),!n&&D.jsx("div",{className:"grow relative",children:D.jsx(zT,{editor:l})}),D.jsx("div",{children:D.jsxs(zl,{onClick:()=>r(n),children:[n?D.jsx(nT,{size:14}):D.jsx(sT,{size:14})," ",n?"Edit":"Preview"]})}),e&&D.jsx("div",{children:D.jsxs(zl,{onClick:()=>e({metaData:a,editorJSONData:l.getJSON()}),children:[D.jsx(oT,{size:14})," Share"]})})]})}),D.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:D.jsx("div",{onClick:c,className:"w-full flex justify-center relative",children:D.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]",children:D.jsxs("div",{ref:d,className:"w-full pt-4 h-full",children:[!n&&D.jsxs("div",{children:[D.jsx(LT,{editor:l}),D.jsx(HT,{editor:l,appendTo:d})]}),D.jsx(VT,{isPreviewMode:n,children:D.jsx(IE,{editor:l})})]})})})})]})})}):D.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[D.jsx(N0,{}),D.jsx("p",{children:"Loading Editor..."})]})};Bt.DdocEditor=EL,Object.defineProperty(Bt,Symbol.toStringTag,{value:"Module"})});
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { DdocProps } from './types';
|
2
2
|
|
3
|
-
declare const DdocEditor: ({ isPreviewMode, onPublish, data, togglePreviewMode, enableCollaboration, collaborationId, }: DdocProps) => import("react/jsx-runtime").JSX.Element;
|
3
|
+
declare const DdocEditor: ({ isPreviewMode, onPublish, data, togglePreviewMode, enableCollaboration, collaborationId, onAutoSave, }: DdocProps) => import("react/jsx-runtime").JSX.Element;
|
4
4
|
export default DdocEditor;
|