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