@logora/debate 0.4.23 → 0.4.25
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/assets/components/input/text_editor/plugins/ToolbarPlugin.module-CjkE3oe-.css +1 -0
- package/dist/components/input/text_editor/plugins/ToolbarPlugin.js +95 -89
- package/dist/components/input/text_editor/plugins/ToolbarPlugin.module.scss.js +16 -16
- package/package.json +1 -1
- package/dist/assets/components/input/text_editor/plugins/ToolbarPlugin.module-C3yG2biv.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._toolbar_13b6u_3{display:flex!important;justify-content:space-between!important;flex-wrap:wrap;background:var(--background-color-primary, white);padding-top:var(--spacer-md, calc(var(--space-unit, 1em) * .75))!important;vertical-align:middle;align-items:flex-start;gap:var(--space-unit, 1em)}._toolbar_13b6u_3._toolbarIsActive_13b6u_13{border-top:1px solid var(--text-tertiary, #fafafa)}._iconToolbar_13b6u_17{display:flex!important;gap:var(--spacer-lg, calc(var(--space-unit, 1em) * 1.5))}._iconToolbar_13b6u_17._shortBar_13b6u_21{gap:var(--spacer-md, calc(var(--space-unit, 1em) * .75))}._toolbarItem_13b6u_25{border:0;background:none;padding:0!important;cursor:pointer;vertical-align:middle;touch-action:manipulation;display:flex;align-items:center;justify-content:center}@media(max-width:576px){._toolbarItem_13b6u_25{min-width:44px;min-height:44px}}._toolbarItem_13b6u_25._disabled_13b6u_42{cursor:not-allowed}._toolbarItem_13b6u_25._active_13b6u_45{background-color:#bababa66;border-radius:50%}._toolbarItem_13b6u_25 ._format_13b6u_49{background-size:contain;display:inline-block;vertical-align:-.25em;display:flex!important}._actionButton_13b6u_56{display:flex!important;gap:var(--space-unit, 1em);margin-left:auto}._inputSubmitActionButton_13b6u_62{width:100%;height:35px;display:flex!important;justify-content:center!important;align-items:center!important;background-color:var(--call-primary-color, #434343)!important}._inputSubmitActionButton_13b6u_62._submitAction_13b6u_70 svg{fill:var(--text-light, white)!important}._inputSubmitActionButton_13b6u_62 ._inputSourceText_13b6u_73{display:none!important;margin-left:var(--spacer-sm, calc(var(--space-unit, 1em) * .5))!important;font-size:var(--font-size-small, 16px)}@container (min-width: 576px){._inputSubmitActionButton_13b6u_62 ._inputSourceText_13b6u_73{display:block!important}}._tooltip_13b6u_84{width:230px!important;margin-left:-117px!important}
|
|
@@ -1,129 +1,130 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { $isListNode as
|
|
1
|
+
import { jsxs as w, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { $isListNode as A, ListNode as z, INSERT_ORDERED_LIST_COMMAND as G, $isListItemNode as E, $createListNode as X } from "@lexical/list";
|
|
3
3
|
import { useLexicalComposerContext as J } from "@lexical/react/LexicalComposerContext";
|
|
4
|
-
import { $isHeadingNode as W, $createQuoteNode as
|
|
5
|
-
import { $setBlocksType as
|
|
4
|
+
import { $isHeadingNode as W, $createQuoteNode as D } from "@lexical/rich-text";
|
|
5
|
+
import { $setBlocksType as O } from "@lexical/selection";
|
|
6
6
|
import { $getNearestNodeOfType as Y, mergeRegister as Z } from "@lexical/utils";
|
|
7
7
|
import a from "classnames";
|
|
8
|
-
import { $getSelection as N, $isRangeSelection as
|
|
8
|
+
import { $getSelection as N, $isRangeSelection as T, SELECTION_CHANGE_COMMAND as ee, FORMAT_TEXT_COMMAND as te, $createParagraphNode as B } from "lexical";
|
|
9
9
|
import { useRef as oe, useState as g, useCallback as ie, useEffect as ae } from "react";
|
|
10
10
|
import { useIntl as ne } from "react-intl";
|
|
11
11
|
import e from "./ToolbarPlugin.module.scss.js";
|
|
12
|
-
import { Icon as
|
|
12
|
+
import { Icon as b } from "../../../icons/icon/Icon.js";
|
|
13
13
|
import { Button as le } from "../../../action/button/Button.js";
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const _e = (s) => {
|
|
15
|
+
const d = ne(), R = 1, [r] = J(), $ = oe(null), [h, I] = g("paragraph"), [se, q] = g(null), [K, x] = g(!1), [P, C] = g(!1), [F, L] = g(!1), k = s.hideSubmit && s.hideSourceAction && s.disableRichText, p = ie(() => {
|
|
16
16
|
const t = N();
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
21
|
-
const o = Y(
|
|
17
|
+
if (T(t)) {
|
|
18
|
+
const n = t.anchor.getNode(), c = n.getKey() === "root" ? n : n.getTopLevelElementOrThrow(), u = c.getKey();
|
|
19
|
+
if (r.getElementByKey(u) !== null)
|
|
20
|
+
if (q(u), A(c)) {
|
|
21
|
+
const o = Y(n, z), f = o ? o.getTag() : c.getTag();
|
|
22
22
|
I(f);
|
|
23
23
|
} else {
|
|
24
|
-
const o = W(
|
|
24
|
+
const o = W(c) ? c.getTag() : c.getType();
|
|
25
25
|
I(o);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
x(t.hasFormat("bold")), C(t.hasFormat("italic")), L(t.hasFormat("underline"));
|
|
28
28
|
}
|
|
29
|
-
}, [
|
|
29
|
+
}, [r]);
|
|
30
30
|
ae(() => Z(
|
|
31
|
-
|
|
31
|
+
r.registerUpdateListener(({ editorState: t }) => {
|
|
32
32
|
t.read(() => {
|
|
33
33
|
p();
|
|
34
34
|
});
|
|
35
35
|
}),
|
|
36
|
-
|
|
36
|
+
r.registerCommand(
|
|
37
37
|
ee,
|
|
38
38
|
() => (p(), !1),
|
|
39
|
-
|
|
39
|
+
R
|
|
40
40
|
)
|
|
41
|
-
), [
|
|
42
|
-
const
|
|
43
|
-
t.
|
|
44
|
-
},
|
|
41
|
+
), [r, p]);
|
|
42
|
+
const l = (t) => {
|
|
43
|
+
t.preventDefault();
|
|
44
|
+
}, M = () => {
|
|
45
45
|
setTimeout(() => {
|
|
46
|
-
|
|
46
|
+
r.getEditorState().read(() => {
|
|
47
47
|
p();
|
|
48
48
|
});
|
|
49
49
|
}, 0);
|
|
50
|
-
},
|
|
51
|
-
|
|
50
|
+
}, _ = (t) => {
|
|
51
|
+
r.dispatchCommand(te, t), t === "bold" && x((n) => !n), t === "italic" && C((n) => !n), t === "underline" && L((n) => !n), M();
|
|
52
52
|
}, U = () => {
|
|
53
|
-
|
|
53
|
+
r.update(() => {
|
|
54
54
|
const t = N();
|
|
55
|
-
if (!
|
|
55
|
+
if (!T(t))
|
|
56
56
|
return;
|
|
57
|
-
const
|
|
58
|
-
for (const m of
|
|
57
|
+
const n = t.getNodes(), c = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const m of n) {
|
|
59
59
|
let o = m;
|
|
60
|
-
for (; o !== null && !
|
|
60
|
+
for (; o !== null && !E(o); )
|
|
61
61
|
o = o.getParent();
|
|
62
|
-
|
|
62
|
+
E(o) && c.add(o);
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
for (const m of
|
|
64
|
+
const u = Array.from(c).reverse();
|
|
65
|
+
for (const m of u) {
|
|
66
66
|
const o = m.getParent();
|
|
67
|
-
if (!
|
|
67
|
+
if (!A(o))
|
|
68
68
|
continue;
|
|
69
|
-
const f =
|
|
70
|
-
for (const
|
|
71
|
-
f.append(
|
|
72
|
-
const
|
|
73
|
-
if (o.insertAfter(f),
|
|
74
|
-
const
|
|
75
|
-
for (const V of
|
|
76
|
-
|
|
77
|
-
f.insertAfter(
|
|
69
|
+
const f = B(), Q = m.getChildren();
|
|
70
|
+
for (const y of Q)
|
|
71
|
+
f.append(y);
|
|
72
|
+
const S = m.getNextSiblings();
|
|
73
|
+
if (o.insertAfter(f), S.length > 0) {
|
|
74
|
+
const y = S[0].getValue(), v = X(o.getListType(), y);
|
|
75
|
+
for (const V of S)
|
|
76
|
+
v.append(V);
|
|
77
|
+
f.insertAfter(v);
|
|
78
78
|
}
|
|
79
79
|
m.remove(), o.getChildrenSize() === 0 && o.remove();
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
}, j = () => {
|
|
83
|
-
h !== "ol" ?
|
|
83
|
+
h !== "ol" ? r.dispatchCommand(G) : U(), M();
|
|
84
84
|
}, H = () => {
|
|
85
|
-
h !== "quote" ?
|
|
85
|
+
h !== "quote" ? r.update(() => {
|
|
86
86
|
const t = N();
|
|
87
|
-
if (
|
|
87
|
+
if (T(t))
|
|
88
88
|
if (t.isCollapsed()) {
|
|
89
|
-
const
|
|
90
|
-
|
|
89
|
+
const c = t.anchor.getNode().getTopLevelElementOrThrow(), u = D();
|
|
90
|
+
c.insertAfter(u), u.selectEnd();
|
|
91
91
|
} else
|
|
92
|
-
|
|
93
|
-
}) :
|
|
92
|
+
O(t, () => D());
|
|
93
|
+
}) : r.update(() => {
|
|
94
94
|
const t = N();
|
|
95
|
-
|
|
96
|
-
}),
|
|
95
|
+
T(t) && O(t, () => B());
|
|
96
|
+
}), M();
|
|
97
97
|
};
|
|
98
|
-
return
|
|
98
|
+
return k ? null : /* @__PURE__ */ w(
|
|
99
99
|
"div",
|
|
100
100
|
{
|
|
101
101
|
className: a(e.toolbar, {
|
|
102
|
-
[e.toolbarIsActive]:
|
|
102
|
+
[e.toolbarIsActive]: k ? !1 : s.isActive
|
|
103
103
|
}),
|
|
104
|
-
ref:
|
|
104
|
+
ref: $,
|
|
105
105
|
children: [
|
|
106
|
-
|
|
106
|
+
s.isActive ? !s.disableRichText && /* @__PURE__ */ w(
|
|
107
107
|
"div",
|
|
108
108
|
{
|
|
109
109
|
className: a(e.iconToolbar, {
|
|
110
|
-
[e.shortBar]:
|
|
110
|
+
[e.shortBar]: s.shortBar
|
|
111
111
|
}),
|
|
112
112
|
children: [
|
|
113
113
|
/* @__PURE__ */ i(
|
|
114
114
|
"button",
|
|
115
115
|
{
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
onTouchStart: l,
|
|
117
|
+
onMouseDown: l,
|
|
118
|
+
onClick: () => _("bold"),
|
|
118
119
|
type: "button",
|
|
119
|
-
className: a(e.toolbarItem, { [e.active]:
|
|
120
|
+
className: a(e.toolbarItem, { [e.active]: K }),
|
|
120
121
|
"data-testid": "format-bold",
|
|
121
|
-
"aria-label":
|
|
122
|
+
"aria-label": d.formatMessage({
|
|
122
123
|
id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
|
|
123
124
|
defaultMessage: "Make text bold"
|
|
124
125
|
}),
|
|
125
126
|
children: /* @__PURE__ */ i(
|
|
126
|
-
|
|
127
|
+
b,
|
|
127
128
|
{
|
|
128
129
|
name: "bold",
|
|
129
130
|
width: 24,
|
|
@@ -136,18 +137,19 @@ const ye = (n) => {
|
|
|
136
137
|
/* @__PURE__ */ i(
|
|
137
138
|
"button",
|
|
138
139
|
{
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
onTouchStart: l,
|
|
141
|
+
onMouseDown: l,
|
|
142
|
+
onClick: () => _("italic"),
|
|
141
143
|
type: "button",
|
|
142
144
|
className: a(e.toolbarItem, {
|
|
143
|
-
[e.active]:
|
|
145
|
+
[e.active]: P
|
|
144
146
|
}),
|
|
145
|
-
"aria-label":
|
|
147
|
+
"aria-label": d.formatMessage({
|
|
146
148
|
id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
|
|
147
149
|
defaultMessage: "Make text italic"
|
|
148
150
|
}),
|
|
149
151
|
children: /* @__PURE__ */ i(
|
|
150
|
-
|
|
152
|
+
b,
|
|
151
153
|
{
|
|
152
154
|
name: "italic",
|
|
153
155
|
width: 24,
|
|
@@ -160,18 +162,19 @@ const ye = (n) => {
|
|
|
160
162
|
/* @__PURE__ */ i(
|
|
161
163
|
"button",
|
|
162
164
|
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
onTouchStart: l,
|
|
166
|
+
onMouseDown: l,
|
|
167
|
+
onClick: () => _("underline"),
|
|
165
168
|
type: "button",
|
|
166
169
|
className: a(e.toolbarItem, {
|
|
167
|
-
[e.active]:
|
|
170
|
+
[e.active]: F
|
|
168
171
|
}),
|
|
169
|
-
"aria-label":
|
|
172
|
+
"aria-label": d.formatMessage({
|
|
170
173
|
id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
|
|
171
174
|
defaultMessage: "Underline text"
|
|
172
175
|
}),
|
|
173
176
|
children: /* @__PURE__ */ i(
|
|
174
|
-
|
|
177
|
+
b,
|
|
175
178
|
{
|
|
176
179
|
name: "underline",
|
|
177
180
|
width: 24,
|
|
@@ -184,18 +187,19 @@ const ye = (n) => {
|
|
|
184
187
|
/* @__PURE__ */ i(
|
|
185
188
|
"button",
|
|
186
189
|
{
|
|
187
|
-
|
|
190
|
+
onTouchStart: l,
|
|
191
|
+
onMouseDown: l,
|
|
188
192
|
onClick: () => H(),
|
|
189
193
|
type: "button",
|
|
190
194
|
className: a(e.toolbarItem, {
|
|
191
195
|
[e.active]: h === "quote"
|
|
192
196
|
}),
|
|
193
|
-
"aria-label":
|
|
197
|
+
"aria-label": d.formatMessage({
|
|
194
198
|
id: "input.text_editor.plugins.toolbar_plugin.blockquote.aria_label",
|
|
195
199
|
defaultMessage: "Add a blockquote"
|
|
196
200
|
}),
|
|
197
201
|
children: /* @__PURE__ */ i(
|
|
198
|
-
|
|
202
|
+
b,
|
|
199
203
|
{
|
|
200
204
|
name: "blockquote",
|
|
201
205
|
width: 24,
|
|
@@ -208,18 +212,19 @@ const ye = (n) => {
|
|
|
208
212
|
/* @__PURE__ */ i(
|
|
209
213
|
"button",
|
|
210
214
|
{
|
|
211
|
-
|
|
215
|
+
onTouchStart: l,
|
|
216
|
+
onMouseDown: l,
|
|
212
217
|
onClick: () => j(),
|
|
213
218
|
type: "button",
|
|
214
219
|
className: a(e.toolbarItem, {
|
|
215
220
|
[e.active]: h === "ol"
|
|
216
221
|
}),
|
|
217
|
-
"aria-label":
|
|
222
|
+
"aria-label": d.formatMessage({
|
|
218
223
|
id: "input.text_editor.plugins.toolbar_plugin.numbered_list.aria_label",
|
|
219
224
|
defaultMessage: "Insert a numbered list"
|
|
220
225
|
}),
|
|
221
226
|
children: /* @__PURE__ */ i(
|
|
222
|
-
|
|
227
|
+
b,
|
|
223
228
|
{
|
|
224
229
|
name: "orderedList",
|
|
225
230
|
width: 24,
|
|
@@ -229,19 +234,20 @@ const ye = (n) => {
|
|
|
229
234
|
)
|
|
230
235
|
}
|
|
231
236
|
),
|
|
232
|
-
!
|
|
237
|
+
!s.hideSourceAction && /* @__PURE__ */ i(
|
|
233
238
|
"button",
|
|
234
239
|
{
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
onTouchStart: l,
|
|
241
|
+
onMouseDown: l,
|
|
242
|
+
onClick: s.onAddSource,
|
|
237
243
|
type: "button",
|
|
238
244
|
className: e.toolbarItem,
|
|
239
|
-
"aria-label":
|
|
245
|
+
"aria-label": d.formatMessage({
|
|
240
246
|
id: "input.text_editor.plugins.toolbar_plugin.add_link.aria_label",
|
|
241
247
|
defaultMessage: "Add hyperlink"
|
|
242
248
|
}),
|
|
243
249
|
children: /* @__PURE__ */ i(
|
|
244
|
-
|
|
250
|
+
b,
|
|
245
251
|
{
|
|
246
252
|
name: "link",
|
|
247
253
|
width: 20,
|
|
@@ -254,18 +260,18 @@ const ye = (n) => {
|
|
|
254
260
|
]
|
|
255
261
|
}
|
|
256
262
|
) : null,
|
|
257
|
-
/* @__PURE__ */ i("div", { className: e.actionButton, children:
|
|
263
|
+
/* @__PURE__ */ i("div", { className: e.actionButton, children: s.hideSubmit ? null : /* @__PURE__ */ i(
|
|
258
264
|
le,
|
|
259
265
|
{
|
|
260
266
|
type: "button",
|
|
261
267
|
"data-testid": "submit-button",
|
|
262
|
-
handleClick:
|
|
268
|
+
handleClick: s.onSubmit,
|
|
263
269
|
className: a(e.inputSubmitActionButton, e.submitAction),
|
|
264
|
-
"aria-label":
|
|
270
|
+
"aria-label": d.formatMessage({
|
|
265
271
|
id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
|
|
266
272
|
defaultMessage: "Send message"
|
|
267
273
|
}),
|
|
268
|
-
children: /* @__PURE__ */ i(
|
|
274
|
+
children: /* @__PURE__ */ i(b, { name: "send", width: 20, height: 20 })
|
|
269
275
|
}
|
|
270
276
|
) })
|
|
271
277
|
]
|
|
@@ -273,5 +279,5 @@ const ye = (n) => {
|
|
|
273
279
|
);
|
|
274
280
|
};
|
|
275
281
|
export {
|
|
276
|
-
|
|
282
|
+
_e as ToolbarPlugin
|
|
277
283
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import '../../../../assets/components/input/text_editor/plugins/ToolbarPlugin.module-
|
|
1
|
+
import '../../../../assets/components/input/text_editor/plugins/ToolbarPlugin.module-CjkE3oe-.css';const t = "_toolbar_13b6u_3", o = "_toolbarIsActive_13b6u_13", n = "_iconToolbar_13b6u_17", _ = "_shortBar_13b6u_21", c = "_toolbarItem_13b6u_25", b = "_active_13b6u_45", i = "_format_13b6u_49", a = "_actionButton_13b6u_56", u = "_inputSubmitActionButton_13b6u_62", s = "_submitAction_13b6u_70", r = {
|
|
2
2
|
toolbar: t,
|
|
3
3
|
toolbarIsActive: o,
|
|
4
|
-
iconToolbar:
|
|
5
|
-
shortBar:
|
|
6
|
-
toolbarItem:
|
|
7
|
-
active:
|
|
4
|
+
iconToolbar: n,
|
|
5
|
+
shortBar: _,
|
|
6
|
+
toolbarItem: c,
|
|
7
|
+
active: b,
|
|
8
8
|
format: i,
|
|
9
|
-
actionButton:
|
|
10
|
-
inputSubmitActionButton:
|
|
11
|
-
submitAction:
|
|
9
|
+
actionButton: a,
|
|
10
|
+
inputSubmitActionButton: u,
|
|
11
|
+
submitAction: s
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
a as actionButton,
|
|
15
|
+
b as active,
|
|
16
|
+
r as default,
|
|
17
17
|
i as format,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
n as iconToolbar,
|
|
19
|
+
u as inputSubmitActionButton,
|
|
20
|
+
_ as shortBar,
|
|
21
|
+
s as submitAction,
|
|
22
22
|
t as toolbar,
|
|
23
23
|
o as toolbarIsActive,
|
|
24
|
-
|
|
24
|
+
c as toolbarItem
|
|
25
25
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._toolbar_awaxp_3{display:flex!important;justify-content:space-between!important;flex-wrap:wrap;background:var(--background-color-primary, white);padding-top:var(--spacer-md, calc(var(--space-unit, 1em) * .75))!important;vertical-align:middle;align-items:flex-start;gap:var(--space-unit, 1em)}._toolbar_awaxp_3._toolbarIsActive_awaxp_13{border-top:1px solid var(--text-tertiary, #fafafa)}._iconToolbar_awaxp_17{display:flex!important;gap:var(--spacer-lg, calc(var(--space-unit, 1em) * 1.5))}._iconToolbar_awaxp_17._shortBar_awaxp_21{gap:var(--spacer-md, calc(var(--space-unit, 1em) * .75))}._toolbarItem_awaxp_25{border:0;background:none;padding:0!important;cursor:pointer;vertical-align:middle;touch-action:manipulation;display:flex;align-items:center;justify-content:center}@container (max-width: 575.98px){._toolbarItem_awaxp_25{min-width:44px;min-height:44px}}._toolbarItem_awaxp_25._disabled_awaxp_42{cursor:not-allowed}._toolbarItem_awaxp_25._active_awaxp_45{background-color:#bababa66;border-radius:50%}._toolbarItem_awaxp_25 ._format_awaxp_49{background-size:contain;display:inline-block;vertical-align:-.25em;display:flex!important}._actionButton_awaxp_56{display:flex!important;gap:var(--space-unit, 1em);margin-left:auto}._inputSubmitActionButton_awaxp_62{width:100%;height:35px;display:flex!important;justify-content:center!important;align-items:center!important;background-color:var(--call-primary-color, #434343)!important}._inputSubmitActionButton_awaxp_62._submitAction_awaxp_70 svg{fill:var(--text-light, white)!important}._inputSubmitActionButton_awaxp_62 ._inputSourceText_awaxp_73{display:none!important;margin-left:var(--spacer-sm, calc(var(--space-unit, 1em) * .5))!important;font-size:var(--font-size-small, 16px)}@container (min-width: 576px){._inputSubmitActionButton_awaxp_62 ._inputSourceText_awaxp_73{display:block!important}}._tooltip_awaxp_84{width:230px!important;margin-left:-117px!important}
|