bootstrap.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //ueditor.config.js,编辑器所在的目录
  2. window.UEDITOR_HOME_URL = Config.__CDN__ + "/assets/addons/ueditor/";
  3. require.config({
  4. paths: {
  5. 'ueditor.config': '../addons/ueditor/ueditor.config',
  6. 'ueditor': '../addons/ueditor/ueditor.all',
  7. 'zeroclipboard': '../addons/ueditor/third-party/zeroclipboard/ZeroClipboard',
  8. },
  9. shim: {
  10. 'ueditor': {
  11. //注意:此处的依赖顺序不能颠倒
  12. deps: ['zeroclipboard', 'ueditor.config'],
  13. exports: 'UE',
  14. init: function(ZeroClipboard) {
  15. //导出到全局变量,供ueditor使用
  16. window.ZeroClipboard = ZeroClipboard;
  17. },
  18. }
  19. }
  20. });
  21. require(['form', 'upload'], function(Form, Upload) {
  22. var _bindevent = Form.events.bindevent;
  23. Form.events.bindevent = function(form) {
  24. _bindevent.apply(this, [form]);
  25. try {
  26. //绑定editor事件
  27. if ($('.editor', form).length > 0) {
  28. require(['ueditor'], function(UE, undefined) {
  29. UE.list = [];
  30. $('.editor', form).each(function() {
  31. var id = $(this).attr("id");
  32. var name = $(this).attr("name");
  33. $(this).removeClass('layui-textarea');
  34. var simple_mode = Yzn.api.parame($(this).data('simple-mode'), false);
  35. var config = {
  36. serverUrl: Yzn.api.fixurl('/addons/ueditor/api/index'),
  37. allowDivTransToP: false, //转换p标签
  38. initialFrameWidth: '100%',
  39. initialFrameHeight: 400, //初始化编辑器高度,默认320
  40. maximumWords: 50000, //允许的最大字符数
  41. }
  42. if (simple_mode) {
  43. // 如果是精简模式,设置精简的工具栏按钮
  44. config.toolbars = [
  45. ['fullscreen', 'source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'pasteplain', '|',
  46. 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|', 'paragraph', 'fontfamily', 'fontsize', '|',
  47. 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', '|', 'simpleupload', 'insertimage', 'insertvideo',
  48. 'attachment', 'insertframe', 'pagebreak', '|', 'horizontal', 'inserttable', '|', 'preview'
  49. ]
  50. ];
  51. }
  52. UE.list[id] = UE.getEditor(id, config);
  53. UE.list[id].addListener("contentChange", function () {
  54. $('#' + id).val(this.getContent());
  55. $('textarea[name="' + name + '"]').val(this.getContent());
  56. })
  57. //打开图片管理
  58. UE.list[id].addListener("upload.online", function(e, editor, dialog) {
  59. dialog.close(false);
  60. Yzn.api.open("general.attachments/select?element_id=&multiple=true&mimetype=image/*", "选择", {
  61. callback: function(data) {
  62. var urlArr = data.url.split(/\,/);
  63. urlArr.forEach(function(item, index) {
  64. var url = Yzn.api.cdnurl(item);
  65. editor.execCommand('insertimage', {
  66. src: url
  67. });
  68. });
  69. }
  70. });
  71. });
  72. //打开附件管理
  73. UE.list[id].addListener("file.online", function(e, editor, dialog) {
  74. dialog.close(false);
  75. Yzn.api.open("general.attachments/select?element_id=&multiple=true&mimetype=application/*", "选择", {
  76. callback: function(data) {
  77. var urlArr = data.url.split(/\,/);
  78. urlArr.forEach(function(item, index) {
  79. var url = Yzn.api.cdnurl(item);
  80. editor.execCommand('insertfile', {
  81. url: url
  82. });
  83. });
  84. }
  85. });
  86. });
  87. });
  88. })
  89. }
  90. } catch (e) {}
  91. }
  92. });