@logora/debate 0.3.13 → 0.3.14
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,76 @@
|
|
|
1
1
|
import { jsx as o, jsxs as l, Fragment as h } from "react/jsx-runtime";
|
|
2
2
|
import B from "classnames";
|
|
3
|
-
import { useState as f, useEffect as
|
|
4
|
-
import { useIntl as
|
|
3
|
+
import { useState as f, useEffect as ie, useCallback as ae, Suspense as le, lazy as ne } from "react";
|
|
4
|
+
import { useIntl as de } 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
|
|
6
|
+
import { ReplyFooter as ce } from "./ReplyFooter.js";
|
|
7
|
+
import { useRichContent as pe } from "./useRichContent.js";
|
|
8
|
+
import { useAuth as me } from "../../auth/use_auth/useAuth.js";
|
|
9
|
+
import { useConfig as ue } from "../../data/config_provider/useConfig.js";
|
|
10
10
|
import { useTranslatedContent as $ } from "../../translation/translated_content/useTranslatedContent.js";
|
|
11
|
-
import { SourceListItem as
|
|
12
|
-
import { HashScroll as
|
|
13
|
-
import { ContentHeader as
|
|
11
|
+
import { SourceListItem as he } from "../../source/source_list_item/SourceListItem.js";
|
|
12
|
+
import { HashScroll as fe } from "../../tools/hash_scroll/HashScroll.js";
|
|
13
|
+
import { ContentHeader as ye } from "../../user_content/content_header/ContentHeader.js";
|
|
14
14
|
import { Icon as D } from "../../icons/icon/Icon.js";
|
|
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
|
|
15
|
+
import { ReadMore as ge } from "../../text/read_more/ReadMore.js";
|
|
16
|
+
import { TranslationButton as _e } from "../../translation/translation_button/TranslationButton.js";
|
|
17
|
+
import { ContentFooter as be } from "../../user_content/content_footer/ContentFooter.js";
|
|
18
|
+
import { VoteButton as Me } from "../../vote/vote_button/VoteButton.js";
|
|
19
|
+
import { VotePaginatedList as ve } from "../../list/paginated_list/VotePaginatedList.js";
|
|
20
|
+
import { UserContentSkeleton as Ce } from "../../skeleton/user_content_skeleton/UserContentSkeleton.js";
|
|
21
|
+
import { Button as Ie } from "../../action/button/Button.js";
|
|
22
|
+
const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), E = (e) => e?.replace(/ /g, " "), Re = ({
|
|
23
23
|
argument: e,
|
|
24
24
|
argumentReplies: n,
|
|
25
25
|
nestingLevel: y = 0,
|
|
26
26
|
groupType: I,
|
|
27
27
|
groupName: S,
|
|
28
28
|
positions: g = [],
|
|
29
|
-
disableLinks:
|
|
29
|
+
disableLinks: P = !1,
|
|
30
30
|
parentArgument: d,
|
|
31
|
-
flashParent:
|
|
32
|
-
expandable:
|
|
31
|
+
flashParent: F,
|
|
32
|
+
expandable: j,
|
|
33
33
|
disabled: _ = !1,
|
|
34
34
|
hideFooter: R = !1,
|
|
35
35
|
hideReplies: T,
|
|
36
|
-
vote:
|
|
37
|
-
fixedContentHeight:
|
|
38
|
-
enableEdition:
|
|
39
|
-
enableDeletion:
|
|
40
|
-
deleteListId:
|
|
41
|
-
showModerationFeedback:
|
|
42
|
-
lineCount:
|
|
43
|
-
replyRedirectUrl:
|
|
44
|
-
hideContent:
|
|
36
|
+
vote: G,
|
|
37
|
+
fixedContentHeight: H = !1,
|
|
38
|
+
enableEdition: V = !0,
|
|
39
|
+
enableDeletion: z = !0,
|
|
40
|
+
deleteListId: O,
|
|
41
|
+
showModerationFeedback: Y,
|
|
42
|
+
lineCount: q = 5,
|
|
43
|
+
replyRedirectUrl: J,
|
|
44
|
+
hideContent: K = !1
|
|
45
45
|
}) => {
|
|
46
|
-
const i =
|
|
46
|
+
const i = de(), { isLoggedIn: Q, currentUser: c } = me(), N = c?.moderation_status === "banned", r = ue(), [p, b] = f(!1), [W, w] = f(!1), [X, Z] = f(!1), x = pe(e), [m, M] = f(), u = $(
|
|
47
47
|
e.content,
|
|
48
48
|
e.language,
|
|
49
49
|
"content",
|
|
50
50
|
e.translation_entries
|
|
51
|
-
),
|
|
51
|
+
), ee = $(
|
|
52
52
|
e.position?.name,
|
|
53
53
|
e.position?.language,
|
|
54
54
|
"name",
|
|
55
55
|
e.position?.translation_entries
|
|
56
56
|
), v = `argument_${e.id}`, C = e.position && g?.map((t) => t.id).indexOf(e.position.id) + 1;
|
|
57
|
-
|
|
58
|
-
n !== void 0 &&
|
|
57
|
+
ie(() => {
|
|
58
|
+
n !== void 0 && re();
|
|
59
59
|
}, [n]);
|
|
60
|
-
const
|
|
60
|
+
const te = (t) => {
|
|
61
61
|
if (v === t) {
|
|
62
62
|
const U = document.getElementById(t);
|
|
63
63
|
U && U.scrollIntoView({ behavior: "smooth" }), w(!0);
|
|
64
64
|
}
|
|
65
65
|
}, A = () => {
|
|
66
|
-
|
|
66
|
+
Z((t) => !t);
|
|
67
67
|
}, L = () => {
|
|
68
68
|
b((t) => !t), M([]);
|
|
69
|
-
},
|
|
69
|
+
}, oe = (t) => {
|
|
70
70
|
if (!m?.find((a) => a.id === t.id))
|
|
71
71
|
return t;
|
|
72
|
-
},
|
|
73
|
-
|
|
72
|
+
}, se = ae((t, a) => /* @__PURE__ */ o(
|
|
73
|
+
he,
|
|
74
74
|
{
|
|
75
75
|
publisher: t.publisher,
|
|
76
76
|
url: t.source_url,
|
|
@@ -78,7 +78,7 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
78
78
|
index: a
|
|
79
79
|
},
|
|
80
80
|
a
|
|
81
|
-
), []),
|
|
81
|
+
), []), re = () => {
|
|
82
82
|
if (n && Array.isArray(n)) {
|
|
83
83
|
const t = n.filter(
|
|
84
84
|
(a) => a.reply_to_id === e.id
|
|
@@ -96,17 +96,17 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
96
96
|
positions: g,
|
|
97
97
|
argumentReplies: n,
|
|
98
98
|
parentArgument: e,
|
|
99
|
-
flashParent: (a) =>
|
|
99
|
+
flashParent: (a) => te(`argument_${a}`)
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
|
-
return /* @__PURE__ */ l(
|
|
102
|
+
return /* @__PURE__ */ l(fe, { elementId: v, onScroll: () => w(!0), children: [
|
|
103
103
|
/* @__PURE__ */ l(
|
|
104
104
|
"div",
|
|
105
105
|
{
|
|
106
106
|
className: B(
|
|
107
107
|
s.argument,
|
|
108
108
|
{
|
|
109
|
-
[s.flash]:
|
|
109
|
+
[s.flash]: W,
|
|
110
110
|
[s.argumentReply]: e.is_reply === !0
|
|
111
111
|
},
|
|
112
112
|
s[`level-${y}`],
|
|
@@ -115,16 +115,16 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
115
115
|
id: v,
|
|
116
116
|
children: [
|
|
117
117
|
/* @__PURE__ */ o(
|
|
118
|
-
|
|
118
|
+
ye,
|
|
119
119
|
{
|
|
120
120
|
selectedContent: e.is_selected,
|
|
121
121
|
author: e.author,
|
|
122
|
-
tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null :
|
|
122
|
+
tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : ee.translatedContent,
|
|
123
123
|
date: e.created_at,
|
|
124
124
|
tagClassName: s[`headerPosition-${C}`],
|
|
125
|
-
disableLinks:
|
|
125
|
+
disableLinks: P,
|
|
126
126
|
isDeleted: e.is_deleted,
|
|
127
|
-
showModerationFeedback:
|
|
127
|
+
showModerationFeedback: Y ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
|
|
128
128
|
moderationReason: e.moderation_entry?.moderation_reason,
|
|
129
129
|
moderationNotes: e.moderation_entry?.moderator_notes,
|
|
130
130
|
moderationPolicyUrl: r.provider?.userGuideUrl
|
|
@@ -133,7 +133,7 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
133
133
|
e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
|
|
134
134
|
id: "info.deleted_by_user",
|
|
135
135
|
defaultMessage: "Content deleted by the user"
|
|
136
|
-
}) }) :
|
|
136
|
+
}) }) : K ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
|
|
137
137
|
id: "argument.argument.content_deleted",
|
|
138
138
|
defaultMessage: "This content has been removed."
|
|
139
139
|
}) }) : /* @__PURE__ */ l(h, { children: [
|
|
@@ -141,14 +141,14 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
141
141
|
"div",
|
|
142
142
|
{
|
|
143
143
|
className: B(s.argumentBody, {
|
|
144
|
-
[s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ?
|
|
144
|
+
[s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? H : !1
|
|
145
145
|
}),
|
|
146
146
|
children: [
|
|
147
147
|
e.is_reply && d && /* @__PURE__ */ l(
|
|
148
148
|
"div",
|
|
149
149
|
{
|
|
150
150
|
className: s.replyTo,
|
|
151
|
-
onClick: () =>
|
|
151
|
+
onClick: () => F(d.id),
|
|
152
152
|
children: [
|
|
153
153
|
i.formatMessage({
|
|
154
154
|
id: "info.replying_to",
|
|
@@ -165,7 +165,7 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
165
165
|
}
|
|
166
166
|
),
|
|
167
167
|
/* @__PURE__ */ o(
|
|
168
|
-
|
|
168
|
+
ge,
|
|
169
169
|
{
|
|
170
170
|
content: /* @__PURE__ */ l(h, { children: [
|
|
171
171
|
e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: i.formatMessage({
|
|
@@ -176,18 +176,18 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
176
176
|
"div",
|
|
177
177
|
{
|
|
178
178
|
className: s.argumentContent,
|
|
179
|
-
dangerouslySetInnerHTML: { __html: x }
|
|
179
|
+
dangerouslySetInnerHTML: { __html: E(x) }
|
|
180
180
|
}
|
|
181
|
-
) : /* @__PURE__ */ o("div", { className: s.argumentContent, children:
|
|
181
|
+
) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: E(u.translatedContent) }),
|
|
182
182
|
u.isTranslated && /* @__PURE__ */ o(
|
|
183
|
-
|
|
183
|
+
_e,
|
|
184
184
|
{
|
|
185
185
|
language: e.language,
|
|
186
186
|
callback: () => u.toggleContent()
|
|
187
187
|
}
|
|
188
188
|
)
|
|
189
189
|
] }),
|
|
190
|
-
lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ?
|
|
190
|
+
lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ? q : void 0,
|
|
191
191
|
readMoreText: i.formatMessage({
|
|
192
192
|
id: "action.read_more",
|
|
193
193
|
defaultMessage: "Read more"
|
|
@@ -196,27 +196,27 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
196
196
|
id: "action.read_less",
|
|
197
197
|
defaultMessage: "Read less"
|
|
198
198
|
}),
|
|
199
|
-
expandable: r?.layout?.showAllArgumentInEmbed !== !0 ?
|
|
199
|
+
expandable: r?.layout?.showAllArgumentInEmbed !== !0 ? j : !1,
|
|
200
200
|
readMoreClassName: e.is_reply ? s.replyStyle : s.argumentStyle
|
|
201
201
|
}
|
|
202
202
|
)
|
|
203
203
|
]
|
|
204
204
|
}
|
|
205
205
|
),
|
|
206
|
-
e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(
|
|
206
|
+
e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(se) })
|
|
207
207
|
] }),
|
|
208
208
|
!R && !e.is_deleted && /* @__PURE__ */ o(
|
|
209
|
-
|
|
209
|
+
be,
|
|
210
210
|
{
|
|
211
211
|
resource: e,
|
|
212
|
-
disabled: _ || e.status === "rejected" || !
|
|
212
|
+
disabled: _ || e.status === "rejected" || !Q && r?.actions?.disableInputForVisitor === !0 || N,
|
|
213
213
|
reportType: "Message",
|
|
214
214
|
softDelete: r.actions?.softDelete,
|
|
215
215
|
deleteType: "messages",
|
|
216
|
-
deleteListId:
|
|
216
|
+
deleteListId: O,
|
|
217
217
|
enableReply: y <= 2 || c.role === "editor" || c.role === "moderator",
|
|
218
218
|
handleReplyTo: A,
|
|
219
|
-
replyRedirectUrl:
|
|
219
|
+
replyRedirectUrl: J,
|
|
220
220
|
shareUrl: `https://app.logora.fr/share/a/${e.id}`,
|
|
221
221
|
shareTitle: i.formatMessage({
|
|
222
222
|
id: "share.argument.title",
|
|
@@ -231,10 +231,10 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
231
231
|
showShareText: !0,
|
|
232
232
|
showShareButton: r?.actions?.hideShareButton !== !0,
|
|
233
233
|
enableReport: !(e.score === 100 && e.manual_score),
|
|
234
|
-
enableEdition:
|
|
235
|
-
enableDeletion:
|
|
234
|
+
enableEdition: V,
|
|
235
|
+
enableDeletion: z,
|
|
236
236
|
children: /* @__PURE__ */ o(
|
|
237
|
-
|
|
237
|
+
Me,
|
|
238
238
|
{
|
|
239
239
|
voteableType: "Message",
|
|
240
240
|
voteableId: e.id,
|
|
@@ -247,7 +247,7 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
247
247
|
}
|
|
248
248
|
),
|
|
249
249
|
!R && !T && /* @__PURE__ */ o(
|
|
250
|
-
|
|
250
|
+
ce,
|
|
251
251
|
{
|
|
252
252
|
numberReplies: e.number_replies,
|
|
253
253
|
repliesAuthors: e.replies_authors,
|
|
@@ -260,15 +260,15 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
260
260
|
}
|
|
261
261
|
),
|
|
262
262
|
!T && /* @__PURE__ */ l(h, { children: [
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
X && /* @__PURE__ */ o(le, { fallback: null, children: /* @__PURE__ */ o(
|
|
264
|
+
Se,
|
|
265
265
|
{
|
|
266
266
|
groupId: e.group_id,
|
|
267
267
|
groupType: I,
|
|
268
268
|
groupName: S,
|
|
269
269
|
positions: g,
|
|
270
270
|
parentId: e.id,
|
|
271
|
-
positionId:
|
|
271
|
+
positionId: G?.position_id,
|
|
272
272
|
disabled: _,
|
|
273
273
|
hideSourceAction: r?.actions?.disableUserSources || !1,
|
|
274
274
|
onSubmit: (t) => {
|
|
@@ -287,11 +287,11 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
287
287
|
) }),
|
|
288
288
|
m?.length > 0 && p && /* @__PURE__ */ o("div", { className: s.repliesList, children: m.map((t) => k(t)) }),
|
|
289
289
|
p && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
|
|
290
|
-
|
|
290
|
+
ve,
|
|
291
291
|
{
|
|
292
292
|
voteableType: "Message",
|
|
293
293
|
currentListId: `argument_${e.id}_reply_list`,
|
|
294
|
-
loadingComponent: /* @__PURE__ */ o(
|
|
294
|
+
loadingComponent: /* @__PURE__ */ o(Ce, {}),
|
|
295
295
|
resource: "messages",
|
|
296
296
|
sort: "+created_at",
|
|
297
297
|
filters: {
|
|
@@ -303,12 +303,12 @@ const Ie = le(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
303
303
|
display: "column",
|
|
304
304
|
resourcePropName: "argument",
|
|
305
305
|
emptyListComponent: /* @__PURE__ */ o(h, {}),
|
|
306
|
-
transformData: (t) =>
|
|
306
|
+
transformData: (t) => oe(t),
|
|
307
307
|
children: k(e)
|
|
308
308
|
}
|
|
309
309
|
) }),
|
|
310
310
|
m?.length > 0 && !p && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
|
|
311
|
-
|
|
311
|
+
Ie,
|
|
312
312
|
{
|
|
313
313
|
role: "link",
|
|
314
314
|
rightIcon: /* @__PURE__ */ o(D, { name: "lightArrow", height: 10, width: 10 }),
|