@logora/debate 0.3.115 → 0.3.117
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,30 +1,30 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as k, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { $isListNode as $, ListNode as q, INSERT_ORDERED_LIST_COMMAND as K, REMOVE_LIST_COMMAND as F } from "@lexical/list";
|
|
3
3
|
import { useLexicalComposerContext as U } from "@lexical/react/LexicalComposerContext";
|
|
4
|
-
import { $isHeadingNode as P, $createQuoteNode as
|
|
5
|
-
import { $setBlocksType as
|
|
4
|
+
import { $isHeadingNode as P, $createQuoteNode as x } from "@lexical/rich-text";
|
|
5
|
+
import { $setBlocksType as I } from "@lexical/selection";
|
|
6
6
|
import { $getNearestNodeOfType as j, mergeRegister as H } from "@lexical/utils";
|
|
7
7
|
import a from "classnames";
|
|
8
|
-
import { $getSelection as
|
|
8
|
+
import { $getSelection as p, $isRangeSelection as N, SELECTION_CHANGE_COMMAND as Q, FORMAT_TEXT_COMMAND as G, $createParagraphNode as V } from "lexical";
|
|
9
9
|
import { useRef as X, useState as m, useCallback as z, useEffect as J } from "react";
|
|
10
10
|
import { useIntl as W } from "react-intl";
|
|
11
11
|
import e from "./ToolbarPlugin.module.scss.js";
|
|
12
|
-
import { Icon as
|
|
12
|
+
import { Icon as d } from "../../../icons/icon/Icon.js";
|
|
13
13
|
import { Button as Y } from "../../../action/button/Button.js";
|
|
14
14
|
const he = (l) => {
|
|
15
|
-
const
|
|
16
|
-
const t =
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
15
|
+
const c = W(), E = 1, [n] = U(), A = X(null), [b, M] = m("paragraph"), [Z, v] = m(null), [w, T] = m(!1), [D, _] = m(!1), [L, y] = m(!1), S = l.hideSubmit && l.hideSourceAction && l.disableRichText, h = z(() => {
|
|
16
|
+
const t = p();
|
|
17
|
+
if (N(t)) {
|
|
18
|
+
const s = t.anchor.getNode(), r = s.getKey() === "root" ? s : s.getTopLevelElementOrThrow(), u = r.getKey();
|
|
19
19
|
if (n.getElementByKey(u) !== null)
|
|
20
|
-
if (
|
|
21
|
-
const g = j(
|
|
22
|
-
|
|
20
|
+
if (v(u), $(r)) {
|
|
21
|
+
const g = j(s, q), B = g ? g.getTag() : r.getTag();
|
|
22
|
+
M(B);
|
|
23
23
|
} else {
|
|
24
|
-
const g = P(
|
|
25
|
-
|
|
24
|
+
const g = P(r) ? r.getTag() : r.getType();
|
|
25
|
+
M(g);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
T(t.hasFormat("bold")), _(t.hasFormat("italic")), y(t.hasFormat("underline"));
|
|
28
28
|
}
|
|
29
29
|
}, [n]);
|
|
30
30
|
J(() => H(
|
|
@@ -36,44 +36,44 @@ const he = (l) => {
|
|
|
36
36
|
n.registerCommand(
|
|
37
37
|
Q,
|
|
38
38
|
() => (h(), !1),
|
|
39
|
-
|
|
39
|
+
E
|
|
40
40
|
)
|
|
41
41
|
), [n, h]);
|
|
42
42
|
const i = (t) => {
|
|
43
43
|
t.preventDefault();
|
|
44
|
-
},
|
|
44
|
+
}, C = () => {
|
|
45
45
|
setTimeout(() => {
|
|
46
46
|
n.getEditorState().read(() => {
|
|
47
47
|
h();
|
|
48
48
|
});
|
|
49
49
|
}, 0);
|
|
50
|
-
},
|
|
51
|
-
n.dispatchCommand(G, t),
|
|
50
|
+
}, f = (t) => {
|
|
51
|
+
n.dispatchCommand(G, t), t === "bold" && T((s) => !s), t === "italic" && _((s) => !s), t === "underline" && y((s) => !s);
|
|
52
52
|
}, O = () => {
|
|
53
|
-
b !== "ol" ? n.dispatchCommand(K) : n.dispatchCommand(F),
|
|
53
|
+
b !== "ol" ? n.dispatchCommand(K) : n.dispatchCommand(F), C();
|
|
54
54
|
}, R = () => {
|
|
55
55
|
b !== "quote" ? n.update(() => {
|
|
56
|
-
const t =
|
|
57
|
-
if (
|
|
56
|
+
const t = p();
|
|
57
|
+
if (N(t))
|
|
58
58
|
if (t.isCollapsed()) {
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const r = t.anchor.getNode().getTopLevelElementOrThrow(), u = x();
|
|
60
|
+
r.insertAfter(u), u.selectEnd();
|
|
61
61
|
} else
|
|
62
|
-
|
|
62
|
+
I(t, () => x());
|
|
63
63
|
}) : n.update(() => {
|
|
64
|
-
const t =
|
|
65
|
-
|
|
66
|
-
}),
|
|
64
|
+
const t = p();
|
|
65
|
+
N(t) && I(t, () => V());
|
|
66
|
+
}), C();
|
|
67
67
|
};
|
|
68
|
-
return
|
|
68
|
+
return S ? null : /* @__PURE__ */ k(
|
|
69
69
|
"div",
|
|
70
70
|
{
|
|
71
71
|
className: a(e.toolbar, {
|
|
72
|
-
[e.toolbarIsActive]:
|
|
72
|
+
[e.toolbarIsActive]: S ? !1 : l.isActive
|
|
73
73
|
}),
|
|
74
|
-
ref:
|
|
74
|
+
ref: A,
|
|
75
75
|
children: [
|
|
76
|
-
l.isActive ? !l.disableRichText && /* @__PURE__ */
|
|
76
|
+
l.isActive ? !l.disableRichText && /* @__PURE__ */ k(
|
|
77
77
|
"div",
|
|
78
78
|
{
|
|
79
79
|
className: a(e.iconToolbar, {
|
|
@@ -85,16 +85,16 @@ const he = (l) => {
|
|
|
85
85
|
{
|
|
86
86
|
onTouchStart: i,
|
|
87
87
|
onMouseDown: i,
|
|
88
|
-
onClick: () =>
|
|
88
|
+
onClick: () => f("bold"),
|
|
89
89
|
type: "button",
|
|
90
|
-
className: a(e.toolbarItem, { [e.active]:
|
|
90
|
+
className: a(e.toolbarItem, { [e.active]: w }),
|
|
91
91
|
"data-testid": "format-bold",
|
|
92
|
-
"aria-label":
|
|
92
|
+
"aria-label": c.formatMessage({
|
|
93
93
|
id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
|
|
94
94
|
defaultMessage: "Make text bold"
|
|
95
95
|
}),
|
|
96
96
|
children: /* @__PURE__ */ o(
|
|
97
|
-
|
|
97
|
+
d,
|
|
98
98
|
{
|
|
99
99
|
name: "bold",
|
|
100
100
|
width: 24,
|
|
@@ -109,17 +109,17 @@ const he = (l) => {
|
|
|
109
109
|
{
|
|
110
110
|
onTouchStart: i,
|
|
111
111
|
onMouseDown: i,
|
|
112
|
-
onClick: () =>
|
|
112
|
+
onClick: () => f("italic"),
|
|
113
113
|
type: "button",
|
|
114
114
|
className: a(e.toolbarItem, {
|
|
115
|
-
[e.active]:
|
|
115
|
+
[e.active]: D
|
|
116
116
|
}),
|
|
117
|
-
"aria-label":
|
|
117
|
+
"aria-label": c.formatMessage({
|
|
118
118
|
id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
|
|
119
119
|
defaultMessage: "Make text italic"
|
|
120
120
|
}),
|
|
121
121
|
children: /* @__PURE__ */ o(
|
|
122
|
-
|
|
122
|
+
d,
|
|
123
123
|
{
|
|
124
124
|
name: "italic",
|
|
125
125
|
width: 24,
|
|
@@ -134,17 +134,17 @@ const he = (l) => {
|
|
|
134
134
|
{
|
|
135
135
|
onTouchStart: i,
|
|
136
136
|
onMouseDown: i,
|
|
137
|
-
onClick: () =>
|
|
137
|
+
onClick: () => f("underline"),
|
|
138
138
|
type: "button",
|
|
139
139
|
className: a(e.toolbarItem, {
|
|
140
|
-
[e.active]:
|
|
140
|
+
[e.active]: L
|
|
141
141
|
}),
|
|
142
|
-
"aria-label":
|
|
142
|
+
"aria-label": c.formatMessage({
|
|
143
143
|
id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
|
|
144
144
|
defaultMessage: "Underline text"
|
|
145
145
|
}),
|
|
146
146
|
children: /* @__PURE__ */ o(
|
|
147
|
-
|
|
147
|
+
d,
|
|
148
148
|
{
|
|
149
149
|
name: "underline",
|
|
150
150
|
width: 24,
|
|
@@ -164,12 +164,12 @@ const he = (l) => {
|
|
|
164
164
|
className: a(e.toolbarItem, {
|
|
165
165
|
[e.active]: b === "quote"
|
|
166
166
|
}),
|
|
167
|
-
"aria-label":
|
|
167
|
+
"aria-label": c.formatMessage({
|
|
168
168
|
id: "input.text_editor.plugins.toolbar_plugin.blockquote.aria_label",
|
|
169
169
|
defaultMessage: "Add a blockquote"
|
|
170
170
|
}),
|
|
171
171
|
children: /* @__PURE__ */ o(
|
|
172
|
-
|
|
172
|
+
d,
|
|
173
173
|
{
|
|
174
174
|
name: "blockquote",
|
|
175
175
|
width: 24,
|
|
@@ -189,12 +189,12 @@ const he = (l) => {
|
|
|
189
189
|
className: a(e.toolbarItem, {
|
|
190
190
|
[e.active]: b === "ol"
|
|
191
191
|
}),
|
|
192
|
-
"aria-label":
|
|
192
|
+
"aria-label": c.formatMessage({
|
|
193
193
|
id: "input.text_editor.plugins.toolbar_plugin.numbered_list.aria_label",
|
|
194
194
|
defaultMessage: "Insert a numbered list"
|
|
195
195
|
}),
|
|
196
196
|
children: /* @__PURE__ */ o(
|
|
197
|
-
|
|
197
|
+
d,
|
|
198
198
|
{
|
|
199
199
|
name: "orderedList",
|
|
200
200
|
width: 24,
|
|
@@ -212,12 +212,12 @@ const he = (l) => {
|
|
|
212
212
|
onClick: l.onAddSource,
|
|
213
213
|
type: "button",
|
|
214
214
|
className: e.toolbarItem,
|
|
215
|
-
"aria-label":
|
|
215
|
+
"aria-label": c.formatMessage({
|
|
216
216
|
id: "input.text_editor.plugins.toolbar_plugin.add_link.aria_label",
|
|
217
217
|
defaultMessage: "Add hyperlink"
|
|
218
218
|
}),
|
|
219
219
|
children: /* @__PURE__ */ o(
|
|
220
|
-
|
|
220
|
+
d,
|
|
221
221
|
{
|
|
222
222
|
name: "link",
|
|
223
223
|
width: 20,
|
|
@@ -237,11 +237,11 @@ const he = (l) => {
|
|
|
237
237
|
"data-testid": "submit-button",
|
|
238
238
|
handleClick: l.onSubmit,
|
|
239
239
|
className: a(e.inputSubmitActionButton, e.submitAction),
|
|
240
|
-
"aria-label":
|
|
240
|
+
"aria-label": c.formatMessage({
|
|
241
241
|
id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
|
|
242
242
|
defaultMessage: "Send message"
|
|
243
243
|
}),
|
|
244
|
-
children: /* @__PURE__ */ o(
|
|
244
|
+
children: /* @__PURE__ */ o(d, { name: "send", width: 20, height: 20 })
|
|
245
245
|
}
|
|
246
246
|
) })
|
|
247
247
|
]
|