/* eslint-disable */ UE.registerUI('horizontalline', function(editor, uiname){ // var uiname = 'toMathType'; // console.log(editor,text); let toMathType = { type:0, text:'' } // 创建dialog var HorizontalLineDialog = new UE.ui.Dialog({ // 指定弹出层路径 iframeUrl: editor.options.UEDITOR_HOME_URL + 'horizontal-line/HorizontalLineDialog.html', // 编辑器实例 editor: editor, // dialog 名称 name: uiname, // dialog 标题 title: '插入答题横线', // dialog 外围 css cssRules: 'width:430px; height: 188px;', //如果给出了buttons就代表dialog有确定和取消 buttons:[ { className:'edui-okbutton', label:'确定', onclick:function () { HorizontalLineDialog.close(true); } }, { className:'edui-cancelbutton', label:'取消', onclick:function () { HorizontalLineDialog.close(false); } } ]}); editor.ready(function(){ UE.utils.cssRule('kfformula', 'img.kfformula{vertical-align: middle;}', editor.document); }); // var iconUrl = editor.options.UEDITOR_HOME_URL + 'kityformula-plugin/kf-icon.png'; var iconUrl =editor.options.UEDITOR_HOME_URL + 'horizontal-line/horizontal-line-icon.png'; var tmpLink = document.createElement('a'); tmpLink.href = iconUrl; tmpLink.href = tmpLink.href; iconUrl = tmpLink.href; var HorizontalLineBtn = new UE.ui.Button({ name:'插入' + uiname, title:'插入答题横线-' + uiname, //需要添加的额外样式,指定icon图标 cssRules :'background: url("' + iconUrl + '") !important', onclick:function () { //渲染dialog HorizontalLineDialog.render(); HorizontalLineDialog.open(); } }); //当点到编辑内容上时,按钮要做的状态反射 editor.addListener('selectionchange', function () { var state = editor.queryCommandState(uiname); if (state == -1) { HorizontalLineBtn.setDisabled(true); HorizontalLineBtn.setChecked(false); } else { HorizontalLineBtn.setDisabled(false); HorizontalLineBtn.setChecked(state); } }); return HorizontalLineBtn; });