@logora/debate 0.3.100 → 0.3.102
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,6 +1,6 @@
|
|
|
1
|
-
import { jsx as o, jsxs as l, Fragment as
|
|
1
|
+
import { jsx as o, jsxs as l, Fragment as f } from "react/jsx-runtime";
|
|
2
2
|
import B from "classnames";
|
|
3
|
-
import { useState as
|
|
3
|
+
import { useState as y, useEffect as le, useCallback as ne, Suspense as de, lazy as ce } from "react";
|
|
4
4
|
import { useIntl as pe } from "react-intl";
|
|
5
5
|
import s from "./Argument.module.scss.js";
|
|
6
6
|
import { ReplyFooter as me } from "./ReplyFooter.js";
|
|
@@ -23,18 +23,18 @@ import { Button as Te } from "../../action/button/Button.js";
|
|
|
23
23
|
const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), F = (e) => e?.replace(/ /g, " "), we = ({
|
|
24
24
|
argument: e,
|
|
25
25
|
argumentReplies: n,
|
|
26
|
-
nestingLevel:
|
|
27
|
-
maxNestingLevel:
|
|
28
|
-
groupType:
|
|
29
|
-
groupName:
|
|
30
|
-
positions:
|
|
26
|
+
nestingLevel: _ = 0,
|
|
27
|
+
maxNestingLevel: S = 2,
|
|
28
|
+
groupType: R,
|
|
29
|
+
groupName: T,
|
|
30
|
+
positions: g = [],
|
|
31
31
|
disableLinks: P = !1,
|
|
32
|
-
parentArgument:
|
|
32
|
+
parentArgument: c,
|
|
33
33
|
flashParent: j,
|
|
34
34
|
expandable: G,
|
|
35
|
-
disabled:
|
|
36
|
-
hideFooter:
|
|
37
|
-
hideReplies:
|
|
35
|
+
disabled: b = !1,
|
|
36
|
+
hideFooter: N = !1,
|
|
37
|
+
hideReplies: w,
|
|
38
38
|
vote: H,
|
|
39
39
|
fixedContentHeight: V = !1,
|
|
40
40
|
enableEdition: z = !0,
|
|
@@ -45,7 +45,7 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
45
45
|
replyRedirectUrl: K,
|
|
46
46
|
hideContent: Q = !1
|
|
47
47
|
}) => {
|
|
48
|
-
const
|
|
48
|
+
const a = pe(), { isLoggedIn: W, currentUser: p } = he(), A = p?.moderation_status === "banned", r = fe(), X = ye(), [m, M] = y(!1), [Z, x] = y(!1), [ee, te] = y(!1), L = ue(e), [u, v] = y(), h = D(
|
|
49
49
|
e.content,
|
|
50
50
|
e.language,
|
|
51
51
|
"content",
|
|
@@ -55,54 +55,54 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
55
55
|
e.position?.language,
|
|
56
56
|
"name",
|
|
57
57
|
e.position?.translation_entries
|
|
58
|
-
),
|
|
58
|
+
), I = `argument_${e.id}`, C = e.position && g?.map((t) => t.id).indexOf(e.position.id) + 1;
|
|
59
59
|
le(() => {
|
|
60
60
|
n !== void 0 && ae();
|
|
61
61
|
}, [n]);
|
|
62
62
|
const se = (t) => {
|
|
63
|
-
if (
|
|
64
|
-
const
|
|
65
|
-
|
|
63
|
+
if (I === t) {
|
|
64
|
+
const d = document.getElementById(t);
|
|
65
|
+
d && d.scrollIntoView({ behavior: "smooth" }), x(!0);
|
|
66
66
|
}
|
|
67
|
-
},
|
|
67
|
+
}, U = () => {
|
|
68
68
|
te((t) => !t);
|
|
69
69
|
}, k = () => {
|
|
70
|
-
|
|
70
|
+
M((t) => !t), v([]);
|
|
71
71
|
}, re = (t) => {
|
|
72
|
-
if (!
|
|
72
|
+
if (!u?.find((i) => i.id === t.id))
|
|
73
73
|
return t;
|
|
74
|
-
}, ie = ne((t,
|
|
74
|
+
}, ie = ne((t, i) => /* @__PURE__ */ o(
|
|
75
75
|
_e,
|
|
76
76
|
{
|
|
77
77
|
publisher: t.publisher,
|
|
78
78
|
url: t.source_url,
|
|
79
79
|
title: t.title,
|
|
80
|
-
index:
|
|
80
|
+
index: i
|
|
81
81
|
},
|
|
82
|
-
|
|
82
|
+
i
|
|
83
83
|
), []), ae = () => {
|
|
84
84
|
if (n && Array.isArray(n)) {
|
|
85
85
|
const t = n.filter(
|
|
86
|
-
(
|
|
86
|
+
(i) => i.reply_to_id === e.id
|
|
87
87
|
);
|
|
88
|
-
t.length > 0 && (
|
|
88
|
+
t.length > 0 && (v(t), M(!0));
|
|
89
89
|
}
|
|
90
|
-
},
|
|
90
|
+
}, $ = (t = null) => /* @__PURE__ */ o(
|
|
91
91
|
Ae,
|
|
92
92
|
{
|
|
93
93
|
...t ? { argument: t } : {},
|
|
94
|
-
nestingLevel:
|
|
95
|
-
maxNestingLevel:
|
|
96
|
-
disabled:
|
|
97
|
-
groupName:
|
|
98
|
-
groupType:
|
|
99
|
-
positions:
|
|
94
|
+
nestingLevel: _ + 1,
|
|
95
|
+
maxNestingLevel: S,
|
|
96
|
+
disabled: b,
|
|
97
|
+
groupName: T,
|
|
98
|
+
groupType: R,
|
|
99
|
+
positions: g,
|
|
100
100
|
argumentReplies: n,
|
|
101
101
|
parentArgument: e,
|
|
102
|
-
flashParent: (
|
|
102
|
+
flashParent: (i) => se(`argument_${i}`)
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
|
-
return /* @__PURE__ */ l(ge, { elementId:
|
|
105
|
+
return /* @__PURE__ */ l(ge, { elementId: I, onScroll: () => x(!0), children: [
|
|
106
106
|
/* @__PURE__ */ l(
|
|
107
107
|
"div",
|
|
108
108
|
{
|
|
@@ -112,10 +112,10 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
112
112
|
[s.flash]: Z,
|
|
113
113
|
[s.argumentReply]: e.is_reply === !0
|
|
114
114
|
},
|
|
115
|
-
s[`level-${
|
|
116
|
-
s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") &&
|
|
115
|
+
s[`level-${_}`],
|
|
116
|
+
s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && C}`]
|
|
117
117
|
),
|
|
118
|
-
id:
|
|
118
|
+
id: I,
|
|
119
119
|
children: [
|
|
120
120
|
/* @__PURE__ */ o(
|
|
121
121
|
be,
|
|
@@ -124,7 +124,7 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
124
124
|
author: e.author,
|
|
125
125
|
tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : oe.translatedContent,
|
|
126
126
|
date: e.created_at,
|
|
127
|
-
tagClassName: s[`headerPosition-${
|
|
127
|
+
tagClassName: s[`headerPosition-${C}`],
|
|
128
128
|
disableLinks: P,
|
|
129
129
|
isDeleted: e.is_deleted,
|
|
130
130
|
showModerationFeedback: q ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
|
|
@@ -133,13 +133,13 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
133
133
|
moderationPolicyUrl: r.provider?.userGuideUrl
|
|
134
134
|
}
|
|
135
135
|
),
|
|
136
|
-
e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children:
|
|
136
|
+
e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
|
|
137
137
|
id: "info.deleted_by_user",
|
|
138
138
|
defaultMessage: "Content deleted by the user"
|
|
139
|
-
}) }) : Q ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children:
|
|
139
|
+
}) }) : Q ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
|
|
140
140
|
id: "argument.argument.content_deleted",
|
|
141
141
|
defaultMessage: "This content has been removed."
|
|
142
|
-
}) }) : /* @__PURE__ */ l(
|
|
142
|
+
}) }) : /* @__PURE__ */ l(f, { children: [
|
|
143
143
|
/* @__PURE__ */ l(
|
|
144
144
|
"div",
|
|
145
145
|
{
|
|
@@ -147,21 +147,21 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
147
147
|
[s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? V : !1
|
|
148
148
|
}),
|
|
149
149
|
children: [
|
|
150
|
-
e.is_reply &&
|
|
150
|
+
e.is_reply && c && /* @__PURE__ */ l(
|
|
151
151
|
"div",
|
|
152
152
|
{
|
|
153
153
|
className: s.replyTo,
|
|
154
|
-
onClick: () => j(
|
|
154
|
+
onClick: () => j(c.id),
|
|
155
155
|
children: [
|
|
156
|
-
|
|
156
|
+
a.formatMessage({
|
|
157
157
|
id: "info.replying_to",
|
|
158
158
|
defaultMessage: "Replying to"
|
|
159
159
|
}),
|
|
160
160
|
/* @__PURE__ */ l("span", { className: s.replyingTo, children: [
|
|
161
|
-
|
|
161
|
+
c.is_deleted ? a.formatMessage({
|
|
162
162
|
id: "info.deleted",
|
|
163
163
|
defaultMessage: "Deleted"
|
|
164
|
-
}) :
|
|
164
|
+
}) : c.author.full_name,
|
|
165
165
|
/* @__PURE__ */ o(E, { name: "chat", height: 16 })
|
|
166
166
|
] })
|
|
167
167
|
]
|
|
@@ -170,32 +170,32 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
170
170
|
/* @__PURE__ */ o(
|
|
171
171
|
Me,
|
|
172
172
|
{
|
|
173
|
-
content: /* @__PURE__ */ l(
|
|
174
|
-
e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children:
|
|
173
|
+
content: /* @__PURE__ */ l(f, { children: [
|
|
174
|
+
e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: a.formatMessage({
|
|
175
175
|
id: "argument.argument.updated",
|
|
176
176
|
defaultMessage: "Updated argument"
|
|
177
177
|
}) }),
|
|
178
|
-
|
|
178
|
+
L && !h.isTranslated ? /* @__PURE__ */ o(
|
|
179
179
|
"div",
|
|
180
180
|
{
|
|
181
181
|
className: s.argumentContent,
|
|
182
|
-
dangerouslySetInnerHTML: { __html: F(
|
|
182
|
+
dangerouslySetInnerHTML: { __html: F(L) }
|
|
183
183
|
}
|
|
184
|
-
) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: F(
|
|
185
|
-
|
|
184
|
+
) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: F(h.translatedContent) }),
|
|
185
|
+
h.isTranslated && /* @__PURE__ */ o(
|
|
186
186
|
ve,
|
|
187
187
|
{
|
|
188
188
|
language: e.language,
|
|
189
|
-
callback: () =>
|
|
189
|
+
callback: () => h.toggleContent()
|
|
190
190
|
}
|
|
191
191
|
)
|
|
192
192
|
] }),
|
|
193
193
|
lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ? J : void 0,
|
|
194
|
-
readMoreText:
|
|
194
|
+
readMoreText: a.formatMessage({
|
|
195
195
|
id: "action.read_more",
|
|
196
196
|
defaultMessage: "Read more"
|
|
197
197
|
}),
|
|
198
|
-
readLessText:
|
|
198
|
+
readLessText: a.formatMessage({
|
|
199
199
|
id: "action.read_less",
|
|
200
200
|
defaultMessage: "Read less"
|
|
201
201
|
}),
|
|
@@ -208,24 +208,24 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
208
208
|
),
|
|
209
209
|
e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(ie) })
|
|
210
210
|
] }),
|
|
211
|
-
!
|
|
211
|
+
!N && !e.is_deleted && /* @__PURE__ */ o(
|
|
212
212
|
Ie,
|
|
213
213
|
{
|
|
214
214
|
resource: e,
|
|
215
|
-
disabled:
|
|
215
|
+
disabled: b || e.status === "rejected" || !W && r?.actions?.disableInputForVisitor === !0 || A,
|
|
216
216
|
reportType: "Message",
|
|
217
217
|
softDelete: r.actions?.softDelete,
|
|
218
218
|
deleteType: "messages",
|
|
219
219
|
deleteListId: Y,
|
|
220
|
-
enableReply:
|
|
221
|
-
handleReplyTo:
|
|
220
|
+
enableReply: _ <= S || p.role === "editor" || p.role === "moderator",
|
|
221
|
+
handleReplyTo: U,
|
|
222
222
|
replyRedirectUrl: K,
|
|
223
223
|
shareUrl: `https://app.logora.fr/share/a/${e.id}`,
|
|
224
|
-
shareTitle:
|
|
224
|
+
shareTitle: a.formatMessage({
|
|
225
225
|
id: "share.argument.title",
|
|
226
226
|
defaultMessage: "Share a debate"
|
|
227
227
|
}),
|
|
228
|
-
shareText:
|
|
228
|
+
shareText: a.formatMessage({
|
|
229
229
|
id: "share.argument.text",
|
|
230
230
|
defaultMessage: "This argument may interest you"
|
|
231
231
|
}),
|
|
@@ -243,18 +243,18 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
243
243
|
voteableId: e.id,
|
|
244
244
|
totalUpvote: e.upvotes,
|
|
245
245
|
totalDownvote: 0,
|
|
246
|
-
activeClassName: s[`voteButtonPosition-${
|
|
247
|
-
disabled: e.status === "rejected" ||
|
|
246
|
+
activeClassName: s[`voteButtonPosition-${C}`],
|
|
247
|
+
disabled: e.status === "rejected" || p?.id === e?.author?.id || A
|
|
248
248
|
}
|
|
249
249
|
)
|
|
250
250
|
}
|
|
251
251
|
),
|
|
252
|
-
!
|
|
252
|
+
!N && !w && /* @__PURE__ */ o(
|
|
253
253
|
me,
|
|
254
254
|
{
|
|
255
255
|
numberReplies: e.number_replies,
|
|
256
256
|
repliesAuthors: e.replies_authors,
|
|
257
|
-
expandReplies:
|
|
257
|
+
expandReplies: m,
|
|
258
258
|
onToggleReplies: k,
|
|
259
259
|
isReply: e.is_reply
|
|
260
260
|
}
|
|
@@ -262,26 +262,33 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
262
262
|
]
|
|
263
263
|
}
|
|
264
264
|
),
|
|
265
|
-
!
|
|
265
|
+
!w && /* @__PURE__ */ l(f, { children: [
|
|
266
266
|
ee && /* @__PURE__ */ o(de, { fallback: null, children: /* @__PURE__ */ o(
|
|
267
267
|
Ne,
|
|
268
268
|
{
|
|
269
269
|
groupId: e.group_id,
|
|
270
|
-
groupType:
|
|
271
|
-
groupName:
|
|
272
|
-
positions:
|
|
270
|
+
groupType: R,
|
|
271
|
+
groupName: T,
|
|
272
|
+
positions: g,
|
|
273
273
|
parentId: e.id,
|
|
274
274
|
positionId: H?.position_id,
|
|
275
|
-
disabled:
|
|
275
|
+
disabled: b,
|
|
276
276
|
hideSourceAction: r?.actions?.disableUserSources || !1,
|
|
277
277
|
onSubmit: (t) => {
|
|
278
|
-
const
|
|
279
|
-
X.add(
|
|
278
|
+
const i = `argument_${e.id}_reply_list`;
|
|
279
|
+
X.add(i, [t]), U(), M(!0);
|
|
280
|
+
},
|
|
281
|
+
onUpdate: (t) => {
|
|
282
|
+
v(
|
|
283
|
+
(i) => i?.map(
|
|
284
|
+
(d) => d.id === t.id ? { ...d, ...t } : d
|
|
285
|
+
)
|
|
286
|
+
);
|
|
280
287
|
},
|
|
281
288
|
isReply: !0,
|
|
282
289
|
autoFocus: !0,
|
|
283
290
|
avatarSize: 40,
|
|
284
|
-
placeholder:
|
|
291
|
+
placeholder: a.formatMessage({
|
|
285
292
|
id: "input.reply_input.your_answer",
|
|
286
293
|
defaultMessage: "Your answer"
|
|
287
294
|
}),
|
|
@@ -290,8 +297,8 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
290
297
|
},
|
|
291
298
|
`Reply${e.id}`
|
|
292
299
|
) }),
|
|
293
|
-
|
|
294
|
-
|
|
300
|
+
u?.length > 0 && m && /* @__PURE__ */ o("div", { className: s.repliesList, children: u.map((t) => $(t)) }),
|
|
301
|
+
m && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
|
|
295
302
|
Se,
|
|
296
303
|
{
|
|
297
304
|
voteableType: "Message",
|
|
@@ -307,18 +314,18 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
307
314
|
perPage: 5,
|
|
308
315
|
display: "column",
|
|
309
316
|
resourcePropName: "argument",
|
|
310
|
-
emptyListComponent: /* @__PURE__ */ o(
|
|
317
|
+
emptyListComponent: /* @__PURE__ */ o(f, {}),
|
|
311
318
|
transformData: (t) => re(t),
|
|
312
|
-
children:
|
|
319
|
+
children: $(e)
|
|
313
320
|
}
|
|
314
321
|
) }),
|
|
315
|
-
|
|
322
|
+
u?.length > 0 && !m && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
|
|
316
323
|
Te,
|
|
317
324
|
{
|
|
318
325
|
role: "link",
|
|
319
326
|
rightIcon: /* @__PURE__ */ o(E, { name: "lightArrow", height: 10, width: 10 }),
|
|
320
327
|
handleClick: k,
|
|
321
|
-
children:
|
|
328
|
+
children: a.formatMessage({
|
|
322
329
|
id: "argument.argument.see_more",
|
|
323
330
|
defaultMessage: "See more"
|
|
324
331
|
})
|
|
@@ -1,137 +1,138 @@
|
|
|
1
1
|
import { jsxs as v, jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { useLocation as
|
|
2
|
+
import Ye from "@rooks/use-sessionstorage-state";
|
|
3
|
+
import { useRef as ke, useState as c, useEffect as p, Suspense as je, lazy as Re } from "react";
|
|
4
|
+
import { useIntl as ze, FormattedMessage as he } from "react-intl";
|
|
5
|
+
import { useLocation as Oe } from "react-router";
|
|
6
6
|
import S from "classnames";
|
|
7
7
|
import n from "./ArgumentInput.module.scss.js";
|
|
8
|
-
import { useDataProvider as
|
|
9
|
-
import { useList as
|
|
10
|
-
import { useConfig as
|
|
11
|
-
import { useInput as
|
|
12
|
-
import { useAuth as
|
|
13
|
-
import { useFormValidation as
|
|
14
|
-
import { useResponsive as
|
|
15
|
-
import { useAuthRequired as
|
|
16
|
-
import { useModal as
|
|
17
|
-
import { useToast as
|
|
18
|
-
import { TogglePosition as
|
|
19
|
-
import { Avatar as
|
|
20
|
-
import { AuthorBox as
|
|
21
|
-
import { TextEditor as
|
|
22
|
-
import { Icon as
|
|
23
|
-
const
|
|
8
|
+
import { useDataProvider as Je } from "../../data/data_provider/useDataProvider.js";
|
|
9
|
+
import { useList as Ke } from "../../list/list_provider/useList.js";
|
|
10
|
+
import { useConfig as Ge } from "../../data/config_provider/useConfig.js";
|
|
11
|
+
import { useInput as He } from "../input_provider/useInput.js";
|
|
12
|
+
import { useAuth as Qe } from "../../auth/use_auth/useAuth.js";
|
|
13
|
+
import { useFormValidation as Xe } from "../../forms/use_form_validation/useFormValidation.js";
|
|
14
|
+
import { useResponsive as Ze } from "../../hooks/use_responsive/useResponsive.js";
|
|
15
|
+
import { useAuthRequired as et } from "../../hooks/use_auth_required/useAuthRequired.js";
|
|
16
|
+
import { useModal as tt } from "../../dialog/modal/useModal.js";
|
|
17
|
+
import { useToast as nt } from "../../dialog/toast_provider/useToast.js";
|
|
18
|
+
import { TogglePosition as at } from "../toggle_position/TogglePosition.js";
|
|
19
|
+
import { Avatar as st } from "../../user/avatar/Avatar.js";
|
|
20
|
+
import { AuthorBox as it } from "../../user/author_box/AuthorBox.js";
|
|
21
|
+
import { TextEditor as ot } from "../text_editor/TextEditor.js";
|
|
22
|
+
import { Icon as rt } from "../../icons/icon/Icon.js";
|
|
23
|
+
const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Ft = ({
|
|
24
24
|
argumentListId: x,
|
|
25
|
-
avatarSize:
|
|
25
|
+
avatarSize: pe = 48,
|
|
26
26
|
disabled: O = !1,
|
|
27
27
|
positions: a = [],
|
|
28
28
|
disabledPositions: N = [],
|
|
29
29
|
groupId: b,
|
|
30
|
-
groupName:
|
|
30
|
+
groupName: _e,
|
|
31
31
|
groupType: J,
|
|
32
|
-
hideSourceAction:
|
|
32
|
+
hideSourceAction: Me = !1,
|
|
33
33
|
isReply: r = !1,
|
|
34
34
|
onSubmit: K,
|
|
35
|
+
onUpdate: G,
|
|
35
36
|
parentId: T,
|
|
36
|
-
placeholder:
|
|
37
|
+
placeholder: ve,
|
|
37
38
|
positionId: A,
|
|
38
|
-
focusOnInit:
|
|
39
|
+
focusOnInit: be = !1,
|
|
39
40
|
activeOnInit: P = !1,
|
|
40
|
-
userGuideUrl:
|
|
41
|
-
hideUserGuideLink:
|
|
42
|
-
hideCharCount:
|
|
43
|
-
disableAutoActivate:
|
|
44
|
-
autoFocus:
|
|
41
|
+
userGuideUrl: H,
|
|
42
|
+
hideUserGuideLink: Ae = !1,
|
|
43
|
+
hideCharCount: Ce = !1,
|
|
44
|
+
disableAutoActivate: we = !1,
|
|
45
|
+
autoFocus: Q = !1
|
|
45
46
|
}) => {
|
|
46
|
-
const o =
|
|
47
|
-
focus:
|
|
48
|
-
setFocus:
|
|
49
|
-
setReset:
|
|
47
|
+
const o = ze(), X = Je(), y = Ke(), _ = Ge(), {
|
|
48
|
+
focus: Z,
|
|
49
|
+
setFocus: ee,
|
|
50
|
+
setReset: Ie,
|
|
50
51
|
inputContent: B,
|
|
51
|
-
setInputContent:
|
|
52
|
-
setInputRichContent:
|
|
53
|
-
} =
|
|
52
|
+
setInputContent: te,
|
|
53
|
+
setInputRichContent: Se
|
|
54
|
+
} = He(), { isLoggedIn: C, currentUser: u } = Qe(), { errors: E, validate: V } = Xe(), { isMobile: m } = Ze(), xe = Oe(), ne = ke(null), [$, q] = c([]), [D, U] = c(""), [ae, W] = c(null), [d, M] = c(null), [se, ie] = c(null), [oe, re] = c(!1), [w, ue] = c(!1), [I, de] = c({}), [Ne, Y] = c(!1), [f, Te] = Ye(
|
|
54
55
|
"userSide",
|
|
55
56
|
{}
|
|
56
|
-
), [g,
|
|
57
|
+
), [g, ye] = c(
|
|
57
58
|
!C && _?.actions?.disableInputForVisitor
|
|
58
|
-
), k =
|
|
59
|
-
typeof window < "u" ? window.location.search :
|
|
59
|
+
), k = et(), { showModal: Le } = tt(), { toast: j } = nt() || {}, le = new URLSearchParams(
|
|
60
|
+
typeof window < "u" ? window.location.search : xe.search
|
|
60
61
|
);
|
|
61
62
|
p(() => {
|
|
62
|
-
|
|
63
|
+
ye(
|
|
63
64
|
!C && _?.actions?.disableInputForVisitor
|
|
64
65
|
);
|
|
65
66
|
}, [C, _]);
|
|
66
|
-
const R = u?.role === "editor" || u?.role === "moderator",
|
|
67
|
+
const R = u?.role === "editor" || u?.role === "moderator", ce = u?.moderation_status === "banned";
|
|
67
68
|
p(() => {
|
|
68
69
|
let e = null;
|
|
69
|
-
typeof window < "u" && (e =
|
|
70
|
+
typeof window < "u" && (e = le.get("positionId")), A && A != a[2]?.id && a?.find((t) => t.id === A) ? M(A) : e && e != a[2]?.id ? M(e) : f && f.groupId == b && f.positionId != a[2]?.id && M(f.positionId);
|
|
70
71
|
}, [A]), p(() => {
|
|
71
|
-
|
|
72
|
-
}, [
|
|
72
|
+
Q && Y(!0);
|
|
73
|
+
}, [Q]), p(() => {
|
|
73
74
|
P && (z(), Y(!0), L());
|
|
74
75
|
}, [P]), p(() => {
|
|
75
76
|
if (typeof window < "u") {
|
|
76
|
-
const e =
|
|
77
|
-
(e === !0 || e === "true") && (Y(!0), L(),
|
|
77
|
+
const e = be || le.get("initArgument");
|
|
78
|
+
(e === !0 || e === "true") && (Y(!0), L(), De());
|
|
78
79
|
}
|
|
79
80
|
}, []), p(() => {
|
|
80
|
-
|
|
81
|
-
}, [
|
|
82
|
-
B?.id && (
|
|
81
|
+
Z && (L(), ee(!1));
|
|
82
|
+
}, [Z]), p(() => {
|
|
83
|
+
B?.id && (Fe(B), ee(!0));
|
|
83
84
|
}, [B]);
|
|
84
|
-
const
|
|
85
|
-
|
|
85
|
+
const Fe = (e) => {
|
|
86
|
+
de(e), ue(!0), q(e.sources), U(e.content), W(e.rich_content), ie(e.id), L(), M(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Se(e.rich_content) : te(e.content);
|
|
86
87
|
}, L = () => {
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
M(e),
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/* @__PURE__ */ s(
|
|
95
|
-
|
|
88
|
+
ne.current.scrollIntoView(!1);
|
|
89
|
+
}, me = () => {
|
|
90
|
+
U(""), W(null), de({}), ie(null), q([]), Ie(!0), te(null);
|
|
91
|
+
}, Pe = (e) => {
|
|
92
|
+
M(e), ge(e);
|
|
93
|
+
}, Be = () => {
|
|
94
|
+
Le(
|
|
95
|
+
/* @__PURE__ */ s(je, { fallback: null, children: /* @__PURE__ */ s(
|
|
96
|
+
ut,
|
|
96
97
|
{
|
|
97
98
|
modalTitle: o.formatMessage({
|
|
98
99
|
id: "modal.side_modal.modal_title",
|
|
99
100
|
defaultMessage: "Choose your side"
|
|
100
101
|
}),
|
|
101
|
-
onChooseSide:
|
|
102
|
+
onChooseSide: Pe,
|
|
102
103
|
positions: a,
|
|
103
|
-
title:
|
|
104
|
+
title: _e,
|
|
104
105
|
disabledPositions: !r && N,
|
|
105
106
|
isNeutral: f && f.groupId == b && f.positionId === a[2]?.id
|
|
106
107
|
}
|
|
107
108
|
) })
|
|
108
109
|
);
|
|
109
|
-
},
|
|
110
|
-
C ?
|
|
111
|
-
},
|
|
112
|
-
g ? k({ loginAction: "argument" }) : (
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
},
|
|
110
|
+
}, Ee = () => {
|
|
111
|
+
C ? se ? qe() : !a || a?.length === 0 || !N?.find((e) => e?.id === d) && d || R && r ? ge(r && R && a[0]?.id) : Be() : k({ loginAction: "argument" });
|
|
112
|
+
}, Ve = (e, t) => {
|
|
113
|
+
g ? k({ loginAction: "argument" }) : (U(e), W(t), V({ content: e }, [{ content: ["url", null] }]));
|
|
114
|
+
}, $e = (e) => {
|
|
115
|
+
q(e);
|
|
116
|
+
}, fe = [
|
|
116
117
|
{ content: ["length", 3] },
|
|
117
118
|
{ content: ["required", null] },
|
|
118
119
|
{ content: ["url", null] },
|
|
119
120
|
...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
|
|
120
|
-
],
|
|
121
|
-
const t = e || d,
|
|
122
|
-
content:
|
|
123
|
-
rich_content:
|
|
121
|
+
], ge = (e) => {
|
|
122
|
+
const t = e || d, l = {
|
|
123
|
+
content: D,
|
|
124
|
+
rich_content: ae,
|
|
124
125
|
group_id: b,
|
|
125
126
|
...J && { group_type: J },
|
|
126
127
|
...t && { position_id: t },
|
|
127
128
|
is_reply: !!T,
|
|
128
129
|
message_id: T || null,
|
|
129
|
-
source_ids:
|
|
130
|
+
source_ids: $?.map((i) => i.id)
|
|
130
131
|
};
|
|
131
|
-
V(
|
|
132
|
+
V(l, fe) && (t && a && a.map((i) => i.id).includes(t) && Te({
|
|
132
133
|
groupId: b,
|
|
133
134
|
positionId: t
|
|
134
|
-
}),
|
|
135
|
+
}), me(), X.create("messages", l).then((i) => {
|
|
135
136
|
if (i.data.success) {
|
|
136
137
|
if (T)
|
|
137
138
|
K(i.data.data.resource), j(
|
|
@@ -151,8 +152,8 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
151
152
|
const h = i.data.data.resource;
|
|
152
153
|
let F = x;
|
|
153
154
|
t && !m && (F = `argumentList${h.position.id}`), K?.(
|
|
154
|
-
|
|
155
|
-
a.find((
|
|
155
|
+
D,
|
|
156
|
+
a.find((We) => We.id === t) || null
|
|
156
157
|
), y.add(F, [h]), j(
|
|
157
158
|
o.formatMessage({
|
|
158
159
|
id: "alert.argument_create",
|
|
@@ -178,42 +179,42 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
178
179
|
);
|
|
179
180
|
}
|
|
180
181
|
}));
|
|
181
|
-
},
|
|
182
|
+
}, qe = () => {
|
|
182
183
|
const e = {
|
|
183
|
-
content:
|
|
184
|
-
rich_content:
|
|
185
|
-
source_ids:
|
|
184
|
+
content: D,
|
|
185
|
+
rich_content: ae,
|
|
186
|
+
source_ids: $?.map((t) => t.id),
|
|
186
187
|
...d && { position_id: d }
|
|
187
188
|
};
|
|
188
|
-
V(e,
|
|
189
|
+
V(e, fe) && X.update("messages", se, e).then((t) => {
|
|
189
190
|
if (t.data.success) {
|
|
190
|
-
const
|
|
191
|
+
const l = t.data.data.resource;
|
|
191
192
|
let i = x;
|
|
192
193
|
if (I?.is_reply || r) {
|
|
193
194
|
const h = I?.message_id || T;
|
|
194
195
|
h && (i = `argument_${h}_reply_list`);
|
|
195
|
-
} else d && !m && (i = `argumentList${
|
|
196
|
-
if (!I?.is_reply && I?.position?.id !=
|
|
197
|
-
const h = `argumentList${I.position.id}`, F = `argumentList${
|
|
198
|
-
y.remove(h, [
|
|
196
|
+
} else d && !m && (i = `argumentList${l.position?.id}`);
|
|
197
|
+
if (!I?.is_reply && I?.position?.id != l.position?.id && !m) {
|
|
198
|
+
const h = `argumentList${I.position.id}`, F = `argumentList${l.position.id}`;
|
|
199
|
+
y.remove(h, [l]), y.add(F, [l]);
|
|
199
200
|
} else
|
|
200
|
-
y.update(i, [
|
|
201
|
-
j(o.formatMessage({ id: "alert.argument_modify" }), {
|
|
201
|
+
y.update(i, [l]);
|
|
202
|
+
G && G(l), j(o.formatMessage({ id: "alert.argument_modify" }), {
|
|
202
203
|
type: "success"
|
|
203
|
-
}),
|
|
204
|
+
}), me();
|
|
204
205
|
}
|
|
205
206
|
});
|
|
206
|
-
},
|
|
207
|
-
if (!
|
|
208
|
-
|
|
207
|
+
}, De = () => {
|
|
208
|
+
if (!oe) {
|
|
209
|
+
re(!0);
|
|
209
210
|
const e = setTimeout(() => {
|
|
210
|
-
|
|
211
|
+
re(!1);
|
|
211
212
|
}, 2e3);
|
|
212
213
|
return () => clearTimeout(e);
|
|
213
214
|
}
|
|
214
215
|
}, z = () => {
|
|
215
|
-
g ? k({ loginAction: "argument" }) :
|
|
216
|
-
},
|
|
216
|
+
g ? k({ loginAction: "argument" }) : ue(!0);
|
|
217
|
+
}, Ue = () => {
|
|
217
218
|
const e = N.find(
|
|
218
219
|
(t) => t.id === d
|
|
219
220
|
);
|
|
@@ -227,7 +228,7 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
227
228
|
);
|
|
228
229
|
};
|
|
229
230
|
return /* @__PURE__ */ v("div", { className: n.inputContainer, children: [
|
|
230
|
-
O && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children:
|
|
231
|
+
O && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ce ? o.formatMessage({
|
|
231
232
|
id: "input.argument_input.user_banned",
|
|
232
233
|
defaultMessage: "You are banned from the debate space."
|
|
233
234
|
}) : o.formatMessage({
|
|
@@ -238,17 +239,17 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
238
239
|
"div",
|
|
239
240
|
{
|
|
240
241
|
className: S(n.argumentInput, {
|
|
241
|
-
[n.flash]:
|
|
242
|
+
[n.flash]: oe,
|
|
242
243
|
[n.replyInputContainer]: r
|
|
243
244
|
}),
|
|
244
|
-
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref:
|
|
245
|
+
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ne, children: /* @__PURE__ */ v("div", { className: n.argumentInputBox, children: [
|
|
245
246
|
a.length > 0 && C && (!r || !R) && /* @__PURE__ */ v("div", { className: n.userPosition, children: [
|
|
246
247
|
/* @__PURE__ */ s("div", { children: o.formatMessage({
|
|
247
248
|
id: "input.position",
|
|
248
249
|
defaultMessage: "Your position"
|
|
249
250
|
}) }),
|
|
250
251
|
/* @__PURE__ */ s(
|
|
251
|
-
|
|
252
|
+
at,
|
|
252
253
|
{
|
|
253
254
|
activeLabel: d === a[0].id ? 0 : d === a[1].id ? 1 : null,
|
|
254
255
|
firstLabel: a[0],
|
|
@@ -273,14 +274,14 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
273
274
|
[n.argumentAuthorContainerActivated]: !m && w || r
|
|
274
275
|
}),
|
|
275
276
|
children: !m && w || r ? /* @__PURE__ */ s(
|
|
276
|
-
|
|
277
|
+
st,
|
|
277
278
|
{
|
|
278
279
|
avatarUrl: u.image_url,
|
|
279
280
|
userName: u.full_name,
|
|
280
|
-
size:
|
|
281
|
+
size: pe
|
|
281
282
|
}
|
|
282
283
|
) : /* @__PURE__ */ s(
|
|
283
|
-
|
|
284
|
+
it,
|
|
284
285
|
{
|
|
285
286
|
fullName: u?.full_name || o.formatMessage({ id: "default_author.full_name" }),
|
|
286
287
|
avatarUrl: u?.image_url,
|
|
@@ -300,35 +301,35 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
300
301
|
}),
|
|
301
302
|
children: [
|
|
302
303
|
/* @__PURE__ */ s(
|
|
303
|
-
|
|
304
|
+
ot,
|
|
304
305
|
{
|
|
305
306
|
handleChange: (e, t) => {
|
|
306
|
-
|
|
307
|
+
Ve(e, t);
|
|
307
308
|
},
|
|
308
309
|
handleSourcesChange: (e) => {
|
|
309
|
-
|
|
310
|
+
$e(e);
|
|
310
311
|
},
|
|
311
|
-
placeholder:
|
|
312
|
+
placeholder: ve,
|
|
312
313
|
"aria-label": o.formatMessage({
|
|
313
314
|
id: "input.argument_input.aria_label",
|
|
314
315
|
defaultMessage: "Message input field"
|
|
315
316
|
}),
|
|
316
|
-
onSubmit:
|
|
317
|
-
sources:
|
|
318
|
-
hideSourceAction:
|
|
317
|
+
onSubmit: Ee,
|
|
318
|
+
sources: $,
|
|
319
|
+
hideSourceAction: Me || g,
|
|
319
320
|
uid: `Argument${b}`,
|
|
320
321
|
onActivation: z,
|
|
321
322
|
showStylesControls: w,
|
|
322
|
-
disabled: O || g ||
|
|
323
|
+
disabled: O || g || ce,
|
|
323
324
|
maxLength: g ? !1 : _?.actions?.argumentMaxLength,
|
|
324
325
|
disableRichText: _?.actions?.disableRichText || g,
|
|
325
326
|
shortBar: r,
|
|
326
327
|
hideSubmit: g,
|
|
327
328
|
allowedDomains: _?.allowed_sources,
|
|
328
329
|
active: P,
|
|
329
|
-
autoFocus:
|
|
330
|
-
hideCharCount:
|
|
331
|
-
disableAutoActivate:
|
|
330
|
+
autoFocus: Ne,
|
|
331
|
+
hideCharCount: Ce,
|
|
332
|
+
disableAutoActivate: we
|
|
332
333
|
}
|
|
333
334
|
),
|
|
334
335
|
E?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: E && Object.values(E).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
|
|
@@ -343,7 +344,7 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
343
344
|
),
|
|
344
345
|
children: [
|
|
345
346
|
/* @__PURE__ */ s(
|
|
346
|
-
|
|
347
|
+
rt,
|
|
347
348
|
{
|
|
348
349
|
name: "announcement",
|
|
349
350
|
className: n.warningIcon,
|
|
@@ -351,12 +352,12 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
351
352
|
width: 20
|
|
352
353
|
}
|
|
353
354
|
),
|
|
354
|
-
/* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children:
|
|
355
|
+
/* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: Ue() })
|
|
355
356
|
]
|
|
356
357
|
}
|
|
357
358
|
),
|
|
358
|
-
w &&
|
|
359
|
-
|
|
359
|
+
w && H && !Ae && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
|
|
360
|
+
he,
|
|
360
361
|
{
|
|
361
362
|
id: "alert.guide_message",
|
|
362
363
|
defaultMessage: "Contributions must comply with our {userCharter}.",
|
|
@@ -365,11 +366,11 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
365
366
|
"a",
|
|
366
367
|
{
|
|
367
368
|
className: n.guideMessage,
|
|
368
|
-
href:
|
|
369
|
+
href: H,
|
|
369
370
|
target: "_blank",
|
|
370
371
|
rel: "noreferrer",
|
|
371
372
|
children: /* @__PURE__ */ s(
|
|
372
|
-
|
|
373
|
+
he,
|
|
373
374
|
{
|
|
374
375
|
id: "alert.user_charter",
|
|
375
376
|
defaultMessage: "user charter"
|
|
@@ -392,5 +393,5 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
392
393
|
] });
|
|
393
394
|
};
|
|
394
395
|
export {
|
|
395
|
-
|
|
396
|
+
Ft as ArgumentInput
|
|
396
397
|
};
|