0
votes

When I need to edit existing text stored in the database, some buttons on the CKeditor toolbar are pressed as they already have some styles.

For instance, if I have the following text in my database:

<strong>asdf</strong>

when I edit this text, the "bold" button is pressed.

I need to set bulletedlist clicked as the default setting of my editor. I listen to the instanceReady event and use execCommand('bulletedlist') when the event is on to achieve my goal:

CKEDITOR.on( 'instanceReady',function(ev) {
  ev.editor.execCommand( 'bulletedlist' );
} );

however, if the text is already bulleted, calling execCommand('bulletedlist') will cancel the bulleted style. I need to know which buttons are pressed when users start editing the text, so I can prevent canceling the default style. How can I achieve this?

1
what is the your use case and what are you expecting to gather from the events?charlietfl
@charlietfl, I've updated the question, please take a look at it, thanks :)Brian

1 Answers

1
votes

To query command state you need to use:

editor.getCommand( 'bulletedlist' ).state;

It will return one of: