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