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