-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.tsx
59 lines (52 loc) · 1.86 KB
/
plugin.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use client';
import { PluginComponent } from "@payloadcms/richtext-lexical";
import { COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, FOCUS_COMMAND } from "@payloadcms/richtext-lexical/lexical";
import { useLexicalComposerContext } from "@payloadcms/richtext-lexical/lexical/react/LexicalComposerContext";
import { useEffect } from "react";
export const FocusPlugin: PluginComponent<any> = () => {
const [editor] = useLexicalComposerContext()
useEffect(() => {
editor.registerCommand(
FOCUS_COMMAND,
() => {
console.log('FOCUS_COMMAND with COMMAND_PRIORITY_EDITOR is triggered')
return false;
},
COMMAND_PRIORITY_EDITOR,
);
editor.registerCommand(
FOCUS_COMMAND,
() => {
console.log('FOCUS_COMMAND with COMMAND_PRIORITY_LOW is triggered')
return false;
},
COMMAND_PRIORITY_LOW,
);
editor.registerCommand(
FOCUS_COMMAND,
() => {
console.log('FOCUS_COMMAND with COMMAND_PRIORITY_NORMAL is triggered')
return false;
},
COMMAND_PRIORITY_NORMAL,
);
editor.registerCommand(
FOCUS_COMMAND,
() => {
console.log('FOCUS_COMMAND with COMMAND_PRIORITY_HIGH is triggered')
return false;
},
COMMAND_PRIORITY_HIGH,
);
editor.registerCommand(
FOCUS_COMMAND,
() => {
console.log('FOCUS_COMMAND with COMMAND_PRIORITY_CRITICAL is triggered')
return false;
},
COMMAND_PRIORITY_CRITICAL,
);
}, [editor]);
return null
}
export default FocusPlugin