@logora/debate 0.3.108 → 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,86 +1,94 @@
1
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";
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
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";
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 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);
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 g = U(n) ? n.getTag() : n.getType();
25
- _(g);
24
+ const f = U(n) ? n.getTag() : n.getType();
25
+ M(f);
26
26
  }
27
- A(t.hasFormat("bold")), v(t.hasFormat("italic")), L(t.hasFormat("underline"));
27
+ v(t.hasFormat("bold")), w(t.hasFormat("italic")), D(t.hasFormat("underline"));
28
28
  }
29
- }, [i]);
30
- X(() => j(
31
- i.registerUpdateListener(({ editorState: t }) => {
29
+ }, [l]);
30
+ J(() => H(
31
+ l.registerUpdateListener(({ editorState: t }) => {
32
32
  t.read(() => {
33
- h();
33
+ g();
34
34
  });
35
35
  }),
36
- i.registerCommand(
37
- H,
38
- (t, d) => (h(), !1),
39
- k
36
+ l.registerCommand(
37
+ Q,
38
+ (t, c) => (g(), !1),
39
+ x
40
40
  )
41
- ), [i, h]);
42
- const c = (t) => {
41
+ ), [l, g]);
42
+ const d = (t) => {
43
43
  t.preventDefault();
44
- }, D = () => {
45
- b !== "ol" ? i.dispatchCommand(q) : i.dispatchCommand(K);
44
+ }, h = () => {
45
+ Promise.resolve().then(() => {
46
+ l.getEditorState().read(() => {
47
+ g();
48
+ });
49
+ });
50
+ }, p = (t) => {
51
+ l.dispatchCommand(G, t), h();
46
52
  }, O = () => {
47
- b !== "quote" ? i.update(() => {
48
- const t = f();
49
- if (p(t))
53
+ b !== "ol" ? l.dispatchCommand(K) : l.dispatchCommand(F), h();
54
+ }, R = () => {
55
+ b !== "quote" ? l.update(() => {
56
+ const t = N();
57
+ if (_(t))
50
58
  if (t.isCollapsed()) {
51
- const n = t.anchor.getNode().getTopLevelElementOrThrow(), m = T();
59
+ const n = t.anchor.getNode().getTopLevelElementOrThrow(), m = C();
52
60
  n.insertAfter(m), m.selectEnd();
53
61
  } else
54
- C(t, () => T());
55
- }) : i.update(() => {
56
- const t = f();
57
- p(t) && C(t, () => Q());
58
- });
62
+ k(t, () => C());
63
+ }) : l.update(() => {
64
+ const t = N();
65
+ _(t) && k(t, () => V());
66
+ }), h();
59
67
  };
60
- return M ? null : /* @__PURE__ */ y(
68
+ return T ? null : /* @__PURE__ */ y(
61
69
  "div",
62
70
  {
63
71
  className: a(e.toolbar, {
64
- [e.toolbarIsActive]: M ? !1 : l.isActive
72
+ [e.toolbarIsActive]: T ? !1 : i.isActive
65
73
  }),
66
- ref: I,
74
+ ref: E,
67
75
  children: [
68
- l.isActive ? !l.disableRichText && /* @__PURE__ */ y(
76
+ i.isActive ? !i.disableRichText && /* @__PURE__ */ y(
69
77
  "div",
70
78
  {
71
79
  className: a(e.iconToolbar, {
72
- [e.shortBar]: l.shortBar
80
+ [e.shortBar]: i.shortBar
73
81
  }),
74
82
  children: [
75
83
  /* @__PURE__ */ o(
76
84
  "button",
77
85
  {
78
- onMouseDown: c,
86
+ onMouseDown: d,
79
87
  onClick: () => {
80
- i.dispatchCommand(N, "bold");
88
+ p("bold");
81
89
  },
82
90
  type: "button",
83
- className: a(e.toolbarItem, { [e.active]: E }),
91
+ className: a(e.toolbarItem, { [e.active]: S }),
84
92
  "data-testid": "format-bold",
85
93
  "aria-label": s.formatMessage({
86
94
  id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
@@ -100,13 +108,13 @@ const ue = (l) => {
100
108
  /* @__PURE__ */ o(
101
109
  "button",
102
110
  {
103
- onMouseDown: c,
111
+ onMouseDown: d,
104
112
  onClick: () => {
105
- i.dispatchCommand(N, "italic");
113
+ p("italic");
106
114
  },
107
115
  type: "button",
108
116
  className: a(e.toolbarItem, {
109
- [e.active]: S
117
+ [e.active]: A
110
118
  }),
111
119
  "aria-label": s.formatMessage({
112
120
  id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
@@ -126,13 +134,13 @@ const ue = (l) => {
126
134
  /* @__PURE__ */ o(
127
135
  "button",
128
136
  {
129
- onMouseDown: c,
137
+ onMouseDown: d,
130
138
  onClick: () => {
131
- i.dispatchCommand(N, "underline");
139
+ p("underline");
132
140
  },
133
141
  type: "button",
134
142
  className: a(e.toolbarItem, {
135
- [e.active]: w
143
+ [e.active]: L
136
144
  }),
137
145
  "aria-label": s.formatMessage({
138
146
  id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
@@ -152,8 +160,8 @@ const ue = (l) => {
152
160
  /* @__PURE__ */ o(
153
161
  "button",
154
162
  {
155
- onMouseDown: c,
156
- onClick: () => O(),
163
+ onMouseDown: d,
164
+ onClick: () => R(),
157
165
  type: "button",
158
166
  className: a(e.toolbarItem, { [e.active]: b === "quote" }),
159
167
  "aria-label": s.formatMessage({
@@ -174,8 +182,8 @@ const ue = (l) => {
174
182
  /* @__PURE__ */ o(
175
183
  "button",
176
184
  {
177
- onMouseDown: c,
178
- onClick: () => D(),
185
+ onMouseDown: d,
186
+ onClick: () => O(),
179
187
  type: "button",
180
188
  className: a(e.toolbarItem, { [e.active]: b === "ol" }),
181
189
  "aria-label": s.formatMessage({
@@ -193,10 +201,10 @@ const ue = (l) => {
193
201
  )
194
202
  }
195
203
  ),
196
- !l.hideSourceAction && /* @__PURE__ */ o(
204
+ !i.hideSourceAction && /* @__PURE__ */ o(
197
205
  "button",
198
206
  {
199
- onClick: l.onAddSource,
207
+ onClick: i.onAddSource,
200
208
  type: "button",
201
209
  className: e.toolbarItem,
202
210
  "aria-label": s.formatMessage({
@@ -217,12 +225,12 @@ const ue = (l) => {
217
225
  ]
218
226
  }
219
227
  ) : null,
220
- /* @__PURE__ */ o("div", { className: e.actionButton, children: l.hideSubmit ? null : /* @__PURE__ */ o(
221
- J,
228
+ /* @__PURE__ */ o("div", { className: e.actionButton, children: i.hideSubmit ? null : /* @__PURE__ */ o(
229
+ Y,
222
230
  {
223
231
  type: "button",
224
232
  "data-testid": "submit-button",
225
- handleClick: l.onSubmit,
233
+ handleClick: i.onSubmit,
226
234
  className: a(e.inputSubmitActionButton, e.submitAction),
227
235
  "aria-label": s.formatMessage({
228
236
  id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
@@ -236,5 +244,5 @@ const ue = (l) => {
236
244
  );
237
245
  };
238
246
  export {
239
- ue as ToolbarPlugin
247
+ ge as ToolbarPlugin
240
248
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.108",
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",