Kindeditor Editor Code filtering solution

Source: Internet
Author: User
Tags tag name
Kindeditor Editor Code filtering solution.Jiaoguoqiang published in 2014-07-26 Category: JavaScript reading (1134) Comments (0)

Many friends in the use of the Kindeditor editor will encounter such a problem, such as: to a tag plus title attribute, browsing, but miraculously found that the title attribute is not. When you switch the HTML source code again, the return editor deletes the title attribute. The main reason is that the kindeditor set the default filtering mechanism for labels and attributes. Kindeditor the default state will filter the HTML code in the editor, mainly in order to generate clean code, there will be unexpected results, and now Gio for you to explain: how to avoid the manually added code is unnecessary filtering.
First of all we know that the 3.4 version of the above version defaults to open the filter mode (filtermode:true). When FilterMode is true, the editor automatically filters the HTML code according to the Htmltags setting.
However, in our usual use, in order to streamline the content code and achieve a good display effect, often use some div and CSS code, if you do not change the editor settings, the code will be filtered, so if you want to keep all the HTML-related code, Please set the FilterMode in Kindeditor.js to false. If you want to preserve specific HTML, configure the Htmltags property after you set FilterMode to True.

Filtermode:true//true: Open filter mode, false: Turn off filter mode

If you change to Filtermode:false, the code added to the editor will be preserved.

But if I just want to not filter a certain label, the other is normal filtering, what should be done. For example, I want to keep the line spacing code <span style= "line-height:30px;" , the other is normal filtration, the method is:
FilterMode: Changing to True is the meaning of opening the filter.
We can then implement it by setting its Htmltags property. Kindeditor defaults to white list filtering, htmltags parameters define the tags and attributes to retain htmltags specify the HTML tags and attributes to keep. The key of object is an HTML tag name, value is an array of HTML attributes, "." The starting property represents the Style property. The modified file is the Kindeditor.js example: adding the Line-height attribute tag under span is OK, of course, to add it in a format that can refer to other existing labels.

To sum up, through the above two ways to achieve the Kindeditor Editor label and property filter effect.

But you must pay attention to turn off the editor's interface is reopened, or refresh, in short, to empty the cache, otherwise it will not work.

Original link: http://www.jiaoguoqiang.com/554.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.