administrate-field-simple_mde_markdown 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +72 -0
  3. data/.circleci/setup-rubygems.sh +3 -0
  4. data/.gitignore +11 -0
  5. data/.rspec +3 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +8 -0
  8. data/Gemfile.lock +196 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +44 -0
  11. data/Rakefile +8 -0
  12. data/administrate-field-simple_mde_markdown.gemspec +31 -0
  13. data/app/assets/javascripts/administrate-field-simple_mde_markdown/application.js +6 -0
  14. data/app/assets/stylesheets/administrate-field-simple_mde_markdown/application.css +3 -0
  15. data/app/views/fields/simple_mde_markdown/_form.html.erb +6 -0
  16. data/app/views/fields/simple_mde_markdown/_index.html.erb +1 -0
  17. data/app/views/fields/simple_mde_markdown/_show.html.erb +1 -0
  18. data/lib/administrate/field/simple_mde_markdown.rb +31 -0
  19. data/node_modules/.bin/marked +1 -0
  20. data/node_modules/codemirror-spell-checker/.eslintrc +23 -0
  21. data/node_modules/codemirror-spell-checker/.npmignore +2 -0
  22. data/node_modules/codemirror-spell-checker/.travis.yml +18 -0
  23. data/node_modules/codemirror-spell-checker/CONTRIBUTING 2.md +10 -0
  24. data/node_modules/codemirror-spell-checker/CONTRIBUTING.md +10 -0
  25. data/node_modules/codemirror-spell-checker/LICENSE +22 -0
  26. data/node_modules/codemirror-spell-checker/README.md +50 -0
  27. data/node_modules/codemirror-spell-checker/bower.json +27 -0
  28. data/node_modules/codemirror-spell-checker/debug/.spell-checker 2.css.icloud +0 -0
  29. data/node_modules/codemirror-spell-checker/debug/spell-checker.css +9 -0
  30. data/node_modules/codemirror-spell-checker/debug/spell-checker.debug.js +2844 -0
  31. data/node_modules/codemirror-spell-checker/debug/spell-checker.js +2841 -0
  32. data/node_modules/codemirror-spell-checker/dist/.spell-checker.min 2.css.icloud +0 -0
  33. data/node_modules/codemirror-spell-checker/dist/en_US.aff +201 -0
  34. data/node_modules/codemirror-spell-checker/dist/en_US.dic +62120 -0
  35. data/node_modules/codemirror-spell-checker/dist/spell-checker.min 2.js +7 -0
  36. data/node_modules/codemirror-spell-checker/dist/spell-checker.min.css +7 -0
  37. data/node_modules/codemirror-spell-checker/dist/spell-checker.min.js +7 -0
  38. data/node_modules/codemirror-spell-checker/gulpfile.js +94 -0
  39. data/node_modules/codemirror-spell-checker/package.json +75 -0
  40. data/node_modules/codemirror-spell-checker/src/css/spell-checker.css +3 -0
  41. data/node_modules/codemirror-spell-checker/src/data/en_US.aff +201 -0
  42. data/node_modules/codemirror-spell-checker/src/data/en_US.dic +62120 -0
  43. data/node_modules/codemirror-spell-checker/src/js/spell-checker.js +119 -0
  44. data/node_modules/codemirror/.package 2.json.icloud +0 -0
  45. data/node_modules/codemirror/AUTHORS +773 -0
  46. data/node_modules/codemirror/CHANGELOG.md +1486 -0
  47. data/node_modules/codemirror/CONTRIBUTING.md +92 -0
  48. data/node_modules/codemirror/LICENSE +21 -0
  49. data/node_modules/codemirror/README.md +49 -0
  50. data/node_modules/codemirror/addon/comment/comment.js +209 -0
  51. data/node_modules/codemirror/addon/comment/continuecomment.js +78 -0
  52. data/node_modules/codemirror/addon/dialog/dialog.css +32 -0
  53. data/node_modules/codemirror/addon/dialog/dialog.js +161 -0
  54. data/node_modules/codemirror/addon/display/autorefresh.js +47 -0
  55. data/node_modules/codemirror/addon/display/fullscreen.css +6 -0
  56. data/node_modules/codemirror/addon/display/fullscreen.js +41 -0
  57. data/node_modules/codemirror/addon/display/panel.js +127 -0
  58. data/node_modules/codemirror/addon/display/placeholder.js +63 -0
  59. data/node_modules/codemirror/addon/display/rulers.js +51 -0
  60. data/node_modules/codemirror/addon/edit/closebrackets.js +187 -0
  61. data/node_modules/codemirror/addon/edit/closetag.js +175 -0
  62. data/node_modules/codemirror/addon/edit/continuelist.js +89 -0
  63. data/node_modules/codemirror/addon/edit/matchbrackets.js +145 -0
  64. data/node_modules/codemirror/addon/edit/matchtags.js +66 -0
  65. data/node_modules/codemirror/addon/edit/trailingspace.js +27 -0
  66. data/node_modules/codemirror/addon/fold/brace-fold.js +105 -0
  67. data/node_modules/codemirror/addon/fold/comment-fold.js +59 -0
  68. data/node_modules/codemirror/addon/fold/foldcode.js +152 -0
  69. data/node_modules/codemirror/addon/fold/foldgutter.css +20 -0
  70. data/node_modules/codemirror/addon/fold/foldgutter.js +146 -0
  71. data/node_modules/codemirror/addon/fold/indent-fold.js +48 -0
  72. data/node_modules/codemirror/addon/fold/markdown-fold.js +49 -0
  73. data/node_modules/codemirror/addon/fold/xml-fold.js +184 -0
  74. data/node_modules/codemirror/addon/hint/anyword-hint.js +41 -0
  75. data/node_modules/codemirror/addon/hint/css-hint.js +60 -0
  76. data/node_modules/codemirror/addon/hint/html-hint.js +348 -0
  77. data/node_modules/codemirror/addon/hint/javascript-hint.js +157 -0
  78. data/node_modules/codemirror/addon/hint/show-hint.css +36 -0
  79. data/node_modules/codemirror/addon/hint/show-hint.js +434 -0
  80. data/node_modules/codemirror/addon/hint/sql-hint.js +299 -0
  81. data/node_modules/codemirror/addon/hint/xml-hint.js +110 -0
  82. data/node_modules/codemirror/addon/lint/coffeescript-lint.js +47 -0
  83. data/node_modules/codemirror/addon/lint/css-lint.js +40 -0
  84. data/node_modules/codemirror/addon/lint/html-lint.js +53 -0
  85. data/node_modules/codemirror/addon/lint/javascript-lint.js +63 -0
  86. data/node_modules/codemirror/addon/lint/json-lint.js +40 -0
  87. data/node_modules/codemirror/addon/lint/lint.css +73 -0
  88. data/node_modules/codemirror/addon/lint/lint.js +252 -0
  89. data/node_modules/codemirror/addon/lint/yaml-lint.js +41 -0
  90. data/node_modules/codemirror/addon/merge/merge.css +119 -0
  91. data/node_modules/codemirror/addon/merge/merge.js +1002 -0
  92. data/node_modules/codemirror/addon/mode/loadmode.js +64 -0
  93. data/node_modules/codemirror/addon/mode/multiplex.js +131 -0
  94. data/node_modules/codemirror/addon/mode/multiplex_test.js +33 -0
  95. data/node_modules/codemirror/addon/mode/overlay.js +90 -0
  96. data/node_modules/codemirror/addon/mode/simple.js +216 -0
  97. data/node_modules/codemirror/addon/runmode/colorize.js +40 -0
  98. data/node_modules/codemirror/addon/runmode/runmode-standalone.js +158 -0
  99. data/node_modules/codemirror/addon/runmode/runmode.js +72 -0
  100. data/node_modules/codemirror/addon/runmode/runmode.node.js +197 -0
  101. data/node_modules/codemirror/addon/scroll/annotatescrollbar.js +122 -0
  102. data/node_modules/codemirror/addon/scroll/scrollpastend.js +48 -0
  103. data/node_modules/codemirror/addon/scroll/simplescrollbars.css +66 -0
  104. data/node_modules/codemirror/addon/scroll/simplescrollbars.js +152 -0
  105. data/node_modules/codemirror/addon/search/jump-to-line.js +50 -0
  106. data/node_modules/codemirror/addon/search/match-highlighter.js +165 -0
  107. data/node_modules/codemirror/addon/search/matchesonscrollbar.css +8 -0
  108. data/node_modules/codemirror/addon/search/matchesonscrollbar.js +97 -0
  109. data/node_modules/codemirror/addon/search/search.js +258 -0
  110. data/node_modules/codemirror/addon/search/searchcursor.js +293 -0
  111. data/node_modules/codemirror/addon/selection/active-line.js +72 -0
  112. data/node_modules/codemirror/addon/selection/mark-selection.js +119 -0
  113. data/node_modules/codemirror/addon/selection/selection-pointer.js +98 -0
  114. data/node_modules/codemirror/addon/tern/tern.css +87 -0
  115. data/node_modules/codemirror/addon/tern/tern.js +718 -0
  116. data/node_modules/codemirror/addon/tern/worker.js +44 -0
  117. data/node_modules/codemirror/addon/wrap/hardwrap.js +145 -0
  118. data/node_modules/codemirror/bin/source-highlight +48 -0
  119. data/node_modules/codemirror/keymap/emacs.js +417 -0
  120. data/node_modules/codemirror/keymap/sublime.js +691 -0
  121. data/node_modules/codemirror/keymap/vim.js +5467 -0
  122. data/node_modules/codemirror/lib/codemirror.css +346 -0
  123. data/node_modules/codemirror/lib/codemirror.js +9698 -0
  124. data/node_modules/codemirror/mode/apl/apl.js +174 -0
  125. data/node_modules/codemirror/mode/asciiarmor/asciiarmor.js +74 -0
  126. data/node_modules/codemirror/mode/asn.1/asn.1.js +204 -0
  127. data/node_modules/codemirror/mode/asterisk/asterisk.js +196 -0
  128. data/node_modules/codemirror/mode/brainfuck/brainfuck.js +85 -0
  129. data/node_modules/codemirror/mode/clike/clike.js +879 -0
  130. data/node_modules/codemirror/mode/clojure/clojure.js +292 -0
  131. data/node_modules/codemirror/mode/cmake/cmake.js +97 -0
  132. data/node_modules/codemirror/mode/cobol/cobol.js +255 -0
  133. data/node_modules/codemirror/mode/coffeescript/coffeescript.js +359 -0
  134. data/node_modules/codemirror/mode/commonlisp/commonlisp.js +124 -0
  135. data/node_modules/codemirror/mode/crystal/crystal.js +433 -0
  136. data/node_modules/codemirror/mode/css/css.js +832 -0
  137. data/node_modules/codemirror/mode/cypher/cypher.js +150 -0
  138. data/node_modules/codemirror/mode/d/d.js +223 -0
  139. data/node_modules/codemirror/mode/dart/dart.js +157 -0
  140. data/node_modules/codemirror/mode/diff/diff.js +47 -0
  141. data/node_modules/codemirror/mode/django/django.js +356 -0
  142. data/node_modules/codemirror/mode/dockerfile/dockerfile.js +211 -0
  143. data/node_modules/codemirror/mode/dtd/dtd.js +142 -0
  144. data/node_modules/codemirror/mode/dylan/dylan.js +352 -0
  145. data/node_modules/codemirror/mode/ebnf/ebnf.js +195 -0
  146. data/node_modules/codemirror/mode/ecl/ecl.js +206 -0
  147. data/node_modules/codemirror/mode/eiffel/eiffel.js +160 -0
  148. data/node_modules/codemirror/mode/elm/elm.js +205 -0
  149. data/node_modules/codemirror/mode/erlang/erlang.js +619 -0
  150. data/node_modules/codemirror/mode/factor/factor.js +85 -0
  151. data/node_modules/codemirror/mode/fcl/fcl.js +173 -0
  152. data/node_modules/codemirror/mode/forth/forth.js +180 -0
  153. data/node_modules/codemirror/mode/fortran/fortran.js +188 -0
  154. data/node_modules/codemirror/mode/gas/gas.js +345 -0
  155. data/node_modules/codemirror/mode/gfm/gfm.js +129 -0
  156. data/node_modules/codemirror/mode/gherkin/gherkin.js +178 -0
  157. data/node_modules/codemirror/mode/go/go.js +187 -0
  158. data/node_modules/codemirror/mode/groovy/groovy.js +230 -0
  159. data/node_modules/codemirror/mode/haml/haml.js +161 -0
  160. data/node_modules/codemirror/mode/handlebars/handlebars.js +66 -0
  161. data/node_modules/codemirror/mode/haskell-literate/haskell-literate.js +43 -0
  162. data/node_modules/codemirror/mode/haskell/haskell.js +268 -0
  163. data/node_modules/codemirror/mode/haxe/haxe.js +515 -0
  164. data/node_modules/codemirror/mode/htmlembedded/htmlembedded.js +37 -0
  165. data/node_modules/codemirror/mode/htmlmixed/htmlmixed.js +152 -0
  166. data/node_modules/codemirror/mode/http/http.js +113 -0
  167. data/node_modules/codemirror/mode/idl/idl.js +290 -0
  168. data/node_modules/codemirror/mode/javascript/javascript.js +899 -0
  169. data/node_modules/codemirror/mode/jinja2/jinja2.js +144 -0
  170. data/node_modules/codemirror/mode/jsx/jsx.js +148 -0
  171. data/node_modules/codemirror/mode/julia/julia.js +433 -0
  172. data/node_modules/codemirror/mode/livescript/livescript.js +280 -0
  173. data/node_modules/codemirror/mode/lua/lua.js +159 -0
  174. data/node_modules/codemirror/mode/markdown/markdown.js +884 -0
  175. data/node_modules/codemirror/mode/mathematica/mathematica.js +176 -0
  176. data/node_modules/codemirror/mode/mbox/mbox.js +129 -0
  177. data/node_modules/codemirror/mode/meta.js +217 -0
  178. data/node_modules/codemirror/mode/mirc/mirc.js +193 -0
  179. data/node_modules/codemirror/mode/mllike/mllike.js +359 -0
  180. data/node_modules/codemirror/mode/modelica/modelica.js +245 -0
  181. data/node_modules/codemirror/mode/mscgen/mscgen.js +175 -0
  182. data/node_modules/codemirror/mode/mumps/mumps.js +148 -0
  183. data/node_modules/codemirror/mode/nginx/nginx.js +178 -0
  184. data/node_modules/codemirror/mode/nsis/nsis.js +95 -0
  185. data/node_modules/codemirror/mode/ntriples/ntriples.js +195 -0
  186. data/node_modules/codemirror/mode/octave/octave.js +139 -0
  187. data/node_modules/codemirror/mode/oz/oz.js +252 -0
  188. data/node_modules/codemirror/mode/pascal/pascal.js +121 -0
  189. data/node_modules/codemirror/mode/pegjs/pegjs.js +114 -0
  190. data/node_modules/codemirror/mode/perl/perl.js +837 -0
  191. data/node_modules/codemirror/mode/php/php.js +234 -0
  192. data/node_modules/codemirror/mode/pig/pig.js +178 -0
  193. data/node_modules/codemirror/mode/powershell/powershell.js +398 -0
  194. data/node_modules/codemirror/mode/properties/properties 2.js +78 -0
  195. data/node_modules/codemirror/mode/properties/properties.js +78 -0
  196. data/node_modules/codemirror/mode/protobuf/protobuf.js +69 -0
  197. data/node_modules/codemirror/mode/pug/pug.js +591 -0
  198. data/node_modules/codemirror/mode/puppet/puppet.js +220 -0
  199. data/node_modules/codemirror/mode/python/python.js +409 -0
  200. data/node_modules/codemirror/mode/q/q.js +139 -0
  201. data/node_modules/codemirror/mode/r/r.js +190 -0
  202. data/node_modules/codemirror/mode/rpm/changes/index.html +66 -0
  203. data/node_modules/codemirror/mode/rpm/rpm.js +109 -0
  204. data/node_modules/codemirror/mode/rst/rst.js +557 -0
  205. data/node_modules/codemirror/mode/ruby/ruby.js +296 -0
  206. data/node_modules/codemirror/mode/rust/rust.js +72 -0
  207. data/node_modules/codemirror/mode/sas/sas.js +303 -0
  208. data/node_modules/codemirror/mode/sass/sass.js +454 -0
  209. data/node_modules/codemirror/mode/scheme/scheme.js +265 -0
  210. data/node_modules/codemirror/mode/shell/shell.js +152 -0
  211. data/node_modules/codemirror/mode/sieve/sieve.js +193 -0
  212. data/node_modules/codemirror/mode/slim/slim.js +575 -0
  213. data/node_modules/codemirror/mode/smalltalk/smalltalk.js +168 -0
  214. data/node_modules/codemirror/mode/smarty/smarty.js +225 -0
  215. data/node_modules/codemirror/mode/solr/solr.js +104 -0
  216. data/node_modules/codemirror/mode/soy/soy 2.js +359 -0
  217. data/node_modules/codemirror/mode/soy/soy.js +235 -0
  218. data/node_modules/codemirror/mode/sparql/sparql.js +180 -0
  219. data/node_modules/codemirror/mode/spreadsheet/spreadsheet.js +112 -0
  220. data/node_modules/codemirror/mode/sql/sql.js +499 -0
  221. data/node_modules/codemirror/mode/stex/stex.js +264 -0
  222. data/node_modules/codemirror/mode/stylus/stylus.js +771 -0
  223. data/node_modules/codemirror/mode/swift/swift.js +219 -0
  224. data/node_modules/codemirror/mode/tcl/tcl.js +139 -0
  225. data/node_modules/codemirror/mode/textile/textile.js +469 -0
  226. data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
  227. data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.js +308 -0
  228. data/node_modules/codemirror/mode/tiki/tiki.css +26 -0
  229. data/node_modules/codemirror/mode/tiki/tiki.js +312 -0
  230. data/node_modules/codemirror/mode/toml/toml.js +88 -0
  231. data/node_modules/codemirror/mode/tornado/tornado.js +68 -0
  232. data/node_modules/codemirror/mode/troff/troff.js +84 -0
  233. data/node_modules/codemirror/mode/ttcn-cfg/ttcn-cfg.js +214 -0
  234. data/node_modules/codemirror/mode/ttcn/ttcn.js +283 -0
  235. data/node_modules/codemirror/mode/turtle/turtle.js +162 -0
  236. data/node_modules/codemirror/mode/twig/twig.js +141 -0
  237. data/node_modules/codemirror/mode/vb/vb.js +275 -0
  238. data/node_modules/codemirror/mode/vbscript/vbscript.js +350 -0
  239. data/node_modules/codemirror/mode/velocity/velocity.js +201 -0
  240. data/node_modules/codemirror/mode/verilog/verilog.js +675 -0
  241. data/node_modules/codemirror/mode/vhdl/vhdl.js +189 -0
  242. data/node_modules/codemirror/mode/vue/vue.js +77 -0
  243. data/node_modules/codemirror/mode/webidl/webidl.js +195 -0
  244. data/node_modules/codemirror/mode/xml/xml.js +402 -0
  245. data/node_modules/codemirror/mode/xquery/xquery.js +448 -0
  246. data/node_modules/codemirror/mode/yacas/yacas.js +204 -0
  247. data/node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +68 -0
  248. data/node_modules/codemirror/mode/yaml/yaml.js +120 -0
  249. data/node_modules/codemirror/mode/z80/z80.js +116 -0
  250. data/node_modules/codemirror/package.json +2395 -0
  251. data/node_modules/codemirror/rollup.config.js +20 -0
  252. data/node_modules/codemirror/src/codemirror.js +3 -0
  253. data/node_modules/codemirror/src/display/Display.js +106 -0
  254. data/node_modules/codemirror/src/display/focus.js +47 -0
  255. data/node_modules/codemirror/src/display/gutters.js +34 -0
  256. data/node_modules/codemirror/src/display/highlight_worker.js +55 -0
  257. data/node_modules/codemirror/src/display/line_numbers.js +48 -0
  258. data/node_modules/codemirror/src/display/mode_state.js +22 -0
  259. data/node_modules/codemirror/src/display/operations.js +205 -0
  260. data/node_modules/codemirror/src/display/scroll_events.js +115 -0
  261. data/node_modules/codemirror/src/display/scrollbars.js +193 -0
  262. data/node_modules/codemirror/src/display/scrolling.js +184 -0
  263. data/node_modules/codemirror/src/display/selection.js +158 -0
  264. data/node_modules/codemirror/src/display/update_display.js +260 -0
  265. data/node_modules/codemirror/src/display/update_line.js +188 -0
  266. data/node_modules/codemirror/src/display/update_lines.js +64 -0
  267. data/node_modules/codemirror/src/display/view_tracking.js +153 -0
  268. data/node_modules/codemirror/src/edit/CodeMirror.js +215 -0
  269. data/node_modules/codemirror/src/edit/commands.js +178 -0
  270. data/node_modules/codemirror/src/edit/deleteNearSelection.js +30 -0
  271. data/node_modules/codemirror/src/edit/drop_events.js +119 -0
  272. data/node_modules/codemirror/src/edit/fromTextArea.js +61 -0
  273. data/node_modules/codemirror/src/edit/global_events.js +42 -0
  274. data/node_modules/codemirror/src/edit/key_events.js +159 -0
  275. data/node_modules/codemirror/src/edit/legacy.js +62 -0
  276. data/node_modules/codemirror/src/edit/main.js +69 -0
  277. data/node_modules/codemirror/src/edit/methods.js +544 -0
  278. data/node_modules/codemirror/src/edit/mouse_events.js +407 -0
  279. data/node_modules/codemirror/src/edit/options.js +193 -0
  280. data/node_modules/codemirror/src/edit/utils.js +7 -0
  281. data/node_modules/codemirror/src/input/ContentEditableInput.js +527 -0
  282. data/node_modules/codemirror/src/input/TextareaInput.js +355 -0
  283. data/node_modules/codemirror/src/input/indent.js +71 -0
  284. data/node_modules/codemirror/src/input/input.js +135 -0
  285. data/node_modules/codemirror/src/input/keymap.js +148 -0
  286. data/node_modules/codemirror/src/input/keynames.js +17 -0
  287. data/node_modules/codemirror/src/input/movement.js +110 -0
  288. data/node_modules/codemirror/src/line/highlight.js +284 -0
  289. data/node_modules/codemirror/src/line/line_data.js +339 -0
  290. data/node_modules/codemirror/src/line/pos.js +40 -0
  291. data/node_modules/codemirror/src/line/saw_special_spans.js +10 -0
  292. data/node_modules/codemirror/src/line/spans.js +382 -0
  293. data/node_modules/codemirror/src/line/utils_line.js +85 -0
  294. data/node_modules/codemirror/src/measurement/position_measurement.js +699 -0
  295. data/node_modules/codemirror/src/measurement/widgets.js +26 -0
  296. data/node_modules/codemirror/src/model/Doc.js +432 -0
  297. data/node_modules/codemirror/src/model/change_measurement.js +61 -0
  298. data/node_modules/codemirror/src/model/changes.js +333 -0
  299. data/node_modules/codemirror/src/model/chunk.js +167 -0
  300. data/node_modules/codemirror/src/model/document_data.js +111 -0
  301. data/node_modules/codemirror/src/model/history.js +228 -0
  302. data/node_modules/codemirror/src/model/line_widget.js +78 -0
  303. data/node_modules/codemirror/src/model/mark_text.js +292 -0
  304. data/node_modules/codemirror/src/model/selection.js +84 -0
  305. data/node_modules/codemirror/src/model/selection_updates.js +208 -0
  306. data/node_modules/codemirror/src/modes.js +96 -0
  307. data/node_modules/codemirror/src/util/StringStream.js +90 -0
  308. data/node_modules/codemirror/src/util/bidi.js +214 -0
  309. data/node_modules/codemirror/src/util/browser.js +33 -0
  310. data/node_modules/codemirror/src/util/dom.js +97 -0
  311. data/node_modules/codemirror/src/util/event.js +103 -0
  312. data/node_modules/codemirror/src/util/feature_detection.js +84 -0
  313. data/node_modules/codemirror/src/util/misc.js +150 -0
  314. data/node_modules/codemirror/src/util/operation_group.js +72 -0
  315. data/node_modules/codemirror/theme/3024-day.css +41 -0
  316. data/node_modules/codemirror/theme/3024-night.css +39 -0
  317. data/node_modules/codemirror/theme/abcdef.css +32 -0
  318. data/node_modules/codemirror/theme/ambiance-mobile.css +5 -0
  319. data/node_modules/codemirror/theme/ambiance.css +74 -0
  320. data/node_modules/codemirror/theme/base16-dark.css +38 -0
  321. data/node_modules/codemirror/theme/base16-light.css +38 -0
  322. data/node_modules/codemirror/theme/bespin.css +34 -0
  323. data/node_modules/codemirror/theme/blackboard.css +32 -0
  324. data/node_modules/codemirror/theme/cobalt.css +25 -0
  325. data/node_modules/codemirror/theme/colorforth.css +33 -0
  326. data/node_modules/codemirror/theme/darcula.css +46 -0
  327. data/node_modules/codemirror/theme/dracula.css +40 -0
  328. data/node_modules/codemirror/theme/duotone-dark.css +35 -0
  329. data/node_modules/codemirror/theme/duotone-light.css +36 -0
  330. data/node_modules/codemirror/theme/eclipse.css +23 -0
  331. data/node_modules/codemirror/theme/elegant.css +13 -0
  332. data/node_modules/codemirror/theme/erlang-dark.css +34 -0
  333. data/node_modules/codemirror/theme/gruvbox-dark.css +37 -0
  334. data/node_modules/codemirror/theme/hopscotch.css +34 -0
  335. data/node_modules/codemirror/theme/icecoder.css +43 -0
  336. data/node_modules/codemirror/theme/idea.css +42 -0
  337. data/node_modules/codemirror/theme/isotope.css +34 -0
  338. data/node_modules/codemirror/theme/lesser-dark.css +47 -0
  339. data/node_modules/codemirror/theme/liquibyte.css +95 -0
  340. data/node_modules/codemirror/theme/lucario.css +37 -0
  341. data/node_modules/codemirror/theme/material.css +53 -0
  342. data/node_modules/codemirror/theme/mbo.css +37 -0
  343. data/node_modules/codemirror/theme/mdn-like.css +46 -0
  344. data/node_modules/codemirror/theme/midnight.css +43 -0
  345. data/node_modules/codemirror/theme/monokai.css +41 -0
  346. data/node_modules/codemirror/theme/neat.css +12 -0
  347. data/node_modules/codemirror/theme/neo.css +43 -0
  348. data/node_modules/codemirror/theme/night.css +27 -0
  349. data/node_modules/codemirror/theme/oceanic-next.css +44 -0
  350. data/node_modules/codemirror/theme/panda-syntax.css +85 -0
  351. data/node_modules/codemirror/theme/paraiso-dark.css +38 -0
  352. data/node_modules/codemirror/theme/paraiso-light.css +38 -0
  353. data/node_modules/codemirror/theme/pastel-on-dark.css +52 -0
  354. data/node_modules/codemirror/theme/railscasts.css +34 -0
  355. data/node_modules/codemirror/theme/rubyblue.css +25 -0
  356. data/node_modules/codemirror/theme/seti.css +44 -0
  357. data/node_modules/codemirror/theme/shadowfox.css +52 -0
  358. data/node_modules/codemirror/theme/solarized.css +168 -0
  359. data/node_modules/codemirror/theme/ssms.css +16 -0
  360. data/node_modules/codemirror/theme/the-matrix.css +30 -0
  361. data/node_modules/codemirror/theme/tomorrow-night-bright.css +35 -0
  362. data/node_modules/codemirror/theme/tomorrow-night-eighties.css +38 -0
  363. data/node_modules/codemirror/theme/ttcn.css +64 -0
  364. data/node_modules/codemirror/theme/twilight.css +32 -0
  365. data/node_modules/codemirror/theme/vibrant-ink.css +34 -0
  366. data/node_modules/codemirror/theme/xq-dark.css +53 -0
  367. data/node_modules/codemirror/theme/xq-light.css +43 -0
  368. data/node_modules/codemirror/theme/yeti.css +44 -0
  369. data/node_modules/codemirror/theme/zenburn.css +37 -0
  370. data/node_modules/marked/.editorconfig +16 -0
  371. data/node_modules/marked/.eslintignore +1 -0
  372. data/node_modules/marked/.eslintrc.json +28 -0
  373. data/node_modules/marked/.package 2.json.icloud +0 -0
  374. data/node_modules/marked/.travis.yml +47 -0
  375. data/node_modules/marked/Makefile +15 -0
  376. data/node_modules/marked/Makefile 2 +15 -0
  377. data/node_modules/marked/README 2.md +75 -0
  378. data/node_modules/marked/README.md +75 -0
  379. data/node_modules/marked/bin/marked +199 -0
  380. data/node_modules/marked/bower.json +23 -0
  381. data/node_modules/marked/component.json +10 -0
  382. data/node_modules/marked/index.js +1 -0
  383. data/node_modules/marked/jasmine.json +11 -0
  384. data/node_modules/marked/lib/marked 2.js +1604 -0
  385. data/node_modules/marked/lib/marked.js +1604 -0
  386. data/node_modules/marked/man/marked.1 +91 -0
  387. data/node_modules/marked/man/marked.1.txt +96 -0
  388. data/node_modules/marked/marked.min.js +6 -0
  389. data/node_modules/marked/package.json +95 -0
  390. data/node_modules/simplemde/.eslintrc +23 -0
  391. data/node_modules/simplemde/.npmignore +9 -0
  392. data/node_modules/simplemde/.travis.yml +18 -0
  393. data/node_modules/simplemde/CONTRIBUTING 2.md +10 -0
  394. data/node_modules/simplemde/CONTRIBUTING.md +10 -0
  395. data/node_modules/simplemde/LICENSE +22 -0
  396. data/node_modules/simplemde/README.md +331 -0
  397. data/node_modules/simplemde/bower.json +23 -0
  398. data/node_modules/simplemde/debug/.simplemde 2.css.icloud +0 -0
  399. data/node_modules/simplemde/debug/simplemde.css +676 -0
  400. data/node_modules/simplemde/debug/simplemde.debug.js +17023 -0
  401. data/node_modules/simplemde/debug/simplemde.js +17019 -0
  402. data/node_modules/simplemde/dist/simplemde.min.css +7 -0
  403. data/node_modules/simplemde/dist/simplemde.min.js +15 -0
  404. data/node_modules/simplemde/gulpfile.js +96 -0
  405. data/node_modules/simplemde/package.json +73 -0
  406. data/node_modules/simplemde/src/css/simplemde.css +328 -0
  407. data/node_modules/simplemde/src/js/codemirror/tablist 2.js +44 -0
  408. data/node_modules/simplemde/src/js/codemirror/tablist.js +44 -0
  409. data/node_modules/simplemde/src/js/simplemde.js +2028 -0
  410. data/node_modules/typo-js/README.md +45 -0
  411. data/node_modules/typo-js/dictionaries/en_US/.en_US 2.dic.icloud +0 -0
  412. data/node_modules/typo-js/dictionaries/en_US/README.md +7 -0
  413. data/node_modules/typo-js/dictionaries/en_US/en_US.aff +201 -0
  414. data/node_modules/typo-js/dictionaries/en_US/en_US.dic +62120 -0
  415. data/node_modules/typo-js/package.json +56 -0
  416. data/node_modules/typo-js/typo.js +931 -0
  417. data/package-lock.json +40 -0
  418. data/package.json +7 -0
  419. metadata +557 -0
