将表格html标记粘贴到tinymce文本框

将表格html标记粘贴到tinymce文本框,tinymce,Tinymce,下面是我当前的Tinymce配置,它将删除所有样式/格式/html标记并粘贴为纯文本, 但是我的客户想把桌子粘上去。因此,我想改进我的tinymce,以便能够在从ms word复制和粘贴时粘贴表(仅) tinyMCE.init({ theme: "advanced", mode: "exact", elements: "txtTextbox1", plugins : "paste,table,dire

下面是我当前的Tinymce配置,它将删除所有样式/格式/html标记并粘贴为纯文本, 但是我的客户想把桌子粘上去。因此,我想改进我的tinymce,以便能够在从ms word复制和粘贴时粘贴表(仅)

tinyMCE.init({
            theme: "advanced",
            mode: "exact",
            elements: "txtTextbox1",
            plugins : "paste,table,directionality,preview,iespell,wordcount,style",        
            theme_advanced_buttons1: "bold,italic,underline,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,undo,redo,|,preview,iespell",
            theme_advanced_buttons2: "tablecontrols,|,link,unlink",
            //theme_advanced_buttons3: "tablecontrols,|,link,unlink",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            force_p_newlines: false,
            force_br_newlines: true,
            forced_root_block: '',
            paste_convert_middot_lists: false,
            paste_text_sticky: true,
            paste_strip_class_attributes: "all",
            paste_remove_styles: true,
            paste_remove_spans: true,
            paste_block_drop: true,
            paste_text_sticky_default: true,

            setup: function (ed) {
                ed.onInit.add(function (ed) {
                    ed.pasteAsPlainText = true;
                    ed.controlManager.setActive("pastetext", true);
                });
            }
        });
已编辑 下面是我的最终代码

tinyMCE.init
        ({
            theme: "advanced",
            mode: "exact",
            elements: "txtTextbox1",
            plugins : "paste,table,directionality,preview,iespell,wordcount,style",        
            theme_advanced_buttons1: "bold,italic,underline,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,undo,redo,|,preview,iespell",
            theme_advanced_buttons2: "tablecontrols,|,link,unlink",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            force_p_newlines: false,
            force_br_newlines: true,
            forced_root_block: '',
            paste_convert_middot_lists: false,            

            paste_preprocess : function(pl, o) 
            {  
                o.content = strip_tags( o.content,'<table><tr><td>' );
            },            
        });


function strip_tags (str, allowed_tags)
{
}
tinyMCE.init
({
主题:“高级”,
模式:“精确”,
元素:“txtTextbox1”,
插件:“粘贴、表格、方向性、预览、iSpell、字数、样式”,
主题高级按钮1:“粗体、斜体、下划线、|、剪切、复制、粘贴、|、左对齐、居中对齐、右对齐、右对齐、满对齐、|、粗体、numlist、|、撤消、重做、|、预览、iSpill”,
主题_高级_按钮2:“表格控件,|,链接,取消链接”,
主题\高级\工具栏\位置:“顶部”,
主题\高级\工具栏\对齐:“左”,
主题\高级\状态栏\位置:“底部”,
force_p_新行:false,
force\u br\u新词:对,
强制的\u根\u块:“”,
粘贴转换中间列表:false,
粘贴预处理:函数(pl,o)
{  
o、 内容=带标签(o.content.);
},            
});
功能条标签(str,允许的标签)
{
}

解决方案是使用粘贴预处理。在中,您将找到一种以纯文本形式粘贴的方法,但为了使表定义粘贴时不剥离的
table
tbody
td
tr
,我找到了复制粘贴tinyMCE 4.0的解决方案

如果您使用此基本示例源

<script type="text/javascript">
tinymce.init({
    selector: "textarea",
    plugins: [
        "advlist autolink lists link image charmap print preview anchor",
        "searchreplace visualblocks code fullscreen",
        "insertdatetime media table contextmenu paste moxiemanager"
    ],
    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
</script>
现在,您可以将(所有ms word、html页面等)粘贴到tinyMCE编辑器


也许,也许会有帮助

谢谢。。这个解决方案帮助我在过去的一周里进行了大量的搜索
   plugins: [
        "advlist autolink lists link image charmap print preview anchor",
        "searchreplace visualblocks code fullscreen",
        "insertdatetime media table contextmenu moxiemanager"
    ],