@muze-nl/simplystore 0.3.6 → 0.4.1

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 (353) hide show
  1. package/package.json +2 -2
  2. package/src/commands.mjs +2 -2
  3. package/src/server.mjs +68 -61
  4. package/src/share.mjs +22 -39
  5. package/.eslintrc.cjs +0 -15
  6. package/test/produce.mjs +0 -79
  7. package/test/share.mjs +0 -18
  8. package/test/test.jsontag +0 -20
  9. package/www/assets/css/style.css +0 -2296
  10. package/www/assets/feather-sprite.svg +0 -1
  11. package/www/assets/img/simplystore-narrow-white.svg +0 -138
  12. package/www/assets/img/simplystore-narrow.svg +0 -138
  13. package/www/assets/img/simplystore-white.svg +0 -153
  14. package/www/assets/img/simplystore.svg +0 -153
  15. package/www/codemirror/AUTHORS +0 -979
  16. package/www/codemirror/CHANGELOG.md +0 -2208
  17. package/www/codemirror/CONTRIBUTING.md +0 -92
  18. package/www/codemirror/LICENSE +0 -21
  19. package/www/codemirror/README.md +0 -47
  20. package/www/codemirror/addon/comment/comment.js +0 -211
  21. package/www/codemirror/addon/comment/continuecomment.js +0 -114
  22. package/www/codemirror/addon/dialog/dialog.css +0 -32
  23. package/www/codemirror/addon/dialog/dialog.js +0 -163
  24. package/www/codemirror/addon/display/autorefresh.js +0 -47
  25. package/www/codemirror/addon/display/fullscreen.css +0 -6
  26. package/www/codemirror/addon/display/fullscreen.js +0 -41
  27. package/www/codemirror/addon/display/panel.js +0 -133
  28. package/www/codemirror/addon/display/placeholder.js +0 -78
  29. package/www/codemirror/addon/display/rulers.js +0 -51
  30. package/www/codemirror/addon/edit/closebrackets.js +0 -201
  31. package/www/codemirror/addon/edit/closetag.js +0 -185
  32. package/www/codemirror/addon/edit/continuelist.js +0 -101
  33. package/www/codemirror/addon/edit/matchbrackets.js +0 -160
  34. package/www/codemirror/addon/edit/matchtags.js +0 -66
  35. package/www/codemirror/addon/edit/trailingspace.js +0 -27
  36. package/www/codemirror/addon/fold/brace-fold.js +0 -119
  37. package/www/codemirror/addon/fold/comment-fold.js +0 -59
  38. package/www/codemirror/addon/fold/foldcode.js +0 -159
  39. package/www/codemirror/addon/fold/foldgutter.css +0 -20
  40. package/www/codemirror/addon/fold/foldgutter.js +0 -169
  41. package/www/codemirror/addon/fold/indent-fold.js +0 -48
  42. package/www/codemirror/addon/fold/markdown-fold.js +0 -49
  43. package/www/codemirror/addon/fold/xml-fold.js +0 -184
  44. package/www/codemirror/addon/hint/anyword-hint.js +0 -41
  45. package/www/codemirror/addon/hint/css-hint.js +0 -66
  46. package/www/codemirror/addon/hint/html-hint.js +0 -351
  47. package/www/codemirror/addon/hint/javascript-hint.js +0 -162
  48. package/www/codemirror/addon/hint/show-hint.css +0 -37
  49. package/www/codemirror/addon/hint/show-hint.js +0 -523
  50. package/www/codemirror/addon/hint/sql-hint.js +0 -304
  51. package/www/codemirror/addon/hint/xml-hint.js +0 -132
  52. package/www/codemirror/addon/lint/coffeescript-lint.js +0 -47
  53. package/www/codemirror/addon/lint/css-lint.js +0 -40
  54. package/www/codemirror/addon/lint/html-lint.js +0 -59
  55. package/www/codemirror/addon/lint/javascript-lint.js +0 -65
  56. package/www/codemirror/addon/lint/json-lint.js +0 -40
  57. package/www/codemirror/addon/lint/lint.css +0 -79
  58. package/www/codemirror/addon/lint/lint.js +0 -291
  59. package/www/codemirror/addon/lint/yaml-lint.js +0 -41
  60. package/www/codemirror/addon/merge/merge.css +0 -119
  61. package/www/codemirror/addon/merge/merge.js +0 -1018
  62. package/www/codemirror/addon/mode/loadmode.js +0 -66
  63. package/www/codemirror/addon/mode/multiplex.js +0 -136
  64. package/www/codemirror/addon/mode/multiplex_test.js +0 -49
  65. package/www/codemirror/addon/mode/overlay.js +0 -90
  66. package/www/codemirror/addon/mode/simple.js +0 -216
  67. package/www/codemirror/addon/runmode/colorize.js +0 -40
  68. package/www/codemirror/addon/runmode/runmode-standalone.js +0 -334
  69. package/www/codemirror/addon/runmode/runmode.js +0 -76
  70. package/www/codemirror/addon/runmode/runmode.node.js +0 -329
  71. package/www/codemirror/addon/scroll/annotatescrollbar.js +0 -128
  72. package/www/codemirror/addon/scroll/scrollpastend.js +0 -48
  73. package/www/codemirror/addon/scroll/simplescrollbars.css +0 -66
  74. package/www/codemirror/addon/scroll/simplescrollbars.js +0 -152
  75. package/www/codemirror/addon/search/jump-to-line.js +0 -53
  76. package/www/codemirror/addon/search/match-highlighter.js +0 -167
  77. package/www/codemirror/addon/search/matchesonscrollbar.css +0 -8
  78. package/www/codemirror/addon/search/matchesonscrollbar.js +0 -97
  79. package/www/codemirror/addon/search/search.js +0 -295
  80. package/www/codemirror/addon/search/searchcursor.js +0 -305
  81. package/www/codemirror/addon/selection/active-line.js +0 -72
  82. package/www/codemirror/addon/selection/mark-selection.js +0 -119
  83. package/www/codemirror/addon/selection/selection-pointer.js +0 -98
  84. package/www/codemirror/addon/tern/tern.css +0 -87
  85. package/www/codemirror/addon/tern/tern.js +0 -756
  86. package/www/codemirror/addon/tern/worker.js +0 -44
  87. package/www/codemirror/addon/wrap/hardwrap.js +0 -160
  88. package/www/codemirror/bin/source-highlight +0 -48
  89. package/www/codemirror/keymap/emacs.js +0 -545
  90. package/www/codemirror/keymap/sublime.js +0 -720
  91. package/www/codemirror/keymap/vim.js +0 -5978
  92. package/www/codemirror/lib/codemirror.css +0 -344
  93. package/www/codemirror/lib/codemirror.js +0 -9874
  94. package/www/codemirror/mode/apl/apl.js +0 -174
  95. package/www/codemirror/mode/asciiarmor/asciiarmor.js +0 -74
  96. package/www/codemirror/mode/asn.1/asn.1.js +0 -204
  97. package/www/codemirror/mode/asterisk/asterisk.js +0 -220
  98. package/www/codemirror/mode/brainfuck/brainfuck.js +0 -85
  99. package/www/codemirror/mode/clike/clike.js +0 -940
  100. package/www/codemirror/mode/clojure/clojure.js +0 -292
  101. package/www/codemirror/mode/cmake/cmake.js +0 -97
  102. package/www/codemirror/mode/cobol/cobol.js +0 -255
  103. package/www/codemirror/mode/coffeescript/coffeescript.js +0 -359
  104. package/www/codemirror/mode/commonlisp/commonlisp.js +0 -125
  105. package/www/codemirror/mode/crystal/crystal.js +0 -433
  106. package/www/codemirror/mode/css/css.js +0 -862
  107. package/www/codemirror/mode/cypher/cypher.js +0 -152
  108. package/www/codemirror/mode/d/d.js +0 -223
  109. package/www/codemirror/mode/dart/dart.js +0 -166
  110. package/www/codemirror/mode/diff/diff.js +0 -47
  111. package/www/codemirror/mode/django/django.js +0 -356
  112. package/www/codemirror/mode/dockerfile/dockerfile.js +0 -211
  113. package/www/codemirror/mode/dtd/dtd.js +0 -142
  114. package/www/codemirror/mode/dylan/dylan.js +0 -352
  115. package/www/codemirror/mode/ebnf/ebnf.js +0 -195
  116. package/www/codemirror/mode/ecl/ecl.js +0 -206
  117. package/www/codemirror/mode/eiffel/eiffel.js +0 -160
  118. package/www/codemirror/mode/elm/elm.js +0 -245
  119. package/www/codemirror/mode/erlang/erlang.js +0 -619
  120. package/www/codemirror/mode/factor/factor.js +0 -85
  121. package/www/codemirror/mode/fcl/fcl.js +0 -173
  122. package/www/codemirror/mode/forth/forth.js +0 -180
  123. package/www/codemirror/mode/fortran/fortran.js +0 -188
  124. package/www/codemirror/mode/gas/gas.js +0 -353
  125. package/www/codemirror/mode/gfm/gfm.js +0 -129
  126. package/www/codemirror/mode/gherkin/gherkin.js +0 -178
  127. package/www/codemirror/mode/go/go.js +0 -187
  128. package/www/codemirror/mode/groovy/groovy.js +0 -247
  129. package/www/codemirror/mode/haml/haml.js +0 -161
  130. package/www/codemirror/mode/handlebars/handlebars.js +0 -70
  131. package/www/codemirror/mode/haskell/haskell.js +0 -268
  132. package/www/codemirror/mode/haskell-literate/haskell-literate.js +0 -43
  133. package/www/codemirror/mode/haxe/haxe.js +0 -515
  134. package/www/codemirror/mode/htmlembedded/htmlembedded.js +0 -37
  135. package/www/codemirror/mode/htmlmixed/htmlmixed.js +0 -153
  136. package/www/codemirror/mode/http/http.js +0 -113
  137. package/www/codemirror/mode/idl/idl.js +0 -290
  138. package/www/codemirror/mode/javascript/javascript.js +0 -960
  139. package/www/codemirror/mode/jinja2/jinja2.js +0 -193
  140. package/www/codemirror/mode/jsx/jsx.js +0 -148
  141. package/www/codemirror/mode/julia/julia.js +0 -390
  142. package/www/codemirror/mode/livescript/livescript.js +0 -280
  143. package/www/codemirror/mode/lua/lua.js +0 -160
  144. package/www/codemirror/mode/markdown/markdown.js +0 -886
  145. package/www/codemirror/mode/mathematica/mathematica.js +0 -176
  146. package/www/codemirror/mode/mbox/mbox.js +0 -129
  147. package/www/codemirror/mode/meta.js +0 -221
  148. package/www/codemirror/mode/mirc/mirc.js +0 -193
  149. package/www/codemirror/mode/mllike/mllike.js +0 -359
  150. package/www/codemirror/mode/modelica/modelica.js +0 -245
  151. package/www/codemirror/mode/mscgen/mscgen.js +0 -175
  152. package/www/codemirror/mode/mumps/mumps.js +0 -148
  153. package/www/codemirror/mode/nginx/nginx.js +0 -178
  154. package/www/codemirror/mode/nsis/nsis.js +0 -95
  155. package/www/codemirror/mode/ntriples/ntriples.js +0 -195
  156. package/www/codemirror/mode/octave/octave.js +0 -139
  157. package/www/codemirror/mode/oz/oz.js +0 -252
  158. package/www/codemirror/mode/pascal/pascal.js +0 -136
  159. package/www/codemirror/mode/pegjs/pegjs.js +0 -111
  160. package/www/codemirror/mode/perl/perl.js +0 -836
  161. package/www/codemirror/mode/php/php.js +0 -234
  162. package/www/codemirror/mode/pig/pig.js +0 -178
  163. package/www/codemirror/mode/powershell/powershell.js +0 -398
  164. package/www/codemirror/mode/properties/properties.js +0 -78
  165. package/www/codemirror/mode/protobuf/protobuf.js +0 -72
  166. package/www/codemirror/mode/pug/pug.js +0 -591
  167. package/www/codemirror/mode/puppet/puppet.js +0 -220
  168. package/www/codemirror/mode/python/python.js +0 -402
  169. package/www/codemirror/mode/q/q.js +0 -139
  170. package/www/codemirror/mode/r/r.js +0 -190
  171. package/www/codemirror/mode/rpm/changes/index.html +0 -66
  172. package/www/codemirror/mode/rpm/rpm.js +0 -109
  173. package/www/codemirror/mode/rst/rst.js +0 -557
  174. package/www/codemirror/mode/ruby/ruby.js +0 -303
  175. package/www/codemirror/mode/rust/rust.js +0 -72
  176. package/www/codemirror/mode/sas/sas.js +0 -303
  177. package/www/codemirror/mode/sass/sass.js +0 -459
  178. package/www/codemirror/mode/scheme/scheme.js +0 -284
  179. package/www/codemirror/mode/shell/shell.js +0 -168
  180. package/www/codemirror/mode/sieve/sieve.js +0 -193
  181. package/www/codemirror/mode/slim/slim.js +0 -575
  182. package/www/codemirror/mode/smalltalk/smalltalk.js +0 -168
  183. package/www/codemirror/mode/smarty/smarty.js +0 -225
  184. package/www/codemirror/mode/solr/solr.js +0 -104
  185. package/www/codemirror/mode/soy/soy.js +0 -665
  186. package/www/codemirror/mode/sparql/sparql.js +0 -184
  187. package/www/codemirror/mode/spreadsheet/spreadsheet.js +0 -112
  188. package/www/codemirror/mode/sql/sql.js +0 -525
  189. package/www/codemirror/mode/stex/stex.js +0 -264
  190. package/www/codemirror/mode/stylus/stylus.js +0 -775
  191. package/www/codemirror/mode/swift/swift.js +0 -221
  192. package/www/codemirror/mode/tcl/tcl.js +0 -140
  193. package/www/codemirror/mode/textile/textile.js +0 -469
  194. package/www/codemirror/mode/tiddlywiki/tiddlywiki.css +0 -14
  195. package/www/codemirror/mode/tiddlywiki/tiddlywiki.js +0 -308
  196. package/www/codemirror/mode/tiki/tiki.css +0 -26
  197. package/www/codemirror/mode/tiki/tiki.js +0 -312
  198. package/www/codemirror/mode/toml/toml.js +0 -88
  199. package/www/codemirror/mode/tornado/tornado.js +0 -68
  200. package/www/codemirror/mode/troff/troff.js +0 -84
  201. package/www/codemirror/mode/ttcn/ttcn.js +0 -283
  202. package/www/codemirror/mode/ttcn-cfg/ttcn-cfg.js +0 -214
  203. package/www/codemirror/mode/turtle/turtle.js +0 -162
  204. package/www/codemirror/mode/twig/twig.js +0 -141
  205. package/www/codemirror/mode/vb/vb.js +0 -275
  206. package/www/codemirror/mode/vbscript/vbscript.js +0 -350
  207. package/www/codemirror/mode/velocity/velocity.js +0 -202
  208. package/www/codemirror/mode/verilog/verilog.js +0 -781
  209. package/www/codemirror/mode/vhdl/vhdl.js +0 -189
  210. package/www/codemirror/mode/vue/vue.js +0 -77
  211. package/www/codemirror/mode/wast/wast.js +0 -132
  212. package/www/codemirror/mode/webidl/webidl.js +0 -195
  213. package/www/codemirror/mode/xml/xml.js +0 -417
  214. package/www/codemirror/mode/xquery/xquery.js +0 -448
  215. package/www/codemirror/mode/yacas/yacas.js +0 -204
  216. package/www/codemirror/mode/yaml/yaml.js +0 -120
  217. package/www/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +0 -72
  218. package/www/codemirror/mode/z80/z80.js +0 -116
  219. package/www/codemirror/package.json +0 -52
  220. package/www/codemirror/rollup.config.js +0 -52
  221. package/www/codemirror/src/addon/runmode/codemirror-standalone.js +0 -24
  222. package/www/codemirror/src/addon/runmode/codemirror.node.js +0 -21
  223. package/www/codemirror/src/addon/runmode/runmode-standalone.js +0 -2
  224. package/www/codemirror/src/addon/runmode/runmode.node.js +0 -2
  225. package/www/codemirror/src/codemirror.js +0 -3
  226. package/www/codemirror/src/display/Display.js +0 -116
  227. package/www/codemirror/src/display/focus.js +0 -50
  228. package/www/codemirror/src/display/gutters.js +0 -44
  229. package/www/codemirror/src/display/highlight_worker.js +0 -55
  230. package/www/codemirror/src/display/line_numbers.js +0 -48
  231. package/www/codemirror/src/display/mode_state.js +0 -22
  232. package/www/codemirror/src/display/operations.js +0 -206
  233. package/www/codemirror/src/display/scroll_events.js +0 -132
  234. package/www/codemirror/src/display/scrollbars.js +0 -194
  235. package/www/codemirror/src/display/scrolling.js +0 -186
  236. package/www/codemirror/src/display/selection.js +0 -173
  237. package/www/codemirror/src/display/update_display.js +0 -267
  238. package/www/codemirror/src/display/update_line.js +0 -189
  239. package/www/codemirror/src/display/update_lines.js +0 -82
  240. package/www/codemirror/src/display/view_tracking.js +0 -153
  241. package/www/codemirror/src/edit/CodeMirror.js +0 -217
  242. package/www/codemirror/src/edit/commands.js +0 -178
  243. package/www/codemirror/src/edit/deleteNearSelection.js +0 -30
  244. package/www/codemirror/src/edit/drop_events.js +0 -130
  245. package/www/codemirror/src/edit/fromTextArea.js +0 -61
  246. package/www/codemirror/src/edit/global_events.js +0 -45
  247. package/www/codemirror/src/edit/key_events.js +0 -163
  248. package/www/codemirror/src/edit/legacy.js +0 -62
  249. package/www/codemirror/src/edit/main.js +0 -69
  250. package/www/codemirror/src/edit/methods.js +0 -555
  251. package/www/codemirror/src/edit/mouse_events.js +0 -417
  252. package/www/codemirror/src/edit/options.js +0 -194
  253. package/www/codemirror/src/edit/utils.js +0 -7
  254. package/www/codemirror/src/input/ContentEditableInput.js +0 -546
  255. package/www/codemirror/src/input/TextareaInput.js +0 -380
  256. package/www/codemirror/src/input/indent.js +0 -71
  257. package/www/codemirror/src/input/input.js +0 -134
  258. package/www/codemirror/src/input/keymap.js +0 -147
  259. package/www/codemirror/src/input/keynames.js +0 -17
  260. package/www/codemirror/src/input/movement.js +0 -111
  261. package/www/codemirror/src/line/highlight.js +0 -284
  262. package/www/codemirror/src/line/line_data.js +0 -349
  263. package/www/codemirror/src/line/pos.js +0 -40
  264. package/www/codemirror/src/line/saw_special_spans.js +0 -10
  265. package/www/codemirror/src/line/spans.js +0 -390
  266. package/www/codemirror/src/line/utils_line.js +0 -85
  267. package/www/codemirror/src/measurement/position_measurement.js +0 -702
  268. package/www/codemirror/src/measurement/widgets.js +0 -26
  269. package/www/codemirror/src/model/Doc.js +0 -436
  270. package/www/codemirror/src/model/change_measurement.js +0 -61
  271. package/www/codemirror/src/model/changes.js +0 -339
  272. package/www/codemirror/src/model/chunk.js +0 -167
  273. package/www/codemirror/src/model/document_data.js +0 -112
  274. package/www/codemirror/src/model/history.js +0 -228
  275. package/www/codemirror/src/model/line_widget.js +0 -78
  276. package/www/codemirror/src/model/mark_text.js +0 -293
  277. package/www/codemirror/src/model/selection.js +0 -84
  278. package/www/codemirror/src/model/selection_updates.js +0 -216
  279. package/www/codemirror/src/modes.js +0 -96
  280. package/www/codemirror/src/util/StringStream.js +0 -90
  281. package/www/codemirror/src/util/bidi.js +0 -215
  282. package/www/codemirror/src/util/browser.js +0 -34
  283. package/www/codemirror/src/util/dom.js +0 -101
  284. package/www/codemirror/src/util/event.js +0 -103
  285. package/www/codemirror/src/util/feature_detection.js +0 -84
  286. package/www/codemirror/src/util/misc.js +0 -168
  287. package/www/codemirror/src/util/operation_group.js +0 -72
  288. package/www/codemirror/theme/3024-day.css +0 -41
  289. package/www/codemirror/theme/3024-night.css +0 -39
  290. package/www/codemirror/theme/abbott.css +0 -268
  291. package/www/codemirror/theme/abcdef.css +0 -32
  292. package/www/codemirror/theme/ambiance-mobile.css +0 -5
  293. package/www/codemirror/theme/ambiance.css +0 -74
  294. package/www/codemirror/theme/ayu-dark.css +0 -44
  295. package/www/codemirror/theme/ayu-mirage.css +0 -45
  296. package/www/codemirror/theme/base16-dark.css +0 -40
  297. package/www/codemirror/theme/base16-light.css +0 -38
  298. package/www/codemirror/theme/bespin.css +0 -34
  299. package/www/codemirror/theme/blackboard.css +0 -32
  300. package/www/codemirror/theme/cobalt.css +0 -25
  301. package/www/codemirror/theme/colorforth.css +0 -33
  302. package/www/codemirror/theme/darcula.css +0 -53
  303. package/www/codemirror/theme/dracula.css +0 -40
  304. package/www/codemirror/theme/duotone-dark.css +0 -35
  305. package/www/codemirror/theme/duotone-light.css +0 -36
  306. package/www/codemirror/theme/eclipse.css +0 -23
  307. package/www/codemirror/theme/elegant.css +0 -13
  308. package/www/codemirror/theme/erlang-dark.css +0 -34
  309. package/www/codemirror/theme/gruvbox-dark.css +0 -39
  310. package/www/codemirror/theme/hopscotch.css +0 -34
  311. package/www/codemirror/theme/icecoder.css +0 -43
  312. package/www/codemirror/theme/idea.css +0 -42
  313. package/www/codemirror/theme/isotope.css +0 -34
  314. package/www/codemirror/theme/juejin.css +0 -30
  315. package/www/codemirror/theme/lesser-dark.css +0 -47
  316. package/www/codemirror/theme/liquibyte.css +0 -95
  317. package/www/codemirror/theme/lucario.css +0 -37
  318. package/www/codemirror/theme/material-darker.css +0 -135
  319. package/www/codemirror/theme/material-ocean.css +0 -141
  320. package/www/codemirror/theme/material-palenight.css +0 -141
  321. package/www/codemirror/theme/material.css +0 -141
  322. package/www/codemirror/theme/mbo.css +0 -37
  323. package/www/codemirror/theme/mdn-like.css +0 -46
  324. package/www/codemirror/theme/midnight.css +0 -39
  325. package/www/codemirror/theme/monokai.css +0 -41
  326. package/www/codemirror/theme/moxer.css +0 -143
  327. package/www/codemirror/theme/neat.css +0 -12
  328. package/www/codemirror/theme/neo.css +0 -43
  329. package/www/codemirror/theme/night.css +0 -27
  330. package/www/codemirror/theme/nord.css +0 -42
  331. package/www/codemirror/theme/oceanic-next.css +0 -46
  332. package/www/codemirror/theme/panda-syntax.css +0 -85
  333. package/www/codemirror/theme/paraiso-dark.css +0 -38
  334. package/www/codemirror/theme/paraiso-light.css +0 -38
  335. package/www/codemirror/theme/pastel-on-dark.css +0 -52
  336. package/www/codemirror/theme/railscasts.css +0 -34
  337. package/www/codemirror/theme/rubyblue.css +0 -25
  338. package/www/codemirror/theme/seti.css +0 -44
  339. package/www/codemirror/theme/shadowfox.css +0 -52
  340. package/www/codemirror/theme/solarized.css +0 -165
  341. package/www/codemirror/theme/ssms.css +0 -16
  342. package/www/codemirror/theme/the-matrix.css +0 -30
  343. package/www/codemirror/theme/tomorrow-night-bright.css +0 -35
  344. package/www/codemirror/theme/tomorrow-night-eighties.css +0 -38
  345. package/www/codemirror/theme/ttcn.css +0 -64
  346. package/www/codemirror/theme/twilight.css +0 -32
  347. package/www/codemirror/theme/vibrant-ink.css +0 -34
  348. package/www/codemirror/theme/xq-dark.css +0 -53
  349. package/www/codemirror/theme/xq-light.css +0 -43
  350. package/www/codemirror/theme/yeti.css +0 -44
  351. package/www/codemirror/theme/yonce.css +0 -59
  352. package/www/codemirror/theme/zenburn.css +0 -37
  353. package/www/index.html +0 -359
