@logora/debate 0.4.19 → 0.4.20

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,100 +1,99 @@
1
- import { jsxs as k, jsx as o } from "react/jsx-runtime";
1
+ import { jsxs as x, 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 x } from "@lexical/rich-text";
5
- import { $setBlocksType as I } from "@lexical/selection";
4
+ import { $isHeadingNode as P, $createQuoteNode as I } from "@lexical/rich-text";
5
+ import { $setBlocksType as E } from "@lexical/selection";
6
6
  import { $getNearestNodeOfType as j, mergeRegister as H } from "@lexical/utils";
7
7
  import a from "classnames";
8
8
  import { $getSelection as p, $isRangeSelection as N, SELECTION_CHANGE_COMMAND as Q, FORMAT_TEXT_COMMAND as G, $createParagraphNode as V } from "lexical";
9
- import { useRef as X, useState as m, useCallback as z, useEffect as J } from "react";
9
+ import { useRef as X, useState as u, 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 d } from "../../../icons/icon/Icon.js";
12
+ import { Icon as c } from "../../../icons/icon/Icon.js";
13
13
  import { Button as Y } from "../../../action/button/Button.js";
14
- const he = (l) => {
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(() => {
14
+ const ge = (i) => {
15
+ const r = W(), S = 1, [l] = U(), A = X(null), [b, M] = u("paragraph"), [Z, v] = u(null), [w, _] = u(!1), [D, T] = u(!1), [L, y] = u(!1), C = i.hideSubmit && i.hideSourceAction && i.disableRichText, g = z(() => {
16
16
  const t = p();
17
17
  if (N(t)) {
18
- const s = t.anchor.getNode(), r = s.getKey() === "root" ? s : s.getTopLevelElementOrThrow(), u = r.getKey();
19
- if (n.getElementByKey(u) !== null)
20
- if (v(u), $(r)) {
21
- const g = j(s, q), B = g ? g.getTag() : r.getTag();
18
+ const n = t.anchor.getNode(), s = n.getKey() === "root" ? n : n.getTopLevelElementOrThrow(), m = s.getKey();
19
+ if (l.getElementByKey(m) !== null)
20
+ if (v(m), $(s)) {
21
+ const f = j(n, q), B = f ? f.getTag() : s.getTag();
22
22
  M(B);
23
23
  } else {
24
- const g = P(r) ? r.getTag() : r.getType();
25
- M(g);
24
+ const f = P(s) ? s.getTag() : s.getType();
25
+ M(f);
26
26
  }
27
- T(t.hasFormat("bold")), _(t.hasFormat("italic")), y(t.hasFormat("underline"));
27
+ _(t.hasFormat("bold")), T(t.hasFormat("italic")), y(t.hasFormat("underline"));
28
28
  }
29
- }, [n]);
29
+ }, [l]);
30
30
  J(() => H(
31
- n.registerUpdateListener(({ editorState: t }) => {
31
+ l.registerUpdateListener(({ editorState: t }) => {
32
32
  t.read(() => {
33
- h();
33
+ g();
34
34
  });
35
35
  }),
36
- n.registerCommand(
36
+ l.registerCommand(
37
37
  Q,
38
- () => (h(), !1),
39
- E
38
+ () => (g(), !1),
39
+ S
40
40
  )
41
- ), [n, h]);
42
- const i = (t) => {
41
+ ), [l, g]);
42
+ const d = (t) => {
43
43
  t.preventDefault();
44
- }, C = () => {
44
+ }, k = () => {
45
45
  setTimeout(() => {
46
- n.getEditorState().read(() => {
47
- h();
46
+ l.getEditorState().read(() => {
47
+ g();
48
48
  });
49
49
  }, 0);
50
- }, f = (t) => {
51
- n.dispatchCommand(G, t), t === "bold" && T((s) => !s), t === "italic" && _((s) => !s), t === "underline" && y((s) => !s);
50
+ }, h = (t) => {
51
+ l.dispatchCommand(G, t), t === "bold" && _((n) => !n), t === "italic" && T((n) => !n), t === "underline" && y((n) => !n);
52
52
  }, O = () => {
53
- b !== "ol" ? n.dispatchCommand(K) : n.dispatchCommand(F), C();
53
+ b !== "ol" ? l.dispatchCommand(K) : l.dispatchCommand(F), k();
54
54
  }, R = () => {
55
- b !== "quote" ? n.update(() => {
55
+ b !== "quote" ? l.update(() => {
56
56
  const t = p();
57
57
  if (N(t))
58
58
  if (t.isCollapsed()) {
59
- const r = t.anchor.getNode().getTopLevelElementOrThrow(), u = x();
60
- r.insertAfter(u), u.selectEnd();
59
+ const s = t.anchor.getNode().getTopLevelElementOrThrow(), m = I();
60
+ s.insertAfter(m), m.selectEnd();
61
61
  } else
62
- I(t, () => x());
63
- }) : n.update(() => {
62
+ E(t, () => I());
63
+ }) : l.update(() => {
64
64
  const t = p();
65
- N(t) && I(t, () => V());
66
- }), C();
65
+ N(t) && E(t, () => V());
66
+ }), k();
67
67
  };
68
- return S ? null : /* @__PURE__ */ k(
68
+ return C ? null : /* @__PURE__ */ x(
69
69
  "div",
70
70
  {
71
71
  className: a(e.toolbar, {
72
- [e.toolbarIsActive]: S ? !1 : l.isActive
72
+ [e.toolbarIsActive]: C ? !1 : i.isActive
73
73
  }),
74
74
  ref: A,
75
75
  children: [
76
- l.isActive ? !l.disableRichText && /* @__PURE__ */ k(
76
+ i.isActive ? !i.disableRichText && /* @__PURE__ */ x(
77
77
  "div",
78
78
  {
79
79
  className: a(e.iconToolbar, {
80
- [e.shortBar]: l.shortBar
80
+ [e.shortBar]: i.shortBar
81
81
  }),
82
82
  children: [
83
83
  /* @__PURE__ */ o(
84
84
  "button",
85
85
  {
86
- onTouchStart: i,
87
- onMouseDown: i,
88
- onClick: () => f("bold"),
86
+ onMouseDown: d,
87
+ onClick: () => h("bold"),
89
88
  type: "button",
90
89
  className: a(e.toolbarItem, { [e.active]: w }),
91
90
  "data-testid": "format-bold",
92
- "aria-label": c.formatMessage({
91
+ "aria-label": r.formatMessage({
93
92
  id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
94
93
  defaultMessage: "Make text bold"
95
94
  }),
96
95
  children: /* @__PURE__ */ o(
97
- d,
96
+ c,
98
97
  {
99
98
  name: "bold",
100
99
  width: 24,
@@ -107,19 +106,18 @@ const he = (l) => {
107
106
  /* @__PURE__ */ o(
108
107
  "button",
109
108
  {
110
- onTouchStart: i,
111
- onMouseDown: i,
112
- onClick: () => f("italic"),
109
+ onMouseDown: d,
110
+ onClick: () => h("italic"),
113
111
  type: "button",
114
112
  className: a(e.toolbarItem, {
115
113
  [e.active]: D
116
114
  }),
117
- "aria-label": c.formatMessage({
115
+ "aria-label": r.formatMessage({
118
116
  id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
119
117
  defaultMessage: "Make text italic"
120
118
  }),
121
119
  children: /* @__PURE__ */ o(
122
- d,
120
+ c,
123
121
  {
124
122
  name: "italic",
125
123
  width: 24,
@@ -132,19 +130,18 @@ const he = (l) => {
132
130
  /* @__PURE__ */ o(
133
131
  "button",
134
132
  {
135
- onTouchStart: i,
136
- onMouseDown: i,
137
- onClick: () => f("underline"),
133
+ onMouseDown: d,
134
+ onClick: () => h("underline"),
138
135
  type: "button",
139
136
  className: a(e.toolbarItem, {
140
137
  [e.active]: L
141
138
  }),
142
- "aria-label": c.formatMessage({
139
+ "aria-label": r.formatMessage({
143
140
  id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
144
141
  defaultMessage: "Underline text"
145
142
  }),
146
143
  children: /* @__PURE__ */ o(
147
- d,
144
+ c,
148
145
  {
149
146
  name: "underline",
150
147
  width: 24,
@@ -157,19 +154,18 @@ const he = (l) => {
157
154
  /* @__PURE__ */ o(
158
155
  "button",
159
156
  {
160
- onTouchStart: i,
161
- onMouseDown: i,
157
+ onMouseDown: d,
162
158
  onClick: () => R(),
163
159
  type: "button",
164
160
  className: a(e.toolbarItem, {
165
161
  [e.active]: b === "quote"
166
162
  }),
167
- "aria-label": c.formatMessage({
163
+ "aria-label": r.formatMessage({
168
164
  id: "input.text_editor.plugins.toolbar_plugin.blockquote.aria_label",
169
165
  defaultMessage: "Add a blockquote"
170
166
  }),
171
167
  children: /* @__PURE__ */ o(
172
- d,
168
+ c,
173
169
  {
174
170
  name: "blockquote",
175
171
  width: 24,
@@ -182,19 +178,18 @@ const he = (l) => {
182
178
  /* @__PURE__ */ o(
183
179
  "button",
184
180
  {
185
- onTouchStart: i,
186
- onMouseDown: i,
181
+ onMouseDown: d,
187
182
  onClick: () => O(),
188
183
  type: "button",
189
184
  className: a(e.toolbarItem, {
190
185
  [e.active]: b === "ol"
191
186
  }),
192
- "aria-label": c.formatMessage({
187
+ "aria-label": r.formatMessage({
193
188
  id: "input.text_editor.plugins.toolbar_plugin.numbered_list.aria_label",
194
189
  defaultMessage: "Insert a numbered list"
195
190
  }),
196
191
  children: /* @__PURE__ */ o(
197
- d,
192
+ c,
198
193
  {
199
194
  name: "orderedList",
200
195
  width: 24,
@@ -204,20 +199,19 @@ const he = (l) => {
204
199
  )
205
200
  }
206
201
  ),
207
- !l.hideSourceAction && /* @__PURE__ */ o(
202
+ !i.hideSourceAction && /* @__PURE__ */ o(
208
203
  "button",
209
204
  {
210
- onTouchStart: i,
211
- onMouseDown: i,
212
- onClick: l.onAddSource,
205
+ onMouseDown: d,
206
+ onClick: i.onAddSource,
213
207
  type: "button",
214
208
  className: e.toolbarItem,
215
- "aria-label": c.formatMessage({
209
+ "aria-label": r.formatMessage({
216
210
  id: "input.text_editor.plugins.toolbar_plugin.add_link.aria_label",
217
211
  defaultMessage: "Add hyperlink"
218
212
  }),
219
213
  children: /* @__PURE__ */ o(
220
- d,
214
+ c,
221
215
  {
222
216
  name: "link",
223
217
  width: 20,
@@ -230,18 +224,18 @@ const he = (l) => {
230
224
  ]
231
225
  }
232
226
  ) : null,
233
- /* @__PURE__ */ o("div", { className: e.actionButton, children: l.hideSubmit ? null : /* @__PURE__ */ o(
227
+ /* @__PURE__ */ o("div", { className: e.actionButton, children: i.hideSubmit ? null : /* @__PURE__ */ o(
234
228
  Y,
235
229
  {
236
230
  type: "button",
237
231
  "data-testid": "submit-button",
238
- handleClick: l.onSubmit,
232
+ handleClick: i.onSubmit,
239
233
  className: a(e.inputSubmitActionButton, e.submitAction),
240
- "aria-label": c.formatMessage({
234
+ "aria-label": r.formatMessage({
241
235
  id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
242
236
  defaultMessage: "Send message"
243
237
  }),
244
- children: /* @__PURE__ */ o(d, { name: "send", width: 20, height: 20 })
238
+ children: /* @__PURE__ */ o(c, { name: "send", width: 20, height: 20 })
245
239
  }
246
240
  ) })
247
241
  ]
@@ -249,5 +243,5 @@ const he = (l) => {
249
243
  );
250
244
  };
251
245
  export {
252
- he as ToolbarPlugin
246
+ ge as ToolbarPlugin
253
247
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",