vapid 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/.gitignore +10 -0
- data/.gitmodules +6 -0
- data/.rspec +2 -0
- data/.rubocop.yml +133 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/vapid +7 -0
- data/lib/vapid.rb +24 -0
- data/lib/vapid/assets/javascripts/vapid/admin.coffee +2 -0
- data/lib/vapid/assets/stylesheets/vapid/admin.scss +72 -0
- data/lib/vapid/builder.rb +70 -0
- data/lib/vapid/cli.rb +96 -0
- data/lib/vapid/controllers/admin_controller.rb +282 -0
- data/lib/vapid/controllers/project_controller.rb +41 -0
- data/lib/vapid/db/migrate/20170202182310_create_groups.rb +12 -0
- data/lib/vapid/db/migrate/20170202183017_create_records.rb +11 -0
- data/lib/vapid/db/migrate/20170202185150_create_users.rb +11 -0
- data/lib/vapid/directive.rb +168 -0
- data/lib/vapid/directives.rb +30 -0
- data/lib/vapid/directives/audio.rb +27 -0
- data/lib/vapid/directives/group.rb +71 -0
- data/lib/vapid/directives/hide.rb +11 -0
- data/lib/vapid/directives/href.rb +11 -0
- data/lib/vapid/directives/image.rb +14 -0
- data/lib/vapid/directives/richtext.rb +15 -0
- data/lib/vapid/directives/show.rb +11 -0
- data/lib/vapid/directives/text.rb +24 -0
- data/lib/vapid/directives/video.rb +28 -0
- data/lib/vapid/generator_template/.gitignore +21 -0
- data/lib/vapid/generator_template/Gemfile.tt +13 -0
- data/lib/vapid/generator_template/README.md +0 -0
- data/lib/vapid/generator_template/assets/favicon.ico +0 -0
- data/lib/vapid/generator_template/assets/images/.keep +0 -0
- data/lib/vapid/generator_template/assets/javascripts/.keep +0 -0
- data/lib/vapid/generator_template/assets/stylesheets/.keep +0 -0
- data/lib/vapid/generator_template/assets/stylesheets/application.css +120 -0
- data/lib/vapid/generator_template/config.ru +3 -0
- data/lib/vapid/generator_template/config/database.yml +12 -0
- data/lib/vapid/generator_template/config/settings.yml.tt +11 -0
- data/lib/vapid/generator_template/templates/index.html.erb +25 -0
- data/lib/vapid/generator_template/templates/layouts/default.html.erb +22 -0
- data/lib/vapid/models.rb +18 -0
- data/lib/vapid/models/group.rb +36 -0
- data/lib/vapid/models/record.rb +30 -0
- data/lib/vapid/models/user.rb +16 -0
- data/lib/vapid/server.rb +93 -0
- data/lib/vapid/settings.rb +13 -0
- data/lib/vapid/template.rb +79 -0
- data/lib/vapid/template/node.rb +91 -0
- data/lib/vapid/template/parser.rb +50 -0
- data/lib/vapid/vendor/semantic-ui/.versions +4 -0
- data/lib/vapid/vendor/semantic-ui/LICENSE +22 -0
- data/lib/vapid/vendor/semantic-ui/README.md +7 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.css +252 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.js +610 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/ad.css +275 -0
- data/lib/vapid/vendor/semantic-ui/components/ad.min.css +10 -0
- data/lib/vapid/vendor/semantic-ui/components/api.js +1167 -0
- data/lib/vapid/vendor/semantic-ui/components/api.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/breadcrumb.css +124 -0
- data/lib/vapid/vendor/semantic-ui/components/breadcrumb.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/button.css +3450 -0
- data/lib/vapid/vendor/semantic-ui/components/button.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/card.css +964 -0
- data/lib/vapid/vendor/semantic-ui/components/card.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.css +625 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.js +831 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/colorize.js +274 -0
- data/lib/vapid/vendor/semantic-ui/components/colorize.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/comment.css +270 -0
- data/lib/vapid/vendor/semantic-ui/components/comment.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/container.css +147 -0
- data/lib/vapid/vendor/semantic-ui/components/container.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.css +200 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.js +708 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/divider.css +260 -0
- data/lib/vapid/vendor/semantic-ui/components/divider.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.css +1442 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.js +3767 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.css +166 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.js +696 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/feed.css +296 -0
- data/lib/vapid/vendor/semantic-ui/components/feed.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/flag.css +1031 -0
- data/lib/vapid/vendor/semantic-ui/components/flag.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/form.css +1067 -0
- data/lib/vapid/vendor/semantic-ui/components/form.js +1603 -0
- data/lib/vapid/vendor/semantic-ui/components/form.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/form.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/grid.css +2002 -0
- data/lib/vapid/vendor/semantic-ui/components/grid.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/header.css +721 -0
- data/lib/vapid/vendor/semantic-ui/components/header.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/icon.css +3292 -0
- data/lib/vapid/vendor/semantic-ui/components/icon.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/image.css +306 -0
- data/lib/vapid/vendor/semantic-ui/components/image.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/input.css +510 -0
- data/lib/vapid/vendor/semantic-ui/components/input.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/item.css +486 -0
- data/lib/vapid/vendor/semantic-ui/components/item.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/label.css +1307 -0
- data/lib/vapid/vendor/semantic-ui/components/label.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/list.css +951 -0
- data/lib/vapid/vendor/semantic-ui/components/list.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/loader.css +347 -0
- data/lib/vapid/vendor/semantic-ui/components/loader.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/menu.css +2002 -0
- data/lib/vapid/vendor/semantic-ui/components/menu.min.css +1 -0
- data/lib/vapid/vendor/semantic-ui/components/message.css +477 -0
- data/lib/vapid/vendor/semantic-ui/components/message.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.css +502 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.js +913 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.css +147 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.js +507 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.css +733 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.js +1475 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.css +516 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.js +931 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/rail.css +152 -0
- data/lib/vapid/vendor/semantic-ui/components/rail.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.css +263 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.js +508 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/reset.css +424 -0
- data/lib/vapid/vendor/semantic-ui/components/reset.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/reveal.css +284 -0
- data/lib/vapid/vendor/semantic-ui/components/reveal.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/search.css +408 -0
- data/lib/vapid/vendor/semantic-ui/components/search.js +1442 -0
- data/lib/vapid/vendor/semantic-ui/components/search.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/search.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/segment.css +798 -0
- data/lib/vapid/vendor/semantic-ui/components/segment.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.css +157 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.js +921 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.css +634 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.js +1036 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/site.css +160 -0
- data/lib/vapid/vendor/semantic-ui/components/site.js +487 -0
- data/lib/vapid/vendor/semantic-ui/components/site.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/site.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/state.js +708 -0
- data/lib/vapid/vendor/semantic-ui/components/state.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/statistic.css +569 -0
- data/lib/vapid/vendor/semantic-ui/components/statistic.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/step.css +623 -0
- data/lib/vapid/vendor/semantic-ui/components/step.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.css +78 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.js +942 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.css +91 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.js +952 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/table.css +1108 -0
- data/lib/vapid/vendor/semantic-ui/components/table.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.css +1964 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.js +1095 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/video.css +125 -0
- data/lib/vapid/vendor/semantic-ui/components/video.js +532 -0
- data/lib/vapid/vendor/semantic-ui/components/video.min.css +10 -0
- data/lib/vapid/vendor/semantic-ui/components/video.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/visibility.js +1288 -0
- data/lib/vapid/vendor/semantic-ui/components/visibility.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/visit.js +517 -0
- data/lib/vapid/vendor/semantic-ui/components/visit.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/package.js +34 -0
- data/lib/vapid/vendor/semantic-ui/package.json +20 -0
- data/lib/vapid/vendor/semantic-ui/semantic.css +36844 -0
- data/lib/vapid/vendor/semantic-ui/semantic.js +22617 -0
- data/lib/vapid/vendor/semantic-ui/semantic.min.css +364 -0
- data/lib/vapid/vendor/semantic-ui/semantic.min.js +19 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.eot +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.otf +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.svg +2671 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.ttf +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/images/flags.png +0 -0
- data/lib/vapid/vendor/trix/.blade.yml +45 -0
- data/lib/vapid/vendor/trix/.github/ISSUE_TEMPLATE.md +13 -0
- data/lib/vapid/vendor/trix/.gitignore +3 -0
- data/lib/vapid/vendor/trix/.ruby-version +1 -0
- data/lib/vapid/vendor/trix/.travis.yml +6 -0
- data/lib/vapid/vendor/trix/CONDUCT.md +79 -0
- data/lib/vapid/vendor/trix/Gemfile +17 -0
- data/lib/vapid/vendor/trix/Gemfile.lock +152 -0
- data/lib/vapid/vendor/trix/LICENSE +20 -0
- data/lib/vapid/vendor/trix/README.md +382 -0
- data/lib/vapid/vendor/trix/assets/index.html +55 -0
- data/lib/vapid/vendor/trix/assets/trix-core.coffee +2 -0
- data/lib/vapid/vendor/trix/assets/trix.coffee +3 -0
- data/lib/vapid/vendor/trix/assets/trix.scss +5 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.coffee.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.scss.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.txt.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/images/README.md +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/attach.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/bold.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/bullets.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/code.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/heading_1.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/italic.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/link.svg +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_decrease.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_increase.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/numbers.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/quote.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/redo.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/remove.svg +4 -0
- data/lib/vapid/vendor/trix/assets/trix/images/strike.svg +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/trash.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/undo.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/attachments.scss +112 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/content.scss +88 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/editor.scss +8 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/icons.scss +14 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/media-queries.scss +7 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/toolbar.scss +194 -0
- data/lib/vapid/vendor/trix/bin/blade +16 -0
- data/lib/vapid/vendor/trix/bin/ci +21 -0
- data/lib/vapid/vendor/trix/bin/rackup +16 -0
- data/lib/vapid/vendor/trix/bin/rake +16 -0
- data/lib/vapid/vendor/trix/bin/release +139 -0
- data/lib/vapid/vendor/trix/bin/setup +69 -0
- data/lib/vapid/vendor/trix/bin/update-status-image +100 -0
- data/lib/vapid/vendor/trix/bower.json +34 -0
- data/lib/vapid/vendor/trix/config.ru +32 -0
- data/lib/vapid/vendor/trix/dist/trix-core.js +11 -0
- data/lib/vapid/vendor/trix/dist/trix.css +286 -0
- data/lib/vapid/vendor/trix/dist/trix.js +20 -0
- data/lib/vapid/vendor/trix/package.json +29 -0
- data/lib/vapid/vendor/trix/polyfills/polyfills.coffee +3 -0
- data/lib/vapid/vendor/trix/polyfills/set.coffee +24 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/CustomElements.js +1029 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/README.md +2 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/promise.js +228 -0
- data/lib/vapid/vendor/trix/src/trix/VERSION +1 -0
- data/lib/vapid/vendor/trix/src/trix/config/block_attributes.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/config/css.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/config/file_size_formatting.coffee +22 -0
- data/lib/vapid/vendor/trix/src/trix/config/index.coffee +9 -0
- data/lib/vapid/vendor/trix/src/trix/config/lang.coffee +26 -0
- data/lib/vapid/vendor/trix/src/trix/config/selection_elements.coffee +26 -0
- data/lib/vapid/vendor/trix/src/trix/config/serialization.coffee +63 -0
- data/lib/vapid/vendor/trix/src/trix/config/text_attributes.coffee +25 -0
- data/lib/vapid/vendor/trix/src/trix/config/toolbar.coffee +41 -0
- data/lib/vapid/vendor/trix/src/trix/config/undo_interval.coffee +7 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/attachment_editor_controller.coffee +104 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/composition_controller.coffee +117 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/controller.coffee +3 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/editor_controller.coffee +369 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/input/composition_input.coffee +57 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/input_controller.coffee +473 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/toolbar_controller.coffee +173 -0
- data/lib/vapid/vendor/trix/src/trix/core/basic_object.coffee +44 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/element_store.coffee +21 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/hash.coffee +98 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/index.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/object_group.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/object_map.coffee +10 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/arrays.coffee +34 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/config.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/custom_elements.coffee +45 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/dom.coffee +185 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/extend.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/functions.coffee +3 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/global.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/index.coffee +10 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/objects.coffee +11 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/ranges.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/selection.coffee +25 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/strings.coffee +46 -0
- data/lib/vapid/vendor/trix/src/trix/core/index.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/object.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/index.coffee +2 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/operation.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/utf16_string.coffee +93 -0
- data/lib/vapid/vendor/trix/src/trix/elements/trix_editor_element.coffee +166 -0
- data/lib/vapid/vendor/trix/src/trix/elements/trix_toolbar_element.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/index.coffee.erb +14 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/control_element.coffee +60 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/debugger.coffee +104 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/element.coffee +86 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/index.coffee +17 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/polyfills/vendor/details-element-polyfill.js +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/debug.jst.eco +17 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/document.jst.eco +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/performance.jst.eco +10 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/render.jst.eco +1 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/selection.jst.eco +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/undo.jst.eco +13 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/view.coffee +58 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/debug_view.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/document_view.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee +51 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/render_view.coffee +21 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/selection_view.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/undo_view.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/deserializer.coffee +55 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/index.coffee +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player.coffee +60 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_controller.coffee +43 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_element.coffee +32 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_view.coffee +133 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recorder.coffee +82 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recording.coffee +54 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/serializer.coffee +61 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment.coffee +157 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment_manager.coffee +24 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment_piece.coffee +47 -0
- data/lib/vapid/vendor/trix/src/trix/models/block.coffee +230 -0
- data/lib/vapid/vendor/trix/src/trix/models/composition.coffee +521 -0
- data/lib/vapid/vendor/trix/src/trix/models/document.coffee +538 -0
- data/lib/vapid/vendor/trix/src/trix/models/editor.coffee +141 -0
- data/lib/vapid/vendor/trix/src/trix/models/html_parser.coffee +335 -0
- data/lib/vapid/vendor/trix/src/trix/models/line_break_insertion.coffee +31 -0
- data/lib/vapid/vendor/trix/src/trix/models/location_mapper.coffee +156 -0
- data/lib/vapid/vendor/trix/src/trix/models/managed_attachment.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/models/piece.coffee +95 -0
- data/lib/vapid/vendor/trix/src/trix/models/point_mapper.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/models/selection_manager.coffee +129 -0
- data/lib/vapid/vendor/trix/src/trix/models/splittable_list.coffee +168 -0
- data/lib/vapid/vendor/trix/src/trix/models/string_piece.coffee +49 -0
- data/lib/vapid/vendor/trix/src/trix/models/text.coffee +168 -0
- data/lib/vapid/vendor/trix/src/trix/models/undo_manager.coffee +40 -0
- data/lib/vapid/vendor/trix/src/trix/observers/mutation_observer.coffee +131 -0
- data/lib/vapid/vendor/trix/src/trix/observers/selection_change_observer.coffee +56 -0
- data/lib/vapid/vendor/trix/src/trix/operations/file_verification_operation.coffee +15 -0
- data/lib/vapid/vendor/trix/src/trix/operations/image_preload_operation.coffee +15 -0
- data/lib/vapid/vendor/trix/src/trix/views/attachment_view.coffee +99 -0
- data/lib/vapid/vendor/trix/src/trix/views/block_view.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/views/document_view.coffee +68 -0
- data/lib/vapid/vendor/trix/src/trix/views/object_group_view.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/views/object_view.coffee +86 -0
- data/lib/vapid/vendor/trix/src/trix/views/piece_view.coffee +97 -0
- data/lib/vapid/vendor/trix/src/trix/views/previewable_attachment_view.coffee +49 -0
- data/lib/vapid/vendor/trix/src/trix/views/text_view.coffee +30 -0
- data/lib/vapid/vendor/trix/test/.gitignore +1 -0
- data/lib/vapid/vendor/trix/test/src/system/attachment_test.coffee +70 -0
- data/lib/vapid/vendor/trix/test/src/system/basic_input_test.coffee +68 -0
- data/lib/vapid/vendor/trix/test/src/system/block_formatting_test.coffee +602 -0
- data/lib/vapid/vendor/trix/test/src/system/caching_test.coffee +21 -0
- data/lib/vapid/vendor/trix/test/src/system/composition_input_test.coffee +138 -0
- data/lib/vapid/vendor/trix/test/src/system/cursor_movement_test.coffee +54 -0
- data/lib/vapid/vendor/trix/test/src/system/custom_element_test.coffee +314 -0
- data/lib/vapid/vendor/trix/test/src/system/html_loading_test.coffee +62 -0
- data/lib/vapid/vendor/trix/test/src/system/html_replacement_test.coffee +101 -0
- data/lib/vapid/vendor/trix/test/src/system/installation_process_test.coffee +59 -0
- data/lib/vapid/vendor/trix/test/src/system/list_formatting_test.coffee +70 -0
- data/lib/vapid/vendor/trix/test/src/system/mutation_input_test.coffee +73 -0
- data/lib/vapid/vendor/trix/test/src/system/pasting_test.coffee +215 -0
- data/lib/vapid/vendor/trix/test/src/system/text_formatting_test.coffee +151 -0
- data/lib/vapid/vendor/trix/test/src/system/undo_test.coffee +48 -0
- data/lib/vapid/vendor/trix/test/src/test.coffee +16 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/assertions.coffee +38 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/editor_helpers.coffee +37 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_empty.jst.eco +1 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_html.jst.eco +2 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_in_table.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_block_styles.jst.eco +6 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_bold_styles.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_image.jst.eco +2 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_styled_content.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_toolbar_and_input.jst.eco +5 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/fixtures.coffee +536 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/logo.png +0 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/index.coffee +18 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/input_helpers.coffee +183 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/selection_helpers.coffee +91 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/test_helpers.coffee +72 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/test_stubs.coffee +31 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/toolbar_helpers.coffee +45 -0
- data/lib/vapid/vendor/trix/test/src/unit/attachment_test.coffee +23 -0
- data/lib/vapid/vendor/trix/test/src/unit/block_test.coffee +22 -0
- data/lib/vapid/vendor/trix/test/src/unit/composition_test.coffee +13 -0
- data/lib/vapid/vendor/trix/test/src/unit/document_test.coffee +11 -0
- data/lib/vapid/vendor/trix/test/src/unit/document_view_test.coffee +6 -0
- data/lib/vapid/vendor/trix/test/src/unit/html_parser_test.coffee +162 -0
- data/lib/vapid/vendor/trix/test/src/unit/location_mapper_test.coffee +185 -0
- data/lib/vapid/vendor/trix/test/src/unit/mutation_observer_test.coffee +84 -0
- data/lib/vapid/vendor/trix/test/src/unit/serialization_test.coffee +7 -0
- data/lib/vapid/vendor/trix/test/src/unit/string_change_summary_test.coffee +57 -0
- data/lib/vapid/vendor/trix/test/src/unit/text_test.coffee +19 -0
- data/lib/vapid/vendor/trix/test/vendor/rangy-core.js +3845 -0
- data/lib/vapid/vendor/trix/test/vendor/rangy-textrange.js +1930 -0
- data/lib/vapid/version.rb +4 -0
- data/lib/vapid/views/admin/install.html.erb +19 -0
- data/lib/vapid/views/admin/login.html.erb +11 -0
- data/lib/vapid/views/admin/overview/index.html.erb +1 -0
- data/lib/vapid/views/admin/records/_form.erb +9 -0
- data/lib/vapid/views/admin/records/edit.html.erb +5 -0
- data/lib/vapid/views/admin/records/index.html.erb +38 -0
- data/lib/vapid/views/admin/records/new.html.erb +3 -0
- data/lib/vapid/views/errors/404.html.erb +1 -0
- data/lib/vapid/views/errors/500.html.erb +1 -0
- data/lib/vapid/views/layouts/admin.html.erb +41 -0
- data/lib/vapid/views/layouts/admin_form.html.erb +22 -0
- data/lib/vapid/views/layouts/error.html.erb +11 -0
- data/vapid.gemspec +48 -0
- metadata +811 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
class Trix.LineBreakInsertion
|
2
|
+
constructor: (@composition) ->
|
3
|
+
{@document} = @composition
|
4
|
+
|
5
|
+
[@startPosition, @endPosition] = @composition.getSelectedRange()
|
6
|
+
@startLocation = @document.locationFromPosition(@startPosition)
|
7
|
+
@endLocation = @document.locationFromPosition(@endPosition)
|
8
|
+
|
9
|
+
@block = @document.getBlockAtIndex(@endLocation.index)
|
10
|
+
@breaksOnReturn = @block.breaksOnReturn()
|
11
|
+
@previousCharacter = @block.text.getStringAtPosition(@endLocation.offset - 1)
|
12
|
+
@nextCharacter = @block.text.getStringAtPosition(@endLocation.offset)
|
13
|
+
|
14
|
+
shouldInsertBlockBreak: ->
|
15
|
+
if @block.hasAttributes() and @block.isListItem() and not @block.isEmpty()
|
16
|
+
@startLocation.offset isnt 0
|
17
|
+
else
|
18
|
+
@breaksOnReturn and @nextCharacter isnt "\n"
|
19
|
+
|
20
|
+
shouldBreakFormattedBlock: ->
|
21
|
+
@block.hasAttributes() and not @block.isListItem() and
|
22
|
+
((@breaksOnReturn and @nextCharacter is "\n") or @previousCharacter is "\n")
|
23
|
+
|
24
|
+
shouldDecreaseListLevel: ->
|
25
|
+
@block.hasAttributes() and @block.isListItem() and @block.isEmpty()
|
26
|
+
|
27
|
+
shouldPrependListItem: ->
|
28
|
+
@block.isListItem() and @startLocation.offset is 0 and not @block.isEmpty()
|
29
|
+
|
30
|
+
shouldRemoveLastBlockAttribute: ->
|
31
|
+
@block.hasAttributes() and not @block.isListItem() and @block.isEmpty()
|
@@ -0,0 +1,156 @@
|
|
1
|
+
{elementContainsNode, findChildIndexOfNode, nodeIsBlockStart,
|
2
|
+
nodeIsBlockStartComment, nodeIsBlockContainer, nodeIsCursorTarget,
|
3
|
+
nodeIsEmptyTextNode, nodeIsTextNode, nodeIsAttachmentElement, tagName, walkTree} = Trix
|
4
|
+
|
5
|
+
class Trix.LocationMapper
|
6
|
+
constructor: (@element) ->
|
7
|
+
|
8
|
+
findLocationFromContainerAndOffset: (container, offset, {strict} = strict: true) ->
|
9
|
+
childIndex = 0
|
10
|
+
foundBlock = false
|
11
|
+
location = index: 0, offset: 0
|
12
|
+
|
13
|
+
if attachmentElement = @findAttachmentElementParentForNode(container)
|
14
|
+
container = attachmentElement.parentNode
|
15
|
+
offset = findChildIndexOfNode(attachmentElement)
|
16
|
+
|
17
|
+
walker = walkTree(@element, usingFilter: rejectAttachmentContents)
|
18
|
+
|
19
|
+
while walker.nextNode()
|
20
|
+
node = walker.currentNode
|
21
|
+
|
22
|
+
if node is container and nodeIsTextNode(container)
|
23
|
+
unless nodeIsCursorTarget(node)
|
24
|
+
location.offset += offset
|
25
|
+
break
|
26
|
+
|
27
|
+
else
|
28
|
+
if node.parentNode is container
|
29
|
+
break if childIndex++ is offset
|
30
|
+
else unless elementContainsNode(container, node)
|
31
|
+
break if childIndex > 0
|
32
|
+
|
33
|
+
if nodeIsBlockStart(node, {strict})
|
34
|
+
location.index++ if foundBlock
|
35
|
+
location.offset = 0
|
36
|
+
foundBlock = true
|
37
|
+
else
|
38
|
+
location.offset += nodeLength(node)
|
39
|
+
|
40
|
+
location
|
41
|
+
|
42
|
+
findContainerAndOffsetFromLocation: (location) ->
|
43
|
+
if location.index is 0 and location.offset is 0
|
44
|
+
container = @element
|
45
|
+
offset = 0
|
46
|
+
|
47
|
+
while container.firstChild
|
48
|
+
container = container.firstChild
|
49
|
+
if nodeIsBlockContainer(container)
|
50
|
+
offset = 1
|
51
|
+
break
|
52
|
+
|
53
|
+
return [container, offset]
|
54
|
+
|
55
|
+
[node, nodeOffset] = @findNodeAndOffsetFromLocation(location)
|
56
|
+
return unless node
|
57
|
+
|
58
|
+
if nodeIsTextNode(node)
|
59
|
+
container = node
|
60
|
+
string = node.textContent
|
61
|
+
offset = location.offset - nodeOffset
|
62
|
+
|
63
|
+
else
|
64
|
+
container = node.parentNode
|
65
|
+
|
66
|
+
unless nodeIsBlockStart(node.previousSibling)
|
67
|
+
unless nodeIsBlockContainer(container)
|
68
|
+
while node is container.lastChild
|
69
|
+
node = container
|
70
|
+
container = container.parentNode
|
71
|
+
break if nodeIsBlockContainer(container)
|
72
|
+
|
73
|
+
offset = findChildIndexOfNode(node)
|
74
|
+
offset++ unless location.offset is 0
|
75
|
+
|
76
|
+
[container, offset]
|
77
|
+
|
78
|
+
findNodeAndOffsetFromLocation: (location) ->
|
79
|
+
offset = 0
|
80
|
+
|
81
|
+
for currentNode in @getSignificantNodesForIndex(location.index)
|
82
|
+
length = nodeLength(currentNode)
|
83
|
+
|
84
|
+
if location.offset <= offset + length
|
85
|
+
if nodeIsTextNode(currentNode)
|
86
|
+
node = currentNode
|
87
|
+
nodeOffset = offset
|
88
|
+
break if location.offset is nodeOffset and nodeIsCursorTarget(node)
|
89
|
+
|
90
|
+
else if not node
|
91
|
+
node = currentNode
|
92
|
+
nodeOffset = offset
|
93
|
+
|
94
|
+
offset += length
|
95
|
+
break if offset > location.offset
|
96
|
+
|
97
|
+
[node, nodeOffset]
|
98
|
+
|
99
|
+
# Private
|
100
|
+
|
101
|
+
findAttachmentElementParentForNode: (node) ->
|
102
|
+
while node and node isnt @element
|
103
|
+
return node if nodeIsAttachmentElement(node)
|
104
|
+
node = node.parentNode
|
105
|
+
|
106
|
+
getSignificantNodesForIndex: (index) ->
|
107
|
+
nodes = []
|
108
|
+
walker = walkTree(@element, usingFilter: acceptSignificantNodes)
|
109
|
+
recordingNodes = false
|
110
|
+
|
111
|
+
while walker.nextNode()
|
112
|
+
node = walker.currentNode
|
113
|
+
if nodeIsBlockStartComment(node)
|
114
|
+
if blockIndex?
|
115
|
+
blockIndex++
|
116
|
+
else
|
117
|
+
blockIndex = 0
|
118
|
+
|
119
|
+
if blockIndex is index
|
120
|
+
recordingNodes = true
|
121
|
+
else if recordingNodes
|
122
|
+
break
|
123
|
+
else if recordingNodes
|
124
|
+
nodes.push(node)
|
125
|
+
|
126
|
+
nodes
|
127
|
+
|
128
|
+
nodeLength = (node) ->
|
129
|
+
if node.nodeType is Node.TEXT_NODE
|
130
|
+
if nodeIsCursorTarget(node)
|
131
|
+
0
|
132
|
+
else
|
133
|
+
string = node.textContent
|
134
|
+
string.length
|
135
|
+
else if tagName(node) is "br" or nodeIsAttachmentElement(node)
|
136
|
+
1
|
137
|
+
else
|
138
|
+
0
|
139
|
+
|
140
|
+
acceptSignificantNodes = (node) ->
|
141
|
+
if rejectEmptyTextNodes(node) is NodeFilter.FILTER_ACCEPT
|
142
|
+
rejectAttachmentContents(node)
|
143
|
+
else
|
144
|
+
NodeFilter.FILTER_REJECT
|
145
|
+
|
146
|
+
rejectEmptyTextNodes = (node) ->
|
147
|
+
if nodeIsEmptyTextNode(node)
|
148
|
+
NodeFilter.FILTER_REJECT
|
149
|
+
else
|
150
|
+
NodeFilter.FILTER_ACCEPT
|
151
|
+
|
152
|
+
rejectAttachmentContents = (node) ->
|
153
|
+
if nodeIsAttachmentElement(node.parentNode)
|
154
|
+
NodeFilter.FILTER_REJECT
|
155
|
+
else
|
156
|
+
NodeFilter.FILTER_ACCEPT
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#= require trix/models/attachment
|
2
|
+
|
3
|
+
class Trix.ManagedAttachment extends Trix.BasicObject
|
4
|
+
constructor: (@attachmentManager, @attachment) ->
|
5
|
+
{@id, @file} = @attachment
|
6
|
+
|
7
|
+
remove: ->
|
8
|
+
@attachmentManager.requestRemovalOfAttachment(@attachment)
|
9
|
+
|
10
|
+
@proxyMethod "attachment.getAttribute"
|
11
|
+
@proxyMethod "attachment.hasAttribute"
|
12
|
+
@proxyMethod "attachment.setAttribute"
|
13
|
+
@proxyMethod "attachment.getAttributes"
|
14
|
+
@proxyMethod "attachment.setAttributes"
|
15
|
+
@proxyMethod "attachment.isPending"
|
16
|
+
@proxyMethod "attachment.isPreviewable"
|
17
|
+
@proxyMethod "attachment.getURL"
|
18
|
+
@proxyMethod "attachment.getHref"
|
19
|
+
@proxyMethod "attachment.getFilename"
|
20
|
+
@proxyMethod "attachment.getFilesize"
|
21
|
+
@proxyMethod "attachment.getFormattedFilesize"
|
22
|
+
@proxyMethod "attachment.getExtension"
|
23
|
+
@proxyMethod "attachment.getContentType"
|
24
|
+
@proxyMethod "attachment.getFile"
|
25
|
+
@proxyMethod "attachment.setFile"
|
26
|
+
@proxyMethod "attachment.releaseFile"
|
27
|
+
@proxyMethod "attachment.getUploadProgress"
|
28
|
+
@proxyMethod "attachment.setUploadProgress"
|
@@ -0,0 +1,95 @@
|
|
1
|
+
class Trix.Piece extends Trix.Object
|
2
|
+
@types: {}
|
3
|
+
|
4
|
+
@registerType: (type, constructor) ->
|
5
|
+
constructor.type = type
|
6
|
+
@types[type] = constructor
|
7
|
+
|
8
|
+
@fromJSON: (pieceJSON) ->
|
9
|
+
if constructor = @types[pieceJSON.type]
|
10
|
+
constructor.fromJSON(pieceJSON)
|
11
|
+
|
12
|
+
constructor: (value, attributes = {}) ->
|
13
|
+
super
|
14
|
+
@attributes = Trix.Hash.box(attributes)
|
15
|
+
|
16
|
+
copyWithAttributes: (attributes) ->
|
17
|
+
new @constructor @getValue(), attributes
|
18
|
+
|
19
|
+
copyWithAdditionalAttributes: (attributes) ->
|
20
|
+
@copyWithAttributes(@attributes.merge(attributes))
|
21
|
+
|
22
|
+
copyWithoutAttribute: (attribute) ->
|
23
|
+
@copyWithAttributes(@attributes.remove(attribute))
|
24
|
+
|
25
|
+
copy: ->
|
26
|
+
@copyWithAttributes(@attributes)
|
27
|
+
|
28
|
+
getAttribute: (attribute) ->
|
29
|
+
@attributes.get(attribute)
|
30
|
+
|
31
|
+
getAttributesHash: ->
|
32
|
+
@attributes
|
33
|
+
|
34
|
+
getAttributes: ->
|
35
|
+
@attributes.toObject()
|
36
|
+
|
37
|
+
getCommonAttributes: ->
|
38
|
+
return {} unless piece = pieceList.getPieceAtIndex(0)
|
39
|
+
attributes = piece.attributes
|
40
|
+
keys = attributes.getKeys()
|
41
|
+
|
42
|
+
pieceList.eachPiece (piece) ->
|
43
|
+
keys = attributes.getKeysCommonToHash(piece.attributes)
|
44
|
+
attributes = attributes.slice(keys)
|
45
|
+
|
46
|
+
attributes.toObject()
|
47
|
+
|
48
|
+
hasAttribute: (attribute) ->
|
49
|
+
@attributes.has(attribute)
|
50
|
+
|
51
|
+
hasSameStringValueAsPiece: (piece) ->
|
52
|
+
piece? and @toString() is piece.toString()
|
53
|
+
|
54
|
+
hasSameAttributesAsPiece: (piece) ->
|
55
|
+
piece? and (@attributes is piece.attributes or @attributes.isEqualTo(piece.attributes))
|
56
|
+
|
57
|
+
isBlockBreak: ->
|
58
|
+
false
|
59
|
+
|
60
|
+
isEqualTo: (piece) ->
|
61
|
+
super or (
|
62
|
+
@hasSameConstructorAs(piece) and
|
63
|
+
@hasSameStringValueAsPiece(piece) and
|
64
|
+
@hasSameAttributesAsPiece(piece)
|
65
|
+
)
|
66
|
+
|
67
|
+
isEmpty: ->
|
68
|
+
@length is 0
|
69
|
+
|
70
|
+
isSerializable: ->
|
71
|
+
true
|
72
|
+
|
73
|
+
toJSON: ->
|
74
|
+
type: @constructor.type
|
75
|
+
attributes: @getAttributes()
|
76
|
+
|
77
|
+
contentsForInspection: ->
|
78
|
+
type: @constructor.type
|
79
|
+
attributes: @attributes.inspect()
|
80
|
+
|
81
|
+
# Grouping
|
82
|
+
|
83
|
+
canBeGrouped: ->
|
84
|
+
@hasAttribute("href")
|
85
|
+
|
86
|
+
canBeGroupedWith: (piece) ->
|
87
|
+
@getAttribute("href") is piece.getAttribute("href")
|
88
|
+
|
89
|
+
# Splittable
|
90
|
+
|
91
|
+
getLength: ->
|
92
|
+
@length
|
93
|
+
|
94
|
+
canBeConsolidatedWith: (piece) ->
|
95
|
+
false
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{getDOMRange, setDOMRange} = Trix
|
2
|
+
|
3
|
+
class Trix.PointMapper
|
4
|
+
createDOMRangeFromPoint: ({x, y}) ->
|
5
|
+
if document.caretPositionFromPoint
|
6
|
+
{offsetNode, offset} = document.caretPositionFromPoint(x, y)
|
7
|
+
domRange = document.createRange()
|
8
|
+
domRange.setStart(offsetNode, offset)
|
9
|
+
domRange
|
10
|
+
|
11
|
+
else if document.caretRangeFromPoint
|
12
|
+
document.caretRangeFromPoint(x, y)
|
13
|
+
|
14
|
+
else if document.body.createTextRange
|
15
|
+
originalDOMRange = getDOMRange()
|
16
|
+
try
|
17
|
+
# IE 11 throws "Unspecified error" when using moveToPoint
|
18
|
+
# during a drag-and-drop operation.
|
19
|
+
textRange = document.body.createTextRange()
|
20
|
+
textRange.moveToPoint(x, y)
|
21
|
+
textRange.select()
|
22
|
+
domRange = getDOMRange()
|
23
|
+
setDOMRange(originalDOMRange)
|
24
|
+
domRange
|
25
|
+
|
26
|
+
getClientRectsForDOMRange: (domRange) ->
|
27
|
+
[start, ..., end] = [domRange.getClientRects()...]
|
28
|
+
[start, end]
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#= require trix/models/location_mapper
|
2
|
+
#= require trix/models/point_mapper
|
3
|
+
#= require trix/observers/selection_change_observer
|
4
|
+
|
5
|
+
{getDOMSelection, getDOMRange, setDOMRange, elementContainsNode,
|
6
|
+
nodeIsCursorTarget, innerElementIsActive, handleEvent, normalizeRange,
|
7
|
+
rangeIsCollapsed, rangesAreEqual} = Trix
|
8
|
+
|
9
|
+
class Trix.SelectionManager extends Trix.BasicObject
|
10
|
+
constructor: (@element) ->
|
11
|
+
@locationMapper = new Trix.LocationMapper @element
|
12
|
+
@pointMapper = new Trix.PointMapper
|
13
|
+
@lockCount = 0
|
14
|
+
handleEvent("mousedown", onElement: @element, withCallback: @didMouseDown)
|
15
|
+
|
16
|
+
getLocationRange: (options = {}) ->
|
17
|
+
locationRange =
|
18
|
+
if options.strict is false
|
19
|
+
@createLocationRangeFromDOMRange(getDOMRange(), strict: false)
|
20
|
+
else if options.ignoreLock
|
21
|
+
@currentLocationRange
|
22
|
+
else
|
23
|
+
@lockedLocationRange ? @currentLocationRange
|
24
|
+
|
25
|
+
setLocationRange: (locationRange) ->
|
26
|
+
return if @lockedLocationRange
|
27
|
+
locationRange = normalizeRange(locationRange)
|
28
|
+
if domRange = @createDOMRangeFromLocationRange(locationRange)
|
29
|
+
setDOMRange(domRange)
|
30
|
+
@updateCurrentLocationRange(locationRange)
|
31
|
+
|
32
|
+
setLocationRangeFromPointRange: (pointRange) ->
|
33
|
+
pointRange = normalizeRange(pointRange)
|
34
|
+
startLocation = @getLocationAtPoint(pointRange[0])
|
35
|
+
endLocation = @getLocationAtPoint(pointRange[1])
|
36
|
+
@setLocationRange([startLocation, endLocation])
|
37
|
+
|
38
|
+
getClientRectAtLocationRange: (locationRange) ->
|
39
|
+
if domRange = @createDOMRangeFromLocationRange(locationRange)
|
40
|
+
@getClientRectsForDOMRange(domRange)[1]
|
41
|
+
|
42
|
+
locationIsCursorTarget: (location) ->
|
43
|
+
[node, offset] = @findNodeAndOffsetFromLocation(location)
|
44
|
+
nodeIsCursorTarget(node)
|
45
|
+
|
46
|
+
lock: ->
|
47
|
+
if @lockCount++ is 0
|
48
|
+
@updateCurrentLocationRange()
|
49
|
+
@lockedLocationRange = @getLocationRange()
|
50
|
+
|
51
|
+
unlock: ->
|
52
|
+
if --@lockCount is 0
|
53
|
+
lockedLocationRange = @lockedLocationRange
|
54
|
+
@lockedLocationRange = null
|
55
|
+
@setLocationRange(lockedLocationRange) if lockedLocationRange?
|
56
|
+
|
57
|
+
clearSelection: ->
|
58
|
+
getDOMSelection()?.removeAllRanges()
|
59
|
+
|
60
|
+
selectionIsCollapsed: ->
|
61
|
+
getDOMRange()?.collapsed is true
|
62
|
+
|
63
|
+
selectionIsExpanded: ->
|
64
|
+
not @selectionIsCollapsed()
|
65
|
+
|
66
|
+
# Private
|
67
|
+
|
68
|
+
@proxyMethod "locationMapper.findLocationFromContainerAndOffset"
|
69
|
+
@proxyMethod "locationMapper.findContainerAndOffsetFromLocation"
|
70
|
+
@proxyMethod "locationMapper.findNodeAndOffsetFromLocation"
|
71
|
+
@proxyMethod "pointMapper.createDOMRangeFromPoint"
|
72
|
+
@proxyMethod "pointMapper.getClientRectsForDOMRange"
|
73
|
+
|
74
|
+
didMouseDown: =>
|
75
|
+
@pauseTemporarily()
|
76
|
+
|
77
|
+
pauseTemporarily: ->
|
78
|
+
@paused = true
|
79
|
+
|
80
|
+
resume = =>
|
81
|
+
@paused = false
|
82
|
+
clearTimeout(resumeTimeout)
|
83
|
+
for handler in resumeHandlers
|
84
|
+
handler.destroy()
|
85
|
+
if elementContainsNode(document, @element)
|
86
|
+
@selectionDidChange()
|
87
|
+
|
88
|
+
resumeTimeout = setTimeout(resume, 200)
|
89
|
+
resumeHandlers = for eventName in ["mousemove", "keydown"]
|
90
|
+
handleEvent(eventName, onElement: document, withCallback: resume)
|
91
|
+
|
92
|
+
selectionDidChange: =>
|
93
|
+
unless @paused or innerElementIsActive(@element)
|
94
|
+
@updateCurrentLocationRange()
|
95
|
+
|
96
|
+
updateCurrentLocationRange: (locationRange) ->
|
97
|
+
if locationRange ?= @createLocationRangeFromDOMRange(getDOMRange())
|
98
|
+
if not rangesAreEqual(locationRange, @currentLocationRange)
|
99
|
+
@currentLocationRange = locationRange
|
100
|
+
@delegate?.locationRangeDidChange?(@currentLocationRange.slice(0))
|
101
|
+
|
102
|
+
createDOMRangeFromLocationRange: (locationRange) ->
|
103
|
+
rangeStart = @findContainerAndOffsetFromLocation(locationRange[0])
|
104
|
+
rangeEnd = if rangeIsCollapsed(locationRange)
|
105
|
+
rangeStart
|
106
|
+
else
|
107
|
+
@findContainerAndOffsetFromLocation(locationRange[1]) ? rangeStart
|
108
|
+
|
109
|
+
if rangeStart? and rangeEnd?
|
110
|
+
domRange = document.createRange()
|
111
|
+
domRange.setStart(rangeStart...)
|
112
|
+
domRange.setEnd(rangeEnd...)
|
113
|
+
domRange
|
114
|
+
|
115
|
+
createLocationRangeFromDOMRange: (domRange, options) ->
|
116
|
+
return unless domRange? and @domRangeWithinElement(domRange)
|
117
|
+
return unless start = @findLocationFromContainerAndOffset(domRange.startContainer, domRange.startOffset, options)
|
118
|
+
end = @findLocationFromContainerAndOffset(domRange.endContainer, domRange.endOffset, options) unless domRange.collapsed
|
119
|
+
normalizeRange([start, end])
|
120
|
+
|
121
|
+
getLocationAtPoint: (point) ->
|
122
|
+
if domRange = @createDOMRangeFromPoint(point)
|
123
|
+
@createLocationRangeFromDOMRange(domRange)?[0]
|
124
|
+
|
125
|
+
domRangeWithinElement: (domRange) ->
|
126
|
+
if domRange.collapsed
|
127
|
+
elementContainsNode(@element, domRange.startContainer)
|
128
|
+
else
|
129
|
+
elementContainsNode(@element, domRange.startContainer) and elementContainsNode(@element, domRange.endContainer)
|