开发者

Get html of a table in TinyMCE (using the table plugin)

开发者 https://www.devze.com 2023-03-18 00:21 出处:网络
I have a TinyMCE editor with the table plugin loaded (I\'m using the TinyMCE Advanced Wordpress plugin). I have to get a selected table\'s HTML code (a tabl开发者_Go百科e that you are currently editin

I have a TinyMCE editor with the table plugin loaded (I'm using the TinyMCE Advanced Wordpress plugin). I have to get a selected table's HTML code (a tabl开发者_Go百科e that you are currently editing - the on you have resize controls on). With normal text I can use tinyMCE.activeEditor.selection.getContent(), but this is not working when dealing with a table. What is the correct way of doing this?

Thanks.


You might use tinyMCE.activeEditor.selection.getNode();. If this is a table element you got your table and will be able to get the html using

var node = tinyMCE.activeEditor.selection.getNode();
var html = node.innerHTML;
// now you will only need to take care of the surrounding table element
// something like "<table>"+ html +"</table>"; maybe having a look at node.attributes
0

精彩评论

暂无评论...
验证码 换一张
取 消