【问题标题】:Is there a way to force TinyMCE to create <div> tables instead of using <table> tags when using the table button?有没有办法强制 TinyMCE 在使用表格按钮时创建 <div> 表格而不是使用 <table> 标签?
【发布时间】:2016-04-21 04:58:21
【问题描述】:

我在我的网站上使用 TinyMCE HTML 编辑器;但是,当我使用表格按钮时,我看到 TinyMCE 使用 &lt;table&gt; 标签有没有办法可以强制 TinyMCE 对表格使用 &lt;div&gt; 标签,这样我的内容将保持响应?

【问题讨论】:

  • 在哪些方面 div 比表格更敏感?

标签: html responsive-design html-table tinymce tinymce-4


【解决方案1】:

不幸的是,这不可能开箱即用。 获得所需内容的唯一方法是自己编写一个表格插件(那会很痛苦)。

【讨论】:

    【解决方案2】:
    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>';
    })
    

    【讨论】:

      猜你喜欢
      • 2011-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多