poly-cms 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +27 -0
- data/Gemfile.lock +95 -0
- data/README.md +3 -0
- data/Rakefile +45 -0
- data/bin/poly +88 -0
- data/config.ru +3 -0
- data/core/admin/assets/images/icons/cache-clear.svg +11 -0
- data/core/admin/assets/images/icons/delete-dark.svg +10 -0
- data/core/admin/assets/images/icons/delete.svg +10 -0
- data/core/admin/assets/images/icons/handle.svg +12 -0
- data/core/admin/assets/images/icons/logout.svg +13 -0
- data/core/admin/assets/images/icons/move.svg +10 -0
- data/core/admin/assets/images/icons/new.svg +9 -0
- data/core/admin/assets/images/icons/prompt.svg +11 -0
- data/core/admin/assets/images/icons/refresh.svg +40 -0
- data/core/admin/assets/images/icons/save.svg +7 -0
- data/core/admin/assets/images/poly-small-boxed.svg +51 -0
- data/core/admin/assets/images/poly-small.svg +52 -0
- data/core/admin/assets/images/poly.svg +36 -0
- data/core/admin/assets/js/app/file-ext.js +15 -0
- data/core/admin/assets/js/app/views/editor.js +300 -0
- data/core/admin/assets/js/app/views/git.js +65 -0
- data/core/admin/assets/js/app/views/main.js +59 -0
- data/core/admin/assets/js/main.js +44 -0
- data/core/admin/assets/js/routes.js +25 -0
- data/core/admin/assets/js/vendor/backbone.js +4 -0
- data/core/admin/assets/js/vendor/codemirror/.gitattributes +8 -0
- data/core/admin/assets/js/vendor/codemirror/.gitignore +6 -0
- data/core/admin/assets/js/vendor/codemirror/.travis.yml +3 -0
- data/core/admin/assets/js/vendor/codemirror/addon/comment/comment.js +145 -0
- data/core/admin/assets/js/vendor/codemirror/addon/comment/continuecomment.js +54 -0
- data/core/admin/assets/js/vendor/codemirror/addon/dialog/dialog.css +32 -0
- data/core/admin/assets/js/vendor/codemirror/addon/dialog/dialog.js +80 -0
- data/core/admin/assets/js/vendor/codemirror/addon/display/fullscreen.css +6 -0
- data/core/admin/assets/js/vendor/codemirror/addon/display/fullscreen.js +30 -0
- data/core/admin/assets/js/vendor/codemirror/addon/display/placeholder.js +54 -0
- data/core/admin/assets/js/vendor/codemirror/addon/edit/closebrackets.js +82 -0
- data/core/admin/assets/js/vendor/codemirror/addon/edit/closetag.js +87 -0
- data/core/admin/assets/js/vendor/codemirror/addon/edit/continuelist.js +25 -0
- data/core/admin/assets/js/vendor/codemirror/addon/edit/matchbrackets.js +86 -0
- data/core/admin/assets/js/vendor/codemirror/addon/edit/matchtags.js +56 -0
- data/core/admin/assets/js/vendor/codemirror/addon/edit/trailingspace.js +15 -0
- data/core/admin/assets/js/vendor/codemirror/addon/fold/brace-fold.js +93 -0
- data/core/admin/assets/js/vendor/codemirror/addon/fold/comment-fold.js +40 -0
- data/core/admin/assets/js/vendor/codemirror/addon/fold/foldcode.js +75 -0
- data/core/admin/assets/js/vendor/codemirror/addon/fold/foldgutter.css +21 -0
- data/core/admin/assets/js/vendor/codemirror/addon/fold/foldgutter.js +124 -0
- data/core/admin/assets/js/vendor/codemirror/addon/fold/indent-fold.js +26 -0
- data/core/admin/assets/js/vendor/codemirror/addon/fold/xml-fold.js +167 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/anyword-hint.js +34 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/css-hint.js +50 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/html-hint.js +337 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/javascript-hint.js +130 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/pig-hint.js +121 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/python-hint.js +95 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/show-hint.css +38 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/show-hint.js +274 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/sql-hint.js +105 -0
- data/core/admin/assets/js/vendor/codemirror/addon/hint/xml-hint.js +69 -0
- data/core/admin/assets/js/vendor/codemirror/addon/lint/coffeescript-lint.js +27 -0
- data/core/admin/assets/js/vendor/codemirror/addon/lint/css-lint.js +19 -0
- data/core/admin/assets/js/vendor/codemirror/addon/lint/javascript-lint.js +126 -0
- data/core/admin/assets/js/vendor/codemirror/addon/lint/json-lint.js +17 -0
- data/core/admin/assets/js/vendor/codemirror/addon/lint/lint.css +73 -0
- data/core/admin/assets/js/vendor/codemirror/addon/lint/lint.js +203 -0
- data/core/admin/assets/js/vendor/codemirror/addon/merge/dep/diff_match_patch.js +50 -0
- data/core/admin/assets/js/vendor/codemirror/addon/merge/merge.css +92 -0
- data/core/admin/assets/js/vendor/codemirror/addon/merge/merge.js +474 -0
- data/core/admin/assets/js/vendor/codemirror/addon/mode/loadmode.js +51 -0
- data/core/admin/assets/js/vendor/codemirror/addon/mode/multiplex.js +101 -0
- data/core/admin/assets/js/vendor/codemirror/addon/mode/multiplex_test.js +30 -0
- data/core/admin/assets/js/vendor/codemirror/addon/mode/overlay.js +59 -0
- data/core/admin/assets/js/vendor/codemirror/addon/runmode/colorize.js +29 -0
- data/core/admin/assets/js/vendor/codemirror/addon/runmode/runmode-standalone.js +136 -0
- data/core/admin/assets/js/vendor/codemirror/addon/runmode/runmode.js +56 -0
- data/core/admin/assets/js/vendor/codemirror/addon/runmode/runmode.node.js +103 -0
- data/core/admin/assets/js/vendor/codemirror/addon/scroll/scrollpastend.js +34 -0
- data/core/admin/assets/js/vendor/codemirror/addon/search/match-highlighter.js +91 -0
- data/core/admin/assets/js/vendor/codemirror/addon/search/search.js +133 -0
- data/core/admin/assets/js/vendor/codemirror/addon/search/searchcursor.js +143 -0
- data/core/admin/assets/js/vendor/codemirror/addon/selection/active-line.js +39 -0
- data/core/admin/assets/js/vendor/codemirror/addon/selection/mark-selection.js +108 -0
- data/core/admin/assets/js/vendor/codemirror/addon/tern/tern.css +85 -0
- data/core/admin/assets/js/vendor/codemirror/addon/tern/tern.js +632 -0
- data/core/admin/assets/js/vendor/codemirror/addon/tern/worker.js +41 -0
- data/core/admin/assets/js/vendor/codemirror/addon/wrap/hardwrap.js +99 -0
- data/core/admin/assets/js/vendor/codemirror/bin/authors.sh +6 -0
- data/core/admin/assets/js/vendor/codemirror/bin/compress +92 -0
- data/core/admin/assets/js/vendor/codemirror/bin/lint +16 -0
- data/core/admin/assets/js/vendor/codemirror/bin/source-highlight +61 -0
- data/core/admin/assets/js/vendor/codemirror/bower.json +15 -0
- data/core/admin/assets/js/vendor/codemirror/demo/activeline.html +78 -0
- data/core/admin/assets/js/vendor/codemirror/demo/anywordhint.html +79 -0
- data/core/admin/assets/js/vendor/codemirror/demo/bidi.html +74 -0
- data/core/admin/assets/js/vendor/codemirror/demo/btree.html +86 -0
- data/core/admin/assets/js/vendor/codemirror/demo/buffers.html +109 -0
- data/core/admin/assets/js/vendor/codemirror/demo/changemode.html +59 -0
- data/core/admin/assets/js/vendor/codemirror/demo/closebrackets.html +63 -0
- data/core/admin/assets/js/vendor/codemirror/demo/closetag.html +40 -0
- data/core/admin/assets/js/vendor/codemirror/demo/complete.html +80 -0
- data/core/admin/assets/js/vendor/codemirror/demo/emacs.html +75 -0
- data/core/admin/assets/js/vendor/codemirror/demo/folding.html +75 -0
- data/core/admin/assets/js/vendor/codemirror/demo/fullscreen.html +130 -0
- data/core/admin/assets/js/vendor/codemirror/demo/hardwrap.html +69 -0
- data/core/admin/assets/js/vendor/codemirror/demo/html5complete.html +54 -0
- data/core/admin/assets/js/vendor/codemirror/demo/indentwrap.html +58 -0
- data/core/admin/assets/js/vendor/codemirror/demo/lint.html +171 -0
- data/core/admin/assets/js/vendor/codemirror/demo/loadmode.html +49 -0
- data/core/admin/assets/js/vendor/codemirror/demo/marker.html +52 -0
- data/core/admin/assets/js/vendor/codemirror/demo/markselection.html +45 -0
- data/core/admin/assets/js/vendor/codemirror/demo/matchhighlighter.html +47 -0
- data/core/admin/assets/js/vendor/codemirror/demo/matchtags.html +49 -0
- data/core/admin/assets/js/vendor/codemirror/demo/merge.html +82 -0
- data/core/admin/assets/js/vendor/codemirror/demo/multiplex.html +75 -0
- data/core/admin/assets/js/vendor/codemirror/demo/mustache.html +68 -0
- data/core/admin/assets/js/vendor/codemirror/demo/placeholder.html +45 -0
- data/core/admin/assets/js/vendor/codemirror/demo/preview.html +88 -0
- data/core/admin/assets/js/vendor/codemirror/demo/resize.html +58 -0
- data/core/admin/assets/js/vendor/codemirror/demo/runmode.html +62 -0
- data/core/admin/assets/js/vendor/codemirror/demo/search.html +94 -0
- data/core/admin/assets/js/vendor/codemirror/demo/spanaffectswrapping_shim.html +85 -0
- data/core/admin/assets/js/vendor/codemirror/demo/tern.html +128 -0
- data/core/admin/assets/js/vendor/codemirror/demo/theme.html +121 -0
- data/core/admin/assets/js/vendor/codemirror/demo/trailingspace.html +48 -0
- data/core/admin/assets/js/vendor/codemirror/demo/variableheight.html +61 -0
- data/core/admin/assets/js/vendor/codemirror/demo/vim.html +74 -0
- data/core/admin/assets/js/vendor/codemirror/demo/visibletabs.html +62 -0
- data/core/admin/assets/js/vendor/codemirror/demo/widget.html +85 -0
- data/core/admin/assets/js/vendor/codemirror/demo/xmlcomplete.html +116 -0
- data/core/admin/assets/js/vendor/codemirror/doc/activebookmark.js +42 -0
- data/core/admin/assets/js/vendor/codemirror/doc/compress.html +231 -0
- data/core/admin/assets/js/vendor/codemirror/doc/docs.css +226 -0
- data/core/admin/assets/js/vendor/codemirror/doc/internals.html +503 -0
- data/core/admin/assets/js/vendor/codemirror/doc/logo.png +0 -0
- data/core/admin/assets/js/vendor/codemirror/doc/logo.svg +147 -0
- data/core/admin/assets/js/vendor/codemirror/doc/manual.html +2512 -0
- data/core/admin/assets/js/vendor/codemirror/doc/realworld.html +134 -0
- data/core/admin/assets/js/vendor/codemirror/doc/releases.html +779 -0
- data/core/admin/assets/js/vendor/codemirror/doc/reporting.html +61 -0
- data/core/admin/assets/js/vendor/codemirror/doc/upgrade_v2.2.html +96 -0
- data/core/admin/assets/js/vendor/codemirror/doc/upgrade_v3.html +230 -0
- data/core/admin/assets/js/vendor/codemirror/index.html +192 -0
- data/core/admin/assets/js/vendor/codemirror/keymap/emacs.js +387 -0
- data/core/admin/assets/js/vendor/codemirror/keymap/extra.js +43 -0
- data/core/admin/assets/js/vendor/codemirror/keymap/vim.js +3704 -0
- data/core/admin/assets/js/vendor/codemirror/lib/codemirror.css +263 -0
- data/core/admin/assets/js/vendor/codemirror/lib/codemirror.js +5910 -0
- data/core/admin/assets/js/vendor/codemirror/mode/apl/apl.js +160 -0
- data/core/admin/assets/js/vendor/codemirror/mode/apl/index.html +72 -0
- data/core/admin/assets/js/vendor/codemirror/mode/asterisk/asterisk.js +183 -0
- data/core/admin/assets/js/vendor/codemirror/mode/asterisk/index.html +154 -0
- data/core/admin/assets/js/vendor/codemirror/mode/clike/clike.js +362 -0
- data/core/admin/assets/js/vendor/codemirror/mode/clike/index.html +195 -0
- data/core/admin/assets/js/vendor/codemirror/mode/clike/scala.html +767 -0
- data/core/admin/assets/js/vendor/codemirror/mode/clojure/clojure.js +224 -0
- data/core/admin/assets/js/vendor/codemirror/mode/clojure/index.html +88 -0
- data/core/admin/assets/js/vendor/codemirror/mode/cobol/cobol.js +240 -0
- data/core/admin/assets/js/vendor/codemirror/mode/cobol/index.html +210 -0
- data/core/admin/assets/js/vendor/codemirror/mode/coffeescript/coffeescript.js +349 -0
- data/core/admin/assets/js/vendor/codemirror/mode/coffeescript/index.html +740 -0
- data/core/admin/assets/js/vendor/codemirror/mode/commonlisp/commonlisp.js +105 -0
- data/core/admin/assets/js/vendor/codemirror/mode/commonlisp/index.html +177 -0
- data/core/admin/assets/js/vendor/codemirror/mode/css/css.js +639 -0
- data/core/admin/assets/js/vendor/codemirror/mode/css/index.html +70 -0
- data/core/admin/assets/js/vendor/codemirror/mode/css/scss.html +157 -0
- data/core/admin/assets/js/vendor/codemirror/mode/css/scss_test.js +84 -0
- data/core/admin/assets/js/vendor/codemirror/mode/css/test.js +130 -0
- data/core/admin/assets/js/vendor/codemirror/mode/d/d.js +205 -0
- data/core/admin/assets/js/vendor/codemirror/mode/d/index.html +273 -0
- data/core/admin/assets/js/vendor/codemirror/mode/diff/diff.js +32 -0
- data/core/admin/assets/js/vendor/codemirror/mode/diff/index.html +117 -0
- data/core/admin/assets/js/vendor/codemirror/mode/dtd/dtd.js +127 -0
- data/core/admin/assets/js/vendor/codemirror/mode/dtd/index.html +89 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ecl/ecl.js +192 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ecl/index.html +52 -0
- data/core/admin/assets/js/vendor/codemirror/mode/eiffel/eiffel.js +147 -0
- data/core/admin/assets/js/vendor/codemirror/mode/eiffel/index.html +430 -0
- data/core/admin/assets/js/vendor/codemirror/mode/erlang/erlang.js +484 -0
- data/core/admin/assets/js/vendor/codemirror/mode/erlang/index.html +75 -0
- data/core/admin/assets/js/vendor/codemirror/mode/fortran/fortran.js +173 -0
- data/core/admin/assets/js/vendor/codemirror/mode/fortran/index.html +81 -0
- data/core/admin/assets/js/vendor/codemirror/mode/gas/gas.js +330 -0
- data/core/admin/assets/js/vendor/codemirror/mode/gas/index.html +68 -0
- data/core/admin/assets/js/vendor/codemirror/mode/gfm/gfm.js +97 -0
- data/core/admin/assets/js/vendor/codemirror/mode/gfm/index.html +82 -0
- data/core/admin/assets/js/vendor/codemirror/mode/gfm/test.js +112 -0
- data/core/admin/assets/js/vendor/codemirror/mode/gherkin/gherkin.js +168 -0
- data/core/admin/assets/js/vendor/codemirror/mode/gherkin/index.html +48 -0
- data/core/admin/assets/js/vendor/codemirror/mode/go/go.js +168 -0
- data/core/admin/assets/js/vendor/codemirror/mode/go/index.html +85 -0
- data/core/admin/assets/js/vendor/codemirror/mode/groovy/groovy.js +211 -0
- data/core/admin/assets/js/vendor/codemirror/mode/groovy/index.html +84 -0
- data/core/admin/assets/js/vendor/codemirror/mode/haml/haml.js +153 -0
- data/core/admin/assets/js/vendor/codemirror/mode/haml/index.html +79 -0
- data/core/admin/assets/js/vendor/codemirror/mode/haml/test.js +94 -0
- data/core/admin/assets/js/vendor/codemirror/mode/haskell/haskell.js +250 -0
- data/core/admin/assets/js/vendor/codemirror/mode/haskell/index.html +73 -0
- data/core/admin/assets/js/vendor/codemirror/mode/haxe/haxe.js +429 -0
- data/core/admin/assets/js/vendor/codemirror/mode/haxe/index.html +103 -0
- data/core/admin/assets/js/vendor/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/core/admin/assets/js/vendor/codemirror/mode/htmlembedded/index.html +60 -0
- data/core/admin/assets/js/vendor/codemirror/mode/htmlmixed/htmlmixed.js +104 -0
- data/core/admin/assets/js/vendor/codemirror/mode/htmlmixed/index.html +85 -0
- data/core/admin/assets/js/vendor/codemirror/mode/http/http.js +98 -0
- data/core/admin/assets/js/vendor/codemirror/mode/http/index.html +45 -0
- data/core/admin/assets/js/vendor/codemirror/mode/index.html +112 -0
- data/core/admin/assets/js/vendor/codemirror/mode/jade/index.html +66 -0
- data/core/admin/assets/js/vendor/codemirror/mode/jade/jade.js +90 -0
- data/core/admin/assets/js/vendor/codemirror/mode/javascript/index.html +107 -0
- data/core/admin/assets/js/vendor/codemirror/mode/javascript/javascript.js +480 -0
- data/core/admin/assets/js/vendor/codemirror/mode/javascript/test.js +10 -0
- data/core/admin/assets/js/vendor/codemirror/mode/javascript/typescript.html +61 -0
- data/core/admin/assets/js/vendor/codemirror/mode/jinja2/index.html +50 -0
- data/core/admin/assets/js/vendor/codemirror/mode/jinja2/jinja2.js +42 -0
- data/core/admin/assets/js/vendor/codemirror/mode/less/index.html +753 -0
- data/core/admin/assets/js/vendor/codemirror/mode/less/less.js +344 -0
- data/core/admin/assets/js/vendor/codemirror/mode/livescript/index.html +459 -0
- data/core/admin/assets/js/vendor/codemirror/mode/livescript/livescript.js +267 -0
- data/core/admin/assets/js/vendor/codemirror/mode/livescript/livescript.ls +266 -0
- data/core/admin/assets/js/vendor/codemirror/mode/lua/index.html +86 -0
- data/core/admin/assets/js/vendor/codemirror/mode/lua/lua.js +144 -0
- data/core/admin/assets/js/vendor/codemirror/mode/markdown/index.html +359 -0
- data/core/admin/assets/js/vendor/codemirror/mode/markdown/markdown.js +551 -0
- data/core/admin/assets/js/vendor/codemirror/mode/markdown/test.js +656 -0
- data/core/admin/assets/js/vendor/codemirror/mode/meta.js +89 -0
- data/core/admin/assets/js/vendor/codemirror/mode/mirc/index.html +161 -0
- data/core/admin/assets/js/vendor/codemirror/mode/mirc/mirc.js +177 -0
- data/core/admin/assets/js/vendor/codemirror/mode/nginx/index.html +181 -0
- data/core/admin/assets/js/vendor/codemirror/mode/nginx/nginx.js +163 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ntriples/index.html +45 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ntriples/ntriples.js +170 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ocaml/index.html +146 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ocaml/ocaml.js +116 -0
- data/core/admin/assets/js/vendor/codemirror/mode/octave/index.html +95 -0
- data/core/admin/assets/js/vendor/codemirror/mode/octave/octave.js +118 -0
- data/core/admin/assets/js/vendor/codemirror/mode/pascal/index.html +61 -0
- data/core/admin/assets/js/vendor/codemirror/mode/pascal/pascal.js +94 -0
- data/core/admin/assets/js/vendor/codemirror/mode/perl/index.html +75 -0
- data/core/admin/assets/js/vendor/codemirror/mode/perl/perl.js +816 -0
- data/core/admin/assets/js/vendor/codemirror/mode/php/index.html +62 -0
- data/core/admin/assets/js/vendor/codemirror/mode/php/php.js +132 -0
- data/core/admin/assets/js/vendor/codemirror/mode/pig/index.html +55 -0
- data/core/admin/assets/js/vendor/codemirror/mode/pig/pig.js +171 -0
- data/core/admin/assets/js/vendor/codemirror/mode/properties/index.html +53 -0
- data/core/admin/assets/js/vendor/codemirror/mode/properties/properties.js +63 -0
- data/core/admin/assets/js/vendor/codemirror/mode/python/index.html +187 -0
- data/core/admin/assets/js/vendor/codemirror/mode/python/python.js +368 -0
- data/core/admin/assets/js/vendor/codemirror/mode/q/index.html +144 -0
- data/core/admin/assets/js/vendor/codemirror/mode/q/q.js +124 -0
- data/core/admin/assets/js/vendor/codemirror/mode/r/index.html +86 -0
- data/core/admin/assets/js/vendor/codemirror/mode/r/r.js +141 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rpm/changes/changes.js +19 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rpm/changes/index.html +67 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rpm/spec/index.html +114 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rpm/spec/spec.css +5 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rpm/spec/spec.js +66 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rst/index.html +534 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rst/rst.js +560 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ruby/index.html +185 -0
- data/core/admin/assets/js/vendor/codemirror/mode/ruby/ruby.js +247 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rust/index.html +61 -0
- data/core/admin/assets/js/vendor/codemirror/mode/rust/rust.js +436 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sass/index.html +66 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sass/sass.js +330 -0
- data/core/admin/assets/js/vendor/codemirror/mode/scheme/index.html +77 -0
- data/core/admin/assets/js/vendor/codemirror/mode/scheme/scheme.js +232 -0
- data/core/admin/assets/js/vendor/codemirror/mode/shell/index.html +66 -0
- data/core/admin/assets/js/vendor/codemirror/mode/shell/shell.js +118 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sieve/index.html +93 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sieve/sieve.js +183 -0
- data/core/admin/assets/js/vendor/codemirror/mode/smalltalk/index.html +68 -0
- data/core/admin/assets/js/vendor/codemirror/mode/smalltalk/smalltalk.js +151 -0
- data/core/admin/assets/js/vendor/codemirror/mode/smarty/index.html +136 -0
- data/core/admin/assets/js/vendor/codemirror/mode/smarty/smarty.js +205 -0
- data/core/admin/assets/js/vendor/codemirror/mode/smartymixed/index.html +114 -0
- data/core/admin/assets/js/vendor/codemirror/mode/smartymixed/smartymixed.js +175 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sparql/index.html +54 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sparql/sparql.js +145 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sql/index.html +75 -0
- data/core/admin/assets/js/vendor/codemirror/mode/sql/sql.js +365 -0
- data/core/admin/assets/js/vendor/codemirror/mode/stex/index.html +110 -0
- data/core/admin/assets/js/vendor/codemirror/mode/stex/stex.js +246 -0
- data/core/admin/assets/js/vendor/codemirror/mode/stex/test.js +120 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tcl/index.html +143 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tcl/tcl.js +131 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tiddlywiki/index.html +155 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tiki/index.html +95 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tiki/tiki.css +26 -0
- data/core/admin/assets/js/vendor/codemirror/mode/tiki/tiki.js +308 -0
- data/core/admin/assets/js/vendor/codemirror/mode/toml/index.html +73 -0
- data/core/admin/assets/js/vendor/codemirror/mode/toml/toml.js +71 -0
- data/core/admin/assets/js/vendor/codemirror/mode/turtle/index.html +51 -0
- data/core/admin/assets/js/vendor/codemirror/mode/turtle/turtle.js +145 -0
- data/core/admin/assets/js/vendor/codemirror/mode/vb/index.html +103 -0
- data/core/admin/assets/js/vendor/codemirror/mode/vb/vb.js +259 -0
- data/core/admin/assets/js/vendor/codemirror/mode/vbscript/index.html +55 -0
- data/core/admin/assets/js/vendor/codemirror/mode/vbscript/vbscript.js +334 -0
- data/core/admin/assets/js/vendor/codemirror/mode/velocity/index.html +119 -0
- data/core/admin/assets/js/vendor/codemirror/mode/velocity/velocity.js +186 -0
- data/core/admin/assets/js/vendor/codemirror/mode/verilog/index.html +132 -0
- data/core/admin/assets/js/vendor/codemirror/mode/verilog/verilog.js +182 -0
- data/core/admin/assets/js/vendor/codemirror/mode/xml/index.html +57 -0
- data/core/admin/assets/js/vendor/codemirror/mode/xml/xml.js +345 -0
- data/core/admin/assets/js/vendor/codemirror/mode/xquery/index.html +210 -0
- data/core/admin/assets/js/vendor/codemirror/mode/xquery/test.js +64 -0
- data/core/admin/assets/js/vendor/codemirror/mode/xquery/xquery.js +432 -0
- data/core/admin/assets/js/vendor/codemirror/mode/yaml/index.html +80 -0
- data/core/admin/assets/js/vendor/codemirror/mode/yaml/yaml.js +97 -0
- data/core/admin/assets/js/vendor/codemirror/mode/z80/index.html +52 -0
- data/core/admin/assets/js/vendor/codemirror/mode/z80/z80.js +85 -0
- data/core/admin/assets/js/vendor/codemirror/package.json +19 -0
- data/core/admin/assets/js/vendor/codemirror/test/comment_test.js +51 -0
- data/core/admin/assets/js/vendor/codemirror/test/doc_test.js +329 -0
- data/core/admin/assets/js/vendor/codemirror/test/driver.js +139 -0
- data/core/admin/assets/js/vendor/codemirror/test/emacs_test.js +135 -0
- data/core/admin/assets/js/vendor/codemirror/test/index.html +209 -0
- data/core/admin/assets/js/vendor/codemirror/test/lint/acorn.js +1593 -0
- data/core/admin/assets/js/vendor/codemirror/test/lint/lint.js +139 -0
- data/core/admin/assets/js/vendor/codemirror/test/lint/walk.js +216 -0
- data/core/admin/assets/js/vendor/codemirror/test/mode_test.css +10 -0
- data/core/admin/assets/js/vendor/codemirror/test/mode_test.js +200 -0
- data/core/admin/assets/js/vendor/codemirror/test/phantom_driver.js +31 -0
- data/core/admin/assets/js/vendor/codemirror/test/run.js +34 -0
- data/core/admin/assets/js/vendor/codemirror/test/test.js +1562 -0
- data/core/admin/assets/js/vendor/codemirror/test/vim_test.js +2391 -0
- data/core/admin/assets/js/vendor/codemirror/theme/3024-day.css +34 -0
- data/core/admin/assets/js/vendor/codemirror/theme/3024-night.css +34 -0
- data/core/admin/assets/js/vendor/codemirror/theme/ambiance-mobile.css +5 -0
- data/core/admin/assets/js/vendor/codemirror/theme/ambiance.css +75 -0
- data/core/admin/assets/js/vendor/codemirror/theme/base16-dark.css +34 -0
- data/core/admin/assets/js/vendor/codemirror/theme/base16-light.css +34 -0
- data/core/admin/assets/js/vendor/codemirror/theme/blackboard.css +28 -0
- data/core/admin/assets/js/vendor/codemirror/theme/cobalt.css +21 -0
- data/core/admin/assets/js/vendor/codemirror/theme/eclipse.css +23 -0
- data/core/admin/assets/js/vendor/codemirror/theme/elegant.css +13 -0
- data/core/admin/assets/js/vendor/codemirror/theme/erlang-dark.css +30 -0
- data/core/admin/assets/js/vendor/codemirror/theme/lesser-dark.css +47 -0
- data/core/admin/assets/js/vendor/codemirror/theme/mbo.css +35 -0
- data/core/admin/assets/js/vendor/codemirror/theme/midnight.css +43 -0
- data/core/admin/assets/js/vendor/codemirror/theme/monokai.css +29 -0
- data/core/admin/assets/js/vendor/codemirror/theme/neat.css +12 -0
- data/core/admin/assets/js/vendor/codemirror/theme/night.css +24 -0
- data/core/admin/assets/js/vendor/codemirror/theme/paraiso-dark.css +34 -0
- data/core/admin/assets/js/vendor/codemirror/theme/paraiso-light.css +34 -0
- data/core/admin/assets/js/vendor/codemirror/theme/rubyblue.css +23 -0
- data/core/admin/assets/js/vendor/codemirror/theme/solarized-mod.css +181 -0
- data/core/admin/assets/js/vendor/codemirror/theme/solarized.css +180 -0
- data/core/admin/assets/js/vendor/codemirror/theme/the-matrix.css +26 -0
- data/core/admin/assets/js/vendor/codemirror/theme/tomorrow-night-eighties.css +34 -0
- data/core/admin/assets/js/vendor/codemirror/theme/twilight.css +28 -0
- data/core/admin/assets/js/vendor/codemirror/theme/vibrant-ink.css +30 -0
- data/core/admin/assets/js/vendor/codemirror/theme/xq-dark.css +49 -0
- data/core/admin/assets/js/vendor/codemirror/theme/xq-light.css +43 -0
- data/core/admin/assets/js/vendor/fastclick.js +777 -0
- data/core/admin/assets/js/vendor/jquery.js +6 -0
- data/core/admin/assets/js/vendor/lodash.underscore.js +38 -0
- data/core/admin/assets/js/vendor/require.js +36 -0
- data/core/admin/assets/scss/bootstrap.scss +18 -0
- data/core/admin/assets/scss/modules/_all.scss +7 -0
- data/core/admin/assets/scss/modules/_colors.scss +7 -0
- data/core/admin/assets/scss/modules/_extensions.scss +24 -0
- data/core/admin/assets/scss/modules/_mixins.scss +18 -0
- data/core/admin/assets/scss/modules/_susy.scss +7 -0
- data/core/admin/assets/scss/partials/_base.scss +33 -0
- data/core/admin/assets/scss/partials/_buttons.scss +9 -0
- data/core/admin/assets/scss/partials/_links.scss +15 -0
- data/core/admin/assets/scss/partials/_main.scss +14 -0
- data/core/admin/assets/scss/partials/_typography.scss +15 -0
- data/core/admin/assets/scss/sections/_editor.scss +274 -0
- data/core/admin/assets/scss/sections/_login.scss +34 -0
- data/core/admin/assets/scss/vendor/_normalize.scss +406 -0
- data/core/admin/layouts/admin.haml +67 -0
- data/core/admin/partials/_head.haml +23 -0
- data/core/admin/partials/_tree.haml +3 -0
- data/core/admin/partials/_treeitem.haml +4 -0
- data/core/admin/settings.yml +4 -0
- data/core/app.rb +21 -0
- data/core/classes/cached.rb +35 -0
- data/core/classes/checker.rb +37 -0
- data/core/classes/commit.rb +62 -0
- data/core/classes/error.rb +9 -0
- data/core/classes/page.rb +165 -0
- data/core/classes/partial.rb +13 -0
- data/core/classes/path.rb +30 -0
- data/core/classes/persona.rb +55 -0
- data/core/classes/sassfile.rb +95 -0
- data/core/classes/settings.rb +19 -0
- data/core/classes/theme.rb +55 -0
- data/core/helpers/base.rb +46 -0
- data/core/helpers/render.rb +26 -0
- data/core/helpers/truncate.rb +17 -0
- data/core/routes/admin.rb +139 -0
- data/core/routes/assetcompiler.rb +23 -0
- data/core/routes/base.rb +22 -0
- data/core/routes/bootstrap.rb +35 -0
- data/core/routes/cache.rb +52 -0
- data/core/routes/deploy.rb +16 -0
- data/core/routes/git.rb +23 -0
- data/poly.gemspec +29 -0
- data/sample/.cabi-data +0 -0
- data/sample/data/home/index.haml +22 -0
- data/sample/data/other/nav/links.yml +4 -0
- data/sample/data/page/about/index.haml +12 -0
- data/sample/data/page/contact-us/index.haml +11 -0
- data/sample/data/page/dynamic-page/index.haml +14 -0
- data/sample/data/page/error/index.haml +8 -0
- data/sample/data/page/html/index.html +4 -0
- data/sample/data/page/no-front-matter/index.haml +7 -0
- data/sample/data/page/not-found/index.haml +8 -0
- data/sample/data/page/static-page/index.haml +14 -0
- data/sample/data/post/about-life/index.md +12 -0
- data/sample/data/post/sample-post/index.haml +12 -0
- data/sample/data/post/technology/index.haml +12 -0
- data/sample/data/post/the-40-hour-workweek/index.haml +9 -0
- data/sample/data/post/things-are-changing/index.haml +9 -0
- data/sample/data/post/yet-another-post/index.haml +11 -0
- data/sample/plugins/my-plugin/plugin.rb +15 -0
- data/sample/settings.yml +21 -0
- data/sample/themes/base/assets/css/readme.txt +6 -0
- data/sample/themes/base/assets/images/poly.svg +36 -0
- data/sample/themes/base/assets/js/app/views/main.js +13 -0
- data/sample/themes/base/assets/js/main.js +31 -0
- data/sample/themes/base/assets/js/vendor/backbone.js +4 -0
- data/sample/themes/base/assets/js/vendor/jquery.js +6 -0
- data/sample/themes/base/assets/js/vendor/lodash.underscore.js +38 -0
- data/sample/themes/base/assets/js/vendor/require.js +36 -0
- data/sample/themes/base/assets/scss/bootstrap.scss +20 -0
- data/sample/themes/base/assets/scss/modules/_all.scss +7 -0
- data/sample/themes/base/assets/scss/modules/_colors.scss +7 -0
- data/sample/themes/base/assets/scss/modules/_extensions.scss +13 -0
- data/sample/themes/base/assets/scss/modules/_mixins.scss +11 -0
- data/sample/themes/base/assets/scss/modules/_susy.scss +7 -0
- data/sample/themes/base/assets/scss/partials/_base.scss +33 -0
- data/sample/themes/base/assets/scss/partials/_buttons.scss +0 -0
- data/sample/themes/base/assets/scss/partials/_links.scss +15 -0
- data/sample/themes/base/assets/scss/partials/_main.scss +39 -0
- data/sample/themes/base/assets/scss/partials/_typography.scss +15 -0
- data/sample/themes/base/assets/scss/sections/_footer.scss +22 -0
- data/sample/themes/base/assets/scss/sections/_header.scss +23 -0
- data/sample/themes/base/assets/scss/sections/_home.scss +13 -0
- data/sample/themes/base/assets/scss/sections/_pages.scss +11 -0
- data/sample/themes/base/assets/scss/vendor/_normalize.scss +406 -0
- data/sample/themes/base/layouts/default.haml +14 -0
- data/sample/themes/base/layouts/post.haml +15 -0
- data/sample/themes/base/partials/_footer.haml +9 -0
- data/sample/themes/base/partials/_ga.haml +10 -0
- data/sample/themes/base/partials/_head.haml +20 -0
- data/sample/themes/base/partials/_header.haml +5 -0
- data/sample/themes/base/settings.yml +4 -0
- data/test/data/post-receive-hook.json +146 -0
- data/test/test_basics.rb +50 -0
- data/test/test_data.rb +14 -0
- data/test/test_deploy.rb +23 -0
- data/test/test_includes.rb +43 -0
- data/test/test_page.rb +47 -0
- metadata +1049 -0
Binary file
|
@@ -0,0 +1,147 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="744.09448819"
|
13
|
+
height="1052.3622047"
|
14
|
+
id="svg2"
|
15
|
+
version="1.1"
|
16
|
+
inkscape:version="0.48.4 r9939"
|
17
|
+
inkscape:export-filename="/home/marijn/src/js/codemirror/doc/logo.png"
|
18
|
+
inkscape:export-xdpi="27.450405"
|
19
|
+
inkscape:export-ydpi="27.450405"
|
20
|
+
sodipodi:docname="logo.svg">
|
21
|
+
<defs
|
22
|
+
id="defs4">
|
23
|
+
<clipPath
|
24
|
+
clipPathUnits="userSpaceOnUse"
|
25
|
+
id="clipPath4138">
|
26
|
+
<path
|
27
|
+
transform="matrix(1.05,0,0,1,-290.76164,27.927128)"
|
28
|
+
d="m 705.08647,231.61324 a 70.710678,104.55079 0 1 1 -141.42135,0 70.710678,104.55079 0 1 1 141.42135,0 z"
|
29
|
+
sodipodi:ry="104.55079"
|
30
|
+
sodipodi:rx="70.710678"
|
31
|
+
sodipodi:cy="231.61324"
|
32
|
+
sodipodi:cx="634.37579"
|
33
|
+
id="path4140"
|
34
|
+
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
35
|
+
sodipodi:type="arc" />
|
36
|
+
</clipPath>
|
37
|
+
</defs>
|
38
|
+
<sodipodi:namedview
|
39
|
+
id="base"
|
40
|
+
pagecolor="#ffffff"
|
41
|
+
bordercolor="#666666"
|
42
|
+
borderopacity="1.0"
|
43
|
+
inkscape:pageopacity="0.0"
|
44
|
+
inkscape:pageshadow="2"
|
45
|
+
inkscape:zoom="1.4"
|
46
|
+
inkscape:cx="291.72812"
|
47
|
+
inkscape:cy="789.2497"
|
48
|
+
inkscape:document-units="px"
|
49
|
+
inkscape:current-layer="layer1"
|
50
|
+
showgrid="false"
|
51
|
+
inkscape:window-width="1600"
|
52
|
+
inkscape:window-height="875"
|
53
|
+
inkscape:window-x="0"
|
54
|
+
inkscape:window-y="25"
|
55
|
+
inkscape:window-maximized="0" />
|
56
|
+
<metadata
|
57
|
+
id="metadata7">
|
58
|
+
<rdf:RDF>
|
59
|
+
<cc:Work
|
60
|
+
rdf:about="">
|
61
|
+
<dc:format>image/svg+xml</dc:format>
|
62
|
+
<dc:type
|
63
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
64
|
+
<dc:title></dc:title>
|
65
|
+
</cc:Work>
|
66
|
+
</rdf:RDF>
|
67
|
+
</metadata>
|
68
|
+
<g
|
69
|
+
inkscape:label="Layer 1"
|
70
|
+
inkscape:groupmode="layer"
|
71
|
+
id="layer1">
|
72
|
+
<text
|
73
|
+
xml:space="preserve"
|
74
|
+
style="font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#a21313;fill-opacity:1;stroke:none;font-family:Ubuntu Mono;-inkscape-font-specification:Ubuntu Mono"
|
75
|
+
x="247.48738"
|
76
|
+
y="163.42795"
|
77
|
+
id="text4006"
|
78
|
+
sodipodi:linespacing="125%"
|
79
|
+
clip-path="url(#clipPath4138)"
|
80
|
+
transform="translate(0.50507287,0.50507595)"><tspan
|
81
|
+
sodipodi:role="line"
|
82
|
+
id="tspan4008"
|
83
|
+
x="247.48738"
|
84
|
+
y="163.42795"> if (unit == "char") moveOnce();</tspan><tspan
|
85
|
+
sodipodi:role="line"
|
86
|
+
x="247.48738"
|
87
|
+
y="182.17795"
|
88
|
+
id="tspan4010"> else if (unit == "column") moveOnce(true);</tspan><tspan
|
89
|
+
sodipodi:role="line"
|
90
|
+
x="247.48738"
|
91
|
+
y="200.92795"
|
92
|
+
id="tspan4012"> else if (unit == "word" || unit == "group") {</tspan><tspan
|
93
|
+
sodipodi:role="line"
|
94
|
+
x="247.48738"
|
95
|
+
y="219.67795"
|
96
|
+
id="tspan4014"> var sawType = null, group = unit == "group";</tspan><tspan
|
97
|
+
sodipodi:role="line"
|
98
|
+
x="247.48738"
|
99
|
+
y="238.42795"
|
100
|
+
id="tspan4016"> for (var first = true;; first = false) {</tspan><tspan
|
101
|
+
sodipodi:role="line"
|
102
|
+
x="247.48738"
|
103
|
+
y="257.17795"
|
104
|
+
id="tspan4018"> if (dir < 0 && !moveOnce(!first)) break;</tspan><tspan
|
105
|
+
sodipodi:role="line"
|
106
|
+
x="247.48738"
|
107
|
+
y="275.92795"
|
108
|
+
id="tspan4020"> var cur = lineObj.text.charAt(ch) || "\n";</tspan><tspan
|
109
|
+
sodipodi:role="line"
|
110
|
+
x="247.48738"
|
111
|
+
y="294.67795"
|
112
|
+
id="tspan4022"> var type = isWordChar(cur) ? "w"</tspan><tspan
|
113
|
+
sodipodi:role="line"
|
114
|
+
x="247.48738"
|
115
|
+
y="313.42795"
|
116
|
+
id="tspan4024"> : !group ? null</tspan><tspan
|
117
|
+
sodipodi:role="line"
|
118
|
+
x="247.48738"
|
119
|
+
y="332.17795"
|
120
|
+
id="tspan4026"> : /\s/.test(cur) ? null</tspan><tspan
|
121
|
+
sodipodi:role="line"
|
122
|
+
x="247.48738"
|
123
|
+
y="350.92795"
|
124
|
+
id="tspan4028"> : "p"; // punctuation</tspan><tspan
|
125
|
+
sodipodi:role="line"
|
126
|
+
x="247.48738"
|
127
|
+
y="369.67795"
|
128
|
+
id="tspan4046"> if (sawType && sawType</tspan></text>
|
129
|
+
<path
|
130
|
+
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"
|
131
|
+
d="M 374.84375 136.8125 C 371.96854 136.71001 368.64305 137.97919 365.15625 142.03125 C 361.97051 140.84608 359.22347 140.35622 356.84375 140.375 C 346.53162 140.4564 343.3125 149.71875 343.3125 149.71875 C 326.2234 146.67934 325.625 162.59375 325.625 162.59375 C 309.43195 163.37101 312.4375 177.375 312.4375 177.375 C 295.67899 180.15651 301.1875 194 301.1875 194 C 284.10838 199.04575 293.4375 212.46875 293.4375 212.46875 C 293.4375 212.46875 277.68174 220.31271 288.1875 232.25 C 288.1875 232.25 273.81776 243.63282 285.90625 253.34375 C 285.90625 253.34375 271.57897 263.97487 286.40625 275.03125 C 286.40625 275.03125 273.84147 285.48036 289.96875 295.3125 C 289.96875 295.3125 278.92374 306.07108 295.59375 314.65625 C 295.59375 314.65625 287.70844 329.01862 305.96875 335.125 C 305.96875 335.125 300.47495 348.88874 319.09375 351.46875 C 319.09375 351.46875 315.90162 357.19564 321.59375 361.15625 C 321.59375 361.15625 310.04416 364.78661 312.5625 374.40625 C 313.83361 379.26171 316.82684 380.49158 323.53125 380.1875 C 323.53125 380.1875 329.096 395.54812 350.46875 398.96875 L 353.125 402.59375 C 353.125 402.59375 342.80592 409.64088 359.125 421.5 C 359.125 421.5 354.16126 425.74314 363.28125 433.34375 C 363.28125 433.34375 357.54117 438.3362 365.75 442.625 C 365.75 442.625 361.35822 445.96166 366.09375 448.125 C 366.09375 448.125 370.88293 490.18262 355.40625 534.4375 C 355.40625 534.4375 341.28721 542.04782 350.1875 556.96875 C 350.1875 556.96875 331.59675 562.24093 345.09375 575.53125 C 345.09375 575.53125 342.0547 585.56155 349.375 585.78125 C 349.375 585.78125 346.16048 592.54552 354.4375 594.5625 C 354.4375 594.5625 353.17883 603.88113 364.09375 602.1875 C 369.44813 608.40994 378.92733 608.70518 385.21875 602.34375 C 396.13361 604.03738 394.875 594.71875 394.875 594.71875 C 403.15197 592.70177 399.9375 585.9375 399.9375 585.9375 C 407.25781 585.7178 404.21875 575.6875 404.21875 575.6875 C 417.71573 562.39718 399.125 557.09375 399.125 557.09375 C 408.0253 542.17282 393.90625 534.5625 393.90625 534.5625 C 378.42953 490.30762 383.21875 448.28125 383.21875 448.28125 C 387.95421 446.11791 383.5625 442.78125 383.5625 442.78125 C 391.77129 438.49245 386.03125 433.5 386.03125 433.5 C 395.15125 425.89939 390.1875 421.65625 390.1875 421.65625 C 406.5066 409.79713 396.1875 402.75 396.1875 402.75 L 398.84375 399.125 C 420.21649 395.70437 425.78125 380.34375 425.78125 380.34375 C 432.48566 380.64783 435.47889 379.41796 436.75 374.5625 C 439.26834 364.94286 427.75 361.3125 427.75 361.3125 C 433.44213 357.35188 430.21875 351.59375 430.21875 351.59375 C 448.83755 349.01373 443.34375 335.28125 443.34375 335.28125 C 461.60406 329.17487 453.71875 314.78125 453.71875 314.78125 C 470.38876 306.19608 459.34375 295.46875 459.34375 295.46875 C 475.47103 285.63661 462.90625 275.1875 462.90625 275.1875 C 477.73353 264.13112 463.40625 253.5 463.40625 253.5 C 475.49474 243.78907 461.15625 232.375 461.15625 232.375 C 471.66201 220.43771 455.875 212.625 455.875 212.625 C 455.875 212.625 465.20411 199.202 448.125 194.15625 C 448.125 194.15625 453.66476 180.31276 436.90625 177.53125 C 436.90625 177.53125 439.88054 163.52726 423.6875 162.75 C 423.6875 162.75 423.0891 146.8356 406 149.875 C 406 149.875 401.14687 135.83532 384.15625 142.15625 C 384.15625 142.15625 380.33279 137.00815 374.84375 136.8125 z M 375.34375 155 C 416.3488 155 449.59375 201.78944 449.59375 259.53125 C 449.59375 317.27306 416.3488 364.09375 375.34375 364.09375 C 334.3387 364.09375 301.09375 317.27306 301.09375 259.53125 C 301.09375 201.78944 334.3387 155 375.34375 155 z "
|
132
|
+
id="rect3058" />
|
133
|
+
<text
|
134
|
+
sodipodi:linespacing="125%"
|
135
|
+
id="text4207"
|
136
|
+
y="491.91403"
|
137
|
+
x="149.69542"
|
138
|
+
style="font-size:95px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#a21313;fill-opacity:1;stroke:none;font-family:Source Sans;-inkscape-font-specification:Source Sans"
|
139
|
+
xml:space="preserve"
|
140
|
+
inkscape:export-xdpi="90"
|
141
|
+
inkscape:export-ydpi="90"><tspan
|
142
|
+
y="491.91403"
|
143
|
+
x="149.69542"
|
144
|
+
id="tspan4209"
|
145
|
+
sodipodi:role="line">Code Mirror</tspan></text>
|
146
|
+
</g>
|
147
|
+
</svg>
|
@@ -0,0 +1,2512 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
|
3
|
+
<title>CodeMirror: User Manual</title>
|
4
|
+
<meta charset="utf-8"/>
|
5
|
+
<link rel=stylesheet href="docs.css">
|
6
|
+
<script src="activebookmark.js"></script>
|
7
|
+
|
8
|
+
<script src="../lib/codemirror.js"></script>
|
9
|
+
<link rel="stylesheet" href="../lib/codemirror.css">
|
10
|
+
<script src="../addon/runmode/runmode.js"></script>
|
11
|
+
<script src="../addon/runmode/colorize.js"></script>
|
12
|
+
<script src="../mode/javascript/javascript.js"></script>
|
13
|
+
<script src="../mode/xml/xml.js"></script>
|
14
|
+
<script src="../mode/css/css.js"></script>
|
15
|
+
<script src="../mode/htmlmixed/htmlmixed.js"></script>
|
16
|
+
<style>
|
17
|
+
dt { text-indent: -2em; padding-left: 2em; margin-top: 1em; }
|
18
|
+
dd { margin-left: 1.5em; margin-bottom: 1em; }
|
19
|
+
dt {margin-top: 1em;}
|
20
|
+
dd dl, dd dt, dd dd, dd ul { margin-top: 0; margin-bottom: 0; }
|
21
|
+
</style>
|
22
|
+
|
23
|
+
<div id=nav>
|
24
|
+
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
|
25
|
+
|
26
|
+
<ul>
|
27
|
+
<li><a href="../index.html">Home</a>
|
28
|
+
<li><a href="#overview" class=active data-default="true">Manual</a>
|
29
|
+
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
30
|
+
</ul>
|
31
|
+
<ul>
|
32
|
+
<li><a href="#usage">Basic Usage</a></li>
|
33
|
+
<li><a href="#config">Configuration</a></li>
|
34
|
+
<li><a href="#events">Events</a></li>
|
35
|
+
<li><a href="#keymaps">Keymaps</a></li>
|
36
|
+
<li><a href="#styling">Customized Styling</a></li>
|
37
|
+
<li><a href="#api">Programming API</a>
|
38
|
+
<ul>
|
39
|
+
<li><a href="#api_constructor">Constructor</a></li>
|
40
|
+
<li><a href="#api_content">Content manipulation</a></li>
|
41
|
+
<li><a href="#api_selection">Selection</a></li>
|
42
|
+
<li><a href="#api_configuration">Configuration</a></li>
|
43
|
+
<li><a href="#api_doc">Document management</a></li>
|
44
|
+
<li><a href="#api_history">History</a></li>
|
45
|
+
<li><a href="#api_marker">Text-marking</a></li>
|
46
|
+
<li><a href="#api_decoration">Widget, gutter, and decoration</a></li>
|
47
|
+
<li><a href="#api_sizing">Sizing, scrolling, and positioning</a></li>
|
48
|
+
<li><a href="#api_mode">Mode, state, and tokens</a></li>
|
49
|
+
<li><a href="#api_misc">Miscellaneous methods</a></li>
|
50
|
+
<li><a href="#api_static">Static properties</a></li>
|
51
|
+
</ul>
|
52
|
+
</li>
|
53
|
+
<li><a href="#addons">Addons</a></li>
|
54
|
+
<li><a href="#modeapi">Writing CodeMirror Modes</a></li>
|
55
|
+
</ul>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<article>
|
59
|
+
|
60
|
+
<section class=first id=overview>
|
61
|
+
<h2>User manual and reference guide</h2>
|
62
|
+
|
63
|
+
<p>CodeMirror is a code-editor component that can be embedded in
|
64
|
+
Web pages. The core library provides <em>only</em> the editor
|
65
|
+
component, no accompanying buttons, auto-completion, or other IDE
|
66
|
+
functionality. It does provide a rich API on top of which such
|
67
|
+
functionality can be straightforwardly implemented. See
|
68
|
+
the <a href="#addons">addons</a> included in the distribution,
|
69
|
+
and the <a href="https://github.com/marijnh/CodeMirror/wiki/CodeMirror-addons">list
|
70
|
+
of externally hosted addons</a>, for reusable
|
71
|
+
implementations of extra features.</p>
|
72
|
+
|
73
|
+
<p>CodeMirror works with language-specific modes. Modes are
|
74
|
+
JavaScript programs that help color (and optionally indent) text
|
75
|
+
written in a given language. The distribution comes with a number
|
76
|
+
of modes (see the <a href="../mode/"><code>mode/</code></a>
|
77
|
+
directory), and it isn't hard to <a href="#modeapi">write new
|
78
|
+
ones</a> for other languages.</p>
|
79
|
+
</section>
|
80
|
+
|
81
|
+
<section id=usage>
|
82
|
+
<h2>Basic Usage</h2>
|
83
|
+
|
84
|
+
<p>The easiest way to use CodeMirror is to simply load the script
|
85
|
+
and style sheet found under <code>lib/</code> in the distribution,
|
86
|
+
plus a mode script from one of the <code>mode/</code> directories.
|
87
|
+
(See <a href="compress.html">the compression helper</a> for an
|
88
|
+
easy way to combine scripts.) For example:</p>
|
89
|
+
|
90
|
+
<pre data-lang="text/html"><script src="lib/codemirror.js"></script>
|
91
|
+
<link rel="stylesheet" href="../lib/codemirror.css">
|
92
|
+
<script src="mode/javascript/javascript.js"></script></pre>
|
93
|
+
|
94
|
+
<p>Having done this, an editor instance can be created like
|
95
|
+
this:</p>
|
96
|
+
|
97
|
+
<pre data-lang="javascript">var myCodeMirror = CodeMirror(document.body);</pre>
|
98
|
+
|
99
|
+
<p>The editor will be appended to the document body, will start
|
100
|
+
empty, and will use the mode that we loaded. To have more control
|
101
|
+
over the new editor, a configuration object can be passed
|
102
|
+
to <a href="#CodeMirror"><code>CodeMirror</code></a> as a second
|
103
|
+
argument:</p>
|
104
|
+
|
105
|
+
<pre data-lang="javascript">var myCodeMirror = CodeMirror(document.body, {
|
106
|
+
value: "function myScript(){return 100;}\n",
|
107
|
+
mode: "javascript"
|
108
|
+
});</pre>
|
109
|
+
|
110
|
+
<p>This will initialize the editor with a piece of code already in
|
111
|
+
it, and explicitly tell it to use the JavaScript mode (which is
|
112
|
+
useful when multiple modes are loaded).
|
113
|
+
See <a href="#config">below</a> for a full discussion of the
|
114
|
+
configuration options that CodeMirror accepts.</p>
|
115
|
+
|
116
|
+
<p>In cases where you don't want to append the editor to an
|
117
|
+
element, and need more control over the way it is inserted, the
|
118
|
+
first argument to the <code>CodeMirror</code> function can also
|
119
|
+
be a function that, when given a DOM element, inserts it into the
|
120
|
+
document somewhere. This could be used to, for example, replace a
|
121
|
+
textarea with a real editor:</p>
|
122
|
+
|
123
|
+
<pre data-lang="javascript">var myCodeMirror = CodeMirror(function(elt) {
|
124
|
+
myTextArea.parentNode.replaceChild(elt, myTextArea);
|
125
|
+
}, {value: myTextArea.value});</pre>
|
126
|
+
|
127
|
+
<p>However, for this use case, which is a common way to use
|
128
|
+
CodeMirror, the library provides a much more powerful
|
129
|
+
shortcut:</p>
|
130
|
+
|
131
|
+
<pre data-lang="javascript">var myCodeMirror = CodeMirror.fromTextArea(myTextArea);</pre>
|
132
|
+
|
133
|
+
<p>This will, among other things, ensure that the textarea's value
|
134
|
+
is updated with the editor's contents when the form (if it is part
|
135
|
+
of a form) is submitted. See the <a href="#fromTextArea">API
|
136
|
+
reference</a> for a full description of this method.</p>
|
137
|
+
|
138
|
+
</section>
|
139
|
+
<section id=config>
|
140
|
+
<h2>Configuration</h2>
|
141
|
+
|
142
|
+
<p>Both the <a href="#CodeMirror"><code>CodeMirror</code></a>
|
143
|
+
function and its <code>fromTextArea</code> method take as second
|
144
|
+
(optional) argument an object containing configuration options.
|
145
|
+
Any option not supplied like this will be taken
|
146
|
+
from <a href="#defaults"><code>CodeMirror.defaults</code></a>, an
|
147
|
+
object containing the default options. You can update this object
|
148
|
+
to change the defaults on your page.</p>
|
149
|
+
|
150
|
+
<p>Options are not checked in any way, so setting bogus option
|
151
|
+
values is bound to lead to odd errors.</p>
|
152
|
+
|
153
|
+
<p>These are the supported options:</p>
|
154
|
+
|
155
|
+
<dl>
|
156
|
+
<dt id="option_value"><code><strong>value</strong>: string|CodeMirror.Doc</code></dt>
|
157
|
+
<dd>The starting value of the editor. Can be a string, or
|
158
|
+
a <a href="#api_doc">document object</a>.</dd>
|
159
|
+
|
160
|
+
<dt id="option_mode"><code><strong>mode</strong>: string|object</code></dt>
|
161
|
+
<dd>The mode to use. When not given, this will default to the
|
162
|
+
first mode that was loaded. It may be a string, which either
|
163
|
+
simply names the mode or is
|
164
|
+
a <a href="http://en.wikipedia.org/wiki/MIME">MIME</a> type
|
165
|
+
associated with the mode. Alternatively, it may be an object
|
166
|
+
containing configuration options for the mode, with
|
167
|
+
a <code>name</code> property that names the mode (for
|
168
|
+
example <code>{name: "javascript", json: true}</code>). The demo
|
169
|
+
pages for each mode contain information about what configuration
|
170
|
+
parameters the mode supports. You can ask CodeMirror which modes
|
171
|
+
and MIME types have been defined by inspecting
|
172
|
+
the <code>CodeMirror.modes</code>
|
173
|
+
and <code>CodeMirror.mimeModes</code> objects. The first maps
|
174
|
+
mode names to their constructors, and the second maps MIME types
|
175
|
+
to mode specs.</dd>
|
176
|
+
|
177
|
+
<dt id="option_theme"><code><strong>theme</strong>: string</code></dt>
|
178
|
+
<dd>The theme to style the editor with. You must make sure the
|
179
|
+
CSS file defining the corresponding <code>.cm-s-[name]</code>
|
180
|
+
styles is loaded (see
|
181
|
+
the <a href="../theme/"><code>theme</code></a> directory in the
|
182
|
+
distribution). The default is <code>"default"</code>, for which
|
183
|
+
colors are included in <code>codemirror.css</code>. It is
|
184
|
+
possible to use multiple theming classes at once—for
|
185
|
+
example <code>"foo bar"</code> will assign both
|
186
|
+
the <code>cm-s-foo</code> and the <code>cm-s-bar</code> classes
|
187
|
+
to the editor.</dd>
|
188
|
+
|
189
|
+
<dt id="option_indentUnit"><code><strong>indentUnit</strong>: integer</code></dt>
|
190
|
+
<dd>How many spaces a block (whatever that means in the edited
|
191
|
+
language) should be indented. The default is 2.</dd>
|
192
|
+
|
193
|
+
<dt id="option_smartIndent"><code><strong>smartIndent</strong>: boolean</code></dt>
|
194
|
+
<dd>Whether to use the context-sensitive indentation that the
|
195
|
+
mode provides (or just indent the same as the line before).
|
196
|
+
Defaults to true.</dd>
|
197
|
+
|
198
|
+
<dt id="option_tabSize"><code><strong>tabSize</strong>: integer</code></dt>
|
199
|
+
<dd>The width of a tab character. Defaults to 4.</dd>
|
200
|
+
|
201
|
+
<dt id="option_indentWithTabs"><code><strong>indentWithTabs</strong>: boolean</code></dt>
|
202
|
+
<dd>Whether, when indenting, the first N*<code>tabSize</code>
|
203
|
+
spaces should be replaced by N tabs. Default is false.</dd>
|
204
|
+
|
205
|
+
<dt id="option_electricChars"><code><strong>electricChars</strong>: boolean</code></dt>
|
206
|
+
<dd>Configures whether the editor should re-indent the current
|
207
|
+
line when a character is typed that might change its proper
|
208
|
+
indentation (only works if the mode supports indentation).
|
209
|
+
Default is true.</dd>
|
210
|
+
|
211
|
+
<dt id="option_rtlMoveVisually"><code><strong>rtlMoveVisually</strong>: boolean</code></dt>
|
212
|
+
<dd>Determines whether horizontal cursor movement through
|
213
|
+
right-to-left (Arabic, Hebrew) text is visual (pressing the left
|
214
|
+
arrow moves the cursor left) or logical (pressing the left arrow
|
215
|
+
moves to the next lower index in the string, which is visually
|
216
|
+
right in right-to-left text). The default is <code>false</code>
|
217
|
+
on Windows, and <code>true</code> on other platforms.</dd>
|
218
|
+
|
219
|
+
<dt id="option_keyMap"><code><strong>keyMap</strong>: string</code></dt>
|
220
|
+
<dd>Configures the keymap to use. The default
|
221
|
+
is <code>"default"</code>, which is the only keymap defined
|
222
|
+
in <code>codemirror.js</code> itself. Extra keymaps are found in
|
223
|
+
the <a href="../keymap/"><code>keymap</code></a> directory. See
|
224
|
+
the <a href="#keymaps">section on keymaps</a> for more
|
225
|
+
information.</dd>
|
226
|
+
|
227
|
+
<dt id="option_extraKeys"><code><strong>extraKeys</strong>: object</code></dt>
|
228
|
+
<dd>Can be used to specify extra keybindings for the editor,
|
229
|
+
alongside the ones defined
|
230
|
+
by <a href="#option_keyMap"><code>keyMap</code></a>. Should be
|
231
|
+
either null, or a valid <a href="#keymaps">keymap</a> value.</dd>
|
232
|
+
|
233
|
+
<dt id="option_lineWrapping"><code><strong>lineWrapping</strong>: boolean</code></dt>
|
234
|
+
<dd>Whether CodeMirror should scroll or wrap for long lines.
|
235
|
+
Defaults to <code>false</code> (scroll).</dd>
|
236
|
+
|
237
|
+
<dt id="option_lineNumbers"><code><strong>lineNumbers</strong>: boolean</code></dt>
|
238
|
+
<dd>Whether to show line numbers to the left of the editor.</dd>
|
239
|
+
|
240
|
+
<dt id="option_firstLineNumber"><code><strong>firstLineNumber</strong>: integer</code></dt>
|
241
|
+
<dd>At which number to start counting lines. Default is 1.</dd>
|
242
|
+
|
243
|
+
<dt id="option_lineNumberFormatter"><code><strong>lineNumberFormatter</strong>: function(line: integer) → string</code></dt>
|
244
|
+
<dd>A function used to format line numbers. The function is
|
245
|
+
passed the line number, and should return a string that will be
|
246
|
+
shown in the gutter.</dd>
|
247
|
+
|
248
|
+
<dt id="option_gutters"><code><strong>gutters</strong>: array<string></code></dt>
|
249
|
+
<dd>Can be used to add extra gutters (beyond or instead of the
|
250
|
+
line number gutter). Should be an array of CSS class names, each
|
251
|
+
of which defines a <code>width</code> (and optionally a
|
252
|
+
background), and which will be used to draw the background of
|
253
|
+
the gutters. <em>May</em> include
|
254
|
+
the <code>CodeMirror-linenumbers</code> class, in order to
|
255
|
+
explicitly set the position of the line number gutter (it will
|
256
|
+
default to be to the right of all other gutters). These class
|
257
|
+
names are the keys passed
|
258
|
+
to <a href="#setGutterMarker"><code>setGutterMarker</code></a>.</dd>
|
259
|
+
|
260
|
+
<dt id="option_fixedGutter"><code><strong>fixedGutter</strong>: boolean</code></dt>
|
261
|
+
<dd>Determines whether the gutter scrolls along with the content
|
262
|
+
horizontally (false) or whether it stays fixed during horizontal
|
263
|
+
scrolling (true, the default).</dd>
|
264
|
+
|
265
|
+
<dt id="option_coverGutterNextToScrollbar"><code><strong>coverGutterNextToScrollbar</strong>: boolean</code></dt>
|
266
|
+
<dd>When <a href="#option_fixedGutter"><code>fixedGutter</code></a>
|
267
|
+
is on, and there is a horizontal scrollbar, by default the
|
268
|
+
gutter will be visible to the left of this scrollbar. If this
|
269
|
+
option is set to true, it will be covered by an element with
|
270
|
+
class <code>CodeMirror-gutter-filler</code>.</dd>
|
271
|
+
|
272
|
+
<dt id="option_readOnly"><code><strong>readOnly</strong>: boolean|string</code></dt>
|
273
|
+
<dd>This disables editing of the editor content by the user. If
|
274
|
+
the special value <code>"nocursor"</code> is given (instead of
|
275
|
+
simply <code>true</code>), focusing of the editor is also
|
276
|
+
disallowed.</dd>
|
277
|
+
|
278
|
+
<dt id="option_showCursorWhenSelecting"><code><strong>showCursorWhenSelecting</strong>: boolean</code></dt>
|
279
|
+
<dd>Whether the cursor should be drawn when a selection is
|
280
|
+
active. Defaults to false.</dd>
|
281
|
+
|
282
|
+
<dt id="option_undoDepth"><code><strong>undoDepth</strong>: integer</code></dt>
|
283
|
+
<dd>The maximum number of undo levels that the editor stores.
|
284
|
+
Defaults to 40.</dd>
|
285
|
+
|
286
|
+
<dt id="option_historyEventDelay"><code><strong>historyEventDelay</strong>: integer</code></dt>
|
287
|
+
<dd>The period of inactivity (in milliseconds) that will cause a
|
288
|
+
new history event to be started when typing or deleting.
|
289
|
+
Defaults to 500.</dd>
|
290
|
+
|
291
|
+
<dt id="option_tabindex"><code><strong>tabindex</strong>: integer</code></dt>
|
292
|
+
<dd>The <a href="http://www.w3.org/TR/html401/interact/forms.html#adef-tabindex">tab
|
293
|
+
index</a> to assign to the editor. If not given, no tab index
|
294
|
+
will be assigned.</dd>
|
295
|
+
|
296
|
+
<dt id="option_autofocus"><code><strong>autofocus</strong>: boolean</code></dt>
|
297
|
+
<dd>Can be used to make CodeMirror focus itself on
|
298
|
+
initialization. Defaults to off.
|
299
|
+
When <a href="#fromTextArea"><code>fromTextArea</code></a> is
|
300
|
+
used, and no explicit value is given for this option, it will be
|
301
|
+
set to true when either the source textarea is focused, or it
|
302
|
+
has an <code>autofocus</code> attribute and no other element is
|
303
|
+
focused.</dd>
|
304
|
+
</dl>
|
305
|
+
|
306
|
+
<p>Below this a few more specialized, low-level options are
|
307
|
+
listed. These are only useful in very specific situations, you
|
308
|
+
might want to skip them the first time you read this manual.</p>
|
309
|
+
|
310
|
+
<dl>
|
311
|
+
<dt id="option_dragDrop"><code><strong>dragDrop</strong>: boolean</code></dt>
|
312
|
+
<dd>Controls whether drag-and-drop is enabled. On by default.</dd>
|
313
|
+
|
314
|
+
<dt id="option_onDragEvent"><code><strong>onDragEvent</strong>: function(instance: CodeMirror, event: Event) → boolean</code></dt>
|
315
|
+
<dd><em>Deprecated! See <a href="#event_dom">these</a> event
|
316
|
+
handlers for the current recommended approach.</em><br>When given,
|
317
|
+
this will be called when the editor is handling
|
318
|
+
a <code>dragenter</code>, <code>dragover</code>,
|
319
|
+
or <code>drop</code> event. It will be passed the editor
|
320
|
+
instance and the event object as arguments. The callback can
|
321
|
+
choose to handle the event itself, in which case it should
|
322
|
+
return <code>true</code> to indicate that CodeMirror should not
|
323
|
+
do anything further.</dd>
|
324
|
+
|
325
|
+
<dt id="option_onKeyEvent"><code><strong>onKeyEvent</strong>: function(instance: CodeMirror, event: Event) → boolean</code></dt>
|
326
|
+
<dd><em>Deprecated! See <a href="#event_dom">these</a> event
|
327
|
+
handlers for the current recommended approach.</em><br>This
|
328
|
+
provides a rather low-level hook into CodeMirror's key handling.
|
329
|
+
If provided, this function will be called on
|
330
|
+
every <code>keydown</code>, <code>keyup</code>,
|
331
|
+
and <code>keypress</code> event that CodeMirror captures. It
|
332
|
+
will be passed two arguments, the editor instance and the key
|
333
|
+
event. This key event is pretty much the raw key event, except
|
334
|
+
that a <code>stop()</code> method is always added to it. You
|
335
|
+
could feed it to, for example, <code>jQuery.Event</code> to
|
336
|
+
further normalize it.<br>This function can inspect the key
|
337
|
+
event, and handle it if it wants to. It may return true to tell
|
338
|
+
CodeMirror to ignore the event. Be wary that, on some browsers,
|
339
|
+
stopping a <code>keydown</code> does not stop
|
340
|
+
the <code>keypress</code> from firing, whereas on others it
|
341
|
+
does. If you respond to an event, you should probably inspect
|
342
|
+
its <code>type</code> property and only do something when it
|
343
|
+
is <code>keydown</code> (or <code>keypress</code> for actions
|
344
|
+
that need character data).</dd>
|
345
|
+
|
346
|
+
<dt id="option_cursorBlinkRate"><code><strong>cursorBlinkRate</strong>: number</code></dt>
|
347
|
+
<dd>Half-period in milliseconds used for cursor blinking. The default blink
|
348
|
+
rate is 530ms. By setting this to zero, blinking can be disabled.</dd>
|
349
|
+
|
350
|
+
<dt id="option_cursorScrollMargin"><code><strong>cursorScrollMargin</strong>: number</code></dt>
|
351
|
+
<dd>How much extra space to always keep above and below the
|
352
|
+
cursor when approaching the top or bottom of the visible view in
|
353
|
+
a scrollable document. Default is 0.</dd>
|
354
|
+
|
355
|
+
<dt id="option_cursorHeight"><code><strong>cursorHeight</strong>: number</code></dt>
|
356
|
+
<dd>Determines the height of the cursor. Default is 1, meaning
|
357
|
+
it spans the whole height of the line. For some fonts (and by
|
358
|
+
some tastes) a smaller height (for example <code>0.85</code>),
|
359
|
+
which causes the cursor to not reach all the way to the bottom
|
360
|
+
of the line, looks better</dd>
|
361
|
+
|
362
|
+
<dt id="option_resetSelectionOnContextMenu"><code><strong>resetSelectionOnContextMenu</strong>: boolean</code></dt>
|
363
|
+
<dd>Controls whether, when the context menu is opened with a
|
364
|
+
click outside of the current selection, the cursor is moved to
|
365
|
+
the point of the click. Defaults to <code>true</code>.</dd>
|
366
|
+
|
367
|
+
<dt id="option_workTime"><code><strong>workTime</strong>, <strong>workDelay</strong>: number</code></dt>
|
368
|
+
<dd>Highlighting is done by a pseudo background-thread that will
|
369
|
+
work for <code>workTime</code> milliseconds, and then use
|
370
|
+
timeout to sleep for <code>workDelay</code> milliseconds. The
|
371
|
+
defaults are 200 and 300, you can change these options to make
|
372
|
+
the highlighting more or less aggressive.</dd>
|
373
|
+
|
374
|
+
<dt id="option_workDelay"><code><strong>workDelay</strong>: number</code></dt>
|
375
|
+
<dd>See <a href="#option_workTime"><code>workTime</code></a>.</dd>
|
376
|
+
|
377
|
+
<dt id="option_pollInterval"><code><strong>pollInterval</strong>: number</code></dt>
|
378
|
+
<dd>Indicates how quickly CodeMirror should poll its input
|
379
|
+
textarea for changes (when focused). Most input is captured by
|
380
|
+
events, but some things, like IME input on some browsers, don't
|
381
|
+
generate events that allow CodeMirror to properly detect it.
|
382
|
+
Thus, it polls. Default is 100 milliseconds.</dd>
|
383
|
+
|
384
|
+
<dt id="option_flattenSpans"><code><strong>flattenSpans</strong>: boolean</code></dt>
|
385
|
+
<dd>By default, CodeMirror will combine adjacent tokens into a
|
386
|
+
single span if they have the same class. This will result in a
|
387
|
+
simpler DOM tree, and thus perform better. With some kinds of
|
388
|
+
styling (such as rounded corners), this will change the way the
|
389
|
+
document looks. You can set this option to false to disable this
|
390
|
+
behavior.</dd>
|
391
|
+
|
392
|
+
<dt id="option_maxHighlightLength"><code><strong>maxHighlightLength</strong>: number</code></dt>
|
393
|
+
<dd>When highlighting long lines, in order to stay responsive,
|
394
|
+
the editor will give up and simply style the rest of the line as
|
395
|
+
plain text when it reaches a certain position. The default is
|
396
|
+
10 000. You can set this to <code>Infinity</code> to turn off
|
397
|
+
this behavior.</dd>
|
398
|
+
|
399
|
+
<dt id="option_crudeMeasuringFrom"><code><strong>crudeMeasuringFrom</strong>: number</code></dt>
|
400
|
+
<dd>When measuring the character positions in long lines, any
|
401
|
+
line longer than this number (default is 10 000),
|
402
|
+
when <a href="#option_lineWrapping">line wrapping</a>
|
403
|
+
is <strong>off</strong>, will simply be assumed to consist of
|
404
|
+
same-sized characters. This means that, on the one hand,
|
405
|
+
measuring will be inaccurate when characters of varying size,
|
406
|
+
right-to-left text, markers, or other irregular elements are
|
407
|
+
present. On the other hand, it means that having such a line
|
408
|
+
won't freeze the user interface because of the expensiveness of
|
409
|
+
the measurements.</dd>
|
410
|
+
|
411
|
+
<dt id="option_viewportMargin"><code><strong>viewportMargin</strong>: integer</code></dt>
|
412
|
+
<dd>Specifies the amount of lines that are rendered above and
|
413
|
+
below the part of the document that's currently scrolled into
|
414
|
+
view. This affects the amount of updates needed when scrolling,
|
415
|
+
and the amount of work that such an update does. You should
|
416
|
+
usually leave it at its default, 10. Can be set
|
417
|
+
to <code>Infinity</code> to make sure the whole document is
|
418
|
+
always rendered, and thus the browser's text search works on it.
|
419
|
+
This <em>will</em> have bad effects on performance of big
|
420
|
+
documents.</dd>
|
421
|
+
</dl>
|
422
|
+
</section>
|
423
|
+
|
424
|
+
<section id=events>
|
425
|
+
<h2>Events</h2>
|
426
|
+
|
427
|
+
<p>Various CodeMirror-related objects emit events, which allow
|
428
|
+
client code to react to various situations. Handlers for such
|
429
|
+
events can be registed with the <a href="#on"><code>on</code></a>
|
430
|
+
and <a href="#off"><code>off</code></a> methods on the objects
|
431
|
+
that the event fires on. To fire your own events,
|
432
|
+
use <code>CodeMirror.signal(target, name, args...)</code>,
|
433
|
+
where <code>target</code> is a non-DOM-node object.</p>
|
434
|
+
|
435
|
+
<p>An editor instance fires the following events.
|
436
|
+
The <code>instance</code> argument always refers to the editor
|
437
|
+
itself.</p>
|
438
|
+
|
439
|
+
<dl>
|
440
|
+
<dt id="event_change"><code><strong>"change"</strong> (instance: CodeMirror, changeObj: object)</code></dt>
|
441
|
+
<dd>Fires every time the content of the editor is changed.
|
442
|
+
The <code>changeObj</code> is a <code>{from, to, text, removed,
|
443
|
+
next}</code> object containing information about the changes
|
444
|
+
that occurred as second argument. <code>from</code>
|
445
|
+
and <code>to</code> are the positions (in the pre-change
|
446
|
+
coordinate system) where the change started and ended (for
|
447
|
+
example, it might be <code>{ch:0, line:18}</code> if the
|
448
|
+
position is at the beginning of line #19). <code>text</code> is
|
449
|
+
an array of strings representing the text that replaced the
|
450
|
+
changed range (split by line). <code>removed</code> is the text
|
451
|
+
that used to be between <code>from</code> and <code>to</code>,
|
452
|
+
which is overwritten by this change. If multiple changes
|
453
|
+
happened during a single operation, the object will have
|
454
|
+
a <code>next</code> property pointing to another change object
|
455
|
+
(which may point to another, etc).</dd>
|
456
|
+
|
457
|
+
<dt id="event_beforeChange"><code><strong>"beforeChange"</strong> (instance: CodeMirror, changeObj: object)</code></dt>
|
458
|
+
<dd>This event is fired before a change is applied, and its
|
459
|
+
handler may choose to modify or cancel the change.
|
460
|
+
The <code>changeObj</code> object
|
461
|
+
has <code>from</code>, <code>to</code>, and <code>text</code>
|
462
|
+
properties, as with
|
463
|
+
the <a href="#event_change"><code>"change"</code></a> event, but
|
464
|
+
never a <code>next</code> property, since this is fired for each
|
465
|
+
individual change, and not batched per operation. It also has
|
466
|
+
a <code>cancel()</code> method, which can be called to cancel
|
467
|
+
the change, and, <strong>if</strong> the change isn't coming
|
468
|
+
from an undo or redo event, an <code>update(from, to,
|
469
|
+
text)</code> method, which may be used to modify the change.
|
470
|
+
Undo or redo changes can't be modified, because they hold some
|
471
|
+
metainformation for restoring old marked ranges that is only
|
472
|
+
valid for that specific change. All three arguments
|
473
|
+
to <code>update</code> are optional, and can be left off to
|
474
|
+
leave the existing value for that field
|
475
|
+
intact. <strong>Note:</strong> you may not do anything from
|
476
|
+
a <code>"beforeChange"</code> handler that would cause changes
|
477
|
+
to the document or its visualization. Doing so will, since this
|
478
|
+
handler is called directly from the bowels of the CodeMirror
|
479
|
+
implementation, probably cause the editor to become
|
480
|
+
corrupted.</dd>
|
481
|
+
|
482
|
+
<dt id="event_cursorActivity"><code><strong>"cursorActivity"</strong> (instance: CodeMirror)</code></dt>
|
483
|
+
<dd>Will be fired when the cursor or selection moves, or any
|
484
|
+
change is made to the editor content.</dd>
|
485
|
+
|
486
|
+
<dt id="event_keyHandled"><code><strong>"keyHandled"</strong> (instance: CodeMirror, name: string, event: Event)</code></dt>
|
487
|
+
<dd>Fired after a key is handled through a
|
488
|
+
keymap. <code>name</code> is the name of the handled key (for
|
489
|
+
example <code>"Ctrl-X"</code> or <code>"'q'"</code>),
|
490
|
+
and <code>event</code> is the DOM <code>keydown</code>
|
491
|
+
or <code>keypress</code> event.</dd>
|
492
|
+
|
493
|
+
<dt id="event_inputRead"><code><strong>"inputRead"</strong> (instance: CodeMirror, changeObj: object)</code></dt>
|
494
|
+
<dd>Fired whenever new input is read from the hidden textarea
|
495
|
+
(typed or pasted by the user).</dd>
|
496
|
+
|
497
|
+
<dt id="event_beforeSelectionChange"><code><strong>"beforeSelectionChange"</strong> (instance: CodeMirror, selection: {head, anchor})</code></dt>
|
498
|
+
<dd>This event is fired before the selection is moved. Its
|
499
|
+
handler may modify the resulting selection head and anchor.
|
500
|
+
The <code>selection</code> parameter is an object
|
501
|
+
with <code>head</code> and <code>anchor</code> properties
|
502
|
+
holding <code>{line, ch}</code> objects, which the handler can
|
503
|
+
read and update. Handlers for this event have the same
|
504
|
+
restriction
|
505
|
+
as <a href="#event_beforeChange"><code>"beforeChange"</code></a>
|
506
|
+
handlers — they should not do anything to directly update the
|
507
|
+
state of the editor.</dd>
|
508
|
+
|
509
|
+
<dt id="event_viewportChange"><code><strong>"viewportChange"</strong> (instance: CodeMirror, from: number, to: number)</code></dt>
|
510
|
+
<dd>Fires whenever the <a href="#getViewport">view port</a> of
|
511
|
+
the editor changes (due to scrolling, editing, or any other
|
512
|
+
factor). The <code>from</code> and <code>to</code> arguments
|
513
|
+
give the new start and end of the viewport.</dd>
|
514
|
+
|
515
|
+
<dt id="event_swapDoc"><code><strong>"swapDoc"</strong> (instance: CodeMirror, oldDoc: Doc)</code></dt>
|
516
|
+
<dd>This is signalled when the editor's document is replaced
|
517
|
+
using the <a href="#swapDoc"><code>swapDoc</code></a>
|
518
|
+
method.</dd>
|
519
|
+
|
520
|
+
<dt id="event_gutterClick"><code><strong>"gutterClick"</strong> (instance: CodeMirror, line: integer, gutter: string, clickEvent: Event)</code></dt>
|
521
|
+
<dd>Fires when the editor gutter (the line-number area) is
|
522
|
+
clicked. Will pass the editor instance as first argument, the
|
523
|
+
(zero-based) number of the line that was clicked as second
|
524
|
+
argument, the CSS class of the gutter that was clicked as third
|
525
|
+
argument, and the raw <code>mousedown</code> event object as
|
526
|
+
fourth argument.</dd>
|
527
|
+
|
528
|
+
<dt id="event_gutterContextMenu"><code><strong>"gutterContextMenu"</strong> (instance: CodeMirror, line: integer, gutter: string, contextMenu: Event: Event)</code></dt>
|
529
|
+
<dd>Fires when the editor gutter (the line-number area)
|
530
|
+
receives a <code>contextmenu</code> event. Will pass the editor
|
531
|
+
instance as first argument, the (zero-based) number of the line
|
532
|
+
that was clicked as second argument, the CSS class of the
|
533
|
+
gutter that was clicked as third argument, and the raw
|
534
|
+
<code>contextmenu</code> mouse event object as fourth argument.
|
535
|
+
You can <code>preventDefault</code> the event, to signal that
|
536
|
+
CodeMirror should do no further handling.</dd>
|
537
|
+
|
538
|
+
<dt id="event_focus"><code><strong>"focus"</strong> (instance: CodeMirror)</code></dt>
|
539
|
+
<dd>Fires whenever the editor is focused.</dd>
|
540
|
+
|
541
|
+
<dt id="event_blur"><code><strong>"blur"</strong> (instance: CodeMirror)</code></dt>
|
542
|
+
<dd>Fires whenever the editor is unfocused.</dd>
|
543
|
+
|
544
|
+
<dt id="event_scroll"><code><strong>"scroll"</strong> (instance: CodeMirror)</code></dt>
|
545
|
+
<dd>Fires when the editor is scrolled.</dd>
|
546
|
+
|
547
|
+
<dt id="event_update"><code><strong>"update"</strong> (instance: CodeMirror)</code></dt>
|
548
|
+
<dd>Will be fired whenever CodeMirror updates its DOM display.</dd>
|
549
|
+
|
550
|
+
<dt id="event_renderLine"><code><strong>"renderLine"</strong> (instance: CodeMirror, line: LineHandle, element: Element)</code></dt>
|
551
|
+
<dd>Fired whenever a line is (re-)rendered to the DOM. Fired
|
552
|
+
right after the DOM element is built, <em>before</em> it is
|
553
|
+
added to the document. The handler may mess with the style of
|
554
|
+
the resulting element, or add event handlers, but
|
555
|
+
should <em>not</em> try to change the state of the editor.</dd>
|
556
|
+
|
557
|
+
<dt id="event_dom"><code><strong>"mousedown"</strong>,
|
558
|
+
<strong>"dblclick"</strong>, <strong>"contextmenu"</strong>, <strong>"keydown"</strong>, <strong>"keypress"</strong>,
|
559
|
+
<strong>"keyup"</strong>, <strong>"dragstart"</strong>, <strong>"dragenter"</strong>,
|
560
|
+
<strong>"dragover"</strong>, <strong>"drop"</strong>
|
561
|
+
(instance: CodeMirror, event: Event)</code></dt>
|
562
|
+
<dd>Fired when CodeMirror is handling a DOM event of this type.
|
563
|
+
You can <code>preventDefault</code> the event, or give it a
|
564
|
+
truthy <code>codemirrorIgnore</code> property, to signal that
|
565
|
+
CodeMirror should do no further handling.</dd>
|
566
|
+
</dl>
|
567
|
+
|
568
|
+
<p>Document objects (instances
|
569
|
+
of <a href="#Doc"><code>CodeMirror.Doc</code></a>) emit the
|
570
|
+
following events:</p>
|
571
|
+
|
572
|
+
<dl>
|
573
|
+
<dt id="event_doc_change"><code><strong>"change"</strong> (doc: CodeMirror.Doc, changeObj: object)</code></dt>
|
574
|
+
<dd>Fired whenever a change occurs to the
|
575
|
+
document. <code>changeObj</code> has a similar type as the
|
576
|
+
object passed to the
|
577
|
+
editor's <a href="#event_change"><code>"change"</code></a>
|
578
|
+
event, but it never has a <code>next</code> property, because
|
579
|
+
document change events are not batched (whereas editor change
|
580
|
+
events are).</dd>
|
581
|
+
|
582
|
+
<dt id="event_doc_beforeChange"><code><strong>"beforeChange"</strong> (doc: CodeMirror.Doc, change: object)</code></dt>
|
583
|
+
<dd>See the <a href="#event_beforeChange">description of the
|
584
|
+
same event</a> on editor instances.</dd>
|
585
|
+
|
586
|
+
<dt id="event_doc_cursorActivity"><code><strong>"cursorActivity"</strong> (doc: CodeMirror.Doc)</code></dt>
|
587
|
+
<dd>Fired whenever the cursor or selection in this document
|
588
|
+
changes.</dd>
|
589
|
+
|
590
|
+
<dt id="event_doc_beforeSelectionChange"><code><strong>"beforeSelectionChange"</strong> (doc: CodeMirror.Doc, selection: {head, anchor})</code></dt>
|
591
|
+
<dd>Equivalent to
|
592
|
+
the <a href="#event_beforeSelectionChange">event by the same
|
593
|
+
name</a> as fired on editor instances.</dd>
|
594
|
+
</dl>
|
595
|
+
|
596
|
+
<p>Line handles (as returned by, for
|
597
|
+
example, <a href="#getLineHandle"><code>getLineHandle</code></a>)
|
598
|
+
support these events:</p>
|
599
|
+
|
600
|
+
<dl>
|
601
|
+
<dt id="event_delete"><code><strong>"delete"</strong> ()</code></dt>
|
602
|
+
<dd>Will be fired when the line object is deleted. A line object
|
603
|
+
is associated with the <em>start</em> of the line. Mostly useful
|
604
|
+
when you need to find out when your <a href="#setGutterMarker">gutter
|
605
|
+
markers</a> on a given line are removed.</dd>
|
606
|
+
<dt id="event_line_change"><code><strong>"change"</strong> (line: LineHandle, changeObj: object)</code></dt>
|
607
|
+
<dd>Fires when the line's text content is changed in any way
|
608
|
+
(but the line is not deleted outright). The <code>change</code>
|
609
|
+
object is similar to the one passed
|
610
|
+
to <a href="#event_change">change event</a> on the editor
|
611
|
+
object.</dd>
|
612
|
+
</dl>
|
613
|
+
|
614
|
+
<p>Marked range handles (<code>CodeMirror.TextMarker</code>), as returned
|
615
|
+
by <a href="#markText"><code>markText</code></a>
|
616
|
+
and <a href="#setBookmark"><code>setBookmark</code></a>, emit the
|
617
|
+
following events:</p>
|
618
|
+
|
619
|
+
<dl>
|
620
|
+
<dt id="event_beforeCursorEnter"><code><strong>"beforeCursorEnter"</strong> ()</code></dt>
|
621
|
+
<dd>Fired when the cursor enters the marked range. From this
|
622
|
+
event handler, the editor state may be inspected
|
623
|
+
but <em>not</em> modified, with the exception that the range on
|
624
|
+
which the event fires may be cleared.</dd>
|
625
|
+
<dt id="event_clear"><code><strong>"clear"</strong> (from: {line, ch}, to: {line, ch})</code></dt>
|
626
|
+
<dd>Fired when the range is cleared, either through cursor
|
627
|
+
movement in combination
|
628
|
+
with <a href="#mark_clearOnEnter"><code>clearOnEnter</code></a>
|
629
|
+
or through a call to its <code>clear()</code> method. Will only
|
630
|
+
be fired once per handle. Note that deleting the range through
|
631
|
+
text editing does not fire this event, because an undo action
|
632
|
+
might bring the range back into existence. <code>from</code>
|
633
|
+
and <code>to</code> give the part of the document that the range
|
634
|
+
spanned when it was cleared.</dd>
|
635
|
+
<dt id="event_hide"><code><strong>"hide"</strong> ()</code></dt>
|
636
|
+
<dd>Fired when the last part of the marker is removed from the
|
637
|
+
document by editing operations.</dd>
|
638
|
+
<dt id="event_unhide"><code><strong>"unhide"</strong> ()</code></dt>
|
639
|
+
<dd>Fired when, after the marker was removed by editing, a undo
|
640
|
+
operation brought the marker back.</dd>
|
641
|
+
</dl>
|
642
|
+
|
643
|
+
<p>Line widgets (<code>CodeMirror.LineWidget</code>), returned
|
644
|
+
by <a href="#addLineWidget"><code>addLineWidget</code></a>, fire
|
645
|
+
these events:</p>
|
646
|
+
|
647
|
+
<dl>
|
648
|
+
<dt id="event_redraw"><code><strong>"redraw"</strong> ()</code></dt>
|
649
|
+
<dd>Fired whenever the editor re-adds the widget to the DOM.
|
650
|
+
This will happen once right after the widget is added (if it is
|
651
|
+
scrolled into view), and then again whenever it is scrolled out
|
652
|
+
of view and back in again, or when changes to the editor options
|
653
|
+
or the line the widget is on require the widget to be
|
654
|
+
redrawn.</dd>
|
655
|
+
</dl>
|
656
|
+
</section>
|
657
|
+
|
658
|
+
<section id=keymaps>
|
659
|
+
<h2>Keymaps</h2>
|
660
|
+
|
661
|
+
<p>Keymaps are ways to associate keys with functionality. A keymap
|
662
|
+
is an object mapping strings that identify the keys to functions
|
663
|
+
that implement their functionality.</p>
|
664
|
+
|
665
|
+
<p>Keys are identified either by name or by character.
|
666
|
+
The <code>CodeMirror.keyNames</code> object defines names for
|
667
|
+
common keys and associates them with their key codes. Examples of
|
668
|
+
names defined here are <code>Enter</code>, <code>F5</code>,
|
669
|
+
and <code>Q</code>. These can be prefixed
|
670
|
+
with <code>Shift-</code>, <code>Cmd-</code>, <code>Ctrl-</code>,
|
671
|
+
and <code>Alt-</code> (in that order!) to specify a modifier. So
|
672
|
+
for example, <code>Shift-Ctrl-Space</code> would be a valid key
|
673
|
+
identifier.</p>
|
674
|
+
|
675
|
+
<p>Common example: map the Tab key to insert spaces instead of a tab
|
676
|
+
character.</p>
|
677
|
+
|
678
|
+
<pre data-lang="javascript">
|
679
|
+
{
|
680
|
+
Tab: function(cm) {
|
681
|
+
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
682
|
+
cm.replaceSelection(spaces, "end", "+input");
|
683
|
+
}
|
684
|
+
}</pre>
|
685
|
+
|
686
|
+
<p>Alternatively, a character can be specified directly by
|
687
|
+
surrounding it in single quotes, for example <code>'$'</code>
|
688
|
+
or <code>'q'</code>. Due to limitations in the way browsers fire
|
689
|
+
key events, these may not be prefixed with modifiers.</p>
|
690
|
+
|
691
|
+
<p>The <code>CodeMirror.keyMap</code> object associates keymaps
|
692
|
+
with names. User code and keymap definitions can assign extra
|
693
|
+
properties to this object. Anywhere where a keymap is expected, a
|
694
|
+
string can be given, which will be looked up in this object. It
|
695
|
+
also contains the <code>"default"</code> keymap holding the
|
696
|
+
default bindings.</p>
|
697
|
+
|
698
|
+
<p id="commands">The values of properties in keymaps can be either functions of
|
699
|
+
a single argument (the CodeMirror instance), strings, or
|
700
|
+
<code>false</code>. Such strings refer to properties of the
|
701
|
+
<code>CodeMirror.commands</code> object, which defines a number of
|
702
|
+
common commands that are used by the default keybindings, and maps
|
703
|
+
them to functions. If the property is set to <code>false</code>,
|
704
|
+
CodeMirror leaves handling of the key up to the browser. A key
|
705
|
+
handler function may return <code>CodeMirror.Pass</code> to indicate
|
706
|
+
that it has decided not to handle the key, and other handlers (or
|
707
|
+
the default behavior) should be given a turn.</p>
|
708
|
+
|
709
|
+
<p>Keys mapped to command names that start with the
|
710
|
+
characters <code>"go"</code> (which should be used for
|
711
|
+
cursor-movement actions) will be fired even when an
|
712
|
+
extra <code>Shift</code> modifier is present (i.e. <code>"Up":
|
713
|
+
"goLineUp"</code> matches both up and shift-up). This is used to
|
714
|
+
easily implement shift-selection.</p>
|
715
|
+
|
716
|
+
<p>Keymaps can defer to each other by defining
|
717
|
+
a <code>fallthrough</code> property. This indicates that when a
|
718
|
+
key is not found in the map itself, one or more other maps should
|
719
|
+
be searched. It can hold either a single keymap or an array of
|
720
|
+
keymaps.</p>
|
721
|
+
|
722
|
+
<p>When a keymap contains a <code>nofallthrough</code> property
|
723
|
+
set to <code>true</code>, keys matched against that map will be
|
724
|
+
ignored if they don't match any of the bindings in the map (no
|
725
|
+
further child maps will be tried). When
|
726
|
+
the <code>disableInput</code> property is set
|
727
|
+
to <code>true</code>, the default effect of inserting a character
|
728
|
+
will be suppressed when the keymap is active as the top-level
|
729
|
+
map.</p>
|
730
|
+
</section>
|
731
|
+
|
732
|
+
<section id=styling>
|
733
|
+
<h2>Customized Styling</h2>
|
734
|
+
|
735
|
+
<p>Up to a certain extent, CodeMirror's look can be changed by
|
736
|
+
modifying style sheet files. The style sheets supplied by modes
|
737
|
+
simply provide the colors for that mode, and can be adapted in a
|
738
|
+
very straightforward way. To style the editor itself, it is
|
739
|
+
possible to alter or override the styles defined
|
740
|
+
in <a href="../lib/codemirror.css"><code>codemirror.css</code></a>.</p>
|
741
|
+
|
742
|
+
<p>Some care must be taken there, since a lot of the rules in this
|
743
|
+
file are necessary to have CodeMirror function properly. Adjusting
|
744
|
+
colors should be safe, of course, and with some care a lot of
|
745
|
+
other things can be changed as well. The CSS classes defined in
|
746
|
+
this file serve the following roles:</p>
|
747
|
+
|
748
|
+
<dl>
|
749
|
+
<dt id="class_CodeMirror"><code><strong>CodeMirror</strong></code></dt>
|
750
|
+
<dd>The outer element of the editor. This should be used for the
|
751
|
+
editor width, height, borders and positioning. Can also be used
|
752
|
+
to set styles that should hold for everything inside the editor
|
753
|
+
(such as font and font size), or to set a background.</dd>
|
754
|
+
|
755
|
+
<dt id="class_CodeMirror_scroll"><code><strong>CodeMirror-scroll</strong></code></dt>
|
756
|
+
<dd>Whether the editor scrolls (<code>overflow: auto</code> +
|
757
|
+
fixed height). By default, it does. Setting
|
758
|
+
the <code>CodeMirror</code> class to have <code>height:
|
759
|
+
auto</code> and giving this class <code>overflow-x: auto;
|
760
|
+
overflow-y: hidden;</code> will cause the editor
|
761
|
+
to <a href="../demo/resize.html">resize to fit its
|
762
|
+
content</a>.</dd>
|
763
|
+
|
764
|
+
<dt id="class_CodeMirror_focused"><code><strong>CodeMirror-focused</strong></code></dt>
|
765
|
+
<dd>Whenever the editor is focused, the top element gets this
|
766
|
+
class. This is used to hide the cursor and give the selection a
|
767
|
+
different color when the editor is not focused.</dd>
|
768
|
+
|
769
|
+
<dt id="class_CodeMirror_gutters"><code><strong>CodeMirror-gutters</strong></code></dt>
|
770
|
+
<dd>This is the backdrop for all gutters. Use it to set the
|
771
|
+
default gutter background color, and optionally add a border on
|
772
|
+
the right of the gutters.</dd>
|
773
|
+
|
774
|
+
<dt id="class_CodeMirror_linenumbers"><code><strong>CodeMirror-linenumbers</strong></code></dt>
|
775
|
+
<dd>Use this for giving a background or width to the line number
|
776
|
+
gutter.</dd>
|
777
|
+
|
778
|
+
<dt id="class_CodeMirror_linenumber"><code><strong>CodeMirror-linenumber</strong></code></dt>
|
779
|
+
<dd>Used to style the actual individual line numbers. These
|
780
|
+
won't be children of the <code>CodeMirror-linenumbers</code>
|
781
|
+
(plural) element, but rather will be absolutely positioned to
|
782
|
+
overlay it. Use this to set alignment and text properties for
|
783
|
+
the line numbers.</dd>
|
784
|
+
|
785
|
+
<dt id="class_CodeMirror_lines"><code><strong>CodeMirror-lines</strong></code></dt>
|
786
|
+
<dd>The visible lines. This is where you specify vertical
|
787
|
+
padding for the editor content.</dd>
|
788
|
+
|
789
|
+
<dt id="class_CodeMirror_cursor"><code><strong>CodeMirror-cursor</strong></code></dt>
|
790
|
+
<dd>The cursor is a block element that is absolutely positioned.
|
791
|
+
You can make it look whichever way you want.</dd>
|
792
|
+
|
793
|
+
<dt id="class_CodeMirror_selected"><code><strong>CodeMirror-selected</strong></code></dt>
|
794
|
+
<dd>The selection is represented by <code>span</code> elements
|
795
|
+
with this class.</dd>
|
796
|
+
|
797
|
+
<dt id="class_CodeMirror_matchingbracket"><code><strong>CodeMirror-matchingbracket</strong></code>,
|
798
|
+
<code><strong>CodeMirror-nonmatchingbracket</strong></code></dt>
|
799
|
+
<dd>These are used to style matched (or unmatched) brackets.</dd>
|
800
|
+
</dl>
|
801
|
+
|
802
|
+
<p>If your page's style sheets do funky things to
|
803
|
+
all <code>div</code> or <code>pre</code> elements (you probably
|
804
|
+
shouldn't do that), you'll have to define rules to cancel these
|
805
|
+
effects out again for elements under the <code>CodeMirror</code>
|
806
|
+
class.</p>
|
807
|
+
|
808
|
+
<p>Themes are also simply CSS files, which define colors for
|
809
|
+
various syntactic elements. See the files in
|
810
|
+
the <a href="../theme/"><code>theme</code></a> directory.</p>
|
811
|
+
</section>
|
812
|
+
|
813
|
+
<section id=api>
|
814
|
+
<h2>Programming API</h2>
|
815
|
+
|
816
|
+
<p>A lot of CodeMirror features are only available through its
|
817
|
+
API. Thus, you need to write code (or
|
818
|
+
use <a href="#addons">addons</a>) if you want to expose them to
|
819
|
+
your users.</p>
|
820
|
+
|
821
|
+
<p>Whenever points in the document are represented, the API uses
|
822
|
+
objects with <code>line</code> and <code>ch</code> properties.
|
823
|
+
Both are zero-based. CodeMirror makes sure to 'clip' any positions
|
824
|
+
passed by client code so that they fit inside the document, so you
|
825
|
+
shouldn't worry too much about sanitizing your coordinates. If you
|
826
|
+
give <code>ch</code> a value of <code>null</code>, or don't
|
827
|
+
specify it, it will be replaced with the length of the specified
|
828
|
+
line.</p>
|
829
|
+
|
830
|
+
<p>Methods prefixed with <code>doc.</code> can, unless otherwise
|
831
|
+
specified, be called both on <code>CodeMirror</code> (editor)
|
832
|
+
instances and <code>CodeMirror.Doc</code> instances. Methods
|
833
|
+
prefixed with <code>cm.</code> are <em>only</em> available
|
834
|
+
on <code>CodeMirror</code> instances.</p>
|
835
|
+
|
836
|
+
<h3 id="api_constructor">Constructor</h3>
|
837
|
+
|
838
|
+
<p id="CodeMirror">Constructing an editor instance is done with
|
839
|
+
the <code><strong>CodeMirror</strong>(place: Element|fn(Element),
|
840
|
+
?option: object)</code> constructor. If the <code>place</code>
|
841
|
+
argument is a DOM element, the editor will be appended to it. If
|
842
|
+
it is a function, it will be called, and is expected to place the
|
843
|
+
editor into the document. <code>options</code> may be an element
|
844
|
+
mapping <a href="#config">option names</a> to values. The options
|
845
|
+
that it doesn't explicitly specify (or all options, if it is not
|
846
|
+
passed) will be taken
|
847
|
+
from <a href="#defaults"><code>CodeMirror.defaults</code></a>.</p>
|
848
|
+
|
849
|
+
<p>Note that the options object passed to the constructor will be
|
850
|
+
mutated when the instance's options
|
851
|
+
are <a href="#setOption">changed</a>, so you shouldn't share such
|
852
|
+
objects between instances.</p>
|
853
|
+
|
854
|
+
<p>See <a href="#fromTextArea"><code>CodeMirror.fromTextArea</code></a>
|
855
|
+
for another way to construct an editor instance.</p>
|
856
|
+
|
857
|
+
<h3 id="api_content">Content manipulation methods</h3>
|
858
|
+
|
859
|
+
<dl>
|
860
|
+
<dt id="getValue"><code><strong>doc.getValue</strong>(?separator: string) → string</code></dt>
|
861
|
+
<dd>Get the current editor content. You can pass it an optional
|
862
|
+
argument to specify the string to be used to separate lines
|
863
|
+
(defaults to <code>"\n"</code>).</dd>
|
864
|
+
<dt id="setValue"><code><strong>doc.setValue</strong>(content: string)</code></dt>
|
865
|
+
<dd>Set the editor content.</dd>
|
866
|
+
|
867
|
+
<dt id="getRange"><code><strong>doc.getRange</strong>(from: {line, ch}, to: {line, ch}, ?separator: string) → string</code></dt>
|
868
|
+
<dd>Get the text between the given points in the editor, which
|
869
|
+
should be <code>{line, ch}</code> objects. An optional third
|
870
|
+
argument can be given to indicate the line separator string to
|
871
|
+
use (defaults to <code>"\n"</code>).</dd>
|
872
|
+
<dt id="replaceRange"><code><strong>doc.replaceRange</strong>(replacement: string, from: {line, ch}, to: {line, ch})</code></dt>
|
873
|
+
<dd>Replace the part of the document between <code>from</code>
|
874
|
+
and <code>to</code> with the given string. <code>from</code>
|
875
|
+
and <code>to</code> must be <code>{line, ch}</code>
|
876
|
+
objects. <code>to</code> can be left off to simply insert the
|
877
|
+
string at position <code>from</code>.</dd>
|
878
|
+
|
879
|
+
<dt id="getLine"><code><strong>doc.getLine</strong>(n: integer) → string</code></dt>
|
880
|
+
<dd>Get the content of line <code>n</code>.</dd>
|
881
|
+
<dt id="setLine"><code><strong>doc.setLine</strong>(n: integer, text: string)</code></dt>
|
882
|
+
<dd>Set the content of line <code>n</code>.</dd>
|
883
|
+
<dt id="removeLine"><code><strong>doc.removeLine</strong>(n: integer)</code></dt>
|
884
|
+
<dd>Remove the given line from the document.</dd>
|
885
|
+
|
886
|
+
<dt id="lineCount"><code><strong>doc.lineCount</strong>() → integer</code></dt>
|
887
|
+
<dd>Get the number of lines in the editor.</dd>
|
888
|
+
<dt id="firstLine"><code><strong>doc.firstLine</strong>() → integer</code></dt>
|
889
|
+
<dd>Get the first line of the editor. This will
|
890
|
+
usually be zero but for <a href="#linkedDoc_from">linked sub-views</a>,
|
891
|
+
or <a href="#api_doc">documents</a> instantiated with a non-zero
|
892
|
+
first line, it might return other values.</dd>
|
893
|
+
<dt id="lastLine"><code><strong>doc.lastLine</strong>() → integer</code></dt>
|
894
|
+
<dd>Get the last line of the editor. This will
|
895
|
+
usually be <code>doc.lineCount() - 1</code>,
|
896
|
+
but for <a href="#linkedDoc_from">linked sub-views</a>,
|
897
|
+
it might return other values.</dd>
|
898
|
+
|
899
|
+
<dt id="getLineHandle"><code><strong>doc.getLineHandle</strong>(num: integer) → LineHandle</code></dt>
|
900
|
+
<dd>Fetches the line handle for the given line number.</dd>
|
901
|
+
<dt id="getLineNumber"><code><strong>doc.getLineNumber</strong>(handle: LineHandle) → integer</code></dt>
|
902
|
+
<dd>Given a line handle, returns the current position of that
|
903
|
+
line (or <code>null</code> when it is no longer in the
|
904
|
+
document).</dd>
|
905
|
+
<dt id="eachLine"><code><strong>doc.eachLine</strong>(f: (line: LineHandle))</code></dt>
|
906
|
+
<dt><code><strong>doc.eachLine</strong>(start: integer, end: integer, f: (line: LineHandle))</code></dt>
|
907
|
+
<dd>Iterate over the whole document, or if <code>start</code>
|
908
|
+
and <code>end</code> line numbers are given, the range
|
909
|
+
from <code>start</code> up to (not including) <code>end</code>,
|
910
|
+
and call <code>f</code> for each line, passing the line handle.
|
911
|
+
This is a faster way to visit a range of line handlers than
|
912
|
+
calling <a href="#getLineHandle"><code>getLineHandle</code></a>
|
913
|
+
for each of them. Note that line handles have
|
914
|
+
a <code>text</code> property containing the line's content (as a
|
915
|
+
string).</dd>
|
916
|
+
|
917
|
+
<dt id="markClean"><code><strong>doc.markClean</strong>()</code></dt>
|
918
|
+
<dd>Set the editor content as 'clean', a flag that it will
|
919
|
+
retain until it is edited, and which will be set again when such
|
920
|
+
an edit is undone again. Useful to track whether the content
|
921
|
+
needs to be saved. This function is deprecated in favor
|
922
|
+
of <a href="#changeGeneration"><code>changeGeneration</code></a>,
|
923
|
+
which allows multiple subsystems to track different notions of
|
924
|
+
cleanness without interfering.</dd>
|
925
|
+
<dt id="changeGeneration"><code><strong>doc.changeGeneration</strong>() → integer</code></dt>
|
926
|
+
<dd>Returns a number that can later be passed
|
927
|
+
to <a href="#isClean"><code>isClean</code></a> to test whether
|
928
|
+
any edits were made (and not undone) in the meantime.</dd>
|
929
|
+
<dt id="isClean"><code><strong>doc.isClean</strong>(?generation: integer) → boolean</code></dt>
|
930
|
+
<dd>Returns whether the document is currently clean — not
|
931
|
+
modified since initialization or the last call
|
932
|
+
to <a href="#markClean"><code>markClean</code></a> if no
|
933
|
+
argument is passed, or since the matching call
|
934
|
+
to <a href="#changeGeneration"><code>changeGeneration</code></a>
|
935
|
+
if a generation value is given.</dd>
|
936
|
+
</dl>
|
937
|
+
|
938
|
+
<h3 id="api_selection">Cursor and selection methods</h3>
|
939
|
+
|
940
|
+
<dl>
|
941
|
+
<dt id="getSelection"><code><strong>doc.getSelection</strong>() → string</code></dt>
|
942
|
+
<dd>Get the currently selected code.</dd>
|
943
|
+
<dt id="replaceSelection"><code><strong>doc.replaceSelection</strong>(replacement: string, ?collapse: string)</code></dt>
|
944
|
+
<dd>Replace the selection with the given string. By default, the
|
945
|
+
new selection will span the inserted text. The
|
946
|
+
optional <code>collapse</code> argument can be used to change
|
947
|
+
this—passing <code>"start"</code> or <code>"end"</code> will
|
948
|
+
collapse the selection to the start or end of the inserted
|
949
|
+
text.</dd>
|
950
|
+
|
951
|
+
<dt id="getCursor"><code><strong>doc.getCursor</strong>(?start: string) → {line, ch}</code></dt>
|
952
|
+
<dd><code>start</code> is a an optional string indicating which
|
953
|
+
end of the selection to return. It may
|
954
|
+
be <code>"start"</code>, <code>"end"</code>, <code>"head"</code>
|
955
|
+
(the side of the selection that moves when you press
|
956
|
+
shift+arrow), or <code>"anchor"</code> (the fixed side of the
|
957
|
+
selection). Omitting the argument is the same as
|
958
|
+
passing <code>"head"</code>. A <code>{line, ch}</code> object
|
959
|
+
will be returned.</dd>
|
960
|
+
<dt id="somethingSelected"><code><strong>doc.somethingSelected</strong>() → boolean</code></dt>
|
961
|
+
<dd>Return true if any text is selected.</dd>
|
962
|
+
<dt id="setCursor"><code><strong>doc.setCursor</strong>(pos: {line, ch})</code></dt>
|
963
|
+
<dd>Set the cursor position. You can either pass a
|
964
|
+
single <code>{line, ch}</code> object, or the line and the
|
965
|
+
character as two separate parameters.</dd>
|
966
|
+
<dt id="setSelection"><code><strong>doc.setSelection</strong>(anchor: {line, ch}, ?head: {line, ch})</code></dt>
|
967
|
+
<dd>Set the selection range. <code>anchor</code>
|
968
|
+
and <code>head</code> should be <code>{line, ch}</code>
|
969
|
+
objects. <code>head</code> defaults to <code>anchor</code> when
|
970
|
+
not given.</dd>
|
971
|
+
<dt id="extendSelection"><code><strong>doc.extendSelection</strong>(from: {line, ch}, ?to: {line, ch})</code></dt>
|
972
|
+
<dd>Similar
|
973
|
+
to <a href="#setSelection"><code>setSelection</code></a>, but
|
974
|
+
will, if shift is held or
|
975
|
+
the <a href="#setExtending">extending</a> flag is set, move the
|
976
|
+
head of the selection while leaving the anchor at its current
|
977
|
+
place. <code>to</code> is optional, and can be passed to
|
978
|
+
ensure a region (for example a word or paragraph) will end up
|
979
|
+
selected (in addition to whatever lies between that region and
|
980
|
+
the current anchor).</dd>
|
981
|
+
<dt id="setExtending"><code><strong>doc.setExtending</strong>(value: boolean)</code></dt>
|
982
|
+
<dd>Sets or clears the 'extending' flag, which acts similar to
|
983
|
+
the shift key, in that it will cause cursor movement and calls
|
984
|
+
to <a href="#extendSelection"><code>extendSelection</code></a>
|
985
|
+
to leave the selection anchor in place.</dd>
|
986
|
+
|
987
|
+
<dt id="hasFocus"><code><strong>cm.hasFocus</strong>() → boolean</code></dt>
|
988
|
+
<dd>Tells you whether the editor currently has focus.</dd>
|
989
|
+
|
990
|
+
<dt id="findPosH"><code><strong>cm.findPosH</strong>(start: {line, ch}, amount: integer, unit: string, visually: boolean) → {line, ch, ?hitSide: boolean}</code></dt>
|
991
|
+
<dd>Used to find the target position for horizontal cursor
|
992
|
+
motion. <code>start</code> is a <code>{line, ch}</code>
|
993
|
+
object, <code>amount</code> an integer (may be negative),
|
994
|
+
and <code>unit</code> one of the
|
995
|
+
string <code>"char"</code>, <code>"column"</code>,
|
996
|
+
or <code>"word"</code>. Will return a position that is produced
|
997
|
+
by moving <code>amount</code> times the distance specified
|
998
|
+
by <code>unit</code>. When <code>visually</code> is true, motion
|
999
|
+
in right-to-left text will be visual rather than logical. When
|
1000
|
+
the motion was clipped by hitting the end or start of the
|
1001
|
+
document, the returned value will have a <code>hitSide</code>
|
1002
|
+
property set to true.</dd>
|
1003
|
+
<dt id="findPosV"><code><strong>cm.findPosV</strong>(start: {line, ch}, amount: integer, unit: string) → {line, ch, ?hitSide: boolean}</code></dt>
|
1004
|
+
<dd>Similar to <a href="#findPosH"><code>findPosH</code></a>,
|
1005
|
+
but used for vertical motion. <code>unit</code> may
|
1006
|
+
be <code>"line"</code> or <code>"page"</code>. The other
|
1007
|
+
arguments and the returned value have the same interpretation as
|
1008
|
+
they have in <code>findPosH</code>.</dd>
|
1009
|
+
</dl>
|
1010
|
+
|
1011
|
+
<h3 id="api_configuration">Configuration methods</h3>
|
1012
|
+
|
1013
|
+
<dl>
|
1014
|
+
<dt id="setOption"><code><strong>cm.setOption</strong>(option: string, value: any)</code></dt>
|
1015
|
+
<dd>Change the configuration of the editor. <code>option</code>
|
1016
|
+
should the name of an <a href="#config">option</a>,
|
1017
|
+
and <code>value</code> should be a valid value for that
|
1018
|
+
option.</dd>
|
1019
|
+
<dt id="getOption"><code><strong>cm.getOption</strong>(option: string) → any</code></dt>
|
1020
|
+
<dd>Retrieves the current value of the given option for this
|
1021
|
+
editor instance.</dd>
|
1022
|
+
|
1023
|
+
<dt id="addKeyMap"><code><strong>cm.addKeyMap</strong>(map: object, bottom: boolean)</code></dt>
|
1024
|
+
<dd>Attach an additional <a href="#keymaps">keymap</a> to the
|
1025
|
+
editor. This is mostly useful for addons that need to register
|
1026
|
+
some key handlers without trampling on
|
1027
|
+
the <a href="#option_extraKeys"><code>extraKeys</code></a>
|
1028
|
+
option. Maps added in this way have a higher precedence than
|
1029
|
+
the <code>extraKeys</code>
|
1030
|
+
and <a href="#option_keyMap"><code>keyMap</code></a> options,
|
1031
|
+
and between them, the maps added earlier have a lower precedence
|
1032
|
+
than those added later, unless the <code>bottom</code> argument
|
1033
|
+
was passed, in which case they end up below other keymaps added
|
1034
|
+
with this method.</dd>
|
1035
|
+
<dt id="removeKeyMap"><code><strong>cm.removeKeyMap</strong>(map: object)</code></dt>
|
1036
|
+
<dd>Disable a keymap added
|
1037
|
+
with <a href="#addKeyMap"><code>addKeyMap</code></a>. Either
|
1038
|
+
pass in the keymap object itself, or a string, which will be
|
1039
|
+
compared against the <code>name</code> property of the active
|
1040
|
+
keymaps.</dd>
|
1041
|
+
|
1042
|
+
<dt id="addOverlay"><code><strong>cm.addOverlay</strong>(mode: string|object, ?options: object)</code></dt>
|
1043
|
+
<dd>Enable a highlighting overlay. This is a stateless mini-mode
|
1044
|
+
that can be used to add extra highlighting. For example,
|
1045
|
+
the <a href="../demo/search.html">search addon</a> uses it to
|
1046
|
+
highlight the term that's currently being
|
1047
|
+
searched. <code>mode</code> can be a <a href="#option_mode">mode
|
1048
|
+
spec</a> or a mode object (an object with
|
1049
|
+
a <a href="#token"><code>token</code></a> method).
|
1050
|
+
The <code>options</code> parameter is optional. If given, it
|
1051
|
+
should be an object. Currently, only the <code>opaque</code>
|
1052
|
+
option is recognized. This defaults to off, but can be given to
|
1053
|
+
allow the overlay styling, when not <code>null</code>, to
|
1054
|
+
override the styling of the base mode entirely, instead of the
|
1055
|
+
two being applied together.</dd>
|
1056
|
+
<dt id="removeOverlay"><code><strong>cm.removeOverlay</strong>(mode: string|object)</code></dt>
|
1057
|
+
<dd>Pass this the exact value passed for the <code>mode</code>
|
1058
|
+
parameter to <a href="#addOverlay"><code>addOverlay</code></a>,
|
1059
|
+
or a string that corresponds to the <code>name</code> propery of
|
1060
|
+
that value, to remove an overlay again.</dd>
|
1061
|
+
|
1062
|
+
<dt id="on"><code><strong>cm.on</strong>(type: string, func: (...args))</code></dt>
|
1063
|
+
<dd>Register an event handler for the given event type (a
|
1064
|
+
string) on the editor instance. There is also
|
1065
|
+
a <code>CodeMirror.on(object, type, func)</code> version
|
1066
|
+
that allows registering of events on any object.</dd>
|
1067
|
+
<dt id="off"><code><strong>cm.off</strong>(type: string, func: (...args))</code></dt>
|
1068
|
+
<dd>Remove an event handler on the editor instance. An
|
1069
|
+
equivalent <code>CodeMirror.off(object, type,
|
1070
|
+
func)</code> also exists.</dd>
|
1071
|
+
</dl>
|
1072
|
+
|
1073
|
+
<h3 id="api_doc">Document management methods</h3>
|
1074
|
+
|
1075
|
+
<p id="Doc">Each editor is associated with an instance
|
1076
|
+
of <code>CodeMirror.Doc</code>, its document. A document
|
1077
|
+
represents the editor content, plus a selection, an undo history,
|
1078
|
+
and a <a href="#option_mode">mode</a>. A document can only be
|
1079
|
+
associated with a single editor at a time. You can create new
|
1080
|
+
documents by calling the <code>CodeMirror.Doc(text, mode,
|
1081
|
+
firstLineNumber)</code> constructor. The last two arguments are
|
1082
|
+
optional and can be used to set a mode for the document and make
|
1083
|
+
it start at a line number other than 0, respectively.</p>
|
1084
|
+
|
1085
|
+
<dl>
|
1086
|
+
<dt id="getDoc"><code><strong>cm.getDoc</strong>() → Doc</code></dt>
|
1087
|
+
<dd>Retrieve the currently active document from an editor.</dd>
|
1088
|
+
<dt id="getEditor"><code><strong>doc.getEditor</strong>() → CodeMirror</code></dt>
|
1089
|
+
<dd>Retrieve the editor associated with a document. May
|
1090
|
+
return <code>null</code>.</dd>
|
1091
|
+
|
1092
|
+
<dt id="swapDoc"><code><strong>cm.swapDoc</strong>(doc: CodeMirror.Doc) → Doc</code></dt>
|
1093
|
+
<dd>Attach a new document to the editor. Returns the old
|
1094
|
+
document, which is now no longer associated with an editor.</dd>
|
1095
|
+
|
1096
|
+
<dt id="copy"><code><strong>doc.copy</strong>(copyHistory: boolean) → Doc</code></dt>
|
1097
|
+
<dd>Create an identical copy of the given doc.
|
1098
|
+
When <code>copyHistory</code> is true, the history will also be
|
1099
|
+
copied. Can not be called directly on an editor.</dd>
|
1100
|
+
|
1101
|
+
<dt id="linkedDoc"><code><strong>doc.linkedDoc</strong>(options: object) → Doc</code></dt>
|
1102
|
+
<dd>Create a new document that's linked to the target document.
|
1103
|
+
Linked documents will stay in sync (changes to one are also
|
1104
|
+
applied to the other) until <a href="#unlinkDoc">unlinked</a>.
|
1105
|
+
These are the options that are supported:
|
1106
|
+
<dl>
|
1107
|
+
<dt id="linkedDoc_sharedHist"><code><strong>sharedHist</strong>: boolean</code></dt>
|
1108
|
+
<dd>When turned on, the linked copy will share an undo
|
1109
|
+
history with the original. Thus, something done in one of
|
1110
|
+
the two can be undone in the other, and vice versa.</dd>
|
1111
|
+
<dt id="linkedDoc_from"><code><strong>from</strong>: integer</code></dt>
|
1112
|
+
<dt id="linkedDoc_to"><code><strong>to</strong>: integer</code></dt>
|
1113
|
+
<dd>Can be given to make the new document a subview of the
|
1114
|
+
original. Subviews only show a given range of lines. Note
|
1115
|
+
that line coordinates inside the subview will be consistent
|
1116
|
+
with those of the parent, so that for example a subview
|
1117
|
+
starting at line 10 will refer to its first line as line 10,
|
1118
|
+
not 0.</dd>
|
1119
|
+
<dt id="linkedDoc_mode"><code><strong>mode</strong>: string|object</code></dt>
|
1120
|
+
<dd>By default, the new document inherits the mode of the
|
1121
|
+
parent. This option can be set to
|
1122
|
+
a <a href="#option_mode">mode spec</a> to give it a
|
1123
|
+
different mode.</dd>
|
1124
|
+
</dl></dd>
|
1125
|
+
<dt id="unlinkDoc"><code><strong>doc.unlinkDoc</strong>(doc: CodeMirror.Doc)</code></dt>
|
1126
|
+
<dd>Break the link between two documents. After calling this,
|
1127
|
+
changes will no longer propagate between the documents, and, if
|
1128
|
+
they had a shared history, the history will become
|
1129
|
+
separate.</dd>
|
1130
|
+
<dt id="iterLinkedDocs"><code><strong>doc.iterLinkedDocs</strong>(function: (doc: CodeMirror.Doc, sharedHist: boolean))</code></dt>
|
1131
|
+
<dd>Will call the given function for all documents linked to the
|
1132
|
+
target document. It will be passed two arguments, the linked document
|
1133
|
+
and a boolean indicating whether that document shares history
|
1134
|
+
with the target.</dd>
|
1135
|
+
</dl>
|
1136
|
+
|
1137
|
+
<h3 id="api_history">History-related methods</h3>
|
1138
|
+
|
1139
|
+
<dl>
|
1140
|
+
<dt id="undo"><code><strong>doc.undo</strong>()</code></dt>
|
1141
|
+
<dd>Undo one edit (if any undo events are stored).</dd>
|
1142
|
+
<dt id="redo"><code><strong>doc.redo</strong>()</code></dt>
|
1143
|
+
<dd>Redo one undone edit.</dd>
|
1144
|
+
|
1145
|
+
<dt id="historySize"><code><strong>doc.historySize</strong>() → {undo: integer, redo: integer}</code></dt>
|
1146
|
+
<dd>Returns an object with <code>{undo, redo}</code> properties,
|
1147
|
+
both of which hold integers, indicating the amount of stored
|
1148
|
+
undo and redo operations.</dd>
|
1149
|
+
<dt id="clearHistory"><code><strong>doc.clearHistory</strong>()</code></dt>
|
1150
|
+
<dd>Clears the editor's undo history.</dd>
|
1151
|
+
<dt id="getHistory"><code><strong>doc.getHistory</strong>() → object</code></dt>
|
1152
|
+
<dd>Get a (JSON-serializeable) representation of the undo history.</dd>
|
1153
|
+
<dt id="setHistory"><code><strong>doc.setHistory</strong>(history: object)</code></dt>
|
1154
|
+
<dd>Replace the editor's undo history with the one provided,
|
1155
|
+
which must be a value as returned
|
1156
|
+
by <a href="#getHistory"><code>getHistory</code></a>. Note that
|
1157
|
+
this will have entirely undefined results if the editor content
|
1158
|
+
isn't also the same as it was when <code>getHistory</code> was
|
1159
|
+
called.</dd>
|
1160
|
+
</dl>
|
1161
|
+
|
1162
|
+
<h3 id="api_marker">Text-marking methods</h3>
|
1163
|
+
|
1164
|
+
<dl>
|
1165
|
+
<dt id="markText"><code><strong>doc.markText</strong>(from: {line, ch}, to: {line, ch}, ?options: object) → TextMarker</code></dt>
|
1166
|
+
<dd>Can be used to mark a range of text with a specific CSS
|
1167
|
+
class name. <code>from</code> and <code>to</code> should
|
1168
|
+
be <code>{line, ch}</code> objects. The <code>options</code>
|
1169
|
+
parameter is optional. When given, it should be an object that
|
1170
|
+
may contain the following configuration options:
|
1171
|
+
<dl>
|
1172
|
+
<dt id="mark_className"><code><strong>className</strong>: string</code></dt>
|
1173
|
+
<dd>Assigns a CSS class to the marked stretch of text.</dd>
|
1174
|
+
<dt id="mark_inclusiveLeft"><code><strong>inclusiveLeft</strong>: boolean</code></dt>
|
1175
|
+
<dd>Determines whether
|
1176
|
+
text inserted on the left of the marker will end up inside
|
1177
|
+
or outside of it.</dd>
|
1178
|
+
<dt id="mark_inclusiveRight"><code><strong>inclusiveRight</strong>: boolean</code></dt>
|
1179
|
+
<dd>Like <code>inclusiveLeft</code>,
|
1180
|
+
but for the right side.</dd>
|
1181
|
+
<dt id="mark_atomic"><code><strong>atomic</strong>: boolean</code></dt>
|
1182
|
+
<dd>Atomic ranges act as a single unit when cursor movement is
|
1183
|
+
concerned—i.e. it is impossible to place the cursor inside of
|
1184
|
+
them. In atomic ranges, <code>inclusiveLeft</code>
|
1185
|
+
and <code>inclusiveRight</code> have a different meaning—they
|
1186
|
+
will prevent the cursor from being placed respectively
|
1187
|
+
directly before and directly after the range.</dd>
|
1188
|
+
<dt id="mark_collapsed"><code><strong>collapsed</strong>: boolean</code></dt>
|
1189
|
+
<dd>Collapsed ranges do not show up in the display. Setting a
|
1190
|
+
range to be collapsed will automatically make it atomic.</dd>
|
1191
|
+
<dt id="mark_clearOnEnter"><code><strong>clearOnEnter</strong>: boolean</code></dt>
|
1192
|
+
<dd>When enabled, will cause the mark to clear itself whenever
|
1193
|
+
the cursor enters its range. This is mostly useful for
|
1194
|
+
text-replacement widgets that need to 'snap open' when the
|
1195
|
+
user tries to edit them. The
|
1196
|
+
<a href="#event_clear"><code>"clear"</code></a> event
|
1197
|
+
fired on the range handle can be used to be notified when this
|
1198
|
+
happens.</dd>
|
1199
|
+
<dt id="mark_replacedWith"><code><strong>replacedWith</strong>: Element</code></dt>
|
1200
|
+
<dd>Use a given node to display this range. Implies both
|
1201
|
+
collapsed and atomic. The given DOM node <em>must</em> be an
|
1202
|
+
inline element (as opposed to a block element).</dd>
|
1203
|
+
<dt><code><strong>handleMouseEvents</strong>: boolean</code></dt>
|
1204
|
+
<dd>When <code>replacedWith</code> is given, this determines
|
1205
|
+
whether the editor will capture mouse and drag events
|
1206
|
+
occurring in this widget. Default is false—the events will be
|
1207
|
+
left alone for the default browser handler, or specific
|
1208
|
+
handlers on the widget, to capture.</dd>
|
1209
|
+
<dt id="mark_readOnly"><code><strong>readOnly</strong>: boolean</code></dt>
|
1210
|
+
<dd>A read-only span can, as long as it is not cleared, not be
|
1211
|
+
modified except by
|
1212
|
+
calling <a href="#setValue"><code>setValue</code></a> to reset
|
1213
|
+
the whole document. <em>Note:</em> adding a read-only span
|
1214
|
+
currently clears the undo history of the editor, because
|
1215
|
+
existing undo events being partially nullified by read-only
|
1216
|
+
spans would corrupt the history (in the current
|
1217
|
+
implementation).</dd>
|
1218
|
+
<dt id="mark_addToHistory"><code><strong>addToHistory</strong>: boolean</code></dt>
|
1219
|
+
<dd>When set to true (default is false), adding this marker
|
1220
|
+
will create an event in the undo history that can be
|
1221
|
+
individually undone (clearing the marker).</dd>
|
1222
|
+
<dt id="mark_startStyle"><code><strong>startStyle</strong>: string</code></dt><dd>Can be used to specify
|
1223
|
+
an extra CSS class to be applied to the leftmost span that
|
1224
|
+
is part of the marker.</dd>
|
1225
|
+
<dt id="mark_endStyle"><code><strong>endStyle</strong>: string</code></dt><dd>Equivalent
|
1226
|
+
to <code>startStyle</code>, but for the rightmost span.</dd>
|
1227
|
+
<dt id="mark_title"><code><strong>title</strong>:
|
1228
|
+
string</code></dt><dd>When given, will give the nodes created
|
1229
|
+
for this span a HTML <code>title</code> attribute with the
|
1230
|
+
given value.</dd>
|
1231
|
+
<dt id="mark_shared"><code><strong>shared</strong>: boolean</code></dt><dd>When the
|
1232
|
+
target document is <a href="#linkedDoc">linked</a> to other
|
1233
|
+
documents, you can set <code>shared</code> to true to make the
|
1234
|
+
marker appear in all documents. By default, a marker appears
|
1235
|
+
only in its target document.</dd>
|
1236
|
+
</dl>
|
1237
|
+
The method will return an object that represents the marker
|
1238
|
+
(with constuctor <code>CodeMirror.TextMarker</code>), which
|
1239
|
+
exposes three methods:
|
1240
|
+
<code><strong>clear</strong>()</code>, to remove the mark,
|
1241
|
+
<code><strong>find</strong>()</code>, which returns
|
1242
|
+
a <code>{from, to}</code> object (both holding document
|
1243
|
+
positions), indicating the current position of the marked range,
|
1244
|
+
or <code>undefined</code> if the marker is no longer in the
|
1245
|
+
document, and finally <code><strong>changed</strong>()</code>,
|
1246
|
+
which you can call if you've done something that might change
|
1247
|
+
the size of the marker (for example changing the content of
|
1248
|
+
a <a href="#mark_replacedWith"><code>replacedWith</code></a>
|
1249
|
+
node), and want to cheaply update the display.</dd>
|
1250
|
+
|
1251
|
+
<dt id="setBookmark"><code><strong>doc.setBookmark</strong>(pos: {line, ch}, ?options: object) → TextMarker</code></dt>
|
1252
|
+
<dd>Inserts a bookmark, a handle that follows the text around it
|
1253
|
+
as it is being edited, at the given position. A bookmark has two
|
1254
|
+
methods <code>find()</code> and <code>clear()</code>. The first
|
1255
|
+
returns the current position of the bookmark, if it is still in
|
1256
|
+
the document, and the second explicitly removes the bookmark.
|
1257
|
+
The options argument is optional. If given, the following
|
1258
|
+
properties are recognized:
|
1259
|
+
<dl>
|
1260
|
+
<dt><code><strong>widget</strong>: Element</code></dt><dd>Can be used to display a DOM
|
1261
|
+
node at the current location of the bookmark (analogous to
|
1262
|
+
the <a href="#mark_replacedWith"><code>replacedWith</code></a>
|
1263
|
+
option to <code>markText</code>).</dd>
|
1264
|
+
<dt><code><strong>insertLeft</strong>: boolean</code></dt><dd>By default, text typed
|
1265
|
+
when the cursor is on top of the bookmark will end up to the
|
1266
|
+
right of the bookmark. Set this option to true to make it go
|
1267
|
+
to the left instead.</dd>
|
1268
|
+
</dl></dd>
|
1269
|
+
|
1270
|
+
<dt id="findMarksAt"><code><strong>doc.findMarksAt</strong>(pos: {line, ch}) → array<TextMarker></code></dt>
|
1271
|
+
<dd>Returns an array of all the bookmarks and marked ranges
|
1272
|
+
present at the given position.</dd>
|
1273
|
+
<dt id="getAllMarks"><code><strong>doc.getAllMarks</strong>() → array<TextMarker></code></dt>
|
1274
|
+
<dd>Returns an array containing all marked ranges in the document.</dd>
|
1275
|
+
</dl>
|
1276
|
+
|
1277
|
+
<h3 id="api_decoration">Widget, gutter, and decoration methods</h3>
|
1278
|
+
|
1279
|
+
<dl>
|
1280
|
+
<dt id="setGutterMarker"><code><strong>cm.setGutterMarker</strong>(line: integer|LineHandle, gutterID: string, value: Element) → LineHandle</code></dt>
|
1281
|
+
<dd>Sets the gutter marker for the given gutter (identified by
|
1282
|
+
its CSS class, see
|
1283
|
+
the <a href="#option_gutters"><code>gutters</code></a> option)
|
1284
|
+
to the given value. Value can be either <code>null</code>, to
|
1285
|
+
clear the marker, or a DOM element, to set it. The DOM element
|
1286
|
+
will be shown in the specified gutter next to the specified
|
1287
|
+
line.</dd>
|
1288
|
+
|
1289
|
+
<dt id="clearGutter"><code><strong>cm.clearGutter</strong>(gutterID: string)</code></dt>
|
1290
|
+
<dd>Remove all gutter markers in
|
1291
|
+
the <a href="#option_gutters">gutter</a> with the given ID.</dd>
|
1292
|
+
|
1293
|
+
<dt id="addLineClass"><code><strong>cm.addLineClass</strong>(line: integer|LineHandle, where: string, class: string) → LineHandle</code></dt>
|
1294
|
+
<dd>Set a CSS class name for the given line. <code>line</code>
|
1295
|
+
can be a number or a line handle. <code>where</code> determines
|
1296
|
+
to which element this class should be applied, can can be one
|
1297
|
+
of <code>"text"</code> (the text element, which lies in front of
|
1298
|
+
the selection), <code>"background"</code> (a background element
|
1299
|
+
that will be behind the selection), or <code>"wrap"</code> (the
|
1300
|
+
wrapper node that wraps all of the line's elements, including
|
1301
|
+
gutter elements). <code>class</code> should be the name of the
|
1302
|
+
class to apply.</dd>
|
1303
|
+
|
1304
|
+
<dt id="removeLineClass"><code><strong>cm.removeLineClass</strong>(line: integer|LineHandle, where: string, class: string) → LineHandle</code></dt>
|
1305
|
+
<dd>Remove a CSS class from a line. <code>line</code> can be a
|
1306
|
+
line handle or number. <code>where</code> should be one
|
1307
|
+
of <code>"text"</code>, <code>"background"</code>,
|
1308
|
+
or <code>"wrap"</code>
|
1309
|
+
(see <a href="#addLineClass"><code>addLineClass</code></a>). <code>class</code>
|
1310
|
+
can be left off to remove all classes for the specified node, or
|
1311
|
+
be a string to remove only a specific class.</dd>
|
1312
|
+
|
1313
|
+
<dt id="lineInfo"><code><strong>cm.lineInfo</strong>(line: integer|LineHandle) → object</code></dt>
|
1314
|
+
<dd>Returns the line number, text content, and marker status of
|
1315
|
+
the given line, which can be either a number or a line handle.
|
1316
|
+
The returned object has the structure <code>{line, handle, text,
|
1317
|
+
gutterMarkers, textClass, bgClass, wrapClass, widgets}</code>,
|
1318
|
+
where <code>gutterMarkers</code> is an object mapping gutter IDs
|
1319
|
+
to marker elements, and <code>widgets</code> is an array
|
1320
|
+
of <a href="#addLineWidget">line widgets</a> attached to this
|
1321
|
+
line, and the various class properties refer to classes added
|
1322
|
+
with <a href="#addLineClass"><code>addLineClass</code></a>.</dd>
|
1323
|
+
|
1324
|
+
<dt id="addWidget"><code><strong>cm.addWidget</strong>(pos: {line, ch}, node: Element, scrollIntoView: boolean)</code></dt>
|
1325
|
+
<dd>Puts <code>node</code>, which should be an absolutely
|
1326
|
+
positioned DOM node, into the editor, positioned right below the
|
1327
|
+
given <code>{line, ch}</code> position.
|
1328
|
+
When <code>scrollIntoView</code> is true, the editor will ensure
|
1329
|
+
that the entire node is visible (if possible). To remove the
|
1330
|
+
widget again, simply use DOM methods (move it somewhere else, or
|
1331
|
+
call <code>removeChild</code> on its parent).</dd>
|
1332
|
+
|
1333
|
+
<dt id="addLineWidget"><code><strong>cm.addLineWidget</strong>(line: integer|LineHandle, node: Element, ?options: object) → LineWidget</code></dt>
|
1334
|
+
<dd>Adds a line widget, an element shown below a line, spanning
|
1335
|
+
the whole of the editor's width, and moving the lines below it
|
1336
|
+
downwards. <code>line</code> should be either an integer or a
|
1337
|
+
line handle, and <code>node</code> should be a DOM node, which
|
1338
|
+
will be displayed below the given line. <code>options</code>,
|
1339
|
+
when given, should be an object that configures the behavior of
|
1340
|
+
the widget. The following options are supported (all default to
|
1341
|
+
false):
|
1342
|
+
<dl>
|
1343
|
+
<dt><code><strong>coverGutter</strong>: boolean</code></dt>
|
1344
|
+
<dd>Whether the widget should cover the gutter.</dd>
|
1345
|
+
<dt><code><strong>noHScroll</strong>: boolean</code></dt>
|
1346
|
+
<dd>Whether the widget should stay fixed in the face of
|
1347
|
+
horizontal scrolling.</dd>
|
1348
|
+
<dt><code><strong>above</strong>: boolean</code></dt>
|
1349
|
+
<dd>Causes the widget to be placed above instead of below
|
1350
|
+
the text of the line.</dd>
|
1351
|
+
<dt><code><strong>showIfHidden</strong>: boolean</code></dt>
|
1352
|
+
<dd>When true, will cause the widget to be rendered even if
|
1353
|
+
the line it is associated with is hidden.</dd>
|
1354
|
+
<dt><code><strong>handleMouseEvents</strong>: boolean</code></dt>
|
1355
|
+
<dd>Determines whether the editor will capture mouse and
|
1356
|
+
drag events occurring in this widget. Default is false—the
|
1357
|
+
events will be left alone for the default browser handler,
|
1358
|
+
or specific handlers on the widget, to capture.</dd>
|
1359
|
+
<dt><code><strong>insertAt</strong>: integer</code></dt>
|
1360
|
+
<dd>By default, the widget is added below other widgets for
|
1361
|
+
the line. This option can be used to place it at a different
|
1362
|
+
position (zero for the top, N to put it after the Nth other
|
1363
|
+
widget). Note that this only has effect once, when the
|
1364
|
+
widget is created.
|
1365
|
+
</dl>
|
1366
|
+
Note that the widget node will become a descendant of nodes with
|
1367
|
+
CodeMirror-specific CSS classes, and those classes might in some
|
1368
|
+
cases affect it. This method returns an object that represents
|
1369
|
+
the widget placement. It'll have a <code>line</code> property
|
1370
|
+
pointing at the line handle that it is associated with, and the following methods:
|
1371
|
+
<dl>
|
1372
|
+
<dt id="widget_clear"><code><strong>clear</strong>()</code></dt><dd>Removes the widget.</dd>
|
1373
|
+
<dt id="widget_changed"><code><strong>changed</strong>()</code></dt><dd>Call
|
1374
|
+
this if you made some change to the widget's DOM node that
|
1375
|
+
might affect its height. It'll force CodeMirror to update
|
1376
|
+
the height of the line that contains the widget.</dd>
|
1377
|
+
</dl>
|
1378
|
+
</dd>
|
1379
|
+
</dl>
|
1380
|
+
|
1381
|
+
<h3 id="api_sizing">Sizing, scrolling and positioning methods</h3>
|
1382
|
+
|
1383
|
+
<dl>
|
1384
|
+
<dt id="setSize"><code><strong>cm.setSize</strong>(width: number|string, height: number|string)</code></dt>
|
1385
|
+
<dd>Programatically set the size of the editor (overriding the
|
1386
|
+
applicable <a href="#css-resize">CSS
|
1387
|
+
rules</a>). <code>width</code> and <code>height</code>
|
1388
|
+
can be either numbers (interpreted as pixels) or CSS units
|
1389
|
+
(<code>"100%"</code>, for example). You can
|
1390
|
+
pass <code>null</code> for either of them to indicate that that
|
1391
|
+
dimension should not be changed.</dd>
|
1392
|
+
|
1393
|
+
<dt id="scrollTo"><code><strong>cm.scrollTo</strong>(x: number, y: number)</code></dt>
|
1394
|
+
<dd>Scroll the editor to a given (pixel) position. Both
|
1395
|
+
arguments may be left as <code>null</code>
|
1396
|
+
or <code>undefined</code> to have no effect.</dd>
|
1397
|
+
<dt id="getScrollInfo"><code><strong>cm.getScrollInfo</strong>() → {left, top, width, height, clientWidth, clientHeight}</code></dt>
|
1398
|
+
<dd>Get an <code>{left, top, width, height, clientWidth,
|
1399
|
+
clientHeight}</code> object that represents the current scroll
|
1400
|
+
position, the size of the scrollable area, and the size of the
|
1401
|
+
visible area (minus scrollbars).</dd>
|
1402
|
+
<dt id="scrollIntoView"><code><strong>cm.scrollIntoView</strong>(what: {line, ch}|{left, top, right, bottom}|{from, to}|null, ?margin: number)</code></dt>
|
1403
|
+
<dd>Scrolls the given position into view. <code>what</code> may
|
1404
|
+
be <code>null</code> to scroll the cursor into view,
|
1405
|
+
a <code>{line, ch}</code> position to scroll a character into
|
1406
|
+
view, a <code>{left, top, right, bottom}</code> pixel range (in
|
1407
|
+
editor-local coordinates), or a range <code>{from, to}</code>
|
1408
|
+
containing either two character positions or two pixel squares.
|
1409
|
+
The <code>margin</code> parameter is optional. When given, it
|
1410
|
+
indicates the amount of vertical pixels around the given area
|
1411
|
+
that should be made visible as well.</dd>
|
1412
|
+
|
1413
|
+
<dt id="cursorCoords"><code><strong>cm.cursorCoords</strong>(where: boolean|{line, ch}, mode: string) → {left, top, bottom}</code></dt>
|
1414
|
+
<dd>Returns an <code>{left, top, bottom}</code> object
|
1415
|
+
containing the coordinates of the cursor position.
|
1416
|
+
If <code>mode</code> is <code>"local"</code>, they will be
|
1417
|
+
relative to the top-left corner of the editable document. If it
|
1418
|
+
is <code>"page"</code> or not given, they are relative to the
|
1419
|
+
top-left corner of the page. <code>where</code> can be a boolean
|
1420
|
+
indicating whether you want the start (<code>true</code>) or the
|
1421
|
+
end (<code>false</code>) of the selection, or, if a <code>{line,
|
1422
|
+
ch}</code> object is given, it specifies the precise position at
|
1423
|
+
which you want to measure.</dd>
|
1424
|
+
<dt id="charCoords"><code><strong>cm.charCoords</strong>(pos: {line, ch}, ?mode: string) → {left, right, top, bottom}</code></dt>
|
1425
|
+
<dd>Returns the position and dimensions of an arbitrary
|
1426
|
+
character. <code>pos</code> should be a <code>{line, ch}</code>
|
1427
|
+
object. This differs from <code>cursorCoords</code> in that
|
1428
|
+
it'll give the size of the whole character, rather than just the
|
1429
|
+
position that the cursor would have when it would sit at that
|
1430
|
+
position.</dd>
|
1431
|
+
<dt id="coordsChar"><code><strong>cm.coordsChar</strong>(object: {left, top}, ?mode: string) → {line, ch}</code></dt>
|
1432
|
+
<dd>Given an <code>{left, top}</code> object, returns
|
1433
|
+
the <code>{line, ch}</code> position that corresponds to it. The
|
1434
|
+
optional <code>mode</code> parameter determines relative to what
|
1435
|
+
the coordinates are interpreted. It may
|
1436
|
+
be <code>"window"</code>, <code>"page"</code> (the default),
|
1437
|
+
or <code>"local"</code>.</dd>
|
1438
|
+
<dt id="lineAtHeight"><code><strong>cm.lineAtHeight</strong>(height: number, ?mode: string) → number</code></dt>
|
1439
|
+
<dd>Computes the line at the given pixel
|
1440
|
+
height. <code>mode</code> can be one of the same strings
|
1441
|
+
that <a href="#coordsChar"><code>coordsChar</code></a>
|
1442
|
+
accepts.</dd>
|
1443
|
+
<dt id="heightAtLine"><code><strong>cm.heightAtLine</strong>(line: number, ?mode: string) → number</code></dt>
|
1444
|
+
<dd>Computes the height of the top of a line, in the coordinate
|
1445
|
+
system specified by <code>mode</code>
|
1446
|
+
(see <a href="#coordsChar"><code>coordsChar</code></a>), which
|
1447
|
+
defaults to <code>"page"</code>. When a line below the bottom of
|
1448
|
+
the document is specified, the returned value is the bottom of
|
1449
|
+
the last line in the document.</dd>
|
1450
|
+
<dt id="defaultTextHeight"><code><strong>cm.defaultTextHeight</strong>() → number</code></dt>
|
1451
|
+
<dd>Returns the line height of the default font for the editor.</dd>
|
1452
|
+
<dt id="defaultCharWidth"><code><strong>cm.defaultCharWidth</strong>() → number</code></dt>
|
1453
|
+
<dd>Returns the pixel width of an 'x' in the default font for
|
1454
|
+
the editor. (Note that for non-monospace fonts, this is mostly
|
1455
|
+
useless, and even for monospace fonts, non-ascii characters
|
1456
|
+
might have a different width).</dd>
|
1457
|
+
|
1458
|
+
<dt id="getViewport"><code><strong>cm.getViewport</strong>() → {from: number, to: number}</code></dt>
|
1459
|
+
<dd>Returns a <code>{from, to}</code> object indicating the
|
1460
|
+
start (inclusive) and end (exclusive) of the currently rendered
|
1461
|
+
part of the document. In big documents, when most content is
|
1462
|
+
scrolled out of view, CodeMirror will only render the visible
|
1463
|
+
part, and a margin around it. See also
|
1464
|
+
the <a href="#event_viewportChange"><code>viewportChange</code></a>
|
1465
|
+
event.</dd>
|
1466
|
+
|
1467
|
+
<dt id="refresh"><code><strong>cm.refresh</strong>()</code></dt>
|
1468
|
+
<dd>If your code does something to change the size of the editor
|
1469
|
+
element (window resizes are already listened for), or unhides
|
1470
|
+
it, you should probably follow up by calling this method to
|
1471
|
+
ensure CodeMirror is still looking as intended.</dd>
|
1472
|
+
</dl>
|
1473
|
+
|
1474
|
+
<h3 id="api_mode">Mode, state, and token-related methods</h3>
|
1475
|
+
|
1476
|
+
<p>When writing language-aware functionality, it can often be
|
1477
|
+
useful to hook into the knowledge that the CodeMirror language
|
1478
|
+
mode has. See <a href="#modeapi">the section on modes</a> for a
|
1479
|
+
more detailed description of how these work.</p>
|
1480
|
+
|
1481
|
+
<dl>
|
1482
|
+
<dt id="getMode"><code><strong>doc.getMode</strong>() → object</code></dt>
|
1483
|
+
<dd>Gets the (outer) mode object for the editor. Note that this
|
1484
|
+
is distinct from <code>getOption("mode")</code>, which gives you
|
1485
|
+
the mode specification, rather than the resolved, instantiated
|
1486
|
+
<a href="#defineMode">mode object</a>.</dd>
|
1487
|
+
|
1488
|
+
<dt id="getModeAt"><code><strong>doc.getModeAt</strong>(pos: {line, ch}) → object</code></dt>
|
1489
|
+
<dd>Gets the inner mode at a given position. This will return
|
1490
|
+
the same as <a href="#getMode"><code>getMode</code></a> for
|
1491
|
+
simple modes, but will return an inner mode for nesting modes
|
1492
|
+
(such as <code>htmlmixed</code>).</dd>
|
1493
|
+
|
1494
|
+
<dt id="getTokenAt"><code><strong>cm.getTokenAt</strong>(pos: {line, ch}, ?precise: boolean) → object</code></dt>
|
1495
|
+
<dd>Retrieves information about the token the current mode found
|
1496
|
+
before the given position (a <code>{line, ch}</code> object). The
|
1497
|
+
returned object has the following properties:
|
1498
|
+
<dl>
|
1499
|
+
<dt><code><strong>start</strong></code></dt><dd>The character (on the given line) at which the token starts.</dd>
|
1500
|
+
<dt><code><strong>end</strong></code></dt><dd>The character at which the token ends.</dd>
|
1501
|
+
<dt><code><strong>string</strong></code></dt><dd>The token's string.</dd>
|
1502
|
+
<dt><code><strong>type</strong></code></dt><dd>The token type the mode assigned
|
1503
|
+
to the token, such as <code>"keyword"</code>
|
1504
|
+
or <code>"comment"</code> (may also be null).</dd>
|
1505
|
+
<dt><code><strong>state</strong></code></dt><dd>The mode's state at the end of this token.</dd>
|
1506
|
+
</dl>
|
1507
|
+
If <code>precise</code> is true, the token will be guaranteed to be accurate based on recent edits. If false or
|
1508
|
+
not specified, the token will use cached state information, which will be faster but might not be accurate if
|
1509
|
+
edits were recently made and highlighting has not yet completed.
|
1510
|
+
</dd>
|
1511
|
+
|
1512
|
+
<dt id="getTokenTypeAt"><code><strong>cm.getTokenTypeAt</strong>(pos: {line, ch}) → string</code></dt>
|
1513
|
+
<dd>This is a (much) cheaper version
|
1514
|
+
of <a href="#getTokenAt"><code>getTokenAt</code></a> useful for
|
1515
|
+
when you just need the type of the token at a given position,
|
1516
|
+
and no other information. Will return <code>null</code> for
|
1517
|
+
unstyled tokens, and a string, potentially containing multiple
|
1518
|
+
space-separated style names, otherwise.</dd>
|
1519
|
+
|
1520
|
+
<dt id="getHelper"><code><strong>cm.getHelper</strong>(pos: {line, ch}, type: string) → helper</code></dt>
|
1521
|
+
<dd>Fetch appropriate helper for the given position. Helpers
|
1522
|
+
provide a way to look up functionality appropriate for a mode.
|
1523
|
+
The <code>type</code> argument provides the helper namespace
|
1524
|
+
(see
|
1525
|
+
also <a href="#registerHelper"><code>registerHelper</code></a>),
|
1526
|
+
in which the value will be looked up. The key that is used
|
1527
|
+
depends on the <a href="#getMode">mode</a> active at the given
|
1528
|
+
position. If the mode object contains a property with the same
|
1529
|
+
name as the <code>type</code> argument, that is tried first.
|
1530
|
+
Next, the mode's <code>helperType</code>, if any, is tried. And
|
1531
|
+
finally, the mode's name.</dd>
|
1532
|
+
|
1533
|
+
<dt id="getStateAfter"><code><strong>cm.getStateAfter</strong>(?line: integer, ?precise: boolean) → object</code></dt>
|
1534
|
+
<dd>Returns the mode's parser state, if any, at the end of the
|
1535
|
+
given line number. If no line number is given, the state at the
|
1536
|
+
end of the document is returned. This can be useful for storing
|
1537
|
+
parsing errors in the state, or getting other kinds of
|
1538
|
+
contextual information for a line. <code>precise</code> is defined
|
1539
|
+
as in <code>getTokenAt()</code>.</dd>
|
1540
|
+
</dl>
|
1541
|
+
|
1542
|
+
<h3 id="api_misc">Miscellaneous methods</h3>
|
1543
|
+
|
1544
|
+
<dl>
|
1545
|
+
<dt id="operation"><code><strong>cm.operation</strong>(func: () → any) → any</code></dt>
|
1546
|
+
<dd>CodeMirror internally buffers changes and only updates its
|
1547
|
+
DOM structure after it has finished performing some operation.
|
1548
|
+
If you need to perform a lot of operations on a CodeMirror
|
1549
|
+
instance, you can call this method with a function argument. It
|
1550
|
+
will call the function, buffering up all changes, and only doing
|
1551
|
+
the expensive update after the function returns. This can be a
|
1552
|
+
lot faster. The return value from this method will be the return
|
1553
|
+
value of your function.</dd>
|
1554
|
+
|
1555
|
+
<dt id="indentLine"><code><strong>cm.indentLine</strong>(line: integer, ?dir: string|integer)</code></dt>
|
1556
|
+
<dd>Adjust the indentation of the given line. The second
|
1557
|
+
argument (which defaults to <code>"smart"</code>) may be one of:
|
1558
|
+
<dl>
|
1559
|
+
<dt><code><strong>"prev"</strong></code></dt>
|
1560
|
+
<dd>Base indentation on the indentation of the previous line.</dd>
|
1561
|
+
<dt><code><strong>"smart"</strong></code></dt>
|
1562
|
+
<dd>Use the mode's smart indentation if available, behave
|
1563
|
+
like <code>"prev"</code> otherwise.</dd>
|
1564
|
+
<dt><code><strong>"add"</strong></code></dt>
|
1565
|
+
<dd>Increase the indentation of the line by
|
1566
|
+
one <a href="#option_indentUnit">indent unit</a>.</dd>
|
1567
|
+
<dt><code><strong>"subtract"</strong></code></dt>
|
1568
|
+
<dd>Reduce the indentation of the line.</dd>
|
1569
|
+
<dt><code><strong><integer></strong></code></dt>
|
1570
|
+
<dd>Add (positive number) or reduce (negative number) the
|
1571
|
+
indentation by the given amount of spaces.</dd>
|
1572
|
+
</dl></dd>
|
1573
|
+
|
1574
|
+
<dt id="toggleOverwrite"><code><strong>cm.toggleOverwrite</strong>(?value: bool)</code></dt>
|
1575
|
+
<dd>Switches between overwrite and normal insert mode (when not
|
1576
|
+
given an argument), or sets the overwrite mode to a specific
|
1577
|
+
state (when given an argument).</dd>
|
1578
|
+
|
1579
|
+
<dt id="posFromIndex"><code><strong>doc.posFromIndex</strong>(index: integer) → {line, ch}</code></dt>
|
1580
|
+
<dd>Calculates and returns a <code>{line, ch}</code> object for a
|
1581
|
+
zero-based <code>index</code> who's value is relative to the start of the
|
1582
|
+
editor's text. If the <code>index</code> is out of range of the text then
|
1583
|
+
the returned object is clipped to start or end of the text
|
1584
|
+
respectively.</dd>
|
1585
|
+
<dt id="indexFromPos"><code><strong>doc.indexFromPos</strong>(object: {line, ch}) → integer</code></dt>
|
1586
|
+
<dd>The reverse of <a href="#posFromIndex"><code>posFromIndex</code></a>.</dd>
|
1587
|
+
|
1588
|
+
<dt id="focus"><code><strong>cm.focus</strong>()</code></dt>
|
1589
|
+
<dd>Give the editor focus.</dd>
|
1590
|
+
|
1591
|
+
<dt id="getInputField"><code><strong>cm.getInputField</strong>() → TextAreaElement</code></dt>
|
1592
|
+
<dd>Returns the hidden textarea used to read input.</dd>
|
1593
|
+
<dt id="getWrapperElement"><code><strong>cm.getWrapperElement</strong>() → Element</code></dt>
|
1594
|
+
<dd>Returns the DOM node that represents the editor, and
|
1595
|
+
controls its size. Remove this from your tree to delete an
|
1596
|
+
editor instance.</dd>
|
1597
|
+
<dt id="getScrollerElement"><code><strong>cm.getScrollerElement</strong>() → Element</code></dt>
|
1598
|
+
<dd>Returns the DOM node that is responsible for the scrolling
|
1599
|
+
of the editor.</dd>
|
1600
|
+
<dt id="getGutterElement"><code><strong>cm.getGutterElement</strong>() → Element</code></dt>
|
1601
|
+
<dd>Fetches the DOM node that contains the editor gutters.</dd>
|
1602
|
+
</dl>
|
1603
|
+
|
1604
|
+
<h3 id="api_static">Static properties</h3>
|
1605
|
+
<p>The <code>CodeMirror</code> object itself provides
|
1606
|
+
several useful properties.</p>
|
1607
|
+
|
1608
|
+
<dl>
|
1609
|
+
<dt id="version"><code><strong>CodeMirror.version</strong>: string</code></dt>
|
1610
|
+
<dd>It contains a string that indicates the version of the
|
1611
|
+
library. This is a triple of
|
1612
|
+
integers <code>"major.minor.patch"</code>,
|
1613
|
+
where <code>patch</code> is zero for releases, and something
|
1614
|
+
else (usually one) for dev snapshots.</dd>
|
1615
|
+
|
1616
|
+
<dt id="fromTextArea"><code><strong>CodeMirror.fromTextArea</strong>(textArea: TextAreaElement, ?config: object)</code></dt>
|
1617
|
+
<dd>
|
1618
|
+
The method provides another way to initialize an editor. It takes a
|
1619
|
+
textarea DOM node as first argument and an optional configuration
|
1620
|
+
object as second. It will replace the textarea with a CodeMirror
|
1621
|
+
instance, and wire up the form of that textarea (if any) to make
|
1622
|
+
sure the editor contents are put into the textarea when the form
|
1623
|
+
is submitted. A CodeMirror instance created this way has three
|
1624
|
+
additional methods:
|
1625
|
+
<dl>
|
1626
|
+
<dt id="save"><code><strong>cm.save</strong>()</code></dt>
|
1627
|
+
<dd>Copy the content of the editor into the textarea.</dd>
|
1628
|
+
|
1629
|
+
<dt id="toTextArea"><code><strong>cm.toTextArea</strong>()</code></dt>
|
1630
|
+
<dd>Remove the editor, and restore the original textarea (with
|
1631
|
+
the editor's current content).</dd>
|
1632
|
+
|
1633
|
+
<dt id="getTextArea"><code><strong>cm.getTextArea</strong>() → TextAreaElement</code></dt>
|
1634
|
+
<dd>Returns the textarea that the instance was based on.</dd>
|
1635
|
+
</dl>
|
1636
|
+
</dd>
|
1637
|
+
|
1638
|
+
<dt id="defaults"><code><strong>CodeMirror.defaults</strong>: object</code></dt>
|
1639
|
+
<dd>An object containing default values for
|
1640
|
+
all <a href="#config">options</a>. You can assign to its
|
1641
|
+
properties to modify defaults (though this won't affect editors
|
1642
|
+
that have already been created).</dd>
|
1643
|
+
|
1644
|
+
<dt id="defineExtension"><code><strong>CodeMirror.defineExtension</strong>(name: string, value: any)</code></dt>
|
1645
|
+
<dd>If you want to define extra methods in terms of the
|
1646
|
+
CodeMirror API, it is possible to
|
1647
|
+
use <code>defineExtension</code>. This will cause the given
|
1648
|
+
value (usually a method) to be added to all CodeMirror instances
|
1649
|
+
created from then on.</dd>
|
1650
|
+
|
1651
|
+
<dt id="defineDocExtension"><code><strong>CodeMirror.defineDocExtension</strong>(name: string, value: any)</code></dt>
|
1652
|
+
<dd>Like <a href="#defineExtenstion"><code>defineExtension</code></a>,
|
1653
|
+
but the method will be added to the interface
|
1654
|
+
for <a href="#Doc"><code>Doc</code></a> objects instead.</dd>
|
1655
|
+
|
1656
|
+
<dt id="defineOption"><code><strong>CodeMirror.defineOption</strong>(name: string,
|
1657
|
+
default: any, updateFunc: function)</code></dt>
|
1658
|
+
<dd>Similarly, <code>defineOption</code> can be used to define new options for
|
1659
|
+
CodeMirror. The <code>updateFunc</code> will be called with the
|
1660
|
+
editor instance and the new value when an editor is initialized,
|
1661
|
+
and whenever the option is modified
|
1662
|
+
through <a href="#setOption"><code>setOption</code></a>.</dd>
|
1663
|
+
|
1664
|
+
<dt id="defineInitHook"><code><strong>CodeMirror.defineInitHook</strong>(func: function)</code></dt>
|
1665
|
+
<dd>If your extention just needs to run some
|
1666
|
+
code whenever a CodeMirror instance is initialized,
|
1667
|
+
use <code>CodeMirror.defineInitHook</code>. Give it a function as
|
1668
|
+
its only argument, and from then on, that function will be called
|
1669
|
+
(with the instance as argument) whenever a new CodeMirror instance
|
1670
|
+
is initialized.</dd>
|
1671
|
+
|
1672
|
+
<dt id="registerHelper"><code><strong>CodeMirror.registerHelper</strong>(type: string, name: string, value: helper)</code></dt>
|
1673
|
+
<dd>Registers a helper value with the given <code>name</code> in
|
1674
|
+
the given namespace (<code>type</code>). This is used to define
|
1675
|
+
functionality that may be looked up by mode. Will create (if it
|
1676
|
+
doesn't already exist) a property on the <code>CodeMirror</code>
|
1677
|
+
object for the given <code>type</code>, pointing to an object
|
1678
|
+
that maps names to values. I.e. after
|
1679
|
+
doing <code>CodeMirror.registerHelper("hint", "foo",
|
1680
|
+
myFoo)</code>, the value <code>CodeMirror.hint.foo</code> will
|
1681
|
+
point to <code>myFoo</code>.</dd>
|
1682
|
+
|
1683
|
+
<dt id="Pos"><code><strong>CodeMirror.Pos</strong>(line: integer, ?ch: integer)</code></dt>
|
1684
|
+
<dd>A constructor for the <code>{line, ch}</code> objects that
|
1685
|
+
are used to represent positions in editor documents.</dd>
|
1686
|
+
|
1687
|
+
<dt id="changeEnd"><code><strong>CodeMirror.changeEnd</strong>(change: object) → {line, ch}</code></dt>
|
1688
|
+
<dd>Utility function that computes an end position from a change
|
1689
|
+
(an object with <code>from</code>, <code>to</code>,
|
1690
|
+
and <code>text</code> properties, as passed to
|
1691
|
+
various <a href="#event_change">event handlers</a>). The
|
1692
|
+
returned position will be the end of the changed
|
1693
|
+
range, <em>after</em> the change is applied.</dd>
|
1694
|
+
</dl>
|
1695
|
+
</section>
|
1696
|
+
|
1697
|
+
<section id=addons>
|
1698
|
+
<h2>Addons</h2>
|
1699
|
+
|
1700
|
+
<p>The <code>addon</code> directory in the distribution contains a
|
1701
|
+
number of reusable components that implement extra editor
|
1702
|
+
functionality. In brief, they are:</p>
|
1703
|
+
|
1704
|
+
<dl>
|
1705
|
+
<dt id="addon_dialog"><a href="../addon/dialog/dialog.js"><code>dialog/dialog.js</code></a></dt>
|
1706
|
+
<dd>Provides a very simple way to query users for text input.
|
1707
|
+
Adds an <code>openDialog</code> method to CodeMirror instances,
|
1708
|
+
which can be called with an HTML fragment that provides the
|
1709
|
+
prompt (should include an <code>input</code> tag), and a
|
1710
|
+
callback function that is called when text has been entered.
|
1711
|
+
Depends on <code>addon/dialog/dialog.css</code>.</dd>
|
1712
|
+
|
1713
|
+
<dt id="addon_searchcursor"><a href="../addon/search/searchcursor.js"><code>search/searchcursor.js</code></a></dt>
|
1714
|
+
<dd>Adds the <code>getSearchCursor(query, start, caseFold) →
|
1715
|
+
cursor</code> method to CodeMirror instances, which can be used
|
1716
|
+
to implement search/replace functionality. <code>query</code>
|
1717
|
+
can be a regular expression or a string (only strings will match
|
1718
|
+
across lines—if they contain newlines). <code>start</code>
|
1719
|
+
provides the starting position of the search. It can be
|
1720
|
+
a <code>{line, ch}</code> object, or can be left off to default
|
1721
|
+
to the start of the document. <code>caseFold</code> is only
|
1722
|
+
relevant when matching a string. It will cause the search to be
|
1723
|
+
case-insensitive. A search cursor has the following methods:
|
1724
|
+
<dl>
|
1725
|
+
<dt><code><strong>findNext</strong>() → boolean</code></dt>
|
1726
|
+
<dt><code><strong>findPrevious</strong>() → boolean</code></dt>
|
1727
|
+
<dd>Search forward or backward from the current position.
|
1728
|
+
The return value indicates whether a match was found. If
|
1729
|
+
matching a regular expression, the return value will be the
|
1730
|
+
array returned by the <code>match</code> method, in case you
|
1731
|
+
want to extract matched groups.</dd>
|
1732
|
+
<dt><code><strong>from</strong>() → {line, ch}</code></dt>
|
1733
|
+
<dt><code><strong>to</strong>() → {line, ch}</code></dt>
|
1734
|
+
<dd>These are only valid when the last call
|
1735
|
+
to <code>findNext</code> or <code>findPrevious</code> did
|
1736
|
+
not return false. They will return <code>{line, ch}</code>
|
1737
|
+
objects pointing at the start and end of the match.</dd>
|
1738
|
+
<dt><code><strong>replace</strong>(text: string)</code></dt>
|
1739
|
+
<dd>Replaces the currently found match with the given text
|
1740
|
+
and adjusts the cursor position to reflect the
|
1741
|
+
replacement.</dd>
|
1742
|
+
</dl></dd>
|
1743
|
+
|
1744
|
+
<dt id="addon_search"><a href="../addon/search/search.js"><code>search/search.js</code></a></dt>
|
1745
|
+
<dd>Implements the search commands. CodeMirror has keys bound to
|
1746
|
+
these by default, but will not do anything with them unless an
|
1747
|
+
implementation is provided. Depends
|
1748
|
+
on <code>searchcursor.js</code>, and will make use
|
1749
|
+
of <a href="#addon_dialog"><code>openDialog</code></a> when
|
1750
|
+
available to make prompting for search queries less ugly.</dd>
|
1751
|
+
|
1752
|
+
<dt id="addon_matchbrackets"><a href="../addon/edit/matchbrackets.js"><code>edit/matchbrackets.js</code></a></dt>
|
1753
|
+
<dd>Defines an option <code>matchBrackets</code> which, when set
|
1754
|
+
to true, causes matching brackets to be highlighted whenever the
|
1755
|
+
cursor is next to them. It also adds a
|
1756
|
+
method <code>matchBrackets</code> that forces this to happen
|
1757
|
+
once, and a method <code>findMatchingBracket</code> that can be
|
1758
|
+
used to run the bracket-finding algorithm that this uses
|
1759
|
+
internally.</dd>
|
1760
|
+
|
1761
|
+
<dt id="addon_closebrackets"><a href="../addon/edit/closebrackets.js"><code>edit/closebrackets.js</code></a></dt>
|
1762
|
+
<dd>Defines an option <code>autoCloseBrackets</code> that will
|
1763
|
+
auto-close brackets and quotes when typed. By default, it'll
|
1764
|
+
auto-close <code>()[]{}''""</code>, but you can pass it a string
|
1765
|
+
similar to that (containing pairs of matching characters), or an
|
1766
|
+
object with <code>pairs</code> and
|
1767
|
+
optionally <code>explode</code> properties to customize
|
1768
|
+
it. <code>explode</code> should be a similar string that gives
|
1769
|
+
the pairs of characters that, when enter is pressed between
|
1770
|
+
them, should have the second character also moved to its own
|
1771
|
+
line. <a href="../demo/closebrackets.html">Demo here</a>.</dd>
|
1772
|
+
|
1773
|
+
<dt id="addon_matchtags"><a href="../addon/edit/matchtags.js"><code>edit/matchtags.js</code></a></dt>
|
1774
|
+
<dd>Defines an option <code>matchTags</code> that, when enabled,
|
1775
|
+
will cause the tags around the cursor to be highlighted (using
|
1776
|
+
the <code>CodeMirror-matchingtag</code> class). Also
|
1777
|
+
defines
|
1778
|
+
a <a href="#commands">command</a> <code>toMatchingTag</code>,
|
1779
|
+
which you can bind a key to in order to jump to the tag mathing
|
1780
|
+
the one under the cursor. Depends on
|
1781
|
+
the <code>addon/fold/xml-fold.js</code>
|
1782
|
+
addon. <a href="../demo/matchtags.html">Demo here.</a></dd>
|
1783
|
+
|
1784
|
+
<dt id="addon_trailingspace"><a href="../addon/edit/trailingspace.js"><code>edit/trailingspace.js</code></a></dt>
|
1785
|
+
<dd>Adds an option <code>showTrailingSpace</code> which, when
|
1786
|
+
enabled, adds the CSS class <code>cm-trailingspace</code> to
|
1787
|
+
stretches of whitespace at the end of lines.
|
1788
|
+
The <a href="../demo/trailingspace.html">demo</a> has a nice
|
1789
|
+
squiggly underline style for this class.</dd>
|
1790
|
+
|
1791
|
+
<dt id="addon_closetag"><a href="../addon/edit/closetag.js"><code>edit/closetag.js</code></a></dt>
|
1792
|
+
<dd>Provides utility functions for adding automatic tag closing
|
1793
|
+
to XML modes. See
|
1794
|
+
the <a href="../demo/closetag.html">demo</a>.</dd>
|
1795
|
+
|
1796
|
+
<dt id="addon_continuelist"><a href="../addon/edit/continuelist.js"><code>edit/continuelist.js</code></a></dt>
|
1797
|
+
<dd>Markdown specific. Defines
|
1798
|
+
a <code>"newlineAndIndentContinueMarkdownList"</code> <a href="#commands">command</a>
|
1799
|
+
command that can be bound to <code>enter</code> to automatically
|
1800
|
+
insert the leading characters for continuing a list. See
|
1801
|
+
the <a href="../mode/markdown/index.html">Markdown mode
|
1802
|
+
demo</a>.</dd>
|
1803
|
+
|
1804
|
+
<dt id="addon_comment"><a href="../addon/comment/comment.js"><code>comment/comment.js</code></a></dt>
|
1805
|
+
<dd>Addon for commenting and uncommenting code. Adds three
|
1806
|
+
methods to CodeMirror instances:
|
1807
|
+
<dl>
|
1808
|
+
<dt id="lineComment"><code><strong>lineComment</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
|
1809
|
+
<dd>Set the lines in the given range to be line comments. Will
|
1810
|
+
fall back to <code>blockComment</code> when no line comment
|
1811
|
+
style is defined for the mode.</dd>
|
1812
|
+
<dt id="blockComment"><code><strong>blockComment</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
|
1813
|
+
<dd>Wrap the code in the given range in a block comment. Will
|
1814
|
+
fall back to <code>lineComment</code> when no block comment
|
1815
|
+
style is defined for the mode.</dd>
|
1816
|
+
<dt id="uncomment"><code><strong>uncomment</strong>(from: {line, ch}, to: {line, ch}, ?options: object) → boolean</code></dt>
|
1817
|
+
<dd>Try to uncomment the given range.
|
1818
|
+
Returns <code>true</code> if a comment range was found and
|
1819
|
+
removed, <code>false</code> otherwise.</dd>
|
1820
|
+
</dl>
|
1821
|
+
The <code>options</code> object accepted by these methods may
|
1822
|
+
have the following properties:
|
1823
|
+
<dl>
|
1824
|
+
<dt><code>blockCommentStart, blockCommentEnd, blockCommentLead, lineComment: string</code></dt>
|
1825
|
+
<dd>Override the <a href="#mode_comment">comment string
|
1826
|
+
properties</a> of the mode with custom comment strings.</dd>
|
1827
|
+
<dt><code><strong>padding</strong>: string</code></dt>
|
1828
|
+
<dd>A string that will be inserted after opening and before
|
1829
|
+
closing comment markers. Defaults to a single space.</dd>
|
1830
|
+
<dt><code><strong>commentBlankLines</strong>: boolean</code></dt>
|
1831
|
+
<dd>Whether, when adding line comments, to also comment lines
|
1832
|
+
that contain only whitespace.</dd>
|
1833
|
+
<dt><code><strong>indent</strong>: boolean</code></dt>
|
1834
|
+
<dd>When adding line comments and this is turned on, it will
|
1835
|
+
align the comment block to the current indentation of the
|
1836
|
+
first line of the block.</dd>
|
1837
|
+
<dt><code><strong>fullLines</strong>: boolean</code></dt>
|
1838
|
+
<dd>When block commenting, this controls whether the whole
|
1839
|
+
lines are indented, or only the precise range that is given.
|
1840
|
+
Defaults to <code>true</code>.</dd>
|
1841
|
+
</dl>
|
1842
|
+
The addon also defines
|
1843
|
+
a <code>toggleComment</code> <a href="#commands">command</a>,
|
1844
|
+
which will try to uncomment the current selection, and if that
|
1845
|
+
fails, line-comments it.</dd>
|
1846
|
+
|
1847
|
+
<dt id="addon_foldcode"><a href="../addon/fold/foldcode.js"><code>fold/foldcode.js</code></a></dt>
|
1848
|
+
<dd>Helps with code folding. Adds a <code>foldCode</code> method
|
1849
|
+
to editor instances, which will try to do a code fold starting
|
1850
|
+
at the given line, or unfold the fold that is already present.
|
1851
|
+
The method takes as first argument the position that should be
|
1852
|
+
folded (may be a line number or
|
1853
|
+
a <a href="#Pos"><code>Pos</code></a>), and as second optional
|
1854
|
+
argument either a range-finder function, or an options object,
|
1855
|
+
supporting the following properties:
|
1856
|
+
<dl>
|
1857
|
+
<dt><code><strong>rangeFinder</strong>: fn(CodeMirror, Pos)</code></dt>
|
1858
|
+
<dd>The function that is used to find foldable ranges. If this
|
1859
|
+
is not directly passed, it will
|
1860
|
+
call <a href="#getHelper"><code>getHelper</code></a> with
|
1861
|
+
a <code>"fold"</code> type to find one that's appropriate for
|
1862
|
+
the mode. There are files in
|
1863
|
+
the <a href="../addon/fold/"><code>addon/fold/</code></a>
|
1864
|
+
directory providing <code>CodeMirror.fold.brace</code>, which
|
1865
|
+
finds blocks in brace languages (JavaScript, C, Java,
|
1866
|
+
etc), <code>CodeMirror.fold.indent</code>, for languages where
|
1867
|
+
indentation determines block structure (Python, Haskell),
|
1868
|
+
and <code>CodeMirror.fold.xml</code>, for XML-style languages,
|
1869
|
+
and <code>CodeMirror.fold.comment</code>, for folding comment
|
1870
|
+
blocks.</dd>
|
1871
|
+
<dt><code><strong>widget</strong>: string|Element</code></dt>
|
1872
|
+
<dd>The widget to show for folded ranges. Can be either a
|
1873
|
+
string, in which case it'll become a span with
|
1874
|
+
class <code>CodeMirror-foldmarker</code>, or a DOM node.</dd>
|
1875
|
+
<dt><code><strong>scanUp</strong>: boolean</code></dt>
|
1876
|
+
<dd>When true (default is false), the addon will try to find
|
1877
|
+
foldable ranges on the lines above the current one if there
|
1878
|
+
isn't an eligible one on the given line.</dd>
|
1879
|
+
<dt><code><strong>minFoldSize</strong>: integer</code></dt>
|
1880
|
+
<dd>The minimum amount of lines that a fold should span to be
|
1881
|
+
accepted. Defaults to 0, which also allows single-line
|
1882
|
+
folds.</dd>
|
1883
|
+
</dl>
|
1884
|
+
See <a href="../demo/folding.html">the demo</a> for an
|
1885
|
+
example.</dd>
|
1886
|
+
|
1887
|
+
<dt id="addon_foldgutter"><a href="../addon/fold/foldgutter.js"><code>fold/foldgutter.js</code></a></dt>
|
1888
|
+
<dd>Provides an option <code>foldGutter</code>, which can be
|
1889
|
+
used to create a gutter with markers indicating the blocks that
|
1890
|
+
can be folded. Create a gutter using
|
1891
|
+
the <a href="#option_gutters"><code>gutters</code></a> option,
|
1892
|
+
giving it the class <code>CodeMirror-foldgutter</code> or
|
1893
|
+
something else if you configure the addon to use a different
|
1894
|
+
class, and this addon will show markers next to folded and
|
1895
|
+
foldable blocks, and handle clicks in this gutter. Note that
|
1896
|
+
CSS styles should be applied to make the gutter, and the fold
|
1897
|
+
markers within it, visible. A default set of CSS styles are
|
1898
|
+
available in:
|
1899
|
+
<a href="../addon/fold/foldgutter.css">
|
1900
|
+
<code>addon/fold/foldgutter.css</code>
|
1901
|
+
</a>.
|
1902
|
+
The option
|
1903
|
+
can be either set to <code>true</code>, or an object containing
|
1904
|
+
the following optional option fields:
|
1905
|
+
<dl>
|
1906
|
+
<dt><code><strong>gutter</strong>: string</code></dt>
|
1907
|
+
<dd>The CSS class of the gutter. Defaults
|
1908
|
+
to <code>"CodeMirror-foldgutter"</code>. You will have to
|
1909
|
+
style this yourself to give it a width (and possibly a
|
1910
|
+
background). See the default gutter style rules above.</dd>
|
1911
|
+
<dt><code><strong>indicatorOpen</strong>: string | Element</code></dt>
|
1912
|
+
<dd>A CSS class or DOM element to be used as the marker for
|
1913
|
+
open, foldable blocks. Defaults
|
1914
|
+
to <code>"CodeMirror-foldgutter-open"</code>.</dd>
|
1915
|
+
<dt><code><strong>indicatorFolded</strong>: string | Element</code></dt>
|
1916
|
+
<dd>A CSS class or DOM element to be used as the marker for
|
1917
|
+
folded blocks. Defaults to <code>"CodeMirror-foldgutter-folded"</code>.</dd>
|
1918
|
+
<dt><code><strong>rangeFinder</strong>: fn(CodeMirror, Pos)</code></dt>
|
1919
|
+
<dd>The range-finder function to use when determining whether
|
1920
|
+
something can be folded. When not
|
1921
|
+
given, <a href="#getHelper"><code>getHelper</code></a> will be
|
1922
|
+
used to determine a default.</dd>
|
1923
|
+
</dl>
|
1924
|
+
Demo <a href="../demo/folding.html">here</a>.</dd>
|
1925
|
+
|
1926
|
+
<dt id="addon_runmode"><a href="../addon/runmode/runmode.js"><code>runmode/runmode.js</code></a></dt>
|
1927
|
+
<dd>Can be used to run a CodeMirror mode over text without
|
1928
|
+
actually opening an editor instance.
|
1929
|
+
See <a href="../demo/runmode.html">the demo</a> for an example.
|
1930
|
+
There are alternate versions of the file avaible for
|
1931
|
+
running <a href="../addon/runmode/runmode-standalone.js">stand-alone</a>
|
1932
|
+
(without including all of CodeMirror) and
|
1933
|
+
for <a href="../addon/runmode/runmode.node.js">running under
|
1934
|
+
node.js</a>.</dd>
|
1935
|
+
|
1936
|
+
<dt id="addon_colorize"><a href="../addon/runmode/colorize.js"><code>runmode/colorize.js</code></a></dt>
|
1937
|
+
<dd>Provides a convenient way to syntax-highlight code snippets
|
1938
|
+
in a webpage. Depends on
|
1939
|
+
the <a href="#addon_runmode"><code>runmode</code></a> addon (or
|
1940
|
+
its standalone variant). Provides
|
1941
|
+
a <code>CodeMirror.colorize</code> function that can be called
|
1942
|
+
with an array (or other array-ish collection) of DOM nodes that
|
1943
|
+
represent the code snippets. By default, it'll get
|
1944
|
+
all <code>pre</code> tags. Will read the <code>data-lang</code>
|
1945
|
+
attribute of these nodes to figure out their language, and
|
1946
|
+
syntax-color their content using the relevant CodeMirror mode
|
1947
|
+
(you'll have to load the scripts for the relevant modes
|
1948
|
+
yourself). A second argument may be provided to give a default
|
1949
|
+
mode, used when no language attribute is found for a node. Used
|
1950
|
+
in this manual to highlight example code.</dd>
|
1951
|
+
|
1952
|
+
<dt id="addon_overlay"><a href="../addon/mode/overlay.js"><code>mode/overlay.js</code></a></dt>
|
1953
|
+
<dd>Mode combinator that can be used to extend a mode with an
|
1954
|
+
'overlay' — a secondary mode is run over the stream, along with
|
1955
|
+
the base mode, and can color specific pieces of text without
|
1956
|
+
interfering with the base mode.
|
1957
|
+
Defines <code>CodeMirror.overlayMode</code>, which is used to
|
1958
|
+
create such a mode. See <a href="../demo/mustache.html">this
|
1959
|
+
demo</a> for a detailed example.</dd>
|
1960
|
+
|
1961
|
+
<dt id="addon_multiplex"><a href="../addon/mode/multiplex.js"><code>mode/multiplex.js</code></a></dt>
|
1962
|
+
<dd>Mode combinator that can be used to easily 'multiplex'
|
1963
|
+
between several modes.
|
1964
|
+
Defines <code>CodeMirror.multiplexingMode</code> which, when
|
1965
|
+
given as first argument a mode object, and as other arguments
|
1966
|
+
any number of <code>{open, close, mode [, delimStyle, innerStyle]}</code>
|
1967
|
+
objects, will return a mode object that starts parsing using the
|
1968
|
+
mode passed as first argument, but will switch to another mode
|
1969
|
+
as soon as it encounters a string that occurs in one of
|
1970
|
+
the <code>open</code> fields of the passed objects. When in a
|
1971
|
+
sub-mode, it will go back to the top mode again when
|
1972
|
+
the <code>close</code> string is encountered.
|
1973
|
+
Pass <code>"\n"</code> for <code>open</code> or <code>close</code>
|
1974
|
+
if you want to switch on a blank line.
|
1975
|
+
<ul><li>When <code>delimStyle</code> is specified, it will be the token
|
1976
|
+
style returned for the delimiter tokens.</li>
|
1977
|
+
<li>When <code>innerStyle</code> is specified, it will be the token
|
1978
|
+
style added for each inner mode token.</li></ul>
|
1979
|
+
The outer mode will not see the content between the delimiters.
|
1980
|
+
See <a href="../demo/multiplex.html">this demo</a> for an
|
1981
|
+
example.</dd>
|
1982
|
+
|
1983
|
+
<dt id="addon_show-hint"><a href="../addon/hint/show-hint.js"><code>hint/show-hint.js</code></a></dt>
|
1984
|
+
<dd>Provides a framework for showing autocompletion hints.
|
1985
|
+
Defines <code>CodeMirror.showHint</code>, which takes a
|
1986
|
+
CodeMirror instance, a hinting function, and optionally an
|
1987
|
+
options object, and pops up a widget that allows the user to
|
1988
|
+
select a completion. Hinting functions are function that take an
|
1989
|
+
editor instance and an optional options object, and return
|
1990
|
+
a <code>{list, from, to}</code> object, where <code>list</code>
|
1991
|
+
is an array of strings or objects (the completions),
|
1992
|
+
and <code>from</code> and <code>to</code> give the start and end
|
1993
|
+
of the token that is being completed as <code>{line, ch}</code>
|
1994
|
+
objects. If no hinting function is given, the addon will try to
|
1995
|
+
use <a href="#getHelper"><code>getHelper</code></a> with
|
1996
|
+
the <code>"hint"</code> type to find one. When completions
|
1997
|
+
aren't simple strings, they should be objects with the folowing
|
1998
|
+
properties:
|
1999
|
+
<dl>
|
2000
|
+
<dt><code><strong>text</strong>: string</code></dt>
|
2001
|
+
<dd>The completion text. This is the only required
|
2002
|
+
property.</dd>
|
2003
|
+
<dt><code><strong>displayText</strong>: string</code></dt>
|
2004
|
+
<dd>The text that should be displayed in the menu.</dd>
|
2005
|
+
<dt><code><strong>className</strong>: string</code></dt>
|
2006
|
+
<dd>A CSS class name to apply to the completion's line in the
|
2007
|
+
menu.</dd>
|
2008
|
+
<dt><code><strong>render</strong>: fn(Element, self, data)</code></dt>
|
2009
|
+
<dd>A method used to create the DOM structure for showing the
|
2010
|
+
completion by appending it to its first argument.</dd>
|
2011
|
+
<dt><code><strong>hint</strong>: fn(CodeMirror, self, data)</code></dt>
|
2012
|
+
<dd>A method used to actually apply the completion, instead of
|
2013
|
+
the default behavior.</dd>
|
2014
|
+
</dl>
|
2015
|
+
The plugin understands the following options (the options object
|
2016
|
+
will also be passed along to the hinting function, which may
|
2017
|
+
understand additional options):
|
2018
|
+
<dl>
|
2019
|
+
<dt><code><strong>async</strong>: boolean</code></dt>
|
2020
|
+
<dd>When set to true, the hinting function's signature should
|
2021
|
+
be <code>(cm, callback, ?options)</code>, and the completion
|
2022
|
+
interface will only be popped up when the hinting function
|
2023
|
+
calls the callback, passing it the object holding the
|
2024
|
+
completions.</dd>
|
2025
|
+
<dt><code><strong>completeSingle</strong>: boolean</code></dt>
|
2026
|
+
<dd>Determines whether, when only a single completion is
|
2027
|
+
available, it is completed without showing the dialog.
|
2028
|
+
Defaults to true.</dd>
|
2029
|
+
<dt><code><strong>alignWithWord</strong>: boolean</code></dt>
|
2030
|
+
<dd>Whether the pop-up should be horizontally aligned with the
|
2031
|
+
start of the word (true, default), or with the cursor (false).</dd>
|
2032
|
+
<dt><code><strong>closeOnUnfocus</strong>: boolean</code></dt>
|
2033
|
+
<dd>When enabled (which is the default), the pop-up will close
|
2034
|
+
when the editor is unfocused.</dd>
|
2035
|
+
<dt><code><strong>customKeys</strong>: keymap</code></dt>
|
2036
|
+
<dd>Allows you to provide a custom keymap of keys to be active
|
2037
|
+
when the pop-up is active. The handlers will be called with an
|
2038
|
+
extra argument, a handle to the completion menu, which
|
2039
|
+
has <code>moveFocus(n)</code>, <code>setFocus(n)</code>, <code>pick()</code>,
|
2040
|
+
and <code>close()</code> methods (see the source for details),
|
2041
|
+
that can be used to change the focused element, pick the
|
2042
|
+
current element or close the menu.</dd>
|
2043
|
+
<dt><code><strong>extraKeys</strong>: keymap</code></dt>
|
2044
|
+
<dd>Like <code>customKeys</code> above, but the bindings will
|
2045
|
+
be added to the set of default bindings, instead of replacing
|
2046
|
+
them.</dd>
|
2047
|
+
</dl>
|
2048
|
+
The following events will be fired on the completions object
|
2049
|
+
during completion:
|
2050
|
+
<dl>
|
2051
|
+
<dt><code><strong>"shown"</strong> ()</code></dt>
|
2052
|
+
<dd>Fired when the pop-up is shown.</dd>
|
2053
|
+
<dt><code><strong>"select"</strong> (completion, Element)</code></dt>
|
2054
|
+
<dd>Fired when a completion is selected. Passed the completion
|
2055
|
+
value (string or object) and the DOM node that represents it
|
2056
|
+
in the menu.</dd>
|
2057
|
+
<dt><code><strong>"close"</strong> ()</code></dt>
|
2058
|
+
<dd>Fired when the completion is finished.</dd>
|
2059
|
+
</dl>
|
2060
|
+
This addon depends styles
|
2061
|
+
from <code>addon/hint/show-hint.css</code>. Check
|
2062
|
+
out <a href="../demo/complete.html">the demo</a> for an
|
2063
|
+
example.</dd>
|
2064
|
+
|
2065
|
+
<dt id="addon_javascript-hint"><a href="../addon/hint/javascript-hint.js"><code>hint/javascript-hint.js</code></a></dt>
|
2066
|
+
<dd>Defines a simple hinting function for JavaScript
|
2067
|
+
(<code>CodeMirror.hint.javascript</code>) and CoffeeScript
|
2068
|
+
(<code>CodeMirror.hint.coffeescript</code>) code. This will
|
2069
|
+
simply use the JavaScript environment that the editor runs in as
|
2070
|
+
a source of information about objects and their properties.</dd>
|
2071
|
+
|
2072
|
+
<dt id="addon_xml-hint"><a href="../addon/hint/xml-hint.js"><code>hint/xml-hint.js</code></a></dt>
|
2073
|
+
<dd>Defines <code>CodeMirror.hint.xml</code>, which produces
|
2074
|
+
hints for XML tagnames, attribute names, and attribute values,
|
2075
|
+
guided by a <code>schemaInfo</code> option (a property of the
|
2076
|
+
second argument passed to the hinting function, or the third
|
2077
|
+
argument passed to <code>CodeMirror.showHint</code>).<br>The
|
2078
|
+
schema info should be an object mapping tag names to information
|
2079
|
+
about these tags, with optionally a <code>"!top"</code> property
|
2080
|
+
containing a list of the names of valid top-level tags. The
|
2081
|
+
values of the properties should be objects with optional
|
2082
|
+
properties <code>children</code> (an array of valid child
|
2083
|
+
element names, omit to simply allow all tags to appear)
|
2084
|
+
and <code>attrs</code> (an object mapping attribute names
|
2085
|
+
to <code>null</code> for free-form attributes, and an array of
|
2086
|
+
valid values for restricted
|
2087
|
+
attributes). <a href="../demo/xmlcomplete.html">Demo
|
2088
|
+
here.</a></dd>
|
2089
|
+
|
2090
|
+
<dt id="addon_html-hint"><a href="../addon/hint/html-hint.js"><code>hint/html-hint.js</code></a></dt>
|
2091
|
+
<dd>Provides schema info to
|
2092
|
+
the <a href="#addon_xml-hint">xml-hint</a> addon for HTML
|
2093
|
+
documents. Defines a schema
|
2094
|
+
object <code>CodeMirror.htmlSchema</code> that you can pass to
|
2095
|
+
as a <code>schemaInfo</code> option, and
|
2096
|
+
a <code>CodeMirror.hint.html</code> hinting function that
|
2097
|
+
automatically calls <code>CodeMirror.hint.xml</code> with this
|
2098
|
+
schema data. See
|
2099
|
+
the <a href="../demo/html5complete.html">demo</a>.</dd>
|
2100
|
+
|
2101
|
+
<dt id="addon_css-hint"><a href="../addon/hint/css-hint.js"><code>hint/css-hint.js</code></a></dt>
|
2102
|
+
<dd>A minimal hinting function for CSS code.
|
2103
|
+
Defines <code>CodeMirror.hint.css</code>.</dd>
|
2104
|
+
|
2105
|
+
<dt id="addon_python-hint"><a href="../addon/hint/python-hint.js"><code>hint/python-hint.js</code></a></dt>
|
2106
|
+
<dd>A very simple hinting function for Python code.
|
2107
|
+
Defines <code>CodeMirror.hint.python</code>.</dd>
|
2108
|
+
|
2109
|
+
<dt id="addon_anyword-hint"><a href="../addon/hint/anyword-hint.js"><code>hint/anyword-hint.js</code></a></dt>
|
2110
|
+
<dd>A very simple hinting function
|
2111
|
+
(<code>CodeMirror.hint.anyword</code>) that simply looks for
|
2112
|
+
words in the nearby code and completes to those. Takes two
|
2113
|
+
optional options, <code>word</code>, a regular expression that
|
2114
|
+
matches words (sequences of one or more character),
|
2115
|
+
and <code>range</code>, which defines how many lines the addon
|
2116
|
+
should scan when completing (defaults to 500).</dd>
|
2117
|
+
|
2118
|
+
<dt id="addon_sql-hint"><a href="../addon/hint/sql-hint.js"><code>hint/sql-hint.js</code></a></dt>
|
2119
|
+
<dd>A simple SQL hinter. Defines <code>CodeMirror.hint.sql</code>.</dd>
|
2120
|
+
|
2121
|
+
<dt id="addon_pig-hint"><a href="../addon/hint/pig-hint.js"><code>hint/pig-hint.js</code></a></dt>
|
2122
|
+
<dd>A simple hinter for <a href="../mode/pig/index.html">Pig Latin</a>. Defines <code>CodeMirror.hint.pig</code>.</dd>
|
2123
|
+
|
2124
|
+
<dt id="addon_match-highlighter"><a href="../addon/search/match-highlighter.js"><code>search/match-highlighter.js</code></a></dt>
|
2125
|
+
<dd>Adds a <code>highlightSelectionMatches</code> option that
|
2126
|
+
can be enabled to highlight all instances of a currently
|
2127
|
+
selected word. Can be set either to true or to an object
|
2128
|
+
containing the following options: <code>minChars</code>, for the
|
2129
|
+
minimum amount of selected characters that triggers a highlight
|
2130
|
+
(default 2), <code>style</code>, for the style to be used to
|
2131
|
+
highlight the matches (default <code>"matchhighlight"</code>,
|
2132
|
+
which will correspond to CSS
|
2133
|
+
class <code>cm-matchhighlight</code>),
|
2134
|
+
and <code>showToken</code> which can be set to <code>true</code>
|
2135
|
+
or to a regexp matching the characters that make up a word. When
|
2136
|
+
enabled, it causes the current word to be highlighted when
|
2137
|
+
nothing is selected (defaults to off).
|
2138
|
+
Demo <a href="../demo/matchhighlighter.html">here</a>.</dd>
|
2139
|
+
|
2140
|
+
<dt id="addon_lint"><a href="../addon/lint/lint.js"><code>lint/lint.js</code></a></dt>
|
2141
|
+
<dd>Defines an interface component for showing linting warnings,
|
2142
|
+
with pluggable warning sources
|
2143
|
+
(see <a href="../addon/lint/json-lint.js"><code>json-lint.js</code></a>,
|
2144
|
+
<a href="../addon/lint/javascript-lint.js"><code>javascript-lint.js</code></a>,
|
2145
|
+
and <a href="../addon/lint/css-lint.js"><code>css-lint.js</code></a>
|
2146
|
+
in the same directory). Defines a <code>lint</code> option that
|
2147
|
+
can be set to a warning source (for
|
2148
|
+
example <code>CodeMirror.lint.javascript</code>), or
|
2149
|
+
to <code>true</code>, in which
|
2150
|
+
case <a href="#getHelper"><code>getHelper</code></a> with
|
2151
|
+
type <code>"lint"</code> is used to determined a validator
|
2152
|
+
function. Depends on <code>addon/lint/lint.css</code>. A demo
|
2153
|
+
can be found <a href="../demo/lint.html">here</a>.</dd>
|
2154
|
+
|
2155
|
+
<dt id="addon_mark-selection"><a href="../addon/selection/mark-selection.js"><code>selection/mark-selection.js</code></a></dt>
|
2156
|
+
<dd>Causes the selected text to be marked with the CSS class
|
2157
|
+
<code>CodeMirror-selectedtext</code> when the <code>styleSelectedText</code> option
|
2158
|
+
is enabled. Useful to change the colour of the selection (in addition to the background),
|
2159
|
+
like in <a href="../demo/markselection.html">this demo</a>.</dd>
|
2160
|
+
|
2161
|
+
<dt id="addon_active-line"><a href="../addon/selection/active-line.js"><code>selection/active-line.js</code></a></dt>
|
2162
|
+
<dd>Defines a <code>styleActiveLine</code> option that, when enabled,
|
2163
|
+
gives the wrapper of the active line the class <code>CodeMirror-activeline</code>,
|
2164
|
+
and adds a background with the class <code>CodeMirror-activeline-background</code>.
|
2165
|
+
is enabled. See the <a href="../demo/activeline.html">demo</a>.</dd>
|
2166
|
+
|
2167
|
+
<dt id="addon_loadmode"><a href="../addon/mode/loadmode.js"><code>mode/loadmode.js</code></a></dt>
|
2168
|
+
<dd>Defines a <code>CodeMirror.requireMode(modename,
|
2169
|
+
callback)</code> function that will try to load a given mode and
|
2170
|
+
call the callback when it succeeded. You'll have to
|
2171
|
+
set <code>CodeMirror.modeURL</code> to a string that mode paths
|
2172
|
+
can be constructed from, for
|
2173
|
+
example <code>"mode/%N/%N.js"</code>—the <code>%N</code>'s will
|
2174
|
+
be replaced with the mode name. Also
|
2175
|
+
defines <code>CodeMirror.autoLoadMode(instance, mode)</code>,
|
2176
|
+
which will ensure the given mode is loaded and cause the given
|
2177
|
+
editor instance to refresh its mode when the loading
|
2178
|
+
succeeded. See the <a href="../demo/loadmode.html">demo</a>.</dd>
|
2179
|
+
|
2180
|
+
<dt id="addon_continuecomment"><a href="../addon/comment/continuecomment.js"><code>comment/continuecomment.js</code></a></dt>
|
2181
|
+
<dd>Adds an <code>continueComments</code> option, which can be
|
2182
|
+
set to true to have the editor prefix new lines inside C-like
|
2183
|
+
block comments with an asterisk when Enter is pressed. It can
|
2184
|
+
also be set to a string in order to bind this functionality to a
|
2185
|
+
specific key..</dd>
|
2186
|
+
|
2187
|
+
<dt id="addon_placeholder"><a href="../addon/display/placeholder.js"><code>display/placeholder.js</code></a></dt>
|
2188
|
+
<dd>Adds a <code>placeholder</code> option that can be used to
|
2189
|
+
make text appear in the editor when it is empty and not focused.
|
2190
|
+
Also gives the editor a <code>CodeMirror-empty</code> CSS class
|
2191
|
+
whenever it doesn't contain any text.
|
2192
|
+
See <a href="../demo/placeholder.html">the demo</a>.</dd>
|
2193
|
+
|
2194
|
+
<dt id="addon_fullscreen"><a href="../addon/display/fullscreen.js"><code>display/fullscreen.js</code></a></dt>
|
2195
|
+
<dd>Defines an option <code>fullScreen</code> that, when set
|
2196
|
+
to <code>true</code>, will make the editor full-screen (as in,
|
2197
|
+
taking up the whole browser window). Depends
|
2198
|
+
on <a href="../addon/display/fullscreen.css"><code>fullscreen.css</code></a>. <a href="../demo/fullscreen.html">Demo
|
2199
|
+
here</a>.</dd>
|
2200
|
+
|
2201
|
+
<dt id="addon_hardwrap"><a href="../addon/wrap/hardwrap.js"><code>wrap/hardwrap.js</code></a></dt>
|
2202
|
+
<dd>Addon to perform hard line wrapping/breaking for paragraphs
|
2203
|
+
of text. Adds these methods to editor instances:
|
2204
|
+
<dl>
|
2205
|
+
<dt><code><strong>wrapParagraph</strong>(?pos: {line, ch}, ?options: object)</code></dt>
|
2206
|
+
<dd>Wraps the paragraph at the given position.
|
2207
|
+
If <code>pos</code> is not given, it defaults to the cursor
|
2208
|
+
position.</dd>
|
2209
|
+
<dt><code><strong>wrapRange</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
|
2210
|
+
<dd>Wraps the given range as one big paragraph.</dd>
|
2211
|
+
<dt><code><strong>wrapParagraphsInRange</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
|
2212
|
+
<dd>Wrapps the paragraphs in (and overlapping with) the
|
2213
|
+
given range individually.</dd>
|
2214
|
+
</dl>
|
2215
|
+
The following options are recognized:
|
2216
|
+
<dl>
|
2217
|
+
<dt><code><strong>paragraphStart</strong>, <strong>paragraphEnd</strong>: RegExp</code></dt>
|
2218
|
+
<dd>Blank lines are always considered paragraph boundaries.
|
2219
|
+
These options can be used to specify a pattern that causes
|
2220
|
+
lines to be considered the start or end of a paragraph.</dd>
|
2221
|
+
<dt><code><strong>column</strong>: number</code></dt>
|
2222
|
+
<dd>The column to wrap at. Defaults to 80.</dd>
|
2223
|
+
<dt><code><strong>wrapOn</strong>: RegExp</code></dt>
|
2224
|
+
<dd>A regular expression that matches only those
|
2225
|
+
two-character strings that allow wrapping. By default, the
|
2226
|
+
addon wraps on whitespace and after dash characters.</dd>
|
2227
|
+
<dt><code><strong>killTrailingSpace</strong>: boolean</code></dt>
|
2228
|
+
<dd>Whether trailing space caused by wrapping should be
|
2229
|
+
preserved, or deleted. Defaults to true.</dd>
|
2230
|
+
</dl>
|
2231
|
+
A demo of the addon is available <a href="../demo/hardwrap.html">here</a>.
|
2232
|
+
</dd>
|
2233
|
+
|
2234
|
+
<dt id="addon_merge"><a href="../addon/merge/merge.js"><code>merge/merge.js</code></a></dt>
|
2235
|
+
<dd>Implements an interface for merging changes, using either a
|
2236
|
+
2-way or a 3-way view. The <code>CodeMirror.MergeView</code>
|
2237
|
+
constructor takes arguments similar to
|
2238
|
+
the <a href="#CodeMirror"><code>CodeMirror</code></a>
|
2239
|
+
constructor, first a node to append the interface to, and then
|
2240
|
+
an options object. Two extra optional options are
|
2241
|
+
recognized, <code>origLeft</code> and <code>origRight</code>,
|
2242
|
+
which may be strings that provide original versions of the
|
2243
|
+
document, which will be shown to the left and right of the
|
2244
|
+
editor in non-editable CodeMirror instances. The merge interface
|
2245
|
+
will highlight changes between the editable document and the
|
2246
|
+
original(s) (<a href="../demo/merge.html">demo</a>).</dd>
|
2247
|
+
|
2248
|
+
<dt id="addon_tern"><a href="../addon/tern/tern.js"><code>tern/tern.js</code></a></dt>
|
2249
|
+
<dd>Provides integration with
|
2250
|
+
the <a href="http://ternjs.net">Tern</a> JavaScript analysis
|
2251
|
+
engine, for completion, definition finding, and minor
|
2252
|
+
refactoring help. See the <a href="../demo/tern.html">demo</a>
|
2253
|
+
for a very simple integration. For more involved scenarios, see
|
2254
|
+
the comments at the top of
|
2255
|
+
the <a href="../addon/tern/tern.js">addon</a> and the
|
2256
|
+
implementation of the
|
2257
|
+
(multi-file) <a href="http://ternjs.net/doc/demo.html">demonstration
|
2258
|
+
on the Tern website</a>.</dd>
|
2259
|
+
</dl>
|
2260
|
+
</section>
|
2261
|
+
|
2262
|
+
<section id=modeapi>
|
2263
|
+
<h2>Writing CodeMirror Modes</h2>
|
2264
|
+
|
2265
|
+
<p>Modes typically consist of a single JavaScript file. This file
|
2266
|
+
defines, in the simplest case, a lexer (tokenizer) for your
|
2267
|
+
language—a function that takes a character stream as input,
|
2268
|
+
advances it past a token, and returns a style for that token. More
|
2269
|
+
advanced modes can also handle indentation for the language.</p>
|
2270
|
+
|
2271
|
+
<p id="defineMode">The mode script should
|
2272
|
+
call <code><strong>CodeMirror.defineMode</strong></code> to
|
2273
|
+
register itself with CodeMirror. This function takes two
|
2274
|
+
arguments. The first should be the name of the mode, for which you
|
2275
|
+
should use a lowercase string, preferably one that is also the
|
2276
|
+
name of the files that define the mode (i.e. <code>"xml"</code> is
|
2277
|
+
defined in <code>xml.js</code>). The second argument should be a
|
2278
|
+
function that, given a CodeMirror configuration object (the thing
|
2279
|
+
passed to the <code>CodeMirror</code> function) and an optional
|
2280
|
+
mode configuration object (as in
|
2281
|
+
the <a href="#option_mode"><code>mode</code></a> option), returns
|
2282
|
+
a mode object.</p>
|
2283
|
+
|
2284
|
+
<p>Typically, you should use this second argument
|
2285
|
+
to <code>defineMode</code> as your module scope function (modes
|
2286
|
+
should not leak anything into the global scope!), i.e. write your
|
2287
|
+
whole mode inside this function.</p>
|
2288
|
+
|
2289
|
+
<p>The main responsibility of a mode script is <em>parsing</em>
|
2290
|
+
the content of the editor. Depending on the language and the
|
2291
|
+
amount of functionality desired, this can be done in really easy
|
2292
|
+
or extremely complicated ways. Some parsers can be stateless,
|
2293
|
+
meaning that they look at one element (<em>token</em>) of the code
|
2294
|
+
at a time, with no memory of what came before. Most, however, will
|
2295
|
+
need to remember something. This is done by using a <em>state
|
2296
|
+
object</em>, which is an object that is always passed when
|
2297
|
+
reading a token, and which can be mutated by the tokenizer.</p>
|
2298
|
+
|
2299
|
+
<p id="startState">Modes that use a state must define
|
2300
|
+
a <code><strong>startState</strong></code> method on their mode
|
2301
|
+
object. This is a function of no arguments that produces a state
|
2302
|
+
object to be used at the start of a document.</p>
|
2303
|
+
|
2304
|
+
<p id="token">The most important part of a mode object is
|
2305
|
+
its <code><strong>token</strong>(stream, state)</code> method. All
|
2306
|
+
modes must define this method. It should read one token from the
|
2307
|
+
stream it is given as an argument, optionally update its state,
|
2308
|
+
and return a style string, or <code>null</code> for tokens that do
|
2309
|
+
not have to be styled. For your styles, you are encouraged to use
|
2310
|
+
the 'standard' names defined in the themes (without
|
2311
|
+
the <code>cm-</code> prefix). If that fails, it is also possible
|
2312
|
+
to come up with your own and write your own CSS theme file.<p>
|
2313
|
+
|
2314
|
+
<p id="token_style_line">A typical token string would
|
2315
|
+
be <code>"variable"</code> or <code>"comment"</code>. Multiple
|
2316
|
+
styles can be returned (separated by spaces), for
|
2317
|
+
example <code>"string error"</code> for a thing that looks like a
|
2318
|
+
string but is invalid somehow (say, missing its closing quote).
|
2319
|
+
When a style is prefixed by <code>"line-"</code>
|
2320
|
+
or <code>"line-background-"</code>, the style will be applied to
|
2321
|
+
the whole line, analogous to what
|
2322
|
+
the <a href="#addLineClass"><code>addLineClass</code></a> method
|
2323
|
+
does—styling the <code>"text"</code> in the simple case, and
|
2324
|
+
the <code>"background"</code> element
|
2325
|
+
when <code>"line-background-"</code> is prefixed.</p>
|
2326
|
+
|
2327
|
+
<p id="StringStream">The stream object that's passed
|
2328
|
+
to <code>token</code> encapsulates a line of code (tokens may
|
2329
|
+
never span lines) and our current position in that line. It has
|
2330
|
+
the following API:</p>
|
2331
|
+
|
2332
|
+
<dl>
|
2333
|
+
<dt><code><strong>eol</strong>() → boolean</code></dt>
|
2334
|
+
<dd>Returns true only if the stream is at the end of the
|
2335
|
+
line.</dd>
|
2336
|
+
<dt><code><strong>sol</strong>() → boolean</code></dt>
|
2337
|
+
<dd>Returns true only if the stream is at the start of the
|
2338
|
+
line.</dd>
|
2339
|
+
|
2340
|
+
<dt><code><strong>peek</strong>() → string</code></dt>
|
2341
|
+
<dd>Returns the next character in the stream without advancing
|
2342
|
+
it. Will return an <code>null</code> at the end of the
|
2343
|
+
line.</dd>
|
2344
|
+
<dt><code><strong>next</strong>() → string</code></dt>
|
2345
|
+
<dd>Returns the next character in the stream and advances it.
|
2346
|
+
Also returns <code>null</code> when no more characters are
|
2347
|
+
available.</dd>
|
2348
|
+
|
2349
|
+
<dt><code><strong>eat</strong>(match: string|regexp|function(char: string) → boolean) → string</code></dt>
|
2350
|
+
<dd><code>match</code> can be a character, a regular expression,
|
2351
|
+
or a function that takes a character and returns a boolean. If
|
2352
|
+
the next character in the stream 'matches' the given argument,
|
2353
|
+
it is consumed and returned. Otherwise, <code>undefined</code>
|
2354
|
+
is returned.</dd>
|
2355
|
+
<dt><code><strong>eatWhile</strong>(match: string|regexp|function(char: string) → boolean) → boolean</code></dt>
|
2356
|
+
<dd>Repeatedly calls <code>eat</code> with the given argument,
|
2357
|
+
until it fails. Returns true if any characters were eaten.</dd>
|
2358
|
+
<dt><code><strong>eatSpace</strong>() → boolean</code></dt>
|
2359
|
+
<dd>Shortcut for <code>eatWhile</code> when matching
|
2360
|
+
white-space.</dd>
|
2361
|
+
<dt><code><strong>skipToEnd</strong>()</code></dt>
|
2362
|
+
<dd>Moves the position to the end of the line.</dd>
|
2363
|
+
<dt><code><strong>skipTo</strong>(ch: string) → boolean</code></dt>
|
2364
|
+
<dd>Skips to the next occurrence of the given character, if
|
2365
|
+
found on the current line (doesn't advance the stream if the
|
2366
|
+
character does not occur on the line). Returns true if the
|
2367
|
+
character was found.</dd>
|
2368
|
+
<dt><code><strong>match</strong>(pattern: string, ?consume: boolean, ?caseFold: boolean) → boolean</code></dt>
|
2369
|
+
<dt><code><strong>match</strong>(pattern: regexp, ?consume: boolean) → array<string></code></dt>
|
2370
|
+
<dd>Act like a
|
2371
|
+
multi-character <code>eat</code>—if <code>consume</code> is true
|
2372
|
+
or not given—or a look-ahead that doesn't update the stream
|
2373
|
+
position—if it is false. <code>pattern</code> can be either a
|
2374
|
+
string or a regular expression starting with <code>^</code>.
|
2375
|
+
When it is a string, <code>caseFold</code> can be set to true to
|
2376
|
+
make the match case-insensitive. When successfully matching a
|
2377
|
+
regular expression, the returned value will be the array
|
2378
|
+
returned by <code>match</code>, in case you need to extract
|
2379
|
+
matched groups.</dd>
|
2380
|
+
|
2381
|
+
<dt><code><strong>backUp</strong>(n: integer)</code></dt>
|
2382
|
+
<dd>Backs up the stream <code>n</code> characters. Backing it up
|
2383
|
+
further than the start of the current token will cause things to
|
2384
|
+
break, so be careful.</dd>
|
2385
|
+
<dt><code><strong>column</strong>() → integer</code></dt>
|
2386
|
+
<dd>Returns the column (taking into account tabs) at which the
|
2387
|
+
current token starts.</dd>
|
2388
|
+
<dt><code><strong>indentation</strong>() → integer</code></dt>
|
2389
|
+
<dd>Tells you how far the current line has been indented, in
|
2390
|
+
spaces. Corrects for tab characters.</dd>
|
2391
|
+
|
2392
|
+
<dt><code><strong>current</strong>() → string</code></dt>
|
2393
|
+
<dd>Get the string between the start of the current token and
|
2394
|
+
the current stream position.</dd>
|
2395
|
+
</dl>
|
2396
|
+
|
2397
|
+
<p id="blankLine">By default, blank lines are simply skipped when
|
2398
|
+
tokenizing a document. For languages that have significant blank
|
2399
|
+
lines, you can define
|
2400
|
+
a <code><strong>blankLine</strong>(state)</code> method on your
|
2401
|
+
mode that will get called whenever a blank line is passed over, so
|
2402
|
+
that it can update the parser state.</p>
|
2403
|
+
|
2404
|
+
<p id="copyState">Because state object are mutated, and CodeMirror
|
2405
|
+
needs to keep valid versions of a state around so that it can
|
2406
|
+
restart a parse at any line, copies must be made of state objects.
|
2407
|
+
The default algorithm used is that a new state object is created,
|
2408
|
+
which gets all the properties of the old object. Any properties
|
2409
|
+
which hold arrays get a copy of these arrays (since arrays tend to
|
2410
|
+
be used as mutable stacks). When this is not correct, for example
|
2411
|
+
because a mode mutates non-array properties of its state object, a
|
2412
|
+
mode object should define
|
2413
|
+
a <code><strong>copyState</strong></code> method, which is given a
|
2414
|
+
state and should return a safe copy of that state.</p>
|
2415
|
+
|
2416
|
+
<p id="indent">If you want your mode to provide smart indentation
|
2417
|
+
(through the <a href="#indentLine"><code>indentLine</code></a>
|
2418
|
+
method and the <code>indentAuto</code>
|
2419
|
+
and <code>newlineAndIndent</code> commands, to which keys can be
|
2420
|
+
<a href="#option_extraKeys">bound</a>), you must define
|
2421
|
+
an <code><strong>indent</strong>(state, textAfter)</code> method
|
2422
|
+
on your mode object.</p>
|
2423
|
+
|
2424
|
+
<p>The indentation method should inspect the given state object,
|
2425
|
+
and optionally the <code>textAfter</code> string, which contains
|
2426
|
+
the text on the line that is being indented, and return an
|
2427
|
+
integer, the amount of spaces to indent. It should usually take
|
2428
|
+
the <a href="#option_indentUnit"><code>indentUnit</code></a>
|
2429
|
+
option into account. An indentation method may
|
2430
|
+
return <code>CodeMirror.Pass</code> to indicate that it
|
2431
|
+
could not come up with a precise indentation.</p>
|
2432
|
+
|
2433
|
+
<p id="mode_comment">To work well with
|
2434
|
+
the <a href="#addon_comment">commenting addon</a>, a mode may
|
2435
|
+
define <code><strong>lineComment</strong></code> (string that
|
2436
|
+
starts a line
|
2437
|
+
comment), <code><strong>blockCommentStart</strong></code>, <code><strong>blockCommentEnd</strong></code>
|
2438
|
+
(strings that start and end block comments),
|
2439
|
+
and <code>blockCommentLead</code> (a string to put at the start of
|
2440
|
+
continued lines in a block comment). All of these are
|
2441
|
+
optional.</p>
|
2442
|
+
|
2443
|
+
<p id="electricChars">Finally, a mode may define
|
2444
|
+
an <code>electricChars</code> property, which should hold a string
|
2445
|
+
containing all the characters that should trigger the behaviour
|
2446
|
+
described for
|
2447
|
+
the <a href="#option_electricChars"><code>electricChars</code></a>
|
2448
|
+
option.</p>
|
2449
|
+
|
2450
|
+
<p>So, to summarize, a mode <em>must</em> provide
|
2451
|
+
a <code>token</code> method, and it <em>may</em>
|
2452
|
+
provide <code>startState</code>, <code>copyState</code>,
|
2453
|
+
and <code>indent</code> methods. For an example of a trivial mode,
|
2454
|
+
see the <a href="../mode/diff/diff.js">diff mode</a>, for a more
|
2455
|
+
involved example, see the <a href="../mode/clike/clike.js">C-like
|
2456
|
+
mode</a>.</p>
|
2457
|
+
|
2458
|
+
<p>Sometimes, it is useful for modes to <em>nest</em>—to have one
|
2459
|
+
mode delegate work to another mode. An example of this kind of
|
2460
|
+
mode is the <a href="../mode/htmlmixed/htmlmixed.js">mixed-mode HTML
|
2461
|
+
mode</a>. To implement such nesting, it is usually necessary to
|
2462
|
+
create mode objects and copy states yourself. To create a mode
|
2463
|
+
object, there are <code>CodeMirror.getMode(options,
|
2464
|
+
parserConfig)</code>, where the first argument is a configuration
|
2465
|
+
object as passed to the mode constructor function, and the second
|
2466
|
+
argument is a mode specification as in
|
2467
|
+
the <a href="#option_mode"><code>mode</code></a> option. To copy a
|
2468
|
+
state object, call <code>CodeMirror.copyState(mode, state)</code>,
|
2469
|
+
where <code>mode</code> is the mode that created the given
|
2470
|
+
state.</p>
|
2471
|
+
|
2472
|
+
<p id="innerMode">In a nested mode, it is recommended to add an
|
2473
|
+
extra method, <code><strong>innerMode</strong></code> which, given
|
2474
|
+
a state object, returns a <code>{state, mode}</code> object with
|
2475
|
+
the inner mode and its state for the current position. These are
|
2476
|
+
used by utility scripts such as the <a href="#addon_closetag">tag
|
2477
|
+
closer</a> to get context information. Use
|
2478
|
+
the <code>CodeMirror.innerMode</code> helper function to, starting
|
2479
|
+
from a mode and a state, recursively walk down to the innermost
|
2480
|
+
mode and state.</p>
|
2481
|
+
|
2482
|
+
<p>To make indentation work properly in a nested parser, it is
|
2483
|
+
advisable to give the <code>startState</code> method of modes that
|
2484
|
+
are intended to be nested an optional argument that provides the
|
2485
|
+
base indentation for the block of code. The JavaScript and CSS
|
2486
|
+
parser do this, for example, to allow JavaScript and CSS code
|
2487
|
+
inside the mixed-mode HTML mode to be properly indented.</p>
|
2488
|
+
|
2489
|
+
<p id="defineMIME">It is possible, and encouraged, to associate
|
2490
|
+
your mode, or a certain configuration of your mode, with
|
2491
|
+
a <a href="http://en.wikipedia.org/wiki/MIME">MIME</a> type. For
|
2492
|
+
example, the JavaScript mode associates itself
|
2493
|
+
with <code>text/javascript</code>, and its JSON variant
|
2494
|
+
with <code>application/json</code>. To do this,
|
2495
|
+
call <code><strong>CodeMirror.defineMIME</strong>(mime,
|
2496
|
+
modeSpec)</code>, where <code>modeSpec</code> can be a string or
|
2497
|
+
object specifying a mode, as in
|
2498
|
+
the <a href="#option_mode"><code>mode</code></a> option.</p>
|
2499
|
+
|
2500
|
+
<p id="extendMode">Sometimes, it is useful to add or override mode
|
2501
|
+
object properties from external code.
|
2502
|
+
The <code><strong>CodeMirror.extendMode</strong></code> function
|
2503
|
+
can be used to add properties to mode objects produced for a
|
2504
|
+
specific mode. Its first argument is the name of the mode, its
|
2505
|
+
second an object that specifies the properties that should be
|
2506
|
+
added. This is mostly useful to add utilities that can later be
|
2507
|
+
looked up through <a href="#getMode"><code>getMode</code></a>.</p>
|
2508
|
+
</section>
|
2509
|
+
|
2510
|
+
</article>
|
2511
|
+
|
2512
|
+
<script>setTimeout(function(){CodeMirror.colorize();}, 20);</script>
|