toggle button in tinymce

I have this code !

(function() {
    tinymce.create("tinymce.plugins.afflpad", {
        init : function(ed, url) {
            ed.addCommand("afflpad_click", function(e) {
                ed.insertContent('<b>' + ed.selection.getContent() + '</b>');

            });
            ed.addButton("afflpad_button", {
                title : "Affiliate Link",
                cmd : "afflpad_click",
                icon : "wp_code",
                state:true,

            });

        },
        getInfo : function() {
            return {
                longname : "Affiliate links",
                author : "NAME",
                authorurl : "HOMEPAGE",
                infourl : "HOMEPAGE",
                version : tinymce.majorVersion + "." + tinymce.minorVersion
            };
        }
    });

    tinymce.PluginManager.add("afflpad", tinymce.plugins.afflpad);
})();

1.The button on first click shoud open <b> and on second click have to close </b> tag

2.How to add active class ?

3.How to detect button object ?


Source: wordpress

Leave a Reply