wdEditor.base.more.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. manager.registerUI('backcolor', function (wdeditor, name) {
  2. var btn = new EditorManager.Button({
  3. name: name,
  4. className: "icon-backColor",
  5. command: 'backcolor',
  6. wdeditor: wdeditor,
  7. cssRules: "font-weight:bold;",
  8. text: "",
  9. title: "背景色",
  10. onBtnClick: function () {
  11. console.log(this.getElement().offsetTop);
  12. // this.prop.css({"top":this.getElement().offsetTop+this.getElement().offsetHeigh
  13. // t,"left":""});
  14. var h = this
  15. .getElement()
  16. .offsetHeight;
  17. var ofs = $(this.getElement()).offset();
  18. ofs.top += h + 3;
  19. this
  20. .popup
  21. .showAt(ofs);
  22. },
  23. setColor: function (color) {
  24. $(this.getElement()).css("color", color);
  25. $(this.getElement()).css("background-color", color);
  26. },
  27. _onPickColor: function (color) {
  28. wdeditor.execCommand(this.getCommand(), color);
  29. this.setColor(color);
  30. this
  31. .popup
  32. .hide();
  33. },
  34. _onpicknocolor: function (color) {
  35. this
  36. .popup
  37. .hide();
  38. },
  39. setSelectionChange: function () {
  40. wdeditor
  41. .addListener("selectionchange", function () {
  42. var value = wdeditor.queryCommandValue(btn.getCommand());
  43. if (btn.setColor) {
  44. btn.setColor(value);
  45. }
  46. });
  47. },
  48. oninit: function () {
  49. var this_ = this;
  50. var picker = new baidu
  51. .editor
  52. .ui
  53. .ColorPicker({
  54. noColorText: wdeditor
  55. .getUeditor()
  56. .getLang("clearColor"),
  57. editor: wdeditor.getUeditor(),
  58. onpickcolor: function (t, color) {
  59. this_._onPickColor(color);
  60. },
  61. onpicknocolor: function (t, color) {
  62. this_._onPickNoColor(color);
  63. }
  64. })
  65. var popup = new baidu
  66. .editor
  67. .ui
  68. .Popup({
  69. content: picker,
  70. editor: wdeditor.getUeditor()
  71. });
  72. this.popup = popup;
  73. }
  74. });
  75. return btn;
  76. });
  77. manager.registerUI('superscript', function (wdeditor, name) {
  78. var btn = new EditorManager.CheckBox({
  79. name: name,
  80. className: "icon-superScript",
  81. text: "",
  82. title: "上标"
  83. });
  84. return btn;
  85. });
  86. manager.registerUI('subscript', function (wdeditor, name) {
  87. var btn = new EditorManager.CheckBox({
  88. name: name,
  89. className: "icon-subScript",
  90. text: "",
  91. title: "下标"
  92. });
  93. return btn;
  94. });
  95. manager.registerUI('insertCMS', function (wdeditor, name) {
  96. var btn = new EditorManager.CheckBox({
  97. name: name,
  98. className: "insideButton-CMS",
  99. text: "插入CMS",
  100. title: "插入CMS",
  101. onBtnClick: function () {
  102. this.wdeditor.execCommand('insertHtml', '<img cmsid="" src="/wd/js/ueditor/lang/zh-cn/images/cmsEdit.png" scrolling="no" frameborder="0" width="300px" height="350px"/>');
  103. }
  104. });
  105. return btn;
  106. });
  107. // manager.registerUI('map', function (wdeditor, name) {
  108. // var btn = new EditorManager.Button({
  109. // name: name,
  110. // text: "地图",
  111. // title: "地图"
  112. // });
  113. // return btn;
  114. // });
  115. manager.registerUI("imagefloat", function (wdeditor, name) {
  116. var btn = new EditorManager.RadioGroup({
  117. wdeditor: wdeditor,
  118. name: name,
  119. command: name,
  120. buttons: {
  121. imagenone: {
  122. name: 'none',
  123. className: "insideButton-inline",
  124. // command: "imagefloat",
  125. text: '顺排',
  126. title: '顺排'
  127. // ,
  128. // onBtnClick: function () {
  129. // this.wdeditor.execCommand('imagefloat', 'none');
  130. // }
  131. },
  132. imageleft: {
  133. name: 'left',
  134. className: "insideButton-imageLeft",
  135. // command: "left",
  136. text: '左环绕',
  137. title: '左环绕'
  138. // ,
  139. // onBtnClick: function () {
  140. // this.wdeditor.execCommand('imagefloat', 'left');
  141. // }
  142. },
  143. imageright: {
  144. name: 'right',
  145. className: "insideButton-imageRigh",
  146. // command: "right",
  147. text: '右环绕',
  148. title: '右环绕'
  149. // ,
  150. // onBtnClick: function () {
  151. // this.wdeditor.execCommand('imagefloat', 'right');
  152. // }
  153. },
  154. imagecenter: {
  155. name: 'center',
  156. className: "insideButton-imageCenter",
  157. // command: "center",
  158. text: '不环绕',
  159. title: '不环绕'
  160. // ,
  161. // onBtnClick: function () {
  162. // this.wdeditor.execCommand('imagefloat', 'center');
  163. // }
  164. }
  165. }
  166. });
  167. return btn;
  168. });
  169. manager.registerUI("duanluo", function (wdeditor, name) {
  170. var btn = new EditorManager.ButtonGroup({
  171. wdeditor: wdeditor,
  172. name: name,
  173. command: name,
  174. className: "insideButton-fatherDiv",
  175. cssRules: "width:160px;display:inline-block;position:relative;vertical-align:top;",
  176. buttons: {
  177. indent: {
  178. type: "button",
  179. name: "indent",
  180. cssRules: "display:inline-block;",
  181. className: "icon-indent",
  182. text: "",
  183. title: "首行缩进",
  184. label: ""
  185. },
  186. rowspacingtop: {
  187. type: "combobox",
  188. name: "rowspacingtop",
  189. className: "icon-rowSpacingTop toolbar-button",
  190. baseClassName:"",
  191. text: "",
  192. title: "段前距",
  193. cssRules: "width:28px;color:rgba(0,0,0,0);height:28px;",
  194. onSelect: function (value) {
  195. wdeditor.execCommand("rowspacing", value, "top");
  196. console.log(value)
  197. },
  198. items: [{
  199. text: 5,
  200. value: 5
  201. }, {
  202. text: 10,
  203. value: 10
  204. }, {
  205. text: 15,
  206. value: 15
  207. }, {
  208. text: 20,
  209. value: 20
  210. }, {
  211. text: 25,
  212. value: 25
  213. }
  214. ],
  215. setSelectionChange: function () {
  216. var this_ = this;
  217. wdeditor.addListener("selectionchange", function () {
  218. var value = this_.wdeditor.getUeditor().queryCommandValue("rowspacing", "top");
  219. this_.selectValue(value);
  220. this_.menu.hide();
  221. });
  222. }
  223. },
  224. rowspacingbottom: {
  225. type: "combobox",
  226. name: "rowspacingbottom",
  227. className: "icon-rowSpacingBottom toolbar-button",
  228. baseClassName:"",
  229. text: "",
  230. title: "段后距",
  231. label: "",
  232. cssRules: "width:28px;color:rgba(0,0,0,0);height:28px;",
  233. onSelect: function (value) {
  234. wdeditor.execCommand("rowspacing", value, "bottom");
  235. },
  236. items: [{
  237. text: 5,
  238. value: 5
  239. }, {
  240. text: 10,
  241. value: 10
  242. }, {
  243. text: 15,
  244. value: 15
  245. }, {
  246. text: 20,
  247. value: 20
  248. }, {
  249. text: 25,
  250. value: 25
  251. }
  252. ],
  253. setSelectionChange: function () {
  254. var this_ = this;
  255. wdeditor.addListener("selectionchange", function () {
  256. var value = this_.wdeditor.getUeditor().queryCommandValue("rowspacing", "bottom");
  257. this_.selectValue(value);
  258. this_.menu.hide();
  259. });
  260. }
  261. },
  262. lineheight: {
  263. type: "combobox",
  264. name: "lineheight",
  265. className: "icon-lineHeight toolbar-button",
  266. baseClassName:"",
  267. text: "",
  268. title: "行间距",
  269. label: "",
  270. cssRules: "width:28px;color:rgba(0,0,0,0);height:28px;",
  271. items: [{
  272. text: 1,
  273. value: 1
  274. }, {
  275. text: 1.5,
  276. value: 1.5
  277. }, {
  278. text: 1.75,
  279. value: 1.75
  280. }, {
  281. text: 2,
  282. value: 2
  283. }, {
  284. text: 3,
  285. value: 3
  286. }, {
  287. text: 4,
  288. value: 4
  289. }, {
  290. text: 5,
  291. value: 5
  292. }
  293. ],
  294. setSelectionChange: function () {
  295. var this_ = this;
  296. wdeditor.addListener("selectionchange", function () {
  297. var value = this_.wdeditor.getUeditor().queryCommandValue("lineheight", "bottom");
  298. this_.selectValue(value);
  299. this_.menu.hide();
  300. });
  301. }
  302. }
  303. }
  304. });
  305. return btn;
  306. });
  307. manager.registerUI('insertunorderedlist', function (wdeditor, name) {
  308. var btn = new EditorManager.CheckBox({
  309. name: name,
  310. text: "项目",
  311. title: "项目"
  312. });
  313. return btn;
  314. });