@@ -1,217 +0,0 @@
1
- import { Display } from "../display/Display.js"
2
- import { onFocus, onBlur } from "../display/focus.js"
3
- import { maybeUpdateLineNumberWidth } from "../display/line_numbers.js"
4
- import { endOperation, operation, startOperation } from "../display/operations.js"
5
- import { initScrollbars } from "../display/scrollbars.js"
6
- import { onScrollWheel } from "../display/scroll_events.js"
7
- import { setScrollLeft, updateScrollTop } from "../display/scrolling.js"
8
- import { clipPos, Pos } from "../line/pos.js"
9
- import { posFromMouse } from "../measurement/position_measurement.js"
10
- import { eventInWidget } from "../measurement/widgets.js"
11
- import Doc from "../model/Doc.js"
12
- import { attachDoc } from "../model/document_data.js"
13
- import { Range } from "../model/selection.js"
14
- import { extendSelection } from "../model/selection_updates.js"
15
- import { ie, ie_version, mobile, webkit } from "../util/browser.js"
16
- import { e_preventDefault, e_stop, on, signal, signalDOMEvent } from "../util/event.js"
17
- import { copyObj, Delayed } from "../util/misc.js"
18
-
19
- import { clearDragCursor, onDragOver, onDragStart, onDrop } from "./drop_events.js"
20
- import { ensureGlobalHandlers } from "./global_events.js"
21
- import { onKeyDown, onKeyPress, onKeyUp } from "./key_events.js"
22
- import { clickInGutter, onContextMenu, onMouseDown } from "./mouse_events.js"
23
- import { themeChanged } from "./utils.js"
24
- import { defaults, optionHandlers, Init } from "./options.js"
25
-
26
- // A CodeMirror instance represents an editor. This is the object
27
- // that user code is usually dealing with.
28
-
29
- export function CodeMirror(place, options) {
30
- if (!(this instanceof CodeMirror)) return new CodeMirror(place, options)
31
-
32
- this.options = options = options ? copyObj(options) : {}
33
- // Determine effective options based on given values and defaults.
34
- copyObj(defaults, options, false)
35
-
36
- let doc = options.value
37
- if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction)
38
- else if (options.mode) doc.modeOption = options.mode
39
- this.doc = doc
40
-
41
- let input = new CodeMirror.inputStyles[options.inputStyle](this)
42
- let display = this.display = new Display(place, doc, input, options)
43
- display.wrapper.CodeMirror = this
44
- themeChanged(this)
45
- if (options.lineWrapping)
46
- this.display.wrapper.className += " CodeMirror-wrap"
47
- initScrollbars(this)
48
-
49
- this.state = {
50
- keyMaps: [], // stores maps added by addKeyMap
51
- overlays: [], // highlighting overlays, as added by addOverlay
52
- modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
53
- overwrite: false,
54
- delayingBlurEvent: false,
55
- focused: false,
56
- suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
57
- pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll
58
- selectingText: false,
59
- draggingText: false,
60
- highlight: new Delayed(), // stores highlight worker timeout
61
- keySeq: null, // Unfinished key sequence
62
- specialChars: null
63
- }
64
-
65
- if (options.autofocus && !mobile) display.input.focus()
66
-
67
- // Override magic textarea content restore that IE sometimes does
68
- // on our hidden textarea on reload
69
- if (ie && ie_version < 11) setTimeout(() => this.display.input.reset(true), 20)
70
-
71
- registerEventHandlers(this)
72
- ensureGlobalHandlers()
73
-
74
- startOperation(this)
75
- this.curOp.forceUpdate = true
76
- attachDoc(this, doc)
77
-
78
- if ((options.autofocus && !mobile) || this.hasFocus())
79
- setTimeout(() => {
80
- if (this.hasFocus() && !this.state.focused) onFocus(this)
81
- }, 20)
82
- else
83
- onBlur(this)
84
-
85
- for (let opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
86
- optionHandlers[opt](this, options[opt], Init)
87
- maybeUpdateLineNumberWidth(this)
88
- if (options.finishInit) options.finishInit(this)
89
- for (let i = 0; i < initHooks.length; ++i) initHooks[i](this)
90
- endOperation(this)
91
- // Suppress optimizelegibility in Webkit, since it breaks text
92
- // measuring on line wrapping boundaries.
93
- if (webkit && options.lineWrapping &&
94
- getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
95
- display.lineDiv.style.textRendering = "auto"
96
- }
97
-
98
- // The default configuration options.
99
- CodeMirror.defaults = defaults
100
- // Functions to run when options are changed.
101
- CodeMirror.optionHandlers = optionHandlers
102
-
103
- export default CodeMirror
104
-
105
- // Attach the necessary event handlers when initializing the editor
106
- function registerEventHandlers(cm) {
107
- let d = cm.display
108
- on(d.scroller, "mousedown", operation(cm, onMouseDown))
109
- // Older IE's will not fire a second mousedown for a double click
110
- if (ie && ie_version < 11)
111
- on(d.scroller, "dblclick", operation(cm, e => {
112
- if (signalDOMEvent(cm, e)) return
113
- let pos = posFromMouse(cm, e)
114
- if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return
115
- e_preventDefault(e)
116
- let word = cm.findWordAt(pos)
117
- extendSelection(cm.doc, word.anchor, word.head)
118
- }))
119
- else
120
- on(d.scroller, "dblclick", e => signalDOMEvent(cm, e) || e_preventDefault(e))
121
- // Some browsers fire contextmenu *after* opening the menu, at
122
- // which point we can't mess with it anymore. Context menu is
123
- // handled in onMouseDown for these browsers.
124
- on(d.scroller, "contextmenu", e => onContextMenu(cm, e))
125
- on(d.input.getField(), "contextmenu", e => {
126
- if (!d.scroller.contains(e.target)) onContextMenu(cm, e)
127
- })
128
-
129
- // Used to suppress mouse event handling when a touch happens
130
- let touchFinished, prevTouch = {end: 0}
131
- function finishTouch() {
132
- if (d.activeTouch) {
133
- touchFinished = setTimeout(() => d.activeTouch = null, 1000)
134
- prevTouch = d.activeTouch
135
- prevTouch.end = +new Date
136
- }
137
- }
138
- function isMouseLikeTouchEvent(e) {
139
- if (e.touches.length != 1) return false
140
- let touch = e.touches[0]
141
- return touch.radiusX <= 1 && touch.radiusY <= 1
142
- }
143
- function farAway(touch, other) {
144
- if (other.left == null) return true
145
- let dx = other.left - touch.left, dy = other.top - touch.top
146
- return dx * dx + dy * dy > 20 * 20
147
- }
148
- on(d.scroller, "touchstart", e => {
149
- if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
150
- d.input.ensurePolled()
151
- clearTimeout(touchFinished)
152
- let now = +new Date
153
- d.activeTouch = {start: now, moved: false,
154
- prev: now - prevTouch.end <= 300 ? prevTouch : null}
155
- if (e.touches.length == 1) {
156
- d.activeTouch.left = e.touches[0].pageX
157
- d.activeTouch.top = e.touches[0].pageY
158
- }
159
- }
160
- })
161
- on(d.scroller, "touchmove", () => {
162
- if (d.activeTouch) d.activeTouch.moved = true
163
- })
164
- on(d.scroller, "touchend", e => {
165
- let touch = d.activeTouch
166
- if (touch && !eventInWidget(d, e) && touch.left != null &&
167
- !touch.moved && new Date - touch.start < 300) {
168
- let pos = cm.coordsChar(d.activeTouch, "page"), range
169
- if (!touch.prev || farAway(touch, touch.prev)) // Single tap
170
- range = new Range(pos, pos)
171
- else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
172
- range = cm.findWordAt(pos)
173
- else // Triple tap
174
- range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)))
175
- cm.setSelection(range.anchor, range.head)
176
- cm.focus()
177
- e_preventDefault(e)
178
- }
179
- finishTouch()
180
- })
181
- on(d.scroller, "touchcancel", finishTouch)
182
-
183
- // Sync scrolling between fake scrollbars and real scrollable
184
- // area, ensure viewport is updated when scrolling.
185
- on(d.scroller, "scroll", () => {
186
- if (d.scroller.clientHeight) {
187
- updateScrollTop(cm, d.scroller.scrollTop)
188
- setScrollLeft(cm, d.scroller.scrollLeft, true)
189
- signal(cm, "scroll", cm)
190
- }
191
- })
192
-
193
- // Listen to wheel events in order to try and update the viewport on time.
194
- on(d.scroller, "mousewheel", e => onScrollWheel(cm, e))
195
- on(d.scroller, "DOMMouseScroll", e => onScrollWheel(cm, e))
196
-
197
- // Prevent wrapper from ever scrolling
198
- on(d.wrapper, "scroll", () => d.wrapper.scrollTop = d.wrapper.scrollLeft = 0)
199
-
200
- d.dragFunctions = {
201
- enter: e => {if (!signalDOMEvent(cm, e)) e_stop(e)},
202
- over: e => {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e) }},
203
- start: e => onDragStart(cm, e),
204
- drop: operation(cm, onDrop),
205
- leave: e => {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm) }}
206
- }
207
-
208
- let inp = d.input.getField()
209
- on(inp, "keyup", e => onKeyUp.call(cm, e))
210
- on(inp, "keydown", operation(cm, onKeyDown))
211
- on(inp, "keypress", operation(cm, onKeyPress))
212
- on(inp, "focus", e => onFocus(cm, e))
213
- on(inp, "blur", e => onBlur(cm, e))
214
- }
215
-
216
- let initHooks = []
217
- CodeMirror.defineInitHook = f => initHooks.push(f)
@@ -1,178 +0,0 @@
1
- import { deleteNearSelection } from "./deleteNearSelection.js"
2
- import { runInOp } from "../display/operations.js"
3
- import { ensureCursorVisible } from "../display/scrolling.js"
4
- import { endOfLine } from "../input/movement.js"
5
- import { clipPos, Pos } from "../line/pos.js"
6
- import { visualLine, visualLineEnd } from "../line/spans.js"
7
- import { getLine, lineNo } from "../line/utils_line.js"
8
- import { Range } from "../model/selection.js"
9
- import { selectAll } from "../model/selection_updates.js"
10
- import { countColumn, sel_dontScroll, sel_move, spaceStr } from "../util/misc.js"
11
- import { getOrder } from "../util/bidi.js"
12
-
13
- // Commands are parameter-less actions that can be performed on an
14
- // editor, mostly used for keybindings.
15
- export let commands = {
16
- selectAll: selectAll,
17
- singleSelection: cm => cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll),
18
- killLine: cm => deleteNearSelection(cm, range => {
19
- if (range.empty()) {
20
- let len = getLine(cm.doc, range.head.line).text.length
21
- if (range.head.ch == len && range.head.line < cm.lastLine())
22
- return {from: range.head, to: Pos(range.head.line + 1, 0)}
23
- else
24
- return {from: range.head, to: Pos(range.head.line, len)}
25
- } else {
26
- return {from: range.from(), to: range.to()}
27
- }
28
- }),
29
- deleteLine: cm => deleteNearSelection(cm, range => ({
30
- from: Pos(range.from().line, 0),
31
- to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
32
- })),
33
- delLineLeft: cm => deleteNearSelection(cm, range => ({
34
- from: Pos(range.from().line, 0), to: range.from()
35
- })),
36
- delWrappedLineLeft: cm => deleteNearSelection(cm, range => {
37
- let top = cm.charCoords(range.head, "div").top + 5
38
- let leftPos = cm.coordsChar({left: 0, top: top}, "div")
39
- return {from: leftPos, to: range.from()}
40
- }),
41
- delWrappedLineRight: cm => deleteNearSelection(cm, range => {
42
- let top = cm.charCoords(range.head, "div").top + 5
43
- let rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
44
- return {from: range.from(), to: rightPos }
45
- }),
46
- undo: cm => cm.undo(),
47
- redo: cm => cm.redo(),
48
- undoSelection: cm => cm.undoSelection(),
49
- redoSelection: cm => cm.redoSelection(),
50
- goDocStart: cm => cm.extendSelection(Pos(cm.firstLine(), 0)),
51
- goDocEnd: cm => cm.extendSelection(Pos(cm.lastLine())),
52
- goLineStart: cm => cm.extendSelectionsBy(range => lineStart(cm, range.head.line),
53
- {origin: "+move", bias: 1}
54
- ),
55
- goLineStartSmart: cm => cm.extendSelectionsBy(range => lineStartSmart(cm, range.head),
56
- {origin: "+move", bias: 1}
57
- ),
58
- goLineEnd: cm => cm.extendSelectionsBy(range => lineEnd(cm, range.head.line),
59
- {origin: "+move", bias: -1}
60
- ),
61
- goLineRight: cm => cm.extendSelectionsBy(range => {
62
- let top = cm.cursorCoords(range.head, "div").top + 5
63
- return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
64
- }, sel_move),
65
- goLineLeft: cm => cm.extendSelectionsBy(range => {
66
- let top = cm.cursorCoords(range.head, "div").top + 5
67
- return cm.coordsChar({left: 0, top: top}, "div")
68
- }, sel_move),
69
- goLineLeftSmart: cm => cm.extendSelectionsBy(range => {
70
- let top = cm.cursorCoords(range.head, "div").top + 5
71
- let pos = cm.coordsChar({left: 0, top: top}, "div")
72
- if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head)
73
- return pos
74
- }, sel_move),
75
- goLineUp: cm => cm.moveV(-1, "line"),
76
- goLineDown: cm => cm.moveV(1, "line"),
77
- goPageUp: cm => cm.moveV(-1, "page"),
78
- goPageDown: cm => cm.moveV(1, "page"),
79
- goCharLeft: cm => cm.moveH(-1, "char"),
80
- goCharRight: cm => cm.moveH(1, "char"),
81
- goColumnLeft: cm => cm.moveH(-1, "column"),
82
- goColumnRight: cm => cm.moveH(1, "column"),
83
- goWordLeft: cm => cm.moveH(-1, "word"),
84
- goGroupRight: cm => cm.moveH(1, "group"),
85
- goGroupLeft: cm => cm.moveH(-1, "group"),
86
- goWordRight: cm => cm.moveH(1, "word"),
87
- delCharBefore: cm => cm.deleteH(-1, "codepoint"),
88
- delCharAfter: cm => cm.deleteH(1, "char"),
89
- delWordBefore: cm => cm.deleteH(-1, "word"),
90
- delWordAfter: cm => cm.deleteH(1, "word"),
91
- delGroupBefore: cm => cm.deleteH(-1, "group"),
92
- delGroupAfter: cm => cm.deleteH(1, "group"),
93
- indentAuto: cm => cm.indentSelection("smart"),
94
- indentMore: cm => cm.indentSelection("add"),
95
- indentLess: cm => cm.indentSelection("subtract"),
96
- insertTab: cm => cm.replaceSelection("\t"),
97
- insertSoftTab: cm => {
98
- let spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize
99
- for (let i = 0; i < ranges.length; i++) {
100
- let pos = ranges[i].from()
101
- let col = countColumn(cm.getLine(pos.line), pos.ch, tabSize)
102
- spaces.push(spaceStr(tabSize - col % tabSize))
103
- }
104
- cm.replaceSelections(spaces)
105
- },
106
- defaultTab: cm => {
107
- if (cm.somethingSelected()) cm.indentSelection("add")
108
- else cm.execCommand("insertTab")
109
- },
110
- // Swap the two chars left and right of each selection's head.
111
- // Move cursor behind the two swapped characters afterwards.
112
- //
113
- // Doesn't consider line feeds a character.
114
- // Doesn't scan more than one line above to find a character.
115
- // Doesn't do anything on an empty line.
116
- // Doesn't do anything with non-empty selections.
117
- transposeChars: cm => runInOp(cm, () => {
118
- let ranges = cm.listSelections(), newSel = []
119
- for (let i = 0; i < ranges.length; i++) {
120
- if (!ranges[i].empty()) continue
121
- let cur = ranges[i].head, line = getLine(cm.doc, cur.line).text
122
- if (line) {
123
- if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1)
124
- if (cur.ch > 0) {
125
- cur = new Pos(cur.line, cur.ch + 1)
126
- cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
127
- Pos(cur.line, cur.ch - 2), cur, "+transpose")
128
- } else if (cur.line > cm.doc.first) {
129
- let prev = getLine(cm.doc, cur.line - 1).text
130
- if (prev) {
131
- cur = new Pos(cur.line, 1)
132
- cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
133
- prev.charAt(prev.length - 1),
134
- Pos(cur.line - 1, prev.length - 1), cur, "+transpose")
135
- }
136
- }
137
- }
138
- newSel.push(new Range(cur, cur))
139
- }
140
- cm.setSelections(newSel)
141
- }),
142
- newlineAndIndent: cm => runInOp(cm, () => {
143
- let sels = cm.listSelections()
144
- for (let i = sels.length - 1; i >= 0; i--)
145
- cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input")
146
- sels = cm.listSelections()
147
- for (let i = 0; i < sels.length; i++)
148
- cm.indentLine(sels[i].from().line, null, true)
149
- ensureCursorVisible(cm)
150
- }),
151
- openLine: cm => cm.replaceSelection("\n", "start"),
152
- toggleOverwrite: cm => cm.toggleOverwrite()
153
- }
154
-
155
-
156
- function lineStart(cm, lineN) {
157
- let line = getLine(cm.doc, lineN)
158
- let visual = visualLine(line)
159
- if (visual != line) lineN = lineNo(visual)
160
- return endOfLine(true, cm, visual, lineN, 1)
161
- }
162
- function lineEnd(cm, lineN) {
163
- let line = getLine(cm.doc, lineN)
164
- let visual = visualLineEnd(line)
165
- if (visual != line) lineN = lineNo(visual)
166
- return endOfLine(true, cm, line, lineN, -1)
167
- }
168
- function lineStartSmart(cm, pos) {
169
- let start = lineStart(cm, pos.line)
170
- let line = getLine(cm.doc, start.line)
171
- let order = getOrder(line, cm.doc.direction)
172
- if (!order || order[0].level == 0) {
173
- let firstNonWS = Math.max(start.ch, line.text.search(/\S/))
174
- let inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
175
- return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
176
- }
177
- return start
178
- }
@@ -1,30 +0,0 @@
1
- import { runInOp } from "../display/operations.js"
2
- import { ensureCursorVisible } from "../display/scrolling.js"
3
- import { cmp } from "../line/pos.js"
4
- import { replaceRange } from "../model/changes.js"
5
- import { lst } from "../util/misc.js"
6
-
7
- // Helper for deleting text near the selection(s), used to implement
8
- // backspace, delete, and similar functionality.
9
- export function deleteNearSelection(cm, compute) {
10
- let ranges = cm.doc.sel.ranges, kill = []
11
- // Build up a set of ranges to kill first, merging overlapping
12
- // ranges.
13
- for (let i = 0; i < ranges.length; i++) {
14
- let toKill = compute(ranges[i])
15
- while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
16
- let replaced = kill.pop()
17
- if (cmp(replaced.from, toKill.from) < 0) {
18
- toKill.from = replaced.from
19
- break
20
- }
21
- }
22
- kill.push(toKill)
23
- }
24
- // Next, remove those actual ranges.
25
- runInOp(cm, () => {
26
- for (let i = kill.length - 1; i >= 0; i--)
27
- replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete")
28
- ensureCursorVisible(cm)
29
- })
30
- }
@@ -1,130 +0,0 @@
1
- import { drawSelectionCursor } from "../display/selection.js"
2
- import { operation } from "../display/operations.js"
3
- import { clipPos } from "../line/pos.js"
4
- import { posFromMouse } from "../measurement/position_measurement.js"
5
- import { eventInWidget } from "../measurement/widgets.js"
6
- import { makeChange, replaceRange } from "../model/changes.js"
7
- import { changeEnd } from "../model/change_measurement.js"
8
- import { simpleSelection } from "../model/selection.js"
9
- import { setSelectionNoUndo, setSelectionReplaceHistory } from "../model/selection_updates.js"
10
- import { ie, presto, safari } from "../util/browser.js"
11
- import { elt, removeChildrenAndAdd } from "../util/dom.js"
12
- import { e_preventDefault, e_stop, signalDOMEvent } from "../util/event.js"
13
- import { indexOf } from "../util/misc.js"
14
-
15
- // Kludge to work around strange IE behavior where it'll sometimes
16
- // re-fire a series of drag-related events right after the drop (#1551)
17
- let lastDrop = 0
18
-
19
- export function onDrop(e) {
20
- let cm = this
21
- clearDragCursor(cm)
22
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
23
- return
24
- e_preventDefault(e)
25
- if (ie) lastDrop = +new Date
26
- let pos = posFromMouse(cm, e, true), files = e.dataTransfer.files
27
- if (!pos || cm.isReadOnly()) return
28
- // Might be a file drop, in which case we simply extract the text
29
- // and insert it.
30
- if (files && files.length && window.FileReader && window.File) {
31
- let n = files.length, text = Array(n), read = 0
32
- const markAsReadAndPasteIfAllFilesAreRead = () => {
33
- if (++read == n) {
34
- operation(cm, () => {
35
- pos = clipPos(cm.doc, pos)
36
- let change = {from: pos, to: pos,
37
- text: cm.doc.splitLines(
38
- text.filter(t => t != null).join(cm.doc.lineSeparator())),
39
- origin: "paste"}
40
- makeChange(cm.doc, change)
41
- setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change))))
42
- })()
43
- }
44
- }
45
- const readTextFromFile = (file, i) => {
46
- if (cm.options.allowDropFileTypes &&
47
- indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
48
- markAsReadAndPasteIfAllFilesAreRead()
49
- return
50
- }
51
- let reader = new FileReader
52
- reader.onerror = () => markAsReadAndPasteIfAllFilesAreRead()
53
- reader.onload = () => {
54
- let content = reader.result
55
- if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
56
- markAsReadAndPasteIfAllFilesAreRead()
57
- return
58
- }
59
- text[i] = content
60
- markAsReadAndPasteIfAllFilesAreRead()
61
- }
62
- reader.readAsText(file)
63
- }
64
- for (let i = 0; i < files.length; i++) readTextFromFile(files[i], i)
65
- } else { // Normal drop
66
- // Don't do a replace if the drop happened inside of the selected text.
67
- if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
68
- cm.state.draggingText(e)
69
- // Ensure the editor is re-focused
70
- setTimeout(() => cm.display.input.focus(), 20)
71
- return
72
- }
73
- try {
74
- let text = e.dataTransfer.getData("Text")
75
- if (text) {
76
- let selected
77
- if (cm.state.draggingText && !cm.state.draggingText.copy)
78
- selected = cm.listSelections()
79
- setSelectionNoUndo(cm.doc, simpleSelection(pos, pos))
80
- if (selected) for (let i = 0; i < selected.length; ++i)
81
- replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag")
82
- cm.replaceSelection(text, "around", "paste")
83
- cm.display.input.focus()
84
- }
85
- }
86
- catch(e){}
87
- }
88
- }
89
-
90
- export function onDragStart(cm, e) {
91
- if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
92
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return
93
-
94
- e.dataTransfer.setData("Text", cm.getSelection())
95
- e.dataTransfer.effectAllowed = "copyMove"
96
-
97
- // Use dummy image instead of default browsers image.
98
- // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
99
- if (e.dataTransfer.setDragImage && !safari) {
100
- let img = elt("img", null, null, "position: fixed; left: 0; top: 0;")
101
- img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
102
- if (presto) {
103
- img.width = img.height = 1
104
- cm.display.wrapper.appendChild(img)
105
- // Force a relayout, or Opera won't use our image for some obscure reason
106
- img._top = img.offsetTop
107
- }
108
- e.dataTransfer.setDragImage(img, 0, 0)
109
- if (presto) img.parentNode.removeChild(img)
110
- }
111
- }
112
-
113
- export function onDragOver(cm, e) {
114
- let pos = posFromMouse(cm, e)
115
- if (!pos) return
116
- let frag = document.createDocumentFragment()
117
- drawSelectionCursor(cm, pos, frag)
118
- if (!cm.display.dragCursor) {
119
- cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors")
120
- cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv)
121
- }
122
- removeChildrenAndAdd(cm.display.dragCursor, frag)
123
- }
124
-
125
- export function clearDragCursor(cm) {
126
- if (cm.display.dragCursor) {
127
- cm.display.lineSpace.removeChild(cm.display.dragCursor)
128
- cm.display.dragCursor = null
129
- }
130
- }
@@ -1,61 +0,0 @@
1
- import { CodeMirror } from "./CodeMirror.js"
2
- import { activeElt } from "../util/dom.js"
3
- import { off, on } from "../util/event.js"
4
- import { copyObj } from "../util/misc.js"
5
-
6
- export function fromTextArea(textarea, options) {
7
- options = options ? copyObj(options) : {}
8
- options.value = textarea.value
9
- if (!options.tabindex && textarea.tabIndex)
10
- options.tabindex = textarea.tabIndex
11
- if (!options.placeholder && textarea.placeholder)
12
- options.placeholder = textarea.placeholder
13
- // Set autofocus to true if this textarea is focused, or if it has
14
- // autofocus and no other element is focused.
15
- if (options.autofocus == null) {
16
- let hasFocus = activeElt(textarea.ownerDocument)
17
- options.autofocus = hasFocus == textarea ||
18
- textarea.getAttribute("autofocus") != null && hasFocus == document.body
19
- }
20
-
21
- function save() {textarea.value = cm.getValue()}
22
-
23
- let realSubmit
24
- if (textarea.form) {
25
- on(textarea.form, "submit", save)
26
- // Deplorable hack to make the submit method do the right thing.
27
- if (!options.leaveSubmitMethodAlone) {
28
- let form = textarea.form
29
- realSubmit = form.submit
30
- try {
31
- let wrappedSubmit = form.submit = () => {
32
- save()
33
- form.submit = realSubmit
34
- form.submit()
35
- form.submit = wrappedSubmit
36
- }
37
- } catch(e) {}
38
- }
39
- }
40
-
41
- options.finishInit = cm => {
42
- cm.save = save
43
- cm.getTextArea = () => textarea
44
- cm.toTextArea = () => {
45
- cm.toTextArea = isNaN // Prevent this from being ran twice
46
- save()
47
- textarea.parentNode.removeChild(cm.getWrapperElement())
48
- textarea.style.display = ""
49
- if (textarea.form) {
50
- off(textarea.form, "submit", save)
51
- if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function")
52
- textarea.form.submit = realSubmit
53
- }
54
- }
55
- }
56
-
57
- textarea.style.display = "none"
58
- let cm = CodeMirror(node => textarea.parentNode.insertBefore(node, textarea.nextSibling),
59
- options)
60
- return cm
61
- }
@@ -1,45 +0,0 @@
1
- import { onBlur } from "../display/focus.js"
2
- import { on } from "../util/event.js"
3
-
4
- // These must be handled carefully, because naively registering a
5
- // handler for each editor will cause the editors to never be
6
- // garbage collected.
7
-
8
- function forEachCodeMirror(f) {
9
- if (!document.getElementsByClassName) return
10
- let byClass = document.getElementsByClassName("CodeMirror"), editors = []
11
- for (let i = 0; i < byClass.length; i++) {
12
- let cm = byClass[i].CodeMirror
13
- if (cm) editors.push(cm)
14
- }
15
- if (editors.length) editors[0].operation(() => {
16
- for (let i = 0; i < editors.length; i++) f(editors[i])
17
- })
18
- }
19
-
20
- let globalsRegistered = false
21
- export function ensureGlobalHandlers() {
22
- if (globalsRegistered) return
23
- registerGlobalHandlers()
24
- globalsRegistered = true
25
- }
26
- function registerGlobalHandlers() {
27
- // When the window resizes, we need to refresh active editors.
28
- let resizeTimer
29
- on(window, "resize", () => {
30
- if (resizeTimer == null) resizeTimer = setTimeout(() => {
31
- resizeTimer = null
32
- forEachCodeMirror(onResize)
33
- }, 100)
34
- })
35
- // When the window loses focus, we want to show the editor as blurred
36
- on(window, "blur", () => forEachCodeMirror(onBlur))
37
- }
38
- // Called when the window resizes
39
- function onResize(cm) {
40
- let d = cm.display
41
- // Might be a text scaling operation, clear size caches.
42
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null
43
- d.scrollbarsClipped = false
44
- cm.setSize()
45
- }