@pie-lib/editable-html-tip-tap 3.0.5-next.20261012220936 → 3.0.5-next.20261012232454

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.
@@ -11,8 +11,8 @@ import { useLayoutEffect as d, useMemo as ae, useRef as f, useState as p } from
11
11
  import { useEditorState as m } from "@tiptap/react";
12
12
  import { styled as h, useTheme as g } from "@mui/material/styles";
13
13
  import { NodeSelection as _ } from "prosemirror-state";
14
- import oe from "@mui/icons-material/Delete";
15
14
  import { color as v } from "@pie-lib/render-ui";
15
+ import oe from "@mui/icons-material/Delete";
16
16
  import y from "@pie-lib/translator";
17
17
  import { jsx as b, jsxs as x } from "react/jsx-runtime";
18
18
  import S from "@mui/icons-material/FormatBold";
@@ -5,14 +5,10 @@ import { styled as o } from "@mui/material/styles";
5
5
  import { color as s } from "@pie-lib/render-ui";
6
6
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
7
  //#region src/components/TiptapContainer.tsx
8
- var u = o("div", { shouldForwardProp: (e) => ![
9
- "noBorder",
10
- "error",
11
- "highlightShape"
12
- ].includes(e) })(({ theme: e, noBorder: t, error: n, highlightShape: r }) => ({
8
+ var u = o("div", { shouldForwardProp: (e) => !["noBorder", "error"].includes(e) })(({ theme: e, noBorder: t, error: n }) => ({
13
9
  position: "relative",
14
10
  padding: "0px",
15
- border: t ? "none" : `1px solid ${r ? s.borderDark() : s.border()}`,
11
+ border: t ? "none" : `1px solid ${s.borderDark()}`,
16
12
  borderRadius: "4px",
17
13
  cursor: "text",
18
14
  "& [data-slate-editor=\"true\"]": {
@@ -144,7 +140,6 @@ function p(o) {
144
140
  return /* @__PURE__ */ l(u, {
145
141
  noBorder: S && S.noBorder,
146
142
  error: S && S.error,
147
- highlightShape: j,
148
143
  className: o.className,
149
144
  style: {
150
145
  width: N.width,
@@ -1,17 +1,17 @@
1
1
  import "react";
2
2
  import { styled as e } from "@mui/material/styles";
3
3
  import t from "prop-types";
4
- import n from "@mui/material/IconButton";
5
- import { color as r } from "@pie-lib/render-ui";
4
+ import { color as n } from "@pie-lib/render-ui";
5
+ import r from "@mui/material/IconButton";
6
6
  import i from "@mui/icons-material/Check";
7
7
  import a from "@pie-lib/translator";
8
8
  import { jsx as o } from "react/jsx-runtime";
9
9
  //#region src/components/common/done-button.tsx
10
- var { translator: s } = a, c = e(n)({
10
+ var { translator: s } = a, c = e(r)({
11
11
  verticalAlign: "top",
12
12
  width: "28px",
13
13
  height: "28px",
14
- color: `var(--editable-html-toolbar-check, ${r.correctWithIcon()})`,
14
+ color: `var(--editable-html-toolbar-check, ${n.correctWithIcon()})`,
15
15
  padding: "4px"
16
16
  }), l = ({ onClick: e, doneButtonRef: t, language: n }) => /* @__PURE__ */ o(c, {
17
17
  "aria-label": s.t("editableHtml.buttons.done", { lng: n }),
@@ -34,7 +34,7 @@ function m({ n: e, children: a, isDragging: o, isOver: u, dragItem: d, value: p,
34
34
  });
35
35
  } else !u && h && g(null);
36
36
  }, [u, h]);
37
- let y = d && u ? d.value.value : p.value || "\xA0", b = o ? "\xA0" : y, x = b !== "\xA0", S = d && u, C = m ? `2px solid ${s.primaryDark()}` : S ? `1px solid ${s.defaults.BORDER_DARK}` : `1px solid ${s.defaults.BORDER_LIGHT}`;
37
+ let y = d && u ? d.value.value : p.value || "\xA0", b = o ? "\xA0" : y, x = b !== "\xA0", S = d && u, C = m ? `2px solid ${s.primaryDark()}` : `1px solid ${s.defaults.BORDER_DARK}`;
38
38
  return /* @__PURE__ */ l("div", {
39
39
  ref: _,
40
40
  className: m ? "selected" : void 0,
@@ -4,60 +4,61 @@ import n, { useEffect as r, useRef as i, useState as a } from "react";
4
4
  import { NodeViewWrapper as o } from "@tiptap/react";
5
5
  import s from "react-dom";
6
6
  import c from "prop-types";
7
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
+ import { color as l } from "@pie-lib/render-ui";
8
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
8
9
  //#region src/components/respArea/ExplicitConstructedResponse.tsx
9
- var d = (c) => {
10
- let { editor: d, node: f, getPos: p, options: m, selected: h } = c, { attrs: g } = f, { value: _ } = g, { respAreaToolbar: v, error: y } = m, b = p(), [x, S] = a(!1), C = v([f, b], d, () => {}), w = i(null), T;
11
- if (y) {
12
- let e = y(), t = parseInt(g.index, 10);
13
- T = !!e?.[t]?.[0];
10
+ var f = (c) => {
11
+ let { editor: f, node: p, getPos: m, options: h, selected: g } = c, { attrs: _ } = p, { value: v } = _, { respAreaToolbar: y, error: b } = h, x = m(), [S, C] = a(!1), w = y([p, x], f, () => {}), T = i(null), E;
12
+ if (b) {
13
+ let e = b(), t = parseInt(_.index, 10);
14
+ E = !!e?.[t]?.[0];
14
15
  }
15
16
  return r(() => {
16
- let { selection: e } = d.state, t = e.from + f.nodeSize === e.to;
17
- h ? t && S(h) : S(h);
17
+ let { selection: e } = f.state, t = e.from + p.nodeSize === e.to;
18
+ g ? t && C(g) : C(g);
18
19
  }, [
19
- d,
20
20
  f,
21
- h
21
+ p,
22
+ g
22
23
  ]), r(() => {
23
24
  let e = (e) => {
24
- !(e.target.closest(".insert-character-dialog") || e.target.closest("[data-toolbar-for]")) && w.current && !w.current.contains(e.target) && !e.target.closest("[data-inline-node]") && S(!1);
25
+ !(e.target.closest(".insert-character-dialog") || e.target.closest("[data-toolbar-for]")) && T.current && !T.current.contains(e.target) && !e.target.closest("[data-inline-node]") && C(!1);
25
26
  };
26
- return x ? document.addEventListener("mousedown", e) : document.removeEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
27
- }, [x]), /* @__PURE__ */ u(o, {
27
+ return S ? document.addEventListener("mousedown", e) : document.removeEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
28
+ }, [S]), /* @__PURE__ */ d(o, {
28
29
  className: "drag-in-the-blank",
29
- "data-selected": h,
30
+ "data-selected": g,
30
31
  style: {
31
32
  display: "inline-flex",
32
33
  minHeight: "55px",
33
34
  position: "relative",
34
35
  cursor: "pointer"
35
36
  },
36
- children: [/* @__PURE__ */ l("div", {
37
- ...g,
37
+ children: [/* @__PURE__ */ u("div", {
38
+ ..._,
38
39
  style: {
39
40
  display: "inline-flex",
40
41
  width: "100%",
41
42
  minHeight: "46px",
42
43
  height: "46px",
43
44
  backgroundColor: "#FFF",
44
- border: `1px solid ${T ? "red" : "#C0C3CF"}`,
45
+ border: `1px solid ${E ? "red" : l.borderDark()}`,
45
46
  boxSizing: "border-box",
46
47
  borderRadius: "4px",
47
48
  overflow: "hidden",
48
49
  padding: "12px 21px",
49
50
  margin: "0 4px",
50
51
  minWidth: "178px",
51
- visibility: x ? "hidden" : "visible"
52
+ visibility: S ? "hidden" : "visible"
52
53
  },
53
- onClick: () => S(!0),
54
- dangerouslySetInnerHTML: { __html: _ || "<div>&nbsp;</div>" }
55
- }), x && /* @__PURE__ */ u(n.Fragment, { children: [/* @__PURE__ */ l("div", {
56
- ref: w,
54
+ onClick: () => C(!0),
55
+ dangerouslySetInnerHTML: { __html: v || "<div>&nbsp;</div>" }
56
+ }), S && /* @__PURE__ */ d(n.Fragment, { children: [/* @__PURE__ */ u("div", {
57
+ ref: T,
57
58
  className: "absolute z-50 bg-white shadow-lg rounded p-2",
58
59
  style: { zIndex: 1 },
59
- children: /* @__PURE__ */ l(C, {})
60
- }), d._tiptapContainerEl && s.createPortal(/* @__PURE__ */ l(e, {
60
+ children: /* @__PURE__ */ u(w, {})
61
+ }), f._tiptapContainerEl && s.createPortal(/* @__PURE__ */ u(e, {
61
62
  deletable: !0,
62
63
  toolbarOpts: { minWidth: "auto" },
63
64
  autoWidth: !0,
@@ -67,18 +68,18 @@ var d = (c) => {
67
68
  right: 0
68
69
  },
69
70
  onDelete: () => {
70
- let { tr: e } = d.state;
71
- e.delete(b, b + f.nodeSize), t(d, !1), d.view.dispatch(e), S(!1), d.commands.focus();
71
+ let { tr: e } = f.state;
72
+ e.delete(x, x + p.nodeSize), t(f, !1), f.view.dispatch(e), C(!1), f.commands.focus();
72
73
  },
73
74
  showDone: !1
74
- }), d._tiptapContainerEl)] })]
75
+ }), f._tiptapContainerEl)] })]
75
76
  });
76
77
  };
77
- d.propTypes = {
78
+ f.propTypes = {
78
79
  attributes: c.object,
79
80
  error: c.any,
80
81
  value: c.string,
81
82
  isFocused: c.bool
82
83
  };
83
84
  //#endregion
84
- export { d as default };
85
+ export { f as default };
@@ -6,74 +6,75 @@ import { NodeViewWrapper as s } from "@tiptap/react";
6
6
  import { NodeSelection as c } from "prosemirror-state";
7
7
  import l from "react-dom";
8
8
  import u from "prop-types";
9
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
10
- import { renderMath as p } from "@pie-element/shared-math-rendering-mathjax";
9
+ import { color as d } from "@pie-lib/render-ui";
10
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
11
+ import { renderMath as m } from "@pie-element/shared-math-rendering-mathjax";
11
12
  //#region src/components/respArea/InlineDropdown.tsx
12
- var m = (u) => {
13
- let { editor: m, node: h, getPos: g, options: _, selected: v } = u, { attrs: y } = h, { value: b, error: x } = y, S = b || "<div>&nbsp</div>", C = g(), w = a(null), T = a(null), E = a(!1), D = a(null), O = () => m._holdInlineDropdownToolbarIndex != null && String(m._holdInlineDropdownToolbarIndex) === String(h.attrs.index), [k, A] = o(!1), [j, M] = o({
13
+ var h = (u) => {
14
+ let { editor: h, node: g, getPos: _, options: v, selected: y } = u, { attrs: b } = g, { value: x, error: S } = b, C = x || "<div>&nbsp</div>", w = _(), T = a(null), E = a(null), D = a(!1), O = a(null), k = () => h._holdInlineDropdownToolbarIndex != null && String(h._holdInlineDropdownToolbarIndex) === String(g.attrs.index), [A, j] = o(!1), [M, N] = o({
14
15
  top: 0,
15
16
  left: 0
16
- }), N = () => {
17
- O() || (A(!1), _.onInlineDropdownToolbarClose?.(m));
18
- }, P = _.respAreaToolbar([h, C], m, N), F = () => {
19
- let { tr: e } = m.state, t = e.doc.nodeAt(C);
17
+ }), P = () => {
18
+ k() || (j(!1), v.onInlineDropdownToolbarClose?.(h));
19
+ }, F = v.respAreaToolbar([g, w], h, P), I = () => {
20
+ let { tr: e } = h.state, t = e.doc.nodeAt(w);
20
21
  if (!t) return;
21
22
  let { selection: n } = e;
22
- n.from === C && n.to === C + t.nodeSize || (e.setSelection(c.create(e.doc, C)), m.view.dispatch(e));
23
- }, I = () => {
24
- E.current || (_.onToolbarCloseRequest ? (E.current = !0, _.onToolbarCloseRequest([h, C], m, () => {
25
- E.current = !1, delete m._holdInlineDropdownToolbarIndex, N();
23
+ n.from === w && n.to === w + t.nodeSize || (e.setSelection(c.create(e.doc, w)), h.view.dispatch(e));
24
+ }, L = () => {
25
+ D.current || (v.onToolbarCloseRequest ? (D.current = !0, v.onToolbarCloseRequest([g, w], h, () => {
26
+ D.current = !1, delete h._holdInlineDropdownToolbarIndex, P();
26
27
  }, () => {
27
- E.current = !1, delete m._holdInlineDropdownToolbarIndex, A(!0), setTimeout(F, 0);
28
- })) : N());
28
+ D.current = !1, delete h._holdInlineDropdownToolbarIndex, j(!0), setTimeout(I, 0);
29
+ })) : P());
29
30
  };
30
31
  i(() => {
31
- let { selection: e } = m.state, t = e.from + h.nodeSize === e.to;
32
- v ? t && A(!0) : k && I();
32
+ let { selection: e } = h.state, t = e.from + g.nodeSize === e.to;
33
+ y ? t && j(!0) : A && L();
33
34
  }, [
34
- m,
35
35
  h,
36
- v
36
+ g,
37
+ y
37
38
  ]);
38
- let L = (e) => e.clientX > document.documentElement.clientWidth || e.clientY > document.documentElement.clientHeight || e.target === document.documentElement;
39
+ let R = (e) => e.clientX > document.documentElement.clientWidth || e.clientY > document.documentElement.clientHeight || e.target === document.documentElement;
39
40
  return i(() => {
40
- D.current && typeof p == "function" && p(D.current);
41
- }, [b]), i(() => {
42
- let e = document.body.getBoundingClientRect(), { from: t } = m.state.selection, n = m.view.coordsAtPos(t);
43
- M({
41
+ O.current && typeof m == "function" && m(O.current);
42
+ }, [x]), i(() => {
43
+ let e = document.body.getBoundingClientRect(), { from: t } = h.state.selection, n = h.view.coordsAtPos(t);
44
+ N({
44
45
  top: n.top + Math.abs(e.top) + 40,
45
46
  left: n.left
46
47
  });
47
48
  let r = (e) => {
48
- if (L(e)) return;
49
+ if (R(e)) return;
49
50
  let t = e.target.closest("[data-toolbar-for]");
50
- !e.target.closest("[data-inline-dropdown-toolbar]") && (!t || t.dataset.toolbarFor !== T.current?.instanceId) && !m._toolbarOpened && w.current && !w.current.contains(e.target) && !e.target.closest("[data-inline-node]") && I();
51
+ !e.target.closest("[data-inline-dropdown-toolbar]") && (!t || t.dataset.toolbarFor !== E.current?.instanceId) && !h._toolbarOpened && T.current && !T.current.contains(e.target) && !e.target.closest("[data-inline-node]") && L();
51
52
  };
52
- return k ? document.addEventListener("mousedown", r) : document.removeEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
53
- }, [k, h]), /* @__PURE__ */ f(s, {
53
+ return A ? document.addEventListener("mousedown", r) : document.removeEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
54
+ }, [A, g]), /* @__PURE__ */ p(s, {
54
55
  className: "inline-dropdown",
55
- "data-selected": v,
56
+ "data-selected": y,
56
57
  style: {
57
58
  display: "inline-flex",
58
59
  height: "50px",
59
60
  cursor: "pointer"
60
61
  },
61
- children: [/* @__PURE__ */ f("div", {
62
- ref: D,
62
+ children: [/* @__PURE__ */ p("div", {
63
+ ref: O,
63
64
  style: {
64
65
  display: "inline-flex",
65
66
  minWidth: "178px",
66
67
  height: "36px",
67
68
  background: "#FFF",
68
- border: "1px solid #C0C3CF",
69
+ border: `1px solid ${d.borderDark()}`,
69
70
  boxSizing: "border-box",
70
71
  borderRadius: "3px",
71
72
  margin: "0 2px",
72
73
  position: "relative",
73
74
  alignItems: "center"
74
75
  },
75
- onClick: () => A(!0),
76
- children: [/* @__PURE__ */ d("div", {
76
+ onClick: () => j(!0),
77
+ children: [/* @__PURE__ */ f("div", {
77
78
  style: {
78
79
  flex: 1,
79
80
  overflow: "hidden",
@@ -81,14 +82,14 @@ var m = (u) => {
81
82
  whiteSpace: "nowrap",
82
83
  textOverflow: "ellipsis"
83
84
  },
84
- children: /* @__PURE__ */ d("span", {
85
+ children: /* @__PURE__ */ f("span", {
85
86
  style: {
86
87
  display: "inline-block",
87
88
  verticalAlign: "middle"
88
89
  },
89
- dangerouslySetInnerHTML: { __html: S }
90
+ dangerouslySetInnerHTML: { __html: C }
90
91
  })
91
- }), /* @__PURE__ */ d(n, {
92
+ }), /* @__PURE__ */ f(n, {
92
93
  direction: "down",
93
94
  style: {
94
95
  position: "absolute",
@@ -96,12 +97,12 @@ var m = (u) => {
96
97
  right: "5px"
97
98
  }
98
99
  })]
99
- }), k && /* @__PURE__ */ f(r.Fragment, { children: [l.createPortal(/* @__PURE__ */ d("div", {
100
- ref: w,
101
- children: /* @__PURE__ */ d(P, { editorCallback: (e) => {
102
- T.current = e;
100
+ }), A && /* @__PURE__ */ p(r.Fragment, { children: [l.createPortal(/* @__PURE__ */ f("div", {
101
+ ref: T,
102
+ children: /* @__PURE__ */ f(F, { editorCallback: (e) => {
103
+ E.current = e;
103
104
  } })
104
- }), m?._tiptapContainerEl || document.body), m._tiptapContainerEl && l.createPortal(/* @__PURE__ */ d(e, {
105
+ }), h?._tiptapContainerEl || document.body), h._tiptapContainerEl && l.createPortal(/* @__PURE__ */ f(e, {
105
106
  deletable: !0,
106
107
  toolbarOpts: { minWidth: "auto" },
107
108
  autoWidth: !0,
@@ -111,16 +112,16 @@ var m = (u) => {
111
112
  right: 0
112
113
  },
113
114
  onDelete: () => {
114
- let { tr: e } = m.state;
115
- e.delete(C, C + h.nodeSize), t(m, !1), delete m._holdInlineDropdownToolbarIndex, m.view.dispatch(e), A(!1), m.commands.focus();
115
+ let { tr: e } = h.state;
116
+ e.delete(w, w + g.nodeSize), t(h, !1), delete h._holdInlineDropdownToolbarIndex, h.view.dispatch(e), j(!1), h.commands.focus();
116
117
  },
117
118
  showDone: !1
118
- }), m._tiptapContainerEl)] })]
119
+ }), h._tiptapContainerEl)] })]
119
120
  });
120
121
  };
121
- m.propTypes = {
122
+ h.propTypes = {
122
123
  attributes: u.object,
123
124
  selectedItem: u.oneOfType([u.string, u.object])
124
125
  };
125
126
  //#endregion
126
- export { m as default };
127
+ export { h as default };
@@ -8,7 +8,7 @@ import { mq as o } from "@pie-lib/math-input";
8
8
  //#region src/components/respArea/MathTemplated.tsx
9
9
  var s = t("span")(() => ({
10
10
  display: "inline-flex",
11
- border: `1px solid ${r.border()}`,
11
+ border: `1px solid ${r.borderDark()}`,
12
12
  margin: "1px 5px",
13
13
  cursor: "pointer",
14
14
  alignItems: "center",
@@ -20,7 +20,7 @@ var s = t("span")(() => ({
20
20
  background: r.backgroundDark(),
21
21
  color: r.text(),
22
22
  display: "inline-flex",
23
- borderRight: `2px solid ${r.border()}`,
23
+ borderRight: `2px solid ${r.borderDark()}`,
24
24
  boxSizing: "border-box",
25
25
  overflow: "hidden",
26
26
  fontSize: "12px",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/editable-html-tip-tap",
3
- "version": "3.0.5-next.20261012220936",
3
+ "version": "3.0.5-next.20261012232454",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",