最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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);
发布评论

评论列表(0)

  1. 暂无评论