@logora/debate 0.3.65 → 0.3.67

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 _ } from "react/jsx-runtime";
2
- import D from "classnames";
3
- import { useState as g, useEffect as P, useCallback as de, Suspense as ce, lazy as pe } from "react";
4
- import { useIntl as ue } from "react-intl";
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 he } from "./useRichContent.js";
8
- import { useAuth as fe } from "../../auth/use_auth/useAuth.js";
9
- import { useConfig as ye } from "../../data/config_provider/useConfig.js";
10
- import { useTranslatedContent as F } from "../../translation/translated_content/useTranslatedContent.js";
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 j } from "../../icons/icon/Icon.js";
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 Re } from "../../list/paginated_list/VotePaginatedList.js";
20
- import { UserContentSkeleton as we } from "../../skeleton/user_content_skeleton/UserContentSkeleton.js";
21
- import { Button as Se } from "../../action/button/Button.js";
22
- const Te = pe(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), G = (e) => e?.replace(/ /g, " "), Ne = ({
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: d,
25
- nestingLevel: b = 0,
26
- maxNestingLevel: w = 2,
27
- groupType: S,
28
- groupName: T,
29
- positions: M = [],
30
- disableLinks: H = !1,
31
- parentArgument: c,
32
- flashParent: V,
33
- expandable: z,
34
- disabled: v = !1,
35
- hideFooter: N = !1,
36
- hideReplies: A,
37
- vote: O,
38
- fixedContentHeight: Y = !1,
39
- enableEdition: q = !0,
40
- enableDeletion: J = !0,
41
- deleteListId: K,
42
- showModerationFeedback: Q,
43
- lineCount: W = 5,
44
- replyRedirectUrl: X,
45
- hideContent: Z = !1
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 = ue(), { isLoggedIn: ee, currentUser: p } = fe(), x = p?.moderation_status === "banned", r = ye(), [u, I] = g(!1), [te, L] = g(!1), [oe, se] = g(!1), U = he(e), [m, h] = g(), f = F(
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
- ), re = F(
53
+ ), oe = D(
53
54
  e.position?.name,
54
55
  e.position?.language,
55
56
  "name",
56
57
  e.position?.translation_entries
57
- ), C = `argument_${e.id}`, R = e.position && M?.map((t) => t.id).indexOf(e.position.id) + 1;
58
- P(() => {
59
- d !== void 0 && ne();
60
- }, [d]), P(() => {
61
- if (typeof window > "u") return;
62
- const t = (a) => {
63
- const n = a.detail?.reply;
64
- !n || n.reply_to_id !== e.id || h((y) => !y || y.length === 0 ? y : y.map((E) => E.id === n.id ? n : E));
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
- se((t) => !t);
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
- }, le = de((t, a) => /* @__PURE__ */ o(
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
- ), []), ne = () => {
92
- if (d && Array.isArray(d)) {
93
- const t = d.filter(
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 && (h(t), I(!0));
88
+ t.length > 0 && (x(t), b(!0));
97
89
  }
98
- }, B = (t = null) => /* @__PURE__ */ o(
90
+ }, U = (t = null) => /* @__PURE__ */ o(
99
91
  Ae,
100
92
  {
101
93
  ...t ? { argument: t } : {},
102
- nestingLevel: b + 1,
103
- maxNestingLevel: w,
104
- disabled: v,
105
- groupName: T,
106
- groupType: S,
107
- positions: M,
108
- argumentReplies: d,
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) => ie(`argument_${a}`)
102
+ flashParent: (a) => se(`argument_${a}`)
111
103
  }
112
104
  );
113
- return /* @__PURE__ */ l(ge, { elementId: C, onScroll: () => L(!0), children: [
105
+ return /* @__PURE__ */ l(ge, { elementId: M, onScroll: () => w(!0), children: [
114
106
  /* @__PURE__ */ l(
115
107
  "div",
116
108
  {
117
- className: D(
109
+ className: B(
118
110
  s.argument,
119
111
  {
120
- [s.flash]: te,
112
+ [s.flash]: Z,
121
113
  [s.argumentReply]: e.is_reply === !0
122
114
  },
123
- s[`level-${b}`],
124
- s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && R}`]
115
+ s[`level-${y}`],
116
+ s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && v}`]
125
117
  ),
126
- id: C,
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 : re.translatedContent,
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-${R}`],
136
- disableLinks: H,
127
+ tagClassName: s[`headerPosition-${v}`],
128
+ disableLinks: F,
137
129
  isDeleted: e.is_deleted,
138
- showModerationFeedback: Q ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
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
- }) }) : Z ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
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(_, { children: [
142
+ }) }) : /* @__PURE__ */ l(h, { children: [
151
143
  /* @__PURE__ */ l(
152
144
  "div",
153
145
  {
154
- className: D(s.argumentBody, {
155
- [s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? Y : !1
146
+ className: B(s.argumentBody, {
147
+ [s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? V : !1
156
148
  }),
157
149
  children: [
158
- e.is_reply && c && /* @__PURE__ */ l(
150
+ e.is_reply && d && /* @__PURE__ */ l(
159
151
  "div",
160
152
  {
161
153
  className: s.replyTo,
162
- onClick: () => V(c.id),
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
- c.is_deleted ? i.formatMessage({
161
+ d.is_deleted ? i.formatMessage({
170
162
  id: "info.deleted",
171
163
  defaultMessage: "Deleted"
172
- }) : c.author.full_name,
173
- /* @__PURE__ */ o(j, { name: "chat", height: 16 })
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(_, { children: [
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
- U && !f.isTranslated ? /* @__PURE__ */ o(
178
+ A && !u.isTranslated ? /* @__PURE__ */ o(
187
179
  "div",
188
180
  {
189
181
  className: s.argumentContent,
190
- dangerouslySetInnerHTML: { __html: G(U) }
182
+ dangerouslySetInnerHTML: { __html: P(A) }
191
183
  }
192
- ) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: G(f.translatedContent) }),
193
- f.isTranslated && /* @__PURE__ */ o(
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: () => f.toggleContent()
189
+ callback: () => u.toggleContent()
198
190
  }
199
191
  )
200
192
  ] }),
201
- lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ? W : void 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 ? z : !1,
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(le) })
209
+ e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(ie) })
218
210
  ] }),
219
- !N && !e.is_deleted && /* @__PURE__ */ o(
211
+ !R && !e.is_deleted && /* @__PURE__ */ o(
220
212
  Ie,
221
213
  {
222
214
  resource: e,
223
- disabled: v || e.status === "rejected" || !ee && r?.actions?.disableInputForVisitor === !0 || x,
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: K,
228
- enableReply: b <= w || p.role === "editor" || p.role === "moderator",
229
- handleReplyTo: k,
230
- replyRedirectUrl: X,
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: q,
246
- enableDeletion: J,
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-${R}`],
255
- disabled: e.status === "rejected" || p?.id === e?.author?.id || x
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
- !N && !A && /* @__PURE__ */ o(
252
+ !R && !T && /* @__PURE__ */ o(
261
253
  me,
262
254
  {
263
255
  numberReplies: e.number_replies,
264
256
  repliesAuthors: e.replies_authors,
265
- expandReplies: u,
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
- !A && /* @__PURE__ */ l(_, { children: [
274
- oe && /* @__PURE__ */ o(ce, { fallback: null, children: /* @__PURE__ */ o(
275
- Te,
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: S,
279
- groupName: T,
280
- positions: M,
270
+ groupType: C,
271
+ groupName: S,
272
+ positions: _,
281
273
  parentId: e.id,
282
- positionId: O?.position_id,
283
- disabled: v,
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
- k(), h([t]), I(!0);
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 && u && /* @__PURE__ */ o("div", { className: s.repliesList, children: m.map((t) => B(t)) }),
301
- u && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
302
- Re,
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(we, {}),
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) => ae(t),
319
- children: B(e)
309
+ emptyListComponent: /* @__PURE__ */ o(h, {}),
310
+ transformData: (t) => re(t),
311
+ children: U(e)
320
312
  }
321
313
  ) }),
322
- m?.length > 0 && !u && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
323
- Se,
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(j, { name: "lightArrow", height: 10, width: 10 }),
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 = Ne;
328
+ }, Ae = we;
337
329
  export {
338
- Ne as Argument,
330
+ we as Argument,
339
331
  Ae as ArgumentContainer
340
332
  };
@@ -1,9 +1,9 @@
1
- import { jsxs as _, jsx as i } from "react/jsx-runtime";
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 C from "classnames";
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((I) => ({ default: I.SideModal }))), xt = ({
24
- argumentListId: I,
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: S = [],
29
- groupId: M,
28
+ disabledPositions: x = [],
29
+ groupId: b,
30
30
  groupName: ge,
31
31
  groupType: O,
32
32
  hideSourceAction: he = !1,
33
- isReply: d = !1,
33
+ isReply: r = !1,
34
34
  onSubmit: J,
35
- parentId: L,
35
+ parentId: F,
36
36
  placeholder: pe,
37
- positionId: w,
37
+ positionId: A,
38
38
  focusOnInit: _e = !1,
39
- activeOnInit: F = !1,
39
+ activeOnInit: P = !1,
40
40
  userGuideUrl: K,
41
- hideUserGuideLink: ve = !1,
42
- hideCharCount: Me = !1,
43
- disableAutoActivate: we = !1
41
+ hideUserGuideLink: Me = !1,
42
+ hideCharCount: ve = !1,
43
+ disableAutoActivate: be = !1
44
44
  }) => {
45
- const r = Ye(), G = Re(), y = je(), h = ze(), {
45
+ const o = Ye(), G = Re(), N = je(), h = ze(), {
46
46
  focus: H,
47
- setFocus: x,
48
- setReset: be,
49
- inputContent: E,
47
+ setFocus: T,
48
+ setReset: Ae,
49
+ inputContent: B,
50
50
  setInputContent: Q,
51
- setInputRichContent: Ae
52
- } = Oe(), { isLoggedIn: b, currentUser: u } = Je(), { errors: P, validate: B } = Ke(), { isMobile: m } = Ge(), Ce = ke(), X = qe(null), [V, U] = c([]), [$, q] = c(""), [Z, D] = c(null), [l, p] = c(null), [ee, te] = c(null), [ne, ae] = c(!1), [A, ie] = c(!1), [W, se] = c({}), [f, Ie] = $e(
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
- !b && h?.actions?.disableInputForVisitor
57
- ), Y = He(), { showModal: ye } = Qe(), { toast: k } = Xe() || {}, oe = new URLSearchParams(
58
- typeof window < "u" ? window.location.search : Ce.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
- !b && h?.actions?.disableInputForVisitor
62
+ !C && h?.actions?.disableInputForVisitor
63
63
  );
64
- }, [b, h]);
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")), w && w != a[2]?.id && a?.find((t) => t.id === w) ? p(w) : e && e != a[2]?.id ? p(e) : f && f.groupId == M && f.positionId != a[2]?.id && p(f.positionId);
69
- }, [w]), v(() => {
70
- F && (j(), x(!0));
71
- }, [F]), v(() => {
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") && (x(!0), Be());
74
+ (e === !0 || e === "true") && (T(!0), Ee());
75
75
  }
76
76
  }, []), v(() => {
77
- H && (de(), x(!1));
77
+ H && (ue(), T(!1));
78
78
  }, [H]), v(() => {
79
- E?.id && (xe(E), x(!0));
80
- }, [E]);
81
- const xe = (e) => {
82
- se(e), ie(!0), U(e.sources), q(e.content), D(e.rich_content), te(e.id), de(), p(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ae(e.rich_content) : Q(e.content);
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
- q(""), D(null), se({}), te(null), U([]), be(!0), Q(null);
87
- }, Ne = (e) => {
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
- }, Te = () => {
90
- ye(
89
+ }, ye = () => {
90
+ xe(
91
91
  /* @__PURE__ */ i(De, { fallback: null, children: /* @__PURE__ */ i(
92
92
  it,
93
93
  {
94
- modalTitle: r.formatMessage({
94
+ modalTitle: o.formatMessage({
95
95
  id: "modal.side_modal.modal_title",
96
96
  defaultMessage: "Choose your side"
97
97
  }),
98
- onChooseSide: Ne,
98
+ onChooseSide: Te,
99
99
  positions: a,
100
100
  title: ge,
101
- disabledPositions: !d && S,
102
- isNeutral: f && f.groupId == M && f.positionId === a[2]?.id
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
- b ? ee ? Pe() : !a || a?.length === 0 || !S?.find((e) => e?.id === l) && l || R && d ? ce(d && R && a[0]?.id) : Te() : Y({ loginAction: "argument" });
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" }) : (q(e), D(t), B({ content: e }, [{ content: ["url", null] }]));
110
- }, Ee = (e) => {
111
- U(e);
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 || l, s = {
119
- content: $,
118
+ const t = e || d, l = {
119
+ content: q,
120
120
  rich_content: Z,
121
- group_id: M,
121
+ group_id: b,
122
122
  ...O && { group_type: O },
123
123
  ...t && { position_id: t },
124
- is_reply: !!L,
125
- message_id: L || null,
126
- source_ids: V?.map((o) => o.id)
124
+ is_reply: !!F,
125
+ message_id: F || null,
126
+ source_ids: U?.map((s) => s.id)
127
127
  };
128
- B(s, le) && (t && a && a.map((o) => o.id).includes(t) && Ie({
129
- groupId: M,
128
+ V(l, le) && (t && a && a.map((s) => s.id).includes(t) && Ie({
129
+ groupId: b,
130
130
  positionId: t
131
- }), ue(), G.create("messages", s).then((o) => {
132
- if (o.data.success) {
133
- if (L)
134
- J(o.data.data.resource), k(
135
- r.formatMessage({
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: r.formatMessage({
141
+ points: o.formatMessage({
142
142
  id: "alert.reply_gain",
143
143
  defaultMessage: " "
144
144
  })
145
145
  }
146
146
  );
147
147
  else {
148
- const N = o.data.data.resource;
149
- let T = I;
150
- t && !m && (T = `argumentList${N.position.id}`), J?.(
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
- ), y.add(T, [N]), k(
154
- r.formatMessage({
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: r.formatMessage({
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: o.data.data?.resource
172
+ content: s.data.data?.resource
173
173
  }
174
174
  })
175
175
  );
176
176
  }
177
177
  }));
178
- }, Pe = () => {
178
+ }, Be = () => {
179
179
  const e = {
180
- content: $,
180
+ content: q,
181
181
  rich_content: Z,
182
- source_ids: V?.map((t) => t.id),
183
- ...l && { position_id: l }
182
+ source_ids: U?.map((t) => t.id),
183
+ ...d && { position_id: d }
184
184
  };
185
- B(e, le) && G.update("messages", ee, e).then((t) => {
185
+ V(e, le) && G.update("messages", ee, e).then((t) => {
186
186
  if (t.data.success) {
187
- const s = t.data.data.resource;
188
- let o = I;
189
- if (s.is_reply ? o = `argument_${s.reply_to_id || W?.reply_to_id}_reply_list` : l && !m && (o = `argumentList${s.position?.id}`), W?.position?.id != s.position?.id && !m && !s.is_reply) {
190
- const N = `argumentList${W.position.id}`, T = `argumentList${s.position.id}`;
191
- y.remove(N, [s]), y.add(T, [s]);
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
- y.update(o, [s]), s.is_reply && typeof window < "u" && window.dispatchEvent(
194
- new CustomEvent("logora:reply:updated", {
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
- }), ue();
196
+ }), de();
201
197
  }
202
198
  });
203
- }, Be = () => {
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 = S.find(
215
- (t) => t.id === l
210
+ const e = x.find(
211
+ (t) => t.id === d
216
212
  );
217
213
  if (e)
218
- return r.formatMessage(
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__ */ _("div", { className: n.inputContainer, children: [
227
- z && /* @__PURE__ */ i("div", { className: n.disabledInputMask, children: re ? r.formatMessage({
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
- }) : r.formatMessage({
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: C(n.argumentInput, {
233
+ className: I(n.argumentInput, {
238
234
  [n.flash]: ne,
239
- [n.replyInputContainer]: d
235
+ [n.replyInputContainer]: r
240
236
  }),
241
- children: /* @__PURE__ */ i("div", { "data-tid": "action_add_argument", ref: X, children: /* @__PURE__ */ _("div", { className: n.argumentInputBox, children: [
242
- a.length > 0 && b && (!d || !R) && /* @__PURE__ */ _("div", { className: n.userPosition, children: [
243
- /* @__PURE__ */ i("div", { children: r.formatMessage({
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: l === a[0].id ? 0 : l === a[1].id ? 1 : null,
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: C(n.argumentTextInputBox, {
256
+ className: I(n.argumentTextInputBox, {
261
257
  [n.argumentTextInputBoxisTablet]: !m,
262
- [n.replyEditorRow]: d
258
+ [n.replyEditorRow]: r
263
259
  }),
264
260
  children: [
265
261
  /* @__PURE__ */ i(
266
262
  "div",
267
263
  {
268
- className: C(n.argumentAuthorContainer, {
264
+ className: I(n.argumentAuthorContainer, {
269
265
  [n.argumentAuthorContainerMobile]: m,
270
- [n.argumentAuthorContainerActivated]: !m && A || d
266
+ [n.argumentAuthorContainerActivated]: !m && w || r
271
267
  }),
272
- children: !m && A || d ? /* @__PURE__ */ i(
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 || r.formatMessage({ id: "default_author.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: C(n.textEditorBox, {
296
- [n.replyTextEditorBox]: d
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
- Ee(e);
302
+ Pe(e);
307
303
  },
308
304
  placeholder: pe,
309
- "aria-label": r.formatMessage({
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: V,
310
+ sources: U,
315
311
  hideSourceAction: he || g,
316
- uid: `Argument${M}`,
312
+ uid: `Argument${b}`,
317
313
  onActivation: j,
318
- showStylesControls: A,
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: d,
318
+ shortBar: r,
323
319
  hideSubmit: g,
324
320
  allowedDomains: h?.allowed_sources,
325
- active: F,
326
- hideCharCount: Me,
327
- disableAutoActivate: we
321
+ active: P,
322
+ hideCharCount: ve,
323
+ disableAutoActivate: be
328
324
  }
329
325
  ),
330
- P?.content && /* @__PURE__ */ i("div", { className: n.argumentInputWarning, children: P && Object.values(P).map((e, t) => /* @__PURE__ */ i("div", { children: e }, t)) }),
331
- A && S?.find(
332
- (e) => e.id === l
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: C(
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
- A && K && !ve && /* @__PURE__ */ i("div", { className: n.guideMessage, children: /* @__PURE__ */ i(
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
- xt as ArgumentInput
387
+ Nt as ArgumentInput
392
388
  };
@@ -1,182 +1,182 @@
1
- import { jsxs as p, Fragment as Y, jsx as o } from "react/jsx-runtime";
2
- import { ListNode as Z, ListItemNode as oo } from "@lexical/list";
3
- import { OverflowNode as to } from "@lexical/overflow";
4
- import { CharacterLimitPlugin as eo } from "@lexical/react/LexicalCharacterLimitPlugin";
5
- import { LexicalComposer as ro } from "@lexical/react/LexicalComposer";
6
- import { ContentEditable as io } from "@lexical/react/LexicalContentEditable";
7
- import { EditorRefPlugin as no } from "@lexical/react/LexicalEditorRefPlugin";
8
- import { LexicalErrorBoundary as so } from "@lexical/react/LexicalErrorBoundary";
9
- import { HistoryPlugin as co } from "@lexical/react/LexicalHistoryPlugin";
10
- import { ListPlugin as lo } from "@lexical/react/LexicalListPlugin";
11
- import { OnChangePlugin as mo } from "@lexical/react/LexicalOnChangePlugin";
12
- import { RichTextPlugin as ao } from "@lexical/react/LexicalRichTextPlugin";
13
- import { QuoteNode as uo } from "@lexical/rich-text";
14
- import R from "classnames";
15
- import { $getRoot as fo } from "lexical";
16
- import { useState as d, useId as po, useEffect as ho } from "react";
17
- import { useIntl as go } from "react-intl";
18
- import So from "./EditorTheme.js";
1
+ import { jsxs as p, Fragment as Z, jsx as o } from "react/jsx-runtime";
2
+ import { ListNode as oo, ListItemNode as to } from "@lexical/list";
3
+ import { OverflowNode as eo } from "@lexical/overflow";
4
+ import { CharacterLimitPlugin as ro } from "@lexical/react/LexicalCharacterLimitPlugin";
5
+ import { LexicalComposer as io } from "@lexical/react/LexicalComposer";
6
+ import { ContentEditable as no } from "@lexical/react/LexicalContentEditable";
7
+ import { EditorRefPlugin as so } from "@lexical/react/LexicalEditorRefPlugin";
8
+ import { LexicalErrorBoundary as co } from "@lexical/react/LexicalErrorBoundary";
9
+ import { HistoryPlugin as lo } from "@lexical/react/LexicalHistoryPlugin";
10
+ import { ListPlugin as mo } from "@lexical/react/LexicalListPlugin";
11
+ import { OnChangePlugin as ao } from "@lexical/react/LexicalOnChangePlugin";
12
+ import { RichTextPlugin as uo } from "@lexical/react/LexicalRichTextPlugin";
13
+ import { QuoteNode as fo } from "@lexical/rich-text";
14
+ import I from "classnames";
15
+ import { $getRoot as po } from "lexical";
16
+ import { useState as d, useId as ho, useEffect as go } from "react";
17
+ import { useIntl as So } from "react-intl";
18
+ import xo from "./EditorTheme.js";
19
19
  import i from "./TextEditor.module.scss.js";
20
- import { AutoSavePlugin as xo } from "./plugins/AutoSavePlugin.js";
21
- import { FocusPlugin as vo } from "./plugins/FocusPlugin.js";
20
+ import { AutoSavePlugin as vo } from "./plugins/AutoSavePlugin.js";
21
+ import { FocusPlugin as Co } from "./plugins/FocusPlugin.js";
22
22
  import { MaxLengthPlugin as Po } from "./plugins/MaxLengthPlugin.js";
23
23
  import { ResetPlugin as To } from "./plugins/ResetPlugin.js";
24
- import { SetContentPlugin as Co } from "./plugins/SetContentPlugin.js";
25
- import { SetRichContentPlugin as No } from "./plugins/SetRichContentPlugin.js";
26
- import { ToolbarPlugin as Eo } from "./plugins/ToolbarPlugin.js";
27
- import { useModal as Io } from "../../dialog/modal/useModal.js";
28
- import { SourceModal as Ro } from "../../source/source_modal/SourceModal.js";
29
- import { SourceListItem as bo } from "../../source/source_list_item/SourceListItem.js";
30
- const b = (c) => c?.replace(/&nbsp;/g, " "), rt = ({
24
+ import { SetContentPlugin as No } from "./plugins/SetContentPlugin.js";
25
+ import { SetRichContentPlugin as Eo } from "./plugins/SetRichContentPlugin.js";
26
+ import { ToolbarPlugin as Io } from "./plugins/ToolbarPlugin.js";
27
+ import { useModal as Ro } from "../../dialog/modal/useModal.js";
28
+ import { SourceModal as bo } from "../../source/source_modal/SourceModal.js";
29
+ import { SourceListItem as Mo } from "../../source/source_list_item/SourceListItem.js";
30
+ const R = (c) => c?.replace(/&nbsp;/g, " "), it = ({
31
31
  placeholder: c,
32
+ initialContent: b,
33
+ initialRichContent: M,
32
34
  onSubmit: h,
33
35
  sources: u,
34
- hideSubmit: M = !1,
35
- hideSourceAction: y = !1,
36
+ hideSubmit: y = !1,
37
+ hideSourceAction: w = !1,
36
38
  onActivation: g,
37
- disabled: w = !1,
39
+ disabled: A = !1,
38
40
  handleChange: S,
39
41
  handleSourcesChange: f,
40
- shortBar: A = !1,
42
+ shortBar: L = !1,
41
43
  active: x = !1,
42
44
  maxLength: l,
43
- disableRichText: L = !1,
44
- editorRef: _,
45
+ disableRichText: _ = !1,
46
+ editorRef: B,
45
47
  uid: v,
46
- allowedDomains: P = [],
47
- hideCharCount: B = !1,
48
- disableAutoActivate: F = !1,
49
- initialContent: T,
50
- ...O
48
+ allowedDomains: C = [],
49
+ hideCharCount: F = !1,
50
+ disableAutoActivate: O = !1,
51
+ ...U
51
52
  }) => {
52
- const [n, U] = d(!1), [j, k] = d(""), [z, H] = d(""), [m, a] = d([]), { showModal: J } = Io(), C = go(), N = po();
53
- ho(() => {
53
+ const [n, j] = d(!1), [k, z] = d(""), [H, J] = d(""), [m, a] = d([]), { showModal: Q } = Ro(), P = So(), T = ho();
54
+ go(() => {
54
55
  u && a(u);
55
56
  }, [u]);
56
- const E = () => {
57
- n || (U(!0), g && g());
58
- }, Q = {
59
- editable: !w,
60
- theme: So,
57
+ const N = () => {
58
+ n || (j(!0), g && g());
59
+ }, W = {
60
+ editable: !A,
61
+ theme: xo,
61
62
  onError(t) {
62
63
  console.error("TextEditor error:", t);
63
64
  },
64
- nodes: [Z, oo, uo, to],
65
- ...T ? { editorState: T } : {}
66
- }, W = () => {
67
- E();
68
- }, $ = (t) => {
65
+ nodes: [oo, to, fo, eo]
66
+ }, $ = () => {
67
+ N();
68
+ }, q = (t) => {
69
69
  t.read(() => {
70
- const e = fo().getTextContent(), r = b(e), s = JSON.stringify(t), I = b(s);
71
- k(r), H(I), S && S(r, I);
70
+ const e = po().getTextContent(), r = R(e), s = JSON.stringify(t), E = R(s);
71
+ z(r), J(E), S && S(r, E);
72
72
  });
73
- }, q = (t) => {
74
- const e = j, r = z, s = m;
73
+ }, D = (t) => {
74
+ const e = k, r = H, s = m;
75
75
  h && (t.preventDefault(), h(e, r, s)), a([]), f?.([]);
76
- }, D = () => {
77
- J(
76
+ }, G = () => {
77
+ Q(
78
78
  /* @__PURE__ */ o(
79
- Ro,
79
+ bo,
80
80
  {
81
- onAddSource: G,
82
- allowedSources: P
81
+ onAddSource: K,
82
+ allowedSources: C
83
83
  }
84
84
  )
85
85
  );
86
- }, G = (t) => {
86
+ }, K = (t) => {
87
87
  a((e) => {
88
88
  const r = [...e, t];
89
89
  return f?.(r), r;
90
90
  });
91
- }, K = (t) => {
91
+ }, V = (t) => {
92
92
  a((e) => {
93
93
  const r = e.filter(
94
94
  (s) => s.source_url !== t.source_url
95
95
  );
96
96
  return f?.(r), r;
97
97
  });
98
- }, V = (t, e) => /* @__PURE__ */ o(
99
- bo,
98
+ }, X = (t, e) => /* @__PURE__ */ o(
99
+ Mo,
100
100
  {
101
101
  publisher: t.publisher,
102
102
  url: t.source_url,
103
103
  title: t.title,
104
104
  index: e,
105
- onRemove: () => K(t)
105
+ onRemove: () => V(t)
106
106
  },
107
107
  e
108
- ), X = () => /* @__PURE__ */ o("div", { className: i.editorPlaceholder, children: c });
109
- return /* @__PURE__ */ p(Y, { children: [
110
- /* @__PURE__ */ o(ro, { initialConfig: Q, children: /* @__PURE__ */ o("div", { className: i.editorContainer, onClick: W, children: /* @__PURE__ */ p(
108
+ ), Y = () => /* @__PURE__ */ o("div", { className: i.editorPlaceholder, children: c });
109
+ return /* @__PURE__ */ p(Z, { children: [
110
+ /* @__PURE__ */ o(io, { initialConfig: W, children: /* @__PURE__ */ o("div", { className: i.editorContainer, onClick: $, children: /* @__PURE__ */ p(
111
111
  "div",
112
112
  {
113
- className: R(i.editorInner, {
113
+ className: I(i.editorInner, {
114
114
  [i.editorInnerInactive]: !n && !x
115
115
  }),
116
116
  children: [
117
117
  /* @__PURE__ */ o(
118
- ao,
118
+ uo,
119
119
  {
120
120
  contentEditable: /* @__PURE__ */ o(
121
- io,
121
+ no,
122
122
  {
123
- className: R(i.editorInput, {
123
+ className: I(i.editorInput, {
124
124
  [i.editorInputInactive]: !n
125
125
  }),
126
- ...O
126
+ ...U
127
127
  }
128
128
  ),
129
- placeholder: c && /* @__PURE__ */ o(X, {}),
130
- ErrorBoundary: so
129
+ placeholder: c && /* @__PURE__ */ o(Y, {}),
130
+ ErrorBoundary: co
131
131
  }
132
132
  ),
133
133
  /* @__PURE__ */ o(
134
- Eo,
134
+ Io,
135
135
  {
136
- hideSourceAction: y,
137
- hideSubmit: M,
138
- disableRichText: L,
139
- shortBar: A,
140
- onSubmit: q,
141
- onAddSource: D,
136
+ hideSourceAction: w,
137
+ hideSubmit: y,
138
+ disableRichText: _,
139
+ shortBar: L,
140
+ onSubmit: D,
141
+ onAddSource: G,
142
142
  isActive: n || x,
143
- sourceTooltip: P?.length > 0 && C.formatMessage({
143
+ sourceTooltip: C?.length > 0 && P.formatMessage({
144
144
  id: "input.allowed_domains_tooltip",
145
145
  defaultMessage: "With the new source function, you can add links to your article."
146
146
  })
147
147
  }
148
148
  ),
149
- n && l && !B && /* @__PURE__ */ p("div", { className: i.charactersCount, children: [
150
- /* @__PURE__ */ o(eo, { maxLength: l }),
149
+ n && l && !F && /* @__PURE__ */ p("div", { className: i.charactersCount, children: [
150
+ /* @__PURE__ */ o(ro, { maxLength: l }),
151
151
  " ",
152
- C.formatMessage({
152
+ P.formatMessage({
153
153
  id: "input.remaining_chars",
154
154
  defaultMessage: "remaining characters"
155
155
  })
156
156
  ] }),
157
+ /* @__PURE__ */ o(mo, {}),
157
158
  /* @__PURE__ */ o(lo, {}),
158
- /* @__PURE__ */ o(co, {}),
159
- /* @__PURE__ */ o(mo, { onChange: $, ignoreSelectionChange: !0 }),
159
+ /* @__PURE__ */ o(ao, { onChange: q, ignoreSelectionChange: !0 }),
160
160
  /* @__PURE__ */ o(
161
- xo,
161
+ vo,
162
162
  {
163
- onSetContent: F ? () => {
164
- } : E,
165
- storageUid: v || N
163
+ onSetContent: O ? () => {
164
+ } : N,
165
+ storageUid: v || T
166
166
  }
167
167
  ),
168
+ /* @__PURE__ */ o(No, { content: b }),
169
+ /* @__PURE__ */ o(Eo, { richContent: M }),
168
170
  /* @__PURE__ */ o(Co, {}),
169
- /* @__PURE__ */ o(No, {}),
170
- /* @__PURE__ */ o(vo, {}),
171
171
  l && /* @__PURE__ */ o(Po, { maxLength: l }),
172
- /* @__PURE__ */ o(To, { storageUid: v || N }),
173
- /* @__PURE__ */ o(no, { editorRef: _ })
172
+ /* @__PURE__ */ o(To, { storageUid: v || T }),
173
+ /* @__PURE__ */ o(so, { editorRef: B })
174
174
  ]
175
175
  }
176
176
  ) }) }),
177
- m && m.length !== 0 ? /* @__PURE__ */ o("div", { className: i.sourcesBox, children: /* @__PURE__ */ o("div", { className: i.sourceList, children: m.map(V) }) }) : null
177
+ m && m.length !== 0 ? /* @__PURE__ */ o("div", { className: i.sourcesBox, children: /* @__PURE__ */ o("div", { className: i.sourceList, children: m.map(X) }) }) : null
178
178
  ] });
179
179
  };
180
180
  export {
181
- rt as TextEditor
181
+ it as TextEditor
182
182
  };
@@ -1,18 +1,18 @@
1
- import { useLexicalComposerContext as p } from "@lexical/react/LexicalComposerContext";
2
- import { $getRoot as u, $createParagraphNode as a, $createTextNode as c } from "lexical";
3
- import { useEffect as s } from "react";
4
- import { useInput as i } from "../../input_provider/useInput.js";
5
- const C = () => {
6
- const [n] = p(), { inputContent: t, setInputContent: r } = i();
7
- return s(() => {
8
- t && n.update(() => {
9
- const e = u();
10
- e.clear();
11
- const o = a();
12
- o.append(c(t)), e.append(o), r(null);
1
+ import { useLexicalComposerContext as a } from "@lexical/react/LexicalComposerContext";
2
+ import { $getRoot as c, $createParagraphNode as i, $createTextNode as u } from "lexical";
3
+ import { useEffect as f } from "react";
4
+ import { useInput as m } from "../../input_provider/useInput.js";
5
+ const x = ({ content: o }) => {
6
+ const [p] = a(), { inputContent: e, setInputContent: s } = m(), t = o || e;
7
+ return f(() => {
8
+ typeof t == "string" && t && p.update(() => {
9
+ const n = c();
10
+ n.clear();
11
+ const r = i();
12
+ r.append(u(t)), n.append(r), !o && e && s(null);
13
13
  });
14
14
  }, [t]), null;
15
15
  };
16
16
  export {
17
- C as SetContentPlugin
17
+ x as SetContentPlugin
18
18
  };
@@ -1,14 +1,14 @@
1
- import { useLexicalComposerContext as r } from "@lexical/react/LexicalComposerContext";
2
- import { useEffect as i } from "react";
3
- import { useInput as s } from "../../input_provider/useInput.js";
4
- const m = () => {
5
- const [t] = r(), { inputRichContent: e, setInputRichContent: o } = s();
6
- return i(() => {
7
- e && t.update(() => {
8
- const n = t.parseEditorState(e);
9
- t.setEditorState(n), o(null);
1
+ import { useLexicalComposerContext as s } from "@lexical/react/LexicalComposerContext";
2
+ import { useEffect as u } from "react";
3
+ import { useInput as c } from "../../input_provider/useInput.js";
4
+ const m = ({ richContent: e }) => {
5
+ const [t] = s(), { inputRichContent: n, setInputRichContent: i } = c(), o = e || n;
6
+ return u(() => {
7
+ o && t.update(() => {
8
+ const r = t.parseEditorState(o);
9
+ t.setEditorState(r), !e && n && i(null);
10
10
  });
11
- }, [e]), null;
11
+ }, [o]), null;
12
12
  };
13
13
  export {
14
14
  m as SetRichContentPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.65",
3
+ "version": "0.3.67",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",