135editor.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. UE.registerUI('135editor',function(editor,uiName){
  2. // var dialog = new UE.ui.Dialog({
  3. // iframeUrl: editor.options.UEDITOR_HOME_URL+'dialogs/135editor/135EditorDialogPage.html',
  4. // cssRules:"width:"+ parseInt(document.body.clientWidth*0.9) +"px;height:"+(window.innerHeight -50)+"px;",
  5. // editor:editor,
  6. // name:uiName,
  7. // title:"135编辑器"
  8. // });
  9. // dialog.fullscreen = false;
  10. // dialog.draggable = false;
  11. var editor135;
  12. function onContentFrom135(event) {
  13. if (typeof event.data !== 'string') {
  14. if(event.data.ready) {
  15. editor135.postMessage(editor.getContent(),'*');
  16. }
  17. return;
  18. };
  19. if(event.data.indexOf('<') !== 0) return;
  20. editor.setContent(event.data);
  21. editor.fireEvent("catchRemoteImage");
  22. window.removeEventListener('message', onContentFrom135);
  23. }
  24. var btn = new UE.ui.Button({
  25. name:'btn-dialog-' + uiName,
  26. className:'edui-for-135editor',
  27. title:'135编辑器',
  28. onclick:function () {
  29. // dialog.render();
  30. // dialog.open();
  31. // 由于内嵌iframe登录存在跨域问题,禁用了cookie, 使用window.open方式调用135编辑器
  32. editor135 = window.open('https://www.135editor.com/beautify_editor.html?callback=true&appkey=','135editor','height='+(window.screen.availHeight-100)+',width='+(window.screen.availWidth-100)+',top=50,left=50,help=no,resizable=no,status=no,scroll=no')
  33. window.removeEventListener('message', onContentFrom135);
  34. window.addEventListener('message', onContentFrom135, false);
  35. }
  36. });
  37. return btn;
  38. },undefined);