Opened 13 years ago

Last modified 8 years ago

#8690 confirmed Bug

Trim trailing whitespace when creating elements

Reported by: liam Owned by:
Priority: Normal Milestone:
Component: Core : Selection Version: 3.0
Keywords: Cc:

Description

Under Windows, if I double-click on a word, the space after the word is also selected. If I then click on a button to add an underline, bold, link, etc. that trailing space will become underlined, part of the link, etc.

Normally, links, etc. should end at the end of the word.

Proposed solution: When creating a new element from a selection, trim trailing whitespace and re-add that space on the outside of the closing tag.

I tried to write a patch, but I am not familiar enough with the code base and was unable to find that place where new elements are created.

Change History (6)

comment:1 Changed 13 years ago by Jakub Ś

Component: GeneralCore : Selection
Status: newconfirmed
Version: 3.6.23.0

It has been working that way from CKEditor 3.0.

This should be fixed as it's more user friendly approach.
Please note that even MS Word doesn't link trailing space even if selected.

comment:2 Changed 13 years ago by Alfonso Martínez de Lizarrondo

I've created a plugin that handles this problem: http://cksource.com/forums/viewtopic.php?f=18&t=24764

comment:3 Changed 8 years ago by Jakub Ś

#2015 & #14791 were marked as duplicates.

comment:4 Changed 8 years ago by Marek Lewandowski

Currently we're relying on default browser implementation. You can see that e.g. on Chrome you might do a selection that will not include tailing whitespace - you do that by doubleclick in the middle of the word and move slightly left (at least when using left-to-right language, like English).

However it's only Chrome that allows you to do that.

I agree on that the feature might help a little with text formatting, however we're not seeing too much of demand our Community just yet - therefore it's not a high priority on our radar.

But it should be fairly simple to implement with a custom plugin. I can see @alfonsoml did an implementation some time ago, however the link seems to be dead. I'll provide some hints on how to do this below:

It's all about listening to doubleclick / selection change event and shrinking the selection. This might be done with range.shrink.

And that's pretty much it.

comment:5 Changed 8 years ago by Alfonso Martínez de Lizarrondo

I thought that the plugin was available in the repository. I've uploaded it right now: http://ckeditor.com/addon/smallerselection

comment:6 Changed 8 years ago by Jakub Ś

Thank you Alfonso.

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