@logora/debate 0.3.114 → 0.3.115
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
|
|
1
|
+
import { jsxs as A, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import Ye from "@rooks/use-sessionstorage-state";
|
|
3
|
-
import { useRef as ke, useState as c, useEffect as p, Suspense as
|
|
3
|
+
import { useRef as ke, useState as c, useEffect as p, Suspense as Re, lazy as je } from "react";
|
|
4
4
|
import { useIntl as ze, FormattedMessage as he } from "react-intl";
|
|
5
5
|
import { useLocation as Oe } from "react-router";
|
|
6
|
-
import
|
|
6
|
+
import x from "classnames";
|
|
7
7
|
import n from "./ArgumentInput.module.scss.js";
|
|
8
8
|
import { useDataProvider as Je } from "../../data/data_provider/useDataProvider.js";
|
|
9
9
|
import { useList as Ke } from "../../list/list_provider/useList.js";
|
|
@@ -20,22 +20,22 @@ import { Avatar as st } from "../../user/avatar/Avatar.js";
|
|
|
20
20
|
import { AuthorBox as it } from "../../user/author_box/AuthorBox.js";
|
|
21
21
|
import { TextEditor as ot } from "../text_editor/TextEditor.js";
|
|
22
22
|
import { Icon as rt } from "../../icons/icon/Icon.js";
|
|
23
|
-
const ut =
|
|
24
|
-
argumentListId:
|
|
23
|
+
const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ default: N.SideModal }))), Ft = ({
|
|
24
|
+
argumentListId: N,
|
|
25
25
|
avatarSize: pe = 48,
|
|
26
26
|
disabled: O = !1,
|
|
27
27
|
positions: a = [],
|
|
28
|
-
disabledPositions:
|
|
29
|
-
groupId:
|
|
28
|
+
disabledPositions: y = [],
|
|
29
|
+
groupId: _,
|
|
30
30
|
groupName: _e,
|
|
31
31
|
groupType: J,
|
|
32
32
|
hideSourceAction: Me = !1,
|
|
33
33
|
isReply: r = !1,
|
|
34
34
|
onSubmit: K,
|
|
35
35
|
onUpdate: G,
|
|
36
|
-
parentId:
|
|
36
|
+
parentId: M,
|
|
37
37
|
placeholder: ve,
|
|
38
|
-
positionId:
|
|
38
|
+
positionId: C,
|
|
39
39
|
focusOnInit: be = !1,
|
|
40
40
|
activeOnInit: P = !1,
|
|
41
41
|
userGuideUrl: H,
|
|
@@ -44,31 +44,31 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
44
44
|
disableAutoActivate: we = !1,
|
|
45
45
|
autoFocus: Q = !1
|
|
46
46
|
}) => {
|
|
47
|
-
const o = ze(), X = Je(),
|
|
47
|
+
const o = ze(), X = Je(), T = Ke(), v = Ge(), {
|
|
48
48
|
focus: Z,
|
|
49
49
|
setFocus: ee,
|
|
50
|
-
setReset:
|
|
50
|
+
setReset: Se,
|
|
51
51
|
inputContent: B,
|
|
52
52
|
setInputContent: te,
|
|
53
|
-
setInputRichContent:
|
|
54
|
-
} = He(), { isLoggedIn:
|
|
53
|
+
setInputRichContent: Ie
|
|
54
|
+
} = He(), { isLoggedIn: w, currentUser: u } = Qe(), { errors: E, validate: $ } = Xe(), { isMobile: m } = Ze(), xe = Oe(), ne = ke(null), [V, q] = c([]), [D, U] = c(""), [ae, W] = c(null), [d, b] = c(null), [se, ie] = c(null), [oe, re] = c(!1), [S, ue] = c(!1), [I, de] = c({}), [Ne, Y] = c(!1), [f, ye] = Ye(
|
|
55
55
|
"userSide",
|
|
56
56
|
{}
|
|
57
|
-
), [g,
|
|
58
|
-
!
|
|
59
|
-
), k = et(), { showModal: Le } = tt(), { toast:
|
|
57
|
+
), [g, Te] = c(
|
|
58
|
+
!w && v?.actions?.disableInputForVisitor
|
|
59
|
+
), k = et(), { showModal: Le } = tt(), { toast: R } = nt() || {}, le = new URLSearchParams(
|
|
60
60
|
typeof window < "u" ? window.location.search : xe.search
|
|
61
61
|
);
|
|
62
62
|
p(() => {
|
|
63
|
-
|
|
64
|
-
!
|
|
63
|
+
Te(
|
|
64
|
+
!w && v?.actions?.disableInputForVisitor
|
|
65
65
|
);
|
|
66
|
-
}, [
|
|
67
|
-
const
|
|
66
|
+
}, [w, v]);
|
|
67
|
+
const j = u?.role === "editor" || u?.role === "moderator", ce = u?.moderation_status === "banned";
|
|
68
68
|
p(() => {
|
|
69
69
|
let e = null;
|
|
70
|
-
typeof window < "u" && (e = le.get("positionId")),
|
|
71
|
-
}, [
|
|
70
|
+
typeof window < "u" && (e = le.get("positionId")), C && C != a[2]?.id && a?.find((t) => t.id === C) ? b(C) : e && e != a[2]?.id ? b(e) : f && f.groupId == _ && f.positionId != a[2]?.id && b(f.positionId);
|
|
71
|
+
}, [C]), p(() => {
|
|
72
72
|
Q && Y(!0);
|
|
73
73
|
}, [Q]), p(() => {
|
|
74
74
|
P && (z(), Y(!0), L());
|
|
@@ -83,16 +83,16 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
83
83
|
B?.id && (Fe(B), ee(!0));
|
|
84
84
|
}, [B]);
|
|
85
85
|
const Fe = (e) => {
|
|
86
|
-
de(e), ue(!0), q(e.sources), U(e.content), W(e.rich_content), ie(e.id), L(),
|
|
86
|
+
de(e), ue(!0), q(e.sources), U(e.content), W(e.rich_content), ie(e.id), L(), b(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ie(e.rich_content) : te(e.content);
|
|
87
87
|
}, L = () => {
|
|
88
88
|
ne.current.scrollIntoView(!1);
|
|
89
89
|
}, me = () => {
|
|
90
|
-
U(""), W(null), de({}), ie(null), q([]),
|
|
90
|
+
U(""), W(null), de({}), ie(null), q([]), Se(!0), te(null);
|
|
91
91
|
}, Pe = (e) => {
|
|
92
|
-
|
|
92
|
+
b(e), ge(e);
|
|
93
93
|
}, Be = () => {
|
|
94
94
|
Le(
|
|
95
|
-
/* @__PURE__ */ s(
|
|
95
|
+
/* @__PURE__ */ s(Re, { fallback: null, children: /* @__PURE__ */ s(
|
|
96
96
|
ut,
|
|
97
97
|
{
|
|
98
98
|
modalTitle: o.formatMessage({
|
|
@@ -102,16 +102,16 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
102
102
|
onChooseSide: Pe,
|
|
103
103
|
positions: a,
|
|
104
104
|
title: _e,
|
|
105
|
-
disabledPositions: !r &&
|
|
106
|
-
isNeutral: f && f.groupId ==
|
|
105
|
+
disabledPositions: !r && y,
|
|
106
|
+
isNeutral: f && f.groupId == _ && f.positionId === a[2]?.id
|
|
107
107
|
}
|
|
108
108
|
) })
|
|
109
109
|
);
|
|
110
110
|
}, Ee = () => {
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
g ? k({ loginAction: "argument" }) : (U(e), W(t),
|
|
114
|
-
},
|
|
111
|
+
w ? se ? qe() : !a || a?.length === 0 || !y?.find((e) => e?.id === d) && d || j && r ? ge(r && j && a[0]?.id) : Be() : k({ loginAction: "argument" });
|
|
112
|
+
}, $e = (e, t) => {
|
|
113
|
+
g ? k({ loginAction: "argument" }) : (U(e), W(t), $({ content: e }, [{ content: ["url", null] }]));
|
|
114
|
+
}, Ve = (e) => {
|
|
115
115
|
q(e);
|
|
116
116
|
}, fe = [
|
|
117
117
|
{ content: ["length", 3] },
|
|
@@ -122,20 +122,20 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
122
122
|
const t = e || d, l = {
|
|
123
123
|
content: D,
|
|
124
124
|
rich_content: ae,
|
|
125
|
-
group_id:
|
|
125
|
+
group_id: _,
|
|
126
126
|
...J && { group_type: J },
|
|
127
127
|
...t && { position_id: t },
|
|
128
|
-
is_reply: !!
|
|
129
|
-
message_id:
|
|
130
|
-
source_ids:
|
|
128
|
+
is_reply: !!M,
|
|
129
|
+
message_id: M || null,
|
|
130
|
+
source_ids: V?.map((i) => i.id)
|
|
131
131
|
};
|
|
132
|
-
|
|
133
|
-
groupId:
|
|
132
|
+
$(l, fe) && (t && a && a.map((i) => i.id).includes(t) && ye({
|
|
133
|
+
groupId: _,
|
|
134
134
|
positionId: t
|
|
135
135
|
}), me(), X.create("messages", l).then((i) => {
|
|
136
136
|
if (i.data.success) {
|
|
137
|
-
if (
|
|
138
|
-
K(i.data.data.resource),
|
|
137
|
+
if (M)
|
|
138
|
+
K(i.data.data.resource), R(
|
|
139
139
|
o.formatMessage({
|
|
140
140
|
id: "alert.argument_create",
|
|
141
141
|
defaultMessage: "Your contribution has been sent !"
|
|
@@ -150,11 +150,11 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
150
150
|
);
|
|
151
151
|
else {
|
|
152
152
|
const h = i.data.data.resource;
|
|
153
|
-
let F =
|
|
153
|
+
let F = N;
|
|
154
154
|
t && !m && (F = `argumentList${h.position.id}`), K?.(
|
|
155
155
|
D,
|
|
156
156
|
a.find((We) => We.id === t) || null
|
|
157
|
-
),
|
|
157
|
+
), T.add(F, [h]), R(
|
|
158
158
|
o.formatMessage({
|
|
159
159
|
id: "alert.argument_create",
|
|
160
160
|
defaultMessage: "Your contribution has been sent !"
|
|
@@ -183,23 +183,23 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
183
183
|
const e = {
|
|
184
184
|
content: D,
|
|
185
185
|
rich_content: ae,
|
|
186
|
-
source_ids:
|
|
186
|
+
source_ids: V?.map((t) => t.id),
|
|
187
187
|
...d && { position_id: d }
|
|
188
188
|
};
|
|
189
|
-
|
|
189
|
+
$(e, fe) && X.update("messages", se, e).then((t) => {
|
|
190
190
|
if (t.data.success) {
|
|
191
191
|
const l = t.data.data.resource;
|
|
192
|
-
let i =
|
|
192
|
+
let i = N;
|
|
193
193
|
if (I?.is_reply || r) {
|
|
194
|
-
const h = I?.message_id ||
|
|
194
|
+
const h = I?.message_id || M;
|
|
195
195
|
h && (i = `argument_${h}_reply_list`);
|
|
196
196
|
} else d && !m && (i = `argumentList${l.position?.id}`);
|
|
197
197
|
if (!I?.is_reply && I?.position?.id != l.position?.id && !m) {
|
|
198
198
|
const h = `argumentList${I.position.id}`, F = `argumentList${l.position.id}`;
|
|
199
|
-
|
|
199
|
+
T.remove(h, [l]), T.add(F, [l]);
|
|
200
200
|
} else
|
|
201
|
-
|
|
202
|
-
G && G(l),
|
|
201
|
+
T.update(i, [l]);
|
|
202
|
+
G && G(l), R(o.formatMessage({ id: "alert.argument_modify" }), {
|
|
203
203
|
type: "success"
|
|
204
204
|
}), me();
|
|
205
205
|
}
|
|
@@ -215,7 +215,7 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
215
215
|
}, z = () => {
|
|
216
216
|
g ? k({ loginAction: "argument" }) : ue(!0);
|
|
217
217
|
}, Ue = () => {
|
|
218
|
-
const e =
|
|
218
|
+
const e = y.find(
|
|
219
219
|
(t) => t.id === d
|
|
220
220
|
);
|
|
221
221
|
if (e)
|
|
@@ -227,7 +227,7 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
227
227
|
{ position: e.name }
|
|
228
228
|
);
|
|
229
229
|
};
|
|
230
|
-
return /* @__PURE__ */
|
|
230
|
+
return /* @__PURE__ */ A("div", { className: n.inputContainer, children: [
|
|
231
231
|
O && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ce ? o.formatMessage({
|
|
232
232
|
id: "input.argument_input.user_banned",
|
|
233
233
|
defaultMessage: "You are banned from the debate space."
|
|
@@ -238,12 +238,12 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
238
238
|
/* @__PURE__ */ s(
|
|
239
239
|
"div",
|
|
240
240
|
{
|
|
241
|
-
className:
|
|
241
|
+
className: x(n.argumentInput, {
|
|
242
242
|
[n.flash]: oe,
|
|
243
243
|
[n.replyInputContainer]: r
|
|
244
244
|
}),
|
|
245
|
-
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ne, children: /* @__PURE__ */
|
|
246
|
-
a.length > 0 &&
|
|
245
|
+
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ne, children: /* @__PURE__ */ A("div", { className: n.argumentInputBox, children: [
|
|
246
|
+
a.length > 0 && w && (!r || !j) && /* @__PURE__ */ A("div", { className: n.userPosition, children: [
|
|
247
247
|
/* @__PURE__ */ s("div", { children: o.formatMessage({
|
|
248
248
|
id: "input.position",
|
|
249
249
|
defaultMessage: "Your position"
|
|
@@ -254,14 +254,14 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
254
254
|
activeLabel: d === a[0].id ? 0 : d === a[1].id ? 1 : null,
|
|
255
255
|
firstLabel: a[0],
|
|
256
256
|
secondLabel: a[1],
|
|
257
|
-
onChange: (e) =>
|
|
257
|
+
onChange: (e) => b(a[e].id)
|
|
258
258
|
}
|
|
259
259
|
)
|
|
260
260
|
] }),
|
|
261
|
-
/* @__PURE__ */
|
|
261
|
+
/* @__PURE__ */ A(
|
|
262
262
|
"div",
|
|
263
263
|
{
|
|
264
|
-
className:
|
|
264
|
+
className: x(n.argumentTextInputBox, {
|
|
265
265
|
[n.argumentTextInputBoxisTablet]: !m,
|
|
266
266
|
[n.replyEditorRow]: r
|
|
267
267
|
}),
|
|
@@ -269,11 +269,11 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
269
269
|
/* @__PURE__ */ s(
|
|
270
270
|
"div",
|
|
271
271
|
{
|
|
272
|
-
className:
|
|
272
|
+
className: x(n.argumentAuthorContainer, {
|
|
273
273
|
[n.argumentAuthorContainerMobile]: m,
|
|
274
|
-
[n.argumentAuthorContainerActivated]: !m &&
|
|
274
|
+
[n.argumentAuthorContainerActivated]: !m && S || r
|
|
275
275
|
}),
|
|
276
|
-
children: !m &&
|
|
276
|
+
children: !m && S || r ? /* @__PURE__ */ s(
|
|
277
277
|
st,
|
|
278
278
|
{
|
|
279
279
|
avatarUrl: u.image_url,
|
|
@@ -291,12 +291,12 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
291
291
|
)
|
|
292
292
|
}
|
|
293
293
|
),
|
|
294
|
-
/* @__PURE__ */
|
|
294
|
+
/* @__PURE__ */ A(
|
|
295
295
|
"div",
|
|
296
296
|
{
|
|
297
297
|
onClick: z,
|
|
298
298
|
"data-testid": "argument-input",
|
|
299
|
-
className:
|
|
299
|
+
className: x(n.textEditorBox, {
|
|
300
300
|
[n.replyTextEditorBox]: r
|
|
301
301
|
}),
|
|
302
302
|
children: [
|
|
@@ -304,10 +304,10 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
304
304
|
ot,
|
|
305
305
|
{
|
|
306
306
|
handleChange: (e, t) => {
|
|
307
|
-
|
|
307
|
+
$e(e, t);
|
|
308
308
|
},
|
|
309
309
|
handleSourcesChange: (e) => {
|
|
310
|
-
|
|
310
|
+
Ve(e);
|
|
311
311
|
},
|
|
312
312
|
placeholder: ve,
|
|
313
313
|
"aria-label": o.formatMessage({
|
|
@@ -315,17 +315,17 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
315
315
|
defaultMessage: "Message input field"
|
|
316
316
|
}),
|
|
317
317
|
onSubmit: Ee,
|
|
318
|
-
sources:
|
|
318
|
+
sources: V,
|
|
319
319
|
hideSourceAction: Me || g,
|
|
320
|
-
uid: `Argument${
|
|
320
|
+
uid: M ? `Reply${_}_${M}` : `Argument${_}`,
|
|
321
321
|
onActivation: z,
|
|
322
|
-
showStylesControls:
|
|
322
|
+
showStylesControls: S,
|
|
323
323
|
disabled: O || g || ce,
|
|
324
|
-
maxLength: g ? !1 :
|
|
325
|
-
disableRichText:
|
|
324
|
+
maxLength: g ? !1 : v?.actions?.argumentMaxLength,
|
|
325
|
+
disableRichText: v?.actions?.disableRichText || g,
|
|
326
326
|
shortBar: r,
|
|
327
327
|
hideSubmit: g,
|
|
328
|
-
allowedDomains:
|
|
328
|
+
allowedDomains: v?.allowed_sources,
|
|
329
329
|
active: P,
|
|
330
330
|
autoFocus: Ne,
|
|
331
331
|
hideCharCount: Ce,
|
|
@@ -333,12 +333,12 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
333
333
|
}
|
|
334
334
|
),
|
|
335
335
|
E?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: E && Object.values(E).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
|
|
336
|
-
|
|
336
|
+
S && y?.find(
|
|
337
337
|
(e) => e.id === d
|
|
338
|
-
) && /* @__PURE__ */
|
|
338
|
+
) && /* @__PURE__ */ A(
|
|
339
339
|
"div",
|
|
340
340
|
{
|
|
341
|
-
className:
|
|
341
|
+
className: x(
|
|
342
342
|
n.argumentInputWarning,
|
|
343
343
|
n.disabledPositionWarning
|
|
344
344
|
),
|
|
@@ -356,7 +356,7 @@ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
356
356
|
]
|
|
357
357
|
}
|
|
358
358
|
),
|
|
359
|
-
|
|
359
|
+
S && H && !Ae && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
|
|
360
360
|
he,
|
|
361
361
|
{
|
|
362
362
|
id: "alert.guide_message",
|