@logora/debate 0.4.51 → 0.4.53

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.
@@ -9,9 +9,10 @@ import { EMAIL_CONSENT_STORAGE_KEY as H } from "../use_auth/useAuthActions.js";
9
9
  import { Icon as K } from "../../icons/icon/Icon.js";
10
10
  import { Button as V } from "../../action/button/Button.js";
11
11
  import { Toggle as W } from "../../input/toggle/Toggle.js";
12
- const oe = ({
12
+ import { utf8ToBase64url as $ } from "../use_auth/base64.js";
13
+ const ie = ({
13
14
  authType: v,
14
- providerName: d,
15
+ providerName: c,
15
16
  loginUrl: M,
16
17
  signupUrl: b,
17
18
  termsUrl: N,
@@ -20,25 +21,25 @@ const oe = ({
20
21
  oAuthRedirectUri: y,
21
22
  scope: I,
22
23
  redirectParameter: f = "logora_redirect",
23
- trackingParameters: U = {},
24
- hideActions: P = !1,
24
+ trackingParameters: P = {},
25
+ hideActions: U = !1,
25
26
  hideLoginButton: k = !1,
26
27
  showEmailConsent: g = !1,
27
28
  showTerms: L = !1,
28
- hideBelowButton: R = !1,
29
- error: x = !1
29
+ hideBelowButton: x = !1,
30
+ error: R = !1
30
31
  }) => {
31
- const [h, A] = g ? G(H, !1) : [!1, () => {
32
- }], o = Y(), c = z(), C = (t) => {
32
+ const [h, T] = g ? G(H, !1) : [!1, () => {
33
+ }], o = Y(), d = z(), A = (t) => {
33
34
  if (typeof window < "u") {
34
- const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams, E = new URLSearchParams(c.search);
35
+ const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams, E = new URLSearchParams(d.search);
35
36
  l.has("code") && l.delete("code"), f && l.append(f, window.location.toString());
36
- for (const [_, F] of Object.entries(U)) {
37
+ for (const [_, F] of Object.entries(P)) {
37
38
  let r = F;
38
39
  if (r) {
39
- const j = c.pathname.slice(
40
+ const j = d.pathname.slice(
40
41
  0,
41
- c.pathname.lastIndexOf("/")
42
+ d.pathname.lastIndexOf("/")
42
43
  );
43
44
  r = r.replace(
44
45
  "{{UTM_CAMPAIGN}}",
@@ -48,19 +49,19 @@ const oe = ({
48
49
  decodeURIComponent(j)
49
50
  );
50
51
  }
51
- _ === "metadata" && r && (r = window.btoa(r)), l.append(_, encodeURIComponent(r));
52
+ _ === "metadata" && r && (r = $(r)), l.append(_, r);
52
53
  }
53
54
  return i.search = l.toString(), i.toString();
54
55
  }
55
56
  return "";
56
- }, T = (t) => {
57
+ }, C = (t) => {
57
58
  const s = new URL(t);
58
59
  if (s.searchParams.delete("code"), s.searchParams.append("client_id", S), s.searchParams.append("redirect_uri", y), s.searchParams.append("scope", I), s.searchParams.append("response_type", "code"), typeof window < "u") {
59
60
  const i = new URL(window.location.href);
60
61
  i.searchParams.delete("code"), s.searchParams.append("state", window.btoa(i.toString()));
61
62
  }
62
63
  return s.href;
63
- }, p = (t) => v === "oauth2_server" ? T(t) : C(t), O = p(M), B = p(b);
64
+ }, p = (t) => v === "oauth2_server" ? C(t) : A(t), B = p(M), O = p(b);
64
65
  return /* @__PURE__ */ n("div", { className: a.ssoForm, children: [
65
66
  /* @__PURE__ */ e("div", { className: a.logo, children: u ? /* @__PURE__ */ e(
66
67
  "img",
@@ -69,7 +70,7 @@ const oe = ({
69
70
  width: 100,
70
71
  className: a.logoImage,
71
72
  src: u,
72
- alt: `Logo ${d}`
73
+ alt: `Logo ${c}`
73
74
  }
74
75
  ) : /* @__PURE__ */ e(
75
76
  K,
@@ -94,17 +95,17 @@ const oe = ({
94
95
  id: "auth.sso_form.subtitle",
95
96
  defaultMessage: "Sign up right now and receive alerts by email."
96
97
  },
97
- { provider: d }
98
+ { provider: c }
98
99
  )
99
100
  ] }),
100
- P ? null : /* @__PURE__ */ n(m, { children: [
101
+ U ? null : /* @__PURE__ */ n(m, { children: [
101
102
  /* @__PURE__ */ e(
102
103
  V,
103
104
  {
104
105
  "data-tid": "link_signup",
105
106
  "data-testid": "signup-button",
106
107
  className: a.loginButton,
107
- to: B,
108
+ to: O,
108
109
  external: !0,
109
110
  border: !1,
110
111
  children: o.formatMessage({
@@ -113,7 +114,7 @@ const oe = ({
113
114
  })
114
115
  }
115
116
  ),
116
- R ? null : /* @__PURE__ */ n(m, { children: [
117
+ x ? null : /* @__PURE__ */ n(m, { children: [
117
118
  k === !0 ? null : /* @__PURE__ */ n("div", { className: a.cgu, children: [
118
119
  o.formatMessage({
119
120
  id: "auth.sso_form.already_account",
@@ -126,7 +127,7 @@ const oe = ({
126
127
  "data-testid": "signin-link",
127
128
  "data-tid": "link_login",
128
129
  rel: "nofollow",
129
- href: O,
130
+ href: B,
130
131
  children: o.formatMessage({
131
132
  id: "auth.sso_form.signin",
132
133
  defaultMessage: "Sign in"
@@ -146,13 +147,13 @@ const oe = ({
146
147
  id: "auth.sso_form.consent_label",
147
148
  defaultMessage: "I agree to receive emails from the editor"
148
149
  },
149
- { variable: d }
150
+ { variable: c }
150
151
  ),
151
- onInputChanged: (t) => A(!h),
152
+ onInputChanged: (t) => T(!h),
152
153
  "data-testid": "accepts-email-input"
153
154
  }
154
155
  ) }) : null,
155
- x ? /* @__PURE__ */ e("div", { className: a.error, children: o.formatMessage({
156
+ R ? /* @__PURE__ */ e("div", { className: a.error, children: o.formatMessage({
156
157
  id: "auth.sso_form.error",
157
158
  defaultMessage: "An error occurred during sign in. Please try again in a few moments."
158
159
  }) }) : null,
@@ -189,5 +190,5 @@ const oe = ({
189
190
  ] });
190
191
  };
191
192
  export {
192
- oe as SSOForm
193
+ ie as SSOForm
193
194
  };
@@ -1,250 +1,249 @@
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";
1
+ import { jsxs as R, jsx as i } from "react/jsx-runtime";
2
+ import { $isListNode as B, ListNode as Y, INSERT_ORDERED_LIST_COMMAND as Z, $isListItemNode as $, $createListNode as ee } from "@lexical/list";
3
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";
4
+ import { $isHeadingNode as oe, $createQuoteNode as q } from "@lexical/rich-text";
5
+ import { $setBlocksType as K } from "@lexical/selection";
6
6
  import { $getNearestNodeOfType as ne, mergeRegister as ie } from "@lexical/utils";
7
- import i from "classnames";
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";
7
+ import l from "classnames";
8
+ import { $getSelection as M, $isRangeSelection as I, SELECTION_CHANGE_COMMAND as le, FORMAT_TEXT_COMMAND as ae, $createParagraphNode as F } from "lexical";
9
+ import { useRef as x, useState as N, useCallback as re, useEffect as U } from "react";
10
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
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(() => {
14
+ const Ce = (a) => {
15
+ const d = se(), j = 1, [r] = te(), H = x(null), [T, S] = N("paragraph"), [de, Q] = N(null), [V, L] = N(!1), [z, A] = N(!1), [G, D] = N(!1), v = a.hideSubmit && a.hideSourceAction && a.disableRichText, _ = re(() => {
16
16
  const e = M();
17
17
  if (I(e)) {
18
- const c = e.anchor.getNode(), r = c.getKey() === "root" ? c : c.getTopLevelElementOrThrow(), u = r.getKey();
19
- if (l.getElementByKey(u) !== null)
20
- if (U(u), P(r)) {
21
- const o = ne(c, Y), p = o ? o.getTag() : r.getTag();
18
+ const n = e.anchor.getNode(), s = n.getKey() === "root" ? n : n.getTopLevelElementOrThrow(), u = s.getKey();
19
+ if (r.getElementByKey(u) !== null)
20
+ if (Q(u), B(s)) {
21
+ const o = ne(n, Y), p = o ? o.getTag() : s.getTag();
22
22
  S(p);
23
23
  } else {
24
- const o = oe(r) ? r.getTag() : r.getType();
24
+ const o = oe(s) ? s.getTag() : s.getType();
25
25
  S(o);
26
26
  }
27
- H(e.hasFormat("bold")), V(e.hasFormat("italic")), G(e.hasFormat("underline"));
27
+ L(e.hasFormat("bold")), A(e.hasFormat("italic")), D(e.hasFormat("underline"));
28
28
  }
29
- }, [l]);
30
- q(() => ie(
31
- l.registerUpdateListener(({ editorState: e }) => {
29
+ }, [r]);
30
+ U(() => ie(
31
+ r.registerUpdateListener(({ editorState: e }) => {
32
32
  e.read(() => {
33
33
  _();
34
34
  });
35
35
  }),
36
- l.registerCommand(
37
- ae,
36
+ r.registerCommand(
37
+ le,
38
38
  () => (_(), !1),
39
- K
39
+ j
40
40
  )
41
- ), [l, _]);
42
- const y = x(!1), s = x(null);
43
- q(() => () => {
44
- s.current && clearTimeout(s.current);
41
+ ), [r, _]);
42
+ const y = x(!1), c = x(null);
43
+ U(() => () => {
44
+ c.current && clearTimeout(c.current);
45
45
  }, []);
46
- const g = (e, c) => {
47
- e.preventDefault(), (e.pointerType === "touch" || e.pointerType === "pen") && (y.current = !0, c(), s.current && clearTimeout(s.current), s.current = setTimeout(() => {
48
- y.current = !1, s.current = null;
49
- }, 500));
46
+ const g = (e, n) => {
47
+ e.pointerType === "touch" || e.pointerType === "pen" ? (e.preventDefault(), y.current = !0, n(), c.current && clearTimeout(c.current), c.current = setTimeout(() => {
48
+ y.current = !1, c.current = null;
49
+ }, 500)) : e.preventDefault();
50
50
  }, h = (e) => {
51
51
  if (y.current) {
52
- y.current = !1, s.current && (clearTimeout(s.current), s.current = null);
52
+ y.current = !1, c.current && (clearTimeout(c.current), c.current = null);
53
53
  return;
54
54
  }
55
55
  e();
56
- }, w = () => {
56
+ }, C = () => {
57
57
  setTimeout(() => {
58
- l.getEditorState().read(() => {
58
+ r.getEditorState().read(() => {
59
59
  _();
60
60
  });
61
61
  }, 0);
62
62
  }, b = (e) => {
63
- l.dispatchCommand(le, e), w();
63
+ r.dispatchCommand(ae, e), e === "bold" ? L((n) => !n) : e === "italic" ? A((n) => !n) : e === "underline" && D((n) => !n), C();
64
64
  }, X = () => {
65
- l.update(() => {
65
+ r.update(() => {
66
66
  const e = M();
67
67
  if (!I(e))
68
68
  return;
69
- const c = e.getNodes(), r = /* @__PURE__ */ new Set();
70
- for (const m of c) {
69
+ const n = e.getNodes(), s = /* @__PURE__ */ new Set();
70
+ for (const m of n) {
71
71
  let o = m;
72
- for (; o !== null && !O(o); )
72
+ for (; o !== null && !$(o); )
73
73
  o = o.getParent();
74
- O(o) && r.add(o);
74
+ $(o) && s.add(o);
75
75
  }
76
- const u = Array.from(r).reverse();
76
+ const u = Array.from(s).reverse();
77
77
  for (const m of u) {
78
78
  const o = m.getParent();
79
- if (!P(o))
79
+ if (!B(o))
80
80
  continue;
81
- const p = $(), J = m.getChildren();
82
- for (const k of J)
83
- p.append(k);
84
- const C = m.getNextSiblings();
85
- if (o.insertAfter(p), C.length > 0) {
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);
81
+ const p = F(), J = m.getChildren();
82
+ for (const w of J)
83
+ p.append(w);
84
+ const k = m.getNextSiblings();
85
+ if (o.insertAfter(p), k.length > 0) {
86
+ const w = k[0].getValue(), P = ee(o.getListType(), w);
87
+ for (const W of k)
88
+ P.append(W);
89
+ p.insertAfter(P);
90
90
  }
91
91
  m.remove(), o.getChildrenSize() === 0 && o.remove();
92
92
  }
93
93
  });
94
- }, A = () => {
95
- T !== "ol" ? l.dispatchCommand(Z) : X(), w();
96
- }, D = () => {
97
- T !== "quote" ? l.update(() => {
94
+ }, E = () => {
95
+ T !== "ol" ? r.dispatchCommand(Z) : X(), C();
96
+ }, O = () => {
97
+ T !== "quote" ? r.update(() => {
98
98
  const e = M();
99
99
  if (I(e))
100
100
  if (e.isCollapsed()) {
101
- const r = e.anchor.getNode().getTopLevelElementOrThrow(), u = R();
102
- r.insertAfter(u), u.selectEnd();
101
+ const s = e.anchor.getNode().getTopLevelElementOrThrow(), u = q();
102
+ s.insertAfter(u), u.selectEnd();
103
103
  } else
104
- B(e, () => R());
105
- }) : l.update(() => {
104
+ K(e, () => q());
105
+ }) : r.update(() => {
106
106
  const e = M();
107
- I(e) && B(e, () => $());
108
- }), w();
107
+ I(e) && K(e, () => F());
108
+ }), C();
109
109
  };
110
- return L ? null : /* @__PURE__ */ E(
110
+ return v ? null : /* @__PURE__ */ R(
111
111
  "div",
112
112
  {
113
- className: i(t.toolbar, {
114
- [t.toolbarIsActive]: L ? !1 : a.isActive
113
+ className: l(t.toolbar, {
114
+ [t.toolbarIsActive]: v ? !1 : a.isActive
115
115
  }),
116
- ref: F,
116
+ ref: H,
117
117
  children: [
118
- a.isActive ? !a.disableRichText && /* @__PURE__ */ E(
118
+ a.isActive ? !a.disableRichText && /* @__PURE__ */ R(
119
119
  "div",
120
120
  {
121
- className: i(t.iconToolbar, {
121
+ className: l(t.iconToolbar, {
122
122
  [t.shortBar]: a.shortBar
123
123
  }),
124
124
  children: [
125
- /* @__PURE__ */ n(
125
+ /* @__PURE__ */ i(
126
126
  "button",
127
127
  {
128
128
  onPointerDown: (e) => g(e, () => b("bold")),
129
129
  onClick: () => h(() => b("bold")),
130
130
  type: "button",
131
- className: i(t.toolbarItem, { [t.active]: j }),
131
+ className: l(t.toolbarItem, { [t.active]: V }),
132
132
  "data-testid": "format-bold",
133
133
  "aria-label": d.formatMessage({
134
134
  id: "input.text_editor.plugins.toolbar_plugin.bold.aria_label",
135
135
  defaultMessage: "Make text bold"
136
136
  }),
137
- children: /* @__PURE__ */ n(
137
+ children: /* @__PURE__ */ i(
138
138
  f,
139
139
  {
140
140
  name: "bold",
141
141
  width: 24,
142
142
  height: 24,
143
- className: i(t.format, t.bold)
143
+ className: l(t.format, t.bold)
144
144
  }
145
145
  )
146
146
  }
147
147
  ),
148
- /* @__PURE__ */ n(
148
+ /* @__PURE__ */ i(
149
149
  "button",
150
150
  {
151
151
  onPointerDown: (e) => g(e, () => b("italic")),
152
152
  onClick: () => h(() => b("italic")),
153
153
  type: "button",
154
- className: i(t.toolbarItem, {
155
- [t.active]: Q
154
+ className: l(t.toolbarItem, {
155
+ [t.active]: z
156
156
  }),
157
157
  "aria-label": d.formatMessage({
158
158
  id: "input.text_editor.plugins.toolbar_plugin.italic.aria_label",
159
159
  defaultMessage: "Make text italic"
160
160
  }),
161
- children: /* @__PURE__ */ n(
161
+ children: /* @__PURE__ */ i(
162
162
  f,
163
163
  {
164
164
  name: "italic",
165
165
  width: 24,
166
166
  height: 24,
167
- className: i(t.format, t.italic)
167
+ className: l(t.format, t.italic)
168
168
  }
169
169
  )
170
170
  }
171
171
  ),
172
- /* @__PURE__ */ n(
172
+ /* @__PURE__ */ i(
173
173
  "button",
174
174
  {
175
175
  onPointerDown: (e) => g(e, () => b("underline")),
176
176
  onClick: () => h(() => b("underline")),
177
177
  type: "button",
178
- className: i(t.toolbarItem, {
179
- [t.active]: z
178
+ className: l(t.toolbarItem, {
179
+ [t.active]: G
180
180
  }),
181
181
  "aria-label": d.formatMessage({
182
182
  id: "input.text_editor.plugins.toolbar_plugin.underline.aria_label",
183
183
  defaultMessage: "Underline text"
184
184
  }),
185
- children: /* @__PURE__ */ n(
185
+ children: /* @__PURE__ */ i(
186
186
  f,
187
187
  {
188
188
  name: "underline",
189
189
  width: 24,
190
190
  height: 24,
191
- className: i(t.format, t.underline)
191
+ className: l(t.format, t.underline)
192
192
  }
193
193
  )
194
194
  }
195
195
  ),
196
- /* @__PURE__ */ n(
196
+ /* @__PURE__ */ i(
197
197
  "button",
198
198
  {
199
- onPointerDown: (e) => g(e, () => D()),
200
- onClick: () => h(() => D()),
199
+ onPointerDown: (e) => g(e, () => O()),
200
+ onClick: () => h(() => O()),
201
201
  type: "button",
202
- className: i(t.toolbarItem, {
202
+ className: l(t.toolbarItem, {
203
203
  [t.active]: T === "quote"
204
204
  }),
205
205
  "aria-label": d.formatMessage({
206
206
  id: "input.text_editor.plugins.toolbar_plugin.blockquote.aria_label",
207
207
  defaultMessage: "Add a blockquote"
208
208
  }),
209
- children: /* @__PURE__ */ n(
209
+ children: /* @__PURE__ */ i(
210
210
  f,
211
211
  {
212
212
  name: "blockquote",
213
213
  width: 24,
214
214
  height: 24,
215
- className: i(t.format, t.quote)
215
+ className: l(t.format, t.quote)
216
216
  }
217
217
  )
218
218
  }
219
219
  ),
220
- /* @__PURE__ */ n(
220
+ /* @__PURE__ */ i(
221
221
  "button",
222
222
  {
223
- onPointerDown: (e) => g(e, () => A()),
224
- onClick: () => h(() => A()),
223
+ onPointerDown: (e) => g(e, () => E()),
224
+ onClick: () => h(() => E()),
225
225
  type: "button",
226
- className: i(t.toolbarItem, {
226
+ className: l(t.toolbarItem, {
227
227
  [t.active]: T === "ol"
228
228
  }),
229
229
  "aria-label": d.formatMessage({
230
230
  id: "input.text_editor.plugins.toolbar_plugin.numbered_list.aria_label",
231
231
  defaultMessage: "Insert a numbered list"
232
232
  }),
233
- children: /* @__PURE__ */ n(
233
+ children: /* @__PURE__ */ i(
234
234
  f,
235
235
  {
236
236
  name: "orderedList",
237
237
  width: 24,
238
238
  height: 24,
239
- className: i(t.format, t.numberedList)
239
+ className: l(t.format, t.numberedList)
240
240
  }
241
241
  )
242
242
  }
243
243
  ),
244
- !a.hideSourceAction && /* @__PURE__ */ n(
244
+ !a.hideSourceAction && /* @__PURE__ */ i(
245
245
  "button",
246
246
  {
247
- onPointerDown: (e) => e.preventDefault(),
248
247
  onClick: a.onAddSource,
249
248
  type: "button",
250
249
  className: t.toolbarItem,
@@ -252,13 +251,13 @@ const we = (a) => {
252
251
  id: "input.text_editor.plugins.toolbar_plugin.add_link.aria_label",
253
252
  defaultMessage: "Add hyperlink"
254
253
  }),
255
- children: /* @__PURE__ */ n(
254
+ children: /* @__PURE__ */ i(
256
255
  f,
257
256
  {
258
257
  name: "link",
259
258
  width: 20,
260
259
  height: 20,
261
- className: i(t.format, t.link)
260
+ className: l(t.format, t.link)
262
261
  }
263
262
  )
264
263
  }
@@ -266,18 +265,18 @@ const we = (a) => {
266
265
  ]
267
266
  }
268
267
  ) : null,
269
- /* @__PURE__ */ n("div", { className: t.actionButton, children: a.hideSubmit ? null : /* @__PURE__ */ n(
268
+ /* @__PURE__ */ i("div", { className: t.actionButton, children: a.hideSubmit ? null : /* @__PURE__ */ i(
270
269
  ce,
271
270
  {
272
271
  type: "button",
273
272
  "data-testid": "submit-button",
274
273
  handleClick: a.onSubmit,
275
- className: i(t.inputSubmitActionButton, t.submitAction),
274
+ className: l(t.inputSubmitActionButton, t.submitAction),
276
275
  "aria-label": d.formatMessage({
277
276
  id: "input.text_editor.plugins.toolbar_plugin.submit_button.aria_label",
278
277
  defaultMessage: "Send message"
279
278
  }),
280
- children: /* @__PURE__ */ n(f, { name: "send", width: 20, height: 20 })
279
+ children: /* @__PURE__ */ i(f, { name: "send", width: 20, height: 20 })
281
280
  }
282
281
  ) })
283
282
  ]
@@ -285,5 +284,5 @@ const we = (a) => {
285
284
  );
286
285
  };
287
286
  export {
288
- we as ToolbarPlugin
287
+ Ce as ToolbarPlugin
289
288
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.51",
3
+ "version": "0.4.53",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",