@logora/debate 0.3.107 → 0.3.109

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