如何在ckeditor中禁用标记验证? [英] how to disable tag validation in ckeditor?

查看:179
本文介绍了如何在ckeditor中禁用标记验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CKeditor显然会在您输入起始标记时自动创建匹配的结束标记。有没有办法可以关闭这个行为?

CKeditor apparently automatically creates matching end tags when you enter a start tag. Is there a way to turn this behavior off?

我有一个情况,我使用CKeditor在管理程序中创建两个文本块,然后我使用这些用第一个块绘制页面,一些静态内容,然后第二个块。现在我有一个案例,我想在表中包装静态内容。我在想,没问题,我会把< table>标签和< / table>标记,静态内容将在表中。但是没有,CKeditor坚持关闭第一个块中的表格标签。

I have a situation where I am creating two blocks of text in an admin program using CKeditor, then I'm using these to paint a page with the first block, some static content, and then the second block. Now I've got a case where I want to wrap the static content in a table. I was thinking, No problem, I'll just put the <table> tag in the first block and the </table> tag in the second block, and the static content will be inside the table. But no, CKeditor insists on closing the table tag in the first block.

一般来说,我可以直接进入源模式并输入HTML,但CKeditor决定重新格式化我的标签。这似乎反而失败了具有源模式的目的。 (我讨厌它,当我告诉计算机我想要,它告诉我,不,你错了,我知道比你更好你想要什么。)

In general, I can go to source mode and enter HTML directly, but CKeditor then decides to reformat my tagging. This seems to rather defeat the purpose of having a source mode. (I hate it when I tell the computer what I want and it tells me, No, you're wrong, I know better than you what you want!)

推荐答案

CKEditor生成有效的HTML。有效的HTML必须包括开始和结束标记。没有办法改变这种行为没有黑客编辑器。注意,即使你强制编辑器生成没有这些标签的内容,它会尝试解决这个问题,而不会像你所期望的那样。例如。载入:

CKEditor produces valid HTML. Valid HTML has to include both - start and end tags. There's no way to change this behaviour without hacking editor. Note that even if you'll force editor to produce content without one of these tags it will then try to fix this and won't do this as you expect. E.g. load:

<p>foo</p></td></tr></table>

你将完全松开这个表,所以只有基于regexp的修复数据加载可以帮助。在相反的情况下:

And you'll completely loose this table so only regexp based fix on data loading could help. In the opposite case:

<table><tr><td><p>foo</p>

你最终会用表格包装段落,所以更好。但是如果有人从编辑器内容中删除此表格,该怎么办?

You'll end up with paragraph wrapped with table, so it's better. But what if someone would remove this table from editor contents?

因此,您应该在编辑器之外进行这种集成 - 将表格添加到一个编辑器的内容, 。您根本无法强制编辑器处理部分HTML。

Therefore you should do this integration outside editor - prepend table to contents of one editor and append to contents of second one. You simply cannot force editor to work on partial HTML.

这篇关于如何在ckeditor中禁用标记验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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