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,355 @@
1
+ import { operation, runInOp } from "../display/operations.js"
2
+ import { prepareSelection } from "../display/selection.js"
3
+ import { applyTextInput, copyableRanges, handlePaste, hiddenTextarea, setLastCopied } from "./input.js"
4
+ import { cursorCoords, posFromMouse } from "../measurement/position_measurement.js"
5
+ import { eventInWidget } from "../measurement/widgets.js"
6
+ import { simpleSelection } from "../model/selection.js"
7
+ import { selectAll, setSelection } from "../model/selection_updates.js"
8
+ import { captureRightClick, ie, ie_version, ios, mac, mobile, presto, webkit } from "../util/browser.js"
9
+ import { activeElt, removeChildrenAndAdd, selectInput } from "../util/dom.js"
10
+ import { e_preventDefault, e_stop, off, on, signalDOMEvent } from "../util/event.js"
11
+ import { hasSelection } from "../util/feature_detection.js"
12
+ import { Delayed, sel_dontScroll } from "../util/misc.js"
13
+
14
+ // TEXTAREA INPUT STYLE
15
+
16
+ export default class TextareaInput {
17
+ constructor(cm) {
18
+ this.cm = cm
19
+ // See input.poll and input.reset
20
+ this.prevInput = ""
21
+
22
+ // Flag that indicates whether we expect input to appear real soon
23
+ // now (after some event like 'keypress' or 'input') and are
24
+ // polling intensively.
25
+ this.pollingFast = false
26
+ // Self-resetting timeout for the poller
27
+ this.polling = new Delayed()
28
+ // Used to work around IE issue with selection being forgotten when focus moves away from textarea
29
+ this.hasSelection = false
30
+ this.composing = null
31
+ }
32
+
33
+ init(display) {
34
+ let input = this, cm = this.cm
35
+ this.createField(display)
36
+ const te = this.textarea
37
+
38
+ display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild)
39
+
40
+ // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
41
+ if (ios) te.style.width = "0px"
42
+
43
+ on(te, "input", () => {
44
+ if (ie && ie_version >= 9 && this.hasSelection) this.hasSelection = null
45
+ input.poll()
46
+ })
47
+
48
+ on(te, "paste", e => {
49
+ if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
50
+
51
+ cm.state.pasteIncoming = true
52
+ input.fastPoll()
53
+ })
54
+
55
+ function prepareCopyCut(e) {
56
+ if (signalDOMEvent(cm, e)) return
57
+ if (cm.somethingSelected()) {
58
+ setLastCopied({lineWise: false, text: cm.getSelections()})
59
+ } else if (!cm.options.lineWiseCopyCut) {
60
+ return
61
+ } else {
62
+ let ranges = copyableRanges(cm)
63
+ setLastCopied({lineWise: true, text: ranges.text})
64
+ if (e.type == "cut") {
65
+ cm.setSelections(ranges.ranges, null, sel_dontScroll)
66
+ } else {
67
+ input.prevInput = ""
68
+ te.value = ranges.text.join("\n")
69
+ selectInput(te)
70
+ }
71
+ }
72
+ if (e.type == "cut") cm.state.cutIncoming = true
73
+ }
74
+ on(te, "cut", prepareCopyCut)
75
+ on(te, "copy", prepareCopyCut)
76
+
77
+ on(display.scroller, "paste", e => {
78
+ if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return
79
+ cm.state.pasteIncoming = true
80
+ input.focus()
81
+ })
82
+
83
+ // Prevent normal selection in the editor (we handle our own)
84
+ on(display.lineSpace, "selectstart", e => {
85
+ if (!eventInWidget(display, e)) e_preventDefault(e)
86
+ })
87
+
88
+ on(te, "compositionstart", () => {
89
+ let start = cm.getCursor("from")
90
+ if (input.composing) input.composing.range.clear()
91
+ input.composing = {
92
+ start: start,
93
+ range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
94
+ }
95
+ })
96
+ on(te, "compositionend", () => {
97
+ if (input.composing) {
98
+ input.poll()
99
+ input.composing.range.clear()
100
+ input.composing = null
101
+ }
102
+ })
103
+ }
104
+
105
+ createField(_display) {
106
+ // Wraps and hides input textarea
107
+ this.wrapper = hiddenTextarea()
108
+ // The semihidden textarea that is focused when the editor is
109
+ // focused, and receives input.
110
+ this.textarea = this.wrapper.firstChild
111
+ }
112
+
113
+ prepareSelection() {
114
+ // Redraw the selection and/or cursor
115
+ let cm = this.cm, display = cm.display, doc = cm.doc
116
+ let result = prepareSelection(cm)
117
+
118
+ // Move the hidden textarea near the cursor to prevent scrolling artifacts
119
+ if (cm.options.moveInputWithCursor) {
120
+ let headPos = cursorCoords(cm, doc.sel.primary().head, "div")
121
+ let wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect()
122
+ result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
123
+ headPos.top + lineOff.top - wrapOff.top))
124
+ result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
125
+ headPos.left + lineOff.left - wrapOff.left))
126
+ }
127
+
128
+ return result
129
+ }
130
+
131
+ showSelection(drawn) {
132
+ let cm = this.cm, display = cm.display
133
+ removeChildrenAndAdd(display.cursorDiv, drawn.cursors)
134
+ removeChildrenAndAdd(display.selectionDiv, drawn.selection)
135
+ if (drawn.teTop != null) {
136
+ this.wrapper.style.top = drawn.teTop + "px"
137
+ this.wrapper.style.left = drawn.teLeft + "px"
138
+ }
139
+ }
140
+
141
+ // Reset the input to correspond to the selection (or to be empty,
142
+ // when not typing and nothing is selected)
143
+ reset(typing) {
144
+ if (this.contextMenuPending || this.composing) return
145
+ let cm = this.cm
146
+ if (cm.somethingSelected()) {
147
+ this.prevInput = ""
148
+ let content = cm.getSelection()
149
+ this.textarea.value = content
150
+ if (cm.state.focused) selectInput(this.textarea)
151
+ if (ie && ie_version >= 9) this.hasSelection = content
152
+ } else if (!typing) {
153
+ this.prevInput = this.textarea.value = ""
154
+ if (ie && ie_version >= 9) this.hasSelection = null
155
+ }
156
+ }
157
+
158
+ getField() { return this.textarea }
159
+
160
+ supportsTouch() { return false }
161
+
162
+ focus() {
163
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
164
+ try { this.textarea.focus() }
165
+ catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
166
+ }
167
+ }
168
+
169
+ blur() { this.textarea.blur() }
170
+
171
+ resetPosition() {
172
+ this.wrapper.style.top = this.wrapper.style.left = 0
173
+ }
174
+
175
+ receivedFocus() { this.slowPoll() }
176
+
177
+ // Poll for input changes, using the normal rate of polling. This
178
+ // runs as long as the editor is focused.
179
+ slowPoll() {
180
+ if (this.pollingFast) return
181
+ this.polling.set(this.cm.options.pollInterval, () => {
182
+ this.poll()
183
+ if (this.cm.state.focused) this.slowPoll()
184
+ })
185
+ }
186
+
187
+ // When an event has just come in that is likely to add or change
188
+ // something in the input textarea, we poll faster, to ensure that
189
+ // the change appears on the screen quickly.
190
+ fastPoll() {
191
+ let missed = false, input = this
192
+ input.pollingFast = true
193
+ function p() {
194
+ let changed = input.poll()
195
+ if (!changed && !missed) {missed = true; input.polling.set(60, p)}
196
+ else {input.pollingFast = false; input.slowPoll()}
197
+ }
198
+ input.polling.set(20, p)
199
+ }
200
+
201
+ // Read input from the textarea, and update the document to match.
202
+ // When something is selected, it is present in the textarea, and
203
+ // selected (unless it is huge, in which case a placeholder is
204
+ // used). When nothing is selected, the cursor sits after previously
205
+ // seen text (can be empty), which is stored in prevInput (we must
206
+ // not reset the textarea when typing, because that breaks IME).
207
+ poll() {
208
+ let cm = this.cm, input = this.textarea, prevInput = this.prevInput
209
+ // Since this is called a *lot*, try to bail out as cheaply as
210
+ // possible when it is clear that nothing happened. hasSelection
211
+ // will be the case when there is a lot of text in the textarea,
212
+ // in which case reading its value would be expensive.
213
+ if (this.contextMenuPending || !cm.state.focused ||
214
+ (hasSelection(input) && !prevInput && !this.composing) ||
215
+ cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
216
+ return false
217
+
218
+ let text = input.value
219
+ // If nothing changed, bail.
220
+ if (text == prevInput && !cm.somethingSelected()) return false
221
+ // Work around nonsensical selection resetting in IE9/10, and
222
+ // inexplicable appearance of private area unicode characters on
223
+ // some key combos in Mac (#2689).
224
+ if (ie && ie_version >= 9 && this.hasSelection === text ||
225
+ mac && /[\uf700-\uf7ff]/.test(text)) {
226
+ cm.display.input.reset()
227
+ return false
228
+ }
229
+
230
+ if (cm.doc.sel == cm.display.selForContextMenu) {
231
+ let first = text.charCodeAt(0)
232
+ if (first == 0x200b && !prevInput) prevInput = "\u200b"
233
+ if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
234
+ }
235
+ // Find the part of the input that is actually new
236
+ let same = 0, l = Math.min(prevInput.length, text.length)
237
+ while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same
238
+
239
+ runInOp(cm, () => {
240
+ applyTextInput(cm, text.slice(same), prevInput.length - same,
241
+ null, this.composing ? "*compose" : null)
242
+
243
+ // Don't leave long text in the textarea, since it makes further polling slow
244
+ if (text.length > 1000 || text.indexOf("\n") > -1) input.value = this.prevInput = ""
245
+ else this.prevInput = text
246
+
247
+ if (this.composing) {
248
+ this.composing.range.clear()
249
+ this.composing.range = cm.markText(this.composing.start, cm.getCursor("to"),
250
+ {className: "CodeMirror-composing"})
251
+ }
252
+ })
253
+ return true
254
+ }
255
+
256
+ ensurePolled() {
257
+ if (this.pollingFast && this.poll()) this.pollingFast = false
258
+ }
259
+
260
+ onKeyPress() {
261
+ if (ie && ie_version >= 9) this.hasSelection = null
262
+ this.fastPoll()
263
+ }
264
+
265
+ onContextMenu(e) {
266
+ let input = this, cm = input.cm, display = cm.display, te = input.textarea
267
+ let pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop
268
+ if (!pos || presto) return // Opera is difficult.
269
+
270
+ // Reset the current text selection only if the click is done outside of the selection
271
+ // and 'resetSelectionOnContextMenu' option is true.
272
+ let reset = cm.options.resetSelectionOnContextMenu
273
+ if (reset && cm.doc.sel.contains(pos) == -1)
274
+ operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll)
275
+
276
+ let oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText
277
+ input.wrapper.style.cssText = "position: absolute"
278
+ let wrapperBox = input.wrapper.getBoundingClientRect()
279
+ te.style.cssText = `position: absolute; width: 30px; height: 30px;
280
+ top: ${e.clientY - wrapperBox.top - 5}px; left: ${e.clientX - wrapperBox.left - 5}px;
281
+ z-index: 1000; background: ${ie ? "rgba(255, 255, 255, .05)" : "transparent"};
282
+ outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`
283
+ let oldScrollY
284
+ if (webkit) oldScrollY = window.scrollY // Work around Chrome issue (#2712)
285
+ display.input.focus()
286
+ if (webkit) window.scrollTo(null, oldScrollY)
287
+ display.input.reset()
288
+ // Adds "Select all" to context menu in FF
289
+ if (!cm.somethingSelected()) te.value = input.prevInput = " "
290
+ input.contextMenuPending = true
291
+ display.selForContextMenu = cm.doc.sel
292
+ clearTimeout(display.detectingSelectAll)
293
+
294
+ // Select-all will be greyed out if there's nothing to select, so
295
+ // this adds a zero-width space so that we can later check whether
296
+ // it got selected.
297
+ function prepareSelectAllHack() {
298
+ if (te.selectionStart != null) {
299
+ let selected = cm.somethingSelected()
300
+ let extval = "\u200b" + (selected ? te.value : "")
301
+ te.value = "\u21da" // Used to catch context-menu undo
302
+ te.value = extval
303
+ input.prevInput = selected ? "" : "\u200b"
304
+ te.selectionStart = 1; te.selectionEnd = extval.length
305
+ // Re-set this, in case some other handler touched the
306
+ // selection in the meantime.
307
+ display.selForContextMenu = cm.doc.sel
308
+ }
309
+ }
310
+ function rehide() {
311
+ input.contextMenuPending = false
312
+ input.wrapper.style.cssText = oldWrapperCSS
313
+ te.style.cssText = oldCSS
314
+ if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos)
315
+
316
+ // Try to detect the user choosing select-all
317
+ if (te.selectionStart != null) {
318
+ if (!ie || (ie && ie_version < 9)) prepareSelectAllHack()
319
+ let i = 0, poll = () => {
320
+ if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
321
+ te.selectionEnd > 0 && input.prevInput == "\u200b") {
322
+ operation(cm, selectAll)(cm)
323
+ } else if (i++ < 10) {
324
+ display.detectingSelectAll = setTimeout(poll, 500)
325
+ } else {
326
+ display.selForContextMenu = null
327
+ display.input.reset()
328
+ }
329
+ }
330
+ display.detectingSelectAll = setTimeout(poll, 200)
331
+ }
332
+ }
333
+
334
+ if (ie && ie_version >= 9) prepareSelectAllHack()
335
+ if (captureRightClick) {
336
+ e_stop(e)
337
+ let mouseup = () => {
338
+ off(window, "mouseup", mouseup)
339
+ setTimeout(rehide, 20)
340
+ }
341
+ on(window, "mouseup", mouseup)
342
+ } else {
343
+ setTimeout(rehide, 50)
344
+ }
345
+ }
346
+
347
+ readOnlyChanged(val) {
348
+ if (!val) this.reset()
349
+ this.textarea.disabled = val == "nocursor"
350
+ }
351
+
352
+ setUneditable() {}
353
+ }
354
+
355
+ TextareaInput.prototype.needsContentAttribute = false
@@ -0,0 +1,71 @@
1
+ import { getContextBefore } from "../line/highlight.js"
2
+ import { Pos } from "../line/pos.js"
3
+ import { getLine } from "../line/utils_line.js"
4
+ import { replaceRange } from "../model/changes.js"
5
+ import { Range } from "../model/selection.js"
6
+ import { replaceOneSelection } from "../model/selection_updates.js"
7
+ import { countColumn, Pass, spaceStr } from "../util/misc.js"
8
+
9
+ // Indent the given line. The how parameter can be "smart",
10
+ // "add"/null, "subtract", or "prev". When aggressive is false
11
+ // (typically set to true for forced single-line indents), empty
12
+ // lines are not indented, and places where the mode returns Pass
13
+ // are left alone.
14
+ export function indentLine(cm, n, how, aggressive) {
15
+ let doc = cm.doc, state
16
+ if (how == null) how = "add"
17
+ if (how == "smart") {
18
+ // Fall back to "prev" when the mode doesn't have an indentation
19
+ // method.
20
+ if (!doc.mode.indent) how = "prev"
21
+ else state = getContextBefore(cm, n).state
22
+ }
23
+
24
+ let tabSize = cm.options.tabSize
25
+ let line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize)
26
+ if (line.stateAfter) line.stateAfter = null
27
+ let curSpaceString = line.text.match(/^\s*/)[0], indentation
28
+ if (!aggressive && !/\S/.test(line.text)) {
29
+ indentation = 0
30
+ how = "not"
31
+ } else if (how == "smart") {
32
+ indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text)
33
+ if (indentation == Pass || indentation > 150) {
34
+ if (!aggressive) return
35
+ how = "prev"
36
+ }
37
+ }
38
+ if (how == "prev") {
39
+ if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize)
40
+ else indentation = 0
41
+ } else if (how == "add") {
42
+ indentation = curSpace + cm.options.indentUnit
43
+ } else if (how == "subtract") {
44
+ indentation = curSpace - cm.options.indentUnit
45
+ } else if (typeof how == "number") {
46
+ indentation = curSpace + how
47
+ }
48
+ indentation = Math.max(0, indentation)
49
+
50
+ let indentString = "", pos = 0
51
+ if (cm.options.indentWithTabs)
52
+ for (let i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t"}
53
+ if (pos < indentation) indentString += spaceStr(indentation - pos)
54
+
55
+ if (indentString != curSpaceString) {
56
+ replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input")
57
+ line.stateAfter = null
58
+ return true
59
+ } else {
60
+ // Ensure that, if the cursor was in the whitespace at the start
61
+ // of the line, it is moved to the end of that space.
62
+ for (let i = 0; i < doc.sel.ranges.length; i++) {
63
+ let range = doc.sel.ranges[i]
64
+ if (range.head.line == n && range.head.ch < curSpaceString.length) {
65
+ let pos = Pos(n, curSpaceString.length)
66
+ replaceOneSelection(doc, i, new Range(pos, pos))
67
+ break
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,135 @@
1
+ import { runInOp } from "../display/operations.js"
2
+ import { ensureCursorVisible } from "../display/scrolling.js"
3
+ import { Pos } from "../line/pos.js"
4
+ import { getLine } from "../line/utils_line.js"
5
+ import { makeChange } from "../model/changes.js"
6
+ import { ios, webkit } from "../util/browser.js"
7
+ import { elt } from "../util/dom.js"
8
+ import { lst, map } from "../util/misc.js"
9
+ import { signalLater } from "../util/operation_group.js"
10
+ import { splitLinesAuto } from "../util/feature_detection.js"
11
+
12
+ import { indentLine } from "./indent.js"
13
+
14
+ // This will be set to a {lineWise: bool, text: [string]} object, so
15
+ // that, when pasting, we know what kind of selections the copied
16
+ // text was made out of.
17
+ export let lastCopied = null
18
+
19
+ export function setLastCopied(newLastCopied) {
20
+ lastCopied = newLastCopied
21
+ }
22
+
23
+ export function applyTextInput(cm, inserted, deleted, sel, origin) {
24
+ let doc = cm.doc
25
+ cm.display.shift = false
26
+ if (!sel) sel = doc.sel
27
+
28
+ let paste = cm.state.pasteIncoming || origin == "paste"
29
+ let textLines = splitLinesAuto(inserted), multiPaste = null
30
+ // When pasting N lines into N selections, insert one line per selection
31
+ if (paste && sel.ranges.length > 1) {
32
+ if (lastCopied && lastCopied.text.join("\n") == inserted) {
33
+ if (sel.ranges.length % lastCopied.text.length == 0) {
34
+ multiPaste = []
35
+ for (let i = 0; i < lastCopied.text.length; i++)
36
+ multiPaste.push(doc.splitLines(lastCopied.text[i]))
37
+ }
38
+ } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
39
+ multiPaste = map(textLines, l => [l])
40
+ }
41
+ }
42
+
43
+ let updateInput
44
+ // Normal behavior is to insert the new text into every selection
45
+ for (let i = sel.ranges.length - 1; i >= 0; i--) {
46
+ let range = sel.ranges[i]
47
+ let from = range.from(), to = range.to()
48
+ if (range.empty()) {
49
+ if (deleted && deleted > 0) // Handle deletion
50
+ from = Pos(from.line, from.ch - deleted)
51
+ else if (cm.state.overwrite && !paste) // Handle overwrite
52
+ to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length))
53
+ else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
54
+ from = to = Pos(from.line, 0)
55
+ }
56
+ updateInput = cm.curOp.updateInput
57
+ let changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
58
+ origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")}
59
+ makeChange(cm.doc, changeEvent)
60
+ signalLater(cm, "inputRead", cm, changeEvent)
61
+ }
62
+ if (inserted && !paste)
63
+ triggerElectric(cm, inserted)
64
+
65
+ ensureCursorVisible(cm)
66
+ cm.curOp.updateInput = updateInput
67
+ cm.curOp.typing = true
68
+ cm.state.pasteIncoming = cm.state.cutIncoming = false
69
+ }
70
+
71
+ export function handlePaste(e, cm) {
72
+ let pasted = e.clipboardData && e.clipboardData.getData("Text")
73
+ if (pasted) {
74
+ e.preventDefault()
75
+ if (!cm.isReadOnly() && !cm.options.disableInput)
76
+ runInOp(cm, () => applyTextInput(cm, pasted, 0, null, "paste"))
77
+ return true
78
+ }
79
+ }
80
+
81
+ export function triggerElectric(cm, inserted) {
82
+ // When an 'electric' character is inserted, immediately trigger a reindent
83
+ if (!cm.options.electricChars || !cm.options.smartIndent) return
84
+ let sel = cm.doc.sel
85
+
86
+ for (let i = sel.ranges.length - 1; i >= 0; i--) {
87
+ let range = sel.ranges[i]
88
+ if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue
89
+ let mode = cm.getModeAt(range.head)
90
+ let indented = false
91
+ if (mode.electricChars) {
92
+ for (let j = 0; j < mode.electricChars.length; j++)
93
+ if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
94
+ indented = indentLine(cm, range.head.line, "smart")
95
+ break
96
+ }
97
+ } else if (mode.electricInput) {
98
+ if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
99
+ indented = indentLine(cm, range.head.line, "smart")
100
+ }
101
+ if (indented) signalLater(cm, "electricInput", cm, range.head.line)
102
+ }
103
+ }
104
+
105
+ export function copyableRanges(cm) {
106
+ let text = [], ranges = []
107
+ for (let i = 0; i < cm.doc.sel.ranges.length; i++) {
108
+ let line = cm.doc.sel.ranges[i].head.line
109
+ let lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}
110
+ ranges.push(lineRange)
111
+ text.push(cm.getRange(lineRange.anchor, lineRange.head))
112
+ }
113
+ return {text: text, ranges: ranges}
114
+ }
115
+
116
+ export function disableBrowserMagic(field, spellcheck) {
117
+ field.setAttribute("autocorrect", "off")
118
+ field.setAttribute("autocapitalize", "off")
119
+ field.setAttribute("spellcheck", !!spellcheck)
120
+ }
121
+
122
+ export function hiddenTextarea() {
123
+ let te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none")
124
+ let div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;")
125
+ // The textarea is kept positioned near the cursor to prevent the
126
+ // fact that it'll be scrolled into view on input from scrolling
127
+ // our fake cursor out of view. On webkit, when wrap=off, paste is
128
+ // very slow. So make the area wide instead.
129
+ if (webkit) te.style.width = "1000px"
130
+ else te.setAttribute("wrap", "off")
131
+ // If border: 0; -- iOS fails to open keyboard (issue #1287)
132
+ if (ios) te.style.border = "1px solid black"
133
+ disableBrowserMagic(te)
134
+ return div
135
+ }