@logora/debate 0.3.50 → 0.3.51
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,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as _, jsx as
|
|
1
|
+
import { jsxs as _, jsx as s } 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 x 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,19 +20,19 @@ 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 st = We(() => import("../../modal/side_modal/index.js").then((N) => ({ default: N.SideModal }))), Nt = ({
|
|
24
|
+
argumentListId: N,
|
|
25
25
|
avatarSize: me = 48,
|
|
26
26
|
disabled: j = !1,
|
|
27
27
|
positions: a = [],
|
|
28
|
-
disabledPositions:
|
|
28
|
+
disabledPositions: y = [],
|
|
29
29
|
groupId: v,
|
|
30
|
-
groupName:
|
|
30
|
+
groupName: ge,
|
|
31
31
|
groupType: z,
|
|
32
|
-
hideSourceAction:
|
|
32
|
+
hideSourceAction: fe = !1,
|
|
33
33
|
isReply: u = !1,
|
|
34
34
|
onSubmit: O,
|
|
35
|
-
parentId:
|
|
35
|
+
parentId: A,
|
|
36
36
|
placeholder: he,
|
|
37
37
|
positionId: b,
|
|
38
38
|
focusOnInit: pe = !1,
|
|
@@ -42,71 +42,71 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
42
42
|
hideCharCount: Me = !1,
|
|
43
43
|
disableAutoActivate: ve = !1
|
|
44
44
|
}) => {
|
|
45
|
-
const
|
|
45
|
+
const r = Ye(), K = Re(), T = je(), h = ze(), {
|
|
46
46
|
focus: G,
|
|
47
|
-
setFocus:
|
|
48
|
-
setReset:
|
|
47
|
+
setFocus: L,
|
|
48
|
+
setReset: Ae,
|
|
49
49
|
inputContent: P,
|
|
50
|
-
setInputContent:
|
|
51
|
-
setInputRichContent:
|
|
52
|
-
} = Oe(), { isLoggedIn:
|
|
50
|
+
setInputContent: be,
|
|
51
|
+
setInputRichContent: we
|
|
52
|
+
} = Oe(), { isLoggedIn: w, currentUser: d } = Je(), { errors: B, validate: E } = Ke(), { isMobile: m } = Ge(), Ce = ke(), H = qe(null), [V, U] = c([]), [$, q] = c(""), [Q, D] = c(null), [l, p] = c(null), [X, Z] = c(null), [ee, te] = c(!1), [C, ne] = c(!1), [ae, se] = c({}), [g, Ie] = $e(
|
|
53
53
|
"userSide",
|
|
54
54
|
{}
|
|
55
|
-
), [
|
|
56
|
-
!
|
|
57
|
-
), W = He(), { showModal: xe } = Qe(), { toast: Y } = Xe() || {},
|
|
58
|
-
typeof window < "u" ? window.location.search :
|
|
55
|
+
), [f, Se] = c(
|
|
56
|
+
!w && h?.actions?.disableInputForVisitor
|
|
57
|
+
), W = He(), { showModal: xe } = Qe(), { toast: Y } = Xe() || {}, oe = new URLSearchParams(
|
|
58
|
+
typeof window < "u" ? window.location.search : Ce.search
|
|
59
59
|
);
|
|
60
60
|
M(() => {
|
|
61
61
|
Se(
|
|
62
|
-
!
|
|
62
|
+
!w && h?.actions?.disableInputForVisitor
|
|
63
63
|
);
|
|
64
|
-
}, [
|
|
65
|
-
const k = d?.role === "editor" || d?.role === "moderator",
|
|
64
|
+
}, [w, h]);
|
|
65
|
+
const k = d?.role === "editor" || d?.role === "moderator", ie = d?.moderation_status === "banned";
|
|
66
66
|
M(() => {
|
|
67
67
|
let e = null;
|
|
68
|
-
typeof window < "u" && (e =
|
|
68
|
+
typeof window < "u" && (e = oe.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 == v && g.positionId != a[2]?.id && p(g.positionId);
|
|
69
69
|
}, [b]), M(() => {
|
|
70
|
-
F && (R(),
|
|
70
|
+
F && (R(), L(!0));
|
|
71
71
|
}, [F]), M(() => {
|
|
72
72
|
if (typeof window < "u") {
|
|
73
|
-
const e = pe ||
|
|
74
|
-
(e === !0 || e === "true") && (
|
|
73
|
+
const e = pe || oe.get("initArgument");
|
|
74
|
+
(e === !0 || e === "true") && (L(!0), Ee());
|
|
75
75
|
}
|
|
76
76
|
}, []), M(() => {
|
|
77
|
-
G && (re(),
|
|
77
|
+
G && (re(), L(!1));
|
|
78
78
|
}, [G]), M(() => {
|
|
79
|
-
P?.id && (Ne(P),
|
|
79
|
+
P?.id && (Ne(P), L(!0));
|
|
80
80
|
}, [P]);
|
|
81
81
|
const Ne = (e) => {
|
|
82
|
-
|
|
82
|
+
se(e), ne(!0), U(e.sources), q(e.content), D(e.rich_content), Z(e.id), re(), p(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? we(e.rich_content) : be(e.content);
|
|
83
83
|
}, re = () => {
|
|
84
84
|
H.current.scrollIntoView(!1);
|
|
85
85
|
}, ue = () => {
|
|
86
|
-
q(""), D(null),
|
|
87
|
-
},
|
|
86
|
+
q(""), D(null), se({}), Z(null), U([]), Ae(!0);
|
|
87
|
+
}, ye = (e) => {
|
|
88
88
|
p(e), le(e);
|
|
89
|
-
},
|
|
89
|
+
}, Te = () => {
|
|
90
90
|
xe(
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
|
|
91
|
+
/* @__PURE__ */ s(De, { fallback: null, children: /* @__PURE__ */ s(
|
|
92
|
+
st,
|
|
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
|
-
onChooseSide:
|
|
98
|
+
onChooseSide: ye,
|
|
99
99
|
positions: a,
|
|
100
|
-
title:
|
|
101
|
-
disabledPositions: !u &&
|
|
102
|
-
isNeutral:
|
|
100
|
+
title: ge,
|
|
101
|
+
disabledPositions: !u && y,
|
|
102
|
+
isNeutral: g && g.groupId == v && g.positionId === a[2]?.id
|
|
103
103
|
}
|
|
104
104
|
) })
|
|
105
105
|
);
|
|
106
106
|
}, Le = () => {
|
|
107
|
-
|
|
107
|
+
w ? X ? Be() : !a || a?.length === 0 || !y?.find((e) => e?.id === l) && l || k && u ? le(u && k && a[0]?.id) : Te() : W({ loginAction: "argument" });
|
|
108
108
|
}, Fe = (e, t) => {
|
|
109
|
-
|
|
109
|
+
f ? W({ loginAction: "argument" }) : (q(e), D(t), E({ content: e }, [{ content: ["url", null] }]));
|
|
110
110
|
}, Pe = (e) => {
|
|
111
111
|
U(e);
|
|
112
112
|
}, de = [
|
|
@@ -115,49 +115,49 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
115
115
|
{ content: ["url", null] },
|
|
116
116
|
...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
|
|
117
117
|
], le = (e) => {
|
|
118
|
-
const t = e || l,
|
|
118
|
+
const t = e || l, o = {
|
|
119
119
|
content: $,
|
|
120
120
|
rich_content: Q,
|
|
121
121
|
group_id: v,
|
|
122
122
|
...z && { group_type: z },
|
|
123
123
|
...t && { position_id: t },
|
|
124
|
-
is_reply: !!
|
|
125
|
-
message_id:
|
|
126
|
-
source_ids: V?.map((
|
|
124
|
+
is_reply: !!A,
|
|
125
|
+
message_id: A || null,
|
|
126
|
+
source_ids: V?.map((i) => i.id)
|
|
127
127
|
};
|
|
128
|
-
E(
|
|
128
|
+
E(o, de) && (t && a && a.map((i) => i.id).includes(t) && Ie({
|
|
129
129
|
groupId: v,
|
|
130
130
|
positionId: t
|
|
131
|
-
}), ue(), K.create("messages",
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
134
|
-
O(
|
|
135
|
-
|
|
131
|
+
}), ue(), K.create("messages", o).then((i) => {
|
|
132
|
+
if (i.data.success) {
|
|
133
|
+
if (A)
|
|
134
|
+
O(i.data.data.resource), Y(
|
|
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 && (
|
|
148
|
+
const I = i.data.data.resource;
|
|
149
|
+
let S = N;
|
|
150
|
+
t && !m && (S = `argumentList${I.position.id}`), O?.(
|
|
151
151
|
$,
|
|
152
152
|
a.find((Ue) => Ue.id === t) || null
|
|
153
|
-
),
|
|
154
|
-
|
|
153
|
+
), T.add(S, [I]), Y(
|
|
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
|
}),
|
|
@@ -169,7 +169,7 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
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
|
);
|
|
@@ -184,14 +184,14 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
184
184
|
};
|
|
185
185
|
E(e, de) && K.update("messages", X, e).then((t) => {
|
|
186
186
|
if (t.data.success) {
|
|
187
|
-
const
|
|
188
|
-
let
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
191
|
-
|
|
187
|
+
const o = t.data.data.resource;
|
|
188
|
+
let i = N;
|
|
189
|
+
if (console.log("[updateArgument] API response:", o), console.log("[updateArgument] is_reply:", o.is_reply, "| message_id:", o.message_id, "| parentId prop:", A), o.is_reply ? i = `argument_${o.message_id || A}_reply_list` : l && !m && (i = `argumentList${o.position?.id}`), console.log("[updateArgument] listId used for update:", i), ae?.position?.id != o.position?.id && !m && !o.is_reply) {
|
|
190
|
+
const I = `argumentList${ae.position.id}`, S = `argumentList${o.position.id}`;
|
|
191
|
+
console.log("[updateArgument] position changed, moving from", I, "to", S), T.remove(I, [o]), T.add(S, [o]);
|
|
192
192
|
} else
|
|
193
|
-
|
|
194
|
-
Y(
|
|
193
|
+
console.log("[updateArgument] calling list.update with listId:", i), T.update(i, [o]);
|
|
194
|
+
Y(r.formatMessage({ id: "alert.argument_modify" }), {
|
|
195
195
|
type: "success"
|
|
196
196
|
}), ue();
|
|
197
197
|
}
|
|
@@ -205,13 +205,13 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
205
205
|
return () => clearTimeout(e);
|
|
206
206
|
}
|
|
207
207
|
}, R = () => {
|
|
208
|
-
|
|
208
|
+
f ? W({ loginAction: "argument" }) : ne(!0);
|
|
209
209
|
}, Ve = () => {
|
|
210
|
-
const e =
|
|
210
|
+
const e = y.find(
|
|
211
211
|
(t) => t.id === l
|
|
212
212
|
);
|
|
213
213
|
if (e)
|
|
214
|
-
return
|
|
214
|
+
return r.formatMessage(
|
|
215
215
|
{
|
|
216
216
|
id: "info.argument_side_limit",
|
|
217
217
|
defaultMessage: "You have reached the argument limit (10) for position {position}."
|
|
@@ -220,27 +220,27 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
220
220
|
);
|
|
221
221
|
};
|
|
222
222
|
return /* @__PURE__ */ _("div", { className: n.inputContainer, children: [
|
|
223
|
-
j && /* @__PURE__ */
|
|
223
|
+
j && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ie ? r.formatMessage({
|
|
224
224
|
id: "input.argument_input.user_banned",
|
|
225
225
|
defaultMessage: "You are banned from the debate space."
|
|
226
|
-
}) :
|
|
226
|
+
}) : r.formatMessage({
|
|
227
227
|
id: "info.debate_is_inactive",
|
|
228
228
|
defaultMessage: "Debate is closed"
|
|
229
229
|
}) }),
|
|
230
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ s(
|
|
231
231
|
"div",
|
|
232
232
|
{
|
|
233
|
-
className:
|
|
233
|
+
className: x(n.argumentInput, {
|
|
234
234
|
[n.flash]: ee,
|
|
235
235
|
[n.replyInputContainer]: u
|
|
236
236
|
}),
|
|
237
|
-
children: /* @__PURE__ */
|
|
238
|
-
a.length > 0 &&
|
|
239
|
-
/* @__PURE__ */
|
|
237
|
+
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: H, children: /* @__PURE__ */ _("div", { className: n.argumentInputBox, children: [
|
|
238
|
+
a.length > 0 && w && (!u || !k) && /* @__PURE__ */ _("div", { className: n.userPosition, children: [
|
|
239
|
+
/* @__PURE__ */ s("div", { children: r.formatMessage({
|
|
240
240
|
id: "input.position",
|
|
241
241
|
defaultMessage: "Your position"
|
|
242
242
|
}) }),
|
|
243
|
-
/* @__PURE__ */
|
|
243
|
+
/* @__PURE__ */ s(
|
|
244
244
|
Ze,
|
|
245
245
|
{
|
|
246
246
|
activeLabel: l === a[0].id ? 0 : l === a[1].id ? 1 : null,
|
|
@@ -253,29 +253,29 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
253
253
|
/* @__PURE__ */ _(
|
|
254
254
|
"div",
|
|
255
255
|
{
|
|
256
|
-
className:
|
|
256
|
+
className: x(n.argumentTextInputBox, {
|
|
257
257
|
[n.argumentTextInputBoxisTablet]: !m,
|
|
258
258
|
[n.replyEditorRow]: u
|
|
259
259
|
}),
|
|
260
260
|
children: [
|
|
261
|
-
/* @__PURE__ */
|
|
261
|
+
/* @__PURE__ */ s(
|
|
262
262
|
"div",
|
|
263
263
|
{
|
|
264
|
-
className:
|
|
264
|
+
className: x(n.argumentAuthorContainer, {
|
|
265
265
|
[n.argumentAuthorContainerMobile]: m,
|
|
266
266
|
[n.argumentAuthorContainerActivated]: !m && C || u
|
|
267
267
|
}),
|
|
268
|
-
children: !m && C || u ? /* @__PURE__ */
|
|
268
|
+
children: !m && C || u ? /* @__PURE__ */ s(
|
|
269
269
|
et,
|
|
270
270
|
{
|
|
271
271
|
avatarUrl: d.image_url,
|
|
272
272
|
userName: d.full_name,
|
|
273
273
|
size: me
|
|
274
274
|
}
|
|
275
|
-
) : /* @__PURE__ */
|
|
275
|
+
) : /* @__PURE__ */ s(
|
|
276
276
|
tt,
|
|
277
277
|
{
|
|
278
|
-
fullName: d?.full_name ||
|
|
278
|
+
fullName: d?.full_name || r.formatMessage({ id: "default_author.full_name" }),
|
|
279
279
|
avatarUrl: d?.image_url,
|
|
280
280
|
points: d?.points || 0,
|
|
281
281
|
slug: d?.hash_id
|
|
@@ -288,11 +288,11 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
288
288
|
{
|
|
289
289
|
onClick: R,
|
|
290
290
|
"data-testid": "argument-input",
|
|
291
|
-
className:
|
|
291
|
+
className: x(n.textEditorBox, {
|
|
292
292
|
[n.replyTextEditorBox]: u
|
|
293
293
|
}),
|
|
294
294
|
children: [
|
|
295
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ s(
|
|
296
296
|
nt,
|
|
297
297
|
{
|
|
298
298
|
handleChange: (e, t) => {
|
|
@@ -302,39 +302,39 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
302
302
|
Pe(e);
|
|
303
303
|
},
|
|
304
304
|
placeholder: he,
|
|
305
|
-
"aria-label":
|
|
305
|
+
"aria-label": r.formatMessage({
|
|
306
306
|
id: "input.argument_input.aria_label",
|
|
307
307
|
defaultMessage: "Message input field"
|
|
308
308
|
}),
|
|
309
309
|
onSubmit: Le,
|
|
310
310
|
sources: V,
|
|
311
|
-
hideSourceAction:
|
|
311
|
+
hideSourceAction: fe || f,
|
|
312
312
|
uid: `Argument${v}`,
|
|
313
313
|
onActivation: R,
|
|
314
314
|
showStylesControls: C,
|
|
315
|
-
disabled: j ||
|
|
316
|
-
maxLength:
|
|
317
|
-
disableRichText: h?.actions?.disableRichText ||
|
|
315
|
+
disabled: j || f || ie,
|
|
316
|
+
maxLength: f ? !1 : h?.actions?.argumentMaxLength,
|
|
317
|
+
disableRichText: h?.actions?.disableRichText || f,
|
|
318
318
|
shortBar: u,
|
|
319
|
-
hideSubmit:
|
|
319
|
+
hideSubmit: f,
|
|
320
320
|
allowedDomains: h?.allowed_sources,
|
|
321
321
|
active: F,
|
|
322
322
|
hideCharCount: Me,
|
|
323
323
|
disableAutoActivate: ve
|
|
324
324
|
}
|
|
325
325
|
),
|
|
326
|
-
B?.content && /* @__PURE__ */
|
|
327
|
-
C &&
|
|
326
|
+
B?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: B && Object.values(B).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
|
|
327
|
+
C && y?.find(
|
|
328
328
|
(e) => e.id === l
|
|
329
329
|
) && /* @__PURE__ */ _(
|
|
330
330
|
"div",
|
|
331
331
|
{
|
|
332
|
-
className:
|
|
332
|
+
className: x(
|
|
333
333
|
n.argumentInputWarning,
|
|
334
334
|
n.disabledPositionWarning
|
|
335
335
|
),
|
|
336
336
|
children: [
|
|
337
|
-
/* @__PURE__ */
|
|
337
|
+
/* @__PURE__ */ s(
|
|
338
338
|
at,
|
|
339
339
|
{
|
|
340
340
|
name: "announcement",
|
|
@@ -343,24 +343,24 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
343
343
|
width: 20
|
|
344
344
|
}
|
|
345
345
|
),
|
|
346
|
-
/* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: Ve() })
|
|
347
347
|
]
|
|
348
348
|
}
|
|
349
349
|
),
|
|
350
|
-
C && J && !_e && /* @__PURE__ */
|
|
350
|
+
C && J && !_e && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
|
|
351
351
|
ce,
|
|
352
352
|
{
|
|
353
353
|
id: "alert.guide_message",
|
|
354
354
|
defaultMessage: "Contributions must comply with our {userCharter}.",
|
|
355
355
|
values: {
|
|
356
|
-
userCharter: /* @__PURE__ */
|
|
356
|
+
userCharter: /* @__PURE__ */ s(
|
|
357
357
|
"a",
|
|
358
358
|
{
|
|
359
359
|
className: n.guideMessage,
|
|
360
360
|
href: J,
|
|
361
361
|
target: "_blank",
|
|
362
362
|
rel: "noreferrer",
|
|
363
|
-
children: /* @__PURE__ */
|
|
363
|
+
children: /* @__PURE__ */ s(
|
|
364
364
|
ce,
|
|
365
365
|
{
|
|
366
366
|
id: "alert.user_charter",
|