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,339 @@
|
|
1
|
+
import { getOrder } from "../util/bidi.js"
|
2
|
+
import { ie, ie_version, webkit } from "../util/browser.js"
|
3
|
+
import { elt, eltP, joinClasses } from "../util/dom.js"
|
4
|
+
import { eventMixin, signal } from "../util/event.js"
|
5
|
+
import { hasBadBidiRects, zeroWidthElement } from "../util/feature_detection.js"
|
6
|
+
import { lst, spaceStr } from "../util/misc.js"
|
7
|
+
|
8
|
+
import { getLineStyles } from "./highlight.js"
|
9
|
+
import { attachMarkedSpans, compareCollapsedMarkers, detachMarkedSpans, lineIsHidden, visualLineContinued } from "./spans.js"
|
10
|
+
import { getLine, lineNo, updateLineHeight } from "./utils_line.js"
|
11
|
+
|
12
|
+
// LINE DATA STRUCTURE
|
13
|
+
|
14
|
+
// Line objects. These hold state related to a line, including
|
15
|
+
// highlighting info (the styles array).
|
16
|
+
export class Line {
|
17
|
+
constructor(text, markedSpans, estimateHeight) {
|
18
|
+
this.text = text
|
19
|
+
attachMarkedSpans(this, markedSpans)
|
20
|
+
this.height = estimateHeight ? estimateHeight(this) : 1
|
21
|
+
}
|
22
|
+
|
23
|
+
lineNo() { return lineNo(this) }
|
24
|
+
}
|
25
|
+
eventMixin(Line)
|
26
|
+
|
27
|
+
// Change the content (text, markers) of a line. Automatically
|
28
|
+
// invalidates cached information and tries to re-estimate the
|
29
|
+
// line's height.
|
30
|
+
export function updateLine(line, text, markedSpans, estimateHeight) {
|
31
|
+
line.text = text
|
32
|
+
if (line.stateAfter) line.stateAfter = null
|
33
|
+
if (line.styles) line.styles = null
|
34
|
+
if (line.order != null) line.order = null
|
35
|
+
detachMarkedSpans(line)
|
36
|
+
attachMarkedSpans(line, markedSpans)
|
37
|
+
let estHeight = estimateHeight ? estimateHeight(line) : 1
|
38
|
+
if (estHeight != line.height) updateLineHeight(line, estHeight)
|
39
|
+
}
|
40
|
+
|
41
|
+
// Detach a line from the document tree and its markers.
|
42
|
+
export function cleanUpLine(line) {
|
43
|
+
line.parent = null
|
44
|
+
detachMarkedSpans(line)
|
45
|
+
}
|
46
|
+
|
47
|
+
// Convert a style as returned by a mode (either null, or a string
|
48
|
+
// containing one or more styles) to a CSS style. This is cached,
|
49
|
+
// and also looks for line-wide styles.
|
50
|
+
let styleToClassCache = {}, styleToClassCacheWithMode = {}
|
51
|
+
function interpretTokenStyle(style, options) {
|
52
|
+
if (!style || /^\s*$/.test(style)) return null
|
53
|
+
let cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache
|
54
|
+
return cache[style] ||
|
55
|
+
(cache[style] = style.replace(/\S+/g, "cm-$&"))
|
56
|
+
}
|
57
|
+
|
58
|
+
// Render the DOM representation of the text of a line. Also builds
|
59
|
+
// up a 'line map', which points at the DOM nodes that represent
|
60
|
+
// specific stretches of text, and is used by the measuring code.
|
61
|
+
// The returned object contains the DOM node, this map, and
|
62
|
+
// information about line-wide styles that were set by the mode.
|
63
|
+
export function buildLineContent(cm, lineView) {
|
64
|
+
// The padding-right forces the element to have a 'border', which
|
65
|
+
// is needed on Webkit to be able to get line-level bounding
|
66
|
+
// rectangles for it (in measureChar).
|
67
|
+
let content = eltP("span", null, null, webkit ? "padding-right: .1px" : null)
|
68
|
+
let builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
|
69
|
+
col: 0, pos: 0, cm: cm,
|
70
|
+
trailingSpace: false,
|
71
|
+
splitSpaces: cm.getOption("lineWrapping")}
|
72
|
+
lineView.measure = {}
|
73
|
+
|
74
|
+
// Iterate over the logical lines that make up this visual line.
|
75
|
+
for (let i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
|
76
|
+
let line = i ? lineView.rest[i - 1] : lineView.line, order
|
77
|
+
builder.pos = 0
|
78
|
+
builder.addToken = buildToken
|
79
|
+
// Optionally wire in some hacks into the token-rendering
|
80
|
+
// algorithm, to deal with browser quirks.
|
81
|
+
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
|
82
|
+
builder.addToken = buildTokenBadBidi(builder.addToken, order)
|
83
|
+
builder.map = []
|
84
|
+
let allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line)
|
85
|
+
insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate))
|
86
|
+
if (line.styleClasses) {
|
87
|
+
if (line.styleClasses.bgClass)
|
88
|
+
builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "")
|
89
|
+
if (line.styleClasses.textClass)
|
90
|
+
builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "")
|
91
|
+
}
|
92
|
+
|
93
|
+
// Ensure at least a single node is present, for measuring.
|
94
|
+
if (builder.map.length == 0)
|
95
|
+
builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)))
|
96
|
+
|
97
|
+
// Store the map and a cache object for the current logical line
|
98
|
+
if (i == 0) {
|
99
|
+
lineView.measure.map = builder.map
|
100
|
+
lineView.measure.cache = {}
|
101
|
+
} else {
|
102
|
+
;(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
|
103
|
+
;(lineView.measure.caches || (lineView.measure.caches = [])).push({})
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
// See issue #2901
|
108
|
+
if (webkit) {
|
109
|
+
let last = builder.content.lastChild
|
110
|
+
if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
|
111
|
+
builder.content.className = "cm-tab-wrap-hack"
|
112
|
+
}
|
113
|
+
|
114
|
+
signal(cm, "renderLine", cm, lineView.line, builder.pre)
|
115
|
+
if (builder.pre.className)
|
116
|
+
builder.textClass = joinClasses(builder.pre.className, builder.textClass || "")
|
117
|
+
|
118
|
+
return builder
|
119
|
+
}
|
120
|
+
|
121
|
+
export function defaultSpecialCharPlaceholder(ch) {
|
122
|
+
let token = elt("span", "\u2022", "cm-invalidchar")
|
123
|
+
token.title = "\\u" + ch.charCodeAt(0).toString(16)
|
124
|
+
token.setAttribute("aria-label", token.title)
|
125
|
+
return token
|
126
|
+
}
|
127
|
+
|
128
|
+
// Build up the DOM representation for a single token, and add it to
|
129
|
+
// the line map. Takes care to render special characters separately.
|
130
|
+
function buildToken(builder, text, style, startStyle, endStyle, title, css) {
|
131
|
+
if (!text) return
|
132
|
+
let displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
|
133
|
+
let special = builder.cm.state.specialChars, mustWrap = false
|
134
|
+
let content
|
135
|
+
if (!special.test(text)) {
|
136
|
+
builder.col += text.length
|
137
|
+
content = document.createTextNode(displayText)
|
138
|
+
builder.map.push(builder.pos, builder.pos + text.length, content)
|
139
|
+
if (ie && ie_version < 9) mustWrap = true
|
140
|
+
builder.pos += text.length
|
141
|
+
} else {
|
142
|
+
content = document.createDocumentFragment()
|
143
|
+
let pos = 0
|
144
|
+
while (true) {
|
145
|
+
special.lastIndex = pos
|
146
|
+
let m = special.exec(text)
|
147
|
+
let skipped = m ? m.index - pos : text.length - pos
|
148
|
+
if (skipped) {
|
149
|
+
let txt = document.createTextNode(displayText.slice(pos, pos + skipped))
|
150
|
+
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]))
|
151
|
+
else content.appendChild(txt)
|
152
|
+
builder.map.push(builder.pos, builder.pos + skipped, txt)
|
153
|
+
builder.col += skipped
|
154
|
+
builder.pos += skipped
|
155
|
+
}
|
156
|
+
if (!m) break
|
157
|
+
pos += skipped + 1
|
158
|
+
let txt
|
159
|
+
if (m[0] == "\t") {
|
160
|
+
let tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize
|
161
|
+
txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))
|
162
|
+
txt.setAttribute("role", "presentation")
|
163
|
+
txt.setAttribute("cm-text", "\t")
|
164
|
+
builder.col += tabWidth
|
165
|
+
} else if (m[0] == "\r" || m[0] == "\n") {
|
166
|
+
txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"))
|
167
|
+
txt.setAttribute("cm-text", m[0])
|
168
|
+
builder.col += 1
|
169
|
+
} else {
|
170
|
+
txt = builder.cm.options.specialCharPlaceholder(m[0])
|
171
|
+
txt.setAttribute("cm-text", m[0])
|
172
|
+
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]))
|
173
|
+
else content.appendChild(txt)
|
174
|
+
builder.col += 1
|
175
|
+
}
|
176
|
+
builder.map.push(builder.pos, builder.pos + 1, txt)
|
177
|
+
builder.pos++
|
178
|
+
}
|
179
|
+
}
|
180
|
+
builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32
|
181
|
+
if (style || startStyle || endStyle || mustWrap || css) {
|
182
|
+
let fullStyle = style || ""
|
183
|
+
if (startStyle) fullStyle += startStyle
|
184
|
+
if (endStyle) fullStyle += endStyle
|
185
|
+
let token = elt("span", [content], fullStyle, css)
|
186
|
+
if (title) token.title = title
|
187
|
+
return builder.content.appendChild(token)
|
188
|
+
}
|
189
|
+
builder.content.appendChild(content)
|
190
|
+
}
|
191
|
+
|
192
|
+
// Change some spaces to NBSP to prevent the browser from collapsing
|
193
|
+
// trailing spaces at the end of a line when rendering text (issue #1362).
|
194
|
+
function splitSpaces(text, trailingBefore) {
|
195
|
+
if (text.length > 1 && !/ /.test(text)) return text
|
196
|
+
let spaceBefore = trailingBefore, result = ""
|
197
|
+
for (let i = 0; i < text.length; i++) {
|
198
|
+
let ch = text.charAt(i)
|
199
|
+
if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
|
200
|
+
ch = "\u00a0"
|
201
|
+
result += ch
|
202
|
+
spaceBefore = ch == " "
|
203
|
+
}
|
204
|
+
return result
|
205
|
+
}
|
206
|
+
|
207
|
+
// Work around nonsense dimensions being reported for stretches of
|
208
|
+
// right-to-left text.
|
209
|
+
function buildTokenBadBidi(inner, order) {
|
210
|
+
return (builder, text, style, startStyle, endStyle, title, css) => {
|
211
|
+
style = style ? style + " cm-force-border" : "cm-force-border"
|
212
|
+
let start = builder.pos, end = start + text.length
|
213
|
+
for (;;) {
|
214
|
+
// Find the part that overlaps with the start of this text
|
215
|
+
let part
|
216
|
+
for (let i = 0; i < order.length; i++) {
|
217
|
+
part = order[i]
|
218
|
+
if (part.to > start && part.from <= start) break
|
219
|
+
}
|
220
|
+
if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css)
|
221
|
+
inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css)
|
222
|
+
startStyle = null
|
223
|
+
text = text.slice(part.to - start)
|
224
|
+
start = part.to
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
|
230
|
+
let widget = !ignoreWidget && marker.widgetNode
|
231
|
+
if (widget) builder.map.push(builder.pos, builder.pos + size, widget)
|
232
|
+
if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
|
233
|
+
if (!widget)
|
234
|
+
widget = builder.content.appendChild(document.createElement("span"))
|
235
|
+
widget.setAttribute("cm-marker", marker.id)
|
236
|
+
}
|
237
|
+
if (widget) {
|
238
|
+
builder.cm.display.input.setUneditable(widget)
|
239
|
+
builder.content.appendChild(widget)
|
240
|
+
}
|
241
|
+
builder.pos += size
|
242
|
+
builder.trailingSpace = false
|
243
|
+
}
|
244
|
+
|
245
|
+
// Outputs a number of spans to make up a line, taking highlighting
|
246
|
+
// and marked text into account.
|
247
|
+
function insertLineContent(line, builder, styles) {
|
248
|
+
let spans = line.markedSpans, allText = line.text, at = 0
|
249
|
+
if (!spans) {
|
250
|
+
for (let i = 1; i < styles.length; i+=2)
|
251
|
+
builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options))
|
252
|
+
return
|
253
|
+
}
|
254
|
+
|
255
|
+
let len = allText.length, pos = 0, i = 1, text = "", style, css
|
256
|
+
let nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed
|
257
|
+
for (;;) {
|
258
|
+
if (nextChange == pos) { // Update current marker set
|
259
|
+
spanStyle = spanEndStyle = spanStartStyle = title = css = ""
|
260
|
+
collapsed = null; nextChange = Infinity
|
261
|
+
let foundBookmarks = [], endStyles
|
262
|
+
for (let j = 0; j < spans.length; ++j) {
|
263
|
+
let sp = spans[j], m = sp.marker
|
264
|
+
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
|
265
|
+
foundBookmarks.push(m)
|
266
|
+
} else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
|
267
|
+
if (sp.to != null && sp.to != pos && nextChange > sp.to) {
|
268
|
+
nextChange = sp.to
|
269
|
+
spanEndStyle = ""
|
270
|
+
}
|
271
|
+
if (m.className) spanStyle += " " + m.className
|
272
|
+
if (m.css) css = (css ? css + ";" : "") + m.css
|
273
|
+
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle
|
274
|
+
if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to)
|
275
|
+
if (m.title && !title) title = m.title
|
276
|
+
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
277
|
+
collapsed = sp
|
278
|
+
} else if (sp.from > pos && nextChange > sp.from) {
|
279
|
+
nextChange = sp.from
|
280
|
+
}
|
281
|
+
}
|
282
|
+
if (endStyles) for (let j = 0; j < endStyles.length; j += 2)
|
283
|
+
if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j]
|
284
|
+
|
285
|
+
if (!collapsed || collapsed.from == pos) for (let j = 0; j < foundBookmarks.length; ++j)
|
286
|
+
buildCollapsedSpan(builder, 0, foundBookmarks[j])
|
287
|
+
if (collapsed && (collapsed.from || 0) == pos) {
|
288
|
+
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
289
|
+
collapsed.marker, collapsed.from == null)
|
290
|
+
if (collapsed.to == null) return
|
291
|
+
if (collapsed.to == pos) collapsed = false
|
292
|
+
}
|
293
|
+
}
|
294
|
+
if (pos >= len) break
|
295
|
+
|
296
|
+
let upto = Math.min(len, nextChange)
|
297
|
+
while (true) {
|
298
|
+
if (text) {
|
299
|
+
let end = pos + text.length
|
300
|
+
if (!collapsed) {
|
301
|
+
let tokenText = end > upto ? text.slice(0, upto - pos) : text
|
302
|
+
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
|
303
|
+
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css)
|
304
|
+
}
|
305
|
+
if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
|
306
|
+
pos = end
|
307
|
+
spanStartStyle = ""
|
308
|
+
}
|
309
|
+
text = allText.slice(at, at = styles[i++])
|
310
|
+
style = interpretTokenStyle(styles[i++], builder.cm.options)
|
311
|
+
}
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
// These objects are used to represent the visible (currently drawn)
|
317
|
+
// part of the document. A LineView may correspond to multiple
|
318
|
+
// logical lines, if those are connected by collapsed ranges.
|
319
|
+
export function LineView(doc, line, lineN) {
|
320
|
+
// The starting line
|
321
|
+
this.line = line
|
322
|
+
// Continuing lines, if any
|
323
|
+
this.rest = visualLineContinued(line)
|
324
|
+
// Number of logical lines in this visual line
|
325
|
+
this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1
|
326
|
+
this.node = this.text = null
|
327
|
+
this.hidden = lineIsHidden(doc, line)
|
328
|
+
}
|
329
|
+
|
330
|
+
// Create a range of LineView objects for the given lines.
|
331
|
+
export function buildViewArray(cm, from, to) {
|
332
|
+
let array = [], nextPos
|
333
|
+
for (let pos = from; pos < to; pos = nextPos) {
|
334
|
+
let view = new LineView(cm.doc, getLine(cm.doc, pos), pos)
|
335
|
+
nextPos = pos + view.size
|
336
|
+
array.push(view)
|
337
|
+
}
|
338
|
+
return array
|
339
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { getLine } from "./utils_line.js"
|
2
|
+
|
3
|
+
// A Pos instance represents a position within the text.
|
4
|
+
export function Pos(line, ch, sticky = null) {
|
5
|
+
if (!(this instanceof Pos)) return new Pos(line, ch, sticky)
|
6
|
+
this.line = line
|
7
|
+
this.ch = ch
|
8
|
+
this.sticky = sticky
|
9
|
+
}
|
10
|
+
|
11
|
+
// Compare two positions, return 0 if they are the same, a negative
|
12
|
+
// number when a is less, and a positive number otherwise.
|
13
|
+
export function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
|
14
|
+
|
15
|
+
export function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
|
16
|
+
|
17
|
+
export function copyPos(x) {return Pos(x.line, x.ch)}
|
18
|
+
export function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
|
19
|
+
export function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
|
20
|
+
|
21
|
+
// Most of the external API clips given positions to make sure they
|
22
|
+
// actually exist within the document.
|
23
|
+
export function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
|
24
|
+
export function clipPos(doc, pos) {
|
25
|
+
if (pos.line < doc.first) return Pos(doc.first, 0)
|
26
|
+
let last = doc.first + doc.size - 1
|
27
|
+
if (pos.line > last) return Pos(last, getLine(doc, last).text.length)
|
28
|
+
return clipToLen(pos, getLine(doc, pos.line).text.length)
|
29
|
+
}
|
30
|
+
function clipToLen(pos, linelen) {
|
31
|
+
let ch = pos.ch
|
32
|
+
if (ch == null || ch > linelen) return Pos(pos.line, linelen)
|
33
|
+
else if (ch < 0) return Pos(pos.line, 0)
|
34
|
+
else return pos
|
35
|
+
}
|
36
|
+
export function clipPosArray(doc, array) {
|
37
|
+
let out = []
|
38
|
+
for (let i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i])
|
39
|
+
return out
|
40
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
// Optimize some code when these features are not used.
|
2
|
+
export let sawReadOnlySpans = false, sawCollapsedSpans = false
|
3
|
+
|
4
|
+
export function seeReadOnlySpans() {
|
5
|
+
sawReadOnlySpans = true
|
6
|
+
}
|
7
|
+
|
8
|
+
export function seeCollapsedSpans() {
|
9
|
+
sawCollapsedSpans = true
|
10
|
+
}
|
@@ -0,0 +1,382 @@
|
|
1
|
+
import { indexOf, lst } from "../util/misc.js"
|
2
|
+
|
3
|
+
import { cmp } from "./pos.js"
|
4
|
+
import { sawCollapsedSpans } from "./saw_special_spans.js"
|
5
|
+
import { getLine, isLine, lineNo } from "./utils_line.js"
|
6
|
+
|
7
|
+
// TEXTMARKER SPANS
|
8
|
+
|
9
|
+
export function MarkedSpan(marker, from, to) {
|
10
|
+
this.marker = marker
|
11
|
+
this.from = from; this.to = to
|
12
|
+
}
|
13
|
+
|
14
|
+
// Search an array of spans for a span matching the given marker.
|
15
|
+
export function getMarkedSpanFor(spans, marker) {
|
16
|
+
if (spans) for (let i = 0; i < spans.length; ++i) {
|
17
|
+
let span = spans[i]
|
18
|
+
if (span.marker == marker) return span
|
19
|
+
}
|
20
|
+
}
|
21
|
+
// Remove a span from an array, returning undefined if no spans are
|
22
|
+
// left (we don't store arrays for lines without spans).
|
23
|
+
export function removeMarkedSpan(spans, span) {
|
24
|
+
let r
|
25
|
+
for (let i = 0; i < spans.length; ++i)
|
26
|
+
if (spans[i] != span) (r || (r = [])).push(spans[i])
|
27
|
+
return r
|
28
|
+
}
|
29
|
+
// Add a span to a line.
|
30
|
+
export function addMarkedSpan(line, span) {
|
31
|
+
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]
|
32
|
+
span.marker.attachLine(line)
|
33
|
+
}
|
34
|
+
|
35
|
+
// Used for the algorithm that adjusts markers for a change in the
|
36
|
+
// document. These functions cut an array of spans at a given
|
37
|
+
// character position, returning an array of remaining chunks (or
|
38
|
+
// undefined if nothing remains).
|
39
|
+
function markedSpansBefore(old, startCh, isInsert) {
|
40
|
+
let nw
|
41
|
+
if (old) for (let i = 0; i < old.length; ++i) {
|
42
|
+
let span = old[i], marker = span.marker
|
43
|
+
let startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh)
|
44
|
+
if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
|
45
|
+
let endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)
|
46
|
+
;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to))
|
47
|
+
}
|
48
|
+
}
|
49
|
+
return nw
|
50
|
+
}
|
51
|
+
function markedSpansAfter(old, endCh, isInsert) {
|
52
|
+
let nw
|
53
|
+
if (old) for (let i = 0; i < old.length; ++i) {
|
54
|
+
let span = old[i], marker = span.marker
|
55
|
+
let endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh)
|
56
|
+
if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
|
57
|
+
let startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)
|
58
|
+
;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
|
59
|
+
span.to == null ? null : span.to - endCh))
|
60
|
+
}
|
61
|
+
}
|
62
|
+
return nw
|
63
|
+
}
|
64
|
+
|
65
|
+
// Given a change object, compute the new set of marker spans that
|
66
|
+
// cover the line in which the change took place. Removes spans
|
67
|
+
// entirely within the change, reconnects spans belonging to the
|
68
|
+
// same marker that appear on both sides of the change, and cuts off
|
69
|
+
// spans partially within the change. Returns an array of span
|
70
|
+
// arrays with one element for each line in (after) the change.
|
71
|
+
export function stretchSpansOverChange(doc, change) {
|
72
|
+
if (change.full) return null
|
73
|
+
let oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans
|
74
|
+
let oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans
|
75
|
+
if (!oldFirst && !oldLast) return null
|
76
|
+
|
77
|
+
let startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0
|
78
|
+
// Get the spans that 'stick out' on both sides
|
79
|
+
let first = markedSpansBefore(oldFirst, startCh, isInsert)
|
80
|
+
let last = markedSpansAfter(oldLast, endCh, isInsert)
|
81
|
+
|
82
|
+
// Next, merge those two ends
|
83
|
+
let sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0)
|
84
|
+
if (first) {
|
85
|
+
// Fix up .to properties of first
|
86
|
+
for (let i = 0; i < first.length; ++i) {
|
87
|
+
let span = first[i]
|
88
|
+
if (span.to == null) {
|
89
|
+
let found = getMarkedSpanFor(last, span.marker)
|
90
|
+
if (!found) span.to = startCh
|
91
|
+
else if (sameLine) span.to = found.to == null ? null : found.to + offset
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
if (last) {
|
96
|
+
// Fix up .from in last (or move them into first in case of sameLine)
|
97
|
+
for (let i = 0; i < last.length; ++i) {
|
98
|
+
let span = last[i]
|
99
|
+
if (span.to != null) span.to += offset
|
100
|
+
if (span.from == null) {
|
101
|
+
let found = getMarkedSpanFor(first, span.marker)
|
102
|
+
if (!found) {
|
103
|
+
span.from = offset
|
104
|
+
if (sameLine) (first || (first = [])).push(span)
|
105
|
+
}
|
106
|
+
} else {
|
107
|
+
span.from += offset
|
108
|
+
if (sameLine) (first || (first = [])).push(span)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
// Make sure we didn't create any zero-length spans
|
113
|
+
if (first) first = clearEmptySpans(first)
|
114
|
+
if (last && last != first) last = clearEmptySpans(last)
|
115
|
+
|
116
|
+
let newMarkers = [first]
|
117
|
+
if (!sameLine) {
|
118
|
+
// Fill gap with whole-line-spans
|
119
|
+
let gap = change.text.length - 2, gapMarkers
|
120
|
+
if (gap > 0 && first)
|
121
|
+
for (let i = 0; i < first.length; ++i)
|
122
|
+
if (first[i].to == null)
|
123
|
+
(gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null))
|
124
|
+
for (let i = 0; i < gap; ++i)
|
125
|
+
newMarkers.push(gapMarkers)
|
126
|
+
newMarkers.push(last)
|
127
|
+
}
|
128
|
+
return newMarkers
|
129
|
+
}
|
130
|
+
|
131
|
+
// Remove spans that are empty and don't have a clearWhenEmpty
|
132
|
+
// option of false.
|
133
|
+
function clearEmptySpans(spans) {
|
134
|
+
for (let i = 0; i < spans.length; ++i) {
|
135
|
+
let span = spans[i]
|
136
|
+
if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
|
137
|
+
spans.splice(i--, 1)
|
138
|
+
}
|
139
|
+
if (!spans.length) return null
|
140
|
+
return spans
|
141
|
+
}
|
142
|
+
|
143
|
+
// Used to 'clip' out readOnly ranges when making a change.
|
144
|
+
export function removeReadOnlyRanges(doc, from, to) {
|
145
|
+
let markers = null
|
146
|
+
doc.iter(from.line, to.line + 1, line => {
|
147
|
+
if (line.markedSpans) for (let i = 0; i < line.markedSpans.length; ++i) {
|
148
|
+
let mark = line.markedSpans[i].marker
|
149
|
+
if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
|
150
|
+
(markers || (markers = [])).push(mark)
|
151
|
+
}
|
152
|
+
})
|
153
|
+
if (!markers) return null
|
154
|
+
let parts = [{from: from, to: to}]
|
155
|
+
for (let i = 0; i < markers.length; ++i) {
|
156
|
+
let mk = markers[i], m = mk.find(0)
|
157
|
+
for (let j = 0; j < parts.length; ++j) {
|
158
|
+
let p = parts[j]
|
159
|
+
if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue
|
160
|
+
let newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to)
|
161
|
+
if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
|
162
|
+
newParts.push({from: p.from, to: m.from})
|
163
|
+
if (dto > 0 || !mk.inclusiveRight && !dto)
|
164
|
+
newParts.push({from: m.to, to: p.to})
|
165
|
+
parts.splice.apply(parts, newParts)
|
166
|
+
j += newParts.length - 3
|
167
|
+
}
|
168
|
+
}
|
169
|
+
return parts
|
170
|
+
}
|
171
|
+
|
172
|
+
// Connect or disconnect spans from a line.
|
173
|
+
export function detachMarkedSpans(line) {
|
174
|
+
let spans = line.markedSpans
|
175
|
+
if (!spans) return
|
176
|
+
for (let i = 0; i < spans.length; ++i)
|
177
|
+
spans[i].marker.detachLine(line)
|
178
|
+
line.markedSpans = null
|
179
|
+
}
|
180
|
+
export function attachMarkedSpans(line, spans) {
|
181
|
+
if (!spans) return
|
182
|
+
for (let i = 0; i < spans.length; ++i)
|
183
|
+
spans[i].marker.attachLine(line)
|
184
|
+
line.markedSpans = spans
|
185
|
+
}
|
186
|
+
|
187
|
+
// Helpers used when computing which overlapping collapsed span
|
188
|
+
// counts as the larger one.
|
189
|
+
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
|
190
|
+
function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
|
191
|
+
|
192
|
+
// Returns a number indicating which of two overlapping collapsed
|
193
|
+
// spans is larger (and thus includes the other). Falls back to
|
194
|
+
// comparing ids when the spans cover exactly the same range.
|
195
|
+
export function compareCollapsedMarkers(a, b) {
|
196
|
+
let lenDiff = a.lines.length - b.lines.length
|
197
|
+
if (lenDiff != 0) return lenDiff
|
198
|
+
let aPos = a.find(), bPos = b.find()
|
199
|
+
let fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b)
|
200
|
+
if (fromCmp) return -fromCmp
|
201
|
+
let toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b)
|
202
|
+
if (toCmp) return toCmp
|
203
|
+
return b.id - a.id
|
204
|
+
}
|
205
|
+
|
206
|
+
// Find out whether a line ends or starts in a collapsed span. If
|
207
|
+
// so, return the marker for that span.
|
208
|
+
function collapsedSpanAtSide(line, start) {
|
209
|
+
let sps = sawCollapsedSpans && line.markedSpans, found
|
210
|
+
if (sps) for (let sp, i = 0; i < sps.length; ++i) {
|
211
|
+
sp = sps[i]
|
212
|
+
if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
|
213
|
+
(!found || compareCollapsedMarkers(found, sp.marker) < 0))
|
214
|
+
found = sp.marker
|
215
|
+
}
|
216
|
+
return found
|
217
|
+
}
|
218
|
+
export function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
|
219
|
+
export function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
|
220
|
+
|
221
|
+
export function collapsedSpanAround(line, ch) {
|
222
|
+
let sps = sawCollapsedSpans && line.markedSpans, found
|
223
|
+
if (sps) for (let i = 0; i < sps.length; ++i) {
|
224
|
+
let sp = sps[i]
|
225
|
+
if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) &&
|
226
|
+
(!found || compareCollapsedMarkers(found, sp.marker) < 0)) found = sp.marker
|
227
|
+
}
|
228
|
+
return found
|
229
|
+
}
|
230
|
+
|
231
|
+
// Test whether there exists a collapsed span that partially
|
232
|
+
// overlaps (covers the start or end, but not both) of a new span.
|
233
|
+
// Such overlap is not allowed.
|
234
|
+
export function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
|
235
|
+
let line = getLine(doc, lineNo)
|
236
|
+
let sps = sawCollapsedSpans && line.markedSpans
|
237
|
+
if (sps) for (let i = 0; i < sps.length; ++i) {
|
238
|
+
let sp = sps[i]
|
239
|
+
if (!sp.marker.collapsed) continue
|
240
|
+
let found = sp.marker.find(0)
|
241
|
+
let fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker)
|
242
|
+
let toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker)
|
243
|
+
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue
|
244
|
+
if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
|
245
|
+
fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
|
246
|
+
return true
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
// A visual line is a line as drawn on the screen. Folding, for
|
251
|
+
// example, can cause multiple logical lines to appear on the same
|
252
|
+
// visual line. This finds the start of the visual line that the
|
253
|
+
// given line is part of (usually that is the line itself).
|
254
|
+
export function visualLine(line) {
|
255
|
+
let merged
|
256
|
+
while (merged = collapsedSpanAtStart(line))
|
257
|
+
line = merged.find(-1, true).line
|
258
|
+
return line
|
259
|
+
}
|
260
|
+
|
261
|
+
export function visualLineEnd(line) {
|
262
|
+
let merged
|
263
|
+
while (merged = collapsedSpanAtEnd(line))
|
264
|
+
line = merged.find(1, true).line
|
265
|
+
return line
|
266
|
+
}
|
267
|
+
|
268
|
+
// Returns an array of logical lines that continue the visual line
|
269
|
+
// started by the argument, or undefined if there are no such lines.
|
270
|
+
export function visualLineContinued(line) {
|
271
|
+
let merged, lines
|
272
|
+
while (merged = collapsedSpanAtEnd(line)) {
|
273
|
+
line = merged.find(1, true).line
|
274
|
+
;(lines || (lines = [])).push(line)
|
275
|
+
}
|
276
|
+
return lines
|
277
|
+
}
|
278
|
+
|
279
|
+
// Get the line number of the start of the visual line that the
|
280
|
+
// given line number is part of.
|
281
|
+
export function visualLineNo(doc, lineN) {
|
282
|
+
let line = getLine(doc, lineN), vis = visualLine(line)
|
283
|
+
if (line == vis) return lineN
|
284
|
+
return lineNo(vis)
|
285
|
+
}
|
286
|
+
|
287
|
+
// Get the line number of the start of the next visual line after
|
288
|
+
// the given line.
|
289
|
+
export function visualLineEndNo(doc, lineN) {
|
290
|
+
if (lineN > doc.lastLine()) return lineN
|
291
|
+
let line = getLine(doc, lineN), merged
|
292
|
+
if (!lineIsHidden(doc, line)) return lineN
|
293
|
+
while (merged = collapsedSpanAtEnd(line))
|
294
|
+
line = merged.find(1, true).line
|
295
|
+
return lineNo(line) + 1
|
296
|
+
}
|
297
|
+
|
298
|
+
// Compute whether a line is hidden. Lines count as hidden when they
|
299
|
+
// are part of a visual line that starts with another line, or when
|
300
|
+
// they are entirely covered by collapsed, non-widget span.
|
301
|
+
export function lineIsHidden(doc, line) {
|
302
|
+
let sps = sawCollapsedSpans && line.markedSpans
|
303
|
+
if (sps) for (let sp, i = 0; i < sps.length; ++i) {
|
304
|
+
sp = sps[i]
|
305
|
+
if (!sp.marker.collapsed) continue
|
306
|
+
if (sp.from == null) return true
|
307
|
+
if (sp.marker.widgetNode) continue
|
308
|
+
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
|
309
|
+
return true
|
310
|
+
}
|
311
|
+
}
|
312
|
+
function lineIsHiddenInner(doc, line, span) {
|
313
|
+
if (span.to == null) {
|
314
|
+
let end = span.marker.find(1, true)
|
315
|
+
return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
|
316
|
+
}
|
317
|
+
if (span.marker.inclusiveRight && span.to == line.text.length)
|
318
|
+
return true
|
319
|
+
for (let sp, i = 0; i < line.markedSpans.length; ++i) {
|
320
|
+
sp = line.markedSpans[i]
|
321
|
+
if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
|
322
|
+
(sp.to == null || sp.to != span.from) &&
|
323
|
+
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
|
324
|
+
lineIsHiddenInner(doc, line, sp)) return true
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
328
|
+
// Find the height above the given line.
|
329
|
+
export function heightAtLine(lineObj) {
|
330
|
+
lineObj = visualLine(lineObj)
|
331
|
+
|
332
|
+
let h = 0, chunk = lineObj.parent
|
333
|
+
for (let i = 0; i < chunk.lines.length; ++i) {
|
334
|
+
let line = chunk.lines[i]
|
335
|
+
if (line == lineObj) break
|
336
|
+
else h += line.height
|
337
|
+
}
|
338
|
+
for (let p = chunk.parent; p; chunk = p, p = chunk.parent) {
|
339
|
+
for (let i = 0; i < p.children.length; ++i) {
|
340
|
+
let cur = p.children[i]
|
341
|
+
if (cur == chunk) break
|
342
|
+
else h += cur.height
|
343
|
+
}
|
344
|
+
}
|
345
|
+
return h
|
346
|
+
}
|
347
|
+
|
348
|
+
// Compute the character length of a line, taking into account
|
349
|
+
// collapsed ranges (see markText) that might hide parts, and join
|
350
|
+
// other lines onto it.
|
351
|
+
export function lineLength(line) {
|
352
|
+
if (line.height == 0) return 0
|
353
|
+
let len = line.text.length, merged, cur = line
|
354
|
+
while (merged = collapsedSpanAtStart(cur)) {
|
355
|
+
let found = merged.find(0, true)
|
356
|
+
cur = found.from.line
|
357
|
+
len += found.from.ch - found.to.ch
|
358
|
+
}
|
359
|
+
cur = line
|
360
|
+
while (merged = collapsedSpanAtEnd(cur)) {
|
361
|
+
let found = merged.find(0, true)
|
362
|
+
len -= cur.text.length - found.from.ch
|
363
|
+
cur = found.to.line
|
364
|
+
len += cur.text.length - found.to.ch
|
365
|
+
}
|
366
|
+
return len
|
367
|
+
}
|
368
|
+
|
369
|
+
// Find the longest line in the document.
|
370
|
+
export function findMaxLine(cm) {
|
371
|
+
let d = cm.display, doc = cm.doc
|
372
|
+
d.maxLine = getLine(doc, doc.first)
|
373
|
+
d.maxLineLength = lineLength(d.maxLine)
|
374
|
+
d.maxLineChanged = true
|
375
|
+
doc.iter(line => {
|
376
|
+
let len = lineLength(line)
|
377
|
+
if (len > d.maxLineLength) {
|
378
|
+
d.maxLineLength = len
|
379
|
+
d.maxLine = line
|
380
|
+
}
|
381
|
+
})
|
382
|
+
}
|