2017-07-20 53 views
0

是否有擴展tinyMCE表格插件的方法,以便模板表格在其第一列上具有默認的200px寬度?我使用inlite主題,我想有默認的表模板像下面默認:如何擴展tinyMCE表格插件

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

回答

0

對於誰可能有這個問題的人,在BeforeSetContent事件可以被用來獲取inserted表。 [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'>"); 
       } 
      }); 
     } 
    });