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