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