medium-editor-insert-plugin
medium-editor-insert-plugin copied to clipboard
pressing backspace in an empty editor causes weird behavior

When the editor is empty, if you press backspace, the p tag with medium-insert-active class keeps popping up. Obviously it always has to be there along with the medium-insert-buttons for the plugin to work, but is there a way to make it not behave like this (as seen in the gif)?
It has nothing to do with medium-insert-buttons, but the plugin needs text to be wrapped into paragraphs in order to work. So when you delete the only paragraph, plugin's clean() function sanitizes the content and adds a paragraph back. To avoid this we would have to disable deleting the last paragraph.
@orthes Thanks!
I experienced a similar problem when the caret was not positioned inside the new inserted p and I had to add this.moveCaret(this.$el) as seen below:
if (this.$el.html().trim() === '' || this.$el.html().trim() === '<br>') {
this.$el.html($templateCache.get('/components/angular-medium-editor/dist/templates/core-empty-line.html'));
this.moveCaret(this.$el);
}