@logora/debate 0.4.56 → 0.4.57

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,21 +1,23 @@
1
1
  import { useLexicalComposerContext as p } from "@lexical/react/LexicalComposerContext";
2
- import c from "@rooks/use-localstorage-state";
3
- import { $addUpdateTag as m, $getRoot as i, $createParagraphNode as d } from "lexical";
4
- import { useEffect as f } from "react";
2
+ import m from "@rooks/use-localstorage-state";
3
+ import { $addUpdateTag as i, $getRoot as l, $createParagraphNode as f } from "lexical";
4
+ import { useEffect as d } from "react";
5
5
  import { useInput as u } from "../../input_provider/useInput.js";
6
- const E = ({ storageUid: o }) => {
7
- const [r] = p(), { reset: t, setReset: n } = u(), [l, g, s] = c(
8
- `TextEditor:content_${o}`,
6
+ const L = ({ storageUid: s }) => {
7
+ const [n] = p(), { reset: t, setReset: a } = u(), [g, x, c] = m(
8
+ `TextEditor:content_${s}`,
9
9
  {}
10
10
  );
11
- return f(() => {
12
- t && r.update(() => {
13
- m("skip-dom-selection");
14
- const e = i(), a = d();
15
- e.clear(), e.append(a), s(), n(!1);
11
+ return d(() => {
12
+ t && n.update(() => {
13
+ i("skip-dom-selection");
14
+ const e = l(), o = f();
15
+ e.clear(), e.append(o);
16
+ const r = o.selectStart();
17
+ r.format = 0, r.style = "", c(), a(!1);
16
18
  });
17
19
  }, [t]), null;
18
20
  };
19
21
  export {
20
- E as ResetPlugin
22
+ L as ResetPlugin
21
23
  };
@@ -1,33 +1,34 @@
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";
1
+ import { jsxs as B, jsx as i } from "react/jsx-runtime";
2
+ import { $isListNode as $, ListNode as Y, INSERT_ORDERED_LIST_COMMAND as Z, $isListItemNode as q, $createListNode as ee } from "@lexical/list";
3
3
  import { useLexicalComposerContext as te } from "@lexical/react/LexicalComposerContext";
4
- import { $isHeadingNode as oe, $createQuoteNode as q } from "@lexical/rich-text";
5
- import { $setBlocksType as K } from "@lexical/selection";
4
+ import { $isHeadingNode as oe, $createQuoteNode as K } from "@lexical/rich-text";
5
+ import { $setBlocksType as F } from "@lexical/selection";
6
6
  import { $getNearestNodeOfType as ne, mergeRegister as ie } from "@lexical/utils";
7
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";
8
+ import { $getSelection as M, $isRangeSelection as I, SELECTION_CHANGE_COMMAND as le, FORMAT_TEXT_COMMAND as ae, $createParagraphNode as U } from "lexical";
9
+ import { useRef as D, useState as N, useCallback as re, useEffect as j } 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
14
  const Ce = (r) => {
15
- const d = se(), j = 1, [a] = te(), H = x(null), [T, S] = N("paragraph"), [de, Q] = N(null), [V, L] = N(!1), [z, A] = N(!1), [G, D] = N(!1), E = r.hideSubmit && r.hideSourceAction && r.disableRichText, _ = re(() => {
15
+ const d = se(), H = 1, [a] = te(), Q = D(null), [T, C] = N("paragraph"), [de, E] = N(null), [V, k] = N(!1), [z, w] = N(!1), [G, x] = N(!1), v = r.hideSubmit && r.hideSourceAction && r.disableRichText, _ = re(() => {
16
16
  const e = M();
17
17
  if (I(e)) {
18
18
  const o = e.anchor.getNode(), s = o.getKey() === "root" ? o : o.getTopLevelElementOrThrow(), u = s.getKey();
19
19
  if (a.getElementByKey(u) !== null)
20
- if (Q(u), B(s)) {
20
+ if (E(u), $(s)) {
21
21
  const n = ne(o, Y), p = n ? n.getTag() : s.getTag();
22
- S(p);
22
+ C(p);
23
23
  } else {
24
24
  const n = oe(s) ? s.getTag() : s.getType();
25
- S(n);
25
+ C(n);
26
26
  }
27
- L(e.hasFormat("bold")), A(e.hasFormat("italic")), D(e.hasFormat("underline"));
28
- }
27
+ k(e.hasFormat("bold")), w(e.hasFormat("italic")), x(e.hasFormat("underline"));
28
+ } else
29
+ E(null), C("paragraph"), k(!1), w(!1), x(!1);
29
30
  }, [a]);
30
- U(() => ie(
31
+ j(() => ie(
31
32
  a.registerUpdateListener(({ editorState: e }) => {
32
33
  e.read(() => {
33
34
  _();
@@ -36,11 +37,11 @@ const Ce = (r) => {
36
37
  a.registerCommand(
37
38
  le,
38
39
  () => (_(), !1),
39
- j
40
+ H
40
41
  )
41
42
  ), [a, _]);
42
- const y = x(!1), c = x(null);
43
- U(() => () => {
43
+ const y = D(!1), c = D(null);
44
+ j(() => () => {
44
45
  c.current && clearTimeout(c.current);
45
46
  }, []);
46
47
  const g = (e, o) => {
@@ -53,17 +54,17 @@ const Ce = (r) => {
53
54
  return;
54
55
  }
55
56
  e();
56
- }, C = () => {
57
+ }, S = () => {
57
58
  setTimeout(() => {
58
59
  a.getEditorState().read(() => {
59
60
  _();
60
61
  });
61
62
  }, 0);
62
63
  }, b = (e) => {
63
- a.dispatchCommand(ae, e), e === "bold" ? L((o) => !o) : e === "italic" ? A((o) => !o) : e === "underline" && D((o) => !o), a.focus(() => {
64
+ a.dispatchCommand(ae, e), e === "bold" ? k((o) => !o) : e === "italic" ? w((o) => !o) : e === "underline" && x((o) => !o), a.focus(() => {
64
65
  const o = a.getRootElement();
65
66
  o && o.focus();
66
- }), C();
67
+ }), S();
67
68
  }, X = () => {
68
69
  a.update(() => {
69
70
  const e = M();
@@ -72,53 +73,53 @@ const Ce = (r) => {
72
73
  const o = e.getNodes(), s = /* @__PURE__ */ new Set();
73
74
  for (const m of o) {
74
75
  let n = m;
75
- for (; n !== null && !$(n); )
76
+ for (; n !== null && !q(n); )
76
77
  n = n.getParent();
77
- $(n) && s.add(n);
78
+ q(n) && s.add(n);
78
79
  }
79
80
  const u = Array.from(s).reverse();
80
81
  for (const m of u) {
81
82
  const n = m.getParent();
82
- if (!B(n))
83
+ if (!$(n))
83
84
  continue;
84
- const p = F(), J = m.getChildren();
85
- for (const w of J)
86
- p.append(w);
87
- const k = m.getNextSiblings();
88
- if (n.insertAfter(p), k.length > 0) {
89
- const w = k[0].getValue(), P = ee(n.getListType(), w);
90
- for (const W of k)
91
- P.append(W);
92
- p.insertAfter(P);
85
+ const p = U(), J = m.getChildren();
86
+ for (const A of J)
87
+ p.append(A);
88
+ const L = m.getNextSiblings();
89
+ if (n.insertAfter(p), L.length > 0) {
90
+ const A = L[0].getValue(), R = ee(n.getListType(), A);
91
+ for (const W of L)
92
+ R.append(W);
93
+ p.insertAfter(R);
93
94
  }
94
95
  m.remove(), n.getChildrenSize() === 0 && n.remove();
95
96
  }
96
97
  });
97
- }, v = () => {
98
- T !== "ol" ? a.dispatchCommand(Z) : X(), C();
99
98
  }, O = () => {
99
+ T !== "ol" ? a.dispatchCommand(Z) : X(), S();
100
+ }, P = () => {
100
101
  T !== "quote" ? a.update(() => {
101
102
  const e = M();
102
103
  if (I(e))
103
104
  if (e.isCollapsed()) {
104
- const s = e.anchor.getNode().getTopLevelElementOrThrow(), u = q();
105
+ const s = e.anchor.getNode().getTopLevelElementOrThrow(), u = K();
105
106
  s.insertAfter(u), u.selectEnd();
106
107
  } else
107
- K(e, () => q());
108
+ F(e, () => K());
108
109
  }) : a.update(() => {
109
110
  const e = M();
110
- I(e) && K(e, () => F());
111
- }), C();
111
+ I(e) && F(e, () => U());
112
+ }), S();
112
113
  };
113
- return E ? null : /* @__PURE__ */ R(
114
+ return v ? null : /* @__PURE__ */ B(
114
115
  "div",
115
116
  {
116
117
  className: l(t.toolbar, {
117
- [t.toolbarIsActive]: E ? !1 : r.isActive
118
+ [t.toolbarIsActive]: v ? !1 : r.isActive
118
119
  }),
119
- ref: H,
120
+ ref: Q,
120
121
  children: [
121
- r.isActive ? !r.disableRichText && /* @__PURE__ */ R(
122
+ r.isActive ? !r.disableRichText && /* @__PURE__ */ B(
122
123
  "div",
123
124
  {
124
125
  className: l(t.iconToolbar, {
@@ -199,8 +200,8 @@ const Ce = (r) => {
199
200
  /* @__PURE__ */ i(
200
201
  "button",
201
202
  {
202
- onPointerDown: (e) => g(e, () => O()),
203
- onClick: () => h(() => O()),
203
+ onPointerDown: (e) => g(e, () => P()),
204
+ onClick: () => h(() => P()),
204
205
  type: "button",
205
206
  className: l(t.toolbarItem, {
206
207
  [t.active]: T === "quote"
@@ -223,8 +224,8 @@ const Ce = (r) => {
223
224
  /* @__PURE__ */ i(
224
225
  "button",
225
226
  {
226
- onPointerDown: (e) => g(e, () => v()),
227
- onClick: () => h(() => v()),
227
+ onPointerDown: (e) => g(e, () => O()),
228
+ onClick: () => h(() => O()),
228
229
  type: "button",
229
230
  className: l(t.toolbarItem, {
230
231
  [t.active]: T === "ol"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.56",
3
+ "version": "0.4.57",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",