CKEditor:如何阻止尖括号转换为 HTML 实体
我们的网站使用诸如 <# TAGNAME #> 之类的标签但 CKEditor 转换 <和>到 < 和 > 这会破坏这些标签以便在我们的软件中使用。
我发现了这个选项: config.protectedSource.push( /<#[\s\S]*##>/g );如果从源模式保存数据,这似乎会停止转换,但在所见即所得模式下,我找不到停止转换的方法。我在他们的 API 中尝试了很多选项,但似乎都没有帮助,我该如何解决这个问题?
Our site is using tags like <# TAGNAME #> but CKEditor converts < and > to < and > which breaks these tags for use in our software.
I've discovered this option: config.protectedSource.push( /<#[\s\S]*##>/g ); which seems to stop the conversion if the data is saved from Source mode, but in WYSIWYG mode I can't find a way to stop the conversion. I've tried many options in their API but none of them seem to have helped, how can I fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们正在考虑使用 CKEDitor 来编辑 Smarty 模板。我们遇到的问题是它替换了大括号内的所有尖括号和&符号,这把一切搞乱了。这是在 Google 搜索中出现的,因此我们的解决方案应该可以帮助任何遇到类似问题的人。
每次切换到源模式以及保存时,CKEditor 都会重建 HTML,因此您需要添加到 HTML http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Data_Processor htmlFilter。
这对我们有用:
onText 函数处理标签或注释中没有的所有位。
我想你可以通过改变上面的代码来做类似的事情 - 我将其保留原样,因为我认为我们的问题和所需的解决方案非常相似。
Were were looking at using CKEDitor to edit Smarty templates. The problem we were hitting was that it was replacing all the angle brackets and ampersands within the curly brackets, which messed everything up. This came up in a Google search so our solution should help anyone with similar issues.
CKEditor rebuilds the HTML every time you switch to Source mode and when you save, so you need to add to the HTML http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Data_Processor htmlFilter.
This worked for us:
The onText function processes all the bits that aren't in tags or comments.
I'd imagine you can do something similar by altering the code above - I've left it as is as I think our problems and required solutions are very similar.
http://cksource.com/forums/viewtopic.php ?f=11&t=20647&start=10
http://cksource.com/forums/viewtopic.php?f=11&t=20647&start=10
如果您输入 <或>在任何所见即所得编辑器中,它们都将在源模式下转换为 HTML 实体。
If you type < or > in any WYSIWYG editor, they will be converted to their HTML entities in source mode.