@pie-lib/editable-html-tip-tap 3.1.3-next.20261110094048 → 3.1.3-next.20261110122209
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,64 +1,65 @@
|
|
|
1
1
|
import e from "./characters/custom-popper.js";
|
|
2
2
|
import { arabicConfig as t, spanishConfig as n, specialConfig as r } from "./characters/characterUtils.js";
|
|
3
3
|
import { returnFocusToText as i } from "../utils/focus.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import u from "
|
|
7
|
-
import d from "
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
4
|
+
import { insertTypedCharacter as a } from "../utils/toolbar-typing.js";
|
|
5
|
+
import { useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
6
|
+
import { get as u } from "@pie-element/shared-lodash";
|
|
7
|
+
import d from "react-dom";
|
|
8
|
+
import f from "prop-types";
|
|
9
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
|
+
import { PureToolbar as g } from "@pie-lib/math-toolbar";
|
|
10
11
|
// src/components/CharacterPicker.tsx
|
|
11
|
-
var
|
|
12
|
+
var _ = ({ letter: e }) => /* @__PURE__ */ m("div", {
|
|
12
13
|
style: {
|
|
13
14
|
fontSize: "24px",
|
|
14
15
|
lineHeight: "24px"
|
|
15
16
|
},
|
|
16
17
|
children: e
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
var
|
|
19
|
+
_.propTypes = { letter: f.string };
|
|
20
|
+
var v = [
|
|
20
21
|
"ArrowLeft",
|
|
21
22
|
"ArrowRight",
|
|
22
23
|
"ArrowUp",
|
|
23
24
|
"ArrowDown"
|
|
24
|
-
],
|
|
25
|
+
], y = "button, a[href], input, select, textarea, [contenteditable=\"true\"], [tabindex]", b = (e) => {
|
|
25
26
|
let t = e.tabIndex >= 0, n = !e.disabled, r = !!e.closest("[inert]"), i = e.getClientRects().length > 0;
|
|
26
27
|
return t && n && !r && i;
|
|
27
|
-
},
|
|
28
|
+
}, x = (e) => Array.from(e.querySelectorAll(y)).filter(b), S = (e, t) => (e + t) % t, C = (e, t, n, r) => e[S(t + {
|
|
28
29
|
ArrowLeft: -1,
|
|
29
30
|
ArrowRight: 1,
|
|
30
31
|
ArrowUp: -r,
|
|
31
32
|
ArrowDown: r
|
|
32
33
|
}[n], e.length)];
|
|
33
|
-
function
|
|
34
|
-
if (!
|
|
35
|
-
let
|
|
34
|
+
function w({ editor: f, opts: _, onClose: y, triggerEl: b, focusOnOpen: S }) {
|
|
35
|
+
if (!_?.characters?.length) return null;
|
|
36
|
+
let w = c(null), T = c(y), [E, D] = l({
|
|
36
37
|
top: 0,
|
|
37
38
|
left: 0
|
|
38
|
-
}), [
|
|
39
|
-
|
|
40
|
-
let
|
|
41
|
-
i(
|
|
42
|
-
},
|
|
43
|
-
if (!
|
|
39
|
+
}), [O, k] = l(null);
|
|
40
|
+
T.current = y;
|
|
41
|
+
let A = () => {
|
|
42
|
+
i(f), T.current();
|
|
43
|
+
}, j = s(() => {
|
|
44
|
+
if (!_) return n;
|
|
44
45
|
switch (!0) {
|
|
45
|
-
case
|
|
46
|
-
case
|
|
47
|
-
case
|
|
48
|
-
default: return
|
|
46
|
+
case _.language === "spanish": return n;
|
|
47
|
+
case _.language === "special": return r;
|
|
48
|
+
case _.language === "arabic": return t;
|
|
49
|
+
default: return _;
|
|
49
50
|
}
|
|
50
|
-
}, [
|
|
51
|
-
rows:
|
|
51
|
+
}, [_]), M = s(() => j.characters.reduce((e, t) => (t.length >= e.columns && (e.columns = t.length), e), {
|
|
52
|
+
rows: j.characters.length,
|
|
52
53
|
columns: 0
|
|
53
|
-
}), [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, []),
|
|
57
|
-
if (!
|
|
58
|
-
let e =
|
|
59
|
-
if (!
|
|
60
|
-
let t = e.getBoundingClientRect(), { from: n } =
|
|
61
|
-
o = Math.max(8, Math.min(o, window.innerHeight - i - 8)), s = Math.max(8, Math.min(s, window.innerWidth - a - 8)),
|
|
54
|
+
}), [j]), N = () => k(null);
|
|
55
|
+
o(() => () => {
|
|
56
|
+
N();
|
|
57
|
+
}, []), o(() => {
|
|
58
|
+
if (!f) return;
|
|
59
|
+
let e = f.options.element, t = f.view.dom, n = () => {
|
|
60
|
+
if (!w.current) return;
|
|
61
|
+
let t = e.getBoundingClientRect(), { from: n } = f.state.selection, r = f.view.coordsAtPos(n), i = w.current.offsetHeight, a = w.current.offsetWidth, o = window.innerHeight - (t.bottom + 60) >= i || t.top < i + 80 ? t.bottom + 60 : t.top - i - 20, s = r.left;
|
|
62
|
+
o = Math.max(8, Math.min(o, window.innerHeight - i - 8)), s = Math.max(8, Math.min(s, window.innerWidth - a - 8)), D({
|
|
62
63
|
top: o,
|
|
63
64
|
left: s
|
|
64
65
|
});
|
|
@@ -71,83 +72,87 @@ function C({ editor: d, opts: g, onClose: v, triggerEl: y, focusOnOpen: x }) {
|
|
|
71
72
|
};
|
|
72
73
|
window.addEventListener("scroll", i, !0), window.addEventListener("resize", i);
|
|
73
74
|
let a = (e) => {
|
|
74
|
-
|
|
75
|
+
w.current && !w.current.contains(e.target) && !t.contains(e.target) && T.current();
|
|
75
76
|
}, o = setTimeout(() => {
|
|
76
77
|
document.addEventListener("click", a);
|
|
77
78
|
});
|
|
78
79
|
return () => {
|
|
79
80
|
clearTimeout(o), r !== null && cancelAnimationFrame(r), window.removeEventListener("scroll", i, !0), window.removeEventListener("resize", i), document.removeEventListener("click", a);
|
|
80
81
|
};
|
|
81
|
-
}, [
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
if (!
|
|
85
|
-
let e =
|
|
86
|
-
e && (e.focus(),
|
|
87
|
-
}, [
|
|
88
|
-
if (!
|
|
82
|
+
}, [f]);
|
|
83
|
+
let P = E.top !== 0 || E.left !== 0, F = () => Array.from(w.current?.querySelectorAll("button:not([disabled])") ?? []), I = c(!1);
|
|
84
|
+
o(() => {
|
|
85
|
+
if (!S || !P || I.current) return;
|
|
86
|
+
let e = F()[0];
|
|
87
|
+
e && (e.focus(), I.current = !0);
|
|
88
|
+
}, [S, P]), o(() => {
|
|
89
|
+
if (!b) return;
|
|
89
90
|
let e = (e, t, n) => {
|
|
90
|
-
|
|
91
|
+
C(n, Math.max(0, n.indexOf(t.closest("button"))), e, M.columns || 1)?.focus();
|
|
91
92
|
}, t = () => {
|
|
92
|
-
let e =
|
|
93
|
-
((t === -1 ? null : e[t + 1]) ||
|
|
93
|
+
let e = x(document.body).filter((e) => !w.current.contains(e)), t = e.indexOf(b);
|
|
94
|
+
((t === -1 ? null : e[t + 1]) || b).focus();
|
|
94
95
|
}, n = (n) => {
|
|
95
|
-
if (!
|
|
96
|
-
let r =
|
|
96
|
+
if (!w.current) return;
|
|
97
|
+
let r = F();
|
|
97
98
|
if (!r.length) return;
|
|
98
|
-
let i = n.target,
|
|
99
|
-
if (
|
|
100
|
-
n.preventDefault(), n.stopPropagation(),
|
|
99
|
+
let i = n.target, o = w.current.contains(i), s = r[0], c = r[r.length - 1];
|
|
100
|
+
if (o && n.key === "Escape") {
|
|
101
|
+
n.preventDefault(), n.stopPropagation(), A();
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
|
-
if (
|
|
104
|
+
if (o && v.includes(n.key)) {
|
|
104
105
|
n.preventDefault(), n.stopPropagation(), e(n.key, i, r);
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
108
|
+
if (o && a(f, n)) {
|
|
109
|
+
n.stopPropagation();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
107
112
|
if (n.key !== "Tab") return;
|
|
108
|
-
let
|
|
109
|
-
|
|
113
|
+
let l = i === b && !n.shiftKey, u = i === s && n.shiftKey, d = i === c && !n.shiftKey;
|
|
114
|
+
l ? (n.preventDefault(), s.focus()) : u ? (n.preventDefault(), b.focus()) : d && (n.preventDefault(), t());
|
|
110
115
|
};
|
|
111
116
|
return document.addEventListener("keydown", n, !0), () => document.removeEventListener("keydown", n, !0);
|
|
112
117
|
}, [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
f,
|
|
119
|
+
b,
|
|
120
|
+
M.columns
|
|
116
121
|
]);
|
|
117
|
-
let
|
|
122
|
+
let L = (e, t) => k({
|
|
118
123
|
anchorEl: e.currentTarget,
|
|
119
124
|
el: t
|
|
120
|
-
}),
|
|
121
|
-
return /* @__PURE__ */
|
|
122
|
-
ref:
|
|
125
|
+
}), R = c("keyboard");
|
|
126
|
+
return /* @__PURE__ */ h(p, { children: [d.createPortal(/* @__PURE__ */ m("div", {
|
|
127
|
+
ref: w,
|
|
123
128
|
className: "insert-character-dialog",
|
|
124
|
-
"data-toolbar-for":
|
|
129
|
+
"data-toolbar-for": f.instanceId,
|
|
125
130
|
onPointerDown: () => {
|
|
126
|
-
|
|
131
|
+
R.current = "pointer";
|
|
127
132
|
},
|
|
128
133
|
onKeyDown: () => {
|
|
129
|
-
|
|
134
|
+
R.current = "keyboard";
|
|
130
135
|
},
|
|
131
136
|
style: {
|
|
132
|
-
visibility:
|
|
137
|
+
visibility: P ? "initial" : "hidden",
|
|
133
138
|
position: "fixed",
|
|
134
|
-
top: `${
|
|
135
|
-
left: `${
|
|
139
|
+
top: `${E.top}px`,
|
|
140
|
+
left: `${E.left}px`,
|
|
136
141
|
maxWidth: "500px",
|
|
137
142
|
zIndex: 1e3
|
|
138
143
|
},
|
|
139
|
-
children: /* @__PURE__ */
|
|
140
|
-
keyPadCharacterRef:
|
|
141
|
-
setKeypadInteraction:
|
|
144
|
+
children: /* @__PURE__ */ m("div", { children: /* @__PURE__ */ m(g, {
|
|
145
|
+
keyPadCharacterRef: _.keyPadCharacterRef,
|
|
146
|
+
setKeypadInteraction: _.setKeypadInteraction,
|
|
142
147
|
noDecimal: !0,
|
|
143
148
|
hideInput: !0,
|
|
144
149
|
noLatexHandling: !0,
|
|
145
150
|
hideDoneButtonBackground: !0,
|
|
146
|
-
layoutForKeyPad:
|
|
147
|
-
additionalKeys:
|
|
148
|
-
name:
|
|
149
|
-
write:
|
|
150
|
-
label:
|
|
151
|
+
layoutForKeyPad: M,
|
|
152
|
+
additionalKeys: j.characters.reduce((e, t) => (e = [...e, ...t.map((e) => ({
|
|
153
|
+
name: u(e, "name") || u(e, "label") || e,
|
|
154
|
+
write: u(e, "write") || e,
|
|
155
|
+
label: u(e, "label") || e,
|
|
151
156
|
category: "character",
|
|
152
157
|
extraClass: "character",
|
|
153
158
|
extraProps: {
|
|
@@ -157,44 +162,44 @@ function C({ editor: d, opts: g, onClose: v, triggerEl: y, focusOnOpen: x }) {
|
|
|
157
162
|
border: "1px solid currentColor"
|
|
158
163
|
}
|
|
159
164
|
},
|
|
160
|
-
...
|
|
161
|
-
onMouseEnter: (t) =>
|
|
162
|
-
onMouseLeave:
|
|
165
|
+
...j.hasPreview ? { actions: {
|
|
166
|
+
onMouseEnter: (t) => L(t, e),
|
|
167
|
+
onMouseLeave: N
|
|
163
168
|
} } : {}
|
|
164
169
|
}))], e), []),
|
|
165
170
|
keypadMode: "language",
|
|
166
171
|
onChange: (e) => {
|
|
167
|
-
typeof e == "string" && (
|
|
172
|
+
typeof e == "string" && (R.current === "pointer" ? f.chain().focus().insertContent(e).run() : f.chain().insertContent(e).run());
|
|
168
173
|
},
|
|
169
|
-
onDone:
|
|
174
|
+
onDone: A
|
|
170
175
|
}) })
|
|
171
|
-
}), document.body),
|
|
172
|
-
onClose:
|
|
173
|
-
anchorEl:
|
|
176
|
+
}), document.body), O && d.createPortal(/* @__PURE__ */ h(e, {
|
|
177
|
+
onClose: N,
|
|
178
|
+
anchorEl: O.anchorEl,
|
|
174
179
|
children: [
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ m("div", { children: O.el.label }),
|
|
181
|
+
/* @__PURE__ */ m("div", {
|
|
177
182
|
style: {
|
|
178
183
|
fontSize: 20,
|
|
179
184
|
lineHeight: "20px"
|
|
180
185
|
},
|
|
181
|
-
children:
|
|
186
|
+
children: O.el.description
|
|
182
187
|
}),
|
|
183
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ m("div", {
|
|
184
189
|
style: {
|
|
185
190
|
fontSize: 20,
|
|
186
191
|
lineHeight: "20px"
|
|
187
192
|
},
|
|
188
|
-
children:
|
|
193
|
+
children: O.el.unicode
|
|
189
194
|
})
|
|
190
195
|
]
|
|
191
196
|
}), document.body)] });
|
|
192
197
|
}
|
|
193
|
-
|
|
194
|
-
editor:
|
|
195
|
-
opts:
|
|
196
|
-
onClose:
|
|
197
|
-
triggerEl:
|
|
198
|
-
focusOnOpen:
|
|
198
|
+
w.propTypes = {
|
|
199
|
+
editor: f.object,
|
|
200
|
+
opts: f.object,
|
|
201
|
+
onClose: f.func.isRequired,
|
|
202
|
+
triggerEl: f.object,
|
|
203
|
+
focusOnOpen: f.bool
|
|
199
204
|
};
|
|
200
|
-
export {
|
|
205
|
+
export { _ as CharacterIcon, w as CharacterPicker };
|
|
@@ -4,22 +4,23 @@ import { ToolbarIcon as r } from "./respArea/ToolbarIcon.js";
|
|
|
4
4
|
import { logicalAlignment as i, selectionDirection as a } from "../extensions/text-direction.js";
|
|
5
5
|
import { writtenLanguage as o } from "../utils/content-languages.js";
|
|
6
6
|
import { returnFocusToText as s } from "../utils/focus.js";
|
|
7
|
-
import {
|
|
8
|
-
import ne from "./
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
7
|
+
import { insertTypedCharacter as ee } from "../utils/toolbar-typing.js";
|
|
8
|
+
import { arabicConfig as te, spanishConfig as ne, specialConfig as re } from "./characters/characterUtils.js";
|
|
9
|
+
import ie from "./icons/TextAlign.js";
|
|
10
|
+
import c from "./ToolbarDisclosure.js";
|
|
11
|
+
import ae from "./icons/CssIcon.js";
|
|
12
|
+
import { AddColumn as oe, AddRow as se, RemoveColumn as ce, RemoveRow as le, RemoveTable as ue } from "./icons/TableIcons.js";
|
|
13
|
+
import { CharacterIcon as l, CharacterPicker as de } from "./CharacterPicker.js";
|
|
14
|
+
import { DoneButton as fe } from "./common/done-button.js";
|
|
15
|
+
import { TOOLBAR_ATTRIBUTE as pe } from "../extensions/inactive-caret.js";
|
|
16
|
+
import { catalogs as me } from "../i18n/index.js";
|
|
17
|
+
import he, { useEffect as u, useLayoutEffect as ge, useMemo as d, useReducer as _e, useRef as ve, useState as f } from "react";
|
|
18
|
+
import { dynamicMessageKey as ye } from "@pie-element/shared-i18n";
|
|
19
|
+
import { useEditorState as be } from "@tiptap/react";
|
|
20
|
+
import { styled as p, useTheme as m } from "@mui/material/styles";
|
|
21
|
+
import { NodeSelection as xe } from "prosemirror-state";
|
|
22
|
+
import { color as h } from "@pie-lib/render-ui";
|
|
23
|
+
import g from "@mui/icons-material/Delete";
|
|
23
24
|
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
24
25
|
import { inlineSideOfArrow as y } from "@pie-element/shared-utils";
|
|
25
26
|
import b from "@mui/icons-material/FormatBold";
|
|
@@ -35,14 +36,14 @@ import k from "@mui/icons-material/Image";
|
|
|
35
36
|
import A from "@mui/icons-material/Redo";
|
|
36
37
|
import j from "@mui/icons-material/Undo";
|
|
37
38
|
import M from "@mui/icons-material/FormatQuote";
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
39
|
+
import Se from "@mui/icons-material/Theaters";
|
|
40
|
+
import Ce from "@mui/icons-material/VolumeUp";
|
|
41
|
+
import we from "@mui/icons-material/BorderAll";
|
|
42
|
+
import Te from "@mui/icons-material/FormatTextdirectionLToR";
|
|
43
|
+
import Ee from "@mui/icons-material/FormatTextdirectionRToL";
|
|
44
|
+
import De from "@mui/icons-material/Translate";
|
|
44
45
|
// src/components/MenuBar.tsx
|
|
45
|
-
var
|
|
46
|
+
var Oe = () => /* @__PURE__ */ _("svg", {
|
|
46
47
|
xmlns: "http://www.w3.org/2000/svg",
|
|
47
48
|
height: "24px",
|
|
48
49
|
viewBox: "0 0 24 24",
|
|
@@ -54,7 +55,7 @@ var Ee = () => /* @__PURE__ */ _("svg", {
|
|
|
54
55
|
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",
|
|
55
56
|
fill: "currentColor"
|
|
56
57
|
})
|
|
57
|
-
}),
|
|
58
|
+
}), N = () => /* @__PURE__ */ _("svg", {
|
|
58
59
|
xmlns: "http://www.w3.org/2000/svg",
|
|
59
60
|
height: "24px",
|
|
60
61
|
viewBox: "0 0 24 24",
|
|
@@ -66,7 +67,7 @@ var Ee = () => /* @__PURE__ */ _("svg", {
|
|
|
66
67
|
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",
|
|
67
68
|
fill: "currentColor"
|
|
68
69
|
})
|
|
69
|
-
}),
|
|
70
|
+
}), ke = () => /* @__PURE__ */ _("svg", {
|
|
70
71
|
width: "30",
|
|
71
72
|
height: "28",
|
|
72
73
|
viewBox: "0 0 30 28",
|
|
@@ -83,21 +84,21 @@ var Ee = () => /* @__PURE__ */ _("svg", {
|
|
|
83
84
|
fill: "currentColor"
|
|
84
85
|
})
|
|
85
86
|
}), P = (e) => e?.extensionManager?.extensions.find(({ name: e }) => e === "contentLanguage")?.options.languages() ?? [];
|
|
86
|
-
function F({ editor: n, classes:
|
|
87
|
-
let [B, V] =
|
|
87
|
+
function F({ editor: n, classes: p, activePlugins: m, toolbarOpts: h, responseAreaProps: F, onChange: I, autoWidthToolbar: L, hasFocus: R, language: z }) {
|
|
88
|
+
let [B, V] = f(!1), [H, Ae] = f({
|
|
88
89
|
el: null,
|
|
89
90
|
keyboard: !1
|
|
90
|
-
}), [U, W] =
|
|
91
|
-
|
|
91
|
+
}), [U, W] = f(!1), [je, Me] = _e((e) => e + 1, 0), G = me.forLocale(z, Me), K = ve(null), q = (e, t) => {
|
|
92
|
+
Ae({
|
|
92
93
|
el: t?.currentTarget ?? null,
|
|
93
94
|
keyboard: t?.detail === 0
|
|
94
95
|
}), V(e);
|
|
95
|
-
}, J =
|
|
96
|
+
}, J = h ?? {}, Y = be({
|
|
96
97
|
editor: n,
|
|
97
98
|
selector: (e) => {
|
|
98
99
|
let { selection: t } = e.editor?.state || {}, n;
|
|
99
100
|
if (!e.editor?.commandManager) return {};
|
|
100
|
-
t instanceof
|
|
101
|
+
t instanceof xe && (n = t.node);
|
|
101
102
|
let r = e.editor?.isActive("math") || e.editor?.isActive("explicit_constructed_response") || e.editor?.isActive("imageUploadNode") || e.editor?.isActive("drag_in_the_blank"), o = t && t.empty === !1 && e.editor.isActive("table"), s = a(e.editor);
|
|
102
103
|
return {
|
|
103
104
|
currentNode: n,
|
|
@@ -140,40 +141,44 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
140
141
|
};
|
|
141
142
|
}
|
|
142
143
|
}), X = !!L, Z = Y.hideDefaultToolbar && Y.currentNode?.type?.name === "drag_in_the_blank", Q = J.alwaysVisible || R && !U && !Y.toolbarOpened && (!Y.hideDefaultToolbar || Z);
|
|
143
|
-
|
|
144
|
+
u(() => {
|
|
144
145
|
R || W(!1);
|
|
145
|
-
}, [R]),
|
|
146
|
+
}, [R]), u(() => {
|
|
146
147
|
if (!U || !n) return;
|
|
147
148
|
let e = () => W(!1), t = n.view.dom;
|
|
148
149
|
return n.on("update", e), n.on("selectionUpdate", e), t.addEventListener("mousedown", e), () => {
|
|
149
150
|
n.off("update", e), n.off("selectionUpdate", e), t.removeEventListener("mousedown", e);
|
|
150
151
|
};
|
|
151
|
-
}, [U, n]),
|
|
152
|
+
}, [U, n]), ge(() => {
|
|
152
153
|
K.current?.toggleAttribute("inert", !Q);
|
|
153
154
|
}, [Q]);
|
|
154
|
-
let
|
|
155
|
-
[
|
|
156
|
-
[
|
|
157
|
-
[
|
|
158
|
-
[
|
|
159
|
-
[
|
|
160
|
-
[
|
|
161
|
-
[
|
|
162
|
-
}),
|
|
155
|
+
let Ne = e(p.toolbar, t, {
|
|
156
|
+
[p.toolbarWithNoDone]: !0,
|
|
157
|
+
[p.toolbarTop]: J.position === "top",
|
|
158
|
+
[p.toolbarRight]: J.alignment === "right",
|
|
159
|
+
[p.focused]: Q,
|
|
160
|
+
[p.autoWidth]: X,
|
|
161
|
+
[p.fullWidth]: !X,
|
|
162
|
+
[p.hidden]: J.isHidden === !0
|
|
163
|
+
}), Pe = J.minWidth === void 0 ? {} : { minWidth: J.minWidth }, Fe = (e) => {
|
|
163
164
|
if (e.key === "Escape") {
|
|
164
165
|
if (e.defaultPrevented || !e.currentTarget.contains(e.target)) return;
|
|
165
166
|
e.preventDefault(), e.stopPropagation(), s(n), V(!1);
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
169
|
+
if (ee(n, e)) {
|
|
170
|
+
e.stopPropagation();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
168
173
|
let t = y(e.key, e.currentTarget);
|
|
169
174
|
if (!t || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
170
175
|
let r = e.target;
|
|
171
176
|
if (r.tagName !== "BUTTON") return;
|
|
172
177
|
let i = Array.from(e.currentTarget.querySelectorAll("button:not(:disabled)")).filter((e) => !e.closest("[hidden]")), a = i[i.indexOf(r) + (t === "inline-end" ? 1 : -1)];
|
|
173
178
|
a && (e.preventDefault(), a.focus());
|
|
174
|
-
},
|
|
179
|
+
}, Ie = (e) => {
|
|
175
180
|
e.preventDefault();
|
|
176
|
-
}, $ = (e) => G.t(
|
|
181
|
+
}, $ = (e) => G.t(ye(`buttons.${e}`)), Le = d(() => [
|
|
177
182
|
{
|
|
178
183
|
icon: /* @__PURE__ */ _(w, {}),
|
|
179
184
|
label: $("insertTable"),
|
|
@@ -182,12 +187,12 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
182
187
|
cols: 2,
|
|
183
188
|
withHeaderRow: !1
|
|
184
189
|
}).run(),
|
|
185
|
-
hidden: (e) => !
|
|
190
|
+
hidden: (e) => !m?.includes("table") || e.isTable,
|
|
186
191
|
isActive: (e) => e.isTable,
|
|
187
192
|
isDisabled: (e) => !e.canTable
|
|
188
193
|
},
|
|
189
194
|
{
|
|
190
|
-
icon: /* @__PURE__ */ _(
|
|
195
|
+
icon: /* @__PURE__ */ _(se, {}),
|
|
191
196
|
label: $("addTableRow"),
|
|
192
197
|
onClick: (e) => e.chain().focus().addRowAfter().run(),
|
|
193
198
|
hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
|
|
@@ -195,7 +200,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
195
200
|
isDisabled: (e) => !e.canTable
|
|
196
201
|
},
|
|
197
202
|
{
|
|
198
|
-
icon: /* @__PURE__ */ _(
|
|
203
|
+
icon: /* @__PURE__ */ _(le, {}),
|
|
199
204
|
label: $("removeTableRow"),
|
|
200
205
|
onClick: (e) => e.chain().focus().deleteRow().run(),
|
|
201
206
|
hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
|
|
@@ -203,7 +208,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
203
208
|
isDisabled: (e) => !e.canTable
|
|
204
209
|
},
|
|
205
210
|
{
|
|
206
|
-
icon: /* @__PURE__ */ _(
|
|
211
|
+
icon: /* @__PURE__ */ _(oe, {}),
|
|
207
212
|
label: $("addTableColumn"),
|
|
208
213
|
onClick: (e) => e.chain().focus().addColumnAfter().run(),
|
|
209
214
|
hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
|
|
@@ -211,7 +216,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
211
216
|
isDisabled: (e) => !e.canTable
|
|
212
217
|
},
|
|
213
218
|
{
|
|
214
|
-
icon: /* @__PURE__ */ _(
|
|
219
|
+
icon: /* @__PURE__ */ _(ce, {}),
|
|
215
220
|
label: $("removeTableColumn"),
|
|
216
221
|
onClick: (e) => e.chain().focus().deleteColumn().run(),
|
|
217
222
|
hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
|
|
@@ -219,7 +224,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
219
224
|
isDisabled: (e) => !e.canTable
|
|
220
225
|
},
|
|
221
226
|
{
|
|
222
|
-
icon: /* @__PURE__ */ _(
|
|
227
|
+
icon: /* @__PURE__ */ _(ue, {}),
|
|
223
228
|
label: $("removeTable"),
|
|
224
229
|
onClick: (e) => e.chain().focus().deleteTable().run(),
|
|
225
230
|
hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
|
|
@@ -227,7 +232,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
227
232
|
isDisabled: (e) => !e.canTable
|
|
228
233
|
},
|
|
229
234
|
{
|
|
230
|
-
icon: /* @__PURE__ */ _(
|
|
235
|
+
icon: /* @__PURE__ */ _(we, {}),
|
|
231
236
|
label: $("tableBorders"),
|
|
232
237
|
toggle: !0,
|
|
233
238
|
onClick: (e) => {
|
|
@@ -246,7 +251,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
246
251
|
label: $("bold"),
|
|
247
252
|
toggle: !0,
|
|
248
253
|
onClick: (e) => e.chain().focus().toggleBold().run(),
|
|
249
|
-
hidden: () => !
|
|
254
|
+
hidden: () => !m?.includes("bold"),
|
|
250
255
|
isActive: (e) => e.isBold,
|
|
251
256
|
isDisabled: (e) => !e.canBold
|
|
252
257
|
},
|
|
@@ -255,7 +260,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
255
260
|
label: $("italic"),
|
|
256
261
|
toggle: !0,
|
|
257
262
|
onClick: (e) => e.chain().focus().toggleItalic().run(),
|
|
258
|
-
hidden: () => !
|
|
263
|
+
hidden: () => !m?.includes("italic"),
|
|
259
264
|
isActive: (e) => e.isItalic,
|
|
260
265
|
isDisabled: (e) => !e.canItalic
|
|
261
266
|
},
|
|
@@ -264,7 +269,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
264
269
|
label: $("strikethrough"),
|
|
265
270
|
toggle: !0,
|
|
266
271
|
onClick: (e) => e.chain().focus().toggleStrike().run(),
|
|
267
|
-
hidden: () => !
|
|
272
|
+
hidden: () => !m?.includes("strikethrough"),
|
|
268
273
|
isActive: (e) => e.isStrike,
|
|
269
274
|
isDisabled: (e) => !e.canStrike
|
|
270
275
|
},
|
|
@@ -273,7 +278,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
273
278
|
label: $("code"),
|
|
274
279
|
toggle: !0,
|
|
275
280
|
onClick: (e) => e.chain().focus().toggleCode().run(),
|
|
276
|
-
hidden: () => !
|
|
281
|
+
hidden: () => !m?.includes("code"),
|
|
277
282
|
isActive: (e) => e.isCode,
|
|
278
283
|
isDisabled: (e) => !e.canCode
|
|
279
284
|
},
|
|
@@ -282,116 +287,116 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
282
287
|
label: $("underline"),
|
|
283
288
|
toggle: !0,
|
|
284
289
|
onClick: (e) => e.chain().focus().toggleUnderline().run(),
|
|
285
|
-
hidden: () => !
|
|
290
|
+
hidden: () => !m?.includes("underline"),
|
|
286
291
|
isActive: (e) => e.isUnderline
|
|
287
292
|
},
|
|
288
293
|
{
|
|
289
|
-
icon: /* @__PURE__ */ _(
|
|
294
|
+
icon: /* @__PURE__ */ _(N, {}),
|
|
290
295
|
label: $("subscript"),
|
|
291
296
|
toggle: !0,
|
|
292
297
|
onClick: (e) => e.chain().focus().toggleSubscript().run(),
|
|
293
|
-
hidden: () => !
|
|
298
|
+
hidden: () => !m?.includes("subscript"),
|
|
294
299
|
isActive: (e) => e.isSubScript
|
|
295
300
|
},
|
|
296
301
|
{
|
|
297
|
-
icon: /* @__PURE__ */ _(
|
|
302
|
+
icon: /* @__PURE__ */ _(Oe, {}),
|
|
298
303
|
label: $("superscript"),
|
|
299
304
|
toggle: !0,
|
|
300
305
|
onClick: (e) => e.chain().focus().toggleSuperscript().run(),
|
|
301
|
-
hidden: () => !
|
|
306
|
+
hidden: () => !m?.includes("superscript"),
|
|
302
307
|
isActive: (e) => e.isSuperScript
|
|
303
308
|
},
|
|
304
309
|
{
|
|
305
310
|
icon: /* @__PURE__ */ _(k, {}),
|
|
306
311
|
label: $("insertImage"),
|
|
307
|
-
hidden: () => !
|
|
312
|
+
hidden: () => !m?.includes("image"),
|
|
308
313
|
onClick: (e) => e.chain().focus().setImageUploadNode().run()
|
|
309
314
|
},
|
|
310
315
|
{
|
|
311
|
-
icon: /* @__PURE__ */ _(
|
|
316
|
+
icon: /* @__PURE__ */ _(Se, {}),
|
|
312
317
|
label: $("insertVideo"),
|
|
313
|
-
hidden: () => !
|
|
318
|
+
hidden: () => !m?.includes("video"),
|
|
314
319
|
onClick: (e) => e.chain().focus().insertMedia({ type: "video" }).run()
|
|
315
320
|
},
|
|
316
321
|
{
|
|
317
|
-
icon: /* @__PURE__ */ _(
|
|
322
|
+
icon: /* @__PURE__ */ _(Ce, {}),
|
|
318
323
|
label: $("insertAudio"),
|
|
319
|
-
hidden: () => !
|
|
324
|
+
hidden: () => !m?.includes("audio"),
|
|
320
325
|
onClick: (e) => e.chain().focus().insertMedia({
|
|
321
326
|
type: "audio",
|
|
322
327
|
tag: "audio"
|
|
323
328
|
}).run()
|
|
324
329
|
},
|
|
325
330
|
{
|
|
326
|
-
icon: /* @__PURE__ */ _(
|
|
331
|
+
icon: /* @__PURE__ */ _(ae, {}),
|
|
327
332
|
label: $("cssClasses"),
|
|
328
|
-
hidden: () => !
|
|
333
|
+
hidden: () => !m?.includes("css"),
|
|
329
334
|
onClick: (e) => e.commands.openCSSClassDialog()
|
|
330
335
|
},
|
|
331
336
|
{
|
|
332
337
|
icon: /* @__PURE__ */ _(M, {}),
|
|
333
338
|
label: $("blockquote"),
|
|
334
339
|
toggle: !0,
|
|
335
|
-
hidden: () => !
|
|
340
|
+
hidden: () => !m?.includes("blockquote"),
|
|
336
341
|
onClick: (e) => e.chain().focus().toggleBlockquote().run(),
|
|
337
342
|
isActive: (e) => e.isBlockquote
|
|
338
343
|
},
|
|
339
344
|
{
|
|
340
|
-
icon: /* @__PURE__ */ _(
|
|
345
|
+
icon: /* @__PURE__ */ _(ke, {}),
|
|
341
346
|
label: $("heading"),
|
|
342
347
|
toggle: !0,
|
|
343
|
-
hidden: () => !
|
|
348
|
+
hidden: () => !m?.includes("h3"),
|
|
344
349
|
onClick: (e) => e.chain().focus().toggleHeadingParagraph().run(),
|
|
345
350
|
isActive: (e) => e.isHeadingParagraph
|
|
346
351
|
},
|
|
347
352
|
{
|
|
348
353
|
icon: /* @__PURE__ */ _(O, {}),
|
|
349
354
|
label: $("insertMath"),
|
|
350
|
-
hidden: () => !
|
|
355
|
+
hidden: () => !m?.includes("math"),
|
|
351
356
|
onClick: (e) => e.chain().focus().insertMath("").run()
|
|
352
357
|
},
|
|
353
358
|
{
|
|
354
|
-
icon: /* @__PURE__ */ _(
|
|
359
|
+
icon: /* @__PURE__ */ _(l, { letter: "ñ" }),
|
|
355
360
|
label: $("spanishCharacters"),
|
|
356
|
-
hidden: () => !
|
|
357
|
-
onClick: (e, t) => q(
|
|
361
|
+
hidden: () => !m?.includes("languageCharacters"),
|
|
362
|
+
onClick: (e, t) => q(ne, t)
|
|
358
363
|
},
|
|
359
364
|
{
|
|
360
|
-
icon: /* @__PURE__ */ _(
|
|
365
|
+
icon: /* @__PURE__ */ _(l, { letter: "€" }),
|
|
361
366
|
label: $("specialCharacters"),
|
|
362
|
-
hidden: () =>
|
|
363
|
-
onClick: (e, t) => q(
|
|
367
|
+
hidden: () => m?.filter((e) => e === "languageCharacters").length !== 2,
|
|
368
|
+
onClick: (e, t) => q(re, t)
|
|
364
369
|
},
|
|
365
370
|
{
|
|
366
|
-
icon: /* @__PURE__ */ _(
|
|
371
|
+
icon: /* @__PURE__ */ _(l, { letter: "ع" }),
|
|
367
372
|
label: $("arabicCharacters"),
|
|
368
|
-
hidden: () => !
|
|
369
|
-
onClick: (e, t) => q(
|
|
373
|
+
hidden: () => !m?.includes("arabicCharacters"),
|
|
374
|
+
onClick: (e, t) => q(te, t)
|
|
370
375
|
},
|
|
371
376
|
{
|
|
372
|
-
hidden: () => !
|
|
373
|
-
render: (e) => /* @__PURE__ */ _(
|
|
377
|
+
hidden: () => !m?.includes("text-align"),
|
|
378
|
+
render: (e) => /* @__PURE__ */ _(ie, {
|
|
374
379
|
editor: n,
|
|
375
380
|
alignment: e.alignment,
|
|
376
381
|
direction: e.dir,
|
|
377
382
|
label: $("textAlignment"),
|
|
378
383
|
alignmentLabel: (e) => $(`align${e[0].toUpperCase()}${e.slice(1)}`),
|
|
379
|
-
className:
|
|
384
|
+
className: p.button
|
|
380
385
|
})
|
|
381
386
|
},
|
|
382
387
|
...[[
|
|
383
388
|
"ltr",
|
|
384
|
-
/* @__PURE__ */ _(
|
|
389
|
+
/* @__PURE__ */ _(Te, {}),
|
|
385
390
|
"leftToRight"
|
|
386
391
|
], [
|
|
387
392
|
"rtl",
|
|
388
|
-
/* @__PURE__ */ _(
|
|
393
|
+
/* @__PURE__ */ _(Ee, {}),
|
|
389
394
|
"rightToLeft"
|
|
390
395
|
]].map(([e, t, n]) => ({
|
|
391
396
|
icon: t,
|
|
392
397
|
label: $(n),
|
|
393
398
|
toggle: !0,
|
|
394
|
-
hidden: () => !
|
|
399
|
+
hidden: () => !m?.includes("text-direction"),
|
|
395
400
|
onClick: (t) => {
|
|
396
401
|
let { rendered: n, pinned: r } = a(t), i = t.chain().focus();
|
|
397
402
|
(n === e && r ? i.unsetBlockDirection() : i.setBlockDirection(e)).run();
|
|
@@ -402,10 +407,10 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
402
407
|
hidden: (e) => P(n).length < 2 && !e.contentLanguage,
|
|
403
408
|
render: (e) => {
|
|
404
409
|
let t = e.contentLanguage && o(e.contentLanguage), r = P(n), i = r.some(({ value: e }) => o(e) === t);
|
|
405
|
-
return /* @__PURE__ */ _(
|
|
410
|
+
return /* @__PURE__ */ _(c, {
|
|
406
411
|
editor: n,
|
|
407
412
|
label: $("contentLanguage"),
|
|
408
|
-
trigger: /* @__PURE__ */ _(
|
|
413
|
+
trigger: /* @__PURE__ */ _(De, {}),
|
|
409
414
|
options: [...t && !i ? [{
|
|
410
415
|
value: e.contentLanguage,
|
|
411
416
|
label: e.contentLanguage
|
|
@@ -418,7 +423,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
418
423
|
label: $("removeContentLanguage")
|
|
419
424
|
}] : []),
|
|
420
425
|
onSelect: (e) => n.chain().focus().setContentLanguage(e).run(),
|
|
421
|
-
className:
|
|
426
|
+
className: p.button,
|
|
422
427
|
list: !0
|
|
423
428
|
});
|
|
424
429
|
}
|
|
@@ -427,7 +432,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
427
432
|
icon: /* @__PURE__ */ _(T, {}),
|
|
428
433
|
label: $("bulletedList"),
|
|
429
434
|
toggle: !0,
|
|
430
|
-
hidden: () => !
|
|
435
|
+
hidden: () => !m?.includes("bulleted-list"),
|
|
431
436
|
onClick: (e) => e.chain().focus().toggleBulletList().run(),
|
|
432
437
|
isActive: (e) => e.isBulletList
|
|
433
438
|
},
|
|
@@ -435,67 +440,67 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
435
440
|
icon: /* @__PURE__ */ _(E, {}),
|
|
436
441
|
label: $("numberedList"),
|
|
437
442
|
toggle: !0,
|
|
438
|
-
hidden: () => !
|
|
443
|
+
hidden: () => !m?.includes("numbered-list"),
|
|
439
444
|
onClick: (e) => e.chain().focus().toggleOrderedList().run(),
|
|
440
445
|
isActive: (e) => e.isOrderedList
|
|
441
446
|
},
|
|
442
447
|
{
|
|
443
448
|
icon: /* @__PURE__ */ _(j, {}),
|
|
444
449
|
label: G.t("buttons.undo"),
|
|
445
|
-
hidden: () => !
|
|
450
|
+
hidden: () => !m?.includes("undo"),
|
|
446
451
|
onClick: (e) => e.chain().focus().undo().run(),
|
|
447
452
|
isDisabled: (e) => !e.canUndo
|
|
448
453
|
},
|
|
449
454
|
{
|
|
450
455
|
icon: /* @__PURE__ */ _(A, {}),
|
|
451
456
|
label: G.t("buttons.redo"),
|
|
452
|
-
hidden: () => !
|
|
457
|
+
hidden: () => !m?.includes("redo"),
|
|
453
458
|
onClick: (e) => e.chain().focus().redo().run(),
|
|
454
459
|
isDisabled: (e) => !e.canRedo
|
|
455
460
|
}
|
|
456
461
|
], [
|
|
457
|
-
|
|
462
|
+
m,
|
|
458
463
|
n,
|
|
459
464
|
G,
|
|
460
|
-
|
|
465
|
+
je
|
|
461
466
|
]);
|
|
462
467
|
return /* @__PURE__ */ v("div", {
|
|
463
468
|
ref: K,
|
|
464
|
-
className:
|
|
465
|
-
style: { ...
|
|
466
|
-
onMouseDown:
|
|
467
|
-
[
|
|
469
|
+
className: Ne,
|
|
470
|
+
style: { ...Pe },
|
|
471
|
+
onMouseDown: Ie,
|
|
472
|
+
[pe]: "",
|
|
468
473
|
children: [
|
|
469
474
|
Z && /* @__PURE__ */ _("div", {
|
|
470
|
-
className:
|
|
475
|
+
className: p.defaultToolbar,
|
|
471
476
|
role: "toolbar",
|
|
472
477
|
tabIndex: -1,
|
|
473
478
|
"aria-label": G.t("responseAreaToolbar"),
|
|
474
479
|
children: /* @__PURE__ */ _("div", {
|
|
475
|
-
className:
|
|
480
|
+
className: p.buttonsContainer,
|
|
476
481
|
children: /* @__PURE__ */ _("button", {
|
|
477
482
|
type: "button",
|
|
478
|
-
className:
|
|
483
|
+
className: p.button,
|
|
479
484
|
onClick: (e) => {
|
|
480
485
|
e.preventDefault(), n.chain().focus().deleteSelection().run(), I?.(n.getHTML());
|
|
481
486
|
},
|
|
482
487
|
"aria-label": "Delete response area",
|
|
483
488
|
title: "Delete response area",
|
|
484
|
-
children: /* @__PURE__ */ _(
|
|
489
|
+
children: /* @__PURE__ */ _(g, {})
|
|
485
490
|
})
|
|
486
491
|
})
|
|
487
492
|
}),
|
|
488
493
|
!Y.hideDefaultToolbar && /* @__PURE__ */ v("div", {
|
|
489
|
-
className:
|
|
494
|
+
className: p.defaultToolbar,
|
|
490
495
|
role: "toolbar",
|
|
491
496
|
tabIndex: -1,
|
|
492
497
|
"aria-label": G.t("toolbar"),
|
|
493
|
-
onKeyDown:
|
|
498
|
+
onKeyDown: Fe,
|
|
494
499
|
children: [
|
|
495
500
|
/* @__PURE__ */ _("div", {
|
|
496
|
-
className:
|
|
497
|
-
children:
|
|
498
|
-
if (t.render) return /* @__PURE__ */ _(
|
|
501
|
+
className: p.buttonsContainer,
|
|
502
|
+
children: Le.filter((e) => !e.hidden?.(Y)).map((t, r) => {
|
|
503
|
+
if (t.render) return /* @__PURE__ */ _(he.Fragment, { children: t.render(Y) }, r);
|
|
499
504
|
let i = t.isDisabled?.(Y), a = t.isActive?.(Y);
|
|
500
505
|
return /* @__PURE__ */ _("button", {
|
|
501
506
|
type: "button",
|
|
@@ -506,22 +511,22 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
506
511
|
onClick: (e) => {
|
|
507
512
|
e.preventDefault(), t.onClick(n, e);
|
|
508
513
|
},
|
|
509
|
-
className: e(
|
|
514
|
+
className: e(p.button, { [p.active]: a }),
|
|
510
515
|
children: t.icon
|
|
511
516
|
}, r);
|
|
512
517
|
})
|
|
513
518
|
}),
|
|
514
|
-
|
|
519
|
+
m?.includes("responseArea") && /* @__PURE__ */ _("button", {
|
|
515
520
|
type: "button",
|
|
516
521
|
"aria-label": "Insert response area",
|
|
517
522
|
title: "Insert response area",
|
|
518
523
|
onClick: () => {
|
|
519
524
|
n.chain().focus().insertResponseArea(F.type).run();
|
|
520
525
|
},
|
|
521
|
-
className:
|
|
526
|
+
className: p.button,
|
|
522
527
|
children: /* @__PURE__ */ _(r, {})
|
|
523
528
|
}),
|
|
524
|
-
J.showDone && /* @__PURE__ */ _(
|
|
529
|
+
J.showDone && /* @__PURE__ */ _(fe, {
|
|
525
530
|
language: z,
|
|
526
531
|
onClick: (e) => {
|
|
527
532
|
I?.(n.getHTML()), e.detail === 0 ? (s(n), W(!0)) : n.commands.blur();
|
|
@@ -529,7 +534,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
529
534
|
})
|
|
530
535
|
]
|
|
531
536
|
}),
|
|
532
|
-
B && /* @__PURE__ */ _(
|
|
537
|
+
B && /* @__PURE__ */ _(de, {
|
|
533
538
|
editor: n,
|
|
534
539
|
triggerEl: H.el,
|
|
535
540
|
focusOnOpen: H.keyboard,
|
|
@@ -544,7 +549,7 @@ function F({ editor: n, classes: m, activePlugins: h, toolbarOpts: g, responseAr
|
|
|
544
549
|
});
|
|
545
550
|
}
|
|
546
551
|
var I = (e) => {
|
|
547
|
-
|
|
552
|
+
m();
|
|
548
553
|
let t = {
|
|
549
554
|
defaultToolbar: "defaultToolbar",
|
|
550
555
|
buttonsContainer: "buttonsContainer",
|
|
@@ -568,7 +573,7 @@ var I = (e) => {
|
|
|
568
573
|
...e,
|
|
569
574
|
classes: t
|
|
570
575
|
}) });
|
|
571
|
-
}, L =
|
|
576
|
+
}, L = p("div")(() => ({
|
|
572
577
|
height: 0,
|
|
573
578
|
overflow: "visible",
|
|
574
579
|
"& .defaultToolbar": {
|
|
@@ -592,19 +597,19 @@ var I = (e) => {
|
|
|
592
597
|
width: "24px",
|
|
593
598
|
height: "24px"
|
|
594
599
|
},
|
|
595
|
-
"&:hover": { color:
|
|
600
|
+
"&:hover": { color: h.text() },
|
|
596
601
|
"&:disabled, &:disabled:hover": {
|
|
597
602
|
opacity: .4,
|
|
598
|
-
color:
|
|
603
|
+
color: h.disabled(),
|
|
599
604
|
cursor: "not-allowed"
|
|
600
605
|
},
|
|
601
|
-
"&:focus": { outline: `2px solid ${
|
|
606
|
+
"&:focus": { outline: `2px solid ${h.buttonFocusOutline()}` }
|
|
602
607
|
},
|
|
603
|
-
"& .active": { color:
|
|
608
|
+
"& .active": { color: h.text() },
|
|
604
609
|
"& .disabled": {
|
|
605
610
|
opacity: .7,
|
|
606
611
|
cursor: "not-allowed",
|
|
607
|
-
"& :hover": { color:
|
|
612
|
+
"& :hover": { color: h.disabled() }
|
|
608
613
|
},
|
|
609
614
|
"& .isActive": {
|
|
610
615
|
background: "var(--purple)",
|
|
@@ -671,7 +676,7 @@ var I = (e) => {
|
|
|
671
676
|
"& .toolbarDisclosureList": {
|
|
672
677
|
flexDirection: "column",
|
|
673
678
|
"& .toolbarButton": {
|
|
674
|
-
color:
|
|
679
|
+
color: h.text(),
|
|
675
680
|
padding: "4px 8px",
|
|
676
681
|
whiteSpace: "nowrap"
|
|
677
682
|
}
|
|
@@ -10,9 +10,11 @@ function s({ editor: s, label: c, trigger: l, options: u, onSelect: d, className
|
|
|
10
10
|
(e?.querySelector("[aria-pressed=\"true\"]") ?? e?.querySelector("button"))?.focus();
|
|
11
11
|
}, [m]), t(() => {
|
|
12
12
|
if (!m || !s) return;
|
|
13
|
-
let e = () => h(!1)
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
let e = () => h(!1), t = () => {
|
|
14
|
+
v.current?.contains(document.activeElement) || e();
|
|
15
|
+
};
|
|
16
|
+
return s.on("selectionUpdate", t), s.on("blur", e), () => {
|
|
17
|
+
s.off("selectionUpdate", t), s.off("blur", e);
|
|
16
18
|
};
|
|
17
19
|
}, [m, s]), /* @__PURE__ */ o("span", {
|
|
18
20
|
className: "toolbarDisclosure",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
/**
|
|
3
|
+
* Typed input (letters, digits, punctuation) while focus is on the formatting toolbar or the
|
|
4
|
+
* character panel goes into the text at the cursor, so a user can mix typing with the panel's
|
|
5
|
+
* buttons. Space, Enter, Tab and the arrows are not characters, so they keep their button and
|
|
6
|
+
* navigation roles. Dead keys report `Dead` and are not handled.
|
|
7
|
+
*
|
|
8
|
+
* Returns true when the key was inserted.
|
|
9
|
+
*/
|
|
10
|
+
export declare const insertTypedCharacter: (editor: Editor, e: KeyboardEvent | React.KeyboardEvent) => boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/utils/toolbar-typing.ts
|
|
2
|
+
var e = (e) => e instanceof HTMLElement && (e.isContentEditable || e.closest("input, textarea, select, [contenteditable=\"true\"]") !== null), t = (t, n) => {
|
|
3
|
+
if (n.defaultPrevented || n.key.length !== 1 || n.key === " " || ("nativeEvent" in n ? n.nativeEvent.isComposing : n.isComposing)) return !1;
|
|
4
|
+
let r = n.getModifierState?.("AltGraph");
|
|
5
|
+
return n.metaKey || !r && (n.ctrlKey || n.altKey) || e(n.target) || !t || !t.isEditable || t.isActive("math") ? !1 : (n.preventDefault(), t.chain().insertContent(n.key).run(), !0);
|
|
6
|
+
};
|
|
7
|
+
export { t as insertTypedCharacter };
|
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.
|
|
3
|
+
"version": "3.1.3-next.20261110122209",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@mui/icons-material": "^7.3.4",
|
|
16
16
|
"@mui/material": "^7.3.4",
|
|
17
17
|
"@pie-framework/mathml-to-latex": "1.4.4",
|
|
18
|
-
"@pie-lib/drag": "5.0.8-next.
|
|
18
|
+
"@pie-lib/drag": "5.0.8-next.20261110122209",
|
|
19
19
|
"@pie-lib/math-input-mathlive": "2.0.1-next.20261110080000",
|
|
20
20
|
"@pie-lib/math-toolbar": "4.0.8-next.20261110080000",
|
|
21
21
|
"@pie-lib/render-ui": "8.0.8-next.20261110080000",
|