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

Bold button gets unchecked on enter click when bullet button is also selected in WP Editor

programmeradmin2浏览0评论

I am using wp_edior.

Here is the scenario :

  1. Click bold, italic, bullets and write 1 line.
  2. Now press enter

Bold and italic buttons gets unchecked.

I tried below solution but it did not work for me.

add_filter( 'tiny_mce_before_init', 'wpse24113_tiny_mce_before_init' );
function wpse24113_tiny_mce_before_init( $initArray )
{
    $initArray['setup'] = <<<JS
[function(ed) {
    ed.onKeyDown.add(function(ed, e) {
        //your function goes here
        console.log('Key down event: ' + e.keyCode);
        if($(".mce-container.mce-btn-group .mce-btn:nth-child(2)").hasClass("mce-active") && (e.keyCode == 13)){
            console.log("active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(2)").addClass("mce-active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(2)").attr("aria-pressed","true");
        }
        if($(".mce-container.mce-btn-group .mce-btn:nth-child(3)").hasClass("mce-active") && (e.keyCode == 13)){
            console.log("active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(3)").addClass("mce-active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(3)").attr("aria-pressed","true");
        }
        if($(".mce-container.mce-btn-group .mce-btn:nth-child(4)").hasClass("mce-active") && (e.keyCode == 13)){
            console.log("active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(4)").addClass("mce-active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(4)").attr("aria-pressed","true");
        }
        if($(".mce-container.mce-btn-group .mce-btn:nth-child(5)").hasClass("mce-active") && (e.keyCode == 13)){
            console.log("active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(5)").addClass("mce-active");
            $(".mce-container.mce-btn-group .mce-btn:nth-child(5)").attr("aria-pressed","true");
        }
    });

}][0]
JS;
    return $initArray;
}

Need a proper solution.

发布评论

评论列表(0)

  1. 暂无评论