XF 2.0 Add new buttons and JS functionality to the editor

Dannymh

Active member
Hi,

I am trying to update my giphy plugin to work with 2.0 but I can't see how to extend the button functionality. I can add Bbcode but this ends up with PHP callback rather than simply executing the JS I need it to execute.

Looking at how the smilies is implemented it looks like a lot of the callback to create the button and trigger the events are hard coded into editor.js so I can not see a way to edit and extend this via a plugin or directly editing that code.

Any help would be appreciated

Dan
 
You can see how XFMG replaces the functionality of the custom BB code button it adds: https://xenforo.com/community/js/xfmg/editor.js

There are various events you can listen to in the main editor.js file to trigger your functionality as well.


This helped massively, I am essentially going to use something similar to the smilies functionality. Just wondering if I can pass language phrases direct to the editor or whether this is now completed at the template level?

Assume template from what i can see
 
If it's like smilies, you'd do that in the template you're loading. You can pass phrases into the editor -- see the editor template.
 
If it's like smilies, you'd do that in the template you're loading. You can pass phrases into the editor -- see the editor template.
thank you, i'll give it a go. today. Have a long flight back to Australia coming up so may leave it for that flight though
 
One other thing I am struggling with is how I transfer options from admin >> options to javascript. In 1.5 we did that through page_container_js_body and adding it to the options set there for JQuery extension. I just cant find the equiv here.

From what I can see I should be able to add it to
helper_js_global

However I can't get it to read the setting at all. Assume this is the correct place to add the change but struggling with the formatting
 
Last edited:
One other thing I am struggling with is how I transfer options from admin >> options to javascript. In 1.5 we did that through page_container_js_body and adding it to the options set there for JQuery extension. I just cant find the equiv here.

From what I can see I should be able to add it to
helper_js_global

However I can't get it to read the setting at all. Assume this is the correct place to add the change but struggling with the formatting


Cancel that just poked around and figured it out.

For anyone else reading this now here is the detail.

Under helper_js_global you can append your option to

Code:
jQuery.extend(true, XF.config, {

format is

Code:
myoption: '{{ $xf.options.myoptionID }}',

you can then use the var myoption as variable in JS as follows

Code:
alert(XF.config.myoption);
 
Top Bottom