@logora/debate 0.3.115 → 0.3.116

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