@logora/debate 0.4.49 → 0.4.50
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,52 +1,50 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { $isListNode as
|
|
3
|
-
import { useLexicalComposerContext as
|
|
4
|
-
import { $isHeadingNode as
|
|
5
|
-
import { $setBlocksType as
|
|
6
|
-
import { $getNearestNodeOfType as
|
|
1
|
+
import { jsxs as E, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { $isListNode as P, ListNode as Y, INSERT_ORDERED_LIST_COMMAND as Z, $isListItemNode as O, $createListNode as ee } from "@lexical/list";
|
|
3
|
+
import { useLexicalComposerContext as te } from "@lexical/react/LexicalComposerContext";
|
|
4
|
+
import { $isHeadingNode as oe, $createQuoteNode as R } from "@lexical/rich-text";
|
|
5
|
+
import { $setBlocksType as B } from "@lexical/selection";
|
|
6
|
+
import { $getNearestNodeOfType as ne, mergeRegister as ie } from "@lexical/utils";
|
|
7
7
|
import i from "classnames";
|
|
8
|
-
import { $getSelection as M, $isRangeSelection as I, SELECTION_CHANGE_COMMAND as
|
|
9
|
-
import { useRef as
|
|
10
|
-
import { useIntl as
|
|
8
|
+
import { $getSelection as M, $isRangeSelection as I, SELECTION_CHANGE_COMMAND as ae, FORMAT_TEXT_COMMAND as le, $createParagraphNode as $ } from "lexical";
|
|
9
|
+
import { useRef as x, useState as N, useCallback as re, useEffect as q } from "react";
|
|
10
|
+
import { useIntl as se } from "react-intl";
|
|
11
11
|
import t from "./ToolbarPlugin.module.scss.js";
|
|
12
12
|
import { Icon as f } from "../../../icons/icon/Icon.js";
|
|
13
|
-
import { Button as
|
|
14
|
-
const
|
|
15
|
-
const d =
|
|
13
|
+
import { Button as ce } from "../../../action/button/Button.js";
|
|
14
|
+
const we = (a) => {
|
|
15
|
+
const d = se(), K = 1, [l] = te(), F = x(null), [T, S] = N("paragraph"), [de, U] = N(null), [j, H] = N(!1), [Q, V] = N(!1), [z, G] = N(!1), L = a.hideSubmit && a.hideSourceAction && a.disableRichText, _ = re(() => {
|
|
16
16
|
const e = M();
|
|
17
17
|
if (I(e)) {
|
|
18
18
|
const c = e.anchor.getNode(), r = c.getKey() === "root" ? c : c.getTopLevelElementOrThrow(), u = r.getKey();
|
|
19
19
|
if (l.getElementByKey(u) !== null)
|
|
20
|
-
if (
|
|
21
|
-
const o =
|
|
22
|
-
|
|
20
|
+
if (U(u), P(r)) {
|
|
21
|
+
const o = ne(c, Y), p = o ? o.getTag() : r.getTag();
|
|
22
|
+
S(p);
|
|
23
23
|
} else {
|
|
24
|
-
const o =
|
|
25
|
-
|
|
24
|
+
const o = oe(r) ? r.getTag() : r.getType();
|
|
25
|
+
S(o);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
H(e.hasFormat("bold")), V(e.hasFormat("italic")), G(e.hasFormat("underline"));
|
|
28
28
|
}
|
|
29
29
|
}, [l]);
|
|
30
|
-
|
|
30
|
+
q(() => ie(
|
|
31
31
|
l.registerUpdateListener(({ editorState: e }) => {
|
|
32
32
|
e.read(() => {
|
|
33
33
|
_();
|
|
34
34
|
});
|
|
35
35
|
}),
|
|
36
36
|
l.registerCommand(
|
|
37
|
-
|
|
37
|
+
ae,
|
|
38
38
|
() => (_(), !1),
|
|
39
|
-
|
|
39
|
+
K
|
|
40
40
|
)
|
|
41
41
|
), [l, _]);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
}, y = k(!1), s = k(null);
|
|
45
|
-
K(() => () => {
|
|
42
|
+
const y = x(!1), s = x(null);
|
|
43
|
+
q(() => () => {
|
|
46
44
|
s.current && clearTimeout(s.current);
|
|
47
45
|
}, []);
|
|
48
46
|
const g = (e, c) => {
|
|
49
|
-
|
|
47
|
+
e.preventDefault(), (e.pointerType === "touch" || e.pointerType === "pen") && (y.current = !0, c(), s.current && clearTimeout(s.current), s.current = setTimeout(() => {
|
|
50
48
|
y.current = !1, s.current = null;
|
|
51
49
|
}, 500));
|
|
52
50
|
}, h = (e) => {
|
|
@@ -62,8 +60,8 @@ const Ce = (a) => {
|
|
|
62
60
|
});
|
|
63
61
|
}, 0);
|
|
64
62
|
}, b = (e) => {
|
|
65
|
-
l.dispatchCommand(
|
|
66
|
-
},
|
|
63
|
+
l.dispatchCommand(le, e), w();
|
|
64
|
+
}, X = () => {
|
|
67
65
|
l.update(() => {
|
|
68
66
|
const e = M();
|
|
69
67
|
if (!I(e))
|
|
@@ -71,53 +69,53 @@ const Ce = (a) => {
|
|
|
71
69
|
const c = e.getNodes(), r = /* @__PURE__ */ new Set();
|
|
72
70
|
for (const m of c) {
|
|
73
71
|
let o = m;
|
|
74
|
-
for (; o !== null && !
|
|
72
|
+
for (; o !== null && !O(o); )
|
|
75
73
|
o = o.getParent();
|
|
76
|
-
|
|
74
|
+
O(o) && r.add(o);
|
|
77
75
|
}
|
|
78
76
|
const u = Array.from(r).reverse();
|
|
79
77
|
for (const m of u) {
|
|
80
78
|
const o = m.getParent();
|
|
81
|
-
if (!
|
|
79
|
+
if (!P(o))
|
|
82
80
|
continue;
|
|
83
|
-
const p =
|
|
84
|
-
for (const
|
|
85
|
-
p.append(
|
|
81
|
+
const p = $(), J = m.getChildren();
|
|
82
|
+
for (const k of J)
|
|
83
|
+
p.append(k);
|
|
86
84
|
const C = m.getNextSiblings();
|
|
87
85
|
if (o.insertAfter(p), C.length > 0) {
|
|
88
|
-
const
|
|
89
|
-
for (const
|
|
90
|
-
|
|
91
|
-
p.insertAfter(
|
|
86
|
+
const k = C[0].getValue(), v = ee(o.getListType(), k);
|
|
87
|
+
for (const W of C)
|
|
88
|
+
v.append(W);
|
|
89
|
+
p.insertAfter(v);
|
|
92
90
|
}
|
|
93
91
|
m.remove(), o.getChildrenSize() === 0 && o.remove();
|
|
94
92
|
}
|
|
95
93
|
});
|
|
94
|
+
}, A = () => {
|
|
95
|
+
T !== "ol" ? l.dispatchCommand(Z) : X(), w();
|
|
96
96
|
}, D = () => {
|
|
97
|
-
T !== "ol" ? l.dispatchCommand(ee) : J(), w();
|
|
98
|
-
}, v = () => {
|
|
99
97
|
T !== "quote" ? l.update(() => {
|
|
100
98
|
const e = M();
|
|
101
99
|
if (I(e))
|
|
102
100
|
if (e.isCollapsed()) {
|
|
103
|
-
const r = e.anchor.getNode().getTopLevelElementOrThrow(), u =
|
|
101
|
+
const r = e.anchor.getNode().getTopLevelElementOrThrow(), u = R();
|
|
104
102
|
r.insertAfter(u), u.selectEnd();
|
|
105
103
|
} else
|
|
106
|
-
|
|
104
|
+
B(e, () => R());
|
|
107
105
|
}) : l.update(() => {
|
|
108
106
|
const e = M();
|
|
109
|
-
I(e) &&
|
|
107
|
+
I(e) && B(e, () => $());
|
|
110
108
|
}), w();
|
|
111
109
|
};
|
|
112
|
-
return L ? null : /* @__PURE__ */
|
|
110
|
+
return L ? null : /* @__PURE__ */ E(
|
|
113
111
|
"div",
|
|
114
112
|
{
|
|
115
113
|
className: i(t.toolbar, {
|
|
116
114
|
[t.toolbarIsActive]: L ? !1 : a.isActive
|
|
117
115
|
}),
|
|
118
|
-
ref:
|
|
116
|
+
ref: F,
|
|
119
117
|
children: [
|
|
120
|
-
a.isActive ? !a.disableRichText && /* @__PURE__ */
|
|
118
|
+
a.isActive ? !a.disableRichText && /* @__PURE__ */ E(
|
|
121
119
|
"div",
|
|
122
120
|
{
|
|
123
121
|
className: i(t.iconToolbar, {
|
|
@@ -130,7 +128,7 @@ const Ce = (a) => {
|
|
|
130
128
|
onPointerDown: (e) => g(e, () => b("bold")),
|
|
131
129
|
onClick: () => h(() => b("bold")),
|
|
132
130
|
type: "button",
|
|
133
|
-
className: i(t.toolbarItem, { [t.active]:
|
|
131
|
+
className: i(t.toolbarItem, { [t.active]: j }),
|
|
134
132
|
"data-testid": "format-bold",
|
|
135
133
|
"aria-label": d.formatMessage({
|
|
136
134
|
id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
|
|
@@ -154,7 +152,7 @@ const Ce = (a) => {
|
|
|
154
152
|
onClick: () => h(() => b("italic")),
|
|
155
153
|
type: "button",
|
|
156
154
|
className: i(t.toolbarItem, {
|
|
157
|
-
[t.active]:
|
|
155
|
+
[t.active]: Q
|
|
158
156
|
}),
|
|
159
157
|
"aria-label": d.formatMessage({
|
|
160
158
|
id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
|
|
@@ -178,7 +176,7 @@ const Ce = (a) => {
|
|
|
178
176
|
onClick: () => h(() => b("underline")),
|
|
179
177
|
type: "button",
|
|
180
178
|
className: i(t.toolbarItem, {
|
|
181
|
-
[t.active]:
|
|
179
|
+
[t.active]: z
|
|
182
180
|
}),
|
|
183
181
|
"aria-label": d.formatMessage({
|
|
184
182
|
id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
|
|
@@ -198,8 +196,8 @@ const Ce = (a) => {
|
|
|
198
196
|
/* @__PURE__ */ n(
|
|
199
197
|
"button",
|
|
200
198
|
{
|
|
201
|
-
onPointerDown: (e) => g(e, () =>
|
|
202
|
-
onClick: () => h(() =>
|
|
199
|
+
onPointerDown: (e) => g(e, () => D()),
|
|
200
|
+
onClick: () => h(() => D()),
|
|
203
201
|
type: "button",
|
|
204
202
|
className: i(t.toolbarItem, {
|
|
205
203
|
[t.active]: T === "quote"
|
|
@@ -222,8 +220,8 @@ const Ce = (a) => {
|
|
|
222
220
|
/* @__PURE__ */ n(
|
|
223
221
|
"button",
|
|
224
222
|
{
|
|
225
|
-
onPointerDown: (e) => g(e, () =>
|
|
226
|
-
onClick: () => h(() =>
|
|
223
|
+
onPointerDown: (e) => g(e, () => A()),
|
|
224
|
+
onClick: () => h(() => A()),
|
|
227
225
|
type: "button",
|
|
228
226
|
className: i(t.toolbarItem, {
|
|
229
227
|
[t.active]: T === "ol"
|
|
@@ -246,7 +244,7 @@ const Ce = (a) => {
|
|
|
246
244
|
!a.hideSourceAction && /* @__PURE__ */ n(
|
|
247
245
|
"button",
|
|
248
246
|
{
|
|
249
|
-
onPointerDown:
|
|
247
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
250
248
|
onClick: a.onAddSource,
|
|
251
249
|
type: "button",
|
|
252
250
|
className: t.toolbarItem,
|
|
@@ -269,7 +267,7 @@ const Ce = (a) => {
|
|
|
269
267
|
}
|
|
270
268
|
) : null,
|
|
271
269
|
/* @__PURE__ */ n("div", { className: t.actionButton, children: a.hideSubmit ? null : /* @__PURE__ */ n(
|
|
272
|
-
|
|
270
|
+
ce,
|
|
273
271
|
{
|
|
274
272
|
type: "button",
|
|
275
273
|
"data-testid": "submit-button",
|
|
@@ -287,5 +285,5 @@ const Ce = (a) => {
|
|
|
287
285
|
);
|
|
288
286
|
};
|
|
289
287
|
export {
|
|
290
|
-
|
|
288
|
+
we as ToolbarPlugin
|
|
291
289
|
};
|