I added a new button in tinymce bbcode called for a [tabs]. What I want is for you to select text and press the button, the text is inserted into the bbcode [tabs] and html text here [/ tabs].

I’ve done it, but there is a problem … when we inserted a second time and make

empty spaces and if I do several times make me more and more empty spaces.

this is the code:

(function() {
    tinymce.PluginManager.add('my_mce_button', function( editor, url ) {
        editor.addButton( 'my_mce_button', {
            text: 'Tabs',
            icon: false,
            type: 'menubutton',
            menu: [
                {
                    text: 'new',
                    onclick: function() {
                        string = tinyMCE.activeEditor.selection.getContent().replace('[tabs]', '').replace('[/tabs]', '');
                        editor.insertContent("[tabs]"+string+"[/tabs]");
                    }
                }
            ]
        });
    });
})();

I use WordPress.

Read more here: Adding content to selected paragraphs TinyMCE in wordpress without blank


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: