0
votes

Given I have disabled toolbar and created my own toolbar with my own markup (with affix-like functionality).

I need to recreate functionality of numbered list and bulleted list buttons of ckeditor toolbar when I click on corresponding buttons of my toolbar.

None of

editor.execCommand('numberedlist')
editor.execCommand('numberedListStyle')
editor.execCommand('bulletedlist')
editor.execCommand('bulletedListStyle')

works.

Maybe I mess with parameters and I need to pass more parameters.

What command I need to call on ckeditor to create ordered and unordered list from current selection?

UPD

When I select some text in ckeditor, open up my web inspector and enter in console:

> content_editors.ru.execCommand('bold')
  true

It works like a charm, text become bold, but no luck with numberedlist or bulletedlist:

> content_editors.ru.execCommand('numberedlist')
  false
> content_editors.ru.execCommand('bulletedlist')
  false

Lists were working until I disabled toolbar plugin in config.js:

config.removePlugins = 'toolbar'
config.allowedContent = 'p h3 h4 h5 h6 strong em u; a[!href]; img[!src]'

UPD2

So diving in what I done for the sake of disabling toolbar.. I haven't allowed ul and ol tags!

So simple

// config.allowedContent = 'p h3 h4 h5 h6 strong em u; a[!href]; img[!src]'
config.allowedContent = 'p h3 h4 h5 h6 strong em u; a[!href]; img[!src]; ul ol;'

did the trick!

1

1 Answers

2
votes

You need to call:

editor.execCommand( 'numberedlist' );
editor.execCommand( 'bulletedlist' );

ofc editor must be a valid ckeditor instance object. You can fetch instance from CKEDITOR.instances.

I.e. for http://ckeditor.com/demo you have to execute following call:

CKEDITOR.instances.editor1.execCommand( 'numberedlist' );