Assuming your node looks something like: {children : [{text: ''}], type: 'title'}
or something on the lines of this.
When you press enter
, it adds an empty node like {children : [{text: ''}], type: 'title'}
You should be able to modify the insertBreak
behaviour this way to modify the kind of node that it adds:
const { insertBreak } = editor
editor.insertBreak = () => {
const { selection } = editor
if (selection) {
const [title] = Editor.nodes(editor, {
match: n =>
!Editor.isEditor(n) &&
Element.isElement(n) &&
(n.type === 'title')
})
if(title){
Transforms.insertNodes(editor, {
children: [{text: ""}],
type: 'default'
})
return
}
}
insertBreak()
}