@logora/debate 0.4.49 → 0.4.50

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,52 +1,50 @@
1
- import { jsxs as P, jsx as n } from "react/jsx-runtime";
2
- import { $isListNode as O, ListNode as Z, INSERT_ORDERED_LIST_COMMAND as ee, $isListItemNode as R, $createListNode as te } from "@lexical/list";
3
- import { useLexicalComposerContext as oe } from "@lexical/react/LexicalComposerContext";
4
- import { $isHeadingNode as ne, $createQuoteNode as B } from "@lexical/rich-text";
5
- import { $setBlocksType as $ } from "@lexical/selection";
6
- import { $getNearestNodeOfType as ie, mergeRegister as ae } from "@lexical/utils";
1
+ import { jsxs as E, jsx as n } from "react/jsx-runtime";
2
+ import { $isListNode as P, ListNode as Y, INSERT_ORDERED_LIST_COMMAND as Z, $isListItemNode as O, $createListNode as ee } from "@lexical/list";
3
+ import { useLexicalComposerContext as te } from "@lexical/react/LexicalComposerContext";
4
+ import { $isHeadingNode as oe, $createQuoteNode as R } from "@lexical/rich-text";
5
+ import { $setBlocksType as B } from "@lexical/selection";
6
+ import { $getNearestNodeOfType as ne, mergeRegister as ie } from "@lexical/utils";
7
7
  import i from "classnames";
8
- import { $getSelection as M, $isRangeSelection as I, SELECTION_CHANGE_COMMAND as le, FORMAT_TEXT_COMMAND as re, $createParagraphNode as q } from "lexical";
9
- import { useRef as k, useState as N, useCallback as se, useEffect as K } from "react";
10
- import { useIntl as ce } from "react-intl";
8
+ import { $getSelection as M, $isRangeSelection as I, SELECTION_CHANGE_COMMAND as ae, FORMAT_TEXT_COMMAND as le, $createParagraphNode as $ } from "lexical";
9
+ import { useRef as x, useState as N, useCallback as re, useEffect as q } from "react";
10
+ import { useIntl as se } from "react-intl";
11
11
  import t from "./ToolbarPlugin.module.scss.js";
12
12
  import { Icon as f } from "../../../icons/icon/Icon.js";
