@muze-nl/simplystore 0.1.2
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/.dockerignore +8 -0
- package/.github/workflows/docker-build.yml +45 -0
- package/.gitignore~ +1 -0
- package/Dockerfile +60 -0
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/data.jsontag +20 -0
- package/design/access-management.md +25 -0
- package/design/acid.md +31 -0
- package/design/commands.md +25 -0
- package/design/identity.md +71 -0
- package/design/immutability.md +26 -0
- package/design/jsontag-selector.md +365 -0
- package/design/multitasking.md +13 -0
- package/design/thoughts.md +32 -0
- package/docs/docker.md +129 -0
- package/package.json +29 -0
- package/package.json~ +29 -0
- package/src/run.mjs +3 -0
- package/src/server.mjs +323 -0
- package/src/triplestore.mjs +182 -0
- package/www/assets/css/style.css +2296 -0
- package/www/assets/feather-sprite.svg +1 -0
- package/www/assets/img/simplystore-narrow-white.svg +138 -0
- package/www/assets/img/simplystore-narrow.svg +138 -0
- package/www/assets/img/simplystore-white.svg +153 -0
- package/www/assets/img/simplystore.svg +153 -0
- package/www/codemirror/AUTHORS +979 -0
- package/www/codemirror/CHANGELOG.md +2208 -0
- package/www/codemirror/CONTRIBUTING.md +92 -0
- package/www/codemirror/LICENSE +21 -0
- package/www/codemirror/README.md +47 -0
- package/www/codemirror/addon/comment/comment.js +211 -0
- package/www/codemirror/addon/comment/continuecomment.js +114 -0
- package/www/codemirror/addon/dialog/dialog.css +32 -0
- package/www/codemirror/addon/dialog/dialog.js +163 -0
- package/www/codemirror/addon/display/autorefresh.js +47 -0
- package/www/codemirror/addon/display/fullscreen.css +6 -0
- package/www/codemirror/addon/display/fullscreen.js +41 -0
- package/www/codemirror/addon/display/panel.js +133 -0
- package/www/codemirror/addon/display/placeholder.js +78 -0
- package/www/codemirror/addon/display/rulers.js +51 -0
- package/www/codemirror/addon/edit/closebrackets.js +201 -0
- package/www/codemirror/addon/edit/closetag.js +185 -0
- package/www/codemirror/addon/edit/continuelist.js +101 -0
- package/www/codemirror/addon/edit/matchbrackets.js +160 -0
- package/www/codemirror/addon/edit/matchtags.js +66 -0
- package/www/codemirror/addon/edit/trailingspace.js +27 -0
- package/www/codemirror/addon/fold/brace-fold.js +119 -0
- package/www/codemirror/addon/fold/comment-fold.js +59 -0
- package/www/codemirror/addon/fold/foldcode.js +159 -0
- package/www/codemirror/addon/fold/foldgutter.css +20 -0
- package/www/codemirror/addon/fold/foldgutter.js +169 -0
- package/www/codemirror/addon/fold/indent-fold.js +48 -0
- package/www/codemirror/addon/fold/markdown-fold.js +49 -0
- package/www/codemirror/addon/fold/xml-fold.js +184 -0
- package/www/codemirror/addon/hint/anyword-hint.js +41 -0
- package/www/codemirror/addon/hint/css-hint.js +66 -0
- package/www/codemirror/addon/hint/html-hint.js +351 -0
- package/www/codemirror/addon/hint/javascript-hint.js +162 -0
- package/www/codemirror/addon/hint/show-hint.css +37 -0
- package/www/codemirror/addon/hint/show-hint.js +523 -0
- package/www/codemirror/addon/hint/sql-hint.js +304 -0
- package/www/codemirror/addon/hint/xml-hint.js +132 -0
- package/www/codemirror/addon/lint/coffeescript-lint.js +47 -0
- package/www/codemirror/addon/lint/css-lint.js +40 -0
- package/www/codemirror/addon/lint/html-lint.js +59 -0
- package/www/codemirror/addon/lint/javascript-lint.js +65 -0
- package/www/codemirror/addon/lint/json-lint.js +40 -0
- package/www/codemirror/addon/lint/lint.css +79 -0
- package/www/codemirror/addon/lint/lint.js +291 -0
- package/www/codemirror/addon/lint/yaml-lint.js +41 -0
- package/www/codemirror/addon/merge/merge.css +119 -0
- package/www/codemirror/addon/merge/merge.js +1018 -0
- package/www/codemirror/addon/mode/loadmode.js +66 -0
- package/www/codemirror/addon/mode/multiplex.js +136 -0
- package/www/codemirror/addon/mode/multiplex_test.js +49 -0
- package/www/codemirror/addon/mode/overlay.js +90 -0
- package/www/codemirror/addon/mode/simple.js +216 -0
- package/www/codemirror/addon/runmode/colorize.js +40 -0
- package/www/codemirror/addon/runmode/runmode-standalone.js +334 -0
- package/www/codemirror/addon/runmode/runmode.js +76 -0
- package/www/codemirror/addon/runmode/runmode.node.js +329 -0
- package/www/codemirror/addon/scroll/annotatescrollbar.js +128 -0
- package/www/codemirror/addon/scroll/scrollpastend.js +48 -0
- package/www/codemirror/addon/scroll/simplescrollbars.css +66 -0
- package/www/codemirror/addon/scroll/simplescrollbars.js +152 -0
- package/www/codemirror/addon/search/jump-to-line.js +53 -0
- package/www/codemirror/addon/search/match-highlighter.js +167 -0
- package/www/codemirror/addon/search/matchesonscrollbar.css +8 -0
- package/www/codemirror/addon/search/matchesonscrollbar.js +97 -0
- package/www/codemirror/addon/search/search.js +295 -0
- package/www/codemirror/addon/search/searchcursor.js +305 -0
- package/www/codemirror/addon/selection/active-line.js +72 -0
- package/www/codemirror/addon/selection/mark-selection.js +119 -0
- package/www/codemirror/addon/selection/selection-pointer.js +98 -0
- package/www/codemirror/addon/tern/tern.css +87 -0
- package/www/codemirror/addon/tern/tern.js +756 -0
- package/www/codemirror/addon/tern/worker.js +44 -0
- package/www/codemirror/addon/wrap/hardwrap.js +160 -0
- package/www/codemirror/bin/source-highlight +48 -0
- package/www/codemirror/keymap/emacs.js +545 -0
- package/www/codemirror/keymap/sublime.js +720 -0
- package/www/codemirror/keymap/vim.js +5978 -0
- package/www/codemirror/lib/codemirror.css +344 -0
- package/www/codemirror/lib/codemirror.js +9874 -0
- package/www/codemirror/mode/apl/apl.js +174 -0
- package/www/codemirror/mode/asciiarmor/asciiarmor.js +74 -0
- package/www/codemirror/mode/asn.1/asn.1.js +204 -0
- package/www/codemirror/mode/asterisk/asterisk.js +220 -0
- package/www/codemirror/mode/brainfuck/brainfuck.js +85 -0
- package/www/codemirror/mode/clike/clike.js +940 -0
- package/www/codemirror/mode/clojure/clojure.js +292 -0
- package/www/codemirror/mode/cmake/cmake.js +97 -0
- package/www/codemirror/mode/cobol/cobol.js +255 -0
- package/www/codemirror/mode/coffeescript/coffeescript.js +359 -0
- package/www/codemirror/mode/commonlisp/commonlisp.js +125 -0
- package/www/codemirror/mode/crystal/crystal.js +433 -0
- package/www/codemirror/mode/css/css.js +862 -0
- package/www/codemirror/mode/cypher/cypher.js +152 -0
- package/www/codemirror/mode/d/d.js +223 -0
- package/www/codemirror/mode/dart/dart.js +166 -0
- package/www/codemirror/mode/diff/diff.js +47 -0
- package/www/codemirror/mode/django/django.js +356 -0
- package/www/codemirror/mode/dockerfile/dockerfile.js +211 -0
- package/www/codemirror/mode/dtd/dtd.js +142 -0
- package/www/codemirror/mode/dylan/dylan.js +352 -0
- package/www/codemirror/mode/ebnf/ebnf.js +195 -0
- package/www/codemirror/mode/ecl/ecl.js +206 -0
- package/www/codemirror/mode/eiffel/eiffel.js +160 -0
- package/www/codemirror/mode/elm/elm.js +245 -0
- package/www/codemirror/mode/erlang/erlang.js +619 -0
- package/www/codemirror/mode/factor/factor.js +85 -0
- package/www/codemirror/mode/fcl/fcl.js +173 -0
- package/www/codemirror/mode/forth/forth.js +180 -0
- package/www/codemirror/mode/fortran/fortran.js +188 -0
- package/www/codemirror/mode/gas/gas.js +353 -0
- package/www/codemirror/mode/gfm/gfm.js +129 -0
- package/www/codemirror/mode/gherkin/gherkin.js +178 -0
- package/www/codemirror/mode/go/go.js +187 -0
- package/www/codemirror/mode/groovy/groovy.js +247 -0
- package/www/codemirror/mode/haml/haml.js +161 -0
- package/www/codemirror/mode/handlebars/handlebars.js +70 -0
- package/www/codemirror/mode/haskell/haskell.js +268 -0
- package/www/codemirror/mode/haskell-literate/haskell-literate.js +43 -0
- package/www/codemirror/mode/haxe/haxe.js +515 -0
- package/www/codemirror/mode/htmlembedded/htmlembedded.js +37 -0
- package/www/codemirror/mode/htmlmixed/htmlmixed.js +153 -0
- package/www/codemirror/mode/http/http.js +113 -0
- package/www/codemirror/mode/idl/idl.js +290 -0
- package/www/codemirror/mode/javascript/javascript.js +960 -0
- package/www/codemirror/mode/jinja2/jinja2.js +193 -0
- package/www/codemirror/mode/jsx/jsx.js +148 -0
- package/www/codemirror/mode/julia/julia.js +390 -0
- package/www/codemirror/mode/livescript/livescript.js +280 -0
- package/www/codemirror/mode/lua/lua.js +160 -0
- package/www/codemirror/mode/markdown/markdown.js +886 -0
- package/www/codemirror/mode/mathematica/mathematica.js +176 -0
- package/www/codemirror/mode/mbox/mbox.js +129 -0
- package/www/codemirror/mode/meta.js +221 -0
- package/www/codemirror/mode/mirc/mirc.js +193 -0
- package/www/codemirror/mode/mllike/mllike.js +359 -0
- package/www/codemirror/mode/modelica/modelica.js +245 -0
- package/www/codemirror/mode/mscgen/mscgen.js +175 -0
- package/www/codemirror/mode/mumps/mumps.js +148 -0
- package/www/codemirror/mode/nginx/nginx.js +178 -0
- package/www/codemirror/mode/nsis/nsis.js +95 -0
- package/www/codemirror/mode/ntriples/ntriples.js +195 -0
- package/www/codemirror/mode/octave/octave.js +139 -0
- package/www/codemirror/mode/oz/oz.js +252 -0
- package/www/codemirror/mode/pascal/pascal.js +136 -0
- package/www/codemirror/mode/pegjs/pegjs.js +111 -0
- package/www/codemirror/mode/perl/perl.js +836 -0
- package/www/codemirror/mode/php/php.js +234 -0
- package/www/codemirror/mode/pig/pig.js +178 -0
- package/www/codemirror/mode/powershell/powershell.js +398 -0
- package/www/codemirror/mode/properties/properties.js +78 -0
- package/www/codemirror/mode/protobuf/protobuf.js +72 -0
- package/www/codemirror/mode/pug/pug.js +591 -0
- package/www/codemirror/mode/puppet/puppet.js +220 -0
- package/www/codemirror/mode/python/python.js +402 -0
- package/www/codemirror/mode/q/q.js +139 -0
- package/www/codemirror/mode/r/r.js +190 -0
- package/www/codemirror/mode/rpm/changes/index.html +66 -0
- package/www/codemirror/mode/rpm/rpm.js +109 -0
- package/www/codemirror/mode/rst/rst.js +557 -0
- package/www/codemirror/mode/ruby/ruby.js +303 -0
- package/www/codemirror/mode/rust/rust.js +72 -0
- package/www/codemirror/mode/sas/sas.js +303 -0
- package/www/codemirror/mode/sass/sass.js +459 -0
- package/www/codemirror/mode/scheme/scheme.js +284 -0
- package/www/codemirror/mode/shell/shell.js +168 -0
- package/www/codemirror/mode/sieve/sieve.js +193 -0
- package/www/codemirror/mode/slim/slim.js +575 -0
- package/www/codemirror/mode/smalltalk/smalltalk.js +168 -0
- package/www/codemirror/mode/smarty/smarty.js +225 -0
- package/www/codemirror/mode/solr/solr.js +104 -0
- package/www/codemirror/mode/soy/soy.js +665 -0
- package/www/codemirror/mode/sparql/sparql.js +184 -0
- package/www/codemirror/mode/spreadsheet/spreadsheet.js +112 -0
- package/www/codemirror/mode/sql/sql.js +525 -0
- package/www/codemirror/mode/stex/stex.js +264 -0
- package/www/codemirror/mode/stylus/stylus.js +775 -0
- package/www/codemirror/mode/swift/swift.js +221 -0
- package/www/codemirror/mode/tcl/tcl.js +140 -0
- package/www/codemirror/mode/textile/textile.js +469 -0
- package/www/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- package/www/codemirror/mode/tiddlywiki/tiddlywiki.js +308 -0
- package/www/codemirror/mode/tiki/tiki.css +26 -0
- package/www/codemirror/mode/tiki/tiki.js +312 -0
- package/www/codemirror/mode/toml/toml.js +88 -0
- package/www/codemirror/mode/tornado/tornado.js +68 -0
- package/www/codemirror/mode/troff/troff.js +84 -0
- package/www/codemirror/mode/ttcn/ttcn.js +283 -0
- package/www/codemirror/mode/ttcn-cfg/ttcn-cfg.js +214 -0
- package/www/codemirror/mode/turtle/turtle.js +162 -0
- package/www/codemirror/mode/twig/twig.js +141 -0
- package/www/codemirror/mode/vb/vb.js +275 -0
- package/www/codemirror/mode/vbscript/vbscript.js +350 -0
- package/www/codemirror/mode/velocity/velocity.js +202 -0
- package/www/codemirror/mode/verilog/verilog.js +781 -0
- package/www/codemirror/mode/vhdl/vhdl.js +189 -0
- package/www/codemirror/mode/vue/vue.js +77 -0
- package/www/codemirror/mode/wast/wast.js +132 -0
- package/www/codemirror/mode/webidl/webidl.js +195 -0
- package/www/codemirror/mode/xml/xml.js +417 -0
- package/www/codemirror/mode/xquery/xquery.js +448 -0
- package/www/codemirror/mode/yacas/yacas.js +204 -0
- package/www/codemirror/mode/yaml/yaml.js +120 -0
- package/www/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +72 -0
- package/www/codemirror/mode/z80/z80.js +116 -0
- package/www/codemirror/package.json +52 -0
- package/www/codemirror/rollup.config.js +52 -0
- package/www/codemirror/src/addon/runmode/codemirror-standalone.js +24 -0
- package/www/codemirror/src/addon/runmode/codemirror.node.js +21 -0
- package/www/codemirror/src/addon/runmode/runmode-standalone.js +2 -0
- package/www/codemirror/src/addon/runmode/runmode.node.js +2 -0
- package/www/codemirror/src/codemirror.js +3 -0
- package/www/codemirror/src/display/Display.js +116 -0
- package/www/codemirror/src/display/focus.js +50 -0
- package/www/codemirror/src/display/gutters.js +44 -0
- package/www/codemirror/src/display/highlight_worker.js +55 -0
- package/www/codemirror/src/display/line_numbers.js +48 -0
- package/www/codemirror/src/display/mode_state.js +22 -0
- package/www/codemirror/src/display/operations.js +206 -0
- package/www/codemirror/src/display/scroll_events.js +132 -0
- package/www/codemirror/src/display/scrollbars.js +194 -0
- package/www/codemirror/src/display/scrolling.js +186 -0
- package/www/codemirror/src/display/selection.js +173 -0
- package/www/codemirror/src/display/update_display.js +267 -0
- package/www/codemirror/src/display/update_line.js +189 -0
- package/www/codemirror/src/display/update_lines.js +82 -0
- package/www/codemirror/src/display/view_tracking.js +153 -0
- package/www/codemirror/src/edit/CodeMirror.js +217 -0
- package/www/codemirror/src/edit/commands.js +178 -0
- package/www/codemirror/src/edit/deleteNearSelection.js +30 -0
- package/www/codemirror/src/edit/drop_events.js +130 -0
- package/www/codemirror/src/edit/fromTextArea.js +61 -0
- package/www/codemirror/src/edit/global_events.js +45 -0
- package/www/codemirror/src/edit/key_events.js +163 -0
- package/www/codemirror/src/edit/legacy.js +62 -0
- package/www/codemirror/src/edit/main.js +69 -0
- package/www/codemirror/src/edit/methods.js +555 -0
- package/www/codemirror/src/edit/mouse_events.js +417 -0
- package/www/codemirror/src/edit/options.js +194 -0
- package/www/codemirror/src/edit/utils.js +7 -0
- package/www/codemirror/src/input/ContentEditableInput.js +546 -0
- package/www/codemirror/src/input/TextareaInput.js +380 -0
- package/www/codemirror/src/input/indent.js +71 -0
- package/www/codemirror/src/input/input.js +134 -0
- package/www/codemirror/src/input/keymap.js +147 -0
- package/www/codemirror/src/input/keynames.js +17 -0
- package/www/codemirror/src/input/movement.js +111 -0
- package/www/codemirror/src/line/highlight.js +284 -0
- package/www/codemirror/src/line/line_data.js +349 -0
- package/www/codemirror/src/line/pos.js +40 -0
- package/www/codemirror/src/line/saw_special_spans.js +10 -0
- package/www/codemirror/src/line/spans.js +390 -0
- package/www/codemirror/src/line/utils_line.js +85 -0
- package/www/codemirror/src/measurement/position_measurement.js +702 -0
- package/www/codemirror/src/measurement/widgets.js +26 -0
- package/www/codemirror/src/model/Doc.js +436 -0
- package/www/codemirror/src/model/change_measurement.js +61 -0
- package/www/codemirror/src/model/changes.js +339 -0
- package/www/codemirror/src/model/chunk.js +167 -0
- package/www/codemirror/src/model/document_data.js +112 -0
- package/www/codemirror/src/model/history.js +228 -0
- package/www/codemirror/src/model/line_widget.js +78 -0
- package/www/codemirror/src/model/mark_text.js +293 -0
- package/www/codemirror/src/model/selection.js +84 -0
- package/www/codemirror/src/model/selection_updates.js +216 -0
- package/www/codemirror/src/modes.js +96 -0
- package/www/codemirror/src/util/StringStream.js +90 -0
- package/www/codemirror/src/util/bidi.js +215 -0
- package/www/codemirror/src/util/browser.js +34 -0
- package/www/codemirror/src/util/dom.js +101 -0
- package/www/codemirror/src/util/event.js +103 -0
- package/www/codemirror/src/util/feature_detection.js +84 -0
- package/www/codemirror/src/util/misc.js +168 -0
- package/www/codemirror/src/util/operation_group.js +72 -0
- package/www/codemirror/theme/3024-day.css +41 -0
- package/www/codemirror/theme/3024-night.css +39 -0
- package/www/codemirror/theme/abbott.css +268 -0
- package/www/codemirror/theme/abcdef.css +32 -0
- package/www/codemirror/theme/ambiance-mobile.css +5 -0
- package/www/codemirror/theme/ambiance.css +74 -0
- package/www/codemirror/theme/ayu-dark.css +44 -0
- package/www/codemirror/theme/ayu-mirage.css +45 -0
- package/www/codemirror/theme/base16-dark.css +40 -0
- package/www/codemirror/theme/base16-light.css +38 -0
- package/www/codemirror/theme/bespin.css +34 -0
- package/www/codemirror/theme/blackboard.css +32 -0
- package/www/codemirror/theme/cobalt.css +25 -0
- package/www/codemirror/theme/colorforth.css +33 -0
- package/www/codemirror/theme/darcula.css +53 -0
- package/www/codemirror/theme/dracula.css +40 -0
- package/www/codemirror/theme/duotone-dark.css +35 -0
- package/www/codemirror/theme/duotone-light.css +36 -0
- package/www/codemirror/theme/eclipse.css +23 -0
- package/www/codemirror/theme/elegant.css +13 -0
- package/www/codemirror/theme/erlang-dark.css +34 -0
- package/www/codemirror/theme/gruvbox-dark.css +39 -0
- package/www/codemirror/theme/hopscotch.css +34 -0
- package/www/codemirror/theme/icecoder.css +43 -0
- package/www/codemirror/theme/idea.css +42 -0
- package/www/codemirror/theme/isotope.css +34 -0
- package/www/codemirror/theme/juejin.css +30 -0
- package/www/codemirror/theme/lesser-dark.css +47 -0
- package/www/codemirror/theme/liquibyte.css +95 -0
- package/www/codemirror/theme/lucario.css +37 -0
- package/www/codemirror/theme/material-darker.css +135 -0
- package/www/codemirror/theme/material-ocean.css +141 -0
- package/www/codemirror/theme/material-palenight.css +141 -0
- package/www/codemirror/theme/material.css +141 -0
- package/www/codemirror/theme/mbo.css +37 -0
- package/www/codemirror/theme/mdn-like.css +46 -0
- package/www/codemirror/theme/midnight.css +39 -0
- package/www/codemirror/theme/monokai.css +41 -0
- package/www/codemirror/theme/moxer.css +143 -0
- package/www/codemirror/theme/neat.css +12 -0
- package/www/codemirror/theme/neo.css +43 -0
- package/www/codemirror/theme/night.css +27 -0
- package/www/codemirror/theme/nord.css +42 -0
- package/www/codemirror/theme/oceanic-next.css +46 -0
- package/www/codemirror/theme/panda-syntax.css +85 -0
- package/www/codemirror/theme/paraiso-dark.css +38 -0
- package/www/codemirror/theme/paraiso-light.css +38 -0
- package/www/codemirror/theme/pastel-on-dark.css +52 -0
- package/www/codemirror/theme/railscasts.css +34 -0
- package/www/codemirror/theme/rubyblue.css +25 -0
- package/www/codemirror/theme/seti.css +44 -0
- package/www/codemirror/theme/shadowfox.css +52 -0
- package/www/codemirror/theme/solarized.css +165 -0
- package/www/codemirror/theme/ssms.css +16 -0
- package/www/codemirror/theme/the-matrix.css +30 -0
- package/www/codemirror/theme/tomorrow-night-bright.css +35 -0
- package/www/codemirror/theme/tomorrow-night-eighties.css +38 -0
- package/www/codemirror/theme/ttcn.css +64 -0
- package/www/codemirror/theme/twilight.css +32 -0
- package/www/codemirror/theme/vibrant-ink.css +34 -0
- package/www/codemirror/theme/xq-dark.css +53 -0
- package/www/codemirror/theme/xq-light.css +43 -0
- package/www/codemirror/theme/yeti.css +44 -0
- package/www/codemirror/theme/yonce.css +59 -0
- package/www/codemirror/theme/zenburn.css +37 -0
- package/www/index.html +216 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ie, ios } from "./browser.js"
|
|
2
|
+
|
|
3
|
+
export function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
|
|
4
|
+
|
|
5
|
+
export let rmClass = function(node, cls) {
|
|
6
|
+
let current = node.className
|
|
7
|
+
let match = classTest(cls).exec(current)
|
|
8
|
+
if (match) {
|
|
9
|
+
let after = current.slice(match.index + match[0].length)
|
|
10
|
+
node.className = current.slice(0, match.index) + (after ? match[1] + after : "")
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function removeChildren(e) {
|
|
15
|
+
for (let count = e.childNodes.length; count > 0; --count)
|
|
16
|
+
e.removeChild(e.firstChild)
|
|
17
|
+
return e
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function removeChildrenAndAdd(parent, e) {
|
|
21
|
+
return removeChildren(parent).appendChild(e)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function elt(tag, content, className, style) {
|
|
25
|
+
let e = document.createElement(tag)
|
|
26
|
+
if (className) e.className = className
|
|
27
|
+
if (style) e.style.cssText = style
|
|
28
|
+
if (typeof content == "string") e.appendChild(document.createTextNode(content))
|
|
29
|
+
else if (content) for (let i = 0; i < content.length; ++i) e.appendChild(content[i])
|
|
30
|
+
return e
|
|
31
|
+
}
|
|
32
|
+
// wrapper for elt, which removes the elt from the accessibility tree
|
|
33
|
+
export function eltP(tag, content, className, style) {
|
|
34
|
+
let e = elt(tag, content, className, style)
|
|
35
|
+
e.setAttribute("role", "presentation")
|
|
36
|
+
return e
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export let range
|
|
40
|
+
if (document.createRange) range = function(node, start, end, endNode) {
|
|
41
|
+
let r = document.createRange()
|
|
42
|
+
r.setEnd(endNode || node, end)
|
|
43
|
+
r.setStart(node, start)
|
|
44
|
+
return r
|
|
45
|
+
}
|
|
46
|
+
else range = function(node, start, end) {
|
|
47
|
+
let r = document.body.createTextRange()
|
|
48
|
+
try { r.moveToElementText(node.parentNode) }
|
|
49
|
+
catch(e) { return r }
|
|
50
|
+
r.collapse(true)
|
|
51
|
+
r.moveEnd("character", end)
|
|
52
|
+
r.moveStart("character", start)
|
|
53
|
+
return r
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function contains(parent, child) {
|
|
57
|
+
if (child.nodeType == 3) // Android browser always returns false when child is a textnode
|
|
58
|
+
child = child.parentNode
|
|
59
|
+
if (parent.contains)
|
|
60
|
+
return parent.contains(child)
|
|
61
|
+
do {
|
|
62
|
+
if (child.nodeType == 11) child = child.host
|
|
63
|
+
if (child == parent) return true
|
|
64
|
+
} while (child = child.parentNode)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function activeElt(doc) {
|
|
68
|
+
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
|
|
69
|
+
// IE < 10 will throw when accessed while the page is loading or in an iframe.
|
|
70
|
+
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
|
|
71
|
+
let activeElement
|
|
72
|
+
try {
|
|
73
|
+
activeElement = doc.activeElement
|
|
74
|
+
} catch(e) {
|
|
75
|
+
activeElement = doc.body || null
|
|
76
|
+
}
|
|
77
|
+
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
|
|
78
|
+
activeElement = activeElement.shadowRoot.activeElement
|
|
79
|
+
return activeElement
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function addClass(node, cls) {
|
|
83
|
+
let current = node.className
|
|
84
|
+
if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls
|
|
85
|
+
}
|
|
86
|
+
export function joinClasses(a, b) {
|
|
87
|
+
let as = a.split(" ")
|
|
88
|
+
for (let i = 0; i < as.length; i++)
|
|
89
|
+
if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i]
|
|
90
|
+
return b
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export let selectInput = function(node) { node.select() }
|
|
94
|
+
if (ios) // Mobile Safari apparently has a bug where select() is broken.
|
|
95
|
+
selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length }
|
|
96
|
+
else if (ie) // Suppress mysterious IE10 errors
|
|
97
|
+
selectInput = function(node) { try { node.select() } catch(_e) {} }
|
|
98
|
+
|
|
99
|
+
export function doc(cm) { return cm.display.wrapper.ownerDocument }
|
|
100
|
+
|
|
101
|
+
export function win(cm) { return doc(cm).defaultView }
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { mac } from "./browser.js"
|
|
2
|
+
import { indexOf } from "./misc.js"
|
|
3
|
+
|
|
4
|
+
// EVENT HANDLING
|
|
5
|
+
|
|
6
|
+
// Lightweight event framework. on/off also work on DOM nodes,
|
|
7
|
+
// registering native DOM handlers.
|
|
8
|
+
|
|
9
|
+
const noHandlers = []
|
|
10
|
+
|
|
11
|
+
export let on = function(emitter, type, f) {
|
|
12
|
+
if (emitter.addEventListener) {
|
|
13
|
+
emitter.addEventListener(type, f, false)
|
|
14
|
+
} else if (emitter.attachEvent) {
|
|
15
|
+
emitter.attachEvent("on" + type, f)
|
|
16
|
+
} else {
|
|
17
|
+
let map = emitter._handlers || (emitter._handlers = {})
|
|
18
|
+
map[type] = (map[type] || noHandlers).concat(f)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getHandlers(emitter, type) {
|
|
23
|
+
return emitter._handlers && emitter._handlers[type] || noHandlers
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function off(emitter, type, f) {
|
|
27
|
+
if (emitter.removeEventListener) {
|
|
28
|
+
emitter.removeEventListener(type, f, false)
|
|
29
|
+
} else if (emitter.detachEvent) {
|
|
30
|
+
emitter.detachEvent("on" + type, f)
|
|
31
|
+
} else {
|
|
32
|
+
let map = emitter._handlers, arr = map && map[type]
|
|
33
|
+
if (arr) {
|
|
34
|
+
let index = indexOf(arr, f)
|
|
35
|
+
if (index > -1)
|
|
36
|
+
map[type] = arr.slice(0, index).concat(arr.slice(index + 1))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function signal(emitter, type /*, values...*/) {
|
|
42
|
+
let handlers = getHandlers(emitter, type)
|
|
43
|
+
if (!handlers.length) return
|
|
44
|
+
let args = Array.prototype.slice.call(arguments, 2)
|
|
45
|
+
for (let i = 0; i < handlers.length; ++i) handlers[i].apply(null, args)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// The DOM events that CodeMirror handles can be overridden by
|
|
49
|
+
// registering a (non-DOM) handler on the editor for the event name,
|
|
50
|
+
// and preventDefault-ing the event in that handler.
|
|
51
|
+
export function signalDOMEvent(cm, e, override) {
|
|
52
|
+
if (typeof e == "string")
|
|
53
|
+
e = {type: e, preventDefault: function() { this.defaultPrevented = true }}
|
|
54
|
+
signal(cm, override || e.type, cm, e)
|
|
55
|
+
return e_defaultPrevented(e) || e.codemirrorIgnore
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function signalCursorActivity(cm) {
|
|
59
|
+
let arr = cm._handlers && cm._handlers.cursorActivity
|
|
60
|
+
if (!arr) return
|
|
61
|
+
let set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = [])
|
|
62
|
+
for (let i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
|
|
63
|
+
set.push(arr[i])
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function hasHandler(emitter, type) {
|
|
67
|
+
return getHandlers(emitter, type).length > 0
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Add on and off methods to a constructor's prototype, to make
|
|
71
|
+
// registering events on such objects more convenient.
|
|
72
|
+
export function eventMixin(ctor) {
|
|
73
|
+
ctor.prototype.on = function(type, f) {on(this, type, f)}
|
|
74
|
+
ctor.prototype.off = function(type, f) {off(this, type, f)}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Due to the fact that we still support jurassic IE versions, some
|
|
78
|
+
// compatibility wrappers are needed.
|
|
79
|
+
|
|
80
|
+
export function e_preventDefault(e) {
|
|
81
|
+
if (e.preventDefault) e.preventDefault()
|
|
82
|
+
else e.returnValue = false
|
|
83
|
+
}
|
|
84
|
+
export function e_stopPropagation(e) {
|
|
85
|
+
if (e.stopPropagation) e.stopPropagation()
|
|
86
|
+
else e.cancelBubble = true
|
|
87
|
+
}
|
|
88
|
+
export function e_defaultPrevented(e) {
|
|
89
|
+
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
|
|
90
|
+
}
|
|
91
|
+
export function e_stop(e) {e_preventDefault(e); e_stopPropagation(e)}
|
|
92
|
+
|
|
93
|
+
export function e_target(e) {return e.target || e.srcElement}
|
|
94
|
+
export function e_button(e) {
|
|
95
|
+
let b = e.which
|
|
96
|
+
if (b == null) {
|
|
97
|
+
if (e.button & 1) b = 1
|
|
98
|
+
else if (e.button & 2) b = 3
|
|
99
|
+
else if (e.button & 4) b = 2
|
|
100
|
+
}
|
|
101
|
+
if (mac && e.ctrlKey && b == 1) b = 3
|
|
102
|
+
return b
|
|
103
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { elt, range, removeChildren, removeChildrenAndAdd } from "./dom.js"
|
|
2
|
+
import { ie, ie_version } from "./browser.js"
|
|
3
|
+
|
|
4
|
+
// Detect drag-and-drop
|
|
5
|
+
export let dragAndDrop = function() {
|
|
6
|
+
// There is *some* kind of drag-and-drop support in IE6-8, but I
|
|
7
|
+
// couldn't get it to work yet.
|
|
8
|
+
if (ie && ie_version < 9) return false
|
|
9
|
+
let div = elt('div')
|
|
10
|
+
return "draggable" in div || "dragDrop" in div
|
|
11
|
+
}()
|
|
12
|
+
|
|
13
|
+
let zwspSupported
|
|
14
|
+
export function zeroWidthElement(measure) {
|
|
15
|
+
if (zwspSupported == null) {
|
|
16
|
+
let test = elt("span", "\u200b")
|
|
17
|
+
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]))
|
|
18
|
+
if (measure.firstChild.offsetHeight != 0)
|
|
19
|
+
zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8)
|
|
20
|
+
}
|
|
21
|
+
let node = zwspSupported ? elt("span", "\u200b") :
|
|
22
|
+
elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px")
|
|
23
|
+
node.setAttribute("cm-text", "")
|
|
24
|
+
return node
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Feature-detect IE's crummy client rect reporting for bidi text
|
|
28
|
+
let badBidiRects
|
|
29
|
+
export function hasBadBidiRects(measure) {
|
|
30
|
+
if (badBidiRects != null) return badBidiRects
|
|
31
|
+
let txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"))
|
|
32
|
+
let r0 = range(txt, 0, 1).getBoundingClientRect()
|
|
33
|
+
let r1 = range(txt, 1, 2).getBoundingClientRect()
|
|
34
|
+
removeChildren(measure)
|
|
35
|
+
if (!r0 || r0.left == r0.right) return false // Safari returns null in some cases (#2780)
|
|
36
|
+
return badBidiRects = (r1.right - r0.right < 3)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// See if "".split is the broken IE version, if so, provide an
|
|
40
|
+
// alternative way to split lines.
|
|
41
|
+
export let splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? string => {
|
|
42
|
+
let pos = 0, result = [], l = string.length
|
|
43
|
+
while (pos <= l) {
|
|
44
|
+
let nl = string.indexOf("\n", pos)
|
|
45
|
+
if (nl == -1) nl = string.length
|
|
46
|
+
let line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl)
|
|
47
|
+
let rt = line.indexOf("\r")
|
|
48
|
+
if (rt != -1) {
|
|
49
|
+
result.push(line.slice(0, rt))
|
|
50
|
+
pos += rt + 1
|
|
51
|
+
} else {
|
|
52
|
+
result.push(line)
|
|
53
|
+
pos = nl + 1
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result
|
|
57
|
+
} : string => string.split(/\r\n?|\n/)
|
|
58
|
+
|
|
59
|
+
export let hasSelection = window.getSelection ? te => {
|
|
60
|
+
try { return te.selectionStart != te.selectionEnd }
|
|
61
|
+
catch(e) { return false }
|
|
62
|
+
} : te => {
|
|
63
|
+
let range
|
|
64
|
+
try {range = te.ownerDocument.selection.createRange()}
|
|
65
|
+
catch(e) {}
|
|
66
|
+
if (!range || range.parentElement() != te) return false
|
|
67
|
+
return range.compareEndPoints("StartToEnd", range) != 0
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export let hasCopyEvent = (() => {
|
|
71
|
+
let e = elt("div")
|
|
72
|
+
if ("oncopy" in e) return true
|
|
73
|
+
e.setAttribute("oncopy", "return;")
|
|
74
|
+
return typeof e.oncopy == "function"
|
|
75
|
+
})()
|
|
76
|
+
|
|
77
|
+
let badZoomedRects = null
|
|
78
|
+
export function hasBadZoomedRects(measure) {
|
|
79
|
+
if (badZoomedRects != null) return badZoomedRects
|
|
80
|
+
let node = removeChildrenAndAdd(measure, elt("span", "x"))
|
|
81
|
+
let normal = node.getBoundingClientRect()
|
|
82
|
+
let fromRange = range(node, 0, 1).getBoundingClientRect()
|
|
83
|
+
return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
|
|
84
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
export function bind(f) {
|
|
2
|
+
let args = Array.prototype.slice.call(arguments, 1)
|
|
3
|
+
return function(){return f.apply(null, args)}
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function copyObj(obj, target, overwrite) {
|
|
7
|
+
if (!target) target = {}
|
|
8
|
+
for (let prop in obj)
|
|
9
|
+
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
|
|
10
|
+
target[prop] = obj[prop]
|
|
11
|
+
return target
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Counts the column offset in a string, taking tabs into account.
|
|
15
|
+
// Used mostly to find indentation.
|
|
16
|
+
export function countColumn(string, end, tabSize, startIndex, startValue) {
|
|
17
|
+
if (end == null) {
|
|
18
|
+
end = string.search(/[^\s\u00a0]/)
|
|
19
|
+
if (end == -1) end = string.length
|
|
20
|
+
}
|
|
21
|
+
for (let i = startIndex || 0, n = startValue || 0;;) {
|
|
22
|
+
let nextTab = string.indexOf("\t", i)
|
|
23
|
+
if (nextTab < 0 || nextTab >= end)
|
|
24
|
+
return n + (end - i)
|
|
25
|
+
n += nextTab - i
|
|
26
|
+
n += tabSize - (n % tabSize)
|
|
27
|
+
i = nextTab + 1
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class Delayed {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.id = null
|
|
34
|
+
this.f = null
|
|
35
|
+
this.time = 0
|
|
36
|
+
this.handler = bind(this.onTimeout, this)
|
|
37
|
+
}
|
|
38
|
+
onTimeout(self) {
|
|
39
|
+
self.id = 0
|
|
40
|
+
if (self.time <= +new Date) {
|
|
41
|
+
self.f()
|
|
42
|
+
} else {
|
|
43
|
+
setTimeout(self.handler, self.time - +new Date)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
set(ms, f) {
|
|
47
|
+
this.f = f
|
|
48
|
+
const time = +new Date + ms
|
|
49
|
+
if (!this.id || time < this.time) {
|
|
50
|
+
clearTimeout(this.id)
|
|
51
|
+
this.id = setTimeout(this.handler, ms)
|
|
52
|
+
this.time = time
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function indexOf(array, elt) {
|
|
58
|
+
for (let i = 0; i < array.length; ++i)
|
|
59
|
+
if (array[i] == elt) return i
|
|
60
|
+
return -1
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Number of pixels added to scroller and sizer to hide scrollbar
|
|
64
|
+
export let scrollerGap = 50
|
|
65
|
+
|
|
66
|
+
// Returned or thrown by various protocols to signal 'I'm not
|
|
67
|
+
// handling this'.
|
|
68
|
+
export let Pass = {toString: function(){return "CodeMirror.Pass"}}
|
|
69
|
+
|
|
70
|
+
// Reused option objects for setSelection & friends
|
|
71
|
+
export let sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}
|
|
72
|
+
|
|
73
|
+
// The inverse of countColumn -- find the offset that corresponds to
|
|
74
|
+
// a particular column.
|
|
75
|
+
export function findColumn(string, goal, tabSize) {
|
|
76
|
+
for (let pos = 0, col = 0;;) {
|
|
77
|
+
let nextTab = string.indexOf("\t", pos)
|
|
78
|
+
if (nextTab == -1) nextTab = string.length
|
|
79
|
+
let skipped = nextTab - pos
|
|
80
|
+
if (nextTab == string.length || col + skipped >= goal)
|
|
81
|
+
return pos + Math.min(skipped, goal - col)
|
|
82
|
+
col += nextTab - pos
|
|
83
|
+
col += tabSize - (col % tabSize)
|
|
84
|
+
pos = nextTab + 1
|
|
85
|
+
if (col >= goal) return pos
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let spaceStrs = [""]
|
|
90
|
+
export function spaceStr(n) {
|
|
91
|
+
while (spaceStrs.length <= n)
|
|
92
|
+
spaceStrs.push(lst(spaceStrs) + " ")
|
|
93
|
+
return spaceStrs[n]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function lst(arr) { return arr[arr.length-1] }
|
|
97
|
+
|
|
98
|
+
export function map(array, f) {
|
|
99
|
+
let out = []
|
|
100
|
+
for (let i = 0; i < array.length; i++) out[i] = f(array[i], i)
|
|
101
|
+
return out
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function insertSorted(array, value, score) {
|
|
105
|
+
let pos = 0, priority = score(value)
|
|
106
|
+
while (pos < array.length && score(array[pos]) <= priority) pos++
|
|
107
|
+
array.splice(pos, 0, value)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function nothing() {}
|
|
111
|
+
|
|
112
|
+
export function createObj(base, props) {
|
|
113
|
+
let inst
|
|
114
|
+
if (Object.create) {
|
|
115
|
+
inst = Object.create(base)
|
|
116
|
+
} else {
|
|
117
|
+
nothing.prototype = base
|
|
118
|
+
inst = new nothing()
|
|
119
|
+
}
|
|
120
|
+
if (props) copyObj(props, inst)
|
|
121
|
+
return inst
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/
|
|
125
|
+
export function isWordCharBasic(ch) {
|
|
126
|
+
return /\w/.test(ch) || ch > "\x80" &&
|
|
127
|
+
(ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
|
|
128
|
+
}
|
|
129
|
+
export function isWordChar(ch, helper) {
|
|
130
|
+
if (!helper) return isWordCharBasic(ch)
|
|
131
|
+
if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true
|
|
132
|
+
return helper.test(ch)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function isEmpty(obj) {
|
|
136
|
+
for (let n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false
|
|
137
|
+
return true
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Extending unicode characters. A series of a non-extending char +
|
|
141
|
+
// any number of extending chars is treated as a single unit as far
|
|
142
|
+
// as editing and measuring is concerned. This is not fully correct,
|
|
143
|
+
// since some scripts/fonts/browsers also treat other configurations
|
|
144
|
+
// of code points as a group.
|
|
145
|
+
let extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/
|
|
146
|
+
export function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
|
|
147
|
+
|
|
148
|
+
// Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
|
|
149
|
+
export function skipExtendingChars(str, pos, dir) {
|
|
150
|
+
while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) pos += dir
|
|
151
|
+
return pos
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Returns the value from the range [`from`; `to`] that satisfies
|
|
155
|
+
// `pred` and is closest to `from`. Assumes that at least `to`
|
|
156
|
+
// satisfies `pred`. Supports `from` being greater than `to`.
|
|
157
|
+
export function findFirst(pred, from, to) {
|
|
158
|
+
// At any point we are certain `to` satisfies `pred`, don't know
|
|
159
|
+
// whether `from` does.
|
|
160
|
+
let dir = from > to ? -1 : 1
|
|
161
|
+
for (;;) {
|
|
162
|
+
if (from == to) return from
|
|
163
|
+
let midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF)
|
|
164
|
+
if (mid == from) return pred(mid) ? from : to
|
|
165
|
+
if (pred(mid)) to = mid
|
|
166
|
+
else from = mid + dir
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getHandlers } from "./event.js"
|
|
2
|
+
|
|
3
|
+
let operationGroup = null
|
|
4
|
+
|
|
5
|
+
export function pushOperation(op) {
|
|
6
|
+
if (operationGroup) {
|
|
7
|
+
operationGroup.ops.push(op)
|
|
8
|
+
} else {
|
|
9
|
+
op.ownsGroup = operationGroup = {
|
|
10
|
+
ops: [op],
|
|
11
|
+
delayedCallbacks: []
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function fireCallbacksForOps(group) {
|
|
17
|
+
// Calls delayed callbacks and cursorActivity handlers until no
|
|
18
|
+
// new ones appear
|
|
19
|
+
let callbacks = group.delayedCallbacks, i = 0
|
|
20
|
+
do {
|
|
21
|
+
for (; i < callbacks.length; i++)
|
|
22
|
+
callbacks[i].call(null)
|
|
23
|
+
for (let j = 0; j < group.ops.length; j++) {
|
|
24
|
+
let op = group.ops[j]
|
|
25
|
+
if (op.cursorActivityHandlers)
|
|
26
|
+
while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
|
27
|
+
op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm)
|
|
28
|
+
}
|
|
29
|
+
} while (i < callbacks.length)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function finishOperation(op, endCb) {
|
|
33
|
+
let group = op.ownsGroup
|
|
34
|
+
if (!group) return
|
|
35
|
+
|
|
36
|
+
try { fireCallbacksForOps(group) }
|
|
37
|
+
finally {
|
|
38
|
+
operationGroup = null
|
|
39
|
+
endCb(group)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let orphanDelayedCallbacks = null
|
|
44
|
+
|
|
45
|
+
// Often, we want to signal events at a point where we are in the
|
|
46
|
+
// middle of some work, but don't want the handler to start calling
|
|
47
|
+
// other methods on the editor, which might be in an inconsistent
|
|
48
|
+
// state or simply not expect any other events to happen.
|
|
49
|
+
// signalLater looks whether there are any handlers, and schedules
|
|
50
|
+
// them to be executed when the last operation ends, or, if no
|
|
51
|
+
// operation is active, when a timeout fires.
|
|
52
|
+
export function signalLater(emitter, type /*, values...*/) {
|
|
53
|
+
let arr = getHandlers(emitter, type)
|
|
54
|
+
if (!arr.length) return
|
|
55
|
+
let args = Array.prototype.slice.call(arguments, 2), list
|
|
56
|
+
if (operationGroup) {
|
|
57
|
+
list = operationGroup.delayedCallbacks
|
|
58
|
+
} else if (orphanDelayedCallbacks) {
|
|
59
|
+
list = orphanDelayedCallbacks
|
|
60
|
+
} else {
|
|
61
|
+
list = orphanDelayedCallbacks = []
|
|
62
|
+
setTimeout(fireOrphanDelayed, 0)
|
|
63
|
+
}
|
|
64
|
+
for (let i = 0; i < arr.length; ++i)
|
|
65
|
+
list.push(() => arr[i].apply(null, args))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function fireOrphanDelayed() {
|
|
69
|
+
let delayed = orphanDelayedCallbacks
|
|
70
|
+
orphanDelayedCallbacks = null
|
|
71
|
+
for (let i = 0; i < delayed.length; ++i) delayed[i]()
|
|
72
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Name: 3024 day
|
|
4
|
+
Author: Jan T. Sott (http://github.com/idleberg)
|
|
5
|
+
|
|
6
|
+
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
|
7
|
+
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
.cm-s-3024-day.CodeMirror { background: #f7f7f7; color: #3a3432; }
|
|
12
|
+
.cm-s-3024-day div.CodeMirror-selected { background: #d6d5d4; }
|
|
13
|
+
|
|
14
|
+
.cm-s-3024-day .CodeMirror-line::selection, .cm-s-3024-day .CodeMirror-line > span::selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d6d5d4; }
|
|
15
|
+
.cm-s-3024-day .CodeMirror-line::-moz-selection, .cm-s-3024-day .CodeMirror-line > span::-moz-selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d9d9d9; }
|
|
16
|
+
|
|
17
|
+
.cm-s-3024-day .CodeMirror-gutters { background: #f7f7f7; border-right: 0px; }
|
|
18
|
+
.cm-s-3024-day .CodeMirror-guttermarker { color: #db2d20; }
|
|
19
|
+
.cm-s-3024-day .CodeMirror-guttermarker-subtle { color: #807d7c; }
|
|
20
|
+
.cm-s-3024-day .CodeMirror-linenumber { color: #807d7c; }
|
|
21
|
+
|
|
22
|
+
.cm-s-3024-day .CodeMirror-cursor { border-left: 1px solid #5c5855; }
|
|
23
|
+
|
|
24
|
+
.cm-s-3024-day span.cm-comment { color: #cdab53; }
|
|
25
|
+
.cm-s-3024-day span.cm-atom { color: #a16a94; }
|
|
26
|
+
.cm-s-3024-day span.cm-number { color: #a16a94; }
|
|
27
|
+
|
|
28
|
+
.cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute { color: #01a252; }
|
|
29
|
+
.cm-s-3024-day span.cm-keyword { color: #db2d20; }
|
|
30
|
+
.cm-s-3024-day span.cm-string { color: #fded02; }
|
|
31
|
+
|
|
32
|
+
.cm-s-3024-day span.cm-variable { color: #01a252; }
|
|
33
|
+
.cm-s-3024-day span.cm-variable-2 { color: #01a0e4; }
|
|
34
|
+
.cm-s-3024-day span.cm-def { color: #e8bbd0; }
|
|
35
|
+
.cm-s-3024-day span.cm-bracket { color: #3a3432; }
|
|
36
|
+
.cm-s-3024-day span.cm-tag { color: #db2d20; }
|
|
37
|
+
.cm-s-3024-day span.cm-link { color: #a16a94; }
|
|
38
|
+
.cm-s-3024-day span.cm-error { background: #db2d20; color: #5c5855; }
|
|
39
|
+
|
|
40
|
+
.cm-s-3024-day .CodeMirror-activeline-background { background: #e8f2ff; }
|
|
41
|
+
.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: #a16a94 !important; }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Name: 3024 night
|
|
4
|
+
Author: Jan T. Sott (http://github.com/idleberg)
|
|
5
|
+
|
|
6
|
+
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
|
7
|
+
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
.cm-s-3024-night.CodeMirror { background: #090300; color: #d6d5d4; }
|
|
12
|
+
.cm-s-3024-night div.CodeMirror-selected { background: #3a3432; }
|
|
13
|
+
.cm-s-3024-night .CodeMirror-line::selection, .cm-s-3024-night .CodeMirror-line > span::selection, .cm-s-3024-night .CodeMirror-line > span > span::selection { background: rgba(58, 52, 50, .99); }
|
|
14
|
+
.cm-s-3024-night .CodeMirror-line::-moz-selection, .cm-s-3024-night .CodeMirror-line > span::-moz-selection, .cm-s-3024-night .CodeMirror-line > span > span::-moz-selection { background: rgba(58, 52, 50, .99); }
|
|
15
|
+
.cm-s-3024-night .CodeMirror-gutters { background: #090300; border-right: 0px; }
|
|
16
|
+
.cm-s-3024-night .CodeMirror-guttermarker { color: #db2d20; }
|
|
17
|
+
.cm-s-3024-night .CodeMirror-guttermarker-subtle { color: #5c5855; }
|
|
18
|
+
.cm-s-3024-night .CodeMirror-linenumber { color: #5c5855; }
|
|
19
|
+
|
|
20
|
+
.cm-s-3024-night .CodeMirror-cursor { border-left: 1px solid #807d7c; }
|
|
21
|
+
|
|
22
|
+
.cm-s-3024-night span.cm-comment { color: #cdab53; }
|
|
23
|
+
.cm-s-3024-night span.cm-atom { color: #a16a94; }
|
|
24
|
+
.cm-s-3024-night span.cm-number { color: #a16a94; }
|
|
25
|
+
|
|
26
|
+
.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute { color: #01a252; }
|
|
27
|
+
.cm-s-3024-night span.cm-keyword { color: #db2d20; }
|
|
28
|
+
.cm-s-3024-night span.cm-string { color: #fded02; }
|
|
29
|
+
|
|
30
|
+
.cm-s-3024-night span.cm-variable { color: #01a252; }
|
|
31
|
+
.cm-s-3024-night span.cm-variable-2 { color: #01a0e4; }
|
|
32
|
+
.cm-s-3024-night span.cm-def { color: #e8bbd0; }
|
|
33
|
+
.cm-s-3024-night span.cm-bracket { color: #d6d5d4; }
|
|
34
|
+
.cm-s-3024-night span.cm-tag { color: #db2d20; }
|
|
35
|
+
.cm-s-3024-night span.cm-link { color: #a16a94; }
|
|
36
|
+
.cm-s-3024-night span.cm-error { background: #db2d20; color: #807d7c; }
|
|
37
|
+
|
|
38
|
+
.cm-s-3024-night .CodeMirror-activeline-background { background: #2F2F2F; }
|
|
39
|
+
.cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
|