防止 TinyMCE 移除跨度元素 [英] Prevent TinyMCE from removing span elements

查看:36
本文介绍了防止 TinyMCE 移除跨度元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是问题演示

您可以在这里尝试:http://fiddle.tinymce.com/SLcaab

这是 TinyMCE 默认配置

This is TinyMCE default configuration

  • 减少所有插件
  • with extended_valid_elements: "span"

1 - 打开 Html 源代码编辑器

1 - Open the Html Source Editor

2 - 将此 html 粘贴到 Html 源代码编辑器中:

2 - Paste this html into the Html Source Editor:

<p><span>Hello</span></p>
<p><a href="http://www.google.com">Google 1</a></p>
<p><a href="http://www.google.com">Google 2</a></p>

3 - 在 Html 源代码编辑器中单击更新以将 html 粘贴到编辑器中

3 - Click update in the Html Source Editor to paste the html in the editor

4 - 请记住,'Hello' 周围有一个跨度.

4 - Remember there is a span around 'Hello'.

5 - 将光标放在 Google 2 之前并按退格键(两个链接应合并在同一段落元素内).

5 - Place your cursor just before Google 2 and press backspace (the two links should merge inside the same paragraph element).

6 - 使用 Html 源代码编辑器查看生成的 html.

6 - Look at the resulting html using the Html Source Editor.

结果(问题):即使我们在 TinyMCE 设置中将span"添加到 extended_valid_elements 中,html 文档中也没有更多的 span.

Result (problem): No more span in the html document even though we added 'span' to the extended_valid_elements in the TinyMCE settings.

注意:我删除了所有插件以确保问题是 TinyMCE 的核心.

Note: I removed all the plugins to make sure the problem is at the core of TinyMCE.

编辑 1 - 我也尝试过: valid_children : "+p[span]" - 仍然不起作用

Edit 1 - I also tried: valid_children : "+p[span]" - still does not work

编辑 2:仅在 WebKit 上重现(在 Firefox 和 IE 上可以)

Edit 2: Only reproduced on WebKit (OK on Firefox and IE)

推荐答案

您是否在运行最新版本的 TinyMCE?我遇到了相反的问题——新版本的 TinyMCE 会添加不需要的跨度元素.降级到 v3.2.7 为我解决了这个问题,如果您愿意使用旧版本,这可能也适用于您.

Are you running the newest version of TinyMCE? I had the opposite problem - new versions of TinyMCE would add in unwanted span elements. Downgrading to v3.2.7 fixed the issue for me, that might also work for you if you are willing to use an old version.

已经报告了类似的错误,请参阅以下链接以了解在span"元素上过滤的错误:http://www.tinymce.com/develop/bugtracker_bugs.php#!order=desc&column=number&filter=span&status=open,verified&type=bug

Similar bugs have been reported, see the following link for bugs filtered on "span" element: http://www.tinymce.com/develop/bugtracker_bugs.php#!order=desc&column=number&filter=span&status=open,verified&type=bug

这篇关于防止 TinyMCE 移除跨度元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