administrate-field-simple_mde_markdown 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +72 -0
- data/.circleci/setup-rubygems.sh +3 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +196 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +8 -0
- data/administrate-field-simple_mde_markdown.gemspec +31 -0
- data/app/assets/javascripts/administrate-field-simple_mde_markdown/application.js +6 -0
- data/app/assets/stylesheets/administrate-field-simple_mde_markdown/application.css +3 -0
- data/app/views/fields/simple_mde_markdown/_form.html.erb +6 -0
- data/app/views/fields/simple_mde_markdown/_index.html.erb +1 -0
- data/app/views/fields/simple_mde_markdown/_show.html.erb +1 -0
- data/lib/administrate/field/simple_mde_markdown.rb +31 -0
- data/node_modules/.bin/marked +1 -0
- data/node_modules/codemirror-spell-checker/.eslintrc +23 -0
- data/node_modules/codemirror-spell-checker/.npmignore +2 -0
- data/node_modules/codemirror-spell-checker/.travis.yml +18 -0
- data/node_modules/codemirror-spell-checker/CONTRIBUTING 2.md +10 -0
- data/node_modules/codemirror-spell-checker/CONTRIBUTING.md +10 -0
- data/node_modules/codemirror-spell-checker/LICENSE +22 -0
- data/node_modules/codemirror-spell-checker/README.md +50 -0
- data/node_modules/codemirror-spell-checker/bower.json +27 -0
- data/node_modules/codemirror-spell-checker/debug/.spell-checker 2.css.icloud +0 -0
- data/node_modules/codemirror-spell-checker/debug/spell-checker.css +9 -0
- data/node_modules/codemirror-spell-checker/debug/spell-checker.debug.js +2844 -0
- data/node_modules/codemirror-spell-checker/debug/spell-checker.js +2841 -0
- data/node_modules/codemirror-spell-checker/dist/.spell-checker.min 2.css.icloud +0 -0
- data/node_modules/codemirror-spell-checker/dist/en_US.aff +201 -0
- data/node_modules/codemirror-spell-checker/dist/en_US.dic +62120 -0
- data/node_modules/codemirror-spell-checker/dist/spell-checker.min 2.js +7 -0
- data/node_modules/codemirror-spell-checker/dist/spell-checker.min.css +7 -0
- data/node_modules/codemirror-spell-checker/dist/spell-checker.min.js +7 -0
- data/node_modules/codemirror-spell-checker/gulpfile.js +94 -0
- data/node_modules/codemirror-spell-checker/package.json +75 -0
- data/node_modules/codemirror-spell-checker/src/css/spell-checker.css +3 -0
- data/node_modules/codemirror-spell-checker/src/data/en_US.aff +201 -0
- data/node_modules/codemirror-spell-checker/src/data/en_US.dic +62120 -0
- data/node_modules/codemirror-spell-checker/src/js/spell-checker.js +119 -0
- data/node_modules/codemirror/.package 2.json.icloud +0 -0
- data/node_modules/codemirror/AUTHORS +773 -0
- data/node_modules/codemirror/CHANGELOG.md +1486 -0
- data/node_modules/codemirror/CONTRIBUTING.md +92 -0
- data/node_modules/codemirror/LICENSE +21 -0
- data/node_modules/codemirror/README.md +49 -0
- data/node_modules/codemirror/addon/comment/comment.js +209 -0
- data/node_modules/codemirror/addon/comment/continuecomment.js +78 -0
- data/node_modules/codemirror/addon/dialog/dialog.css +32 -0
- data/node_modules/codemirror/addon/dialog/dialog.js +161 -0
- data/node_modules/codemirror/addon/display/autorefresh.js +47 -0
- data/node_modules/codemirror/addon/display/fullscreen.css +6 -0
- data/node_modules/codemirror/addon/display/fullscreen.js +41 -0
- data/node_modules/codemirror/addon/display/panel.js +127 -0
- data/node_modules/codemirror/addon/display/placeholder.js +63 -0
- data/node_modules/codemirror/addon/display/rulers.js +51 -0
- data/node_modules/codemirror/addon/edit/closebrackets.js +187 -0
- data/node_modules/codemirror/addon/edit/closetag.js +175 -0
- data/node_modules/codemirror/addon/edit/continuelist.js +89 -0
- data/node_modules/codemirror/addon/edit/matchbrackets.js +145 -0
- data/node_modules/codemirror/addon/edit/matchtags.js +66 -0
- data/node_modules/codemirror/addon/edit/trailingspace.js +27 -0
- data/node_modules/codemirror/addon/fold/brace-fold.js +105 -0
- data/node_modules/codemirror/addon/fold/comment-fold.js +59 -0
- data/node_modules/codemirror/addon/fold/foldcode.js +152 -0
- data/node_modules/codemirror/addon/fold/foldgutter.css +20 -0
- data/node_modules/codemirror/addon/fold/foldgutter.js +146 -0
- data/node_modules/codemirror/addon/fold/indent-fold.js +48 -0
- data/node_modules/codemirror/addon/fold/markdown-fold.js +49 -0
- data/node_modules/codemirror/addon/fold/xml-fold.js +184 -0
- data/node_modules/codemirror/addon/hint/anyword-hint.js +41 -0
- data/node_modules/codemirror/addon/hint/css-hint.js +60 -0
- data/node_modules/codemirror/addon/hint/html-hint.js +348 -0
- data/node_modules/codemirror/addon/hint/javascript-hint.js +157 -0
- data/node_modules/codemirror/addon/hint/show-hint.css +36 -0
- data/node_modules/codemirror/addon/hint/show-hint.js +434 -0
- data/node_modules/codemirror/addon/hint/sql-hint.js +299 -0
- data/node_modules/codemirror/addon/hint/xml-hint.js +110 -0
- data/node_modules/codemirror/addon/lint/coffeescript-lint.js +47 -0
- data/node_modules/codemirror/addon/lint/css-lint.js +40 -0
- data/node_modules/codemirror/addon/lint/html-lint.js +53 -0
- data/node_modules/codemirror/addon/lint/javascript-lint.js +63 -0
- data/node_modules/codemirror/addon/lint/json-lint.js +40 -0
- data/node_modules/codemirror/addon/lint/lint.css +73 -0
- data/node_modules/codemirror/addon/lint/lint.js +252 -0
- data/node_modules/codemirror/addon/lint/yaml-lint.js +41 -0
- data/node_modules/codemirror/addon/merge/merge.css +119 -0
- data/node_modules/codemirror/addon/merge/merge.js +1002 -0
- data/node_modules/codemirror/addon/mode/loadmode.js +64 -0
- data/node_modules/codemirror/addon/mode/multiplex.js +131 -0
- data/node_modules/codemirror/addon/mode/multiplex_test.js +33 -0
- data/node_modules/codemirror/addon/mode/overlay.js +90 -0
- data/node_modules/codemirror/addon/mode/simple.js +216 -0
- data/node_modules/codemirror/addon/runmode/colorize.js +40 -0
- data/node_modules/codemirror/addon/runmode/runmode-standalone.js +158 -0
- data/node_modules/codemirror/addon/runmode/runmode.js +72 -0
- data/node_modules/codemirror/addon/runmode/runmode.node.js +197 -0
- data/node_modules/codemirror/addon/scroll/annotatescrollbar.js +122 -0
- data/node_modules/codemirror/addon/scroll/scrollpastend.js +48 -0
- data/node_modules/codemirror/addon/scroll/simplescrollbars.css +66 -0
- data/node_modules/codemirror/addon/scroll/simplescrollbars.js +152 -0
- data/node_modules/codemirror/addon/search/jump-to-line.js +50 -0
- data/node_modules/codemirror/addon/search/match-highlighter.js +165 -0
- data/node_modules/codemirror/addon/search/matchesonscrollbar.css +8 -0
- data/node_modules/codemirror/addon/search/matchesonscrollbar.js +97 -0
- data/node_modules/codemirror/addon/search/search.js +258 -0
- data/node_modules/codemirror/addon/search/searchcursor.js +293 -0
- data/node_modules/codemirror/addon/selection/active-line.js +72 -0
- data/node_modules/codemirror/addon/selection/mark-selection.js +119 -0
- data/node_modules/codemirror/addon/selection/selection-pointer.js +98 -0
- data/node_modules/codemirror/addon/tern/tern.css +87 -0
- data/node_modules/codemirror/addon/tern/tern.js +718 -0
- data/node_modules/codemirror/addon/tern/worker.js +44 -0
- data/node_modules/codemirror/addon/wrap/hardwrap.js +145 -0
- data/node_modules/codemirror/bin/source-highlight +48 -0
- data/node_modules/codemirror/keymap/emacs.js +417 -0
- data/node_modules/codemirror/keymap/sublime.js +691 -0
- data/node_modules/codemirror/keymap/vim.js +5467 -0
- data/node_modules/codemirror/lib/codemirror.css +346 -0
- data/node_modules/codemirror/lib/codemirror.js +9698 -0
- data/node_modules/codemirror/mode/apl/apl.js +174 -0
- data/node_modules/codemirror/mode/asciiarmor/asciiarmor.js +74 -0
- data/node_modules/codemirror/mode/asn.1/asn.1.js +204 -0
- data/node_modules/codemirror/mode/asterisk/asterisk.js +196 -0
- data/node_modules/codemirror/mode/brainfuck/brainfuck.js +85 -0
- data/node_modules/codemirror/mode/clike/clike.js +879 -0
- data/node_modules/codemirror/mode/clojure/clojure.js +292 -0
- data/node_modules/codemirror/mode/cmake/cmake.js +97 -0
- data/node_modules/codemirror/mode/cobol/cobol.js +255 -0
- data/node_modules/codemirror/mode/coffeescript/coffeescript.js +359 -0
- data/node_modules/codemirror/mode/commonlisp/commonlisp.js +124 -0
- data/node_modules/codemirror/mode/crystal/crystal.js +433 -0
- data/node_modules/codemirror/mode/css/css.js +832 -0
- data/node_modules/codemirror/mode/cypher/cypher.js +150 -0
- data/node_modules/codemirror/mode/d/d.js +223 -0
- data/node_modules/codemirror/mode/dart/dart.js +157 -0
- data/node_modules/codemirror/mode/diff/diff.js +47 -0
- data/node_modules/codemirror/mode/django/django.js +356 -0
- data/node_modules/codemirror/mode/dockerfile/dockerfile.js +211 -0
- data/node_modules/codemirror/mode/dtd/dtd.js +142 -0
- data/node_modules/codemirror/mode/dylan/dylan.js +352 -0
- data/node_modules/codemirror/mode/ebnf/ebnf.js +195 -0
- data/node_modules/codemirror/mode/ecl/ecl.js +206 -0
- data/node_modules/codemirror/mode/eiffel/eiffel.js +160 -0
- data/node_modules/codemirror/mode/elm/elm.js +205 -0
- data/node_modules/codemirror/mode/erlang/erlang.js +619 -0
- data/node_modules/codemirror/mode/factor/factor.js +85 -0
- data/node_modules/codemirror/mode/fcl/fcl.js +173 -0
- data/node_modules/codemirror/mode/forth/forth.js +180 -0
- data/node_modules/codemirror/mode/fortran/fortran.js +188 -0
- data/node_modules/codemirror/mode/gas/gas.js +345 -0
- data/node_modules/codemirror/mode/gfm/gfm.js +129 -0
- data/node_modules/codemirror/mode/gherkin/gherkin.js +178 -0
- data/node_modules/codemirror/mode/go/go.js +187 -0
- data/node_modules/codemirror/mode/groovy/groovy.js +230 -0
- data/node_modules/codemirror/mode/haml/haml.js +161 -0
- data/node_modules/codemirror/mode/handlebars/handlebars.js +66 -0
- data/node_modules/codemirror/mode/haskell-literate/haskell-literate.js +43 -0
- data/node_modules/codemirror/mode/haskell/haskell.js +268 -0
- data/node_modules/codemirror/mode/haxe/haxe.js +515 -0
- data/node_modules/codemirror/mode/htmlembedded/htmlembedded.js +37 -0
- data/node_modules/codemirror/mode/htmlmixed/htmlmixed.js +152 -0
- data/node_modules/codemirror/mode/http/http.js +113 -0
- data/node_modules/codemirror/mode/idl/idl.js +290 -0
- data/node_modules/codemirror/mode/javascript/javascript.js +899 -0
- data/node_modules/codemirror/mode/jinja2/jinja2.js +144 -0
- data/node_modules/codemirror/mode/jsx/jsx.js +148 -0
- data/node_modules/codemirror/mode/julia/julia.js +433 -0
- data/node_modules/codemirror/mode/livescript/livescript.js +280 -0
- data/node_modules/codemirror/mode/lua/lua.js +159 -0
- data/node_modules/codemirror/mode/markdown/markdown.js +884 -0
- data/node_modules/codemirror/mode/mathematica/mathematica.js +176 -0
- data/node_modules/codemirror/mode/mbox/mbox.js +129 -0
- data/node_modules/codemirror/mode/meta.js +217 -0
- data/node_modules/codemirror/mode/mirc/mirc.js +193 -0
- data/node_modules/codemirror/mode/mllike/mllike.js +359 -0
- data/node_modules/codemirror/mode/modelica/modelica.js +245 -0
- data/node_modules/codemirror/mode/mscgen/mscgen.js +175 -0
- data/node_modules/codemirror/mode/mumps/mumps.js +148 -0
- data/node_modules/codemirror/mode/nginx/nginx.js +178 -0
- data/node_modules/codemirror/mode/nsis/nsis.js +95 -0
- data/node_modules/codemirror/mode/ntriples/ntriples.js +195 -0
- data/node_modules/codemirror/mode/octave/octave.js +139 -0
- data/node_modules/codemirror/mode/oz/oz.js +252 -0
- data/node_modules/codemirror/mode/pascal/pascal.js +121 -0
- data/node_modules/codemirror/mode/pegjs/pegjs.js +114 -0
- data/node_modules/codemirror/mode/perl/perl.js +837 -0
- data/node_modules/codemirror/mode/php/php.js +234 -0
- data/node_modules/codemirror/mode/pig/pig.js +178 -0
- data/node_modules/codemirror/mode/powershell/powershell.js +398 -0
- data/node_modules/codemirror/mode/properties/properties 2.js +78 -0
- data/node_modules/codemirror/mode/properties/properties.js +78 -0
- data/node_modules/codemirror/mode/protobuf/protobuf.js +69 -0
- data/node_modules/codemirror/mode/pug/pug.js +591 -0
- data/node_modules/codemirror/mode/puppet/puppet.js +220 -0
- data/node_modules/codemirror/mode/python/python.js +409 -0
- data/node_modules/codemirror/mode/q/q.js +139 -0
- data/node_modules/codemirror/mode/r/r.js +190 -0
- data/node_modules/codemirror/mode/rpm/changes/index.html +66 -0
- data/node_modules/codemirror/mode/rpm/rpm.js +109 -0
- data/node_modules/codemirror/mode/rst/rst.js +557 -0
- data/node_modules/codemirror/mode/ruby/ruby.js +296 -0
- data/node_modules/codemirror/mode/rust/rust.js +72 -0
- data/node_modules/codemirror/mode/sas/sas.js +303 -0
- data/node_modules/codemirror/mode/sass/sass.js +454 -0
- data/node_modules/codemirror/mode/scheme/scheme.js +265 -0
- data/node_modules/codemirror/mode/shell/shell.js +152 -0
- data/node_modules/codemirror/mode/sieve/sieve.js +193 -0
- data/node_modules/codemirror/mode/slim/slim.js +575 -0
- data/node_modules/codemirror/mode/smalltalk/smalltalk.js +168 -0
- data/node_modules/codemirror/mode/smarty/smarty.js +225 -0
- data/node_modules/codemirror/mode/solr/solr.js +104 -0
- data/node_modules/codemirror/mode/soy/soy 2.js +359 -0
- data/node_modules/codemirror/mode/soy/soy.js +235 -0
- data/node_modules/codemirror/mode/sparql/sparql.js +180 -0
- data/node_modules/codemirror/mode/spreadsheet/spreadsheet.js +112 -0
- data/node_modules/codemirror/mode/sql/sql.js +499 -0
- data/node_modules/codemirror/mode/stex/stex.js +264 -0
- data/node_modules/codemirror/mode/stylus/stylus.js +771 -0
- data/node_modules/codemirror/mode/swift/swift.js +219 -0
- data/node_modules/codemirror/mode/tcl/tcl.js +139 -0
- data/node_modules/codemirror/mode/textile/textile.js +469 -0
- data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.js +308 -0
- data/node_modules/codemirror/mode/tiki/tiki.css +26 -0
- data/node_modules/codemirror/mode/tiki/tiki.js +312 -0
- data/node_modules/codemirror/mode/toml/toml.js +88 -0
- data/node_modules/codemirror/mode/tornado/tornado.js +68 -0
- data/node_modules/codemirror/mode/troff/troff.js +84 -0
- data/node_modules/codemirror/mode/ttcn-cfg/ttcn-cfg.js +214 -0
- data/node_modules/codemirror/mode/ttcn/ttcn.js +283 -0
- data/node_modules/codemirror/mode/turtle/turtle.js +162 -0
- data/node_modules/codemirror/mode/twig/twig.js +141 -0
- data/node_modules/codemirror/mode/vb/vb.js +275 -0
- data/node_modules/codemirror/mode/vbscript/vbscript.js +350 -0
- data/node_modules/codemirror/mode/velocity/velocity.js +201 -0
- data/node_modules/codemirror/mode/verilog/verilog.js +675 -0
- data/node_modules/codemirror/mode/vhdl/vhdl.js +189 -0
- data/node_modules/codemirror/mode/vue/vue.js +77 -0
- data/node_modules/codemirror/mode/webidl/webidl.js +195 -0
- data/node_modules/codemirror/mode/xml/xml.js +402 -0
- data/node_modules/codemirror/mode/xquery/xquery.js +448 -0
- data/node_modules/codemirror/mode/yacas/yacas.js +204 -0
- data/node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +68 -0
- data/node_modules/codemirror/mode/yaml/yaml.js +120 -0
- data/node_modules/codemirror/mode/z80/z80.js +116 -0
- data/node_modules/codemirror/package.json +2395 -0
- data/node_modules/codemirror/rollup.config.js +20 -0
- data/node_modules/codemirror/src/codemirror.js +3 -0
- data/node_modules/codemirror/src/display/Display.js +106 -0
- data/node_modules/codemirror/src/display/focus.js +47 -0
- data/node_modules/codemirror/src/display/gutters.js +34 -0
- data/node_modules/codemirror/src/display/highlight_worker.js +55 -0
- data/node_modules/codemirror/src/display/line_numbers.js +48 -0
- data/node_modules/codemirror/src/display/mode_state.js +22 -0
- data/node_modules/codemirror/src/display/operations.js +205 -0
- data/node_modules/codemirror/src/display/scroll_events.js +115 -0
- data/node_modules/codemirror/src/display/scrollbars.js +193 -0
- data/node_modules/codemirror/src/display/scrolling.js +184 -0
- data/node_modules/codemirror/src/display/selection.js +158 -0
- data/node_modules/codemirror/src/display/update_display.js +260 -0
- data/node_modules/codemirror/src/display/update_line.js +188 -0
- data/node_modules/codemirror/src/display/update_lines.js +64 -0
- data/node_modules/codemirror/src/display/view_tracking.js +153 -0
- data/node_modules/codemirror/src/edit/CodeMirror.js +215 -0
- data/node_modules/codemirror/src/edit/commands.js +178 -0
- data/node_modules/codemirror/src/edit/deleteNearSelection.js +30 -0
- data/node_modules/codemirror/src/edit/drop_events.js +119 -0
- data/node_modules/codemirror/src/edit/fromTextArea.js +61 -0
- data/node_modules/codemirror/src/edit/global_events.js +42 -0
- data/node_modules/codemirror/src/edit/key_events.js +159 -0
- data/node_modules/codemirror/src/edit/legacy.js +62 -0
- data/node_modules/codemirror/src/edit/main.js +69 -0
- data/node_modules/codemirror/src/edit/methods.js +544 -0
- data/node_modules/codemirror/src/edit/mouse_events.js +407 -0
- data/node_modules/codemirror/src/edit/options.js +193 -0
- data/node_modules/codemirror/src/edit/utils.js +7 -0
- data/node_modules/codemirror/src/input/ContentEditableInput.js +527 -0
- data/node_modules/codemirror/src/input/TextareaInput.js +355 -0
- data/node_modules/codemirror/src/input/indent.js +71 -0
- data/node_modules/codemirror/src/input/input.js +135 -0
- data/node_modules/codemirror/src/input/keymap.js +148 -0
- data/node_modules/codemirror/src/input/keynames.js +17 -0
- data/node_modules/codemirror/src/input/movement.js +110 -0
- data/node_modules/codemirror/src/line/highlight.js +284 -0
- data/node_modules/codemirror/src/line/line_data.js +339 -0
- data/node_modules/codemirror/src/line/pos.js +40 -0
- data/node_modules/codemirror/src/line/saw_special_spans.js +10 -0
- data/node_modules/codemirror/src/line/spans.js +382 -0
- data/node_modules/codemirror/src/line/utils_line.js +85 -0
- data/node_modules/codemirror/src/measurement/position_measurement.js +699 -0
- data/node_modules/codemirror/src/measurement/widgets.js +26 -0
- data/node_modules/codemirror/src/model/Doc.js +432 -0
- data/node_modules/codemirror/src/model/change_measurement.js +61 -0
- data/node_modules/codemirror/src/model/changes.js +333 -0
- data/node_modules/codemirror/src/model/chunk.js +167 -0
- data/node_modules/codemirror/src/model/document_data.js +111 -0
- data/node_modules/codemirror/src/model/history.js +228 -0
- data/node_modules/codemirror/src/model/line_widget.js +78 -0
- data/node_modules/codemirror/src/model/mark_text.js +292 -0
- data/node_modules/codemirror/src/model/selection.js +84 -0
- data/node_modules/codemirror/src/model/selection_updates.js +208 -0
- data/node_modules/codemirror/src/modes.js +96 -0
- data/node_modules/codemirror/src/util/StringStream.js +90 -0
- data/node_modules/codemirror/src/util/bidi.js +214 -0
- data/node_modules/codemirror/src/util/browser.js +33 -0
- data/node_modules/codemirror/src/util/dom.js +97 -0
- data/node_modules/codemirror/src/util/event.js +103 -0
- data/node_modules/codemirror/src/util/feature_detection.js +84 -0
- data/node_modules/codemirror/src/util/misc.js +150 -0
- data/node_modules/codemirror/src/util/operation_group.js +72 -0
- data/node_modules/codemirror/theme/3024-day.css +41 -0
- data/node_modules/codemirror/theme/3024-night.css +39 -0
- data/node_modules/codemirror/theme/abcdef.css +32 -0
- data/node_modules/codemirror/theme/ambiance-mobile.css +5 -0
- data/node_modules/codemirror/theme/ambiance.css +74 -0
- data/node_modules/codemirror/theme/base16-dark.css +38 -0
- data/node_modules/codemirror/theme/base16-light.css +38 -0
- data/node_modules/codemirror/theme/bespin.css +34 -0
- data/node_modules/codemirror/theme/blackboard.css +32 -0
- data/node_modules/codemirror/theme/cobalt.css +25 -0
- data/node_modules/codemirror/theme/colorforth.css +33 -0
- data/node_modules/codemirror/theme/darcula.css +46 -0
- data/node_modules/codemirror/theme/dracula.css +40 -0
- data/node_modules/codemirror/theme/duotone-dark.css +35 -0
- data/node_modules/codemirror/theme/duotone-light.css +36 -0
- data/node_modules/codemirror/theme/eclipse.css +23 -0
- data/node_modules/codemirror/theme/elegant.css +13 -0
- data/node_modules/codemirror/theme/erlang-dark.css +34 -0
- data/node_modules/codemirror/theme/gruvbox-dark.css +37 -0
- data/node_modules/codemirror/theme/hopscotch.css +34 -0
- data/node_modules/codemirror/theme/icecoder.css +43 -0
- data/node_modules/codemirror/theme/idea.css +42 -0
- data/node_modules/codemirror/theme/isotope.css +34 -0
- data/node_modules/codemirror/theme/lesser-dark.css +47 -0
- data/node_modules/codemirror/theme/liquibyte.css +95 -0
- data/node_modules/codemirror/theme/lucario.css +37 -0
- data/node_modules/codemirror/theme/material.css +53 -0
- data/node_modules/codemirror/theme/mbo.css +37 -0
- data/node_modules/codemirror/theme/mdn-like.css +46 -0
- data/node_modules/codemirror/theme/midnight.css +43 -0
- data/node_modules/codemirror/theme/monokai.css +41 -0
- data/node_modules/codemirror/theme/neat.css +12 -0
- data/node_modules/codemirror/theme/neo.css +43 -0
- data/node_modules/codemirror/theme/night.css +27 -0
- data/node_modules/codemirror/theme/oceanic-next.css +44 -0
- data/node_modules/codemirror/theme/panda-syntax.css +85 -0
- data/node_modules/codemirror/theme/paraiso-dark.css +38 -0
- data/node_modules/codemirror/theme/paraiso-light.css +38 -0
- data/node_modules/codemirror/theme/pastel-on-dark.css +52 -0
- data/node_modules/codemirror/theme/railscasts.css +34 -0
- data/node_modules/codemirror/theme/rubyblue.css +25 -0
- data/node_modules/codemirror/theme/seti.css +44 -0
- data/node_modules/codemirror/theme/shadowfox.css +52 -0
- data/node_modules/codemirror/theme/solarized.css +168 -0
- data/node_modules/codemirror/theme/ssms.css +16 -0
- data/node_modules/codemirror/theme/the-matrix.css +30 -0
- data/node_modules/codemirror/theme/tomorrow-night-bright.css +35 -0
- data/node_modules/codemirror/theme/tomorrow-night-eighties.css +38 -0
- data/node_modules/codemirror/theme/ttcn.css +64 -0
- data/node_modules/codemirror/theme/twilight.css +32 -0
- data/node_modules/codemirror/theme/vibrant-ink.css +34 -0
- data/node_modules/codemirror/theme/xq-dark.css +53 -0
- data/node_modules/codemirror/theme/xq-light.css +43 -0
- data/node_modules/codemirror/theme/yeti.css +44 -0
- data/node_modules/codemirror/theme/zenburn.css +37 -0
- data/node_modules/marked/.editorconfig +16 -0
- data/node_modules/marked/.eslintignore +1 -0
- data/node_modules/marked/.eslintrc.json +28 -0
- data/node_modules/marked/.package 2.json.icloud +0 -0
- data/node_modules/marked/.travis.yml +47 -0
- data/node_modules/marked/Makefile +15 -0
- data/node_modules/marked/Makefile 2 +15 -0
- data/node_modules/marked/README 2.md +75 -0
- data/node_modules/marked/README.md +75 -0
- data/node_modules/marked/bin/marked +199 -0
- data/node_modules/marked/bower.json +23 -0
- data/node_modules/marked/component.json +10 -0
- data/node_modules/marked/index.js +1 -0
- data/node_modules/marked/jasmine.json +11 -0
- data/node_modules/marked/lib/marked 2.js +1604 -0
- data/node_modules/marked/lib/marked.js +1604 -0
- data/node_modules/marked/man/marked.1 +91 -0
- data/node_modules/marked/man/marked.1.txt +96 -0
- data/node_modules/marked/marked.min.js +6 -0
- data/node_modules/marked/package.json +95 -0
- data/node_modules/simplemde/.eslintrc +23 -0
- data/node_modules/simplemde/.npmignore +9 -0
- data/node_modules/simplemde/.travis.yml +18 -0
- data/node_modules/simplemde/CONTRIBUTING 2.md +10 -0
- data/node_modules/simplemde/CONTRIBUTING.md +10 -0
- data/node_modules/simplemde/LICENSE +22 -0
- data/node_modules/simplemde/README.md +331 -0
- data/node_modules/simplemde/bower.json +23 -0
- data/node_modules/simplemde/debug/.simplemde 2.css.icloud +0 -0
- data/node_modules/simplemde/debug/simplemde.css +676 -0
- data/node_modules/simplemde/debug/simplemde.debug.js +17023 -0
- data/node_modules/simplemde/debug/simplemde.js +17019 -0
- data/node_modules/simplemde/dist/simplemde.min.css +7 -0
- data/node_modules/simplemde/dist/simplemde.min.js +15 -0
- data/node_modules/simplemde/gulpfile.js +96 -0
- data/node_modules/simplemde/package.json +73 -0
- data/node_modules/simplemde/src/css/simplemde.css +328 -0
- data/node_modules/simplemde/src/js/codemirror/tablist 2.js +44 -0
- data/node_modules/simplemde/src/js/codemirror/tablist.js +44 -0
- data/node_modules/simplemde/src/js/simplemde.js +2028 -0
- data/node_modules/typo-js/README.md +45 -0
- data/node_modules/typo-js/dictionaries/en_US/.en_US 2.dic.icloud +0 -0
- data/node_modules/typo-js/dictionaries/en_US/README.md +7 -0
- data/node_modules/typo-js/dictionaries/en_US/en_US.aff +201 -0
- data/node_modules/typo-js/dictionaries/en_US/en_US.dic +62120 -0
- data/node_modules/typo-js/package.json +56 -0
- data/node_modules/typo-js/typo.js +931 -0
- data/package-lock.json +40 -0
- data/package.json +7 -0
- metadata +557 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
import { heightAtLine } from "../line/spans.js"
|
2
|
+
import { getLine, lineAtHeight, updateLineHeight } from "../line/utils_line.js"
|
3
|
+
import { paddingTop, textHeight } from "../measurement/position_measurement.js"
|
4
|
+
import { ie, ie_version } from "../util/browser.js"
|
5
|
+
|
6
|
+
// Read the actual heights of the rendered lines, and update their
|
7
|
+
// stored heights to match.
|
8
|
+
export function updateHeightsInViewport(cm) {
|
9
|
+
let display = cm.display
|
10
|
+
let prevBottom = display.lineDiv.offsetTop
|
11
|
+
for (let i = 0; i < display.view.length; i++) {
|
12
|
+
let cur = display.view[i], height
|
13
|
+
if (cur.hidden) continue
|
14
|
+
if (ie && ie_version < 8) {
|
15
|
+
let bot = cur.node.offsetTop + cur.node.offsetHeight
|
16
|
+
height = bot - prevBottom
|
17
|
+
prevBottom = bot
|
18
|
+
} else {
|
19
|
+
let box = cur.node.getBoundingClientRect()
|
20
|
+
height = box.bottom - box.top
|
21
|
+
}
|
22
|
+
let diff = cur.line.height - height
|
23
|
+
if (height < 2) height = textHeight(display)
|
24
|
+
if (diff > .005 || diff < -.005) {
|
25
|
+
updateLineHeight(cur.line, height)
|
26
|
+
updateWidgetHeight(cur.line)
|
27
|
+
if (cur.rest) for (let j = 0; j < cur.rest.length; j++)
|
28
|
+
updateWidgetHeight(cur.rest[j])
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
// Read and store the height of line widgets associated with the
|
34
|
+
// given line.
|
35
|
+
function updateWidgetHeight(line) {
|
36
|
+
if (line.widgets) for (let i = 0; i < line.widgets.length; ++i) {
|
37
|
+
let w = line.widgets[i], parent = w.node.parentNode
|
38
|
+
if (parent) w.height = parent.offsetHeight
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
// Compute the lines that are visible in a given viewport (defaults
|
43
|
+
// the the current scroll position). viewport may contain top,
|
44
|
+
// height, and ensure (see op.scrollToPos) properties.
|
45
|
+
export function visibleLines(display, doc, viewport) {
|
46
|
+
let top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop
|
47
|
+
top = Math.floor(top - paddingTop(display))
|
48
|
+
let bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight
|
49
|
+
|
50
|
+
let from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom)
|
51
|
+
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
|
52
|
+
// forces those lines into the viewport (if possible).
|
53
|
+
if (viewport && viewport.ensure) {
|
54
|
+
let ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line
|
55
|
+
if (ensureFrom < from) {
|
56
|
+
from = ensureFrom
|
57
|
+
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)
|
58
|
+
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
|
59
|
+
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight)
|
60
|
+
to = ensureTo
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return {from: from, to: Math.max(to, from + 1)}
|
64
|
+
}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import { buildViewArray } from "../line/line_data.js"
|
2
|
+
import { sawCollapsedSpans } from "../line/saw_special_spans.js"
|
3
|
+
import { visualLineEndNo, visualLineNo } from "../line/spans.js"
|
4
|
+
import { findViewIndex } from "../measurement/position_measurement.js"
|
5
|
+
import { indexOf } from "../util/misc.js"
|
6
|
+
|
7
|
+
// Updates the display.view data structure for a given change to the
|
8
|
+
// document. From and to are in pre-change coordinates. Lendiff is
|
9
|
+
// the amount of lines added or subtracted by the change. This is
|
10
|
+
// used for changes that span multiple lines, or change the way
|
11
|
+
// lines are divided into visual lines. regLineChange (below)
|
12
|
+
// registers single-line changes.
|
13
|
+
export function regChange(cm, from, to, lendiff) {
|
14
|
+
if (from == null) from = cm.doc.first
|
15
|
+
if (to == null) to = cm.doc.first + cm.doc.size
|
16
|
+
if (!lendiff) lendiff = 0
|
17
|
+
|
18
|
+
let display = cm.display
|
19
|
+
if (lendiff && to < display.viewTo &&
|
20
|
+
(display.updateLineNumbers == null || display.updateLineNumbers > from))
|
21
|
+
display.updateLineNumbers = from
|
22
|
+
|
23
|
+
cm.curOp.viewChanged = true
|
24
|
+
|
25
|
+
if (from >= display.viewTo) { // Change after
|
26
|
+
if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
|
27
|
+
resetView(cm)
|
28
|
+
} else if (to <= display.viewFrom) { // Change before
|
29
|
+
if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
|
30
|
+
resetView(cm)
|
31
|
+
} else {
|
32
|
+
display.viewFrom += lendiff
|
33
|
+
display.viewTo += lendiff
|
34
|
+
}
|
35
|
+
} else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
|
36
|
+
resetView(cm)
|
37
|
+
} else if (from <= display.viewFrom) { // Top overlap
|
38
|
+
let cut = viewCuttingPoint(cm, to, to + lendiff, 1)
|
39
|
+
if (cut) {
|
40
|
+
display.view = display.view.slice(cut.index)
|
41
|
+
display.viewFrom = cut.lineN
|
42
|
+
display.viewTo += lendiff
|
43
|
+
} else {
|
44
|
+
resetView(cm)
|
45
|
+
}
|
46
|
+
} else if (to >= display.viewTo) { // Bottom overlap
|
47
|
+
let cut = viewCuttingPoint(cm, from, from, -1)
|
48
|
+
if (cut) {
|
49
|
+
display.view = display.view.slice(0, cut.index)
|
50
|
+
display.viewTo = cut.lineN
|
51
|
+
} else {
|
52
|
+
resetView(cm)
|
53
|
+
}
|
54
|
+
} else { // Gap in the middle
|
55
|
+
let cutTop = viewCuttingPoint(cm, from, from, -1)
|
56
|
+
let cutBot = viewCuttingPoint(cm, to, to + lendiff, 1)
|
57
|
+
if (cutTop && cutBot) {
|
58
|
+
display.view = display.view.slice(0, cutTop.index)
|
59
|
+
.concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
|
60
|
+
.concat(display.view.slice(cutBot.index))
|
61
|
+
display.viewTo += lendiff
|
62
|
+
} else {
|
63
|
+
resetView(cm)
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
let ext = display.externalMeasured
|
68
|
+
if (ext) {
|
69
|
+
if (to < ext.lineN)
|
70
|
+
ext.lineN += lendiff
|
71
|
+
else if (from < ext.lineN + ext.size)
|
72
|
+
display.externalMeasured = null
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
// Register a change to a single line. Type must be one of "text",
|
77
|
+
// "gutter", "class", "widget"
|
78
|
+
export function regLineChange(cm, line, type) {
|
79
|
+
cm.curOp.viewChanged = true
|
80
|
+
let display = cm.display, ext = cm.display.externalMeasured
|
81
|
+
if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
|
82
|
+
display.externalMeasured = null
|
83
|
+
|
84
|
+
if (line < display.viewFrom || line >= display.viewTo) return
|
85
|
+
let lineView = display.view[findViewIndex(cm, line)]
|
86
|
+
if (lineView.node == null) return
|
87
|
+
let arr = lineView.changes || (lineView.changes = [])
|
88
|
+
if (indexOf(arr, type) == -1) arr.push(type)
|
89
|
+
}
|
90
|
+
|
91
|
+
// Clear the view.
|
92
|
+
export function resetView(cm) {
|
93
|
+
cm.display.viewFrom = cm.display.viewTo = cm.doc.first
|
94
|
+
cm.display.view = []
|
95
|
+
cm.display.viewOffset = 0
|
96
|
+
}
|
97
|
+
|
98
|
+
function viewCuttingPoint(cm, oldN, newN, dir) {
|
99
|
+
let index = findViewIndex(cm, oldN), diff, view = cm.display.view
|
100
|
+
if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
|
101
|
+
return {index: index, lineN: newN}
|
102
|
+
let n = cm.display.viewFrom
|
103
|
+
for (let i = 0; i < index; i++)
|
104
|
+
n += view[i].size
|
105
|
+
if (n != oldN) {
|
106
|
+
if (dir > 0) {
|
107
|
+
if (index == view.length - 1) return null
|
108
|
+
diff = (n + view[index].size) - oldN
|
109
|
+
index++
|
110
|
+
} else {
|
111
|
+
diff = n - oldN
|
112
|
+
}
|
113
|
+
oldN += diff; newN += diff
|
114
|
+
}
|
115
|
+
while (visualLineNo(cm.doc, newN) != newN) {
|
116
|
+
if (index == (dir < 0 ? 0 : view.length - 1)) return null
|
117
|
+
newN += dir * view[index - (dir < 0 ? 1 : 0)].size
|
118
|
+
index += dir
|
119
|
+
}
|
120
|
+
return {index: index, lineN: newN}
|
121
|
+
}
|
122
|
+
|
123
|
+
// Force the view to cover a given range, adding empty view element
|
124
|
+
// or clipping off existing ones as needed.
|
125
|
+
export function adjustView(cm, from, to) {
|
126
|
+
let display = cm.display, view = display.view
|
127
|
+
if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
|
128
|
+
display.view = buildViewArray(cm, from, to)
|
129
|
+
display.viewFrom = from
|
130
|
+
} else {
|
131
|
+
if (display.viewFrom > from)
|
132
|
+
display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view)
|
133
|
+
else if (display.viewFrom < from)
|
134
|
+
display.view = display.view.slice(findViewIndex(cm, from))
|
135
|
+
display.viewFrom = from
|
136
|
+
if (display.viewTo < to)
|
137
|
+
display.view = display.view.concat(buildViewArray(cm, display.viewTo, to))
|
138
|
+
else if (display.viewTo > to)
|
139
|
+
display.view = display.view.slice(0, findViewIndex(cm, to))
|
140
|
+
}
|
141
|
+
display.viewTo = to
|
142
|
+
}
|
143
|
+
|
144
|
+
// Count the number of lines in the view whose DOM representation is
|
145
|
+
// out of date (or nonexistent).
|
146
|
+
export function countDirtyView(cm) {
|
147
|
+
let view = cm.display.view, dirty = 0
|
148
|
+
for (let i = 0; i < view.length; i++) {
|
149
|
+
let lineView = view[i]
|
150
|
+
if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty
|
151
|
+
}
|
152
|
+
return dirty
|
153
|
+
}
|
@@ -0,0 +1,215 @@
|
|
1
|
+
import { Display } from "../display/Display.js"
|
2
|
+
import { onFocus, onBlur } from "../display/focus.js"
|
3
|
+
import { setGuttersForLineNumbers, updateGutters } from "../display/gutters.js"
|
4
|
+
import { maybeUpdateLineNumberWidth } from "../display/line_numbers.js"
|
5
|
+
import { endOperation, operation, startOperation } from "../display/operations.js"
|
6
|
+
import { initScrollbars } from "../display/scrollbars.js"
|
7
|
+
import { onScrollWheel } from "../display/scroll_events.js"
|
8
|
+
import { setScrollLeft, updateScrollTop } from "../display/scrolling.js"
|
9
|
+
import { clipPos, Pos } from "../line/pos.js"
|
10
|
+
import { posFromMouse } from "../measurement/position_measurement.js"
|
11
|
+
import { eventInWidget } from "../measurement/widgets.js"
|
12
|
+
import Doc from "../model/Doc.js"
|
13
|
+
import { attachDoc } from "../model/document_data.js"
|
14
|
+
import { Range } from "../model/selection.js"
|
15
|
+
import { extendSelection } from "../model/selection_updates.js"
|
16
|
+
import { ie, ie_version, mobile, webkit } from "../util/browser.js"
|
17
|
+
import { e_preventDefault, e_stop, on, signal, signalDOMEvent } from "../util/event.js"
|
18
|
+
import { bind, copyObj, Delayed } from "../util/misc.js"
|
19
|
+
|
20
|
+
import { clearDragCursor, onDragOver, onDragStart, onDrop } from "./drop_events.js"
|
21
|
+
import { ensureGlobalHandlers } from "./global_events.js"
|
22
|
+
import { onKeyDown, onKeyPress, onKeyUp } from "./key_events.js"
|
23
|
+
import { clickInGutter, onContextMenu, onMouseDown } from "./mouse_events.js"
|
24
|
+
import { themeChanged } from "./utils.js"
|
25
|
+
import { defaults, optionHandlers, Init } from "./options.js"
|
26
|
+
|
27
|
+
// A CodeMirror instance represents an editor. This is the object
|
28
|
+
// that user code is usually dealing with.
|
29
|
+
|
30
|
+
export function CodeMirror(place, options) {
|
31
|
+
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options)
|
32
|
+
|
33
|
+
this.options = options = options ? copyObj(options) : {}
|
34
|
+
// Determine effective options based on given values and defaults.
|
35
|
+
copyObj(defaults, options, false)
|
36
|
+
setGuttersForLineNumbers(options)
|
37
|
+
|
38
|
+
let doc = options.value
|
39
|
+
if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction)
|
40
|
+
else if (options.mode) doc.modeOption = options.mode
|
41
|
+
this.doc = doc
|
42
|
+
|
43
|
+
let input = new CodeMirror.inputStyles[options.inputStyle](this)
|
44
|
+
let display = this.display = new Display(place, doc, input)
|
45
|
+
display.wrapper.CodeMirror = this
|
46
|
+
updateGutters(this)
|
47
|
+
themeChanged(this)
|
48
|
+
if (options.lineWrapping)
|
49
|
+
this.display.wrapper.className += " CodeMirror-wrap"
|
50
|
+
initScrollbars(this)
|
51
|
+
|
52
|
+
this.state = {
|
53
|
+
keyMaps: [], // stores maps added by addKeyMap
|
54
|
+
overlays: [], // highlighting overlays, as added by addOverlay
|
55
|
+
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
|
56
|
+
overwrite: false,
|
57
|
+
delayingBlurEvent: false,
|
58
|
+
focused: false,
|
59
|
+
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
|
60
|
+
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
|
61
|
+
selectingText: false,
|
62
|
+
draggingText: false,
|
63
|
+
highlight: new Delayed(), // stores highlight worker timeout
|
64
|
+
keySeq: null, // Unfinished key sequence
|
65
|
+
specialChars: null
|
66
|
+
}
|
67
|
+
|
68
|
+
if (options.autofocus && !mobile) display.input.focus()
|
69
|
+
|
70
|
+
// Override magic textarea content restore that IE sometimes does
|
71
|
+
// on our hidden textarea on reload
|
72
|
+
if (ie && ie_version < 11) setTimeout(() => this.display.input.reset(true), 20)
|
73
|
+
|
74
|
+
registerEventHandlers(this)
|
75
|
+
ensureGlobalHandlers()
|
76
|
+
|
77
|
+
startOperation(this)
|
78
|
+
this.curOp.forceUpdate = true
|
79
|
+
attachDoc(this, doc)
|
80
|
+
|
81
|
+
if ((options.autofocus && !mobile) || this.hasFocus())
|
82
|
+
setTimeout(bind(onFocus, this), 20)
|
83
|
+
else
|
84
|
+
onBlur(this)
|
85
|
+
|
86
|
+
for (let opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
|
87
|
+
optionHandlers[opt](this, options[opt], Init)
|
88
|
+
maybeUpdateLineNumberWidth(this)
|
89
|
+
if (options.finishInit) options.finishInit(this)
|
90
|
+
for (let i = 0; i < initHooks.length; ++i) initHooks[i](this)
|
91
|
+
endOperation(this)
|
92
|
+
// Suppress optimizelegibility in Webkit, since it breaks text
|
93
|
+
// measuring on line wrapping boundaries.
|
94
|
+
if (webkit && options.lineWrapping &&
|
95
|
+
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
|
96
|
+
display.lineDiv.style.textRendering = "auto"
|
97
|
+
}
|
98
|
+
|
99
|
+
// The default configuration options.
|
100
|
+
CodeMirror.defaults = defaults
|
101
|
+
// Functions to run when options are changed.
|
102
|
+
CodeMirror.optionHandlers = optionHandlers
|
103
|
+
|
104
|
+
export default CodeMirror
|
105
|
+
|
106
|
+
// Attach the necessary event handlers when initializing the editor
|
107
|
+
function registerEventHandlers(cm) {
|
108
|
+
let d = cm.display
|
109
|
+
on(d.scroller, "mousedown", operation(cm, onMouseDown))
|
110
|
+
// Older IE's will not fire a second mousedown for a double click
|
111
|
+
if (ie && ie_version < 11)
|
112
|
+
on(d.scroller, "dblclick", operation(cm, e => {
|
113
|
+
if (signalDOMEvent(cm, e)) return
|
114
|
+
let pos = posFromMouse(cm, e)
|
115
|
+
if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return
|
116
|
+
e_preventDefault(e)
|
117
|
+
let word = cm.findWordAt(pos)
|
118
|
+
extendSelection(cm.doc, word.anchor, word.head)
|
119
|
+
}))
|
120
|
+
else
|
121
|
+
on(d.scroller, "dblclick", e => signalDOMEvent(cm, e) || e_preventDefault(e))
|
122
|
+
// Some browsers fire contextmenu *after* opening the menu, at
|
123
|
+
// which point we can't mess with it anymore. Context menu is
|
124
|
+
// handled in onMouseDown for these browsers.
|
125
|
+
on(d.scroller, "contextmenu", e => onContextMenu(cm, e))
|
126
|
+
|
127
|
+
// Used to suppress mouse event handling when a touch happens
|
128
|
+
let touchFinished, prevTouch = {end: 0}
|
129
|
+
function finishTouch() {
|
130
|
+
if (d.activeTouch) {
|
131
|
+
touchFinished = setTimeout(() => d.activeTouch = null, 1000)
|
132
|
+
prevTouch = d.activeTouch
|
133
|
+
prevTouch.end = +new Date
|
134
|
+
}
|
135
|
+
}
|
136
|
+
function isMouseLikeTouchEvent(e) {
|
137
|
+
if (e.touches.length != 1) return false
|
138
|
+
let touch = e.touches[0]
|
139
|
+
return touch.radiusX <= 1 && touch.radiusY <= 1
|
140
|
+
}
|
141
|
+
function farAway(touch, other) {
|
142
|
+
if (other.left == null) return true
|
143
|
+
let dx = other.left - touch.left, dy = other.top - touch.top
|
144
|
+
return dx * dx + dy * dy > 20 * 20
|
145
|
+
}
|
146
|
+
on(d.scroller, "touchstart", e => {
|
147
|
+
if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
|
148
|
+
d.input.ensurePolled()
|
149
|
+
clearTimeout(touchFinished)
|
150
|
+
let now = +new Date
|
151
|
+
d.activeTouch = {start: now, moved: false,
|
152
|
+
prev: now - prevTouch.end <= 300 ? prevTouch : null}
|
153
|
+
if (e.touches.length == 1) {
|
154
|
+
d.activeTouch.left = e.touches[0].pageX
|
155
|
+
d.activeTouch.top = e.touches[0].pageY
|
156
|
+
}
|
157
|
+
}
|
158
|
+
})
|
159
|
+
on(d.scroller, "touchmove", () => {
|
160
|
+
if (d.activeTouch) d.activeTouch.moved = true
|
161
|
+
})
|
162
|
+
on(d.scroller, "touchend", e => {
|
163
|
+
let touch = d.activeTouch
|
164
|
+
if (touch && !eventInWidget(d, e) && touch.left != null &&
|
165
|
+
!touch.moved && new Date - touch.start < 300) {
|
166
|
+
let pos = cm.coordsChar(d.activeTouch, "page"), range
|
167
|
+
if (!touch.prev || farAway(touch, touch.prev)) // Single tap
|
168
|
+
range = new Range(pos, pos)
|
169
|
+
else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
|
170
|
+
range = cm.findWordAt(pos)
|
171
|
+
else // Triple tap
|
172
|
+
range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)))
|
173
|
+
cm.setSelection(range.anchor, range.head)
|
174
|
+
cm.focus()
|
175
|
+
e_preventDefault(e)
|
176
|
+
}
|
177
|
+
finishTouch()
|
178
|
+
})
|
179
|
+
on(d.scroller, "touchcancel", finishTouch)
|
180
|
+
|
181
|
+
// Sync scrolling between fake scrollbars and real scrollable
|
182
|
+
// area, ensure viewport is updated when scrolling.
|
183
|
+
on(d.scroller, "scroll", () => {
|
184
|
+
if (d.scroller.clientHeight) {
|
185
|
+
updateScrollTop(cm, d.scroller.scrollTop)
|
186
|
+
setScrollLeft(cm, d.scroller.scrollLeft, true)
|
187
|
+
signal(cm, "scroll", cm)
|
188
|
+
}
|
189
|
+
})
|
190
|
+
|
191
|
+
// Listen to wheel events in order to try and update the viewport on time.
|
192
|
+
on(d.scroller, "mousewheel", e => onScrollWheel(cm, e))
|
193
|
+
on(d.scroller, "DOMMouseScroll", e => onScrollWheel(cm, e))
|
194
|
+
|
195
|
+
// Prevent wrapper from ever scrolling
|
196
|
+
on(d.wrapper, "scroll", () => d.wrapper.scrollTop = d.wrapper.scrollLeft = 0)
|
197
|
+
|
198
|
+
d.dragFunctions = {
|
199
|
+
enter: e => {if (!signalDOMEvent(cm, e)) e_stop(e)},
|
200
|
+
over: e => {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e) }},
|
201
|
+
start: e => onDragStart(cm, e),
|
202
|
+
drop: operation(cm, onDrop),
|
203
|
+
leave: e => {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm) }}
|
204
|
+
}
|
205
|
+
|
206
|
+
let inp = d.input.getField()
|
207
|
+
on(inp, "keyup", e => onKeyUp.call(cm, e))
|
208
|
+
on(inp, "keydown", operation(cm, onKeyDown))
|
209
|
+
on(inp, "keypress", operation(cm, onKeyPress))
|
210
|
+
on(inp, "focus", e => onFocus(cm, e))
|
211
|
+
on(inp, "blur", e => onBlur(cm, e))
|
212
|
+
}
|
213
|
+
|
214
|
+
let initHooks = []
|
215
|
+
CodeMirror.defineInitHook = f => initHooks.push(f)
|
@@ -0,0 +1,178 @@
|
|
1
|
+
import { deleteNearSelection } from "./deleteNearSelection.js"
|
2
|
+
import { runInOp } from "../display/operations.js"
|
3
|
+
import { ensureCursorVisible } from "../display/scrolling.js"
|
4
|
+
import { endOfLine } from "../input/movement.js"
|
5
|
+
import { clipPos, Pos } from "../line/pos.js"
|
6
|
+
import { visualLine, visualLineEnd } from "../line/spans.js"
|
7
|
+
import { getLine, lineNo } from "../line/utils_line.js"
|
8
|
+
import { Range } from "../model/selection.js"
|
9
|
+
import { selectAll } from "../model/selection_updates.js"
|
10
|
+
import { countColumn, sel_dontScroll, sel_move, spaceStr } from "../util/misc.js"
|
11
|
+
import { getOrder } from "../util/bidi.js"
|
12
|
+
|
13
|
+
// Commands are parameter-less actions that can be performed on an
|
14
|
+
// editor, mostly used for keybindings.
|
15
|
+
export let commands = {
|
16
|
+
selectAll: selectAll,
|
17
|
+
singleSelection: cm => cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll),
|
18
|
+
killLine: cm => deleteNearSelection(cm, range => {
|
19
|
+
if (range.empty()) {
|
20
|
+
let len = getLine(cm.doc, range.head.line).text.length
|
21
|
+
if (range.head.ch == len && range.head.line < cm.lastLine())
|
22
|
+
return {from: range.head, to: Pos(range.head.line + 1, 0)}
|
23
|
+
else
|
24
|
+
return {from: range.head, to: Pos(range.head.line, len)}
|
25
|
+
} else {
|
26
|
+
return {from: range.from(), to: range.to()}
|
27
|
+
}
|
28
|
+
}),
|
29
|
+
deleteLine: cm => deleteNearSelection(cm, range => ({
|
30
|
+
from: Pos(range.from().line, 0),
|
31
|
+
to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
|
32
|
+
})),
|
33
|
+
delLineLeft: cm => deleteNearSelection(cm, range => ({
|
34
|
+
from: Pos(range.from().line, 0), to: range.from()
|
35
|
+
})),
|
36
|
+
delWrappedLineLeft: cm => deleteNearSelection(cm, range => {
|
37
|
+
let top = cm.charCoords(range.head, "div").top + 5
|
38
|
+
let leftPos = cm.coordsChar({left: 0, top: top}, "div")
|
39
|
+
return {from: leftPos, to: range.from()}
|
40
|
+
}),
|
41
|
+
delWrappedLineRight: cm => deleteNearSelection(cm, range => {
|
42
|
+
let top = cm.charCoords(range.head, "div").top + 5
|
43
|
+
let rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
|
44
|
+
return {from: range.from(), to: rightPos }
|
45
|
+
}),
|
46
|
+
undo: cm => cm.undo(),
|
47
|
+
redo: cm => cm.redo(),
|
48
|
+
undoSelection: cm => cm.undoSelection(),
|
49
|
+
redoSelection: cm => cm.redoSelection(),
|
50
|
+
goDocStart: cm => cm.extendSelection(Pos(cm.firstLine(), 0)),
|
51
|
+
goDocEnd: cm => cm.extendSelection(Pos(cm.lastLine())),
|
52
|
+
goLineStart: cm => cm.extendSelectionsBy(range => lineStart(cm, range.head.line),
|
53
|
+
{origin: "+move", bias: 1}
|
54
|
+
),
|
55
|
+
goLineStartSmart: cm => cm.extendSelectionsBy(range => lineStartSmart(cm, range.head),
|
56
|
+
{origin: "+move", bias: 1}
|
57
|
+
),
|
58
|
+
goLineEnd: cm => cm.extendSelectionsBy(range => lineEnd(cm, range.head.line),
|
59
|
+
{origin: "+move", bias: -1}
|
60
|
+
),
|
61
|
+
goLineRight: cm => cm.extendSelectionsBy(range => {
|
62
|
+
let top = cm.cursorCoords(range.head, "div").top + 5
|
63
|
+
return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
|
64
|
+
}, sel_move),
|
65
|
+
goLineLeft: cm => cm.extendSelectionsBy(range => {
|
66
|
+
let top = cm.cursorCoords(range.head, "div").top + 5
|
67
|
+
return cm.coordsChar({left: 0, top: top}, "div")
|
68
|
+
}, sel_move),
|
69
|
+
goLineLeftSmart: cm => cm.extendSelectionsBy(range => {
|
70
|
+
let top = cm.cursorCoords(range.head, "div").top + 5
|
71
|
+
let pos = cm.coordsChar({left: 0, top: top}, "div")
|
72
|
+
if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head)
|
73
|
+
return pos
|
74
|
+
}, sel_move),
|
75
|
+
goLineUp: cm => cm.moveV(-1, "line"),
|
76
|
+
goLineDown: cm => cm.moveV(1, "line"),
|
77
|
+
goPageUp: cm => cm.moveV(-1, "page"),
|
78
|
+
goPageDown: cm => cm.moveV(1, "page"),
|
79
|
+
goCharLeft: cm => cm.moveH(-1, "char"),
|
80
|
+
goCharRight: cm => cm.moveH(1, "char"),
|
81
|
+
goColumnLeft: cm => cm.moveH(-1, "column"),
|
82
|
+
goColumnRight: cm => cm.moveH(1, "column"),
|
83
|
+
goWordLeft: cm => cm.moveH(-1, "word"),
|
84
|
+
goGroupRight: cm => cm.moveH(1, "group"),
|
85
|
+
goGroupLeft: cm => cm.moveH(-1, "group"),
|
86
|
+
goWordRight: cm => cm.moveH(1, "word"),
|
87
|
+
delCharBefore: cm => cm.deleteH(-1, "char"),
|
88
|
+
delCharAfter: cm => cm.deleteH(1, "char"),
|
89
|
+
delWordBefore: cm => cm.deleteH(-1, "word"),
|
90
|
+
delWordAfter: cm => cm.deleteH(1, "word"),
|
91
|
+
delGroupBefore: cm => cm.deleteH(-1, "group"),
|
92
|
+
delGroupAfter: cm => cm.deleteH(1, "group"),
|
93
|
+
indentAuto: cm => cm.indentSelection("smart"),
|
94
|
+
indentMore: cm => cm.indentSelection("add"),
|
95
|
+
indentLess: cm => cm.indentSelection("subtract"),
|
96
|
+
insertTab: cm => cm.replaceSelection("\t"),
|
97
|
+
insertSoftTab: cm => {
|
98
|
+
let spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize
|
99
|
+
for (let i = 0; i < ranges.length; i++) {
|
100
|
+
let pos = ranges[i].from()
|
101
|
+
let col = countColumn(cm.getLine(pos.line), pos.ch, tabSize)
|
102
|
+
spaces.push(spaceStr(tabSize - col % tabSize))
|
103
|
+
}
|
104
|
+
cm.replaceSelections(spaces)
|
105
|
+
},
|
106
|
+
defaultTab: cm => {
|
107
|
+
if (cm.somethingSelected()) cm.indentSelection("add")
|
108
|
+
else cm.execCommand("insertTab")
|
109
|
+
},
|
110
|
+
// Swap the two chars left and right of each selection's head.
|
111
|
+
// Move cursor behind the two swapped characters afterwards.
|
112
|
+
//
|
113
|
+
// Doesn't consider line feeds a character.
|
114
|
+
// Doesn't scan more than one line above to find a character.
|
115
|
+
// Doesn't do anything on an empty line.
|
116
|
+
// Doesn't do anything with non-empty selections.
|
117
|
+
transposeChars: cm => runInOp(cm, () => {
|
118
|
+
let ranges = cm.listSelections(), newSel = []
|
119
|
+
for (let i = 0; i < ranges.length; i++) {
|
120
|
+
if (!ranges[i].empty()) continue
|
121
|
+
let cur = ranges[i].head, line = getLine(cm.doc, cur.line).text
|
122
|
+
if (line) {
|
123
|
+
if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1)
|
124
|
+
if (cur.ch > 0) {
|
125
|
+
cur = new Pos(cur.line, cur.ch + 1)
|
126
|
+
cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
|
127
|
+
Pos(cur.line, cur.ch - 2), cur, "+transpose")
|
128
|
+
} else if (cur.line > cm.doc.first) {
|
129
|
+
let prev = getLine(cm.doc, cur.line - 1).text
|
130
|
+
if (prev) {
|
131
|
+
cur = new Pos(cur.line, 1)
|
132
|
+
cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
|
133
|
+
prev.charAt(prev.length - 1),
|
134
|
+
Pos(cur.line - 1, prev.length - 1), cur, "+transpose")
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
newSel.push(new Range(cur, cur))
|
139
|
+
}
|
140
|
+
cm.setSelections(newSel)
|
141
|
+
}),
|
142
|
+
newlineAndIndent: cm => runInOp(cm, () => {
|
143
|
+
let sels = cm.listSelections()
|
144
|
+
for (let i = sels.length - 1; i >= 0; i--)
|
145
|
+
cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input")
|
146
|
+
sels = cm.listSelections()
|
147
|
+
for (let i = 0; i < sels.length; i++)
|
148
|
+
cm.indentLine(sels[i].from().line, null, true)
|
149
|
+
ensureCursorVisible(cm)
|
150
|
+
}),
|
151
|
+
openLine: cm => cm.replaceSelection("\n", "start"),
|
152
|
+
toggleOverwrite: cm => cm.toggleOverwrite()
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
function lineStart(cm, lineN) {
|
157
|
+
let line = getLine(cm.doc, lineN)
|
158
|
+
let visual = visualLine(line)
|
159
|
+
if (visual != line) lineN = lineNo(visual)
|
160
|
+
return endOfLine(true, cm, visual, lineN, 1)
|
161
|
+
}
|
162
|
+
function lineEnd(cm, lineN) {
|
163
|
+
let line = getLine(cm.doc, lineN)
|
164
|
+
let visual = visualLineEnd(line)
|
165
|
+
if (visual != line) lineN = lineNo(visual)
|
166
|
+
return endOfLine(true, cm, line, lineN, -1)
|
167
|
+
}
|
168
|
+
function lineStartSmart(cm, pos) {
|
169
|
+
let start = lineStart(cm, pos.line)
|
170
|
+
let line = getLine(cm.doc, start.line)
|
171
|
+
let order = getOrder(line, cm.doc.direction)
|
172
|
+
if (!order || order[0].level == 0) {
|
173
|
+
let firstNonWS = Math.max(0, line.text.search(/\S/))
|
174
|
+
let inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
|
175
|
+
return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
|
176
|
+
}
|
177
|
+
return start
|
178
|
+
}
|