├── .babelrc ├── .browserslistrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .prettierrc ├── MIT-LICENSE.txt ├── README.md ├── build ├── build.js ├── dev-client.js ├── dev-server.js ├── utils.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js ├── prod.env.js └── test.env.js ├── dist ├── index.html ├── static │ ├── demo.md │ ├── js │ │ └── jquery-3.1.1.min.js │ └── qrcode-ssq.jpg └── vendor.css ├── gh-page.sh ├── index.html ├── mpeditor.png ├── package.json ├── postcss.config.js ├── src ├── css │ ├── common.less │ ├── mixins.less │ ├── mpeditor.less │ ├── nav.less │ ├── preview.less │ ├── theme-white.less │ ├── theme.less │ ├── tooltip.less │ └── var.less ├── img │ ├── square.png │ └── square_check_fill.png ├── js │ ├── blockquote.js │ ├── download.js │ ├── plugins │ │ ├── blockify-tag.js │ │ ├── blockquote.js │ │ ├── footnote.js │ │ ├── highlight.js │ │ ├── image.js │ │ ├── lib │ │ │ └── custom-tag.js │ │ ├── list.js │ │ └── table-container.js │ └── utils.js ├── main.js ├── mpeditor.html └── mpeditor.js ├── static ├── demo.md ├── js │ └── jquery-3.1.1.min.js ├── kfive.md ├── qrcode-ssq.jpg └── touji.md ├── webpack.config.js └── wechat.jpeg /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [["@babel/preset-env"]], 3 | "plugins": ["@babel/plugin-proposal-class-properties"], 4 | "comments": false, 5 | "exclude": "node_modules" 6 | } 7 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | chrome >= 60 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [{.travis.yml,ci.yml}] 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@ecomfe/eslint-config'], 3 | rules: { 4 | 'comma-dangle': 'off', 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .DS_Store 3 | gh-pages 4 | node_modules/ 5 | npm-debug.log 6 | test/unit/coverage 7 | dist 8 | yarn.lock 9 | package-lock.json 10 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "semi": true, 4 | "printWidth": 120, 5 | "tabWidth": 4, 6 | "useTabs": false, 7 | "bracketSpacing": false, 8 | "trailingComma": "none", 9 | "arrowParens": "avoid", 10 | "overrides": [ 11 | { 12 | "files": ".prettierrc", 13 | "options": { "parser": "json" } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2017 Theowang http://js8.in 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 欢迎使用 MPEditor Markdown 编辑器 2 | 3 | **MPEditor**是专注于微信公众号的编辑阅读器,利用MPEditor可以使用 **Markdown** 语法编写微信公众号文章,编辑完后可以复制到公众号发布平台直接发布,真正的实现即看即所得(保证不会乱~): 4 | 5 | * 更加贴合微信UI标准 6 | * 支持实时预览 7 | * 支持同步滚动 8 | * 支持语法高亮 9 | * 支持emoji表情(注意开了水印会影响效果) 10 | * 扩展语法支持自定义颜色和字号 11 | 12 | > MPEditor解决了微信公众号编辑中遇见的一些编辑问题,增加了「工(ma)程(nong)师(men)」经常遇见的代码高亮、emoji问题。希望你会喜欢这种极(zhuang)客(bi)的体验 13 | 14 | 在线体验:http://js8.in/mpeditor 15 | 16 | ![MPEditor](./mpeditor.png) 17 | 18 | ## 部署 19 | 20 | ```bash 21 | npm i 22 | # 本地测试 23 | npm run dev 24 | # 发布 25 | npm run build 26 | ``` 27 | 28 | ## 广告 29 | ![关注三水清](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 30 | 31 | 上面是个「三水清」的微信公众号二维码,欢迎扫描关注 32 | 33 | ## 给作者加鸡腿 34 | 35 | ![加鸡腿](./wechat.jpeg) 36 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const ora = require('ora'); 3 | const shell = require('shelljs'); 4 | const path = require('path'); 5 | const chalk = require('chalk'); 6 | process.env.NODE_ENV = 'production'; 7 | const webpackConfig = require('./webpack.prod.conf'); 8 | const config = require('../config'); 9 | 10 | const spinner = ora('building for production...'); 11 | spinner.start(); 12 | 13 | const assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory); 14 | shell.rm('-rf', assetsPath); 15 | shell.mkdir('-p', assetsPath); 16 | shell.config.silent = true; 17 | shell.cp('-R', 'static/*', assetsPath); 18 | shell.config.silent = false; 19 | 20 | webpack(webpackConfig, function (err, stats) { 21 | spinner.stop(); 22 | if (err) { 23 | throw err; 24 | } 25 | process.stdout.write( 26 | stats.toString({ 27 | colors: true, 28 | modules: false, 29 | children: false, 30 | chunks: false, 31 | chunkModules: false, 32 | }) + '\n\n' 33 | ); 34 | 35 | console.log(chalk.cyan(' Build complete.\n')); 36 | console.log( 37 | chalk.yellow( 38 | ' Tip: built files are meant to be served over an HTTP server.\n' + 39 | " Opening index.html over file:// won't work.\n" 40 | ) 41 | ); 42 | }); 43 | -------------------------------------------------------------------------------- /build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true'); 3 | 4 | hotClient.subscribe(function (event) { 5 | if (event.action === 'reload') { 6 | window.location.reload(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /build/dev-server.js: -------------------------------------------------------------------------------- 1 | const config = require('../config'); 2 | 3 | const opn = require('opn'); 4 | const path = require('path'); 5 | const express = require('express'); 6 | const webpack = require('webpack'); 7 | const proxyMiddleware = require('http-proxy-middleware'); 8 | const webpackConfig = require('./webpack.dev.conf'); 9 | 10 | // default port where dev server listens for incoming traffic 11 | const port = process.env.PORT || config.dev.port; 12 | // automatically open browser, if not set will be false 13 | const autoOpenBrowser = !!config.dev.autoOpenBrowser; 14 | // Define HTTP proxies to your custom API backend 15 | // https://github.com/chimurai/http-proxy-middleware 16 | const proxyTable = config.dev.proxyTable; 17 | 18 | const app = express(); 19 | const compiler = webpack(webpackConfig); 20 | const devMiddleware = require('webpack-dev-middleware')(compiler, { 21 | publicPath: webpackConfig.output.publicPath, 22 | quiet: true 23 | }); 24 | 25 | const hotMiddleware = require('webpack-hot-middleware')(compiler, { 26 | log: () => {} 27 | }); 28 | // force page reload when html-webpack-plugin template changes 29 | compiler.plugin('compilation', function (compilation) { 30 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 31 | hotMiddleware.publish({action: 'reload'}); 32 | cb(); 33 | }); 34 | }); 35 | 36 | // proxy api requests 37 | Object.keys(proxyTable).forEach(function (context) { 38 | var options = proxyTable[context]; 39 | if (typeof options === 'string') { 40 | options = {target: options}; 41 | } 42 | app.use(proxyMiddleware(options.filter || context, options)); 43 | }); 44 | 45 | // handle fallback for HTML5 history API 46 | app.use(require('connect-history-api-fallback')()); 47 | 48 | // serve webpack bundle output 49 | app.use(devMiddleware); 50 | 51 | // enable hot-reload and state-preserving 52 | // compilation error display 53 | app.use(hotMiddleware); 54 | 55 | // serve pure static assets 56 | const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory); 57 | app.use(staticPath, express.static('./static')); 58 | 59 | const uri = 'http://localhost:' + port; 60 | 61 | devMiddleware.waitUntilValid(function () { 62 | console.log('> Listening at ' + uri + '\n'); 63 | }); 64 | 65 | module.exports = app.listen(port, function (err) { 66 | if (err) { 67 | console.log(err); 68 | return; 69 | } 70 | 71 | // when env is testing, don't need open it 72 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 73 | opn(uri); 74 | } 75 | }); 76 | -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const config = require('../config'); 3 | // const ExtractTextPlugin = require('extract-text-webpack-plugin'); 4 | 5 | exports.assetsPath = function (_path) { 6 | const assetsSubDirectory = 7 | process.env.NODE_ENV === 'production' ? config.build.assetsSubDirectory : config.dev.assetsSubDirectory; 8 | return path.posix.join(assetsSubDirectory, _path); 9 | }; 10 | 11 | exports.cssLoaders = function (options) { 12 | options = options || {}; 13 | // generate loader string to be used with extract text plugin 14 | function generateLoaders(loaders) { 15 | const sourceLoader = loaders 16 | .map(function (loader) { 17 | var extraParamChar; 18 | if (/\?/.test(loader)) { 19 | loader = loader.replace(/\?/, '-loader?'); 20 | extraParamChar = '&'; 21 | } else { 22 | loader = loader + '-loader'; 23 | extraParamChar = '?'; 24 | } 25 | return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : ''); 26 | }) 27 | .join('!'); 28 | 29 | // Extract CSS when that option is specified 30 | // (which is the case during production build) 31 | // if (options.extract) { 32 | // return ExtractTextPlugin.extract({ 33 | // use: sourceLoader, 34 | // fallback: 'vue-style-loader' 35 | // }) 36 | // } else { 37 | // return ['vue-style-loader', sourceLoader].join('!') 38 | // } 39 | } 40 | 41 | // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html 42 | return { 43 | css: generateLoaders(['css']), 44 | postcss: generateLoaders(['css']), 45 | less: generateLoaders(['css', 'less']), 46 | }; 47 | }; 48 | 49 | // Generate loaders for standalone style files (outside of .vue) 50 | exports.styleLoaders = function (options) { 51 | const output = []; 52 | const loaders = exports.cssLoaders(options); 53 | for (let extension in loaders) { 54 | const loader = loaders[extension]; 55 | output.push({ 56 | test: new RegExp('\\.' + extension + '$'), 57 | loader, 58 | }); 59 | } 60 | return output; 61 | }; 62 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | const utils = require('./utils'); 2 | const webpack = require('webpack'); 3 | const config = require('../config'); 4 | const merge = require('webpack-merge'); 5 | const baseWebpackConfig = require('../webpack.config'); 6 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 7 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(name => { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]); 12 | }); 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | mode: 'development', 16 | module: { 17 | rules: utils.styleLoaders({sourceMap: config.dev.cssSourceMap}) 18 | }, 19 | // cheap-module-eval-source-map is faster for development 20 | devtool: '#cheap-module-eval-source-map', 21 | plugins: [ 22 | new webpack.DefinePlugin({ 23 | 'process.env': config.dev.env 24 | }), 25 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 26 | new webpack.HotModuleReplacementPlugin(), 27 | new webpack.NoEmitOnErrorsPlugin(), 28 | // https://github.com/ampedandwired/html-webpack-plugin 29 | new HtmlWebpackPlugin({ 30 | filename: 'index.html', 31 | template: 'index.html', 32 | inject: true 33 | }), 34 | new FriendlyErrorsPlugin() 35 | ] 36 | }); 37 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const utils = require('./utils'); 3 | const webpack = require('webpack'); 4 | const config = require('../config'); 5 | const merge = require('webpack-merge'); 6 | const baseWebpackConfig = require('../webpack.config'); 7 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 8 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 9 | const TerserPlugin = require('terser-webpack-plugin'); 10 | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); 11 | const env = process.env.NODE_ENV === 'testing' ? require('../config/test.env') : config.build.env; 12 | 13 | const webpackConfig = merge(baseWebpackConfig, { 14 | mode: 'production', 15 | module: { 16 | rules: utils.styleLoaders({ 17 | sourceMap: config.build.productionSourceMap, 18 | extract: true 19 | }) 20 | }, 21 | devtool: config.build.productionSourceMap ? '#source-map' : false, 22 | output: { 23 | path: config.build.assetsRoot, 24 | publicPath: './', 25 | filename: utils.assetsPath('js/[name].[chunkhash:7].js'), 26 | chunkFilename: utils.assetsPath('js/[name].[chunkhash:7].js') 27 | }, 28 | optimization: { 29 | minimizer: [ 30 | new TerserPlugin({ 31 | cache: true, 32 | parallel: true, 33 | sourceMap: true, // Must be set to true if using source-maps in production 34 | terserOptions: { 35 | comments: false, 36 | compress: { 37 | unused: true, 38 | // 删掉 debugger 39 | drop_debugger: true, // eslint-disable-line 40 | // 移除 console 41 | drop_console: true, // eslint-disable-line 42 | // 移除无用的代码 43 | dead_code: true // eslint-disable-line 44 | }, 45 | ie8: false, 46 | safari10: true, 47 | warnings: false, 48 | toplevel: true 49 | } 50 | }), 51 | new OptimizeCSSAssetsPlugin({ 52 | assetNameRegExp: /\.css$/g, 53 | cssProcessorOptions: { 54 | mergeLonghand: false, 55 | cssDeclarationSorter: false, 56 | normalizeUrl: false, 57 | discardUnused: false, 58 | // 避免 cssnano 重新计算 z-index 59 | zindex: false, 60 | reduceIdents: false, 61 | safe: true, 62 | // cssnano 集成了autoprefixer的功能 63 | // 会使用到autoprefixer进行无关前缀的清理 64 | // 关闭autoprefixer功能 65 | // 使用postcss的autoprefixer功能 66 | autoprefixer: false, 67 | discardComments: { 68 | removeAll: true 69 | } 70 | }, 71 | canPrint: true 72 | }) 73 | ], 74 | splitChunks: { 75 | chunks: 'all', 76 | minSize: 30000, 77 | maxSize: 0, 78 | minChunks: 1, 79 | maxAsyncRequests: 6, 80 | maxInitialRequests: 4, 81 | automaticNameDelimiter: '~', 82 | cacheGroups: { 83 | default: false, 84 | common: { 85 | name: 'vendor', 86 | test: /[\\/]node_modules[\\/]/, 87 | enforce: true, 88 | priority: 9 89 | } 90 | } 91 | } 92 | }, 93 | plugins: [ 94 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 95 | new webpack.DefinePlugin({ 96 | 'process.env': env 97 | }), 98 | // extract css into its own file 99 | new MiniCssExtractPlugin({ 100 | filename: utils.assetsPath('css/[name].[contenthash:7].css'), 101 | chunkFilename: '[name].css' 102 | }), 103 | // generate dist index.html with correct asset hash for caching. 104 | // you can customize output by editing /index.html 105 | // see https://github.com/ampedandwired/html-webpack-plugin 106 | new HtmlWebpackPlugin({ 107 | filename: process.env.NODE_ENV === 'testing' ? 'index.html' : config.build.index, 108 | template: 'index.html', 109 | inject: true, 110 | minify: { 111 | removeComments: true, 112 | collapseWhitespace: true, 113 | removeAttributeQuotes: true 114 | // more options: 115 | // https://github.com/kangax/html-minifier#options-quick-reference 116 | }, 117 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 118 | chunksSortMode: 'dependency' 119 | }) 120 | ] 121 | }); 122 | 123 | if (config.build.bundleAnalyzerReport) { 124 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; 125 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()); 126 | } 127 | 128 | module.exports = webpackConfig; 129 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge'); 2 | var prodEnv = require('./prod.env'); 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"', 6 | }); 7 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | const path = require('path'); 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: './', 11 | productionSourceMap: false, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | // Run the build command with an extra argument to 17 | // View the bundle analyzer report after build finishes: 18 | // `npm run build --report` 19 | // Set to `true` or `false` to always turn it on or off 20 | }, 21 | dev: { 22 | env: require('./dev.env'), 23 | port: 8098, 24 | autoOpenBrowser: true, 25 | assetsSubDirectory: 'static', 26 | assetsPublicPath: '/', 27 | proxyTable: {}, 28 | // CSS Sourcemaps off by default because relative paths are "buggy" 29 | // with this option, according to the CSS-Loader README 30 | // (https://github.com/webpack/css-loader#sourcemaps) 31 | // In our experience, they generally work as expected, 32 | // just be aware of this issue when enabling this option. 33 | cssSourceMap: false, 34 | }, 35 | }; 36 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"', 3 | }; 4 | -------------------------------------------------------------------------------- /config/test.env.js: -------------------------------------------------------------------------------- 1 | const merge = require('webpack-merge'); 2 | const devEnv = require('./dev.env'); 3 | 4 | module.exports = merge(devEnv, { 5 | NODE_ENV: '"testing"', 6 | }); 7 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | MPEditor - 微信公众号Markdown编辑器
-------------------------------------------------------------------------------- /dist/static/demo.md: -------------------------------------------------------------------------------- 1 | # 公众号 Markdown 编辑器 2 | 3 | **MPEditor**是专注于微信公众号的编辑阅读器,利用 MPEditor 可以使用 **Markdown** 语法编写微信公众号文章,编辑完后可以复制到公众号发布平台直接发布,真正的实现即看即所得: 4 | 5 | - 更加贴合微信 UI 标准 6 | - 支持实时预览 7 | - 支持同步滚动 8 | - 支持语法高亮 9 | - 自动加「参考资料」脚注 10 | 11 | > MPEditor 解决了微信公众号编辑中遇见的一些编辑问题,增加了「工(ma)程(nong)师(men)」经常遇见的代码高亮、emoji 问题。希望你会喜欢这种极(zhuang)客(bi)的体验 12 | 13 | 使用方法 14 | 15 | 在左侧 Markdown 编辑器中编写 Markdown 格式的内容,编辑完成后点击右上角`√`,复制内容到微信编辑器粘贴即可。 16 | 17 | ## 本编辑器支持快捷键 18 | 19 | - `⌘+S` / `Ctrl+S`:保存编写的内容 20 | - `⌘+B` / `Ctrl+B`:加粗 21 | - `⌘+I` / `Ctrl+I`:斜体 22 | - `⌘+'` / `Ctrl+'`:引用 23 | - `⌘+U` / `Ctrl+U`:删除线, 24 | - `⌘+P` / `Ctrl+P`:快速插入图片, 25 | - `⌘+H` / `Ctrl+H`:`header-box`语法,(往后看) 26 | - `⌘+K` / `Ctrl+K`:快速链接 27 | 28 | 什么是 Markdown 29 | 30 | Markdown 是一种方便记忆、书写的纯文本标记语言,用户可以使用这些标记符号以最小的输入代价生成极富表现力的文档:譬如您正在阅读的这份文档。它使用简单的符号标记不同的标题,分割不同的段落,**粗体** 、 _斜体_ 、~~delete~~ 某些文字。MPEditor 使用了 [markdown-it](https://github.com/markdown-it/markdown-it 'markdown-it')转换语法,[CodeMirror](https://codemirror.net 'CodeMirror')来做编辑器 31 | 32 | 语法 33 | 34 | ## 1. 标题 35 | 标题样式使用`#`来创建,分别有六种标题样式: 36 | 37 | ### 标题三 38 | 39 | #### 标题四 40 | 41 | ##### 标题五,不常用 42 | 43 | ###### 标题六,不常用 44 | 45 | ## 2. 列表样式 46 | 列表支持有序列表和无需列表。 47 | 48 | - 偶是个无序列表 49 | - 我是个二级无序列表 50 | - 真巧啊我也是个无序列表 51 | 52 | 1. 我是个有序列表啊 53 | 2. 嗯,me too~ 54 | 3. markdown so easy! 妈妈再也不用担心我的**学习**了 55 | 56 | !> 由于微信原因,最多支持到二级列表。 57 | 58 | ## 3. 高亮代码 59 | 60 | 使用了微信原生语法高亮,复制代码到微信编辑器中自动替换为微信的语法高亮。 61 | 62 | ```js 63 | // 新语法检测 64 | import $ from 'jQuery'; 65 | $(document).on('click', () => { 66 | let that = this; 67 | console.log(that); 68 | }); 69 | 70 | var aceEditor = new ace.editor('#id'); 71 | 72 | $(function () { 73 | $('div').html('I am a div.'); 74 | $('div').html('I am a long long long long long long long long long long long long long string.'); 75 | }); 76 | ``` 77 | 78 | 上面是 `JavaScript`,下面是 `php`: 79 | 80 | ```php 81 | echo 'hello,world' 82 | ``` 83 | 84 | ## 4. 链接 85 | 86 | 链接样式使用`![]()`方式编写如下面: 87 | 88 | - MPEditor:https://github.com/ksky521/mpeditor 89 | - demo: [点击查看 demo](https://github.com/ksky521/mpeditor/blob/master/static/demo.md) 90 | 91 | 另外还支持[脚注语法](https://github.com "Github"),滑到页面底部会看到参考资料。 92 | 93 | ## 5. 表格样式 94 | 95 | 下面是个普通的表格 96 | | 公众号 | id | 备注 | 97 | |:-----|-----|:------:| 98 | | 三水清 | sanshuiqing123 | 作者很帅 | 99 | | 博客 | http://js8.in | 程序媛鼓励师 | 100 | 101 | 支持另外一种语法: 102 | 公众号 | id/网址 | 备注 103 | ------------ | ---------- | ------ 104 | 三水清 | sanshuiqing123 | 作者很帅 105 | 博客 | http://js8.in | 程序媛鼓励师 106 | 107 | 宽度过长的表格可以滚动,可在自定义主题中调节宽度: 108 | 109 | | 姓名 | 年龄 | 工作 | 邮箱 | 手机 | 110 | | :--------- | :--: | -----------: | :-------------: | :---------: | 111 | | 小可爱 | 18 | 吃可爱多 | lovely@test.com | 18812345678 | 112 | | 小小勇敢 | 20 | 爬棵勇敢树 | brave@test.com | 17712345678 | 113 | | 小小小机智 | 22 | 看一本机智书 | smart@test.com | 16612345678 | 114 | 115 | 116 | ## 6. 图片格式 117 | 118 | 图片支持简单的样式,例如下面的: 119 | 120 | ![关注三水清](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 121 | 122 | 还支持在`()`中填写图片的尺寸,例如换个小点的头像: 123 | 124 | ![关注三水清](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg =120x120) 125 | 126 | 另外还支持``标签语法,添加图片横屏滑动幻灯片(灵感来自MarkdownNice) 127 | 128 | 左右滑动展示更多 129 | 130 | 这是个竖向滑动的 131 | 132 | 上下滑动展示更多 133 | ## 7. 引用 134 | 135 | > MPEditor 解决了微信公众号编辑中遇见的一些编辑问题,增加了「工(ma)程(nong)师(men)」经常遇见的代码高亮、emoji 问题。希望你会喜欢这种极(zhuang)客(bi)的体验 136 | 137 | 下面是个特殊的引用,背景是红色 138 | 139 | !> MPEditor 解决了微信公众号编辑中遇见的一些编辑问题,增加了「工(ma)程(nong)师(men)」经常遇见的代码高亮、emoji 问题。希望你会喜欢这种极(zhuang)客(bi)的体验 140 | 141 | ### 多级引用 142 | 143 | 引用的格式是在符号 `>` 后面书写文字,文字的内容可以包含标题、链接、图片、粗体和斜体等。 144 | 145 | 一级引用如下: 146 | 147 | > ### 一级引用示例 148 | > 149 | > 读一本好书,就是在和高尚的人谈话。 **——歌德** 150 | > 151 | > [网站](https://js8.in) 152 | > 153 | > ![这里写图片描述](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 154 | 155 | 当使用多个 `>` 符号时,就会变成多级引用 156 | 157 | 二级引用如下: 158 | 159 | > > ### 二级引用示例 160 | > > 161 | > > 读一本好书,就是在和高尚的人谈话。 **——歌德** 162 | > > 163 | > > [网站](https://js8.in) 164 | > > 165 | > > ![这里写图片描述](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 166 | 167 | 三级引用如下: 168 | 169 | > > > ### 三级引用示例 170 | > > > 171 | > > > 读一本好书,就是在和高尚的人谈话。 **——歌德** 172 | > > > 173 | > > > [网站](https://js8.in) 174 | > > > 175 | > > > ![这里写图片描述](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 176 | 177 | ## 8. 分割线 178 | 179 | --分割线-- 180 | 181 | ==密封线== 182 | 183 | ## 9. 特殊组件 184 | 185 | ?> 下面是一些特殊样式,你可能用得到 186 | 187 | #### 盒子标题 188 | 189 | 盒子标题 190 | 191 | #### 主副标题样式 192 | 193 | 这是标题 194 | 195 | 这里是主标题 196 | 197 | #### 底部扫码 198 | 199 | 200 | 201 | 202 | ## 10. 支持html 203 | 204 | 例如我们内置样色 `class`: 205 | 206 | green/success 207 | info/blue 208 | danger/red 209 | warning/yellow 210 | gray 211 | 212 | ### 其他样式 213 | 214 | 自定义样式字号等 215 | 216 | 再一次感谢您花费时间阅读这份欢迎稿! 217 | 218 | --EOF-- 219 | 220 | 作者[@三水清](http://weibo.com/sanshuiqing)
221 | 2021 年 01 月 12 日 222 | 223 |
224 |

下面是个「三水清」的微信公众号二维码,欢迎扫描关注:

225 | 226 |
227 | -------------------------------------------------------------------------------- /dist/static/qrcode-ssq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksky521/mpeditor/af34458627a0da7d70e9cf4216c4cda5a661609b/dist/static/qrcode-ssq.jpg -------------------------------------------------------------------------------- /dist/vendor.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:initial;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:initial}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:initial}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}[hidden],template{display:none} -------------------------------------------------------------------------------- /gh-page.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | npm run build 4 | rm -rf gh-pages 5 | mkdir gh-pages 6 | cp -r dist/* gh-pages 7 | cd gh-pages 8 | 9 | sed -i "" "s/src=\/static/src=.\/static/g" index.html 10 | 11 | git init 12 | git add -A 13 | date_str=`date "+DATE: %m/%d/%Y%nTIME: %H:%M:%S"` 14 | git commit -m "build on $date_str" 15 | echo 'push remote github' 16 | git push -u git@github.com:ksky521/mpeditor.git master:gh-pages --force 17 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MPEditor - 微信公众号Markdown编辑器 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /mpeditor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksky521/mpeditor/af34458627a0da7d70e9cf4216c4cda5a661609b/mpeditor.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mpeditor", 3 | "author": "ksky521 ", 4 | "version": "1.0.0", 5 | "scripts": { 6 | "start": "node build/dev-server.js", 7 | "build": "node build/build.js" 8 | }, 9 | "keywords": [ 10 | "wechat", 11 | "markdown", 12 | "mped ", 13 | "wechat editor", 14 | "markdown editor" 15 | ], 16 | "license": "MIT", 17 | "lint-staged": { 18 | "(src|build|config)/**/*.js": [ 19 | "eslint --fix" 20 | ] 21 | }, 22 | "husky": { 23 | "hooks": { 24 | "pre-commit": "lint-staged" 25 | } 26 | }, 27 | "description": "wechat markdown editor", 28 | "devDependencies": { 29 | "@babel/core": "^7.4.5", 30 | "@babel/plugin-proposal-class-properties": "^7.8.3", 31 | "@babel/preset-env": "^7.4.5", 32 | "@ecomfe/eslint-config": "^4.0.0", 33 | "autoprefixer": "^9.8.2", 34 | "babel-eslint": "^10.1.0", 35 | "babel-loader": "^8.1.0", 36 | "chalk": "^4.1.0", 37 | "connect-history-api-fallback": "^1.3.0", 38 | "css-loader": "^3.6.0", 39 | "cssnano": "^4.1.10", 40 | "eslint": "^6.8.0", 41 | "eslint-friendly-formatter": "^4.0.1", 42 | "eslint-loader": "^4.0.2", 43 | "eslint-plugin-babel": "^5.3.0", 44 | "express": "^4.14.1", 45 | "file-loader": "^6.0.0", 46 | "friendly-errors-webpack-plugin": "^1.3.1", 47 | "html-webpack-plugin": "^3.0.0", 48 | "html-loader":"^1.3.2", 49 | "http-proxy-middleware": "^1.0.4", 50 | "husky": "^4.0.0", 51 | "less": "^3.11.3", 52 | "less-loader": "^6.1.1", 53 | "lint-staged": "^9.2.5", 54 | "mini-css-extract-plugin": "^0.9.0", 55 | "opn": "^6.0.0", 56 | "optimize-css-assets-webpack-plugin": "^5.0.3", 57 | "ora": "^4.0.4", 58 | "postcss-loader": "^3.0.0", 59 | "shelljs": "^0.8.4", 60 | "strip-ansi": "^6.0.0", 61 | "style-loader": "^1.2.1", 62 | "terser-webpack-plugin": "^3.0.6", 63 | "url-loader": "^4.1.0", 64 | "webpack": "^4.43.0", 65 | "webpack-dev-middleware": "^3.7.2", 66 | "webpack-hot-middleware": "^2.17.0", 67 | "webpack-merge": "^4.2.2" 68 | }, 69 | "main": "src/js/mpeditor", 70 | "dependencies": { 71 | "handlebars":"^4.7.7", 72 | "highlight.js": "~10.5.0", 73 | "markdown-it": "~12.0.4", 74 | "markdown-it-imsize": "~2.0.1", 75 | "clipboard": "^2.0.6", 76 | "normalize.css": "^8.0.1", 77 | "pangu": "^4.0.7" 78 | }, 79 | "engines": { 80 | "node": ">= 4.0.0", 81 | "npm": ">= 3.0.0" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [require('autoprefixer')] 3 | }; 4 | -------------------------------------------------------------------------------- /src/css/common.less: -------------------------------------------------------------------------------- 1 | * { 2 | padding: 0; 3 | margin: 0; 4 | } 5 | 6 | html { 7 | font-size: 12px; 8 | } 9 | 10 | body, 11 | button, 12 | input, 13 | select { 14 | font-family: PingFang SC, Hiragino Sans GB, Microsoft Yahei, sans-serif; 15 | } 16 | 17 | body { 18 | font-size: 14px; 19 | line-height: 20px; 20 | } 21 | -------------------------------------------------------------------------------- /src/css/mixins.less: -------------------------------------------------------------------------------- 1 | .clearfix { 2 | &::after { 3 | display: block; 4 | content: ''; 5 | clear: both; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/css/mpeditor.less: -------------------------------------------------------------------------------- 1 | @import 'mixins'; 2 | @import 'var'; 3 | @import 'tooltip'; 4 | @import 'preview'; 5 | @import 'nav'; 6 | @import 'theme'; 7 | .mpeditor { 8 | position: relative; 9 | // overflow-y: hidden; 10 | .clearfix(); 11 | .mpe-col { 12 | width: 50%; 13 | height: 100%; 14 | } 15 | .CodeMirror { 16 | font-size: @editor-font-size; 17 | line-height: @editor-line-height; 18 | height: 100vh; 19 | box-shadow: inset 0 0 12px -6px #000 !important; 20 | } 21 | .mpe { 22 | &_fl { 23 | float: left; 24 | } 25 | &_fr { 26 | float: right; 27 | } 28 | &-toast { 29 | position: fixed; 30 | z-index: 5000; 31 | width: 100px; 32 | height: 100px; 33 | top: 40%; 34 | left: 50%; 35 | margin-left: -50px; 36 | background: rgba(17, 17, 17, 0.7); 37 | text-align: center; 38 | border-radius: 5px; 39 | color: #fff; 40 | display: none; 41 | svg { 42 | margin-top: 10px; 43 | color: #fff; 44 | width: 50px; 45 | margin-bottom: 10px; 46 | } 47 | p { 48 | margin: 0 0 15px; 49 | } 50 | } 51 | 52 | &-wrap { 53 | display: flex; 54 | margin-top: @nav-height; 55 | .clearfix(); 56 | } 57 | &-nav-wrap { 58 | position: fixed; 59 | } 60 | 61 | // editor 62 | &-editor { 63 | width: 100%; 64 | height: 100%; 65 | border: none; 66 | font-size: @editor-font-size; 67 | line-height: @editor-line-height; 68 | 69 | &-wrap { 70 | // padding-top: 10px; 71 | // height: 100%; 72 | // padding: 0 20px 0 0; 73 | } 74 | .CodeMirror{ 75 | padding: 10px 0; 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/css/nav.less: -------------------------------------------------------------------------------- 1 | @import 'var'; 2 | 3 | // 导航条 4 | .mpe-nav { 5 | &-wrap { 6 | height: @nav-height; 7 | top: 0; 8 | left: 0; 9 | width: 100%; 10 | padding: 0; 11 | border: 0; 12 | border-top: 1px solid rgba(128, 128, 128, 0.1); 13 | border-bottom: 1px solid rgba(128, 128, 128, 0.1); 14 | border-radius: 0; 15 | z-index: 20; 16 | background-color: #222; 17 | // box-shadow:0 1px 3px rgba(0, 0, 0, 0.065); 18 | .clearfix(); 19 | } 20 | &-tools { 21 | list-style-type: none; 22 | } 23 | &-text { 24 | color: #fff; 25 | padding: 8px 11px; 26 | span { 27 | line-height: 24px; 28 | } 29 | } 30 | &-select { 31 | width: 110px; 32 | padding-right: 16px; 33 | select { 34 | border: 0; 35 | outline: 0; 36 | background-color: transparent; 37 | width: 100%; 38 | font-size: inherit; 39 | height: 24px; 40 | line-height: 24px; 41 | position: relative; 42 | z-index: 1; 43 | // padding-left: 15px; 44 | margin-top: 8px; 45 | // padding: 6px 8px; 46 | display: table-cell; 47 | background: #eee; 48 | border: 0; 49 | border-radius: 3px; 50 | } 51 | } 52 | &-item { 53 | float: left; 54 | a { 55 | height: 24px; 56 | width: 24px; 57 | display: block; 58 | padding: 8px 11px; 59 | font-weight: 600; 60 | line-height: 20px; 61 | color: #fff; 62 | position: relative; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/css/preview.less: -------------------------------------------------------------------------------- 1 | @import 'var'; 2 | @import 'theme'; 3 | 4 | .mpe-preview { 5 | @def-color: #3f3f3f; 6 | @def-link-color: @color-primary; 7 | @warn-color: @color-warning; 8 | @title-color: #000; 9 | 10 | @def-font-size: 16px; 11 | @def-line-height: 1.7em; 12 | // 公众号文章样式 13 | font-size: @def-font-size; 14 | line-height: @def-line-height; 15 | color: @def-color; 16 | background-color: #fff; 17 | 18 | // preview 19 | overflow: auto; 20 | padding: 10px 15px; 21 | position: relative; 22 | border: none; 23 | font-size: @editor-font-size; 24 | 25 | &::selection { 26 | background: #fde6ba; 27 | color: #000; 28 | } 29 | &-wrap { 30 | overflow-y: auto; 31 | &.mobile { 32 | box-shadow: 0 0 60px rgba(0, 0, 0, 0.1); 33 | width: 375px; 34 | margin: 0 auto; 35 | } 36 | } 37 | .mpe-section-divider { 38 | margin: 0 !important; 39 | padding: 0 !important; 40 | } 41 | p { 42 | // text-align: justify; 43 | min-height: 0 !important; 44 | margin-bottom: 10px; 45 | } 46 | a { 47 | color: @def-link-color; 48 | text-decoration: none; 49 | } 50 | h1, 51 | h2, 52 | h3, 53 | h4, 54 | h5, 55 | h6 { 56 | margin: 12px 0 8px; 57 | font-weight: bold; 58 | color: @title-color; 59 | } 60 | h1 { 61 | line-height: 1.75; 62 | font-size: 1.2em; 63 | font-weight: 600; 64 | margin: 1.75em auto 0.5em; 65 | text-align: center; 66 | background-color: #303133; 67 | color: #fff; 68 | display: table; 69 | padding: 0 1em; 70 | } 71 | 72 | h2 { 73 | line-height: 1.75; 74 | font-size: 1.2em; 75 | font-weight: 600; 76 | margin: 1.5em auto 0.5em; 77 | } 78 | 79 | h3 { 80 | border-left: 3px solid @color-primary; 81 | text-align: left; 82 | padding-left: 10px; 83 | font-size: 1.1em; 84 | font-weight: 600; 85 | margin: 1.5em 8px 0.5em 0; 86 | } 87 | h4 { 88 | font-size: 16px; 89 | color: #666; 90 | font-weight: 600; 91 | } 92 | h5 { 93 | font-size: 18px; 94 | font-weight: bold; 95 | min-height: 32px; 96 | line-height: 28px; 97 | border-bottom: solid 1px @title-color; 98 | color: @title-color; 99 | display: inline-block; 100 | margin: 12px auto; 101 | padding: 0.5 * @def-font-size 0 0; 102 | text-align: center; 103 | width: 80%; 104 | display: flex; 105 | flex-direction: column; 106 | justify-content: center; 107 | } 108 | h6 { 109 | font-size: 18px; 110 | border-bottom: solid 1px @title-color; 111 | margin-bottom: 10px; 112 | } 113 | 114 | del { 115 | text-decoration: none; 116 | } 117 | 118 | table, 119 | pre, 120 | dl, 121 | q, 122 | ul, 123 | ol { 124 | margin: 16px 0; 125 | } 126 | 127 | ul, 128 | ol { 129 | padding-left: 2em; 130 | } 131 | li { 132 | margin-bottom: 0.25em; 133 | font-size: @def-font-size; 134 | } 135 | 136 | li p { 137 | font-size: @def-font-size; 138 | color: @def-color; 139 | margin: 0.5em 0 !important; 140 | } 141 | ol { 142 | list-style-type: decimal; 143 | } 144 | ul { 145 | list-style-type: disc; 146 | font-size: @def-font-size; 147 | } 148 | ul ul, 149 | ul ol, 150 | ol ul, 151 | ol ol { 152 | margin: 0; 153 | padding-left: 1em; 154 | list-style-type: circle; 155 | } 156 | 157 | p.task-list-list.uncheck { 158 | color: #777; 159 | } 160 | 161 | ol ol, 162 | ul ol { 163 | list-style-type: lower-roman; 164 | } 165 | 166 | ul ul ol, 167 | ul ol ol, 168 | ol ul ol, 169 | ol ol ol { 170 | list-style-type: lower-alpha; 171 | } 172 | 173 | dl { 174 | padding: 0; 175 | } 176 | 177 | dl dt { 178 | font-size: @def-font-size; 179 | font-weight: bold; 180 | font-style: italic; 181 | } 182 | 183 | dl dd { 184 | margin: 0 0 1em; 185 | padding: 0 1em; 186 | } 187 | .table-container { 188 | overflow-x: auto; 189 | } 190 | table { 191 | padding: 0; 192 | border-collapse: collapse; 193 | border-spacing: 0; 194 | font-size: @def-font-size; 195 | font: inherit; 196 | border: 0; 197 | tbody { 198 | margin: 0; 199 | padding: 0; 200 | border: 0; 201 | } 202 | tr { 203 | border: 0; 204 | border-top: 1px solid #ccc; 205 | background-color: white; 206 | margin: 0; 207 | padding: 0; 208 | } 209 | tr:nth-child(2n) { 210 | background-color: #f8f8f8; 211 | } 212 | tr th, 213 | tr td { 214 | min-width: 85px; 215 | font-size: @def-font-size; 216 | border: 1px solid #ccc; 217 | margin: 0; 218 | padding: 3px 8px; 219 | } 220 | tr th { 221 | font-weight: bold; 222 | background-color: #f0f0f0; 223 | } 224 | } 225 | 226 | // 内置样式 227 | span.green, 228 | span.success { 229 | color: @color-success; 230 | } 231 | span.blue, 232 | span.info { 233 | color: @color-primary; 234 | } 235 | span.red, 236 | span.danger { 237 | color: @color-danger; 238 | } 239 | span.yellow, 240 | span.warning { 241 | color: @color-warning; 242 | } 243 | 244 | span.gray { 245 | color: @color-text-secondary; 246 | } 247 | 248 | // 代码相关 249 | code { 250 | margin: 0 3px; 251 | display: inline; 252 | color: #d14; 253 | border-radius: 4px; 254 | padding: 0 4px; 255 | 256 | // border: 1px solid #e2e2e2 !important; 257 | background: rgba(27, 31, 35, 0.05); 258 | font-size: 14px; 259 | font-family: 'consolas', 'menlo', 'courier', 'monospace', 'Microsoft Yahei' !important; 260 | } 261 | 262 | /*wechat code block*/ 263 | // .code-snippet { 264 | // font-size: 14px; 265 | // margin: 10px 0; 266 | // display: block; 267 | // overflow-x: auto; 268 | // color: #333; 269 | // position: relative; 270 | // background-color: rgba(0, 0, 0, 0.03); 271 | // border: 1px solid #f0f0f0; 272 | // border-radius: 2px; 273 | // counter-reset: line; 274 | // line-height: 26px; 275 | // white-space: normal; 276 | // } 277 | .rich_media_content .code-snippet *, 278 | .rich_media_content .code-snippet__fix * { 279 | max-width: 1000% !important; 280 | } 281 | .code-snippet__fix { 282 | word-wrap: break-word !important; 283 | font-size: 14px; 284 | margin: 10px 0; 285 | color: #333; 286 | position: relative; 287 | background-color: rgba(0, 0, 0, 0.03); 288 | border: 1px solid #f0f0f0; 289 | border-radius: 2px; 290 | display: flex; 291 | line-height: 26px; 292 | pre { 293 | margin: 0; 294 | overflow-x: auto; 295 | padding: 1em; 296 | padding-left: 0; 297 | white-space: normal; 298 | flex: 1; 299 | -webkit-overflow-scrolling: touch; 300 | } 301 | code { 302 | white-space: pre; 303 | display: -webkit-box; 304 | display: -webkit-flex; 305 | display: flex; 306 | text-align: left; 307 | font-size: 14px; 308 | white-space: pre; 309 | position: relative; 310 | background: transparent; 311 | color: @color-text-primary; 312 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 313 | } 314 | .code-snippet__line-index { 315 | counter-reset: line; 316 | flex-shrink: 0; 317 | height: 100%; 318 | padding: 1em 10px; 319 | margin: 0; 320 | list-style-type: none; 321 | } 322 | .code-snippet__line-index li { 323 | list-style-type: none; 324 | text-align: right; 325 | margin: 0; 326 | font-size: 14px; 327 | } 328 | .code-snippet__line-index li::before { 329 | min-width: 1.5em; 330 | text-align: right; 331 | left: -2.5em; 332 | counter-increment: line; 333 | content: counter(line); 334 | display: inline; 335 | color: rgba(0, 0, 0, 0.15); 336 | } 337 | 338 | .code-snippet_nowrap code span.code-snippet_outer::after { 339 | content: ' '; 340 | } 341 | 342 | .code-snippet__comment, 343 | .code-snippet__quote { 344 | color: #afafaf; 345 | font-style: italic; 346 | } 347 | 348 | .code-snippet__keyword, 349 | .code-snippet__selector-tag, 350 | .code-snippet__subst { 351 | color: #ca7d37; 352 | } 353 | 354 | .code-snippet__number, 355 | .code-snippet__literal, 356 | .code-snippet__variable, 357 | .code-snippet__template-variable, 358 | .code-snippet__tag .code-snippet__attr { 359 | color: #0e9ce5; 360 | } 361 | 362 | .code-snippet__string, 363 | .code-snippet__doctag { 364 | color: #d14; 365 | } 366 | 367 | .code-snippet__title, 368 | .code-snippet__section, 369 | .code-snippet__selector-id { 370 | color: #d14; 371 | } 372 | 373 | .code-snippet__subst { 374 | font-weight: normal; 375 | } 376 | 377 | .code-snippet__type, 378 | .code-snippet__class .code-snippet__title { 379 | color: #0e9ce5; 380 | } 381 | 382 | .code-snippet__tag, 383 | .code-snippet__name, 384 | .code-snippet__attribute { 385 | color: #0e9ce5; 386 | font-weight: normal; 387 | } 388 | 389 | .code-snippet__regexp, 390 | .code-snippet__link { 391 | color: #ca7d37; 392 | } 393 | 394 | .code-snippet__symbol, 395 | .code-snippet__bullet { 396 | color: #d14; 397 | } 398 | 399 | .code-snippet__built_in, 400 | .code-snippet__builtin-name { 401 | color: #ca7d37; 402 | } 403 | 404 | .code-snippet__meta { 405 | color: #afafaf; 406 | } 407 | 408 | .code-snippet__deletion { 409 | background: #fdd; 410 | } 411 | 412 | .code-snippet__addition { 413 | background: #dfd; 414 | } 415 | 416 | .code-snippet__emphasis { 417 | font-style: italic; 418 | } 419 | 420 | .code-snippet__strong { 421 | font-weight: bold; 422 | } 423 | } 424 | // from https://www.mdnice.com/ 425 | // quote 426 | /*引用*/ 427 | blockquote { 428 | border: none; 429 | color: #303133; 430 | &.multiquote-1 { 431 | border-left: 3px solid @color-primary; 432 | border-radius: 3px; 433 | // border-left: 0; 434 | background-color: #ecf8ff; 435 | padding: 0.8em 1em; 436 | color: #5e6d82; 437 | quotes: none; 438 | 439 | p { 440 | margin: 0; 441 | font-size: 14px; 442 | text-align: left !important; 443 | } 444 | } 445 | h1, 446 | h2, 447 | h3, 448 | h4, 449 | h5, 450 | h6 { 451 | margin: 0 0 8px; 452 | font-weight: bold; 453 | } 454 | &::before, 455 | &::after { 456 | content: none; 457 | } 458 | &.multiquote-1, 459 | &.multiquote-2, 460 | &.multiquote-3 { 461 | h2, 462 | h3 { 463 | border-left: 0; 464 | } 465 | figure img { 466 | max-width: 80%; 467 | } 468 | } 469 | 470 | &.multiquote-2 { 471 | margin: 20px auto; 472 | box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.2); 473 | padding: 20px; 474 | width: 80%; 475 | } 476 | 477 | &.multiquote-3 { 478 | box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.2); 479 | padding: 20px; 480 | margin: 20px auto; 481 | width: 70%; 482 | } 483 | 484 | &.multiquote-3 p { 485 | text-align: center; 486 | } 487 | 488 | &.multiquote-3 h3 { 489 | text-align: center; 490 | border-left: 0; 491 | } 492 | } 493 | // image-flow 494 | .imageflow { 495 | border: 0 none; 496 | &-wrap { 497 | border: 0 none; 498 | overflow: hidden; 499 | margin: 1em auto; 500 | white-space: normal; 501 | text-align: center; 502 | padding: 5px; 503 | overflow: hidden; 504 | } 505 | &-box { 506 | white-space: nowrap; 507 | overflow-x: scroll; 508 | } 509 | &-item { 510 | display: inline-block; 511 | word-wrap: break-word; 512 | white-space: normal; 513 | vertical-align: middle; 514 | width: 100%; 515 | } 516 | &-img { 517 | display: inline-block; 518 | } 519 | &-text { 520 | text-align: center; 521 | margin-top: 0px; 522 | padding-top: 0px; 523 | color: #888; 524 | } 525 | } 526 | 527 | .image-box { 528 | display: flex; 529 | flex-direction: column; 530 | justify-content: center; 531 | align-items: center; 532 | img{ 533 | max-width: 90%; 534 | } 535 | } 536 | // footnote 537 | .footnote{ 538 | &s-sep{ 539 | border-left: 0 !important; 540 | padding-left: 0 !important; 541 | } 542 | &s-sep:before { 543 | content: "参考资料"; 544 | display: block; 545 | } 546 | &-word { 547 | color: @color-primary; 548 | font-weight: bold; 549 | } 550 | &-ref { 551 | color: @color-primary; 552 | font-weight: bold; 553 | } 554 | 555 | &-item { 556 | display: flex; 557 | } 558 | 559 | &-num { 560 | display: inline; 561 | padding-right: 10px; 562 | background: none; 563 | font-size: 80%; 564 | opacity: 0.6; 565 | line-height: 26px; 566 | font-family: ptima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; 567 | } 568 | 569 | &-item p { 570 | display: inline; 571 | font-size: 14px; 572 | width: 90%; 573 | padding: 0px; 574 | margin: 0; 575 | line-height: 26px; 576 | color: black; 577 | word-break:break-all; 578 | width: calc(100%-50) 579 | } 580 | } 581 | 582 | 583 | 584 | 585 | sub, sup { 586 | line-height: 0; 587 | } 588 | 589 | 590 | } 591 | -------------------------------------------------------------------------------- /src/css/theme-white.less: -------------------------------------------------------------------------------- 1 | .mpe-theme-white { 2 | background-color: #fff; 3 | color: #2C3E50; 4 | } 5 | -------------------------------------------------------------------------------- /src/css/theme.less: -------------------------------------------------------------------------------- 1 | @color-primary: #409EFF; 2 | @color-success: #67C23A; 3 | @color-warning: #E6A23C; 4 | @color-danger: #F56C6C; 5 | @color-text-primary: #303133; 6 | @color-text-regular: #606266; 7 | @color-text-secondary: #909399; 8 | -------------------------------------------------------------------------------- /src/css/tooltip.less: -------------------------------------------------------------------------------- 1 | .mpe-tooltip { 2 | position: absolute; 3 | z-index: 999; 4 | display: block; 5 | font-size: 12px; 6 | word-wrap: break-word; 7 | opacity: 0; 8 | 9 | @tooltip-arrow-width: 5px; 10 | @tooltip-margin: 0; 11 | @tooltip-arrow-color: #3cc51f; 12 | 13 | &_top { 14 | padding: @tooltip-arrow-width 0; 15 | margin-top: @tooltip-margin; 16 | 17 | .mpe-tooltip-inner::before { 18 | bottom: 0; 19 | left: 50%; 20 | margin-left: -@tooltip-arrow-width; 21 | content: ''; 22 | border-width: @tooltip-arrow-width @tooltip-arrow-width 0; 23 | border-top-color: @tooltip-arrow-color; 24 | } 25 | } 26 | &_right { 27 | padding: 0 @tooltip-arrow-width; 28 | margin-left: @tooltip-margin; 29 | 30 | .mpe-tooltip-inner::before { 31 | top: 50%; 32 | left: 0; 33 | margin-top: -@tooltip-arrow-width; 34 | content: ''; 35 | border-width: @tooltip-arrow-width @tooltip-arrow-width @tooltip-arrow-width 0; 36 | border-right-color: @tooltip-arrow-color; 37 | } 38 | } 39 | &_bottom { 40 | padding: @tooltip-arrow-width 0; 41 | margin-top: @tooltip-margin; 42 | 43 | .mpe-tooltip-inner::before { 44 | top: 0; 45 | left: 50%; 46 | margin-left: -@tooltip-arrow-width; 47 | content: ''; 48 | border-width: 0 @tooltip-arrow-width @tooltip-arrow-width; 49 | border-bottom-color: @tooltip-arrow-color; 50 | } 51 | } 52 | &_left { 53 | padding: 0 @tooltip-arrow-width; 54 | margin-left: -@tooltip-margin; 55 | 56 | .mpe-tooltip-inner::before { 57 | top: 50%; 58 | right: 0; 59 | margin-top: -@tooltip-arrow-width; 60 | content: ''; 61 | border-width: @tooltip-arrow-width 0 @tooltip-arrow-width @tooltip-arrow-width; 62 | border-left-color: @tooltip-arrow-color; 63 | } 64 | } 65 | 66 | // Wrapper for the tooltip content 67 | &-inner { 68 | max-width: 200px; 69 | padding: 3px 8px; 70 | color: #fff; 71 | text-align: center; 72 | background-color: @tooltip-arrow-color; 73 | border-radius: 3px; 74 | 75 | &::before { 76 | position: absolute; 77 | width: 0; 78 | height: 0; 79 | border-color: transparent; 80 | border-style: solid; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/css/var.less: -------------------------------------------------------------------------------- 1 | @editor-font-size: 16px; 2 | @editor-line-height: 26px; 3 | @nav-height: 40px; 4 | -------------------------------------------------------------------------------- /src/img/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksky521/mpeditor/af34458627a0da7d70e9cf4216c4cda5a661609b/src/img/square.png -------------------------------------------------------------------------------- /src/img/square_check_fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksky521/mpeditor/af34458627a0da7d70e9cf4216c4cda5a661609b/src/img/square_check_fill.png -------------------------------------------------------------------------------- /src/js/blockquote.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksky521/mpeditor/af34458627a0da7d70e9cf4216c4cda5a661609b/src/js/blockquote.js -------------------------------------------------------------------------------- /src/js/download.js: -------------------------------------------------------------------------------- 1 | export default function downloadBlobAsFile(data, filename) { 2 | const contentType = 'application/octet-stream'; 3 | if (!data) { 4 | console.error(' No data'); 5 | return; 6 | } 7 | 8 | if (!filename) { 9 | filename = 'filetodonwload.txt'; 10 | } 11 | 12 | if (typeof data === 'object') { 13 | data = JSON.stringify(data, undefined, 4); 14 | } 15 | 16 | let blob = new Blob([data], {type: contentType}); 17 | let e = document.createEvent('MouseEvents'); 18 | let a = document.createElement('a'); 19 | 20 | a.download = filename; 21 | a.href = URL.createObjectURL(blob); 22 | a.dataset.downloadurl = [contentType, a.download, a.href].join(':'); 23 | e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 24 | a.dispatchEvent(e); 25 | } 26 | -------------------------------------------------------------------------------- /src/js/plugins/blockify-tag.js: -------------------------------------------------------------------------------- 1 | import {htmlInlineParser} from '../utils'; 2 | import customTag from './lib/custom-tag'; 3 | const diyTags = ['header-box', 'qrcode-box', 'image-flow']; 4 | export default (md, opts) => { 5 | const tokenize = (state, start) => { 6 | let token; 7 | const srcLine = state.src.slice(state.bMarks[start], state.eMarks[start]); 8 | if ( 9 | (srcLine.charCodeAt(0) === 0x2d /* - */ && srcLine.charCodeAt(1) === 0x2d) 10 | || (srcLine.charCodeAt(0) === 0x3d /* = */ && srcLine.charCodeAt(1) === 0x3d) 11 | ) { 12 | // console.log(srcLine); 13 | const m = /(?:^|\n)((-|=){2,})([^\s|\=\-]+)\1(?:\n|$)/.exec(srcLine); 14 | if (m && m[1]) { 15 | token = state.push('EOFLine', '', 0); 16 | token.meta = m[2]; 17 | token.block = true; 18 | token.content = m[3]; 19 | 20 | // update line 21 | state.line++; 22 | return true; 23 | } 24 | return false; 25 | } 26 | // console.log(srcLine.charCodeAt(0), srcLine) 27 | if ( 28 | (srcLine.charCodeAt(0) === 0x21 /* ! */ || srcLine.charCodeAt(0) === 0x3f) 29 | /* ? */ && srcLine.charCodeAt(1) === 0x3e /* > */ 30 | ) { 31 | // !> ?> 32 | token = state.push('customBlockquote', '', 0); 33 | token.meta = srcLine[0]; 34 | token.block = true; 35 | token.content = srcLine.replace(/^[\!\?]\>/, ''); 36 | 37 | // update line 38 | state.line++; 39 | return true; 40 | } 41 | if (srcLine.charCodeAt(0) !== 0x3c /* < */) { 42 | return false; 43 | } 44 | const secondCh = srcLine.charCodeAt(1); 45 | if ( 46 | secondCh === 0x21 47 | /* ! */ || secondCh === 0x3f 48 | /* ? */ || secondCh === 0x2f 49 | /* / */ || !isLetter(secondCh) 50 | ) { 51 | return false; 52 | } 53 | const a = htmlInlineParser(srcLine); 54 | if (a && a.tag !== '' && diyTags.indexOf(a.tag) !== -1) { 55 | // console.log(a); 56 | token = state.push('blockifyTag', '', 0); 57 | token.meta = a; 58 | token.block = true; 59 | 60 | // update line 61 | state.line++; 62 | return true; 63 | } 64 | 65 | return false; 66 | }; 67 | 68 | md.renderer.rules.blockifyTag = customTag; 69 | md.block.ruler.before('paragraph', 'blockifyTag', tokenize); 70 | 71 | md.renderer.rules.customBlockquote = (tokens, idx) => { 72 | const meta = tokens[idx].meta; 73 | const content = tokens[idx].content; 74 | /* eslint-disable max-len */ 75 | if (meta === '!') { 76 | return `

