@logora/debate 0.3.95 → 0.3.97

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,49 +1,34 @@
1
- import { useLexicalComposerContext as c } from "@lexical/react/LexicalComposerContext";
2
- import { IS_IOS as f, KEY_ENTER_COMMAND as l, INSERT_PARAGRAPH_COMMAND as g, COMMAND_PRIORITY_LOW as h, $getRoot as d } from "lexical";
3
- import { useRef as S, useEffect as E } from "react";
4
- const I = (t) => t.inputType === "insertParagraph" || t.inputType === "insertLineBreak", a = (t) => {
5
- let r = "";
6
- return t.read(() => {
7
- const n = d();
8
- r = `${n.getChildrenSize()}:${n.getTextContent()}`;
9
- }), r;
10
- }, T = () => {
11
- const [t] = c(), r = S(null);
12
- return E(() => {
13
- if (!f)
1
+ import { useLexicalComposerContext as u } from "@lexical/react/LexicalComposerContext";
2
+ import { IS_IOS as d, INSERT_PARAGRAPH_COMMAND as l } from "lexical";
3
+ import { useRef as f, useEffect as m } from "react";
4
+ const E = 100, p = (t) => t.key === "Enter" && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey && !t.isComposing, i = (t) => JSON.stringify(t.toJSON()), A = () => {
5
+ const [t] = u(), r = f([]);
6
+ return m(() => {
7
+ if (!d)
14
8
  return;
15
- const n = (e) => {
16
- I(e) && (r.current = e.timeStamp);
17
- }, s = t.registerRootListener(
9
+ const s = (e) => {
10
+ if (!p(e) || e.defaultPrevented)
11
+ return;
12
+ const o = i(t.getEditorState()), n = {
13
+ timeoutId: null
14
+ };
15
+ n.timeoutId = setTimeout(() => {
16
+ r.current = r.current.filter(
17
+ (c) => c !== n
18
+ ), i(t.getEditorState()) === o && t.dispatchCommand(l, void 0);
19
+ }, E), r.current.push(n);
20
+ }, a = t.registerRootListener(
18
21
  (e, o) => {
19
- o?.removeEventListener(
20
- "beforeinput",
21
- n,
22
- !0
23
- ), e?.addEventListener("beforeinput", n, !0);
22
+ o?.removeEventListener("keydown", s), e?.addEventListener("keydown", s);
24
23
  }
25
- ), i = t.registerCommand(
26
- l,
27
- (e) => {
28
- if (!e || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey)
29
- return !1;
30
- const o = a(
31
- t.getEditorState()
32
- ), u = e.timeStamp;
33
- return requestAnimationFrame(() => {
34
- const p = r.current !== null && r.current >= u, m = a(
35
- t.getEditorState()
36
- );
37
- !p && m === o && t.dispatchCommand(g, void 0);
38
- }), !1;
39
- },
40
- h
41
24
  );
42
25
  return () => {
43
- i(), s();
26
+ r.current.forEach((e) => {
27
+ clearTimeout(e.timeoutId);
28
+ }), r.current = [], a();
44
29
  };
45
30
  }, [t]), null;
46
31
  };
47
32
  export {
48
- T as IOSInsertParagraphFallbackPlugin
33
+ A as IOSInsertParagraphFallbackPlugin
49
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.95",
3
+ "version": "0.3.97",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",