gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:25:34 24 4
gpt4 key购买 nike

下面是我当前的 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)
{
}

最佳答案

解决方案是使用 paste_preprocess。在 this SO-thread您会找到一种粘贴为纯文本的方法,但要保持表格定义 table , tbody , td , tr粘贴时不被剥离

关于tinymce - 将表格 html 标签粘贴到 tinymce 文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13229541/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com