reactjs-tiptap-editor-pro
Version:
A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React
1,544 lines • 114 kB
JavaScript
var dr = Object.defineProperty;
var ur = (e, t, n) => t in e ? dr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var me = (e, t, n) => ur(e, typeof t != "symbol" ? t + "" : t, n);
import * as ie from "react";
import { useRef as ne, useState as I, useEffect as R, useMemo as z, Fragment as Ve, useCallback as O, memo as fr, forwardRef as hr, useId as mr, useImperativeHandle as gr, useLayoutEffect as pr } from "react";
import { jsx as a, jsxs as p, Fragment as E } from "react/jsx-runtime";
import { i as Ke, S as re, t as vr, a as Ce, b as oe, r as J, c as Z, f as yr, d as ae, e as wr, D as Xe, g as qe, A as C, h as Ye, j as Je, C as xr, k as Ze, B as Y, s as cn, l as dn, m as un, u as Te, n as vt, o as L, p as U, P as br, q as Cr, v as Tr, L as $e, I as ye, w as se, x as Ae, y as Ar, K as ge, T as fn, M as yt, z as wt, F as Sr, E as hn, G as mn, H as Pr, J as he, N as _r, O as Er, Q as Nr, R as gn, U as $r, V as Or, W as j, X as Rr, Y as Ir, Z as Dr, _ as Br, $ as Mr, a0 as kr, a1 as X, a2 as Lr, a3 as xt, a4 as bt, a5 as Ct, a6 as Tt, a7 as At, a8 as St, a9 as pn, aa as zr, ab as vn, ac as yn, ad as Fr, ae as jr, af as Hr, ag as Pt, ah as Ur, ai as Gr, aj as Wr, ak as Vr, al as Kr, am as _t, an as Et, ao as Xr, ap as qr, aq as Yr, ar as Jr, as as Zr, at as Qr, au as ei } from "./ColorPicker-B3iXkFey.js";
import { u as D, B as ti, l as B, I as we, V as Nt, E as ni } from "./locale-bundle-CT7qZRHF.js";
import * as F from "@radix-ui/react-toast";
import { X as ri, HelpCircle as ii, Pencil as oi, Trash2 as ai } from "lucide-react";
import { Editor as si, makeDropdownToolbar as li } from "easydrawer";
import ci from "katex";
import $t from "mermaid";
import di, { sticky as ui } from "tippy.js";
function Uc() {
var o;
const e = ne({ editor: null }), [t, n] = I(!1), [r, i] = I(null);
return R(() => {
var s;
(s = e.current) != null && s.editor && (n(!0), i(e.current.editor));
}, [e, (o = e.current) == null ? void 0 : o.editor]), { isReady: t, editor: r, editorRef: e };
}
function wn(e, t) {
for (var n = -1, r = e == null ? 0 : e.length, i = Array(r); ++n < r; )
i[n] = t(e[n], n, e);
return i;
}
var G = Array.isArray, Ot = re ? re.prototype : void 0, Rt = Ot ? Ot.toString : void 0;
function xe(e) {
if (typeof e == "string")
return e;
if (G(e))
return wn(e, xe) + "";
if (Ke(e))
return Rt ? Rt.call(e) : "";
var t = e + "";
return t == "0" && 1 / e == -1 / 0 ? "-0" : t;
}
var fi = 1 / 0, hi = 17976931348623157e292;
function mi(e) {
if (!e)
return e === 0 ? e : 0;
if (e = vr(e), e === fi || e === -1 / 0) {
var t = e < 0 ? -1 : 1;
return t * hi;
}
return e === e ? e : 0;
}
function gi(e) {
var t = mi(e), n = t % 1;
return t === t ? n ? t - n : t : 0;
}
function Qe(e) {
return e;
}
var pi = "[object AsyncFunction]", vi = "[object Function]", yi = "[object GeneratorFunction]", wi = "[object Proxy]";
function xn(e) {
if (!Ce(e))
return !1;
var t = oe(e);
return t == vi || t == yi || t == pi || t == wi;
}
var Oe = J["__core-js_shared__"], It = function() {
var e = /[^.]+$/.exec(Oe && Oe.keys && Oe.keys.IE_PROTO || "");
return e ? "Symbol(src)_1." + e : "";
}();
function xi(e) {
return !!It && It in e;
}
var bi = Function.prototype, Ci = bi.toString;
function ee(e) {
if (e != null) {
try {
return Ci.call(e);
} catch {
}
try {
return e + "";
} catch {
}
}
return "";
}
var Ti = /[\\^$.*+?()[\]{}|]/g, Ai = /^\[object .+?Constructor\]$/, Si = Function.prototype, Pi = Object.prototype, _i = Si.toString, Ei = Pi.hasOwnProperty, Ni = RegExp(
"^" + _i.call(Ei).replace(Ti, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
);
function $i(e) {
if (!Ce(e) || xi(e))
return !1;
var t = xn(e) ? Ni : Ai;
return t.test(ee(e));
}
function Oi(e, t) {
return e == null ? void 0 : e[t];
}
function te(e, t) {
var n = Oi(e, t);
return $i(n) ? n : void 0;
}
var Be = te(J, "WeakMap");
function Ri(e, t, n) {
switch (n.length) {
case 0:
return e.call(t);
case 1:
return e.call(t, n[0]);
case 2:
return e.call(t, n[0], n[1]);
case 3:
return e.call(t, n[0], n[1], n[2]);
}
return e.apply(t, n);
}
var Ii = 800, Di = 16, Bi = Date.now;
function Mi(e) {
var t = 0, n = 0;
return function() {
var r = Bi(), i = Di - (r - n);
if (n = r, i > 0) {
if (++t >= Ii)
return arguments[0];
} else
t = 0;
return e.apply(void 0, arguments);
};
}
function ki(e) {
return function() {
return e;
};
}
var Dt = function() {
try {
var e = te(Object, "defineProperty");
return e({}, "", {}), e;
} catch {
}
}(), Li = Dt ? function(e, t) {
return Dt(e, "toString", {
configurable: !0,
enumerable: !1,
value: ki(t),
writable: !0
});
} : Qe, zi = Mi(Li);
function Fi(e, t, n, r) {
for (var i = e.length, o = n + -1; ++o < i; )
if (t(e[o], o, e))
return o;
return -1;
}
function ji(e) {
return e !== e;
}
function Hi(e, t, n) {
for (var r = n - 1, i = e.length; ++r < i; )
if (e[r] === t)
return r;
return -1;
}
function Ui(e, t, n) {
return t === t ? Hi(e, t, n) : Fi(e, ji, n);
}
function Gi(e, t) {
var n = e == null ? 0 : e.length;
return !!n && Ui(e, t, 0) > -1;
}
var Wi = 9007199254740991, Vi = /^(?:0|[1-9]\d*)$/;
function bn(e, t) {
var n = typeof e;
return t = t ?? Wi, !!t && (n == "number" || n != "symbol" && Vi.test(e)) && e > -1 && e % 1 == 0 && e < t;
}
function Cn(e, t) {
return e === t || e !== e && t !== t;
}
var Bt = Math.max;
function Ki(e, t, n) {
return t = Bt(t === void 0 ? e.length - 1 : t, 0), function() {
for (var r = arguments, i = -1, o = Bt(r.length - t, 0), s = Array(o); ++i < o; )
s[i] = r[t + i];
i = -1;
for (var c = Array(t + 1); ++i < t; )
c[i] = r[i];
return c[t] = n(s), Ri(e, this, c);
};
}
function Xi(e, t) {
return zi(Ki(e, t, Qe), e + "");
}
var qi = 9007199254740991;
function et(e) {
return typeof e == "number" && e > -1 && e % 1 == 0 && e <= qi;
}
function Tn(e) {
return e != null && et(e.length) && !xn(e);
}
var Yi = Object.prototype;
function Ji(e) {
var t = e && e.constructor, n = typeof t == "function" && t.prototype || Yi;
return e === n;
}
function Zi(e, t) {
for (var n = -1, r = Array(e); ++n < e; )
r[n] = t(n);
return r;
}
var Qi = "[object Arguments]";
function Mt(e) {
return Z(e) && oe(e) == Qi;
}
var An = Object.prototype, eo = An.hasOwnProperty, to = An.propertyIsEnumerable, tt = Mt(/* @__PURE__ */ function() {
return arguments;
}()) ? Mt : function(e) {
return Z(e) && eo.call(e, "callee") && !to.call(e, "callee");
};
function no() {
return !1;
}
var Sn = typeof exports == "object" && exports && !exports.nodeType && exports, kt = Sn && typeof module == "object" && module && !module.nodeType && module, ro = kt && kt.exports === Sn, Lt = ro ? J.Buffer : void 0, io = Lt ? Lt.isBuffer : void 0, Me = io || no, oo = "[object Arguments]", ao = "[object Array]", so = "[object Boolean]", lo = "[object Date]", co = "[object Error]", uo = "[object Function]", fo = "[object Map]", ho = "[object Number]", mo = "[object Object]", go = "[object RegExp]", po = "[object Set]", vo = "[object String]", yo = "[object WeakMap]", wo = "[object ArrayBuffer]", xo = "[object DataView]", bo = "[object Float32Array]", Co = "[object Float64Array]", To = "[object Int8Array]", Ao = "[object Int16Array]", So = "[object Int32Array]", Po = "[object Uint8Array]", _o = "[object Uint8ClampedArray]", Eo = "[object Uint16Array]", No = "[object Uint32Array]", $ = {};
$[bo] = $[Co] = $[To] = $[Ao] = $[So] = $[Po] = $[_o] = $[Eo] = $[No] = !0;
$[oo] = $[ao] = $[wo] = $[so] = $[xo] = $[lo] = $[co] = $[uo] = $[fo] = $[ho] = $[mo] = $[go] = $[po] = $[vo] = $[yo] = !1;
function $o(e) {
return Z(e) && et(e.length) && !!$[oe(e)];
}
function nt(e) {
return function(t) {
return e(t);
};
}
var Pn = typeof exports == "object" && exports && !exports.nodeType && exports, ce = Pn && typeof module == "object" && module && !module.nodeType && module, Oo = ce && ce.exports === Pn, Re = Oo && yr.process, be = function() {
try {
var e = ce && ce.require && ce.require("util").types;
return e || Re && Re.binding && Re.binding("util");
} catch {
}
}(), zt = be && be.isTypedArray, _n = zt ? nt(zt) : $o, Ro = Object.prototype, Io = Ro.hasOwnProperty;
function Do(e, t) {
var n = G(e), r = !n && tt(e), i = !n && !r && Me(e), o = !n && !r && !i && _n(e), s = n || r || i || o, c = s ? Zi(e.length, String) : [], l = c.length;
for (var d in e)
Io.call(e, d) && !(s && // Safari 9 has enumerable `arguments.length` in strict mode.
(d == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
i && (d == "offset" || d == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
o && (d == "buffer" || d == "byteLength" || d == "byteOffset") || // Skip index properties.
bn(d, l))) && c.push(d);
return c;
}
function Bo(e, t) {
return function(n) {
return e(t(n));
};
}
var Mo = Bo(Object.keys, Object), ko = Object.prototype, Lo = ko.hasOwnProperty;
function zo(e) {
if (!Ji(e))
return Mo(e);
var t = [];
for (var n in Object(e))
Lo.call(e, n) && n != "constructor" && t.push(n);
return t;
}
function En(e) {
return Tn(e) ? Do(e) : zo(e);
}
var Fo = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, jo = /^\w*$/;
function rt(e, t) {
if (G(e))
return !1;
var n = typeof e;
return n == "number" || n == "symbol" || n == "boolean" || e == null || Ke(e) ? !0 : jo.test(e) || !Fo.test(e) || t != null && e in Object(t);
}
var de = te(Object, "create");
function Ho() {
this.__data__ = de ? de(null) : {}, this.size = 0;
}
function Uo(e) {
var t = this.has(e) && delete this.__data__[e];
return this.size -= t ? 1 : 0, t;
}
var Go = "__lodash_hash_undefined__", Wo = Object.prototype, Vo = Wo.hasOwnProperty;
function Ko(e) {
var t = this.__data__;
if (de) {
var n = t[e];
return n === Go ? void 0 : n;
}
return Vo.call(t, e) ? t[e] : void 0;
}
var Xo = Object.prototype, qo = Xo.hasOwnProperty;
function Yo(e) {
var t = this.__data__;
return de ? t[e] !== void 0 : qo.call(t, e);
}
var Jo = "__lodash_hash_undefined__";
function Zo(e, t) {
var n = this.__data__;
return this.size += this.has(e) ? 0 : 1, n[e] = de && t === void 0 ? Jo : t, this;
}
function Q(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
Q.prototype.clear = Ho;
Q.prototype.delete = Uo;
Q.prototype.get = Ko;
Q.prototype.has = Yo;
Q.prototype.set = Zo;
function Qo() {
this.__data__ = [], this.size = 0;
}
function Se(e, t) {
for (var n = e.length; n--; )
if (Cn(e[n][0], t))
return n;
return -1;
}
var ea = Array.prototype, ta = ea.splice;
function na(e) {
var t = this.__data__, n = Se(t, e);
if (n < 0)
return !1;
var r = t.length - 1;
return n == r ? t.pop() : ta.call(t, n, 1), --this.size, !0;
}
function ra(e) {
var t = this.__data__, n = Se(t, e);
return n < 0 ? void 0 : t[n][1];
}
function ia(e) {
return Se(this.__data__, e) > -1;
}
function oa(e, t) {
var n = this.__data__, r = Se(n, e);
return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this;
}
function V(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
V.prototype.clear = Qo;
V.prototype.delete = na;
V.prototype.get = ra;
V.prototype.has = ia;
V.prototype.set = oa;
var ue = te(J, "Map");
function aa() {
this.size = 0, this.__data__ = {
hash: new Q(),
map: new (ue || V)(),
string: new Q()
};
}
function sa(e) {
var t = typeof e;
return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
}
function Pe(e, t) {
var n = e.__data__;
return sa(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
}
function la(e) {
var t = Pe(this, e).delete(e);
return this.size -= t ? 1 : 0, t;
}
function ca(e) {
return Pe(this, e).get(e);
}
function da(e) {
return Pe(this, e).has(e);
}
function ua(e, t) {
var n = Pe(this, e), r = n.size;
return n.set(e, t), this.size += n.size == r ? 0 : 1, this;
}
function K(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
K.prototype.clear = aa;
K.prototype.delete = la;
K.prototype.get = ca;
K.prototype.has = da;
K.prototype.set = ua;
var fa = "Expected a function";
function it(e, t) {
if (typeof e != "function" || t != null && typeof t != "function")
throw new TypeError(fa);
var n = function() {
var r = arguments, i = t ? t.apply(this, r) : r[0], o = n.cache;
if (o.has(i))
return o.get(i);
var s = e.apply(this, r);
return n.cache = o.set(i, s) || o, s;
};
return n.cache = new (it.Cache || K)(), n;
}
it.Cache = K;
var ha = 500;
function ma(e) {
var t = it(e, function(r) {
return n.size === ha && n.clear(), r;
}), n = t.cache;
return t;
}
var ga = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, pa = /\\(\\)?/g, va = ma(function(e) {
var t = [];
return e.charCodeAt(0) === 46 && t.push(""), e.replace(ga, function(n, r, i, o) {
t.push(i ? o.replace(pa, "$1") : r || n);
}), t;
});
function ke(e) {
return e == null ? "" : xe(e);
}
function Nn(e, t) {
return G(e) ? e : rt(e, t) ? [e] : va(ke(e));
}
function _e(e) {
if (typeof e == "string" || Ke(e))
return e;
var t = e + "";
return t == "0" && 1 / e == -1 / 0 ? "-0" : t;
}
function $n(e, t) {
t = Nn(t, e);
for (var n = 0, r = t.length; e != null && n < r; )
e = e[_e(t[n++])];
return n && n == r ? e : void 0;
}
function ya(e, t, n) {
var r = e == null ? void 0 : $n(e, t);
return r === void 0 ? n : r;
}
function On(e, t) {
for (var n = -1, r = t.length, i = e.length; ++n < r; )
e[i + n] = t[n];
return e;
}
var Ft = re ? re.isConcatSpreadable : void 0;
function wa(e) {
return G(e) || tt(e) || !!(Ft && e && e[Ft]);
}
function xa(e, t, n, r, i) {
var o = -1, s = e.length;
for (n || (n = wa), i || (i = []); ++o < s; ) {
var c = e[o];
n(c) && On(i, c);
}
return i;
}
function ba(e, t, n) {
var r = -1, i = e.length;
t < 0 && (t = -t > i ? 0 : i + t), n = n > i ? i : n, n < 0 && (n += i), i = t > n ? 0 : n - t >>> 0, t >>>= 0;
for (var o = Array(i); ++r < i; )
o[r] = e[r + t];
return o;
}
function Ca(e, t, n) {
var r = e.length;
return n = n === void 0 ? r : n, n >= r ? e : ba(e, t, n);
}
var Ta = "\\ud800-\\udfff", Aa = "\\u0300-\\u036f", Sa = "\\ufe20-\\ufe2f", Pa = "\\u20d0-\\u20ff", _a = Aa + Sa + Pa, Ea = "\\ufe0e\\ufe0f", Na = "\\u200d", $a = RegExp("[" + Na + Ta + _a + Ea + "]");
function ot(e) {
return $a.test(e);
}
function Oa(e) {
return e.split("");
}
var Rn = "\\ud800-\\udfff", Ra = "\\u0300-\\u036f", Ia = "\\ufe20-\\ufe2f", Da = "\\u20d0-\\u20ff", Ba = Ra + Ia + Da, Ma = "\\ufe0e\\ufe0f", ka = "[" + Rn + "]", Le = "[" + Ba + "]", ze = "\\ud83c[\\udffb-\\udfff]", La = "(?:" + Le + "|" + ze + ")", In = "[^" + Rn + "]", Dn = "(?:\\ud83c[\\udde6-\\uddff]){2}", Bn = "[\\ud800-\\udbff][\\udc00-\\udfff]", za = "\\u200d", Mn = La + "?", kn = "[" + Ma + "]?", Fa = "(?:" + za + "(?:" + [In, Dn, Bn].join("|") + ")" + kn + Mn + ")*", ja = kn + Mn + Fa, Ha = "(?:" + [In + Le + "?", Le, Dn, Bn, ka].join("|") + ")", Ua = RegExp(ze + "(?=" + ze + ")|" + Ha + ja, "g");
function Ga(e) {
return e.match(Ua) || [];
}
function Wa(e) {
return ot(e) ? Ga(e) : Oa(e);
}
function Va() {
this.__data__ = new V(), this.size = 0;
}
function Ka(e) {
var t = this.__data__, n = t.delete(e);
return this.size = t.size, n;
}
function Xa(e) {
return this.__data__.get(e);
}
function qa(e) {
return this.__data__.has(e);
}
var Ya = 200;
function Ja(e, t) {
var n = this.__data__;
if (n instanceof V) {
var r = n.__data__;
if (!ue || r.length < Ya - 1)
return r.push([e, t]), this.size = ++n.size, this;
n = this.__data__ = new K(r);
}
return n.set(e, t), this.size = n.size, this;
}
function W(e) {
var t = this.__data__ = new V(e);
this.size = t.size;
}
W.prototype.clear = Va;
W.prototype.delete = Ka;
W.prototype.get = Xa;
W.prototype.has = qa;
W.prototype.set = Ja;
function Za(e, t) {
for (var n = -1, r = e == null ? 0 : e.length, i = 0, o = []; ++n < r; ) {
var s = e[n];
t(s, n, e) && (o[i++] = s);
}
return o;
}
function Qa() {
return [];
}
var es = Object.prototype, ts = es.propertyIsEnumerable, jt = Object.getOwnPropertySymbols, ns = jt ? function(e) {
return e == null ? [] : (e = Object(e), Za(jt(e), function(t) {
return ts.call(e, t);
}));
} : Qa;
function rs(e, t, n) {
var r = t(e);
return G(e) ? r : On(r, n(e));
}
function Ht(e) {
return rs(e, En, ns);
}
var Fe = te(J, "DataView"), je = te(J, "Promise"), He = te(J, "Set"), Ut = "[object Map]", is = "[object Object]", Gt = "[object Promise]", Wt = "[object Set]", Vt = "[object WeakMap]", Kt = "[object DataView]", os = ee(Fe), as = ee(ue), ss = ee(je), ls = ee(He), cs = ee(Be), q = oe;
(Fe && q(new Fe(new ArrayBuffer(1))) != Kt || ue && q(new ue()) != Ut || je && q(je.resolve()) != Gt || He && q(new He()) != Wt || Be && q(new Be()) != Vt) && (q = function(e) {
var t = oe(e), n = t == is ? e.constructor : void 0, r = n ? ee(n) : "";
if (r)
switch (r) {
case os:
return Kt;
case as:
return Ut;
case ss:
return Gt;
case ls:
return Wt;
case cs:
return Vt;
}
return t;
});
var Xt = J.Uint8Array, ds = "__lodash_hash_undefined__";
function us(e) {
return this.__data__.set(e, ds), this;
}
function fs(e) {
return this.__data__.has(e);
}
function fe(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.__data__ = new K(); ++t < n; )
this.add(e[t]);
}
fe.prototype.add = fe.prototype.push = us;
fe.prototype.has = fs;
function hs(e, t) {
for (var n = -1, r = e == null ? 0 : e.length; ++n < r; )
if (t(e[n], n, e))
return !0;
return !1;
}
function Ln(e, t) {
return e.has(t);
}
var ms = 1, gs = 2;
function zn(e, t, n, r, i, o) {
var s = n & ms, c = e.length, l = t.length;
if (c != l && !(s && l > c))
return !1;
var d = o.get(e), f = o.get(t);
if (d && f)
return d == t && f == e;
var u = -1, h = !0, m = n & gs ? new fe() : void 0;
for (o.set(e, t), o.set(t, e); ++u < c; ) {
var g = e[u], y = t[u];
if (r)
var x = s ? r(y, g, u, t, e, o) : r(g, y, u, e, t, o);
if (x !== void 0) {
if (x)
continue;
h = !1;
break;
}
if (m) {
if (!hs(t, function(S, _) {
if (!Ln(m, _) && (g === S || i(g, S, n, r, o)))
return m.push(_);
})) {
h = !1;
break;
}
} else if (!(g === y || i(g, y, n, r, o))) {
h = !1;
break;
}
}
return o.delete(e), o.delete(t), h;
}
function ps(e) {
var t = -1, n = Array(e.size);
return e.forEach(function(r, i) {
n[++t] = [i, r];
}), n;
}
function vs(e) {
var t = -1, n = Array(e.size);
return e.forEach(function(r) {
n[++t] = r;
}), n;
}
var ys = 1, ws = 2, xs = "[object Boolean]", bs = "[object Date]", Cs = "[object Error]", Ts = "[object Map]", As = "[object Number]", Ss = "[object RegExp]", Ps = "[object Set]", _s = "[object String]", Es = "[object Symbol]", Ns = "[object ArrayBuffer]", $s = "[object DataView]", qt = re ? re.prototype : void 0, Ie = qt ? qt.valueOf : void 0;
function Os(e, t, n, r, i, o, s) {
switch (n) {
case $s:
if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset)
return !1;
e = e.buffer, t = t.buffer;
case Ns:
return !(e.byteLength != t.byteLength || !o(new Xt(e), new Xt(t)));
case xs:
case bs:
case As:
return Cn(+e, +t);
case Cs:
return e.name == t.name && e.message == t.message;
case Ss:
case _s:
return e == t + "";
case Ts:
var c = ps;
case Ps:
var l = r & ys;
if (c || (c = vs), e.size != t.size && !l)
return !1;
var d = s.get(e);
if (d)
return d == t;
r |= ws, s.set(e, t);
var f = zn(c(e), c(t), r, i, o, s);
return s.delete(e), f;
case Es:
if (Ie)
return Ie.call(e) == Ie.call(t);
}
return !1;
}
var Rs = 1, Is = Object.prototype, Ds = Is.hasOwnProperty;
function Bs(e, t, n, r, i, o) {
var s = n & Rs, c = Ht(e), l = c.length, d = Ht(t), f = d.length;
if (l != f && !s)
return !1;
for (var u = l; u--; ) {
var h = c[u];
if (!(s ? h in t : Ds.call(t, h)))
return !1;
}
var m = o.get(e), g = o.get(t);
if (m && g)
return m == t && g == e;
var y = !0;
o.set(e, t), o.set(t, e);
for (var x = s; ++u < l; ) {
h = c[u];
var S = e[h], _ = t[h];
if (r)
var N = s ? r(_, S, h, t, e, o) : r(S, _, h, e, t, o);
if (!(N === void 0 ? S === _ || i(S, _, n, r, o) : N)) {
y = !1;
break;
}
x || (x = h == "constructor");
}
if (y && !x) {
var b = e.constructor, v = t.constructor;
b != v && "constructor" in e && "constructor" in t && !(typeof b == "function" && b instanceof b && typeof v == "function" && v instanceof v) && (y = !1);
}
return o.delete(e), o.delete(t), y;
}
var Ms = 1, Yt = "[object Arguments]", Jt = "[object Array]", pe = "[object Object]", ks = Object.prototype, Zt = ks.hasOwnProperty;
function Ls(e, t, n, r, i, o) {
var s = G(e), c = G(t), l = s ? Jt : q(e), d = c ? Jt : q(t);
l = l == Yt ? pe : l, d = d == Yt ? pe : d;
var f = l == pe, u = d == pe, h = l == d;
if (h && Me(e)) {
if (!Me(t))
return !1;
s = !0, f = !1;
}
if (h && !f)
return o || (o = new W()), s || _n(e) ? zn(e, t, n, r, i, o) : Os(e, t, l, n, r, i, o);
if (!(n & Ms)) {
var m = f && Zt.call(e, "__wrapped__"), g = u && Zt.call(t, "__wrapped__");
if (m || g) {
var y = m ? e.value() : e, x = g ? t.value() : t;
return o || (o = new W()), i(y, x, n, r, o);
}
}
return h ? (o || (o = new W()), Bs(e, t, n, r, i, o)) : !1;
}
function at(e, t, n, r, i) {
return e === t ? !0 : e == null || t == null || !Z(e) && !Z(t) ? e !== e && t !== t : Ls(e, t, n, r, at, i);
}
var zs = 1, Fs = 2;
function js(e, t, n, r) {
var i = n.length, o = i;
if (e == null)
return !o;
for (e = Object(e); i--; ) {
var s = n[i];
if (s[2] ? s[1] !== e[s[0]] : !(s[0] in e))
return !1;
}
for (; ++i < o; ) {
s = n[i];
var c = s[0], l = e[c], d = s[1];
if (s[2]) {
if (l === void 0 && !(c in e))
return !1;
} else {
var f = new W(), u;
if (!(u === void 0 ? at(d, l, zs | Fs, r, f) : u))
return !1;
}
}
return !0;
}
function Fn(e) {
return e === e && !Ce(e);
}
function Hs(e) {
for (var t = En(e), n = t.length; n--; ) {
var r = t[n], i = e[r];
t[n] = [r, i, Fn(i)];
}
return t;
}
function jn(e, t) {
return function(n) {
return n == null ? !1 : n[e] === t && (t !== void 0 || e in Object(n));
};
}
function Us(e) {
var t = Hs(e);
return t.length == 1 && t[0][2] ? jn(t[0][0], t[0][1]) : function(n) {
return n === e || js(n, e, t);
};
}
function Gs(e, t) {
return e != null && t in Object(e);
}
function Ws(e, t, n) {
t = Nn(t, e);
for (var r = -1, i = t.length, o = !1; ++r < i; ) {
var s = _e(t[r]);
if (!(o = e != null && n(e, s)))
break;
e = e[s];
}
return o || ++r != i ? o : (i = e == null ? 0 : e.length, !!i && et(i) && bn(s, i) && (G(e) || tt(e)));
}
function Vs(e, t) {
return e != null && Ws(e, t, Gs);
}
var Ks = 1, Xs = 2;
function qs(e, t) {
return rt(e) && Fn(t) ? jn(_e(e), t) : function(n) {
var r = ya(n, e);
return r === void 0 && r === t ? Vs(n, e) : at(t, r, Ks | Xs);
};
}
function Hn(e) {
return function(t) {
return t == null ? void 0 : t[e];
};
}
function Ys(e) {
return function(t) {
return $n(t, e);
};
}
function Js(e) {
return rt(e) ? Hn(_e(e)) : Ys(e);
}
function Zs(e) {
return typeof e == "function" ? e : e == null ? Qe : typeof e == "object" ? G(e) ? qs(e[0], e[1]) : Us(e) : Js(e);
}
function De(e) {
return Z(e) && Tn(e);
}
var Qs = 200;
function el(e, t, n, r) {
var i = -1, o = Gi, s = !0, c = e.length, l = [], d = t.length;
if (!c)
return l;
n && (t = wn(t, nt(n))), t.length >= Qs && (o = Ln, s = !1, t = new fe(t));
e:
for (; ++i < c; ) {
var f = e[i], u = n == null ? f : n(f);
if (f = f !== 0 ? f : 0, s && u === u) {
for (var h = d; h--; )
if (t[h] === u)
continue e;
l.push(f);
} else o(t, u, r) || l.push(f);
}
return l;
}
function tl(e) {
var t = e == null ? 0 : e.length;
return t ? e[t - 1] : void 0;
}
var nl = Xi(function(e, t) {
var n = tl(t);
return De(n) && (n = void 0), De(e) ? el(e, xa(t, 1, De), Zs(n)) : [];
}), rl = "[object RegExp]";
function il(e) {
return Z(e) && oe(e) == rl;
}
var Qt = be && be.isRegExp, ol = Qt ? nt(Qt) : il, al = Hn("length"), Un = "\\ud800-\\udfff", sl = "\\u0300-\\u036f", ll = "\\ufe20-\\ufe2f", cl = "\\u20d0-\\u20ff", dl = sl + ll + cl, ul = "\\ufe0e\\ufe0f", fl = "[" + Un + "]", Ue = "[" + dl + "]", Ge = "\\ud83c[\\udffb-\\udfff]", hl = "(?:" + Ue + "|" + Ge + ")", Gn = "[^" + Un + "]", Wn = "(?:\\ud83c[\\udde6-\\uddff]){2}", Vn = "[\\ud800-\\udbff][\\udc00-\\udfff]", ml = "\\u200d", Kn = hl + "?", Xn = "[" + ul + "]?", gl = "(?:" + ml + "(?:" + [Gn, Wn, Vn].join("|") + ")" + Xn + Kn + ")*", pl = Xn + Kn + gl, vl = "(?:" + [Gn + Ue + "?", Ue, Wn, Vn, fl].join("|") + ")", en = RegExp(Ge + "(?=" + Ge + ")|" + vl + pl, "g");
function yl(e) {
for (var t = en.lastIndex = 0; en.test(e); )
++t;
return t;
}
function wl(e) {
return ot(e) ? yl(e) : al(e);
}
var xl = 30, bl = "...", Cl = /\w*$/;
function Tl(e, t) {
var n = xl, r = bl;
if (Ce(t)) {
var i = "separator" in t ? t.separator : i;
n = "length" in t ? gi(t.length) : n, r = "omission" in t ? xe(t.omission) : r;
}
e = ke(e);
var o = e.length;
if (ot(e)) {
var s = Wa(e);
o = s.length;
}
if (n >= o)
return e;
var c = n - wl(r);
if (c < 1)
return r;
var l = s ? Ca(s, 0, c).join("") : e.slice(0, c);
if (i === void 0)
return l + r;
if (s && (c += l.length - c), ol(i)) {
if (e.slice(c).search(i)) {
var d, f = l;
for (i.global || (i = RegExp(i.source, ke(Cl.exec(i)) + "g")), i.lastIndex = 0; d = i.exec(f); )
var u = d.index;
l = l.slice(0, u === void 0 ? c : u);
}
} else if (e.indexOf(xe(i), c) != c) {
var h = l.lastIndexOf(i);
h > -1 && (l = l.slice(0, h));
}
return l + r;
}
const Al = F.Provider, qn = ie.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ a(
F.Viewport,
{
ref: n,
className: ae(
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
e
),
...t
}
));
qn.displayName = F.Viewport.displayName;
const Sl = wr(
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md !border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
{
variants: {
variant: {
default: "border bg-background text-foreground",
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
}
},
defaultVariants: {
variant: "default"
}
}
), Yn = ie.forwardRef(({ className: e, variant: t, ...n }, r) => /* @__PURE__ */ a(
F.Root,
{
ref: r,
className: ae(Sl({ variant: t }), e),
...n
}
));
Yn.displayName = F.Root.displayName;
const Pl = ie.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ a(
F.Action,
{
ref: n,
className: ae(
"inline-flex h-8 shrink-0 items-center justify-center rounded-md !border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
e
),
...t
}
));
Pl.displayName = F.Action.displayName;
const Jn = ie.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ a(
F.Close,
{
ref: n,
className: ae(
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
e
),
"toast-close": "",
...t,
children: /* @__PURE__ */ a(ri, { className: "h-4 w-4" })
}
));
Jn.displayName = F.Close.displayName;
const Zn = ie.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ a(
F.Title,
{
ref: n,
className: ae("text-sm font-semibold", e),
...t
}
));
Zn.displayName = F.Title.displayName;
const Qn = ie.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ a(
F.Description,
{
ref: n,
className: ae("text-sm opacity-90", e),
...t
}
));
Qn.displayName = F.Description.displayName;
let le = !1;
function _l({ editor: e, attrs: t, extension: n }) {
const [r, i] = I(!1), o = ne(null), s = ne(null), { alt: c, align: l } = t, d = n == null ? void 0 : n.options.upload, f = () => {
(async () => {
const w = document.querySelector("#easydrawer");
w && (o.current = new si(w, {
wheelEventsEnabled: !1,
disableZoom: !0
}), s.current = li(o.current), s.current.addDefaultToolWidgets(), o.current.loadFromSVG(decodeURIComponent(c)));
})();
};
R(() => {
r && setTimeout(() => {
f();
}, 200);
}, [r]);
const u = async () => {
if (o.current) {
const T = o.current.toSVG(), w = T.outerHTML, P = `drawer-${cn()}.svg`;
let M = dn(T.outerHTML);
if (d) {
const k = un(M, P);
M = await d(k);
}
e == null || e.chain().focus().setDrawer(
{
type: "drawer",
src: M,
alt: encodeURIComponent(w),
width: 426,
height: 212
},
!!w
).run(), e == null || e.commands.setAlignImageDrawer(l);
}
i(!1);
}, h = (T) => {
const w = o.current.toolController.getPrimaryTools()[2], P = s.current.getWidgetById("pen-1");
w && P && (w.setColor(T), P.serializeState());
}, m = (T) => {
const w = o.current.toolController.getPrimaryTools()[2], P = s.current.getWidgetById("pen-1");
w && P && (w.setThickness(T), P.serializeState());
}, g = (T) => {
const w = o.current.toolController.getPrimaryTools()[3], P = s.current.getWidgetById("pen-2");
w && P && (w.setColor(T), P.serializeState());
}, y = (T) => {
const w = s.current.getWidgetById("shape");
w && w.setShapeType(T);
}, x = (T) => {
const w = o.current.toolController.getPrimaryTools()[5], P = s.current.getWidgetById("shape");
w && P && (w.setColor(T), P.serializeState());
}, S = (T) => {
const w = o.current.toolController.getPrimaryTools()[5], P = s.current.getWidgetById("shape");
w && P && (w.setThickness(T), P.serializeState());
}, _ = (T) => {
const w = o.current.toolController.getPrimaryTools()[5], P = s.current.getWidgetById("shape");
w && P && (w.setBorderColor(T), P.serializeState());
}, N = () => {
if (le) {
for (; o.current.history.redoStackSize > 0; )
o.current.history.redo();
le = !1;
return;
}
o.current.history.undo();
};
return /* @__PURE__ */ p(
Xe,
{
onOpenChange: i,
open: r,
children: [
/* @__PURE__ */ a(qe, { asChild: !0, children: /* @__PURE__ */ a(
C,
{
action: () => i(!0),
icon: "Pencil",
tooltip: "Edit Drawer"
}
) }),
/* @__PURE__ */ p(Ye, { className: "z-[99999] !max-w-[1300px]", children: [
/* @__PURE__ */ a(Je, { children: "Edit Drawer" }),
/* @__PURE__ */ p("div", { style: { height: "100%", borderWidth: 1, background: "white", position: "relative" }, children: [
/* @__PURE__ */ a(
"div",
{
className: "size-full",
id: "easydrawer"
}
),
/* @__PURE__ */ a(
xr,
{
changeBorderColorShape: _,
changeColorShape: x,
changeShape: y,
onClear: () => {
if (!le) {
for (; o.current.history.undoStackSize > 0; )
N();
le = !0;
}
},
onRedo: () => {
le || o.current.history.redo();
},
onThicknessChange: S,
onUndo: N,
refEditor: o,
setColorHighlight: g,
setColorPen: h,
setThicknessPen: m
}
)
] }),
/* @__PURE__ */ a(Ze, { children: /* @__PURE__ */ a(
Y,
{
onClick: u,
type: "button",
children: "Save changes"
}
) })
] })
]
}
);
}
function er(e, t) {
const [n, r] = I(void 0);
return R(() => {
const i = () => {
const o = e.extensionManager.extensions.find((s) => s.name === t);
o && r(o);
};
return e.on("selectionUpdate", i), e.on("transaction", i), () => {
e.off("selectionUpdate", i), e.off("transaction", i);
};
}, [e, t]), n;
}
const El = {
maxWidth: "auto",
zIndex: 20,
appendTo: "parent",
moveTransition: "transform 0.1s ease-out"
};
function Nl({ item: e, disabled: t, editor: n }) {
var i;
const r = e.component;
return r ? /* @__PURE__ */ a(Ve, { children: e.type === "divider" ? /* @__PURE__ */ a(
U,
{
className: "!mx-1 !my-2 !h-[16px]",
orientation: "vertical"
}
) : /* @__PURE__ */ a(
r,
{
...e.componentProps,
disabled: t || ((i = e == null ? void 0 : e.componentProps) == null ? void 0 : i.disabled),
editor: n
}
) }) : /* @__PURE__ */ a(E, {});
}
function $l(e) {
return e.type.name === "drawer";
}
function Ol(e) {
const { lang: t } = D(), n = Te(e.editor, vt.name), r = er(e.editor, vt.name), i = ({ editor: s }) => {
const { selection: c } = s.view.state, { $from: l, to: d } = c;
let f = !1;
return s.view.state.doc.nodesBetween(l.pos, d, (u) => {
if ($l(u))
return f = !0, !1;
}), f;
}, o = z(() => e.disabled ? [] : ec(e.editor), [e.disabled, e.editor, t]);
return /* @__PURE__ */ a(E, { children: /* @__PURE__ */ a(
L,
{
editor: e == null ? void 0 : e.editor,
shouldShow: i,
tippyOptions: El,
children: o != null && o.length ? /* @__PURE__ */ a("div", { className: "pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800", children: /* @__PURE__ */ a("div", { className: "relative flex h-[26px] flex-nowrap items-center justify-start whitespace-nowrap", children: o == null ? void 0 : o.map((s, c) => s.type === "edit" && (n != null && n.src) ? /* @__PURE__ */ a(
_l,
{
attrs: n,
editor: e.editor,
extension: r
},
`bubbleMenu-drawer-${c}`
) : /* @__PURE__ */ a(
Nl,
{
disabled: e.disabled,
editor: e.editor,
item: s
},
`bubbleMenu-drawer-${c}`
)) }) }) : /* @__PURE__ */ a(E, {})
}
) });
}
const Rl = { padding: "0 12px 12px" }, Il = ({ width: e, maxWidth: t, height: n, onOk: r, children: i }) => {
const { t: o } = D(), [s, c] = I({
width: "",
height: "",
maxWidth: ""
});
R(() => {
c({
width: e,
height: n,
maxWidth: t
});
}, [n, t, e]);
function l(d) {
d.preventDefault(), d.stopPropagation(), r(s);
}
return /* @__PURE__ */ p(br, { modal: !0, children: [
/* @__PURE__ */ a(Cr, { asChild: !0, children: i }),
/* @__PURE__ */ a(Tr, { children: /* @__PURE__ */ a("div", { style: Rl, children: /* @__PURE__ */ p("form", { className: "flex flex-col gap-2", onSubmit: l, children: [
/* @__PURE__ */ a($e, { className: "mb-[6px]", children: "Width" }),
/* @__PURE__ */ a("div", { className: "flex w-full max-w-sm items-center gap-1.5", children: /* @__PURE__ */ a("div", { className: "relative items-center w-full max-w-sm", children: /* @__PURE__ */ a(
ye,
{
type: "number",
value: s.width,
required: !0,
onChange: (d) => c({ ...s, width: d.target.value })
}
) }) }),
/* @__PURE__ */ a($e, { className: "mb-[6px]", children: "Max Width" }),
/* @__PURE__ */ a("div", { className: "flex w-full max-w-sm items-center gap-1.5", children: /* @__PURE__ */ a("div", { className: "relative items-center w-full max-w-sm", children: /* @__PURE__ */ a(
ye,
{
type: "number",
value: s.maxWidth,
required: !0,
onChange: (d) => c({ ...s, maxWidth: d.target.value })
}
) }) }),
/* @__PURE__ */ a($e, { className: "mb-[6px]", children: "Height" }),
/* @__PURE__ */ a("div", { className: "flex w-full max-w-sm items-center gap-1.5", children: /* @__PURE__ */ a("div", { className: "relative items-center w-full max-w-sm", children: /* @__PURE__ */ a(
ye,
{
type: "number",
value: s.height,
required: !0,
onChange: (d) => c({ ...s, height: d.target.value })
}
) }) }),
/* @__PURE__ */ a(Y, { type: "submit", className: "self-end mt-2", children: o("editor.link.dialog.button.apply") })
] }) }) })
] });
};
function Dl({ editor: e }) {
const { t } = D(), { width: n, height: r, url: i } = Te(e, se.name, {
width: 0,
height: 0,
url: "",
defaultShowPicker: !1
}), [o, s] = I(!1), [c, l] = I(""), d = O(() => {
s(!1);
}, [s]);
R(() => {
o && l(i);
}, [o, i]);
const f = O(() => {
e.chain().updateAttributes(se.name, {
url: c
}).setNodeSelection(e.state.selection.from).focus().run(), s(!1);
}, [e, c, s]), u = O(() => {
window.open(i, "_blank");
}, [i]), h = O(() => {
s(!0);
}, [s]), m = O(
(x) => {
e.chain().updateAttributes(se.name, x).setNodeSelection(e.state.selection.from).focus().run();
},
[e]
), g = O(() => e.isActive(se.name) && !i, [e, i]), y = O(() => Ae(se.name, e), [e]);
return /* @__PURE__ */ p(E, { children: [
/* @__PURE__ */ a(
L,
{
className: "bubble-menu",
editor: e,
pluginKey: "iframe-bubble-menu",
shouldShow: g,
tippyOptions: {
popperOptions: {
modifiers: [{ name: "flip", enabled: !1 }]
},
placement: "bottom-start",
offset: [-2, 16],
zIndex: 9999
// onHidden: () => {
// toggleVisible(false)
// },
},
children: /* @__PURE__ */ p("div", { className: "w-auto px-3 py-2 transition-all !border rounded-sm shadow-sm pointer-events-auto select-none border-neutral-200 dark:border-neutral-800 bg-background", children: [
/* @__PURE__ */ a(
C,
{
action: u,
icon: "Eye",
tooltip: "Visit Link"
}
),
/* @__PURE__ */ a(
C,
{
action: h,
icon: "Pencil",
tooltip: "Open Edit Link"
}
),
/* @__PURE__ */ a(Il, { width: n, height: r, onOk: m, children: /* @__PURE__ */ a(
C,
{
icon: "Settings",
tooltip: t("editor.settings")
}
) }),
/* @__PURE__ */ a(
C,
{
action: y,
icon: "Trash2",
tooltip: t("editor.delete")
}
)
] })
}
),
/* @__PURE__ */ p(
Xe,
{
open: o,
onOpenChange: s,
children: [
/* @__PURE__ */ a(qe, {}),
/* @__PURE__ */ p(Ye, { children: [
/* @__PURE__ */ a(Ar, { children: /* @__PURE__ */ a(Je, { children: "Edit Link Iframe" }) }),
/* @__PURE__ */ a(
ye,
{
value: c,
onInput: (x) => l(x.target.value),
type: "url",
autoFocus: !0,
placeholder: "Enter link"
}
),
/* @__PURE__ */ p(Ze, { children: [
/* @__PURE__ */ a(Y, { onClick: d, children: "Cancel" }),
/* @__PURE__ */ a(Y, { onClick: f, children: "OK" })
] })
] })
]
}
)
] });
}
function Bl({ editor: e, ...t }) {
const n = Te(e, ge.name, {
text: "",
defaultShowPicker: !1
}), { text: r, defaultShowPicker: i } = n, [o, s] = I(""), [c, l] = I(!1), d = O(() => e.isActive(ge.name), [e]), f = O(() => Ae(ge.name, e), [e]), u = O(() => {
e.chain().focus().setKatex({ text: o }).run(), l(!1);
}, [e, o]);
R(() => {
i && (l(!0), e.chain().updateAttributes(ge.name, { defaultShowPicker: !1 }).focus().run());
}, [e, i, l]), R(() => {
c && s(r || "");
}, [c]);
const h = z(() => {
try {
return ci.renderToString(`${o}`);
} catch {
return o;
}
}, [o]), m = z(
() => `${o}`.trim() ? /* @__PURE__ */ a("span", { contentEditable: !1, dangerouslySetInnerHTML: { __html: h || "" } }) : null,
[o, h]
);
return /* @__PURE__ */ a(
L,
{
editor: e,
pluginKey: "Katex-bubble-menu",
shouldShow: d,
tippyOptions: {
popperOptions: {
modifiers: [{ name: "flip", enabled: !1 }]
},
placement: "bottom-start",
offset: [-2, 16],
zIndex: 9999,
onHidden: () => {
l(!1);
}
},
children: t != null && t.disabled ? /* @__PURE__ */ a(E, {}) : /* @__PURE__ */ a("div", { className: "p-2 bg-white !border rounded-lg shadow-sm dark:bg-black border-neutral-200 dark:border-neutral-800", children: c ? /* @__PURE__ */ p(E, { children: [
/* @__PURE__ */ a(
fn,
{
value: o,
onChange: (g) => s(g.target.value),
autoFocus: !0,
placeholder: "Formula text",
rows: 3,
defaultValue: r,
style: { marginBottom: 8 }
}
),
m && /* @__PURE__ */ a("div", { className: "my-[10px] p-[10px] rounded-[6px] !border-[1px] whitespace-nowrap overflow-auto", children: m }),
/* @__PURE__ */ p("div", { className: "flex items-center justify-between gap-[6px]", children: [
/* @__PURE__ */ a(Y, { onClick: u, className: "flex-1", children: "Submit" }),
/* @__PURE__ */ a("a", { href: "https://katex.org/docs/supported", target: "_blank", rel: "noreferrer noopener", children: /* @__PURE__ */ a(ii, { size: 16 }) })
] })
] }) : /* @__PURE__ */ p("div", { className: "flex items-center justify-center gap-[6px]", children: [
/* @__PURE__ */ a(C, { tooltip: "Edit", action: () => l(!c), children: /* @__PURE__ */ a(oi, { size: 16 }) }),
/* @__PURE__ */ a(C, { tooltip: "Delete", action: f, children: /* @__PURE__ */ a(ai, { size: 16 }) })
] }) })
}
);
}
const tn = `graph TB
a-->b`, Ml = ({ editor: e, attrs: t, extension: n }) => {
const { alt: r, align: i } = t, [o, s] = I(decodeURIComponent(r ?? tn)), [c, l] = I(""), [d, f] = I(!1), u = ne(null), h = n == null ? void 0 : n.options.upload, m = async (x) => {
try {
const { svg: S } = await $t.render("mermaid-svg", x);
l(S);
} catch {
l("");
}
}, g = () => {
$t.initialize({
darkMode: !1,
startOnLoad: !1,
// fontFamily:'',
fontSize: 12,
theme: "base"
}), m(o);
};
return R(() => {
d && g();
}, [d]), R(() => {
d && m(o);
}, [o]), /* @__PURE__ */ p(
Xe,
{
onOpenChange: f,
open: d,
children: [
/* @__PURE__ */ a(qe, { asChild: !0, children: /* @__PURE__ */ a(
C,
{
action: () => f(!0),
icon: "Pencil",
tooltip: "Edit Mermaid"
}
) }),
/* @__PURE__ */ p(Ye, { className: "z-[99999] !max-w-[1300px]", children: [
/* @__PURE__ */ a(Je, { children: "Edit Mermaid" }),
/* @__PURE__ */ a("div", { style: { height: "100%", border: "1px solid hsl(var(--border))" }, children: /* @__PURE__ */ p("div", { className: "flex gap-[10px] rounded-[10px] p-[10px]", children: [
/* @__PURE__ */ a(
fn,
{
autoFocus: !0,
className: "flex-1",
defaultValue: tn,
onChange: (x) => s(x.target.value),
placeholder: "Text",
required: !0,
rows: 10,
value: o,
style: {
color: "hsl(var(--foreground))"
}
}
),
/* @__PURE__ */ a(
"div",
{
className: "flex flex-1 items-center justify-center rounded-[10px] p-[10px]",
dangerouslySetInnerHTML: { __html: c },
ref: u,
style: { height: "100%", border: "1px solid hsl(var(--border))", minHeight: 500, background: "#fff" }
}
)
] }) }),
/* @__PURE__ */ a(Ze, { children: /* @__PURE__ */ a(
Y,
{
onClick: async () => {
if (o !== "") {
if (o) {
const x = u.current.querySelector("svg"), { width: S, height: _ } = x.getBoundingClientRect(), N = `mermaid-${cn()}.svg`;
let b = dn(x.outerHTML);
if (h) {
const v = un(b, N);
b = await h(v);
}
e == null || e.chain().focus().setMermaid(
{
type: "mermaid",
src: b,
alt: encodeURIComponent(o),
width: S,
height: _
},
!!o
).run(), e == null || e.commands.setAlignImageMermaid(i);
}
f(!1);
}
},
type: "button",
children: "Save changes"
}
) })
] })
]
}
);
}, kl = {
maxWidth: "auto",
zIndex: 20,
appendTo: "parent",
moveTransition: "transform 0.1s ease-out"
};
function Ll({ item: e, disabled: t, editor: n }) {
var i;
const r = e.component;
return r ? /* @__PURE__ */ a(Ve, { children: e.type === "divider" ? /* @__PURE__ */ a(
U,
{
className: "!mx-1 !my-2 !h-[16px]",
orientation: "vertical"
}
) : /* @__PURE__ */ a(
r,
{
...e.componentProps,
disabled: t || ((i = e == null ? void 0 : e.componentProps) == null ? void 0 : i.disabled),
editor: n
}
) }) : /* @__PURE__ */ a(E, {});
}
function zl(e) {
return e.type.name === "mermaid";
}
function Fl(e) {
const { lang: t } = D(), n = Te(e.editor, yt.name), r = er(e.editor, yt.name), i = ({ editor: s }) => {
const { selection: c } = s.view.state, { $from: l, to: d } = c;
let f = !1;
return s.view.state.doc.nodesBetween(l.pos, d, (u) => {
if (zl(u))
return f = !0, !1;
}), f;
}, o = z(() => e.disabled ? [] : Ql(e.editor), [e.disabled, e.editor, t]);
return /* @__PURE__ */ a(E, { children: /* @__PURE__ */ a(
L,
{
editor: e == null ? void 0 : e.editor,
shouldShow: i,
tippyOptions: kl,
children: o != null && o.length ? /* @__PURE__ */ a("div", { className: "pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800", children: /* @__PURE__ */ a("div", { className: "relative flex h-[26px] flex-nowrap items-center justify-start whitespace-nowrap", children: o == null ? void 0 : o.map((s, c) => s.type === "edit" && (n != null && n.src) ? /* @__PURE__ */ a(
Ml,
{
attrs: n,
editor: e.editor,
extension: r
},
`bubbleMenu-mermaid-${c}`
) : /* @__PURE__ */ a(
Ll,
{
disabled: e.disabled,
editor: e.editor,
item: s
},
`bubbleMenu-mermaid-${c}`
)) }) }) : /* @__PURE__ */ a(E, {})
}
) });
}
function jl({ editor: e, disabled: t }) {
const [n, r] = I(!1), { t: i } = D(), o = O(({ editor: l