@@ -0,0 +1,61 @@
1
+ import { cmp, Pos } from "../line/pos.js"
2
+ import { lst } from "../util/misc.js"
3
+
4
+ import { normalizeSelection, Range, Selection } from "./selection.js"
5
+
6
+ // Compute the position of the end of a change (its 'to' property
7
+ // refers to the pre-change end).
8
+ export function changeEnd(change) {
9
+ if (!change.text) return change.to
10
+ return Pos(change.from.line + change.text.length - 1,
11
+ lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
12
+ }
13
+
14
+ // Adjust a position to refer to the post-change position of the
15
+ // same text, or the end of the change if the change covers it.
16
+ function adjustForChange(pos, change) {
17
+ if (cmp(pos, change.from) < 0) return pos
18
+ if (cmp(pos, change.to) <= 0) return changeEnd(change)
19
+
20
+ let line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch
21
+ if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch
22
+ return Pos(line, ch)
23
+ }
24
+
25
+ export function computeSelAfterChange(doc, change) {
26
+ let out = []
27
+ for (let i = 0; i < doc.sel.ranges.length; i++) {
28
+ let range = doc.sel.ranges[i]
29
+ out.push(new Range(adjustForChange(range.anchor, change),
30
+ adjustForChange(range.head, change)))
31
+ }
32
+ return normalizeSelection(doc.cm, out, doc.sel.primIndex)
33
+ }
34
+
35
+ function offsetPos(pos, old, nw) {
36
+ if (pos.line == old.line)
37
+ return Pos(nw.line, pos.ch - old.ch + nw.ch)
38
+ else
39
+ return Pos(nw.line + (pos.line - old.line), pos.ch)
40
+ }
41
+
42
+ // Used by replaceSelections to allow moving the selection to the
43
+ // start or around the replaced test. Hint may be "start" or "around".
44
+ export function computeReplacedSel(doc, changes, hint) {
45
+ let out = []
46
+ let oldPrev = Pos(doc.first, 0), newPrev = oldPrev
47
+ for (let i = 0; i < changes.length; i++) {
48
+ let change = changes[i]
49
+ let from = offsetPos(change.from, oldPrev, newPrev)
50
+ let to = offsetPos(changeEnd(change), oldPrev, newPrev)
51
+ oldPrev = change.to
52
+ newPrev = to
53
+ if (hint == "around") {
54
+ let range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0
55
+ out[i] = new Range(inv ? to : from, inv ? from : to)
56
+ } else {
57
+ out[i] = new Range(from, from)
58
+ }
59
+ }
60
+ return new Selection(out, doc.sel.primIndex)
61
+ }
@@ -0,0 +1,333 @@
1
+ import { retreatFrontier } from "../line/highlight.js"
2
+ import { startWorker } from "../display/highlight_worker.js"
3
+ import { operation } from "../display/operations.js"
4
+ import { regChange, regLineChange } from "../display/view_tracking.js"
5
+ import { clipLine, clipPos, cmp, Pos } from "../line/pos.js"
6
+ import { sawReadOnlySpans } from "../line/saw_special_spans.js"
7
+ import { lineLength, removeReadOnlyRanges, stretchSpansOverChange, visualLine } from "../line/spans.js"
8
+ import { getBetween, getLine, lineNo } from "../line/utils_line.js"
9
+ import { estimateHeight } from "../measurement/position_measurement.js"
10
+ import { hasHandler, signal, signalCursorActivity } from "../util/event.js"
11
+ import { indexOf, lst, map, sel_dontScroll } from "../util/misc.js"
12
+ import { signalLater } from "../util/operation_group.js"
13
+
14
+ import { changeEnd, computeSelAfterChange } from "./change_measurement.js"
15
+ import { isWholeLineUpdate, linkedDocs, updateDoc } from "./document_data.js"
16
+ import { addChangeToHistory, historyChangeFromChange, mergeOldSpans, pushSelectionToHistory } from "./history.js"
17
+ import { Range, Selection } from "./selection.js"
18
+ import { setSelection, setSelectionNoUndo } from "./selection_updates.js"
19
+
20
+ // UPDATING
21
+
22
+ // Allow "beforeChange" event handlers to influence a change
23
+ function filterChange(doc, change, update) {
24
+ let obj = {
25
+ canceled: false,
26
+ from: change.from,
27
+ to: change.to,
28
+ text: change.text,
29
+ origin: change.origin,
30
+ cancel: () => obj.canceled = true
31
+ }
32
+ if (update) obj.update = (from, to, text, origin) => {
33
+ if (from) obj.from = clipPos(doc, from)
34
+ if (to) obj.to = clipPos(doc, to)
35
+ if (text) obj.text = text
36
+ if (origin !== undefined) obj.origin = origin
37
+ }
38
+ signal(doc, "beforeChange", doc, obj)
39
+ if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj)
40
+
41
+ if (obj.canceled) return null
42
+ return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
43
+ }
44
+
45
+ // Apply a change to a document, and add it to the document's
46
+ // history, and propagating it to all linked documents.
47
+ export function makeChange(doc, change, ignoreReadOnly) {
48
+ if (doc.cm) {
49
+ if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly)
50
+ if (doc.cm.state.suppressEdits) return
51
+ }
52
+
53
+ if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
54
+ change = filterChange(doc, change, true)
55
+ if (!change) return
56
+ }
57
+
58
+ // Possibly split or suppress the update based on the presence
59
+ // of read-only spans in its range.
60
+ let split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
61
+ if (split) {
62
+ for (let i = split.length - 1; i >= 0; --i)
63
+ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin})
64
+ } else {
65
+ makeChangeInner(doc, change)
66
+ }
67
+ }
68
+
69
+ function makeChangeInner(doc, change) {
70
+ if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return
71
+ let selAfter = computeSelAfterChange(doc, change)
72
+ addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN)
73
+
74
+ makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change))
75
+ let rebased = []
76
+
77
+ linkedDocs(doc, (doc, sharedHist) => {
78
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
79
+ rebaseHist(doc.history, change)
80
+ rebased.push(doc.history)
81
+ }
82
+ makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change))
83
+ })
84
+ }
85
+
86
+ // Revert a change stored in a document's history.
87
+ export function makeChangeFromHistory(doc, type, allowSelectionOnly) {
88
+ let suppress = doc.cm && doc.cm.state.suppressEdits
89
+ if (suppress && !allowSelectionOnly) return
90
+
91
+ let hist = doc.history, event, selAfter = doc.sel
92
+ let source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done
93
+
94
+ // Verify that there is a useable event (so that ctrl-z won't
95
+ // needlessly clear selection events)
96
+ let i = 0
97
+ for (; i < source.length; i++) {
98
+ event = source[i]
99
+ if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
100
+ break
101
+ }
102
+ if (i == source.length) return
103
+ hist.lastOrigin = hist.lastSelOrigin = null
104
+
105
+ for (;;) {
106
+ event = source.pop()
107
+ if (event.ranges) {
108
+ pushSelectionToHistory(event, dest)
109
+ if (allowSelectionOnly && !event.equals(doc.sel)) {
110
+ setSelection(doc, event, {clearRedo: false})
111
+ return
112
+ }
113
+ selAfter = event
114
+ } else if (suppress) {
115
+ source.push(event)
116
+ return
117
+ } else break
118
+ }
119
+
120
+ // Build up a reverse change object to add to the opposite history
121
+ // stack (redo when undoing, and vice versa).
122
+ let antiChanges = []
123
+ pushSelectionToHistory(selAfter, dest)
124
+ dest.push({changes: antiChanges, generation: hist.generation})
125
+ hist.generation = event.generation || ++hist.maxGeneration
126
+
127
+ let filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")
128
+
129
+ for (let i = event.changes.length - 1; i >= 0; --i) {
130
+ let change = event.changes[i]
131
+ change.origin = type
132
+ if (filter && !filterChange(doc, change, false)) {
133
+ source.length = 0
134
+ return
135
+ }
136
+
137
+ antiChanges.push(historyChangeFromChange(doc, change))
138
+
139
+ let after = i ? computeSelAfterChange(doc, change) : lst(source)
140
+ makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change))
141
+ if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)})
142
+ let rebased = []
143
+
144
+ // Propagate to the linked documents
145
+ linkedDocs(doc, (doc, sharedHist) => {
146
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
147
+ rebaseHist(doc.history, change)
148
+ rebased.push(doc.history)
149
+ }
150
+ makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change))
151
+ })
152
+ }
153
+ }
154
+
155
+ // Sub-views need their line numbers shifted when text is added
156
+ // above or below them in the parent document.
157
+ function shiftDoc(doc, distance) {
158
+ if (distance == 0) return
159
+ doc.first += distance
160
+ doc.sel = new Selection(map(doc.sel.ranges, range => new Range(
161
+ Pos(range.anchor.line + distance, range.anchor.ch),
162
+ Pos(range.head.line + distance, range.head.ch)
163
+ )), doc.sel.primIndex)
164
+ if (doc.cm) {
165
+ regChange(doc.cm, doc.first, doc.first - distance, distance)
166
+ for (let d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
167
+ regLineChange(doc.cm, l, "gutter")
168
+ }
169
+ }
170
+
171
+ // More lower-level change function, handling only a single document
172
+ // (not linked ones).
173
+ function makeChangeSingleDoc(doc, change, selAfter, spans) {
174
+ if (doc.cm && !doc.cm.curOp)
175
+ return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans)
176
+
177
+ if (change.to.line < doc.first) {
178
+ shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line))
179
+ return
180
+ }
181
+ if (change.from.line > doc.lastLine()) return
182
+
183
+ // Clip the change to the size of this doc
184
+ if (change.from.line < doc.first) {
185
+ let shift = change.text.length - 1 - (doc.first - change.from.line)
186
+ shiftDoc(doc, shift)
187
+ change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
188
+ text: [lst(change.text)], origin: change.origin}
189
+ }
190
+ let last = doc.lastLine()
191
+ if (change.to.line > last) {
192
+ change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
193
+ text: [change.text[0]], origin: change.origin}
194
+ }
195
+
196
+ change.removed = getBetween(doc, change.from, change.to)
197
+
198
+ if (!selAfter) selAfter = computeSelAfterChange(doc, change)
199
+ if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans)
200
+ else updateDoc(doc, change, spans)
201
+ setSelectionNoUndo(doc, selAfter, sel_dontScroll)
202
+ }
203
+
204
+ // Handle the interaction of a change to a document with the editor
205
+ // that this document is part of.
206
+ function makeChangeSingleDocInEditor(cm, change, spans) {
207
+ let doc = cm.doc, display = cm.display, from = change.from, to = change.to
208
+
209
+ let recomputeMaxLength = false, checkWidthStart = from.line
210
+ if (!cm.options.lineWrapping) {
211
+ checkWidthStart = lineNo(visualLine(getLine(doc, from.line)))
212
+ doc.iter(checkWidthStart, to.line + 1, line => {
213
+ if (line == display.maxLine) {
214
+ recomputeMaxLength = true
215
+ return true
216
+ }
217
+ })
218
+ }
219
+
220
+ if (doc.sel.contains(change.from, change.to) > -1)
221
+ signalCursorActivity(cm)
222
+
223
+ updateDoc(doc, change, spans, estimateHeight(cm))
224
+
225
+ if (!cm.options.lineWrapping) {
226
+ doc.iter(checkWidthStart, from.line + change.text.length, line => {
227
+ let len = lineLength(line)
228
+ if (len > display.maxLineLength) {
229
+ display.maxLine = line
230
+ display.maxLineLength = len
231
+ display.maxLineChanged = true
232
+ recomputeMaxLength = false
233
+ }
234
+ })
235
+ if (recomputeMaxLength) cm.curOp.updateMaxLine = true
236
+ }
237
+
238
+ retreatFrontier(doc, from.line)
239
+ startWorker(cm, 400)
240
+
241
+ let lendiff = change.text.length - (to.line - from.line) - 1
242
+ // Remember that these lines changed, for updating the display
243
+ if (change.full)
244
+ regChange(cm)
245
+ else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
246
+ regLineChange(cm, from.line, "text")
247
+ else
248
+ regChange(cm, from.line, to.line + 1, lendiff)
249
+
250
+ let changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change")
251
+ if (changeHandler || changesHandler) {
252
+ let obj = {
253
+ from: from, to: to,
254
+ text: change.text,
255
+ removed: change.removed,
256
+ origin: change.origin
257
+ }
258
+ if (changeHandler) signalLater(cm, "change", cm, obj)
259
+ if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj)
260
+ }
261
+ cm.display.selForContextMenu = null
262
+ }
263
+
264
+ export function replaceRange(doc, code, from, to, origin) {
265
+ if (!to) to = from
266
+ if (cmp(to, from) < 0) [from, to] = [to, from]
267
+ if (typeof code == "string") code = doc.splitLines(code)
268
+ makeChange(doc, {from, to, text: code, origin})
269
+ }
270
+
271
+ // Rebasing/resetting history to deal with externally-sourced changes
272
+
273
+ function rebaseHistSelSingle(pos, from, to, diff) {
274
+ if (to < pos.line) {
275
+ pos.line += diff
276
+ } else if (from < pos.line) {
277
+ pos.line = from
278
+ pos.ch = 0
279
+ }
280
+ }
281
+
282
+ // Tries to rebase an array of history events given a change in the
283
+ // document. If the change touches the same lines as the event, the
284
+ // event, and everything 'behind' it, is discarded. If the change is
285
+ // before the event, the event's positions are updated. Uses a
286
+ // copy-on-write scheme for the positions, to avoid having to
287
+ // reallocate them all on every rebase, but also avoid problems with
288
+ // shared position objects being unsafely updated.
289
+ function rebaseHistArray(array, from, to, diff) {
290
+ for (let i = 0; i < array.length; ++i) {
291
+ let sub = array[i], ok = true
292
+ if (sub.ranges) {
293
+ if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true }
294
+ for (let j = 0; j < sub.ranges.length; j++) {
295
+ rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)
296
+ rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)
297
+ }
298
+ continue
299
+ }
300
+ for (let j = 0; j < sub.changes.length; ++j) {
301
+ let cur = sub.changes[j]
302
+ if (to < cur.from.line) {
303
+ cur.from = Pos(cur.from.line + diff, cur.from.ch)
304
+ cur.to = Pos(cur.to.line + diff, cur.to.ch)
305
+ } else if (from <= cur.to.line) {
306
+ ok = false
307
+ break
308
+ }
309
+ }
310
+ if (!ok) {
311
+ array.splice(0, i + 1)
312
+ i = 0
313
+ }
314
+ }
315
+ }
316
+
317
+ function rebaseHist(hist, change) {
318
+ let from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1
319
+ rebaseHistArray(hist.done, from, to, diff)
320
+ rebaseHistArray(hist.undone, from, to, diff)
321
+ }
322
+
323
+ // Utility for applying a change to a line by handle or number,
324
+ // returning the number and optionally registering the line as
325
+ // changed.
326
+ export function changeLine(doc, handle, changeType, op) {
327
+ let no = handle, line = handle
328
+ if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle))
329
+ else no = lineNo(handle)
330
+ if (no == null) return null
331
+ if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType)
332
+ return line
333
+ }
@@ -0,0 +1,167 @@
1
+ import { cleanUpLine } from "../line/line_data.js"
2
+ import { indexOf } from "../util/misc.js"
3
+ import { signalLater } from "../util/operation_group.js"
4
+
5
+ // The document is represented as a BTree consisting of leaves, with
6
+ // chunk of lines in them, and branches, with up to ten leaves or
7
+ // other branch nodes below them. The top node is always a branch
8
+ // node, and is the document object itself (meaning it has
9
+ // additional methods and properties).
10
+ //
11
+ // All nodes have parent links. The tree is used both to go from
12
+ // line numbers to line objects, and to go from objects to numbers.
13
+ // It also indexes by height, and is used to convert between height
14
+ // and line object, and to find the total height of the document.
15
+ //
16
+ // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
17
+
18
+ export function LeafChunk(lines) {
19
+ this.lines = lines
20
+ this.parent = null
21
+ let height = 0
22
+ for (let i = 0; i < lines.length; ++i) {
23
+ lines[i].parent = this
24
+ height += lines[i].height
25
+ }
26
+ this.height = height
27
+ }
28
+
29
+ LeafChunk.prototype = {
30
+ chunkSize() { return this.lines.length },
31
+
32
+ // Remove the n lines at offset 'at'.
33
+ removeInner(at, n) {
34
+ for (let i = at, e = at + n; i < e; ++i) {
35
+ let line = this.lines[i]
36
+ this.height -= line.height
37
+ cleanUpLine(line)
38
+ signalLater(line, "delete")
39
+ }
40
+ this.lines.splice(at, n)
41
+ },
42
+
43
+ // Helper used to collapse a small branch into a single leaf.
44
+ collapse(lines) {
45
+ lines.push.apply(lines, this.lines)
46
+ },
47
+
48
+ // Insert the given array of lines at offset 'at', count them as
49
+ // having the given height.
50
+ insertInner(at, lines, height) {
51
+ this.height += height
52
+ this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))
53
+ for (let i = 0; i < lines.length; ++i) lines[i].parent = this
54
+ },
55
+
56
+ // Used to iterate over a part of the tree.
57
+ iterN(at, n, op) {
58
+ for (let e = at + n; at < e; ++at)
59
+ if (op(this.lines[at])) return true
60
+ }
61
+ }
62
+
63
+ export function BranchChunk(children) {
64
+ this.children = children
65
+ let size = 0, height = 0
66
+ for (let i = 0; i < children.length; ++i) {
67
+ let ch = children[i]
68
+ size += ch.chunkSize(); height += ch.height
69
+ ch.parent = this
70
+ }
71
+ this.size = size
72
+ this.height = height
73
+ this.parent = null
74
+ }
75
+
76
+ BranchChunk.prototype = {
77
+ chunkSize() { return this.size },
78
+
79
+ removeInner(at, n) {
80
+ this.size -= n
81
+ for (let i = 0; i < this.children.length; ++i) {
82
+ let child = this.children[i], sz = child.chunkSize()
83
+ if (at < sz) {
84
+ let rm = Math.min(n, sz - at), oldHeight = child.height
85
+ child.removeInner(at, rm)
86
+ this.height -= oldHeight - child.height
87
+ if (sz == rm) { this.children.splice(i--, 1); child.parent = null }
88
+ if ((n -= rm) == 0) break
89
+ at = 0
90
+ } else at -= sz
91
+ }
92
+ // If the result is smaller than 25 lines, ensure that it is a
93
+ // single leaf node.
94
+ if (this.size - n < 25 &&
95
+ (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
96
+ let lines = []
97
+ this.collapse(lines)
98
+ this.children = [new LeafChunk(lines)]
99
+ this.children[0].parent = this
100
+ }
101
+ },
102
+
103
+ collapse(lines) {
104
+ for (let i = 0; i < this.children.length; ++i) this.children[i].collapse(lines)
105
+ },
106
+
107
+ insertInner(at, lines, height) {
108
+ this.size += lines.length
109
+ this.height += height
110
+ for (let i = 0; i < this.children.length; ++i) {
111
+ let child = this.children[i], sz = child.chunkSize()
112
+ if (at <= sz) {
113
+ child.insertInner(at, lines, height)
114
+ if (child.lines && child.lines.length > 50) {
115
+ // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
116
+ // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
117
+ let remaining = child.lines.length % 25 + 25
118
+ for (let pos = remaining; pos < child.lines.length;) {
119
+ let leaf = new LeafChunk(child.lines.slice(pos, pos += 25))
120
+ child.height -= leaf.height
121
+ this.children.splice(++i, 0, leaf)
122
+ leaf.parent = this
123
+ }
124
+ child.lines = child.lines.slice(0, remaining)
125
+ this.maybeSpill()
126
+ }
127
+ break
128
+ }
129
+ at -= sz
130
+ }
131
+ },
132
+
133
+ // When a node has grown, check whether it should be split.
134
+ maybeSpill() {
135
+ if (this.children.length <= 10) return
136
+ let me = this
137
+ do {
138
+ let spilled = me.children.splice(me.children.length - 5, 5)
139
+ let sibling = new BranchChunk(spilled)
140
+ if (!me.parent) { // Become the parent node
141
+ let copy = new BranchChunk(me.children)
142
+ copy.parent = me
143
+ me.children = [copy, sibling]
144
+ me = copy
145
+ } else {
146
+ me.size -= sibling.size
147
+ me.height -= sibling.height
148
+ let myIndex = indexOf(me.parent.children, me)
149
+ me.parent.children.splice(myIndex + 1, 0, sibling)
150
+ }
151
+ sibling.parent = me.parent
152
+ } while (me.children.length > 10)
153
+ me.parent.maybeSpill()
154
+ },
155
+
156
+ iterN(at, n, op) {
157
+ for (let i = 0; i < this.children.length; ++i) {
158
+ let child = this.children[i], sz = child.chunkSize()
159
+ if (at < sz) {
160
+ let used = Math.min(n, sz - at)
161
+ if (child.iterN(at, used, op)) return true
162
+ if ((n -= used) == 0) break
163
+ at = 0
164
+ } else at -= sz
165
+ }
166
+ }
167
+ }