diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 000000000..f20a7d435
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,6 @@
+/kindeditor*.js
+/dist
+/src/header.js
+/src/footer.js
+/lib
+/test
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 000000000..9f0aa5009
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,16 @@
+
+root: true
+
+parserOptions:
+ ecmaVersion: 2017
+ sourceType: module
+
+globals:
+ KindEditor: readonly
+
+env:
+ browser: true
+ node: true
+
+rules:
+ no-undef: error
diff --git a/.eslintrc-es3.yaml b/.eslintrc-es3.yaml
new file mode 100644
index 000000000..482a7fb27
--- /dev/null
+++ b/.eslintrc-es3.yaml
@@ -0,0 +1,9 @@
+
+root: true
+
+parserOptions:
+ ecmaVersion: 3
+
+rules:
+ quote-props: [ error, 'as-needed', { keywords: true, unnecessary: false } ]
+ dot-notation: [ error, { allowKeywords: false, allowPattern: '.*' } ]
diff --git a/.gitignore b/.gitignore
index 6bf256e54..723a32565 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,6 @@ dist/
node_modules/
_build/
attached/*
+
+/.idea
+/kindeditor*
diff --git a/.idea/dictionaries/k.xml b/.idea/dictionaries/k.xml
new file mode 100644
index 000000000..2fd6c7ae1
--- /dev/null
+++ b/.idea/dictionaries/k.xml
@@ -0,0 +1,7 @@
+
+
+
+ kindeditor
+
+
+
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 000000000..4a755ce06
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,5 @@
+/*
+!/lang
+!/plugins
+!/themes
+!/kindeditor*.js
diff --git a/Gruntfile.js b/Gruntfile.js
deleted file mode 100644
index d4ca6dd06..000000000
--- a/Gruntfile.js
+++ /dev/null
@@ -1,119 +0,0 @@
-
-module.exports = function(grunt) {
-
-var BANNER = '/* <%= pkg.name %> <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd") %>), Copyright (C) kindeditor.net, Licence: http://kindeditor.net/license.php */\r\n';
-
-var SRC_FILES = [
- 'src/header.js',
- 'src/core.js',
- 'src/config.js',
- 'src/event.js',
- 'src/html.js',
- 'src/selector.js',
- 'src/node.js',
- 'src/range.js',
- 'src/cmd.js',
- 'src/widget.js',
- 'src/edit.js',
- 'src/toolbar.js',
- 'src/menu.js',
- 'src/colorpicker.js',
- 'src/uploadbutton.js',
- 'src/dialog.js',
- 'src/tabs.js',
- 'src/ajax.js',
- 'src/main.js',
- 'src/footer.js',
-];
-
-var PLUGIN_FILES = [
- 'plugins/anchor/anchor.js',
- 'plugins/autoheight/autoheight.js',
- 'plugins/baidumap/baidumap.js',
- 'plugins/map/map.js',
- 'plugins/clearhtml/clearhtml.js',
- 'plugins/code/code.js',
- 'plugins/emoticons/emoticons.js',
- 'plugins/filemanager/filemanager.js',
- 'plugins/flash/flash.js',
- 'plugins/image/image.js',
- 'plugins/insertfile/insertfile.js',
- 'plugins/lineheight/lineheight.js',
- 'plugins/link/link.js',
- 'plugins/map/map.js',
- 'plugins/media/media.js',
- 'plugins/multiimage/multiimage.js',
- 'plugins/pagebreak/pagebreak.js',
- 'plugins/plainpaste/plainpaste.js',
- 'plugins/preview/preview.js',
- 'plugins/quickformat/quickformat.js',
- 'plugins/table/table.js',
- 'plugins/template/template.js',
- 'plugins/wordpaste/wordpaste.js',
- 'plugins/fixtoolbar/fixtoolbar.js'
-];
-
-var pkg = grunt.file.readJSON('package.json');
-
-var lang = grunt.option('lang') || 'en';
-
-grunt.initConfig({
- pkg : pkg,
- concat : {
- options : {
- process : function(src, filepath) {
- src = src.replace(/\$\{VERSION\}/g, pkg.version + ' (' + grunt.template.today('yyyy-mm-dd') + ')');
- src = src.replace(/\$\{THISYEAR\}/g, grunt.template.today('yyyy'));
- src = src.replace(/\/\*\*(\r\n|\n)[\s\S]*?\*\//g, '');
- src = src.replace(/(^|\s)\/\/.*$/mg, '');
- src = src.replace(/(\r\n|\n)\/\*\*\/.*(\r\n|\n)/g, '');
- src = src.replace(/[ \t]+$/mg, '');
- src = src.replace(/(\r\n|\n){2,}/g, '$1');
- return src;
- }
- },
- build : {
- src : SRC_FILES.concat('lang/' + lang + '.js').concat(PLUGIN_FILES),
- dest : 'kindeditor-all.js'
- }
- },
- uglify : {
- options : {
- banner : BANNER,
- },
- build : {
- src : '<%= pkg.filename %>-all.js',
- dest : '<%= pkg.filename %>-all-min.js'
- }
- },
- compress : {
- main : {
- options: {
- archive: 'dist/<%= pkg.filename %>-<%= pkg.version %>-' + lang + '.zip',
- },
- files: [
- {src: ['asp/**'], dest: 'kindeditor/'},
- {src: ['asp.net/**'], dest: 'kindeditor/'},
- {src: ['attached'], dest: 'kindeditor/'},
- {src: ['jsp/**'], dest: 'kindeditor/'},
- {src: ['lang/**'], dest: 'kindeditor/'},
- {src: ['php/**'], dest: 'kindeditor/'},
- {src: ['plugins/**'], dest: 'kindeditor/'},
- {src: ['themes/**'], dest: 'kindeditor/'},
- {src: ['kindeditor*.js'], dest: 'kindeditor/'},
- {src: ['license.txt'], dest: 'kindeditor/'},
- ]
- }
- }
-});
-
-grunt.loadNpmTasks('grunt-contrib-concat');
-grunt.loadNpmTasks('grunt-contrib-uglify');
-grunt.loadNpmTasks('grunt-contrib-compress');
-
-grunt.registerTask('build', ['concat', 'uglify']);
-grunt.registerTask('zip', ['build', 'compress']);
-
-grunt.registerTask('default', 'build');
-
-};
diff --git a/README.md b/README.md
index c90a94c1a..96235d027 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,13 @@ KindEditor is a lightweight, Open Source(LGPL), cross browser, web based WYSIWYG
http://kindeditor.net/
+## Compatibility
+
+- IE6 compatible for `kindeditor-all.js` & `kindeditor-all-min.js`
+- IE8 compatible for `kindeditor.js`
+
+ if using IE6 or IE7, you need to polyfill `JSON.parse` before `kindeditor.js` load
+
## Contributors
* Timon Lin
diff --git a/build.js b/build.js
new file mode 100755
index 000000000..d6cacf6bf
--- /dev/null
+++ b/build.js
@@ -0,0 +1,110 @@
+#!/usr/bin/env node
+
+const fs = require('fs');
+const child_process = require('child_process');
+const AdmZip = require('adm-zip');
+const pkg = require('./package.json');
+const today = new Date().toISOString().replace(/T.*/, ''); // yyyy-mm-dd
+
+const lang = 'zh-CN';
+
+// noinspection HttpUrlsUsage
+const BANNER = `/* ${pkg.name} ${pkg.version} (${today}), Copyright (C) kindeditor.net, Licence: http://kindeditor.net/license.php */\n`;
+
+// noinspection SpellCheckingInspection
+const PLUGIN_FILES = [
+ 'plugins/ajax.js',
+ `lang/${lang}.js`,
+ 'plugins/anchor/anchor.js',
+ 'plugins/autoheight/autoheight.js',
+ 'plugins/baidumap/baidumap.js',
+ 'plugins/map/map.js',
+ 'plugins/clearhtml/clearhtml.js',
+ 'plugins/code/code.js',
+ 'plugins/emoticons/emoticons.js',
+ 'plugins/filemanager/filemanager.js',
+ 'plugins/flash/flash.js',
+ 'plugins/image/image.js',
+ 'plugins/insertfile/insertfile.js',
+ 'plugins/lineheight/lineheight.js',
+ 'plugins/link/link.js',
+ 'plugins/media/media.js',
+ 'plugins/multiimage/multiimage.js',
+ 'plugins/pagebreak/pagebreak.js',
+ 'plugins/plainpaste/plainpaste.js',
+ 'plugins/preview/preview.js',
+ 'plugins/quickformat/quickformat.js',
+ 'plugins/table/table.js',
+ 'plugins/template/template.js',
+ 'plugins/wordpaste/wordpaste.js',
+ 'plugins/fixtoolbar/fixtoolbar.js',
+];
+
+const concat = (...plugins) => ['src/header.js', 'dist/main.js', ...plugins, 'src/footer.js']
+ .map(file => fs.readFileSync(file, 'utf8').replace(/\r/g, ''))
+ // remove webpack generated codes
+ .map((src, index) => index !== 1 ? src : src.replace(RegExp(('^'
+ + '/******/ (function() { // webpackBootstrap\n'
+ + '/******/ \t"use strict";\n'
+ + 'var __webpack_exports__ = {};\n'
+ + '%' // place holder for body
+ + '/******/ })()\n;'
+ + '$').replace(/[*(){}]/g, '\\$&').replace('%', '([\\s\\S]*)')), '$1')
+ ).join('\n')
+ .replace(/\${VERSION}/g, `${pkg.version} (${today})`) // yyyy-mm-dd
+ .replace(/\${THISYEAR}/g, today.replace(/-.*/, '')) // yyyy
+ .replace(/([\s\S])\/\*[\s\S]*?\*\//g, '$1') // remove block comments except header
+ .replace(/(^;?|\s)\/\/.*$/mg, '') // remove line comments
+ .replace(/\s+$/mg, '') // remove trailing white spaces
+ .replace(/\n+/g, '\n') // merge multiple blank lines to one
+;
+
+const fsize = /* Stats | string */x => `${x.size || Buffer.from(x, 'utf8').length}`.replace(/\d(?=(\d{3})+$)/g, '$&,');
+const generate = (outputFilename, content, ie6) => {
+ if (ie6) {
+ content = content.replace(/,\s*json\s*:\s*JSON\.parse\b/, ''); // remove K.json initial for IE6 compatible
+ console.log(` - ${outputFilename} ${fsize(content)} (ie6 enabled)`);
+ } else {
+ console.log(` - ${outputFilename} ${fsize(content)}`);
+ }
+ fs.writeFileSync(outputFilename, content, 'utf8');
+ if (content.match(/webpack|CONCATENATED|harmony/)) {
+ console.log(' ERR: webpack generated code still not striped');
+ process.exit(1);
+ }
+ if (ie6 && content.match(/JSON\.parse/)) {
+ console.log(' ERR: global JSON is not IE6 compatible');
+ process.exit(1);
+ }
+ try {
+ child_process.execSync('npm exec eslint -- '
+ + `--color --no-ignore --no-eslintrc -c .eslintrc-es3.yaml ${outputFilename}`, {stdio : 'inherit'});
+ } catch (e) {
+ process.exit(1);
+ }
+};
+
+(async () => {
+ child_process.execSync('npm exec webpack', {stdio : 'inherit'});
+
+ console.log();
+ console.log('generating artifacts');
+ generate('kindeditor.js', concat());
+ generate('kindeditor-all.js', concat(...PLUGIN_FILES), true);
+
+ const minify = async file => (await require('terser').minify(fs.readFileSync(file, 'utf8'), {
+ ie8 : true, format : {comments : false},
+ })).code;
+ // generate('kindeditor-min.js', BANNER + (await minify('kindeditor.js')));
+ generate('kindeditor-all-min.js', BANNER + (await minify('kindeditor-all.js')), true);
+
+ const zipFileName = `dist/${pkg.filename}-${pkg.version}-${lang}.zip`;
+ const zip = new AdmZip(null, {});
+ fs.readdirSync('.', 'utf8').filter(name => /^(asp(\.net)?|jsp|lang|php|plugins|themes)$/.test(name))
+ .forEach(name => zip.addLocalFolder(name, `kindeditor/${name}/`));
+ fs.readdirSync('.', 'utf8').filter(name => /^(kindeditor.*\.js|license\.txt)$/.test(name))
+ .forEach(name => zip.addLocalFile(name, 'kindeditor/'));
+ zip.writeZip(zipFileName, () => {
+ console.log(` - ${zipFileName} ${fsize(fs.statSync(zipFileName))}`);
+ });
+})();
diff --git a/kindeditor-all-min.js b/kindeditor-all-min.js
deleted file mode 100644
index 1cae5c303..000000000
--- a/kindeditor-all-min.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/* KindEditor 4.1.12 (2019-03-07), Copyright (C) kindeditor.net, Licence: http://kindeditor.net/license.php */
-!function(window,undefined){function _isArray(a){return a?"[object Array]"===Object.prototype.toString.call(a):!1}function _isFunction(a){return a?"[object Function]"===Object.prototype.toString.call(a):!1}function _inArray(a,b){for(var c=0,d=b.length;d>c;c++)if(a===b[c])return c;return-1}function _each(a,b){if(_isArray(a))for(var c=0,d=a.length;d>c&&b.call(a[c],c,a[c])!==!1;c++);else for(var e in a)if(a.hasOwnProperty(e)&&b.call(a[e],e,a[e])===!1)break}function _trim(a){return a.replace(/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,"")}function _inString(a,b,c){return c=c===undefined?",":c,(c+b+c).indexOf(c+a+c)>=0}function _addUnit(a,b){return b=b||"px",a&&/^-?\d+(?:\.\d+)?$/.test(a)?a+b:a}function _removeUnit(a){var b;return a&&(b=/(\d+)/.exec(a))?parseInt(b[1],10):0}function _escape(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function _unescape(a){return a.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function _toCamel(a){var b=a.split("-");return a="",_each(b,function(b,c){a+=b>0?c.charAt(0).toUpperCase()+c.substr(1):c}),a}function _toHex(a){function b(a){var b=parseInt(a,10).toString(16).toUpperCase();return b.length>1?b:"0"+b}return a.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/gi,function(a,c,d,e){return"#"+b(c)+b(d)+b(e)})}function _toMap(a,b){b=b===undefined?",":b;var c,d={},e=_isArray(a)?a:a.split(b);return _each(e,function(a,b){if(c=/^(\d+)\.\.(\d+)$/.exec(b))for(var e=parseInt(c[1],10);e<=parseInt(c[2],10);e++)d[e.toString()]=!0;else d[b]=!0}),d}function _toArray(a,b){return Array.prototype.slice.call(a,b||0)}function _undef(a,b){return a===undefined?b:a}function _invalidUrl(a){return!a||/[<>"]/.test(a)}function _addParam(a,b){return a.indexOf("?")>=0?a+"&"+b:a+"?"+b}function _extend(a,b,c){c||(c=b,b=null);var d;if(b){var e=function(){};e.prototype=b.prototype,d=new e,_each(c,function(a,b){d[a]=b})}else d=c;d.constructor=a,a.prototype=d,a.parent=b?b.prototype:null}function _json(text){var match;(match=/\{[\s\S]*\}|\[[\s\S]*\]/.exec(text))&&(text=match[0]);var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;if(cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return eval("("+text+")");throw"JSON parse error"}function _getBasePath(){for(var a,b=document.getElementsByTagName("script"),c=0,d=b.length;d>c;c++)if(a=b[c].src||"",/kindeditor[\w\-\.]*\.js/.test(a))return a.substring(0,a.lastIndexOf("/")+1);return""}function _bindEvent(a,b,c){a.addEventListener?a.addEventListener(b,c,_useCapture):a.attachEvent&&a.attachEvent("on"+b,c)}function _unbindEvent(a,b,c){a.removeEventListener?a.removeEventListener(b,c,_useCapture):a.detachEvent&&a.detachEvent("on"+b,c)}function KEvent(a,b){this.init(a,b)}function _getId(a){return a[_eventExpendo]||null}function _setId(a){return a[_eventExpendo]=++_eventId,_eventId}function _removeId(a){try{delete a[_eventExpendo]}catch(b){a.removeAttribute&&a.removeAttribute(_eventExpendo)}}function _bind(a,b,c){if(b.indexOf(",")>=0)return void _each(b.split(","),function(){_bind(a,this,c)});var d=_getId(a);d||(d=_setId(a)),_eventData[d]===undefined&&(_eventData[d]={});var e=_eventData[d][b];e&&e.length>0?_unbindEvent(a,b,e[0]):(_eventData[d][b]=[],_eventData[d].el=a),e=_eventData[d][b],0===e.length&&(e[0]=function(b){var c=b?new KEvent(a,b):undefined;_each(e,function(b,d){b>0&&d&&d.call(a,c)})}),_inArray(c,e)<0&&e.push(c),_bindEvent(a,b,e[0])}function _unbind(a,b,c){if(b&&b.indexOf(",")>=0)return void _each(b.split(","),function(){_unbind(a,this,c)});var d=_getId(a);if(d){if(b===undefined)return void(d in _eventData&&(_each(_eventData[d],function(b,c){"el"!=b&&c.length>0&&_unbindEvent(a,b,c[0])}),delete _eventData[d],_removeId(a)));if(_eventData[d]){var e=_eventData[d][b];if(e&&e.length>0){c===undefined?(_unbindEvent(a,b,e[0]),delete _eventData[d][b]):(_each(e,function(a,b){a>0&&b===c&&e.splice(a,1)}),1==e.length&&(_unbindEvent(a,b,e[0]),delete _eventData[d][b]));var f=0;_each(_eventData[d],function(){f++}),2>f&&(delete _eventData[d],_removeId(a))}}}}function _fire(a,b){if(b.indexOf(",")>=0)return void _each(b.split(","),function(){_fire(a,this)});var c=_getId(a);if(c){var d=_eventData[c][b];_eventData[c]&&d&&d.length>0&&d[0]()}}function _ctrl(a,b,c){b=/^\d{2,}$/.test(b)?b:b.toUpperCase().charCodeAt(0),_bind(a,"keydown",function(d){!d.ctrlKey||d.which!=b||d.shiftKey||d.altKey||(c.call(a),d.stop())})}function _ready(a){function b(){e||(e=!0,a(KindEditor),_readyFinished=!0)}function c(){if(!e){try{document.documentElement.doScroll("left")}catch(a){return void setTimeout(c,100)}b()}}function d(){"complete"===document.readyState&&b()}if(_readyFinished)return void a(KindEditor);var e=!1;if(document.addEventListener)_bind(document,"DOMContentLoaded",b);else if(document.attachEvent){_bind(document,"readystatechange",d);var f=!1;try{f=null==window.frameElement}catch(g){}document.documentElement.doScroll&&f&&c()}_bind(window,"load",b)}function _getCssList(a){a=a.replace(/"/g,'"');for(var b,c={},d=/\s*([\w\-]+)\s*:([^;]*)(;|$)/g;b=d.exec(a);){var e=_trim(b[1].toLowerCase()),f=_trim(_toHex(b[2]));c[e]=f}return c}function _getAttrList(a){for(var b,c={},d=/\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g;b=d.exec(a);){var e=(b[1]||b[2]||b[4]||b[6]).toLowerCase(),f=(b[2]?b[3]:b[4]?b[5]:b[7])||"";c[e]=f}return c}function _addClassToTag(a,b){return a=/\s+class\s*=/.test(a)?a.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/,function(a,c,d,e){return(" "+d+" ").indexOf(" "+b+" ")<0?""===d?c+b+e:c+d+" "+b+e:a}):a.substr(0,a.length-1)+' class="'+b+'">'}function _formatCss(a){var b="";return _each(_getCssList(a),function(a,c){b+=a+":"+c+";"}),b}function _formatUrl(a,b,c,d){function e(a){for(var b=a.split("/"),c=[],d=0,e=b.length;e>d;d++){var f=b[d];".."==f?c.length>0&&c.pop():""!==f&&"."!=f&&c.push(f)}return"/"+c.join("/")}function f(b,c){if(a.substr(0,b.length)===b){for(var e=[],g=0;c>g;g++)e.push("..");var i=".";return e.length>0&&(i+="/"+e.join("/")),"/"==d&&(i+="/"),i+a.substr(b.length)}return(h=/^(.*)\//.exec(b))?f(h[1],++c):void 0}if(b=_undef(b,"").toLowerCase(),"data:"!=a.substr(0,5)&&(a=a.replace(/([^:])\/\//g,"$1/")),_inArray(b,["absolute","relative","domain"])<0)return a;if(c=c||location.protocol+"//"+location.host,d===undefined){var g=location.pathname.match(/^(\/.*)\//);d=g?g[1]:""}var h;if(h=/^(\w+:\/\/[^\/]*)/.exec(a)){if(h[1]!==c)return a}else if(/^\w+:/.test(a))return a;return/^\//.test(a)?a=c+e(a.substr(1)):/^\w+:\/\//.test(a)||(a=c+e(d+"/"+a)),"relative"===b?a=f(c+d,0).substr(2):"absolute"===b&&a.substr(0,c.length)===c&&(a=a.substr(c.length)),a}function _formatHtml(a,b,c,d,e){null==a&&(a=""),c=c||"",d=_undef(d,!1),e=_undef(e," ");var f="xx-small,x-small,small,medium,large,x-large,xx-large".split(",");a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/gi,function(a,b,c,d){return b+c.replace(/<(?:br|br\s[^>]*)>/gi,"\n")+d}),a=a.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/gi,"
"),a=a.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/gi,"$1
$2"),a=a.replace(/\u200B/g,""),a=a.replace(/\u00A9/g,"©"),a=a.replace(/\u00AE/g,"®"),a=a.replace(/\u2003/g," "),a=a.replace(/\u3000/g," "),a=a.replace(/<[^>]+/g,function(a){return a.replace(/\s+/g," ")});var g={};b&&(_each(b,function(a,b){for(var c=a.split(","),d=0,e=c.length;e>d;d++)g[c[d]]=_toMap(b)}),g.script||(a=a.replace(/(<(?:script|script\s[^>]*)>)([\s\S]*?)(<\/script>)/gi,"")),g.style||(a=a.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/gi,"")));var h=/(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g,i=[];return a=a.replace(h,function(a,h,j,k,l,m,n){var o=a,p=h||"",q=j||"",r=k.toLowerCase(),s=l||"",t=m?" "+m:"",u=n||"";if(b&&!g[r])return"";if(""===t&&_SINGLE_TAG_MAP[r]&&(t=" /"),_INLINE_TAG_MAP[r]&&(p&&(p=" "),u&&(u=" ")),_PRE_TAG_MAP[r]&&(q?u="\n":p="\n"),d&&"br"==r&&(u="\n"),_BLOCK_TAG_MAP[r]&&!_PRE_TAG_MAP[r])if(d){q&&i.length>0&&i[i.length-1]===r?i.pop():i.push(r),p="\n",u="\n";for(var v=0,w=q?i.length:i.length-1;w>v;v++)p+=e,q||(u+=e);t?i.pop():q||(u+=e)}else p=u="";if(""!==s){var x=_getAttrList(o);if("font"===r){var y={},z="";_each(x,function(a,b){"color"===a&&(y.color=b,delete x[a]),"size"===a&&(y["font-size"]=f[parseInt(b,10)-1]||"",delete x[a]),"face"===a&&(y["font-family"]=b,delete x[a]),"style"===a&&(z=b)}),z&&!/;$/.test(z)&&(z+=";"),_each(y,function(a,b){""!==b&&(/\s/.test(b)&&(b="'"+b+"'"),z+=a+":"+b+";")}),x.style=z}_each(x,function(a,d){if(_FILL_ATTR_MAP[a]&&(x[a]=a),_inArray(a,["src","href"])>=0&&(x[a]=_formatUrl(d,c)),(b&&"style"!==a&&!g[r]["*"]&&!g[r][a]||"body"===r&&"contenteditable"===a||/^kindeditor_\d+$/.test(a))&&delete x[a],"style"===a&&""!==d){var e=_getCssList(d);_each(e,function(a,c){!b||g[r].style||g[r]["."+a]||delete e[a]});var f="";_each(e,function(a,b){f+=a+":"+b+";"}),x.style=f}}),s="",_each(x,function(a,b){("style"!==a||""!==b)&&(b=b.replace(/"/g,"""),s+=" "+a+'="'+b+'"')})}return"font"===r&&(r="span"),p+"<"+q+r+s+t+">"+u}),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/gi,function(a,b,c,d){return b+c.replace(/\n/g,'\n')+d}),a=a.replace(/\n\s*\n/g,"\n"),a=a.replace(/\n/g,"\n"),_trim(a)}function _clearMsWord(a,b){return a=a.replace(//gi,"").replace(//gi,"").replace(/"];return _isArray(c)||(c=[c]),_each(c,function(a,b){b&&e.push('')}),d&&e.push(""),e.push("