简体   繁体   中英

ckeditor does not rise always onSelectionChange event

I try to get the onSelectionChange event for ckeditor.

When you select something it ckeditor rise correctly the event, but if you select something else in the same paragraph the event is not raised.

Is there a way to make creditor rise onSelectionChange event any time i select some text. ?

Any advice on solve this issue ?

Thanks

The answer is in the API documentation :

Fired when selection inside editor has been changed. Note that this event is fired only when selection's start element (container of a selecion start) changes, not on every possible selection change. Thanks to that selectionChange is fired less frequently, but on every context (the elements path holding selection's start) change.

You can observe all mouse and keyboard actions though ( JSFiddle ):

function logSelection() {
    console.log( this.getSelection() );
}

CKEDITOR.replace( 'editor', {
    on: {
        contentDom: function() {
            this.document.on( 'mouseup', logSelection, this );
            this.document.on( 'keyup', logSelection, this );
        }
    }
} );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM