Jump to content

CKEditor add extra H1 button?


anderson
 Share

Recommended Posts

Hi,

I'm new, in every aspect.  I want to boost CKEditor a little: add some extra button H1,H2,H3.  (So, one step less than clicking "format" dropdown.)

I've seen this thread: Customise CKEditor toolbar per role

So I tried creating a /site/ready.php , inside which:

$this->addHookBefore('Field(name=my_ckeditor_field)::getInputfield', function(HookEvent $event) {
    $field = $event->object;
    // Add extra buttons for superuser only
    if($this->user->isSuperuser()) $field->toolbar .= ', Table, TextColor, h3';
});

Apparently it's wrong, backend home page doesn't load any more, other backend pages have this text before header, and "h3" button doesn't show, and "table" and "textcolor", neither.

Maybe this is a dumb question? Please help.

Link to comment
Share on other sites

2 hours ago, Autofahrn said:

Does your ready.php start with


<?php namespace ProcessWire;

And to have the H buttons you'll need some more code (maybe plugin) which can be triggered from the toolbar reference.

Edit:

https://ckeditor.com/cke4/addon/formatbuttons

Thank you very much!

I'll try to learn about CKE addon.

Now I add 

<?php namespace ProcessWire;

but why "Table, TextColor" still don't show? Did I miss something else?

Link to comment
Share on other sites

Glad you get it running. In the end its not that complicated, but the dependancies need to be understood first. I know....

And, yes, toolbar entries are case sensitive (no need for an additional line, you may place the buttons anywhere), and sometimes you'll need to read the code in plugin.js to find the string you have to put in.

Link to comment
Share on other sites

15 hours ago, Autofahrn said:

Glad you get it running. In the end its not that complicated, but the dependancies need to be understood first. I know....

And, yes, toolbar entries are case sensitive (no need for an additional line, you may place the buttons anywhere), and sometimes you'll need to read the code in plugin.js to find the string you have to put in.

Thanks again, I appreciate it!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...