【问题标题】:How to extend tinyMCE table plugin如何扩展 tinyMCE 表插件
【发布时间】:2017-07-21 14:04:51
【问题描述】:

是否有办法扩展 tinyMCE 表格插件,使模板表格的第一列默认宽度为 200 像素?我正在使用 inlite 主题,我希望默认的表格模板如下所示:

<table>
   <tr>
     <td width='200px'>First columns will have 200px width by default</td>
     <td></td>
   </tr>
</table>

【问题讨论】:

    标签: javascript tinymce


    【解决方案1】:

    对于可能遇到此问题的任何人,都可以使用 BeforeSetContent 事件来获取插入的表。 [https://www.tinymce.com/docs/advanced/events/#beforesetcontent][1]

    tinymce.init({
            selector: '.tinymce' ,
            theme: 'inlite',
            plugins: 'table',
            insert_toolbar: 'quicktable',
            table_appearance_options: true,
            selection_toolbar: 'bold italic underline',
            nonbreaking_force_tab: true,
            inline: true,
            init_instance_callback: function (editor) {
                editor.on('BeforeSetContent', function (e) {
                    if(e.content.indexOf('<td>')){
                        e.content = e.content.replace(/<td>/, "<td width='200'>");
                    }
                });
            }
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-18
      • 2012-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-10
      • 2016-09-04
      • 1970-01-01
      相关资源
      最近更新 更多