我在我的网站上使用TinyMCE HTML编辑器;但是,当我使用表格按钮时,我看到TinyMCE使用<table>
标签是否有一种方法可以强制TinyMCE使用<div>
标签,这样我的内容将保持响应?
不幸的是,这不是开箱即用的。获得你想要的东西的唯一方法就是自己写一个表插件(那会很痛苦)。
setup: function (ed) {
ed.on('BeforeSetContent', function(e) {
if (e.content.startsWith("<table ")) {
// write jquery code to replace <table> tag with a <div> tag whenever a table is added in the editor.
}
});
},
可能有些过滤器功能如下:
$('table').filter(function(){
return $.trim($(this).text()) === 'Text Here';
}).replaceWith(function () {
return '<div>' + $(this).text() + '</div>';
})