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