UNPKG

@uva-glass/component-library

Version:

React components UvA

91 lines (90 loc) 2.77 kB
import { a3 as x, a4 as I, a5 as P, a7 as S, h as y, al as T, a1 as _, am as F, a0 as v, an as p, a as B, u as E } from "./Lexical.prod-CniF7zEE.js"; const h = /* @__PURE__ */ new Map(); function k(e) { const t = {}; if (!e) return t; const n = e.split(";"); for (const s of n) if (s !== "") { const [c, o] = s.split(/:([^]+)/); c && o && (t[c.trim()] = o.trim()); } return t; } function q(e) { let t = h.get(e); return t === void 0 && (t = k(e), h.set(e, t)), t; } function C(e, t) { const n = e.getStartEndPoints(); if (t.isSelected(e) && !t.isSegmented() && !t.isToken() && n !== null) { const [s, c] = n, o = e.isBackward(), r = s.getNode(), i = c.getNode(), f = t.is(r), l = t.is(i); if (f || l) { const [a, u] = F(e), w = r.is(i), K = t.is(o ? i : r), N = t.is(o ? r : i); let g, d = 0; return w ? (d = a > u ? u : a, g = a > u ? a : u) : K ? (d = o ? u : a, g = void 0) : N && (d = 0, g = o ? a : u), t.__text = t.__text.slice(d, g), t; } } return t; } function D(e) { const t = e.getStyle(), n = k(t); h.set(t, n); } function M(e, t) { const n = e.getFormatType(), s = e.getIndent(); n !== t.getFormatType() && t.setFormat(n), s !== t.getIndent() && t.setIndent(s); } function G(e, t, n = M) { if (e === null) return; const s = e.getStartEndPoints(), c = /* @__PURE__ */ new Map(); let o = null; if (s) { const [r, i] = s; o = v(), o.anchor.set(r.key, r.offset, r.type), o.focus.set(i.key, i.offset, i.type); const f = m(r.getNode(), p), l = m(i.getNode(), p); y(f) && c.set(f.getKey(), f), y(l) && c.set(l.getKey(), l); } for (const r of e.getNodes()) y(r) && p(r) && c.set(r.getKey(), r); for (const [r, i] of c) { const f = t(); n(i, f), i.replace(f, !0), o && (r === o.anchor.key && o.anchor.set(f.getKey(), o.anchor.offset, o.anchor.type), r === o.focus.key && o.focus.set(f.getKey(), o.focus.offset, o.focus.type)); } o && e.is(B()) && E(o); } function R(e, t) { const n = x(e.focus, t ? "previous" : "next"); if (I(n)) return !1; for (const s of P(n)) { if (S(s)) return !s.origin.isInline(); if (!y(s.origin)) { if (T(s.origin)) return !0; break; } } return !1; } function O(e, t, n, s) { e.modify(t ? "extend" : "move", n, s); } function $(e) { const t = e.anchor.getNode(); return (_(t) ? t : t.getParentOrThrow()).getDirection() === "rtl"; } function V(e, t, n) { const s = $(e); O(e, t, n ? !s : s, "character"); } function m(e, t) { let n = e; for (; n !== null && n.getParent() !== null && !t(n); ) n = n.getParentOrThrow(); return t(n) ? n : null; } export { C as B, V as G, q as I, D as R, R as W, G as _ }; //# sourceMappingURL=LexicalSelection.prod-BfAlhGGm.js.map