Opened 10 years ago

Last modified 8 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 Piotrek Koszuliński)

  1. Open image2 sample.
  2. Insert two captioned, not aligned images one after another.
  3. Use magicline to create a space between them.
  4. Try to remove this space now. It's impossible.

Original description

Hi, I tried in your "" 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 &lt;div&gt; on ENTER.</div><div>This editor produces &lt;div&gt; on ENTER.</div><div contenteditable="false">This editor produces &lt;div&gt; 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 10 years ago by Piotrek Koszuliński

Component: GeneralUI : Widgets
Description: modified (diff)
Keywords: contentditable false delete lines removed
Status: newconfirmed
Summary: can't delete lines between contenteditable false DIVsCan't delete an empty line between block widgets
Version: Beta

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.

comment:2 Changed 9 years ago by Daniele Arancia

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 9 years ago by Piotrek Koszuliński

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 8 years ago by ferahl

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]) {

		// In the case of <p>&nbsp;</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)) {

		// Is the child empty? Then remove it.
		// Note: CKEditor sometimes decides to use 
		// for extra inconsistency/complexity.
		var trimmedText = startNode.getText().trim();
		if (!trimmedText ||
			(trimmedText.length === 1 && trimmedText.charCodeAt(0) === 8203)) {

			// `preventdefault` stops CKEditor removing the ENTIRE
			// content if it's the top line..
Last edited 8 years ago by ferahl (previous) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy