@logora/debate 0.4.73 → 0.4.75
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.
- package/dist/components/input/argument_input/ArgumentInput.js +58 -57
- package/dist/components/input/text_editor/TextEditor.js +102 -101
- package/dist/components/input/text_editor/plugins/SetContentPlugin.js +11 -11
- package/dist/components/input/text_editor/plugins/SetRichContentPlugin.js +9 -9
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as C, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import We from "@rooks/use-sessionstorage-state";
|
|
3
|
-
import { useRef as Ye, useState as c, useEffect as p, Suspense as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { useLocation as
|
|
3
|
+
import { useRef as Ye, useState as c, useEffect as p, Suspense as je, lazy as ze } from "react";
|
|
4
|
+
import { useIntl as Oe, FormattedMessage as he } from "react-intl";
|
|
5
|
+
import { useLocation as Re } from "react-router";
|
|
6
6
|
import x from "classnames";
|
|
7
7
|
import n from "./ArgumentInput.module.scss.js";
|
|
8
8
|
import { useDataProvider as Je } from "../../data/data_provider/useDataProvider.js";
|
|
@@ -20,17 +20,17 @@ import { Avatar as st } from "../../user/avatar/Avatar.js";
|
|
|
20
20
|
import { AuthorBox as it } from "../../user/author_box/AuthorBox.js";
|
|
21
21
|
import { TextEditor as ot } from "../text_editor/TextEditor.js";
|
|
22
22
|
import { Icon as rt } from "../../icons/icon/Icon.js";
|
|
23
|
-
const ut =
|
|
23
|
+
const ut = ze(() => import("../../modal/side_modal/index.js").then((N) => ({ default: N.SideModal }))), Ft = ({
|
|
24
24
|
argumentListId: N,
|
|
25
25
|
avatarSize: pe = 48,
|
|
26
|
-
disabled:
|
|
26
|
+
disabled: R = !1,
|
|
27
27
|
positions: a = [],
|
|
28
|
-
disabledPositions:
|
|
28
|
+
disabledPositions: T = [],
|
|
29
29
|
groupId: _,
|
|
30
30
|
groupName: _e,
|
|
31
31
|
groupType: J,
|
|
32
32
|
hideSourceAction: Me = !1,
|
|
33
|
-
isReply:
|
|
33
|
+
isReply: i = !1,
|
|
34
34
|
onSubmit: K,
|
|
35
35
|
onUpdate: G,
|
|
36
36
|
parentId: M,
|
|
@@ -44,34 +44,34 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
44
44
|
disableAutoActivate: we = !1,
|
|
45
45
|
autoFocus: Q = !1
|
|
46
46
|
}) => {
|
|
47
|
-
const
|
|
47
|
+
const r = Oe(), X = Je(), y = Ke(), v = Ge(), {
|
|
48
48
|
focus: Z,
|
|
49
49
|
setFocus: ee,
|
|
50
50
|
setReset: Se,
|
|
51
51
|
inputContent: B,
|
|
52
52
|
setInputContent: te,
|
|
53
53
|
setInputRichContent: Ie
|
|
54
|
-
} = He(), { isLoggedIn: S, currentUser: u } = Qe(), { errors: E, validate: $ } = Xe(), { isMobile: m } = Ze(), xe =
|
|
54
|
+
} = He(), { isLoggedIn: S, currentUser: u } = Qe(), { errors: E, validate: $ } = Xe(), { isMobile: m } = Ze(), xe = Re(), ne = Ye(null), [V, k] = c([]), [q, D] = c(""), [ae, U] = c(null), [d, b] = c(null), [se, ie] = c(null), [oe, re] = c(!1), [I, ue] = c(!1), [A, de] = c({}), [Ne, W] = c(!1), [f, Te] = We(
|
|
55
55
|
"userSide",
|
|
56
56
|
{}
|
|
57
|
-
), [g,
|
|
57
|
+
), [g, ye] = c(
|
|
58
58
|
!S && v?.actions?.disableInputForVisitor
|
|
59
|
-
), Y = et(), { showModal: Le } = tt(), { toast:
|
|
59
|
+
), Y = et(), { showModal: Le } = tt(), { toast: j } = nt() || {}, le = new URLSearchParams(
|
|
60
60
|
typeof window < "u" ? window.location.search : xe.search
|
|
61
61
|
);
|
|
62
62
|
p(() => {
|
|
63
|
-
|
|
63
|
+
ye(
|
|
64
64
|
!S && v?.actions?.disableInputForVisitor
|
|
65
65
|
);
|
|
66
66
|
}, [S, v]);
|
|
67
|
-
const
|
|
67
|
+
const z = u?.role === "editor" || u?.role === "moderator", ce = u?.moderation_status === "banned";
|
|
68
68
|
p(() => {
|
|
69
69
|
let e = null;
|
|
70
70
|
typeof window < "u" && (e = le.get("positionId")), w && w != a[2]?.id && a?.find((t) => t.id === w) ? b(w) : e && e != a[2]?.id ? b(e) : f && f.groupId == _ && f.positionId != a[2]?.id && b(f.positionId);
|
|
71
71
|
}, [w]), p(() => {
|
|
72
72
|
Q && W(!0);
|
|
73
73
|
}, [Q]), p(() => {
|
|
74
|
-
P && (
|
|
74
|
+
P && (O(), W(!0), L());
|
|
75
75
|
}, [P]), p(() => {
|
|
76
76
|
if (typeof window < "u") {
|
|
77
77
|
const e = be || le.get("initArgument");
|
|
@@ -80,7 +80,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
80
80
|
}, []), p(() => {
|
|
81
81
|
Z && (L(), ee(!1));
|
|
82
82
|
}, [Z]), p(() => {
|
|
83
|
-
B?.id && (Fe(B), ee(!0));
|
|
83
|
+
B?.id && !i && (Fe(B), ee(!0));
|
|
84
84
|
}, [B]);
|
|
85
85
|
const Fe = (e) => {
|
|
86
86
|
de(e), ue(!0), k(e.sources), D(e.content), U(e.rich_content), ie(e.id), L(), b(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ie(e.rich_content) : te(e.content);
|
|
@@ -92,23 +92,23 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
92
92
|
b(e), ge(e);
|
|
93
93
|
}, Be = () => {
|
|
94
94
|
Le(
|
|
95
|
-
/* @__PURE__ */ s(
|
|
95
|
+
/* @__PURE__ */ s(je, { fallback: null, children: /* @__PURE__ */ s(
|
|
96
96
|
ut,
|
|
97
97
|
{
|
|
98
|
-
modalTitle:
|
|
98
|
+
modalTitle: r.formatMessage({
|
|
99
99
|
id: "modal.side_modal.modal_title",
|
|
100
100
|
defaultMessage: "Choose your side"
|
|
101
101
|
}),
|
|
102
102
|
onChooseSide: Pe,
|
|
103
103
|
positions: a,
|
|
104
104
|
title: _e,
|
|
105
|
-
disabledPositions: !
|
|
105
|
+
disabledPositions: !i && T,
|
|
106
106
|
isNeutral: f && f.groupId == _ && f.positionId === a[2]?.id
|
|
107
107
|
}
|
|
108
108
|
) })
|
|
109
109
|
);
|
|
110
110
|
}, Ee = () => {
|
|
111
|
-
S ? se ? ke() : !a || a?.length === 0 || !
|
|
111
|
+
S ? se ? ke() : !a || a?.length === 0 || !T?.find((e) => e?.id === d) && d || z && i ? ge(i && z && a[0]?.id) : Be() : Y({ loginAction: "argument" });
|
|
112
112
|
}, $e = (e, t) => {
|
|
113
113
|
g ? Y({ loginAction: "argument" }) : (D(e), U(t), $({ content: e }, [{ content: ["url", null] }]));
|
|
114
114
|
}, Ve = (e) => {
|
|
@@ -127,41 +127,41 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
127
127
|
...t && { position_id: t },
|
|
128
128
|
is_reply: !!M,
|
|
129
129
|
message_id: M || null,
|
|
130
|
-
source_ids: V?.map((
|
|
130
|
+
source_ids: V?.map((o) => o.id)
|
|
131
131
|
};
|
|
132
|
-
$(l, fe) && (t && a && a.map((
|
|
132
|
+
$(l, fe) && (t && a && a.map((o) => o.id).includes(t) && Te({
|
|
133
133
|
groupId: _,
|
|
134
134
|
positionId: t
|
|
135
|
-
}), me(), X.create("messages", l).then((
|
|
136
|
-
if (
|
|
135
|
+
}), me(), X.create("messages", l).then((o) => {
|
|
136
|
+
if (o.data.success) {
|
|
137
137
|
if (M)
|
|
138
|
-
K(
|
|
139
|
-
|
|
138
|
+
K(o.data.data.resource), j(
|
|
139
|
+
r.formatMessage({
|
|
140
140
|
id: "alert.argument_create",
|
|
141
141
|
defaultMessage: "Your contribution has been sent !"
|
|
142
142
|
}),
|
|
143
143
|
{
|
|
144
144
|
type: "success",
|
|
145
|
-
points:
|
|
145
|
+
points: r.formatMessage({
|
|
146
146
|
id: "alert.reply_gain",
|
|
147
147
|
defaultMessage: " "
|
|
148
148
|
})
|
|
149
149
|
}
|
|
150
150
|
);
|
|
151
151
|
else {
|
|
152
|
-
const h =
|
|
152
|
+
const h = o.data.data.resource;
|
|
153
153
|
let F = N;
|
|
154
154
|
t && !m && (F = `argumentList${h.position.id}`), K?.(
|
|
155
155
|
q,
|
|
156
156
|
a.find((Ue) => Ue.id === t) || null
|
|
157
|
-
),
|
|
158
|
-
|
|
157
|
+
), y.add(F, [h]), j(
|
|
158
|
+
r.formatMessage({
|
|
159
159
|
id: "alert.argument_create",
|
|
160
160
|
defaultMessage: "Your contribution has been sent !"
|
|
161
161
|
}),
|
|
162
162
|
{
|
|
163
163
|
type: "success",
|
|
164
|
-
points:
|
|
164
|
+
points: r.formatMessage({
|
|
165
165
|
id: "alert.argument_create_gain",
|
|
166
166
|
defaultMessage: "Up to 10 eloquence points"
|
|
167
167
|
}),
|
|
@@ -173,7 +173,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
173
173
|
typeof window < "u" && window.dispatchEvent(
|
|
174
174
|
new CustomEvent("logora:user_content:created", {
|
|
175
175
|
detail: {
|
|
176
|
-
content:
|
|
176
|
+
content: o.data.data?.resource
|
|
177
177
|
}
|
|
178
178
|
})
|
|
179
179
|
);
|
|
@@ -189,17 +189,17 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
189
189
|
$(e, fe) && X.update("messages", se, e).then((t) => {
|
|
190
190
|
if (t.data.success) {
|
|
191
191
|
const l = t.data.data.resource;
|
|
192
|
-
let
|
|
193
|
-
if (A?.is_reply ||
|
|
192
|
+
let o = N;
|
|
193
|
+
if (A?.is_reply || i) {
|
|
194
194
|
const h = A?.message_id || A?.reply_to_id || M;
|
|
195
|
-
h && (
|
|
196
|
-
} else d && !m && (
|
|
195
|
+
h && (o = `argument_${h}_reply_list`);
|
|
196
|
+
} else d && !m && (o = `argumentList${l.position?.id}`);
|
|
197
197
|
if (!A?.is_reply && A?.position?.id != l.position?.id && !m) {
|
|
198
198
|
const h = `argumentList${A.position.id}`, F = `argumentList${l.position.id}`;
|
|
199
|
-
|
|
199
|
+
y.remove(h, [l]), y.add(F, [l]);
|
|
200
200
|
} else
|
|
201
|
-
|
|
202
|
-
G && G(l),
|
|
201
|
+
y.update(o, [l]);
|
|
202
|
+
G && G(l), j(r.formatMessage({ id: "alert.argument_modify" }), {
|
|
203
203
|
type: "success"
|
|
204
204
|
}), me();
|
|
205
205
|
}
|
|
@@ -212,14 +212,14 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
212
212
|
}, 2e3);
|
|
213
213
|
return () => clearTimeout(e);
|
|
214
214
|
}
|
|
215
|
-
},
|
|
215
|
+
}, O = () => {
|
|
216
216
|
g ? Y({ loginAction: "argument" }) : ue(!0);
|
|
217
217
|
}, De = () => {
|
|
218
|
-
const e =
|
|
218
|
+
const e = T.find(
|
|
219
219
|
(t) => t.id === d
|
|
220
220
|
);
|
|
221
221
|
if (e)
|
|
222
|
-
return
|
|
222
|
+
return r.formatMessage(
|
|
223
223
|
{
|
|
224
224
|
id: "info.argument_side_limit",
|
|
225
225
|
defaultMessage: "You have reached the argument limit (10) for position {position}."
|
|
@@ -228,10 +228,10 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
228
228
|
);
|
|
229
229
|
};
|
|
230
230
|
return /* @__PURE__ */ C("div", { className: n.inputContainer, children: [
|
|
231
|
-
|
|
231
|
+
R && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ce ? r.formatMessage({
|
|
232
232
|
id: "input.argument_input.user_banned",
|
|
233
233
|
defaultMessage: "You are banned from the debate space."
|
|
234
|
-
}) :
|
|
234
|
+
}) : r.formatMessage({
|
|
235
235
|
id: "info.debate_is_inactive",
|
|
236
236
|
defaultMessage: "Debate is closed"
|
|
237
237
|
}) }),
|
|
@@ -240,11 +240,11 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
240
240
|
{
|
|
241
241
|
className: x(n.argumentInput, {
|
|
242
242
|
[n.flash]: oe,
|
|
243
|
-
[n.replyInputContainer]:
|
|
243
|
+
[n.replyInputContainer]: i
|
|
244
244
|
}),
|
|
245
245
|
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ne, children: /* @__PURE__ */ C("div", { className: n.argumentInputBox, children: [
|
|
246
|
-
a.length > 0 && S && (!
|
|
247
|
-
/* @__PURE__ */ s("div", { children:
|
|
246
|
+
a.length > 0 && S && (!i || !z) && /* @__PURE__ */ C("div", { className: n.userPosition, children: [
|
|
247
|
+
/* @__PURE__ */ s("div", { children: r.formatMessage({
|
|
248
248
|
id: "input.position",
|
|
249
249
|
defaultMessage: "Your position"
|
|
250
250
|
}) }),
|
|
@@ -263,7 +263,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
263
263
|
{
|
|
264
264
|
className: x(n.argumentTextInputBox, {
|
|
265
265
|
[n.argumentTextInputBoxisTablet]: !m,
|
|
266
|
-
[n.replyEditorRow]:
|
|
266
|
+
[n.replyEditorRow]: i
|
|
267
267
|
}),
|
|
268
268
|
children: [
|
|
269
269
|
/* @__PURE__ */ s(
|
|
@@ -271,9 +271,9 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
271
271
|
{
|
|
272
272
|
className: x(n.argumentAuthorContainer, {
|
|
273
273
|
[n.argumentAuthorContainerMobile]: m,
|
|
274
|
-
[n.argumentAuthorContainerActivated]: !m && I ||
|
|
274
|
+
[n.argumentAuthorContainerActivated]: !m && I || i
|
|
275
275
|
}),
|
|
276
|
-
children: !m && I ||
|
|
276
|
+
children: !m && I || i ? /* @__PURE__ */ s(
|
|
277
277
|
st,
|
|
278
278
|
{
|
|
279
279
|
avatarUrl: u.image_url,
|
|
@@ -283,7 +283,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
283
283
|
) : /* @__PURE__ */ s(
|
|
284
284
|
it,
|
|
285
285
|
{
|
|
286
|
-
fullName: u?.full_name ||
|
|
286
|
+
fullName: u?.full_name || r.formatMessage({ id: "default_author.full_name" }),
|
|
287
287
|
avatarUrl: u?.image_url,
|
|
288
288
|
points: u?.points || 0,
|
|
289
289
|
slug: u?.hash_id
|
|
@@ -294,10 +294,10 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
294
294
|
/* @__PURE__ */ C(
|
|
295
295
|
"div",
|
|
296
296
|
{
|
|
297
|
-
onClick:
|
|
297
|
+
onClick: O,
|
|
298
298
|
"data-testid": "argument-input",
|
|
299
299
|
className: x(n.textEditorBox, {
|
|
300
|
-
[n.replyTextEditorBox]:
|
|
300
|
+
[n.replyTextEditorBox]: i
|
|
301
301
|
}),
|
|
302
302
|
children: [
|
|
303
303
|
/* @__PURE__ */ s(
|
|
@@ -310,7 +310,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
310
310
|
Ve(e);
|
|
311
311
|
},
|
|
312
312
|
placeholder: ve,
|
|
313
|
-
"aria-label":
|
|
313
|
+
"aria-label": r.formatMessage({
|
|
314
314
|
id: "input.argument_input.aria_label",
|
|
315
315
|
defaultMessage: "Message input field"
|
|
316
316
|
}),
|
|
@@ -318,12 +318,13 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
318
318
|
sources: V,
|
|
319
319
|
hideSourceAction: Me || g,
|
|
320
320
|
uid: M ? `Reply${_}_${M}` : `Argument${_}`,
|
|
321
|
-
onActivation:
|
|
321
|
+
onActivation: O,
|
|
322
322
|
showStylesControls: I,
|
|
323
|
-
disabled:
|
|
323
|
+
disabled: R || g || ce,
|
|
324
324
|
maxLength: g ? !1 : v?.actions?.argumentMaxLength,
|
|
325
325
|
disableRichText: v?.actions?.disableRichText || g,
|
|
326
|
-
shortBar:
|
|
326
|
+
shortBar: i,
|
|
327
|
+
isReply: i,
|
|
327
328
|
hideSubmit: g,
|
|
328
329
|
allowedDomains: v?.allowed_sources,
|
|
329
330
|
active: P,
|
|
@@ -333,7 +334,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
|
|
|
333
334
|
}
|
|
334
335
|
),
|
|
335
336
|
E?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: E && Object.values(E).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
|
|
336
|
-
I &&
|
|
337
|
+
I && T?.find(
|
|
337
338
|
(e) => e.id === d
|
|
338
339
|
) && /* @__PURE__ */ C(
|
|
339
340
|
"div",
|
|
@@ -1,187 +1,188 @@
|
|
|
1
|
-
import { jsxs as S, 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 f, useId as
|
|
17
|
-
import { useIntl as
|
|
18
|
-
import
|
|
1
|
+
import { jsxs as S, Fragment as re, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { ListNode as ie, ListItemNode as ne } from "@lexical/list";
|
|
3
|
+
import { OverflowNode as se } from "@lexical/overflow";
|
|
4
|
+
import { CharacterLimitPlugin as ce } from "@lexical/react/LexicalCharacterLimitPlugin";
|
|
5
|
+
import { LexicalComposer as le } from "@lexical/react/LexicalComposer";
|
|
6
|
+
import { ContentEditable as me } from "@lexical/react/LexicalContentEditable";
|
|
7
|
+
import { EditorRefPlugin as ae } from "@lexical/react/LexicalEditorRefPlugin";
|
|
8
|
+
import { LexicalErrorBoundary as de } from "@lexical/react/LexicalErrorBoundary";
|
|
9
|
+
import { HistoryPlugin as ue } from "@lexical/react/LexicalHistoryPlugin";
|
|
10
|
+
import { ListPlugin as fe } from "@lexical/react/LexicalListPlugin";
|
|
11
|
+
import { OnChangePlugin as pe } from "@lexical/react/LexicalOnChangePlugin";
|
|
12
|
+
import { RichTextPlugin as he } from "@lexical/react/LexicalRichTextPlugin";
|
|
13
|
+
import { QuoteNode as ge } from "@lexical/rich-text";
|
|
14
|
+
import M from "classnames";
|
|
15
|
+
import { $getRoot as Se } from "lexical";
|
|
16
|
+
import { useState as f, useId as xe, useRef as Pe, useEffect as w } from "react";
|
|
17
|
+
import { useIntl as Ce } from "react-intl";
|
|
18
|
+
import Te from "./EditorTheme.js";
|
|
19
19
|
import i from "./TextEditor.module.scss.js";
|
|
20
|
-
import { AutoSavePlugin as
|
|
21
|
-
import { FocusPlugin as
|
|
22
|
-
import { IOSInsertParagraphFallbackPlugin as
|
|
23
|
-
import { MaxLengthPlugin as
|
|
24
|
-
import { ResetPlugin as
|
|
20
|
+
import { AutoSavePlugin as Ie } from "./plugins/AutoSavePlugin.js";
|
|
21
|
+
import { FocusPlugin as Ne } from "./plugins/FocusPlugin.js";
|
|
22
|
+
import { IOSInsertParagraphFallbackPlugin as ve } from "./plugins/IOSInsertParagraphFallbackPlugin.js";
|
|
23
|
+
import { MaxLengthPlugin as Ee } from "./plugins/MaxLengthPlugin.js";
|
|
24
|
+
import { ResetPlugin as be } from "./plugins/ResetPlugin.js";
|
|
25
25
|
import { SetContentPlugin as Re } from "./plugins/SetContentPlugin.js";
|
|
26
|
-
import { SetRichContentPlugin as
|
|
27
|
-
import { ToolbarPlugin as
|
|
26
|
+
import { SetRichContentPlugin as Me } from "./plugins/SetRichContentPlugin.js";
|
|
27
|
+
import { ToolbarPlugin as we } from "./plugins/ToolbarPlugin.js";
|
|
28
28
|
import { useModal as ye } from "../../dialog/modal/useModal.js";
|
|
29
|
-
import { SourceModal as
|
|
30
|
-
import { SourceListItem as
|
|
31
|
-
const y = (l) => l?.replace(/ /g, " "),
|
|
29
|
+
import { SourceModal as Le } from "../../source/source_modal/SourceModal.js";
|
|
30
|
+
import { SourceListItem as _e } from "../../source/source_list_item/SourceListItem.js";
|
|
31
|
+
const y = (l) => l?.replace(/ /g, " "), mt = ({
|
|
32
32
|
placeholder: l,
|
|
33
|
-
initialContent:
|
|
34
|
-
initialRichContent:
|
|
33
|
+
initialContent: L,
|
|
34
|
+
initialRichContent: _,
|
|
35
35
|
onSubmit: x,
|
|
36
36
|
sources: p,
|
|
37
|
-
hideSubmit:
|
|
38
|
-
hideSourceAction:
|
|
37
|
+
hideSubmit: A = !1,
|
|
38
|
+
hideSourceAction: O = !1,
|
|
39
39
|
onActivation: n,
|
|
40
|
-
disabled:
|
|
40
|
+
disabled: k = !1,
|
|
41
41
|
handleChange: P,
|
|
42
42
|
handleSourcesChange: h,
|
|
43
|
-
shortBar:
|
|
43
|
+
shortBar: B = !1,
|
|
44
44
|
active: g = !1,
|
|
45
45
|
maxLength: m,
|
|
46
|
-
disableRichText:
|
|
47
|
-
editorRef:
|
|
46
|
+
disableRichText: U = !1,
|
|
47
|
+
editorRef: j,
|
|
48
48
|
uid: C,
|
|
49
49
|
allowedDomains: T = [],
|
|
50
|
-
hideCharCount:
|
|
51
|
-
disableAutoActivate:
|
|
50
|
+
hideCharCount: z = !1,
|
|
51
|
+
disableAutoActivate: F = !1,
|
|
52
52
|
autoFocus: a = !1,
|
|
53
|
-
|
|
53
|
+
isReply: I = !1,
|
|
54
|
+
...H
|
|
54
55
|
}) => {
|
|
55
|
-
const [s,
|
|
56
|
-
|
|
57
|
-
a && !
|
|
58
|
-
}, [a, n]),
|
|
56
|
+
const [s, J] = f(a || g), [Q, W] = f(""), [$, q] = f(""), [d, u] = f([]), { showModal: D } = ye(), N = Ce(), v = xe(), E = Pe(!1);
|
|
57
|
+
w(() => {
|
|
58
|
+
a && !E.current && n && (E.current = !0, n());
|
|
59
|
+
}, [a, n]), w(() => {
|
|
59
60
|
p && u(p);
|
|
60
61
|
}, [p]);
|
|
61
|
-
const
|
|
62
|
-
s || (
|
|
63
|
-
},
|
|
64
|
-
editable: !
|
|
65
|
-
theme:
|
|
62
|
+
const b = () => {
|
|
63
|
+
s || (J(!0), n && n());
|
|
64
|
+
}, G = {
|
|
65
|
+
editable: !k,
|
|
66
|
+
theme: Te,
|
|
66
67
|
onError(t) {
|
|
67
68
|
console.error("TextEditor error:", t);
|
|
68
69
|
},
|
|
69
|
-
nodes: [
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
},
|
|
70
|
+
nodes: [ie, ne, ge, se]
|
|
71
|
+
}, K = () => {
|
|
72
|
+
b();
|
|
73
|
+
}, V = (t) => {
|
|
73
74
|
t.read(() => {
|
|
74
|
-
const o =
|
|
75
|
-
|
|
75
|
+
const o = Se().getTextContent(), r = y(o), c = JSON.stringify(t), R = y(c);
|
|
76
|
+
W(r), q(R), P && P(r, R);
|
|
76
77
|
});
|
|
77
|
-
},
|
|
78
|
-
const o =
|
|
78
|
+
}, X = (t) => {
|
|
79
|
+
const o = Q, r = $, c = d;
|
|
79
80
|
x && (t.preventDefault(), x(o, r, c)), u([]), h?.([]);
|
|
80
|
-
},
|
|
81
|
-
|
|
81
|
+
}, Y = () => {
|
|
82
|
+
D(
|
|
82
83
|
/* @__PURE__ */ e(
|
|
83
|
-
|
|
84
|
+
Le,
|
|
84
85
|
{
|
|
85
|
-
onAddSource:
|
|
86
|
+
onAddSource: Z,
|
|
86
87
|
allowedSources: T
|
|
87
88
|
}
|
|
88
89
|
)
|
|
89
90
|
);
|
|
90
|
-
},
|
|
91
|
+
}, Z = (t) => {
|
|
91
92
|
u((o) => {
|
|
92
93
|
const r = [...o, t];
|
|
93
94
|
return h?.(r), r;
|
|
94
95
|
});
|
|
95
|
-
},
|
|
96
|
+
}, ee = (t) => {
|
|
96
97
|
u((o) => {
|
|
97
98
|
const r = o.filter(
|
|
98
99
|
(c) => c.source_url !== t.source_url
|
|
99
100
|
);
|
|
100
101
|
return h?.(r), r;
|
|
101
102
|
});
|
|
102
|
-
},
|
|
103
|
-
|
|
103
|
+
}, te = (t, o) => /* @__PURE__ */ e(
|
|
104
|
+
_e,
|
|
104
105
|
{
|
|
105
106
|
publisher: t.publisher,
|
|
106
107
|
url: t.source_url,
|
|
107
108
|
title: t.title,
|
|
108
109
|
index: o,
|
|
109
|
-
onRemove: () =>
|
|
110
|
+
onRemove: () => ee(t)
|
|
110
111
|
},
|
|
111
112
|
o
|
|
112
|
-
),
|
|
113
|
-
return /* @__PURE__ */ S(
|
|
114
|
-
/* @__PURE__ */ e(
|
|
113
|
+
), oe = () => /* @__PURE__ */ e("div", { className: i.editorPlaceholder, children: l });
|
|
114
|
+
return /* @__PURE__ */ S(re, { children: [
|
|
115
|
+
/* @__PURE__ */ e(le, { initialConfig: G, children: /* @__PURE__ */ e("div", { className: i.editorContainer, onClick: K, children: /* @__PURE__ */ S(
|
|
115
116
|
"div",
|
|
116
117
|
{
|
|
117
|
-
className:
|
|
118
|
+
className: M(i.editorInner, {
|
|
118
119
|
[i.editorInnerInactive]: !s && !g
|
|
119
120
|
}),
|
|
120
121
|
children: [
|
|
121
122
|
/* @__PURE__ */ e(
|
|
122
|
-
|
|
123
|
+
he,
|
|
123
124
|
{
|
|
124
125
|
contentEditable: /* @__PURE__ */ e(
|
|
125
|
-
|
|
126
|
+
me,
|
|
126
127
|
{
|
|
127
|
-
className:
|
|
128
|
+
className: M(i.editorInput, {
|
|
128
129
|
[i.editorInputInactive]: !s
|
|
129
130
|
}),
|
|
130
|
-
...
|
|
131
|
+
...H
|
|
131
132
|
}
|
|
132
133
|
),
|
|
133
|
-
placeholder: l && /* @__PURE__ */ e(
|
|
134
|
-
ErrorBoundary:
|
|
134
|
+
placeholder: l && /* @__PURE__ */ e(oe, {}),
|
|
135
|
+
ErrorBoundary: de
|
|
135
136
|
}
|
|
136
137
|
),
|
|
137
138
|
/* @__PURE__ */ e(
|
|
138
|
-
|
|
139
|
+
we,
|
|
139
140
|
{
|
|
140
|
-
hideSourceAction:
|
|
141
|
-
hideSubmit:
|
|
142
|
-
disableRichText:
|
|
143
|
-
shortBar:
|
|
144
|
-
onSubmit:
|
|
145
|
-
onAddSource:
|
|
141
|
+
hideSourceAction: O,
|
|
142
|
+
hideSubmit: A,
|
|
143
|
+
disableRichText: U,
|
|
144
|
+
shortBar: B,
|
|
145
|
+
onSubmit: X,
|
|
146
|
+
onAddSource: Y,
|
|
146
147
|
isActive: s || g,
|
|
147
|
-
sourceTooltip: T?.length > 0 &&
|
|
148
|
+
sourceTooltip: T?.length > 0 && N.formatMessage({
|
|
148
149
|
id: "input.allowed_domains_tooltip",
|
|
149
150
|
defaultMessage: "With the new source function, you can add links to your article."
|
|
150
151
|
})
|
|
151
152
|
}
|
|
152
153
|
),
|
|
153
|
-
s && m && !
|
|
154
|
-
/* @__PURE__ */ e(
|
|
154
|
+
s && m && !z && /* @__PURE__ */ S("div", { className: i.charactersCount, children: [
|
|
155
|
+
/* @__PURE__ */ e(ce, { maxLength: m }),
|
|
155
156
|
" ",
|
|
156
|
-
|
|
157
|
+
N.formatMessage({
|
|
157
158
|
id: "input.remaining_chars",
|
|
158
159
|
defaultMessage: "remaining characters"
|
|
159
160
|
})
|
|
160
161
|
] }),
|
|
162
|
+
/* @__PURE__ */ e(fe, {}),
|
|
161
163
|
/* @__PURE__ */ e(ue, {}),
|
|
162
|
-
/* @__PURE__ */ e(
|
|
163
|
-
/* @__PURE__ */ e(fe, { onChange: K, ignoreSelectionChange: !0 }),
|
|
164
|
+
/* @__PURE__ */ e(pe, { onChange: V, ignoreSelectionChange: !0 }),
|
|
164
165
|
/* @__PURE__ */ e(
|
|
165
|
-
|
|
166
|
+
Ie,
|
|
166
167
|
{
|
|
167
|
-
onSetContent:
|
|
168
|
-
} :
|
|
169
|
-
storageUid: C ||
|
|
168
|
+
onSetContent: F ? () => {
|
|
169
|
+
} : b,
|
|
170
|
+
storageUid: C || v
|
|
170
171
|
}
|
|
171
172
|
),
|
|
172
|
-
/* @__PURE__ */ e(Re, { content:
|
|
173
|
-
/* @__PURE__ */ e(
|
|
174
|
-
/* @__PURE__ */ e(
|
|
175
|
-
/* @__PURE__ */ e(
|
|
176
|
-
m && /* @__PURE__ */ e(
|
|
177
|
-
/* @__PURE__ */ e(
|
|
178
|
-
/* @__PURE__ */ e(
|
|
173
|
+
/* @__PURE__ */ e(Re, { content: L, isReply: I }),
|
|
174
|
+
/* @__PURE__ */ e(Me, { richContent: _, isReply: I }),
|
|
175
|
+
/* @__PURE__ */ e(Ne, { autoFocus: a }),
|
|
176
|
+
/* @__PURE__ */ e(ve, {}),
|
|
177
|
+
m && /* @__PURE__ */ e(Ee, { maxLength: m }),
|
|
178
|
+
/* @__PURE__ */ e(be, { storageUid: C || v }),
|
|
179
|
+
/* @__PURE__ */ e(ae, { editorRef: j })
|
|
179
180
|
]
|
|
180
181
|
}
|
|
181
182
|
) }) }),
|
|
182
|
-
d && d.length !== 0 ? /* @__PURE__ */ e("div", { className: i.sourcesBox, children: /* @__PURE__ */ e("div", { className: i.sourceList, children: d.map(
|
|
183
|
+
d && d.length !== 0 ? /* @__PURE__ */ e("div", { className: i.sourcesBox, children: /* @__PURE__ */ e("div", { className: i.sourceList, children: d.map(te) }) }) : null
|
|
183
184
|
] });
|
|
184
185
|
};
|
|
185
186
|
export {
|
|
186
|
-
|
|
187
|
+
mt as TextEditor
|
|
187
188
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useLexicalComposerContext as
|
|
2
|
-
import { $getRoot as
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { useInput as
|
|
5
|
-
const
|
|
6
|
-
const [
|
|
7
|
-
return
|
|
8
|
-
typeof t == "string" && t &&
|
|
9
|
-
const n =
|
|
1
|
+
import { useLexicalComposerContext as a } from "@lexical/react/LexicalComposerContext";
|
|
2
|
+
import { $getRoot as c, $createParagraphNode as f, $createTextNode as u } from "lexical";
|
|
3
|
+
import { useEffect as m } from "react";
|
|
4
|
+
import { useInput as d } from "../../input_provider/useInput.js";
|
|
5
|
+
const $ = ({ content: e, isReply: p = !1 }) => {
|
|
6
|
+
const [s] = a(), { inputContent: o, setInputContent: i } = d(), t = e || (!p && typeof o == "string" ? o : void 0);
|
|
7
|
+
return m(() => {
|
|
8
|
+
typeof t == "string" && t && s.update(() => {
|
|
9
|
+
const n = c();
|
|
10
10
|
n.clear();
|
|
11
|
-
const r =
|
|
11
|
+
const r = f();
|
|
12
12
|
r.append(u(t)), n.append(r), !e && o && i(null);
|
|
13
13
|
});
|
|
14
14
|
}, [t]), null;
|
|
15
15
|
};
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
$ as SetContentPlugin
|
|
18
18
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { useLexicalComposerContext as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { useInput as
|
|
4
|
-
const
|
|
5
|
-
const [t] =
|
|
6
|
-
return
|
|
1
|
+
import { useLexicalComposerContext as u } from "@lexical/react/LexicalComposerContext";
|
|
2
|
+
import { useEffect as c } from "react";
|
|
3
|
+
import { useInput as p } from "../../input_provider/useInput.js";
|
|
4
|
+
const l = ({ richContent: e, isReply: i = !1 }) => {
|
|
5
|
+
const [t] = u(), { inputRichContent: n, setInputRichContent: r } = p(), o = e || (i ? void 0 : n);
|
|
6
|
+
return c(() => {
|
|
7
7
|
o && t.update(() => {
|
|
8
|
-
const
|
|
9
|
-
t.setEditorState(
|
|
8
|
+
const s = t.parseEditorState(o);
|
|
9
|
+
t.setEditorState(s), !e && n && r(null);
|
|
10
10
|
});
|
|
11
11
|
}, [o]), null;
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
l as SetRichContentPlugin
|
|
15
15
|
};
|