zoomla
Version:
16年专业研发|中文alexa排名第一的CMS品牌-基于dotNET core、功能强大,集成站群、微信开发、小程序与ERP及OA办公系统,支持国际语言和多民族语言,世界五百强与大型门户专用高端网站内核CMS系统
79 lines (67 loc) • 2.35 kB
JavaScript
UE.registerUI('kityformula', function (editor, uiname) {//kityformula
editor.registerCommand(uiname, {
execCommand: function () {
kfDialog.open();
}
});
// 创建dialog
var kfDialog = new UE.ui.Dialog({
// 指定弹出层路径
iframeUrl: editor.options.UEDITOR_HOME_URL + 'kityformula-plugin/kityFormulaDialog.html',
// 编辑器实例
editor: editor,
// dialog 名称
name: uiname,
// dialog 标题
title: '插入公式 - KityFormula',
// dialog 外围 css
cssRules: 'width:783px; height: 386px;',
//如果给出了buttons就代表dialog有确定和取消
buttons:[
{
className:'edui-okbutton',
label:'确定',
onclick:function () {
kfDialog.close(true);
}
},
{
className:'edui-cancelbutton',
label:'取消',
onclick:function () {
kfDialog.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 tmpLink = document.createElement('a');
tmpLink.href = iconUrl;
tmpLink.href = tmpLink.href;
iconUrl = tmpLink.href;
var kfBtn = new UE.ui.Button({
name:'插入' + uiname,
title:'插入公式-' + uiname,
//需要添加的额外样式,指定icon图标
cssRules :'background: url("' + iconUrl + '") !important',
onclick:function () {
//渲染dialog
kfDialog.render();
kfDialog.open();
}
});
//当点到编辑内容上时,按钮要做的状态反射
editor.addListener('selectionchange', function () {
var state = editor.queryCommandState(uiname);
if (state == -1) {
kfBtn.setDisabled(true);
kfBtn.setChecked(false);
} else {
kfBtn.setDisabled(false);
kfBtn.setChecked(state);
}
});
return kfBtn;
});