| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- 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<selectOptions.length;i++){
- var so = selectOptions[i];
- items.push({
- label:so.label
- ,value:so.value
- ,renderLabelHtml:function () {
- //这个是希望每个条目的字体是不同的
- return '<div class="edui-label %%-label" style="line-height:2;font-size:' +
- this.value + 'px;">' + (this.label || '') + '</div>';
- }
- });
- }
- //创建下来框
- 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;
- }
|