medium-editor-insert-plugin icon indicating copy to clipboard operation
medium-editor-insert-plugin copied to clipboard

pressing backspace in an empty editor causes weird behavior

Open d0minicw0ng opened this issue 10 years ago • 3 comments

medium editor

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)?

d0minicw0ng avatar Aug 28 '15 09:08 d0minicw0ng

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.

linkesch avatar Aug 28 '15 12:08 linkesch

@orthes Thanks!

d0minicw0ng avatar Aug 28 '15 12:08 d0minicw0ng

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);
            }

iulian-cricon avatar Feb 05 '16 15:02 iulian-cricon