13
- import { Button as de } from "../../../action/button/Button.js";
14
- const Ce = (a) => {
15
- const d = ce(), F = 1, [l] = oe(), U = k(null), [T, x] = N("paragraph"), [ue, j] = N(null), [H, Q] = N(!1), [V, z] = N(!1), [G, X] = N(!1), L = a.hideSubmit && a.hideSourceAction && a.disableRichText, _ = se(() => {
13
+ import { Button as ce } from "../../../action/button/Button.js";
14
+ const we = (a) => {
15
+ const d = se(), K = 1, [l] = te(), F = x(null), [T, S] = N("paragraph"), [de, U] = N(null), [j, H] = N(!1), [Q, V] = N(!1), [z, G] = N(!1), L = a.hideSubmit && a.hideSourceAction && a.disableRichText, _ = re(() => {
16
16
  const e = M();
17
17
  if (I(e)) {
18
18
  const c = e.anchor.getNode(), r = c.getKey() === "root" ? c : c.getTopLevelElementOrThrow(), u = r.getKey();
19
19
  if (l.getElementByKey(u) !== null)
20
- if (j(u), O(r)) {
21
- const o = ie(c, Z), p = o ? o.getTag() : r.getTag();
22
- x(p);
20
+ if (U(u), P(r)) {
21
+ const o = ne(c, Y), p = o ? o.getTag() : r.getTag();
22
+ S(p);
23
23
  } else {
24
- const o = ne(r) ? r.getTag() : r.getType();
25
- x(o);
24
+ const o = oe(r) ? r.getTag() : r.getType();
25
+ S(o);
26
26
  }
27
- Q(e.hasFormat("bold")), z(e.hasFormat("italic")), X(e.hasFormat("underline"));
27
+ H(e.hasFormat("bold")), V(e.hasFormat("italic")), G(e.hasFormat("underline"));
28
28
  }
29
29
  }, [l]);
30
- K(() => ae(
30
+ q(() => ie(
31
31
  l.registerUpdateListener(({ editorState: e }) => {
32
32
  e.read(() => {
33
33
  _();
34
34
  });
35
35
  }),
36
36
  l.registerCommand(
37
- le,
37
+ ae,
38
38
  () => (_(), !1),
39
- F
39
+ K
40
40
  )
41
41
  ), [l, _]);
42
- const A = (e) => {
43
- e.pointerType !== "touch" && e.pointerType !== "pen" && e.preventDefault();
44
- }, y = k(!1), s = k(null);
45
- K(() => () => {
42
+ const y = x(!1), s = x(null);
43
+ q(() => () => {
46
44
  s.current && clearTimeout(s.current);
47
45
  }, []);
48
46
  const g = (e, c) => {
49
- A(e), (e.pointerType === "touch" || e.pointerType === "pen") && (y.current = !0, c(), s.current && clearTimeout(s.current), s.current = setTimeout(() => {
47
+ e.preventDefault(), (e.pointerType === "touch" || e.pointerType === "pen") && (y.current = !0, c(), s.current && clearTimeout(s.current), s.current = setTimeout(() => {
50
48
  y.current = !1, s.current = null;
51
49
  }, 500));
52
50
  }, h = (e) => {
@@ -62,8 +60,8 @@ const Ce = (a) => {
62
60
  });
63
61
  }, 0);
64
62
  }, b = (e) => {
65
- l.dispatchCommand(re, e), w();
66
- }, J = () => {
63
+ l.dispatchCommand(le, e), w();
64
+ }, X = () => {
67
65
  l.update(() => {
68
66
  const e = M();
69
67
  if (!I(e))
@@ -71,53 +69,53 @@ const Ce = (a) => {
71
69
  const c = e.getNodes(), r = /* @__PURE__ */ new Set();
72
70
  for (const m of c) {
73
71
  let o = m;
74
- for (; o !== null && !R(o); )
72
+ for (; o !== null && !O(o); )
75
73
  o = o.getParent();
76
- R(o) && r.add(o);
74
+ O(o) && r.add(o);
77
75
  }
78
76
  const u = Array.from(r).reverse();
79
77
  for (const m of u) {
80
78
  const o = m.getParent();
81
- if (!O(o))
79
+ if (!P(o))
82
80
  continue;
83
- const p = q(), W = m.getChildren();
84
- for (const S of W)
85
- p.append(S);
81
+ const p = $(), J = m.getChildren();
82
+ for (const k of J)
83
+ p.append(k);
86
84
  const C = m.getNextSiblings();
87
85
  if (o.insertAfter(p), C.length > 0) {
88
- const S = C[0].getValue(), E = te(o.getListType(), S);
89
- for (const Y of C)
90
- E.append(Y);
91
- p.insertAfter(E);
86
+ const k = C[0].getValue(), v = ee(o.getListType(), k);
87
+ for (const W of C)
88
+ v.append(W);
89
+ p.insertAfter(v);
92
90
  }
93
91
  m.remove(), o.getChildrenSize() === 0 && o.remove();
94
92
  }
95
93
  });
94
+ }, A = () => {
95
+ T !== "ol" ? l.dispatchCommand(Z) : X(), w();
96
96
  }, D = () => {
97
- T !== "ol" ? l.dispatchCommand(ee) : J(), w();
98
- }, v = () => {
99
97
  T !== "quote" ? l.update(() => {
100
98
  const e = M();
101
99
  if (I(e))
102
100
  if (e.isCollapsed()) {
103
- const r = e.anchor.getNode().getTopLevelElementOrThrow(), u = B();
101
+ const r = e.anchor.getNode().getTopLevelElementOrThrow(), u = R();
104
102
  r.insertAfter(u), u.selectEnd();
105
103
  } else
106
- $(e, () => B());
104
+ B(e, () => R());
107
105
  }) : l.update(() => {
108
106
  const e = M();
109
- I(e) && $(e, () => q());
107
+ I(e) && B(e, () => $());
110
108
  }), w();
111
109
  };
112
- return L ? null : /* @__PURE__ */ P(
110
+ return L ? null : /* @__PURE__ */ E(
113
111
  "div",
114
112
  {
115
113
  className: i(t.toolbar, {
116
114
  [t.toolbarIsActive]: L ? !1 : a.isActive
117
115
  }),
118
- ref: U,
116
+ ref: F,
119
117
  children: [
120
- a.isActive ? !a.disableRichText && /* @__PURE__ */ P(
118
+ a.isActive ? !a.disableRichText && /* @__PURE__ */ E(
121
119
  "div",
122
120
  {
123
121
  className: i(t.iconToolbar, {
@@ -130,7 +128,7 @@ const Ce = (a) => {
130
128
  onPointerDown: (e) => g(e, () => b("bold")),
131
129
  onClick: () => h(() => b("bold")),
132
130
  type: "button",
133
- className: i(t.toolbarItem, { [t.active]: H }),
131
+ className: i(t.toolbarItem, { [t.active]: j }),
134
132
  "data-testid": "format-bold",
135
133
  "aria-label": d.formatMessage({
136
134
  id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
@@ -154,7 +152,7 @@ const Ce = (a) => {
154
152
  onClick: () => h(() => b("italic")),
155
153
  type: "button",
156
154
  className: i(t.toolbarItem, {
157
- [t.active]: V
155
+ [t.active]: Q
158
156
  }),
159
157
  "aria-label": d.formatMessage({
160
158
  id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
@@ -178,7 +176,7 @@ const Ce = (a) => {
178
176
  onClick: () => h(() => b("underline")),
179
177
  type: "button",
180
178
  className: i(t.toolbarItem, {
181
- [t.active]: G
179
+ [t.active]: z
182
180
  }),
183
181
  "aria-label": d.formatMessage({
184
182
  id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
@@ -198,8 +196,8 @@ const Ce = (a) => {
198
196
  /* @__PURE__ */ n(
199
197
  "button",
200
198
  {
201
- onPointerDown: (e) => g(e, () => v()),
202
- onClick: () => h(() => v()),
199
+ onPointerDown: (e) => g(e, () => D()),
200
+ onClick: () => h(() => D()),
203
201
  type: "button",
204
202
  className: i(t.toolbarItem, {
205
203
  [t.active]: T === "quote"
@@ -222,8 +220,8 @@ const Ce = (a) => {
222
220
  /* @__PURE__ */ n(
223
221
  "button",
224
222
  {
225
- onPointerDown: (e) => g(e, () => D()),
226
- onClick: () => h(() => D()),
223
+ onPointerDown: (e) => g(e, () => A()),
224
+ onClick: () => h(() => A()),
227
225
  type: "button",
228
226
  className: i(t.toolbarItem, {
229
227
  [t.active]: T === "ol"
@@ -246,7 +244,7 @@ const Ce = (a) => {
246
244
  !a.hideSourceAction && /* @__PURE__ */ n(
247
245
  "button",
248
246
  {
249
- onPointerDown: A,
247
+ onPointerDown: (e) => e.preventDefault(),
250
248
  onClick: a.onAddSource,
251
249
  type: "button",
252
250
  className: t.toolbarItem,
@@ -269,7 +267,7 @@ const Ce = (a) => {
269
267
  }
270
268
  ) : null,
271
269
  /* @__PURE__ */ n("div", { className: t.actionButton, children: a.hideSubmit ? null : /* @__PURE__ */ n(
272
- de,
270
+ ce,
273
271
  {
274
272
  type: "button",
275
273
  "data-testid": "submit-button",
@@ -287,5 +285,5 @@ const Ce = (a) => {
287
285
  );
288
286
  };
289
287
  export {
290
- Ce as ToolbarPlugin
288
+ we as ToolbarPlugin
291
289
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.49",
3
+ "version": "0.4.50",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",