{
attrs: {type: {default: 'condition-block'}, value: {default: {}}, id: {default: ''} },
content: 'block+',
inline: true,
group: "inline",
draggable: true,
toDOM: (node) => {
const block = document.createElement("p");
block.insertAdjacentHTML('afterbegin', `
<span>Condition block ${counter++}</span>
<button class="close-btn">X</button>
`)
block.addEventListener('mousedown', (e) => this.onClick(e));
block.classList.add('variable-block');
return block;
},
parseDOM: [{
tag: "p[data-type='condition-block']",
}]
}
}
command i use to insert new node:
const attrs = {type: 'condition-block', value: {}, id: Date.now()};
const { state, dispatch } = this.editor.view;
dispatch(state.tr.replaceSelectionWith(schema.nodes.conditionBlock.create(attrs)))
the issue is if the selection inside a block(h1…6, p) it will create the new p block inside the current selected node. how can i add the new node as ENTER typing behavior. i want the new node to be create as new paragraph.