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
精彩评论