@logora/debate 0.4.21 → 0.4.22

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