burp_cms 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +165 -0
- data/README.markdown +11 -0
- data/Rakefile +56 -0
- data/app/assets/images/burp/add-group-to-menu-1.png +0 -0
- data/app/assets/images/burp/add-group-to-menu-2.png +0 -0
- data/app/assets/images/burp/add-group-to-menu-3.png +0 -0
- data/app/assets/images/burp/add-group-to-menu-4.png +0 -0
- data/app/assets/images/burp/add-image-1.png +0 -0
- data/app/assets/images/burp/add-image-2.png +0 -0
- data/app/assets/images/burp/add-image-3.png +0 -0
- data/app/assets/images/burp/add-image-4.png +0 -0
- data/app/assets/images/burp/add-image-5.png +0 -0
- data/app/assets/images/burp/add-link-to-group-1.png +0 -0
- data/app/assets/images/burp/add-link-to-group-2.png +0 -0
- data/app/assets/images/burp/add-link-to-group-3.png +0 -0
- data/app/assets/images/burp/add-link-to-menu-1.png +0 -0
- data/app/assets/images/burp/add-link-to-menu-2.png +0 -0
- data/app/assets/images/burp/add-link-to-menu-3.png +0 -0
- data/app/assets/images/burp/add-link-to-menu-4.png +0 -0
- data/app/assets/images/burp/add-page-to-menu-1.png +0 -0
- data/app/assets/images/burp/add-page-to-menu-2.png +0 -0
- data/app/assets/images/burp/add-page-to-menu-3.png +0 -0
- data/app/assets/images/burp/add-page-to-menu-4.png +0 -0
- data/app/assets/images/burp/add-page-to-menu-5.png +0 -0
- data/app/assets/images/burp/adding-a-page-1.png +0 -0
- data/app/assets/images/burp/adding-a-page-2.png +0 -0
- data/app/assets/images/burp/adding-a-page-3.png +0 -0
- data/app/assets/images/burp/adding-a-page-4.png +0 -0
- data/app/assets/images/burp/change-page-title-1.png +0 -0
- data/app/assets/images/burp/change-page-title-2.png +0 -0
- data/app/assets/images/burp/change-page-title-3.png +0 -0
- data/app/assets/images/burp/change-page-title-4.png +0 -0
- data/app/assets/images/burp/change-the-text-1.png +0 -0
- data/app/assets/images/burp/change-the-text-2.png +0 -0
- data/app/assets/images/burp/change-the-text-3.png +0 -0
- data/app/assets/images/burp/enter-page-edit-mode-1.png +0 -0
- data/app/assets/images/burp/enter-page-edit-mode-2.png +0 -0
- data/app/assets/images/burp/enter-page-edit-mode-3.png +0 -0
- data/app/assets/images/burp/enter-page-edit-mode-4.jpg +0 -0
- data/app/assets/images/burp/enter-page-edit-mode-4.png +0 -0
- data/app/assets/images/burp/img/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/burp/img/glyphicons-halflings.png +0 -0
- data/app/assets/images/burp/move-link-to-bottom-of-menu-1.png +0 -0
- data/app/assets/images/burp/move-link-to-bottom-of-menu-2.png +0 -0
- data/app/assets/images/burp/move-link-to-bottom-of-menu-3.png +0 -0
- data/app/assets/images/burp/remove-a-page-1.png +0 -0
- data/app/assets/images/burp/remove-a-page-2.png +0 -0
- data/app/assets/images/burp/remove-a-page-3.png +0 -0
- data/app/assets/images/burp/remove-a-page-4.png +0 -0
- data/app/assets/images/burp/remove-image-1.png +0 -0
- data/app/assets/images/burp/remove-image-2.png +0 -0
- data/app/assets/images/burp/remove-image-3.png +0 -0
- data/app/assets/images/burp/remove-image-4.png +0 -0
- data/app/assets/images/burp/remove-image-5.png +0 -0
- data/app/assets/images/burp/remove-page-from-menu-1.png +0 -0
- data/app/assets/images/burp/remove-page-from-menu-2.png +0 -0
- data/app/assets/images/burp/remove-page-from-menu-3.png +0 -0
- data/app/assets/images/burp/remove-page-from-menu-4.png +0 -0
- data/app/assets/javascripts/burp/application.js +22 -0
- data/app/assets/javascripts/burp/burp.js +2 -0
- data/app/assets/javascripts/burp/cms_helper.js +49 -0
- data/app/assets/javascripts/burp/edit-page.js +22 -0
- data/app/assets/javascripts/burp/lib/bootstrap.min.js +6 -0
- data/app/assets/javascripts/burp/lib/debug.js +222 -0
- data/app/assets/javascripts/burp/lib/fileupload.js +1255 -0
- data/app/assets/javascripts/burp/lib/missing-restful-verbs.js +46 -0
- data/app/assets/javascripts/burp/menu-functions.js +28 -0
- data/app/assets/javascripts/burp/pages-drag-and-drop.js +151 -0
- data/app/assets/packages/burp/editing/css/dropzone.css +15 -0
- data/app/assets/packages/burp/editing/css/edit-content.less +126 -0
- data/app/assets/packages/burp/editing/css/gallery.css +167 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/LICENSE +23 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/README.md +8 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/activeline.html +72 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/changemode.html +50 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/closetag.html +65 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/complete.html +70 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/emacs.html +59 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/folding.html +61 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/formatting.html +80 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/fullscreen.html +152 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/loadmode.html +39 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/marker.html +52 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/matchhighlighter.html +37 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/multiplex.html +59 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/mustache.html +57 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/preview.html +76 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/resize.html +41 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/runmode.html +49 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/search.html +83 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/theme.html +78 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/vim.html +50 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/demo/visibletabs.html +61 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/baboon.png +0 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/baboon_vector.svg +153 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/compress.html +148 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/docs.css +154 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/internals.html +494 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/manual.html +1128 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/oldrelease.html +267 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/reporting.html +57 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/doc/upgrade_v2.2.html +95 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/index.html +417 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/keymap/emacs.js +29 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/keymap/vim.js +766 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/codemirror.css +168 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/codemirror.js +3181 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/closetag.js +146 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/dialog.css +23 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/dialog.js +63 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/foldcode.js +196 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/formatting.js +297 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/javascript-hint.js +134 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/loadmode.js +51 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/match-highlighter.js +44 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/multiplex.js +72 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/overlay.js +52 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/pig-hint.js +123 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js +49 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/search.js +118 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/searchcursor.js +117 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/simple-hint.css +16 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/simple-hint.js +72 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/clike/clike.js +271 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/clike/index.html +101 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/clike/scala.html +765 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/clojure/clojure.js +207 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/clojure/index.html +66 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/coffeescript/LICENSE +22 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/coffeescript/coffeescript.js +347 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/coffeescript/index.html +727 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/css/css.js +124 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/css/index.html +55 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/diff/diff.js +32 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/diff/index.html +104 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/ecl/ecl.js +203 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/ecl/index.html +42 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/erlang/erlang.js +251 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/erlang/index.html +61 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/gfm/gfm.js +144 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/gfm/index.html +47 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/go/go.js +170 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/go/index.html +72 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/groovy/groovy.js +210 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/groovy/index.html +71 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/haskell/haskell.js +242 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/haskell/index.html +60 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/htmlembedded/htmlembedded.js +68 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/htmlembedded/index.html +49 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/htmlmixed/htmlmixed.js +85 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/htmlmixed/index.html +51 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/javascript/index.html +77 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/javascript/javascript.js +361 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/jinja2/index.html +37 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/jinja2/jinja2.js +42 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/less/index.html +618 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/less/less.js +232 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/lua/index.html +72 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/lua/lua.js +140 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/markdown/index.html +338 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/markdown/markdown.js +245 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/mysql/index.html +41 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/mysql/mysql.js +188 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/ntriples/index.html +32 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/ntriples/ntriples.js +172 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/pascal/LICENSE +7 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/pascal/index.html +48 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/pascal/pascal.js +94 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/perl/LICENSE +19 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/perl/index.html +62 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/perl/perl.js +816 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/php/index.html +48 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/php/php.js +150 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/pig/index.html +42 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/pig/pig.js +172 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/plsql/index.html +62 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/plsql/plsql.js +217 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/properties/index.html +40 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/properties/properties.js +63 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/python/LICENSE.txt +21 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/python/index.html +122 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/python/python.js +338 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/r/LICENSE +24 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/r/index.html +73 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/r/r.js +141 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rpm/changes/changes.js +19 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rpm/changes/index.html +53 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rpm/spec/index.html +99 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rpm/spec/spec.css +5 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rpm/spec/spec.js +66 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rst/index.html +525 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rst/rst.js +326 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/ruby/LICENSE +24 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/ruby/index.html +171 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/ruby/ruby.js +195 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rust/index.html +48 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/rust/rust.js +432 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/scheme/index.html +64 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/scheme/scheme.js +230 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/shell/index.html +50 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/shell/shell.js +103 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/smalltalk/index.html +55 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/smalltalk/smalltalk.js +139 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/smarty/index.html +82 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/smarty/smarty.js +148 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/sparql/index.html +40 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/sparql/sparql.js +143 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/stex/index.html +95 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/stex/stex.js +182 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/stex/test.html +263 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/tiddlywiki/index.html +140 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/tiddlywiki/tiddlywiki.js +384 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/tiki/index.html +82 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/tiki/tiki.css +26 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/tiki/tiki.js +316 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/vbscript/index.html +42 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/vbscript/vbscript.js +26 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/velocity/index.html +103 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/velocity/velocity.js +146 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/verilog/index.html +210 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/verilog/verilog.js +194 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xml/index.html +44 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xml/xml.js +325 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/LICENSE +20 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/index.html +222 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/test/index.html +27 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/test/testBase.js +42 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/test/testEmptySequenceKeyword.js +16 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/test/testMultiAttr.js +16 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/test/testNamespaces.js +91 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/test/testProcessingInstructions.js +16 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/test/testQuotes.js +19 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/xquery/xquery.js +448 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/yaml/index.html +67 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/mode/yaml/yaml.js +95 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/package.json +29 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/test/index.html +28 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/test/mode_test.css +22 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/test/mode_test.js +164 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/test/test.js +344 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/ambiance.css +81 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/blackboard.css +25 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/cobalt.css +18 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/eclipse.css +25 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/elegant.css +10 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/erlang-dark.css +21 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/lesser-dark.css +44 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/monokai.css +28 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/neat.css +9 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/night.css +21 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/rubyblue.css +21 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/vibrant-ink.css +27 -0
- data/app/assets/packages/burp/editing/dep/CodeMirror-2.3/theme/xq-dark.css +46 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/FontAwesome-Vectors.pdf +3180 -7
- data/app/assets/packages/burp/editing/dep/FontAwesome/FontAwesome.ttf +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/README.md +18 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/css/font-awesome-ie7.css +645 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/css/font-awesome.less +309 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/css/font-awesome-ie7.css +213 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/css/font-awesome.css +303 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/css/prettify.css +30 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/css/site.css +4904 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/fontawesome-webfont.eot +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/fontawesome-webfont.svg +255 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/fontawesome-webfont.ttf +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/fontawesome-webfont.woff +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/museo_slab_300-webfont.eot +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/museo_slab_300-webfont.ttf +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/museo_slab_500-webfont.eot +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/museo_slab_500-webfont.ttf +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/proximanova-webfont.eot +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/font/proximanova-webfont.ttf +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/ico/favicon.ico +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/backbone.min.js +37 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/index/index.js +89 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/jquery-1.7.1.min.js +4 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/prettify.min.js +28 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-alert.js +94 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-button.js +98 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-carousel.js +157 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-collapse.js +136 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-dropdown.js +92 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-modal.js +210 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-popover.js +95 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-scrollspy.js +125 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-tab.js +130 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-tooltip.js +270 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-transition.js +51 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/tw-bs-201/bootstrap-typeahead.js +271 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/js/underscore.min.js +31 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/font-awesome-ie7.less +245 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/font-awesome.less +327 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/font-site.less +26 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/mixins.less +43 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/site.less +300 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/accordion.less +33 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/alerts.less +58 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/bootstrap.less +62 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/breadcrumbs.less +24 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/button-groups.less +191 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/buttons.less +191 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/carousel.less +121 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/close.less +29 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/code.less +57 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/component-animations.less +20 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/dropdowns.less +143 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/forms.less +584 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/grid.less +5 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/hero-unit.less +22 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/labels-badges.less +55 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/layouts.less +17 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/mixins.less +631 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/modals.less +90 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/navbar.less +364 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/navs.less +363 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/pager.less +36 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/pagination.less +56 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/popovers.less +49 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/progress-bars.less +117 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/reset.less +126 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/responsive-1200px-min.less +26 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/responsive-767px-max.less +149 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/responsive-768px-979px.less +17 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/responsive-navbar.less +146 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/responsive-utilities.less +41 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/responsive.less +48 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/scaffolding.less +29 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/sprites.less +191 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/tables.less +176 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/thumbnails.less +47 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/tooltip.less +35 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/type.less +235 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/utilities.less +23 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/variables.less +205 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/twbs-203/wells.less +27 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/assets/less/variables.less +206 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/docs/index.html +1087 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/font/fontawesome-webfont.eot +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/font/fontawesome-webfont.svg +255 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/font/fontawesome-webfont.ttf +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/font/fontawesome-webfont.woff +0 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/less/font-awesome-ie7.less +245 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/less/font-awesome.less +329 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/sass/font-awesome.sass +712 -0
- data/app/assets/packages/burp/editing/dep/FontAwesome/sass/font-awesome.scss +329 -0
- data/app/assets/packages/burp/editing/js/admin-dock.js +282 -0
- data/app/assets/packages/burp/editing/js/content-decorator.js +321 -0
- data/app/assets/packages/burp/editing/js/main.js +331 -0
- data/app/assets/packages/burp/editing/js/marked.js +781 -0
- data/app/assets/packages/burp/editing/js/md5.js +207 -0
- data/app/assets/packages/burp/editing/js/stay.js +143 -0
- data/app/assets/packages/burp/editing.js +23 -0
- data/app/assets/packages/burp/editing.less +7 -0
- data/app/assets/packages/gritter/README.markdown +57 -0
- data/app/assets/packages/gritter/css/jquery.gritter.less +101 -0
- data/app/assets/packages/gritter/gritter.js +3 -0
- data/app/assets/packages/gritter/gritter.less +3 -0
- data/app/assets/packages/gritter/images/gritter-light.png +0 -0
- data/app/assets/packages/gritter/images/gritter-long.png +0 -0
- data/app/assets/packages/gritter/images/gritter.png +0 -0
- data/app/assets/packages/gritter/images/ie-spacer.gif +0 -0
- data/app/assets/packages/gritter/images/trees.jpg +0 -0
- data/app/assets/packages/gritter/index.html +269 -0
- data/app/assets/packages/gritter/js/jquery.gritter.js +418 -0
- data/app/assets/packages/gritter/js/jquery.gritter.min.js +1 -0
- data/app/assets/stylesheets/burp/application.less +82 -0
- data/app/assets/stylesheets/burp/bootstrap.less +6158 -0
- data/app/assets/stylesheets/burp/docs.less +83 -0
- data/app/assets/stylesheets/burp/fileupload.less +31 -0
- data/app/assets/stylesheets/burp/views/dnd-menu.less +87 -0
- data/app/assets/stylesheets/burp/views/files/index.less +40 -0
- data/app/assets/stylesheets/burp/views/pages/index.less +4 -0
- data/app/assets/stylesheets/burp/views/static/help.less +11 -0
- data/app/controllers/burp/application_controller.rb +45 -0
- data/app/controllers/burp/catch_all_controller.rb +24 -0
- data/app/controllers/burp/error_controller.rb +7 -0
- data/app/controllers/burp/files_controller.rb +92 -0
- data/app/controllers/burp/groups_controller.rb +49 -0
- data/app/controllers/burp/links_controller.rb +48 -0
- data/app/controllers/burp/menus_controller.rb +33 -0
- data/app/controllers/burp/pages_controller.rb +112 -0
- data/app/controllers/burp/static_controller.rb +11 -0
- data/app/helpers/burp/application_helper.rb +4 -0
- data/app/lib/burp/access.rb +63 -0
- data/app/lib/burp/group.rb +110 -0
- data/app/lib/burp/link.rb +66 -0
- data/app/lib/burp/page.rb +23 -0
- data/app/lib/burp/util/upload_handler.rb +84 -0
- data/app/lib/burp/util.rb +39 -0
- data/app/models/burp/file_model.rb +45 -0
- data/app/models/burp/menu.rb +60 -0
- data/app/models/burp/page_model.rb +158 -0
- data/app/views/burp/files/index.html.erb +87 -0
- data/app/views/burp/groups/edit.html.erb +18 -0
- data/app/views/burp/links/edit.html.erb +19 -0
- data/app/views/burp/menus/edit.html.erb +157 -0
- data/app/views/burp/menus/index.html.erb +9 -0
- data/app/views/burp/pages/edit.html.erb +20 -0
- data/app/views/burp/pages/index.html.erb +114 -0
- data/app/views/burp/static/help.html.erb +543 -0
- data/app/views/burp/static/index.html.erb +15 -0
- data/app/views/layouts/burp/application.html.erb +57 -0
- data/config/cucumber.yml +12 -0
- data/config/initializers/bootstrap_form.rb +2 -0
- data/config/routes.rb +30 -0
- data/lib/burp/capistrano.rb +51 -0
- data/lib/burp/engine.rb +15 -0
- data/lib/burp/version.rb +3 -0
- data/lib/burp_cms.rb +64 -0
- data/lib/tasks/burp_tasks.rake +99 -0
- metadata +845 -0
|
@@ -0,0 +1,1128 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>CodeMirror: User Manual</title>
|
|
5
|
+
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
|
|
6
|
+
<link rel="stylesheet" type="text/css" href="docs.css"/>
|
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
8
|
+
<style>dl dl {margin: 0;}</style>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
|
|
12
|
+
<h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMirror</a></h1>
|
|
13
|
+
|
|
14
|
+
<pre class="grey">
|
|
15
|
+
<img src="baboon.png" class="logo" alt="logo"/>/* User manual and
|
|
16
|
+
reference guide */
|
|
17
|
+
</pre>
|
|
18
|
+
|
|
19
|
+
<div class="clear"><div class="leftbig blk">
|
|
20
|
+
|
|
21
|
+
<h2 id="overview">Overview</h2>
|
|
22
|
+
|
|
23
|
+
<p>CodeMirror is a code-editor component that can be embedded in
|
|
24
|
+
Web pages. The code library provides <em>only</em> the editor
|
|
25
|
+
component, no accompanying buttons, auto-completion, or other IDE
|
|
26
|
+
functionality. It does provide a rich API on top of which such
|
|
27
|
+
functionality can be straightforwardly implemented. See
|
|
28
|
+
the <a href="#addons">add-ons</a> included in the distribution,
|
|
29
|
+
and
|
|
30
|
+
the <a href="https://github.com/jagthedrummer/codemirror-ui">CodeMirror
|
|
31
|
+
UI</a> project, for reusable implementations of extra features.</p>
|
|
32
|
+
|
|
33
|
+
<p>CodeMirror works with language-specific modes. Modes are
|
|
34
|
+
JavaScript programs that help color (and optionally indent) text
|
|
35
|
+
written in a given language. The distribution comes with a number
|
|
36
|
+
of modes (see the <code>mode/</code> directory), and it isn't hard
|
|
37
|
+
to <a href="#modeapi">write new ones</a> for other languages.</p>
|
|
38
|
+
|
|
39
|
+
<h2 id="usage">Basic Usage</h2>
|
|
40
|
+
|
|
41
|
+
<p>The easiest way to use CodeMirror is to simply load the script
|
|
42
|
+
and style sheet found under <code>lib/</code> in the distribution,
|
|
43
|
+
plus a mode script from one of the <code>mode/</code> directories
|
|
44
|
+
and a theme stylesheet from <code>theme/</code>. (See
|
|
45
|
+
also <a href="compress.html">the compression helper</a>.) For
|
|
46
|
+
example:</p>
|
|
47
|
+
|
|
48
|
+
<pre><script src="lib/codemirror.js"></script>
|
|
49
|
+
<link rel="stylesheet" href="../lib/codemirror.css">
|
|
50
|
+
<script src="mode/javascript/javascript.js"></script></pre>
|
|
51
|
+
|
|
52
|
+
<p>Having done this, an editor instance can be created like
|
|
53
|
+
this:</p>
|
|
54
|
+
|
|
55
|
+
<pre>var myCodeMirror = CodeMirror(document.body);</pre>
|
|
56
|
+
|
|
57
|
+
<p>The editor will be appended to the document body, will start
|
|
58
|
+
empty, and will use the mode that we loaded. To have more control
|
|
59
|
+
over the new editor, a configuration object can be passed
|
|
60
|
+
to <code>CodeMirror</code> as a second argument:</p>
|
|
61
|
+
|
|
62
|
+
<pre>var myCodeMirror = CodeMirror(document.body, {
|
|
63
|
+
value: "function myScript(){return 100;}\n",
|
|
64
|
+
mode: "javascript"
|
|
65
|
+
});</pre>
|
|
66
|
+
|
|
67
|
+
<p>This will initialize the editor with a piece of code already in
|
|
68
|
+
it, and explicitly tell it to use the JavaScript mode (which is
|
|
69
|
+
useful when multiple modes are loaded).
|
|
70
|
+
See <a href="#config">below</a> for a full discussion of the
|
|
71
|
+
configuration options that CodeMirror accepts.</p>
|
|
72
|
+
|
|
73
|
+
<p>In cases where you don't want to append the editor to an
|
|
74
|
+
element, and need more control over the way it is inserted, the
|
|
75
|
+
first argument to the <code>CodeMirror</code> function can also
|
|
76
|
+
be a function that, when given a DOM element, inserts it into the
|
|
77
|
+
document somewhere. This could be used to, for example, replace a
|
|
78
|
+
textarea with a real editor:</p>
|
|
79
|
+
|
|
80
|
+
<pre>var myCodeMirror = CodeMirror(function(elt) {
|
|
81
|
+
myTextArea.parentNode.replaceChild(elt, myTextArea);
|
|
82
|
+
}, {value: myTextArea.value});</pre>
|
|
83
|
+
|
|
84
|
+
<p>However, for this use case, which is a common way to use
|
|
85
|
+
CodeMirror, the library provides a much more powerful
|
|
86
|
+
shortcut:</p>
|
|
87
|
+
|
|
88
|
+
<pre>var myCodeMirror = CodeMirror.fromTextArea(myTextArea);</pre>
|
|
89
|
+
|
|
90
|
+
<p>This will, among other things, ensure that the textarea's value
|
|
91
|
+
is updated when the form (if it is part of a form) is submitted.
|
|
92
|
+
See the <a href="#fromTextArea">API reference</a> for a full
|
|
93
|
+
description of this method.</p>
|
|
94
|
+
|
|
95
|
+
<h2 id="config">Configuration</h2>
|
|
96
|
+
|
|
97
|
+
<p>Both the <code>CodeMirror</code> function and
|
|
98
|
+
its <code>fromTextArea</code> method take as second (optional)
|
|
99
|
+
argument an object containing configuration options. Any option
|
|
100
|
+
not supplied like this will be taken
|
|
101
|
+
from <code>CodeMirror.defaults</code>, an object containing the
|
|
102
|
+
default options. You can update this object to change the defaults
|
|
103
|
+
on your page.</p>
|
|
104
|
+
|
|
105
|
+
<p>Options are not checked in any way, so setting bogus option
|
|
106
|
+
values is bound to lead to odd errors.</p>
|
|
107
|
+
|
|
108
|
+
<p>These are the supported options:</p>
|
|
109
|
+
|
|
110
|
+
<dl>
|
|
111
|
+
<dt id="option_value"><code>value (string)</code></dt>
|
|
112
|
+
<dd>The starting value of the editor.</dd>
|
|
113
|
+
|
|
114
|
+
<dt id="option_mode"><code>mode (string or object)</code></dt>
|
|
115
|
+
<dd>The mode to use. When not given, this will default to the
|
|
116
|
+
first mode that was loaded. It may be a string, which either
|
|
117
|
+
simply names the mode or is
|
|
118
|
+
a <a href="http://en.wikipedia.org/wiki/MIME">MIME</a> type
|
|
119
|
+
associated with the mode. Alternatively, it may be an object
|
|
120
|
+
containing configuration options for the mode, with
|
|
121
|
+
a <code>name</code> property that names the mode (for
|
|
122
|
+
example <code>{name: "javascript", json: true}</code>). The demo
|
|
123
|
+
pages for each mode contain information about what configuration
|
|
124
|
+
parameters the mode supports. You can ask CodeMirror which modes
|
|
125
|
+
and MIME types are loaded with
|
|
126
|
+
the <code>CodeMirror.listModes</code>
|
|
127
|
+
and <code>CodeMirror.listMIMEs</code> functions.</dd>
|
|
128
|
+
|
|
129
|
+
<dt id="option_theme"><code>theme (string)</code></dt>
|
|
130
|
+
<dd>The theme to style the editor with. You must make sure the
|
|
131
|
+
CSS file defining the corresponding <code>.cm-s-[name]</code>
|
|
132
|
+
styles is loaded (see
|
|
133
|
+
the <a href="../theme/"><code>theme</code></a> directory in the
|
|
134
|
+
distribution). The default is <code>"default"</code>, for which
|
|
135
|
+
colors are included in <code>codemirror.css</code>. It is
|
|
136
|
+
possible to use multiple theming classes at once—for
|
|
137
|
+
example <code>"foo bar"</code> will assign both
|
|
138
|
+
the <code>cm-s-foo</code> and the <code>cm-s-bar</code> classes
|
|
139
|
+
to the editor.</dd>
|
|
140
|
+
|
|
141
|
+
<dt id="option_indentUnit"><code>indentUnit (integer)</code></dt>
|
|
142
|
+
<dd>How many spaces a block (whatever that means in the edited
|
|
143
|
+
language) should be indented. The default is 2.</dd>
|
|
144
|
+
|
|
145
|
+
<dt id="option_smartIndent"><code>smartIndent (boolean)</code></dt>
|
|
146
|
+
<dd>Whether to use the context-sensitive indentation that the
|
|
147
|
+
mode provides (or just indent the same as the line before).
|
|
148
|
+
Defaults to true.</dd>
|
|
149
|
+
|
|
150
|
+
<dt id="option_tabSize"><code>tabSize (integer)</code></dt>
|
|
151
|
+
<dd>The width of a tab character. Defaults to 4.</dd>
|
|
152
|
+
|
|
153
|
+
<dt id="option_indentWithTabs"><code>indentWithTabs (boolean)</code></dt>
|
|
154
|
+
<dd>Whether, when indenting, the first N*<code>tabSize</code>
|
|
155
|
+
spaces should be replaced by N tabs. Default is false.</dd>
|
|
156
|
+
|
|
157
|
+
<dt id="option_electricChars"><code>electricChars (boolean)</code></dt>
|
|
158
|
+
<dd>Configures whether the editor should re-indent the current
|
|
159
|
+
line when a character is typed that might change its proper
|
|
160
|
+
indentation (only works if the mode supports indentation).
|
|
161
|
+
Default is true.</dd>
|
|
162
|
+
|
|
163
|
+
<dt id="option_autoClearEmptyLines"><code>autoClearEmptyLines (boolean)</code></dt>
|
|
164
|
+
<dd>When turned on (default is off), this will clear
|
|
165
|
+
automatically clear lines consisting only of whitespace when the
|
|
166
|
+
cursor leaves them. This is mostly useful to prevent auto
|
|
167
|
+
indentation from introducing trailing whitespace in a file.</dd>
|
|
168
|
+
|
|
169
|
+
<dt id="option_keyMap"><code>keyMap (string)</code></dt>
|
|
170
|
+
<dd>Configures the keymap to use. The default
|
|
171
|
+
is <code>"default"</code>, which is the only keymap defined
|
|
172
|
+
in <code>codemirror.js</code> itself. Extra keymaps are found in
|
|
173
|
+
the <a href="../keymap/"><code>keymap</code></a> directory. See
|
|
174
|
+
the <a href="#keymaps">section on keymaps</a> for more
|
|
175
|
+
information.</dd>
|
|
176
|
+
|
|
177
|
+
<dt id="option_extraKeys"><code>extraKeys (object)</code></dt>
|
|
178
|
+
<dd>Can be used to specify extra keybindings for the editor,
|
|
179
|
+
alongside the ones defined
|
|
180
|
+
by <a href="#option_keyMap"><code>keyMap</code></a>. Should be
|
|
181
|
+
either null, or a valid <a href="#keymaps">keymap</a> value.</dd>
|
|
182
|
+
|
|
183
|
+
<dt id="option_lineWrapping"><code>lineWrapping (boolean)</code></dt>
|
|
184
|
+
<dd>Whether CodeMirror should scroll or wrap for long lines.
|
|
185
|
+
Defaults to <code>false</code> (scroll).</dd>
|
|
186
|
+
|
|
187
|
+
<dt id="option_lineNumbers"><code>lineNumbers (boolean)</code></dt>
|
|
188
|
+
<dd>Whether to show line numbers to the left of the editor.</dd>
|
|
189
|
+
|
|
190
|
+
<dt id="option_firstLineNumber"><code>firstLineNumber (integer)</code></dt>
|
|
191
|
+
<dd>At which number to start counting lines. Default is 1.</dd>
|
|
192
|
+
|
|
193
|
+
<dt id="option_gutter"><code>gutter (boolean)</code></dt>
|
|
194
|
+
<dd>Can be used to force a 'gutter' (empty space on the left of
|
|
195
|
+
the editor) to be shown even when no line numbers are active.
|
|
196
|
+
This is useful for setting <a href="#setMarker">markers</a>.</dd>
|
|
197
|
+
|
|
198
|
+
<dt id="option_fixedGutter"><code>fixedGutter (boolean)</code></dt>
|
|
199
|
+
<dd>When enabled (off by default), this will make the gutter
|
|
200
|
+
stay visible when the document is scrolled horizontally.</dd>
|
|
201
|
+
|
|
202
|
+
<dt id="option_readOnly"><code>readOnly (boolean)</code></dt>
|
|
203
|
+
<dd>This disables editing of the editor content by the user. If
|
|
204
|
+
the special value <code>"nocursor"</code> is given (instead of
|
|
205
|
+
simply <code>true</code>), focusing of the editor is also
|
|
206
|
+
disallowed.</dd>
|
|
207
|
+
|
|
208
|
+
<dt id="option_onChange"><code>onChange (function)</code></dt>
|
|
209
|
+
<dd>When given, this function will be called every time the
|
|
210
|
+
content of the editor is changed. It will be given the editor
|
|
211
|
+
instance as first argument, and an <code>{from, to, text, next}</code>
|
|
212
|
+
object containing information about the changes
|
|
213
|
+
that occurred as second argument. <code>from</code>
|
|
214
|
+
and <code>to</code> are the positions (in the pre-change
|
|
215
|
+
coordinate system) where the change started and
|
|
216
|
+
ended (for example, it might be <code>{ch:0, line:18}</code> if the
|
|
217
|
+
position is at the beginning of line #19). <code>text</code>
|
|
218
|
+
is an array of strings representing the text that replaced the changed
|
|
219
|
+
range (split by line). If multiple changes happened during a single
|
|
220
|
+
operation, the object will have a <code>next</code> property pointing to
|
|
221
|
+
another change object (which may point to another, etc).</dd>
|
|
222
|
+
|
|
223
|
+
<dt id="option_onCursorActivity"><code>onCursorActivity (function)</code></dt>
|
|
224
|
+
<dd>Will be called when the cursor or selection moves, or any
|
|
225
|
+
change is made to the editor content.</dd>
|
|
226
|
+
|
|
227
|
+
<dt id="option_onGutterClick"><code>onGutterClick (function)</code></dt>
|
|
228
|
+
<dd>When given, will be called whenever the editor gutter (the
|
|
229
|
+
line-number area) is clicked. Will be given the editor instance
|
|
230
|
+
as first argument, the (zero-based) number of the line that was
|
|
231
|
+
clicked as second argument, and the raw <code>mousedown</code>
|
|
232
|
+
event object as third argument.</dd>
|
|
233
|
+
|
|
234
|
+
<dt id="option_onFocus"><code>onFocus, onBlur (function)</code></dt>
|
|
235
|
+
<dd>The given functions will be called whenever the editor is
|
|
236
|
+
focused or unfocused.</dd>
|
|
237
|
+
|
|
238
|
+
<dt id="option_onScroll"><code>onScroll (function)</code></dt>
|
|
239
|
+
<dd>When given, will be called whenever the editor is
|
|
240
|
+
scrolled.</dd>
|
|
241
|
+
|
|
242
|
+
<dt id="option_onHighlightComplete"><code>onHighlightComplete (function)</code></dt>
|
|
243
|
+
<dd>Whenever the editor's content has been fully highlighted,
|
|
244
|
+
this function (if given) will be called. It'll be given a single
|
|
245
|
+
argument, the editor instance.</dd>
|
|
246
|
+
|
|
247
|
+
<dt id="option_onUpdate"><code>onUpdate (function)</code></dt>
|
|
248
|
+
<dd>Will be called whenever CodeMirror updates its DOM display.</dd>
|
|
249
|
+
|
|
250
|
+
<dt id="option_matchBrackets"><code>matchBrackets (boolean)</code></dt>
|
|
251
|
+
<dd>Determines whether brackets are matched whenever the cursor
|
|
252
|
+
is moved next to a bracket.</dd>
|
|
253
|
+
|
|
254
|
+
<dt id="option_workTime"><code>workTime, workDelay (number)</code></dt>
|
|
255
|
+
<dd>Highlighting is done by a pseudo background-thread that will
|
|
256
|
+
work for <code>workTime</code> milliseconds, and then use
|
|
257
|
+
timeout to sleep for <code>workDelay</code> milliseconds. The
|
|
258
|
+
defaults are 200 and 300, you can change these options to make
|
|
259
|
+
the highlighting more or less aggressive.</dd>
|
|
260
|
+
|
|
261
|
+
<dt id="option_pollInterval"><code>pollInterval (number)</code></dt>
|
|
262
|
+
<dd>Indicates how quickly CodeMirror should poll its input
|
|
263
|
+
textarea for changes. Most input is captured by events, but some
|
|
264
|
+
things, like IME input on some browsers, doesn't generate events
|
|
265
|
+
that allow CodeMirror to properly detect it. Thus, it polls.
|
|
266
|
+
Default is 100 milliseconds.</dd>
|
|
267
|
+
|
|
268
|
+
<dt id="option_undoDepth"><code>undoDepth (integer)</code></dt>
|
|
269
|
+
<dd>The maximum number of undo levels that the editor stores.
|
|
270
|
+
Defaults to 40.</dd>
|
|
271
|
+
|
|
272
|
+
<dt id="option_tabindex"><code>tabindex (integer)</code></dt>
|
|
273
|
+
<dd>The <a href="http://www.w3.org/TR/html401/interact/forms.html#adef-tabindex">tab
|
|
274
|
+
index</a> to assign to the editor. If not given, no tab index
|
|
275
|
+
will be assigned.</dd>
|
|
276
|
+
|
|
277
|
+
<dt id="option_autofocus"><code>autofocus (boolean)</code></dt>
|
|
278
|
+
<dd>Can be used to make CodeMirror focus itself on
|
|
279
|
+
initialization. Defaults to off.
|
|
280
|
+
When <a href="#fromTextArea"><code>fromTextArea</code></a> is
|
|
281
|
+
used, and no explicit value is given for this option, it will
|
|
282
|
+
inherit the setting from the textarea's <code>autofocus</code>
|
|
283
|
+
attribute.</dd>
|
|
284
|
+
|
|
285
|
+
<dt id="option_dragDrop"><code>dragDrop (boolean)</code></dt>
|
|
286
|
+
<dd>Controls whether drag-and-drop is enabled. On by default.</dd>
|
|
287
|
+
|
|
288
|
+
<dt id="option_onDragEvent"><code>onDragEvent (function)</code></dt>
|
|
289
|
+
<dd>When given, this will be called when the editor is handling
|
|
290
|
+
a <code>dragenter</code>, <code>dragover</code>,
|
|
291
|
+
or <code>drop</code> event. It will be passed the editor instance
|
|
292
|
+
and the event object as arguments. The callback can choose to
|
|
293
|
+
handle the event itself, in which case it should
|
|
294
|
+
return <code>true</code> to indicate that CodeMirror should not
|
|
295
|
+
do anything further.</dd>
|
|
296
|
+
|
|
297
|
+
<dt id="option_onKeyEvent"><code>onKeyEvent (function)</code></dt>
|
|
298
|
+
<dd>This provides a rather low-level hook into CodeMirror's key
|
|
299
|
+
handling. If provided, this function will be called on
|
|
300
|
+
every <code>keydown</code>, <code>keyup</code>,
|
|
301
|
+
and <code>keypress</code> event that CodeMirror captures. It
|
|
302
|
+
will be passed two arguments, the editor instance and the key
|
|
303
|
+
event. This key event is pretty much the raw key event, except
|
|
304
|
+
that a <code>stop()</code> method is always added to it. You
|
|
305
|
+
could feed it to, for example, <code>jQuery.Event</code> to
|
|
306
|
+
further normalize it.<br>This function can inspect the key
|
|
307
|
+
event, and handle it if it wants to. It may return true to tell
|
|
308
|
+
CodeMirror to ignore the event. Be wary that, on some browsers,
|
|
309
|
+
stopping a <code>keydown</code> does not stop
|
|
310
|
+
the <code>keypress</code> from firing, whereas on others it
|
|
311
|
+
does. If you respond to an event, you should probably inspect
|
|
312
|
+
its <code>type</code> property and only do something when it
|
|
313
|
+
is <code>keydown</code> (or <code>keypress</code> for actions
|
|
314
|
+
that need character data).</dd>
|
|
315
|
+
</dl>
|
|
316
|
+
|
|
317
|
+
<h2 id="keymaps">Keymaps</h2>
|
|
318
|
+
|
|
319
|
+
<p>Keymaps are ways to associate keys with functionality. A keymap
|
|
320
|
+
is an object mapping strings that identify the keys to functions
|
|
321
|
+
that implement their functionality.</p>
|
|
322
|
+
|
|
323
|
+
<p>Keys are identified either by name or by character.
|
|
324
|
+
The <code>CodeMirror.keyNames</code> object defines names for
|
|
325
|
+
common keys and associates them with their key codes. Examples of
|
|
326
|
+
names defined here are <code>Enter</code>, <code>F5</code>,
|
|
327
|
+
and <code>Q</code>. These can be prefixed
|
|
328
|
+
with <code>Shift-</code>, <code>Cmd-</code>, <code>Ctrl-</code>,
|
|
329
|
+
and <code>Alt-</code> (in that order!) to specify a modifier. So
|
|
330
|
+
for example, <code>Shift-Ctrl-Space</code> would be a valid key
|
|
331
|
+
identifier.</p>
|
|
332
|
+
|
|
333
|
+
<p>Alternatively, a character can be specified directly by
|
|
334
|
+
surrounding it in single quotes, for example <code>'$'</code>
|
|
335
|
+
or <code>'q'</code>. Due to limitations in the way browsers fire
|
|
336
|
+
key events, these may not be prefixed with modifiers.</p>
|
|
337
|
+
|
|
338
|
+
<p>The <code>CodeMirror.keyMap</code> object associates keymaps
|
|
339
|
+
with names. User code and keymap definitions can assign extra
|
|
340
|
+
properties to this object. Anywhere where a keymap is expected, a
|
|
341
|
+
string can be given, which will be looked up in this object. It
|
|
342
|
+
also contains the <code>"default"</code> keymap holding the
|
|
343
|
+
default bindings.</p>
|
|
344
|
+
|
|
345
|
+
<p>The values of properties in keymaps can be either functions of
|
|
346
|
+
a single argument (the CodeMirror instance), or strings. Such
|
|
347
|
+
strings refer to properties of the
|
|
348
|
+
<code>CodeMirror.commands</code> object, which defines a number of
|
|
349
|
+
common commands that are used by the default keybindings, and maps
|
|
350
|
+
them to functions. A key handler function may throw
|
|
351
|
+
<code>CodeMirror.Pass</code> to indicate that it has decided not
|
|
352
|
+
to handle the key, and other handlers (or the default behavior)
|
|
353
|
+
should be given a turn.</p>
|
|
354
|
+
|
|
355
|
+
<p>Keys mapped to command names that start with the
|
|
356
|
+
characters <code>"go"</code> (which should be used for
|
|
357
|
+
cursor-movement actions) will be fired even when an
|
|
358
|
+
extra <code>Shift</code> modifier is present (i.e. <code>"Up":
|
|
359
|
+
"goLineUp"</code> matches both up and shift-up). This is used to
|
|
360
|
+
easily implement shift-selection.</p>
|
|
361
|
+
|
|
362
|
+
<p>Keymaps can defer to each other by defining
|
|
363
|
+
a <code>fallthrough</code> property. This indicates that when a
|
|
364
|
+
key is not found in the map itself, one or more other maps should
|
|
365
|
+
be searched. It can hold either a single keymap or an array of
|
|
366
|
+
keymaps.</p>
|
|
367
|
+
|
|
368
|
+
<p>When a keymap contains a <code>nofallthrough</code> property
|
|
369
|
+
set to <code>true</code>, keys matched against that map will be
|
|
370
|
+
ignored if they don't match any of the bindings in the map (no
|
|
371
|
+
further child maps will be tried, and the default effect of
|
|
372
|
+
inserting a character will not occur).</p>
|
|
373
|
+
|
|
374
|
+
<h2 id="styling">Customized Styling</h2>
|
|
375
|
+
|
|
376
|
+
<p>Up to a certain extent, CodeMirror's look can be changed by
|
|
377
|
+
modifying style sheet files. The style sheets supplied by modes
|
|
378
|
+
simply provide the colors for that mode, and can be adapted in a
|
|
379
|
+
very straightforward way. To style the editor itself, it is
|
|
380
|
+
possible to alter or override the styles defined
|
|
381
|
+
in <a href="../lib/codemirror.css"><code>codemirror.css</code></a>.</p>
|
|
382
|
+
|
|
383
|
+
<p>Some care must be taken there, since a lot of the rules in this
|
|
384
|
+
file are necessary to have CodeMirror function properly. Adjusting
|
|
385
|
+
colors should be safe, of course, and with some care a lot of
|
|
386
|
+
other things can be changed as well. The CSS classes defined in
|
|
387
|
+
this file serve the following roles:</p>
|
|
388
|
+
|
|
389
|
+
<dl>
|
|
390
|
+
<dt id="class_CodeMirror"><code>CodeMirror</code></dt>
|
|
391
|
+
<dd>The outer element of the editor. This should be used for
|
|
392
|
+
borders and positioning. Can also be used to set styles that
|
|
393
|
+
should hold for everything inside the editor (such as font
|
|
394
|
+
and font size), or to set a background.</dd>
|
|
395
|
+
|
|
396
|
+
<dt id="class_CodeMirror_scroll"><code>CodeMirror-scroll</code></dt>
|
|
397
|
+
<dd>This determines whether the editor scrolls (<code>overflow:
|
|
398
|
+
auto</code> + fixed height). By default, it does. Giving
|
|
399
|
+
this <code>height: auto; overflow: visible;</code> will cause
|
|
400
|
+
the editor to resize to fit its content.</dd>
|
|
401
|
+
|
|
402
|
+
<dt id="class_CodeMirror_focused"><code>CodeMirror-focused</code></dt>
|
|
403
|
+
<dd>Whenever the editor is focused, the top element gets this
|
|
404
|
+
class. This is used to hide the cursor and give the selection a
|
|
405
|
+
different color when the editor is not focused.</dd>
|
|
406
|
+
|
|
407
|
+
<dt id="class_CodeMirror_gutter"><code>CodeMirror-gutter</code></dt>
|
|
408
|
+
<dd>Use this for giving a background or a border to the editor
|
|
409
|
+
gutter. Don't set any padding here,
|
|
410
|
+
use <code>CodeMirror-gutter-text</code> for that. By default,
|
|
411
|
+
the gutter is 'fluid', meaning it will adjust its width to the
|
|
412
|
+
maximum line number or line marker width. You can also set a
|
|
413
|
+
fixed width if you want.</dd>
|
|
414
|
+
|
|
415
|
+
<dt id="class_CodeMirror_gutter_text"><code>CodeMirror-gutter-text</code></dt>
|
|
416
|
+
<dd>Used to style the actual line numbers. For the numbers to
|
|
417
|
+
line up, you must make sure that the font in the gutter is the
|
|
418
|
+
same as the one in the rest of the editor, so you should
|
|
419
|
+
probably only set font style and size in
|
|
420
|
+
the <code>CodeMirror</code> class.</dd>
|
|
421
|
+
|
|
422
|
+
<dt id="class_CodeMirror_lines"><code>CodeMirror-lines</code></dt>
|
|
423
|
+
<dd>The visible lines. If this has vertical
|
|
424
|
+
padding, <code>CodeMirror-gutter</code> should have the same
|
|
425
|
+
padding.</dd>
|
|
426
|
+
|
|
427
|
+
<dt id="class_CodeMirror_cursor"><code>CodeMirror-cursor</code></dt>
|
|
428
|
+
<dd>The cursor is a block element that is absolutely positioned.
|
|
429
|
+
You can make it look whichever way you want.</dd>
|
|
430
|
+
|
|
431
|
+
<dt id="class_CodeMirror_selected"><code>CodeMirror-selected</code></dt>
|
|
432
|
+
<dd>The selection is represented by <code>span</code> elements
|
|
433
|
+
with this class.</dd>
|
|
434
|
+
|
|
435
|
+
<dt id="class_CodeMirror_matchingbracket"><code>CodeMirror-matchingbracket</code>,
|
|
436
|
+
<code>CodeMirror-nonmatchingbracket</code></dt>
|
|
437
|
+
<dd>These are used to style matched (or unmatched) brackets.</dd>
|
|
438
|
+
</dl>
|
|
439
|
+
|
|
440
|
+
<p>The actual lines, as well as the cursor, are represented
|
|
441
|
+
by <code>pre</code> elements. By default no text styling (such as
|
|
442
|
+
bold) that might change line height is applied. If you do want
|
|
443
|
+
such effects, you'll have to give <code>CodeMirror pre</code> a
|
|
444
|
+
fixed height.</p>
|
|
445
|
+
|
|
446
|
+
<p>If your page's style sheets do funky things to
|
|
447
|
+
all <code>div</code> or <code>pre</code> elements (you probably
|
|
448
|
+
shouldn't do that), you'll have to define rules to cancel these
|
|
449
|
+
effects out again for elements under the <code>CodeMirror</code>
|
|
450
|
+
class.</p>
|
|
451
|
+
|
|
452
|
+
<p>Themes are also simply CSS files, which define colors for
|
|
453
|
+
various syntactic elements. See the files in
|
|
454
|
+
the <a href="../theme/"><code>theme</code></a> directory.</p>
|
|
455
|
+
|
|
456
|
+
<h2 id="api">Programming API</h2>
|
|
457
|
+
|
|
458
|
+
<p>A lot of CodeMirror features are only available through its API.
|
|
459
|
+
This has the disadvantage that you need to do work to enable them,
|
|
460
|
+
and the advantage that CodeMirror will fit seamlessly into your
|
|
461
|
+
application.</p>
|
|
462
|
+
|
|
463
|
+
<p>Whenever points in the document are represented, the API uses
|
|
464
|
+
objects with <code>line</code> and <code>ch</code> properties.
|
|
465
|
+
Both are zero-based. CodeMirror makes sure to 'clip' any positions
|
|
466
|
+
passed by client code so that they fit inside the document, so you
|
|
467
|
+
shouldn't worry too much about sanitizing your coordinates. If you
|
|
468
|
+
give <code>ch</code> a value of <code>null</code>, or don't
|
|
469
|
+
specify it, it will be replaced with the length of the specified
|
|
470
|
+
line.</p>
|
|
471
|
+
|
|
472
|
+
<dl>
|
|
473
|
+
<dt id="getValue"><code>getValue() → string</code></dt>
|
|
474
|
+
<dd>Get the current editor content.</dd>
|
|
475
|
+
<dt id="setValue"><code>setValue(string)</code></dt>
|
|
476
|
+
<dd>Set the editor content.</dd>
|
|
477
|
+
|
|
478
|
+
<dt id="getSelection"><code>getSelection() → string</code></dt>
|
|
479
|
+
<dd>Get the currently selected code.</dd>
|
|
480
|
+
<dt id="replaceSelection"><code>replaceSelection(string)</code></dt>
|
|
481
|
+
<dd>Replace the selection with the given string.</dd>
|
|
482
|
+
|
|
483
|
+
<dt id="focus"><code>focus()</code></dt>
|
|
484
|
+
<dd>Give the editor focus.</dd>
|
|
485
|
+
<dt id="scrollTo"><code>scrollTo(x, y)</code></dt>
|
|
486
|
+
<dd>Scroll the editor to a given (pixel) position. Both
|
|
487
|
+
arguments may be left as <code>null</code>
|
|
488
|
+
or <code>undefined</code> to have no effect.</dd>
|
|
489
|
+
<dt id="getScrollInfo"><code>getScrollInfo()</code></dt>
|
|
490
|
+
<dd>Get an <code>{x, y, width, height}</code> object that
|
|
491
|
+
represents the current scroll position and scrollable area size
|
|
492
|
+
of the editor.</dd>
|
|
493
|
+
|
|
494
|
+
<dt id="setOption"><code>setOption(option, value)</code></dt>
|
|
495
|
+
<dd>Change the configuration of the editor. <code>option</code>
|
|
496
|
+
should the name of an <a href="#config">option</a>,
|
|
497
|
+
and <code>value</code> should be a valid value for that
|
|
498
|
+
option.</dd>
|
|
499
|
+
<dt id="getOption"><code>getOption(option) → value</code></dt>
|
|
500
|
+
<dd>Retrieves the current value of the given option for this
|
|
501
|
+
editor instance.</dd>
|
|
502
|
+
|
|
503
|
+
<dt id="cursorCoords"><code>cursorCoords(start, mode) → object</code></dt>
|
|
504
|
+
<dd>Returns an <code>{x, y, yBot}</code> object containing the
|
|
505
|
+
coordinates of the cursor. If <code>mode</code>
|
|
506
|
+
is <code>"local"</code>, they will be relative to the top-left
|
|
507
|
+
corner of the editable document. If it is <code>"page"</code> or
|
|
508
|
+
not given, they are relative to the top-left corner of the
|
|
509
|
+
page. <code>yBot</code> is the coordinate of the bottom of the
|
|
510
|
+
cursor. <code>start</code> is a boolean indicating whether you
|
|
511
|
+
want the start or the end of the selection.</dd>
|
|
512
|
+
<dt id="charCoords"><code>charCoords(pos, mode) → object</code></dt>
|
|
513
|
+
<dd>Like <code>cursorCoords</code>, but returns the position of
|
|
514
|
+
an arbitrary characters. <code>pos</code> should be
|
|
515
|
+
a <code>{line, ch}</code> object.</dd>
|
|
516
|
+
<dt id="coordsChar"><code>coordsChar(object) → pos</code></dt>
|
|
517
|
+
<dd>Given an <code>{x, y}</code> object (in page coordinates),
|
|
518
|
+
returns the <code>{line, ch}</code> position that corresponds to
|
|
519
|
+
it.</dd>
|
|
520
|
+
|
|
521
|
+
<dt id="undo"><code>undo()</code></dt>
|
|
522
|
+
<dd>Undo one edit (if any undo events are stored).</dd>
|
|
523
|
+
<dt id="redo"><code>redo()</code></dt>
|
|
524
|
+
<dd>Redo one undone edit.</dd>
|
|
525
|
+
<dt id="historySize"><code>historySize() → object</code></dt>
|
|
526
|
+
<dd>Returns an object with <code>{undo, redo}</code> properties,
|
|
527
|
+
both of which hold integers, indicating the amount of stored
|
|
528
|
+
undo and redo operations.</dd>
|
|
529
|
+
<dt id="clearHistory"><code>clearHistory()</code></dt>
|
|
530
|
+
<dd>Clears the editor's undo history.</dd>
|
|
531
|
+
|
|
532
|
+
<dt id="indentLine"><code>indentLine(line, dir)</code></dt>
|
|
533
|
+
<dd>Reset the given line's indentation to the indentation
|
|
534
|
+
prescribed by the mode. If the second argument is given,
|
|
535
|
+
indentation will be increased (if <code>dir</code> is true) or
|
|
536
|
+
decreased (if false) by an <a href="#option_indentUnit">indent
|
|
537
|
+
unit</a> instead.</dd>
|
|
538
|
+
|
|
539
|
+
<dt id="getTokenAt"><code>getTokenAt(pos) → object</code></dt>
|
|
540
|
+
<dd>Retrieves information about the token the current mode found
|
|
541
|
+
before the given position (a <code>{line, ch}</code> object). The
|
|
542
|
+
returned object has the following properties:
|
|
543
|
+
<dl>
|
|
544
|
+
<dt><code>start</code></dt><dd>The character (on the given line) at which the token starts.</dd>
|
|
545
|
+
<dt><code>end</code></dt><dd>The character at which the token ends.</dd>
|
|
546
|
+
<dt><code>string</code></dt><dd>The token's string.</dd>
|
|
547
|
+
<dt><code>className</code></dt><dd>The class the mode assigned
|
|
548
|
+
to the token. (Can be null when no class was assigned.)</dd>
|
|
549
|
+
<dt><code>state</code></dt><dd>The mode's state at the end of this token.</dd>
|
|
550
|
+
</dl></dd>
|
|
551
|
+
|
|
552
|
+
<dt id="markText"><code>markText(from, to, className) → object</code></dt>
|
|
553
|
+
<dd>Can be used to mark a range of text with a specific CSS
|
|
554
|
+
class name. <code>from</code> and <code>to</code> should
|
|
555
|
+
be <code>{line, ch}</code> objects. The method will return an
|
|
556
|
+
object with two methods, <code>clear()</code>, which removes the
|
|
557
|
+
mark, and <code>find()</code>, which returns a <code>{from,
|
|
558
|
+
to}</code> (both document positions), indicating the current
|
|
559
|
+
position of the marked range.</dd>
|
|
560
|
+
|
|
561
|
+
<dt id="setBookmark"><code>setBookmark(pos) → object</code></dt>
|
|
562
|
+
<dd>Inserts a bookmark, a handle that follows the text around it
|
|
563
|
+
as it is being edited, at the given position. A bookmark has two
|
|
564
|
+
methods <code>find()</code> and <code>clear()</code>. The first
|
|
565
|
+
returns the current position of the bookmark, if it is still in
|
|
566
|
+
the document, and the second explicitly removes the
|
|
567
|
+
bookmark.</dd>
|
|
568
|
+
|
|
569
|
+
<dt id="findMarksAt"><code>findMarksAt(pos) → array</code></dt>
|
|
570
|
+
<dd>Returns an array of all the bookmarks and marked ranges
|
|
571
|
+
present at the given position.</dd>
|
|
572
|
+
|
|
573
|
+
<dt id="setMarker"><code>setMarker(line, text, className) → lineHandle</code></dt>
|
|
574
|
+
<dd>Add a gutter marker for the given line. Gutter markers are
|
|
575
|
+
shown in the line-number area (instead of the number for this
|
|
576
|
+
line). Both <code>text</code> and <code>className</code> are
|
|
577
|
+
optional. Setting <code>text</code> to a Unicode character like
|
|
578
|
+
● tends to give a nice effect. To put a picture in the gutter,
|
|
579
|
+
set <code>text</code> to a space and <code>className</code> to
|
|
580
|
+
something that sets a background image. If you
|
|
581
|
+
specify <code>text</code>, the given text (which may contain
|
|
582
|
+
HTML) will, by default, replace the line number for that line.
|
|
583
|
+
If this is not what you want, you can include the
|
|
584
|
+
string <code>%N%</code> in the text, which will be replaced by
|
|
585
|
+
the line number.</dd>
|
|
586
|
+
<dt id="clearMarker"><code>clearMarker(line)</code></dt>
|
|
587
|
+
<dd>Clears a marker created
|
|
588
|
+
with <code>setMarker</code>. <code>line</code> can be either a
|
|
589
|
+
number or a handle returned by <code>setMarker</code> (since a
|
|
590
|
+
number may now refer to a different line if something was added
|
|
591
|
+
or deleted).</dd>
|
|
592
|
+
<dt id="setLineClass"><code>setLineClass(line, className, backgroundClassName) → lineHandle</code></dt>
|
|
593
|
+
<dd>Set a CSS class name for the given line. <code>line</code>
|
|
594
|
+
can be a number or a line handle (as returned
|
|
595
|
+
by <code>setMarker</code> or this
|
|
596
|
+
function). <code>className</code> will be used to style the text
|
|
597
|
+
for the line, and <code>backgroundClassName</code> to style its
|
|
598
|
+
background (which lies behind the selection).
|
|
599
|
+
Pass <code>null</code> to clear the classes for a line.</dd>
|
|
600
|
+
<dt id="hideLine"><code>hideLine(line) → lineHandle</code></dt>
|
|
601
|
+
<dd>Hide the given line (either by number or by handle). Hidden
|
|
602
|
+
lines don't show up in the editor, and their numbers are skipped
|
|
603
|
+
when <a href="#option_lineNumbers">line numbers</a> are enabled.
|
|
604
|
+
Deleting a region around them does delete them, and coping a
|
|
605
|
+
region around will include them in the copied text.</dd>
|
|
606
|
+
<dt id="showLine"><code>showLine(line) → lineHandle</code></dt>
|
|
607
|
+
<dd>The inverse of <code>hideLine</code>—re-shows a previously
|
|
608
|
+
hidden line, by number or by handle.</dd>
|
|
609
|
+
|
|
610
|
+
<dt id="onDeleteLine"><code>onDeleteLine(line, func)</code></dt>
|
|
611
|
+
<dd>Register a function that should be called when the line is
|
|
612
|
+
deleted from the document.</dd>
|
|
613
|
+
|
|
614
|
+
<dt id="lineInfo"><code>lineInfo(line) → object</code></dt>
|
|
615
|
+
<dd>Returns the line number, text content, and marker status of
|
|
616
|
+
the given line, which can be either a number or a handle
|
|
617
|
+
returned by <code>setMarker</code>. The returned object has the
|
|
618
|
+
structure <code>{line, handle, text, markerText, markerClass,
|
|
619
|
+
lineClass, bgClass}</code>.</dd>
|
|
620
|
+
|
|
621
|
+
<dt id="getLineHandle"><code>getLineHandle(num) → lineHandle</code></dt>
|
|
622
|
+
<dd>Fetches the line handle for the given line number.</dd>
|
|
623
|
+
|
|
624
|
+
<dt id="addWidget"><code>addWidget(pos, node, scrollIntoView)</code></dt>
|
|
625
|
+
<dd>Puts <code>node</code>, which should be an absolutely
|
|
626
|
+
positioned DOM node, into the editor, positioned right below the
|
|
627
|
+
given <code>{line, ch}</code> position.
|
|
628
|
+
When <code>scrollIntoView</code> is true, the editor will ensure
|
|
629
|
+
that the entire node is visible (if possible). To remove the
|
|
630
|
+
widget again, simply use DOM methods (move it somewhere else, or
|
|
631
|
+
call <code>removeChild</code> on its parent).</dd>
|
|
632
|
+
|
|
633
|
+
<dt id="matchBrackets"><code>matchBrackets()</code></dt>
|
|
634
|
+
<dd>Force matching-bracket-highlighting to happen.</dd>
|
|
635
|
+
|
|
636
|
+
<dt id="lineCount"><code>lineCount() → number</code></dt>
|
|
637
|
+
<dd>Get the number of lines in the editor.</dd>
|
|
638
|
+
|
|
639
|
+
<dt id="getCursor"><code>getCursor(start) → object</code></dt>
|
|
640
|
+
<dd><code>start</code> is a boolean indicating whether the start
|
|
641
|
+
or the end of the selection must be retrieved. If it is not
|
|
642
|
+
given, the current cursor pos, i.e. the side of the selection
|
|
643
|
+
that would move if you pressed an arrow key, is chosen.
|
|
644
|
+
A <code>{line, ch}</code> object will be returned.</dd>
|
|
645
|
+
<dt id="somethingSelected"><code>somethingSelected() → boolean</code></dt>
|
|
646
|
+
<dd>Return true if any text is selected.</dd>
|
|
647
|
+
<dt id="setCursor"><code>setCursor(pos)</code></dt>
|
|
648
|
+
<dd>Set the cursor position. You can either pass a
|
|
649
|
+
single <code>{line, ch}</code> object, or the line and the
|
|
650
|
+
character as two separate parameters.</dd>
|
|
651
|
+
<dt id="setSelection"><code>setSelection(start, end)</code></dt>
|
|
652
|
+
<dd>Set the selection range. <code>start</code>
|
|
653
|
+
and <code>end</code> should be <code>{line, ch}</code> objects.</dd>
|
|
654
|
+
|
|
655
|
+
<dt id="getLine"><code>getLine(n) → string</code></dt>
|
|
656
|
+
<dd>Get the content of line <code>n</code>.</dd>
|
|
657
|
+
<dt id="setLine"><code>setLine(n, text)</code></dt>
|
|
658
|
+
<dd>Set the content of line <code>n</code>.</dd>
|
|
659
|
+
<dt id="removeLine"><code>removeLine(n)</code></dt>
|
|
660
|
+
<dd>Remove the given line from the document.</dd>
|
|
661
|
+
|
|
662
|
+
<dt id="getRange"><code>getRange(from, to) → string</code></td>
|
|
663
|
+
<dd>Get the text between the given points in the editor, which
|
|
664
|
+
should be <code>{line, ch}</code> objects.</dd>
|
|
665
|
+
<dt id="replaceRange"><code>replaceRange(string, from, to)</code></dt>
|
|
666
|
+
<dd>Replace the part of the document between <code>from</code>
|
|
667
|
+
and <code>to</code> with the given string. <code>from</code>
|
|
668
|
+
and <code>to</code> must be <code>{line, ch}</code>
|
|
669
|
+
objects. <code>to</code> can be left off to simply insert the
|
|
670
|
+
string at position <code>from</code>.</dd>
|
|
671
|
+
|
|
672
|
+
<dt id="posFromIndex"><code>posFromIndex(index) → object</code></dt>
|
|
673
|
+
<dd>Calculates and returns a <code>{line, ch}</code> object for a
|
|
674
|
+
zero-based <code>index</code> who's value is relative to the start of the
|
|
675
|
+
editor's text. If the <code>index</code> is out of range of the text then
|
|
676
|
+
the returned object is clipped to start or end of the text
|
|
677
|
+
respectively.</dd>
|
|
678
|
+
<dt id="indexFromPos"><code>indexFromPos(object) → number</code></dt>
|
|
679
|
+
<dd>The reverse of <a href="#posFromIndex"><code>posFromIndex</code></a>.</dd>
|
|
680
|
+
</dl>
|
|
681
|
+
|
|
682
|
+
<p>The following are more low-level methods:</p>
|
|
683
|
+
|
|
684
|
+
<dl>
|
|
685
|
+
<dt id="operation"><code>operation(func) → result</code></dt>
|
|
686
|
+
<dd>CodeMirror internally buffers changes and only updates its
|
|
687
|
+
DOM structure after it has finished performing some operation.
|
|
688
|
+
If you need to perform a lot of operations on a CodeMirror
|
|
689
|
+
instance, you can call this method with a function argument. It
|
|
690
|
+
will call the function, buffering up all changes, and only doing
|
|
691
|
+
the expensive update after the function returns. This can be a
|
|
692
|
+
lot faster. The return value from this method will be the return
|
|
693
|
+
value of your function.</dd>
|
|
694
|
+
|
|
695
|
+
<dt id="compoundChange"><code>compoundChange(func) → result</code></dt>
|
|
696
|
+
<dd>Will call the given function (and return its result),
|
|
697
|
+
combining all changes made while that function executes into a
|
|
698
|
+
single undo event.</dd>
|
|
699
|
+
|
|
700
|
+
<dt id="refresh"><code>refresh()</code></dt>
|
|
701
|
+
<dd>If your code does something to change the size of the editor
|
|
702
|
+
element (window resizes are already listened for), or unhides
|
|
703
|
+
it, you should probably follow up by calling this method to
|
|
704
|
+
ensure CodeMirror is still looking as intended.</dd>
|
|
705
|
+
|
|
706
|
+
<dt id="getInputField"><code>getInputField() → textarea</code></dt>
|
|
707
|
+
<dd>Returns the hidden textarea used to read input.</dd>
|
|
708
|
+
<dt id="getWrapperElement"><code>getWrapperElement() → node</code></dt>
|
|
709
|
+
<dd>Returns the DOM node that represents the editor. Remove this
|
|
710
|
+
from your tree to delete an editor instance.</dd>
|
|
711
|
+
<dt id="getScrollerElement"><code>getScrollerElement() → node</code></dt>
|
|
712
|
+
<dd>Returns the DOM node that is responsible for the sizing and
|
|
713
|
+
the scrolling of the editor. You can change
|
|
714
|
+
the <code>height</code> and <code>width</code> styles of this
|
|
715
|
+
element to resize an editor. (You might have to call
|
|
716
|
+
the <a href="#refresh"><code>refresh</code></a> method
|
|
717
|
+
afterwards.)</dd>
|
|
718
|
+
<dt id="getGutterElement"><code>getGutterElement() → node</code></dt>
|
|
719
|
+
<dd>Fetches the DOM node that represents the editor gutter.</dd>
|
|
720
|
+
|
|
721
|
+
<dt id="getStateAfter"><code>getStateAfter(line) → state</code></dt>
|
|
722
|
+
<dd>Returns the mode's parser state, if any, at the end of the
|
|
723
|
+
given line number. If no line number is given, the state at the
|
|
724
|
+
end of the document is returned. This can be useful for storing
|
|
725
|
+
parsing errors in the state, or getting other kinds of
|
|
726
|
+
contextual information for a line.</dd>
|
|
727
|
+
</dl>
|
|
728
|
+
|
|
729
|
+
<p id="fromTextArea">Finally, the <code>CodeMirror</code> object
|
|
730
|
+
itself has a method <code>fromTextArea</code>. This takes a
|
|
731
|
+
textarea DOM node as first argument and an optional configuration
|
|
732
|
+
object as second. It will replace the textarea with a CodeMirror
|
|
733
|
+
instance, and wire up the form of that textarea (if any) to make
|
|
734
|
+
sure the editor contents are put into the textarea when the form
|
|
735
|
+
is submitted. A CodeMirror instance created this way has two
|
|
736
|
+
additional methods:</p>
|
|
737
|
+
|
|
738
|
+
<dl>
|
|
739
|
+
<dt id="save"><code>save()</code></dt>
|
|
740
|
+
<dd>Copy the content of the editor into the textarea.</dd>
|
|
741
|
+
|
|
742
|
+
<dt id="toTextArea"><code>toTextArea()</code></dt>
|
|
743
|
+
<dd>Remove the editor, and restore the original textarea (with
|
|
744
|
+
the editor's current content).</dd>
|
|
745
|
+
|
|
746
|
+
<dt id="getTextArea"><code>getTextArea() → textarea</code></dt>
|
|
747
|
+
<dd>Returns the textarea that the instance was based on.</dd>
|
|
748
|
+
</dl>
|
|
749
|
+
|
|
750
|
+
<p id="defineExtension">If you want to define extra methods in terms
|
|
751
|
+
of the CodeMirror API, it is possible to
|
|
752
|
+
use <code>CodeMirror.defineExtension(name, value)</code>. This
|
|
753
|
+
will cause the given value (usually a method) to be added to all
|
|
754
|
+
CodeMirror instances created from then on.</p>
|
|
755
|
+
|
|
756
|
+
<h2 id="addons">Add-ons</h2>
|
|
757
|
+
|
|
758
|
+
<p>The <code>lib/util</code> directory in the distribution
|
|
759
|
+
contains a number of reusable components that implement extra
|
|
760
|
+
editor functionality. In brief, they are:</p>
|
|
761
|
+
|
|
762
|
+
<dl>
|
|
763
|
+
<dt id="util_dialog"><a href="../lib/util/dialog.js"><code>dialog.js</code></a></dt>
|
|
764
|
+
<dd>Provides a very simple way to query users for text input.
|
|
765
|
+
Adds an <code>openDialog</code> method to CodeMirror instances,
|
|
766
|
+
which can be called with an HTML fragment that provides the
|
|
767
|
+
prompt (should include an <code>input</code> tag), and a
|
|
768
|
+
callback function that is called when text has been entered.
|
|
769
|
+
Depends on <code>lib/util/dialog.css</code>.</dd>
|
|
770
|
+
<dt id="util_searchcursor"><a href="../lib/util/searchcursor.js"><code>searchcursor.js</code></a></dt>
|
|
771
|
+
<dd>Adds the <code>getSearchCursor(query, start, caseFold) →
|
|
772
|
+
cursor</code> method to CodeMirror instances, which can be used
|
|
773
|
+
to implement search/replace functionality. <code>query</code>
|
|
774
|
+
can be a regular expression or a string (only strings will match
|
|
775
|
+
across lines—if they contain newlines). <code>start</code>
|
|
776
|
+
provides the starting position of the search. It can be
|
|
777
|
+
a <code>{line, ch}</code> object, or can be left off to default
|
|
778
|
+
to the start of the document. <code>caseFold</code> is only
|
|
779
|
+
relevant when matching a string. It will cause the search to be
|
|
780
|
+
case-insensitive. A search cursor has the following methods:
|
|
781
|
+
<dl>
|
|
782
|
+
<dt><code>findNext(), findPrevious() → boolean</code></dt>
|
|
783
|
+
<dd>Search forward or backward from the current position.
|
|
784
|
+
The return value indicates whether a match was found. If
|
|
785
|
+
matching a regular expression, the return value will be the
|
|
786
|
+
array returned by the <code>match</code> method, in case you
|
|
787
|
+
want to extract matched groups.</dd>
|
|
788
|
+
<dt><code>from(), to() → object</code></dt>
|
|
789
|
+
<dd>These are only valid when the last call
|
|
790
|
+
to <code>findNext</code> or <code>findPrevious</code> did
|
|
791
|
+
not return false. They will return <code>{line, ch}</code>
|
|
792
|
+
objects pointing at the start and end of the match.</dd>
|
|
793
|
+
<dt><code>replace(text)</code></dt>
|
|
794
|
+
<dd>Replaces the currently found match with the given text
|
|
795
|
+
and adjusts the cursor position to reflect the
|
|
796
|
+
replacement.</dd>
|
|
797
|
+
</dl></dd>
|
|
798
|
+
|
|
799
|
+
<dt id="util_search"><a href="../lib/util/search.js"><code>search.js</code></a></dt>
|
|
800
|
+
<dd>Implements the search commands. CodeMirror has keys bound to
|
|
801
|
+
these by default, but will not do anything with them unless an
|
|
802
|
+
implementation is provided. Depends
|
|
803
|
+
on <code>searchcursor.js</code>, and will make use
|
|
804
|
+
of <a href="#util_dialog"><code>openDialog</code></a> when
|
|
805
|
+
available to make prompting for search queries less ugly.</dd>
|
|
806
|
+
<dt id="util_foldcode"><a href="../lib/util/foldcode.js"><code>foldcode.js</code></a></dt>
|
|
807
|
+
<dd>Helps with code folding.
|
|
808
|
+
See <a href="../demo/folding.html">the demo</a> for an example.
|
|
809
|
+
Call <code>CodeMirror.newFoldFunction</code> with a range-finder
|
|
810
|
+
helper function to create a function that will, when applied to
|
|
811
|
+
a CodeMirror instance and a line number, attempt to fold or
|
|
812
|
+
unfold the block starting at the given line. A range-finder is a
|
|
813
|
+
language-specific function that also takes an instance and a
|
|
814
|
+
line number, and returns an end line for the block, or null if
|
|
815
|
+
no block is started on that line. This file
|
|
816
|
+
provides <code>CodeMirror.braceRangeFinder</code>, which finds
|
|
817
|
+
blocks in brace languages (JavaScript, C, Java,
|
|
818
|
+
etc), <code>CodeMirror.indentRangeFinder</code>, for languages
|
|
819
|
+
where indentation determines block structure (Python, Haskell),
|
|
820
|
+
and <code>CodeMirror.tagRangeFinder</code>, for XML-style
|
|
821
|
+
languages.</dd>
|
|
822
|
+
<dt id="util_runmode"><a href="../lib/util/runmode.js"><code>runmode.js</code></a></dt>
|
|
823
|
+
<dd>Can be used to run a CodeMirror mode over text without
|
|
824
|
+
actually opening an editor instance.
|
|
825
|
+
See <a href="../demo/runmode.html">the demo</a> for an
|
|
826
|
+
example.</dd>
|
|
827
|
+
<dt id="util_overlay"><a href="../lib/util/overlay.js"><code>overlay.js</code></a></dt>
|
|
828
|
+
<dd>Mode combinator that can be used to extend a mode with an
|
|
829
|
+
'overlay' — a secondary mode is run over the stream, along with
|
|
830
|
+
the base mode, and can color specific pieces of text without
|
|
831
|
+
interfering with the base mode.
|
|
832
|
+
Defines <code>CodeMirror.overlayMode</code>, which is used to
|
|
833
|
+
create such a mode. See <a href="../demo/mustache.html">this
|
|
834
|
+
demo</a> for a detailed example.</dd>
|
|
835
|
+
<dt id="util_multiplex"><a href="../lib/util/multiplex.js"><code>multiplex.js</code></a></dt>
|
|
836
|
+
<dd>Mode combinator that can be used to easily 'multiplex'
|
|
837
|
+
between several modes.
|
|
838
|
+
Defines <code>CodeMirror.multiplexingMode</code> which, when
|
|
839
|
+
given as first argument a mode object, and as other arguments
|
|
840
|
+
any number of <code>{open, close, mode [, delimStyle]}</code>
|
|
841
|
+
objects, will return a mode object that starts parsing using the
|
|
842
|
+
mode passed as first argument, but will switch to another mode
|
|
843
|
+
as soon as it encounters a string that occurs in one of
|
|
844
|
+
the <code>open</code> fields of the passed objects. When in a
|
|
845
|
+
sub-mode, it will go back to the top mode again when
|
|
846
|
+
the <code>close</code> string is encountered.
|
|
847
|
+
When <code>delimStyle</code> is specified, it will be the token
|
|
848
|
+
style returned for the delimiter tokens. The outer mode will not
|
|
849
|
+
see the content between the delimiters.
|
|
850
|
+
See <a href="../demo/multiplex.html">this demo</a> for an
|
|
851
|
+
example.</dd>
|
|
852
|
+
<dt id="util_simple-hint"><a href="../lib/util/simple-hint.js"><code>simple-hint.js</code></a></dt>
|
|
853
|
+
<dd>Provides a framework for showing autocompletion hints.
|
|
854
|
+
Defines <code>CodeMirror.simpleHint</code>, which takes a
|
|
855
|
+
CodeMirror instance and a hinting function, and pops up a widget
|
|
856
|
+
that allows the user to select a completion. Hinting functions
|
|
857
|
+
are function that take an editor instance, and return
|
|
858
|
+
a <code>{list, from, to}</code> object, where <code>list</code>
|
|
859
|
+
is an array of strings (the completions), and <code>from</code>
|
|
860
|
+
and <code>to</code> give the start and end of the token that is
|
|
861
|
+
being completed. Depends
|
|
862
|
+
on <code>lib/util/simple-hint.css</code>.</dd>
|
|
863
|
+
<dt id="util_javascript-hint"><a href="../lib/util/javascript-hint.js"><code>javascript-hint.js</code></a></dt>
|
|
864
|
+
<dd>Defines <code>CodeMirror.javascriptHint</code>
|
|
865
|
+
and <code>CodeMirror.coffeescriptHint</code>, which are simple
|
|
866
|
+
hinting functions for the JavaScript and CoffeeScript
|
|
867
|
+
modes.</dd>
|
|
868
|
+
<dt id="util_match-highlighter"><a href="../lib/util/match-highlighter.js"><code>match-highlighter.js</code></a></dt>
|
|
869
|
+
<dd>Adds a <code>matchHighlight</code> method to CodeMirror
|
|
870
|
+
instances that can be called (typically from
|
|
871
|
+
a <a href="#option_onCursorActivity"><code>onCursorActivity</code></a>
|
|
872
|
+
handler) to highlight all instances of a currently selected word
|
|
873
|
+
with the a classname given as a first argument to the method.
|
|
874
|
+
Depends on
|
|
875
|
+
the <a href="#util_searchcursor"><code>searchcursor</code></a>
|
|
876
|
+
add-on. Demo <a href="../demo/matchhighlighter.html">here</a>.</dd>
|
|
877
|
+
<dt id="util_closetag"><a href="../lib/util/closetag.js"><code>closetag.js</code></a></dt>
|
|
878
|
+
<dd>Provides utility functions for adding automatic tag closing
|
|
879
|
+
to XML modes. See
|
|
880
|
+
the <a href="../demo/closetag.html">demo</a>.</dd>
|
|
881
|
+
<dt id="util_loadmode"><a href="../lib/util/loadmode.js"><code>loadmode.js</code></a></dt>
|
|
882
|
+
<dd>Defines a <code>CodeMirror.requireMode(modename,
|
|
883
|
+
callback)</code> function that will try to load a given mode and
|
|
884
|
+
call the callback when it succeeded. You'll have to
|
|
885
|
+
set <code>CodeMirror.modeURL</code> to a string that mode paths
|
|
886
|
+
can be constructed from, for
|
|
887
|
+
example <code>"mode/%N/%N.js"</code>—the <code>%N</code>'s will
|
|
888
|
+
be replaced with the mode name. Also
|
|
889
|
+
defines <code>CodeMirror.autoLoadMode(instance, mode)</code>,
|
|
890
|
+
which will ensure the given mode is loaded and cause the given
|
|
891
|
+
editor instance to refresh its mode when the loading
|
|
892
|
+
succeeded. See the <a href="../demo/loadmode.html">demo</a>.</dd>
|
|
893
|
+
</dl>
|
|
894
|
+
|
|
895
|
+
<h2 id="modeapi">Writing CodeMirror Modes</h2>
|
|
896
|
+
|
|
897
|
+
<p>Modes typically consist of a single JavaScript file. This file
|
|
898
|
+
defines, in the simplest case, a lexer (tokenizer) for your
|
|
899
|
+
language—a function that takes a character stream as input,
|
|
900
|
+
advances it past a token, and returns a style for that token. More
|
|
901
|
+
advanced modes can also handle indentation for the language.</p>
|
|
902
|
+
|
|
903
|
+
<p id="defineMode">The mode script should
|
|
904
|
+
call <code>CodeMirror.defineMode</code> to register itself with
|
|
905
|
+
CodeMirror. This function takes two arguments. The first should be
|
|
906
|
+
the name of the mode, for which you should use a lowercase string,
|
|
907
|
+
preferably one that is also the name of the files that define the
|
|
908
|
+
mode (i.e. <code>"xml"</code> is defined <code>xml.js</code>). The
|
|
909
|
+
second argument should be a function that, given a CodeMirror
|
|
910
|
+
configuration object (the thing passed to
|
|
911
|
+
the <code>CodeMirror</code> function) and an optional mode
|
|
912
|
+
configuration object (as in
|
|
913
|
+
the <a href="#option_mode"><code>mode</code></a> option), returns
|
|
914
|
+
a mode object.</p>
|
|
915
|
+
|
|
916
|
+
<p>Typically, you should use this second argument
|
|
917
|
+
to <code>defineMode</code> as your module scope function (modes
|
|
918
|
+
should not leak anything into the global scope!), i.e. write your
|
|
919
|
+
whole mode inside this function.</p>
|
|
920
|
+
|
|
921
|
+
<p>The main responsibility of a mode script is <em>parsing</em>
|
|
922
|
+
the content of the editor. Depending on the language and the
|
|
923
|
+
amount of functionality desired, this can be done in really easy
|
|
924
|
+
or extremely complicated ways. Some parsers can be stateless,
|
|
925
|
+
meaning that they look at one element (<em>token</em>) of the code
|
|
926
|
+
at a time, with no memory of what came before. Most, however, will
|
|
927
|
+
need to remember something. This is done by using a <em>state
|
|
928
|
+
object</em>, which is an object that is always passed when
|
|
929
|
+
reading a token, and which can be mutated by the tokenizer.</p>
|
|
930
|
+
|
|
931
|
+
<p id="startState">Modes that use a state must define
|
|
932
|
+
a <code>startState</code> method on their mode object. This is a
|
|
933
|
+
function of no arguments that produces a state object to be used
|
|
934
|
+
at the start of a document.</p>
|
|
935
|
+
|
|
936
|
+
<p id="token">The most important part of a mode object is
|
|
937
|
+
its <code>token(stream, state)</code> method. All modes must
|
|
938
|
+
define this method. It should read one token from the stream it is
|
|
939
|
+
given as an argument, optionally update its state, and return a
|
|
940
|
+
style string, or <code>null</code> for tokens that do not have to
|
|
941
|
+
be styled. For your styles, you can either use the 'standard' ones
|
|
942
|
+
defined in the themes (without the <code>cm-</code> prefix), or
|
|
943
|
+
define your own and have people include a custom CSS file for your
|
|
944
|
+
mode.<p>
|
|
945
|
+
|
|
946
|
+
<p id="StringStream">The stream object encapsulates a line of code
|
|
947
|
+
(tokens may never span lines) and our current position in that
|
|
948
|
+
line. It has the following API:</p>
|
|
949
|
+
|
|
950
|
+
<dl>
|
|
951
|
+
<dt><code>eol() → boolean</code></dt>
|
|
952
|
+
<dd>Returns true only if the stream is at the end of the
|
|
953
|
+
line.</dd>
|
|
954
|
+
<dt><code>sol() → boolean</code></dt>
|
|
955
|
+
<dd>Returns true only if the stream is at the start of the
|
|
956
|
+
line.</dd>
|
|
957
|
+
|
|
958
|
+
<dt><code>peek() → character</code></dt>
|
|
959
|
+
<dd>Returns the next character in the stream without advancing
|
|
960
|
+
it. Will return <code>undefined</code> at the end of the
|
|
961
|
+
line.</dd>
|
|
962
|
+
<dt><code>next() → character</code></dt>
|
|
963
|
+
<dd>Returns the next character in the stream and advances it.
|
|
964
|
+
Also returns <code>undefined</code> when no more characters are
|
|
965
|
+
available.</dd>
|
|
966
|
+
|
|
967
|
+
<dt><code>eat(match) → character</code></dt>
|
|
968
|
+
<dd><code>match</code> can be a character, a regular expression,
|
|
969
|
+
or a function that takes a character and returns a boolean. If
|
|
970
|
+
the next character in the stream 'matches' the given argument,
|
|
971
|
+
it is consumed and returned. Otherwise, <code>undefined</code>
|
|
972
|
+
is returned.</dd>
|
|
973
|
+
<dt><code>eatWhile(match) → boolean</code></dt>
|
|
974
|
+
<dd>Repeatedly calls <code>eat</code> with the given argument,
|
|
975
|
+
until it fails. Returns true if any characters were eaten.</dd>
|
|
976
|
+
<dt><code>eatSpace() → boolean</code></dt>
|
|
977
|
+
<dd>Shortcut for <code>eatWhile</code> when matching
|
|
978
|
+
white-space.</dd>
|
|
979
|
+
<dt><code>skipToEnd()</code></dt>
|
|
980
|
+
<dd>Moves the position to the end of the line.</dd>
|
|
981
|
+
<dt><code>skipTo(ch) → boolean</code></dt>
|
|
982
|
+
<dd>Skips to the next occurrence of the given character, if
|
|
983
|
+
found on the current line (doesn't advance the stream if the
|
|
984
|
+
character does not occur on the line). Returns true if the
|
|
985
|
+
character was found.</dd>
|
|
986
|
+
<dt><code>match(pattern, consume, caseFold) → boolean</code></dt>
|
|
987
|
+
<dd>Act like a
|
|
988
|
+
multi-character <code>eat</code>—if <code>consume</code> is true
|
|
989
|
+
or not given—or a look-ahead that doesn't update the stream
|
|
990
|
+
position—if it is false. <code>pattern</code> can be either a
|
|
991
|
+
string or a regular expression starting with <code>^</code>.
|
|
992
|
+
When it is a string, <code>caseFold</code> can be set to true to
|
|
993
|
+
make the match case-insensitive. When successfully matching a
|
|
994
|
+
regular expression, the returned value will be the array
|
|
995
|
+
returned by <code>match</code>, in case you need to extract
|
|
996
|
+
matched groups.</dd>
|
|
997
|
+
|
|
998
|
+
<dt><code>backUp(n)</code></dt>
|
|
999
|
+
<dd>Backs up the stream <code>n</code> characters. Backing it up
|
|
1000
|
+
further than the start of the current token will cause things to
|
|
1001
|
+
break, so be careful.</dd>
|
|
1002
|
+
<dt><code>column() → integer</code></dt>
|
|
1003
|
+
<dd>Returns the column (taking into account tabs) at which the
|
|
1004
|
+
current token starts. Can be used to find out whether a token
|
|
1005
|
+
starts a new line.</dd>
|
|
1006
|
+
<dt><code>indentation() → integer</code></dt>
|
|
1007
|
+
<dd>Tells you how far the current line has been indented, in
|
|
1008
|
+
spaces. Corrects for tab characters.</dd>
|
|
1009
|
+
|
|
1010
|
+
<dt><code>current() → string</code></dt>
|
|
1011
|
+
<dd>Get the string between the start of the current token and
|
|
1012
|
+
the current stream position.</dd>
|
|
1013
|
+
</dl>
|
|
1014
|
+
|
|
1015
|
+
<p id="blankLine">By default, blank lines are simply skipped when
|
|
1016
|
+
tokenizing a document. For languages that have significant blank
|
|
1017
|
+
lines, you can define a <code>blankLine(state)</code> method on
|
|
1018
|
+
your mode that will get called whenever a blank line is passed
|
|
1019
|
+
over, so that it can update the parser state.</p>
|
|
1020
|
+
|
|
1021
|
+
<p id="copyState">Because state object are mutated, and CodeMirror
|
|
1022
|
+
needs to keep valid versions of a state around so that it can
|
|
1023
|
+
restart a parse at any line, copies must be made of state objects.
|
|
1024
|
+
The default algorithm used is that a new state object is created,
|
|
1025
|
+
which gets all the properties of the old object. Any properties
|
|
1026
|
+
which hold arrays get a copy of these arrays (since arrays tend to
|
|
1027
|
+
be used as mutable stacks). When this is not correct, for example
|
|
1028
|
+
because a mode mutates non-array properties of its state object, a
|
|
1029
|
+
mode object should define a <code>copyState</code> method,
|
|
1030
|
+
which is given a state and should return a safe copy of that
|
|
1031
|
+
state.</p>
|
|
1032
|
+
|
|
1033
|
+
<p id="compareStates">By default, CodeMirror will stop re-parsing
|
|
1034
|
+
a document as soon as it encounters a few lines that were
|
|
1035
|
+
highlighted the same in the old parse as in the new one. It is
|
|
1036
|
+
possible to provide an explicit way to test whether a state is
|
|
1037
|
+
equivalent to another one, which CodeMirror will use (instead of
|
|
1038
|
+
the unchanged-lines heuristic) to decide when to stop
|
|
1039
|
+
highlighting. You do this by providing
|
|
1040
|
+
a <code>compareStates</code> method on your mode object, which
|
|
1041
|
+
takes two state arguments and returns a boolean indicating whether
|
|
1042
|
+
they are equivalent. See the XML mode, which uses this to provide
|
|
1043
|
+
reliable highlighting of bad closing tags, as an example.</p>
|
|
1044
|
+
|
|
1045
|
+
<p id="indent">If you want your mode to provide smart indentation
|
|
1046
|
+
(though the <a href="#indentLine"><code>indentLine</code></a>
|
|
1047
|
+
method and the <code>indentAuto</code>
|
|
1048
|
+
and <code>newlineAndIndent</code> commands, which keys can be
|
|
1049
|
+
<a href="#option_extraKeys">bound</a> to), you must define
|
|
1050
|
+
an <code>indent(state, textAfter)</code> method on your mode
|
|
1051
|
+
object.</p>
|
|
1052
|
+
|
|
1053
|
+
<p>The indentation method should inspect the given state object,
|
|
1054
|
+
and optionally the <code>textAfter</code> string, which contains
|
|
1055
|
+
the text on the line that is being indented, and return an
|
|
1056
|
+
integer, the amount of spaces to indent. It should usually take
|
|
1057
|
+
the <a href="#option_indentUnit"><code>indentUnit</code></a>
|
|
1058
|
+
option into account.</p>
|
|
1059
|
+
|
|
1060
|
+
<p id="electricChars">Finally, a mode may define
|
|
1061
|
+
an <code>electricChars</code> property, which should hold a string
|
|
1062
|
+
containing all the characters that should trigger the behaviour
|
|
1063
|
+
described for
|
|
1064
|
+
the <a href="#option_electricChars"><code>electricChars</code></a>
|
|
1065
|
+
option.</p>
|
|
1066
|
+
|
|
1067
|
+
<p>So, to summarize, a mode <em>must</em> provide
|
|
1068
|
+
a <code>token</code> method, and it <em>may</em>
|
|
1069
|
+
provide <code>startState</code>, <code>copyState</code>,
|
|
1070
|
+
<code>compareStates</code>, and <code>indent</code> methods. For
|
|
1071
|
+
an example of a trivial mode, see
|
|
1072
|
+
the <a href="../mode/diff/diff.js">diff mode</a>, for a more involved
|
|
1073
|
+
example, see the <a href="../mode/clike/clike.js">C-like
|
|
1074
|
+
mode</a>.</p>
|
|
1075
|
+
|
|
1076
|
+
<p>Sometimes, it is useful for modes to <em>nest</em>—to have one
|
|
1077
|
+
mode delegate work to another mode. An example of this kind of
|
|
1078
|
+
mode is the <a href="../mode/htmlmixed/htmlmixed.js">mixed-mode HTML
|
|
1079
|
+
mode</a>. To implement such nesting, it is usually necessary to
|
|
1080
|
+
create mode objects and copy states yourself. To create a mode
|
|
1081
|
+
object, there are <code>CodeMirror.getMode(options,
|
|
1082
|
+
parserConfig)</code>, where the first argument is a configuration
|
|
1083
|
+
object as passed to the mode constructor function, and the second
|
|
1084
|
+
argument is a mode specification as in
|
|
1085
|
+
the <a href="#option_mode"><code>mode</code></a> option. To copy a
|
|
1086
|
+
state object, call <code>CodeMirror.copyState(mode, state)</code>,
|
|
1087
|
+
where <code>mode</code> is the mode that created the given
|
|
1088
|
+
state.</p>
|
|
1089
|
+
|
|
1090
|
+
<p>To make indentation work properly in a nested parser, it is
|
|
1091
|
+
advisable to give the <code>startState</code> method of modes that
|
|
1092
|
+
are intended to be nested an optional argument that provides the
|
|
1093
|
+
base indentation for the block of code. The JavaScript and CSS
|
|
1094
|
+
parser do this, for example, to allow JavaScript and CSS code
|
|
1095
|
+
inside the mixed-mode HTML mode to be properly indented.</p>
|
|
1096
|
+
|
|
1097
|
+
<p>Finally, it is possible to associate your mode, or a certain
|
|
1098
|
+
configuration of your mode, with
|
|
1099
|
+
a <a href="http://en.wikipedia.org/wiki/MIME">MIME</a> type. For
|
|
1100
|
+
example, the JavaScript mode associates itself
|
|
1101
|
+
with <code>text/javascript</code>, and its JSON variant
|
|
1102
|
+
with <code>application/json</code>. To do this,
|
|
1103
|
+
call <code>CodeMirror.defineMIME(mime, modeSpec)</code>,
|
|
1104
|
+
where <code>modeSpec</code> can be a string or object specifying a
|
|
1105
|
+
mode, as in the <a href="#option_mode"><code>mode</code></a>
|
|
1106
|
+
option.</p>
|
|
1107
|
+
|
|
1108
|
+
</div><div class="rightsmall blk">
|
|
1109
|
+
|
|
1110
|
+
<h2>Contents</h2>
|
|
1111
|
+
|
|
1112
|
+
<ul>
|
|
1113
|
+
<li><a href="#overview">Overview</a></li>
|
|
1114
|
+
<li><a href="#usage">Basic Usage</a></li>
|
|
1115
|
+
<li><a href="#config">Configuration</a></li>
|
|
1116
|
+
<li><a href="#keymaps">Keymaps</a></li>
|
|
1117
|
+
<li><a href="#styling">Customized Styling</a></li>
|
|
1118
|
+
<li><a href="#api">Programming API</a></li>
|
|
1119
|
+
<li><a href="#addons">Add-ons</a></li>
|
|
1120
|
+
<li><a href="#modeapi">Writing CodeMirror Modes</a></li>
|
|
1121
|
+
</ul>
|
|
1122
|
+
|
|
1123
|
+
</div></div>
|
|
1124
|
+
|
|
1125
|
+
<div style="height: 2em"> </div>
|
|
1126
|
+
|
|
1127
|
+
</body>
|
|
1128
|
+
</html>
|