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