@muze-nl/simplystore 0.3.6 → 0.4.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.
- package/package.json +2 -2
- package/package.json~ +33 -0
- package/src/server.mjs +68 -61
- package/www/codemirror/addon/comment/comment.js +0 -211
- package/www/codemirror/addon/comment/continuecomment.js +0 -114
- package/www/codemirror/addon/dialog/dialog.css +0 -32
- package/www/codemirror/addon/dialog/dialog.js +0 -163
- package/www/codemirror/addon/display/autorefresh.js +0 -47
- package/www/codemirror/addon/display/fullscreen.css +0 -6
- package/www/codemirror/addon/display/fullscreen.js +0 -41
- package/www/codemirror/addon/display/panel.js +0 -133
- package/www/codemirror/addon/display/placeholder.js +0 -78
- package/www/codemirror/addon/display/rulers.js +0 -51
- package/www/codemirror/addon/edit/closebrackets.js +0 -201
- package/www/codemirror/addon/edit/closetag.js +0 -185
- package/www/codemirror/addon/edit/continuelist.js +0 -101
- package/www/codemirror/addon/edit/matchbrackets.js +0 -160
- package/www/codemirror/addon/edit/matchtags.js +0 -66
- package/www/codemirror/addon/edit/trailingspace.js +0 -27
- package/www/codemirror/addon/fold/brace-fold.js +0 -119
- package/www/codemirror/addon/fold/comment-fold.js +0 -59
- package/www/codemirror/addon/fold/foldcode.js +0 -159
- package/www/codemirror/addon/fold/foldgutter.css +0 -20
- package/www/codemirror/addon/fold/foldgutter.js +0 -169
- package/www/codemirror/addon/fold/indent-fold.js +0 -48
- package/www/codemirror/addon/fold/markdown-fold.js +0 -49
- package/www/codemirror/addon/fold/xml-fold.js +0 -184
- package/www/codemirror/addon/hint/anyword-hint.js +0 -41
- package/www/codemirror/addon/hint/css-hint.js +0 -66
- package/www/codemirror/addon/hint/html-hint.js +0 -351
- package/www/codemirror/addon/hint/javascript-hint.js +0 -162
- package/www/codemirror/addon/hint/show-hint.css +0 -37
- package/www/codemirror/addon/hint/show-hint.js +0 -523
- package/www/codemirror/addon/hint/sql-hint.js +0 -304
- package/www/codemirror/addon/hint/xml-hint.js +0 -132
- package/www/codemirror/addon/lint/coffeescript-lint.js +0 -47
- package/www/codemirror/addon/lint/css-lint.js +0 -40
- package/www/codemirror/addon/lint/html-lint.js +0 -59
- package/www/codemirror/addon/lint/json-lint.js +0 -40
- package/www/codemirror/addon/lint/yaml-lint.js +0 -41
- package/www/codemirror/addon/merge/merge.css +0 -119
- package/www/codemirror/addon/merge/merge.js +0 -1018
- package/www/codemirror/addon/mode/loadmode.js +0 -66
- package/www/codemirror/addon/mode/multiplex.js +0 -136
- package/www/codemirror/addon/mode/multiplex_test.js +0 -49
- package/www/codemirror/addon/mode/overlay.js +0 -90
- package/www/codemirror/addon/mode/simple.js +0 -216
- package/www/codemirror/addon/runmode/colorize.js +0 -40
- package/www/codemirror/addon/runmode/runmode-standalone.js +0 -334
- package/www/codemirror/addon/runmode/runmode.js +0 -76
- package/www/codemirror/addon/runmode/runmode.node.js +0 -329
- package/www/codemirror/addon/scroll/annotatescrollbar.js +0 -128
- package/www/codemirror/addon/scroll/scrollpastend.js +0 -48
- package/www/codemirror/addon/scroll/simplescrollbars.css +0 -66
- package/www/codemirror/addon/scroll/simplescrollbars.js +0 -152
- package/www/codemirror/addon/search/jump-to-line.js +0 -53
- package/www/codemirror/addon/search/match-highlighter.js +0 -167
- package/www/codemirror/addon/search/matchesonscrollbar.css +0 -8
- package/www/codemirror/addon/search/matchesonscrollbar.js +0 -97
- package/www/codemirror/addon/search/search.js +0 -295
- package/www/codemirror/addon/search/searchcursor.js +0 -305
- package/www/codemirror/addon/selection/active-line.js +0 -72
- package/www/codemirror/addon/selection/mark-selection.js +0 -119
- package/www/codemirror/addon/selection/selection-pointer.js +0 -98
- package/www/codemirror/addon/tern/tern.css +0 -87
- package/www/codemirror/addon/tern/tern.js +0 -756
- package/www/codemirror/addon/tern/worker.js +0 -44
- package/www/codemirror/addon/wrap/hardwrap.js +0 -160
- package/www/codemirror/bin/source-highlight +0 -48
- package/www/codemirror/keymap/emacs.js +0 -545
- package/www/codemirror/keymap/sublime.js +0 -720
- package/www/codemirror/keymap/vim.js +0 -5978
- package/www/codemirror/mode/apl/apl.js +0 -174
- package/www/codemirror/mode/asciiarmor/asciiarmor.js +0 -74
- package/www/codemirror/mode/asn.1/asn.1.js +0 -204
- package/www/codemirror/mode/asterisk/asterisk.js +0 -220
- package/www/codemirror/mode/brainfuck/brainfuck.js +0 -85
- package/www/codemirror/mode/clike/clike.js +0 -940
- package/www/codemirror/mode/clojure/clojure.js +0 -292
- package/www/codemirror/mode/cmake/cmake.js +0 -97
- package/www/codemirror/mode/cobol/cobol.js +0 -255
- package/www/codemirror/mode/coffeescript/coffeescript.js +0 -359
- package/www/codemirror/mode/commonlisp/commonlisp.js +0 -125
- package/www/codemirror/mode/crystal/crystal.js +0 -433
- package/www/codemirror/mode/css/css.js +0 -862
- package/www/codemirror/mode/cypher/cypher.js +0 -152
- package/www/codemirror/mode/d/d.js +0 -223
- package/www/codemirror/mode/dart/dart.js +0 -166
- package/www/codemirror/mode/diff/diff.js +0 -47
- package/www/codemirror/mode/django/django.js +0 -356
- package/www/codemirror/mode/dockerfile/dockerfile.js +0 -211
- package/www/codemirror/mode/dtd/dtd.js +0 -142
- package/www/codemirror/mode/dylan/dylan.js +0 -352
- package/www/codemirror/mode/ebnf/ebnf.js +0 -195
- package/www/codemirror/mode/ecl/ecl.js +0 -206
- package/www/codemirror/mode/eiffel/eiffel.js +0 -160
- package/www/codemirror/mode/elm/elm.js +0 -245
- package/www/codemirror/mode/erlang/erlang.js +0 -619
- package/www/codemirror/mode/factor/factor.js +0 -85
- package/www/codemirror/mode/fcl/fcl.js +0 -173
- package/www/codemirror/mode/forth/forth.js +0 -180
- package/www/codemirror/mode/fortran/fortran.js +0 -188
- package/www/codemirror/mode/gas/gas.js +0 -353
- package/www/codemirror/mode/gfm/gfm.js +0 -129
- package/www/codemirror/mode/gherkin/gherkin.js +0 -178
- package/www/codemirror/mode/go/go.js +0 -187
- package/www/codemirror/mode/groovy/groovy.js +0 -247
- package/www/codemirror/mode/haml/haml.js +0 -161
- package/www/codemirror/mode/handlebars/handlebars.js +0 -70
- package/www/codemirror/mode/haskell/haskell.js +0 -268
- package/www/codemirror/mode/haskell-literate/haskell-literate.js +0 -43
- package/www/codemirror/mode/haxe/haxe.js +0 -515
- package/www/codemirror/mode/htmlembedded/htmlembedded.js +0 -37
- package/www/codemirror/mode/htmlmixed/htmlmixed.js +0 -153
- package/www/codemirror/mode/http/http.js +0 -113
- package/www/codemirror/mode/idl/idl.js +0 -290
- package/www/codemirror/mode/jinja2/jinja2.js +0 -193
- package/www/codemirror/mode/jsx/jsx.js +0 -148
- package/www/codemirror/mode/julia/julia.js +0 -390
- package/www/codemirror/mode/livescript/livescript.js +0 -280
- package/www/codemirror/mode/lua/lua.js +0 -160
- package/www/codemirror/mode/markdown/markdown.js +0 -886
- package/www/codemirror/mode/mathematica/mathematica.js +0 -176
- package/www/codemirror/mode/mbox/mbox.js +0 -129
- package/www/codemirror/mode/meta.js +0 -221
- package/www/codemirror/mode/mirc/mirc.js +0 -193
- package/www/codemirror/mode/mllike/mllike.js +0 -359
- package/www/codemirror/mode/modelica/modelica.js +0 -245
- package/www/codemirror/mode/mscgen/mscgen.js +0 -175
- package/www/codemirror/mode/mumps/mumps.js +0 -148
- package/www/codemirror/mode/nginx/nginx.js +0 -178
- package/www/codemirror/mode/nsis/nsis.js +0 -95
- package/www/codemirror/mode/ntriples/ntriples.js +0 -195
- package/www/codemirror/mode/octave/octave.js +0 -139
- package/www/codemirror/mode/oz/oz.js +0 -252
- package/www/codemirror/mode/pascal/pascal.js +0 -136
- package/www/codemirror/mode/pegjs/pegjs.js +0 -111
- package/www/codemirror/mode/perl/perl.js +0 -836
- package/www/codemirror/mode/php/php.js +0 -234
- package/www/codemirror/mode/pig/pig.js +0 -178
- package/www/codemirror/mode/powershell/powershell.js +0 -398
- package/www/codemirror/mode/properties/properties.js +0 -78
- package/www/codemirror/mode/protobuf/protobuf.js +0 -72
- package/www/codemirror/mode/pug/pug.js +0 -591
- package/www/codemirror/mode/puppet/puppet.js +0 -220
- package/www/codemirror/mode/python/python.js +0 -402
- package/www/codemirror/mode/q/q.js +0 -139
- package/www/codemirror/mode/r/r.js +0 -190
- package/www/codemirror/mode/rpm/changes/index.html +0 -66
- package/www/codemirror/mode/rpm/rpm.js +0 -109
- package/www/codemirror/mode/rst/rst.js +0 -557
- package/www/codemirror/mode/ruby/ruby.js +0 -303
- package/www/codemirror/mode/rust/rust.js +0 -72
- package/www/codemirror/mode/sas/sas.js +0 -303
- package/www/codemirror/mode/sass/sass.js +0 -459
- package/www/codemirror/mode/scheme/scheme.js +0 -284
- package/www/codemirror/mode/shell/shell.js +0 -168
- package/www/codemirror/mode/sieve/sieve.js +0 -193
- package/www/codemirror/mode/slim/slim.js +0 -575
- package/www/codemirror/mode/smalltalk/smalltalk.js +0 -168
- package/www/codemirror/mode/smarty/smarty.js +0 -225
- package/www/codemirror/mode/solr/solr.js +0 -104
- package/www/codemirror/mode/soy/soy.js +0 -665
- package/www/codemirror/mode/sparql/sparql.js +0 -184
- package/www/codemirror/mode/spreadsheet/spreadsheet.js +0 -112
- package/www/codemirror/mode/sql/sql.js +0 -525
- package/www/codemirror/mode/stex/stex.js +0 -264
- package/www/codemirror/mode/stylus/stylus.js +0 -775
- package/www/codemirror/mode/swift/swift.js +0 -221
- package/www/codemirror/mode/tcl/tcl.js +0 -140
- package/www/codemirror/mode/textile/textile.js +0 -469
- package/www/codemirror/mode/tiddlywiki/tiddlywiki.css +0 -14
- package/www/codemirror/mode/tiddlywiki/tiddlywiki.js +0 -308
- package/www/codemirror/mode/tiki/tiki.css +0 -26
- package/www/codemirror/mode/tiki/tiki.js +0 -312
- package/www/codemirror/mode/toml/toml.js +0 -88
- package/www/codemirror/mode/tornado/tornado.js +0 -68
- package/www/codemirror/mode/troff/troff.js +0 -84
- package/www/codemirror/mode/ttcn/ttcn.js +0 -283
- package/www/codemirror/mode/ttcn-cfg/ttcn-cfg.js +0 -214
- package/www/codemirror/mode/turtle/turtle.js +0 -162
- package/www/codemirror/mode/twig/twig.js +0 -141
- package/www/codemirror/mode/vb/vb.js +0 -275
- package/www/codemirror/mode/vbscript/vbscript.js +0 -350
- package/www/codemirror/mode/velocity/velocity.js +0 -202
- package/www/codemirror/mode/verilog/verilog.js +0 -781
- package/www/codemirror/mode/vhdl/vhdl.js +0 -189
- package/www/codemirror/mode/vue/vue.js +0 -77
- package/www/codemirror/mode/wast/wast.js +0 -132
- package/www/codemirror/mode/webidl/webidl.js +0 -195
- package/www/codemirror/mode/xml/xml.js +0 -417
- package/www/codemirror/mode/xquery/xquery.js +0 -448
- package/www/codemirror/mode/yacas/yacas.js +0 -204
- package/www/codemirror/mode/yaml/yaml.js +0 -120
- package/www/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +0 -72
- package/www/codemirror/mode/z80/z80.js +0 -116
- package/www/codemirror/rollup.config.js +0 -52
- package/www/codemirror/src/addon/runmode/codemirror-standalone.js +0 -24
- package/www/codemirror/src/addon/runmode/codemirror.node.js +0 -21
- package/www/codemirror/src/addon/runmode/runmode-standalone.js +0 -2
- package/www/codemirror/src/addon/runmode/runmode.node.js +0 -2
- package/www/codemirror/src/codemirror.js +0 -3
- package/www/codemirror/src/display/Display.js +0 -116
- package/www/codemirror/src/display/focus.js +0 -50
- package/www/codemirror/src/display/gutters.js +0 -44
- package/www/codemirror/src/display/highlight_worker.js +0 -55
- package/www/codemirror/src/display/line_numbers.js +0 -48
- package/www/codemirror/src/display/mode_state.js +0 -22
- package/www/codemirror/src/display/operations.js +0 -206
- package/www/codemirror/src/display/scroll_events.js +0 -132
- package/www/codemirror/src/display/scrollbars.js +0 -194
- package/www/codemirror/src/display/scrolling.js +0 -186
- package/www/codemirror/src/display/selection.js +0 -173
- package/www/codemirror/src/display/update_display.js +0 -267
- package/www/codemirror/src/display/update_line.js +0 -189
- package/www/codemirror/src/display/update_lines.js +0 -82
- package/www/codemirror/src/display/view_tracking.js +0 -153
- package/www/codemirror/src/edit/CodeMirror.js +0 -217
- package/www/codemirror/src/edit/commands.js +0 -178
- package/www/codemirror/src/edit/deleteNearSelection.js +0 -30
- package/www/codemirror/src/edit/drop_events.js +0 -130
- package/www/codemirror/src/edit/fromTextArea.js +0 -61
- package/www/codemirror/src/edit/global_events.js +0 -45
- package/www/codemirror/src/edit/key_events.js +0 -163
- package/www/codemirror/src/edit/legacy.js +0 -62
- package/www/codemirror/src/edit/main.js +0 -69
- package/www/codemirror/src/edit/methods.js +0 -555
- package/www/codemirror/src/edit/mouse_events.js +0 -417
- package/www/codemirror/src/edit/options.js +0 -194
- package/www/codemirror/src/edit/utils.js +0 -7
- package/www/codemirror/src/input/ContentEditableInput.js +0 -546
- package/www/codemirror/src/input/TextareaInput.js +0 -380
- package/www/codemirror/src/input/indent.js +0 -71
- package/www/codemirror/src/input/input.js +0 -134
- package/www/codemirror/src/input/keymap.js +0 -147
- package/www/codemirror/src/input/keynames.js +0 -17
- package/www/codemirror/src/input/movement.js +0 -111
- package/www/codemirror/src/line/highlight.js +0 -284
- package/www/codemirror/src/line/line_data.js +0 -349
- package/www/codemirror/src/line/pos.js +0 -40
- package/www/codemirror/src/line/saw_special_spans.js +0 -10
- package/www/codemirror/src/line/spans.js +0 -390
- package/www/codemirror/src/line/utils_line.js +0 -85
- package/www/codemirror/src/measurement/position_measurement.js +0 -702
- package/www/codemirror/src/measurement/widgets.js +0 -26
- package/www/codemirror/src/model/Doc.js +0 -436
- package/www/codemirror/src/model/change_measurement.js +0 -61
- package/www/codemirror/src/model/changes.js +0 -339
- package/www/codemirror/src/model/chunk.js +0 -167
- package/www/codemirror/src/model/document_data.js +0 -112
- package/www/codemirror/src/model/history.js +0 -228
- package/www/codemirror/src/model/line_widget.js +0 -78
- package/www/codemirror/src/model/mark_text.js +0 -293
- package/www/codemirror/src/model/selection.js +0 -84
- package/www/codemirror/src/model/selection_updates.js +0 -216
- package/www/codemirror/src/modes.js +0 -96
- package/www/codemirror/src/util/StringStream.js +0 -90
- package/www/codemirror/src/util/bidi.js +0 -215
- package/www/codemirror/src/util/browser.js +0 -34
- package/www/codemirror/src/util/dom.js +0 -101
- package/www/codemirror/src/util/event.js +0 -103
- package/www/codemirror/src/util/feature_detection.js +0 -84
- package/www/codemirror/src/util/misc.js +0 -168
- package/www/codemirror/src/util/operation_group.js +0 -72
- package/www/codemirror/theme/3024-day.css +0 -41
- package/www/codemirror/theme/3024-night.css +0 -39
- package/www/codemirror/theme/abbott.css +0 -268
- package/www/codemirror/theme/abcdef.css +0 -32
- package/www/codemirror/theme/ambiance-mobile.css +0 -5
- package/www/codemirror/theme/ambiance.css +0 -74
- package/www/codemirror/theme/ayu-dark.css +0 -44
- package/www/codemirror/theme/ayu-mirage.css +0 -45
- package/www/codemirror/theme/base16-dark.css +0 -40
- package/www/codemirror/theme/base16-light.css +0 -38
- package/www/codemirror/theme/bespin.css +0 -34
- package/www/codemirror/theme/blackboard.css +0 -32
- package/www/codemirror/theme/cobalt.css +0 -25
- package/www/codemirror/theme/colorforth.css +0 -33
- package/www/codemirror/theme/darcula.css +0 -53
- package/www/codemirror/theme/dracula.css +0 -40
- package/www/codemirror/theme/duotone-dark.css +0 -35
- package/www/codemirror/theme/duotone-light.css +0 -36
- package/www/codemirror/theme/eclipse.css +0 -23
- package/www/codemirror/theme/elegant.css +0 -13
- package/www/codemirror/theme/erlang-dark.css +0 -34
- package/www/codemirror/theme/gruvbox-dark.css +0 -39
- package/www/codemirror/theme/hopscotch.css +0 -34
- package/www/codemirror/theme/icecoder.css +0 -43
- package/www/codemirror/theme/idea.css +0 -42
- package/www/codemirror/theme/isotope.css +0 -34
- package/www/codemirror/theme/juejin.css +0 -30
- package/www/codemirror/theme/lesser-dark.css +0 -47
- package/www/codemirror/theme/liquibyte.css +0 -95
- package/www/codemirror/theme/lucario.css +0 -37
- package/www/codemirror/theme/material-darker.css +0 -135
- package/www/codemirror/theme/material-palenight.css +0 -141
- package/www/codemirror/theme/material.css +0 -141
- package/www/codemirror/theme/mbo.css +0 -37
- package/www/codemirror/theme/mdn-like.css +0 -46
- package/www/codemirror/theme/midnight.css +0 -39
- package/www/codemirror/theme/monokai.css +0 -41
- package/www/codemirror/theme/moxer.css +0 -143
- package/www/codemirror/theme/neat.css +0 -12
- package/www/codemirror/theme/neo.css +0 -43
- package/www/codemirror/theme/night.css +0 -27
- package/www/codemirror/theme/nord.css +0 -42
- package/www/codemirror/theme/oceanic-next.css +0 -46
- package/www/codemirror/theme/panda-syntax.css +0 -85
- package/www/codemirror/theme/paraiso-dark.css +0 -38
- package/www/codemirror/theme/paraiso-light.css +0 -38
- package/www/codemirror/theme/pastel-on-dark.css +0 -52
- package/www/codemirror/theme/railscasts.css +0 -34
- package/www/codemirror/theme/rubyblue.css +0 -25
- package/www/codemirror/theme/seti.css +0 -44
- package/www/codemirror/theme/shadowfox.css +0 -52
- package/www/codemirror/theme/solarized.css +0 -165
- package/www/codemirror/theme/ssms.css +0 -16
- package/www/codemirror/theme/the-matrix.css +0 -30
- package/www/codemirror/theme/tomorrow-night-bright.css +0 -35
- package/www/codemirror/theme/tomorrow-night-eighties.css +0 -38
- package/www/codemirror/theme/ttcn.css +0 -64
- package/www/codemirror/theme/twilight.css +0 -32
- package/www/codemirror/theme/vibrant-ink.css +0 -34
- package/www/codemirror/theme/xq-dark.css +0 -53
- package/www/codemirror/theme/xq-light.css +0 -43
- package/www/codemirror/theme/yeti.css +0 -44
- package/www/codemirror/theme/yonce.css +0 -59
- package/www/codemirror/theme/zenburn.css +0 -37
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import { delayBlurEvent, ensureFocus } from "../display/focus.js"
|
|
2
|
-
import { operation } from "../display/operations.js"
|
|
3
|
-
import { visibleLines } from "../display/update_lines.js"
|
|
4
|
-
import { clipPos, cmp, maxPos, minPos, Pos } from "../line/pos.js"
|
|
5
|
-
import { getLine, lineAtHeight } from "../line/utils_line.js"
|
|
6
|
-
import { posFromMouse } from "../measurement/position_measurement.js"
|
|
7
|
-
import { eventInWidget } from "../measurement/widgets.js"
|
|
8
|
-
import { normalizeSelection, Range, Selection } from "../model/selection.js"
|
|
9
|
-
import { extendRange, extendSelection, replaceOneSelection, setSelection } from "../model/selection_updates.js"
|
|
10
|
-
import { captureRightClick, chromeOS, ie, ie_version, mac, webkit, safari } from "../util/browser.js"
|
|
11
|
-
import { getOrder, getBidiPartAt } from "../util/bidi.js"
|
|
12
|
-
import { activeElt, doc as getDoc, win } from "../util/dom.js"
|
|
13
|
-
import { e_button, e_defaultPrevented, e_preventDefault, e_target, hasHandler, off, on, signal, signalDOMEvent } from "../util/event.js"
|
|
14
|
-
import { dragAndDrop } from "../util/feature_detection.js"
|
|
15
|
-
import { bind, countColumn, findColumn, sel_mouse } from "../util/misc.js"
|
|
16
|
-
import { addModifierNames } from "../input/keymap.js"
|
|
17
|
-
import { Pass } from "../util/misc.js"
|
|
18
|
-
|
|
19
|
-
import { dispatchKey } from "./key_events.js"
|
|
20
|
-
import { commands } from "./commands.js"
|
|
21
|
-
|
|
22
|
-
const DOUBLECLICK_DELAY = 400
|
|
23
|
-
|
|
24
|
-
class PastClick {
|
|
25
|
-
constructor(time, pos, button) {
|
|
26
|
-
this.time = time
|
|
27
|
-
this.pos = pos
|
|
28
|
-
this.button = button
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
compare(time, pos, button) {
|
|
32
|
-
return this.time + DOUBLECLICK_DELAY > time &&
|
|
33
|
-
cmp(pos, this.pos) == 0 && button == this.button
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let lastClick, lastDoubleClick
|
|
38
|
-
function clickRepeat(pos, button) {
|
|
39
|
-
let now = +new Date
|
|
40
|
-
if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
|
|
41
|
-
lastClick = lastDoubleClick = null
|
|
42
|
-
return "triple"
|
|
43
|
-
} else if (lastClick && lastClick.compare(now, pos, button)) {
|
|
44
|
-
lastDoubleClick = new PastClick(now, pos, button)
|
|
45
|
-
lastClick = null
|
|
46
|
-
return "double"
|
|
47
|
-
} else {
|
|
48
|
-
lastClick = new PastClick(now, pos, button)
|
|
49
|
-
lastDoubleClick = null
|
|
50
|
-
return "single"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// A mouse down can be a single click, double click, triple click,
|
|
55
|
-
// start of selection drag, start of text drag, new cursor
|
|
56
|
-
// (ctrl-click), rectangle drag (alt-drag), or xwin
|
|
57
|
-
// middle-click-paste. Or it might be a click on something we should
|
|
58
|
-
// not interfere with, such as a scrollbar or widget.
|
|
59
|
-
export function onMouseDown(e) {
|
|
60
|
-
let cm = this, display = cm.display
|
|
61
|
-
if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return
|
|
62
|
-
display.input.ensurePolled()
|
|
63
|
-
display.shift = e.shiftKey
|
|
64
|
-
|
|
65
|
-
if (eventInWidget(display, e)) {
|
|
66
|
-
if (!webkit) {
|
|
67
|
-
// Briefly turn off draggability, to allow widgets to do
|
|
68
|
-
// normal dragging things.
|
|
69
|
-
display.scroller.draggable = false
|
|
70
|
-
setTimeout(() => display.scroller.draggable = true, 100)
|
|
71
|
-
}
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
if (clickInGutter(cm, e)) return
|
|
75
|
-
let pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"
|
|
76
|
-
win(cm).focus()
|
|
77
|
-
|
|
78
|
-
// #3261: make sure, that we're not starting a second selection
|
|
79
|
-
if (button == 1 && cm.state.selectingText)
|
|
80
|
-
cm.state.selectingText(e)
|
|
81
|
-
|
|
82
|
-
if (pos && handleMappedButton(cm, button, pos, repeat, e)) return
|
|
83
|
-
|
|
84
|
-
if (button == 1) {
|
|
85
|
-
if (pos) leftButtonDown(cm, pos, repeat, e)
|
|
86
|
-
else if (e_target(e) == display.scroller) e_preventDefault(e)
|
|
87
|
-
} else if (button == 2) {
|
|
88
|
-
if (pos) extendSelection(cm.doc, pos)
|
|
89
|
-
setTimeout(() => display.input.focus(), 20)
|
|
90
|
-
} else if (button == 3) {
|
|
91
|
-
if (captureRightClick) cm.display.input.onContextMenu(e)
|
|
92
|
-
else delayBlurEvent(cm)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function handleMappedButton(cm, button, pos, repeat, event) {
|
|
97
|
-
let name = "Click"
|
|
98
|
-
if (repeat == "double") name = "Double" + name
|
|
99
|
-
else if (repeat == "triple") name = "Triple" + name
|
|
100
|
-
name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name
|
|
101
|
-
|
|
102
|
-
return dispatchKey(cm, addModifierNames(name, event), event, bound => {
|
|
103
|
-
if (typeof bound == "string") bound = commands[bound]
|
|
104
|
-
if (!bound) return false
|
|
105
|
-
let done = false
|
|
106
|
-
try {
|
|
107
|
-
if (cm.isReadOnly()) cm.state.suppressEdits = true
|
|
108
|
-
done = bound(cm, pos) != Pass
|
|
109
|
-
} finally {
|
|
110
|
-
cm.state.suppressEdits = false
|
|
111
|
-
}
|
|
112
|
-
return done
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function configureMouse(cm, repeat, event) {
|
|
117
|
-
let option = cm.getOption("configureMouse")
|
|
118
|
-
let value = option ? option(cm, repeat, event) : {}
|
|
119
|
-
if (value.unit == null) {
|
|
120
|
-
let rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey
|
|
121
|
-
value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line"
|
|
122
|
-
}
|
|
123
|
-
if (value.extend == null || cm.doc.extend) value.extend = cm.doc.extend || event.shiftKey
|
|
124
|
-
if (value.addNew == null) value.addNew = mac ? event.metaKey : event.ctrlKey
|
|
125
|
-
if (value.moveOnDrag == null) value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey)
|
|
126
|
-
return value
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function leftButtonDown(cm, pos, repeat, event) {
|
|
130
|
-
if (ie) setTimeout(bind(ensureFocus, cm), 0)
|
|
131
|
-
else cm.curOp.focus = activeElt(getDoc(cm))
|
|
132
|
-
|
|
133
|
-
let behavior = configureMouse(cm, repeat, event)
|
|
134
|
-
|
|
135
|
-
let sel = cm.doc.sel, contained
|
|
136
|
-
if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
|
|
137
|
-
repeat == "single" && (contained = sel.contains(pos)) > -1 &&
|
|
138
|
-
(cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&
|
|
139
|
-
(cmp(contained.to(), pos) > 0 || pos.xRel < 0))
|
|
140
|
-
leftButtonStartDrag(cm, event, pos, behavior)
|
|
141
|
-
else
|
|
142
|
-
leftButtonSelect(cm, event, pos, behavior)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Start a text drag. When it ends, see if any dragging actually
|
|
146
|
-
// happen, and treat as a click if it didn't.
|
|
147
|
-
function leftButtonStartDrag(cm, event, pos, behavior) {
|
|
148
|
-
let display = cm.display, moved = false
|
|
149
|
-
let dragEnd = operation(cm, e => {
|
|
150
|
-
if (webkit) display.scroller.draggable = false
|
|
151
|
-
cm.state.draggingText = false
|
|
152
|
-
if (cm.state.delayingBlurEvent) {
|
|
153
|
-
if (cm.hasFocus()) cm.state.delayingBlurEvent = false
|
|
154
|
-
else delayBlurEvent(cm)
|
|
155
|
-
}
|
|
156
|
-
off(display.wrapper.ownerDocument, "mouseup", dragEnd)
|
|
157
|
-
off(display.wrapper.ownerDocument, "mousemove", mouseMove)
|
|
158
|
-
off(display.scroller, "dragstart", dragStart)
|
|
159
|
-
off(display.scroller, "drop", dragEnd)
|
|
160
|
-
if (!moved) {
|
|
161
|
-
e_preventDefault(e)
|
|
162
|
-
if (!behavior.addNew)
|
|
163
|
-
extendSelection(cm.doc, pos, null, null, behavior.extend)
|
|
164
|
-
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
|
|
165
|
-
if ((webkit && !safari) || ie && ie_version == 9)
|
|
166
|
-
setTimeout(() => {display.wrapper.ownerDocument.body.focus({preventScroll: true}); display.input.focus()}, 20)
|
|
167
|
-
else
|
|
168
|
-
display.input.focus()
|
|
169
|
-
}
|
|
170
|
-
})
|
|
171
|
-
let mouseMove = function(e2) {
|
|
172
|
-
moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10
|
|
173
|
-
}
|
|
174
|
-
let dragStart = () => moved = true
|
|
175
|
-
// Let the drag handler handle this.
|
|
176
|
-
if (webkit) display.scroller.draggable = true
|
|
177
|
-
cm.state.draggingText = dragEnd
|
|
178
|
-
dragEnd.copy = !behavior.moveOnDrag
|
|
179
|
-
on(display.wrapper.ownerDocument, "mouseup", dragEnd)
|
|
180
|
-
on(display.wrapper.ownerDocument, "mousemove", mouseMove)
|
|
181
|
-
on(display.scroller, "dragstart", dragStart)
|
|
182
|
-
on(display.scroller, "drop", dragEnd)
|
|
183
|
-
|
|
184
|
-
cm.state.delayingBlurEvent = true
|
|
185
|
-
setTimeout(() => display.input.focus(), 20)
|
|
186
|
-
// IE's approach to draggable
|
|
187
|
-
if (display.scroller.dragDrop) display.scroller.dragDrop()
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function rangeForUnit(cm, pos, unit) {
|
|
191
|
-
if (unit == "char") return new Range(pos, pos)
|
|
192
|
-
if (unit == "word") return cm.findWordAt(pos)
|
|
193
|
-
if (unit == "line") return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)))
|
|
194
|
-
let result = unit(cm, pos)
|
|
195
|
-
return new Range(result.from, result.to)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Normal selection, as opposed to text dragging.
|
|
199
|
-
function leftButtonSelect(cm, event, start, behavior) {
|
|
200
|
-
if (ie) delayBlurEvent(cm)
|
|
201
|
-
let display = cm.display, doc = cm.doc
|
|
202
|
-
e_preventDefault(event)
|
|
203
|
-
|
|
204
|
-
let ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges
|
|
205
|
-
if (behavior.addNew && !behavior.extend) {
|
|
206
|
-
ourIndex = doc.sel.contains(start)
|
|
207
|
-
if (ourIndex > -1)
|
|
208
|
-
ourRange = ranges[ourIndex]
|
|
209
|
-
else
|
|
210
|
-
ourRange = new Range(start, start)
|
|
211
|
-
} else {
|
|
212
|
-
ourRange = doc.sel.primary()
|
|
213
|
-
ourIndex = doc.sel.primIndex
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (behavior.unit == "rectangle") {
|
|
217
|
-
if (!behavior.addNew) ourRange = new Range(start, start)
|
|
218
|
-
start = posFromMouse(cm, event, true, true)
|
|
219
|
-
ourIndex = -1
|
|
220
|
-
} else {
|
|
221
|
-
let range = rangeForUnit(cm, start, behavior.unit)
|
|
222
|
-
if (behavior.extend)
|
|
223
|
-
ourRange = extendRange(ourRange, range.anchor, range.head, behavior.extend)
|
|
224
|
-
else
|
|
225
|
-
ourRange = range
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (!behavior.addNew) {
|
|
229
|
-
ourIndex = 0
|
|
230
|
-
setSelection(doc, new Selection([ourRange], 0), sel_mouse)
|
|
231
|
-
startSel = doc.sel
|
|
232
|
-
} else if (ourIndex == -1) {
|
|
233
|
-
ourIndex = ranges.length
|
|
234
|
-
setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
|
|
235
|
-
{scroll: false, origin: "*mouse"})
|
|
236
|
-
} else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
|
|
237
|
-
setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
|
238
|
-
{scroll: false, origin: "*mouse"})
|
|
239
|
-
startSel = doc.sel
|
|
240
|
-
} else {
|
|
241
|
-
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
let lastPos = start
|
|
245
|
-
function extendTo(pos) {
|
|
246
|
-
if (cmp(lastPos, pos) == 0) return
|
|
247
|
-
lastPos = pos
|
|
248
|
-
|
|
249
|
-
if (behavior.unit == "rectangle") {
|
|
250
|
-
let ranges = [], tabSize = cm.options.tabSize
|
|
251
|
-
let startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize)
|
|
252
|
-
let posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize)
|
|
253
|
-
let left = Math.min(startCol, posCol), right = Math.max(startCol, posCol)
|
|
254
|
-
for (let line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
|
255
|
-
line <= end; line++) {
|
|
256
|
-
let text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize)
|
|
257
|
-
if (left == right)
|
|
258
|
-
ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)))
|
|
259
|
-
else if (text.length > leftPos)
|
|
260
|
-
ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))))
|
|
261
|
-
}
|
|
262
|
-
if (!ranges.length) ranges.push(new Range(start, start))
|
|
263
|
-
setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
|
264
|
-
{origin: "*mouse", scroll: false})
|
|
265
|
-
cm.scrollIntoView(pos)
|
|
266
|
-
} else {
|
|
267
|
-
let oldRange = ourRange
|
|
268
|
-
let range = rangeForUnit(cm, pos, behavior.unit)
|
|
269
|
-
let anchor = oldRange.anchor, head
|
|
270
|
-
if (cmp(range.anchor, anchor) > 0) {
|
|
271
|
-
head = range.head
|
|
272
|
-
anchor = minPos(oldRange.from(), range.anchor)
|
|
273
|
-
} else {
|
|
274
|
-
head = range.anchor
|
|
275
|
-
anchor = maxPos(oldRange.to(), range.head)
|
|
276
|
-
}
|
|
277
|
-
let ranges = startSel.ranges.slice(0)
|
|
278
|
-
ranges[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head))
|
|
279
|
-
setSelection(doc, normalizeSelection(cm, ranges, ourIndex), sel_mouse)
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
let editorSize = display.wrapper.getBoundingClientRect()
|
|
284
|
-
// Used to ensure timeout re-tries don't fire when another extend
|
|
285
|
-
// happened in the meantime (clearTimeout isn't reliable -- at
|
|
286
|
-
// least on Chrome, the timeouts still happen even when cleared,
|
|
287
|
-
// if the clear happens after their scheduled firing time).
|
|
288
|
-
let counter = 0
|
|
289
|
-
|
|
290
|
-
function extend(e) {
|
|
291
|
-
let curCount = ++counter
|
|
292
|
-
let cur = posFromMouse(cm, e, true, behavior.unit == "rectangle")
|
|
293
|
-
if (!cur) return
|
|
294
|
-
if (cmp(cur, lastPos) != 0) {
|
|
295
|
-
cm.curOp.focus = activeElt(getDoc(cm))
|
|
296
|
-
extendTo(cur)
|
|
297
|
-
let visible = visibleLines(display, doc)
|
|
298
|
-
if (cur.line >= visible.to || cur.line < visible.from)
|
|
299
|
-
setTimeout(operation(cm, () => {if (counter == curCount) extend(e)}), 150)
|
|
300
|
-
} else {
|
|
301
|
-
let outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0
|
|
302
|
-
if (outside) setTimeout(operation(cm, () => {
|
|
303
|
-
if (counter != curCount) return
|
|
304
|
-
display.scroller.scrollTop += outside
|
|
305
|
-
extend(e)
|
|
306
|
-
}), 50)
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function done(e) {
|
|
311
|
-
cm.state.selectingText = false
|
|
312
|
-
counter = Infinity
|
|
313
|
-
// If e is null or undefined we interpret this as someone trying
|
|
314
|
-
// to explicitly cancel the selection rather than the user
|
|
315
|
-
// letting go of the mouse button.
|
|
316
|
-
if (e) {
|
|
317
|
-
e_preventDefault(e)
|
|
318
|
-
display.input.focus()
|
|
319
|
-
}
|
|
320
|
-
off(display.wrapper.ownerDocument, "mousemove", move)
|
|
321
|
-
off(display.wrapper.ownerDocument, "mouseup", up)
|
|
322
|
-
doc.history.lastSelOrigin = null
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
let move = operation(cm, e => {
|
|
326
|
-
if (e.buttons === 0 || !e_button(e)) done(e)
|
|
327
|
-
else extend(e)
|
|
328
|
-
})
|
|
329
|
-
let up = operation(cm, done)
|
|
330
|
-
cm.state.selectingText = up
|
|
331
|
-
on(display.wrapper.ownerDocument, "mousemove", move)
|
|
332
|
-
on(display.wrapper.ownerDocument, "mouseup", up)
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Used when mouse-selecting to adjust the anchor to the proper side
|
|
336
|
-
// of a bidi jump depending on the visual position of the head.
|
|
337
|
-
function bidiSimplify(cm, range) {
|
|
338
|
-
let {anchor, head} = range, anchorLine = getLine(cm.doc, anchor.line)
|
|
339
|
-
if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) return range
|
|
340
|
-
let order = getOrder(anchorLine)
|
|
341
|
-
if (!order) return range
|
|
342
|
-
let index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index]
|
|
343
|
-
if (part.from != anchor.ch && part.to != anchor.ch) return range
|
|
344
|
-
let boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1)
|
|
345
|
-
if (boundary == 0 || boundary == order.length) return range
|
|
346
|
-
|
|
347
|
-
// Compute the relative visual position of the head compared to the
|
|
348
|
-
// anchor (<0 is to the left, >0 to the right)
|
|
349
|
-
let leftSide
|
|
350
|
-
if (head.line != anchor.line) {
|
|
351
|
-
leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0
|
|
352
|
-
} else {
|
|
353
|
-
let headIndex = getBidiPartAt(order, head.ch, head.sticky)
|
|
354
|
-
let dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1)
|
|
355
|
-
if (headIndex == boundary - 1 || headIndex == boundary)
|
|
356
|
-
leftSide = dir < 0
|
|
357
|
-
else
|
|
358
|
-
leftSide = dir > 0
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
let usePart = order[boundary + (leftSide ? -1 : 0)]
|
|
362
|
-
let from = leftSide == (usePart.level == 1)
|
|
363
|
-
let ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before"
|
|
364
|
-
return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head)
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
// Determines whether an event happened in the gutter, and fires the
|
|
369
|
-
// handlers for the corresponding event.
|
|
370
|
-
function gutterEvent(cm, e, type, prevent) {
|
|
371
|
-
let mX, mY
|
|
372
|
-
if (e.touches) {
|
|
373
|
-
mX = e.touches[0].clientX
|
|
374
|
-
mY = e.touches[0].clientY
|
|
375
|
-
} else {
|
|
376
|
-
try { mX = e.clientX; mY = e.clientY }
|
|
377
|
-
catch(e) { return false }
|
|
378
|
-
}
|
|
379
|
-
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false
|
|
380
|
-
if (prevent) e_preventDefault(e)
|
|
381
|
-
|
|
382
|
-
let display = cm.display
|
|
383
|
-
let lineBox = display.lineDiv.getBoundingClientRect()
|
|
384
|
-
|
|
385
|
-
if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e)
|
|
386
|
-
mY -= lineBox.top - display.viewOffset
|
|
387
|
-
|
|
388
|
-
for (let i = 0; i < cm.display.gutterSpecs.length; ++i) {
|
|
389
|
-
let g = display.gutters.childNodes[i]
|
|
390
|
-
if (g && g.getBoundingClientRect().right >= mX) {
|
|
391
|
-
let line = lineAtHeight(cm.doc, mY)
|
|
392
|
-
let gutter = cm.display.gutterSpecs[i]
|
|
393
|
-
signal(cm, type, cm, line, gutter.className, e)
|
|
394
|
-
return e_defaultPrevented(e)
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export function clickInGutter(cm, e) {
|
|
400
|
-
return gutterEvent(cm, e, "gutterClick", true)
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// CONTEXT MENU HANDLING
|
|
404
|
-
|
|
405
|
-
// To make the context menu work, we need to briefly unhide the
|
|
406
|
-
// textarea (making it as unobtrusive as possible) to let the
|
|
407
|
-
// right-click take effect on it.
|
|
408
|
-
export function onContextMenu(cm, e) {
|
|
409
|
-
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return
|
|
410
|
-
if (signalDOMEvent(cm, e, "contextmenu")) return
|
|
411
|
-
if (!captureRightClick) cm.display.input.onContextMenu(e)
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
function contextMenuInGutter(cm, e) {
|
|
415
|
-
if (!hasHandler(cm, "gutterContextMenu")) return false
|
|
416
|
-
return gutterEvent(cm, e, "gutterContextMenu", false)
|
|
417
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { onBlur } from "../display/focus.js"
|
|
2
|
-
import { getGutters, updateGutters } from "../display/gutters.js"
|
|
3
|
-
import { loadMode, resetModeState } from "../display/mode_state.js"
|
|
4
|
-
import { initScrollbars, updateScrollbars } from "../display/scrollbars.js"
|
|
5
|
-
import { updateSelection } from "../display/selection.js"
|
|
6
|
-
import { regChange } from "../display/view_tracking.js"
|
|
7
|
-
import { getKeyMap } from "../input/keymap.js"
|
|
8
|
-
import { defaultSpecialCharPlaceholder } from "../line/line_data.js"
|
|
9
|
-
import { Pos } from "../line/pos.js"
|
|
10
|
-
import { findMaxLine } from "../line/spans.js"
|
|
11
|
-
import { clearCaches, compensateForHScroll, estimateLineHeights } from "../measurement/position_measurement.js"
|
|
12
|
-
import { replaceRange } from "../model/changes.js"
|
|
13
|
-
import { mobile, windows } from "../util/browser.js"
|
|
14
|
-
import { addClass, rmClass } from "../util/dom.js"
|
|
15
|
-
import { off, on } from "../util/event.js"
|
|
16
|
-
|
|
17
|
-
import { themeChanged } from "./utils.js"
|
|
18
|
-
|
|
19
|
-
export let Init = {toString: function(){return "CodeMirror.Init"}}
|
|
20
|
-
|
|
21
|
-
export let defaults = {}
|
|
22
|
-
export let optionHandlers = {}
|
|
23
|
-
|
|
24
|
-
export function defineOptions(CodeMirror) {
|
|
25
|
-
let optionHandlers = CodeMirror.optionHandlers
|
|
26
|
-
|
|
27
|
-
function option(name, deflt, handle, notOnInit) {
|
|
28
|
-
CodeMirror.defaults[name] = deflt
|
|
29
|
-
if (handle) optionHandlers[name] =
|
|
30
|
-
notOnInit ? (cm, val, old) => {if (old != Init) handle(cm, val, old)} : handle
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
CodeMirror.defineOption = option
|
|
34
|
-
|
|
35
|
-
// Passed to option handlers when there is no old value.
|
|
36
|
-
CodeMirror.Init = Init
|
|
37
|
-
|
|
38
|
-
// These two are, on init, called from the constructor because they
|
|
39
|
-
// have to be initialized before the editor can start at all.
|
|
40
|
-
option("value", "", (cm, val) => cm.setValue(val), true)
|
|
41
|
-
option("mode", null, (cm, val) => {
|
|
42
|
-
cm.doc.modeOption = val
|
|
43
|
-
loadMode(cm)
|
|
44
|
-
}, true)
|
|
45
|
-
|
|
46
|
-
option("indentUnit", 2, loadMode, true)
|
|
47
|
-
option("indentWithTabs", false)
|
|
48
|
-
option("smartIndent", true)
|
|
49
|
-
option("tabSize", 4, cm => {
|
|
50
|
-
resetModeState(cm)
|
|
51
|
-
clearCaches(cm)
|
|
52
|
-
regChange(cm)
|
|
53
|
-
}, true)
|
|
54
|
-
|
|
55
|
-
option("lineSeparator", null, (cm, val) => {
|
|
56
|
-
cm.doc.lineSep = val
|
|
57
|
-
if (!val) return
|
|
58
|
-
let newBreaks = [], lineNo = cm.doc.first
|
|
59
|
-
cm.doc.iter(line => {
|
|
60
|
-
for (let pos = 0;;) {
|
|
61
|
-
let found = line.text.indexOf(val, pos)
|
|
62
|
-
if (found == -1) break
|
|
63
|
-
pos = found + val.length
|
|
64
|
-
newBreaks.push(Pos(lineNo, found))
|
|
65
|
-
}
|
|
66
|
-
lineNo++
|
|
67
|
-
})
|
|
68
|
-
for (let i = newBreaks.length - 1; i >= 0; i--)
|
|
69
|
-
replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length))
|
|
70
|
-
})
|
|
71
|
-
option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g, (cm, val, old) => {
|
|
72
|
-
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
|
|
73
|
-
if (old != Init) cm.refresh()
|
|
74
|
-
})
|
|
75
|
-
option("specialCharPlaceholder", defaultSpecialCharPlaceholder, cm => cm.refresh(), true)
|
|
76
|
-
option("electricChars", true)
|
|
77
|
-
option("inputStyle", mobile ? "contenteditable" : "textarea", () => {
|
|
78
|
-
throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
|
|
79
|
-
}, true)
|
|
80
|
-
option("spellcheck", false, (cm, val) => cm.getInputField().spellcheck = val, true)
|
|
81
|
-
option("autocorrect", false, (cm, val) => cm.getInputField().autocorrect = val, true)
|
|
82
|
-
option("autocapitalize", false, (cm, val) => cm.getInputField().autocapitalize = val, true)
|
|
83
|
-
option("rtlMoveVisually", !windows)
|
|
84
|
-
option("wholeLineUpdateBefore", true)
|
|
85
|
-
|
|
86
|
-
option("theme", "default", cm => {
|
|
87
|
-
themeChanged(cm)
|
|
88
|
-
updateGutters(cm)
|
|
89
|
-
}, true)
|
|
90
|
-
option("keyMap", "default", (cm, val, old) => {
|
|
91
|
-
let next = getKeyMap(val)
|
|
92
|
-
let prev = old != Init && getKeyMap(old)
|
|
93
|
-
if (prev && prev.detach) prev.detach(cm, next)
|
|
94
|
-
if (next.attach) next.attach(cm, prev || null)
|
|
95
|
-
})
|
|
96
|
-
option("extraKeys", null)
|
|
97
|
-
option("configureMouse", null)
|
|
98
|
-
|
|
99
|
-
option("lineWrapping", false, wrappingChanged, true)
|
|
100
|
-
option("gutters", [], (cm, val) => {
|
|
101
|
-
cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers)
|
|
102
|
-
updateGutters(cm)
|
|
103
|
-
}, true)
|
|
104
|
-
option("fixedGutter", true, (cm, val) => {
|
|
105
|
-
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"
|
|
106
|
-
cm.refresh()
|
|
107
|
-
}, true)
|
|
108
|
-
option("coverGutterNextToScrollbar", false, cm => updateScrollbars(cm), true)
|
|
109
|
-
option("scrollbarStyle", "native", cm => {
|
|
110
|
-
initScrollbars(cm)
|
|
111
|
-
updateScrollbars(cm)
|
|
112
|
-
cm.display.scrollbars.setScrollTop(cm.doc.scrollTop)
|
|
113
|
-
cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft)
|
|
114
|
-
}, true)
|
|
115
|
-
option("lineNumbers", false, (cm, val) => {
|
|
116
|
-
cm.display.gutterSpecs = getGutters(cm.options.gutters, val)
|
|
117
|
-
updateGutters(cm)
|
|
118
|
-
}, true)
|
|
119
|
-
option("firstLineNumber", 1, updateGutters, true)
|
|
120
|
-
option("lineNumberFormatter", integer => integer, updateGutters, true)
|
|
121
|
-
option("showCursorWhenSelecting", false, updateSelection, true)
|
|
122
|
-
|
|
123
|
-
option("resetSelectionOnContextMenu", true)
|
|
124
|
-
option("lineWiseCopyCut", true)
|
|
125
|
-
option("pasteLinesPerSelection", true)
|
|
126
|
-
option("selectionsMayTouch", false)
|
|
127
|
-
|
|
128
|
-
option("readOnly", false, (cm, val) => {
|
|
129
|
-
if (val == "nocursor") {
|
|
130
|
-
onBlur(cm)
|
|
131
|
-
cm.display.input.blur()
|
|
132
|
-
}
|
|
133
|
-
cm.display.input.readOnlyChanged(val)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
option("screenReaderLabel", null, (cm, val) => {
|
|
137
|
-
val = (val === '') ? null : val
|
|
138
|
-
cm.display.input.screenReaderLabelChanged(val)
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
option("disableInput", false, (cm, val) => {if (!val) cm.display.input.reset()}, true)
|
|
142
|
-
option("dragDrop", true, dragDropChanged)
|
|
143
|
-
option("allowDropFileTypes", null)
|
|
144
|
-
|
|
145
|
-
option("cursorBlinkRate", 530)
|
|
146
|
-
option("cursorScrollMargin", 0)
|
|
147
|
-
option("cursorHeight", 1, updateSelection, true)
|
|
148
|
-
option("singleCursorHeightPerLine", true, updateSelection, true)
|
|
149
|
-
option("workTime", 100)
|
|
150
|
-
option("workDelay", 100)
|
|
151
|
-
option("flattenSpans", true, resetModeState, true)
|
|
152
|
-
option("addModeClass", false, resetModeState, true)
|
|
153
|
-
option("pollInterval", 100)
|
|
154
|
-
option("undoDepth", 200, (cm, val) => cm.doc.history.undoDepth = val)
|
|
155
|
-
option("historyEventDelay", 1250)
|
|
156
|
-
option("viewportMargin", 10, cm => cm.refresh(), true)
|
|
157
|
-
option("maxHighlightLength", 10000, resetModeState, true)
|
|
158
|
-
option("moveInputWithCursor", true, (cm, val) => {
|
|
159
|
-
if (!val) cm.display.input.resetPosition()
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
option("tabindex", null, (cm, val) => cm.display.input.getField().tabIndex = val || "")
|
|
163
|
-
option("autofocus", null)
|
|
164
|
-
option("direction", "ltr", (cm, val) => cm.doc.setDirection(val), true)
|
|
165
|
-
option("phrases", null)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function dragDropChanged(cm, value, old) {
|
|
169
|
-
let wasOn = old && old != Init
|
|
170
|
-
if (!value != !wasOn) {
|
|
171
|
-
let funcs = cm.display.dragFunctions
|
|
172
|
-
let toggle = value ? on : off
|
|
173
|
-
toggle(cm.display.scroller, "dragstart", funcs.start)
|
|
174
|
-
toggle(cm.display.scroller, "dragenter", funcs.enter)
|
|
175
|
-
toggle(cm.display.scroller, "dragover", funcs.over)
|
|
176
|
-
toggle(cm.display.scroller, "dragleave", funcs.leave)
|
|
177
|
-
toggle(cm.display.scroller, "drop", funcs.drop)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function wrappingChanged(cm) {
|
|
182
|
-
if (cm.options.lineWrapping) {
|
|
183
|
-
addClass(cm.display.wrapper, "CodeMirror-wrap")
|
|
184
|
-
cm.display.sizer.style.minWidth = ""
|
|
185
|
-
cm.display.sizerWidth = null
|
|
186
|
-
} else {
|
|
187
|
-
rmClass(cm.display.wrapper, "CodeMirror-wrap")
|
|
188
|
-
findMaxLine(cm)
|
|
189
|
-
}
|
|
190
|
-
estimateLineHeights(cm)
|
|
191
|
-
regChange(cm)
|
|
192
|
-
clearCaches(cm)
|
|
193
|
-
setTimeout(() => updateScrollbars(cm), 100)
|
|
194
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { clearCaches } from "../measurement/position_measurement.js"
|
|
2
|
-
|
|
3
|
-
export function themeChanged(cm) {
|
|
4
|
-
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
|
|
5
|
-
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-")
|
|
6
|
-
clearCaches(cm)
|
|
7
|
-
}
|