Jump to content

Custom CK Editor toolbar button


a-ok
 Share

Recommended Posts

I've had a bit of a look around but cannot find anything but is it possible to create your own CK Editor toolbar button and custom behaviour? I am wanting to use 'annotations' in the text field so if the user highlights a piece of text, then clicks a CK Editor toolbar custom button, it links the piece of text to an annotation (either create the annotation there and then (title, media, summary, source title and source url) OR select a repeater row from a separate 'Annotations' field further down the CMS editing page) – any thoughts or suggestions?

Link to comment
Share on other sites

Another question would be... is it possible to edit the 'wire/modules/Inputfield/InputfieldCKEditor/plugins/pwlink/plugin.js' file within '/site/templates/' as an extension so updates don't override any added/adapted code?

Link to comment
Share on other sites

You can certainly create your own plugin and toolbar button for CKEditor. PW doesn't get in the way of that, but it's something that you would learn about in the CKEditor docs rather than the PW docs.

You can place your plugin in /site/modules/InputfieldCKEditor/plugins/ and then select it for CKEditor fields in the field settings on the Input tab. Or if you want to include your CKEditor plugin in a PW module you could have a look at how HannaCodeHelper does it.

You will need to include the name of the toolbar button in the CKEditor Toolbar section of the field settings.

2 hours ago, oma said:

Another question would be... is it possible to edit the 'wire/modules/Inputfield/InputfieldCKEditor/plugins/pwlink/plugin.js' file within '/site/templates/' as an extension so updates don't override any added/adapted code?

Copy /wire/modules/Inputfield/InputfieldCKEditor/plugins/pwlink/ to /site/modules/InputfieldCKEditor/plugins/pwlink/ and make your changes there.

Link to comment
Share on other sites

That's great @Robin S – so copying files to the same directory under /site/ allows for custom overwriting... this is great.

Thanks for the other info too. I have managed to manipulate /wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module so should do the same for that too I guess! I realise it gets a little dodgy doing things like this but won't be updating the version once it's live.

Link to comment
Share on other sites

4 minutes ago, oma said:

I have managed to manipulate /wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module so should do the same for that too I guess! I realise it gets a little dodgy doing things like this but won't be updating the version once it's live.

As a general rule, you can copy any PW module from /wire/modules/ to /site/modules/ if you want to customise it.

When you do a Modules > Refresh you will see a notice...

Session: Module "SomeModule" has multiple files (bold file is the one in use). Click here to change which file is used

...and you can enter the module settings to switch between the version in /wire/ and the version in /site/.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Robin S said:

As a general rule, you can copy any PW module from /wire/modules/ to /site/modules/ if you want to customise it.

When you do a Modules > Refresh you will see a notice...


Session: Module "SomeModule" has multiple files (bold file is the one in use). Click here to change which file is used

...and you can enter the module settings to switch between the version in /wire/ and the version in /site/.

Thanks @Robin S this makes sense. One thing I noticed though, specifically with copying and using ProcessPageEditLink.module is that it didn't create the tab 'Attributes' but rather stuck the Attributes content (when editing a link in the modal) at the bottom. As soon as I switched it to the /wire/ version it worked. So I copied that whole file, as it is, into /site/ and it did the same thing. Weird.

Link to comment
Share on other sites

1 hour ago, oma said:

One thing I noticed though, specifically with copying and using ProcessPageEditLink.module is that it didn't create the tab 'Attributes' but rather stuck the Attributes content (when editing a link in the modal) at the bottom. As soon as I switched it to the /wire/ version it worked. So I copied that whole file, as it is, into /site/ and it did the same thing. Weird.

Must be something wrong with your modified version. It works as expected for me:

2017-01-17_143840.png

Link to comment
Share on other sites

10 hours ago, Robin S said:

Must be something wrong with your modified version. It works as expected for me:

2017-01-17_143840.png

Ah maaan. It's just weird that if I copy the original into /sites/ and use that it doesn't work (so it's not modified... just in a different location).

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...