jquery Editor KindEditor4.1.4 code highlighting settings tutorial _jquery

Source: Internet
Author: User
Editor Kindeditor official website: http://www.kindsoft.net/

1, the need to load the JS and CSS files are:
Copy Code code as follows:

<script src= "Kindeditor-4.1.4/kindeditor.js" type= "Text/javascript" charset= "Utf-8" ></script>
<script src= "Kindeditor-4.1.4/plugins/code/prettify.js" type= "Text/javascript" ></script>
<link href= "Kindeditor-4.1.4/plugins/code/prettify.css" rel= "stylesheet" type= "Text/css"/>

2, editor initialization settings, add Prettyprint in the inside ():
Copy Code code as follows:

Kindeditor.ready (function (K) {
Window. Editorobject = k.create (' #txtBody ', {
Csspath: ' Plugins/code/prettify.css ',
Resizetype:1,
Allowpreviewemoticons:false,
Allowimageupload:false,
Items: [
' Code ', ' FontName ', ' fontsize ', ' | ', ' forecolor ', ' hilitecolor ', ' bold ', ' italic ', ' underline ',
' Removeformat ', ' | ', ' justifyleft ', ' justifycenter ', ' justifyright ', ' insertorderedlist ',
' Insertunorderedlist ', ' | ', ' emoticons ', ' image ', ' link '
});
Prettyprint ();
});

If the code to be highlighted is initially hidden, to be displayed, you need to invoke Prettyprint ();
Copy Code code as follows:

function Show (i) {
var id = ' #divBody ' + i;
if ($ (ID). Is (": hidden")) {
$ (' #divIntro ' + i). Hide ();
$ (ID). Slidedown ();
$ (ID). Next ("a"). Text ("Shrink ...");
Prettyprint ();
}
else{
$ (' #divIntro ' + i). Show ();
$ (ID). Slideup ();
$ (ID). Next ("a"). Text ("detailed ...");
}
}

3, the default code is not to change lines, to automatically change the line can modify PRETTIFY.CSS, White-space original value of the pre modified to Pre-wrap:
Copy Code code as follows:

Pre.prettyprint {
border:0;
BORDER-LEFT:3PX Solid RGB (204, 204, 204);
Margin-left:2em;
Padding:0.5em;
font-size:110%;
Display:block;
font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
Margin:1em 0px;
White-space:pre-wrap; /* The original value is pre;*/
}

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.