Opened 11 years ago
Last modified 10 years ago
#12087 confirmed Bug
Can't delete an empty line between block widgets
Reported by: | Daniele Arancia | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | UI : Widgets | Version: | 4.3 Beta |
Keywords: | Cc: |
Description (last modified by )
- Open image2 sample.
- Insert two captioned, not aligned images one after another.
- Use magicline to create a space between them.
- Try to remove this space now. It's impossible.
Original description
Hi, I tried in your "http://ckeditor.com/demo#enter" demo page, using the third CKeditor with title "Produce <div> on ENTER", to create 3 divs: the first with contenteditable="false", the second with no setting, the third with contenteditable="false".
So I put the following content as content of the ckeditor body: <div contenteditable="false">This editor produces <div> on ENTER.</div><div>This editor produces <div> on ENTER.</div><div contenteditable="false">This editor produces <div> on ENTER.</div>
The bug I found is that I can't delete the second line. If I clean the row and try pressing backspace or delete button, CKeditor will delete the first and/or the third div.
Many thanks in advance Kind regards Daniele
Change History (4)
comment:1 Changed 11 years ago by
Component: | General → UI : Widgets |
---|---|
Description: | modified (diff) |
Keywords: | contentditable false delete lines removed |
Status: | new → confirmed |
Summary: | can't delete lines between contenteditable false DIVs → Can't delete an empty line between block widgets |
Version: | 4.4.1 → 4.3 Beta |
comment:2 Changed 10 years ago by
We had no news since the bug opening. Do you plan to resolve this bug in any of the next releases? Thank you.
comment:3 Changed 10 years ago by
We don't plan to work on this ticket at the moment. We would like to improve keyboard handling around widgets, but we don't have resources to work on that now.
comment:4 Changed 10 years ago by
I ran into this problem too. I have no experience with CKEditor so for now I just made a hacky fix - listening to KEY DOWN events on the editor. Also prevents a nasty additional bug where CKEditor removes all the content if you are on the top line and have a widget in the content, and another one where if you delete the top line content and then press backspace again, it will delete everything.
handleKeyDown: function(e) { if (e.which === KeyCodes.BACKSPACE || e.which === KeyCodes.DELETE) { var range = this.editor.getSelection().getRanges()[0]; var startNode = range.startContainer; // Another fix: prevent CKEditor from deleting all content. if (startNode.$ === this.$el[0]) { e.preventDefault(); return; } // In the case of <p> </p> we need to go one further up // to the p as the startNode is an empty text node. if (startNode.type === CKEDITOR.NODE_TEXT) { startNode = startNode.getParent(); } var previousNode = startNode.getPrevious(); // Bail if the previous node is not a widget. if (previousNode && (!previousNode.$.dataset || !previousNode.$.dataset.ckeWidgetId)) { return; } // Is the child empty? Then remove it. // Note: CKEditor sometimes decides to use // http://www.fileformat.info/info/unicode/char/200b/index.htm // for extra inconsistency/complexity. var trimmedText = startNode.getText().trim(); if (!trimmedText || (trimmedText.length === 1 && trimmedText.charCodeAt(0) === 8203)) { startNode.remove(); // `preventdefault` stops CKEditor removing the ENTIRE // content if it's the top line.. e.preventDefault(); } } }
I rewrote your ticket description so it mentions widgets. Note that non-editable content inside editor is only handled in form of widgets. Raw contenteditable=false works, but it's not officially supported.