@logora/debate 0.3.106 → 0.3.107

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