Vladislav Rastrusny
Active member
Hello.
How do we add a button to the editor? I tried the same tinyMCE way as in WordPress, but the button just doesn't want to be added. I've created a hook listener for editor_js_setup like this:
But the button does not appear. What do I do wrong?
How do we add a button to the editor? I tried the same tinyMCE way as in WordPress, but the button just doesn't want to be added. I've created a hook listener for editor_js_setup like this:
PHP:
<?php
class FractalizeR_Translit_TemplateHookListener {
static function editor_js_setup($name, &$contents, array $params,
XenForo_Template_Abstract $template) {
static $done;
if ($done === true) {
return;
}
$done = true;
$contents .= <<<'EOD'
<script language="javascript">
$(
function() {
if(window.tinymce) {
// Load plugin specific language pack
tinymce.create('tinymce.plugins.XfrTranslit', {
init : function (ed, url)
{
ed.addCommand('xfrTranslit', function(ui, val)
{
alert("Done!!!");
});
// Register WPSynHighlight button
ed.addButton('xenforo_translit', {
title : 'xenforo_translit',
cmd : 'xfrTranslit',
image : url + '/img/button.gif'
});
},
addButtons : function (theme, tb)
{
var controlManager = theme.editor.controlManager;
tb.add(controlManager.createButton('xenforo_translit',
{ title: 'xenforo.translit', cmd: 'xfrTranslit', ui: false, value: 'TRANSLIT' }
));
},
getInfo : function()
{
return {
longname : 'XenForo Translit',
author : 'FractalizeR',
version : '1.0'
};
}
});
// Register plugin
tinymce.PluginManager.add('XfrTranslit', tinymce.plugins.XfrTranslit);
}
}
);
</script>
EOD;
}
}
But the button does not appear. What do I do wrong?