ueditoradd.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. (function ($ang) {
  2. 'use strict';
  3. $ang.module('devself.common').directive('uiKindeditor', function ($ocLazyLoad) {
  4. return {
  5. restrict: 'EA',
  6. require: '?ngModel',
  7. link: function (scope, element, attrs, ctrl) {
  8. $ocLazyLoad.load('../../scripts/kindeditor/kindeditor-all-min.js').then(function () {
  9. var _initContent, editor;
  10. var fexUE = {
  11. initEditor: function () {
  12. editor = KindEditor.create(element[0], {
  13. width: '90%',
  14. height: '400px',
  15. resizeType: 1,
  16. langType: 'zh-CN',
  17. uploadJson: '',
  18. formatUploadUrl: false,
  19. allowImageUpload: false,
  20. allowFileManager: true,
  21. items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  22. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  23. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  24. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  25. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  26. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  27. 'anchor', 'link', 'unlink', '|', 'about'],
  28. afterChange: function () {
  29. ctrl.$setViewValue(this.html());
  30. }
  31. });
  32. },
  33. setContent: function (content) {
  34. if (editor) {
  35. editor.html(content);
  36. }
  37. }
  38. }
  39. if (!ctrl) {
  40. return;
  41. }
  42. _initContent = ctrl.$viewValue;
  43. ctrl.$render = function () {
  44. _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
  45. fexUE.setContent(_initContent);
  46. };
  47. fexUE.initEditor();
  48. });
  49. }
  50. }
  51. }).directive('uiUeditor', ["$ocLazyLoad", "$compile", function ($ocLazyLoad, $compile) {
  52. return {
  53. restrict: 'EA',
  54. require: '?ngModel',
  55. link: function (scope, element, attrs, ctrl) {
  56. //Ueditor富文本框先存代码,以后可能使用
  57. //$ocLazyLoad.load(['../Areas/AdminManage/Content/Vendor/jquery/ueditor/ueditor.config.js',
  58. //'../Areas/AdminManage/Content/Vendor/jquery/ueditor/ueditor.all.js']).then(function () {
  59. // var _self = this,
  60. // _initContent,
  61. // editor,
  62. // editorReady = false
  63. // var fexUE = {
  64. // initEditor: function () {
  65. // var _self = this;
  66. // if (typeof UE != 'undefined') {
  67. // editor = new UE.ui.Editor({
  68. // initialContent: _initContent,
  69. // autoHeightEnabled: false,
  70. // autoFloatEnabled: false
  71. // });
  72. // editor.render(element[0]);
  73. // editor.ready(function () {
  74. // editorReady = true;
  75. // _self.setContent(_initContent);
  76. // editor.addListener('contentChange', function () {
  77. // scope.$apply(function () {
  78. // ctrl.$setViewValue(editor.getContent());
  79. // });
  80. // });
  81. // });
  82. // }
  83. // },
  84. // setContent: function (content) {
  85. // if (editor && editorReady) {
  86. // editor.setContent(content);
  87. // }
  88. // }
  89. // };
  90. // if (!ctrl) {
  91. // return;
  92. // }
  93. // _initContent = ctrl.$viewValue;
  94. // ctrl.$render = function () {
  95. // _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
  96. // fexUE.setContent(_initContent);
  97. // };
  98. // fexUE.initEditor();
  99. //});
  100. }
  101. };
  102. }]);
  103. })(angular);