var _min_toolbars=[ [ 'undo', 'redo' ,'|', 'indent',"bold","italic","underline", 'strikethrough' ,"|","insertorderedlist","insertunorderedlist" ,'|','paragraph','fontfamily','fontsize', 'justifyleft', 'justifycenter','justifyright', 'justifyjustify' ,"|",'removeformat','forecolor','backcolor' ,'|','date','time',"fullscreen" ,'|','insertimage' ] ] var empty_toolbars=[]; function _addCustomButton() { UE.registerUI('插入变量',function(editor,uiName){ //注册按钮执行时的command命令,用uiName作为command名字,使用命令默认就会带有回退操作 editor.registerCommand(uiName,{ execCommand:function(cmdName,value){ this.execCommand('insertHTML',value); } }); var selectOptions = []; selectOptions.push({label:'文件编号',value:'${_文件编号}'}); selectOptions.push({label:'发送人',value:'${_发送人}'}); selectOptions.push({label:'部门',value:'${_部门}'}); selectOptions.push({label:'发送时间',value:'${_发送时间}'}); selectOptions.push({label:'自定义变量',value:'${}'}); var items = []; for(var i=0;i' + (this.label || '') + ''; } }); } //创建下来框 var combox = new UE.ui.Combox({ //需要指定当前的编辑器实例 editor:editor, //添加条目 items:items, //当选中时要做的事情 onselect:function (t, index) { //拿到选中条目的值 editor.execCommand(uiName, this.items[index].value); }, //提示 title:uiName, //当编辑器没有焦点时,combox默认显示的内容 initValue:uiName }); return combox; }); } function checkVar(value){ var $findRegExp = /\${([^\$}]*?)}/gm; var result; while(result=$findRegExp.exec(value)){ var variableName = result[1]; if(variableName==''){ return "请填写变量名" } if(variableName.length>20){ return "请确认变量表达式填写正确" } } return true; }