/**
 * Created by JetBrains WebStorm.
 * User: taoqili
 * Date: 11-9-7
 * Time: 下午8:18
 * To change this template use File | Settings | File Templates.
 */
baidu.editor.commands["wordcount"]={
    queryCommandValue:function(){
        var open = this.options.wordCount,
             max= this.options.maximumWords,
             msg = this.options.messages.wordCountMsg,
            errMsg=this.options.messages.wordOverFlowMsg;

        if(!open) return "";
        var reg = new RegExp("[\r\t\n]","g");
        var contentText = this.getContentTxt().replace(reg,""),
            length = contentText.length;
        if(max-length<0){
            return "<span style='color:red;direction: none'>"+errMsg+"</span> "
        }
        msg = msg.replace("{#leave}",max-length >= 0 ? max-length:0);
        msg = msg.replace("{#count}",length);

        return msg;
    }
};