@pie-lib/editable-html-tip-tap 3.1.3-next.20261102140134 → 3.1.3-next.20261103123052

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +1,64 @@
1
- import { arabicConfig as e, spanishConfig as t, specialConfig as n } from "./characters/characterUtils.js";
2
- import r from "./characters/custom-popper.js";
3
- import { useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
4
- import { get as c } from "@pie-element/shared-lodash";
5
- import l from "react-dom";
6
- import u from "prop-types";
7
- import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
8
- import { PureToolbar as m } from "@pie-lib/math-toolbar";
1
+ import { returnFocusToText as e } from "../utils/focus.js";
2
+ import { arabicConfig as t, spanishConfig as n, specialConfig as r } from "./characters/characterUtils.js";
3
+ import i from "./characters/custom-popper.js";
4
+ import { useEffect as a, useMemo as o, useRef as s, useState as c } from "react";
5
+ import { get as l } from "@pie-element/shared-lodash";
6
+ import u from "react-dom";
7
+ import d from "prop-types";
8
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
9
+ import { PureToolbar as h } from "@pie-lib/math-toolbar";
9
10
  //#region src/components/CharacterPicker.tsx
10
- var h = ({ letter: e }) => /* @__PURE__ */ f("div", {
11
+ var g = ({ letter: e }) => /* @__PURE__ */ p("div", {
11
12
  style: {
12
13
  fontSize: "24px",
13
14
  lineHeight: "24px"
14
15
  },
15
16
  children: e
16
17
  });
17
- h.propTypes = { letter: u.string };
18
- var g = [
18
+ g.propTypes = { letter: d.string };
19
+ var _ = [
19
20
  "ArrowLeft",
20
21
  "ArrowRight",
21
22
  "ArrowUp",
22
23
  "ArrowDown"
23
- ], _ = "button, a[href], input, select, textarea, [contenteditable=\"true\"], [tabindex]", v = (e) => {
24
+ ], v = "button, a[href], input, select, textarea, [contenteditable=\"true\"], [tabindex]", y = (e) => {
24
25
  let t = e.tabIndex >= 0, n = !e.disabled, r = !!e.closest("[inert]"), i = e.getClientRects().length > 0;
25
26
  return t && n && !r && i;
26
- }, y = (e) => Array.from(e.querySelectorAll(_)).filter(v), b = (e, t) => (e + t) % t, x = (e, t, n, r) => e[b(t + {
27
+ }, b = (e) => Array.from(e.querySelectorAll(v)).filter(y), x = (e, t) => (e + t) % t, S = (e, t, n, r) => e[x(t + {
27
28
  ArrowLeft: -1,
28
29
  ArrowRight: 1,
29
30
  ArrowUp: -r,
30
31
  ArrowDown: r
31
32
  }[n], e.length)];
32
- function S({ editor: u, opts: h, onClose: _, triggerEl: v, focusOnOpen: b }) {
33
- if (!h?.characters?.length) return null;
34
- let S = o(null), C = o(_), [w, T] = s({
33
+ function C({ editor: d, opts: g, onClose: v, triggerEl: y, focusOnOpen: x }) {
34
+ if (!g?.characters?.length) return null;
35
+ let C = s(null), w = s(v), [T, E] = c({
35
36
  top: 0,
36
37
  left: 0
37
- }), [E, D] = s(null);
38
- C.current = _;
39
- let O = a(() => {
40
- if (!h) return t;
38
+ }), [D, O] = c(null);
39
+ w.current = v;
40
+ let k = () => {
41
+ e(d), w.current();
42
+ }, A = o(() => {
43
+ if (!g) return n;
41
44
  switch (!0) {
42
- case h.language === "spanish": return t;
43
- case h.language === "special": return n;
44
- case h.language === "arabic": return e;
45
- default: return h;
45
+ case g.language === "spanish": return n;
46
+ case g.language === "special": return r;
47
+ case g.language === "arabic": return t;
48
+ default: return g;
46
49
  }
47
- }, [h]), k = a(() => O.characters.reduce((e, t) => (t.length >= e.columns && (e.columns = t.length), e), {
48
- rows: O.characters.length,
50
+ }, [g]), j = o(() => A.characters.reduce((e, t) => (t.length >= e.columns && (e.columns = t.length), e), {
51
+ rows: A.characters.length,
49
52
  columns: 0
50
- }), [O]), A = () => D(null);
51
- i(() => () => {
52
- A();
53
- }, []), i(() => {
54
- if (!u) return;
55
- let e = u.options.element, t = u.view.dom, n = () => {
56
- if (!S.current) return;
57
- let t = e.getBoundingClientRect(), { from: n } = u.state.selection, r = u.view.coordsAtPos(n), i = S.current.offsetHeight, a = S.current.offsetWidth, o = window.innerHeight - (t.bottom + 60) >= i || t.top < i + 80 ? t.bottom + 60 : t.top - i - 20, s = r.left;
58
- o = Math.max(8, Math.min(o, window.innerHeight - i - 8)), s = Math.max(8, Math.min(s, window.innerWidth - a - 8)), T({
53
+ }), [A]), M = () => O(null);
54
+ a(() => () => {
55
+ M();
56
+ }, []), a(() => {
57
+ if (!d) return;
58
+ let e = d.options.element, t = d.view.dom, n = () => {
59
+ if (!C.current) return;
60
+ let t = e.getBoundingClientRect(), { from: n } = d.state.selection, r = d.view.coordsAtPos(n), i = C.current.offsetHeight, a = C.current.offsetWidth, o = window.innerHeight - (t.bottom + 60) >= i || t.top < i + 80 ? t.bottom + 60 : t.top - i - 20, s = r.left;
61
+ o = Math.max(8, Math.min(o, window.innerHeight - i - 8)), s = Math.max(8, Math.min(s, window.innerWidth - a - 8)), E({
59
62
  top: o,
60
63
  left: s
61
64
  });
@@ -68,131 +71,131 @@ function S({ editor: u, opts: h, onClose: _, triggerEl: v, focusOnOpen: b }) {
68
71
  };
69
72
  window.addEventListener("scroll", i, !0), window.addEventListener("resize", i);
70
73
  let a = (e) => {
71
- S.current && !S.current.contains(e.target) && !t.contains(e.target) && C.current();
74
+ C.current && !C.current.contains(e.target) && !t.contains(e.target) && w.current();
72
75
  }, o = setTimeout(() => {
73
76
  document.addEventListener("click", a);
74
77
  });
75
78
  return () => {
76
79
  clearTimeout(o), r !== null && cancelAnimationFrame(r), window.removeEventListener("scroll", i, !0), window.removeEventListener("resize", i), document.removeEventListener("click", a);
77
80
  };
78
- }, [u]);
79
- let j = w.top !== 0 || w.left !== 0, M = () => Array.from(S.current?.querySelectorAll("button:not([disabled])") ?? []), N = o(!1);
80
- i(() => {
81
- if (!b || !j || N.current) return;
82
- let e = M()[0];
83
- e && (e.focus(), N.current = !0);
84
- }, [b, j]), i(() => {
85
- if (!v) return;
86
- let e = () => {
87
- C.current(), v.focus();
88
- }, t = (e, t, n) => {
89
- x(n, Math.max(0, n.indexOf(t.closest("button"))), e, k.columns || 1)?.focus();
90
- }, n = () => {
91
- let e = y(document.body).filter((e) => !S.current.contains(e)), t = e.indexOf(v);
92
- ((t === -1 ? null : e[t + 1]) || v).focus();
93
- }, r = (r) => {
94
- if (!S.current) return;
95
- let i = M();
96
- if (!i.length) return;
97
- let a = r.target, o = S.current.contains(a), s = i[0], c = i[i.length - 1];
98
- if (o && r.key === "Escape") {
99
- r.preventDefault(), r.stopPropagation(), e();
81
+ }, [d]);
82
+ let N = T.top !== 0 || T.left !== 0, P = () => Array.from(C.current?.querySelectorAll("button:not([disabled])") ?? []), F = s(!1);
83
+ a(() => {
84
+ if (!x || !N || F.current) return;
85
+ let e = P()[0];
86
+ e && (e.focus(), F.current = !0);
87
+ }, [x, N]), a(() => {
88
+ if (!y) return;
89
+ let e = (e, t, n) => {
90
+ S(n, Math.max(0, n.indexOf(t.closest("button"))), e, j.columns || 1)?.focus();
91
+ }, t = () => {
92
+ let e = b(document.body).filter((e) => !C.current.contains(e)), t = e.indexOf(y);
93
+ ((t === -1 ? null : e[t + 1]) || y).focus();
94
+ }, n = (n) => {
95
+ if (!C.current) return;
96
+ let r = P();
97
+ if (!r.length) return;
98
+ let i = n.target, a = C.current.contains(i), o = r[0], s = r[r.length - 1];
99
+ if (a && n.key === "Escape") {
100
+ n.preventDefault(), n.stopPropagation(), k();
100
101
  return;
101
102
  }
102
- if (o && g.includes(r.key)) {
103
- r.preventDefault(), r.stopPropagation(), t(r.key, a, i);
103
+ if (a && _.includes(n.key)) {
104
+ n.preventDefault(), n.stopPropagation(), e(n.key, i, r);
104
105
  return;
105
106
  }
106
- if (r.key !== "Tab") return;
107
- let l = a === v && !r.shiftKey, u = a === s && r.shiftKey, d = a === c && !r.shiftKey;
108
- l ? (r.preventDefault(), s.focus()) : u ? (r.preventDefault(), v.focus()) : d && (r.preventDefault(), n());
107
+ if (n.key !== "Tab") return;
108
+ let c = i === y && !n.shiftKey, l = i === o && n.shiftKey, u = i === s && !n.shiftKey;
109
+ c ? (n.preventDefault(), o.focus()) : l ? (n.preventDefault(), y.focus()) : u && (n.preventDefault(), t());
109
110
  };
110
- return document.addEventListener("keydown", r, !0), () => document.removeEventListener("keydown", r, !0);
111
- }, [v, k.columns]);
112
- let P = (e, t) => D({
111
+ return document.addEventListener("keydown", n, !0), () => document.removeEventListener("keydown", n, !0);
112
+ }, [
113
+ d,
114
+ y,
115
+ j.columns
116
+ ]);
117
+ let I = (e, t) => O({
113
118
  anchorEl: e.currentTarget,
114
119
  el: t
115
- }), F = o("keyboard");
116
- return /* @__PURE__ */ p(d, { children: [l.createPortal(/* @__PURE__ */ f("div", {
117
- ref: S,
120
+ }), L = s("keyboard");
121
+ return /* @__PURE__ */ m(f, { children: [u.createPortal(/* @__PURE__ */ p("div", {
122
+ ref: C,
118
123
  className: "insert-character-dialog",
119
- "data-toolbar-for": u.instanceId,
124
+ "data-toolbar-for": d.instanceId,
120
125
  onPointerDown: () => {
121
- F.current = "pointer";
126
+ L.current = "pointer";
122
127
  },
123
128
  onKeyDown: () => {
124
- F.current = "keyboard";
129
+ L.current = "keyboard";
125
130
  },
126
131
  style: {
127
- visibility: j ? "initial" : "hidden",
132
+ visibility: N ? "initial" : "hidden",
128
133
  position: "fixed",
129
- top: `${w.top}px`,
130
- left: `${w.left}px`,
134
+ top: `${T.top}px`,
135
+ left: `${T.left}px`,
131
136
  maxWidth: "500px",
132
137
  zIndex: 1e3
133
138
  },
134
- children: /* @__PURE__ */ f("div", { children: /* @__PURE__ */ f(m, {
135
- keyPadCharacterRef: h.keyPadCharacterRef,
136
- setKeypadInteraction: h.setKeypadInteraction,
139
+ children: /* @__PURE__ */ p("div", { children: /* @__PURE__ */ p(h, {
140
+ keyPadCharacterRef: g.keyPadCharacterRef,
141
+ setKeypadInteraction: g.setKeypadInteraction,
137
142
  noDecimal: !0,
138
143
  hideInput: !0,
139
144
  noLatexHandling: !0,
140
145
  hideDoneButtonBackground: !0,
141
- layoutForKeyPad: k,
142
- additionalKeys: O.characters.reduce((e, t) => (e = [...e, ...t.map((e) => ({
143
- name: c(e, "name") || c(e, "label") || e,
144
- write: c(e, "write") || e,
145
- label: c(e, "label") || e,
146
+ layoutForKeyPad: j,
147
+ additionalKeys: A.characters.reduce((e, t) => (e = [...e, ...t.map((e) => ({
148
+ name: l(e, "name") || l(e, "label") || e,
149
+ write: l(e, "write") || e,
150
+ label: l(e, "label") || e,
146
151
  category: "character",
147
152
  extraClass: "character",
148
153
  extraProps: {
149
154
  ...e.extraProps || {},
150
155
  style: {
151
156
  ...(e.extraProps || {}).style,
152
- border: "1px solid #000"
157
+ border: "1px solid currentColor"
153
158
  }
154
159
  },
155
- ...O.hasPreview ? { actions: {
156
- onMouseEnter: (t) => P(t, e),
157
- onMouseLeave: A
160
+ ...A.hasPreview ? { actions: {
161
+ onMouseEnter: (t) => I(t, e),
162
+ onMouseLeave: M
158
163
  } } : {}
159
164
  }))], e), []),
160
165
  keypadMode: "language",
161
166
  onChange: (e) => {
162
- typeof e == "string" && (F.current === "pointer" ? u.chain().focus().insertContent(e).run() : u.chain().insertContent(e).run());
167
+ typeof e == "string" && (L.current === "pointer" ? d.chain().focus().insertContent(e).run() : d.chain().insertContent(e).run());
163
168
  },
164
- onDone: () => {
165
- _(), v?.focus();
166
- }
169
+ onDone: k
167
170
  }) })
168
- }), document.body), E && l.createPortal(/* @__PURE__ */ p(r, {
169
- onClose: A,
170
- anchorEl: E.anchorEl,
171
+ }), document.body), D && u.createPortal(/* @__PURE__ */ m(i, {
172
+ onClose: M,
173
+ anchorEl: D.anchorEl,
171
174
  children: [
172
- /* @__PURE__ */ f("div", { children: E.el.label }),
173
- /* @__PURE__ */ f("div", {
175
+ /* @__PURE__ */ p("div", { children: D.el.label }),
176
+ /* @__PURE__ */ p("div", {
174
177
  style: {
175
178
  fontSize: 20,
176
179
  lineHeight: "20px"
177
180
  },
178
- children: E.el.description
181
+ children: D.el.description
179
182
  }),
180
- /* @__PURE__ */ f("div", {
183
+ /* @__PURE__ */ p("div", {
181
184
  style: {
182
185
  fontSize: 20,
183
186
  lineHeight: "20px"
184
187
  },
185
- children: E.el.unicode
188
+ children: D.el.unicode
186
189
  })
187
190
  ]
188
191
  }), document.body)] });
189
192
  }
190
- S.propTypes = {
191
- editor: u.object,
192
- opts: u.object,
193
- onClose: u.func.isRequired,
194
- triggerEl: u.object,
195
- focusOnOpen: u.bool
193
+ C.propTypes = {
194
+ editor: d.object,
195
+ opts: d.object,
196
+ onClose: d.func.isRequired,
197
+ triggerEl: d.object,
198
+ focusOnOpen: d.bool
196
199
  };
197
200
  //#endregion
198
- export { h as CharacterIcon, S as CharacterPicker };
201
+ export { g as CharacterIcon, C as CharacterPicker };
@@ -4,42 +4,43 @@ import { clsx as r } from "../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dis
4
4
  import { logicalAlignment as i, selectionDirection as a } from "../extensions/text-direction.js";
5
5
  import { ToolbarIcon as o } from "./respArea/ToolbarIcon.js";
6
6
  import { writtenLanguage as s } from "../utils/content-languages.js";
7
+ import { returnFocusToText as c } from "../utils/focus.js";
7
8
  import { arabicConfig as ee, spanishConfig as te, specialConfig as ne } from "./characters/characterUtils.js";
8
9
  import re from "./ToolbarDisclosure.js";
9
10
  import ie from "./icons/TextAlign.js";
10
11
  import ae from "./icons/CssIcon.js";
11
- import { AddColumn as oe, AddRow as se, RemoveColumn as ce, RemoveRow as le, RemoveTable as c } from "./icons/TableIcons.js";
12
- import { CharacterIcon as l, CharacterPicker as ue } from "./CharacterPicker.js";
13
- import de, { useEffect as u, useLayoutEffect as fe, useMemo as pe, useRef as me, useState as d } from "react";
12
+ import { AddColumn as oe, AddRow as se, RemoveColumn as ce, RemoveRow as l, RemoveTable as le } from "./icons/TableIcons.js";
13
+ import { CharacterIcon as u, CharacterPicker as ue } from "./CharacterPicker.js";
14
+ import de, { useEffect as d, useLayoutEffect as fe, useMemo as pe, useRef as me, useState as f } from "react";
14
15
  import { useEditorState as he } from "@tiptap/react";
15
- import { styled as f, useTheme as p } from "@mui/material/styles";
16
+ import { styled as p, useTheme as m } from "@mui/material/styles";
16
17
  import { NodeSelection as ge } from "prosemirror-state";
17
- import { color as m } from "@pie-lib/render-ui";
18
+ import { color as h } from "@pie-lib/render-ui";
18
19
  import _e from "@mui/icons-material/Delete";
19
- import h from "@pie-lib/translator";
20
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
20
+ import g from "@pie-lib/translator";
21
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
21
22
  import { inlineSideOfArrow as ve } from "@pie-element/shared-utils";
22
23
  import ye from "@mui/icons-material/FormatBold";
23
- import v from "@mui/icons-material/FormatItalic";
24
- import y from "@mui/icons-material/FormatStrikethrough";
25
- import b from "@mui/icons-material/Code";
26
- import x from "@mui/icons-material/GridOn";
27
- import S from "@mui/icons-material/FormatListBulleted";
28
- import C from "@mui/icons-material/FormatListNumbered";
29
- import w from "@mui/icons-material/FormatUnderlined";
30
- import T from "@mui/icons-material/Functions";
31
- import E from "@mui/icons-material/Image";
32
- import D from "@mui/icons-material/Redo";
33
- import O from "@mui/icons-material/Undo";
34
- import k from "@mui/icons-material/FormatQuote";
35
- import A from "@mui/icons-material/Theaters";
36
- import j from "@mui/icons-material/VolumeUp";
37
- import M from "@mui/icons-material/BorderAll";
38
- import N from "@mui/icons-material/FormatTextdirectionLToR";
39
- import P from "@mui/icons-material/FormatTextdirectionRToL";
40
- import be from "@mui/icons-material/Translate";
24
+ import y from "@mui/icons-material/FormatItalic";
25
+ import b from "@mui/icons-material/FormatStrikethrough";
26
+ import x from "@mui/icons-material/Code";
27
+ import S from "@mui/icons-material/GridOn";
28
+ import C from "@mui/icons-material/FormatListBulleted";
29
+ import w from "@mui/icons-material/FormatListNumbered";
30
+ import T from "@mui/icons-material/FormatUnderlined";
31
+ import E from "@mui/icons-material/Functions";
32
+ import D from "@mui/icons-material/Image";
33
+ import O from "@mui/icons-material/Redo";
34
+ import k from "@mui/icons-material/Undo";
35
+ import A from "@mui/icons-material/FormatQuote";
36
+ import j from "@mui/icons-material/Theaters";
37
+ import M from "@mui/icons-material/VolumeUp";
38
+ import N from "@mui/icons-material/BorderAll";
39
+ import P from "@mui/icons-material/FormatTextdirectionLToR";
40
+ import be from "@mui/icons-material/FormatTextdirectionRToL";
41
+ import xe from "@mui/icons-material/Translate";
41
42
  //#region src/components/MenuBar.tsx
42
- var { translator: F } = h, xe = () => /* @__PURE__ */ g("svg", {
43
+ var { translator: F } = g, Se = () => /* @__PURE__ */ _("svg", {
43
44
  xmlns: "http://www.w3.org/2000/svg",
44
45
  height: "24px",
45
46
  viewBox: "0 0 24 24",
@@ -47,11 +48,11 @@ var { translator: F } = h, xe = () => /* @__PURE__ */ g("svg", {
47
48
  fill: "none",
48
49
  "aria-hidden": "true",
49
50
  focusable: "false",
50
- children: /* @__PURE__ */ g("path", {
51
+ children: /* @__PURE__ */ _("path", {
51
52
  d: "M22,7h-2v1h3v1h-4V7c0-0.55,0.45-1,1-1h2V5h-3V4h3c0.55,0,1,0.45,1,1v1C23,6.55,22.55,7,22,7z M5.88,20h2.66l3.4-5.42h0.12 l3.4,5.42h2.66l-4.65-7.27L17.81,6h-2.68l-3.07,4.99h-0.12L8.85,6H6.19l4.32,6.73L5.88,20z",
52
53
  fill: "currentColor"
53
54
  })
54
- }), Se = () => /* @__PURE__ */ g("svg", {
55
+ }), Ce = () => /* @__PURE__ */ _("svg", {
55
56
  xmlns: "http://www.w3.org/2000/svg",
56
57
  height: "24px",
57
58
  viewBox: "0 0 24 24",
@@ -59,11 +60,11 @@ var { translator: F } = h, xe = () => /* @__PURE__ */ g("svg", {
59
60
  fill: "none",
60
61
  "aria-hidden": "true",
61
62
  focusable: "false",
62
- children: /* @__PURE__ */ g("path", {
63
+ children: /* @__PURE__ */ _("path", {
63
64
  d: "M22,18h-2v1h3v1h-4v-2c0-0.55,0.45-1,1-1h2v-1h-3v-1h3c0.55,0,1,0.45,1,1v1C23,17.55,22.55,18,22,18z M5.88,18h2.66 l3.4-5.42h0.12l3.4,5.42h2.66l-4.65-7.27L17.81,4h-2.68l-3.07,4.99h-0.12L8.85,4H6.19l4.32,6.73L5.88,18z",
64
65
  fill: "currentColor"
65
66
  })
66
- }), Ce = () => /* @__PURE__ */ g("svg", {
67
+ }), we = () => /* @__PURE__ */ _("svg", {
67
68
  width: "30",
68
69
  height: "28",
69
70
  viewBox: "0 0 30 28",
@@ -75,21 +76,21 @@ var { translator: F } = h, xe = () => /* @__PURE__ */ g("svg", {
75
76
  },
76
77
  "aria-hidden": "true",
77
78
  focusable: "false",
78
- children: /* @__PURE__ */ g("path", {
79
+ children: /* @__PURE__ */ _("path", {
79
80
  d: "M27 4V24H29C29.5 24 30 24.5 30 25V27C30 27.5625 29.5 28 29 28H19C18.4375 28 18 27.5625 18 27V25C18 24.5 18.4375 24 19 24H21V16H9V24H11C11.5 24 12 24.5 12 25V27C12 27.5625 11.5 28 11 28H1C0.4375 28 0 27.5625 0 27V25C0 24.5 0.4375 24 1 24H3V4H1C0.4375 4 0 3.5625 0 3V1C0 0.5 0.4375 0 1 0H11C11.5 0 12 0.5 12 1V3C12 3.5625 11.5 4 11 4H9V12H21V4H19C18.4375 4 18 3.5625 18 3V1C18 0.5 18.4375 0 19 0H29C29.5 0 30 0.5 30 1V3C30 3.5625 29.5 4 29 4H27Z",
80
81
  fill: "currentColor"
81
82
  })
82
83
  }), I = (e) => e?.extensionManager?.extensions.find(({ name: e }) => e === "contentLanguage")?.options.languages() ?? [];
83
- function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAreaProps: h, onChange: L, autoWidthToolbar: R, hasFocus: z, language: B }) {
84
- let [V, H] = d(!1), [U, we] = d({
84
+ function L({ editor: t, classes: p, activePlugins: m, toolbarOpts: h, responseAreaProps: g, onChange: L, autoWidthToolbar: R, hasFocus: z, language: B }) {
85
+ let [V, H] = f(!1), [U, Te] = f({
85
86
  el: null,
86
87
  keyboard: !1
87
- }), [W, G] = d(!1), K = me(null), q = (e, t) => {
88
- we({
88
+ }), [W, G] = f(!1), K = me(null), q = (e, t) => {
89
+ Te({
89
90
  el: t?.currentTarget ?? null,
90
91
  keyboard: t?.detail === 0
91
92
  }), H(e);
92
- }, J = m ?? {}, Y = he({
93
+ }, J = h ?? {}, Y = he({
93
94
  editor: t,
94
95
  selector: (e) => {
95
96
  let { selection: t } = e.editor?.state || {}, n;
@@ -137,9 +138,9 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
137
138
  };
138
139
  }
139
140
  }), X = !!R, Z = Y.hideDefaultToolbar && Y.currentNode?.type?.name === "drag_in_the_blank", Q = J.alwaysVisible || z && !W && !Y.toolbarOpened && (!Y.hideDefaultToolbar || Z);
140
- u(() => {
141
+ d(() => {
141
142
  z || G(!1);
142
- }, [z]), u(() => {
143
+ }, [z]), d(() => {
143
144
  if (!W || !t) return;
144
145
  let e = () => G(!1), n = t.view.dom;
145
146
  return t.on("update", e), t.on("selectionUpdate", e), n.addEventListener("mousedown", e), () => {
@@ -148,38 +149,43 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
148
149
  }, [W, t]), fe(() => {
149
150
  K.current?.toggleAttribute("inert", !Q);
150
151
  }, [Q]);
151
- let Te = r(f.toolbar, e, {
152
- [f.toolbarWithNoDone]: !0,
153
- [f.toolbarTop]: J.position === "top",
154
- [f.toolbarRight]: J.alignment === "right",
155
- [f.focused]: Q,
156
- [f.autoWidth]: X,
157
- [f.fullWidth]: !X,
158
- [f.hidden]: J.isHidden === !0
159
- }), Ee = J.minWidth === void 0 ? {} : { minWidth: J.minWidth }, De = (e) => {
160
- let t = ve(e.key, e.currentTarget);
161
- if (!t || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
162
- let n = e.target;
163
- if (n.tagName !== "BUTTON") return;
164
- let r = Array.from(e.currentTarget.querySelectorAll("button:not(:disabled)")).filter((e) => !e.closest("[hidden]")), i = r[r.indexOf(n) + (t === "inline-end" ? 1 : -1)];
165
- i && (e.preventDefault(), i.focus());
166
- }, Oe = (e) => {
152
+ let Ee = r(p.toolbar, e, {
153
+ [p.toolbarWithNoDone]: !0,
154
+ [p.toolbarTop]: J.position === "top",
155
+ [p.toolbarRight]: J.alignment === "right",
156
+ [p.focused]: Q,
157
+ [p.autoWidth]: X,
158
+ [p.fullWidth]: !X,
159
+ [p.hidden]: J.isHidden === !0
160
+ }), De = J.minWidth === void 0 ? {} : { minWidth: J.minWidth }, Oe = (e) => {
161
+ if (e.key === "Escape") {
162
+ if (e.defaultPrevented || !e.currentTarget.contains(e.target)) return;
163
+ e.preventDefault(), e.stopPropagation(), c(t), H(!1);
164
+ return;
165
+ }
166
+ let n = ve(e.key, e.currentTarget);
167
+ if (!n || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
168
+ let r = e.target;
169
+ if (r.tagName !== "BUTTON") return;
170
+ let i = Array.from(e.currentTarget.querySelectorAll("button:not(:disabled)")).filter((e) => !e.closest("[hidden]")), a = i[i.indexOf(r) + (n === "inline-end" ? 1 : -1)];
171
+ a && (e.preventDefault(), a.focus());
172
+ }, ke = (e) => {
167
173
  e.preventDefault();
168
- }, $ = (e) => F.t(`editableHtml.buttons.${e}`, { lng: B }), ke = pe(() => [
174
+ }, $ = (e) => F.t(`editableHtml.buttons.${e}`, { lng: B }), Ae = pe(() => [
169
175
  {
170
- icon: /* @__PURE__ */ g(x, {}),
176
+ icon: /* @__PURE__ */ _(S, {}),
171
177
  label: $("insertTable"),
172
178
  onClick: (e) => e.chain().focus().insertTable({
173
179
  rows: 2,
174
180
  cols: 2,
175
181
  withHeaderRow: !1
176
182
  }).run(),
177
- hidden: (e) => !p?.includes("table") || e.isTable,
183
+ hidden: (e) => !m?.includes("table") || e.isTable,
178
184
  isActive: (e) => e.isTable,
179
185
  isDisabled: (e) => !e.canTable
180
186
  },
181
187
  {
182
- icon: /* @__PURE__ */ g(se, {}),
188
+ icon: /* @__PURE__ */ _(se, {}),
183
189
  label: $("addTableRow"),
184
190
  onClick: (e) => e.chain().focus().addRowAfter().run(),
185
191
  hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
@@ -187,7 +193,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
187
193
  isDisabled: (e) => !e.canTable
188
194
  },
189
195
  {
190
- icon: /* @__PURE__ */ g(le, {}),
196
+ icon: /* @__PURE__ */ _(l, {}),
191
197
  label: $("removeTableRow"),
192
198
  onClick: (e) => e.chain().focus().deleteRow().run(),
193
199
  hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
@@ -195,7 +201,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
195
201
  isDisabled: (e) => !e.canTable
196
202
  },
197
203
  {
198
- icon: /* @__PURE__ */ g(oe, {}),
204
+ icon: /* @__PURE__ */ _(oe, {}),
199
205
  label: $("addTableColumn"),
200
206
  onClick: (e) => e.chain().focus().addColumnAfter().run(),
201
207
  hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
@@ -203,7 +209,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
203
209
  isDisabled: (e) => !e.canTable
204
210
  },
205
211
  {
206
- icon: /* @__PURE__ */ g(ce, {}),
212
+ icon: /* @__PURE__ */ _(ce, {}),
207
213
  label: $("removeTableColumn"),
208
214
  onClick: (e) => e.chain().focus().deleteColumn().run(),
209
215
  hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
@@ -211,7 +217,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
211
217
  isDisabled: (e) => !e.canTable
212
218
  },
213
219
  {
214
- icon: /* @__PURE__ */ g(c, {}),
220
+ icon: /* @__PURE__ */ _(le, {}),
215
221
  label: $("removeTable"),
216
222
  onClick: (e) => e.chain().focus().deleteTable().run(),
217
223
  hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
@@ -219,7 +225,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
219
225
  isDisabled: (e) => !e.canTable
220
226
  },
221
227
  {
222
- icon: /* @__PURE__ */ g(M, {}),
228
+ icon: /* @__PURE__ */ _(N, {}),
223
229
  label: $("tableBorders"),
224
230
  toggle: !0,
225
231
  onClick: (e) => {
@@ -234,156 +240,156 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
234
240
  isDisabled: (e) => !e.canTable
235
241
  },
236
242
  {
237
- icon: /* @__PURE__ */ g(ye, {}),
243
+ icon: /* @__PURE__ */ _(ye, {}),
238
244
  label: $("bold"),
239
245
  toggle: !0,
240
246
  onClick: (e) => e.chain().focus().toggleBold().run(),
241
- hidden: () => !p?.includes("bold"),
247
+ hidden: () => !m?.includes("bold"),
242
248
  isActive: (e) => e.isBold,
243
249
  isDisabled: (e) => !e.canBold
244
250
  },
245
251
  {
246
- icon: /* @__PURE__ */ g(v, {}),
252
+ icon: /* @__PURE__ */ _(y, {}),
247
253
  label: $("italic"),
248
254
  toggle: !0,
249
255
  onClick: (e) => e.chain().focus().toggleItalic().run(),
250
- hidden: () => !p?.includes("italic"),
256
+ hidden: () => !m?.includes("italic"),
251
257
  isActive: (e) => e.isItalic,
252
258
  isDisabled: (e) => !e.canItalic
253
259
  },
254
260
  {
255
- icon: /* @__PURE__ */ g(y, {}),
261
+ icon: /* @__PURE__ */ _(b, {}),
256
262
  label: $("strikethrough"),
257
263
  toggle: !0,
258
264
  onClick: (e) => e.chain().focus().toggleStrike().run(),
259
- hidden: () => !p?.includes("strikethrough"),
265
+ hidden: () => !m?.includes("strikethrough"),
260
266
  isActive: (e) => e.isStrike,
261
267
  isDisabled: (e) => !e.canStrike
262
268
  },
263
269
  {
264
- icon: /* @__PURE__ */ g(b, {}),
270
+ icon: /* @__PURE__ */ _(x, {}),
265
271
  label: $("code"),
266
272
  toggle: !0,
267
273
  onClick: (e) => e.chain().focus().toggleCode().run(),
268
- hidden: () => !p?.includes("code"),
274
+ hidden: () => !m?.includes("code"),
269
275
  isActive: (e) => e.isCode,
270
276
  isDisabled: (e) => !e.canCode
271
277
  },
272
278
  {
273
- icon: /* @__PURE__ */ g(w, {}),
279
+ icon: /* @__PURE__ */ _(T, {}),
274
280
  label: $("underline"),
275
281
  toggle: !0,
276
282
  onClick: (e) => e.chain().focus().toggleUnderline().run(),
277
- hidden: () => !p?.includes("underline"),
283
+ hidden: () => !m?.includes("underline"),
278
284
  isActive: (e) => e.isUnderline
279
285
  },
280
286
  {
281
- icon: /* @__PURE__ */ g(Se, {}),
287
+ icon: /* @__PURE__ */ _(Ce, {}),
282
288
  label: $("subscript"),
283
289
  toggle: !0,
284
290
  onClick: (e) => e.chain().focus().toggleSubscript().run(),
285
- hidden: () => !p?.includes("subscript"),
291
+ hidden: () => !m?.includes("subscript"),
286
292
  isActive: (e) => e.isSubScript
287
293
  },
288
294
  {
289
- icon: /* @__PURE__ */ g(xe, {}),
295
+ icon: /* @__PURE__ */ _(Se, {}),
290
296
  label: $("superscript"),
291
297
  toggle: !0,
292
298
  onClick: (e) => e.chain().focus().toggleSuperscript().run(),
293
- hidden: () => !p?.includes("superscript"),
299
+ hidden: () => !m?.includes("superscript"),
294
300
  isActive: (e) => e.isSuperScript
295
301
  },
296
302
  {
297
- icon: /* @__PURE__ */ g(E, {}),
303
+ icon: /* @__PURE__ */ _(D, {}),
298
304
  label: $("insertImage"),
299
- hidden: () => !p?.includes("image"),
305
+ hidden: () => !m?.includes("image"),
300
306
  onClick: (e) => e.chain().focus().setImageUploadNode().run()
301
307
  },
302
308
  {
303
- icon: /* @__PURE__ */ g(A, {}),
309
+ icon: /* @__PURE__ */ _(j, {}),
304
310
  label: $("insertVideo"),
305
- hidden: () => !p?.includes("video"),
311
+ hidden: () => !m?.includes("video"),
306
312
  onClick: (e) => e.chain().focus().insertMedia({ type: "video" }).run()
307
313
  },
308
314
  {
309
- icon: /* @__PURE__ */ g(j, {}),
315
+ icon: /* @__PURE__ */ _(M, {}),
310
316
  label: $("insertAudio"),
311
- hidden: () => !p?.includes("audio"),
317
+ hidden: () => !m?.includes("audio"),
312
318
  onClick: (e) => e.chain().focus().insertMedia({
313
319
  type: "audio",
314
320
  tag: "audio"
315
321
  }).run()
316
322
  },
317
323
  {
318
- icon: /* @__PURE__ */ g(ae, {}),
324
+ icon: /* @__PURE__ */ _(ae, {}),
319
325
  label: $("cssClasses"),
320
- hidden: () => !p?.includes("css"),
326
+ hidden: () => !m?.includes("css"),
321
327
  onClick: (e) => e.commands.openCSSClassDialog()
322
328
  },
323
329
  {
324
- icon: /* @__PURE__ */ g(k, {}),
330
+ icon: /* @__PURE__ */ _(A, {}),
325
331
  label: $("blockquote"),
326
332
  toggle: !0,
327
- hidden: () => !p?.includes("blockquote"),
333
+ hidden: () => !m?.includes("blockquote"),
328
334
  onClick: (e) => e.chain().focus().toggleBlockquote().run(),
329
335
  isActive: (e) => e.isBlockquote
330
336
  },
331
337
  {
332
- icon: /* @__PURE__ */ g(Ce, {}),
338
+ icon: /* @__PURE__ */ _(we, {}),
333
339
  label: $("heading"),
334
340
  toggle: !0,
335
- hidden: () => !p?.includes("h3"),
341
+ hidden: () => !m?.includes("h3"),
336
342
  onClick: (e) => e.chain().focus().toggleHeadingParagraph().run(),
337
343
  isActive: (e) => e.isHeadingParagraph
338
344
  },
339
345
  {
340
- icon: /* @__PURE__ */ g(T, {}),
346
+ icon: /* @__PURE__ */ _(E, {}),
341
347
  label: $("insertMath"),
342
- hidden: () => !p?.includes("math"),
348
+ hidden: () => !m?.includes("math"),
343
349
  onClick: (e) => e.chain().focus().insertMath("").run()
344
350
  },
345
351
  {
346
- icon: /* @__PURE__ */ g(l, { letter: "ñ" }),
352
+ icon: /* @__PURE__ */ _(u, { letter: "ñ" }),
347
353
  label: $("spanishCharacters"),
348
- hidden: () => !p?.includes("languageCharacters"),
354
+ hidden: () => !m?.includes("languageCharacters"),
349
355
  onClick: (e, t) => q(te, t)
350
356
  },
351
357
  {
352
- icon: /* @__PURE__ */ g(l, { letter: "€" }),
358
+ icon: /* @__PURE__ */ _(u, { letter: "€" }),
353
359
  label: $("specialCharacters"),
354
- hidden: () => p?.filter((e) => e === "languageCharacters").length !== 2,
360
+ hidden: () => m?.filter((e) => e === "languageCharacters").length !== 2,
355
361
  onClick: (e, t) => q(ne, t)
356
362
  },
357
363
  {
358
- icon: /* @__PURE__ */ g(l, { letter: "ع" }),
364
+ icon: /* @__PURE__ */ _(u, { letter: "ع" }),
359
365
  label: $("arabicCharacters"),
360
- hidden: () => !p?.includes("arabicCharacters"),
366
+ hidden: () => !m?.includes("arabicCharacters"),
361
367
  onClick: (e, t) => q(ee, t)
362
368
  },
363
369
  {
364
- hidden: () => !p?.includes("text-align"),
365
- render: (e) => /* @__PURE__ */ g(ie, {
370
+ hidden: () => !m?.includes("text-align"),
371
+ render: (e) => /* @__PURE__ */ _(ie, {
366
372
  editor: t,
367
373
  alignment: e.alignment,
368
374
  direction: e.dir,
369
375
  label: $("textAlignment"),
370
376
  alignmentLabel: (e) => $(`align${e[0].toUpperCase()}${e.slice(1)}`),
371
- className: f.button
377
+ className: p.button
372
378
  })
373
379
  },
374
380
  ...[[
375
381
  "ltr",
376
- /* @__PURE__ */ g(N, {}),
382
+ /* @__PURE__ */ _(P, {}),
377
383
  "leftToRight"
378
384
  ], [
379
385
  "rtl",
380
- /* @__PURE__ */ g(P, {}),
386
+ /* @__PURE__ */ _(be, {}),
381
387
  "rightToLeft"
382
388
  ]].map(([e, t, n]) => ({
383
389
  icon: t,
384
390
  label: $(n),
385
391
  toggle: !0,
386
- hidden: () => !p?.includes("text-direction"),
392
+ hidden: () => !m?.includes("text-direction"),
387
393
  onClick: (t) => {
388
394
  let { rendered: n, pinned: r } = a(t), i = t.chain().focus();
389
395
  (n === e && r ? i.unsetBlockDirection() : i.setBlockDirection(e)).run();
@@ -394,10 +400,10 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
394
400
  hidden: (e) => I(t).length < 2 && !e.contentLanguage,
395
401
  render: (e) => {
396
402
  let n = e.contentLanguage && s(e.contentLanguage), r = I(t), i = r.some(({ value: e }) => s(e) === n);
397
- return /* @__PURE__ */ g(re, {
403
+ return /* @__PURE__ */ _(re, {
398
404
  editor: t,
399
405
  label: $("contentLanguage"),
400
- trigger: /* @__PURE__ */ g(be, {}),
406
+ trigger: /* @__PURE__ */ _(xe, {}),
401
407
  options: [...n && !i ? [{
402
408
  value: e.contentLanguage,
403
409
  label: e.contentLanguage
@@ -410,84 +416,84 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
410
416
  label: $("removeContentLanguage")
411
417
  }] : []),
412
418
  onSelect: (e) => t.chain().focus().setContentLanguage(e).run(),
413
- className: f.button,
419
+ className: p.button,
414
420
  list: !0
415
421
  });
416
422
  }
417
423
  },
418
424
  {
419
- icon: /* @__PURE__ */ g(S, {}),
425
+ icon: /* @__PURE__ */ _(C, {}),
420
426
  label: $("bulletedList"),
421
427
  toggle: !0,
422
- hidden: () => !p?.includes("bulleted-list"),
428
+ hidden: () => !m?.includes("bulleted-list"),
423
429
  onClick: (e) => e.chain().focus().toggleBulletList().run(),
424
430
  isActive: (e) => e.isBulletList
425
431
  },
426
432
  {
427
- icon: /* @__PURE__ */ g(C, {}),
433
+ icon: /* @__PURE__ */ _(w, {}),
428
434
  label: $("numberedList"),
429
435
  toggle: !0,
430
- hidden: () => !p?.includes("numbered-list"),
436
+ hidden: () => !m?.includes("numbered-list"),
431
437
  onClick: (e) => e.chain().focus().toggleOrderedList().run(),
432
438
  isActive: (e) => e.isOrderedList
433
439
  },
434
440
  {
435
- icon: /* @__PURE__ */ g(O, {}),
441
+ icon: /* @__PURE__ */ _(k, {}),
436
442
  label: F.t("common:undo", { lng: B }),
437
- hidden: () => !p?.includes("undo"),
443
+ hidden: () => !m?.includes("undo"),
438
444
  onClick: (e) => e.chain().focus().undo().run(),
439
445
  isDisabled: (e) => !e.canUndo
440
446
  },
441
447
  {
442
- icon: /* @__PURE__ */ g(D, {}),
448
+ icon: /* @__PURE__ */ _(O, {}),
443
449
  label: F.t("graphing.redo", { lng: B }),
444
- hidden: () => !p?.includes("redo"),
450
+ hidden: () => !m?.includes("redo"),
445
451
  onClick: (e) => e.chain().focus().redo().run(),
446
452
  isDisabled: (e) => !e.canRedo
447
453
  }
448
454
  ], [
449
- p,
455
+ m,
450
456
  t,
451
457
  B
452
458
  ]);
453
- return /* @__PURE__ */ _("div", {
459
+ return /* @__PURE__ */ v("div", {
454
460
  ref: K,
455
- className: Te,
456
- style: { ...Ee },
457
- onMouseDown: Oe,
461
+ className: Ee,
462
+ style: { ...De },
463
+ onMouseDown: ke,
458
464
  children: [
459
- Z && /* @__PURE__ */ g("div", {
460
- className: f.defaultToolbar,
465
+ Z && /* @__PURE__ */ _("div", {
466
+ className: p.defaultToolbar,
461
467
  role: "toolbar",
462
468
  tabIndex: -1,
463
469
  "aria-label": F.t("editableHtml.responseAreaToolbar", { lng: B }),
464
- children: /* @__PURE__ */ g("div", {
465
- className: f.buttonsContainer,
466
- children: /* @__PURE__ */ g("button", {
470
+ children: /* @__PURE__ */ _("div", {
471
+ className: p.buttonsContainer,
472
+ children: /* @__PURE__ */ _("button", {
467
473
  type: "button",
468
- className: f.button,
474
+ className: p.button,
469
475
  onClick: (e) => {
470
476
  e.preventDefault(), t.chain().focus().deleteSelection().run(), L?.(t.getHTML());
471
477
  },
472
478
  "aria-label": "Delete response area",
473
479
  title: "Delete response area",
474
- children: /* @__PURE__ */ g(_e, {})
480
+ children: /* @__PURE__ */ _(_e, {})
475
481
  })
476
482
  })
477
483
  }),
478
- !Y.hideDefaultToolbar && /* @__PURE__ */ _("div", {
479
- className: f.defaultToolbar,
484
+ !Y.hideDefaultToolbar && /* @__PURE__ */ v("div", {
485
+ className: p.defaultToolbar,
480
486
  role: "toolbar",
481
487
  tabIndex: -1,
482
488
  "aria-label": F.t("editableHtml.toolbar", { lng: B }),
483
- onKeyDown: De,
489
+ onKeyDown: Oe,
484
490
  children: [
485
- /* @__PURE__ */ g("div", {
486
- className: f.buttonsContainer,
487
- children: ke.filter((e) => !e.hidden?.(Y)).map((e, n) => {
488
- if (e.render) return /* @__PURE__ */ g(de.Fragment, { children: e.render(Y) }, n);
491
+ /* @__PURE__ */ _("div", {
492
+ className: p.buttonsContainer,
493
+ children: Ae.filter((e) => !e.hidden?.(Y)).map((e, n) => {
494
+ if (e.render) return /* @__PURE__ */ _(de.Fragment, { children: e.render(Y) }, n);
489
495
  let i = e.isDisabled?.(Y), a = e.isActive?.(Y);
490
- return /* @__PURE__ */ g("button", {
496
+ return /* @__PURE__ */ _("button", {
491
497
  type: "button",
492
498
  disabled: i,
493
499
  "aria-label": e.label,
@@ -496,30 +502,30 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
496
502
  onClick: (n) => {
497
503
  n.preventDefault(), e.onClick(t, n);
498
504
  },
499
- className: r(f.button, { [f.active]: a }),
505
+ className: r(p.button, { [p.active]: a }),
500
506
  children: e.icon
501
507
  }, n);
502
508
  })
503
509
  }),
504
- p?.includes("responseArea") && /* @__PURE__ */ g("button", {
510
+ m?.includes("responseArea") && /* @__PURE__ */ _("button", {
505
511
  type: "button",
506
512
  "aria-label": "Insert response area",
507
513
  title: "Insert response area",
508
514
  onClick: () => {
509
- t.chain().focus().insertResponseArea(h.type).run();
515
+ t.chain().focus().insertResponseArea(g.type).run();
510
516
  },
511
- className: f.button,
512
- children: /* @__PURE__ */ g(o, {})
517
+ className: p.button,
518
+ children: /* @__PURE__ */ _(o, {})
513
519
  }),
514
- J.showDone && /* @__PURE__ */ g(n, {
520
+ J.showDone && /* @__PURE__ */ _(n, {
515
521
  language: B,
516
522
  onClick: (e) => {
517
- L?.(t.getHTML()), e.detail === 0 ? (t.view.focus(), t.commands.focus("end"), G(!0)) : t.commands.blur();
523
+ L?.(t.getHTML()), e.detail === 0 ? (c(t), G(!0)) : t.commands.blur();
518
524
  }
519
525
  })
520
526
  ]
521
527
  }),
522
- V && /* @__PURE__ */ g(ue, {
528
+ V && /* @__PURE__ */ _(ue, {
523
529
  editor: t,
524
530
  triggerEl: U.el,
525
531
  focusOnOpen: U.keyboard,
@@ -534,7 +540,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
534
540
  });
535
541
  }
536
542
  var R = (e) => {
537
- p();
543
+ m();
538
544
  let t = {
539
545
  defaultToolbar: "defaultToolbar",
540
546
  buttonsContainer: "buttonsContainer",
@@ -554,11 +560,11 @@ var R = (e) => {
554
560
  label: "label",
555
561
  shared: "shared"
556
562
  };
557
- return /* @__PURE__ */ g(z, { children: /* @__PURE__ */ g(L, {
563
+ return /* @__PURE__ */ _(z, { children: /* @__PURE__ */ _(L, {
558
564
  ...e,
559
565
  classes: t
560
566
  }) });
561
- }, z = f("div")(() => ({
567
+ }, z = p("div")(() => ({
562
568
  height: 0,
563
569
  overflow: "visible",
564
570
  "& .defaultToolbar": {
@@ -582,14 +588,19 @@ var R = (e) => {
582
588
  width: "24px",
583
589
  height: "24px"
584
590
  },
585
- "&:hover": { color: m.text() },
586
- "&:focus": { outline: `2px solid ${m.buttonFocusOutline()}` }
591
+ "&:hover": { color: h.text() },
592
+ "&:disabled, &:disabled:hover": {
593
+ opacity: .4,
594
+ color: h.disabled(),
595
+ cursor: "not-allowed"
596
+ },
597
+ "&:focus": { outline: `2px solid ${h.buttonFocusOutline()}` }
587
598
  },
588
- "& .active": { color: m.text() },
599
+ "& .active": { color: h.text() },
589
600
  "& .disabled": {
590
601
  opacity: .7,
591
602
  cursor: "not-allowed",
592
- "& :hover": { color: m.disabled() }
603
+ "& :hover": { color: h.disabled() }
593
604
  },
594
605
  "& .isActive": {
595
606
  background: "var(--purple)",
@@ -656,7 +667,7 @@ var R = (e) => {
656
667
  "& .toolbarDisclosureList": {
657
668
  flexDirection: "column",
658
669
  "& .toolbarButton": {
659
- color: m.text(),
670
+ color: h.text(),
660
671
  padding: "4px 8px",
661
672
  whiteSpace: "nowrap"
662
673
  }
@@ -26,10 +26,39 @@ export declare const ZeroWidthSpaceHandlingPlugin: Plugin<any>;
26
26
  export declare const MathNode: Node<any, any>;
27
27
  /**
28
28
  * The math toolbar's viewport left edge. Its inline-start edge meets the anchor's, so it opens
29
- * rightwards in LTR text and leftwards in RTL, and it stays `margin` inside the viewport.
29
+ * rightwards in LTR text and leftwards in RTL, and it stays `margin` inside the visible bounds.
30
30
  */
31
31
  export declare const mathToolbarLeft: (anchor: {
32
32
  left: number;
33
33
  right: number;
34
- }, toolbarWidth: number, rtl: boolean, viewportWidth: number, margin: number) => number;
34
+ }, toolbarWidth: number, rtl: boolean, bounds: {
35
+ left: number;
36
+ right: number;
37
+ }, margin: number) => number;
38
+ type Bounds = {
39
+ top: number;
40
+ bottom: number;
41
+ left: number;
42
+ right: number;
43
+ };
44
+ /**
45
+ * The viewport area in which `el`'s content is visible: the viewport, narrowed by every ancestor
46
+ * (and `el` itself) that clips its overflow, e.g. a scrolling pane below a sticky header.
47
+ * `<body>` is skipped (the browser hands its overflow to the viewport, e.g. MUI's
48
+ * `overflow: hidden` while a dialog is open), and the walk stops at a `position: fixed`
49
+ * element, since nothing above it can clip it.
50
+ */
51
+ export declare const visibleBounds: (el: Element | null) => Bounds;
52
+ /**
53
+ * The math toolbar's viewport top edge. It opens below the anchor when it fits in the visible
54
+ * bounds, otherwise on whichever side of the anchor has more room, staying `margin` inside them.
55
+ */
56
+ export declare const mathToolbarTop: (anchor: {
57
+ top: number;
58
+ bottom: number;
59
+ }, toolbarHeight: number, bounds: {
60
+ top: number;
61
+ bottom: number;
62
+ }, margin: number) => number;
35
63
  export declare const MathNodeView: (props: any) => React.JSX.Element;
64
+ export {};
@@ -168,15 +168,39 @@ var w = /\\left\.\s*|\\right\.\s*/g, T = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, E = {
168
168
  ];
169
169
  },
170
170
  addNodeView() {
171
- return o((e) => /* @__PURE__ */ p(W, {
171
+ return o((e) => /* @__PURE__ */ p(q, {
172
172
  ...e,
173
173
  options: this.options
174
174
  }));
175
175
  }
176
176
  }), U = (e, t, n, r, i) => {
177
177
  let a = n ? e.right - t : e.left;
178
- return Math.max(i, Math.min(a, r - t - i));
179
- }, W = (o) => {
178
+ return Math.max(r.left + i, Math.min(a, r.right - t - i));
179
+ }, W = (e) => [
180
+ "auto",
181
+ "scroll",
182
+ "hidden",
183
+ "clip"
184
+ ].includes(e), G = (e) => {
185
+ let t = {
186
+ top: 0,
187
+ bottom: window.innerHeight,
188
+ left: 0,
189
+ right: window.innerWidth
190
+ };
191
+ for (let n = e; n && n !== document.body && n !== document.documentElement; n = n.parentElement) {
192
+ let { overflowX: e, overflowY: r, position: i } = window.getComputedStyle(n);
193
+ if (W(e) || W(r)) {
194
+ let i = n.getBoundingClientRect();
195
+ W(r) && (t.top = Math.max(t.top, i.top), t.bottom = Math.min(t.bottom, i.bottom)), W(e) && (t.left = Math.max(t.left, i.left), t.right = Math.min(t.right, i.right));
196
+ }
197
+ if (i === "fixed") break;
198
+ }
199
+ return t;
200
+ }, K = (e, t, n, r) => {
201
+ let i = n.bottom - e.bottom - r, a = e.top - n.top - r, o = t <= i || i >= a ? e.bottom : e.top - t;
202
+ return Math.max(n.top + r, Math.min(o, n.bottom - t - r));
203
+ }, q = (o) => {
180
204
  let { node: s, updateAttributes: c, editor: l, selected: u, options: h, getPos: g } = o, [_, v] = i(u), y = r(null), S = r(null), w = r(Date.now()), [T, E] = i({
181
205
  top: 0,
182
206
  left: 0
@@ -211,12 +235,13 @@ var w = /\\left\.\s*|\\right\.\s*/g, T = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, E = {
211
235
  }
212
236
  let e = () => {
213
237
  if (!y.current) return;
214
- let { from: e } = l.state.selection, t = l.view.coordsAtPos(e), n = S.current?.getBoundingClientRect?.(), r = C(S.current ?? l.view.dom), i = n?.height ? n.top : t.top, a = n?.height ? n.bottom : t.bottom ?? t.top, o = y.current.offsetHeight, s = y.current.offsetWidth, c = window.innerHeight - (a + 0) >= o ? a + 0 : i - o - 0;
215
- c = Math.max(8, Math.min(c, window.innerHeight - o - 8));
216
- let u = U(n?.width ? n : t, s, r, window.innerWidth, 8), d = (l._tiptapContainerEl || document.body).getBoundingClientRect();
238
+ let { from: e } = l.state.selection, t = l.view.coordsAtPos(e), n = S.current?.getBoundingClientRect?.(), r = C(S.current ?? l.view.dom), i = n?.height ? n.top : t.top, a = n?.height ? n.bottom : t.bottom ?? t.top, o = y.current.offsetHeight, s = y.current.offsetWidth, c = l._tiptapContainerEl || document.body, u = G(c), d = K({
239
+ top: i,
240
+ bottom: a
241
+ }, o, u, 8), f = U(n?.width ? n : t, s, r, u, 8), p = c.getBoundingClientRect();
217
242
  E({
218
- top: c - d.top,
219
- left: u - d.left
243
+ top: d - p.top,
244
+ left: f - p.left
220
245
  });
221
246
  };
222
247
  e();
@@ -225,22 +250,29 @@ var w = /\\left\.\s*|\\right\.\s*/g, T = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, E = {
225
250
  t = null, e();
226
251
  }));
227
252
  };
228
- return t = requestAnimationFrame(() => {
253
+ t = requestAnimationFrame(() => {
229
254
  t = null, e();
230
- }), window.addEventListener("scroll", n, !0), window.addEventListener("resize", n), () => {
231
- t !== null && cancelAnimationFrame(t), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", n);
255
+ }), window.addEventListener("scroll", n, !0), window.addEventListener("resize", n);
256
+ let r = typeof ResizeObserver > "u" ? null : new ResizeObserver(n);
257
+ return y.current && r?.observe(y.current), () => {
258
+ t !== null && cancelAnimationFrame(t), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", n), r?.disconnect();
232
259
  };
233
260
  }, [l, _]), n(() => {
234
- let e = performance.now(), t = (t) => {
235
- if (t?.timeStamp < e) return;
236
- let n = t?.target, r = (document.querySelectorAll?.("[id^=\"equation-editor-select\"][id*=\"listbox\"], [aria-labelledby=\"equation-editor-label\"][role=\"listbox\"]") || []).length > 0, i = !!(n?.id && n.id.includes("equation-editor-select")) || !!n?.closest?.("[id*=\"equation-editor-select\"]"), a = !!n?.closest?.(`.math-node-${w.current}`);
237
- if (y.current && !y.current.contains(n) && !n?.closest?.("[data-inline-node]") && !r && !i && !a) {
261
+ let e = performance.now(), t = !1, n = () => {
262
+ t = !0;
263
+ }, r = (n) => {
264
+ let r = n?.detail === 0 ? n.timeStamp < e : !t;
265
+ if (t = !1, r) return;
266
+ let i = n?.target, a = (document.querySelectorAll?.("[id^=\"equation-editor-select\"][id*=\"listbox\"], [aria-labelledby=\"equation-editor-label\"][role=\"listbox\"]") || []).length > 0, o = !!(i?.id && i.id.includes("equation-editor-select")) || !!i?.closest?.("[id*=\"equation-editor-select\"]"), c = !!i?.closest?.(`.math-node-${w.current}`);
267
+ if (y.current && !y.current.contains(i) && !i?.closest?.("[data-inline-node]") && !a && !o && !c) {
238
268
  v(!1);
239
- let e = !!l?.view?.dom?.contains(n);
269
+ let e = !!l?.view?.dom?.contains(i);
240
270
  I(s.attrs.latex, { moveCursorAfterNode: !e });
241
271
  }
242
272
  };
243
- return _ ? document.addEventListener("click", t) : document.removeEventListener("click", t), () => document.removeEventListener("click", t);
273
+ return _ && (document.addEventListener("mousedown", n, !0), document.addEventListener("click", r)), () => {
274
+ document.removeEventListener("mousedown", n, !0), document.removeEventListener("click", r);
275
+ };
244
276
  }, [
245
277
  l,
246
278
  _,
@@ -293,4 +325,4 @@ var w = /\\left\.\s*|\\right\.\s*/g, T = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, E = {
293
325
  });
294
326
  };
295
327
  //#endregion
296
- export { R as EnsureTextAfterMathPlugin, H as MathNode, W as MathNodeView, V as ZeroWidthSpaceHandlingPlugin, j as convertLatexToMathMl, A as convertMathMlToLatex, U as mathToolbarLeft, F as sanitizeMathMl };
328
+ export { R as EnsureTextAfterMathPlugin, H as MathNode, q as MathNodeView, V as ZeroWidthSpaceHandlingPlugin, j as convertLatexToMathMl, A as convertMathMlToLatex, U as mathToolbarLeft, K as mathToolbarTop, F as sanitizeMathMl, G as visibleBounds };
@@ -0,0 +1,7 @@
1
+ import type { Editor } from '@tiptap/core';
2
+ /**
3
+ * Puts focus back in the text. The editor keeps its selection while focus is in the toolbar or the
4
+ * character panel, so focusing it without a position puts the cursor back where it was before the
5
+ * user tabbed out of the text.
6
+ */
7
+ export declare const returnFocusToText: (editor: Editor) => void;
@@ -0,0 +1,6 @@
1
+ //#region src/utils/focus.ts
2
+ var e = (e) => {
3
+ e.view.focus(), e.commands.focus();
4
+ };
5
+ //#endregion
6
+ export { e as returnFocusToText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/editable-html-tip-tap",
3
- "version": "3.1.3-next.20261102140134",
3
+ "version": "3.1.3-next.20261103123052",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,11 +14,11 @@
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
16
  "@pie-framework/mathml-to-latex": "1.4.4",
17
- "@pie-lib/drag": "5.0.8-next.20261027193325",
18
- "@pie-lib/math-input": "9.0.8-next.20261027193325",
19
- "@pie-lib/math-toolbar": "4.0.8-next.20261027193325",
20
- "@pie-lib/render-ui": "8.0.8-next.20261027193325",
21
- "@pie-lib/translator": "5.0.3-next.20261027184745",
17
+ "@pie-lib/drag": "5.0.8-next.20261103123052",
18
+ "@pie-lib/math-input": "9.0.8-next.20261103123052",
19
+ "@pie-lib/math-toolbar": "4.0.8-next.20261103123052",
20
+ "@pie-lib/render-ui": "8.0.8-next.20261103123052",
21
+ "@pie-lib/translator": "5.0.3-next.20261103123052",
22
22
  "@tiptap/core": "3.32.0",
23
23
  "@tiptap/extension-character-count": "3.32.0",
24
24
  "@tiptap/extension-color": "3.32.0",
@@ -43,12 +43,12 @@
43
43
  "react-portal": "^4.2.0",
44
44
  "tippy.js": "latest",
45
45
  "to-style": "^1.3.3",
46
- "@pie-element/shared-i18n": "0.1.3-next.20261026212738",
46
+ "@pie-element/shared-i18n": "0.1.3-next.20261103123052",
47
47
  "@pie-element/shared-lodash": "0.1.4-next.20261026212738",
48
48
  "@pie-element/shared-utils": "0.1.7-next.20261027193325",
49
49
  "clsx": "^2.1.1",
50
50
  "prosemirror-state": "^1.4.4",
51
- "@pie-element/shared-math-rendering-mathjax": "0.1.9-next.20261026200905",
51
+ "@pie-element/shared-math-rendering-mathjax": "0.1.9-next.20261102164954",
52
52
  "@tiptap/extensions": "3.32.0",
53
53
  "@tiptap/extension-list": "3.32.0",
54
54
  "@tiptap/extension-bubble-menu": "3.32.0",