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