${content}

`; 77 | } 78 | return `

${content}

`; 79 | 80 | /* eslint-enable max-len */ 81 | }; 82 | md.block.ruler.before('paragraph', 'customBlockquote', tokenize); 83 | 84 | // 分割线样式 85 | md.renderer.rules.EOFLine = (tokens, idx) => { 86 | const {content, meta} = tokens[idx]; 87 | /* eslint-disable max-len */ 88 | return ` 89 |
90 |
93 |
94 |

${content}

95 |
96 |
97 |
`; 98 | /* eslint-enable max-len */ 99 | }; 100 | md.block.ruler.before('paragraph', 'EOFLine', tokenize); 101 | }; 102 | 103 | function isLetter(ch) { 104 | /* eslint no-bitwise:0 */ 105 | let lc = ch | 0x20; // to lower case 106 | return lc >= 0x61 /* a */ && lc <= 0x7a; 107 | } 108 | -------------------------------------------------------------------------------- /src/js/plugins/blockquote.js: -------------------------------------------------------------------------------- 1 | function makeRule() { 2 | return function addTableContainer(state) { 3 | let count = 0; 4 | let outerQuoteToekn; 5 | for (let i = 0; i < state.tokens.length; i++) { 6 | const curToken = state.tokens[i]; 7 | if (curToken.type === 'blockquote_open') { 8 | if (count === 0) { 9 | // 最外层 blockquote 的 token 10 | outerQuoteToekn = curToken; 11 | } 12 | count++; 13 | continue; 14 | } 15 | if (count > 0) { 16 | outerQuoteToekn.attrs = [['class', 'multiquote-' + count]]; 17 | count = 0; 18 | } 19 | } 20 | }; 21 | } 22 | 23 | export default md => { 24 | md.core.ruler.push('blockquote-class', makeRule(md)); 25 | }; 26 | -------------------------------------------------------------------------------- /src/js/plugins/footnote.js: -------------------------------------------------------------------------------- 1 | function renderFootnoteAnchorName(tokens, idx, options, env) { 2 | const n = Number(tokens[idx].meta.id + 1).toString(); 3 | let prefix = ''; 4 | 5 | if (typeof env.docId === 'string') { 6 | prefix = '-' + env.docId + '-'; 7 | } 8 | 9 | return prefix + n; 10 | } 11 | 12 | function renderFootnoteCaption(tokens, idx) { 13 | let n = Number(tokens[idx].meta.id + 1).toString(); 14 | 15 | if (tokens[idx].meta.subId > 0) { 16 | n += ':' + tokens[idx].meta.subId; 17 | } 18 | 19 | return '[' + n + ']'; 20 | } 21 | 22 | // eslint-disable-next-line 23 | function renderFootnoteWord(tokens, idx, options, env, slf) { 24 | return '' + tokens[idx].content + ''; 25 | } 26 | 27 | function renderFootnoteRef(tokens, idx, options, env, slf) { 28 | // var id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf); 29 | const caption = slf.rules.footnote_caption(tokens, idx, options, env, slf); 30 | return '' + caption + ''; 31 | } 32 | 33 | // eslint-disable-next-line 34 | function renderFootnoteBlockOpen(tokens, idx, options) { 35 | return '

\n
\n'; 36 | } 37 | 38 | function renderFootnoteBlockClose() { 39 | return '
\n'; 40 | } 41 | 42 | function renderFootnoteOpen(tokens, idx, options, env, slf) { 43 | let id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf); 44 | 45 | if (tokens[idx].meta.subId > 0) { 46 | id += ':' + tokens[idx].meta.subId; 47 | } 48 | 49 | return '[' + id + '] '; 50 | } 51 | 52 | function renderFootnoteClose() { 53 | return '\n'; 54 | } 55 | 56 | // Process [link]( "stuff") 57 | function isSpace(code) { 58 | switch (code) { 59 | case 0x09: 60 | case 0x20: 61 | return true; 62 | default: 63 | } 64 | return false; 65 | } 66 | 67 | function normalizeReference(str) { 68 | // use .toUpperCase() instead of .toLowerCase() 69 | // here to avoid a conflict with Object.prototype 70 | // members (most notably, `__proto__`) 71 | return str.trim().replace(/\s+/g, ' ').toUpperCase(); 72 | } 73 | 74 | function linkFoot(state, silent) { 75 | let attrs; 76 | let code; 77 | let label; 78 | let pos; 79 | let res; 80 | let ref; 81 | let title; 82 | let token; 83 | let href = ''; 84 | let start = state.pos; 85 | let footnoteContent; 86 | let parseReference = true; 87 | const oldPos = state.pos; 88 | const max = state.posMax; 89 | 90 | if (state.src.charCodeAt(state.pos) !== 0x5b /* [ */) { 91 | return false; 92 | } 93 | 94 | const labelStart = state.pos + 1; 95 | const labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true); 96 | 97 | // parser failed to find ']', so it's not a valid link 98 | if (labelEnd < 0) { 99 | return false; 100 | } 101 | 102 | pos = labelEnd + 1; 103 | if (pos < max && state.src.charCodeAt(pos) === 0x28 /* ( */) { 104 | // 105 | // Inline link 106 | // 107 | 108 | // might have found a valid shortcut link, disable reference parsing 109 | parseReference = false; 110 | 111 | // [link]( "title" ) 112 | // ^^ skipping these spaces 113 | pos++; 114 | for (; pos < max; pos++) { 115 | code = state.src.charCodeAt(pos); 116 | if (!isSpace(code) && code !== 0x0a) { 117 | break; 118 | } 119 | } 120 | if (pos >= max) { 121 | return false; 122 | } 123 | 124 | // [link]( "title" ) 125 | // ^^^^^^ parsing link destination 126 | start = pos; 127 | res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax); 128 | if (res.ok) { 129 | href = state.md.normalizeLink(res.str); 130 | footnoteContent = res.str; 131 | if (state.md.validateLink(href)) { 132 | pos = res.pos; 133 | } 134 | else { 135 | href = ''; 136 | } 137 | } 138 | 139 | // [link]( "title" ) 140 | // ^^ skipping these spaces 141 | start = pos; 142 | for (; pos < max; pos++) { 143 | code = state.src.charCodeAt(pos); 144 | if (!isSpace(code) && code !== 0x0a) { 145 | break; 146 | } 147 | } 148 | 149 | // [link]( "title" ) 150 | // ^^^^^^^ parsing link title 151 | res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax); 152 | if (pos < max && start !== pos && res.ok) { 153 | title = res.str; 154 | pos = res.pos; 155 | 156 | // [link]( "title" ) 157 | // ^^ skipping these spaces 158 | for (; pos < max; pos++) { 159 | code = state.src.charCodeAt(pos); 160 | if (!isSpace(code) && code !== 0x0a) { 161 | break; 162 | } 163 | } 164 | } 165 | else { 166 | title = ''; 167 | } 168 | 169 | if (pos >= max || state.src.charCodeAt(pos) !== 0x29 /* ) */) { 170 | // parsing a valid shortcut link failed, fallback to reference 171 | parseReference = true; 172 | } 173 | pos++; 174 | } 175 | 176 | if (parseReference) { 177 | // 178 | // Link reference 179 | // 180 | if (typeof state.env.references === 'undefined') { 181 | return false; 182 | } 183 | 184 | if (pos < max && state.src.charCodeAt(pos) === 0x5b /* [ */) { 185 | start = pos + 1; 186 | pos = state.md.helpers.parseLinkLabel(state, pos); 187 | if (pos >= 0) { 188 | label = state.src.slice(start, pos++); 189 | } 190 | else { 191 | pos = labelEnd + 1; 192 | } 193 | } 194 | else { 195 | pos = labelEnd + 1; 196 | } 197 | 198 | // covers label === '' and label === undefined 199 | // (collapsed reference link and shortcut reference link respectively) 200 | if (!label) { 201 | label = state.src.slice(labelStart, labelEnd); 202 | } 203 | 204 | ref = state.env.references[normalizeReference(label)]; 205 | if (!ref) { 206 | state.pos = oldPos; 207 | return false; 208 | } 209 | href = ref.href; 210 | title = ref.title; 211 | } 212 | 213 | // 214 | // We found the end of the link, and know for a fact it's a valid link; 215 | // so all that's left to do is to call tokenizer. 216 | // 217 | if (!silent) { 218 | // 如果存在标题则转成脚注 219 | if (title) { 220 | state.pos = labelStart; 221 | state.posMax = labelEnd; 222 | 223 | let tokens; 224 | 225 | if (!state.env.footnotes) { 226 | state.env.footnotes = {}; 227 | } 228 | if (!state.env.footnotes.list) { 229 | state.env.footnotes.list = []; 230 | } 231 | 232 | const footnoteId = state.env.footnotes.list.length; 233 | 234 | // *用来让链接倾斜 235 | state.md.inline.parse(`${title}: *${footnoteContent}*`, state.md, state.env, (tokens = [])); 236 | 237 | token = state.push('footnote_word', '', 0); 238 | token.content = state.src.slice(labelStart, labelEnd); 239 | 240 | token = state.push('footnote_ref', '', 0); 241 | token.meta = {id: footnoteId}; 242 | 243 | state.env.footnotes.list[footnoteId] = {tokens: tokens}; 244 | } 245 | // 不存在标题则判断域名 246 | else { 247 | state.pos = labelStart; 248 | state.posMax = labelEnd; 249 | 250 | token = state.push('link_open', 'a', 1); 251 | attrs = [['href', href]]; 252 | token.attrs = attrs; 253 | if (title) { 254 | attrs.push(['title', title]); 255 | } 256 | 257 | state.md.inline.tokenize(state); 258 | 259 | token = state.push('link_close', 'a', -1); 260 | } 261 | } 262 | 263 | state.pos = pos; 264 | state.posMax = max; 265 | 266 | return true; 267 | } 268 | 269 | // Glue footnote tokens to end of token stream 270 | function footnoteTail(state) { 271 | let i; 272 | let l; 273 | let lastParagraph; 274 | let list; 275 | let token; 276 | let tokens; 277 | let current; 278 | let currentLabel; 279 | let insideRef = false; 280 | let refTokens = {}; 281 | 282 | if (!state.env.footnotes) { 283 | return; 284 | } 285 | 286 | state.tokens = state.tokens.filter(tok => { 287 | if (tok.type === 'footnote_reference_open') { 288 | insideRef = true; 289 | current = []; 290 | currentLabel = tok.meta.label; 291 | return false; 292 | } 293 | if (tok.type === 'footnote_reference_close') { 294 | insideRef = false; 295 | // prepend ':' to avoid conflict with Object.prototype members 296 | refTokens[':' + currentLabel] = current; 297 | return false; 298 | } 299 | if (insideRef) { 300 | current.push(tok); 301 | } 302 | return !insideRef; 303 | }); 304 | 305 | if (!state.env.footnotes.list) { 306 | return; 307 | } 308 | list = state.env.footnotes.list; 309 | 310 | token = new state.Token('footnote_block_open', '', 1); 311 | state.tokens.push(token); 312 | 313 | for (i = 0, l = list.length; i < l; i++) { 314 | token = new state.Token('footnote_open', '', 1); 315 | token.meta = {id: i, label: list[i].label}; 316 | state.tokens.push(token); 317 | 318 | if (list[i].tokens) { 319 | tokens = []; 320 | 321 | token = new state.Token('paragraph_open', 'p', 1); 322 | token.block = true; 323 | tokens.push(token); 324 | 325 | token = new state.Token('inline', '', 0); 326 | token.children = list[i].tokens; 327 | token.content = ''; 328 | tokens.push(token); 329 | 330 | token = new state.Token('paragraph_close', 'p', -1); 331 | token.block = true; 332 | tokens.push(token); 333 | } 334 | else if (list[i].label) { 335 | tokens = refTokens[':' + list[i].label]; 336 | } 337 | 338 | state.tokens = state.tokens.concat(tokens); 339 | if (state.tokens[state.tokens.length - 1].type === 'paragraph_close') { 340 | lastParagraph = state.tokens.pop(); 341 | } 342 | else { 343 | lastParagraph = null; 344 | } 345 | 346 | if (lastParagraph) { 347 | state.tokens.push(lastParagraph); 348 | } 349 | 350 | token = new state.Token('footnote_close', '', -1); 351 | state.tokens.push(token); 352 | } 353 | 354 | token = new state.Token('footnote_block_close', '', -1); 355 | state.tokens.push(token); 356 | } 357 | 358 | export default md => { 359 | md.renderer.rules.footnote_ref = renderFootnoteRef; 360 | md.renderer.rules.footnote_word = renderFootnoteWord; 361 | md.renderer.rules.footnote_block_open = renderFootnoteBlockOpen; 362 | md.renderer.rules.footnote_block_close = renderFootnoteBlockClose; 363 | md.renderer.rules.footnote_open = renderFootnoteOpen; 364 | md.renderer.rules.footnote_close = renderFootnoteClose; 365 | 366 | // helpers (only used in other rules, no tokens are attached to those) 367 | md.renderer.rules.footnote_caption = renderFootnoteCaption; 368 | md.renderer.rules.footnote_anchor_name = renderFootnoteAnchorName; 369 | 370 | md.inline.ruler.at('link', linkFoot); 371 | md.core.ruler.after('inline', 'footnote_tail', footnoteTail); 372 | }; 373 | -------------------------------------------------------------------------------- /src/js/plugins/highlight.js: -------------------------------------------------------------------------------- 1 | // 缩小highlight包大小,按需引入,900kb->90kb 2 | import highlightjs from 'highlight.js/lib/core'; 3 | 4 | import bash from 'highlight.js/lib/languages/bash'; 5 | import clojure from 'highlight.js/lib/languages/clojure'; 6 | import cpp from 'highlight.js/lib/languages/cpp'; 7 | import css from 'highlight.js/lib/languages/css'; 8 | import dart from 'highlight.js/lib/languages/dart'; 9 | import dockerfile from 'highlight.js/lib/languages/dockerfile'; 10 | import erlang from 'highlight.js/lib/languages/erlang'; 11 | import go from 'highlight.js/lib/languages/go'; 12 | import gradle from 'highlight.js/lib/languages/gradle'; 13 | import groovy from 'highlight.js/lib/languages/groovy'; 14 | import haskell from 'highlight.js/lib/languages/haskell'; 15 | import java from 'highlight.js/lib/languages/java'; 16 | import javascript from 'highlight.js/lib/languages/javascript'; 17 | import json from 'highlight.js/lib/languages/json'; 18 | import julia from 'highlight.js/lib/languages/julia'; 19 | import kotlin from 'highlight.js/lib/languages/kotlin'; 20 | import lisp from 'highlight.js/lib/languages/lisp'; 21 | import lua from 'highlight.js/lib/languages/lua'; 22 | import makefile from 'highlight.js/lib/languages/makefile'; 23 | import markdown from 'highlight.js/lib/languages/markdown'; 24 | import matlab from 'highlight.js/lib/languages/matlab'; 25 | import objectivec from 'highlight.js/lib/languages/objectivec'; 26 | import perl from 'highlight.js/lib/languages/perl'; 27 | import php from 'highlight.js/lib/languages/php'; 28 | import python from 'highlight.js/lib/languages/python'; 29 | import r from 'highlight.js/lib/languages/r'; 30 | import ruby from 'highlight.js/lib/languages/ruby'; 31 | import rust from 'highlight.js/lib/languages/rust'; 32 | import scala from 'highlight.js/lib/languages/scala'; 33 | import shell from 'highlight.js/lib/languages/shell'; 34 | import sql from 'highlight.js/lib/languages/sql'; 35 | import swift from 'highlight.js/lib/languages/swift'; 36 | import typescript from 'highlight.js/lib/languages/typescript'; 37 | import verilog from 'highlight.js/lib/languages/verilog'; 38 | import vhdl from 'highlight.js/lib/languages/vhdl'; 39 | import xml from 'highlight.js/lib/languages/xml'; 40 | import yaml from 'highlight.js/lib/languages/yaml'; 41 | import diff from 'highlight.js/lib/languages/diff'; 42 | highlightjs.configure({ 43 | classPrefix: 'code-snippet__' 44 | }); 45 | highlightjs.registerLanguage('bash', bash); 46 | highlightjs.registerLanguage('clojure', clojure); 47 | highlightjs.registerLanguage('cpp', cpp); 48 | highlightjs.registerLanguage('css', css); 49 | highlightjs.registerLanguage('dart', dart); 50 | highlightjs.registerLanguage('dockerfile', dockerfile); 51 | highlightjs.registerLanguage('erlang', erlang); 52 | highlightjs.registerLanguage('go', go); 53 | highlightjs.registerLanguage('gradle', gradle); 54 | highlightjs.registerLanguage('groovy', groovy); 55 | highlightjs.registerLanguage('haskell', haskell); 56 | highlightjs.registerLanguage('java', java); 57 | highlightjs.registerLanguage('javascript', javascript); 58 | highlightjs.registerLanguage('json', json); 59 | highlightjs.registerLanguage('julia', julia); 60 | highlightjs.registerLanguage('kotlin', kotlin); 61 | highlightjs.registerLanguage('lisp', lisp); 62 | highlightjs.registerLanguage('lua', lua); 63 | highlightjs.registerLanguage('makefile', makefile); 64 | highlightjs.registerLanguage('markdown', markdown); 65 | highlightjs.registerLanguage('matlab', matlab); 66 | highlightjs.registerLanguage('objectivec', objectivec); 67 | highlightjs.registerLanguage('perl', perl); 68 | highlightjs.registerLanguage('php', php); 69 | highlightjs.registerLanguage('python', python); 70 | highlightjs.registerLanguage('r', r); 71 | highlightjs.registerLanguage('ruby', ruby); 72 | highlightjs.registerLanguage('rust', rust); 73 | highlightjs.registerLanguage('scala', scala); 74 | highlightjs.registerLanguage('shell', shell); 75 | highlightjs.registerLanguage('sql', sql); 76 | highlightjs.registerLanguage('swift', swift); 77 | highlightjs.registerLanguage('typescript', typescript); 78 | highlightjs.registerLanguage('verilog', verilog); 79 | highlightjs.registerLanguage('vhdl', vhdl); 80 | highlightjs.registerLanguage('xml', xml); 81 | highlightjs.registerLanguage('yaml', yaml); 82 | highlightjs.registerLanguage('diff', diff); 83 | 84 | export default function (md) { 85 | md.renderer.rules.fence = function (tokens, idx, options, env, slf) { 86 | let token = tokens[idx]; 87 | let info = token.info ? String(token.info).trim() : ''; 88 | let lang = 'bash'; 89 | 90 | if (info) { 91 | lang = info.split(/\s+/g)[0]; 92 | } 93 | const str = token.content.trim().replace(//g, '>'); 94 | let useHljs = false; 95 | if (lang && highlightjs.getLanguage(lang)) { 96 | useHljs = true; 97 | } 98 | 99 | const lines = str.split('\n'); 100 | const codeLines = []; 101 | const numbers = []; 102 | for (let i = 0; i < lines.length; i++) { 103 | const line = lines[i]; 104 | /* eslint-disable max-len */ 105 | 106 | codeLines.push( 107 | `${ 108 | line 109 | ? useHljs 110 | ? highlightjs 111 | .highlight(lang, line, true) 112 | .value.replace('&gt;', '>') 113 | .replace('&lt;', '<') 114 | : line 115 | : '
' 116 | }
` 117 | ); 118 | numbers.push('
  • '); 119 | } 120 | return `
    121 |
      122 | ${numbers.join('')} 123 |
    124 |
    125 |             ${codeLines.join('')}
    126 |             
    `; 127 | }; 128 | } 129 | -------------------------------------------------------------------------------- /src/js/plugins/image.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function implicitFiguresPlugin(md, options) { 4 | options = options || {}; 5 | 6 | function implicitFigures(state) { 7 | // reset tabIndex on md.render() 8 | 9 | // do not process first and last token 10 | for (let i = 1, l = state.tokens.length; i < l - 1; ++i) { 11 | let token = state.tokens[i]; 12 | 13 | if (token.type !== 'inline') { 14 | continue; 15 | } 16 | // children: image alone, or link_open -> image -> link_close 17 | if (!token.children || (token.children.length !== 1 && token.children.length !== 3)) { 18 | continue; 19 | } 20 | // one child, should be img 21 | if (token.children.length === 1 && token.children[0].type !== 'image') { 22 | continue; 23 | } 24 | // three children, should be image enclosed in link 25 | if ( 26 | token.children.length === 3 27 | && (token.children[0].type !== 'link_open' 28 | || token.children[1].type !== 'image' 29 | || token.children[2].type !== 'link_close') 30 | ) { 31 | continue; 32 | } 33 | // prev token is paragraph open 34 | if (i !== 0 && state.tokens[i - 1].type !== 'paragraph_open') { 35 | continue; 36 | } 37 | // next token is paragraph close 38 | if (i !== l - 1 && state.tokens[i + 1].type !== 'paragraph_close') { 39 | continue; 40 | } 41 | 42 | // We have inline token containing an image only. 43 | // Previous token is paragraph open. 44 | // Next token is paragraph close. 45 | // Lets replace the paragraph tokens with figure tokens. 46 | let figure = state.tokens[i - 1]; 47 | figure.type = 'section_open'; 48 | figure.tag = 'section'; 49 | state.tokens[i + 1].type = 'section_close'; 50 | state.tokens[i + 1].tag = 'section'; 51 | state.tokens[i - 1].attrPush(['class', 'image-box']); 52 | let image; 53 | 54 | 55 | // for linked images, image is one off 56 | image = token.children.length === 1 ? token.children[0] : token.children[1]; 57 | 58 | if (image.children && image.children.length) { 59 | const textToken = new state.Token('section_open', 'section', 1); 60 | textToken.attrPush(['class', 'image-text']); 61 | token.children.push(textToken); 62 | token.children.splice(token.children.length, 0, ...image.children); 63 | token.children.push(new state.Token('section_close', 'section', -1)); 64 | image.children.length = 0; 65 | } 66 | 67 | 68 | } 69 | } 70 | md.core.ruler.before('linkify', 'implicit_figures', implicitFigures); 71 | }; 72 | -------------------------------------------------------------------------------- /src/js/plugins/lib/custom-tag.js: -------------------------------------------------------------------------------- 1 | export default function (tokens, idx) { 2 | const {tag, content, attrs} = tokens[idx].meta; 3 | /* eslint-disable max-len */ 4 | 5 | switch (tag) { 6 | case 'header-box': 7 | if (attrs['sub-title'] && typeof attrs['sub-title'] === 'string') { 8 | return ` 9 |
    10 |
    11 |

    ${attrs['sub-title']}

    12 |
    13 |
    14 |
    15 |

    ${content}

    16 |
    17 |
    18 |
    `; 19 | } 20 | return ` 21 |
    22 |
    23 |
    24 |
    25 |

    ${content}

    26 |
    27 |
    28 |
    29 |
    `; 30 | case 'image-flow': 31 | if (attrs.images) { 32 | if (attrs.vertical) { 33 | let wrappedContent = ''; 34 | const {width = 320, height = 344} = attrs; 35 | attrs.images.split(',').forEach(src => { 36 | wrappedContent += `
    37 | 38 |
    `; 39 | }); 40 | return ` 41 |
    42 |
    43 |
    44 |
    45 | ${wrappedContent} 46 |
    47 |
    48 |
    49 |

    ${ 50 | content ? content : '上下滑动展示更多' 51 | }

    52 |
    53 | `; 54 | } 55 | let wrappedContent = ''; 56 | attrs.images.split(',').forEach(src => { 57 | wrappedContent += `
    `; 58 | }); 59 | 60 | return ` 61 |
    62 |
    63 |
    64 | ${wrappedContent} 65 |
    66 |
    67 |

    ${content ? content : '左右滑动展示更多'}

    68 |
    69 | `; 70 | } 71 | 72 | case 'qrcode-box': 73 | return ` 74 |
    75 |
    76 |
    77 |
    78 |
    79 |
    80 |

    扫描二维码

    81 |

    获取更多精彩

    82 |
    83 |
    84 |

    三水清

    85 |
    86 |
    87 |
    88 | no 89 |
    90 |
    91 |
    92 |
    93 |
    `; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/js/plugins/list.js: -------------------------------------------------------------------------------- 1 | function makeRule(md) { 2 | return function replaceListItem() { 3 | md.renderer.rules.list_item_open = function replaceOpen() { 4 | return '
  • '; 5 | }; 6 | md.renderer.rules.list_item_close = function replaceClose() { 7 | return '
  • '; 8 | }; 9 | }; 10 | } 11 | 12 | export default md => { 13 | md.core.ruler.push('replace-li', makeRule(md)); 14 | }; 15 | -------------------------------------------------------------------------------- /src/js/plugins/table-container.js: -------------------------------------------------------------------------------- 1 | function makeRule() { 2 | return function addTableContainer(state) { 3 | let arr = []; 4 | for (let i = 0; i < state.tokens.length; i++) { 5 | let curToken = state.tokens[i]; 6 | if (curToken.type === 'table_open') { 7 | let tableContainerStart = new state.Token('html_inline', '', 0); 8 | tableContainerStart.content = '
    '; 9 | arr.push(tableContainerStart); 10 | arr.push(curToken); 11 | } 12 | else if (curToken.type === 'table_close') { 13 | let tableContainerClose = new state.Token('html_inline', '', 0); 14 | tableContainerClose.content = '
    '; 15 | arr.push(curToken); 16 | arr.push(tableContainerClose); 17 | } 18 | else { 19 | arr.push(curToken); 20 | } 21 | } 22 | state.tokens = arr; 23 | }; 24 | } 25 | 26 | export default md => { 27 | md.core.ruler.push('table-container', makeRule(md)); 28 | }; 29 | -------------------------------------------------------------------------------- /src/js/utils.js: -------------------------------------------------------------------------------- 1 | const autoCloseTagRe = /^<([A-Za-z][A-Za-z0-9\-]*)[^\<]*\/>$/; 2 | const openCloseTagRe = /^<([A-Za-z][A-Za-z0-9\-]*)([^\<]*)>(.*?)<\/\1>$/; 3 | 4 | exports.htmlInlineParser = function (html) { 5 | if ('<' === html.charAt(0)) { 6 | // 自闭和 7 | let m = autoCloseTagRe.exec(html); 8 | // console.log(m,html) 9 | if (m && m[1]) { 10 | return {tag: m[1]}; 11 | } 12 | m = openCloseTagRe.exec(html); 13 | if (m) { 14 | let [_0, tag, attrs, content] = m; 15 | attrs = attrs.trim(); 16 | if (attrs !== '') { 17 | attrs = attrs 18 | .split(/\s+/) 19 | .map(a => { 20 | if (a.indexOf('=') !== -1) { 21 | const idx = a.indexOf('='); 22 | return [a.slice(0, idx), a.slice(idx + 1)]; 23 | } 24 | return [a, '']; 25 | }) 26 | .reduce((prev, next) => { 27 | prev[next[0]] = next[1] ? next[1].replace(/^['"]|['"]$/g, '') : true; 28 | return prev; 29 | }, {}); 30 | } 31 | 32 | return { 33 | tag, 34 | attrs: attrs ? attrs : {}, 35 | content: content.trim() 36 | }; 37 | } 38 | return false; 39 | } 40 | return false; 41 | }; 42 | exports.dateFormat = function dateFormat(d = new Date(), pattern = 'yyyy-MM-dd') { 43 | const type = typeof d; 44 | if (type === 'string' || type === 'number') { 45 | d = new Date(d); 46 | } 47 | let y = d.getFullYear().toString(); 48 | let o = { 49 | M: d.getMonth() + 1, // month 50 | d: d.getDate(), // day 51 | h: d.getHours(), // hour 52 | m: d.getMinutes(), // minute 53 | s: d.getSeconds() // second 54 | }; 55 | pattern = pattern.replace(/(y+)/gi, (a, b) => y.substr(4 - Math.min(4, b.length))); 56 | Object.keys(o).forEach(i => { 57 | pattern = pattern.replace(new RegExp('(' + i + '+)', 'g'), (a, b) => 58 | (o[i] < 10 && b.length > 1 ? '0' + o[i] : o[i]) 59 | ); 60 | }); 61 | return pattern; 62 | }; 63 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Editor from 'mpeditor'; 2 | import $ from 'jQuery'; 3 | import 'normalize.css'; 4 | const $win = $(window); 5 | const LS = window.localStorage; 6 | $(() => { 7 | $('#js-mpeditor').height($win.height()); 8 | const query = new URLSearchParams(window.location.search); 9 | const queryObj = {}; 10 | for (let [k, v] of query) { 11 | queryObj[k] = v; 12 | } 13 | if (queryObj.tpl) { 14 | $.get(`./static/${queryObj.tpl}`).done(createEditor); 15 | } 16 | else { 17 | LS.mpe_content ? createEditor(LS.mpe_content) : $.get('./static/demo.md').done(createEditor); 18 | } 19 | }); 20 | 21 | function createEditor(data) { 22 | let editor = new Editor('#js-mpeditor', {text: data.trim()}); 23 | $win.resize(() => { 24 | let height = $win.height(); 25 | $('#js-mpeditor').height(height); 26 | 27 | editor.resize.bind(editor)(height); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /src/mpeditor.html: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |
      5 |
    6 |
      7 |
    • 8 | 编辑器主题 9 |
    • 10 |
    • 11 | 20 |
    • 21 |
    • 22 | 23 | 24 | 25 |
    • 26 | 36 | 37 |
    • 38 | 39 | 40 | 41 |
    • 42 |
    • 43 | 44 | 45 | 46 |
    • 47 |
    • 48 | 49 | 50 | 51 |
    • 52 |
    53 |
    54 |
    55 |
    56 |
    57 |
    58 | 59 |
    60 |
    61 |
    62 |
    63 |
    64 |
    65 |
    66 |
    67 |
    68 | 69 |

    已保存

    70 |
    71 |
    72 | -------------------------------------------------------------------------------- /src/mpeditor.js: -------------------------------------------------------------------------------- 1 | import './css/common.less'; 2 | import './css/mpeditor.less'; 3 | import './css/theme-white.less'; 4 | import Clipboard from 'clipboard'; 5 | import $ from 'jQuery'; 6 | import pangu from 'pangu'; 7 | import handlebars from 'handlebars'; 8 | /* globals CodeMirror, $, jQuery */ 9 | // markdown-it 10 | import markdownIt from 'markdown-it'; 11 | import mdImgSize from 'markdown-it-imsize'; 12 | 13 | import mdHighlight from './js/plugins/highlight'; 14 | import mdFootnote from './js/plugins/footnote'; 15 | import mdBlockQuote from './js/plugins/blockquote'; 16 | import mdList from './js/plugins/list'; 17 | import mdImage from './js/plugins/image'; 18 | import blockifyTag from './js/plugins/blockify-tag'; 19 | import mdTableContainter from './js/plugins/table-container'; 20 | 21 | // output plugin 22 | import downloadBlobAsFile from './js/download.js'; 23 | import {dateFormat} from './js/utils'; 24 | // html 25 | import tmpl from './mpeditor.html'; 26 | handlebars.registerHelper('$def', function (varName, varValue, options) { 27 | options.data.root[varName] = varValue; 28 | }); 29 | 30 | const LS = window.localStorage; 31 | 32 | const KEYS_MAPS = { 33 | 'Cmd-S': 'save', 34 | 'Cmd-B': 'bold', 35 | 'Cmd-I': 'italicize', 36 | 'Cmd-\'': 'blockquote', 37 | 'Cmd-U': 'strikethrough', 38 | // 'Cmd-U': 'unorderedList', 39 | 'Cmd-P': 'image', 40 | 'Cmd-H': 'headerbox', 41 | 'Cmd-K': 'link' 42 | }; 43 | export default class Editor { 44 | actions = { 45 | save(instance) { 46 | this._save(); 47 | }, 48 | bold() { 49 | this.toggleAround('**', '**'); 50 | }, 51 | italicize() { 52 | this.toggleAround('*', '*'); 53 | }, 54 | strikethrough() { 55 | this.toggleAround('~~', '~~'); 56 | }, 57 | code() { 58 | this.toggleAround('```\r\n', '\r\n```'); 59 | }, 60 | blockquote() { 61 | this.toggleBefore('> '); 62 | }, 63 | orderedList() { 64 | this.toggleBefore('1. '); 65 | }, 66 | unorderedList() { 67 | this.toggleBefore('* '); 68 | }, 69 | image() { 70 | this.toggleAround('![', '](http://)'); 71 | }, 72 | link() { 73 | this.toggleAround('[', '](http://)'); 74 | }, 75 | headerbox() { 76 | this.toggleAround('', ''); 77 | } 78 | }; 79 | constructor(node, {text, updateDelayTime = 300} = {}) { 80 | let $container = $(node).html(tmpl); 81 | this.scale = 1; 82 | this.index = 1; 83 | 84 | this.$container = $container; 85 | let that = this; 86 | $container.find('[eid]').each((i, dom) => { 87 | dom = $(dom); 88 | let id = dom.attr('eid'); 89 | that['$' + id] = dom; 90 | }); 91 | // 在创建codeMirror之前 92 | const extraKeys = this.registerKeyMaps(); 93 | 94 | this.resize(); 95 | let editor = (this.editor = this._initEditor(this.$editor[0], text, extraKeys)); 96 | this.converter = this._initMarkdownRender(); 97 | if (text) { 98 | this.updatePreview(text); 99 | } 100 | 101 | let timer; 102 | editor.on('change', () => { 103 | timer && clearTimeout(timer); 104 | timer = setTimeout(() => that.updatePreview(), updateDelayTime); 105 | }); 106 | 107 | // 跟滚动相关 108 | this._scrollingHelper = $('
    '); 109 | this._isPreviewMoving = false; 110 | this._isEditorMoving = false; 111 | this._bindEvent(); 112 | // 自动保存 113 | this._autoSave(); 114 | } 115 | 116 | _setCurrentIndex(index) { 117 | this.index = parseInt(index, 10); 118 | } 119 | setValue(content) { 120 | this.editor.setValue(content); 121 | this.updatePreview(); 122 | return this; 123 | } 124 | // 系统变量 125 | getSysVar() { 126 | const d = new Date(); 127 | const year = d.getFullYear(); 128 | const month = ('00' + (d.getMonth() + 1)).slice(-2); 129 | const day = ('00' + d.getDate()).slice(-2); 130 | return { 131 | $sys: { 132 | year, 133 | month, 134 | day, 135 | today: dateFormat(new Date()) 136 | } 137 | }; 138 | } 139 | render(content) { 140 | content = content || this.editor.getValue(); 141 | // const template = handlebars.compile(content); 142 | // console.log(content, this.getSysVar()); 143 | // let text = this.converter.render(template(this.getSysVar())); 144 | let text = this.converter.render(content); 145 | 146 | return text; 147 | } 148 | updatePreview(content) { 149 | // this._isInput = false; 150 | this._isUpdatePreview = true; 151 | // console.log(this.editor.getValue()) 152 | let val = this.render(content); 153 | this.$preview.html(val); 154 | // pangu 155 | pangu.spacingNode(this.$preview[0]); 156 | // TODO 收集footnote 157 | return this; 158 | } 159 | toggleAround(start, end) { 160 | let doc = this.editor.getDoc(); 161 | let cursor = doc.getCursor(); 162 | 163 | if (doc.somethingSelected()) { 164 | let selection = doc.getSelection(); 165 | if (selection.startsWith(start) && selection.endsWith(end)) { 166 | doc.replaceSelection(selection.substring(start.length, selection.length - end.length), 'around'); 167 | } 168 | else { 169 | doc.replaceSelection(start + selection + end, 'around'); 170 | } 171 | } 172 | else { 173 | // If no selection then insert start and end args and set cursor position between the two. 174 | doc.replaceRange(start + end, {line: cursor.line, ch: cursor.ch}); 175 | doc.setCursor({line: cursor.line, ch: cursor.ch + start.length}); 176 | } 177 | } 178 | toggleBefore(insertion) { 179 | let doc = this.editor.getDoc(); 180 | let cursor = doc.getCursor(); 181 | 182 | if (doc.somethingSelected()) { 183 | let selections = doc.listSelections(); 184 | let remove = null; 185 | this.editor.operation(function () { 186 | selections.forEach(function (selection) { 187 | let pos = [selection.head.line, selection.anchor.line].sort(); 188 | 189 | // Remove if the first text starts with it 190 | if (remove == null) { 191 | remove = doc.getLine(pos[0]).startsWith(insertion); 192 | } 193 | 194 | for (let i = pos[0]; i <= pos[1]; i++) { 195 | if (remove) { 196 | // Don't remove if we don't start with it 197 | if (doc.getLine(i).startsWith(insertion)) { 198 | doc.replaceRange('', {line: i, ch: 0}, {line: i, ch: insertion.length}); 199 | } 200 | } 201 | else { 202 | doc.replaceRange(insertion, {line: i, ch: 0}); 203 | } 204 | } 205 | }); 206 | }); 207 | } 208 | else { 209 | let line = cursor.line; 210 | if (doc.getLine(line).startsWith(insertion)) { 211 | doc.replaceRange('', {line: line, ch: 0}, {line: line, ch: insertion.length}); 212 | } 213 | else { 214 | doc.replaceRange(insertion, {line: line, ch: 0}); 215 | } 216 | } 217 | } 218 | registerKeyMaps(keyMaps = KEYS_MAPS) { 219 | const extraKeys = {}; 220 | Object.keys(keyMaps).forEach(key => { 221 | const actionName = keyMaps[key]; 222 | if (typeof this.actions[actionName] !== 'function') { 223 | throw `MPEditor CodeMirror: ${actionName} is not a registered action`; 224 | } 225 | 226 | let realName = key 227 | .replace('Cmd-', CodeMirror.keyMap.default === CodeMirror.keyMap.macDefault ? 'Cmd-' : 'Ctrl-') 228 | .replace('Alt-', CodeMirror.keyMap.default === CodeMirror.keyMap.macDefault ? 'Shift-' : 'Alt-'); 229 | extraKeys[realName] = this.actions[actionName].bind(this); 230 | }); 231 | return extraKeys; 232 | } 233 | // 改变大小 234 | resize(height) { 235 | height = height || this.$container.height(); 236 | // let $nav = this.$nav; 237 | // height = height; 238 | // this.$editor.height(height); 239 | this.$previewContainer.height(height); 240 | // this.$container.find('[eclass=mpe-col]').height(height); 241 | // this.editor && this.editor.resize(); 242 | } 243 | // 私有方法 244 | 245 | _autoSave() { 246 | // this._autoSaveTimer = setInterval(() => { 247 | let text = this.editor.getValue(); 248 | if (text !== '') { 249 | LS.mpe_content = text; 250 | } 251 | // }, 10e3) 252 | } 253 | _handleScroll() { 254 | const markdownEditor = this.editor; 255 | 256 | const $preview = this.$preview; 257 | const $container = this.$container; 258 | 259 | const cmData = markdownEditor.getScrollInfo(); 260 | const editorToTop = cmData.top; 261 | const editorScrollHeight = cmData.height - cmData.clientHeight; 262 | this.scale = ($preview[0].offsetHeight - $container[0].offsetHeight + 40) / editorScrollHeight; 263 | const $previewContainer = this.$previewContainer; 264 | if (this.index === 1) { 265 | $previewContainer.scrollTop(editorToTop * this.scale); 266 | } 267 | else { 268 | markdownEditor.scrollTo(null, $previewContainer.scrollTop() / this.scale + 40); 269 | } 270 | } 271 | _bindEvent() { 272 | const markdownEditor = this.editor; 273 | const $preview = this.$preview; 274 | // let $editor = this.$editor 275 | const that = this; 276 | // TODO 277 | this.$container.find('[eclass=mpe-col]').mouseover(function () { 278 | that._setCurrentIndex(this.dataset.index); 279 | }); 280 | 281 | markdownEditor.on('scroll', this._handleScroll.bind(this)); 282 | 283 | $preview.parent().on('scroll', this._handleScroll.bind(this)); 284 | // 工具栏 285 | const clipboard = new Clipboard(this.$copyBtn[0], { 286 | action: 'cut', 287 | target: () => this.$preview[0] 288 | }); 289 | clipboard.on('success', e => { 290 | this._createTips(this.$copyBtn, '复制成功'); 291 | }); 292 | this.$editorTheme.on('change', function () { 293 | let theme = this.value; 294 | const removeClasses = that.editor.display.wrapper.className.split(/\s+/).filter(a => /^cm\-s\-/.test(a)); 295 | $(that.editor.display.wrapper).removeClass(removeClasses.join(' ')).addClass(`cm-s-${theme}`); 296 | // 存储 297 | LS.mpe_editorTheme = theme; 298 | }); 299 | // this.$mobileBtn.on('click', () => { 300 | // this.$previewContainer.addClass('mobile'); 301 | // this.$mobileBtn.hide(); 302 | // this.$pcBtn.show(); 303 | // }); 304 | // this.$pcBtn.on('click', () => { 305 | // this.$previewContainer.removeClass('mobile'); 306 | // this.$pcBtn.hide(); 307 | // this.$mobileBtn.show(); 308 | // }); 309 | this.$downloadBtn.on('click', () => { 310 | let text = this.editor.getValue(); 311 | if (text.trim()) { 312 | downloadBlobAsFile(text, 'untitled.md'); 313 | } 314 | else { 315 | alert('写点啥再下载吧'); 316 | } 317 | }); 318 | this.$clearBtn.on('click', () => { 319 | delete LS.mpe_content; 320 | this.setValue(''); 321 | }); 322 | } 323 | _save() { 324 | this._autoSave(); 325 | let $toast = this.$toast.show(); 326 | setTimeout(() => $toast.hide(), 800); 327 | } 328 | _createTips(node, text, dir = 'bottom', timeout = 2000) { 329 | let tmpl = ` 330 |
    331 |
    ${text}
    332 |
    333 | `; 334 | let pos = $(node).position(); 335 | 336 | let $tip = $(tmpl).appendTo(this.$container); 337 | $tip.css({ 338 | top: pos.top - 20, 339 | left: pos.left - $(node).width() / 2 340 | }).animate({opacity: 1, top: pos.top + $(node).height() + 20}, 300); 341 | setTimeout(() => { 342 | $tip.animate({opacity: 0}, 300, () => { 343 | $tip.remove(); 344 | }); 345 | }, timeout); 346 | return $tip; 347 | } 348 | _initMarkdownRender() { 349 | let md = markdownIt({ 350 | html: true, // Enable HTML tags in source 351 | xhtmlOut: false, // Use '/' to close single tags (
    ). 352 | // This is only for full CommonMark compatibility. 353 | breaks: false, // Convert '\n' in paragraphs into
    354 | langPrefix: 'language-', // CSS language prefix for fenced blocks. Can be 355 | // useful for external highlighters. 356 | linkify: false, // Autoconvert URL-like text to links 357 | // Enable some language-neutral replacement + quotes beautification 358 | // For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js 359 | typographer: false, 360 | 361 | // Double + single quotes replacement pairs, when typographer enabled, 362 | // and smartquotes on. Could be either a String or an Array. 363 | // 364 | // For example, you can use '«»„“' for Russian, '„“‚‘' for German, 365 | // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp). 366 | quotes: '“”‘’' 367 | }); 368 | // 添加plugin 369 | md.use(mdBlockQuote) // blockquote嵌套 370 | .use(mdHighlight) // 语法高亮 371 | .use(mdFootnote) // footnote 372 | .use(mdTableContainter) 373 | .use(mdImage) // 图示 374 | .use(mdList) // li列表处理 375 | .use(blockifyTag) // 自定义样式 376 | .use(mdImgSize); // 图片 377 | 378 | return md; 379 | } 380 | // 初始化编辑器 381 | _initEditor(id, val, extraKeys) { 382 | let theme = LS.mpe_editorTheme ? LS.mpe_editorTheme : 'default'; 383 | // eslint-disable-next-line 384 | let editor = CodeMirror.fromTextArea(id, { 385 | lineNumbers: false, 386 | lineWrapping: true, 387 | styleActiveLine: true, 388 | theme, 389 | extraKeys, 390 | mode: 'text/x-markdown' 391 | }); 392 | 393 | if (val) { 394 | editor.setValue(val); 395 | } 396 | return editor; 397 | } 398 | } 399 | -------------------------------------------------------------------------------- /static/demo.md: -------------------------------------------------------------------------------- 1 | # 公众号 Markdown 编辑器 2 | 3 | **MPEditor**是专注于微信公众号的编辑阅读器,利用 MPEditor 可以使用 **Markdown** 语法编写微信公众号文章,编辑完后可以复制到公众号发布平台直接发布,真正的实现即看即所得: 4 | 5 | - 更加贴合微信 UI 标准 6 | - 支持实时预览 7 | - 支持同步滚动 8 | - 支持语法高亮 9 | - 自动加「参考资料」脚注 10 | 11 | > MPEditor 解决了微信公众号编辑中遇见的一些编辑问题,增加了「工(ma)程(nong)师(men)」经常遇见的代码高亮、emoji 问题。希望你会喜欢这种极(zhuang)客(bi)的体验 12 | 13 | 使用方法 14 | 15 | 在左侧 Markdown 编辑器中编写 Markdown 格式的内容,编辑完成后点击右上角`√`,复制内容到微信编辑器粘贴即可。 16 | 17 | ## 本编辑器支持快捷键 18 | 19 | - `⌘+S` / `Ctrl+S`:保存编写的内容 20 | - `⌘+B` / `Ctrl+B`:加粗 21 | - `⌘+I` / `Ctrl+I`:斜体 22 | - `⌘+'` / `Ctrl+'`:引用 23 | - `⌘+U` / `Ctrl+U`:删除线, 24 | - `⌘+P` / `Ctrl+P`:快速插入图片, 25 | - `⌘+H` / `Ctrl+H`:`header-box`语法,(往后看) 26 | - `⌘+K` / `Ctrl+K`:快速链接 27 | 28 | 什么是 Markdown 29 | 30 | Markdown 是一种方便记忆、书写的纯文本标记语言,用户可以使用这些标记符号以最小的输入代价生成极富表现力的文档:譬如您正在阅读的这份文档。它使用简单的符号标记不同的标题,分割不同的段落,**粗体** 、 _斜体_ 、~~delete~~ 某些文字。MPEditor 使用了 [markdown-it](https://github.com/markdown-it/markdown-it 'markdown-it')转换语法,[CodeMirror](https://codemirror.net 'CodeMirror')来做编辑器 31 | 32 | 语法 33 | 34 | ## 1. 标题 35 | 标题样式使用`#`来创建,分别有六种标题样式: 36 | 37 | ### 标题三 38 | 39 | #### 标题四 40 | 41 | ##### 标题五,不常用 42 | 43 | ###### 标题六,不常用 44 | 45 | ## 2. 列表样式 46 | 列表支持有序列表和无需列表。 47 | 48 | - 偶是个无序列表 49 | - 我是个二级无序列表 50 | - 真巧啊我也是个无序列表 51 | 52 | 1. 我是个有序列表啊 53 | 2. 嗯,me too~ 54 | 3. markdown so easy! 妈妈再也不用担心我的**学习**了 55 | 56 | !> 由于微信原因,最多支持到二级列表。 57 | 58 | ## 3. 高亮代码 59 | 60 | 使用了微信原生语法高亮,复制代码到微信编辑器中自动替换为微信的语法高亮。 61 | 62 | ```js 63 | // 新语法检测 64 | import $ from 'jQuery'; 65 | $(document).on('click', () => { 66 | let that = this; 67 | console.log(that); 68 | }); 69 | 70 | var aceEditor = new ace.editor('#id'); 71 | 72 | $(function () { 73 | $('div').html('I am a div.'); 74 | $('div').html('I am a long long long long long long long long long long long long long string.'); 75 | }); 76 | ``` 77 | 78 | 上面是 `JavaScript`,下面是 `php`: 79 | 80 | ```php 81 | echo 'hello,world' 82 | ``` 83 | 84 | ## 4. 链接 85 | 86 | 链接样式使用`![]()`方式编写如下面: 87 | 88 | - MPEditor:https://github.com/ksky521/mpeditor 89 | - demo: [点击查看 demo](https://github.com/ksky521/mpeditor/blob/master/static/demo.md) 90 | 91 | 另外还支持[脚注语法](https://github.com "Github"),滑到页面底部会看到参考资料。 92 | 93 | ## 5. 表格样式 94 | 95 | 下面是个普通的表格 96 | | 公众号 | id | 备注 | 97 | |:-----|-----|:------:| 98 | | 三水清 | sanshuiqing123 | 作者很帅 | 99 | | 博客 | http://js8.in | 程序媛鼓励师 | 100 | 101 | 支持另外一种语法: 102 | 公众号 | id/网址 | 备注 103 | ------------ | ---------- | ------ 104 | 三水清 | sanshuiqing123 | 作者很帅 105 | 博客 | http://js8.in | 程序媛鼓励师 106 | 107 | 宽度过长的表格可以滚动,可在自定义主题中调节宽度: 108 | 109 | | 姓名 | 年龄 | 工作 | 邮箱 | 手机 | 110 | | :--------- | :--: | -----------: | :-------------: | :---------: | 111 | | 小可爱 | 18 | 吃可爱多 | lovely@test.com | 18812345678 | 112 | | 小小勇敢 | 20 | 爬棵勇敢树 | brave@test.com | 17712345678 | 113 | | 小小小机智 | 22 | 看一本机智书 | smart@test.com | 16612345678 | 114 | 115 | 116 | ## 6. 图片格式 117 | 118 | 图片支持简单的样式,例如下面的: 119 | 120 | ![关注三水清](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 121 | 122 | 还支持在`()`中填写图片的尺寸,例如换个小点的头像: 123 | 124 | ![关注三水清](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg =120x120) 125 | 126 | 另外还支持``标签语法,添加图片横屏滑动幻灯片(灵感来自MarkdownNice) 127 | 128 | 左右滑动展示更多 129 | 130 | 这是个竖向滑动的 131 | 132 | 上下滑动展示更多 133 | ## 7. 引用 134 | 135 | > MPEditor 解决了微信公众号编辑中遇见的一些编辑问题,增加了「工(ma)程(nong)师(men)」经常遇见的代码高亮、emoji 问题。希望你会喜欢这种极(zhuang)客(bi)的体验 136 | 137 | 下面是个特殊的引用,背景是红色 138 | 139 | !> MPEditor 解决了微信公众号编辑中遇见的一些编辑问题,增加了「工(ma)程(nong)师(men)」经常遇见的代码高亮、emoji 问题。希望你会喜欢这种极(zhuang)客(bi)的体验 140 | 141 | ### 多级引用 142 | 143 | 引用的格式是在符号 `>` 后面书写文字,文字的内容可以包含标题、链接、图片、粗体和斜体等。 144 | 145 | 一级引用如下: 146 | 147 | > ### 一级引用示例 148 | > 149 | > 读一本好书,就是在和高尚的人谈话。 **——歌德** 150 | > 151 | > [网站](https://js8.in) 152 | > 153 | > ![这里写图片描述](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 154 | 155 | 当使用多个 `>` 符号时,就会变成多级引用 156 | 157 | 二级引用如下: 158 | 159 | > > ### 二级引用示例 160 | > > 161 | > > 读一本好书,就是在和高尚的人谈话。 **——歌德** 162 | > > 163 | > > [网站](https://js8.in) 164 | > > 165 | > > ![这里写图片描述](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 166 | 167 | 三级引用如下: 168 | 169 | > > > ### 三级引用示例 170 | > > > 171 | > > > 读一本好书,就是在和高尚的人谈话。 **——歌德** 172 | > > > 173 | > > > [网站](https://js8.in) 174 | > > > 175 | > > > ![这里写图片描述](https://raw.githubusercontent.com/ksky521/mpeditor/master/static/qrcode-ssq.jpg) 176 | 177 | ## 8. 分割线 178 | 179 | --分割线-- 180 | 181 | ==密封线== 182 | 183 | ## 9. 特殊组件 184 | 185 | ?> 下面是一些特殊样式,你可能用得到 186 | 187 | #### 盒子标题 188 | 189 | 盒子标题 190 | 191 | #### 主副标题样式 192 | 193 | 这是标题 194 | 195 | 这里是主标题 196 | 197 | #### 底部扫码 198 | 199 | 200 | 201 | 202 | ## 10. 支持html 203 | 204 | 例如我们内置样色 `class`: 205 | 206 | green/success 207 | info/blue 208 | danger/red 209 | warning/yellow 210 | gray 211 | 212 | ### 其他样式 213 | 214 | 自定义样式字号等 215 | 216 | 再一次感谢您花费时间阅读这份欢迎稿! 217 | 218 | --EOF-- 219 | 220 | 作者[@三水清](http://weibo.com/sanshuiqing)
    221 | 2021 年 01 月 12 日 222 | 223 |
    224 |

    下面是个「三水清」的微信公众号二维码,欢迎扫描关注:

    225 | 226 |
    227 | -------------------------------------------------------------------------------- /static/js/jquery-3.1.1.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery v3.1.1 | (c) jQuery Foundation | jquery.org/license */ 2 | !function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.1.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,C=/^.[^:#\[\.,]*$/;function D(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):C.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(D(this,a||[],!1))},not:function(a){return this.pushStack(D(this,a||[],!0))},is:function(a){return!!D(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var E,F=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,G=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||E,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:F.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),B.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};G.prototype=r.fn,E=r(d);var H=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function J(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return J(a,"nextSibling")},prev:function(a){return J(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return a.contentDocument||r.merge([],a.childNodes)}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(I[a]||r.uniqueSort(e),H.test(a)&&e.reverse()),this.pushStack(e)}});var K=/[^\x20\t\r\n\f]+/g;function L(a){var b={};return r.each(a.match(K)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?L(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function M(a){return a}function N(a){throw a}function O(a,b,c){var d;try{a&&r.isFunction(d=a.promise)?d.call(a).done(b).fail(c):a&&r.isFunction(d=a.then)?d.call(a,b,c):b.call(void 0,a)}catch(a){c.call(void 0,a)}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b=f&&(d!==N&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:M,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:M)),c[2][3].add(g(0,a,r.isFunction(d)?d:N))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(O(a,g.done(h(c)).resolve,g.reject),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)O(e[c],h(c),g.reject);return g.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&P.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var Q=r.Deferred();r.fn.ready=function(a){return Q.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,holdReady:function(a){a?r.readyWait++:r.ready(!0)},ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||Q.resolveWith(d,[r]))}}),r.ready.then=Q.then;function R(){d.removeEventListener("DOMContentLoaded",R), 3 | a.removeEventListener("load",R),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",R),a.addEventListener("load",R));var S=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)S(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h1,null,!0)},removeData:function(a){return this.each(function(){W.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=V.get(a,b),c&&(!d||r.isArray(c)?d=V.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return V.get(a,c)||V.access(a,c,{empty:r.Callbacks("once memory").add(function(){V.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length\x20\t\r\n\f]+)/i,ka=/^$|\/(?:java|ecma)script/i,la={option:[1,""],thead:[1,"","
    "],col:[2,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],_default:[0,"",""]};la.optgroup=la.option,la.tbody=la.tfoot=la.colgroup=la.caption=la.thead,la.th=la.td;function ma(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&r.nodeName(a,b)?r.merge([a],c):c}function na(a,b){for(var c=0,d=a.length;c-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=ma(l.appendChild(f),"script"),j&&na(g),c){k=0;while(f=g[k++])ka.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var qa=d.documentElement,ra=/^key/,sa=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ta=/^([^.]*)(?:\.(.+)|)/;function ua(){return!0}function va(){return!1}function wa(){try{return d.activeElement}catch(a){}}function xa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)xa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=va;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(qa,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(K)||[""],j=b.length;while(j--)h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.hasData(a)&&V.get(a);if(q&&(i=q.events)){b=(b||"").match(K)||[""],j=b.length;while(j--)if(h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&V.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(V.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i\x20\t\r\n\f]*)[^>]*)\/>/gi,za=/\s*$/g;function Da(a,b){return r.nodeName(a,"table")&&r.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a:a}function Ea(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Fa(a){var b=Ba.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ga(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(V.hasData(a)&&(f=V.access(a),g=V.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c1&&"string"==typeof q&&!o.checkClone&&Aa.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ia(f,b,c,d)});if(m&&(e=pa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(ma(e,"script"),Ea),i=h.length;l")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=ma(h),f=ma(a),d=0,e=f.length;d0&&na(g,!i&&ma(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(T(c)){if(b=c[V.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[V.expando]=void 0}c[W.expando]&&(c[W.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ja(this,a,!0)},remove:function(a){return Ja(this,a)},text:function(a){return S(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.appendChild(a)}})},prepend:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(ma(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return S(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!za.test(a)&&!la[(ja.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c1)}});function Ya(a,b,c,d,e){return new Ya.prototype.init(a,b,c,d,e)}r.Tween=Ya,Ya.prototype={constructor:Ya,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=Ya.propHooks[this.prop];return a&&a.get?a.get(this):Ya.propHooks._default.get(this)},run:function(a){var b,c=Ya.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Ya.propHooks._default.set(this),this}},Ya.prototype.init.prototype=Ya.prototype,Ya.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},Ya.propHooks.scrollTop=Ya.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=Ya.prototype.init,r.fx.step={};var Za,$a,_a=/^(?:toggle|show|hide)$/,ab=/queueHooks$/;function bb(){$a&&(a.requestAnimationFrame(bb),r.fx.tick())}function cb(){return a.setTimeout(function(){Za=void 0}),Za=r.now()}function db(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ba[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function eb(a,b,c){for(var d,e=(hb.tweeners[b]||[]).concat(hb.tweeners["*"]),f=0,g=e.length;f1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?ib:void 0)), 4 | void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&r.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(K);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),ib={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=jb[b]||r.find.attr;jb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=jb[g],jb[g]=e,e=null!=c(a,b,d)?g:null,jb[g]=f),e}});var kb=/^(?:input|select|textarea|button)$/i,lb=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return S(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):kb.test(a.nodeName)||lb.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function mb(a){var b=a.match(K)||[];return b.join(" ")}function nb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,nb(this)))});if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,nb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,nb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(K)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=nb(this),b&&V.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":V.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+mb(nb(c))+" ").indexOf(b)>-1)return!0;return!1}});var ob=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":r.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(ob,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:mb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(r.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var pb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!pb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,pb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(V.get(h,"events")||{})[b.type]&&V.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&T(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!T(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=V.access(d,b);e||d.addEventListener(a,c,!0),V.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=V.access(d,b)-1;e?V.access(d,b,e):(d.removeEventListener(a,c,!0),V.remove(d,b))}}});var qb=a.location,rb=r.now(),sb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var tb=/\[\]$/,ub=/\r?\n/g,vb=/^(?:submit|button|image|reset|file)$/i,wb=/^(?:input|select|textarea|keygen)/i;function xb(a,b,c,d){var e;if(r.isArray(b))r.each(b,function(b,e){c||tb.test(a)?d(a,e):xb(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)xb(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(r.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)xb(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&wb.test(this.nodeName)&&!vb.test(a)&&(this.checked||!ia.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:r.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(ub,"\r\n")}}):{name:b.name,value:c.replace(ub,"\r\n")}}).get()}});var yb=/%20/g,zb=/#.*$/,Ab=/([?&])_=[^&]*/,Bb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Cb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Db=/^(?:GET|HEAD)$/,Eb=/^\/\//,Fb={},Gb={},Hb="*/".concat("*"),Ib=d.createElement("a");Ib.href=qb.href;function Jb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(K)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Kb(a,b,c,d){var e={},f=a===Gb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Lb(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Mb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Nb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:qb.href,type:"GET",isLocal:Cb.test(qb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Hb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Lb(Lb(a,r.ajaxSettings),b):Lb(r.ajaxSettings,a)},ajaxPrefilter:Jb(Fb),ajaxTransport:Jb(Gb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Bb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||qb.href)+"").replace(Eb,qb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(K)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Ib.protocol+"//"+Ib.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Kb(Fb,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Db.test(o.type),f=o.url.replace(zb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(yb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(sb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Ab,"$1"),n=(sb.test(f)?"&":"?")+"_="+rb++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Hb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Kb(Gb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Mb(o,y,d)),v=Nb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Ob={0:200,1223:204},Pb=r.ajaxSettings.xhr();o.cors=!!Pb&&"withCredentials"in Pb,o.ajax=Pb=!!Pb,r.ajaxTransport(function(b){var c,d;if(o.cors||Pb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Ob[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("