@logora/debate 0.3.14 → 0.3.15
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,171 +1,175 @@
|
|
|
1
|
-
import { jsxs as u, 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
|
|
1
|
+
import { jsxs as u, Fragment as Y, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { ListNode as Z, ListItemNode as tt } from "@lexical/list";
|
|
3
|
+
import { OverflowNode as ot } from "@lexical/overflow";
|
|
4
|
+
import { CharacterLimitPlugin as et } from "@lexical/react/LexicalCharacterLimitPlugin";
|
|
5
|
+
import { LexicalComposer as rt } from "@lexical/react/LexicalComposer";
|
|
6
|
+
import { ContentEditable as it } from "@lexical/react/LexicalContentEditable";
|
|
7
|
+
import { EditorRefPlugin as nt } from "@lexical/react/LexicalEditorRefPlugin";
|
|
8
|
+
import { LexicalErrorBoundary as st } from "@lexical/react/LexicalErrorBoundary";
|
|
9
|
+
import { HistoryPlugin as lt } from "@lexical/react/LexicalHistoryPlugin";
|
|
10
|
+
import { ListPlugin as ct } from "@lexical/react/LexicalListPlugin";
|
|
11
|
+
import { OnChangePlugin as at } from "@lexical/react/LexicalOnChangePlugin";
|
|
12
12
|
import { RichTextPlugin as mt } from "@lexical/react/LexicalRichTextPlugin";
|
|
13
|
-
import { QuoteNode as
|
|
14
|
-
import
|
|
15
|
-
import { $getRoot as
|
|
16
|
-
import { useState as
|
|
17
|
-
import { useIntl as
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { AutoSavePlugin as
|
|
21
|
-
import { FocusPlugin as
|
|
22
|
-
import { MaxLengthPlugin as
|
|
23
|
-
import { ResetPlugin as
|
|
24
|
-
import { SetContentPlugin as
|
|
13
|
+
import { QuoteNode as dt } from "@lexical/rich-text";
|
|
14
|
+
import y from "classnames";
|
|
15
|
+
import { $getRoot as ft } from "lexical";
|
|
16
|
+
import { useState as d, useId as ut, useEffect as I } from "react";
|
|
17
|
+
import { useIntl as pt } from "react-intl";
|
|
18
|
+
import ht from "./EditorTheme.js";
|
|
19
|
+
import r from "./TextEditor.module.scss.js";
|
|
20
|
+
import { AutoSavePlugin as gt } from "./plugins/AutoSavePlugin.js";
|
|
21
|
+
import { FocusPlugin as xt } from "./plugins/FocusPlugin.js";
|
|
22
|
+
import { MaxLengthPlugin as St } from "./plugins/MaxLengthPlugin.js";
|
|
23
|
+
import { ResetPlugin as Ct } from "./plugins/ResetPlugin.js";
|
|
24
|
+
import { SetContentPlugin as Nt } from "./plugins/SetContentPlugin.js";
|
|
25
25
|
import { SetRichContentPlugin as Pt } from "./plugins/SetRichContentPlugin.js";
|
|
26
|
-
import { ToolbarPlugin as
|
|
26
|
+
import { ToolbarPlugin as Et } from "./plugins/ToolbarPlugin.js";
|
|
27
27
|
import { useModal as vt } from "../../dialog/modal/useModal.js";
|
|
28
|
-
import { SourceModal as
|
|
29
|
-
import { SourceListItem as
|
|
30
|
-
const
|
|
31
|
-
|
|
28
|
+
import { SourceModal as Tt } from "../../source/source_modal/SourceModal.js";
|
|
29
|
+
import { SourceListItem as yt } from "../../source/source_list_item/SourceListItem.js";
|
|
30
|
+
const b = (o) => o?.replace(/ /g, " "), M = (o) => {
|
|
31
|
+
!o || typeof o != "object" || (typeof o.text == "string" && (o.text = b(o.text)), Array.isArray(o.children) && o.children.forEach(M));
|
|
32
|
+
}, oo = ({
|
|
33
|
+
placeholder: o,
|
|
32
34
|
onSubmit: p,
|
|
33
|
-
sources:
|
|
34
|
-
hideSubmit:
|
|
35
|
-
hideSourceAction:
|
|
35
|
+
sources: i,
|
|
36
|
+
hideSubmit: A = !1,
|
|
37
|
+
hideSourceAction: w = !1,
|
|
36
38
|
onActivation: h,
|
|
37
|
-
disabled:
|
|
39
|
+
disabled: L = !1,
|
|
38
40
|
handleChange: g,
|
|
39
41
|
handleSourcesChange: x,
|
|
40
|
-
shortBar:
|
|
42
|
+
shortBar: R = !1,
|
|
41
43
|
active: S = !1,
|
|
42
44
|
maxLength: c,
|
|
43
|
-
disableRichText:
|
|
45
|
+
disableRichText: O = !1,
|
|
44
46
|
editorRef: _,
|
|
45
47
|
uid: C,
|
|
46
|
-
allowedDomains:
|
|
47
|
-
hideCharCount:
|
|
48
|
-
disableAutoActivate:
|
|
49
|
-
...
|
|
48
|
+
allowedDomains: N = [],
|
|
49
|
+
hideCharCount: j = !1,
|
|
50
|
+
disableAutoActivate: B = !1,
|
|
51
|
+
...F
|
|
50
52
|
}) => {
|
|
51
|
-
const [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, [
|
|
55
|
-
x &&
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
editable: !
|
|
61
|
-
theme:
|
|
62
|
-
onError(
|
|
63
|
-
console.error("TextEditor error:",
|
|
53
|
+
const [s, U] = d(!1), [k, z] = d(""), [J, H] = d(""), [l, f] = d([]), { showModal: Q } = vt(), P = pt(), E = ut();
|
|
54
|
+
I(() => {
|
|
55
|
+
i && i.length > 0 && f(i);
|
|
56
|
+
}, [i]), I(() => {
|
|
57
|
+
x && l.length > 0 && x(l);
|
|
58
|
+
}, [l]);
|
|
59
|
+
const v = () => {
|
|
60
|
+
s || (U(!0), h && h());
|
|
61
|
+
}, W = {
|
|
62
|
+
editable: !L,
|
|
63
|
+
theme: ht,
|
|
64
|
+
onError(e) {
|
|
65
|
+
console.error("TextEditor error:", e);
|
|
64
66
|
},
|
|
65
|
-
nodes: [
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
67
|
+
nodes: [Z, tt, dt, ot]
|
|
68
|
+
}, $ = () => {
|
|
69
|
+
v();
|
|
70
|
+
}, q = (e) => {
|
|
71
|
+
e.read(() => {
|
|
72
|
+
const n = ft().getTextContent(), a = b(n), m = e.toJSON();
|
|
73
|
+
M(m.root);
|
|
74
|
+
const T = JSON.stringify(m);
|
|
75
|
+
z(a), H(T), g && g(a, T);
|
|
72
76
|
});
|
|
73
|
-
},
|
|
74
|
-
const
|
|
75
|
-
p && (
|
|
76
|
-
},
|
|
77
|
-
|
|
77
|
+
}, D = (e) => {
|
|
78
|
+
const n = k, a = J, m = l;
|
|
79
|
+
p && (e.preventDefault(), p(n, a, m)), f([]);
|
|
80
|
+
}, G = () => {
|
|
81
|
+
Q(
|
|
78
82
|
/* @__PURE__ */ t(
|
|
79
|
-
|
|
83
|
+
Tt,
|
|
80
84
|
{
|
|
81
|
-
onAddSource:
|
|
82
|
-
allowedSources:
|
|
85
|
+
onAddSource: K,
|
|
86
|
+
allowedSources: N
|
|
83
87
|
}
|
|
84
88
|
)
|
|
85
89
|
);
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
+
}, K = (e) => {
|
|
91
|
+
f([...l, e]);
|
|
92
|
+
}, V = (e, n) => /* @__PURE__ */ t(
|
|
93
|
+
yt,
|
|
90
94
|
{
|
|
91
|
-
publisher:
|
|
92
|
-
url:
|
|
93
|
-
title:
|
|
94
|
-
index:
|
|
95
|
+
publisher: e.publisher,
|
|
96
|
+
url: e.source_url,
|
|
97
|
+
title: e.title,
|
|
98
|
+
index: n
|
|
95
99
|
},
|
|
96
|
-
|
|
97
|
-
),
|
|
98
|
-
return /* @__PURE__ */ u(
|
|
99
|
-
/* @__PURE__ */ t(
|
|
100
|
+
n
|
|
101
|
+
), X = () => /* @__PURE__ */ t("div", { className: r.editorPlaceholder, children: o });
|
|
102
|
+
return /* @__PURE__ */ u(Y, { children: [
|
|
103
|
+
/* @__PURE__ */ t(rt, { initialConfig: W, children: /* @__PURE__ */ t("div", { className: r.editorContainer, onClick: $, children: /* @__PURE__ */ u(
|
|
100
104
|
"div",
|
|
101
105
|
{
|
|
102
|
-
className:
|
|
103
|
-
[
|
|
106
|
+
className: y(r.editorInner, {
|
|
107
|
+
[r.editorInnerInactive]: !s && !S
|
|
104
108
|
}),
|
|
105
109
|
children: [
|
|
106
110
|
/* @__PURE__ */ t(
|
|
107
111
|
mt,
|
|
108
112
|
{
|
|
109
113
|
contentEditable: /* @__PURE__ */ t(
|
|
110
|
-
|
|
114
|
+
it,
|
|
111
115
|
{
|
|
112
|
-
className:
|
|
113
|
-
[
|
|
116
|
+
className: y(r.editorInput, {
|
|
117
|
+
[r.editorInputInactive]: !s
|
|
114
118
|
}),
|
|
115
|
-
...
|
|
119
|
+
...F
|
|
116
120
|
}
|
|
117
121
|
),
|
|
118
|
-
placeholder:
|
|
119
|
-
ErrorBoundary:
|
|
122
|
+
placeholder: o && /* @__PURE__ */ t(X, {}),
|
|
123
|
+
ErrorBoundary: st
|
|
120
124
|
}
|
|
121
125
|
),
|
|
122
126
|
/* @__PURE__ */ t(
|
|
123
|
-
|
|
127
|
+
Et,
|
|
124
128
|
{
|
|
125
|
-
hideSourceAction:
|
|
126
|
-
hideSubmit:
|
|
127
|
-
disableRichText:
|
|
128
|
-
shortBar:
|
|
129
|
-
onSubmit:
|
|
130
|
-
onAddSource:
|
|
131
|
-
isActive:
|
|
132
|
-
sourceTooltip:
|
|
129
|
+
hideSourceAction: w,
|
|
130
|
+
hideSubmit: A,
|
|
131
|
+
disableRichText: O,
|
|
132
|
+
shortBar: R,
|
|
133
|
+
onSubmit: D,
|
|
134
|
+
onAddSource: G,
|
|
135
|
+
isActive: s || S,
|
|
136
|
+
sourceTooltip: N?.length > 0 && P.formatMessage({
|
|
133
137
|
id: "input.allowed_domains_tooltip",
|
|
134
138
|
defaultMessage: "With the new source function, you can add links to your article."
|
|
135
139
|
})
|
|
136
140
|
}
|
|
137
141
|
),
|
|
138
|
-
|
|
139
|
-
/* @__PURE__ */ t(
|
|
142
|
+
s && c && !j && /* @__PURE__ */ u("div", { className: r.charactersCount, children: [
|
|
143
|
+
/* @__PURE__ */ t(et, { maxLength: c }),
|
|
140
144
|
" ",
|
|
141
|
-
|
|
145
|
+
P.formatMessage({
|
|
142
146
|
id: "input.remaining_chars",
|
|
143
147
|
defaultMessage: "remaining characters"
|
|
144
148
|
})
|
|
145
149
|
] }),
|
|
150
|
+
/* @__PURE__ */ t(ct, {}),
|
|
146
151
|
/* @__PURE__ */ t(lt, {}),
|
|
147
|
-
/* @__PURE__ */ t(
|
|
148
|
-
/* @__PURE__ */ t(ct, { onChange: $, ignoreSelectionChange: !0 }),
|
|
152
|
+
/* @__PURE__ */ t(at, { onChange: q, ignoreSelectionChange: !0 }),
|
|
149
153
|
/* @__PURE__ */ t(
|
|
150
|
-
|
|
154
|
+
gt,
|
|
151
155
|
{
|
|
152
|
-
onSetContent:
|
|
153
|
-
} :
|
|
154
|
-
storageUid: C ||
|
|
156
|
+
onSetContent: B ? () => {
|
|
157
|
+
} : v,
|
|
158
|
+
storageUid: C || E
|
|
155
159
|
}
|
|
156
160
|
),
|
|
157
|
-
/* @__PURE__ */ t(
|
|
161
|
+
/* @__PURE__ */ t(Nt, {}),
|
|
158
162
|
/* @__PURE__ */ t(Pt, {}),
|
|
159
|
-
/* @__PURE__ */ t(
|
|
160
|
-
c && /* @__PURE__ */ t(
|
|
161
|
-
/* @__PURE__ */ t(
|
|
162
|
-
/* @__PURE__ */ t(
|
|
163
|
+
/* @__PURE__ */ t(xt, {}),
|
|
164
|
+
c && /* @__PURE__ */ t(St, { maxLength: c }),
|
|
165
|
+
/* @__PURE__ */ t(Ct, { storageUid: C || E }),
|
|
166
|
+
/* @__PURE__ */ t(nt, { editorRef: _ })
|
|
163
167
|
]
|
|
164
168
|
}
|
|
165
169
|
) }) }),
|
|
166
|
-
|
|
170
|
+
i && i.length !== 0 ? /* @__PURE__ */ t("div", { className: r.sourcesBox, children: /* @__PURE__ */ t("div", { className: r.sourceList, children: i.map(V) }) }) : null
|
|
167
171
|
] });
|
|
168
172
|
};
|
|
169
173
|
export {
|
|
170
|
-
|
|
174
|
+
oo as TextEditor
|
|
171
175
|
};
|