TinyMCE function: Remove (earlier) added style from the editor

This is a simple code to create a function in the TinyMCE (Advanced) editor. It creates an icon in the toolbar and once

This is a simple code to create a function in the TinyMCE (Advanced) editor. It creates an icon in the toolbar and once you click it some DIV tags will be added into the editor. This works great.. But how can I undo that style (div) from the element.

This will be added to the editor, once you click on the icon:

<div class="kader well"><div class="remove_kader"></div><p> [TEXT] </p></div>

I want to create a function to remove the div elements from the (selected) text. The best way would be, when you click on the "remove_kader" DIV. See below (the blue arrow).

tinymce.create('tinymce.plugins.wpse723953_plugin', {
    init : function(ed, url) {
        ed.addCommand('wpse72395_insert_shortcode', function() {
            selected = tinyMCE.activeEditor.selection.getContent();
            if( selected ){
                content =  '<div class="kader well"><p>'+selected+'</p><div class="remove_kader"></div></div>';
            }else{
                content =  '<div class="kader well"><p></p><div class="remove_kader"></div></div>';
            }
            tinymce.execCommand('mceInsertContent', false, content);
        });
        ed.addButton('mm_kader', {title : 'Kader aanmaken', cmd : 'wpse72395_insert_shortcode', image: url + '/icon.png' });
    }
});
tinymce.PluginManager.add('mm_kader', tinymce.plugins.wpse723953_plugin);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745195445a4616064.html

相关推荐

  • TinyMCE function: Remove (earlier) added style from the editor

    This is a simple code to create a function in the TinyMCE (Advanced) editor. It creates an icon in the toolbar and once

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信