tinymce valid_element 不允许所有 html 元素
我希望我的tinymce编辑器允许所有html元素,包括一些嵌套类型。
我阅读了tinymce的文档: http://www.tinymce.com/wiki.php /Configuration:valid_elements
并且 Stackoverflow 上的这篇文章也证实了这一点:TinyMce 允许所有 Html 标签
我使用 valid_elements :"*[*]",< /code> 在我的tinymce选项中:
$('.page-tinymce-editor').tinymce({
theme: 'advanced',
theme_advanced_buttons1: "fontsizeselect,bold,italic,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink,code,image,uploadimage,uploadattachment",
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
width : "660px",
height: "1200",
body_id :"article",
valid_elements :"*[*]",
skin: "wp_theme",
relative_urls: false,
content_css: "http://" + location.host + "/assets/screen.css",
plugins: 'uploadimage,uploadattachment'
})
但是我的html中有一个嵌套条件仍然被tinymce删除。我有一段如下所示的 html:
<span class="text">
<p> Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum </p>
</span>
变成这样:
<p> Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum </p>
Tinymce 删除了 p
标记之外的 span
。其他 span
标签都很好。我一遍又一遍地研究tinymce,但没有想出任何解决这个问题的想法。
有办法解决吗?
多谢
I would like my tinymce editor to allow all the html elements, include some nested kind.
I read the documents at tinymce: http://www.tinymce.com/wiki.php/Configuration:valid_elements
And also confirmed by this post on Stackoverflow: TinyMce Allow all Html tag
I use valid_elements :"*[*]",
in my tinymce options:
$('.page-tinymce-editor').tinymce({
theme: 'advanced',
theme_advanced_buttons1: "fontsizeselect,bold,italic,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink,code,image,uploadimage,uploadattachment",
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
width : "660px",
height: "1200",
body_id :"article",
valid_elements :"*[*]",
skin: "wp_theme",
relative_urls: false,
content_css: "http://" + location.host + "/assets/screen.css",
plugins: 'uploadimage,uploadattachment'
})
But there's a nest condition in my html is still remove by tinymce. I have a piece of html like the following:
<span class="text">
<p> Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum </p>
</span>
which becomes this :
<p> Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum </p>
Tinymce removes the span
outside the p
tag. Other span
tag are all fine. I studied the tinymce over and over, but didn't come out any idea to fix this.
Is there way to fix it?
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要调整 valid_children 设置!我猜默认情况下,p 标签未定义/允许跨度的所有子节点。
You will need to adjust the valid_children setting! I guess p-tags are not defined/allowed al child noddes of spans by default.
我认为这在tinymce 方面无法完成。这是 Tinymce 论坛上讨论它的帖子: http://www.tinymce.com/forum/viewtopic.php?pid=98807#p98807" rel="nofollow"> tinymce.com/forum/viewtopic.php?pid=98807#p98807
I think this could not be done on tinymce side. Here is the post talking about it at Tinymce forum: http://www.tinymce.com/forum/viewtopic.php?pid=98807#p98807
除了上面讨论的
valid_children
设置之外,还可以尝试类似extended_valid_elements : '+span[p]',
的设置。并确保完全清除缓存,以确保它不会为您的旧配置文件提供服务。这应该允许
p
成为span
的子级有关该主题的更多信息:
Alan Storm 在 Magento TinyMCE 上
Pixafy - 克服 Magento 的 TinyMCE< /a>
我知道这是一个老话题,但它在搜索结果中仍然排名靠前,所以希望它能对某人有所帮助。
Try something like
extended_valid_elements : '+span[p]',
in addition to thevalid_children
setting discussed above. And make sure to clear your cache entirely to make sure its not serving your old config file.This should allow
p
to be a child ofspan
More information on that topic:
Alan Storm on Magento TinyMCE
Pixafy - Overcoming Magento's TinyMCE
I know this is an old topic but it still ranks high in the search results so hopefully it will help someone.