common.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. function setUEUpload(id,url){
  2. UE.registerUI('上传图片', function(editor, uiName) {
  3. editor.registerCommand(uiName, {
  4. execCommand: function() {
  5. layer.open({
  6. type: 2,
  7. title: '图库列表',
  8. shadeClose: true,
  9. shade: 0.3,
  10. area: ['1100px', '600px'],
  11. content: url
  12. });
  13. }
  14. });
  15. var btn = new UE.ui.Button({
  16. name: uiName,
  17. title: uiName,
  18. cssRules: 'background-position: -380px 0px;',
  19. onclick: function() {
  20. editor.execCommand(uiName);
  21. }
  22. });
  23. editor.addListener('selectionchange', function() {
  24. var state = editor.queryCommandState(uiName);
  25. if (state == -1) {
  26. btn.setDisabled(true);
  27. btn.setChecked(false);
  28. } else {
  29. btn.setDisabled(false);
  30. btn.setChecked(state);
  31. }
  32. });
  33. return btn;
  34. });
  35. // return UE.getEditor('container');
  36. return UE.getEditor(id);
  37. }
  38. function upload(array){
  39. for(var i=0; i<array.length; i++){
  40. UE.getEditor("container").execCommand('inserthtml','<p><img src="'+array[i]+'"></p>', true);
  41. }
  42. layui.use("layer",function (){ layer.closeAll(); });
  43. }