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