@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
|
|
2
|
-
import { IS_IOS as
|
|
3
|
-
import { useRef as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
|
|
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
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33
|
+
A as IOSInsertParagraphFallbackPlugin
|
|
49
34
|
};
|