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,62 @@
|
|
1
|
+
{assert, test, testGroup} = Trix.TestHelpers
|
2
|
+
|
3
|
+
testGroup "HTML loading", ->
|
4
|
+
testGroup "inline elements", template: "editor_with_styled_content", ->
|
5
|
+
cases =
|
6
|
+
"BR before block element styled otherwise":
|
7
|
+
html: """a<br><figure class="attachment"><img src="#{TEST_IMAGE_URL}"></figure>"""
|
8
|
+
expectedDocument: "a\n#{Trix.OBJECT_REPLACEMENT_CHARACTER}\n"
|
9
|
+
|
10
|
+
"BR in text before block element styled otherwise":
|
11
|
+
html: """<div>a<br>b<figure class="attachment"><img src="#{TEST_IMAGE_URL}"></figure></div>"""
|
12
|
+
expectedDocument: "a\nb#{Trix.OBJECT_REPLACEMENT_CHARACTER}\n"
|
13
|
+
|
14
|
+
for name, details of cases
|
15
|
+
do (name, details) ->
|
16
|
+
test name, (expectDocument) ->
|
17
|
+
getEditor().loadHTML(details.html)
|
18
|
+
expectDocument(details.expectedDocument)
|
19
|
+
|
20
|
+
testGroup "bold elements", template: "editor_with_bold_styles", ->
|
21
|
+
test "<strong> with font-weight: 500", (expectDocument) ->
|
22
|
+
getEditor().loadHTML("<strong>a</strong>")
|
23
|
+
assert.textAttributes([0, 1], bold: true)
|
24
|
+
expectDocument("a\n")
|
25
|
+
|
26
|
+
test "<span> with font-weight: 600", (expectDocument) ->
|
27
|
+
getEditor().loadHTML("<span>a</span>")
|
28
|
+
assert.textAttributes([0, 1], bold: true)
|
29
|
+
expectDocument("a\n")
|
30
|
+
|
31
|
+
test "<article> with font-weight: bold", (expectDocument) ->
|
32
|
+
getEditor().loadHTML("<article>a</article>")
|
33
|
+
assert.textAttributes([0, 1], bold: true)
|
34
|
+
expectDocument("a\n")
|
35
|
+
|
36
|
+
testGroup "styled block elements", template: "editor_with_block_styles", ->
|
37
|
+
test "<em> in <blockquote> with font-style: italic", (expectDocument) ->
|
38
|
+
getEditor().loadHTML("<blockquote>a<em>b</em></blockquote>")
|
39
|
+
assert.textAttributes([0, 1], {})
|
40
|
+
assert.textAttributes([1, 2], italic: true)
|
41
|
+
assert.blockAttributes([0, 2], ["quote"])
|
42
|
+
expectDocument("ab\n")
|
43
|
+
|
44
|
+
test "<strong> in <li> with font-weight: bold", (expectDocument) ->
|
45
|
+
getEditor().loadHTML("<ul><li>a<strong>b</strong></li></ul>")
|
46
|
+
assert.textAttributes([0, 1], {})
|
47
|
+
assert.textAttributes([1, 2], bold: true)
|
48
|
+
assert.blockAttributes([0, 2], ["bulletList","bullet"])
|
49
|
+
expectDocument("ab\n")
|
50
|
+
|
51
|
+
test "newline in <li> with font-weight: bold", (expectDocument) ->
|
52
|
+
getEditor().loadHTML("<ul><li>a<br>b</li></ul>")
|
53
|
+
assert.textAttributes([0, 2], {})
|
54
|
+
assert.blockAttributes([0, 2], ["bulletList","bullet"])
|
55
|
+
expectDocument("a\nb\n")
|
56
|
+
|
57
|
+
testGroup "in a table", template: "editor_in_table", ->
|
58
|
+
test "block elements", (expectDocument) ->
|
59
|
+
getEditor().loadHTML("<h1>a</h1><blockquote>b</blockquote>")
|
60
|
+
assert.blockAttributes([0, 2], ["heading1"])
|
61
|
+
assert.blockAttributes([2, 4], ["quote"])
|
62
|
+
expectDocument("a\nb\n")
|
@@ -0,0 +1,101 @@
|
|
1
|
+
{assert, clickToolbarButton, collapseSelection, defer, moveCursor, selectNode, typeCharacters, test, testGroup, triggerEvent} = Trix.TestHelpers
|
2
|
+
|
3
|
+
testGroup "HTML replacement", ->
|
4
|
+
testGroup "deleting with command+backspace", template: "editor_empty", ->
|
5
|
+
test "from the end of a line", (expectDocument) ->
|
6
|
+
getEditor().loadHTML("<div>a</div><blockquote>b</blockquote><div>c</div>")
|
7
|
+
getSelectionManager().setLocationRange(index: 1, offset: 1)
|
8
|
+
pressCommandBackspace replaceText: "b", ->
|
9
|
+
assert.locationRange(index: 1, offset: 0)
|
10
|
+
assert.blockAttributes [0, 2], []
|
11
|
+
assert.blockAttributes [2, 3], ["quote"]
|
12
|
+
assert.blockAttributes [3, 5], []
|
13
|
+
expectDocument("a\n\nc\n")
|
14
|
+
|
15
|
+
test "in the first block", (expectDocument) ->
|
16
|
+
getEditor().loadHTML("<div>a</div><blockquote>b</blockquote>")
|
17
|
+
getSelectionManager().setLocationRange(index: 0, offset: 1)
|
18
|
+
pressCommandBackspace replaceText: "a", ->
|
19
|
+
assert.locationRange(index: 0, offset: 0)
|
20
|
+
assert.blockAttributes [0, 1], []
|
21
|
+
assert.blockAttributes [1, 3], ["quote"]
|
22
|
+
expectDocument("\nb\n")
|
23
|
+
|
24
|
+
test "from the middle of a line", (expectDocument) ->
|
25
|
+
getEditor().loadHTML("<div>a</div><blockquote>bc</blockquote><div>d</div>")
|
26
|
+
getSelectionManager().setLocationRange(index: 1, offset: 1)
|
27
|
+
pressCommandBackspace replaceText: "b", ->
|
28
|
+
assert.locationRange(index: 1, offset: 0)
|
29
|
+
assert.blockAttributes [0, 2], []
|
30
|
+
assert.blockAttributes [2, 4], ["quote"]
|
31
|
+
assert.blockAttributes [4, 6], []
|
32
|
+
expectDocument("a\nc\nd\n")
|
33
|
+
|
34
|
+
test "from the middle of a line in a multi-line block", (expectDocument) ->
|
35
|
+
getEditor().loadHTML("<div>a</div><blockquote>bc<br>d</blockquote><div>e</div>")
|
36
|
+
getSelectionManager().setLocationRange(index: 1, offset: 1)
|
37
|
+
pressCommandBackspace replaceText: "b", ->
|
38
|
+
assert.locationRange(index: 1, offset: 0)
|
39
|
+
assert.blockAttributes([0, 2], [])
|
40
|
+
assert.blockAttributes([2, 6], ["quote"])
|
41
|
+
expectDocument("a\nc\nd\ne\n")
|
42
|
+
|
43
|
+
test "from the end of a list item", (expectDocument) ->
|
44
|
+
getEditor().loadHTML("<ul><li>a</li><li>b</li></ul>")
|
45
|
+
getSelectionManager().setLocationRange(index: 1, offset: 1)
|
46
|
+
pressCommandBackspace replaceText: "b", ->
|
47
|
+
assert.locationRange(index: 1, offset: 0)
|
48
|
+
assert.blockAttributes([0, 2], ["bulletList", "bullet"])
|
49
|
+
assert.blockAttributes([2, 4], ["bulletList", "bullet"])
|
50
|
+
expectDocument("a\n\n")
|
51
|
+
|
52
|
+
test "a character that is its text node's only data", (expectDocument) ->
|
53
|
+
getEditor().loadHTML("<div>a<br>b<br><strong>c</strong></div>")
|
54
|
+
getSelectionManager().setLocationRange(index: 0, offset: 3)
|
55
|
+
pressCommandBackspace replaceText: "b", ->
|
56
|
+
assert.locationRange(index: 0, offset: 2)
|
57
|
+
expectDocument("a\n\nc\n")
|
58
|
+
|
59
|
+
test "a formatted word", (expectDocument) ->
|
60
|
+
getEditor().loadHTML("<div>a<strong>bc</strong></div>")
|
61
|
+
getSelectionManager().setLocationRange(index: 0, offset: 4)
|
62
|
+
pressCommandBackspace replaceElementWithText: "bc", ->
|
63
|
+
assert.locationRange(index: 0, offset: 1)
|
64
|
+
expectDocument("a\n")
|
65
|
+
|
66
|
+
pressCommandBackspace = ({replaceText, replaceElementWithText}, callback) ->
|
67
|
+
triggerEvent(document.activeElement, "keydown", charCode: 0, keyCode: 8, which: 8, metaKey: true)
|
68
|
+
range = rangy.getSelection().getRangeAt(0)
|
69
|
+
|
70
|
+
if replaceElementWithText
|
71
|
+
element = getElementWithText(replaceElementWithText)
|
72
|
+
{previousSibling} = element
|
73
|
+
element.parentNode.removeChild(element)
|
74
|
+
range.collapseAfter(previousSibling)
|
75
|
+
else
|
76
|
+
range.findText(replaceText, direction: "backward")
|
77
|
+
range.splitBoundaries()
|
78
|
+
|
79
|
+
node = range.getNodes()[0]
|
80
|
+
{previousSibling, nextSibling, parentNode} = node
|
81
|
+
|
82
|
+
if previousSibling?.nodeType is Node.COMMENT_NODE
|
83
|
+
parentNode.removeChild(previousSibling)
|
84
|
+
|
85
|
+
node.data = ""
|
86
|
+
parentNode.removeChild(node)
|
87
|
+
|
88
|
+
unless parentNode.hasChildNodes()
|
89
|
+
parentNode.appendChild(document.createElement("br"))
|
90
|
+
|
91
|
+
range.collapseBefore(nextSibling ? parentNode.firstChild)
|
92
|
+
|
93
|
+
range.select()
|
94
|
+
requestAnimationFrame(callback)
|
95
|
+
|
96
|
+
|
97
|
+
getElementWithText = (text) ->
|
98
|
+
for element in document.activeElement.querySelectorAll("*")
|
99
|
+
if element.innerText is text
|
100
|
+
return element
|
101
|
+
null
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{assert, defer, test, testGroup} = Trix.TestHelpers
|
2
|
+
|
3
|
+
testGroup "Installation process", template: "editor_html", ->
|
4
|
+
test "element.editorController", ->
|
5
|
+
assert.ok getEditorController() instanceof Trix.EditorController
|
6
|
+
|
7
|
+
test "creates a contenteditable element", ->
|
8
|
+
assert.ok getEditorElement()
|
9
|
+
|
10
|
+
test "loads the initial document", ->
|
11
|
+
assert.equal getEditorElement().textContent, "Hello world"
|
12
|
+
|
13
|
+
test "sets value property", (done) ->
|
14
|
+
defer ->
|
15
|
+
assert.equal getEditorElement().value, "<div>Hello world</div>"
|
16
|
+
done()
|
17
|
+
|
18
|
+
|
19
|
+
testGroup "Installation process without specified elements", template: "editor_empty", ->
|
20
|
+
test "creates identified toolbar and input elements", (done) ->
|
21
|
+
editorElement = getEditorElement()
|
22
|
+
|
23
|
+
toolbarId = editorElement.getAttribute("toolbar")
|
24
|
+
assert.ok /trix-toolbar-\d+/.test(toolbarId), "toolbar id not assert.ok #{JSON.stringify(toolbarId)}"
|
25
|
+
toolbarElement = document.getElementById(toolbarId)
|
26
|
+
assert.ok toolbarElement, "toolbar element not assert.ok"
|
27
|
+
assert.equal editorElement.toolbarElement, toolbarElement
|
28
|
+
|
29
|
+
inputId = editorElement.getAttribute("input")
|
30
|
+
assert.ok /trix-input-\d+/.test(inputId), "input id not assert.ok #{JSON.stringify(inputId)}"
|
31
|
+
inputElement = document.getElementById(inputId)
|
32
|
+
assert.ok inputElement, "input element not assert.ok"
|
33
|
+
assert.equal editorElement.inputElement, inputElement
|
34
|
+
|
35
|
+
done()
|
36
|
+
|
37
|
+
|
38
|
+
testGroup "Installation process with specified elements", template: "editor_with_toolbar_and_input", ->
|
39
|
+
test "uses specified elements", (done) ->
|
40
|
+
editorElement = getEditorElement()
|
41
|
+
assert.equal editorElement.toolbarElement, document.getElementById("my_toolbar")
|
42
|
+
assert.equal editorElement.inputElement, document.getElementById("my_input")
|
43
|
+
assert.equal editorElement.value, "<div>Hello world</div>"
|
44
|
+
done()
|
45
|
+
|
46
|
+
test "can be cloned", (done) ->
|
47
|
+
originalElement = document.getElementById("my_editor")
|
48
|
+
clonedElement = originalElement.cloneNode(true)
|
49
|
+
|
50
|
+
{parentElement} = originalElement
|
51
|
+
parentElement.removeChild(originalElement)
|
52
|
+
parentElement.appendChild(clonedElement)
|
53
|
+
|
54
|
+
defer ->
|
55
|
+
editorElement = getEditorElement()
|
56
|
+
assert.equal editorElement.toolbarElement, document.getElementById("my_toolbar")
|
57
|
+
assert.equal editorElement.inputElement, document.getElementById("my_input")
|
58
|
+
assert.equal editorElement.value, "<div>Hello world</div>"
|
59
|
+
done()
|
@@ -0,0 +1,70 @@
|
|
1
|
+
{assert, clickToolbarButton, defer, moveCursor, pressKey, test, testGroup, triggerEvent, typeCharacters} = Trix.TestHelpers
|
2
|
+
|
3
|
+
testGroup "List formatting", template: "editor_empty", ->
|
4
|
+
test "creating a new list item", (done) ->
|
5
|
+
typeCharacters "a", ->
|
6
|
+
clickToolbarButton attribute: "bullet", ->
|
7
|
+
typeCharacters "\n", ->
|
8
|
+
assert.locationRange(index: 1, offset: 0)
|
9
|
+
assert.blockAttributes([0, 2], ["bulletList", "bullet"])
|
10
|
+
assert.blockAttributes([2, 3], ["bulletList", "bullet"])
|
11
|
+
done()
|
12
|
+
|
13
|
+
test "breaking out of a list", (expectDocument) ->
|
14
|
+
typeCharacters "a", ->
|
15
|
+
clickToolbarButton attribute: "bullet", ->
|
16
|
+
typeCharacters "\n\n", ->
|
17
|
+
assert.blockAttributes([0, 2], ["bulletList", "bullet"])
|
18
|
+
assert.blockAttributes([2, 3], [])
|
19
|
+
expectDocument("a\n\n")
|
20
|
+
|
21
|
+
test "pressing return at the beginning of a non-empty list item", (expectDocument) ->
|
22
|
+
clickToolbarButton attribute: "bullet", ->
|
23
|
+
typeCharacters "a\nb", ->
|
24
|
+
moveCursor "left", ->
|
25
|
+
pressKey "return", ->
|
26
|
+
assert.blockAttributes([0, 2], ["bulletList", "bullet"])
|
27
|
+
assert.blockAttributes([2, 3], ["bulletList", "bullet"])
|
28
|
+
assert.blockAttributes([3, 5], ["bulletList", "bullet"])
|
29
|
+
expectDocument("a\n\nb\n")
|
30
|
+
|
31
|
+
test "pressing shift-return at the end of a list item", (expectDocument) ->
|
32
|
+
clickToolbarButton attribute: "bullet", ->
|
33
|
+
typeCharacters "a", ->
|
34
|
+
pressShiftReturn = triggerEvent(document.activeElement, "keydown", charCode: 0, keyCode: 13, which: 13, shiftKey: true)
|
35
|
+
assert.notOk pressShiftReturn # Assert defaultPrevented
|
36
|
+
assert.blockAttributes([0, 2], ["bulletList", "bullet"])
|
37
|
+
expectDocument("a\n\n")
|
38
|
+
|
39
|
+
test "pressing delete at the beginning of a non-empty nested list item", (expectDocument) ->
|
40
|
+
clickToolbarButton attribute: "bullet", ->
|
41
|
+
typeCharacters "a\n", ->
|
42
|
+
clickToolbarButton action: "increaseNestingLevel", ->
|
43
|
+
typeCharacters "b\n", ->
|
44
|
+
clickToolbarButton action: "increaseNestingLevel", ->
|
45
|
+
typeCharacters "c", ->
|
46
|
+
getSelectionManager().setLocationRange(index: 1, offset: 0)
|
47
|
+
getComposition().deleteInDirection("backward")
|
48
|
+
getEditorController().render()
|
49
|
+
defer ->
|
50
|
+
assert.blockAttributes([0, 2], ["bulletList", "bullet"])
|
51
|
+
assert.blockAttributes([3, 4], ["bulletList", "bullet", "bulletList", "bullet"])
|
52
|
+
expectDocument("ab\nc\n")
|
53
|
+
|
54
|
+
test "decreasing list item's level decreases its nested items level too", (expectDocument) ->
|
55
|
+
clickToolbarButton attribute: "bullet", ->
|
56
|
+
typeCharacters "a\n", ->
|
57
|
+
clickToolbarButton action: "increaseNestingLevel", ->
|
58
|
+
typeCharacters "b\n", ->
|
59
|
+
clickToolbarButton action: "increaseNestingLevel", ->
|
60
|
+
typeCharacters "c", ->
|
61
|
+
getSelectionManager().setLocationRange(index: 1, offset: 1)
|
62
|
+
|
63
|
+
for n in [0...3]
|
64
|
+
getComposition().deleteInDirection("backward")
|
65
|
+
getEditorController().render()
|
66
|
+
|
67
|
+
assert.blockAttributes([0, 2], ["bulletList", "bullet"])
|
68
|
+
assert.blockAttributes([2, 3], [])
|
69
|
+
assert.blockAttributes([3, 5], ["bulletList", "bullet"])
|
70
|
+
expectDocument("a\n\nc\n")
|
@@ -0,0 +1,73 @@
|
|
1
|
+
{assert, defer, test, testGroup, triggerEvent, typeCharacters, clickToolbarButton, isToolbarButtonActive, insertNode} = Trix.TestHelpers
|
2
|
+
|
3
|
+
testGroup "Mutation input", template: "editor_empty", ->
|
4
|
+
test "deleting a newline", (expectDocument) ->
|
5
|
+
element = getEditorElement()
|
6
|
+
element.editor.insertString("a\n\nb")
|
7
|
+
|
8
|
+
triggerEvent(element, "keydown", charCode: 0, keyCode: 229, which: 229)
|
9
|
+
br = element.querySelectorAll("br")[1]
|
10
|
+
br.parentNode.removeChild(br)
|
11
|
+
requestAnimationFrame ->
|
12
|
+
expectDocument("a\nb\n")
|
13
|
+
|
14
|
+
test "typing formatted text after a newline at the end of block", (expectDocument) ->
|
15
|
+
element = getEditorElement()
|
16
|
+
element.editor.insertHTML("<ul><li>a</li><li><br></li></ul>")
|
17
|
+
element.editor.setSelectedRange(3)
|
18
|
+
|
19
|
+
clickToolbarButton attribute: "bold", ->
|
20
|
+
# Press B key
|
21
|
+
triggerEvent(element, "keydown", charCode: 0, keyCode: 66, which: 66)
|
22
|
+
triggerEvent(element, "keypress", charCode: 98, keyCode: 98, which: 98)
|
23
|
+
|
24
|
+
node = document.createTextNode("b")
|
25
|
+
extraBR = element.querySelectorAll("br")[1]
|
26
|
+
extraBR.parentNode.insertBefore(node, extraBR)
|
27
|
+
extraBR.parentNode.removeChild(extraBR)
|
28
|
+
|
29
|
+
requestAnimationFrame ->
|
30
|
+
assert.ok isToolbarButtonActive(attribute: "bold")
|
31
|
+
assert.textAttributes([0, 1], {})
|
32
|
+
assert.textAttributes([3, 4], bold: true)
|
33
|
+
expectDocument("a\n\nb\n")
|
34
|
+
|
35
|
+
test "backspacing an attachment at the beginning of an otherwise empty document", (expectDocument) ->
|
36
|
+
element = getEditorElement()
|
37
|
+
element.editor.loadHTML("""<img src="#{TEST_IMAGE_URL}" width="10" height="10">""")
|
38
|
+
|
39
|
+
requestAnimationFrame ->
|
40
|
+
element.editor.setSelectedRange([0, 1])
|
41
|
+
triggerEvent(element, "keydown", charCode: 0, keyCode: 8, which: 8)
|
42
|
+
|
43
|
+
element.firstElementChild.innerHTML = "<br>"
|
44
|
+
|
45
|
+
requestAnimationFrame ->
|
46
|
+
assert.locationRange index: 0, offset: 0
|
47
|
+
expectDocument("\n")
|
48
|
+
|
49
|
+
test "backspacing a block comment node", (expectDocument) ->
|
50
|
+
element = getEditorElement()
|
51
|
+
element.editor.loadHTML("""<blockquote>a</blockquote><div>b</div>""")
|
52
|
+
defer ->
|
53
|
+
element.editor.setSelectedRange(2)
|
54
|
+
triggerEvent(element, "keydown", charCode: 0, keyCode: 8, which: 8)
|
55
|
+
commentNode = element.lastChild.firstChild
|
56
|
+
commentNode.parentNode.removeChild(commentNode)
|
57
|
+
defer ->
|
58
|
+
assert.locationRange index: 0, offset: 1
|
59
|
+
expectDocument("ab\n")
|
60
|
+
|
61
|
+
test "typing formatted text with autocapitalization on", (expectDocument) ->
|
62
|
+
element = getEditorElement()
|
63
|
+
|
64
|
+
clickToolbarButton attribute: "bold", ->
|
65
|
+
# Type "b", autocapitalize to "B"
|
66
|
+
triggerEvent(element, "keydown", charCode: 0, keyCode: 66, which: 66)
|
67
|
+
triggerEvent(element, "keypress", charCode: 98, keyCode: 98, which: 98)
|
68
|
+
triggerEvent(element, "textInput", data: "B")
|
69
|
+
|
70
|
+
insertNode document.createTextNode("B"), ->
|
71
|
+
assert.ok isToolbarButtonActive(attribute: "bold")
|
72
|
+
assert.textAttributes([0, 1], bold: true)
|
73
|
+
expectDocument("B\n")
|
@@ -0,0 +1,215 @@
|
|
1
|
+
{assert, clickToolbarButton, createFile, defer, expandSelection, moveCursor, pasteContent, pressKey, test, testGroup, triggerEvent, typeCharacters} = Trix.TestHelpers
|
2
|
+
|
3
|
+
testGroup "Pasting", template: "editor_empty", ->
|
4
|
+
test "paste plain text", (expectDocument) ->
|
5
|
+
typeCharacters "abc", ->
|
6
|
+
moveCursor "left", ->
|
7
|
+
pasteContent "text/plain", "!", ->
|
8
|
+
expectDocument "ab!c\n"
|
9
|
+
|
10
|
+
test "paste simple html", (expectDocument) ->
|
11
|
+
typeCharacters "abc", ->
|
12
|
+
moveCursor "left", ->
|
13
|
+
pasteContent "text/html", "<", ->
|
14
|
+
expectDocument "ab<c\n"
|
15
|
+
|
16
|
+
test "paste complex html", (expectDocument) ->
|
17
|
+
typeCharacters "abc", ->
|
18
|
+
moveCursor "left", ->
|
19
|
+
pasteContent "text/html", "<div>Hello world<br></div><div>This is a test</div>", ->
|
20
|
+
expectDocument "abHello world\nThis is a test\nc\n"
|
21
|
+
|
22
|
+
test "prefers plain text when html lacks formatting", (expectDocument) ->
|
23
|
+
pasteData =
|
24
|
+
"text/html": "<meta charset='utf-8'>a\nb"
|
25
|
+
"text/plain": "a\nb"
|
26
|
+
|
27
|
+
pasteContent pasteData, ->
|
28
|
+
expectDocument "a\nb\n"
|
29
|
+
|
30
|
+
test "prefers formatted html", (expectDocument) ->
|
31
|
+
pasteData =
|
32
|
+
"text/html": "<meta charset='utf-8'>a\n<strong>b</strong>"
|
33
|
+
"text/plain": "a\nb"
|
34
|
+
|
35
|
+
pasteContent pasteData, ->
|
36
|
+
expectDocument "a b\n"
|
37
|
+
|
38
|
+
test "paste URL", (expectDocument) ->
|
39
|
+
typeCharacters "a", ->
|
40
|
+
pasteContent "URL", "http://example.com", ->
|
41
|
+
assert.textAttributes([1, 18], href: "http://example.com")
|
42
|
+
expectDocument "ahttp://example.com\n"
|
43
|
+
|
44
|
+
test "paste URL with name", (expectDocument) ->
|
45
|
+
pasteData =
|
46
|
+
"URL": "http://example.com"
|
47
|
+
"public.url-name": "Example"
|
48
|
+
"text/plain": "http://example.com"
|
49
|
+
|
50
|
+
pasteContent pasteData, ->
|
51
|
+
assert.textAttributes([0, 7], href: "http://example.com")
|
52
|
+
expectDocument "Example\n"
|
53
|
+
|
54
|
+
test "paste complex html into formatted block", (done) ->
|
55
|
+
typeCharacters "abc", ->
|
56
|
+
clickToolbarButton attribute: "quote", ->
|
57
|
+
pasteContent "text/html", "<div>Hello world<br></div><pre>This is a test</pre>", ->
|
58
|
+
document = getDocument()
|
59
|
+
assert.equal document.getBlockCount(), 2
|
60
|
+
|
61
|
+
block = document.getBlockAtIndex(0)
|
62
|
+
assert.deepEqual block.getAttributes(), ["quote"],
|
63
|
+
assert.equal block.toString(), "abcHello world\n"
|
64
|
+
|
65
|
+
block = document.getBlockAtIndex(1)
|
66
|
+
assert.deepEqual block.getAttributes(), ["quote", "code"]
|
67
|
+
assert.equal block.toString(), "This is a test\n"
|
68
|
+
|
69
|
+
done()
|
70
|
+
|
71
|
+
test "paste list into list", (done) ->
|
72
|
+
clickToolbarButton attribute: "bullet", ->
|
73
|
+
typeCharacters "abc\n", ->
|
74
|
+
pasteContent "text/html", "<ul><li>one</li><li>two</li></ul>", ->
|
75
|
+
document = getDocument()
|
76
|
+
assert.equal document.getBlockCount(), 3
|
77
|
+
|
78
|
+
block = document.getBlockAtIndex(0)
|
79
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
80
|
+
assert.equal block.toString(), "abc\n"
|
81
|
+
|
82
|
+
block = document.getBlockAtIndex(1)
|
83
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
84
|
+
assert.equal block.toString(), "one\n"
|
85
|
+
|
86
|
+
block = document.getBlockAtIndex(2)
|
87
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
88
|
+
assert.equal block.toString(), "two\n"
|
89
|
+
|
90
|
+
done()
|
91
|
+
|
92
|
+
test "paste list into quote", (done) ->
|
93
|
+
clickToolbarButton attribute: "quote", ->
|
94
|
+
typeCharacters "abc", ->
|
95
|
+
pasteContent "text/html", "<ul><li>one</li><li>two</li></ul>", ->
|
96
|
+
document = getDocument()
|
97
|
+
assert.equal document.getBlockCount(), 3
|
98
|
+
|
99
|
+
block = document.getBlockAtIndex(0)
|
100
|
+
assert.deepEqual block.getAttributes(), ["quote"]
|
101
|
+
assert.equal block.toString(), "abc\n"
|
102
|
+
|
103
|
+
block = document.getBlockAtIndex(1)
|
104
|
+
assert.deepEqual block.getAttributes(), ["quote", "bulletList", "bullet"]
|
105
|
+
assert.equal block.toString(), "one\n"
|
106
|
+
|
107
|
+
block = document.getBlockAtIndex(2)
|
108
|
+
assert.deepEqual block.getAttributes(), ["quote", "bulletList", "bullet"]
|
109
|
+
assert.equal block.toString(), "two\n"
|
110
|
+
|
111
|
+
done()
|
112
|
+
|
113
|
+
test "paste list into quoted list", (done) ->
|
114
|
+
clickToolbarButton attribute: "quote", ->
|
115
|
+
clickToolbarButton attribute: "bullet", ->
|
116
|
+
typeCharacters "abc\n", ->
|
117
|
+
pasteContent "text/html", "<ul><li>one</li><li>two</li></ul>", ->
|
118
|
+
document = getDocument()
|
119
|
+
assert.equal document.getBlockCount(), 3
|
120
|
+
|
121
|
+
block = document.getBlockAtIndex(0)
|
122
|
+
assert.deepEqual block.getAttributes(), ["quote", "bulletList", "bullet"]
|
123
|
+
assert.equal block.toString(), "abc\n"
|
124
|
+
|
125
|
+
block = document.getBlockAtIndex(1)
|
126
|
+
assert.deepEqual block.getAttributes(), ["quote", "bulletList", "bullet"]
|
127
|
+
assert.equal block.toString(), "one\n"
|
128
|
+
|
129
|
+
block = document.getBlockAtIndex(2)
|
130
|
+
assert.deepEqual block.getAttributes(), ["quote", "bulletList", "bullet"]
|
131
|
+
assert.equal block.toString(), "two\n"
|
132
|
+
|
133
|
+
done()
|
134
|
+
|
135
|
+
test "paste nested list into empty list item", (done) ->
|
136
|
+
clickToolbarButton attribute: "bullet", ->
|
137
|
+
typeCharacters "y\nzz", ->
|
138
|
+
getSelectionManager().setLocationRange(index: 0, offset: 1)
|
139
|
+
defer ->
|
140
|
+
pressKey "backspace", ->
|
141
|
+
pasteContent "text/html", "<ul><li>a<ul><li>b</li></ul></li></ul>", ->
|
142
|
+
document = getDocument()
|
143
|
+
assert.equal document.getBlockCount(), 3
|
144
|
+
|
145
|
+
block = document.getBlockAtIndex(0)
|
146
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
147
|
+
assert.equal block.toString(), "a\n"
|
148
|
+
|
149
|
+
block = document.getBlockAtIndex(1)
|
150
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet", "bulletList", "bullet"]
|
151
|
+
assert.equal block.toString(), "b\n"
|
152
|
+
|
153
|
+
block = document.getBlockAtIndex(2)
|
154
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
155
|
+
assert.equal block.toString(), "zz\n"
|
156
|
+
done()
|
157
|
+
|
158
|
+
test "paste nested list over list item contents", (done) ->
|
159
|
+
clickToolbarButton attribute: "bullet", ->
|
160
|
+
typeCharacters "y\nzz", ->
|
161
|
+
getSelectionManager().setLocationRange(index: 0, offset: 1)
|
162
|
+
defer ->
|
163
|
+
expandSelection "left", ->
|
164
|
+
pasteContent "text/html", "<ul><li>a<ul><li>b</li></ul></li></ul>", ->
|
165
|
+
document = getDocument()
|
166
|
+
assert.equal document.getBlockCount(), 3
|
167
|
+
|
168
|
+
block = document.getBlockAtIndex(0)
|
169
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
170
|
+
assert.equal block.toString(), "a\n"
|
171
|
+
|
172
|
+
block = document.getBlockAtIndex(1)
|
173
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet", "bulletList", "bullet"]
|
174
|
+
assert.equal block.toString(), "b\n"
|
175
|
+
|
176
|
+
block = document.getBlockAtIndex(2)
|
177
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
178
|
+
assert.equal block.toString(), "zz\n"
|
179
|
+
done()
|
180
|
+
|
181
|
+
test "paste list into empty block before list", (done) ->
|
182
|
+
clickToolbarButton attribute: "bullet", ->
|
183
|
+
typeCharacters "c", ->
|
184
|
+
moveCursor "left", ->
|
185
|
+
pressKey "return", ->
|
186
|
+
getSelectionManager().setLocationRange(index: 0, offset: 0)
|
187
|
+
defer ->
|
188
|
+
pasteContent "text/html", "<ul><li>a</li><li>b</li></ul>", ->
|
189
|
+
document = getDocument()
|
190
|
+
assert.equal document.getBlockCount(), 3
|
191
|
+
|
192
|
+
block = document.getBlockAtIndex(0)
|
193
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
194
|
+
assert.equal block.toString(), "a\n"
|
195
|
+
|
196
|
+
block = document.getBlockAtIndex(1)
|
197
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
198
|
+
assert.equal block.toString(), "b\n"
|
199
|
+
|
200
|
+
block = document.getBlockAtIndex(2)
|
201
|
+
assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]
|
202
|
+
assert.equal block.toString(), "c\n"
|
203
|
+
done()
|
204
|
+
|
205
|
+
test "paste file", (expectDocument) ->
|
206
|
+
typeCharacters "a", ->
|
207
|
+
pasteContent "Files", (createFile()), ->
|
208
|
+
expectDocument "a#{Trix.OBJECT_REPLACEMENT_CHARACTER}\n"
|
209
|
+
|
210
|
+
test "paste event with no clipboardData", (expectDocument) ->
|
211
|
+
typeCharacters "a", ->
|
212
|
+
triggerEvent(document.activeElement, "paste")
|
213
|
+
document.activeElement.insertAdjacentHTML("beforeend", "<span>bc</span>")
|
214
|
+
requestAnimationFrame ->
|
215
|
+
expectDocument("abc\n")
|