有没有办法迫使TinyMCE创建 tables instead of using tags when using the table button?

问题描述 投票:1回答:2

我在我的网站上使用TinyMCE HTML编辑器;但是,当我使用表格按钮时,我看到TinyMCE使用<table>标签是否有一种方法可以强制TinyMCE使用<div>标签,这样我的内容将保持响应?

html responsive-design html-table tinymce tinymce-4
2个回答
0
投票

不幸的是,这不是开箱即用的。获得你想要的东西的唯一方法就是自己写一个表插件(那会很痛苦)。


0
投票
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>';
})
© www.soinside.com 2019 - 2024. All rights reserved.