提交 5c3a9da4 编写于 作者: C campaign

by zhanyi

上级 9a184da5
Ueditor Change List
Version 1.2.5
新增功能
. table整体重构
. table支持插入表头和标题
. table支持拷贝
. table支持任意调整宽高
. table支持任意前插后插行列
. 粘贴支持纯文本和源码模式选择
. 添加计算字数的getContentLength接口
Version 1.2.4
新增功能
. 官网新增API文档
......
......@@ -26,6 +26,12 @@
<div class="clear"></div>
<div id="btns">
<div >
当前输入的字数(包括html标签)共 : <span id="htmlcount"></span>
</div>
<div >
当前输入的字数共 : <span id="txtcount"></span>
</div>
<div >
<input type="button" value="获得整个html的内容" onclick="getAllHtml()">
<input type="button" value="获得内容" onclick="getContent()">
......@@ -54,8 +60,11 @@
<script type="text/javascript">
//实例化编辑器
var ue=UE.getEditor('editor');
var ue = UE.getEditor('editor');
ue.addListener('selectionchange',function(){
document.getElementById('htmlcount').innerHTML = this.getContentLength();
document.getElementById('txtcount').innerHTML = this.getContentLength(true);
});
function createEditor(){
enableBtn();
UE.getEditor('editor')
......
......@@ -986,6 +986,25 @@
if ( !lang )break;
}
return lang;
},
/**
* 计算编辑器当前内容的长度
* @name getLang
* @grammar editor.getLang(path) => (JSON|String) 路径根据的是lang目录下的语言文件的路径结构
* @example
* editor.getLang('contextMenu.delete') //如果当前是中文,那返回是的是删除
*/
getContentLength : function(ingoneHtml,tagNames){
var count = this.getContent().length;
if(ingoneHtml){
tagNames = (tagNames||[]).concat([ 'hr','img','iframe']);
count = this.getContentTxt().replace(/[ \t\r\n]+/g,'').length;
for(var i= 0,ci;ci=tagNames[i++];){
count += this.document.getElementsByTagName(ci).length;
}
this.fireEvent('wordCount',count);
}
return count;
}
/**
* 得到dialog实例对象
......
......@@ -14,6 +14,7 @@ UE.plugins['wordcount'] = function(){
var me = this;
me.setOpt({
wordCount:true,
wordCountIngoreHtml:true,
maximumWords:10000,
wordCountMsg: me.options.wordCountMsg||me.getLang("wordCountMsg"),
wordOverFlowMsg:me.options.wordOverFlowMsg||me.getLang("wordOverFlowMsg")
......@@ -27,20 +28,15 @@ UE.plugins['wordcount'] = function(){
}
me.commands["wordcount"]={
queryCommandValue:function(cmd,onlyCount){
var length,contentText,reg;
var length;
if(onlyCount){
reg = new RegExp("[\r\t\n]","g");
contentText = this.getContentTxt().replace(reg,"");
return contentText.length;
return this.getContentLength(this.options.wordCountIngoreHtml);
}
reg = new RegExp("[\r\t\n]","g");
contentText = this.getContentTxt().replace(reg,"");
length = contentText.length;
length = this.getContentLength(this.options.wordCountIngoreHtml);
if(max-length<0){
me.fireEvent('wordcountoverflow',length);
return errMsg;
}
return msg.replace("{#leave}",max-length >= 0 ? max-length:0).replace("{#count}",length);
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册