123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /* eslint-disable */
- UE.registerUI('chineselattice', function(editor, uiname){
- // var uiname = 'toMathType';
- // console.log(editor,text);
- let toMathType = {
- type:0,
- text:''
- }
- sessionStorage.toMathType = JSON.stringify(toMathType);
- // 创建dialog
- var ChineseLatticeDialog = new UE.ui.Dialog({
- // 指定弹出层路径
- iframeUrl: editor.options.UEDITOR_HOME_URL + 'chinese-lattice/chineseLatticeDialog.html',
- // 编辑器实例
- editor: editor,
- // dialog 名称
- name: uiname,
- // dialog 标题
- title: '插入作文格子',
- // dialog 外围 css
- cssRules: 'width:430px; height: 188px;',
- //如果给出了buttons就代表dialog有确定和取消
- buttons:[
- {
- className:'edui-okbutton',
- label:'确定',
- onclick:function () {
- ChineseLatticeDialog.close(true);
- }
- },
- {
- className:'edui-cancelbutton',
- label:'取消',
- onclick:function () {
- ChineseLatticeDialog.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 + 'chinese-lattice/chinese-lattice-icon.png';
- var tmpLink = document.createElement('a');
- tmpLink.href = iconUrl;
- tmpLink.href = tmpLink.href;
- iconUrl = tmpLink.href;
- var ChineseLatticeBtn = new UE.ui.Button({
- name:uiname,
- title:'插入作文格子-' + uiname,
- //需要添加的额外样式,指定icon图标
- cssRules :'background: url("' + iconUrl + '") !important',
- onclick:function () {
- //渲染dialog
- ChineseLatticeDialog.render();
- ChineseLatticeDialog.open();
- sessionStorage.toMathType = JSON.stringify(toMathType);
- }
- });
- //当点到编辑内容上时,按钮要做的状态反射
- editor.addListener('selectionchange', function () {
- var state = editor.queryCommandState(uiname);
- if (state == -1) {
- ChineseLatticeBtn.setDisabled(true);
- ChineseLatticeBtn.setChecked(false);
- } else {
- ChineseLatticeBtn.setDisabled(false);
- ChineseLatticeBtn.setChecked(state);
- }
- });
- return ChineseLatticeBtn;
- });
|