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