jhtmlarea wysiwyg编辑器 – 添加表格

我已经进行了大量搜索,寻找有关添加自定义工具栏按钮的信息,该按钮会将表格插入编辑器中。

这就是我能找到的(顺便说一下,没有回答这个问题): 在jHtmlArea中添加表格

任何人都有任何想法,如何做或看到类似的东西,我可以作为参考?

谢谢乔

很抱歉重振旧主题,但我也希望能够使用jhtmlarea添加表格。 这就是我提出的

$("#editor").htmlarea({ toolbar: [ ["html"], ["bold","italic","underline","strikeThrough","|","subscript","superscript"], ["orderedList","unorderedList"], ["indent","outdent"], ["link","unlink","|","horizontalrule"], ["cut","copy","paste"], [{ css: 'jhtml-table', text: 'Insert Table', action: function(btn) { var t = this, li = btn.closest('li'); var trtd = Array(11).join(''+Array(11).join('')+''); var tbl = $('' + trtd + '
 
') .css({position:'absolute', background:'#fff', border:'#bbb 1px solid', outline:'0 none'}) .appendTo(li) .focus().blur(function(e){ tbl.remove(); }); tbl.find('tbody td').css({border:'#bbb 1px solid',height:'12px',width:'12px'}) .hover(function(e){ var td = $(this), x = td.index()+1, y = td.closest('tr').index()+1; tbl.find('tfoot td').html(x + 'x' + y); tbl.find('tbody tr').slice(0,y).each(function(i){ $(this).find('td').slice(0,x).css({background:'#ddd'}); $(this).find('td').slice(x).css({background:'none'}); }); tbl.find('tbody tr').slice(y).each(function(i){ $(this).find('td').css({background:'none'}); }) }) .click(function(e){ var td = $(this), x = td.index()+2, y = td.closest('tr').index()+2; t.pasteHTML('' + Array(y).join(''+Array(x).join('')+'') + '
 
'); tbl.remove(); }); } }] ], css: "css/jHtmlArea.editor.css" });

我没有做任何跨浏览器测试(它在Chrome中运行),它非常简单,但它提供了一种快速放入html表的方法。

    Interesting Posts