Here we will share with you the kindeditor code modified by myself. It mainly fixes some bugs and adds some common functions. We recommend this to you. For more information, see. Some personal changes to kindeditor
1. Replace the content in the script
2. color selector extension, copy the fck editor to select the color
3.swfupload.swf pre-upload image preview function
Kindeditor. js
Function _ formatHtml (html, htmlTags, urlType, wellFormatted, indentChar) {if (html = null) {html = '';} // 2015-03-25 html = html. replace (/textarea _/ig, "textarea"); urlType = urlType | ''; wellFormatted = _ undef (wellFormatted, false); indentChar = _ undef (indentChar, '\ t'); var fontSizeList = 'xx-small, x-small, small, medium, large, x-large, xx-large '. split (','); // read and process the data in the script from. var obj ={}; var index = 0; html = html. replace (/(
] *>) ([\ S \ S] *?) (<\/Script>)/ig, function ($0, $1, $2, $3) {var value = $2 + ''; if (value) {var key = "{$ script _" + index + "$}"; obj [key] = value; index ++; return $1 + key + $3 ;} else {return $0 ;}}); html = html. replace (/(<(? : Pre | pre \ s [^>] *)>) ([\ s \ S] *?) (<\/Pre>)/ig, function ($0, $1, $2, $3) {return $1 + $2. replace (/<(? : Br | br \ s [^>] *)>/ig, '\ n') + $3 ;}); html = html. replace (/<(? : Br | br \ s [^>] *) \ s * \/?> \ S * <\/p>/ig ,'
'); Html = html. replace (/(<(? : P | p \ s [^>] *)>) \ s * (<\/p>)/ig, '$1
$2 '); html = html. replace (/\ u200B/g, ''); html = html. replace (/\ u00A9/g ,'©'); Html = html. replace (/\ u00AE/g ,'®'); Html = html. replace (/<[^>] +/g, function ($0) {return $0. replace (/\ s +/g, '') ;}); var htmlTagMap ={}; if (htmlTags) {_ each (htmlTags, function (key, val) {var arr = key. split (','); for (var I = 0, len = arr. length; I <len; I ++) {htmlTagMap [arr [I] = _ toMap (val) ;}}); if (! HtmlTagMap. script) {html = html. replace (/(<(?: Script | script \ s [^>] *)>) ([\ s \ S] *?) (<\/Script>)/ig, '');} if (! HtmlTagMap. style) {html = html. replace (/(<(?: Style | style \ s [^>] *)>) ([\ s \ S] *?) (<\/Style>)/ig, '') ;}} var re =/(\ s *) <(\/)? ([\ W \-:] + )((?: \ S + | (?: \ S + [\ w \-:] +) | (?: \ S + [\ w \-:] + = [^ \ s "'<>] +) | (?: \ S + [\ w \-: "] + =" [^ "] *") | (?: \ S + [\ w \-: "] + = '[^'] * ') *) (\/)?> (\ S *)/g; var tagStack = []; html = html. replace (re, function ($0, $1, $2, $3, $4, $5, $6) {var full = $0, startNewline = $1 | '', startSlash = $2 |'', tagName = $3. toLowerCase (), attr = $4 | '', endSlash = $5? ''+ $5:'', endNewline = $6 | ''; if (htmlTags &&! HtmlTagMap [tagName]) {return '';} if (endSlash ='' & _ SINGLE_TAG_MAP [tagName]) {endSlash = '/';} if (_ INLINE_TAG_MAP [tagName]) {if (startNewline) {startNewline = '';} if (endNewline) {endNewline ='';} if (_ PRE_TAG_MAP [tagName]) {if (startSlash) {endNewline = '\ n';} else {startNewline =' \ n' ;}} if (wellFormatted & tagName = 'br ') {endNewline = '\ n';} if (_ BLOCK_TAG_MAP [t AgName] &! _ PRE_TAG_MAP [tagName]) {if (wellFormatted) {if (startSlash & tagStack. length> 0 & tagStack [tagStack. length-1] === tagName) {tagStack. pop ();} else {tagStack. push (tagName) ;}startnewline = '\ n'; endNewline =' \ n'; for (var I = 0, len = startSlash? TagStack. length: tagStack. length-1; I <len; I ++) {startNewline + = indentChar; if (! StartSlash) {endNewline + = indentChar ;}} if (endSlash) {tagStack. pop () ;}else if (! StartSlash) {endNewline + = indentChar;} else {startNewline = endNewline = '';}} if (attr! = '') {Var attrMap = _ getAttrList (full); if (tagName = 'font') {var fontStyleMap ={}, fontStyle = ''; _ each (attrMap, function (key, val) {if (key = 'color') {fontStyleMap. color = val; delete attrMap [key];} if (key = 'SIZE') {fontStyleMap ['font-size'] = fontSizeList [parseInt (val, 10) -1] | ''; delete attrMap [key];} if (key = 'face') {fontStyleMap ['font-family '] = val; delete attr Map [key] ;}if (key === 'style') {fontStyle = val ;}}); if (fontStyle &&! /; $ /. Test (fontStyle) {fontStyle + = ';} _ each (fontStyleMap, function (key, val) {if (val = '') {return ;} if (/\ s /. test (val) {val = "'" + val + "'";} fontStyle + = key + ':' + val + ';' ;}); attrMap. style = fontStyle;} _ each (attrMap, function (key, val) {if (_ FILL_ATTR_MAP [key]) {attrMap [key] = key ;} if (_ inArray (key, ['src', 'href '])> = 0) {attrMap [key] = _ formatUrl (val, urlType );} If (htmlTags & key! = 'Style '&&! HtmlTagMap [tagName] ['*'] &! HtmlTagMap [tagName] [key] | tagName = 'body' & key = 'contenteditable' |/^ kindeditor _ \ d + $ /. test (key) {delete attrMap [key];} if (key = 'style' & val! = '') {Var styleMap = _ getCssList (val); _ each (styleMap, function (k, v) {if (htmlTags &&! HtmlTagMap [tagName]. style &&! HtmlTagMap [tagName] ['. '+ k]) {delete styleMap [k] ;}}); var style = ''; _ each (styleMap, function (k, v) {style + = k + ':' + v + ';}); attrMap. style = style ;}}); attr = ''; _ each (attrMap, function (key, val) {if (key = 'style' & val = '') {return;} val = val. replace (/"/g, '"'); attr + = ''+ key + '="' + val + '"';});} if (tagName = 'font') {tagName = 'span ';} return startNewli Ne + '<' + startSlash + tagName + attr + endSlash + '>' + endNewline;}); html = html. replace (/(<(?: Pre | pre \ s [^>] *)>) ([\ s \ S] *?) (<\/Pre>)/ig, function ($0, $1, $2, $3) {return $1 + $2. replace (/\ n/g, '\ n') + $3 ;}); html = html. replace (/\ n \ s * \ n/g, '\ n'); html = html. replace (/\ n/g, '\ n'); for (var key in obj) {html = html. replace (key, obj [key]);} // alert (html); return _ trim (html );}
The above is all the modified kindeditor code. I hope you will like it.