@dialpad/dialtone-vue
Version:
Vue component library for Dialpad's design system Dialtone
1,431 lines • 91.8 kB
JavaScript
import { getPhoneNumberRegex as e, linkRegex as t, returnFirstEl as n, warnIfUnmounted as r } from "./common/utils/index.js";
import { t as i } from "./_plugin-vue_export-helper-BTgDAbhb.js";
import { codeToEmojiData as a, emojiRegex as o, emojiShortCodeRegex as s, getEmojiData as c, stringToUnicode as l } from "./common/emoji/index.js";
import u from "./lib/avatar/avatar.js";
import d from "./lib/badge/badge.js";
import f from "./lib/link/link.js";
import { DialtoneLocalization as p } from "./localization/index.js";
import m from "./lib/button/button.js";
import h from "./lib/list-item/list-item.js";
import g from "./lib/stack/stack.js";
import _ from "./lib/popover/popover.js";
import v from "./lib/emoji/emoji.js";
import y from "./lib/input/input.js";
import { Editor as b, EditorContent as x, NodeViewWrapper as S, VueNodeViewRenderer as C, VueRenderer as w, nodeViewProps as T } from "./node_modules/@tiptap/vue-3.js";
import { RICH_TEXT_EDITOR_AUTOFOCUS_TYPES as ee, RICH_TEXT_EDITOR_OUTPUT_FORMATS as te, RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS as ne } from "./lib/rich-text-editor/rich-text-editor-constants.js";
import { t as re } from "./markdownRenderer-vnndXQhE.js";
import { Fragment as E, createBlock as D, createCommentVNode as O, createElementBlock as k, createElementVNode as A, createTextVNode as ie, createVNode as j, defineComponent as ae, h as oe, markRaw as se, mergeProps as ce, nextTick as le, normalizeClass as ue, onBeforeUnmount as de, onMounted as fe, openBlock as M, ref as pe, renderList as me, resolveComponent as N, resolveDynamicComponent as he, toDisplayString as P, vShow as ge, withCtx as F, withDirectives as _e, withKeys as ve, withModifiers as ye } from "vue";
import { emojiPattern as be } from "regex-combined-emojis";
import { DtIconLock as xe } from "@dialpad/dialtone-icons/vue3";
import { Extension as Se, InputRule as Ce, Mark as we, Node as Te, combineTransactionSteps as Ee, findChildrenInRange as De, getChangedRanges as Oe, getMarkRange as ke, getMarksBetween as Ae, getText as je, getTextSerializersFromSchema as Me, isTextSelection as Ne, mergeAttributes as I, nodeInputRule as Pe, nodePasteRule as Fe, posToDOMRect as Ie } from "@tiptap/core";
import { NodeSelection as Le, Plugin as Re, PluginKey as L } from "@tiptap/pm/state";
import { CellSelection as ze } from "@tiptap/pm/tables";
import Be from "@tiptap/extension-blockquote";
import Ve from "@tiptap/extension-code-block";
import He from "@tiptap/extension-code";
import Ue from "@tiptap/extension-document";
import { Gapcursor as We, Placeholder as Ge, UndoRedo as Ke } from "@tiptap/extensions";
import qe from "@tiptap/extension-hard-break";
import Je from "@tiptap/extension-paragraph";
import Ye from "@tiptap/extension-bold";
import { BulletList as Xe, ListItem as Ze, OrderedList as Qe } from "@tiptap/extension-list";
import $e from "@tiptap/extension-italic";
import et from "@tiptap/extension-link";
import tt from "@tiptap/extension-strike";
import nt from "@tiptap/extension-underline";
import rt from "@tiptap/extension-text";
import it from "@tiptap/extension-text-align";
import { Table as at, TableCell as ot, TableHeader as st, TableRow as ct } from "@tiptap/extension-table";
import { TextStyle as lt, TextStyleKit as ut } from "@tiptap/extension-text-style";
import dt from "@tiptap/suggestion";
import ft from "@tiptap/extension-image";
import pt from "@tiptap/extension-mention";
import mt from "@dialpad/dialtone-icons/vue3/hash";
import ht from "@dialpad/dialtone-icons/vue3/lock";
import gt from "deep-equal";
//#region ../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
var _t = [
"top",
"right",
"bottom",
"left"
], vt = ["start", "end"], yt = /* @__PURE__ */ _t.reduce((e, t) => e.concat(t, t + "-" + vt[0], t + "-" + vt[1]), []), R = Math.min, z = Math.max, bt = Math.round, B = (e) => ({
x: e,
y: e
}), xt = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function St(e, t, n) {
return z(e, R(t, n));
}
function V(e, t) {
return typeof e == "function" ? e(t) : e;
}
function H(e) {
return e.split("-")[0];
}
function U(e) {
return e.split("-")[1];
}
function Ct(e) {
return e === "x" ? "y" : "x";
}
function wt(e) {
return e === "y" ? "height" : "width";
}
function W(e) {
let t = e[0];
return t === "t" || t === "b" ? "y" : "x";
}
function Tt(e) {
return Ct(W(e));
}
function Et(e, t, n) {
n === void 0 && (n = !1);
let r = U(e), i = Tt(e), a = wt(i), o = i === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
return t.reference[a] > t.floating[a] && (o = Ft(o)), [o, Ft(o)];
}
function Dt(e) {
let t = Ft(e);
return [
Ot(e),
t,
Ot(t)
];
}
function Ot(e) {
return e.includes("start") ? e.replace("start", "end") : e.replace("end", "start");
}
var kt = ["left", "right"], At = ["right", "left"], jt = ["top", "bottom"], Mt = ["bottom", "top"];
function Nt(e, t, n) {
switch (e) {
case "top":
case "bottom": return n ? t ? At : kt : t ? kt : At;
case "left":
case "right": return t ? jt : Mt;
default: return [];
}
}
function Pt(e, t, n, r) {
let i = U(e), a = Nt(H(e), n === "start", r);
return i && (a = a.map((e) => e + "-" + i), t && (a = a.concat(a.map(Ot)))), a;
}
function Ft(e) {
let t = H(e);
return xt[t] + e.slice(t.length);
}
function It(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function Lt(e) {
return typeof e == "number" ? {
top: e,
right: e,
bottom: e,
left: e
} : It(e);
}
function G(e) {
let { x: t, y: n, width: r, height: i } = e;
return {
width: r,
height: i,
top: n,
left: t,
right: t + r,
bottom: n + i,
x: t,
y: n
};
}
//#endregion
//#region ../../node_modules/.pnpm/@floating-ui+core@1.7.5/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
function Rt(e, t, n) {
let { reference: r, floating: i } = e, a = W(t), o = Tt(t), s = wt(o), c = H(t), l = a === "y", u = r.x + r.width / 2 - i.width / 2, d = r.y + r.height / 2 - i.height / 2, f = r[s] / 2 - i[s] / 2, p;
switch (c) {
case "top":
p = {
x: u,
y: r.y - i.height
};
break;
case "bottom":
p = {
x: u,
y: r.y + r.height
};
break;
case "right":
p = {
x: r.x + r.width,
y: d
};
break;
case "left":
p = {
x: r.x - i.width,
y: d
};
break;
default: p = {
x: r.x,
y: r.y
};
}
switch (U(t)) {
case "start":
p[o] -= f * (n && l ? -1 : 1);
break;
case "end":
p[o] += f * (n && l ? -1 : 1);
break;
}
return p;
}
async function zt(e, t) {
t === void 0 && (t = {});
let { x: n, y: r, platform: i, rects: a, elements: o, strategy: s } = e, { boundary: c = "clippingAncestors", rootBoundary: l = "viewport", elementContext: u = "floating", altBoundary: d = !1, padding: f = 0 } = V(t, e), p = Lt(f), m = o[d ? u === "floating" ? "reference" : "floating" : u], h = G(await i.getClippingRect({
element: await (i.isElement == null ? void 0 : i.isElement(m)) ?? !0 ? m : m.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(o.floating)),
boundary: c,
rootBoundary: l,
strategy: s
})), g = u === "floating" ? {
x: n,
y: r,
width: a.floating.width,
height: a.floating.height
} : a.reference, _ = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(o.floating)), v = await (i.isElement == null ? void 0 : i.isElement(_)) && await (i.getScale == null ? void 0 : i.getScale(_)) || {
x: 1,
y: 1
}, y = G(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: o,
rect: g,
offsetParent: _,
strategy: s
}) : g);
return {
top: (h.top - y.top + p.top) / v.y,
bottom: (y.bottom - h.bottom + p.bottom) / v.y,
left: (h.left - y.left + p.left) / v.x,
right: (y.right - h.right + p.right) / v.x
};
}
var Bt = 50, Vt = async (e, t, n) => {
let { placement: r = "bottom", strategy: i = "absolute", middleware: a = [], platform: o } = n, s = o.detectOverflow ? o : {
...o,
detectOverflow: zt
}, c = await (o.isRTL == null ? void 0 : o.isRTL(t)), l = await o.getElementRects({
reference: e,
floating: t,
strategy: i
}), { x: u, y: d } = Rt(l, r, c), f = r, p = 0, m = {};
for (let n = 0; n < a.length; n++) {
let h = a[n];
if (!h) continue;
let { name: g, fn: _ } = h, { x: v, y, data: b, reset: x } = await _({
x: u,
y: d,
initialPlacement: r,
placement: f,
strategy: i,
middlewareData: m,
rects: l,
platform: s,
elements: {
reference: e,
floating: t
}
});
u = v ?? u, d = y ?? d, m[g] = {
...m[g],
...b
}, x && p < Bt && (p++, typeof x == "object" && (x.placement && (f = x.placement), x.rects && (l = x.rects === !0 ? await o.getElementRects({
reference: e,
floating: t,
strategy: i
}) : x.rects), {x: u, y: d} = Rt(l, f, c)), n = -1);
}
return {
x: u,
y: d,
placement: f,
strategy: i,
middlewareData: m
};
}, Ht = (e) => ({
name: "arrow",
options: e,
async fn(t) {
let { x: n, y: r, placement: i, rects: a, platform: o, elements: s, middlewareData: c } = t, { element: l, padding: u = 0 } = V(e, t) || {};
if (l == null) return {};
let d = Lt(u), f = {
x: n,
y: r
}, p = Tt(i), m = wt(p), h = await o.getDimensions(l), g = p === "y", _ = g ? "top" : "left", v = g ? "bottom" : "right", y = g ? "clientHeight" : "clientWidth", b = a.reference[m] + a.reference[p] - f[p] - a.floating[m], x = f[p] - a.reference[p], S = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(l)), C = S ? S[y] : 0;
(!C || !await (o.isElement == null ? void 0 : o.isElement(S))) && (C = s.floating[y] || a.floating[m]);
let w = b / 2 - x / 2, T = C / 2 - h[m] / 2 - 1, ee = R(d[_], T), te = R(d[v], T), ne = ee, re = C - h[m] - te, E = C / 2 - h[m] / 2 + w, D = St(ne, E, re), O = !c.arrow && U(i) != null && E !== D && a.reference[m] / 2 - (E < ne ? ee : te) - h[m] / 2 < 0, k = O ? E < ne ? E - ne : E - re : 0;
return {
[p]: f[p] + k,
data: {
[p]: D,
centerOffset: E - D - k,
...O && { alignmentOffset: k }
},
reset: O
};
}
});
function Ut(e, t, n) {
return (e ? [...n.filter((t) => U(t) === e), ...n.filter((t) => U(t) !== e)] : n.filter((e) => H(e) === e)).filter((n) => e ? U(n) === e || (t ? Ot(n) !== n : !1) : !0);
}
var Wt = function(e) {
return e === void 0 && (e = {}), {
name: "autoPlacement",
options: e,
async fn(t) {
let { rects: n, middlewareData: r, placement: i, platform: a, elements: o } = t, { crossAxis: s = !1, alignment: c, allowedPlacements: l = yt, autoAlignment: u = !0, ...d } = V(e, t), f = c !== void 0 || l === yt ? Ut(c || null, u, l) : l, p = await a.detectOverflow(t, d), m = r.autoPlacement?.index || 0, h = f[m];
if (h == null) return {};
let g = Et(h, n, await (a.isRTL == null ? void 0 : a.isRTL(o.floating)));
if (i !== h) return { reset: { placement: f[0] } };
let _ = [
p[H(h)],
p[g[0]],
p[g[1]]
], v = [...r.autoPlacement?.overflows || [], {
placement: h,
overflows: _
}], y = f[m + 1];
if (y) return {
data: {
index: m + 1,
overflows: v
},
reset: { placement: y }
};
let b = v.map((e) => {
let t = U(e.placement);
return [
e.placement,
t && s ? e.overflows.slice(0, 2).reduce((e, t) => e + t, 0) : e.overflows[0],
e.overflows
];
}).sort((e, t) => e[1] - t[1]), x = b.filter((e) => e[2].slice(0, U(e[0]) ? 2 : 3).every((e) => e <= 0))[0]?.[0] || b[0][0];
return x === i ? {} : {
data: {
index: m + 1,
overflows: v
},
reset: { placement: x }
};
}
};
}, Gt = function(e) {
return e === void 0 && (e = {}), {
name: "flip",
options: e,
async fn(t) {
var n;
let { placement: r, middlewareData: i, rects: a, initialPlacement: o, platform: s, elements: c } = t, { mainAxis: l = !0, crossAxis: u = !0, fallbackPlacements: d, fallbackStrategy: f = "bestFit", fallbackAxisSideDirection: p = "none", flipAlignment: m = !0, ...h } = V(e, t);
if ((n = i.arrow) != null && n.alignmentOffset) return {};
let g = H(r), _ = W(o), v = H(o) === o, y = await (s.isRTL == null ? void 0 : s.isRTL(c.floating)), b = d || (v || !m ? [Ft(o)] : Dt(o)), x = p !== "none";
!d && x && b.push(...Pt(o, m, p, y));
let S = [o, ...b], C = await s.detectOverflow(t, h), w = [], T = i.flip?.overflows || [];
if (l && w.push(C[g]), u) {
let e = Et(r, a, y);
w.push(C[e[0]], C[e[1]]);
}
if (T = [...T, {
placement: r,
overflows: w
}], !w.every((e) => e <= 0)) {
let e = (i.flip?.index || 0) + 1, t = S[e];
if (t && (!(u === "alignment" && _ !== W(t)) || T.every((e) => W(e.placement) === _ ? e.overflows[0] > 0 : !0))) return {
data: {
index: e,
overflows: T
},
reset: { placement: t }
};
let n = T.filter((e) => e.overflows[0] <= 0).sort((e, t) => e.overflows[1] - t.overflows[1])[0]?.placement;
if (!n) switch (f) {
case "bestFit": {
let e = T.filter((e) => {
if (x) {
let t = W(e.placement);
return t === _ || t === "y";
}
return !0;
}).map((e) => [e.placement, e.overflows.filter((e) => e > 0).reduce((e, t) => e + t, 0)]).sort((e, t) => e[1] - t[1])[0]?.[0];
e && (n = e);
break;
}
case "initialPlacement":
n = o;
break;
}
if (r !== n) return { reset: { placement: n } };
}
return {};
}
};
};
function Kt(e, t) {
return {
top: e.top - t.height,
right: e.right - t.width,
bottom: e.bottom - t.height,
left: e.left - t.width
};
}
function qt(e) {
return _t.some((t) => e[t] >= 0);
}
var Jt = function(e) {
return e === void 0 && (e = {}), {
name: "hide",
options: e,
async fn(t) {
let { rects: n, platform: r } = t, { strategy: i = "referenceHidden", ...a } = V(e, t);
switch (i) {
case "referenceHidden": {
let e = Kt(await r.detectOverflow(t, {
...a,
elementContext: "reference"
}), n.reference);
return { data: {
referenceHiddenOffsets: e,
referenceHidden: qt(e)
} };
}
case "escaped": {
let e = Kt(await r.detectOverflow(t, {
...a,
altBoundary: !0
}), n.floating);
return { data: {
escapedOffsets: e,
escaped: qt(e)
} };
}
default: return {};
}
}
};
};
function Yt(e) {
let t = R(...e.map((e) => e.left)), n = R(...e.map((e) => e.top)), r = z(...e.map((e) => e.right)), i = z(...e.map((e) => e.bottom));
return {
x: t,
y: n,
width: r - t,
height: i - n
};
}
function Xt(e) {
let t = e.slice().sort((e, t) => e.y - t.y), n = [], r = null;
for (let e = 0; e < t.length; e++) {
let i = t[e];
!r || i.y - r.y > r.height / 2 ? n.push([i]) : n[n.length - 1].push(i), r = i;
}
return n.map((e) => G(Yt(e)));
}
var Zt = function(e) {
return e === void 0 && (e = {}), {
name: "inline",
options: e,
async fn(t) {
let { placement: n, elements: r, rects: i, platform: a, strategy: o } = t, { padding: s = 2, x: c, y: l } = V(e, t), u = Array.from(await (a.getClientRects == null ? void 0 : a.getClientRects(r.reference)) || []), d = Xt(u), f = G(Yt(u)), p = Lt(s);
function m() {
if (d.length === 2 && d[0].left > d[1].right && c != null && l != null) return d.find((e) => c > e.left - p.left && c < e.right + p.right && l > e.top - p.top && l < e.bottom + p.bottom) || f;
if (d.length >= 2) {
if (W(n) === "y") {
let e = d[0], t = d[d.length - 1], r = H(n) === "top", i = e.top, a = t.bottom, o = r ? e.left : t.left, s = r ? e.right : t.right;
return {
top: i,
bottom: a,
left: o,
right: s,
width: s - o,
height: a - i,
x: o,
y: i
};
}
let e = H(n) === "left", t = z(...d.map((e) => e.right)), r = R(...d.map((e) => e.left)), i = d.filter((n) => e ? n.left === r : n.right === t), a = i[0].top, o = i[i.length - 1].bottom, s = r, c = t;
return {
top: a,
bottom: o,
left: s,
right: c,
width: c - s,
height: o - a,
x: s,
y: a
};
}
return f;
}
let h = await a.getElementRects({
reference: { getBoundingClientRect: m },
floating: r.floating,
strategy: o
});
return i.reference.x !== h.reference.x || i.reference.y !== h.reference.y || i.reference.width !== h.reference.width || i.reference.height !== h.reference.height ? { reset: { rects: h } } : {};
}
};
}, Qt = /* @__PURE__ */ new Set(["left", "top"]);
async function $t(e, t) {
let { placement: n, platform: r, elements: i } = e, a = await (r.isRTL == null ? void 0 : r.isRTL(i.floating)), o = H(n), s = U(n), c = W(n) === "y", l = Qt.has(o) ? -1 : 1, u = a && c ? -1 : 1, d = V(t, e), { mainAxis: f, crossAxis: p, alignmentAxis: m } = typeof d == "number" ? {
mainAxis: d,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: d.mainAxis || 0,
crossAxis: d.crossAxis || 0,
alignmentAxis: d.alignmentAxis
};
return s && typeof m == "number" && (p = s === "end" ? m * -1 : m), c ? {
x: p * u,
y: f * l
} : {
x: f * l,
y: p * u
};
}
var en = function(e) {
return e === void 0 && (e = 0), {
name: "offset",
options: e,
async fn(t) {
var n;
let { x: r, y: i, placement: a, middlewareData: o } = t, s = await $t(t, e);
return a === o.offset?.placement && (n = o.arrow) != null && n.alignmentOffset ? {} : {
x: r + s.x,
y: i + s.y,
data: {
...s,
placement: a
}
};
}
};
}, tn = function(e) {
return e === void 0 && (e = {}), {
name: "shift",
options: e,
async fn(t) {
let { x: n, y: r, placement: i, platform: a } = t, { mainAxis: o = !0, crossAxis: s = !1, limiter: c = { fn: (e) => {
let { x: t, y: n } = e;
return {
x: t,
y: n
};
} }, ...l } = V(e, t), u = {
x: n,
y: r
}, d = await a.detectOverflow(t, l), f = W(H(i)), p = Ct(f), m = u[p], h = u[f];
if (o) {
let e = p === "y" ? "top" : "left", t = p === "y" ? "bottom" : "right", n = m + d[e], r = m - d[t];
m = St(n, m, r);
}
if (s) {
let e = f === "y" ? "top" : "left", t = f === "y" ? "bottom" : "right", n = h + d[e], r = h - d[t];
h = St(n, h, r);
}
let g = c.fn({
...t,
[p]: m,
[f]: h
});
return {
...g,
data: {
x: g.x - n,
y: g.y - r,
enabled: {
[p]: o,
[f]: s
}
}
};
}
};
}, nn = function(e) {
return e === void 0 && (e = {}), {
name: "size",
options: e,
async fn(t) {
var n, r;
let { placement: i, rects: a, platform: o, elements: s } = t, { apply: c = () => {}, ...l } = V(e, t), u = await o.detectOverflow(t, l), d = H(i), f = U(i), p = W(i) === "y", { width: m, height: h } = a.floating, g, _;
d === "top" || d === "bottom" ? (g = d, _ = f === (await (o.isRTL == null ? void 0 : o.isRTL(s.floating)) ? "start" : "end") ? "left" : "right") : (_ = d, g = f === "end" ? "top" : "bottom");
let v = h - u.top - u.bottom, y = m - u.left - u.right, b = R(h - u[g], v), x = R(m - u[_], y), S = !t.middlewareData.shift, C = b, w = x;
if ((n = t.middlewareData.shift) != null && n.enabled.x && (w = y), (r = t.middlewareData.shift) != null && r.enabled.y && (C = v), S && !f) {
let e = z(u.left, 0), t = z(u.right, 0), n = z(u.top, 0), r = z(u.bottom, 0);
p ? w = m - 2 * (e !== 0 || t !== 0 ? e + t : z(u.left, u.right)) : C = h - 2 * (n !== 0 || r !== 0 ? n + r : z(u.top, u.bottom));
}
await c({
...t,
availableWidth: w,
availableHeight: C
});
let T = await o.getDimensions(s.floating);
return m !== T.width || h !== T.height ? { reset: { rects: !0 } } : {};
}
};
};
//#endregion
//#region ../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
function rn() {
return typeof window < "u";
}
function an(e) {
return on(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function K(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function q(e) {
return ((on(e) ? e.ownerDocument : e.document) || window.document)?.documentElement;
}
function on(e) {
return rn() ? e instanceof Node || e instanceof K(e).Node : !1;
}
function J(e) {
return rn() ? e instanceof Element || e instanceof K(e).Element : !1;
}
function Y(e) {
return rn() ? e instanceof HTMLElement || e instanceof K(e).HTMLElement : !1;
}
function sn(e) {
return !rn() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof K(e).ShadowRoot;
}
function cn(e) {
let { overflow: t, overflowX: n, overflowY: r, display: i } = Z(e);
return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && i !== "inline" && i !== "contents";
}
function ln(e) {
return /^(table|td|th)$/.test(an(e));
}
function un(e) {
try {
if (e.matches(":popover-open")) return !0;
} catch {}
try {
return e.matches(":modal");
} catch {
return !1;
}
}
var dn = /transform|translate|scale|rotate|perspective|filter/, fn = /paint|layout|strict|content/, X = (e) => !!e && e !== "none", pn;
function mn(e) {
let t = J(e) ? Z(e) : e;
return X(t.transform) || X(t.translate) || X(t.scale) || X(t.rotate) || X(t.perspective) || !gn() && (X(t.backdropFilter) || X(t.filter)) || dn.test(t.willChange || "") || fn.test(t.contain || "");
}
function hn(e) {
let t = Q(e);
for (; Y(t) && !_n(t);) {
if (mn(t)) return t;
if (un(t)) return null;
t = Q(t);
}
return null;
}
function gn() {
return pn ?? (pn = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), pn;
}
function _n(e) {
return /^(html|body|#document)$/.test(an(e));
}
function Z(e) {
return K(e).getComputedStyle(e);
}
function vn(e) {
return J(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function Q(e) {
if (an(e) === "html") return e;
let t = e.assignedSlot || e.parentNode || sn(e) && e.host || q(e);
return sn(t) ? t.host : t;
}
function yn(e) {
let t = Q(e);
return _n(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Y(t) && cn(t) ? t : yn(t);
}
function bn(e, t, n) {
t === void 0 && (t = []), n === void 0 && (n = !0);
let r = yn(e), i = r === e.ownerDocument?.body, a = K(r);
if (i) {
let e = xn(a);
return t.concat(a, a.visualViewport || [], cn(r) ? r : [], e && n ? bn(e) : []);
} else return t.concat(r, bn(r, [], n));
}
function xn(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
//#endregion
//#region ../../node_modules/.pnpm/@floating-ui+dom@1.7.6/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
function Sn(e) {
let t = Z(e), n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0, i = Y(e), a = i ? e.offsetWidth : n, o = i ? e.offsetHeight : r, s = bt(n) !== a || bt(r) !== o;
return s && (n = a, r = o), {
width: n,
height: r,
$: s
};
}
function Cn(e) {
return J(e) ? e : e.contextElement;
}
function wn(e) {
let t = Cn(e);
if (!Y(t)) return B(1);
let n = t.getBoundingClientRect(), { width: r, height: i, $: a } = Sn(t), o = (a ? bt(n.width) : n.width) / r, s = (a ? bt(n.height) : n.height) / i;
return (!o || !Number.isFinite(o)) && (o = 1), (!s || !Number.isFinite(s)) && (s = 1), {
x: o,
y: s
};
}
var Tn = /* @__PURE__ */ B(0);
function En(e) {
let t = K(e);
return !gn() || !t.visualViewport ? Tn : {
x: t.visualViewport.offsetLeft,
y: t.visualViewport.offsetTop
};
}
function Dn(e, t, n) {
return t === void 0 && (t = !1), !n || t && n !== K(e) ? !1 : t;
}
function On(e, t, n, r) {
t === void 0 && (t = !1), n === void 0 && (n = !1);
let i = e.getBoundingClientRect(), a = Cn(e), o = B(1);
t && (r ? J(r) && (o = wn(r)) : o = wn(e));
let s = Dn(a, n, r) ? En(a) : B(0), c = (i.left + s.x) / o.x, l = (i.top + s.y) / o.y, u = i.width / o.x, d = i.height / o.y;
if (a) {
let e = K(a), t = r && J(r) ? K(r) : r, n = e, i = xn(n);
for (; i && r && t !== n;) {
let e = wn(i), t = i.getBoundingClientRect(), r = Z(i), a = t.left + (i.clientLeft + parseFloat(r.paddingLeft)) * e.x, o = t.top + (i.clientTop + parseFloat(r.paddingTop)) * e.y;
c *= e.x, l *= e.y, u *= e.x, d *= e.y, c += a, l += o, n = K(i), i = xn(n);
}
}
return G({
width: u,
height: d,
x: c,
y: l
});
}
function kn(e, t) {
let n = vn(e).scrollLeft;
return t ? t.left + n : On(q(e)).left + n;
}
function An(e, t) {
let n = e.getBoundingClientRect();
return {
x: n.left + t.scrollLeft - kn(e, n),
y: n.top + t.scrollTop
};
}
function jn(e) {
let { elements: t, rect: n, offsetParent: r, strategy: i } = e, a = i === "fixed", o = q(r), s = t ? un(t.floating) : !1;
if (r === o || s && a) return n;
let c = {
scrollLeft: 0,
scrollTop: 0
}, l = B(1), u = B(0), d = Y(r);
if ((d || !d && !a) && ((an(r) !== "body" || cn(o)) && (c = vn(r)), d)) {
let e = On(r);
l = wn(r), u.x = e.x + r.clientLeft, u.y = e.y + r.clientTop;
}
let f = o && !d && !a ? An(o, c) : B(0);
return {
width: n.width * l.x,
height: n.height * l.y,
x: n.x * l.x - c.scrollLeft * l.x + u.x + f.x,
y: n.y * l.y - c.scrollTop * l.y + u.y + f.y
};
}
function Mn(e) {
return Array.from(e.getClientRects());
}
function Nn(e) {
let t = q(e), n = vn(e), r = e.ownerDocument.body, i = z(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), a = z(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight), o = -n.scrollLeft + kn(e), s = -n.scrollTop;
return Z(r).direction === "rtl" && (o += z(t.clientWidth, r.clientWidth) - i), {
width: i,
height: a,
x: o,
y: s
};
}
var Pn = 25;
function Fn(e, t) {
let n = K(e), r = q(e), i = n.visualViewport, a = r.clientWidth, o = r.clientHeight, s = 0, c = 0;
if (i) {
a = i.width, o = i.height;
let e = gn();
(!e || e && t === "fixed") && (s = i.offsetLeft, c = i.offsetTop);
}
let l = kn(r);
if (l <= 0) {
let e = r.ownerDocument, t = e.body, n = getComputedStyle(t), i = e.compatMode === "CSS1Compat" && parseFloat(n.marginLeft) + parseFloat(n.marginRight) || 0, o = Math.abs(r.clientWidth - t.clientWidth - i);
o <= Pn && (a -= o);
} else l <= Pn && (a += l);
return {
width: a,
height: o,
x: s,
y: c
};
}
function In(e, t) {
let n = On(e, !0, t === "fixed"), r = n.top + e.clientTop, i = n.left + e.clientLeft, a = Y(e) ? wn(e) : B(1);
return {
width: e.clientWidth * a.x,
height: e.clientHeight * a.y,
x: i * a.x,
y: r * a.y
};
}
function Ln(e, t, n) {
let r;
if (t === "viewport") r = Fn(e, n);
else if (t === "document") r = Nn(q(e));
else if (J(t)) r = In(t, n);
else {
let n = En(e);
r = {
x: t.x - n.x,
y: t.y - n.y,
width: t.width,
height: t.height
};
}
return G(r);
}
function Rn(e, t) {
let n = Q(e);
return n === t || !J(n) || _n(n) ? !1 : Z(n).position === "fixed" || Rn(n, t);
}
function zn(e, t) {
let n = t.get(e);
if (n) return n;
let r = bn(e, [], !1).filter((e) => J(e) && an(e) !== "body"), i = null, a = Z(e).position === "fixed", o = a ? Q(e) : e;
for (; J(o) && !_n(o);) {
let t = Z(o), n = mn(o);
!n && t.position === "fixed" && (i = null), (a ? !n && !i : !n && t.position === "static" && i && (i.position === "absolute" || i.position === "fixed") || cn(o) && !n && Rn(e, o)) ? r = r.filter((e) => e !== o) : i = t, o = Q(o);
}
return t.set(e, r), r;
}
function Bn(e) {
let { element: t, boundary: n, rootBoundary: r, strategy: i } = e, a = [...n === "clippingAncestors" ? un(t) ? [] : zn(t, this._c) : [].concat(n), r], o = Ln(t, a[0], i), s = o.top, c = o.right, l = o.bottom, u = o.left;
for (let e = 1; e < a.length; e++) {
let n = Ln(t, a[e], i);
s = z(n.top, s), c = R(n.right, c), l = R(n.bottom, l), u = z(n.left, u);
}
return {
width: c - u,
height: l - s,
x: u,
y: s
};
}
function Vn(e) {
let { width: t, height: n } = Sn(e);
return {
width: t,
height: n
};
}
function Hn(e, t, n) {
let r = Y(t), i = q(t), a = n === "fixed", o = On(e, !0, a, t), s = {
scrollLeft: 0,
scrollTop: 0
}, c = B(0);
function l() {
c.x = kn(i);
}
if (r || !r && !a) if ((an(t) !== "body" || cn(i)) && (s = vn(t)), r) {
let e = On(t, !0, a, t);
c.x = e.x + t.clientLeft, c.y = e.y + t.clientTop;
} else i && l();
a && !r && i && l();
let u = i && !r && !a ? An(i, s) : B(0);
return {
x: o.left + s.scrollLeft - c.x - u.x,
y: o.top + s.scrollTop - c.y - u.y,
width: o.width,
height: o.height
};
}
function Un(e) {
return Z(e).position === "static";
}
function Wn(e, t) {
if (!Y(e) || Z(e).position === "fixed") return null;
if (t) return t(e);
let n = e.offsetParent;
return q(e) === n && (n = n.ownerDocument.body), n;
}
function Gn(e, t) {
let n = K(e);
if (un(e)) return n;
if (!Y(e)) {
let t = Q(e);
for (; t && !_n(t);) {
if (J(t) && !Un(t)) return t;
t = Q(t);
}
return n;
}
let r = Wn(e, t);
for (; r && ln(r) && Un(r);) r = Wn(r, t);
return r && _n(r) && Un(r) && !mn(r) ? n : r || hn(e) || n;
}
var Kn = async function(e) {
let t = this.getOffsetParent || Gn, n = this.getDimensions, r = await n(e.floating);
return {
reference: Hn(e.reference, await t(e.floating), e.strategy),
floating: {
x: 0,
y: 0,
width: r.width,
height: r.height
}
};
};
function qn(e) {
return Z(e).direction === "rtl";
}
var Jn = {
convertOffsetParentRelativeRectToViewportRelativeRect: jn,
getDocumentElement: q,
getClippingRect: Bn,
getOffsetParent: Gn,
getElementRects: Kn,
getClientRects: Mn,
getDimensions: Vn,
getScale: wn,
isElement: J,
isRTL: qn
}, Yn = en, Xn = Wt, Zn = tn, Qn = Gt, $n = nn, er = Jt, tr = Ht, nr = Zt, rr = (e, t, n) => {
let r = /* @__PURE__ */ new Map(), i = {
platform: Jn,
...n
}, a = {
...i.platform,
_c: r
};
return Vt(e, t, {
...i,
platform: a
});
};
//#endregion
//#region ../../node_modules/.pnpm/@tiptap+vue-3@3.19.0_patch_hash=65d98f737afae097542c692b176a81069e1b7b8d577d1d7e222a944_23bfa7b5fde667bfc96216774c3ce084/node_modules/@tiptap/vue-3/dist/menus/index.js
function ir(e, t) {
let n = Math.min(e.top, t.top), r = Math.max(e.bottom, t.bottom), i = Math.min(e.left, t.left), a = Math.max(e.right, t.right) - i, o = r - n;
return new DOMRect(i, n, a, o);
}
var ar = class {
constructor({ editor: e, element: t, view: n, updateDelay: r = 250, resizeDelay: i = 60, shouldShow: a, appendTo: o, getReferencedVirtualElement: s, options: c }) {
this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.floatingUIOptions = {
strategy: "absolute",
placement: "top",
offset: 8,
flip: {},
shift: {},
arrow: !1,
size: !1,
autoPlacement: !1,
hide: !1,
inline: !1,
onShow: void 0,
onHide: void 0,
onUpdate: void 0,
onDestroy: void 0
}, this.shouldShow = ({ view: e, state: t, from: n, to: r }) => {
let { doc: i, selection: a } = t, { empty: o } = a, s = !i.textBetween(n, r).length && Ne(t.selection), c = this.element.contains(document.activeElement);
return !(!(e.hasFocus() || c) || o || s || !this.editor.isEditable);
}, this.mousedownHandler = () => {
this.preventHide = !0;
}, this.dragstartHandler = () => {
this.hide();
}, this.resizeHandler = () => {
this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
this.updatePosition();
}, this.resizeDelay);
}, this.focusHandler = () => {
setTimeout(() => this.update(this.editor.view));
}, this.blurHandler = ({ event: e }) => {
if (this.editor.isDestroyed) {
this.destroy();
return;
}
if (this.preventHide) {
this.preventHide = !1;
return;
}
e?.relatedTarget && this.element.parentNode?.contains(e.relatedTarget) || e?.relatedTarget !== this.editor.view.dom && this.hide();
}, this.handleDebouncedUpdate = (e, t) => {
let n = !t?.selection.eq(e.state.selection), r = !t?.doc.eq(e.state.doc);
!n && !r || (this.updateDebounceTimer && clearTimeout(this.updateDebounceTimer), this.updateDebounceTimer = window.setTimeout(() => {
this.updateHandler(e, n, r, t);
}, this.updateDelay));
}, this.updateHandler = (e, t, n, r) => {
let { composing: i } = e;
if (!(i || !t && !n)) {
if (!this.getShouldShow(r)) {
this.hide();
return;
}
this.updatePosition(), this.show();
}
}, this.transactionHandler = ({ transaction: e }) => {
let t = e.getMeta("bubbleMenu");
t === "updatePosition" ? this.updatePosition() : t && typeof t == "object" && t.type === "updateOptions" && this.updateOptions(t.options);
}, this.editor = e, this.element = t, this.view = n, this.updateDelay = r, this.resizeDelay = i, this.appendTo = o, this.scrollTarget = c?.scrollTarget ?? window, this.getReferencedVirtualElement = s, this.floatingUIOptions = {
...this.floatingUIOptions,
...c
}, this.element.tabIndex = 0, a && (this.shouldShow = a), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.editor.on("transaction", this.transactionHandler), window.addEventListener("resize", this.resizeHandler), this.scrollTarget.addEventListener("scroll", this.resizeHandler), this.update(n, n.state), this.getShouldShow() && (this.show(), this.updatePosition());
}
get middlewares() {
let e = [];
return this.floatingUIOptions.flip && e.push(Qn(typeof this.floatingUIOptions.flip == "boolean" ? void 0 : this.floatingUIOptions.flip)), this.floatingUIOptions.shift && e.push(Zn(typeof this.floatingUIOptions.shift == "boolean" ? void 0 : this.floatingUIOptions.shift)), this.floatingUIOptions.offset && e.push(Yn(typeof this.floatingUIOptions.offset == "boolean" ? void 0 : this.floatingUIOptions.offset)), this.floatingUIOptions.arrow && e.push(tr(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && e.push($n(typeof this.floatingUIOptions.size == "boolean" ? void 0 : this.floatingUIOptions.size)), this.floatingUIOptions.autoPlacement && e.push(Xn(typeof this.floatingUIOptions.autoPlacement == "boolean" ? void 0 : this.floatingUIOptions.autoPlacement)), this.floatingUIOptions.hide && e.push(er(typeof this.floatingUIOptions.hide == "boolean" ? void 0 : this.floatingUIOptions.hide)), this.floatingUIOptions.inline && e.push(nr(typeof this.floatingUIOptions.inline == "boolean" ? void 0 : this.floatingUIOptions.inline)), e;
}
get virtualElement() {
let { selection: e } = this.editor.state, t = this.getReferencedVirtualElement?.call(this);
if (t) return t;
if (!this.view?.dom?.parentNode) return;
let n = Ie(this.view, e.from, e.to), r = {
getBoundingClientRect: () => n,
getClientRects: () => [n]
};
if (e instanceof Le) {
let t = this.view.nodeDOM(e.from), n = t.dataset.nodeViewWrapper ? t : t.querySelector("[data-node-view-wrapper]");
n && (t = n), t && (r = {
getBoundingClientRect: () => t.getBoundingClientRect(),
getClientRects: () => [t.getBoundingClientRect()]
});
}
if (e instanceof ze) {
let { $anchorCell: t, $headCell: n } = e, i = t ? t.pos : n.pos, a = n ? n.pos : t.pos, o = this.view.nodeDOM(i), s = this.view.nodeDOM(a);
if (!o || !s) return;
let c = o === s ? o.getBoundingClientRect() : ir(o.getBoundingClientRect(), s.getBoundingClientRect());
r = {
getBoundingClientRect: () => c,
getClientRects: () => [c]
};
}
return r;
}
updatePosition() {
let e = this.virtualElement;
e && rr(e, this.element, {
placement: this.floatingUIOptions.placement,
strategy: this.floatingUIOptions.strategy,
middleware: this.middlewares
}).then(({ x: e, y: t, strategy: n, middlewareData: r }) => {
if (r.hide?.referenceHidden || r.hide?.escaped) {
this.element.style.visibility = "hidden";
return;
}
this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = n, this.element.style.left = `${e}px`, this.element.style.top = `${t}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
});
}
update(e, t) {
let { state: n } = e, r = n.selection.from !== n.selection.to;
if (this.updateDelay > 0 && r) {
this.handleDebouncedUpdate(e, t);
return;
}
let i = !t?.selection.eq(e.state.selection), a = !t?.doc.eq(e.state.doc);
this.updateHandler(e, i, a, t);
}
getShouldShow(e) {
let { state: t } = this.view, { selection: n } = t, { ranges: r } = n, i = Math.min(...r.map((e) => e.$from.pos)), a = Math.max(...r.map((e) => e.$to.pos));
return this.shouldShow?.call(this, {
editor: this.editor,
element: this.element,
view: this.view,
state: t,
oldState: e,
from: i,
to: a
}) || !1;
}
show() {
var e;
this.isVisible || (this.element.style.visibility = "visible", this.element.style.opacity = "1", (e = (typeof this.appendTo == "function" ? this.appendTo() : this.appendTo) ?? this.view.dom.parentElement) == null || e.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0);
}
hide() {
this.isVisible && (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), this.isVisible = !1);
}
updateOptions(e) {
if (e.updateDelay !== void 0 && (this.updateDelay = e.updateDelay), e.resizeDelay !== void 0 && (this.resizeDelay = e.resizeDelay), e.appendTo !== void 0 && (this.appendTo = e.appendTo), e.getReferencedVirtualElement !== void 0 && (this.getReferencedVirtualElement = e.getReferencedVirtualElement), e.shouldShow !== void 0 && e.shouldShow && (this.shouldShow = e.shouldShow), e.options !== void 0) {
let t = e.options.scrollTarget ?? window;
t !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = t, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
...this.floatingUIOptions,
...e.options
};
}
}
destroy() {
this.hide(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), window.removeEventListener("resize", this.resizeHandler), this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler), this.editor.off("transaction", this.transactionHandler), this.floatingUIOptions.onDestroy && this.floatingUIOptions.onDestroy();
}
}, or = (e) => new Re({
key: typeof e.pluginKey == "string" ? new L(e.pluginKey) : e.pluginKey,
view: (t) => new ar({
view: t,
...e
})
}), sr = ae({
name: "BubbleMenu",
inheritAttrs: !1,
props: {
pluginKey: {
type: [String, Object],
default: "bubbleMenu"
},
editor: {
type: Object,
required: !0
},
updateDelay: {
type: Number,
default: void 0
},
resizeDelay: {
type: Number,
default: void 0
},
options: {
type: Object,
default: () => ({})
},
appendTo: {
type: [Object, Function],
default: void 0
},
shouldShow: {
type: Function,
default: null
},
getReferencedVirtualElement: {
type: Function,
default: void 0
}
},
setup(e, { slots: t, attrs: n }) {
let r = pe(null);
return fe(() => {
let { editor: t, options: n, pluginKey: i, resizeDelay: a, appendTo: o, shouldShow: s, getReferencedVirtualElement: c, updateDelay: l } = e, u = r.value;
u && (u.style.visibility = "hidden", u.style.position = "absolute", u.remove(), le(() => {
t.registerPlugin(or({
editor: t,
element: u,
options: n,
pluginKey: i,
resizeDelay: a,
appendTo: o,
shouldShow: s,
getReferencedVirtualElement: c,
updateDelay: l
}));
}));
}), de(() => {
let { pluginKey: t, editor: n } = e;
n.unregisterPlugin(t);
}), () => oe("div", {
ref: r,
...n
}, t.default?.call(t));
}
}), cr = class {
constructor({ editor: e, element: t, view: n, updateDelay: r = 250, resizeDelay: i = 60, options: a, appendTo: o, shouldShow: s }) {
this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.shouldShow = ({ view: e, state: t }) => {
let { selection: n } = t, { $anchor: r, empty: i } = n, a = r.depth === 1, o = r.parent.isTextblock && !r.parent.type.spec.code && !r.parent.textContent && r.parent.childCount === 0 && !this.getTextContent(r.parent);
return !(!e.hasFocus() || !i || !a || !o || !this.editor.isEditable);
}, this.floatingUIOptions = {
strategy: "absolute",
placement: "right",
offset: 8,
flip: {},
shift: {},
arrow: !1,
size: !1,
autoPlacement: !1,
hide: !1,
inline: !1
}, this.updateHandler = (e, t, n, r) => {
let { composing: i } = e;
if (!(i || !t && !n)) {
if (!this.getShouldShow(r)) {
this.hide();
return;
}
this.updatePosition(), this.show();
}
}, this.mousedownHandler = () => {
this.preventHide = !0;
}, this.focusHandler = () => {
setTimeout(() => this.update(this.editor.view));
}, this.blurHandler = ({ event: e }) => {
if (this.preventHide) {
this.preventHide = !1;
return;
}
e?.relatedTarget && this.element.parentNode?.contains(e.relatedTarget) || e?.relatedTarget !== this.editor.view.dom && this.hide();
}, this.transactionHandler = ({ transaction: e }) => {
let t = e.getMeta("floatingMenu");
t === "updatePosition" ? this.updatePosition() : t && typeof t == "object" && t.type === "updateOptions" && this.updateOptions(t.options);
}, this.resizeHandler = () => {
this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
this.updatePosition();
}, this.resizeDelay);
}, this.editor = e, this.element = t, this.view = n, this.updateDelay = r, this.resizeDelay = i, this.appendTo = o, this.scrollTarget = a?.scrollTarget ?? window, this.floatingUIOptions = {
...this.floatingUIOptions,
...a
}, this.element.tabIndex = 0, s && (this.shouldShow = s), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.editor.on("transaction", this.transactionHandler), window.addEventListener("resize", this.resizeHandler), this.scrollTarget.addEventListener("scroll", this.resizeHandler), this.update(n, n.state), this.getShouldShow() && (this.show(), this.updatePosition());
}
getTextContent(e) {
return je(e, { textSerializers: Me(this.editor.schema) });
}
get middlewares() {
let e = [];
return this.floatingUIOptions.flip && e.push(Qn(typeof this.floatingUIOptions.flip == "boolean" ? void 0 : this.floatingUIOptions.flip)), this.floatingUIOptions.shift && e.push(Zn(typeof this.floatingUIOptions.shift == "boolean" ? void 0 : this.floatingUIOptions.shift)), this.floatingUIOptions.offset && e.push(Yn(typeof this.floatingUIOptions.offset == "boolean" ? void 0 : this.floatingUIOptions.offset)), this.floatingUIOptions.arrow && e.push(tr(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && e.push($n(typeof this.floatingUIOptions.size == "boolean" ? void 0 : this.floatingUIOptions.size)), this.floatingUIOptions.autoPlacement && e.push(Xn(typeof this.floatingUIOptions.autoPlacement == "boolean" ? void 0 : this.floatingUIOptions.autoPlacement)), this.floatingUIOptions.hide && e.push(er(typeof this.floatingUIOptions.hide == "boolean" ? void 0 : this.floatingUIOptions.hide)), this.floatingUIOptions.inline && e.push(nr(typeof this.floatingUIOptions.inline == "boolean" ? void 0 : this.floatingUIOptions.inline)), e;
}
getShouldShow(e) {
let { state: t } = this.view, { selection: n } = t, { ranges: r } = n, i = Math.min(...r.map((e) => e.$from.pos)), a = Math.max(...r.map((e) => e.$to.pos));
return this.shouldShow?.call(this, {
editor: this.editor,
view: this.view,
state: t,
oldState: e,
from: i,
to: a
});
}
updateOptions(e) {
if (e.updateDelay !== void 0 && (this.updateDelay = e.updateDelay), e.resizeDelay !== void 0 && (this.resizeDelay = e.resizeDelay), e.appendTo !== void 0 && (this.appendTo = e.appendTo), e.shouldShow !== void 0 && e.shouldShow && (this.shouldShow = e.shouldShow), e.options !== void 0) {
let t = e.options.scrollTarget ?? window;
t !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = t, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
...this.floatingUIOptions,
...e.options
};
}
}
updatePosition() {
let { selection: e } = this.editor.state, t = Ie(this.view, e.from, e.to);
rr({
getBoundingClientRect: () => t,
getClientRects: () => [t]
}, this.element, {
placement: this.floatingUIOptions.placement,
strategy: this.floatingUIOptions.strategy,
middleware: this.middlewares
}).then(({ x: e, y: t, strategy: n, middlewareData: r }) => {
if (r.hide?.referenceHidden || r.hide?.escaped) {
this.element.style.visibility = "hidden";
return;
}
this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = n, this.element.style.left = `${e}px`, this.element.style.top = `${t}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
});
}
update(e, t) {
let n = !t?.selection.eq(e.state.selection), r = !t?.doc.eq(e.state.doc);
this.updateHandler(e, n, r, t);
}
show() {
var e;
this.isVisible || (this.element.style.visibility = "visible", this.element.style.opacity = "1", (e = (typeof this.appendTo == "function" ? this.appendTo() : this.appendTo) ?? this.view.dom.parentElement) == null || e.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0);
}
hide() {
this.isVisible && (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), this.isVisible = !1);
}
destroy() {
this.hide(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), window.removeEventListener("resize", this.resizeHandler), this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler), this.editor.off("transaction", this.transactionHandler), this.floatingUIOptions.onDestroy && this.floatingUIOptions.onDestroy();
}
}, lr = (e) => new Re({
key: typeof e.pluginKey == "string" ? new L(e.pluginKey) : e.pluginKey,
view: (t) => new cr({
view: t,
...e
})
});
ae({
name: "FloatingMenu",
inheritAttrs: !1,
props: {
pluginKey: {
type: null,
default: "floatingMenu"
},
editor: {
type: Object,
required: !0
},
updateDelay: {
type: Number,
default: void 0
},
resizeDelay: {
type: Number,
default: void 0
},
options: {
type: Object,
default: () => ({})
},
appendTo: {
type: [Object, Function],
default: void 0
},
shouldShow: {
type: Function,
default: null
}
},
setup(e, { slots: t, attrs: n }) {
let r = pe(null);
return fe(() => {
let { pluginKey: t, editor: n, updateDelay: i, resizeDelay: a, options: o, appendTo: s, shouldShow: c } = e, l = r.value;
l && (l.style.visibility = "hidden", l.style.position = "absolute", l.remove(), n.registerPlugin(lr({
pluginKey: t,
editor: n,
element: l,
updateDelay: i,
resizeDelay: a,
options: o,
appendTo: s,
shouldShow: c
})));
}), de(() => {
let { pluginKey: t, editor: n } = e;
n.unregisterPlugin(t);
}), () => oe("div", {
ref: r,
...n
}, t.default?.call(t));
}
});
//#endregion
//#region components/rich_text_editor/extensions/table/table.js
var $ = (e) => ({
default: null,
parseHTML: (t) => t.getAttribute(e),
renderHTML: (t) => t[e] ? { [e]: t[e] } : {}
}), ur = () => {
let e = $("style");
return e.renderHTML = (e) => e.style ? { style: dr(e.style) } : {}, e;
};
function dr(e) {
return e.replace(/(?<![a-z-])width\s*:\s*([^;]+);?/gi, (e, t) => /^\s*0\s*[a-z%]*\s*(!important)?\s*$/i.test(t) ? "width: 100%;" : e);
}
var fr = at.extend({
addAttributes() {
return {
...this.parent?.(),
border: $("border"),
cellpadding: $("cellpadding"),
cellspacing: $("cellspacing"),
style: ur()
};
},
renderHTML({ HTMLAttributes: e }) {
return [
"table",
I(this.options.HTMLAttributes, e),
["tbody", 0]
];
}
}), pr = ct.extend({ addAttributes() {
return {
...this.parent?.(),
style: $("style")
};
} }), mr = {
style: $("style"),
valign: $("valign"),
width: $("width")
}, hr = ot.extend({ addAttributes() {
return {
...this.parent?.(),
...mr
};
} }), gr = st.extend({ addAttributes() {
return {
...this.parent?.(),
...mr
};
} }), _r = lt.extend({ parseHTML() {
return [
...this.parent?.() || [],
{
tag: "div",
consuming: !1,
getAttrs: (e) => e.hasAttribute("style") ? {} : !1
},
{
tag: "a",
consuming: !1,
getAttrs: (e) => e.hasAttribute("style") ? {} : !1
}
];
} }), vr = {
compatConfig: { MODE: 3 },
name: "EmojiComponent",
components: {
NodeViewWrapper: S,
DtEmoji: v
},
props: T
};
function yr(e, t, n, r, i, a) {
let o = N("dt-emoji"), s = N("node-view-wrapper");
return M(), D(s, { class: "d-d-inline-block d-va-bottom d-lh0" }, {
default: F(() => [j(o, {
size: "500",
code: e.node.attrs.code
}, null, 8, ["code"])]),
_: 1
});
}
var br = /* @__PURE__ */ i(vr, [["render", yr]]), xr = {
compatConfig: { MODE: 3 },
name: "SuggestionList",
components: { DtListItem: h },
props: {
items: {
type: Array,
required: !0
},
command: {
type: Function,
required: !0
},
itemComponent: {
type: Object,
required: !0
},
itemType: {
type: String,
required: !0
}
},
data() {
return { selectedIndex: 0