ckeditor / ckeditor4

The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
https://ckeditor.com/ckeditor-4
Other
5.79k stars 2.48k forks source link

Create event which gets fired with every actual selection change #3320

Open jswiderski opened 5 years ago

jswiderski commented 5 years ago

Type of report

Feature request

Provide description of the new feature

We have got an interesting question from one of editor users:

Could you tell me - if there is an option in Сkeditor 4 that prohibits (forbids) nested (inserted) tags? Example, some text can be only bold or only italic, but not italic and bold at the same time!

The natural thing is to use selectionChange event and disable all other commands/buttons when tag like strong gets detected.

An example of such implementation can be found here: example.zip. The problem with selectionChange event is that it doesn't get fired when start element doesn't change what makes this event useless for such selection-aware use case (please see attached screen-cast - not-working.zip).

Perhaps a different event could be introduced or the selectionChange event could be modified to check also the end element, perhaps start/end offsets/containers of a range, whether selection was perilously collapsed and now is non-collapsed etc.

Comandeer commented 5 years ago

There is selectioncheck, however it is fired before selectionChange and due to the fact how we use selectionChange in the editor, it's pretty useless at its current form.

selectionChange behaviour was introduced to increase performance, however it is really limiting for certain use-cases 😞