Estoy trabajando con slatejs, y quiero saber:
Si mi Element.type actual es title , parece <h1></h1> ,
pero cuando hago clic enter , se creará una nueva etiqueta <h1> .
Si quiero el salto de línea después del tipo de title y el nuevo tipo de elemento se convertirá en predeterminado, ¿qué debo hacer?
Suponiendo que su nodo se parezca a: {children : [{text: ''}], type: 'title'} o algo parecido a esto.
Cuando presiona enter , agrega un nodo vacío como {children: [{text: ''}], type: 'title'}
Debería poder modificar el comportamiento insertBreak de esta manera para modificar el tipo de nodo que agrega:
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() }