@logora/debate 0.3.115 → 0.3.116
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,100 +1,106 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
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
|
-
import { $isHeadingNode as P, $createQuoteNode as
|
|
5
|
-
import { $setBlocksType as
|
|
4
|
+
import { $isHeadingNode as P, $createQuoteNode as x } from "@lexical/rich-text";
|
|
5
|
+
import { $setBlocksType as E } 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 f, $isRangeSelection as p, SELECTION_CHANGE_COMMAND as Q, FORMAT_TEXT_COMMAND as V, $createParagraphNode as G } 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
|
-
import { Icon as
|
|
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
|
|
16
|
-
const t =
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
21
|
-
const g = j(
|
|
22
|
-
|
|
14
|
+
const he = (s) => {
|
|
15
|
+
const c = W(), I = 1, [i] = U(), A = X(null), [b, M] = m("paragraph"), [Z, v] = m(null), [w, T] = m(!1), [D, _] = m(!1), [L, S] = m(!1), y = s.hideSubmit && s.hideSourceAction && s.disableRichText, h = z(() => {
|
|
16
|
+
const t = f();
|
|
17
|
+
if (p(t)) {
|
|
18
|
+
const r = t.anchor.getNode(), n = r.getKey() === "root" ? r : r.getTopLevelElementOrThrow(), u = n.getKey();
|
|
19
|
+
if (i.getElementByKey(u) !== null)
|
|
20
|
+
if (v(u), $(n)) {
|
|
21
|
+
const g = j(r, q), B = g ? g.getTag() : n.getTag();
|
|
22
|
+
M(B);
|
|
23
23
|
} else {
|
|
24
|
-
const g = P(
|
|
25
|
-
|
|
24
|
+
const g = P(n) ? n.getTag() : n.getType();
|
|
25
|
+
M(g);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
T(t.hasFormat("bold")), _(t.hasFormat("italic")), S(t.hasFormat("underline"));
|
|
28
28
|
}
|
|
29
|
-
}, [
|
|
29
|
+
}, [i]);
|
|
30
30
|
J(() => H(
|
|
31
|
-
|
|
31
|
+
i.registerUpdateListener(({ editorState: t }) => {
|
|
32
32
|
t.read(() => {
|
|
33
33
|
h();
|
|
34
34
|
});
|
|
35
35
|
}),
|
|
36
|
-
|
|
36
|
+
i.registerCommand(
|
|
37
37
|
Q,
|
|
38
38
|
() => (h(), !1),
|
|
39
|
-
|
|
39
|
+
I
|
|
40
40
|
)
|
|
41
|
-
), [
|
|
42
|
-
const
|
|
41
|
+
), [i, h]);
|
|
42
|
+
const l = (t) => {
|
|
43
43
|
t.preventDefault();
|
|
44
|
-
},
|
|
44
|
+
}, C = () => {
|
|
45
45
|
setTimeout(() => {
|
|
46
|
-
|
|
46
|
+
i.getEditorState().read(() => {
|
|
47
47
|
h();
|
|
48
48
|
});
|
|
49
49
|
}, 0);
|
|
50
|
-
},
|
|
51
|
-
|
|
50
|
+
}, N = (t) => {
|
|
51
|
+
i.getEditorState().read(() => {
|
|
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
|
+
});
|
|
52
58
|
}, O = () => {
|
|
53
|
-
b !== "ol" ?
|
|
59
|
+
b !== "ol" ? i.dispatchCommand(K) : i.dispatchCommand(F), C();
|
|
54
60
|
}, R = () => {
|
|
55
|
-
b !== "quote" ?
|
|
56
|
-
const t =
|
|
57
|
-
if (
|
|
61
|
+
b !== "quote" ? i.update(() => {
|
|
62
|
+
const t = f();
|
|
63
|
+
if (p(t))
|
|
58
64
|
if (t.isCollapsed()) {
|
|
59
|
-
const
|
|
60
|
-
|
|
65
|
+
const n = t.anchor.getNode().getTopLevelElementOrThrow(), u = x();
|
|
66
|
+
n.insertAfter(u), u.selectEnd();
|
|
61
67
|
} else
|
|
62
|
-
|
|
63
|
-
}) :
|
|
64
|
-
const t =
|
|
65
|
-
|
|
66
|
-
}),
|
|
68
|
+
E(t, () => x());
|
|
69
|
+
}) : i.update(() => {
|
|
70
|
+
const t = f();
|
|
71
|
+
p(t) && E(t, () => G());
|
|
72
|
+
}), C();
|
|
67
73
|
};
|
|
68
|
-
return
|
|
74
|
+
return y ? null : /* @__PURE__ */ k(
|
|
69
75
|
"div",
|
|
70
76
|
{
|
|
71
77
|
className: a(e.toolbar, {
|
|
72
|
-
[e.toolbarIsActive]:
|
|
78
|
+
[e.toolbarIsActive]: y ? !1 : s.isActive
|
|
73
79
|
}),
|
|
74
|
-
ref:
|
|
80
|
+
ref: A,
|
|
75
81
|
children: [
|
|
76
|
-
|
|
82
|
+
s.isActive ? !s.disableRichText && /* @__PURE__ */ k(
|
|
77
83
|
"div",
|
|
78
84
|
{
|
|
79
85
|
className: a(e.iconToolbar, {
|
|
80
|
-
[e.shortBar]:
|
|
86
|
+
[e.shortBar]: s.shortBar
|
|
81
87
|
}),
|
|
82
88
|
children: [
|
|
83
89
|
/* @__PURE__ */ o(
|
|
84
90
|
"button",
|
|
85
91
|
{
|
|
86
|
-
onTouchStart:
|
|
87
|
-
onMouseDown:
|
|
88
|
-
onClick: () =>
|
|
92
|
+
onTouchStart: l,
|
|
93
|
+
onMouseDown: l,
|
|
94
|
+
onClick: () => N("bold"),
|
|
89
95
|
type: "button",
|
|
90
|
-
className: a(e.toolbarItem, { [e.active]:
|
|
96
|
+
className: a(e.toolbarItem, { [e.active]: w }),
|
|
91
97
|
"data-testid": "format-bold",
|
|
92
|
-
"aria-label":
|
|
98
|
+
"aria-label": c.formatMessage({
|
|
93
99
|
id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
|
|
94
100
|
defaultMessage: "Make text bold"
|
|
95
101
|
}),
|
|
96
102
|
children: /* @__PURE__ */ o(
|
|
97
|
-
|
|
103
|
+
d,
|
|
98
104
|
{
|
|
99
105
|
name: "bold",
|
|
100
106
|
width: 24,
|
|
@@ -107,19 +113,19 @@ const he = (l) => {
|
|
|
107
113
|
/* @__PURE__ */ o(
|
|
108
114
|
"button",
|
|
109
115
|
{
|
|
110
|
-
onTouchStart:
|
|
111
|
-
onMouseDown:
|
|
112
|
-
onClick: () =>
|
|
116
|
+
onTouchStart: l,
|
|
117
|
+
onMouseDown: l,
|
|
118
|
+
onClick: () => N("italic"),
|
|
113
119
|
type: "button",
|
|
114
120
|
className: a(e.toolbarItem, {
|
|
115
|
-
[e.active]:
|
|
121
|
+
[e.active]: D
|
|
116
122
|
}),
|
|
117
|
-
"aria-label":
|
|
123
|
+
"aria-label": c.formatMessage({
|
|
118
124
|
id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
|
|
119
125
|
defaultMessage: "Make text italic"
|
|
120
126
|
}),
|
|
121
127
|
children: /* @__PURE__ */ o(
|
|
122
|
-
|
|
128
|
+
d,
|
|
123
129
|
{
|
|
124
130
|
name: "italic",
|
|
125
131
|
width: 24,
|
|
@@ -132,19 +138,19 @@ const he = (l) => {
|
|
|
132
138
|
/* @__PURE__ */ o(
|
|
133
139
|
"button",
|
|
134
140
|
{
|
|
135
|
-
onTouchStart:
|
|
136
|
-
onMouseDown:
|
|
137
|
-
onClick: () =>
|
|
141
|
+
onTouchStart: l,
|
|
142
|
+
onMouseDown: l,
|
|
143
|
+
onClick: () => N("underline"),
|
|
138
144
|
type: "button",
|
|
139
145
|
className: a(e.toolbarItem, {
|
|
140
|
-
[e.active]:
|
|
146
|
+
[e.active]: L
|
|
141
147
|
}),
|
|
142
|
-
"aria-label":
|
|
148
|
+
"aria-label": c.formatMessage({
|
|
143
149
|
id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
|
|
144
150
|
defaultMessage: "Underline text"
|
|
145
151
|
}),
|
|
146
152
|
children: /* @__PURE__ */ o(
|
|
147
|
-
|
|
153
|
+
d,
|
|
148
154
|
{
|
|
149
155
|
name: "underline",
|
|
150
156
|
width: 24,
|
|
@@ -157,19 +163,19 @@ const he = (l) => {
|
|
|
157
163
|
/* @__PURE__ */ o(
|
|
158
164
|
"button",
|
|
159
165
|
{
|
|
160
|
-
onTouchStart:
|
|
161
|
-
onMouseDown:
|
|
166
|
+
onTouchStart: l,
|
|
167
|
+
onMouseDown: l,
|
|
162
168
|
onClick: () => R(),
|
|
163
169
|
type: "button",
|
|
164
170
|
className: a(e.toolbarItem, {
|
|
165
171
|
[e.active]: b === "quote"
|
|
166
172
|
}),
|
|
167
|
-
"aria-label":
|
|
173
|
+
"aria-label": c.formatMessage({
|
|
168
174
|
id: "input.text_editor.plugins.toolbar_plugin.blockquote.aria_label",
|
|
169
175
|
defaultMessage: "Add a blockquote"
|
|
170
176
|
}),
|
|
171
177
|
children: /* @__PURE__ */ o(
|
|
172
|
-
|
|
178
|
+
d,
|
|
173
179
|
{
|
|
174
180
|
name: "blockquote",
|
|
175
181
|
width: 24,
|
|
@@ -182,19 +188,19 @@ const he = (l) => {
|
|
|
182
188
|
/* @__PURE__ */ o(
|
|
183
189
|
"button",
|
|
184
190
|
{
|
|
185
|
-
onTouchStart:
|
|
186
|
-
onMouseDown:
|
|
191
|
+
onTouchStart: l,
|
|
192
|
+
onMouseDown: l,
|
|
187
193
|
onClick: () => O(),
|
|
188
194
|
type: "button",
|
|
189
195
|
className: a(e.toolbarItem, {
|
|
190
196
|
[e.active]: b === "ol"
|
|
191
197
|
}),
|
|
192
|
-
"aria-label":
|
|
198
|
+
"aria-label": c.formatMessage({
|
|
193
199
|
id: "input.text_editor.plugins.toolbar_plugin.numbered_list.aria_label",
|
|
194
200
|
defaultMessage: "Insert a numbered list"
|
|
195
201
|
}),
|
|
196
202
|
children: /* @__PURE__ */ o(
|
|
197
|
-
|
|
203
|
+
d,
|
|
198
204
|
{
|
|
199
205
|
name: "orderedList",
|
|
200
206
|
width: 24,
|
|
@@ -204,20 +210,20 @@ const he = (l) => {
|
|
|
204
210
|
)
|
|
205
211
|
}
|
|
206
212
|
),
|
|
207
|
-
!
|
|
213
|
+
!s.hideSourceAction && /* @__PURE__ */ o(
|
|
208
214
|
"button",
|
|
209
215
|
{
|
|
210
|
-
onTouchStart:
|
|
211
|
-
onMouseDown:
|
|
212
|
-
onClick:
|
|
216
|
+
onTouchStart: l,
|
|
217
|
+
onMouseDown: l,
|
|
218
|
+
onClick: s.onAddSource,
|
|
213
219
|
type: "button",
|
|
214
220
|
className: e.toolbarItem,
|
|
215
|
-
"aria-label":
|
|
221
|
+
"aria-label": c.formatMessage({
|
|
216
222
|
id: "input.text_editor.plugins.toolbar_plugin.add_link.aria_label",
|
|
217
223
|
defaultMessage: "Add hyperlink"
|
|
218
224
|
}),
|
|
219
225
|
children: /* @__PURE__ */ o(
|
|
220
|
-
|
|
226
|
+
d,
|
|
221
227
|
{
|
|
222
228
|
name: "link",
|
|
223
229
|
width: 20,
|
|
@@ -230,18 +236,18 @@ const he = (l) => {
|
|
|
230
236
|
]
|
|
231
237
|
}
|
|
232
238
|
) : null,
|
|
233
|
-
/* @__PURE__ */ o("div", { className: e.actionButton, children:
|
|
239
|
+
/* @__PURE__ */ o("div", { className: e.actionButton, children: s.hideSubmit ? null : /* @__PURE__ */ o(
|
|
234
240
|
Y,
|
|
235
241
|
{
|
|
236
242
|
type: "button",
|
|
237
243
|
"data-testid": "submit-button",
|
|
238
|
-
handleClick:
|
|
244
|
+
handleClick: s.onSubmit,
|
|
239
245
|
className: a(e.inputSubmitActionButton, e.submitAction),
|
|
240
|
-
"aria-label":
|
|
246
|
+
"aria-label": c.formatMessage({
|
|
241
247
|
id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
|
|
242
248
|
defaultMessage: "Send message"
|
|
243
249
|
}),
|
|
244
|
-
children: /* @__PURE__ */ o(
|
|
250
|
+
children: /* @__PURE__ */ o(d, { name: "send", width: 20, height: 20 })
|
|
245
251
|
}
|
|
246
252
|
) })
|
|
247
253
|
]
|