@logora/debate 0.3.113 → 0.3.114

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