bootstrap.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. window.UEDITOR_HOME_URL = Config.__CDN__ + "/assets/addons/ueditor/";
  2. require.config({
  3. paths: {
  4. 'ueditor.config': '../addons/ueditor/ueditor.config',
  5. 'ueditor': '../addons/ueditor/ueditor.all.min',
  6. 'ueditor.zh': '../addons/ueditor/i18n/zh-cn/zh-cn',
  7. 'zeroclipboard': '../addons/ueditor/third-party/zeroclipboard/ZeroClipboard.min',
  8. },
  9. shim: {
  10. 'ueditor': {
  11. deps: ['zeroclipboard', 'ueditor.config'],
  12. exports: 'UE',
  13. init: function (ZeroClipboard) {
  14. //导出到全局变量,供ueditor使用
  15. window.ZeroClipboard = ZeroClipboard;
  16. },
  17. },
  18. 'ueditor.zh': ['ueditor']
  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. require(['ueditor', 'ueditor.zh'], function (UE, undefined) {
  28. UE.list = [];
  29. window.UEDITOR_CONFIG['uploadService'] = function (context, editor) {
  30. return {
  31. Upload: () => { return Upload },
  32. Fast: () => { return Fast },
  33. }
  34. };
  35. $(Config.ueditor.classname || '.editor', form).each(function () {
  36. var id = $(this).attr("id");
  37. var name = $(this).attr("name");
  38. $(this).removeClass('form-control');
  39. UE.list[id] = UE.getEditor(id, {
  40. allowDivTransToP: false, //阻止div自动转p标签
  41. initialFrameWidth: '100%',
  42. initialFrameHeight: 320,
  43. autoFloatEnabled: false,
  44. baiduMapAk: Config.ueditor.baiduMapAk || '', //百度地图api密钥(ak)
  45. // autoHeightEnabled: true, //自动高度
  46. zIndex: 90,
  47. xssFilterRules: false,
  48. outputXssFilter: false,
  49. inputXssFilter: false,
  50. catchRemoteImageEnable: true,
  51. imageAllowFiles: '',//允许上传的图片格式,编辑器默认[".png", ".jpg", ".jpeg", ".gif", ".bmp"]
  52. });
  53. UE.list[id].addListener("contentChange", function () {
  54. $('#' + id).val(this.getContent());
  55. $('textarea[name="' + name + '"]').val(this.getContent());
  56. })
  57. });
  58. })
  59. } catch (e) {
  60. console.log('绑定editor事件', e)
  61. }
  62. }
  63. });