Opened 17 years ago

Last modified 13 years ago

#1424 confirmed New Feature

Delete / backspace next to "Control" elements should select that control, rather than deleting

Reported by: Scott McNaught Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Discussion Cc:

Description

When the cursor is placed next to (as IE puts it) a "control" element, such as an image or a table, it should select it on delete / backspace.

This improves the intuitiveness of deleting and makes sure people dont delete things accidently.

Here is a function partially implemented which does this

FCKListsLib.ControlElements = {'img':1, 'table':1, 'input':1};

// Helper function upon deleting a node that may be a control (must select it first)
// A control is something like an image or table which can be selected with the cursor
FCKEnterKey.prototype.HandleControlNodeSelect = function(pRange, bIsForward)
{
	// Check to see if we are about to delete an image or table
	// TODO: this is IE specific at the moment!
	if(FCKBrowserInfo.IsIE)
	{
		// TODO: this only works when a element is in a block
		var pStartBlock = pRange.StartBlock;

		if(pStartBlock)
		{
			var iDirection = bIsForward ? 0 : -1;
			var iOffset = pRange._Range.startOffset;
			var pPrevious = pStartBlock.childNodes[iOffset + iDirection];

			if(pPrevious && FCKListsLib.ControlElements[nodeGetTagName(pPrevious)] != null)
			{
				FCKSelection.SelectNode(pPrevious);
				return true;
			}
		}
	}
	
	return false;
}

Change History (5)

comment:1 Changed 17 years ago by Scott McNaught

When called from backspace function:

	// Select clickable controls first before deleting them	
	if(this.HandleControlNodeSelect(pRange, false))
	{
		pRange.Release();
		return true;
	}

When called from delete function

	// Select clickable controls first before deleting them	
	if(this.HandleControlNodeSelect(pRange, true))
	{
		pRange.Release();
		return true;
	}

comment:2 Changed 17 years ago by Frederico Caldeira Knabben

Keywords: Discussion added
Milestone: FCKeditor 3.0
Type: BugNew Feature

If not adding a lot of overhead to the code, I think it is a good idea. We can also make it configurable, for those guys who will (certainly) say that they prefer it the other way.

For now, targeting to the 3.0 for discussion.

comment:3 Changed 16 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 3.0CKEditor 3.x

comment:4 Changed 14 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 3.x

Milestone CKEditor 3.x deleted

comment:5 Changed 13 years ago by Jakub Ś

Status: newconfirmed
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