layedit.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /**
  2. @Name:layui.layedit 富文本编辑器
  3. @Author:贤心
  4. @License:MIT
  5. */
  6. layui.define(['layer', 'form'], function(exports){
  7. "use strict";
  8. var $ = layui.$
  9. ,layer = layui.layer
  10. ,form = layui.form
  11. ,hint = layui.hint()
  12. ,device = layui.device()
  13. ,MOD_NAME = 'layedit', THIS = 'layui-this', SHOW = 'layui-show', ABLED = 'layui-disabled'
  14. ,Edit = function(){
  15. var that = this;
  16. that.index = 0;
  17. //全局配置
  18. that.config = {
  19. //默认工具bar
  20. tool: [
  21. 'strong', 'italic', 'underline', 'del'
  22. ,'|'
  23. ,'left', 'center', 'right'
  24. ,'|'
  25. ,'link', 'unlink', 'face', 'image'
  26. ]
  27. ,hideTool: []
  28. ,height: 280 //默认高
  29. };
  30. };
  31. //全局设置
  32. Edit.prototype.set = function(options){
  33. var that = this;
  34. $.extend(true, that.config, options);
  35. return that;
  36. };
  37. //事件监听
  38. Edit.prototype.on = function(events, callback){
  39. return layui.onevent(MOD_NAME, events, callback);
  40. };
  41. //建立编辑器
  42. Edit.prototype.build = function(id, settings){
  43. settings = settings || {};
  44. var that = this
  45. ,config = that.config
  46. ,ELEM = 'layui-layedit', textArea = $('#'+id)
  47. ,name = 'LAY_layedit_'+ (++that.index)
  48. ,haveBuild = textArea.next('.'+ELEM)
  49. ,set = $.extend({}, config, settings)
  50. ,tool = function(){
  51. var node = [], hideTools = {};
  52. layui.each(set.hideTool, function(_, item){
  53. hideTools[item] = true;
  54. });
  55. layui.each(set.tool, function(_, item){
  56. if(tools[item] && !hideTools[item]){
  57. node.push(tools[item]);
  58. }
  59. });
  60. return node.join('');
  61. }()
  62. ,editor = $(['<div class="'+ ELEM +'">'
  63. ,'<div class="layui-unselect layui-layedit-tool">'+ tool +'</div>'
  64. ,'<div class="layui-layedit-iframe">'
  65. ,'<iframe id="'+ name +'" name="'+ name +'" textarea="'+ id +'" frameborder="0"></iframe>'
  66. ,'</div>'
  67. ,'</div>'].join(''))
  68. //编辑器不兼容ie8以下
  69. if(device.ie && device.ie < 8){
  70. return textArea.removeClass('layui-hide').addClass(SHOW);
  71. }
  72. haveBuild[0] && (haveBuild.remove());
  73. setIframe.call(that, editor, textArea[0], set)
  74. textArea.addClass('layui-hide').after(editor);
  75. return that.index;
  76. };
  77. //获得编辑器中内容
  78. Edit.prototype.getContent = function(index){
  79. var iframeWin = getWin(index);
  80. if(!iframeWin[0]) return;
  81. return toLower(iframeWin[0].document.body.innerHTML);
  82. };
  83. //获得编辑器中纯文本内容
  84. Edit.prototype.getText = function(index){
  85. var iframeWin = getWin(index);
  86. if(!iframeWin[0]) return;
  87. return $(iframeWin[0].document.body).text();
  88. };
  89. /**
  90. * 设置编辑器内容
  91. * @param {[type]} index 编辑器索引
  92. * @param {[type]} content 要设置的内容
  93. * @param {[type]} flag 是否追加模式
  94. */
  95. Edit.prototype.setContent = function(index, content, flag){
  96. var iframeWin = getWin(index);
  97. if(!iframeWin[0]) return;
  98. if(flag){
  99. $(iframeWin[0].document.body).append(content)
  100. }else{
  101. $(iframeWin[0].document.body).html(content)
  102. };
  103. layedit.sync(index)
  104. };
  105. //将编辑器内容同步到textarea(一般用于异步提交时)
  106. Edit.prototype.sync = function(index){
  107. var iframeWin = getWin(index);
  108. if(!iframeWin[0]) return;
  109. var textarea = $('#'+iframeWin[1].attr('textarea'));
  110. textarea.val(toLower(iframeWin[0].document.body.innerHTML));
  111. };
  112. //获取编辑器选中内容
  113. Edit.prototype.getSelection = function(index){
  114. var iframeWin = getWin(index);
  115. if(!iframeWin[0]) return;
  116. var range = Range(iframeWin[0].document);
  117. return document.selection ? range.text : range.toString();
  118. };
  119. //iframe初始化
  120. var setIframe = function(editor, textArea, set){
  121. var that = this, iframe = editor.find('iframe');
  122. iframe.css({
  123. height: set.height
  124. }).on('load', function(){
  125. var conts = iframe.contents()
  126. ,iframeWin = iframe.prop('contentWindow')
  127. ,head = conts.find('head')
  128. ,style = $(['<style>'
  129. ,'*{margin: 0; padding: 0;}'
  130. ,'body{padding: 10px; line-height: 20px; overflow-x: hidden; word-wrap: break-word; font: 14px Helvetica Neue,Helvetica,PingFang SC,Microsoft YaHei,Tahoma,Arial,sans-serif; -webkit-box-sizing: border-box !important; -moz-box-sizing: border-box !important; box-sizing: border-box !important;}'
  131. ,'a{color:#01AAED; text-decoration:none;}a:hover{color:#c00}'
  132. ,'p{margin-bottom: 10px;}'
  133. ,'img{display: inline-block; border: none; vertical-align: middle;}'
  134. ,'pre{margin: 10px 0; padding: 10px; line-height: 20px; border: 1px solid #ddd; border-left-width: 6px; background-color: #F2F2F2; color: #333; font-family: Courier New; font-size: 12px;}'
  135. ,'</style>'].join(''))
  136. ,body = conts.find('body');
  137. head.append(style);
  138. body.attr('contenteditable', 'true').css({
  139. 'min-height': set.height
  140. }).html(textArea.value||'');
  141. hotkey.apply(that, [iframeWin, iframe, textArea, set]); //快捷键处理
  142. toolActive.call(that, iframeWin, editor, set); //触发工具
  143. });
  144. }
  145. //获得iframe窗口对象
  146. ,getWin = function(index){
  147. var iframe = $('#LAY_layedit_'+ index)
  148. ,iframeWin = iframe.prop('contentWindow');
  149. return [iframeWin, iframe];
  150. }
  151. //IE8下将标签处理成小写
  152. ,toLower = function(html){
  153. if(device.ie == 8){
  154. html = html.replace(/<.+>/g, function(str){
  155. return str.toLowerCase();
  156. });
  157. }
  158. return html;
  159. }
  160. //快捷键处理
  161. ,hotkey = function(iframeWin, iframe, textArea, set){
  162. var iframeDOM = iframeWin.document, body = $(iframeDOM.body);
  163. body.on('keydown', function(e){
  164. var keycode = e.keyCode;
  165. //处理回车
  166. if(keycode === 13){
  167. var range = Range(iframeDOM);
  168. var container = getContainer(range)
  169. ,parentNode = container.parentNode;
  170. if(parentNode.tagName.toLowerCase() === 'pre'){
  171. if(e.shiftKey) return
  172. layer.msg('请暂时用shift+enter');
  173. return false;
  174. }
  175. iframeDOM.execCommand('formatBlock', false, '<p>');
  176. }
  177. });
  178. //给textarea同步内容
  179. $(textArea).parents('form').on('submit', function(){
  180. var html = body.html();
  181. //IE8下将标签处理成小写
  182. if(device.ie == 8){
  183. html = html.replace(/<.+>/g, function(str){
  184. return str.toLowerCase();
  185. });
  186. }
  187. textArea.value = html;
  188. });
  189. //处理粘贴
  190. body.on('paste', function(e){
  191. iframeDOM.execCommand('formatBlock', false, '<p>');
  192. setTimeout(function(){
  193. filter.call(iframeWin, body);
  194. textArea.value = body.html();
  195. }, 100);
  196. });
  197. }
  198. //标签过滤
  199. ,filter = function(body){
  200. var iframeWin = this
  201. ,iframeDOM = iframeWin.document;
  202. //清除影响版面的css属性
  203. body.find('*[style]').each(function(){
  204. var textAlign = this.style.textAlign;
  205. this.removeAttribute('style');
  206. $(this).css({
  207. 'text-align': textAlign || ''
  208. })
  209. });
  210. //修饰表格
  211. body.find('table').addClass('layui-table');
  212. //移除不安全的标签
  213. body.find('script,link').remove();
  214. }
  215. //Range对象兼容性处理
  216. ,Range = function(iframeDOM){
  217. return iframeDOM.selection
  218. ? iframeDOM.selection.createRange()
  219. : iframeDOM.getSelection().getRangeAt(0);
  220. }
  221. //当前Range对象的endContainer兼容性处理
  222. ,getContainer = function(range){
  223. return range.endContainer || range.parentElement().childNodes[0]
  224. }
  225. //在选区插入内联元素
  226. ,insertInline = function(tagName, attr, range){
  227. var iframeDOM = this.document
  228. ,elem = document.createElement(tagName)
  229. for(var key in attr){
  230. elem.setAttribute(key, attr[key]);
  231. }
  232. elem.removeAttribute('text');
  233. if(iframeDOM.selection){ //IE
  234. var text = range.text || attr.text;
  235. if(tagName === 'a' && !text) return;
  236. if(text){
  237. elem.innerHTML = text;
  238. }
  239. range.pasteHTML($(elem).prop('outerHTML'));
  240. range.select();
  241. } else { //非IE
  242. var text = range.toString() || attr.text;
  243. if(tagName === 'a' && !text) return;
  244. if(text){
  245. elem.innerHTML = text;
  246. }
  247. range.deleteContents();
  248. range.insertNode(elem);
  249. }
  250. }
  251. //工具选中
  252. ,toolCheck = function(tools, othis){
  253. var iframeDOM = this.document
  254. ,CHECK = 'layedit-tool-active'
  255. ,container = getContainer(Range(iframeDOM))
  256. ,item = function(type){
  257. return tools.find('.layedit-tool-'+type)
  258. }
  259. if(othis){
  260. othis[othis.hasClass(CHECK) ? 'removeClass' : 'addClass'](CHECK);
  261. }
  262. tools.find('>i').removeClass(CHECK);
  263. item('unlink').addClass(ABLED);
  264. $(container).parents().each(function(){
  265. var tagName = this.tagName.toLowerCase()
  266. ,textAlign = this.style.textAlign;
  267. //文字
  268. if(tagName === 'b' || tagName === 'strong'){
  269. item('b').addClass(CHECK)
  270. }
  271. if(tagName === 'i' || tagName === 'em'){
  272. item('i').addClass(CHECK)
  273. }
  274. if(tagName === 'u'){
  275. item('u').addClass(CHECK)
  276. }
  277. if(tagName === 'strike'){
  278. item('d').addClass(CHECK)
  279. }
  280. //对齐
  281. if(tagName === 'p'){
  282. if(textAlign === 'center'){
  283. item('center').addClass(CHECK);
  284. } else if(textAlign === 'right'){
  285. item('right').addClass(CHECK);
  286. } else {
  287. item('left').addClass(CHECK);
  288. }
  289. }
  290. //超链接
  291. if(tagName === 'a'){
  292. item('link').addClass(CHECK);
  293. item('unlink').removeClass(ABLED);
  294. }
  295. });
  296. }
  297. //触发工具
  298. ,toolActive = function(iframeWin, editor, set){
  299. var iframeDOM = iframeWin.document
  300. ,body = $(iframeDOM.body)
  301. ,toolEvent = {
  302. //超链接
  303. link: function(range){
  304. var container = getContainer(range)
  305. ,parentNode = $(container).parent();
  306. link.call(body, {
  307. href: parentNode.attr('href')
  308. ,target: parentNode.attr('target')
  309. }, function(field){
  310. var parent = parentNode[0];
  311. if(parent.tagName === 'A'){
  312. parent.href = field.url;
  313. } else {
  314. insertInline.call(iframeWin, 'a', {
  315. target: field.target
  316. ,href: field.url
  317. ,text: field.url
  318. }, range);
  319. }
  320. });
  321. }
  322. //清除超链接
  323. ,unlink: function(range){
  324. iframeDOM.execCommand('unlink');
  325. }
  326. //表情
  327. ,face: function(range){
  328. face.call(this, function(img){
  329. insertInline.call(iframeWin, 'img', {
  330. src: img.src
  331. ,alt: img.alt
  332. }, range);
  333. });
  334. }
  335. //图片
  336. ,image: function(range){
  337. var that = this;
  338. layui.use('upload', function(upload){
  339. var uploadImage = set.uploadImage || {};
  340. upload.render({
  341. url: uploadImage.url
  342. ,method: uploadImage.type
  343. ,elem: $(that).find('input')[0]
  344. ,done: function(res){
  345. if(res.code == 0){
  346. res.data = res.data || {};
  347. insertInline.call(iframeWin, 'img', {
  348. src: res.data.src
  349. ,alt: res.data.title
  350. }, range);
  351. } else {
  352. layer.msg(res.msg||'上传失败');
  353. }
  354. }
  355. });
  356. });
  357. }
  358. //插入代码
  359. ,code: function(range){
  360. code.call(body, function(pre){
  361. insertInline.call(iframeWin, 'pre', {
  362. text: pre.code
  363. ,'lay-lang': pre.lang
  364. }, range);
  365. });
  366. }
  367. //帮助
  368. ,help: function(){
  369. layer.open({
  370. type: 2
  371. ,title: '帮助'
  372. ,area: ['600px', '380px']
  373. ,shadeClose: true
  374. ,shade: 0.1
  375. ,skin: 'layui-layer-msg'
  376. ,content: ['http://www.layui.com/about/layedit/help.html', 'no']
  377. });
  378. }
  379. }
  380. ,tools = editor.find('.layui-layedit-tool')
  381. ,click = function(){
  382. var othis = $(this)
  383. ,events = othis.attr('layedit-event')
  384. ,command = othis.attr('lay-command');
  385. if(othis.hasClass(ABLED)) return;
  386. body.focus();
  387. var range = Range(iframeDOM)
  388. ,container = range.commonAncestorContainer
  389. if(command){
  390. iframeDOM.execCommand(command);
  391. if(/justifyLeft|justifyCenter|justifyRight/.test(command)){
  392. iframeDOM.execCommand('formatBlock', false, '<p>');
  393. }
  394. setTimeout(function(){
  395. body.focus();
  396. }, 10);
  397. } else {
  398. toolEvent[events] && toolEvent[events].call(this, range);
  399. }
  400. toolCheck.call(iframeWin, tools, othis);
  401. }
  402. ,isClick = /image/
  403. tools.find('>i').on('mousedown', function(){
  404. var othis = $(this)
  405. ,events = othis.attr('layedit-event');
  406. if(isClick.test(events)) return;
  407. click.call(this)
  408. }).on('click', function(){
  409. var othis = $(this)
  410. ,events = othis.attr('layedit-event');
  411. if(!isClick.test(events)) return;
  412. click.call(this)
  413. });
  414. //触发内容区域
  415. body.on('click', function(){
  416. toolCheck.call(iframeWin, tools);
  417. layer.close(face.index);
  418. });
  419. }
  420. //超链接面板
  421. ,link = function(options, callback){
  422. var body = this, index = layer.open({
  423. type: 1
  424. ,id: 'LAY_layedit_link'
  425. ,area: '350px'
  426. ,shade: 0.05
  427. ,shadeClose: true
  428. ,moveType: 1
  429. ,title: '超链接'
  430. ,skin: 'layui-layer-msg'
  431. ,content: ['<ul class="layui-form" style="margin: 15px;">'
  432. ,'<li class="layui-form-item">'
  433. ,'<label class="layui-form-label" style="width: 60px;">URL</label>'
  434. ,'<div class="layui-input-block" style="margin-left: 90px">'
  435. ,'<input name="url" lay-verify="url" value="'+ (options.href||'') +'" autofocus="true" autocomplete="off" class="layui-input">'
  436. ,'</div>'
  437. ,'</li>'
  438. ,'<li class="layui-form-item">'
  439. ,'<label class="layui-form-label" style="width: 60px;">打开方式</label>'
  440. ,'<div class="layui-input-block" style="margin-left: 90px">'
  441. ,'<input type="radio" name="target" value="_self" class="layui-input" title="当前窗口"'
  442. + ((options.target==='_self' || !options.target) ? 'checked' : '') +'>'
  443. ,'<input type="radio" name="target" value="_blank" class="layui-input" title="新窗口" '
  444. + (options.target==='_blank' ? 'checked' : '') +'>'
  445. ,'</div>'
  446. ,'</li>'
  447. ,'<li class="layui-form-item" style="text-align: center;">'
  448. ,'<button type="button" lay-submit lay-filter="layedit-link-yes" class="layui-btn"> 确定 </button>'
  449. ,'<button style="margin-left: 20px;" type="button" class="layui-btn layui-btn-primary"> 取消 </button>'
  450. ,'</li>'
  451. ,'</ul>'].join('')
  452. ,success: function(layero, index){
  453. var eventFilter = 'submit(layedit-link-yes)';
  454. form.render('radio');
  455. layero.find('.layui-btn-primary').on('click', function(){
  456. layer.close(index);
  457. body.focus();
  458. });
  459. form.on(eventFilter, function(data){
  460. layer.close(link.index);
  461. callback && callback(data.field);
  462. });
  463. }
  464. });
  465. link.index = index;
  466. }
  467. //表情面板
  468. ,face = function(callback){
  469. //表情库
  470. var faces = function(){
  471. var alt = ["[微笑]", "[嘻嘻]", "[哈哈]", "[可爱]", "[可怜]", "[挖鼻]", "[吃惊]", "[害羞]", "[挤眼]", "[闭嘴]", "[鄙视]", "[爱你]", "[泪]", "[偷笑]", "[亲亲]", "[生病]", "[太开心]", "[白眼]", "[右哼哼]", "[左哼哼]", "[嘘]", "[衰]", "[委屈]", "[吐]", "[哈欠]", "[抱抱]", "[怒]", "[疑问]", "[馋嘴]", "[拜拜]", "[思考]", "[汗]", "[困]", "[睡]", "[钱]", "[失望]", "[酷]", "[色]", "[哼]", "[鼓掌]", "[晕]", "[悲伤]", "[抓狂]", "[黑线]", "[阴险]", "[怒骂]", "[互粉]", "[心]", "[伤心]", "[猪头]", "[熊猫]", "[兔子]", "[ok]", "[耶]", "[good]", "[NO]", "[赞]", "[来]", "[弱]", "[草泥马]", "[神马]", "[囧]", "[浮云]", "[给力]", "[围观]", "[威武]", "[奥特曼]", "[礼物]", "[钟]", "[话筒]", "[蜡烛]", "[蛋糕]"], arr = {};
  472. layui.each(alt, function(index, item){
  473. arr[item] = layui.cache.dir + 'images/face/'+ index + '.gif';
  474. });
  475. return arr;
  476. }();
  477. face.hide = face.hide || function(e){
  478. if($(e.target).attr('layedit-event') !== 'face'){
  479. layer.close(face.index);
  480. }
  481. }
  482. return face.index = layer.tips(function(){
  483. var content = [];
  484. layui.each(faces, function(key, item){
  485. content.push('<li title="'+ key +'"><img src="'+ item +'" alt="'+ key +'"></li>');
  486. });
  487. return '<ul class="layui-clear">' + content.join('') + '</ul>';
  488. }(), this, {
  489. tips: 1
  490. ,time: 0
  491. ,skin: 'layui-box layui-util-face'
  492. ,maxWidth: 500
  493. ,success: function(layero, index){
  494. layero.css({
  495. marginTop: -4
  496. ,marginLeft: -10
  497. }).find('.layui-clear>li').on('click', function(){
  498. callback && callback({
  499. src: faces[this.title]
  500. ,alt: this.title
  501. });
  502. layer.close(index);
  503. });
  504. $(document).off('click', face.hide).on('click', face.hide);
  505. }
  506. });
  507. }
  508. //插入代码面板
  509. ,code = function(callback){
  510. var body = this, index = layer.open({
  511. type: 1
  512. ,id: 'LAY_layedit_code'
  513. ,area: '550px'
  514. ,shade: 0.05
  515. ,shadeClose: true
  516. ,moveType: 1
  517. ,title: '插入代码'
  518. ,skin: 'layui-layer-msg'
  519. ,content: ['<ul class="layui-form layui-form-pane" style="margin: 15px;">'
  520. ,'<li class="layui-form-item">'
  521. ,'<label class="layui-form-label">请选择语言</label>'
  522. ,'<div class="layui-input-block">'
  523. ,'<select name="lang">'
  524. ,'<option value="JavaScript">JavaScript</option>'
  525. ,'<option value="HTML">HTML</option>'
  526. ,'<option value="CSS">CSS</option>'
  527. ,'<option value="Java">Java</option>'
  528. ,'<option value="PHP">PHP</option>'
  529. ,'<option value="C#">C#</option>'
  530. ,'<option value="Python">Python</option>'
  531. ,'<option value="Ruby">Ruby</option>'
  532. ,'<option value="Go">Go</option>'
  533. ,'</select>'
  534. ,'</div>'
  535. ,'</li>'
  536. ,'<li class="layui-form-item layui-form-text">'
  537. ,'<label class="layui-form-label">代码</label>'
  538. ,'<div class="layui-input-block">'
  539. ,'<textarea name="code" lay-verify="required" autofocus="true" class="layui-textarea" style="height: 200px;"></textarea>'
  540. ,'</div>'
  541. ,'</li>'
  542. ,'<li class="layui-form-item" style="text-align: center;">'
  543. ,'<button type="button" lay-submit lay-filter="layedit-code-yes" class="layui-btn"> 确定 </button>'
  544. ,'<button style="margin-left: 20px;" type="button" class="layui-btn layui-btn-primary"> 取消 </button>'
  545. ,'</li>'
  546. ,'</ul>'].join('')
  547. ,success: function(layero, index){
  548. var eventFilter = 'submit(layedit-code-yes)';
  549. form.render('select');
  550. layero.find('.layui-btn-primary').on('click', function(){
  551. layer.close(index);
  552. body.focus();
  553. });
  554. form.on(eventFilter, function(data){
  555. layer.close(code.index);
  556. callback && callback(data.field);
  557. });
  558. }
  559. });
  560. code.index = index;
  561. }
  562. //全部工具
  563. ,tools = {
  564. html: '<i class="layui-icon layedit-tool-html" title="HTML源代码" lay-command="html" layedit-event="html"">&#xe64b;</i><span class="layedit-tool-mid"></span>'
  565. ,strong: '<i class="layui-icon layedit-tool-b" title="加粗" lay-command="Bold" layedit-event="b"">&#xe62b;</i>'
  566. ,italic: '<i class="layui-icon layedit-tool-i" title="斜体" lay-command="italic" layedit-event="i"">&#xe644;</i>'
  567. ,underline: '<i class="layui-icon layedit-tool-u" title="下划线" lay-command="underline" layedit-event="u"">&#xe646;</i>'
  568. ,del: '<i class="layui-icon layedit-tool-d" title="删除线" lay-command="strikeThrough" layedit-event="d"">&#xe64f;</i>'
  569. ,'|': '<span class="layedit-tool-mid"></span>'
  570. ,left: '<i class="layui-icon layedit-tool-left" title="左对齐" lay-command="justifyLeft" layedit-event="left"">&#xe649;</i>'
  571. ,center: '<i class="layui-icon layedit-tool-center" title="居中对齐" lay-command="justifyCenter" layedit-event="center"">&#xe647;</i>'
  572. ,right: '<i class="layui-icon layedit-tool-right" title="右对齐" lay-command="justifyRight" layedit-event="right"">&#xe648;</i>'
  573. ,link: '<i class="layui-icon layedit-tool-link" title="插入链接" layedit-event="link"">&#xe64c;</i>'
  574. ,unlink: '<i class="layui-icon layedit-tool-unlink layui-disabled" title="清除链接" lay-command="unlink" layedit-event="unlink"">&#xe64d;</i>'
  575. ,face: '<i class="layui-icon layedit-tool-face" title="表情" layedit-event="face"">&#xe650;</i>'
  576. ,image: '<i class="layui-icon layedit-tool-image" title="图片" layedit-event="image">&#xe64a;<input type="file" name="file"></i>'
  577. ,code: '<i class="layui-icon layedit-tool-code" title="插入代码" layedit-event="code">&#xe64e;</i>'
  578. ,help: '<i class="layui-icon layedit-tool-help" title="帮助" layedit-event="help">&#xe607;</i>'
  579. }
  580. ,edit = new Edit();
  581. exports(MOD_NAME, edit);
  582. });