简体   繁体   English

如何在CKEditor 3.6.4中关闭自动格式化代码?

[英]How to turn off auto-formating code in CKEditor 3.6.4?

maybe is way to turn off auto-formating HTML code in CKEditor version 3.6.4? 也许是在CKEditor 3.6.4版中关闭自动格式化HTML代码的方法吗?

I found only how to disable auto </br> after <td> in CKEditor? 我发现在CKEditor中的<td>之后如何禁用auto </br>? , but i need to turn off this function. ,但我需要关闭此功能。


Now i try to save code: 现在我尝试保存代码:

{if key is 1}<li>custom text</li>{/if}

and i get: 我得到:

<li>

{if key is 1}</li>

<li>

custom text</li>

<li>

{/if}</li> 

CKEditor works with a valid HTML only and text outside <li> tags is not valid. CKEditor仅适用于有效的HTML,并且<li>标记之外的文本无效。 Quoting CKEditor basic concepts : 引用CKEditor的基本概念

CKEditor is not a tool that will let you input invalid HTML code. CKEditor不是允许您输入无效HTML代码的工具。 CKEditor abides by W3C standards so it will modify code if it is invalid. CKEditor遵守W3C标准,因此如果无效,它将修改代码。

You can however try to use config.protectedSource to hide these template's markers, but you would need to create a good RegExps to hide only real tags and not any text between { and } . 但是,您可以尝试使用config.protectedSource隐藏这些模板的标记,但是您需要创建一个良好的RegExps来仅隐藏实际标记,而不能隐藏{}之间的任何文本。 The simplest implementation that could work would be: 可行的最简单的实现是:

config.protectedSource = [
    /{\/?[\w]+(?: [\w\s]+)?}/g
];

But the real on will depend on what really may be used in these tags. 但是真正的依据将取决于这些标签中实际使用的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM