0

I'm trying to add the placeholder widget to my custom toolbarenter image description here- for the life of me I can't figure out how:

<script src="https://cdn.ckeditor.com/4.5.2/standard-all/ckeditor.js"></script>

It works with the default toolbar:

<textarea cols="80" id="editor1" name="editor1" rows="10">test1</textarea>

CKEDITOR.replace( 'editor1', {
  extraPlugins: 'placeholder',
  height: 50
} );

But not with a custom toolbar:

<textarea cols="80" id="editor2" name="editor2" rows="10">test2</textarea>

CKEDITOR.replace( 'editor2', {
  extraPlugins: 'placeholder',
  height: 50,
  toolbar: [{ name: 'tools',group: 'tools', items: [ 'Bold','Placeholder', 'Redo' ], groups: [ 'tools'] }]
} );

As I understand it there are 2 ways to insert a button to toolbar: 1. use name in toolbar itself (editor 2 example) 2. using editor.ui.addButton function:

editor.ui.addButton && editor.ui.addButton( 'CreatePlaceholder', {
                label: lang.toolbar,
                command: 'placeholder',
            //  toolbar: 'insert,5',
                toolbar: 'clipboard,0',
                icon: 'placeholder'
            } );

I created a fiddle to show:

  1. a default toolbar with a Placeholder button
  2. a custom toolbar that I can't add Placeholder button to

Can you please show/tell me how to add Placeholder to a custom made toolbar? Thank you

1 Answer 1

0

You have named your button 'CreatePlaceholder', so you should use this name in toolbar.

editor.ui.addButton && editor.ui.addButton( 'CreatePlaceholder', ...

CKEDITOR.replace( 'editor3', {
    ...
    toolbar: [{ name: 'tools',group: 'tools', items: [ 'Bold','CreatePlaceholder', ...

Full code: http://jsfiddle.net/nw3o4gy5/

Also take a look at CKEDITOR.ui.addButton.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.