当您从word文档复制并粘贴到tinyMCE编辑器时,有时会出现不需要的<p>
标记:
<p> </p>
<div class="starpasspro-example-question">
<p><strong>Example: Levels of strategy</strong></p>
<p>Microsoft is one of the world’s largest organisations, providing corporate solutions to businesses throughout the world to help them realise their fullest potential. At Microsoft, there are three levels of strategy as follows:</p>
</div>
<p> </p>
这里生成的代码我想以任何方式删除<p>
标记吗?
答案 0 :(得分:15)
在tinymce.init({ });
示例:强>
tinymce.init({
forced_root_block : "",
force_br_newlines : true,
force_p_newlines : false,
});
答案 1 :(得分:3)
它会有所帮助。
添加到 tinymce.yml 文件
forced_root_block : ""
force_br_newlines : true
force_p_newlines : false
答案 2 :(得分:0)
是的,这是可能的。有一种安全的方法可以删除您要删除的所有html元素(您可以定义要保留的内容)。它是通过使用tinymce配置参数paste_preprocess
和自定义函数strip_tags
。请查看here。
答案 3 :(得分:0)
将此添加到functions.php文件和标准p-tag中 将一些参数添加到tiny_mce_before_init挂钩中将删除标签。如果您想了解它的工作原理,可以在此页面上进一步阅读:https://codex.wordpress.org/TinyMCE
////////////////////////////////////////////////////////////////////////
//////////REMOVE STANDARD <P> FROM TINYMCE EDITOR/////////////////////////
///////////////////////////////////////////////////////////////////////
function my_format_TinyMCE( $in ) {
$in['forced_root_block'] = "";
$in['force_br_newlines'] = TRUE;
$in['force_p_newlines'] = FALSE;
return $in;
}
add_filter( 'tiny_mce_before_init', 'my_format_TinyMCE' );
答案 4 :(得分:0)
在BoundField中使用HtmlEncode =“ false”
<asp:BoundField DataField="PostContent" HtmlEncode="false" />
答案 5 :(得分:0)
感谢 Prahalad Gaggar!
我遇到了同样的问题,我通过阅读这个主题解决了这个问题:https://stackoverflow.com/a/22397116/14491024
这是我的代码,每次添加
function HTMLeditor(参数){
$('#exampleModalCenter').modal('show');
tinymce.init({
height: 500,
selector: ".modal-body",
theme: 'modern',
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools'
],
toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'print preview media | forecolor backcolor emoticons ',
image_advtab: true,
setup: function (editor) {
editor.on('init', function (e) {
editor.setContent(parameters);
});
}
});
}
问题解决了:
function HTMLeditor(参数){
$('#exampleModalCenter').modal('show');
tinymce.init({
height: 500,
selector: ".modal-body",
theme: 'modern',
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools'
],
toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'print preview media | forecolor backcolor emoticons ',
image_advtab: true,
//remove <p><br /><br /></p>
forced_root_block: "" ,
force_br_newlines: true,
force_p_newlines: false,
setup: function (editor) {
editor.on('init', function (e) {
editor.setContent(parameters);
});
}
});
}