@logora/debate 0.3.108 → 0.3.109
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,86 +1,94 @@
|
|
|
1
1
|
import { jsxs as y, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { $isListNode as
|
|
3
|
-
import { useLexicalComposerContext as
|
|
4
|
-
import { $isHeadingNode as U, $createQuoteNode as
|
|
5
|
-
import { $setBlocksType as
|
|
6
|
-
import { $getNearestNodeOfType as
|
|
2
|
+
import { $isListNode as $, ListNode as q, INSERT_ORDERED_LIST_COMMAND as K, REMOVE_LIST_COMMAND as F } from "@lexical/list";
|
|
3
|
+
import { useLexicalComposerContext as P } from "@lexical/react/LexicalComposerContext";
|
|
4
|
+
import { $isHeadingNode as U, $createQuoteNode as C } from "@lexical/rich-text";
|
|
5
|
+
import { $setBlocksType as k } from "@lexical/selection";
|
|
6
|
+
import { $getNearestNodeOfType as j, mergeRegister as H } from "@lexical/utils";
|
|
7
7
|
import a from "classnames";
|
|
8
|
-
import { $getSelection as
|
|
9
|
-
import { useRef as
|
|
10
|
-
import { useIntl as
|
|
8
|
+
import { $getSelection as N, $isRangeSelection as _, SELECTION_CHANGE_COMMAND as Q, FORMAT_TEXT_COMMAND as G, $createParagraphNode as V } from "lexical";
|
|
9
|
+
import { useRef as X, useState as u, useCallback as z, useEffect as J } from "react";
|
|
10
|
+
import { useIntl as W } from "react-intl";
|
|
11
11
|
import e from "./ToolbarPlugin.module.scss.js";
|
|
12
12
|
import { Icon as r } from "../../../icons/icon/Icon.js";
|
|
13
|
-
import { Button as
|
|
14
|
-
const
|
|
15
|
-
const s =
|
|
16
|
-
const t =
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
|
|
13
|
+
import { Button as Y } from "../../../action/button/Button.js";
|
|
14
|
+
const ge = (i) => {
|
|
15
|
+
const s = W(), x = 1, [l] = P(), E = X(null), [b, M] = u("paragraph"), [Z, I] = u(null), [S, v] = u(!1), [A, w] = u(!1), [L, D] = u(!1), T = i.hideSubmit && i.hideSourceAction && i.disableRichText, g = z(() => {
|
|
16
|
+
const t = N();
|
|
17
|
+
if (_(t)) {
|
|
18
|
+
const c = t.anchor.getNode(), n = c.getKey() === "root" ? c : c.getTopLevelElementOrThrow(), m = n.getKey();
|
|
19
|
+
if (l.getElementByKey(m) !== null)
|
|
20
|
+
if (I(m), $(n)) {
|
|
21
|
+
const f = j(c, q), B = f ? f.getTag() : n.getTag();
|
|
22
|
+
M(B);
|
|
23
23
|
} else {
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const f = U(n) ? n.getTag() : n.getType();
|
|
25
|
+
M(f);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
v(t.hasFormat("bold")), w(t.hasFormat("italic")), D(t.hasFormat("underline"));
|
|
28
28
|
}
|
|
29
|
-
}, [
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
}, [l]);
|
|
30
|
+
J(() => H(
|
|
31
|
+
l.registerUpdateListener(({ editorState: t }) => {
|
|
32
32
|
t.read(() => {
|
|
33
|
-
|
|
33
|
+
g();
|
|
34
34
|
});
|
|
35
35
|
}),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
(t,
|
|
39
|
-
|
|
36
|
+
l.registerCommand(
|
|
37
|
+
Q,
|
|
38
|
+
(t, c) => (g(), !1),
|
|
39
|
+
x
|
|
40
40
|
)
|
|
41
|
-
), [
|
|
42
|
-
const
|
|
41
|
+
), [l, g]);
|
|
42
|
+
const d = (t) => {
|
|
43
43
|
t.preventDefault();
|
|
44
|
-
},
|
|
45
|
-
|
|
44
|
+
}, h = () => {
|
|
45
|
+
Promise.resolve().then(() => {
|
|
46
|
+
l.getEditorState().read(() => {
|
|
47
|
+
g();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}, p = (t) => {
|
|
51
|
+
l.dispatchCommand(G, t), h();
|
|
46
52
|
}, O = () => {
|
|
47
|
-
b !== "
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
b !== "ol" ? l.dispatchCommand(K) : l.dispatchCommand(F), h();
|
|
54
|
+
}, R = () => {
|
|
55
|
+
b !== "quote" ? l.update(() => {
|
|
56
|
+
const t = N();
|
|
57
|
+
if (_(t))
|
|
50
58
|
if (t.isCollapsed()) {
|
|
51
|
-
const n = t.anchor.getNode().getTopLevelElementOrThrow(), m =
|
|
59
|
+
const n = t.anchor.getNode().getTopLevelElementOrThrow(), m = C();
|
|
52
60
|
n.insertAfter(m), m.selectEnd();
|
|
53
61
|
} else
|
|
54
|
-
|
|
55
|
-
}) :
|
|
56
|
-
const t =
|
|
57
|
-
|
|
58
|
-
});
|
|
62
|
+
k(t, () => C());
|
|
63
|
+
}) : l.update(() => {
|
|
64
|
+
const t = N();
|
|
65
|
+
_(t) && k(t, () => V());
|
|
66
|
+
}), h();
|
|
59
67
|
};
|
|
60
|
-
return
|
|
68
|
+
return T ? null : /* @__PURE__ */ y(
|
|
61
69
|
"div",
|
|
62
70
|
{
|
|
63
71
|
className: a(e.toolbar, {
|
|
64
|
-
[e.toolbarIsActive]:
|
|
72
|
+
[e.toolbarIsActive]: T ? !1 : i.isActive
|
|
65
73
|
}),
|
|
66
|
-
ref:
|
|
74
|
+
ref: E,
|
|
67
75
|
children: [
|
|
68
|
-
|
|
76
|
+
i.isActive ? !i.disableRichText && /* @__PURE__ */ y(
|
|
69
77
|
"div",
|
|
70
78
|
{
|
|
71
79
|
className: a(e.iconToolbar, {
|
|
72
|
-
[e.shortBar]:
|
|
80
|
+
[e.shortBar]: i.shortBar
|
|
73
81
|
}),
|
|
74
82
|
children: [
|
|
75
83
|
/* @__PURE__ */ o(
|
|
76
84
|
"button",
|
|
77
85
|
{
|
|
78
|
-
onMouseDown:
|
|
86
|
+
onMouseDown: d,
|
|
79
87
|
onClick: () => {
|
|
80
|
-
|
|
88
|
+
p("bold");
|
|
81
89
|
},
|
|
82
90
|
type: "button",
|
|
83
|
-
className: a(e.toolbarItem, { [e.active]:
|
|
91
|
+
className: a(e.toolbarItem, { [e.active]: S }),
|
|
84
92
|
"data-testid": "format-bold",
|
|
85
93
|
"aria-label": s.formatMessage({
|
|
86
94
|
id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
|
|
@@ -100,13 +108,13 @@ const ue = (l) => {
|
|
|
100
108
|
/* @__PURE__ */ o(
|
|
101
109
|
"button",
|
|
102
110
|
{
|
|
103
|
-
onMouseDown:
|
|
111
|
+
onMouseDown: d,
|
|
104
112
|
onClick: () => {
|
|
105
|
-
|
|
113
|
+
p("italic");
|
|
106
114
|
},
|
|
107
115
|
type: "button",
|
|
108
116
|
className: a(e.toolbarItem, {
|
|
109
|
-
[e.active]:
|
|
117
|
+
[e.active]: A
|
|
110
118
|
}),
|
|
111
119
|
"aria-label": s.formatMessage({
|
|
112
120
|
id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
|
|
@@ -126,13 +134,13 @@ const ue = (l) => {
|
|
|
126
134
|
/* @__PURE__ */ o(
|
|
127
135
|
"button",
|
|
128
136
|
{
|
|
129
|
-
onMouseDown:
|
|
137
|
+
onMouseDown: d,
|
|
130
138
|
onClick: () => {
|
|
131
|
-
|
|
139
|
+
p("underline");
|
|
132
140
|
},
|
|
133
141
|
type: "button",
|
|
134
142
|
className: a(e.toolbarItem, {
|
|
135
|
-
[e.active]:
|
|
143
|
+
[e.active]: L
|
|
136
144
|
}),
|
|
137
145
|
"aria-label": s.formatMessage({
|
|
138
146
|
id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
|
|
@@ -152,8 +160,8 @@ const ue = (l) => {
|
|
|
152
160
|
/* @__PURE__ */ o(
|
|
153
161
|
"button",
|
|
154
162
|
{
|
|
155
|
-
onMouseDown:
|
|
156
|
-
onClick: () =>
|
|
163
|
+
onMouseDown: d,
|
|
164
|
+
onClick: () => R(),
|
|
157
165
|
type: "button",
|
|
158
166
|
className: a(e.toolbarItem, { [e.active]: b === "quote" }),
|
|
159
167
|
"aria-label": s.formatMessage({
|
|
@@ -174,8 +182,8 @@ const ue = (l) => {
|
|
|
174
182
|
/* @__PURE__ */ o(
|
|
175
183
|
"button",
|
|
176
184
|
{
|
|
177
|
-
onMouseDown:
|
|
178
|
-
onClick: () =>
|
|
185
|
+
onMouseDown: d,
|
|
186
|
+
onClick: () => O(),
|
|
179
187
|
type: "button",
|
|
180
188
|
className: a(e.toolbarItem, { [e.active]: b === "ol" }),
|
|
181
189
|
"aria-label": s.formatMessage({
|
|
@@ -193,10 +201,10 @@ const ue = (l) => {
|
|
|
193
201
|
)
|
|
194
202
|
}
|
|
195
203
|
),
|
|
196
|
-
!
|
|
204
|
+
!i.hideSourceAction && /* @__PURE__ */ o(
|
|
197
205
|
"button",
|
|
198
206
|
{
|
|
199
|
-
onClick:
|
|
207
|
+
onClick: i.onAddSource,
|
|
200
208
|
type: "button",
|
|
201
209
|
className: e.toolbarItem,
|
|
202
210
|
"aria-label": s.formatMessage({
|
|
@@ -217,12 +225,12 @@ const ue = (l) => {
|
|
|
217
225
|
]
|
|
218
226
|
}
|
|
219
227
|
) : null,
|
|
220
|
-
/* @__PURE__ */ o("div", { className: e.actionButton, children:
|
|
221
|
-
|
|
228
|
+
/* @__PURE__ */ o("div", { className: e.actionButton, children: i.hideSubmit ? null : /* @__PURE__ */ o(
|
|
229
|
+
Y,
|
|
222
230
|
{
|
|
223
231
|
type: "button",
|
|
224
232
|
"data-testid": "submit-button",
|
|
225
|
-
handleClick:
|
|
233
|
+
handleClick: i.onSubmit,
|
|
226
234
|
className: a(e.inputSubmitActionButton, e.submitAction),
|
|
227
235
|
"aria-label": s.formatMessage({
|
|
228
236
|
id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
|
|
@@ -236,5 +244,5 @@ const ue = (l) => {
|
|
|
236
244
|
);
|
|
237
245
|
};
|
|
238
246
|
export {
|
|
239
|
-
|
|
247
|
+
ge as ToolbarPlugin
|
|
240
248
|
};
|