@logora/debate 0.3.107 → 0.3.108

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