addHorizontalLineDialog.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* eslint-disable */
  2. UE.registerUI('horizontalline', function(editor, uiname){
  3. // var uiname = 'toMathType';
  4. // console.log(editor,text);
  5. let toMathType = {
  6. type:0,
  7. text:''
  8. }
  9. // 创建dialog
  10. var HorizontalLineDialog = new UE.ui.Dialog({
  11. // 指定弹出层路径
  12. iframeUrl: editor.options.UEDITOR_HOME_URL + 'horizontal-line/HorizontalLineDialog.html',
  13. // 编辑器实例
  14. editor: editor,
  15. // dialog 名称
  16. name: uiname,
  17. // dialog 标题
  18. title: '插入答题横线',
  19. // dialog 外围 css
  20. cssRules: 'width:430px; height: 188px;',
  21. //如果给出了buttons就代表dialog有确定和取消
  22. buttons:[
  23. {
  24. className:'edui-okbutton',
  25. label:'确定',
  26. onclick:function () {
  27. HorizontalLineDialog.close(true);
  28. }
  29. },
  30. {
  31. className:'edui-cancelbutton',
  32. label:'取消',
  33. onclick:function () {
  34. HorizontalLineDialog.close(false);
  35. }
  36. }
  37. ]});
  38. editor.ready(function(){
  39. UE.utils.cssRule('kfformula', 'img.kfformula{vertical-align: middle;}', editor.document);
  40. });
  41. // var iconUrl = editor.options.UEDITOR_HOME_URL + 'kityformula-plugin/kf-icon.png';
  42. var iconUrl =editor.options.UEDITOR_HOME_URL + 'horizontal-line/horizontal-line-icon.png';
  43. var tmpLink = document.createElement('a');
  44. tmpLink.href = iconUrl;
  45. tmpLink.href = tmpLink.href;
  46. iconUrl = tmpLink.href;
  47. var HorizontalLineBtn = new UE.ui.Button({
  48. name:'插入' + uiname,
  49. title:'插入答题横线-' + uiname,
  50. //需要添加的额外样式,指定icon图标
  51. cssRules :'background: url("' + iconUrl + '") !important',
  52. onclick:function () {
  53. //渲染dialog
  54. HorizontalLineDialog.render();
  55. HorizontalLineDialog.open();
  56. }
  57. });
  58. //当点到编辑内容上时,按钮要做的状态反射
  59. editor.addListener('selectionchange', function () {
  60. var state = editor.queryCommandState(uiname);
  61. if (state == -1) {
  62. HorizontalLineBtn.setDisabled(true);
  63. HorizontalLineBtn.setChecked(false);
  64. } else {
  65. HorizontalLineBtn.setDisabled(false);
  66. HorizontalLineBtn.setChecked(state);
  67. }
  68. });
  69. return HorizontalLineBtn;
  70. });