From 4cf1d4130b927d0ad3bc42055e445f2dc42de95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Fri, 9 Oct 2020 00:26:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=87=E6=8D=A2markdown=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E5=88=B0vditor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular.json | 7 - package-lock.json | 13 + package.json | 1 + src/app/view/write/write.component.html | 7 +- src/app/view/write/write.component.less | 1 + src/app/view/write/write.component.ts | 53 +- src/assets/editor/README.md | 268 - src/assets/editor/css/editormd.css | 4620 --------- src/assets/editor/css/editormd.logo.css | 98 - src/assets/editor/css/editormd.logo.min.css | 2 - src/assets/editor/css/editormd.min.css | 5 - src/assets/editor/css/editormd.preview.css | 3554 ------- .../editor/css/editormd.preview.min.css | 5 - src/assets/editor/editormd.js | 4598 --------- src/assets/editor/editormd.min.js | 3 - src/assets/editor/fonts/FontAwesome.otf | Bin 93888 -> 0 bytes src/assets/editor/fonts/editormd-logo.eot | Bin 1320 -> 0 bytes src/assets/editor/fonts/editormd-logo.svg | 11 - src/assets/editor/fonts/editormd-logo.ttf | Bin 1156 -> 0 bytes src/assets/editor/fonts/editormd-logo.woff | Bin 1232 -> 0 bytes .../editor/fonts/fontawesome-webfont.eot | Bin 60767 -> 0 bytes .../editor/fonts/fontawesome-webfont.svg | 565 -- .../editor/fonts/fontawesome-webfont.ttf | Bin 122092 -> 0 bytes .../editor/fonts/fontawesome-webfont.woff | Bin 71508 -> 0 bytes .../editor/fonts/fontawesome-webfont.woff2 | Bin 56780 -> 0 bytes src/assets/editor/images/loading.gif | Bin 7726 -> 0 bytes src/assets/editor/images/loading@2x.gif | Bin 16166 -> 0 bytes src/assets/editor/images/loading@3x.gif | Bin 21727 -> 0 bytes .../images/logos/editormd-favicon-16x16.ico | Bin 1150 -> 0 bytes .../images/logos/editormd-favicon-24x24.ico | Bin 1150 -> 0 bytes .../images/logos/editormd-favicon-32x32.ico | Bin 5430 -> 0 bytes .../images/logos/editormd-favicon-48x48.ico | Bin 15086 -> 0 bytes .../images/logos/editormd-favicon-64x64.ico | Bin 32038 -> 0 bytes .../images/logos/editormd-logo-114x114.png | Bin 5869 -> 0 bytes .../images/logos/editormd-logo-120x120.png | Bin 6141 -> 0 bytes .../images/logos/editormd-logo-144x144.png | Bin 7545 -> 0 bytes .../images/logos/editormd-logo-16x16.png | Bin 1448 -> 0 bytes .../images/logos/editormd-logo-180x180.png | Bin 7963 -> 0 bytes .../images/logos/editormd-logo-240x240.png | Bin 10470 -> 0 bytes .../images/logos/editormd-logo-24x24.png | Bin 1790 -> 0 bytes .../images/logos/editormd-logo-320x320.png | Bin 14714 -> 0 bytes .../images/logos/editormd-logo-32x32.png | Bin 2064 -> 0 bytes .../images/logos/editormd-logo-48x48.png | Bin 2701 -> 0 bytes .../images/logos/editormd-logo-57x57.png | Bin 3054 -> 0 bytes .../images/logos/editormd-logo-64x64.png | Bin 3408 -> 0 bytes .../images/logos/editormd-logo-72x72.png | Bin 3691 -> 0 bytes .../images/logos/editormd-logo-96x96.png | Bin 4857 -> 0 bytes src/assets/editor/images/logos/vi.png | Bin 46203 -> 0 bytes src/assets/editor/lib/codemirror/AUTHORS | 436 - src/assets/editor/lib/codemirror/LICENSE | 19 - src/assets/editor/lib/codemirror/README.md | 12 - .../lib/codemirror/addon/comment/comment.js | 183 - .../addon/comment/continuecomment.js | 85 - .../lib/codemirror/addon/dialog/dialog.css | 32 - .../lib/codemirror/addon/dialog/dialog.js | 155 - .../codemirror/addon/display/fullscreen.css | 6 - .../codemirror/addon/display/fullscreen.js | 41 - .../lib/codemirror/addon/display/panel.js | 94 - .../codemirror/addon/display/placeholder.js | 58 - .../lib/codemirror/addon/display/rulers.js | 64 - .../codemirror/addon/edit/closebrackets.js | 161 - .../lib/codemirror/addon/edit/closetag.js | 166 - .../lib/codemirror/addon/edit/continuelist.js | 51 - .../codemirror/addon/edit/matchbrackets.js | 120 - .../lib/codemirror/addon/edit/matchtags.js | 66 - .../codemirror/addon/edit/trailingspace.js | 27 - .../lib/codemirror/addon/fold/brace-fold.js | 105 - .../lib/codemirror/addon/fold/comment-fold.js | 57 - .../lib/codemirror/addon/fold/foldcode.js | 149 - .../lib/codemirror/addon/fold/foldgutter.css | 20 - .../lib/codemirror/addon/fold/foldgutter.js | 144 - .../lib/codemirror/addon/fold/indent-fold.js | 44 - .../codemirror/addon/fold/markdown-fold.js | 49 - .../lib/codemirror/addon/fold/xml-fold.js | 182 - .../lib/codemirror/addon/hint/anyword-hint.js | 41 - .../lib/codemirror/addon/hint/css-hint.js | 56 - .../lib/codemirror/addon/hint/html-hint.js | 348 - .../codemirror/addon/hint/javascript-hint.js | 146 - .../lib/codemirror/addon/hint/show-hint.css | 38 - .../lib/codemirror/addon/hint/show-hint.js | 394 - .../lib/codemirror/addon/hint/sql-hint.js | 240 - .../lib/codemirror/addon/hint/xml-hint.js | 110 - .../addon/lint/coffeescript-lint.js | 41 - .../lib/codemirror/addon/lint/css-lint.js | 35 - .../codemirror/addon/lint/javascript-lint.js | 136 - .../lib/codemirror/addon/lint/json-lint.js | 31 - .../editor/lib/codemirror/addon/lint/lint.css | 73 - .../editor/lib/codemirror/addon/lint/lint.js | 205 - .../lib/codemirror/addon/lint/yaml-lint.js | 28 - .../lib/codemirror/addon/merge/merge.css | 112 - .../lib/codemirror/addon/merge/merge.js | 735 -- .../lib/codemirror/addon/mode/loadmode.js | 64 - .../lib/codemirror/addon/mode/multiplex.js | 118 - .../codemirror/addon/mode/multiplex_test.js | 33 - .../lib/codemirror/addon/mode/overlay.js | 85 - .../lib/codemirror/addon/mode/simple.js | 213 - .../lib/codemirror/addon/runmode/colorize.js | 40 - .../addon/runmode/runmode-standalone.js | 157 - .../lib/codemirror/addon/runmode/runmode.js | 72 - .../codemirror/addon/runmode/runmode.node.js | 120 - .../addon/scroll/annotatescrollbar.js | 100 - .../codemirror/addon/scroll/scrollpastend.js | 46 - .../addon/scroll/simplescrollbars.css | 66 - .../addon/scroll/simplescrollbars.js | 141 - .../addon/search/match-highlighter.js | 128 - .../addon/search/matchesonscrollbar.css | 8 - .../addon/search/matchesonscrollbar.js | 95 - .../lib/codemirror/addon/search/search.js | 164 - .../codemirror/addon/search/searchcursor.js | 189 - .../codemirror/addon/selection/active-line.js | 71 - .../addon/selection/mark-selection.js | 118 - .../addon/selection/selection-pointer.js | 98 - .../editor/lib/codemirror/addon/tern/tern.css | 86 - .../editor/lib/codemirror/addon/tern/tern.js | 697 -- .../lib/codemirror/addon/tern/worker.js | 44 - .../lib/codemirror/addon/wrap/hardwrap.js | 139 - .../editor/lib/codemirror/addons.min.js | 4 - src/assets/editor/lib/codemirror/bower.json | 16 - .../editor/lib/codemirror/codemirror.min.css | 3 - .../editor/lib/codemirror/codemirror.min.js | 54 - .../editor/lib/codemirror/lib/codemirror.css | 331 - .../editor/lib/codemirror/lib/codemirror.js | 8645 ----------------- .../editor/lib/codemirror/mode/apl/apl.js | 175 - .../editor/lib/codemirror/mode/apl/index.html | 72 - .../lib/codemirror/mode/asterisk/asterisk.js | 198 - .../lib/codemirror/mode/asterisk/index.html | 154 - .../editor/lib/codemirror/mode/clike/clike.js | 493 - .../lib/codemirror/mode/clike/index.html | 251 - .../lib/codemirror/mode/clike/scala.html | 767 -- .../lib/codemirror/mode/clojure/clojure.js | 243 - .../lib/codemirror/mode/clojure/index.html | 88 - .../editor/lib/codemirror/mode/cobol/cobol.js | 255 - .../lib/codemirror/mode/cobol/index.html | 210 - .../mode/coffeescript/coffeescript.js | 369 - .../codemirror/mode/coffeescript/index.html | 740 -- .../codemirror/mode/commonlisp/commonlisp.js | 122 - .../lib/codemirror/mode/commonlisp/index.html | 177 - .../editor/lib/codemirror/mode/css/css.js | 766 -- .../editor/lib/codemirror/mode/css/index.html | 75 - .../editor/lib/codemirror/mode/css/less.html | 152 - .../lib/codemirror/mode/css/less_test.js | 51 - .../editor/lib/codemirror/mode/css/scss.html | 157 - .../lib/codemirror/mode/css/scss_test.js | 110 - .../editor/lib/codemirror/mode/css/test.js | 195 - .../lib/codemirror/mode/cypher/cypher.js | 146 - .../lib/codemirror/mode/cypher/index.html | 63 - src/assets/editor/lib/codemirror/mode/d/d.js | 218 - .../editor/lib/codemirror/mode/d/index.html | 273 - .../editor/lib/codemirror/mode/dart/dart.js | 50 - .../lib/codemirror/mode/dart/index.html | 71 - .../editor/lib/codemirror/mode/diff/diff.js | 47 - .../lib/codemirror/mode/diff/index.html | 117 - .../lib/codemirror/mode/django/django.js | 67 - .../lib/codemirror/mode/django/index.html | 63 - .../codemirror/mode/dockerfile/dockerfile.js | 76 - .../lib/codemirror/mode/dockerfile/index.html | 73 - .../editor/lib/codemirror/mode/dtd/dtd.js | 142 - .../editor/lib/codemirror/mode/dtd/index.html | 89 - .../editor/lib/codemirror/mode/dylan/dylan.js | 299 - .../lib/codemirror/mode/dylan/index.html | 407 - .../editor/lib/codemirror/mode/ebnf/ebnf.js | 195 - .../lib/codemirror/mode/ebnf/index.html | 102 - .../editor/lib/codemirror/mode/ecl/ecl.js | 207 - .../editor/lib/codemirror/mode/ecl/index.html | 52 - .../lib/codemirror/mode/eiffel/eiffel.js | 162 - .../lib/codemirror/mode/eiffel/index.html | 429 - .../lib/codemirror/mode/erlang/erlang.js | 622 -- .../lib/codemirror/mode/erlang/index.html | 76 - .../editor/lib/codemirror/mode/forth/forth.js | 180 - .../lib/codemirror/mode/forth/index.html | 75 - .../lib/codemirror/mode/fortran/fortran.js | 188 - .../lib/codemirror/mode/fortran/index.html | 81 - .../editor/lib/codemirror/mode/gas/gas.js | 345 - .../editor/lib/codemirror/mode/gas/index.html | 68 - .../editor/lib/codemirror/mode/gfm/gfm.js | 123 - .../editor/lib/codemirror/mode/gfm/index.html | 93 - .../editor/lib/codemirror/mode/gfm/test.js | 213 - .../lib/codemirror/mode/gherkin/gherkin.js | 178 - .../lib/codemirror/mode/gherkin/index.html | 48 - .../editor/lib/codemirror/mode/go/go.js | 185 - .../editor/lib/codemirror/mode/go/index.html | 85 - .../lib/codemirror/mode/groovy/groovy.js | 226 - .../lib/codemirror/mode/groovy/index.html | 84 - .../editor/lib/codemirror/mode/haml/haml.js | 159 - .../lib/codemirror/mode/haml/index.html | 79 - .../editor/lib/codemirror/mode/haml/test.js | 97 - .../lib/codemirror/mode/haskell/haskell.js | 267 - .../lib/codemirror/mode/haskell/index.html | 73 - .../editor/lib/codemirror/mode/haxe/haxe.js | 518 - .../lib/codemirror/mode/haxe/index.html | 124 - .../mode/htmlembedded/htmlembedded.js | 86 - .../codemirror/mode/htmlembedded/index.html | 58 - .../codemirror/mode/htmlmixed/htmlmixed.js | 121 - .../lib/codemirror/mode/htmlmixed/index.html | 89 - .../editor/lib/codemirror/mode/http/http.js | 113 - .../lib/codemirror/mode/http/index.html | 45 - .../editor/lib/codemirror/mode/idl/idl.js | 290 - .../editor/lib/codemirror/mode/idl/index.html | 64 - .../editor/lib/codemirror/mode/index.html | 134 - .../lib/codemirror/mode/jade/index.html | 70 - .../editor/lib/codemirror/mode/jade/jade.js | 590 -- .../lib/codemirror/mode/javascript/index.html | 114 - .../codemirror/mode/javascript/javascript.js | 692 -- .../codemirror/mode/javascript/json-ld.html | 72 - .../lib/codemirror/mode/javascript/test.js | 200 - .../mode/javascript/typescript.html | 61 - .../lib/codemirror/mode/jinja2/index.html | 54 - .../lib/codemirror/mode/jinja2/jinja2.js | 142 - .../lib/codemirror/mode/julia/index.html | 195 - .../editor/lib/codemirror/mode/julia/julia.js | 301 - .../lib/codemirror/mode/kotlin/index.html | 89 - .../lib/codemirror/mode/kotlin/kotlin.js | 280 - .../lib/codemirror/mode/livescript/index.html | 459 - .../codemirror/mode/livescript/livescript.js | 280 - .../editor/lib/codemirror/mode/lua/index.html | 85 - .../editor/lib/codemirror/mode/lua/lua.js | 159 - .../lib/codemirror/mode/markdown/index.html | 359 - .../lib/codemirror/mode/markdown/markdown.js | 765 -- .../lib/codemirror/mode/markdown/test.js | 754 -- src/assets/editor/lib/codemirror/mode/meta.js | 177 - .../lib/codemirror/mode/mirc/index.html | 160 - .../editor/lib/codemirror/mode/mirc/mirc.js | 193 - .../lib/codemirror/mode/mllike/index.html | 179 - .../lib/codemirror/mode/mllike/mllike.js | 205 - .../lib/codemirror/mode/modelica/index.html | 67 - .../lib/codemirror/mode/modelica/modelica.js | 245 - .../lib/codemirror/mode/nginx/index.html | 181 - .../editor/lib/codemirror/mode/nginx/nginx.js | 178 - .../lib/codemirror/mode/ntriples/index.html | 45 - .../lib/codemirror/mode/ntriples/ntriples.js | 186 - .../lib/codemirror/mode/octave/index.html | 83 - .../lib/codemirror/mode/octave/octave.js | 135 - .../lib/codemirror/mode/pascal/index.html | 61 - .../lib/codemirror/mode/pascal/pascal.js | 109 - .../lib/codemirror/mode/pegjs/index.html | 66 - .../editor/lib/codemirror/mode/pegjs/pegjs.js | 114 - .../lib/codemirror/mode/perl/index.html | 75 - .../editor/lib/codemirror/mode/perl/perl.js | 837 -- .../editor/lib/codemirror/mode/php/index.html | 64 - .../editor/lib/codemirror/mode/php/php.js | 226 - .../editor/lib/codemirror/mode/php/test.js | 154 - .../editor/lib/codemirror/mode/pig/index.html | 55 - .../editor/lib/codemirror/mode/pig/pig.js | 188 - .../lib/codemirror/mode/properties/index.html | 53 - .../codemirror/mode/properties/properties.js | 78 - .../lib/codemirror/mode/puppet/index.html | 121 - .../lib/codemirror/mode/puppet/puppet.js | 220 - .../lib/codemirror/mode/python/index.html | 198 - .../lib/codemirror/mode/python/python.js | 359 - .../editor/lib/codemirror/mode/q/index.html | 144 - src/assets/editor/lib/codemirror/mode/q/q.js | 139 - .../editor/lib/codemirror/mode/r/index.html | 85 - src/assets/editor/lib/codemirror/mode/r/r.js | 162 - .../codemirror/mode/rpm/changes/index.html | 66 - .../editor/lib/codemirror/mode/rpm/index.html | 149 - .../editor/lib/codemirror/mode/rpm/rpm.js | 101 - .../editor/lib/codemirror/mode/rst/index.html | 535 - .../editor/lib/codemirror/mode/rst/rst.js | 557 -- .../lib/codemirror/mode/ruby/index.html | 183 - .../editor/lib/codemirror/mode/ruby/ruby.js | 285 - .../editor/lib/codemirror/mode/ruby/test.js | 14 - .../lib/codemirror/mode/rust/index.html | 60 - .../editor/lib/codemirror/mode/rust/rust.js | 451 - .../lib/codemirror/mode/sass/index.html | 66 - .../editor/lib/codemirror/mode/sass/sass.js | 414 - .../lib/codemirror/mode/scheme/index.html | 77 - .../lib/codemirror/mode/scheme/scheme.js | 248 - .../lib/codemirror/mode/shell/index.html | 66 - .../editor/lib/codemirror/mode/shell/shell.js | 139 - .../editor/lib/codemirror/mode/shell/test.js | 58 - .../lib/codemirror/mode/sieve/index.html | 93 - .../editor/lib/codemirror/mode/sieve/sieve.js | 193 - .../lib/codemirror/mode/slim/index.html | 96 - .../editor/lib/codemirror/mode/slim/slim.js | 575 -- .../editor/lib/codemirror/mode/slim/test.js | 96 - .../lib/codemirror/mode/smalltalk/index.html | 68 - .../codemirror/mode/smalltalk/smalltalk.js | 168 - .../lib/codemirror/mode/smarty/index.html | 136 - .../lib/codemirror/mode/smarty/smarty.js | 221 - .../codemirror/mode/smartymixed/index.html | 114 - .../mode/smartymixed/smartymixed.js | 197 - .../lib/codemirror/mode/solr/index.html | 57 - .../editor/lib/codemirror/mode/solr/solr.js | 104 - .../editor/lib/codemirror/mode/soy/index.html | 68 - .../editor/lib/codemirror/mode/soy/soy.js | 198 - .../lib/codemirror/mode/sparql/index.html | 61 - .../lib/codemirror/mode/sparql/sparql.js | 174 - .../codemirror/mode/spreadsheet/index.html | 42 - .../mode/spreadsheet/spreadsheet.js | 109 - .../editor/lib/codemirror/mode/sql/index.html | 84 - .../editor/lib/codemirror/mode/sql/sql.js | 391 - .../lib/codemirror/mode/stex/index.html | 110 - .../editor/lib/codemirror/mode/stex/stex.js | 251 - .../editor/lib/codemirror/mode/stex/test.js | 123 - .../lib/codemirror/mode/stylus/index.html | 104 - .../lib/codemirror/mode/stylus/stylus.js | 444 - .../editor/lib/codemirror/mode/tcl/index.html | 142 - .../editor/lib/codemirror/mode/tcl/tcl.js | 147 - .../lib/codemirror/mode/textile/index.html | 191 - .../lib/codemirror/mode/textile/test.js | 417 - .../lib/codemirror/mode/textile/textile.js | 469 - .../lib/codemirror/mode/tiddlywiki/index.html | 154 - .../codemirror/mode/tiddlywiki/tiddlywiki.css | 14 - .../codemirror/mode/tiddlywiki/tiddlywiki.js | 369 - .../lib/codemirror/mode/tiki/index.html | 95 - .../editor/lib/codemirror/mode/tiki/tiki.css | 26 - .../editor/lib/codemirror/mode/tiki/tiki.js | 323 - .../lib/codemirror/mode/toml/index.html | 73 - .../editor/lib/codemirror/mode/toml/toml.js | 88 - .../lib/codemirror/mode/tornado/index.html | 63 - .../lib/codemirror/mode/tornado/tornado.js | 68 - .../lib/codemirror/mode/turtle/index.html | 50 - .../lib/codemirror/mode/turtle/turtle.js | 162 - .../editor/lib/codemirror/mode/vb/index.html | 102 - .../editor/lib/codemirror/mode/vb/vb.js | 274 - .../lib/codemirror/mode/vbscript/index.html | 55 - .../lib/codemirror/mode/vbscript/vbscript.js | 350 - .../lib/codemirror/mode/velocity/index.html | 118 - .../lib/codemirror/mode/velocity/velocity.js | 201 - .../lib/codemirror/mode/verilog/index.html | 120 - .../lib/codemirror/mode/verilog/test.js | 273 - .../lib/codemirror/mode/verilog/verilog.js | 537 - .../editor/lib/codemirror/mode/xml/index.html | 57 - .../editor/lib/codemirror/mode/xml/test.js | 51 - .../editor/lib/codemirror/mode/xml/xml.js | 384 - .../lib/codemirror/mode/xquery/index.html | 210 - .../editor/lib/codemirror/mode/xquery/test.js | 67 - .../lib/codemirror/mode/xquery/xquery.js | 447 - .../lib/codemirror/mode/yaml/index.html | 80 - .../editor/lib/codemirror/mode/yaml/yaml.js | 117 - .../editor/lib/codemirror/mode/z80/index.html | 52 - .../editor/lib/codemirror/mode/z80/z80.js | 100 - src/assets/editor/lib/codemirror/modes.min.js | 10 - src/assets/editor/lib/codemirror/package.json | 21 - .../editor/lib/codemirror/theme/3024-day.css | 40 - .../lib/codemirror/theme/3024-night.css | 39 - .../lib/codemirror/theme/ambiance-mobile.css | 5 - .../editor/lib/codemirror/theme/ambiance.css | 75 - .../lib/codemirror/theme/base16-dark.css | 38 - .../lib/codemirror/theme/base16-light.css | 38 - .../lib/codemirror/theme/blackboard.css | 32 - .../editor/lib/codemirror/theme/cobalt.css | 25 - .../lib/codemirror/theme/colorforth.css | 33 - .../editor/lib/codemirror/theme/eclipse.css | 23 - .../editor/lib/codemirror/theme/elegant.css | 13 - .../lib/codemirror/theme/erlang-dark.css | 34 - .../lib/codemirror/theme/lesser-dark.css | 47 - .../editor/lib/codemirror/theme/mbo.css | 37 - .../editor/lib/codemirror/theme/mdn-like.css | 46 - .../editor/lib/codemirror/theme/midnight.css | 47 - .../editor/lib/codemirror/theme/monokai.css | 33 - .../editor/lib/codemirror/theme/neat.css | 12 - .../editor/lib/codemirror/theme/neo.css | 43 - .../editor/lib/codemirror/theme/night.css | 28 - .../lib/codemirror/theme/paraiso-dark.css | 38 - .../lib/codemirror/theme/paraiso-light.css | 38 - .../lib/codemirror/theme/pastel-on-dark.css | 53 - .../editor/lib/codemirror/theme/rubyblue.css | 25 - .../editor/lib/codemirror/theme/solarized.css | 165 - .../lib/codemirror/theme/the-matrix.css | 30 - .../theme/tomorrow-night-bright.css | 35 - .../theme/tomorrow-night-eighties.css | 38 - .../editor/lib/codemirror/theme/twilight.css | 32 - .../lib/codemirror/theme/vibrant-ink.css | 34 - .../editor/lib/codemirror/theme/xq-dark.css | 53 - .../editor/lib/codemirror/theme/xq-light.css | 43 - .../editor/lib/codemirror/theme/zenburn.css | 37 - src/assets/editor/lib/flowchart.min.js | 5 - src/assets/editor/lib/jquery.flowchart.min.js | 2 - src/assets/editor/lib/marked.min.js | 9 - src/assets/editor/lib/prettify.min.js | 15 - src/assets/editor/lib/raphael.min.js | 11 - src/assets/editor/lib/sequence-diagram.min.js | 7 - src/assets/editor/lib/underscore.min.js | 5 - .../code-block-dialog/code-block-dialog.js | 237 - .../plugins/emoji-dialog/emoji-dialog.js | 327 - .../editor/plugins/emoji-dialog/emoji.json | 28 - .../goto-line-dialog/goto-line-dialog.js | 157 - .../editor/plugins/help-dialog/help-dialog.js | 102 - src/assets/editor/plugins/help-dialog/help.md | 77 - .../html-entities-dialog.js | 173 - .../html-entities-dialog/html-entities.json | 936 -- .../plugins/image-dialog/image-dialog.js | 255 - .../editor/plugins/link-dialog/link-dialog.js | 133 - src/assets/editor/plugins/plugin-template.js | 111 - .../preformatted-text-dialog.js | 172 - .../reference-link-dialog.js | 153 - .../plugins/table-dialog/table-dialog.js | 218 - .../editor/plugins/test-plugin/test-plugin.js | 66 - src/styles.less | 2 + 390 files changed, 48 insertions(+), 75554 deletions(-) delete mode 100644 src/assets/editor/README.md delete mode 100644 src/assets/editor/css/editormd.css delete mode 100644 src/assets/editor/css/editormd.logo.css delete mode 100644 src/assets/editor/css/editormd.logo.min.css delete mode 100644 src/assets/editor/css/editormd.min.css delete mode 100644 src/assets/editor/css/editormd.preview.css delete mode 100644 src/assets/editor/css/editormd.preview.min.css delete mode 100644 src/assets/editor/editormd.js delete mode 100644 src/assets/editor/editormd.min.js delete mode 100644 src/assets/editor/fonts/FontAwesome.otf delete mode 100644 src/assets/editor/fonts/editormd-logo.eot delete mode 100644 src/assets/editor/fonts/editormd-logo.svg delete mode 100644 src/assets/editor/fonts/editormd-logo.ttf delete mode 100644 src/assets/editor/fonts/editormd-logo.woff delete mode 100644 src/assets/editor/fonts/fontawesome-webfont.eot delete mode 100644 src/assets/editor/fonts/fontawesome-webfont.svg delete mode 100644 src/assets/editor/fonts/fontawesome-webfont.ttf delete mode 100644 src/assets/editor/fonts/fontawesome-webfont.woff delete mode 100644 src/assets/editor/fonts/fontawesome-webfont.woff2 delete mode 100644 src/assets/editor/images/loading.gif delete mode 100644 src/assets/editor/images/loading@2x.gif delete mode 100644 src/assets/editor/images/loading@3x.gif delete mode 100644 src/assets/editor/images/logos/editormd-favicon-16x16.ico delete mode 100644 src/assets/editor/images/logos/editormd-favicon-24x24.ico delete mode 100644 src/assets/editor/images/logos/editormd-favicon-32x32.ico delete mode 100644 src/assets/editor/images/logos/editormd-favicon-48x48.ico delete mode 100644 src/assets/editor/images/logos/editormd-favicon-64x64.ico delete mode 100644 src/assets/editor/images/logos/editormd-logo-114x114.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-120x120.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-144x144.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-16x16.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-180x180.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-240x240.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-24x24.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-320x320.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-32x32.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-48x48.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-57x57.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-64x64.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-72x72.png delete mode 100644 src/assets/editor/images/logos/editormd-logo-96x96.png delete mode 100644 src/assets/editor/images/logos/vi.png delete mode 100644 src/assets/editor/lib/codemirror/AUTHORS delete mode 100644 src/assets/editor/lib/codemirror/LICENSE delete mode 100644 src/assets/editor/lib/codemirror/README.md delete mode 100644 src/assets/editor/lib/codemirror/addon/comment/comment.js delete mode 100644 src/assets/editor/lib/codemirror/addon/comment/continuecomment.js delete mode 100644 src/assets/editor/lib/codemirror/addon/dialog/dialog.css delete mode 100644 src/assets/editor/lib/codemirror/addon/dialog/dialog.js delete mode 100644 src/assets/editor/lib/codemirror/addon/display/fullscreen.css delete mode 100644 src/assets/editor/lib/codemirror/addon/display/fullscreen.js delete mode 100644 src/assets/editor/lib/codemirror/addon/display/panel.js delete mode 100644 src/assets/editor/lib/codemirror/addon/display/placeholder.js delete mode 100644 src/assets/editor/lib/codemirror/addon/display/rulers.js delete mode 100644 src/assets/editor/lib/codemirror/addon/edit/closebrackets.js delete mode 100644 src/assets/editor/lib/codemirror/addon/edit/closetag.js delete mode 100644 src/assets/editor/lib/codemirror/addon/edit/continuelist.js delete mode 100644 src/assets/editor/lib/codemirror/addon/edit/matchbrackets.js delete mode 100644 src/assets/editor/lib/codemirror/addon/edit/matchtags.js delete mode 100644 src/assets/editor/lib/codemirror/addon/edit/trailingspace.js delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/brace-fold.js delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/comment-fold.js delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/foldcode.js delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/foldgutter.css delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/foldgutter.js delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/indent-fold.js delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/markdown-fold.js delete mode 100644 src/assets/editor/lib/codemirror/addon/fold/xml-fold.js delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/anyword-hint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/css-hint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/html-hint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/javascript-hint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/show-hint.css delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/show-hint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/sql-hint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/hint/xml-hint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/lint/coffeescript-lint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/lint/css-lint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/lint/javascript-lint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/lint/json-lint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/lint/lint.css delete mode 100644 src/assets/editor/lib/codemirror/addon/lint/lint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/lint/yaml-lint.js delete mode 100644 src/assets/editor/lib/codemirror/addon/merge/merge.css delete mode 100644 src/assets/editor/lib/codemirror/addon/merge/merge.js delete mode 100644 src/assets/editor/lib/codemirror/addon/mode/loadmode.js delete mode 100644 src/assets/editor/lib/codemirror/addon/mode/multiplex.js delete mode 100644 src/assets/editor/lib/codemirror/addon/mode/multiplex_test.js delete mode 100644 src/assets/editor/lib/codemirror/addon/mode/overlay.js delete mode 100644 src/assets/editor/lib/codemirror/addon/mode/simple.js delete mode 100644 src/assets/editor/lib/codemirror/addon/runmode/colorize.js delete mode 100644 src/assets/editor/lib/codemirror/addon/runmode/runmode-standalone.js delete mode 100644 src/assets/editor/lib/codemirror/addon/runmode/runmode.js delete mode 100644 src/assets/editor/lib/codemirror/addon/runmode/runmode.node.js delete mode 100644 src/assets/editor/lib/codemirror/addon/scroll/annotatescrollbar.js delete mode 100644 src/assets/editor/lib/codemirror/addon/scroll/scrollpastend.js delete mode 100644 src/assets/editor/lib/codemirror/addon/scroll/simplescrollbars.css delete mode 100644 src/assets/editor/lib/codemirror/addon/scroll/simplescrollbars.js delete mode 100644 src/assets/editor/lib/codemirror/addon/search/match-highlighter.js delete mode 100644 src/assets/editor/lib/codemirror/addon/search/matchesonscrollbar.css delete mode 100644 src/assets/editor/lib/codemirror/addon/search/matchesonscrollbar.js delete mode 100644 src/assets/editor/lib/codemirror/addon/search/search.js delete mode 100644 src/assets/editor/lib/codemirror/addon/search/searchcursor.js delete mode 100644 src/assets/editor/lib/codemirror/addon/selection/active-line.js delete mode 100644 src/assets/editor/lib/codemirror/addon/selection/mark-selection.js delete mode 100644 src/assets/editor/lib/codemirror/addon/selection/selection-pointer.js delete mode 100644 src/assets/editor/lib/codemirror/addon/tern/tern.css delete mode 100644 src/assets/editor/lib/codemirror/addon/tern/tern.js delete mode 100644 src/assets/editor/lib/codemirror/addon/tern/worker.js delete mode 100644 src/assets/editor/lib/codemirror/addon/wrap/hardwrap.js delete mode 100644 src/assets/editor/lib/codemirror/addons.min.js delete mode 100644 src/assets/editor/lib/codemirror/bower.json delete mode 100644 src/assets/editor/lib/codemirror/codemirror.min.css delete mode 100644 src/assets/editor/lib/codemirror/codemirror.min.js delete mode 100644 src/assets/editor/lib/codemirror/lib/codemirror.css delete mode 100644 src/assets/editor/lib/codemirror/lib/codemirror.js delete mode 100644 src/assets/editor/lib/codemirror/mode/apl/apl.js delete mode 100644 src/assets/editor/lib/codemirror/mode/apl/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/asterisk/asterisk.js delete mode 100644 src/assets/editor/lib/codemirror/mode/asterisk/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/clike/clike.js delete mode 100644 src/assets/editor/lib/codemirror/mode/clike/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/clike/scala.html delete mode 100644 src/assets/editor/lib/codemirror/mode/clojure/clojure.js delete mode 100644 src/assets/editor/lib/codemirror/mode/clojure/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/cobol/cobol.js delete mode 100644 src/assets/editor/lib/codemirror/mode/cobol/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/coffeescript/coffeescript.js delete mode 100644 src/assets/editor/lib/codemirror/mode/coffeescript/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/commonlisp/commonlisp.js delete mode 100644 src/assets/editor/lib/codemirror/mode/commonlisp/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/css/css.js delete mode 100644 src/assets/editor/lib/codemirror/mode/css/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/css/less.html delete mode 100644 src/assets/editor/lib/codemirror/mode/css/less_test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/css/scss.html delete mode 100644 src/assets/editor/lib/codemirror/mode/css/scss_test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/css/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/cypher/cypher.js delete mode 100644 src/assets/editor/lib/codemirror/mode/cypher/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/d/d.js delete mode 100644 src/assets/editor/lib/codemirror/mode/d/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/dart/dart.js delete mode 100644 src/assets/editor/lib/codemirror/mode/dart/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/diff/diff.js delete mode 100644 src/assets/editor/lib/codemirror/mode/diff/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/django/django.js delete mode 100644 src/assets/editor/lib/codemirror/mode/django/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/dockerfile/dockerfile.js delete mode 100644 src/assets/editor/lib/codemirror/mode/dockerfile/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/dtd/dtd.js delete mode 100644 src/assets/editor/lib/codemirror/mode/dtd/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/dylan/dylan.js delete mode 100644 src/assets/editor/lib/codemirror/mode/dylan/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/ebnf/ebnf.js delete mode 100644 src/assets/editor/lib/codemirror/mode/ebnf/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/ecl/ecl.js delete mode 100644 src/assets/editor/lib/codemirror/mode/ecl/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/eiffel/eiffel.js delete mode 100644 src/assets/editor/lib/codemirror/mode/eiffel/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/erlang/erlang.js delete mode 100644 src/assets/editor/lib/codemirror/mode/erlang/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/forth/forth.js delete mode 100644 src/assets/editor/lib/codemirror/mode/forth/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/fortran/fortran.js delete mode 100644 src/assets/editor/lib/codemirror/mode/fortran/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/gas/gas.js delete mode 100644 src/assets/editor/lib/codemirror/mode/gas/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/gfm/gfm.js delete mode 100644 src/assets/editor/lib/codemirror/mode/gfm/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/gfm/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/gherkin/gherkin.js delete mode 100644 src/assets/editor/lib/codemirror/mode/gherkin/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/go/go.js delete mode 100644 src/assets/editor/lib/codemirror/mode/go/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/groovy/groovy.js delete mode 100644 src/assets/editor/lib/codemirror/mode/groovy/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/haml/haml.js delete mode 100644 src/assets/editor/lib/codemirror/mode/haml/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/haml/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/haskell/haskell.js delete mode 100644 src/assets/editor/lib/codemirror/mode/haskell/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/haxe/haxe.js delete mode 100644 src/assets/editor/lib/codemirror/mode/haxe/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/htmlembedded/htmlembedded.js delete mode 100644 src/assets/editor/lib/codemirror/mode/htmlembedded/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/htmlmixed/htmlmixed.js delete mode 100644 src/assets/editor/lib/codemirror/mode/htmlmixed/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/http/http.js delete mode 100644 src/assets/editor/lib/codemirror/mode/http/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/idl/idl.js delete mode 100644 src/assets/editor/lib/codemirror/mode/idl/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/jade/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/jade/jade.js delete mode 100644 src/assets/editor/lib/codemirror/mode/javascript/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/javascript/javascript.js delete mode 100644 src/assets/editor/lib/codemirror/mode/javascript/json-ld.html delete mode 100644 src/assets/editor/lib/codemirror/mode/javascript/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/javascript/typescript.html delete mode 100644 src/assets/editor/lib/codemirror/mode/jinja2/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/jinja2/jinja2.js delete mode 100644 src/assets/editor/lib/codemirror/mode/julia/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/julia/julia.js delete mode 100644 src/assets/editor/lib/codemirror/mode/kotlin/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/kotlin/kotlin.js delete mode 100644 src/assets/editor/lib/codemirror/mode/livescript/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/livescript/livescript.js delete mode 100644 src/assets/editor/lib/codemirror/mode/lua/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/lua/lua.js delete mode 100644 src/assets/editor/lib/codemirror/mode/markdown/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/markdown/markdown.js delete mode 100644 src/assets/editor/lib/codemirror/mode/markdown/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/meta.js delete mode 100644 src/assets/editor/lib/codemirror/mode/mirc/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/mirc/mirc.js delete mode 100644 src/assets/editor/lib/codemirror/mode/mllike/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/mllike/mllike.js delete mode 100644 src/assets/editor/lib/codemirror/mode/modelica/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/modelica/modelica.js delete mode 100644 src/assets/editor/lib/codemirror/mode/nginx/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/nginx/nginx.js delete mode 100644 src/assets/editor/lib/codemirror/mode/ntriples/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/ntriples/ntriples.js delete mode 100644 src/assets/editor/lib/codemirror/mode/octave/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/octave/octave.js delete mode 100644 src/assets/editor/lib/codemirror/mode/pascal/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/pascal/pascal.js delete mode 100644 src/assets/editor/lib/codemirror/mode/pegjs/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/pegjs/pegjs.js delete mode 100644 src/assets/editor/lib/codemirror/mode/perl/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/perl/perl.js delete mode 100644 src/assets/editor/lib/codemirror/mode/php/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/php/php.js delete mode 100644 src/assets/editor/lib/codemirror/mode/php/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/pig/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/pig/pig.js delete mode 100644 src/assets/editor/lib/codemirror/mode/properties/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/properties/properties.js delete mode 100644 src/assets/editor/lib/codemirror/mode/puppet/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/puppet/puppet.js delete mode 100644 src/assets/editor/lib/codemirror/mode/python/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/python/python.js delete mode 100644 src/assets/editor/lib/codemirror/mode/q/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/q/q.js delete mode 100644 src/assets/editor/lib/codemirror/mode/r/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/r/r.js delete mode 100644 src/assets/editor/lib/codemirror/mode/rpm/changes/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/rpm/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/rpm/rpm.js delete mode 100644 src/assets/editor/lib/codemirror/mode/rst/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/rst/rst.js delete mode 100644 src/assets/editor/lib/codemirror/mode/ruby/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/ruby/ruby.js delete mode 100644 src/assets/editor/lib/codemirror/mode/ruby/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/rust/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/rust/rust.js delete mode 100644 src/assets/editor/lib/codemirror/mode/sass/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/sass/sass.js delete mode 100644 src/assets/editor/lib/codemirror/mode/scheme/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/scheme/scheme.js delete mode 100644 src/assets/editor/lib/codemirror/mode/shell/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/shell/shell.js delete mode 100644 src/assets/editor/lib/codemirror/mode/shell/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/sieve/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/sieve/sieve.js delete mode 100644 src/assets/editor/lib/codemirror/mode/slim/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/slim/slim.js delete mode 100644 src/assets/editor/lib/codemirror/mode/slim/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/smalltalk/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/smalltalk/smalltalk.js delete mode 100644 src/assets/editor/lib/codemirror/mode/smarty/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/smarty/smarty.js delete mode 100644 src/assets/editor/lib/codemirror/mode/smartymixed/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/smartymixed/smartymixed.js delete mode 100644 src/assets/editor/lib/codemirror/mode/solr/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/solr/solr.js delete mode 100644 src/assets/editor/lib/codemirror/mode/soy/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/soy/soy.js delete mode 100644 src/assets/editor/lib/codemirror/mode/sparql/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/sparql/sparql.js delete mode 100644 src/assets/editor/lib/codemirror/mode/spreadsheet/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/spreadsheet/spreadsheet.js delete mode 100644 src/assets/editor/lib/codemirror/mode/sql/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/sql/sql.js delete mode 100644 src/assets/editor/lib/codemirror/mode/stex/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/stex/stex.js delete mode 100644 src/assets/editor/lib/codemirror/mode/stex/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/stylus/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/stylus/stylus.js delete mode 100644 src/assets/editor/lib/codemirror/mode/tcl/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/tcl/tcl.js delete mode 100644 src/assets/editor/lib/codemirror/mode/textile/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/textile/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/textile/textile.js delete mode 100644 src/assets/editor/lib/codemirror/mode/tiddlywiki/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/tiddlywiki/tiddlywiki.css delete mode 100644 src/assets/editor/lib/codemirror/mode/tiddlywiki/tiddlywiki.js delete mode 100644 src/assets/editor/lib/codemirror/mode/tiki/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/tiki/tiki.css delete mode 100644 src/assets/editor/lib/codemirror/mode/tiki/tiki.js delete mode 100644 src/assets/editor/lib/codemirror/mode/toml/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/toml/toml.js delete mode 100644 src/assets/editor/lib/codemirror/mode/tornado/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/tornado/tornado.js delete mode 100644 src/assets/editor/lib/codemirror/mode/turtle/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/turtle/turtle.js delete mode 100644 src/assets/editor/lib/codemirror/mode/vb/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/vb/vb.js delete mode 100644 src/assets/editor/lib/codemirror/mode/vbscript/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/vbscript/vbscript.js delete mode 100644 src/assets/editor/lib/codemirror/mode/velocity/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/velocity/velocity.js delete mode 100644 src/assets/editor/lib/codemirror/mode/verilog/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/verilog/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/verilog/verilog.js delete mode 100644 src/assets/editor/lib/codemirror/mode/xml/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/xml/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/xml/xml.js delete mode 100644 src/assets/editor/lib/codemirror/mode/xquery/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/xquery/test.js delete mode 100644 src/assets/editor/lib/codemirror/mode/xquery/xquery.js delete mode 100644 src/assets/editor/lib/codemirror/mode/yaml/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/yaml/yaml.js delete mode 100644 src/assets/editor/lib/codemirror/mode/z80/index.html delete mode 100644 src/assets/editor/lib/codemirror/mode/z80/z80.js delete mode 100644 src/assets/editor/lib/codemirror/modes.min.js delete mode 100644 src/assets/editor/lib/codemirror/package.json delete mode 100644 src/assets/editor/lib/codemirror/theme/3024-day.css delete mode 100644 src/assets/editor/lib/codemirror/theme/3024-night.css delete mode 100644 src/assets/editor/lib/codemirror/theme/ambiance-mobile.css delete mode 100644 src/assets/editor/lib/codemirror/theme/ambiance.css delete mode 100644 src/assets/editor/lib/codemirror/theme/base16-dark.css delete mode 100644 src/assets/editor/lib/codemirror/theme/base16-light.css delete mode 100644 src/assets/editor/lib/codemirror/theme/blackboard.css delete mode 100644 src/assets/editor/lib/codemirror/theme/cobalt.css delete mode 100644 src/assets/editor/lib/codemirror/theme/colorforth.css delete mode 100644 src/assets/editor/lib/codemirror/theme/eclipse.css delete mode 100644 src/assets/editor/lib/codemirror/theme/elegant.css delete mode 100644 src/assets/editor/lib/codemirror/theme/erlang-dark.css delete mode 100644 src/assets/editor/lib/codemirror/theme/lesser-dark.css delete mode 100644 src/assets/editor/lib/codemirror/theme/mbo.css delete mode 100644 src/assets/editor/lib/codemirror/theme/mdn-like.css delete mode 100644 src/assets/editor/lib/codemirror/theme/midnight.css delete mode 100644 src/assets/editor/lib/codemirror/theme/monokai.css delete mode 100644 src/assets/editor/lib/codemirror/theme/neat.css delete mode 100644 src/assets/editor/lib/codemirror/theme/neo.css delete mode 100644 src/assets/editor/lib/codemirror/theme/night.css delete mode 100644 src/assets/editor/lib/codemirror/theme/paraiso-dark.css delete mode 100644 src/assets/editor/lib/codemirror/theme/paraiso-light.css delete mode 100644 src/assets/editor/lib/codemirror/theme/pastel-on-dark.css delete mode 100644 src/assets/editor/lib/codemirror/theme/rubyblue.css delete mode 100644 src/assets/editor/lib/codemirror/theme/solarized.css delete mode 100644 src/assets/editor/lib/codemirror/theme/the-matrix.css delete mode 100644 src/assets/editor/lib/codemirror/theme/tomorrow-night-bright.css delete mode 100644 src/assets/editor/lib/codemirror/theme/tomorrow-night-eighties.css delete mode 100644 src/assets/editor/lib/codemirror/theme/twilight.css delete mode 100644 src/assets/editor/lib/codemirror/theme/vibrant-ink.css delete mode 100644 src/assets/editor/lib/codemirror/theme/xq-dark.css delete mode 100644 src/assets/editor/lib/codemirror/theme/xq-light.css delete mode 100644 src/assets/editor/lib/codemirror/theme/zenburn.css delete mode 100644 src/assets/editor/lib/flowchart.min.js delete mode 100644 src/assets/editor/lib/jquery.flowchart.min.js delete mode 100644 src/assets/editor/lib/marked.min.js delete mode 100644 src/assets/editor/lib/prettify.min.js delete mode 100644 src/assets/editor/lib/raphael.min.js delete mode 100644 src/assets/editor/lib/sequence-diagram.min.js delete mode 100644 src/assets/editor/lib/underscore.min.js delete mode 100644 src/assets/editor/plugins/code-block-dialog/code-block-dialog.js delete mode 100644 src/assets/editor/plugins/emoji-dialog/emoji-dialog.js delete mode 100644 src/assets/editor/plugins/emoji-dialog/emoji.json delete mode 100644 src/assets/editor/plugins/goto-line-dialog/goto-line-dialog.js delete mode 100644 src/assets/editor/plugins/help-dialog/help-dialog.js delete mode 100644 src/assets/editor/plugins/help-dialog/help.md delete mode 100644 src/assets/editor/plugins/html-entities-dialog/html-entities-dialog.js delete mode 100644 src/assets/editor/plugins/html-entities-dialog/html-entities.json delete mode 100644 src/assets/editor/plugins/image-dialog/image-dialog.js delete mode 100644 src/assets/editor/plugins/link-dialog/link-dialog.js delete mode 100644 src/assets/editor/plugins/plugin-template.js delete mode 100644 src/assets/editor/plugins/preformatted-text-dialog/preformatted-text-dialog.js delete mode 100644 src/assets/editor/plugins/reference-link-dialog/reference-link-dialog.js delete mode 100644 src/assets/editor/plugins/table-dialog/table-dialog.js delete mode 100644 src/assets/editor/plugins/test-plugin/test-plugin.js diff --git a/angular.json b/angular.json index 94596a3..597ef25 100644 --- a/angular.json +++ b/angular.json @@ -34,18 +34,11 @@ "src/manifest.webmanifest" ], "styles": [ - "src/assets/editor/css/editormd.css", "./node_modules/ng-zorro-antd/ng-zorro-antd.min.css", "src/styles.less" ], "scripts": [ "./node_modules/jquery/dist/jquery.min.js", - "src/assets/editor/lib/marked.min.js", - "src/assets/editor/lib/prettify.min.js", - "src/assets/editor/lib/underscore.min.js", - "src/assets/editor/lib/flowchart.min.js", - "src/assets/editor/lib/jquery.flowchart.min.js", - "src/assets/editor/editormd.min.js" ] }, "configurations": { diff --git a/package-lock.json b/package-lock.json index 7fcdf0a..c0a1732 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4338,6 +4338,11 @@ "integrity": "sha1-YPOuy4nV+uUgwRqhnvwruYKq3n0=", "dev": true }, + "diff-match-patch": { + "version": "1.0.5", + "resolved": "https://registry.npm.taobao.org/diff-match-patch/download/diff-match-patch-1.0.5.tgz", + "integrity": "sha1-q7WE1fEM0Rlt/FWqA3AVkq4/ezc=" + }, "diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npm.taobao.org/diffie-hellman/download/diffie-hellman-5.0.3.tgz", @@ -12742,6 +12747,14 @@ "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "dev": true }, + "vditor": { + "version": "3.5.4", + "resolved": "https://registry.npm.taobao.org/vditor/download/vditor-3.5.4.tgz", + "integrity": "sha1-/7b5nq01vAW0cnUV9vnlpZhxAeg=", + "requires": { + "diff-match-patch": "^1.0.5" + } + }, "vendors": { "version": "1.0.4", "resolved": "https://registry.npm.taobao.org/vendors/download/vendors-1.0.4.tgz", diff --git a/package.json b/package.json index 1ac71d2..bd16f34 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "ng-zorro-antd": "^9.3.0", "rxjs": "^6.6.3", "tslib": "^2.0.1", + "vditor": "^3.5.4", "zone.js": "^0.11.1" }, "devDependencies": { diff --git a/src/app/view/write/write.component.html b/src/app/view/write/write.component.html index 26f8786..1c658c4 100644 --- a/src/app/view/write/write.component.html +++ b/src/app/view/write/write.component.html @@ -3,10 +3,11 @@ +
-
- -
+ + + { + // 判断是更新文章还是恢复文章 + this.articleId = this.activatedRoute.snapshot.queryParams.id; + if (this.articleId != null) { + this.isUpdate = true; + this.getArticle(); + } + if (!this.articleId && localStorage.getItem('tmpArticle')) { + this.article = JSON.parse(localStorage.getItem('tmpArticle')); + } + } + }); // 用户权限判断 this.userService.watchUserInfo({ complete: () => null, @@ -91,12 +97,6 @@ export class WriteComponent implements OnInit { }); } - /** - * 设置高度 - */ - setSuitableHeight() { - this.conf.height = (window.innerHeight - 120) + ''; - } // 提交按钮的事件 articleSubmit() { @@ -200,6 +200,7 @@ export class WriteComponent implements OnInit { url: this.article.url, id: this.article.id }; + this.vditor.setValue(this.article.mdContent) }, error: e => { if (e.code === 2010) { diff --git a/src/assets/editor/README.md b/src/assets/editor/README.md deleted file mode 100644 index 655d710..0000000 --- a/src/assets/editor/README.md +++ /dev/null @@ -1,268 +0,0 @@ -# Editor.md - -![](https://pandao.github.io/editor.md/images/logos/editormd-logo-180x180.png) - -![](https://img.shields.io/github/stars/pandao/editor.md.svg) -![](https://img.shields.io/github/forks/pandao/editor.md.svg) -![](https://img.shields.io/github/tag/pandao/editor.md.svg) -![](https://img.shields.io/github/release/pandao/editor.md.svg) -![](https://img.shields.io/github/issues/pandao/editor.md.svg) -![](https://img.shields.io/bower/v/editor.md.svg) - -**Editor.md** : The open source embeddable online markdown editor (component), based on CodeMirror & jQuery & Marked. - -### Features - -- Support Standard Markdown / CommonMark and GFM (GitHub Flavored Markdown); -- Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Code fold, Search replace, Read only, Themes, Multi-languages, L18n, HTML entities, Code syntax highlighting...; -- Markdown Extras : Support [ToC (Table of Contents)](https://pandao.github.io/editor.md/examples/toc.html), [Emoji](https://pandao.github.io/editor.md/examples/emoji.html), [Task lists](https://pandao.github.io/editor.md/examples/task-lists.html), [@Links](https://pandao.github.io/editor.md/examples/@links.html)...; -- Compatible with all major browsers (IE8+), compatible Zepto.js and iPad; -- Support [decode & fliter of the HTML tags & attributes](https://pandao.github.io/editor.md/examples/html-tags-decode.html); -- Support [TeX (LaTeX expressions, Based on KaTeX)](https://pandao.github.io/editor.md/examples/katex.html), [Flowchart](https://pandao.github.io/editor.md/examples/flowchart.html) and [Sequence Diagram](https://pandao.github.io/editor.md/examples/sequence-diagram.html) of Markdown extended syntax; -- Support AMD/CMD (Require.js & Sea.js) Module Loader, and Custom/define editor plugins; - -[README & Examples (English)](https://pandao.github.io/editor.md/en.html) - - --------- - -**Editor.md** 是一款开源的、可嵌入的 Markdown 在线编辑器(组件),基于 CodeMirror、jQuery 和 Marked 构建。 - -![editormd-screenshot](https://pandao.github.io/editor.md/examples/images/editormd-screenshot.png "editormd-screenshot") - -#### 主要特性 - -- 支持通用 Markdown / CommonMark 和 GFM (GitHub Flavored Markdown) 风格的语法,也可[变身为代码编辑器](https://pandao.github.io/editor.md/examples/change-mode.html); -- 支持实时预览、图片(跨域)上传、预格式文本/代码/表格插入、代码折叠、跳转到行、搜索替换、只读模式、自定义样式主题和多语言语法高亮等功能; -- 支持 [ToC(Table of Contents)](https://pandao.github.io/editor.md/examples/toc.html)、[Emoji表情](https://pandao.github.io/editor.md/examples/emoji.html)、[Task lists](https://pandao.github.io/editor.md/examples/task-lists.html)、[@链接](https://pandao.github.io/editor.md/examples/@links.html)等 Markdown 扩展语法; -- 支持 TeX 科学公式(基于 [KaTeX](https://pandao.github.io/editor.md/examples/katex.html))、流程图 [Flowchart](https://pandao.github.io/editor.md/examples/flowchart.html) 和 [时序图 Sequence Diagram](https://pandao.github.io/editor.md/examples/sequence-diagram.html); -- 支持[识别和解析 HTML 标签,并且支持自定义过滤标签及属性解析](https://pandao.github.io/editor.md/examples/html-tags-decode.html),具有可靠的安全性和几乎无限的扩展性; -- 支持 AMD / CMD 模块化加载(支持 [Require.js](https://pandao.github.io/editor.md/examples/use-requirejs.html) & [Sea.js](https://pandao.github.io/editor.md/examples/use-seajs.html)),并且支持[自定义扩展插件](https://pandao.github.io/editor.md/examples/define-plugin.html); -- 兼容主流的浏览器(IE8+)和 [Zepto.js](https://pandao.github.io/editor.md/examples/use-zepto.html),且支持 iPad 等平板设备; - -#### Download & install - -Download: - -[Github download](https://github.com/pandao/editor.md/archive/master.zip) - -NPM install : - -```bash -npm install editor.md -``` - -Bower install : - -```bash -bower install editor.md -``` - -#### Usages - -##### Create a Markdown editor - -```html - -
- - -
- - - -``` - -If you using modular script loader: - -- [Using Require.js](https://github.com/pandao/editor.md/tree/master/examples/use-requirejs.html) -- [Using Sea.js](https://github.com/pandao/editor.md/tree/master/examples/use-seajs.html) - -##### Markdown to HTML - -```html - -
- - -
- - - - - -``` - -> See the full example: [http://editor.md.ipandao.com/examples/html-preview-markdown-to-html.html](http://editor.md.ipandao.com/examples/html-preview-markdown-to-html.html) - -##### HTML to Markdown? - -Sorry, Editor.md not support HTML to Markdown parsing, Maybe In the future. - -#### Examples - -[https://pandao.github.io/editor.md/examples/index.html](https://pandao.github.io/editor.md/examples/index.html) - -#### Options - -Editor.md options and default values: - -```javascript -{ - mode : "gfm", // gfm or markdown - name : "", // Form element name for post - value : "", // value for CodeMirror, if mode not gfm/markdown - theme : "", // Editor.md self themes, before v1.5.0 is CodeMirror theme, default empty - editorTheme : "default", // Editor area, this is CodeMirror theme at v1.5.0 - previewTheme : "", // Preview area theme, default empty - markdown : "", // Markdown source code - appendMarkdown : "", // if in init textarea value not empty, append markdown to textarea - width : "100%", - height : "100%", - path : "./lib/", // Dependents module file directory - pluginPath : "", // If this empty, default use settings.path + "../plugins/" - delay : 300, // Delay parse markdown to html, Uint : ms - autoLoadModules : true, // Automatic load dependent module files - watch : true, - placeholder : "Enjoy Markdown! coding now...", - gotoLine : true, // Enable / disable goto a line - codeFold : false, - autoHeight : false, - autoFocus : true, // Enable / disable auto focus editor left input area - autoCloseTags : true, - searchReplace : true, // Enable / disable (CodeMirror) search and replace function - syncScrolling : true, // options: true | false | "single", default true - readOnly : false, // Enable / disable readonly mode - tabSize : 4, - indentUnit : 4, - lineNumbers : true, // Display editor line numbers - lineWrapping : true, - autoCloseBrackets : true, - showTrailingSpace : true, - matchBrackets : true, - indentWithTabs : true, - styleSelectedText : true, - matchWordHighlight : true, // options: true, false, "onselected" - styleActiveLine : true, // Highlight the current line - dialogLockScreen : true, - dialogShowMask : true, - dialogDraggable : true, - dialogMaskBgColor : "#fff", - dialogMaskOpacity : 0.1, - fontSize : "13px", - saveHTMLToTextarea : false, // If enable, Editor will create a "); - markdownTextarea = this.markdownTextarea = editor.children("textarea"); - } - - markdownTextarea.addClass(classNames.textarea.markdown).attr("placeholder", settings.placeholder); - - if (typeof markdownTextarea.attr("name") === "undefined" || markdownTextarea.attr("name") === "") - { - markdownTextarea.attr("name", (settings.name !== "") ? settings.name : id + "-markdown-doc"); - } - - var appendElements = [ - (!settings.readOnly) ? "" : "", - ( (settings.saveHTMLToTextarea) ? "" : "" ), - "
", - "
", - "
" - ].join("\n"); - - editor.append(appendElements).addClass(classPrefix + "vertical"); - - if (settings.theme !== "") - { - editor.addClass(classPrefix + "theme-" + settings.theme); - } - - this.mask = editor.children("." + classPrefix + "mask"); - this.containerMask = editor.children("." + classPrefix + "container-mask"); - - if (settings.markdown !== "") - { - markdownTextarea.val(settings.markdown); - } - - if (settings.appendMarkdown !== "") - { - markdownTextarea.val(markdownTextarea.val() + settings.appendMarkdown); - } - - this.htmlTextarea = editor.children("." + classNames.textarea.html); - this.preview = editor.children("." + classPrefix + "preview"); - this.previewContainer = this.preview.children("." + classPrefix + "preview-container"); - - if (settings.previewTheme !== "") - { - this.preview.addClass(classPrefix + "preview-theme-" + settings.previewTheme); - } - - if (typeof define === "function" && define.amd) - { - if (typeof katex !== "undefined") - { - editormd.$katex = katex; - } - - if (settings.searchReplace && !settings.readOnly) - { - editormd.loadCSS(settings.path + "codemirror/addon/dialog/dialog"); - editormd.loadCSS(settings.path + "codemirror/addon/search/matchesonscrollbar"); - } - } - - if ((typeof define === "function" && define.amd) || !settings.autoLoadModules) - { - if (typeof CodeMirror !== "undefined") { - editormd.$CodeMirror = CodeMirror; - } - - if (typeof marked !== "undefined") { - editormd.$marked = marked; - } - - this.setCodeMirror().setToolbar().loadedDisplay(); - } - else - { - this.loadQueues(); - } - - return this; - }, - - /** - * 所需组件加载队列 - * Required components loading queue - * - * @returns {editormd} 返回editormd的实例对象 - */ - - loadQueues : function() { - var _this = this; - var settings = this.settings; - var loadPath = settings.path; - - var loadFlowChartOrSequenceDiagram = function() { - - if (editormd.isIE8) - { - _this.loadedDisplay(); - - return ; - } - - if (settings.flowChart || settings.sequenceDiagram) - { - editormd.loadScript(loadPath + "raphael.min", function() { - - editormd.loadScript(loadPath + "underscore.min", function() { - - if (!settings.flowChart && settings.sequenceDiagram) - { - editormd.loadScript(loadPath + "sequence-diagram.min", function() { - _this.loadedDisplay(); - }); - } - else if (settings.flowChart && !settings.sequenceDiagram) - { - editormd.loadScript(loadPath + "flowchart.min", function() { - editormd.loadScript(loadPath + "jquery.flowchart.min", function() { - _this.loadedDisplay(); - }); - }); - } - else if (settings.flowChart && settings.sequenceDiagram) - { - editormd.loadScript(loadPath + "flowchart.min", function() { - editormd.loadScript(loadPath + "jquery.flowchart.min", function() { - editormd.loadScript(loadPath + "sequence-diagram.min", function() { - _this.loadedDisplay(); - }); - }); - }); - } - }); - - }); - } - else - { - _this.loadedDisplay(); - } - }; - - editormd.loadCSS(loadPath + "codemirror/codemirror.min"); - - if (settings.searchReplace && !settings.readOnly) - { - editormd.loadCSS(loadPath + "codemirror/addon/dialog/dialog"); - editormd.loadCSS(loadPath + "codemirror/addon/search/matchesonscrollbar"); - } - - if (settings.codeFold) - { - editormd.loadCSS(loadPath + "codemirror/addon/fold/foldgutter"); - } - - editormd.loadScript(loadPath + "codemirror/codemirror.min", function() { - editormd.$CodeMirror = CodeMirror; - - editormd.loadScript(loadPath + "codemirror/modes.min", function() { - - editormd.loadScript(loadPath + "codemirror/addons.min", function() { - - _this.setCodeMirror(); - - if (settings.mode !== "gfm" && settings.mode !== "markdown") - { - _this.loadedDisplay(); - - return false; - } - - _this.setToolbar(); - - editormd.loadScript(loadPath + "marked.min", function() { - - editormd.$marked = marked; - - if (settings.previewCodeHighlight) - { - editormd.loadScript(loadPath + "prettify.min", function() { - loadFlowChartOrSequenceDiagram(); - }); - } - else - { - loadFlowChartOrSequenceDiagram(); - } - }); - - }); - - }); - - }); - - return this; - }, - - /** - * 设置 Editor.md 的整体主题,主要是工具栏 - * Setting Editor.md theme - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setTheme : function(theme) { - var editor = this.editor; - var oldTheme = this.settings.theme; - var themePrefix = this.classPrefix + "theme-"; - - editor.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); - - this.settings.theme = theme; - - return this; - }, - - /** - * 设置 CodeMirror(编辑区)的主题 - * Setting CodeMirror (Editor area) theme - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setEditorTheme : function(theme) { - var settings = this.settings; - settings.editorTheme = theme; - - if (theme !== "default") - { - editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); - } - - this.cm.setOption("theme", theme); - - return this; - }, - - /** - * setEditorTheme() 的别名 - * setEditorTheme() alias - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setCodeMirrorTheme : function (theme) { - this.setEditorTheme(theme); - - return this; - }, - - /** - * 设置 Editor.md 的主题 - * Setting Editor.md theme - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setPreviewTheme : function(theme) { - var preview = this.preview; - var oldTheme = this.settings.previewTheme; - var themePrefix = this.classPrefix + "preview-theme-"; - - preview.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); - - this.settings.previewTheme = theme; - - return this; - }, - - /** - * 配置和初始化CodeMirror组件 - * CodeMirror initialization - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setCodeMirror : function() { - var settings = this.settings; - var editor = this.editor; - - if (settings.editorTheme !== "default") - { - editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); - } - - var codeMirrorConfig = { - mode : settings.mode, - theme : settings.editorTheme, - tabSize : settings.tabSize, - dragDrop : false, - autofocus : settings.autoFocus, - autoCloseTags : settings.autoCloseTags, - readOnly : (settings.readOnly) ? "nocursor" : false, - indentUnit : settings.indentUnit, - lineNumbers : settings.lineNumbers, - lineWrapping : settings.lineWrapping, - extraKeys : { - "Ctrl-Q": function(cm) { - cm.foldCode(cm.getCursor()); - } - }, - foldGutter : settings.codeFold, - gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], - matchBrackets : settings.matchBrackets, - indentWithTabs : settings.indentWithTabs, - styleActiveLine : settings.styleActiveLine, - styleSelectedText : settings.styleSelectedText, - autoCloseBrackets : settings.autoCloseBrackets, - showTrailingSpace : settings.showTrailingSpace, - highlightSelectionMatches : ( (!settings.matchWordHighlight) ? false : { showToken: (settings.matchWordHighlight === "onselected") ? false : /\w/ } ) - }; - - this.codeEditor = this.cm = editormd.$CodeMirror.fromTextArea(this.markdownTextarea[0], codeMirrorConfig); - this.codeMirror = this.cmElement = editor.children(".CodeMirror"); - - if (settings.value !== "") - { - this.cm.setValue(settings.value); - } - - this.codeMirror.css({ - fontSize : settings.fontSize, - width : (!settings.watch) ? "100%" : "50%" - }); - - if (settings.autoHeight) - { - this.codeMirror.css("height", "auto"); - this.cm.setOption("viewportMargin", Infinity); - } - - if (!settings.lineNumbers) - { - this.codeMirror.find(".CodeMirror-gutters").css("border-right", "none"); - } - - return this; - }, - - /** - * 获取CodeMirror的配置选项 - * Get CodeMirror setting options - * - * @returns {Mixed} return CodeMirror setting option value - */ - - getCodeMirrorOption : function(key) { - return this.cm.getOption(key); - }, - - /** - * 配置和重配置CodeMirror的选项 - * CodeMirror setting options / resettings - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setCodeMirrorOption : function(key, value) { - - this.cm.setOption(key, value); - - return this; - }, - - /** - * 添加 CodeMirror 键盘快捷键 - * Add CodeMirror keyboard shortcuts key map - * - * @returns {editormd} 返回editormd的实例对象 - */ - - addKeyMap : function(map, bottom) { - this.cm.addKeyMap(map, bottom); - - return this; - }, - - /** - * 移除 CodeMirror 键盘快捷键 - * Remove CodeMirror keyboard shortcuts key map - * - * @returns {editormd} 返回editormd的实例对象 - */ - - removeKeyMap : function(map) { - this.cm.removeKeyMap(map); - - return this; - }, - - /** - * 跳转到指定的行 - * Goto CodeMirror line - * - * @param {String|Intiger} line line number or "first"|"last" - * @returns {editormd} 返回editormd的实例对象 - */ - - gotoLine : function (line) { - - var settings = this.settings; - - if (!settings.gotoLine) - { - return this; - } - - var cm = this.cm; - var editor = this.editor; - var count = cm.lineCount(); - var preview = this.preview; - - if (typeof line === "string") - { - if(line === "last") - { - line = count; - } - - if (line === "first") - { - line = 1; - } - } - - if (typeof line !== "number") - { - alert("Error: The line number must be an integer."); - return this; - } - - line = parseInt(line) - 1; - - if (line > count) - { - alert("Error: The line number range 1-" + count); - - return this; - } - - cm.setCursor( {line : line, ch : 0} ); - - var scrollInfo = cm.getScrollInfo(); - var clientHeight = scrollInfo.clientHeight; - var coords = cm.charCoords({line : line, ch : 0}, "local"); - - cm.scrollTo(null, (coords.top + coords.bottom - clientHeight) / 2); - - if (settings.watch) - { - var cmScroll = this.codeMirror.find(".CodeMirror-scroll")[0]; - var height = $(cmScroll).height(); - var scrollTop = cmScroll.scrollTop; - var percent = (scrollTop / cmScroll.scrollHeight); - - if (scrollTop === 0) - { - preview.scrollTop(0); - } - else if (scrollTop + height >= cmScroll.scrollHeight - 16) - { - preview.scrollTop(preview[0].scrollHeight); - } - else - { - preview.scrollTop(preview[0].scrollHeight * percent); - } - } - - cm.focus(); - - return this; - }, - - /** - * 扩展当前实例对象,可同时设置多个或者只设置一个 - * Extend editormd instance object, can mutil setting. - * - * @returns {editormd} this(editormd instance object.) - */ - - extend : function() { - if (typeof arguments[1] !== "undefined") - { - if (typeof arguments[1] === "function") - { - arguments[1] = $.proxy(arguments[1], this); - } - - this[arguments[0]] = arguments[1]; - } - - if (typeof arguments[0] === "object" && typeof arguments[0].length === "undefined") - { - $.extend(true, this, arguments[0]); - } - - return this; - }, - - /** - * 设置或扩展当前实例对象,单个设置 - * Extend editormd instance object, one by one - * - * @param {String|Object} key option key - * @param {String|Object} value option value - * @returns {editormd} this(editormd instance object.) - */ - - set : function (key, value) { - - if (typeof value !== "undefined" && typeof value === "function") - { - value = $.proxy(value, this); - } - - this[key] = value; - - return this; - }, - - /** - * 重新配置 - * Resetting editor options - * - * @param {String|Object} key option key - * @param {String|Object} value option value - * @returns {editormd} this(editormd instance object.) - */ - - config : function(key, value) { - var settings = this.settings; - - if (typeof key === "object") - { - settings = $.extend(true, settings, key); - } - - if (typeof key === "string") - { - settings[key] = value; - } - - this.settings = settings; - this.recreate(); - - return this; - }, - - /** - * 注册事件处理方法 - * Bind editor event handle - * - * @param {String} eventType event type - * @param {Function} callback 回调函数 - * @returns {editormd} this(editormd instance object.) - */ - - on : function(eventType, callback) { - var settings = this.settings; - - if (typeof settings["on" + eventType] !== "undefined") - { - settings["on" + eventType] = $.proxy(callback, this); - } - - return this; - }, - - /** - * 解除事件处理方法 - * Unbind editor event handle - * - * @param {String} eventType event type - * @returns {editormd} this(editormd instance object.) - */ - - off : function(eventType) { - var settings = this.settings; - - if (typeof settings["on" + eventType] !== "undefined") - { - settings["on" + eventType] = function(){}; - } - - return this; - }, - - /** - * 显示工具栏 - * Display toolbar - * - * @param {Function} [callback=function(){}] 回调函数 - * @returns {editormd} 返回editormd的实例对象 - */ - - showToolbar : function(callback) { - var settings = this.settings; - - if(settings.readOnly) { - return this; - } - - if (settings.toolbar && (this.toolbar.length < 1 || this.toolbar.find("." + this.classPrefix + "menu").html() === "") ) - { - this.setToolbar(); - } - - settings.toolbar = true; - - this.toolbar.show(); - this.resize(); - - $.proxy(callback || function(){}, this)(); - - return this; - }, - - /** - * 隐藏工具栏 - * Hide toolbar - * - * @param {Function} [callback=function(){}] 回调函数 - * @returns {editormd} this(editormd instance object.) - */ - - hideToolbar : function(callback) { - var settings = this.settings; - - settings.toolbar = false; - this.toolbar.hide(); - this.resize(); - - $.proxy(callback || function(){}, this)(); - - return this; - }, - - /** - * 页面滚动时工具栏的固定定位 - * Set toolbar in window scroll auto fixed position - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setToolbarAutoFixed : function(fixed) { - - var state = this.state; - var editor = this.editor; - var toolbar = this.toolbar; - var settings = this.settings; - - if (typeof fixed !== "undefined") - { - settings.toolbarAutoFixed = fixed; - } - - var autoFixedHandle = function(){ - var $window = $(window); - var top = $window.scrollTop(); - - if (!settings.toolbarAutoFixed) - { - return false; - } - - if (top - editor.offset().top > 10 && top < editor.height()) - { - toolbar.css({ - position : "fixed", - width : editor.width() + "px", - left : ($window.width() - editor.width()) / 2 + "px" - }); - } - else - { - toolbar.css({ - position : "absolute", - width : "100%", - left : 0 - }); - } - }; - - if (!state.fullscreen && !state.preview && settings.toolbar && settings.toolbarAutoFixed) - { - $(window).bind("scroll", autoFixedHandle); - } - - return this; - }, - - /** - * 配置和初始化工具栏 - * Set toolbar and Initialization - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setToolbar : function() { - var settings = this.settings; - - if(settings.readOnly) { - return this; - } - - var editor = this.editor; - var preview = this.preview; - var classPrefix = this.classPrefix; - - var toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); - - if (settings.toolbar && toolbar.length < 1) - { - var toolbarHTML = "
    "; - - editor.append(toolbarHTML); - toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); - } - - if (!settings.toolbar) - { - toolbar.hide(); - - return this; - } - - toolbar.show(); - - var icons = (typeof settings.toolbarIcons === "function") ? settings.toolbarIcons() - : ((typeof settings.toolbarIcons === "string") ? editormd.toolbarModes[settings.toolbarIcons] : settings.toolbarIcons); - - var toolbarMenu = toolbar.find("." + this.classPrefix + "menu"), menu = ""; - var pullRight = false; - - for (var i = 0, len = icons.length; i < len; i++) - { - var name = icons[i]; - - if (name === "||") - { - pullRight = true; - } - else if (name === "|") - { - menu += "
  • |
  • "; - } - else - { - var isHeader = (/h(\d)/.test(name)); - var index = name; - - if (name === "watch" && !settings.watch) { - index = "unwatch"; - } - - var title = settings.lang.toolbar[index]; - var iconTexts = settings.toolbarIconTexts[index]; - var iconClass = settings.toolbarIconsClass[index]; - - title = (typeof title === "undefined") ? "" : title; - iconTexts = (typeof iconTexts === "undefined") ? "" : iconTexts; - iconClass = (typeof iconClass === "undefined") ? "" : iconClass; - - var menuItem = pullRight ? "
  • " : "
  • "; - - if (typeof settings.toolbarCustomIcons[name] !== "undefined" && typeof settings.toolbarCustomIcons[name] !== "function") - { - menuItem += settings.toolbarCustomIcons[name]; - } - else - { - menuItem += ""; - menuItem += ""+((isHeader) ? name.toUpperCase() : ( (iconClass === "") ? iconTexts : "") ) + ""; - menuItem += ""; - } - - menuItem += "
  • "; - - menu = pullRight ? menuItem + menu : menu + menuItem; - } - } - - toolbarMenu.html(menu); - - toolbarMenu.find("[title=\"Lowercase\"]").attr("title", settings.lang.toolbar.lowercase); - toolbarMenu.find("[title=\"ucwords\"]").attr("title", settings.lang.toolbar.ucwords); - - this.setToolbarHandler(); - this.setToolbarAutoFixed(); - - return this; - }, - - /** - * 工具栏图标事件处理对象序列 - * Get toolbar icons event handlers - * - * @param {Object} cm CodeMirror的实例对象 - * @param {String} name 要获取的事件处理器名称 - * @returns {Object} 返回处理对象序列 - */ - - dialogLockScreen : function() { - $.proxy(editormd.dialogLockScreen, this)(); - - return this; - }, - - dialogShowMask : function(dialog) { - $.proxy(editormd.dialogShowMask, this)(dialog); - - return this; - }, - - getToolbarHandles : function(name) { - var toolbarHandlers = this.toolbarHandlers = editormd.toolbarHandlers; - - return (name && typeof toolbarIconHandlers[name] !== "undefined") ? toolbarHandlers[name] : toolbarHandlers; - }, - - /** - * 工具栏图标事件处理器 - * Bind toolbar icons event handle - * - * @returns {editormd} 返回editormd的实例对象 - */ - - setToolbarHandler : function() { - var _this = this; - var settings = this.settings; - - if (!settings.toolbar || settings.readOnly) { - return this; - } - - var toolbar = this.toolbar; - var cm = this.cm; - var classPrefix = this.classPrefix; - var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu > li > a"); - var toolbarIconHandlers = this.getToolbarHandles(); - - toolbarIcons.bind(editormd.mouseOrTouch("click", "touchend"), function(event) { - - var icon = $(this).children(".fa"); - var name = icon.attr("name"); - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (name === "") { - return ; - } - - _this.activeIcon = icon; - - if (typeof toolbarIconHandlers[name] !== "undefined") - { - $.proxy(toolbarIconHandlers[name], _this)(cm); - } - else - { - if (typeof settings.toolbarHandlers[name] !== "undefined") - { - $.proxy(settings.toolbarHandlers[name], _this)(cm, icon, cursor, selection); - } - } - - if (name !== "link" && name !== "reference-link" && name !== "image" && name !== "code-block" && - name !== "preformatted-text" && name !== "watch" && name !== "preview" && name !== "search" && name !== "fullscreen" && name !== "info") - { - cm.focus(); - } - - return false; - - }); - - return this; - }, - - /** - * 动态创建对话框 - * Creating custom dialogs - * - * @param {Object} options 配置项键值对 Key/Value - * @returns {dialog} 返回创建的dialog的jQuery实例对象 - */ - - createDialog : function(options) { - return $.proxy(editormd.createDialog, this)(options); - }, - - /** - * 创建关于Editor.md的对话框 - * Create about Editor.md dialog - * - * @returns {editormd} 返回editormd的实例对象 - */ - - createInfoDialog : function() { - var _this = this; - var editor = this.editor; - var classPrefix = this.classPrefix; - - var infoDialogHTML = [ - "
    ", - "
    ", - "

    " + editormd.title + "v" + editormd.version + "

    ", - "

    " + this.lang.description + "

    ", - "

    " + editormd.homePage + "

    ", - "

    Copyright © 2015 Pandao, The MIT License.

    ", - "
    ", - "", - "
    " - ].join("\n"); - - editor.append(infoDialogHTML); - - var infoDialog = this.infoDialog = editor.children("." + classPrefix + "dialog-info"); - - infoDialog.find("." + classPrefix + "dialog-close").bind(editormd.mouseOrTouch("click", "touchend"), function() { - _this.hideInfoDialog(); - }); - - infoDialog.css("border", (editormd.isIE8) ? "1px solid #ddd" : "").css("z-index", editormd.dialogZindex).show(); - - this.infoDialogPosition(); - - return this; - }, - - /** - * 关于Editor.md对话居中定位 - * Editor.md dialog position handle - * - * @returns {editormd} 返回editormd的实例对象 - */ - - infoDialogPosition : function() { - var infoDialog = this.infoDialog; - - var _infoDialogPosition = function() { - infoDialog.css({ - top : ($(window).height() - infoDialog.height()) / 2 + "px", - left : ($(window).width() - infoDialog.width()) / 2 + "px" - }); - }; - - _infoDialogPosition(); - - $(window).resize(_infoDialogPosition); - - return this; - }, - - /** - * 显示关于Editor.md - * Display about Editor.md dialog - * - * @returns {editormd} 返回editormd的实例对象 - */ - - showInfoDialog : function() { - - $("html,body").css("overflow-x", "hidden"); - - var _this = this; - var editor = this.editor; - var settings = this.settings; - var infoDialog = this.infoDialog = editor.children("." + this.classPrefix + "dialog-info"); - - if (infoDialog.length < 1) - { - this.createInfoDialog(); - } - - this.lockScreen(true); - - this.mask.css({ - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }).show(); - - infoDialog.css("z-index", editormd.dialogZindex).show(); - - this.infoDialogPosition(); - - return this; - }, - - /** - * 隐藏关于Editor.md - * Hide about Editor.md dialog - * - * @returns {editormd} 返回editormd的实例对象 - */ - - hideInfoDialog : function() { - $("html,body").css("overflow-x", ""); - this.infoDialog.hide(); - this.mask.hide(); - this.lockScreen(false); - - return this; - }, - - /** - * 锁屏 - * lock screen - * - * @param {Boolean} lock Boolean 布尔值,是否锁屏 - * @returns {editormd} 返回editormd的实例对象 - */ - - lockScreen : function(lock) { - editormd.lockScreen(lock); - this.resize(); - - return this; - }, - - /** - * 编辑器界面重建,用于动态语言包或模块加载等 - * Recreate editor - * - * @returns {editormd} 返回editormd的实例对象 - */ - - recreate : function() { - var _this = this; - var editor = this.editor; - var settings = this.settings; - - this.codeMirror.remove(); - - this.setCodeMirror(); - - if (!settings.readOnly) - { - if (editor.find(".editormd-dialog").length > 0) { - editor.find(".editormd-dialog").remove(); - } - - if (settings.toolbar) - { - this.getToolbarHandles(); - this.setToolbar(); - } - } - - this.loadedDisplay(true); - - return this; - }, - - /** - * 高亮预览HTML的pre代码部分 - * highlight of preview codes - * - * @returns {editormd} 返回editormd的实例对象 - */ - - previewCodeHighlight : function() { - var settings = this.settings; - var previewContainer = this.previewContainer; - - if (settings.previewCodeHighlight) - { - previewContainer.find("pre").addClass("prettyprint linenums"); - - if (typeof prettyPrint !== "undefined") - { - prettyPrint(); - } - } - - return this; - }, - - /** - * 解析TeX(KaTeX)科学公式 - * TeX(KaTeX) Renderer - * - * @returns {editormd} 返回editormd的实例对象 - */ - - katexRender : function() { - - if (timer === null) - { - return this; - } - - this.previewContainer.find("." + editormd.classNames.tex).each(function(){ - var tex = $(this); - editormd.$katex.render(tex.text(), tex[0]); - - tex.find(".katex").css("font-size", "1.6em"); - }); - - return this; - }, - - /** - * 解析和渲染流程图及时序图 - * FlowChart and SequenceDiagram Renderer - * - * @returns {editormd} 返回editormd的实例对象 - */ - - flowChartAndSequenceDiagramRender : function() { - var $this = this; - var settings = this.settings; - var previewContainer = this.previewContainer; - - if (editormd.isIE8) { - return this; - } - - if (settings.flowChart) { - if (flowchartTimer === null) { - return this; - } - - previewContainer.find(".flowchart").flowChart(); - } - - if (settings.sequenceDiagram) { - previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"}); - } - - var preview = $this.preview; - var codeMirror = $this.codeMirror; - var codeView = codeMirror.find(".CodeMirror-scroll"); - - var height = codeView.height(); - var scrollTop = codeView.scrollTop(); - var percent = (scrollTop / codeView[0].scrollHeight); - var tocHeight = 0; - - preview.find(".markdown-toc-list").each(function(){ - tocHeight += $(this).height(); - }); - - var tocMenuHeight = preview.find(".editormd-toc-menu").height(); - tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; - - if (scrollTop === 0) - { - preview.scrollTop(0); - } - else if (scrollTop + height >= codeView[0].scrollHeight - 16) - { - preview.scrollTop(preview[0].scrollHeight); - } - else - { - preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); - } - - return this; - }, - - /** - * 注册键盘快捷键处理 - * Register CodeMirror keyMaps (keyboard shortcuts). - * - * @param {Object} keyMap KeyMap key/value {"(Ctrl/Shift/Alt)-Key" : function(){}} - * @returns {editormd} return this - */ - - registerKeyMaps : function(keyMap) { - - var _this = this; - var cm = this.cm; - var settings = this.settings; - var toolbarHandlers = editormd.toolbarHandlers; - var disabledKeyMaps = settings.disabledKeyMaps; - - keyMap = keyMap || null; - - if (keyMap) - { - for (var i in keyMap) - { - if ($.inArray(i, disabledKeyMaps) < 0) - { - var map = {}; - map[i] = keyMap[i]; - - cm.addKeyMap(keyMap); - } - } - } - else - { - for (var k in editormd.keyMaps) - { - var _keyMap = editormd.keyMaps[k]; - var handle = (typeof _keyMap === "string") ? $.proxy(toolbarHandlers[_keyMap], _this) : $.proxy(_keyMap, _this); - - if ($.inArray(k, ["F9", "F10", "F11"]) < 0 && $.inArray(k, disabledKeyMaps) < 0) - { - var _map = {}; - _map[k] = handle; - - cm.addKeyMap(_map); - } - } - - $(window).keydown(function(event) { - - var keymaps = { - "120" : "F9", - "121" : "F10", - "122" : "F11" - }; - - if ( $.inArray(keymaps[event.keyCode], disabledKeyMaps) < 0 ) - { - switch (event.keyCode) - { - case 120: - $.proxy(toolbarHandlers["watch"], _this)(); - return false; - break; - - case 121: - $.proxy(toolbarHandlers["preview"], _this)(); - return false; - break; - - case 122: - $.proxy(toolbarHandlers["fullscreen"], _this)(); - return false; - break; - - default: - break; - } - } - }); - } - - return this; - }, - - /** - * 绑定同步滚动 - * - * @returns {editormd} return this - */ - - bindScrollEvent : function() { - - var _this = this; - var preview = this.preview; - var settings = this.settings; - var codeMirror = this.codeMirror; - var mouseOrTouch = editormd.mouseOrTouch; - - if (!settings.syncScrolling) { - return this; - } - - var cmBindScroll = function() { - codeMirror.find(".CodeMirror-scroll").bind(mouseOrTouch("scroll", "touchmove"), function(event) { - var height = $(this).height(); - var scrollTop = $(this).scrollTop(); - var percent = (scrollTop / $(this)[0].scrollHeight); - - var tocHeight = 0; - - preview.find(".markdown-toc-list").each(function(){ - tocHeight += $(this).height(); - }); - - var tocMenuHeight = preview.find(".editormd-toc-menu").height(); - tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; - - if (scrollTop === 0) - { - preview.scrollTop(0); - } - else if (scrollTop + height >= $(this)[0].scrollHeight - 16) - { - preview.scrollTop(preview[0].scrollHeight); - } - else - { - preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); - } - - $.proxy(settings.onscroll, _this)(event); - }); - }; - - var cmUnbindScroll = function() { - codeMirror.find(".CodeMirror-scroll").unbind(mouseOrTouch("scroll", "touchmove")); - }; - - var previewBindScroll = function() { - - preview.bind(mouseOrTouch("scroll", "touchmove"), function(event) { - var height = $(this).height(); - var scrollTop = $(this).scrollTop(); - var percent = (scrollTop / $(this)[0].scrollHeight); - var codeView = codeMirror.find(".CodeMirror-scroll"); - - if(scrollTop === 0) - { - codeView.scrollTop(0); - } - else if (scrollTop + height >= $(this)[0].scrollHeight) - { - codeView.scrollTop(codeView[0].scrollHeight); - } - else - { - codeView.scrollTop(codeView[0].scrollHeight * percent); - } - - $.proxy(settings.onpreviewscroll, _this)(event); - }); - - }; - - var previewUnbindScroll = function() { - preview.unbind(mouseOrTouch("scroll", "touchmove")); - }; - - codeMirror.bind({ - mouseover : cmBindScroll, - mouseout : cmUnbindScroll, - touchstart : cmBindScroll, - touchend : cmUnbindScroll - }); - - if (settings.syncScrolling === "single") { - return this; - } - - preview.bind({ - mouseover : previewBindScroll, - mouseout : previewUnbindScroll, - touchstart : previewBindScroll, - touchend : previewUnbindScroll - }); - - return this; - }, - - bindChangeEvent : function() { - - var _this = this; - var cm = this.cm; - var settings = this.settings; - - if (!settings.syncScrolling) { - return this; - } - - cm.on("change", function(_cm, changeObj) { - - if (settings.watch) - { - _this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); - } - - timer = setTimeout(function() { - clearTimeout(timer); - _this.save(); - timer = null; - }, settings.delay); - }); - - return this; - }, - - /** - * 加载队列完成之后的显示处理 - * Display handle of the module queues loaded after. - * - * @param {Boolean} recreate 是否为重建编辑器 - * @returns {editormd} 返回editormd的实例对象 - */ - - loadedDisplay : function(recreate) { - - recreate = recreate || false; - - var _this = this; - var editor = this.editor; - var preview = this.preview; - var settings = this.settings; - - this.containerMask.hide(); - - this.save(); - - if (settings.watch) { - preview.show(); - } - - editor.data("oldWidth", editor.width()).data("oldHeight", editor.height()); // 为了兼容Zepto - - this.resize(); - this.registerKeyMaps(); - - $(window).resize(function(){ - _this.resize(); - }); - - this.bindScrollEvent().bindChangeEvent(); - - if (!recreate) - { - $.proxy(settings.onload, this)(); - } - - this.state.loaded = true; - - return this; - }, - - /** - * 设置编辑器的宽度 - * Set editor width - * - * @param {Number|String} width 编辑器宽度值 - * @returns {editormd} 返回editormd的实例对象 - */ - - width : function(width) { - - this.editor.css("width", (typeof width === "number") ? width + "px" : width); - this.resize(); - - return this; - }, - - /** - * 设置编辑器的高度 - * Set editor height - * - * @param {Number|String} height 编辑器高度值 - * @returns {editormd} 返回editormd的实例对象 - */ - - height : function(height) { - - this.editor.css("height", (typeof height === "number") ? height + "px" : height); - this.resize(); - - return this; - }, - - /** - * 调整编辑器的尺寸和布局 - * Resize editor layout - * - * @param {Number|String} [width=null] 编辑器宽度值 - * @param {Number|String} [height=null] 编辑器高度值 - * @returns {editormd} 返回editormd的实例对象 - */ - - resize : function(width, height) { - - width = width || null; - height = height || null; - - var state = this.state; - var editor = this.editor; - var preview = this.preview; - var toolbar = this.toolbar; - var settings = this.settings; - var codeMirror = this.codeMirror; - - if (width) - { - editor.css("width", (typeof width === "number") ? width + "px" : width); - } - - if (settings.autoHeight && !state.fullscreen && !state.preview) - { - editor.css("height", "auto"); - codeMirror.css("height", "auto"); - } - else - { - if (height) - { - editor.css("height", (typeof height === "number") ? height + "px" : height); - } - - if (state.fullscreen) - { - editor.height($(window).height()); - } - - if (settings.toolbar && !settings.readOnly) - { - codeMirror.css("margin-top", toolbar.height() + 1).height(editor.height() - toolbar.height()); - } - else - { - codeMirror.css("margin-top", 0).height(editor.height()); - } - } - - if(settings.watch) - { - codeMirror.width(editor.width() / 2); - preview.width((!state.preview) ? editor.width() / 2 : editor.width()); - - this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); - - if (settings.toolbar && !settings.readOnly) - { - preview.css("top", toolbar.height() + 1); - } - else - { - preview.css("top", 0); - } - - if (settings.autoHeight && !state.fullscreen && !state.preview) - { - preview.height(""); - } - else - { - var previewHeight = (settings.toolbar && !settings.readOnly) ? editor.height() - toolbar.height() : editor.height(); - - preview.height(previewHeight); - } - } - else - { - codeMirror.width(editor.width()); - preview.hide(); - } - - if (state.loaded) - { - $.proxy(settings.onresize, this)(); - } - - return this; - }, - - /** - * 解析和保存Markdown代码 - * Parse & Saving Markdown source code - * - * @returns {editormd} 返回editormd的实例对象 - */ - - save : function() { - - var _this = this; - var state = this.state; - var settings = this.settings; - - if (timer === null && !(!settings.watch && state.preview)) - { - return this; - } - - var cm = this.cm; - var cmValue = cm.getValue(); - var previewContainer = this.previewContainer; - - if (settings.mode !== "gfm" && settings.mode !== "markdown") - { - this.markdownTextarea.val(cmValue); - - return this; - } - - var marked = editormd.$marked; - var markdownToC = this.markdownToC = []; - var rendererOptions = this.markedRendererOptions = { - toc : settings.toc, - tocm : settings.tocm, - tocStartLevel : settings.tocStartLevel, - pageBreak : settings.pageBreak, - taskList : settings.taskList, - emoji : settings.emoji, - tex : settings.tex, - atLink : settings.atLink, // for @link - emailLink : settings.emailLink, // for mail address auto link - flowChart : settings.flowChart, - sequenceDiagram : settings.sequenceDiagram, - previewCodeHighlight : settings.previewCodeHighlight, - }; - - var markedOptions = this.markedOptions = { - renderer : editormd.markedRenderer(markdownToC, rendererOptions), - gfm : true, - tables : true, - breaks : true, - pedantic : false, - sanitize : (settings.htmlDecode) ? false : true, // 关闭忽略HTML标签,即开启识别HTML标签,默认为false - smartLists : true, - smartypants : true - }; - - marked.setOptions(markedOptions); - - var newMarkdownDoc = editormd.$marked(cmValue, markedOptions); - - //console.info("cmValue", cmValue, newMarkdownDoc); - - newMarkdownDoc = editormd.filterHTMLTags(newMarkdownDoc, settings.htmlDecode); - - //console.error("cmValue", cmValue, newMarkdownDoc); - - this.markdownTextarea.text(cmValue); - - cm.save(); - - if (settings.saveHTMLToTextarea) - { - this.htmlTextarea.text(newMarkdownDoc); - } - - if(settings.watch || (!settings.watch && state.preview)) - { - previewContainer.html(newMarkdownDoc); - - this.previewCodeHighlight(); - - if (settings.toc) - { - var tocContainer = (settings.tocContainer === "") ? previewContainer : $(settings.tocContainer); - var tocMenu = tocContainer.find("." + this.classPrefix + "toc-menu"); - - tocContainer.attr("previewContainer", (settings.tocContainer === "") ? "true" : "false"); - - if (settings.tocContainer !== "" && tocMenu.length > 0) - { - tocMenu.remove(); - } - - editormd.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); - - if (settings.tocDropdown || tocContainer.find("." + this.classPrefix + "toc-menu").length > 0) - { - editormd.tocDropdownMenu(tocContainer, (settings.tocTitle !== "") ? settings.tocTitle : this.lang.tocTitle); - } - - if (settings.tocContainer !== "") - { - previewContainer.find(".markdown-toc").css("border", "none"); - } - } - - if (settings.tex) - { - if (!editormd.kaTeXLoaded && settings.autoLoadModules) - { - editormd.loadKaTeX(function() { - editormd.$katex = katex; - editormd.kaTeXLoaded = true; - _this.katexRender(); - }); - } - else - { - editormd.$katex = katex; - this.katexRender(); - } - } - - if (settings.flowChart || settings.sequenceDiagram) - { - flowchartTimer = setTimeout(function(){ - clearTimeout(flowchartTimer); - _this.flowChartAndSequenceDiagramRender(); - flowchartTimer = null; - }, 10); - } - - if (state.loaded) - { - $.proxy(settings.onchange, this)(); - } - } - - return this; - }, - - /** - * 聚焦光标位置 - * Focusing the cursor position - * - * @returns {editormd} 返回editormd的实例对象 - */ - - focus : function() { - this.cm.focus(); - - return this; - }, - - /** - * 设置光标的位置 - * Set cursor position - * - * @param {Object} cursor 要设置的光标位置键值对象,例:{line:1, ch:0} - * @returns {editormd} 返回editormd的实例对象 - */ - - setCursor : function(cursor) { - this.cm.setCursor(cursor); - - return this; - }, - - /** - * 获取当前光标的位置 - * Get the current position of the cursor - * - * @returns {Cursor} 返回一个光标Cursor对象 - */ - - getCursor : function() { - return this.cm.getCursor(); - }, - - /** - * 设置光标选中的范围 - * Set cursor selected ranges - * - * @param {Object} from 开始位置的光标键值对象,例:{line:1, ch:0} - * @param {Object} to 结束位置的光标键值对象,例:{line:1, ch:0} - * @returns {editormd} 返回editormd的实例对象 - */ - - setSelection : function(from, to) { - - this.cm.setSelection(from, to); - - return this; - }, - - /** - * 获取光标选中的文本 - * Get the texts from cursor selected - * - * @returns {String} 返回选中文本的字符串形式 - */ - - getSelection : function() { - return this.cm.getSelection(); - }, - - /** - * 设置光标选中的文本范围 - * Set the cursor selection ranges - * - * @param {Array} ranges cursor selection ranges array - * @returns {Array} return this - */ - - setSelections : function(ranges) { - this.cm.setSelections(ranges); - - return this; - }, - - /** - * 获取光标选中的文本范围 - * Get the cursor selection ranges - * - * @returns {Array} return selection ranges array - */ - - getSelections : function() { - return this.cm.getSelections(); - }, - - /** - * 替换当前光标选中的文本或在当前光标处插入新字符 - * Replace the text at the current cursor selected or insert a new character at the current cursor position - * - * @param {String} value 要插入的字符值 - * @returns {editormd} 返回editormd的实例对象 - */ - - replaceSelection : function(value) { - this.cm.replaceSelection(value); - - return this; - }, - - /** - * 在当前光标处插入新字符 - * Insert a new character at the current cursor position - * - * 同replaceSelection()方法 - * With the replaceSelection() method - * - * @param {String} value 要插入的字符值 - * @returns {editormd} 返回editormd的实例对象 - */ - - insertValue : function(value) { - this.replaceSelection(value); - - return this; - }, - - /** - * 追加markdown - * append Markdown to editor - * - * @param {String} md 要追加的markdown源文档 - * @returns {editormd} 返回editormd的实例对象 - */ - - appendMarkdown : function(md) { - var settings = this.settings; - var cm = this.cm; - - cm.setValue(cm.getValue() + md); - - return this; - }, - - /** - * 设置和传入编辑器的markdown源文档 - * Set Markdown source document - * - * @param {String} md 要传入的markdown源文档 - * @returns {editormd} 返回editormd的实例对象 - */ - - setMarkdown : function(md) { - this.cm.setValue(md || this.settings.markdown); - - return this; - }, - - /** - * 获取编辑器的markdown源文档 - * Set Editor.md markdown/CodeMirror value - * - * @returns {editormd} 返回editormd的实例对象 - */ - - getMarkdown : function() { - return this.cm.getValue(); - }, - - /** - * 获取编辑器的源文档 - * Get CodeMirror value - * - * @returns {editormd} 返回editormd的实例对象 - */ - - getValue : function() { - return this.cm.getValue(); - }, - - /** - * 设置编辑器的源文档 - * Set CodeMirror value - * - * @param {String} value set code/value/string/text - * @returns {editormd} 返回editormd的实例对象 - */ - - setValue : function(value) { - this.cm.setValue(value); - - return this; - }, - - /** - * 清空编辑器 - * Empty CodeMirror editor container - * - * @returns {editormd} 返回editormd的实例对象 - */ - - clear : function() { - this.cm.setValue(""); - - return this; - }, - - /** - * 获取解析后存放在Textarea的HTML源码 - * Get parsed html code from Textarea - * - * @returns {String} 返回HTML源码 - */ - - getHTML : function() { - if (!this.settings.saveHTMLToTextarea) - { - alert("Error: settings.saveHTMLToTextarea == false"); - - return false; - } - - return this.htmlTextarea.val(); - }, - - /** - * getHTML()的别名 - * getHTML (alias) - * - * @returns {String} Return html code 返回HTML源码 - */ - - getTextareaSavedHTML : function() { - return this.getHTML(); - }, - - /** - * 获取预览窗口的HTML源码 - * Get html from preview container - * - * @returns {editormd} 返回editormd的实例对象 - */ - - getPreviewedHTML : function() { - if (!this.settings.watch) - { - alert("Error: settings.watch == false"); - - return false; - } - - return this.previewContainer.html(); - }, - - /** - * 开启实时预览 - * Enable real-time watching - * - * @returns {editormd} 返回editormd的实例对象 - */ - - watch : function(callback) { - var settings = this.settings; - - if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) - { - return this; - } - - this.state.watching = settings.watch = true; - this.preview.show(); - - if (this.toolbar) - { - var watchIcon = settings.toolbarIconsClass.watch; - var unWatchIcon = settings.toolbarIconsClass.unwatch; - - var icon = this.toolbar.find(".fa[name=watch]"); - icon.parent().attr("title", settings.lang.toolbar.watch); - icon.removeClass(unWatchIcon).addClass(watchIcon); - } - - this.codeMirror.css("border-right", "1px solid #ddd").width(this.editor.width() / 2); - - timer = 0; - - this.save().resize(); - - if (!settings.onwatch) - { - settings.onwatch = callback || function() {}; - } - - $.proxy(settings.onwatch, this)(); - - return this; - }, - - /** - * 关闭实时预览 - * Disable real-time watching - * - * @returns {editormd} 返回editormd的实例对象 - */ - - unwatch : function(callback) { - var settings = this.settings; - this.state.watching = settings.watch = false; - this.preview.hide(); - - if (this.toolbar) - { - var watchIcon = settings.toolbarIconsClass.watch; - var unWatchIcon = settings.toolbarIconsClass.unwatch; - - var icon = this.toolbar.find(".fa[name=watch]"); - icon.parent().attr("title", settings.lang.toolbar.unwatch); - icon.removeClass(watchIcon).addClass(unWatchIcon); - } - - this.codeMirror.css("border-right", "none").width(this.editor.width()); - - this.resize(); - - if (!settings.onunwatch) - { - settings.onunwatch = callback || function() {}; - } - - $.proxy(settings.onunwatch, this)(); - - return this; - }, - - /** - * 显示编辑器 - * Show editor - * - * @param {Function} [callback=function()] 回调函数 - * @returns {editormd} 返回editormd的实例对象 - */ - - show : function(callback) { - callback = callback || function() {}; - - var _this = this; - this.editor.show(0, function() { - $.proxy(callback, _this)(); - }); - - return this; - }, - - /** - * 隐藏编辑器 - * Hide editor - * - * @param {Function} [callback=function()] 回调函数 - * @returns {editormd} 返回editormd的实例对象 - */ - - hide : function(callback) { - callback = callback || function() {}; - - var _this = this; - this.editor.hide(0, function() { - $.proxy(callback, _this)(); - }); - - return this; - }, - - /** - * 隐藏编辑器部分,只预览HTML - * Enter preview html state - * - * @returns {editormd} 返回editormd的实例对象 - */ - - previewing : function() { - - var _this = this; - var editor = this.editor; - var preview = this.preview; - var toolbar = this.toolbar; - var settings = this.settings; - var codeMirror = this.codeMirror; - var previewContainer = this.previewContainer; - - if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) { - return this; - } - - if (settings.toolbar && toolbar) { - toolbar.toggle(); - toolbar.find(".fa[name=preview]").toggleClass("active"); - } - - codeMirror.toggle(); - - var escHandle = function(event) { - if (event.shiftKey && event.keyCode === 27) { - _this.previewed(); - } - }; - - if (codeMirror.css("display") === "none") // 为了兼容Zepto,而不使用codeMirror.is(":hidden") - { - this.state.preview = true; - - if (this.state.fullscreen) { - preview.css("background", "#fff"); - } - - editor.find("." + this.classPrefix + "preview-close-btn").show().bind(editormd.mouseOrTouch("click", "touchend"), function(){ - _this.previewed(); - }); - - if (!settings.watch) - { - this.save(); - } - else - { - previewContainer.css("padding", ""); - } - - previewContainer.addClass(this.classPrefix + "preview-active"); - - preview.show().css({ - position : "", - top : 0, - width : editor.width(), - height : (settings.autoHeight && !this.state.fullscreen) ? "auto" : editor.height() - }); - - if (this.state.loaded) - { - $.proxy(settings.onpreviewing, this)(); - } - - $(window).bind("keyup", escHandle); - } - else - { - $(window).unbind("keyup", escHandle); - this.previewed(); - } - }, - - /** - * 显示编辑器部分,退出只预览HTML - * Exit preview html state - * - * @returns {editormd} 返回editormd的实例对象 - */ - - previewed : function() { - - var editor = this.editor; - var preview = this.preview; - var toolbar = this.toolbar; - var settings = this.settings; - var previewContainer = this.previewContainer; - var previewCloseBtn = editor.find("." + this.classPrefix + "preview-close-btn"); - - this.state.preview = false; - - this.codeMirror.show(); - - if (settings.toolbar) { - toolbar.show(); - } - - preview[(settings.watch) ? "show" : "hide"](); - - previewCloseBtn.hide().unbind(editormd.mouseOrTouch("click", "touchend")); - - previewContainer.removeClass(this.classPrefix + "preview-active"); - - if (settings.watch) - { - previewContainer.css("padding", "20px"); - } - - preview.css({ - background : null, - position : "absolute", - width : editor.width() / 2, - height : (settings.autoHeight && !this.state.fullscreen) ? "auto" : editor.height() - toolbar.height(), - top : (settings.toolbar) ? toolbar.height() : 0 - }); - - if (this.state.loaded) - { - $.proxy(settings.onpreviewed, this)(); - } - - return this; - }, - - /** - * 编辑器全屏显示 - * Fullscreen show - * - * @returns {editormd} 返回editormd的实例对象 - */ - - fullscreen : function() { - - var _this = this; - var state = this.state; - var editor = this.editor; - var preview = this.preview; - var toolbar = this.toolbar; - var settings = this.settings; - var fullscreenClass = this.classPrefix + "fullscreen"; - - if (toolbar) { - toolbar.find(".fa[name=fullscreen]").parent().toggleClass("active"); - } - - var escHandle = function(event) { - if (!event.shiftKey && event.keyCode === 27) - { - if (state.fullscreen) - { - _this.fullscreenExit(); - } - } - }; - - if (!editor.hasClass(fullscreenClass)) - { - state.fullscreen = true; - - $("html,body").css("overflow", "hidden"); - - editor.css({ - width : $(window).width(), - height : $(window).height() - }).addClass(fullscreenClass); - - this.resize(); - - $.proxy(settings.onfullscreen, this)(); - - $(window).bind("keyup", escHandle); - } - else - { - $(window).unbind("keyup", escHandle); - this.fullscreenExit(); - } - - return this; - }, - - /** - * 编辑器退出全屏显示 - * Exit fullscreen state - * - * @returns {editormd} 返回editormd的实例对象 - */ - - fullscreenExit : function() { - - var editor = this.editor; - var settings = this.settings; - var toolbar = this.toolbar; - var fullscreenClass = this.classPrefix + "fullscreen"; - - this.state.fullscreen = false; - - if (toolbar) { - toolbar.find(".fa[name=fullscreen]").parent().removeClass("active"); - } - - $("html,body").css("overflow", ""); - - editor.css({ - width : editor.data("oldWidth"), - height : editor.data("oldHeight") - }).removeClass(fullscreenClass); - - this.resize(); - - $.proxy(settings.onfullscreenExit, this)(); - - return this; - }, - - /** - * 加载并执行插件 - * Load and execute the plugin - * - * @param {String} name plugin name / function name - * @param {String} path plugin load path - * @returns {editormd} 返回editormd的实例对象 - */ - - executePlugin : function(name, path) { - - var _this = this; - var cm = this.cm; - var settings = this.settings; - - path = settings.pluginPath + path; - - if (typeof define === "function") - { - if (typeof this[name] === "undefined") - { - alert("Error: " + name + " plugin is not found, you are not load this plugin."); - - return this; - } - - this[name](cm); - - return this; - } - - if ($.inArray(path, editormd.loadFiles.plugin) < 0) - { - editormd.loadPlugin(path, function() { - editormd.loadPlugins[name] = _this[name]; - _this[name](cm); - }); - } - else - { - $.proxy(editormd.loadPlugins[name], this)(cm); - } - - return this; - }, - - /** - * 搜索替换 - * Search & replace - * - * @param {String} command CodeMirror serach commands, "find, fintNext, fintPrev, clearSearch, replace, replaceAll" - * @returns {editormd} return this - */ - - search : function(command) { - var settings = this.settings; - - if (!settings.searchReplace) - { - alert("Error: settings.searchReplace == false"); - return this; - } - - if (!settings.readOnly) - { - this.cm.execCommand(command || "find"); - } - - return this; - }, - - searchReplace : function() { - this.search("replace"); - - return this; - }, - - searchReplaceAll : function() { - this.search("replaceAll"); - - return this; - } - }; - - editormd.fn.init.prototype = editormd.fn; - - /** - * 锁屏 - * lock screen when dialog opening - * - * @returns {void} - */ - - editormd.dialogLockScreen = function() { - var settings = this.settings || {dialogLockScreen : true}; - - if (settings.dialogLockScreen) - { - $("html,body").css("overflow", "hidden"); - this.resize(); - } - }; - - /** - * 显示透明背景层 - * Display mask layer when dialog opening - * - * @param {Object} dialog dialog jQuery object - * @returns {void} - */ - - editormd.dialogShowMask = function(dialog) { - var editor = this.editor; - var settings = this.settings || {dialogShowMask : true}; - - dialog.css({ - top : ($(window).height() - dialog.height()) / 2 + "px", - left : ($(window).width() - dialog.width()) / 2 + "px" - }); - - if (settings.dialogShowMask) { - editor.children("." + this.classPrefix + "mask").css("z-index", parseInt(dialog.css("z-index")) - 1).show(); - } - }; - - editormd.toolbarHandlers = { - undo : function() { - this.cm.undo(); - }, - - redo : function() { - this.cm.redo(); - }, - - bold : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - cm.replaceSelection("**" + selection + "**"); - - if(selection === "") { - cm.setCursor(cursor.line, cursor.ch + 2); - } - }, - - del : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - cm.replaceSelection("~~" + selection + "~~"); - - if(selection === "") { - cm.setCursor(cursor.line, cursor.ch + 2); - } - }, - - italic : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - cm.replaceSelection("*" + selection + "*"); - - if(selection === "") { - cm.setCursor(cursor.line, cursor.ch + 1); - } - }, - - quote : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (cursor.ch !== 0) - { - cm.setCursor(cursor.line, 0); - cm.replaceSelection("> " + selection); - cm.setCursor(cursor.line, cursor.ch + 2); - } - else - { - cm.replaceSelection("> " + selection); - } - - //cm.replaceSelection("> " + selection); - //cm.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2); - }, - - ucfirst : function() { - var cm = this.cm; - var selection = cm.getSelection(); - var selections = cm.listSelections(); - - cm.replaceSelection(editormd.firstUpperCase(selection)); - cm.setSelections(selections); - }, - - ucwords : function() { - var cm = this.cm; - var selection = cm.getSelection(); - var selections = cm.listSelections(); - - cm.replaceSelection(editormd.wordsFirstUpperCase(selection)); - cm.setSelections(selections); - }, - - uppercase : function() { - var cm = this.cm; - var selection = cm.getSelection(); - var selections = cm.listSelections(); - - cm.replaceSelection(selection.toUpperCase()); - cm.setSelections(selections); - }, - - lowercase : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - var selections = cm.listSelections(); - - cm.replaceSelection(selection.toLowerCase()); - cm.setSelections(selections); - }, - - h1 : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (cursor.ch !== 0) - { - cm.setCursor(cursor.line, 0); - cm.replaceSelection("# " + selection); - cm.setCursor(cursor.line, cursor.ch + 2); - } - else - { - cm.replaceSelection("# " + selection); - } - }, - - h2 : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (cursor.ch !== 0) - { - cm.setCursor(cursor.line, 0); - cm.replaceSelection("## " + selection); - cm.setCursor(cursor.line, cursor.ch + 3); - } - else - { - cm.replaceSelection("## " + selection); - } - }, - - h3 : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (cursor.ch !== 0) - { - cm.setCursor(cursor.line, 0); - cm.replaceSelection("### " + selection); - cm.setCursor(cursor.line, cursor.ch + 4); - } - else - { - cm.replaceSelection("### " + selection); - } - }, - - h4 : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (cursor.ch !== 0) - { - cm.setCursor(cursor.line, 0); - cm.replaceSelection("#### " + selection); - cm.setCursor(cursor.line, cursor.ch + 5); - } - else - { - cm.replaceSelection("#### " + selection); - } - }, - - h5 : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (cursor.ch !== 0) - { - cm.setCursor(cursor.line, 0); - cm.replaceSelection("##### " + selection); - cm.setCursor(cursor.line, cursor.ch + 6); - } - else - { - cm.replaceSelection("##### " + selection); - } - }, - - h6 : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (cursor.ch !== 0) - { - cm.setCursor(cursor.line, 0); - cm.replaceSelection("###### " + selection); - cm.setCursor(cursor.line, cursor.ch + 7); - } - else - { - cm.replaceSelection("###### " + selection); - } - }, - - "list-ul" : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (selection === "") - { - cm.replaceSelection("- " + selection); - } - else - { - var selectionText = selection.split("\n"); - - for (var i = 0, len = selectionText.length; i < len; i++) - { - selectionText[i] = (selectionText[i] === "") ? "" : "- " + selectionText[i]; - } - - cm.replaceSelection(selectionText.join("\n")); - } - }, - - "list-ol" : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if(selection === "") - { - cm.replaceSelection("1. " + selection); - } - else - { - var selectionText = selection.split("\n"); - - for (var i = 0, len = selectionText.length; i < len; i++) - { - selectionText[i] = (selectionText[i] === "") ? "" : (i+1) + ". " + selectionText[i]; - } - - cm.replaceSelection(selectionText.join("\n")); - } - }, - - hr : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - cm.replaceSelection(((cursor.ch !== 0) ? "\n\n" : "\n") + "------------\n\n"); - }, - - tex : function() { - if (!this.settings.tex) - { - alert("settings.tex === false"); - return this; - } - - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - cm.replaceSelection("$$" + selection + "$$"); - - if(selection === "") { - cm.setCursor(cursor.line, cursor.ch + 2); - } - }, - - link : function() { - this.executePlugin("linkDialog", "link-dialog/link-dialog"); - }, - - "reference-link" : function() { - this.executePlugin("referenceLinkDialog", "reference-link-dialog/reference-link-dialog"); - }, - - pagebreak : function() { - if (!this.settings.pageBreak) - { - alert("settings.pageBreak === false"); - return this; - } - - var cm = this.cm; - var selection = cm.getSelection(); - - cm.replaceSelection("\r\n[========]\r\n"); - }, - - image : function() { - this.executePlugin("imageDialog", "image-dialog/image-dialog"); - }, - - code : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - cm.replaceSelection("`" + selection + "`"); - - if (selection === "") { - cm.setCursor(cursor.line, cursor.ch + 1); - } - }, - - "code-block" : function() { - this.executePlugin("codeBlockDialog", "code-block-dialog/code-block-dialog"); - }, - - "preformatted-text" : function() { - this.executePlugin("preformattedTextDialog", "preformatted-text-dialog/preformatted-text-dialog"); - }, - - table : function() { - this.executePlugin("tableDialog", "table-dialog/table-dialog"); - }, - - datetime : function() { - var cm = this.cm; - var selection = cm.getSelection(); - var date = new Date(); - var langName = this.settings.lang.name; - var datefmt = editormd.dateFormat() + " " + editormd.dateFormat((langName === "zh-cn" || langName === "zh-tw") ? "cn-week-day" : "week-day"); - - cm.replaceSelection(datefmt); - }, - - emoji : function() { - this.executePlugin("emojiDialog", "emoji-dialog/emoji-dialog"); - }, - - "html-entities" : function() { - this.executePlugin("htmlEntitiesDialog", "html-entities-dialog/html-entities-dialog"); - }, - - "goto-line" : function() { - this.executePlugin("gotoLineDialog", "goto-line-dialog/goto-line-dialog"); - }, - - watch : function() { - this[this.settings.watch ? "unwatch" : "watch"](); - }, - - preview : function() { - this.previewing(); - }, - - fullscreen : function() { - this.fullscreen(); - }, - - clear : function() { - this.clear(); - }, - - search : function() { - this.search(); - }, - - help : function() { - this.executePlugin("helpDialog", "help-dialog/help-dialog"); - }, - - info : function() { - this.showInfoDialog(); - } - }; - - editormd.keyMaps = { - "Ctrl-1" : "h1", - "Ctrl-2" : "h2", - "Ctrl-3" : "h3", - "Ctrl-4" : "h4", - "Ctrl-5" : "h5", - "Ctrl-6" : "h6", - "Ctrl-B" : "bold", // if this is string == editormd.toolbarHandlers.xxxx - "Ctrl-D" : "datetime", - - "Ctrl-E" : function() { // emoji - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (!this.settings.emoji) - { - alert("Error: settings.emoji == false"); - return ; - } - - cm.replaceSelection(":" + selection + ":"); - - if (selection === "") { - cm.setCursor(cursor.line, cursor.ch + 1); - } - }, - "Ctrl-Alt-G" : "goto-line", - "Ctrl-H" : "hr", - "Ctrl-I" : "italic", - "Ctrl-K" : "code", - - "Ctrl-L" : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - var title = (selection === "") ? "" : " \""+selection+"\""; - - cm.replaceSelection("[" + selection + "]("+title+")"); - - if (selection === "") { - cm.setCursor(cursor.line, cursor.ch + 1); - } - }, - "Ctrl-U" : "list-ul", - - "Shift-Ctrl-A" : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - if (!this.settings.atLink) - { - alert("Error: settings.atLink == false"); - return ; - } - - cm.replaceSelection("@" + selection); - - if (selection === "") { - cm.setCursor(cursor.line, cursor.ch + 1); - } - }, - - "Shift-Ctrl-C" : "code", - "Shift-Ctrl-Q" : "quote", - "Shift-Ctrl-S" : "del", - "Shift-Ctrl-K" : "tex", // KaTeX - - "Shift-Alt-C" : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - cm.replaceSelection(["```", selection, "```"].join("\n")); - - if (selection === "") { - cm.setCursor(cursor.line, cursor.ch + 3); - } - }, - - "Shift-Ctrl-Alt-C" : "code-block", - "Shift-Ctrl-H" : "html-entities", - "Shift-Alt-H" : "help", - "Shift-Ctrl-E" : "emoji", - "Shift-Ctrl-U" : "uppercase", - "Shift-Alt-U" : "ucwords", - "Shift-Ctrl-Alt-U" : "ucfirst", - "Shift-Alt-L" : "lowercase", - - "Shift-Ctrl-I" : function() { - var cm = this.cm; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - - var title = (selection === "") ? "" : " \""+selection+"\""; - - cm.replaceSelection("![" + selection + "]("+title+")"); - - if (selection === "") { - cm.setCursor(cursor.line, cursor.ch + 4); - } - }, - - "Shift-Ctrl-Alt-I" : "image", - "Shift-Ctrl-L" : "link", - "Shift-Ctrl-O" : "list-ol", - "Shift-Ctrl-P" : "preformatted-text", - "Shift-Ctrl-T" : "table", - "Shift-Alt-P" : "pagebreak", - "F9" : "watch", - "F10" : "preview", - "F11" : "fullscreen", - }; - - /** - * 清除字符串两边的空格 - * Clear the space of strings both sides. - * - * @param {String} str string - * @returns {String} trimed string - */ - - var trim = function(str) { - return (!String.prototype.trim) ? str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "") : str.trim(); - }; - - editormd.trim = trim; - - /** - * 所有单词首字母大写 - * Words first to uppercase - * - * @param {String} str string - * @returns {String} string - */ - - var ucwords = function (str) { - return str.toLowerCase().replace(/\b(\w)|\s(\w)/g, function($1) { - return $1.toUpperCase(); - }); - }; - - editormd.ucwords = editormd.wordsFirstUpperCase = ucwords; - - /** - * 字符串首字母大写 - * Only string first char to uppercase - * - * @param {String} str string - * @returns {String} string - */ - - var firstUpperCase = function(str) { - return str.toLowerCase().replace(/\b(\w)/, function($1){ - return $1.toUpperCase(); - }); - }; - - var ucfirst = firstUpperCase; - - editormd.firstUpperCase = editormd.ucfirst = firstUpperCase; - - editormd.urls = { - atLinkBase : "https://github.com/" - }; - - editormd.regexs = { - atLink : /@(\w+)/g, - email : /(\w+)@(\w+)\.(\w+)\.?(\w+)?/g, - emailLink : /(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g, - emoji : /:([\w\+-]+):/g, - emojiDatetime : /(\d{2}:\d{2}:\d{2})/g, - twemoji : /:(tw-([\w]+)-?(\w+)?):/g, - fontAwesome : /:(fa-([\w]+)(-(\w+)){0,}):/g, - editormdLogo : /:(editormd-logo-?(\w+)?):/g, - pageBreak : /^\[[=]{8,}\]$/ - }; - - // Emoji graphics files url path - editormd.emoji = { - path : "https://www.webpagefx.com/tools/emoji-cheat-sheet/graphics/emojis/", - ext : ".png" - }; - - // Twitter Emoji (Twemoji) graphics files url path - editormd.twemoji = { - path : "http://twemoji.maxcdn.com/36x36/", - ext : ".png" - }; - - /** - * 自定义marked的解析器 - * Custom Marked renderer rules - * - * @param {Array} markdownToC 传入用于接收TOC的数组 - * @returns {Renderer} markedRenderer 返回marked的Renderer自定义对象 - */ - - editormd.markedRenderer = function(markdownToC, options) { - var defaults = { - toc : true, // Table of contents - tocm : false, - tocStartLevel : 1, // Said from H1 to create ToC - pageBreak : true, - atLink : true, // for @link - emailLink : true, // for mail address auto link - taskList : false, // Enable Github Flavored Markdown task lists - emoji : false, // :emoji: , Support Twemoji, fontAwesome, Editor.md logo emojis. - tex : false, // TeX(LaTeX), based on KaTeX - flowChart : false, // flowChart.js only support IE9+ - sequenceDiagram : false, // sequenceDiagram.js only support IE9+ - }; - - var settings = $.extend(defaults, options || {}); - var marked = editormd.$marked; - var markedRenderer = new marked.Renderer(); - markdownToC = markdownToC || []; - - var regexs = editormd.regexs; - var atLinkReg = regexs.atLink; - var emojiReg = regexs.emoji; - var emailReg = regexs.email; - var emailLinkReg = regexs.emailLink; - var twemojiReg = regexs.twemoji; - var faIconReg = regexs.fontAwesome; - var editormdLogoReg = regexs.editormdLogo; - var pageBreakReg = regexs.pageBreak; - - markedRenderer.emoji = function(text) { - - text = text.replace(editormd.regexs.emojiDatetime, function($1) { - return $1.replace(/:/g, ":"); - }); - - var matchs = text.match(emojiReg); - - if (!matchs || !settings.emoji) { - return text; - } - - for (var i = 0, len = matchs.length; i < len; i++) - { - if (matchs[i] === ":+1:") { - matchs[i] = ":\\+1:"; - } - - text = text.replace(new RegExp(matchs[i]), function($1, $2){ - var faMatchs = $1.match(faIconReg); - var name = $1.replace(/:/g, ""); - - if (faMatchs) - { - for (var fa = 0, len1 = faMatchs.length; fa < len1; fa++) - { - var faName = faMatchs[fa].replace(/:/g, ""); - - return ""; - } - } - else - { - var emdlogoMathcs = $1.match(editormdLogoReg); - var twemojiMatchs = $1.match(twemojiReg); - - if (emdlogoMathcs) - { - for (var x = 0, len2 = emdlogoMathcs.length; x < len2; x++) - { - var logoName = emdlogoMathcs[x].replace(/:/g, ""); - return ""; - } - } - else if (twemojiMatchs) - { - for (var t = 0, len3 = twemojiMatchs.length; t < len3; t++) - { - var twe = twemojiMatchs[t].replace(/:/g, "").replace("tw-", ""); - return "\"twemoji-""; - } - } - else - { - var src = (name === "+1") ? "plus1" : name; - src = (src === "black_large_square") ? "black_square" : src; - src = (src === "moon") ? "waxing_gibbous_moon" : src; - - return "\":""; - } - } - }); - } - - return text; - }; - - markedRenderer.atLink = function(text) { - - if (atLinkReg.test(text)) - { - if (settings.atLink) - { - text = text.replace(emailReg, function($1, $2, $3, $4) { - return $1.replace(/@/g, "_#_@_#_"); - }); - - text = text.replace(atLinkReg, function($1, $2) { - return "" + $1 + ""; - }).replace(/_#_@_#_/g, "@"); - } - - if (settings.emailLink) - { - text = text.replace(emailLinkReg, function($1, $2, $3, $4, $5) { - return (!$2 && $.inArray($5, "jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|")) < 0) ? ""+$1+"" : $1; - }); - } - - return text; - } - - return text; - }; - - markedRenderer.link = function (href, title, text) { - - if (this.options.sanitize) { - try { - var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase(); - } catch(e) { - return ""; - } - - if (prot.indexOf("javascript:") === 0) { - return ""; - } - } - - var out = "" + text.replace(/@/g, "@") + ""; - } - - if (title) { - out += " title=\"" + title + "\""; - } - - out += ">" + text + ""; - - return out; - }; - - markedRenderer.heading = function(text, level, raw) { - - var linkText = text; - var hasLinkReg = /\s*\]*)\>(.*)\<\/a\>\s*/; - var getLinkTextReg = /\s*\]+)\>([^\>]*)\<\/a\>\s*/g; - - if (hasLinkReg.test(text)) - { - var tempText = []; - text = text.split(/\]+)\>([^\>]*)\<\/a\>/); - - for (var i = 0, len = text.length; i < len; i++) - { - tempText.push(text[i].replace(/\s*href\=\"(.*)\"\s*/g, "")); - } - - text = tempText.join(" "); - } - - text = trim(text); - - var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-"); - var toc = { - text : text, - level : level, - slug : escapedText - }; - - var isChinese = /^[\u4e00-\u9fa5]+$/.test(text); - var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-"); - - markdownToC.push(toc); - - var headingHTML = ""; - - headingHTML += ""; - headingHTML += ""; - headingHTML += (hasLinkReg) ? this.atLink(this.emoji(linkText)) : this.atLink(this.emoji(text)); - headingHTML += ""; - - return headingHTML; - }; - - markedRenderer.pageBreak = function(text) { - if (pageBreakReg.test(text) && settings.pageBreak) - { - text = "
    "; - } - - return text; - }; - - markedRenderer.paragraph = function(text) { - var isTeXInline = /\$\$(.*)\$\$/g.test(text); - var isTeXLine = /^\$\$(.*)\$\$$/.test(text); - var isTeXAddClass = (isTeXLine) ? " class=\"" + editormd.classNames.tex + "\"" : ""; - var isToC = (settings.tocm) ? /^(\[TOC\]|\[TOCM\])$/.test(text) : /^\[TOC\]$/.test(text); - var isToCMenu = /^\[TOCM\]$/.test(text); - - if (!isTeXLine && isTeXInline) - { - text = text.replace(/(\$\$([^\$]*)\$\$)+/g, function($1, $2) { - return "" + $2.replace(/\$/g, "") + ""; - }); - } - else - { - text = (isTeXLine) ? text.replace(/\$/g, "") : text; - } - - var tocHTML = "
    " + text + "
    "; - - return (isToC) ? ( (isToCMenu) ? "
    " + tocHTML + "

    " : tocHTML ) - : ( (pageBreakReg.test(text)) ? this.pageBreak(text) : "" + this.atLink(this.emoji(text)) + "

    \n" ); - }; - - markedRenderer.code = function (code, lang, escaped) { - - if (lang === "seq" || lang === "sequence") - { - return "
    " + code + "
    "; - } - else if ( lang === "flow") - { - return "
    " + code + "
    "; - } - else if ( lang === "math" || lang === "latex" || lang === "katex") - { - return "

    " + code + "

    "; - } - else - { - - return marked.Renderer.prototype.code.apply(this, arguments); - } - }; - - markedRenderer.tablecell = function(content, flags) { - var type = (flags.header) ? "th" : "td"; - var tag = (flags.align) ? "<" + type +" style=\"text-align:" + flags.align + "\">" : "<" + type + ">"; - - return tag + this.atLink(this.emoji(content)) + "\n"; - }; - - markedRenderer.listitem = function(text) { - if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) - { - text = text.replace(/^\s*\[\s\]\s*/, " ") - .replace(/^\s*\[x\]\s*/, " "); - - return "
  • " + this.atLink(this.emoji(text)) + "
  • "; - } - else - { - return "
  • " + this.atLink(this.emoji(text)) + "
  • "; - } - }; - - return markedRenderer; - }; - - /** - * - * 生成TOC(Table of Contents) - * Creating ToC (Table of Contents) - * - * @param {Array} toc 从marked获取的TOC数组列表 - * @param {Element} container 插入TOC的容器元素 - * @param {Integer} startLevel Hx 起始层级 - * @returns {Object} tocContainer 返回ToC列表容器层的jQuery对象元素 - */ - - editormd.markdownToCRenderer = function(toc, container, tocDropdown, startLevel) { - - var html = ""; - var lastLevel = 0; - var classPrefix = this.classPrefix; - - startLevel = startLevel || 1; - - for (var i = 0, len = toc.length; i < len; i++) - { - var text = toc[i].text; - var level = toc[i].level; - - if (level < startLevel) { - continue; - } - - if (level > lastLevel) - { - html += ""; - } - else if (level < lastLevel) - { - html += (new Array(lastLevel - level + 2)).join(""); - } - else - { - html += ""; - } - - html += "
  • " + text + "
      "; - lastLevel = level; - } - - var tocContainer = container.find(".markdown-toc"); - - if ((tocContainer.length < 1 && container.attr("previewContainer") === "false")) - { - var tocHTML = "
      "; - - tocHTML = (tocDropdown) ? "
      " + tocHTML + "
      " : tocHTML; - - container.html(tocHTML); - - tocContainer = container.find(".markdown-toc"); - } - - if (tocDropdown) - { - tocContainer.wrap("

      "); - } - - tocContainer.html("
        ").children(".markdown-toc-list").html(html.replace(/\r?\n?\\<\/ul\>/g, "")); - - return tocContainer; - }; - - /** - * - * 生成TOC下拉菜单 - * Creating ToC dropdown menu - * - * @param {Object} container 插入TOC的容器jQuery对象元素 - * @param {String} tocTitle ToC title - * @returns {Object} return toc-menu object - */ - - editormd.tocDropdownMenu = function(container, tocTitle) { - - tocTitle = tocTitle || "Table of Contents"; - - var zindex = 400; - var tocMenus = container.find("." + this.classPrefix + "toc-menu"); - - tocMenus.each(function() { - var $this = $(this); - var toc = $this.children(".markdown-toc"); - var icon = ""; - var btn = "" + icon + tocTitle + ""; - var menu = toc.children("ul"); - var list = menu.find("li"); - - toc.append(btn); - - list.first().before("
      • " + tocTitle + " " + icon + "

      • "); - - $this.mouseover(function(){ - menu.show(); - - list.each(function(){ - var li = $(this); - var ul = li.children("ul"); - - if (ul.html() === "") - { - ul.remove(); - } - - if (ul.length > 0 && ul.html() !== "") - { - var firstA = li.children("a").first(); - - if (firstA.children(".fa").length < 1) - { - firstA.append( $(icon).css({ float:"right", paddingTop:"4px" }) ); - } - } - - li.mouseover(function(){ - ul.css("z-index", zindex).show(); - zindex += 1; - }).mouseleave(function(){ - ul.hide(); - }); - }); - }).mouseleave(function(){ - menu.hide(); - }); - }); - - return tocMenus; - }; - - /** - * 简单地过滤指定的HTML标签 - * Filter custom html tags - * - * @param {String} html 要过滤HTML - * @param {String} filters 要过滤的标签 - * @returns {String} html 返回过滤的HTML - */ - - editormd.filterHTMLTags = function(html, filters) { - - if (typeof html !== "string") { - html = new String(html); - } - - if (typeof filters !== "string") { - return html; - } - - var expression = filters.split("|"); - var filterTags = expression[0].split(","); - var attrs = expression[1]; - - for (var i = 0, len = filterTags.length; i < len; i++) - { - var tag = filterTags[i]; - - html = html.replace(new RegExp("\<\s*" + tag + "\s*([^\>]*)\>([^\>]*)\<\s*\/" + tag + "\s*\>", "igm"), ""); - } - - //return html; - - if (typeof attrs !== "undefined") - { - var htmlTagRegex = /\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/ig; - - if (attrs === "*") - { - html = html.replace(htmlTagRegex, function($1, $2, $3, $4, $5) { - return "<" + $2 + ">" + $4 + ""; - }); - } - else if (attrs === "on*") - { - html = html.replace(htmlTagRegex, function($1, $2, $3, $4, $5) { - var el = $("<" + $2 + ">" + $4 + ""); - var _attrs = $($1)[0].attributes; - var $attrs = {}; - - $.each(_attrs, function(i, e) { - if (e.nodeName !== '"') $attrs[e.nodeName] = e.nodeValue; - }); - - $.each($attrs, function(i) { - if (i.indexOf("on") === 0) { - delete $attrs[i]; - } - }); - - el.attr($attrs); - - var text = (typeof el[1] !== "undefined") ? $(el[1]).text() : ""; - - return el[0].outerHTML + text; - }); - } - else - { - html = html.replace(htmlTagRegex, function($1, $2, $3, $4) { - var filterAttrs = attrs.split(","); - var el = $($1); - el.html($4); - - $.each(filterAttrs, function(i) { - el.attr(filterAttrs[i], null); - }); - - return el[0].outerHTML; - }); - } - } - - return html; - }; - - /** - * 将Markdown文档解析为HTML用于前台显示 - * Parse Markdown to HTML for Font-end preview. - * - * @param {String} id 用于显示HTML的对象ID - * @param {Object} [options={}] 配置选项,可选 - * @returns {Object} div 返回jQuery对象元素 - */ - - editormd.markdownToHTML = function(id, options) { - var defaults = { - gfm : true, - toc : true, - tocm : false, - tocStartLevel : 1, - tocTitle : "目录", - tocDropdown : false, - tocContainer : "", - markdown : "", - markdownSourceCode : false, - htmlDecode : false, - autoLoadKaTeX : true, - pageBreak : true, - atLink : true, // for @link - emailLink : true, // for mail address auto link - tex : false, - taskList : false, // Github Flavored Markdown task lists - emoji : false, - flowChart : false, - sequenceDiagram : false, - previewCodeHighlight : true - }; - - editormd.$marked = marked; - - var div = $("#" + id); - var settings = div.settings = $.extend(true, defaults, options || {}); - var saveTo = div.find("textarea"); - - if (saveTo.length < 1) - { - div.append(""); - saveTo = div.find("textarea"); - } - - var markdownDoc = (settings.markdown === "") ? saveTo.val() : settings.markdown; - var markdownToC = []; - - var rendererOptions = { - toc : settings.toc, - tocm : settings.tocm, - tocStartLevel : settings.tocStartLevel, - taskList : settings.taskList, - emoji : settings.emoji, - tex : settings.tex, - pageBreak : settings.pageBreak, - atLink : settings.atLink, // for @link - emailLink : settings.emailLink, // for mail address auto link - flowChart : settings.flowChart, - sequenceDiagram : settings.sequenceDiagram, - previewCodeHighlight : settings.previewCodeHighlight, - }; - - var markedOptions = { - renderer : editormd.markedRenderer(markdownToC, rendererOptions), - gfm : settings.gfm, - tables : true, - breaks : true, - pedantic : false, - sanitize : (settings.htmlDecode) ? false : true, // 是否忽略HTML标签,即是否开启HTML标签解析,为了安全性,默认不开启 - smartLists : true, - smartypants : true - }; - - markdownDoc = new String(markdownDoc); - - var markdownParsed = marked(markdownDoc, markedOptions); - - markdownParsed = editormd.filterHTMLTags(markdownParsed, settings.htmlDecode); - - if (settings.markdownSourceCode) { - saveTo.text(markdownDoc); - } else { - saveTo.remove(); - } - - div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed); - - var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div; - - if (settings.tocContainer !== "") - { - tocContainer.attr("previewContainer", false); - } - - if (settings.toc) - { - div.tocContainer = this.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); - - if (settings.tocDropdown || div.find("." + this.classPrefix + "toc-menu").length > 0) - { - this.tocDropdownMenu(div, settings.tocTitle); - } - - if (settings.tocContainer !== "") - { - div.find(".editormd-toc-menu, .editormd-markdown-toc").remove(); - } - } - - if (settings.previewCodeHighlight) - { - div.find("pre").addClass("prettyprint linenums"); - prettyPrint(); - } - - if (!editormd.isIE8) - { - if (settings.flowChart) { - div.find(".flowchart").flowChart(); - } - - if (settings.sequenceDiagram) { - div.find(".sequence-diagram").sequenceDiagram({theme: "simple"}); - } - } - - if (settings.tex) - { - var katexHandle = function() { - div.find("." + editormd.classNames.tex).each(function(){ - var tex = $(this); - katex.render(tex.html().replace(/</g, "<").replace(/>/g, ">"), tex[0]); - tex.find(".katex").css("font-size", "1.6em"); - }); - }; - - if (settings.autoLoadKaTeX && !editormd.$katex && !editormd.kaTeXLoaded) - { - this.loadKaTeX(function() { - editormd.$katex = katex; - editormd.kaTeXLoaded = true; - katexHandle(); - }); - } - else - { - katexHandle(); - } - } - - div.getMarkdown = function() { - return saveTo.val(); - }; - - return div; - }; - - // Editor.md themes, change toolbar themes etc. - // added @1.5.0 - editormd.themes = ["default", "dark"]; - - // Preview area themes - // added @1.5.0 - editormd.previewThemes = ["default", "dark"]; - - // CodeMirror / editor area themes - // @1.5.0 rename -> editorThemes, old version -> themes - editormd.editorThemes = [ - "default", "3024-day", "3024-night", - "ambiance", "ambiance-mobile", - "base16-dark", "base16-light", "blackboard", - "cobalt", - "eclipse", "elegant", "erlang-dark", - "lesser-dark", - "mbo", "mdn-like", "midnight", "monokai", - "neat", "neo", "night", - "paraiso-dark", "paraiso-light", "pastel-on-dark", - "rubyblue", - "solarized", - "the-matrix", "tomorrow-night-eighties", "twilight", - "vibrant-ink", - "xq-dark", "xq-light" - ]; - - editormd.loadPlugins = {}; - - editormd.loadFiles = { - js : [], - css : [], - plugin : [] - }; - - /** - * 动态加载Editor.md插件,但不立即执行 - * Load editor.md plugins - * - * @param {String} fileName 插件文件路径 - * @param {Function} [callback=function()] 加载成功后执行的回调函数 - * @param {String} [into="head"] 嵌入页面的位置 - */ - - editormd.loadPlugin = function(fileName, callback, into) { - callback = callback || function() {}; - - this.loadScript(fileName, function() { - editormd.loadFiles.plugin.push(fileName); - callback(); - }, into); - }; - - /** - * 动态加载CSS文件的方法 - * Load css file method - * - * @param {String} fileName CSS文件名 - * @param {Function} [callback=function()] 加载成功后执行的回调函数 - * @param {String} [into="head"] 嵌入页面的位置 - */ - - editormd.loadCSS = function(fileName, callback, into) { - into = into || "head"; - callback = callback || function() {}; - - var css = document.createElement("link"); - css.type = "text/css"; - css.rel = "stylesheet"; - css.onload = css.onreadystatechange = function() { - editormd.loadFiles.css.push(fileName); - callback(); - }; - - css.href = fileName + ".css"; - - if(into === "head") { - document.getElementsByTagName("head")[0].appendChild(css); - } else { - document.body.appendChild(css); - } - }; - - editormd.isIE = (navigator.appName == "Microsoft Internet Explorer"); - editormd.isIE8 = (editormd.isIE && navigator.appVersion.match(/8./i) == "8."); - - /** - * 动态加载JS文件的方法 - * Load javascript file method - * - * @param {String} fileName JS文件名 - * @param {Function} [callback=function()] 加载成功后执行的回调函数 - * @param {String} [into="head"] 嵌入页面的位置 - */ - - editormd.loadScript = function(fileName, callback, into) { - - into = into || "head"; - callback = callback || function() {}; - - var script = null; - script = document.createElement("script"); - script.id = fileName.replace(/[\./]+/g, "-"); - script.type = "text/javascript"; - script.src = fileName + ".js"; - - if (editormd.isIE8) - { - script.onreadystatechange = function() { - if(script.readyState) - { - if (script.readyState === "loaded" || script.readyState === "complete") - { - script.onreadystatechange = null; - editormd.loadFiles.js.push(fileName); - callback(); - } - } - }; - } - else - { - script.onload = function() { - editormd.loadFiles.js.push(fileName); - callback(); - }; - } - - if (into === "head") { - document.getElementsByTagName("head")[0].appendChild(script); - } else { - document.body.appendChild(script); - } - }; - - // 使用国外的CDN,加载速度有时会很慢,或者自定义URL - // You can custom KaTeX load url. - editormd.katexURL = { - css : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min", - js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min" - }; - - editormd.kaTeXLoaded = false; - - /** - * 加载KaTeX文件 - * load KaTeX files - * - * @param {Function} [callback=function()] 加载成功后执行的回调函数 - */ - - editormd.loadKaTeX = function (callback) { - editormd.loadCSS(editormd.katexURL.css, function(){ - editormd.loadScript(editormd.katexURL.js, callback || function(){}); - }); - }; - - /** - * 锁屏 - * lock screen - * - * @param {Boolean} lock Boolean 布尔值,是否锁屏 - * @returns {void} - */ - - editormd.lockScreen = function(lock) { - $("html,body").css("overflow", (lock) ? "hidden" : ""); - }; - - /** - * 动态创建对话框 - * Creating custom dialogs - * - * @param {Object} options 配置项键值对 Key/Value - * @returns {dialog} 返回创建的dialog的jQuery实例对象 - */ - - editormd.createDialog = function(options) { - var defaults = { - name : "", - width : 420, - height: 240, - title : "", - drag : true, - closed : true, - content : "", - mask : true, - maskStyle : { - backgroundColor : "#fff", - opacity : 0.1 - }, - lockScreen : true, - footer : true, - buttons : false - }; - - options = $.extend(true, defaults, options); - - var $this = this; - var editor = this.editor; - var classPrefix = editormd.classPrefix; - var guid = (new Date()).getTime(); - var dialogName = ( (options.name === "") ? classPrefix + "dialog-" + guid : options.name); - var mouseOrTouch = editormd.mouseOrTouch; - - var html = "
        "; - - if (options.title !== "") - { - html += "
        "; - html += "" + options.title + ""; - html += "
        "; - } - - if (options.closed) - { - html += ""; - } - - html += "
        " + options.content; - - if (options.footer || typeof options.footer === "string") - { - html += "
        " + ( (typeof options.footer === "boolean") ? "" : options.footer) + "
        "; - } - - html += "
        "; - - html += "
        "; - html += "
        "; - html += "
        "; - - editor.append(html); - - var dialog = editor.find("." + dialogName); - - dialog.lockScreen = function(lock) { - if (options.lockScreen) - { - $("html,body").css("overflow", (lock) ? "hidden" : ""); - $this.resize(); - } - - return dialog; - }; - - dialog.showMask = function() { - if (options.mask) - { - editor.find("." + classPrefix + "mask").css(options.maskStyle).css("z-index", editormd.dialogZindex - 1).show(); - } - return dialog; - }; - - dialog.hideMask = function() { - if (options.mask) - { - editor.find("." + classPrefix + "mask").hide(); - } - - return dialog; - }; - - dialog.loading = function(show) { - var loading = dialog.find("." + classPrefix + "dialog-mask"); - loading[(show) ? "show" : "hide"](); - - return dialog; - }; - - dialog.lockScreen(true).showMask(); - - dialog.show().css({ - zIndex : editormd.dialogZindex, - border : (editormd.isIE8) ? "1px solid #ddd" : "", - width : (typeof options.width === "number") ? options.width + "px" : options.width, - height : (typeof options.height === "number") ? options.height + "px" : options.height - }); - - var dialogPosition = function(){ - dialog.css({ - top : ($(window).height() - dialog.height()) / 2 + "px", - left : ($(window).width() - dialog.width()) / 2 + "px" - }); - }; - - dialogPosition(); - - $(window).resize(dialogPosition); - - dialog.children("." + classPrefix + "dialog-close").bind(mouseOrTouch("click", "touchend"), function() { - dialog.hide().lockScreen(false).hideMask(); - }); - - if (typeof options.buttons === "object") - { - var footer = dialog.footer = dialog.find("." + classPrefix + "dialog-footer"); - - for (var key in options.buttons) - { - var btn = options.buttons[key]; - var btnClassName = classPrefix + key + "-btn"; - - footer.append(""); - btn[1] = $.proxy(btn[1], dialog); - footer.children("." + btnClassName).bind(mouseOrTouch("click", "touchend"), btn[1]); - } - } - - if (options.title !== "" && options.drag) - { - var posX, posY; - var dialogHeader = dialog.children("." + classPrefix + "dialog-header"); - - if (!options.mask) { - dialogHeader.bind(mouseOrTouch("click", "touchend"), function(){ - editormd.dialogZindex += 2; - dialog.css("z-index", editormd.dialogZindex); - }); - } - - dialogHeader.mousedown(function(e) { - e = e || window.event; //IE - posX = e.clientX - parseInt(dialog[0].style.left); - posY = e.clientY - parseInt(dialog[0].style.top); - - document.onmousemove = moveAction; - }); - - var userCanSelect = function (obj) { - obj.removeClass(classPrefix + "user-unselect").off("selectstart"); - }; - - var userUnselect = function (obj) { - obj.addClass(classPrefix + "user-unselect").on("selectstart", function(event) { // selectstart for IE - return false; - }); - }; - - var moveAction = function (e) { - e = e || window.event; //IE - - var left, top, nowLeft = parseInt(dialog[0].style.left), nowTop = parseInt(dialog[0].style.top); - - if( nowLeft >= 0 ) { - if( nowLeft + dialog.width() <= $(window).width()) { - left = e.clientX - posX; - } else { - left = $(window).width() - dialog.width(); - document.onmousemove = null; - } - } else { - left = 0; - document.onmousemove = null; - } - - if( nowTop >= 0 ) { - top = e.clientY - posY; - } else { - top = 0; - document.onmousemove = null; - } - - - document.onselectstart = function() { - return false; - }; - - userUnselect($("body")); - userUnselect(dialog); - dialog[0].style.left = left + "px"; - dialog[0].style.top = top + "px"; - }; - - document.onmouseup = function() { - userCanSelect($("body")); - userCanSelect(dialog); - - document.onselectstart = null; - document.onmousemove = null; - }; - - dialogHeader.touchDraggable = function() { - var offset = null; - var start = function(e) { - var orig = e.originalEvent; - var pos = $(this).parent().position(); - - offset = { - x : orig.changedTouches[0].pageX - pos.left, - y : orig.changedTouches[0].pageY - pos.top - }; - }; - - var move = function(e) { - e.preventDefault(); - var orig = e.originalEvent; - - $(this).parent().css({ - top : orig.changedTouches[0].pageY - offset.y, - left : orig.changedTouches[0].pageX - offset.x - }); - }; - - this.bind("touchstart", start).bind("touchmove", move); - }; - - dialogHeader.touchDraggable(); - } - - editormd.dialogZindex += 2; - - return dialog; - }; - - /** - * 鼠标和触摸事件的判断/选择方法 - * MouseEvent or TouchEvent type switch - * - * @param {String} [mouseEventType="click"] 供选择的鼠标事件 - * @param {String} [touchEventType="touchend"] 供选择的触摸事件 - * @returns {String} EventType 返回事件类型名称 - */ - - editormd.mouseOrTouch = function(mouseEventType, touchEventType) { - mouseEventType = mouseEventType || "click"; - touchEventType = touchEventType || "touchend"; - - var eventType = mouseEventType; - - try { - document.createEvent("TouchEvent"); - eventType = touchEventType; - } catch(e) {} - - return eventType; - }; - - /** - * 日期时间的格式化方法 - * Datetime format method - * - * @param {String} [format=""] 日期时间的格式,类似PHP的格式 - * @returns {String} datefmt 返回格式化后的日期时间字符串 - */ - - editormd.dateFormat = function(format) { - format = format || ""; - - var addZero = function(d) { - return (d < 10) ? "0" + d : d; - }; - - var date = new Date(); - var year = date.getFullYear(); - var year2 = year.toString().slice(2, 4); - var month = addZero(date.getMonth() + 1); - var day = addZero(date.getDate()); - var weekDay = date.getDay(); - var hour = addZero(date.getHours()); - var min = addZero(date.getMinutes()); - var second = addZero(date.getSeconds()); - var ms = addZero(date.getMilliseconds()); - var datefmt = ""; - - var ymd = year2 + "-" + month + "-" + day; - var fymd = year + "-" + month + "-" + day; - var hms = hour + ":" + min + ":" + second; - - switch (format) - { - case "UNIX Time" : - datefmt = date.getTime(); - break; - - case "UTC" : - datefmt = date.toUTCString(); - break; - - case "yy" : - datefmt = year2; - break; - - case "year" : - case "yyyy" : - datefmt = year; - break; - - case "month" : - case "mm" : - datefmt = month; - break; - - case "cn-week-day" : - case "cn-wd" : - var cnWeekDays = ["日", "一", "二", "三", "四", "五", "六"]; - datefmt = "星期" + cnWeekDays[weekDay]; - break; - - case "week-day" : - case "wd" : - var weekDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; - datefmt = weekDays[weekDay]; - break; - - case "day" : - case "dd" : - datefmt = day; - break; - - case "hour" : - case "hh" : - datefmt = hour; - break; - - case "min" : - case "ii" : - datefmt = min; - break; - - case "second" : - case "ss" : - datefmt = second; - break; - - case "ms" : - datefmt = ms; - break; - - case "yy-mm-dd" : - datefmt = ymd; - break; - - case "yyyy-mm-dd" : - datefmt = fymd; - break; - - case "yyyy-mm-dd h:i:s ms" : - case "full + ms" : - datefmt = fymd + " " + hms + " " + ms; - break; - - case "full" : - case "yyyy-mm-dd h:i:s" : - default: - datefmt = fymd + " " + hms; - break; - } - - return datefmt; - }; - - return editormd; - -})); diff --git a/src/assets/editor/editormd.min.js b/src/assets/editor/editormd.min.js deleted file mode 100644 index f810e34..0000000 --- a/src/assets/editor/editormd.min.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! Editor.md v1.5.0 | editormd.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-06-09 */ -!function(e){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd||define(["jquery"],e):window.editormd=e()}(function(){"use strict";var e="undefined"!=typeof jQuery?jQuery:Zepto;if("undefined"!=typeof e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.0",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.toolbarModes={full:["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"],simple:["undo","redo","|","bold","del","italic","quote","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","watch","preview","fullscreen","|","help","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",delay:300,autoLoadModules:!0,watch:!0,placeholder:"Enjoy Markdown! coding now...",gotoLine:!0,codeFold:!1,autoHeight:!1,autoFocus:!0,autoCloseTags:!0,searchReplace:!0,syncScrolling:!0,readOnly:!1,tabSize:4,indentUnit:4,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,showTrailingSpace:!0,matchBrackets:!0,indentWithTabs:!0,styleSelectedText:!0,matchWordHighlight:!0,styleActiveLine:!0,dialogLockScreen:!0,dialogShowMask:!0,dialogDraggable:!0,dialogMaskBgColor:"#fff",dialogMaskOpacity:.1,fontSize:"13px",saveHTMLToTextarea:!1,disabledKeyMaps:[],onload:function(){},onresize:function(){},onchange:function(){},onwatch:null,onunwatch:null,onpreviewing:function(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'a',ucwords:'Aa'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.classPrefix+"bold","list-ul":"fa-list-ul","list-ol":"fa-list-ol",hr:"fa-minus",link:"fa-link","reference-link":"fa-anchor",image:"fa-picture-o",code:"fa-code","preformatted-text":"fa-file-code-o","code-block":"fa-file-code-o",table:"fa-table",datetime:"fa-clock-o",emoji:"fa-smile-o","html-entities":"fa-copyright",pagebreak:"fa-newspaper-o","goto-line":"fa-terminal",watch:"fa-eye-slash",unwatch:"fa-eye",preview:"fa-desktop",search:"fa-search",fullscreen:"fa-arrows-alt",clear:"fa-eraser",help:"fa-question-circle",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线Markdown编辑器
        Open source online Markdown editor.",tocTitle:"目录",toolbar:{undo:"撤销(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗体",del:"删除线",italic:"斜体",quote:"引用",ucwords:"将每个单词首字母转成大写",uppercase:"将所选转换成大写",lowercase:"将所选转换成小写",h1:"标题1",h2:"标题2",h3:"标题3",h4:"标题4",h5:"标题5",h6:"标题6","list-ul":"无序列表","list-ol":"有序列表",hr:"横线",link:"链接","reference-link":"引用链接",image:"添加图片",code:"行内代码","preformatted-text":"预格式文本 / 代码块(缩进风格)","code-block":"代码块(多语言风格)",table:"添加表格",datetime:"日期时间",emoji:"Emoji表情","html-entities":"HTML实体字符",pagebreak:"插入分页符","goto-line":"跳转到行",watch:"关闭实时预览",unwatch:"开启实时预览",preview:"全窗口预览HTML(按 Shift + ESC还原)",fullscreen:"全屏(按ESC还原)",clear:"清空",search:"搜索",help:"使用帮助",info:"关于"+t.title},buttons:{enter:"确定",cancel:"取消",close:"关闭"},dialog:{link:{title:"添加链接",url:"链接地址",urlTitle:"链接标题",urlEmpty:"错误:请填写链接地址。"},referenceLink:{title:"添加引用链接",name:"引用名称",url:"链接地址",urlId:"链接ID",urlTitle:"链接标题",nameEmpty:"错误:引用链接的名称不能为空。",idEmpty:"错误:请填写引用链接的ID。",urlEmpty:"错误:请填写引用链接的URL地址。"},image:{title:"添加图片",url:"图片地址",link:"图片链接",alt:"图片描述",uploadButton:"本地上传",imageURLEmpty:"错误:图片地址不能为空。",uploadFileEmpty:"错误:上传的图片不能为空。",formatNotAllowed:"错误:只允许上传图片文件,允许上传的图片文件格式有:"},preformattedText:{title:"添加预格式文本或代码块",emptyAlert:"错误:请填写预格式文本或代码的内容。"},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。"},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,n=this.settings=e.extend(!0,t.defaults,o);i="object"==typeof i?n.id:i;var a=this.editor=e("#"+i);this.id=i,this.lang=n.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};n.pluginPath=""===n.pluginPath?n.path+"../plugins/":n.pluginPath,this.state.watching=n.watch?!0:!1,a.hasClass("editormd")||a.addClass("editormd"),a.css({width:"number"==typeof n.width?n.width+"px":n.width,height:"number"==typeof n.height?n.height+"px":n.height}),n.autoHeight&&a.css("height","auto");var l=this.markdownTextarea=a.children("textarea");l.length<1&&(a.append(""),l=this.markdownTextarea=a.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",n.placeholder),("undefined"==typeof l.attr("name")||""===l.attr("name"))&&l.attr("name",""!==n.name?n.name:i+"-markdown-doc");var c=[n.readOnly?"":'',n.saveHTMLToTextarea?'':"",'
        ','
        ','
        '].join("\n");return a.append(c).addClass(r+"vertical"),""!==n.theme&&a.addClass(r+"theme-"+n.theme),this.mask=a.children("."+r+"mask"),this.containerMask=a.children("."+r+"container-mask"),""!==n.markdown&&l.val(n.markdown),""!==n.appendMarkdown&&l.val(l.val()+n.appendMarkdown),this.htmlTextarea=a.children("."+s.textarea.html),this.preview=a.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==n.previewTheme&&this.preview.addClass(r+"preview-theme-"+n.previewTheme),"function"==typeof define&&define.amd&&("undefined"!=typeof katex&&(t.$katex=katex),n.searchReplace&&!n.readOnly&&(t.loadCSS(n.path+"codemirror/addon/dialog/dialog"),t.loadCSS(n.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!n.autoLoadModules?("undefined"!=typeof CodeMirror&&(t.$CodeMirror=CodeMirror),"undefined"!=typeof marked&&(t.$marked=marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){return t.isIE8?void e.loadedDisplay():void(i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay())};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){return e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode?(e.loadedDisplay(),!1):(e.setToolbar(),void t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()}))})})}),this},setTheme:function(e){var t=this.editor,i=this.settings.theme,o=this.classPrefix+"theme-";return t.removeClass(o+i).addClass(o+e),this.settings.theme=e,this},setEditorTheme:function(e){var i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.editorTheme),this.cm.setOption("theme",e),this},setCodeMirrorTheme:function(e){return this.setEditorTheme(e),this},setPreviewTheme:function(e){var t=this.preview,i=this.settings.previewTheme,o=this.classPrefix+"preview-theme-";return t.removeClass(o+i).addClass(o+e),this.settings.previewTheme=e,this},setCodeMirror:function(){var e=this.settings,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={mode:e.mode,theme:e.editorTheme,tabSize:e.tabSize,dragDrop:!1,autofocus:e.autoFocus,autoCloseTags:e.autoCloseTags,readOnly:e.readOnly?"nocursor":!1,indentUnit:e.indentUnit,lineNumbers:e.lineNumbers,lineWrapping:e.lineWrapping,extraKeys:{"Ctrl-Q":function(e){e.foldCode(e.getCursor())}},foldGutter:e.codeFold,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],matchBrackets:e.matchBrackets,indentWithTabs:e.indentWithTabs,styleActiveLine:e.styleActiveLine,styleSelectedText:e.styleSelectedText,autoCloseBrackets:e.autoCloseBrackets,showTrailingSpace:e.showTrailingSpace,highlightSelectionMatches:e.matchWordHighlight?{showToken:"onselected"===e.matchWordHighlight?!1:/\w/}:!1};return this.codeEditor=this.cm=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.children(".CodeMirror"),""!==e.value&&this.cm.setValue(e.value),this.codeMirror.css({fontSize:e.fontSize,width:e.watch?"50%":"100%"}),e.autoHeight&&(this.codeMirror.css("height","auto"),this.cm.setOption("viewportMargin",1/0)),e.lineNumbers||this.codeMirror.find(".CodeMirror-gutters").css("border-right","none"),this},getCodeMirrorOption:function(e){return this.cm.getOption(e)},setCodeMirrorOption:function(e,t){return this.cm.setOption(e,t),this},addKeyMap:function(e,t){return this.cm.addKeyMap(e,t),this},removeKeyMap:function(e){return this.cm.removeKeyMap(e),this},gotoLine:function(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=(this.editor,o.lineCount()),n=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if(t=parseInt(t)-1,t>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var a=o.getScrollInfo(),s=a.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;n.scrollTop(0===d?0:d+h>=c.scrollHeight-16?n[0].scrollHeight:n[0].scrollHeight*u)}return o.focus(),this},extend:function(){return"undefined"!=typeof arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&"undefined"==typeof arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return"undefined"!=typeof i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return"undefined"!=typeof o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return"undefined"!=typeof t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){var i=this.settings;return i.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,n=this.settings;"undefined"!=typeof t&&(n.toolbarAutoFixed=t);var a=function(){var t=e(window),i=t.scrollTop();return n.toolbarAutoFixed?void r.css(i-o.offset().top>10&&i
          ';i.append(n),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var a="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=a.length;d>h;h++){var u=a[h];if("||"===u)c=!0;else if("|"===u)l+='
        • |
        • ';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p="undefined"==typeof p?"":p,m="undefined"==typeof m?"":m,w="undefined"==typeof w?"":w;var v=c?'
        • ':"
        • ";"undefined"!=typeof e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='',v+=''+(f?u.toUpperCase():""===w?m:"")+"",v+=""),v+="
        • ",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&"undefined"!=typeof toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var i=this,o=this.settings;if(!o.toolbar||o.readOnly)return this;var r=this.toolbar,n=this.cm,a=this.classPrefix,s=this.toolbarIcons=r.find("."+a+"menu > li > a"),l=this.getToolbarHandles();return s.bind(t.mouseOrTouch("click","touchend"),function(t){var r=e(this).children(".fa"),a=r.attr("name"),s=n.getCursor(),c=n.getSelection();return""!==a?(i.activeIcon=r,"undefined"!=typeof l[a]?e.proxy(l[a],i)(n):"undefined"!=typeof o.toolbarHandlers[a]&&e.proxy(o.toolbarHandlers[a],i)(n,r,s,c),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&n.focus(),!1):void 0}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['
          ','
          ','

          '+t.title+"v"+t.version+"

          ","

          "+this.lang.description+"

          ",'

          '+t.homePage+'

          ','

          Copyright © 2015 Pandao, The MIT License.

          ',"
          ",'',"
          "].join("\n");i.append(r);var n=this.infoDialog=i.children("."+o+"dialog-info");return n.find("."+o+"dialog-close").bind(t.mouseOrTouch("click","touchend"),function(){e.hideInfoDialog()}),n.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&e.find(".editormd-dialog").remove(),t.toolbar&&(this.getToolbarHandles(),this.setToolbar())),this.loadedDisplay(!0),this},previewCodeHighlight:function(){var e=this.settings,t=this.previewContainer;return e.previewCodeHighlight&&(t.find("pre").addClass("prettyprint linenums"),"undefined"!=typeof prettyPrint&&prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,n=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;n.find(".flowchart").flowChart()}r.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var a=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;a.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=a.find(".editormd-toc-menu").height();return f=f?f:0,a.scrollTop(0===h?0:h+c>=l[0].scrollHeight-16?a[0].scrollHeight:(a[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,n=this.settings,a=t.toolbarHandlers,s=n.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(a[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:return e.proxy(a.watch,o)(),!1;case 121:return e.proxy(a.preview,o)(),!1;case 122:return e.proxy(a.fullscreen,o)(),!1}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,n=this.codeMirror,a=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){n.find(".CodeMirror-scroll").bind(a("scroll","touchmove"),function(t){var n=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c?c:0,o.scrollTop(0===a?0:a+n>=e(this)[0].scrollHeight-16?o[0].scrollHeight:(o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){n.find(".CodeMirror-scroll").unbind(a("scroll","touchmove"))},c=function(){o.bind(a("scroll","touchmove"),function(t){var o=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=n.find(".CodeMirror-scroll");l.scrollTop(0===a?0:a+o>=e(this)[0].scrollHeight?l[0].scrollHeight:l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(a("scroll","touchmove"))};return n.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(t,r){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,n=this.settings;return this.containerMask.hide(),this.save(),n.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(n.onload,this)(),this.state.loaded=!0,this},width:function(e){return this.editor.css("width","number"==typeof e?e+"px":e),this.resize(),this},height:function(e){return this.editor.css("height","number"==typeof e?e+"px":e),this.resize(),this},resize:function(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,n=this.preview,a=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",a.height()+1).height(r.height()-a.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2),n.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?n.css("top",a.height()+1):n.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-a.height():r.height();n.height(c)}else n.height("");else l.width(r.width()),n.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,n=this.state,a=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==a.mode&&"markdown"!==a.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,pageBreak:a.pageBreak,taskList:a.taskList,emoji:a.emoji,tex:a.tex,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:a.htmlDecode?!1:!0,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,a.htmlDecode),this.markdownTextarea.text(l),s.save(),a.saveHTMLToTextarea&&this.htmlTextarea.text(g),a.watch||!a.watch&&n.preview){if(c.html(g),this.previewCodeHighlight(),a.toc){var p=""===a.tocContainer?c:e(a.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===a.tocContainer?"true":"false"),""!==a.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==a.tocTitle?a.tocTitle:this.lang.tocTitle),""!==a.tocContainer&&c.find(".markdown-toc").css("border","none")}a.tex&&(!t.kaTeXLoaded&&a.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(a.flowChart||a.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),n.loaded&&e.proxy(a.onchange,this)()}return this},focus:function(){return this.cm.focus(),this},setCursor:function(e){return this.cm.setCursor(e),this},getCursor:function(){return this.cm.getCursor()},setSelection:function(e,t){return this.cm.setSelection(e,t),this},getSelection:function(){return this.cm.getSelection()},setSelections:function(e){return this.cm.setSelections(e),this},getSelections:function(){return this.cm.getSelections()},replaceSelection:function(e){return this.cm.replaceSelection(e),this},insertValue:function(e){return this.replaceSelection(e),this},appendMarkdown:function(e){var t=(this.settings,this.cm);return t.setValue(t.getValue()+e),this},setMarkdown:function(e){return this.cm.setValue(e||this.settings.markdown),this},getMarkdown:function(){return this.cm.getValue()},getValue:function(){return this.cm.getValue()},setValue:function(e){return this.cm.setValue(e),this},clear:function(){return this.cm.setValue(""),this},getHTML:function(){return this.settings.saveHTMLToTextarea?this.htmlTextarea.val():(alert("Error: settings.saveHTMLToTextarea == false"),!1)},getTextareaSavedHTML:function(){return this.getHTML()},getPreviewedHTML:function(){return this.settings.watch?this.previewContainer.html():(alert("Error: settings.watch == false"),!1)},watch:function(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,n=o.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",o.lang.toolbar.watch),a.removeClass(n).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",i.lang.toolbar.unwatch),n.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},previewing:function(){var i=this,o=this.editor,r=this.preview,n=this.toolbar,a=this.settings,s=this.codeMirror,l=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;a.toolbar&&n&&(n.toggle(),n.find(".fa[name=preview]").toggleClass("active")),s.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&i.previewed()};"none"===s.css("display")?(this.state.preview=!0,this.state.fullscreen&&r.css("background","#fff"),o.find("."+this.classPrefix+"preview-close-btn").show().bind(t.mouseOrTouch("click","touchend"),function(){i.previewed()}),a.watch?l.css("padding",""):this.save(),l.addClass(this.classPrefix+"preview-active"),r.show().css({position:"",top:0,width:o.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":o.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var i=this.editor,o=this.preview,r=this.toolbar,n=this.settings,a=this.previewContainer,s=i.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),n.toolbar&&r.show(),o[n.watch?"show":"hide"](),s.hide().unbind(t.mouseOrTouch("click","touchend")),a.removeClass(this.classPrefix+"preview-active"),n.watch&&a.css("padding","20px"),o.css({background:null,position:"absolute",width:i.width()/2,height:n.autoHeight&&!this.state.fullscreen?"auto":i.height()-r.height(),top:n.toolbar?r.height():0}),this.state.loaded&&e.proxy(n.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=(this.preview,this.toolbar),n=this.settings,a=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(a)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(a),this.resize(),e.proxy(n.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,n=this.cm,a=this.settings;return o=a.pluginPath+o,"function"==typeof define?"undefined"==typeof this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](n),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](n)}):e.proxy(t.loadPlugins[i],this)(n),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){var t=this.settings||{dialogLockScreen:!0};t.dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.toolbarHandlers={undo:function(){this.cm.undo()},redo:function(){this.cm.redo()},bold:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("**"+i+"**"),""===i&&e.setCursor(t.line,t.ch+2)},del:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("~~"+i+"~~"),""===i&&e.setCursor(t.line,t.ch+2)},italic:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("*"+i+"*"),""===i&&e.setCursor(t.line,t.ch+1)},quote:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("> "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("> "+i)},ucfirst:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},uppercase:function(){var e=this.cm,t=e.getSelection(),i=e.listSelections();e.replaceSelection(t.toUpperCase()),e.setSelections(i)},lowercase:function(){var e=this.cm,t=(e.getCursor(),e.getSelection()),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("# "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("# "+i)},h2:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0), -e.replaceSelection("## "+i),e.setCursor(t.line,t.ch+3)):e.replaceSelection("## "+i)},h3:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("### "+i),e.setCursor(t.line,t.ch+4)):e.replaceSelection("### "+i)},h4:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("#### "+i),e.setCursor(t.line,t.ch+5)):e.replaceSelection("#### "+i)},h5:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("##### "+i),e.setCursor(t.line,t.ch+6)):e.replaceSelection("##### "+i)},h6:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("###### "+i),e.setCursor(t.line,t.ch+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":"- "+i[o];e.replaceSelection(i.join("\n"))}},"list-ol":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("1. "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":o+1+". "+i[o];e.replaceSelection(i.join("\n"))}},hr:function(){{var e=this.cm,t=e.getCursor();e.getSelection()}e.replaceSelection((0!==t.ch?"\n\n":"\n")+"------------\n\n")},tex:function(){if(!this.settings.tex)return alert("settings.tex === false"),this;var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("$$"+i+"$$"),""===i&&e.setCursor(t.line,t.ch+2)},link:function(){this.executePlugin("linkDialog","link-dialog/link-dialog")},"reference-link":function(){this.executePlugin("referenceLinkDialog","reference-link-dialog/reference-link-dialog")},pagebreak:function(){if(!this.settings.pageBreak)return alert("settings.pageBreak === false"),this;{var e=this.cm;e.getSelection()}e.replaceSelection("\r\n[========]\r\n")},image:function(){this.executePlugin("imageDialog","image-dialog/image-dialog")},code:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("`"+i+"`"),""===i&&e.setCursor(t.line,t.ch+1)},"code-block":function(){this.executePlugin("codeBlockDialog","code-block-dialog/code-block-dialog")},"preformatted-text":function(){this.executePlugin("preformattedTextDialog","preformatted-text-dialog/preformatted-text-dialog")},table:function(){this.executePlugin("tableDialog","table-dialog/table-dialog")},datetime:function(){var e=this.cm,i=(e.getSelection(),new Date,this.settings.lang.name),o=t.dateFormat()+" "+t.dateFormat("zh-cn"===i||"zh-tw"===i?"cn-week-day":"week-day");e.replaceSelection(o)},emoji:function(){this.executePlugin("emojiDialog","emoji-dialog/emoji-dialog")},"html-entities":function(){this.executePlugin("htmlEntitiesDialog","html-entities-dialog/html-entities-dialog")},"goto-line":function(){this.executePlugin("gotoLineDialog","goto-line-dialog/goto-line-dialog")},watch:function(){this[this.settings.watch?"unwatch":"watch"]()},preview:function(){this.previewing()},fullscreen:function(){this.fullscreen()},clear:function(){this.clear()},search:function(){this.search()},help:function(){this.executePlugin("helpDialog","help-dialog/help-dialog")},info:function(){this.showInfoDialog()}},t.keyMaps={"Ctrl-1":"h1","Ctrl-2":"h2","Ctrl-3":"h3","Ctrl-4":"h4","Ctrl-5":"h5","Ctrl-6":"h6","Ctrl-B":"bold","Ctrl-D":"datetime","Ctrl-E":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.emoji?(e.replaceSelection(":"+i+":"),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.emoji == false")},"Ctrl-Alt-G":"goto-line","Ctrl-H":"hr","Ctrl-I":"italic","Ctrl-K":"code","Ctrl-L":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+1)},"Ctrl-U":"list-ul","Shift-Ctrl-A":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.atLink?(e.replaceSelection("@"+i),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.atLink == false")},"Shift-Ctrl-C":"code","Shift-Ctrl-Q":"quote","Shift-Ctrl-S":"del","Shift-Ctrl-K":"tex","Shift-Alt-C":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection(["```",i,"```"].join("\n")),""===i&&e.setCursor(t.line,t.ch+3)},"Shift-Ctrl-Alt-C":"code-block","Shift-Ctrl-H":"html-entities","Shift-Alt-H":"help","Shift-Ctrl-E":"emoji","Shift-Ctrl-U":"uppercase","Shift-Alt-U":"ucwords","Shift-Ctrl-Alt-U":"ucfirst","Shift-Alt-L":"lowercase","Shift-Ctrl-I":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("!["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+4)},"Shift-Ctrl-Alt-I":"image","Shift-Ctrl-L":"link","Shift-Ctrl-O":"list-ol","Shift-Ctrl-P":"preformatted-text","Shift-Ctrl-T":"table","Shift-Alt-P":"pagebreak",F9:"watch",F10:"preview",F11:"fullscreen"};var r=function(e){return String.prototype.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};t.trim=r;var n=function(e){return e.toLowerCase().replace(/\b(\w)|\s(\w)/g,function(e){return e.toUpperCase()})};t.ucwords=t.wordsFirstUpperCase=n;var a=function(e){return e.toLowerCase().replace(/\b(\w)/,function(e){return e.toUpperCase()})};return t.firstUpperCase=t.ucfirst=a,t.urls={atLinkBase:"https://github.com/"},t.regexs={atLink:/@(\w+)/g,email:/(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,emailLink:/(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,emoji:/:([\w\+-]+):/g,emojiDatetime:/(\d{2}:\d{2}:\d{2})/g,twemoji:/:(tw-([\w]+)-?(\w+)?):/g,fontAwesome:/:(fa-([\w]+)(-(\w+)){0,}):/g,editormdLogo:/:(editormd-logo-?(\w+)?):/g,pageBreak:/^\[[=]{8,}\]$/},t.emoji={path:"http://www.emoji-cheat-sheet.com/graphics/emojis/",ext:".png"},t.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},t.markedRenderer=function(i,o){var n={toc:!0,tocm:!1,tocStartLevel:1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1},a=e.extend(n,o||{}),s=t.$marked,l=new s.Renderer;i=i||[];var c=t.regexs,h=c.atLink,d=c.emoji,u=c.email,f=c.emailLink,g=c.twemoji,p=c.fontAwesome,m=c.editormdLogo,w=c.pageBreak;return l.emoji=function(e){e=e.replace(t.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")});var i=e.match(d);if(!i||!a.emoji)return e;for(var o=0,r=i.length;r>o;o++)":+1:"===i[o]&&(i[o]=":\\+1:"),e=e.replace(new RegExp(i[o]),function(e,i){var o=e.match(p),r=e.replace(/:/g,"");if(o)for(var n=0,a=o.length;a>n;n++){var s=o[n].replace(/:/g,"");return''}else{var l=e.match(m),c=e.match(g);if(l)for(var h=0,d=l.length;d>h;h++){var u=l[h].replace(/:/g,"");return''}else{if(!c){var f="+1"===r?"plus1":r;return f="black_large_square"===f?"black_square":f,f="moon"===f?"waxing_gibbous_moon":f,':'+r+':'}for(var w=0,v=c.length;v>w;w++){var k=c[w].replace(/:/g,"").replace("tw-","");return'twemoji-'+k+''}}}});return e},l.atLink=function(i){return h.test(i)?(a.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return''+e+""}).replace(/_#_@_#_/g,"@")),a.emailLink&&(i=i.replace(f,function(t,i,o,r,n){return!i&&e.inArray(n,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?''+t+"":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize){try{var o=decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(r){return""}if(0===o.indexOf("javascript:"))return""}var n=''+i.replace(/@/g,"@")+""):(t&&(n+=' title="'+t+'"'),n+=">"+i+"")},l.heading=function(e,t,o){var n=e,a=/\s*\]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var s=[];e=e.split(/\]+)\>([^\>]*)\<\/a\>/);for(var l=0,c=e.length;c>l;l++)s.push(e[l].replace(/\s*href\=\"(.*)\"\s*/g,""));e=s.join(" ")}e=r(e);var h=e.toLowerCase().replace(/[^\w]+/g,"-"),d={text:e,level:t,slug:h},u=/^[\u4e00-\u9fa5]+$/.test(e),f=u?escape(e).replace(/\%/g,""):e.toLowerCase().replace(/[^\w]+/g,"-");i.push(d);var g="';return g+='',g+='',g+=this.atLink(a?this.emoji(n):this.emoji(e)),g+=""},l.pageBreak=function(e){return w.test(e)&&a.pageBreak&&(e='
          '),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",n=a.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return''+i.replace(/\$/g,"")+""}):o?e.replace(/\$/g,""):e;var l='
          '+e+"
          ";return n?s?'
          '+l+"

          ":l:w.test(e)?this.pageBreak(e):""+this.atLink(this.emoji(e))+"

          \n"},l.code=function(e,i,o){return"seq"===i||"sequence"===i?'
          '+e+"
          ":"flow"===i?'
          '+e+"
          ":"math"===i||"latex"===i||"katex"===i?'

          '+e+"

          ":s.Renderer.prototype.code.apply(this,arguments)},l.tablecell=function(e,t){var i=t.header?"th":"td",o=t.align?"<"+i+' style="text-align:'+t.align+'">':"<"+i+">";return o+this.atLink(this.emoji(e))+"\n"},l.listitem=function(e){return a.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,' ').replace(/^\s*\[x\]\s*/,' '),'
        • '+this.atLink(this.emoji(e))+"
        • "):"
        • "+this.atLink(this.emoji(e))+"
        • "},l},t.markdownToCRenderer=function(e,t,i,o){var r="",n=0,a=this.classPrefix;o=o||1;for(var s=0,l=e.length;l>s;s++){var c=e[s].text,h=e[s].level;o>h||(r+=h>n?"":n>h?new Array(n-h+2).join("
      • "):"",r+='
      • '+c+"