Exit from a custom element style in ContentEditable after press CTRL+ENTER key in React

Viewed 66

I'm trying to create a website like medium.com and I have a page that I can create a new post with tools (bold,italic,insert image,add quote,add code) and I create styles for these elements like the below image created for quote text.

enter image description here

when I press the Enter key this block expands correctly. and I want to exit this block when pressing CTRL + ENTER. I wrote this code to handle it.

if (e.ctrlKey && (e.keyCode == 13 || e.keyCode == 10)) {
    document.execCommand('insertParagraph');
    e.preventDefault()

}

but when I press CTRL+KEY the last style doesn't destroy. and new line created with the last quote style. actually create new blockquote tag in the new line.

enter image description here

How can I fix it? thanks

0 Answers
Related