@logora/debate 0.3.116 → 0.3.117
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.
|
@@ -2,96 +2,90 @@ import { jsxs as k, jsx as o } from "react/jsx-runtime";
|
|
|
2
2
|
import { $isListNode as $, ListNode as q, INSERT_ORDERED_LIST_COMMAND as K, REMOVE_LIST_COMMAND as F } from "@lexical/list";
|
|
3
3
|
import { useLexicalComposerContext as U } from "@lexical/react/LexicalComposerContext";
|
|
4
4
|
import { $isHeadingNode as P, $createQuoteNode as x } from "@lexical/rich-text";
|
|
5
|
-
import { $setBlocksType as
|
|
5
|
+
import { $setBlocksType as I } from "@lexical/selection";
|
|
6
6
|
import { $getNearestNodeOfType as j, mergeRegister as H } from "@lexical/utils";
|
|
7
7
|
import a from "classnames";
|
|
8
|
-
import { $getSelection as
|
|
8
|
+
import { $getSelection as p, $isRangeSelection as N, SELECTION_CHANGE_COMMAND as Q, FORMAT_TEXT_COMMAND as G, $createParagraphNode as V } from "lexical";
|
|
9
9
|
import { useRef as X, useState as m, useCallback as z, useEffect as J } from "react";
|
|
10
10
|
import { useIntl as W } from "react-intl";
|
|
11
11
|
import e from "./ToolbarPlugin.module.scss.js";
|
|
12
12
|
import { Icon as d } from "../../../icons/icon/Icon.js";
|
|
13
13
|
import { Button as Y } from "../../../action/button/Button.js";
|
|
14
|
-
const he = (
|
|
15
|
-
const c = W(),
|
|
16
|
-
const t =
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
if (v(u), $(
|
|
21
|
-
const g = j(
|
|
14
|
+
const he = (l) => {
|
|
15
|
+
const c = W(), E = 1, [n] = U(), A = X(null), [b, M] = m("paragraph"), [Z, v] = m(null), [w, T] = m(!1), [D, _] = m(!1), [L, y] = m(!1), S = l.hideSubmit && l.hideSourceAction && l.disableRichText, h = z(() => {
|
|
16
|
+
const t = p();
|
|
17
|
+
if (N(t)) {
|
|
18
|
+
const s = t.anchor.getNode(), r = s.getKey() === "root" ? s : s.getTopLevelElementOrThrow(), u = r.getKey();
|
|
19
|
+
if (n.getElementByKey(u) !== null)
|
|
20
|
+
if (v(u), $(r)) {
|
|
21
|
+
const g = j(s, q), B = g ? g.getTag() : r.getTag();
|
|
22
22
|
M(B);
|
|
23
23
|
} else {
|
|
24
|
-
const g = P(
|
|
24
|
+
const g = P(r) ? r.getTag() : r.getType();
|
|
25
25
|
M(g);
|
|
26
26
|
}
|
|
27
|
-
T(t.hasFormat("bold")), _(t.hasFormat("italic")),
|
|
27
|
+
T(t.hasFormat("bold")), _(t.hasFormat("italic")), y(t.hasFormat("underline"));
|
|
28
28
|
}
|
|
29
|
-
}, [
|
|
29
|
+
}, [n]);
|
|
30
30
|
J(() => H(
|
|
31
|
-
|
|
31
|
+
n.registerUpdateListener(({ editorState: t }) => {
|
|
32
32
|
t.read(() => {
|
|
33
33
|
h();
|
|
34
34
|
});
|
|
35
35
|
}),
|
|
36
|
-
|
|
36
|
+
n.registerCommand(
|
|
37
37
|
Q,
|
|
38
38
|
() => (h(), !1),
|
|
39
|
-
|
|
39
|
+
E
|
|
40
40
|
)
|
|
41
|
-
), [
|
|
42
|
-
const
|
|
41
|
+
), [n, h]);
|
|
42
|
+
const i = (t) => {
|
|
43
43
|
t.preventDefault();
|
|
44
44
|
}, C = () => {
|
|
45
45
|
setTimeout(() => {
|
|
46
|
-
|
|
46
|
+
n.getEditorState().read(() => {
|
|
47
47
|
h();
|
|
48
48
|
});
|
|
49
49
|
}, 0);
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
const r = f();
|
|
53
|
-
if (!p(r))
|
|
54
|
-
return;
|
|
55
|
-
const n = !r.hasFormat(t);
|
|
56
|
-
i.dispatchCommand(V, t), t === "bold" && T(n), t === "italic" && _(n), t === "underline" && S(n);
|
|
57
|
-
});
|
|
50
|
+
}, f = (t) => {
|
|
51
|
+
n.dispatchCommand(G, t), t === "bold" && T((s) => !s), t === "italic" && _((s) => !s), t === "underline" && y((s) => !s);
|
|
58
52
|
}, O = () => {
|
|
59
|
-
b !== "ol" ?
|
|
53
|
+
b !== "ol" ? n.dispatchCommand(K) : n.dispatchCommand(F), C();
|
|
60
54
|
}, R = () => {
|
|
61
|
-
b !== "quote" ?
|
|
62
|
-
const t =
|
|
63
|
-
if (
|
|
55
|
+
b !== "quote" ? n.update(() => {
|
|
56
|
+
const t = p();
|
|
57
|
+
if (N(t))
|
|
64
58
|
if (t.isCollapsed()) {
|
|
65
|
-
const
|
|
66
|
-
|
|
59
|
+
const r = t.anchor.getNode().getTopLevelElementOrThrow(), u = x();
|
|
60
|
+
r.insertAfter(u), u.selectEnd();
|
|
67
61
|
} else
|
|
68
|
-
|
|
69
|
-
}) :
|
|
70
|
-
const t =
|
|
71
|
-
|
|
62
|
+
I(t, () => x());
|
|
63
|
+
}) : n.update(() => {
|
|
64
|
+
const t = p();
|
|
65
|
+
N(t) && I(t, () => V());
|
|
72
66
|
}), C();
|
|
73
67
|
};
|
|
74
|
-
return
|
|
68
|
+
return S ? null : /* @__PURE__ */ k(
|
|
75
69
|
"div",
|
|
76
70
|
{
|
|
77
71
|
className: a(e.toolbar, {
|
|
78
|
-
[e.toolbarIsActive]:
|
|
72
|
+
[e.toolbarIsActive]: S ? !1 : l.isActive
|
|
79
73
|
}),
|
|
80
74
|
ref: A,
|
|
81
75
|
children: [
|
|
82
|
-
|
|
76
|
+
l.isActive ? !l.disableRichText && /* @__PURE__ */ k(
|
|
83
77
|
"div",
|
|
84
78
|
{
|
|
85
79
|
className: a(e.iconToolbar, {
|
|
86
|
-
[e.shortBar]:
|
|
80
|
+
[e.shortBar]: l.shortBar
|
|
87
81
|
}),
|
|
88
82
|
children: [
|
|
89
83
|
/* @__PURE__ */ o(
|
|
90
84
|
"button",
|
|
91
85
|
{
|
|
92
|
-
onTouchStart:
|
|
93
|
-
onMouseDown:
|
|
94
|
-
onClick: () =>
|
|
86
|
+
onTouchStart: i,
|
|
87
|
+
onMouseDown: i,
|
|
88
|
+
onClick: () => f("bold"),
|
|
95
89
|
type: "button",
|
|
96
90
|
className: a(e.toolbarItem, { [e.active]: w }),
|
|
97
91
|
"data-testid": "format-bold",
|
|
@@ -113,9 +107,9 @@ const he = (s) => {
|
|
|
113
107
|
/* @__PURE__ */ o(
|
|
114
108
|
"button",
|
|
115
109
|
{
|
|
116
|
-
onTouchStart:
|
|
117
|
-
onMouseDown:
|
|
118
|
-
onClick: () =>
|
|
110
|
+
onTouchStart: i,
|
|
111
|
+
onMouseDown: i,
|
|
112
|
+
onClick: () => f("italic"),
|
|
119
113
|
type: "button",
|
|
120
114
|
className: a(e.toolbarItem, {
|
|
121
115
|
[e.active]: D
|
|
@@ -138,9 +132,9 @@ const he = (s) => {
|
|
|
138
132
|
/* @__PURE__ */ o(
|
|
139
133
|
"button",
|
|
140
134
|
{
|
|
141
|
-
onTouchStart:
|
|
142
|
-
onMouseDown:
|
|
143
|
-
onClick: () =>
|
|
135
|
+
onTouchStart: i,
|
|
136
|
+
onMouseDown: i,
|
|
137
|
+
onClick: () => f("underline"),
|
|
144
138
|
type: "button",
|
|
145
139
|
className: a(e.toolbarItem, {
|
|
146
140
|
[e.active]: L
|
|
@@ -163,8 +157,8 @@ const he = (s) => {
|
|
|
163
157
|
/* @__PURE__ */ o(
|
|
164
158
|
"button",
|
|
165
159
|
{
|
|
166
|
-
onTouchStart:
|
|
167
|
-
onMouseDown:
|
|
160
|
+
onTouchStart: i,
|
|
161
|
+
onMouseDown: i,
|
|
168
162
|
onClick: () => R(),
|
|
169
163
|
type: "button",
|
|
170
164
|
className: a(e.toolbarItem, {
|
|
@@ -188,8 +182,8 @@ const he = (s) => {
|
|
|
188
182
|
/* @__PURE__ */ o(
|
|
189
183
|
"button",
|
|
190
184
|
{
|
|
191
|
-
onTouchStart:
|
|
192
|
-
onMouseDown:
|
|
185
|
+
onTouchStart: i,
|
|
186
|
+
onMouseDown: i,
|
|
193
187
|
onClick: () => O(),
|
|
194
188
|
type: "button",
|
|
195
189
|
className: a(e.toolbarItem, {
|
|
@@ -210,12 +204,12 @@ const he = (s) => {
|
|
|
210
204
|
)
|
|
211
205
|
}
|
|
212
206
|
),
|
|
213
|
-
!
|
|
207
|
+
!l.hideSourceAction && /* @__PURE__ */ o(
|
|
214
208
|
"button",
|
|
215
209
|
{
|
|
216
|
-
onTouchStart:
|
|
217
|
-
onMouseDown:
|
|
218
|
-
onClick:
|
|
210
|
+
onTouchStart: i,
|
|
211
|
+
onMouseDown: i,
|
|
212
|
+
onClick: l.onAddSource,
|
|
219
213
|
type: "button",
|
|
220
214
|
className: e.toolbarItem,
|
|
221
215
|
"aria-label": c.formatMessage({
|
|
@@ -236,12 +230,12 @@ const he = (s) => {
|
|
|
236
230
|
]
|
|
237
231
|
}
|
|
238
232
|
) : null,
|
|
239
|
-
/* @__PURE__ */ o("div", { className: e.actionButton, children:
|
|
233
|
+
/* @__PURE__ */ o("div", { className: e.actionButton, children: l.hideSubmit ? null : /* @__PURE__ */ o(
|
|
240
234
|
Y,
|
|
241
235
|
{
|
|
242
236
|
type: "button",
|
|
243
237
|
"data-testid": "submit-button",
|
|
244
|
-
handleClick:
|
|
238
|
+
handleClick: l.onSubmit,
|
|
245
239
|
className: a(e.inputSubmitActionButton, e.submitAction),
|
|
246
240
|
"aria-label": c.formatMessage({
|
|
247
241
|
id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
|