editor.ftl 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <#--简易编辑器-->
  2. <#--name:输入框名称-->
  3. <#--width\height:编辑器的宽度高度-->
  4. <#--content:初始化内容-->
  5. <#macro editor name label="" content="" validation="" width="100%" height="480" labelStyle="" appId="" help="" helpDirection="" colSm="">
  6. <div class="form-group ms-form-group">
  7. <#include "control.ftl"/><#rt/>
  8. <div class="ms-form-control ms-from-group-input col-sm-9 has-feedback">
  9. <script type="text/plain" id="editor_${name}" name="${name}" style="width:${width}px;height:${height}px">${content?default('')}</script>
  10. <script type="text/javascript">
  11. //实例化编辑器
  12. //建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
  13. // var ue = UE.getEditor('editor_${name}');
  14. var URL = window.UEDITOR_HOME_URL || "${base}/static/plugins/ueditor/1.4.3.1/";
  15. var ue = UE.getEditor('editor_${name}', {
  16. imageScaleEnabled :true,
  17. // 服务器统一请求接口路径
  18. serverUrl: URL + "jsp/msController.jsp?jsonConfig=%7BvideoUrlPrefix:'${base}',fileUrlPrefix:'${base}',imageUrlPrefix:'${base}',imagePathFormat:'/upload/${appId?default(0)}/editor/%7Btime%7D',filePathFormat:'/upload/${appId?default(0)}/editor/%7Btime%7D',videoPathFormat:'/upload/${appId?default(0)}/editor/%7Btime%7D'%7D",
  19. autoHeightEnabled: true,
  20. autoFloatEnabled: false,
  21. scaleEnabled: true,
  22. compressSide:0,
  23. maxImageSideLength:2000,
  24. maximumWords: 80000,
  25. });
  26. //重新设置编辑器的style
  27. ue.ready(function () {
  28. $(".edui-editor-bottomContainer").height(30);
  29. });
  30. </script>
  31. </div>
  32. </div>
  33. </#macro>
  34. <#--简易编辑器-->
  35. <#--inputName:输入框名称-->
  36. <#--width\height:编辑器的宽度高度-->
  37. <#--content:初始化内容-->
  38. <#macro smallUedit inputName width height content>
  39. <script type="text/plain" id="editor_${inputName}" name="${inputName}">${content?default('')}</script>
  40. <div class="editor-bottom-bar">
  41. 当前已输入
  42. <span class="char_count">
  43. 0
  44. </span>
  45. 个字符, 您还可以输入
  46. <span class="char_remain">
  47. 80000
  48. </span>
  49. 个字符。
  50. </div>
  51. <style>
  52. .editor-bottom-bar {
  53. white-space: nowrap;
  54. border: 1px solid #ccc;
  55. line-height: 20px;
  56. font-size: 12px;
  57. text-align: right;
  58. margin-right: 5px;
  59. color: #aaa;
  60. border-top: 0;
  61. width: ${width}px;
  62. }
  63. </style>
  64. <script type="text/javascript">
  65. var charLimit = 80000;
  66. window.editor_${inputName} = new UE.ui.Editor({
  67. initialFrameWidth : ${width},
  68. initialFrameHeight : ${height}
  69. });
  70. window.editor_${inputName}.render("editor_${inputName}");
  71. function computeChar() {
  72. var len = editor_${inputName}.getContent().length;
  73. if (len > charLimit) {
  74. $(".editor-bottom-bar").html("<span style='color:red;'>你输入的字符个数("
  75. + len + ")已经超出最大允许值!</span>")
  76. } else {
  77. $(".editor-bottom-bar").html("当前已输入<span class='char_count'>" + len
  78. + "</span>个字符, 您还可以输入<span class='char_remain'>"
  79. + (charLimit - len) + "</span>个字符。")
  80. }
  81. }
  82. window.editor_${inputName}.addListener("keyup", function(type, evt) {
  83. computeChar()
  84. })
  85. </script>
  86. </#macro>