html - TinyMce 编辑器不允许使用 html 标签
问题描述
我正在使用 TinyMce 编辑器并尝试复制粘贴一些 html 标记并存储在数据库中,但问题是,它正在自动删除引导手风琴代码
<script>
tinymce.init({
forced_root_blocks: false,
selector: "textarea#cmshtml",
relative_urls: false,
convert_urls: false,
forced_root_block : false,
force_p_newlines : false,
width : "320",
height : "290",
remove_script_host: false,
document_base_url: base_url,
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
valid_elements : '*[*]',
toolbar: "anchor | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link "
});
</script>
原始数据——
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
<div class="panel-heading">
<div class="panel-title">
<span class="glyphicon glyphicon-minus iconclr"></span>
What is Lorem Ipsum?
</div>
</div>
</a>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
</div>
<div class="panel panel-default">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2" >
<div class="panel-heading">
<div class="panel-title">
<span class="glyphicon glyphicon-plus iconclr"></span>
Why do we use it?
</div>
</div>
</a>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
</div>
</div>
当我试图在编辑器中复制粘贴上面的代码并尝试保存它时,会删除手风琴并给我以下结果
输出数据-
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<span class="glyphicon glyphicon-minus iconclr"></span>
What is Lorem Ipsum?
</div>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<span class="glyphicon glyphicon-plus iconclr"></span>
Why do we use it?
</div>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
</div>
</div>
谁能给点建议?
解决方案
尝试对tinyMce Docs中的 valid_elements 使用完整的 XHTML 规则集。我使用默认规则集,但删除了添加到 a.xml 的所有属性。见小提琴。
推荐阅读
- python - 反向 z 分数 pandas 数据框
- hive - 在 Hive 查询方面需要帮助
- sql - 在sql调度期间获取员工的空闲时间段
- cluster-analysis - k-means 算法的第一个质心应该是“随机的”?
- java - 自定义声音不播放 Firebase 消息 Android
- android-ndk - LOCAL_CFLAGS 和 APP_CFLAGS 有什么区别?
- python - Python 将 xml/字符串数据插入 PostgreSql 数据库
- sql - 如何从 MS Access 中的 SQL 编辑器运行 vba 函数
- python - Keys.ALT 和 Keys.LEFT_ALT 在硒中不起作用?(Python)
- python - Django Paginator - 我在继承自 Paginator 的类中创建了一个函数,以及为什么我不能在前端使用这个函数