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