Skip to content

Plugins

Plugins are React components placed inside the EditorProvider, and are primarily used to register Behaviors ad-hoc in the Editor using the editor.registerBehavior(...) API:

function LogTextPlugin() {
const editor = useEditor()
useEffect(() => {
const unregisterBehavior = editor.registerBehavior({
behavior: defineBehavior({
on: 'insert.text',
actions: [
({event}) => [
{
type: 'effect',
effect: () => {
console.log(event)
},
},
],
],
}),
})
return () => {
unregisterBehavior()
}
}, [editor])
return null
}