active_admin_pro 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +5 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/active_admin_pro.js +41 -0
- data/app/assets/javascripts/active_admin_pro/actions/new.js +8 -0
- data/app/assets/javascripts/active_admin_pro/actions/show.js +12 -0
- data/app/assets/javascripts/active_admin_pro/components/codemirror_input.js +92 -0
- data/app/assets/javascripts/active_admin_pro/components/flashes.js +9 -0
- data/app/assets/javascripts/active_admin_pro/components/link.js +23 -0
- data/app/assets/javascripts/active_admin_pro/components/phone_input.js +52 -0
- data/app/assets/javascripts/active_admin_pro/components/select_input.js +31 -0
- data/app/assets/javascripts/active_admin_pro/components/sortable_handle.js +8 -0
- data/app/assets/javascripts/active_admin_pro/components/summernote_input.js +132 -0
- data/app/assets/javascripts/active_admin_pro/components/text_input.js +47 -0
- data/app/assets/javascripts/active_admin_pro/components/time_zone_input.js +51 -0
- data/app/assets/javascripts/active_admin_pro/components/title_to_slug.js +16 -0
- data/app/assets/stylesheets/active_admin_pro.scss +20 -0
- data/app/assets/stylesheets/active_admin_pro/breakpoints.scss +3 -0
- data/app/assets/stylesheets/active_admin_pro/components/_input_variables.scss +9 -0
- data/app/assets/stylesheets/active_admin_pro/components/actions.scss +13 -0
- data/app/assets/stylesheets/active_admin_pro/components/boolean_input.scss +13 -0
- data/app/assets/stylesheets/active_admin_pro/components/button.scss +7 -0
- data/app/assets/stylesheets/active_admin_pro/components/check_boxes_input.scss +38 -0
- data/app/assets/stylesheets/active_admin_pro/components/codemirror_input.scss +53 -0
- data/app/assets/stylesheets/active_admin_pro/components/comments.scss +17 -0
- data/app/assets/stylesheets/active_admin_pro/components/datepicker.scss +108 -0
- data/app/assets/stylesheets/active_admin_pro/components/dialog.scss +66 -0
- data/app/assets/stylesheets/active_admin_pro/components/dropdown_menu_button.scss +40 -0
- data/app/assets/stylesheets/active_admin_pro/components/fieldset.scss +26 -0
- data/app/assets/stylesheets/active_admin_pro/components/file_input.scss +27 -0
- data/app/assets/stylesheets/active_admin_pro/components/has_many_fields.scss +4 -0
- data/app/assets/stylesheets/active_admin_pro/components/inline_errors.scss +7 -0
- data/app/assets/stylesheets/active_admin_pro/components/link.scss +16 -0
- data/app/assets/stylesheets/active_admin_pro/components/panel.scss +62 -0
- data/app/assets/stylesheets/active_admin_pro/components/phone_input.scss +31 -0
- data/app/assets/stylesheets/active_admin_pro/components/radio_input.scss +38 -0
- data/app/assets/stylesheets/active_admin_pro/components/segmented_control.scss +41 -0
- data/app/assets/stylesheets/active_admin_pro/components/select_input.scss +42 -0
- data/app/assets/stylesheets/active_admin_pro/components/sortable_handle.scss +21 -0
- data/app/assets/stylesheets/active_admin_pro/components/string_input.scss +85 -0
- data/app/assets/stylesheets/active_admin_pro/components/summernote_input.scss +190 -0
- data/app/assets/stylesheets/active_admin_pro/components/table.scss +100 -0
- data/app/assets/stylesheets/active_admin_pro/components/text_input.scss +55 -0
- data/app/assets/stylesheets/active_admin_pro/functions/color.scss +130 -0
- data/app/assets/stylesheets/active_admin_pro/functions/text-color.scss +35 -0
- data/app/assets/stylesheets/active_admin_pro/layout/actions/comments.scss +14 -0
- data/app/assets/stylesheets/active_admin_pro/layout/actions/index.scss +88 -0
- data/app/assets/stylesheets/active_admin_pro/layout/actions/show.scss +25 -0
- data/app/assets/stylesheets/active_admin_pro/layout/body.scss +60 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/action_items.scss +32 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/actions/comments.scss +10 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/active_admin_content.scss +22 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/breadcrumbs.scss +57 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/navigation.scss +197 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/sidebar.scss +5 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/title_bar.scss +24 -0
- data/app/assets/stylesheets/active_admin_pro/layout/desktop/wrapper.scss +5 -0
- data/app/assets/stylesheets/active_admin_pro/layout/filters.scss +41 -0
- data/app/assets/stylesheets/active_admin_pro/layout/flashes.scss +52 -0
- data/app/assets/stylesheets/active_admin_pro/layout/footer.scss +3 -0
- data/app/assets/stylesheets/active_admin_pro/layout/mobile/actions/index.scss +7 -0
- data/app/assets/stylesheets/active_admin_pro/layout/tablet/actions/dashboard.scss +105 -0
- data/app/assets/stylesheets/active_admin_pro/layout/tablet/actions/index.scss +20 -0
- data/app/assets/stylesheets/active_admin_pro/layout/tablet/actions/show.scss +78 -0
- data/app/assets/stylesheets/active_admin_pro/layout/tablet/active_admin_content.scss +9 -0
- data/app/assets/stylesheets/active_admin_pro/layout/tablet/flashes.scss +5 -0
- data/app/assets/stylesheets/active_admin_pro/layout/tablet/navigation.scss +48 -0
- data/app/assets/stylesheets/active_admin_pro/layout/tablet/title_bar.scss +53 -0
- data/app/assets/stylesheets/active_admin_pro/mixins/button.scss +48 -0
- data/app/assets/stylesheets/active_admin_pro/variables.scss +10 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon.scss +87 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-color.scss +26 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-radius.scss +48 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-style.scss +25 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_border-width.scss +25 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_buttons.scss +64 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_clearfix.scss +25 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_ellipsis.scss +30 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_font-stacks.scss +31 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_hide-text.scss +27 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_margin.scss +26 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_padding.scss +26 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_position.scss +48 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_prefixer.scss +66 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_retina-image.scss +25 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_size.scss +51 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_text-inputs.scss +113 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_timing-functions.scss +34 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_triangle.scss +63 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/addons/_word-wrap.scss +29 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_animation.scss +43 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_appearance.scss +3 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_backface-visibility.scss +3 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_background-image.scss +42 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_background.scss +55 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_border-image.scss +59 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_calc.scss +4 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_columns.scss +47 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_filter.scss +4 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_flex-box.scss +287 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_font-face.scss +24 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_font-feature-settings.scss +4 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_hidpi-media-query.scss +10 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_hyphens.scss +4 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_image-rendering.scss +14 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_keyframes.scss +36 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_linear-gradient.scss +38 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_perspective.scss +8 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_placeholder.scss +8 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_radial-gradient.scss +39 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_selection.scss +42 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_text-decoration.scss +19 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_transform.scss +15 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_transition.scss +71 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/css3/_user-select.scss +3 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_assign-inputs.scss +11 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_contains-falsy.scss +20 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_contains.scss +26 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-length.scss +11 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-light.scss +21 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-number.scss +11 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_is-size.scss +13 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_modular-scale.scss +69 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_px-to-em.scss +13 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_px-to-rem.scss +15 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_shade.scss +24 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_strip-units.scss +17 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_tint.scss +24 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_transition-property-name.scss +22 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/functions/_unpack.scss +27 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_convert-units.scss +21 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_directional-values.scss +96 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_font-source-declaration.scss +43 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_gradient-positions-parser.scss +13 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-angle-parser.scss +25 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-gradient-parser.scss +41 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-positions-parser.scss +61 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_radial-arg-parser.scss +69 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_radial-gradient-parser.scss +50 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_radial-positions-parser.scss +18 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_render-gradients.scss +26 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_shape-size-stripper.scss +10 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/helpers/_str-to-num.scss +50 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/settings/_asset-pipeline.scss +7 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/settings/_prefixer.scss +9 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/bourbon/settings/_px-to-em.scss +1 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat.scss +22 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/_neat-helpers.scss +8 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/functions/_new-breakpoint.scss +49 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/functions/_private.scss +108 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_box-sizing.scss +11 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_direction-context.scss +31 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_display-context.scss +26 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_fill-parent.scss +22 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_media.scss +92 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_omega.scss +91 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_outer-container.scss +36 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_pad.scss +23 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_private.scss +35 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_row.scss +53 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_shift.scss +48 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_span-columns.scss +90 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_to-deprecate.scss +105 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/grid/_visual-grid.scss +40 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/settings/_disable-warnings.scss +11 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/settings/_grid.scss +53 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/neat/settings/_visual-grid.scss +25 -0
- data/app/assets/stylesheets/active_admin_pro/vendor/normalize.css +423 -0
- data/app/assets/stylesheets/codemirror/themes/activeadmin_pro.scss +117 -0
- data/app/inputs/codemirror_input.rb +27 -0
- data/app/inputs/datepicker_input.rb +16 -0
- data/app/inputs/phone_input.rb +5 -0
- data/app/inputs/summernote_input.rb +5 -0
- data/app/inputs/time_zone_input.rb +43 -0
- data/app/models/activeadmin_pro/summernote_image.rb +5 -0
- data/config/initializers/active_admin.rb +50 -0
- data/config/locales/en.yml +55 -0
- data/lib/active_admin_pro/admin_user/admin_user.rb +52 -0
- data/lib/active_admin_pro/engine.rb +8 -0
- data/lib/active_admin_pro/summernote_image/summernote_image.rb +61 -0
- data/lib/active_admin_pro/user/user.rb +53 -0
- data/lib/active_admin_pro/version.rb +3 -0
- data/lib/activeadmin_pro.rb +9 -0
- data/lib/generators/activeadmin_pro/install_generator.rb +14 -0
- data/lib/tasks/activeadmin_pro_tasks.rake +4 -0
- data/spec/spec_helper.rb +34 -0
- data/vendor/assets/javascripts/bootstrap.js +1243 -0
- data/vendor/assets/javascripts/codemirror.js +8887 -0
- data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +183 -0
- data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +85 -0
- data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.css +32 -0
- data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +157 -0
- data/vendor/assets/javascripts/codemirror/addons/display/autorefresh.js +47 -0
- data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.css +6 -0
- data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.js +41 -0
- data/vendor/assets/javascripts/codemirror/addons/display/panel.js +112 -0
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +60 -0
- data/vendor/assets/javascripts/codemirror/addons/display/rulers.js +63 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +195 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +169 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +51 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +120 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +66 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/trailingspace.js +27 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +105 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/comment-fold.js +57 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +149 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.css +20 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +146 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +44 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/markdown-fold.js +49 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +182 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +41 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +60 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +348 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +146 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.css +38 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +386 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +254 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +110 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +41 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/css-lint.js +35 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/html-lint.js +46 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +136 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +31 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.css +73 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +231 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/yaml-lint.js +28 -0
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.css +112 -0
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +775 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/loadmode.js +64 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +123 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/multiplex_test.js +33 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/overlay.js +85 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/simple.js +213 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/colorize.js +40 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +157 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +72 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +178 -0
- data/vendor/assets/javascripts/codemirror/addons/scroll/annotatescrollbar.js +115 -0
- data/vendor/assets/javascripts/codemirror/addons/scroll/scrollpastend.js +46 -0
- data/vendor/assets/javascripts/codemirror/addons/scroll/simplescrollbars.css +66 -0
- data/vendor/assets/javascripts/codemirror/addons/scroll/simplescrollbars.js +147 -0
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +128 -0
- data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.css +8 -0
- data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.js +97 -0
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +228 -0
- data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +189 -0
- data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +71 -0
- data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +118 -0
- data/vendor/assets/javascripts/codemirror/addons/selection/selection-pointer.js +98 -0
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.css +87 -0
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +700 -0
- data/vendor/assets/javascripts/codemirror/addons/tern/worker.js +44 -0
- data/vendor/assets/javascripts/codemirror/addons/wrap/hardwrap.js +139 -0
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +366 -0
- data/vendor/assets/javascripts/codemirror/modes/css.js +823 -0
- data/vendor/assets/javascripts/codemirror/modes/diff.js +47 -0
- data/vendor/assets/javascripts/codemirror/modes/dockerfile.js +79 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +130 -0
- data/vendor/assets/javascripts/codemirror/modes/go.js +185 -0
- data/vendor/assets/javascripts/codemirror/modes/haml.js +159 -0
- data/vendor/assets/javascripts/codemirror/modes/handlebars.js +53 -0
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +28 -0
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +150 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +708 -0
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +792 -0
- data/vendor/assets/javascripts/codemirror/modes/nginx.js +178 -0
- data/vendor/assets/javascripts/codemirror/modes/php.js +234 -0
- data/vendor/assets/javascripts/codemirror/modes/python.js +358 -0
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +285 -0
- data/vendor/assets/javascripts/codemirror/modes/rust.js +58 -0
- data/vendor/assets/javascripts/codemirror/modes/sass.js +414 -0
- data/vendor/assets/javascripts/codemirror/modes/shell.js +139 -0
- data/vendor/assets/javascripts/codemirror/modes/xml.js +385 -0
- data/vendor/assets/javascripts/codemirror/modes/yaml.js +117 -0
- data/vendor/assets/javascripts/intl-tel-input.js +963 -0
- data/vendor/assets/javascripts/intl-tel-utils.js +480 -0
- data/vendor/assets/javascripts/slug.js +212 -0
- data/vendor/assets/javascripts/summernote.js +6939 -0
- data/vendor/assets/stylesheets/codemirror.css +334 -0
- data/vendor/assets/stylesheets/codemirror/themes/base16-dark.css +38 -0
- data/vendor/assets/stylesheets/codemirror/themes/base16-light.css +38 -0
- data/vendor/assets/stylesheets/codemirror/themes/dracula.css +41 -0
- data/vendor/assets/stylesheets/codemirror/themes/material.css +53 -0
- data/vendor/assets/stylesheets/codemirror/themes/monokai.css +35 -0
- data/vendor/assets/stylesheets/codemirror/themes/solarized.css +163 -0
- data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +34 -0
- data/vendor/assets/stylesheets/intl-tel-input.scss +1054 -0
- data/vendor/assets/stylesheets/summernote-bs3.css +5425 -0
- data/vendor/assets/stylesheets/summernote.css +1 -0
- metadata +604 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineSimpleMode("handlebars", {
|
15
|
+
start: [
|
16
|
+
{ regex: /\{\{!--/, push: "dash_comment", token: "comment" },
|
17
|
+
{ regex: /\{\{!/, push: "comment", token: "comment" },
|
18
|
+
{ regex: /\{\{/, push: "handlebars", token: "tag" }
|
19
|
+
],
|
20
|
+
handlebars: [
|
21
|
+
{ regex: /\}\}/, pop: true, token: "tag" },
|
22
|
+
|
23
|
+
// Double and single quotes
|
24
|
+
{ regex: /"(?:[^\\]|\\.)*?"/, token: "string" },
|
25
|
+
{ regex: /'(?:[^\\]|\\.)*?'/, token: "string" },
|
26
|
+
|
27
|
+
// Handlebars keywords
|
28
|
+
{ regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },
|
29
|
+
{ regex: /(?:else|this)\b/, token: "keyword" },
|
30
|
+
|
31
|
+
// Numeral
|
32
|
+
{ regex: /\d+/i, token: "number" },
|
33
|
+
|
34
|
+
// Atoms like = and .
|
35
|
+
{ regex: /=|~|@|true|false/, token: "atom" },
|
36
|
+
|
37
|
+
// Paths
|
38
|
+
{ regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/, token: "variable-2" }
|
39
|
+
],
|
40
|
+
dash_comment: [
|
41
|
+
{ regex: /--\}\}/, pop: true, token: "comment" },
|
42
|
+
|
43
|
+
// Commented code
|
44
|
+
{ regex: /./, token: "comment"}
|
45
|
+
],
|
46
|
+
comment: [
|
47
|
+
{ regex: /\}\}/, pop: true, token: "comment" },
|
48
|
+
{ regex: /./, token: "comment" }
|
49
|
+
]
|
50
|
+
});
|
51
|
+
|
52
|
+
CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
|
53
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
|
7
|
+
require("../../addon/mode/multiplex"));
|
8
|
+
else if (typeof define == "function" && define.amd) // AMD
|
9
|
+
define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
|
10
|
+
"../../addon/mode/multiplex"], mod);
|
11
|
+
else // Plain browser env
|
12
|
+
mod(CodeMirror);
|
13
|
+
})(function(CodeMirror) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
|
17
|
+
return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), {
|
18
|
+
open: parserConfig.open || parserConfig.scriptStartRegex || "<%",
|
19
|
+
close: parserConfig.close || parserConfig.scriptEndRegex || "%>",
|
20
|
+
mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec)
|
21
|
+
});
|
22
|
+
}, "htmlmixed");
|
23
|
+
|
24
|
+
CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"});
|
25
|
+
CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
|
26
|
+
CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"});
|
27
|
+
CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"});
|
28
|
+
});
|
@@ -0,0 +1,150 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
var defaultTags = {
|
15
|
+
script: [
|
16
|
+
["lang", /(javascript|babel)/i, "javascript"],
|
17
|
+
["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, "javascript"],
|
18
|
+
["type", /./, "text/plain"],
|
19
|
+
[null, null, "javascript"]
|
20
|
+
],
|
21
|
+
style: [
|
22
|
+
["lang", /^css$/i, "css"],
|
23
|
+
["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
|
24
|
+
["type", /./, "text/plain"],
|
25
|
+
[null, null, "css"]
|
26
|
+
]
|
27
|
+
};
|
28
|
+
|
29
|
+
function maybeBackup(stream, pat, style) {
|
30
|
+
var cur = stream.current(), close = cur.search(pat);
|
31
|
+
if (close > -1) {
|
32
|
+
stream.backUp(cur.length - close);
|
33
|
+
} else if (cur.match(/<\/?$/)) {
|
34
|
+
stream.backUp(cur.length);
|
35
|
+
if (!stream.match(pat, false)) stream.match(cur);
|
36
|
+
}
|
37
|
+
return style;
|
38
|
+
}
|
39
|
+
|
40
|
+
var attrRegexpCache = {};
|
41
|
+
function getAttrRegexp(attr) {
|
42
|
+
var regexp = attrRegexpCache[attr];
|
43
|
+
if (regexp) return regexp;
|
44
|
+
return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
|
45
|
+
}
|
46
|
+
|
47
|
+
function getAttrValue(stream, attr) {
|
48
|
+
var pos = stream.pos, match;
|
49
|
+
while (pos >= 0 && stream.string.charAt(pos) !== "<") pos--;
|
50
|
+
if (pos < 0) return pos;
|
51
|
+
if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr)))
|
52
|
+
return match[2];
|
53
|
+
return "";
|
54
|
+
}
|
55
|
+
|
56
|
+
function getTagRegexp(tagName, anchored) {
|
57
|
+
return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
|
58
|
+
}
|
59
|
+
|
60
|
+
function addTags(from, to) {
|
61
|
+
for (var tag in from) {
|
62
|
+
var dest = to[tag] || (to[tag] = []);
|
63
|
+
var source = from[tag];
|
64
|
+
for (var i = source.length - 1; i >= 0; i--)
|
65
|
+
dest.unshift(source[i])
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
function findMatchingMode(tagInfo, stream) {
|
70
|
+
for (var i = 0; i < tagInfo.length; i++) {
|
71
|
+
var spec = tagInfo[i];
|
72
|
+
if (!spec[0] || spec[1].test(getAttrValue(stream, spec[0]))) return spec[2];
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
|
77
|
+
var htmlMode = CodeMirror.getMode(config, {
|
78
|
+
name: "xml",
|
79
|
+
htmlMode: true,
|
80
|
+
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
|
81
|
+
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
|
82
|
+
});
|
83
|
+
|
84
|
+
var tags = {};
|
85
|
+
var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
|
86
|
+
addTags(defaultTags, tags);
|
87
|
+
if (configTags) addTags(configTags, tags);
|
88
|
+
if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
|
89
|
+
tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
|
90
|
+
|
91
|
+
function html(stream, state) {
|
92
|
+
var tagName = state.htmlState.tagName;
|
93
|
+
var tagInfo = tagName && tags[tagName.toLowerCase()];
|
94
|
+
|
95
|
+
var style = htmlMode.token(stream, state.htmlState), modeSpec;
|
96
|
+
|
97
|
+
if (tagInfo && /\btag\b/.test(style) && stream.current() === ">" &&
|
98
|
+
(modeSpec = findMatchingMode(tagInfo, stream))) {
|
99
|
+
var mode = CodeMirror.getMode(config, modeSpec);
|
100
|
+
var endTagA = getTagRegexp(tagName, true), endTag = getTagRegexp(tagName, false);
|
101
|
+
state.token = function (stream, state) {
|
102
|
+
if (stream.match(endTagA, false)) {
|
103
|
+
state.token = html;
|
104
|
+
state.localState = state.localMode = null;
|
105
|
+
return null;
|
106
|
+
}
|
107
|
+
return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
|
108
|
+
};
|
109
|
+
state.localMode = mode;
|
110
|
+
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
|
111
|
+
}
|
112
|
+
return style;
|
113
|
+
};
|
114
|
+
|
115
|
+
return {
|
116
|
+
startState: function () {
|
117
|
+
var state = htmlMode.startState();
|
118
|
+
return {token: html, localMode: null, localState: null, htmlState: state};
|
119
|
+
},
|
120
|
+
|
121
|
+
copyState: function (state) {
|
122
|
+
var local;
|
123
|
+
if (state.localState) {
|
124
|
+
local = CodeMirror.copyState(state.localMode, state.localState);
|
125
|
+
}
|
126
|
+
return {token: state.token, localMode: state.localMode, localState: local,
|
127
|
+
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
|
128
|
+
},
|
129
|
+
|
130
|
+
token: function (stream, state) {
|
131
|
+
return state.token(stream, state);
|
132
|
+
},
|
133
|
+
|
134
|
+
indent: function (state, textAfter) {
|
135
|
+
if (!state.localMode || /^\s*<\//.test(textAfter))
|
136
|
+
return htmlMode.indent(state.htmlState, textAfter);
|
137
|
+
else if (state.localMode.indent)
|
138
|
+
return state.localMode.indent(state.localState, textAfter);
|
139
|
+
else
|
140
|
+
return CodeMirror.Pass;
|
141
|
+
},
|
142
|
+
|
143
|
+
innerMode: function (state) {
|
144
|
+
return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
|
145
|
+
}
|
146
|
+
};
|
147
|
+
}, "xml", "javascript", "css");
|
148
|
+
|
149
|
+
CodeMirror.defineMIME("text/html", "htmlmixed");
|
150
|
+
});
|
@@ -0,0 +1,708 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// TODO actually recognize syntax of TypeScript constructs
|
5
|
+
|
6
|
+
(function(mod) {
|
7
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
8
|
+
mod(require("../../lib/codemirror"));
|
9
|
+
else if (typeof define == "function" && define.amd) // AMD
|
10
|
+
define(["../../lib/codemirror"], mod);
|
11
|
+
else // Plain browser env
|
12
|
+
mod(CodeMirror);
|
13
|
+
})(function(CodeMirror) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
17
|
+
var indentUnit = config.indentUnit;
|
18
|
+
var statementIndent = parserConfig.statementIndent;
|
19
|
+
var jsonldMode = parserConfig.jsonld;
|
20
|
+
var jsonMode = parserConfig.json || jsonldMode;
|
21
|
+
var isTS = parserConfig.typescript;
|
22
|
+
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
23
|
+
|
24
|
+
// Tokenizer
|
25
|
+
|
26
|
+
var keywords = function(){
|
27
|
+
function kw(type) {return {type: type, style: "keyword"};}
|
28
|
+
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
29
|
+
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
30
|
+
|
31
|
+
var jsKeywords = {
|
32
|
+
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
33
|
+
"return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,
|
34
|
+
"var": kw("var"), "const": kw("var"), "let": kw("var"),
|
35
|
+
"async": kw("async"), "function": kw("function"), "catch": kw("catch"),
|
36
|
+
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
37
|
+
"in": operator, "typeof": operator, "instanceof": operator,
|
38
|
+
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
39
|
+
"this": kw("this"), "class": kw("class"), "super": kw("atom"),
|
40
|
+
"await": C, "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
|
41
|
+
};
|
42
|
+
|
43
|
+
// Extend the 'normal' keywords with the TypeScript language extensions
|
44
|
+
if (isTS) {
|
45
|
+
var type = {type: "variable", style: "variable-3"};
|
46
|
+
var tsKeywords = {
|
47
|
+
// object-like things
|
48
|
+
"interface": kw("interface"),
|
49
|
+
"extends": kw("extends"),
|
50
|
+
"constructor": kw("constructor"),
|
51
|
+
|
52
|
+
// scope modifiers
|
53
|
+
"public": kw("public"),
|
54
|
+
"private": kw("private"),
|
55
|
+
"protected": kw("protected"),
|
56
|
+
"static": kw("static"),
|
57
|
+
|
58
|
+
// types
|
59
|
+
"string": type, "number": type, "bool": type, "any": type
|
60
|
+
};
|
61
|
+
|
62
|
+
for (var attr in tsKeywords) {
|
63
|
+
jsKeywords[attr] = tsKeywords[attr];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
return jsKeywords;
|
68
|
+
}();
|
69
|
+
|
70
|
+
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
71
|
+
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
72
|
+
|
73
|
+
function readRegexp(stream) {
|
74
|
+
var escaped = false, next, inSet = false;
|
75
|
+
while ((next = stream.next()) != null) {
|
76
|
+
if (!escaped) {
|
77
|
+
if (next == "/" && !inSet) return;
|
78
|
+
if (next == "[") inSet = true;
|
79
|
+
else if (inSet && next == "]") inSet = false;
|
80
|
+
}
|
81
|
+
escaped = !escaped && next == "\\";
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
// Used as scratch variables to communicate multiple values without
|
86
|
+
// consing up tons of objects.
|
87
|
+
var type, content;
|
88
|
+
function ret(tp, style, cont) {
|
89
|
+
type = tp; content = cont;
|
90
|
+
return style;
|
91
|
+
}
|
92
|
+
function tokenBase(stream, state) {
|
93
|
+
var ch = stream.next();
|
94
|
+
if (ch == '"' || ch == "'") {
|
95
|
+
state.tokenize = tokenString(ch);
|
96
|
+
return state.tokenize(stream, state);
|
97
|
+
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
98
|
+
return ret("number", "number");
|
99
|
+
} else if (ch == "." && stream.match("..")) {
|
100
|
+
return ret("spread", "meta");
|
101
|
+
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
102
|
+
return ret(ch);
|
103
|
+
} else if (ch == "=" && stream.eat(">")) {
|
104
|
+
return ret("=>", "operator");
|
105
|
+
} else if (ch == "0" && stream.eat(/x/i)) {
|
106
|
+
stream.eatWhile(/[\da-f]/i);
|
107
|
+
return ret("number", "number");
|
108
|
+
} else if (ch == "0" && stream.eat(/o/i)) {
|
109
|
+
stream.eatWhile(/[0-7]/i);
|
110
|
+
return ret("number", "number");
|
111
|
+
} else if (ch == "0" && stream.eat(/b/i)) {
|
112
|
+
stream.eatWhile(/[01]/i);
|
113
|
+
return ret("number", "number");
|
114
|
+
} else if (/\d/.test(ch)) {
|
115
|
+
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
116
|
+
return ret("number", "number");
|
117
|
+
} else if (ch == "/") {
|
118
|
+
if (stream.eat("*")) {
|
119
|
+
state.tokenize = tokenComment;
|
120
|
+
return tokenComment(stream, state);
|
121
|
+
} else if (stream.eat("/")) {
|
122
|
+
stream.skipToEnd();
|
123
|
+
return ret("comment", "comment");
|
124
|
+
} else if (state.lastType == "operator" || state.lastType == "keyword c" ||
|
125
|
+
state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
|
126
|
+
readRegexp(stream);
|
127
|
+
stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
|
128
|
+
return ret("regexp", "string-2");
|
129
|
+
} else {
|
130
|
+
stream.eatWhile(isOperatorChar);
|
131
|
+
return ret("operator", "operator", stream.current());
|
132
|
+
}
|
133
|
+
} else if (ch == "`") {
|
134
|
+
state.tokenize = tokenQuasi;
|
135
|
+
return tokenQuasi(stream, state);
|
136
|
+
} else if (ch == "#") {
|
137
|
+
stream.skipToEnd();
|
138
|
+
return ret("error", "error");
|
139
|
+
} else if (isOperatorChar.test(ch)) {
|
140
|
+
stream.eatWhile(isOperatorChar);
|
141
|
+
return ret("operator", "operator", stream.current());
|
142
|
+
} else if (wordRE.test(ch)) {
|
143
|
+
stream.eatWhile(wordRE);
|
144
|
+
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
145
|
+
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
146
|
+
ret("variable", "variable", word);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
function tokenString(quote) {
|
151
|
+
return function(stream, state) {
|
152
|
+
var escaped = false, next;
|
153
|
+
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
154
|
+
state.tokenize = tokenBase;
|
155
|
+
return ret("jsonld-keyword", "meta");
|
156
|
+
}
|
157
|
+
while ((next = stream.next()) != null) {
|
158
|
+
if (next == quote && !escaped) break;
|
159
|
+
escaped = !escaped && next == "\\";
|
160
|
+
}
|
161
|
+
if (!escaped) state.tokenize = tokenBase;
|
162
|
+
return ret("string", "string");
|
163
|
+
};
|
164
|
+
}
|
165
|
+
|
166
|
+
function tokenComment(stream, state) {
|
167
|
+
var maybeEnd = false, ch;
|
168
|
+
while (ch = stream.next()) {
|
169
|
+
if (ch == "/" && maybeEnd) {
|
170
|
+
state.tokenize = tokenBase;
|
171
|
+
break;
|
172
|
+
}
|
173
|
+
maybeEnd = (ch == "*");
|
174
|
+
}
|
175
|
+
return ret("comment", "comment");
|
176
|
+
}
|
177
|
+
|
178
|
+
function tokenQuasi(stream, state) {
|
179
|
+
var escaped = false, next;
|
180
|
+
while ((next = stream.next()) != null) {
|
181
|
+
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
|
182
|
+
state.tokenize = tokenBase;
|
183
|
+
break;
|
184
|
+
}
|
185
|
+
escaped = !escaped && next == "\\";
|
186
|
+
}
|
187
|
+
return ret("quasi", "string-2", stream.current());
|
188
|
+
}
|
189
|
+
|
190
|
+
var brackets = "([{}])";
|
191
|
+
// This is a crude lookahead trick to try and notice that we're
|
192
|
+
// parsing the argument patterns for a fat-arrow function before we
|
193
|
+
// actually hit the arrow token. It only works if the arrow is on
|
194
|
+
// the same line as the arguments and there's no strange noise
|
195
|
+
// (comments) in between. Fallback is to only notice when we hit the
|
196
|
+
// arrow, and not declare the arguments as locals for the arrow
|
197
|
+
// body.
|
198
|
+
function findFatArrow(stream, state) {
|
199
|
+
if (state.fatArrowAt) state.fatArrowAt = null;
|
200
|
+
var arrow = stream.string.indexOf("=>", stream.start);
|
201
|
+
if (arrow < 0) return;
|
202
|
+
|
203
|
+
var depth = 0, sawSomething = false;
|
204
|
+
for (var pos = arrow - 1; pos >= 0; --pos) {
|
205
|
+
var ch = stream.string.charAt(pos);
|
206
|
+
var bracket = brackets.indexOf(ch);
|
207
|
+
if (bracket >= 0 && bracket < 3) {
|
208
|
+
if (!depth) { ++pos; break; }
|
209
|
+
if (--depth == 0) break;
|
210
|
+
} else if (bracket >= 3 && bracket < 6) {
|
211
|
+
++depth;
|
212
|
+
} else if (wordRE.test(ch)) {
|
213
|
+
sawSomething = true;
|
214
|
+
} else if (/["'\/]/.test(ch)) {
|
215
|
+
return;
|
216
|
+
} else if (sawSomething && !depth) {
|
217
|
+
++pos;
|
218
|
+
break;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
if (sawSomething && !depth) state.fatArrowAt = pos;
|
222
|
+
}
|
223
|
+
|
224
|
+
// Parser
|
225
|
+
|
226
|
+
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
227
|
+
|
228
|
+
function JSLexical(indented, column, type, align, prev, info) {
|
229
|
+
this.indented = indented;
|
230
|
+
this.column = column;
|
231
|
+
this.type = type;
|
232
|
+
this.prev = prev;
|
233
|
+
this.info = info;
|
234
|
+
if (align != null) this.align = align;
|
235
|
+
}
|
236
|
+
|
237
|
+
function inScope(state, varname) {
|
238
|
+
for (var v = state.localVars; v; v = v.next)
|
239
|
+
if (v.name == varname) return true;
|
240
|
+
for (var cx = state.context; cx; cx = cx.prev) {
|
241
|
+
for (var v = cx.vars; v; v = v.next)
|
242
|
+
if (v.name == varname) return true;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
function parseJS(state, style, type, content, stream) {
|
247
|
+
var cc = state.cc;
|
248
|
+
// Communicate our context to the combinators.
|
249
|
+
// (Less wasteful than consing up a hundred closures on every call.)
|
250
|
+
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
|
251
|
+
|
252
|
+
if (!state.lexical.hasOwnProperty("align"))
|
253
|
+
state.lexical.align = true;
|
254
|
+
|
255
|
+
while(true) {
|
256
|
+
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
257
|
+
if (combinator(type, content)) {
|
258
|
+
while(cc.length && cc[cc.length - 1].lex)
|
259
|
+
cc.pop()();
|
260
|
+
if (cx.marked) return cx.marked;
|
261
|
+
if (type == "variable" && inScope(state, content)) return "variable-2";
|
262
|
+
return style;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
// Combinator utils
|
268
|
+
|
269
|
+
var cx = {state: null, column: null, marked: null, cc: null};
|
270
|
+
function pass() {
|
271
|
+
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
272
|
+
}
|
273
|
+
function cont() {
|
274
|
+
pass.apply(null, arguments);
|
275
|
+
return true;
|
276
|
+
}
|
277
|
+
function register(varname) {
|
278
|
+
function inList(list) {
|
279
|
+
for (var v = list; v; v = v.next)
|
280
|
+
if (v.name == varname) return true;
|
281
|
+
return false;
|
282
|
+
}
|
283
|
+
var state = cx.state;
|
284
|
+
if (state.context) {
|
285
|
+
cx.marked = "def";
|
286
|
+
if (inList(state.localVars)) return;
|
287
|
+
state.localVars = {name: varname, next: state.localVars};
|
288
|
+
} else {
|
289
|
+
if (inList(state.globalVars)) return;
|
290
|
+
if (parserConfig.globalVars)
|
291
|
+
state.globalVars = {name: varname, next: state.globalVars};
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
// Combinators
|
296
|
+
|
297
|
+
var defaultVars = {name: "this", next: {name: "arguments"}};
|
298
|
+
function pushcontext() {
|
299
|
+
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
300
|
+
cx.state.localVars = defaultVars;
|
301
|
+
}
|
302
|
+
function popcontext() {
|
303
|
+
cx.state.localVars = cx.state.context.vars;
|
304
|
+
cx.state.context = cx.state.context.prev;
|
305
|
+
}
|
306
|
+
function pushlex(type, info) {
|
307
|
+
var result = function() {
|
308
|
+
var state = cx.state, indent = state.indented;
|
309
|
+
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
310
|
+
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
|
311
|
+
indent = outer.indented;
|
312
|
+
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
313
|
+
};
|
314
|
+
result.lex = true;
|
315
|
+
return result;
|
316
|
+
}
|
317
|
+
function poplex() {
|
318
|
+
var state = cx.state;
|
319
|
+
if (state.lexical.prev) {
|
320
|
+
if (state.lexical.type == ")")
|
321
|
+
state.indented = state.lexical.indented;
|
322
|
+
state.lexical = state.lexical.prev;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
poplex.lex = true;
|
326
|
+
|
327
|
+
function expect(wanted) {
|
328
|
+
function exp(type) {
|
329
|
+
if (type == wanted) return cont();
|
330
|
+
else if (wanted == ";") return pass();
|
331
|
+
else return cont(exp);
|
332
|
+
};
|
333
|
+
return exp;
|
334
|
+
}
|
335
|
+
|
336
|
+
function statement(type, value) {
|
337
|
+
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
338
|
+
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
339
|
+
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
340
|
+
if (type == "{") return cont(pushlex("}"), block, poplex);
|
341
|
+
if (type == ";") return cont();
|
342
|
+
if (type == "if") {
|
343
|
+
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
344
|
+
cx.state.cc.pop()();
|
345
|
+
return cont(pushlex("form"), expression, statement, poplex, maybeelse);
|
346
|
+
}
|
347
|
+
if (type == "function") return cont(functiondef);
|
348
|
+
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
349
|
+
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
350
|
+
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
351
|
+
block, poplex, poplex);
|
352
|
+
if (type == "case") return cont(expression, expect(":"));
|
353
|
+
if (type == "default") return cont(expect(":"));
|
354
|
+
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
355
|
+
statement, poplex, popcontext);
|
356
|
+
if (type == "class") return cont(pushlex("form"), className, poplex);
|
357
|
+
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
358
|
+
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
359
|
+
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
360
|
+
}
|
361
|
+
function expression(type) {
|
362
|
+
return expressionInner(type, false);
|
363
|
+
}
|
364
|
+
function expressionNoComma(type) {
|
365
|
+
return expressionInner(type, true);
|
366
|
+
}
|
367
|
+
function expressionInner(type, noComma) {
|
368
|
+
if (cx.state.fatArrowAt == cx.stream.start) {
|
369
|
+
var body = noComma ? arrowBodyNoComma : arrowBody;
|
370
|
+
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
|
371
|
+
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
372
|
+
}
|
373
|
+
|
374
|
+
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
375
|
+
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
376
|
+
if (type == "async") return cont(expression);
|
377
|
+
if (type == "function") return cont(functiondef, maybeop);
|
378
|
+
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
|
379
|
+
if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
|
380
|
+
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
381
|
+
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
382
|
+
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
383
|
+
if (type == "quasi") { return pass(quasi, maybeop); }
|
384
|
+
return cont();
|
385
|
+
}
|
386
|
+
function maybeexpression(type) {
|
387
|
+
if (type.match(/[;\}\)\],]/)) return pass();
|
388
|
+
return pass(expression);
|
389
|
+
}
|
390
|
+
function maybeexpressionNoComma(type) {
|
391
|
+
if (type.match(/[;\}\)\],]/)) return pass();
|
392
|
+
return pass(expressionNoComma);
|
393
|
+
}
|
394
|
+
|
395
|
+
function maybeoperatorComma(type, value) {
|
396
|
+
if (type == ",") return cont(expression);
|
397
|
+
return maybeoperatorNoComma(type, value, false);
|
398
|
+
}
|
399
|
+
function maybeoperatorNoComma(type, value, noComma) {
|
400
|
+
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
401
|
+
var expr = noComma == false ? expression : expressionNoComma;
|
402
|
+
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
403
|
+
if (type == "operator") {
|
404
|
+
if (/\+\+|--/.test(value)) return cont(me);
|
405
|
+
if (value == "?") return cont(expression, expect(":"), expr);
|
406
|
+
return cont(expr);
|
407
|
+
}
|
408
|
+
if (type == "quasi") { return pass(quasi, me); }
|
409
|
+
if (type == ";") return;
|
410
|
+
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
411
|
+
if (type == ".") return cont(property, me);
|
412
|
+
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
413
|
+
}
|
414
|
+
function quasi(type, value) {
|
415
|
+
if (type != "quasi") return pass();
|
416
|
+
if (value.slice(value.length - 2) != "${") return cont(quasi);
|
417
|
+
return cont(expression, continueQuasi);
|
418
|
+
}
|
419
|
+
function continueQuasi(type) {
|
420
|
+
if (type == "}") {
|
421
|
+
cx.marked = "string-2";
|
422
|
+
cx.state.tokenize = tokenQuasi;
|
423
|
+
return cont(quasi);
|
424
|
+
}
|
425
|
+
}
|
426
|
+
function arrowBody(type) {
|
427
|
+
findFatArrow(cx.stream, cx.state);
|
428
|
+
return pass(type == "{" ? statement : expression);
|
429
|
+
}
|
430
|
+
function arrowBodyNoComma(type) {
|
431
|
+
findFatArrow(cx.stream, cx.state);
|
432
|
+
return pass(type == "{" ? statement : expressionNoComma);
|
433
|
+
}
|
434
|
+
function maybelabel(type) {
|
435
|
+
if (type == ":") return cont(poplex, statement);
|
436
|
+
return pass(maybeoperatorComma, expect(";"), poplex);
|
437
|
+
}
|
438
|
+
function property(type) {
|
439
|
+
if (type == "variable") {cx.marked = "property"; return cont();}
|
440
|
+
}
|
441
|
+
function objprop(type, value) {
|
442
|
+
if (type == "async") {
|
443
|
+
return cont(objprop);
|
444
|
+
} else if (type == "variable" || cx.style == "keyword") {
|
445
|
+
cx.marked = "property";
|
446
|
+
if (value == "get" || value == "set") return cont(getterSetter);
|
447
|
+
return cont(afterprop);
|
448
|
+
} else if (type == "number" || type == "string") {
|
449
|
+
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
450
|
+
return cont(afterprop);
|
451
|
+
} else if (type == "jsonld-keyword") {
|
452
|
+
return cont(afterprop);
|
453
|
+
} else if (type == "[") {
|
454
|
+
return cont(expression, expect("]"), afterprop);
|
455
|
+
}
|
456
|
+
}
|
457
|
+
function getterSetter(type) {
|
458
|
+
if (type != "variable") return pass(afterprop);
|
459
|
+
cx.marked = "property";
|
460
|
+
return cont(functiondef);
|
461
|
+
}
|
462
|
+
function afterprop(type) {
|
463
|
+
if (type == ":") return cont(expressionNoComma);
|
464
|
+
if (type == "(") return pass(functiondef);
|
465
|
+
}
|
466
|
+
function commasep(what, end) {
|
467
|
+
function proceed(type) {
|
468
|
+
if (type == ",") {
|
469
|
+
var lex = cx.state.lexical;
|
470
|
+
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
471
|
+
return cont(what, proceed);
|
472
|
+
}
|
473
|
+
if (type == end) return cont();
|
474
|
+
return cont(expect(end));
|
475
|
+
}
|
476
|
+
return function(type) {
|
477
|
+
if (type == end) return cont();
|
478
|
+
return pass(what, proceed);
|
479
|
+
};
|
480
|
+
}
|
481
|
+
function contCommasep(what, end, info) {
|
482
|
+
for (var i = 3; i < arguments.length; i++)
|
483
|
+
cx.cc.push(arguments[i]);
|
484
|
+
return cont(pushlex(end, info), commasep(what, end), poplex);
|
485
|
+
}
|
486
|
+
function block(type) {
|
487
|
+
if (type == "}") return cont();
|
488
|
+
return pass(statement, block);
|
489
|
+
}
|
490
|
+
function maybetype(type) {
|
491
|
+
if (isTS && type == ":") return cont(typedef);
|
492
|
+
}
|
493
|
+
function maybedefault(_, value) {
|
494
|
+
if (value == "=") return cont(expressionNoComma);
|
495
|
+
}
|
496
|
+
function typedef(type) {
|
497
|
+
if (type == "variable") {cx.marked = "variable-3"; return cont();}
|
498
|
+
}
|
499
|
+
function vardef() {
|
500
|
+
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
501
|
+
}
|
502
|
+
function pattern(type, value) {
|
503
|
+
if (type == "variable") { register(value); return cont(); }
|
504
|
+
if (type == "[") return contCommasep(pattern, "]");
|
505
|
+
if (type == "{") return contCommasep(proppattern, "}");
|
506
|
+
}
|
507
|
+
function proppattern(type, value) {
|
508
|
+
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
|
509
|
+
register(value);
|
510
|
+
return cont(maybeAssign);
|
511
|
+
}
|
512
|
+
if (type == "variable") cx.marked = "property";
|
513
|
+
return cont(expect(":"), pattern, maybeAssign);
|
514
|
+
}
|
515
|
+
function maybeAssign(_type, value) {
|
516
|
+
if (value == "=") return cont(expressionNoComma);
|
517
|
+
}
|
518
|
+
function vardefCont(type) {
|
519
|
+
if (type == ",") return cont(vardef);
|
520
|
+
}
|
521
|
+
function maybeelse(type, value) {
|
522
|
+
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
523
|
+
}
|
524
|
+
function forspec(type) {
|
525
|
+
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
526
|
+
}
|
527
|
+
function forspec1(type) {
|
528
|
+
if (type == "var") return cont(vardef, expect(";"), forspec2);
|
529
|
+
if (type == ";") return cont(forspec2);
|
530
|
+
if (type == "variable") return cont(formaybeinof);
|
531
|
+
return pass(expression, expect(";"), forspec2);
|
532
|
+
}
|
533
|
+
function formaybeinof(_type, value) {
|
534
|
+
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
535
|
+
return cont(maybeoperatorComma, forspec2);
|
536
|
+
}
|
537
|
+
function forspec2(type, value) {
|
538
|
+
if (type == ";") return cont(forspec3);
|
539
|
+
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
540
|
+
return pass(expression, expect(";"), forspec3);
|
541
|
+
}
|
542
|
+
function forspec3(type) {
|
543
|
+
if (type != ")") cont(expression);
|
544
|
+
}
|
545
|
+
function functiondef(type, value) {
|
546
|
+
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
547
|
+
if (type == "variable") {register(value); return cont(functiondef);}
|
548
|
+
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
|
549
|
+
}
|
550
|
+
function funarg(type) {
|
551
|
+
if (type == "spread") return cont(funarg);
|
552
|
+
return pass(pattern, maybetype, maybedefault);
|
553
|
+
}
|
554
|
+
function className(type, value) {
|
555
|
+
if (type == "variable") {register(value); return cont(classNameAfter);}
|
556
|
+
}
|
557
|
+
function classNameAfter(type, value) {
|
558
|
+
if (value == "extends") return cont(expression, classNameAfter);
|
559
|
+
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
560
|
+
}
|
561
|
+
function classBody(type, value) {
|
562
|
+
if (type == "variable" || cx.style == "keyword") {
|
563
|
+
if (value == "static") {
|
564
|
+
cx.marked = "keyword";
|
565
|
+
return cont(classBody);
|
566
|
+
}
|
567
|
+
cx.marked = "property";
|
568
|
+
if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
|
569
|
+
return cont(functiondef, classBody);
|
570
|
+
}
|
571
|
+
if (value == "*") {
|
572
|
+
cx.marked = "keyword";
|
573
|
+
return cont(classBody);
|
574
|
+
}
|
575
|
+
if (type == ";") return cont(classBody);
|
576
|
+
if (type == "}") return cont();
|
577
|
+
}
|
578
|
+
function classGetterSetter(type) {
|
579
|
+
if (type != "variable") return pass();
|
580
|
+
cx.marked = "property";
|
581
|
+
return cont();
|
582
|
+
}
|
583
|
+
function afterExport(_type, value) {
|
584
|
+
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
585
|
+
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
586
|
+
return pass(statement);
|
587
|
+
}
|
588
|
+
function afterImport(type) {
|
589
|
+
if (type == "string") return cont();
|
590
|
+
return pass(importSpec, maybeFrom);
|
591
|
+
}
|
592
|
+
function importSpec(type, value) {
|
593
|
+
if (type == "{") return contCommasep(importSpec, "}");
|
594
|
+
if (type == "variable") register(value);
|
595
|
+
if (value == "*") cx.marked = "keyword";
|
596
|
+
return cont(maybeAs);
|
597
|
+
}
|
598
|
+
function maybeAs(_type, value) {
|
599
|
+
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
600
|
+
}
|
601
|
+
function maybeFrom(_type, value) {
|
602
|
+
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
|
603
|
+
}
|
604
|
+
function arrayLiteral(type) {
|
605
|
+
if (type == "]") return cont();
|
606
|
+
return pass(expressionNoComma, maybeArrayComprehension);
|
607
|
+
}
|
608
|
+
function maybeArrayComprehension(type) {
|
609
|
+
if (type == "for") return pass(comprehension, expect("]"));
|
610
|
+
if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
|
611
|
+
return pass(commasep(expressionNoComma, "]"));
|
612
|
+
}
|
613
|
+
function comprehension(type) {
|
614
|
+
if (type == "for") return cont(forspec, comprehension);
|
615
|
+
if (type == "if") return cont(expression, comprehension);
|
616
|
+
}
|
617
|
+
|
618
|
+
function isContinuedStatement(state, textAfter) {
|
619
|
+
return state.lastType == "operator" || state.lastType == "," ||
|
620
|
+
isOperatorChar.test(textAfter.charAt(0)) ||
|
621
|
+
/[,.]/.test(textAfter.charAt(0));
|
622
|
+
}
|
623
|
+
|
624
|
+
// Interface
|
625
|
+
|
626
|
+
return {
|
627
|
+
startState: function(basecolumn) {
|
628
|
+
var state = {
|
629
|
+
tokenize: tokenBase,
|
630
|
+
lastType: "sof",
|
631
|
+
cc: [],
|
632
|
+
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
633
|
+
localVars: parserConfig.localVars,
|
634
|
+
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
635
|
+
indented: 0
|
636
|
+
};
|
637
|
+
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
638
|
+
state.globalVars = parserConfig.globalVars;
|
639
|
+
return state;
|
640
|
+
},
|
641
|
+
|
642
|
+
token: function(stream, state) {
|
643
|
+
if (stream.sol()) {
|
644
|
+
if (!state.lexical.hasOwnProperty("align"))
|
645
|
+
state.lexical.align = false;
|
646
|
+
state.indented = stream.indentation();
|
647
|
+
findFatArrow(stream, state);
|
648
|
+
}
|
649
|
+
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
|
650
|
+
var style = state.tokenize(stream, state);
|
651
|
+
if (type == "comment") return style;
|
652
|
+
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
653
|
+
return parseJS(state, style, type, content, stream);
|
654
|
+
},
|
655
|
+
|
656
|
+
indent: function(state, textAfter) {
|
657
|
+
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
658
|
+
if (state.tokenize != tokenBase) return 0;
|
659
|
+
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
660
|
+
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
661
|
+
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
662
|
+
var c = state.cc[i];
|
663
|
+
if (c == poplex) lexical = lexical.prev;
|
664
|
+
else if (c != maybeelse) break;
|
665
|
+
}
|
666
|
+
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
667
|
+
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
668
|
+
lexical = lexical.prev;
|
669
|
+
var type = lexical.type, closing = firstChar == type;
|
670
|
+
|
671
|
+
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
|
672
|
+
else if (type == "form" && firstChar == "{") return lexical.indented;
|
673
|
+
else if (type == "form") return lexical.indented + indentUnit;
|
674
|
+
else if (type == "stat")
|
675
|
+
return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
|
676
|
+
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
677
|
+
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
678
|
+
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
679
|
+
else return lexical.indented + (closing ? 0 : indentUnit);
|
680
|
+
},
|
681
|
+
|
682
|
+
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
683
|
+
blockCommentStart: jsonMode ? null : "/*",
|
684
|
+
blockCommentEnd: jsonMode ? null : "*/",
|
685
|
+
lineComment: jsonMode ? null : "//",
|
686
|
+
fold: "brace",
|
687
|
+
closeBrackets: "()[]{}''\"\"``",
|
688
|
+
|
689
|
+
helperType: jsonMode ? "json" : "javascript",
|
690
|
+
jsonldMode: jsonldMode,
|
691
|
+
jsonMode: jsonMode
|
692
|
+
};
|
693
|
+
});
|
694
|
+
|
695
|
+
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
696
|
+
|
697
|
+
CodeMirror.defineMIME("text/javascript", "javascript");
|
698
|
+
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
699
|
+
CodeMirror.defineMIME("application/javascript", "javascript");
|
700
|
+
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
701
|
+
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
702
|
+
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
703
|
+
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
704
|
+
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
705
|
+
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
706
|
+
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
707
|
+
|
708
|
+
});
|