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,168 @@
|
|
1
|
+
{spliceArray} = Trix
|
2
|
+
|
3
|
+
class Trix.SplittableList extends Trix.Object
|
4
|
+
@box: (objects) ->
|
5
|
+
if objects instanceof this
|
6
|
+
objects
|
7
|
+
else
|
8
|
+
new this objects
|
9
|
+
|
10
|
+
constructor: (objects = []) ->
|
11
|
+
super
|
12
|
+
@objects = objects.slice(0)
|
13
|
+
@length = @objects.length
|
14
|
+
|
15
|
+
indexOf: (object) ->
|
16
|
+
@objects.indexOf(object)
|
17
|
+
|
18
|
+
splice: (args...) ->
|
19
|
+
new @constructor spliceArray(@objects, args...)
|
20
|
+
|
21
|
+
eachObject: (callback) ->
|
22
|
+
callback(object, index) for object, index in @objects
|
23
|
+
|
24
|
+
insertObjectAtIndex: (object, index) ->
|
25
|
+
@splice(index, 0, object)
|
26
|
+
|
27
|
+
insertSplittableListAtIndex: (splittableList, index) ->
|
28
|
+
@splice(index, 0, splittableList.objects...)
|
29
|
+
|
30
|
+
insertSplittableListAtPosition: (splittableList, position) ->
|
31
|
+
[objects, index] = @splitObjectAtPosition(position)
|
32
|
+
new @constructor(objects).insertSplittableListAtIndex(splittableList, index)
|
33
|
+
|
34
|
+
editObjectAtIndex: (index, callback) ->
|
35
|
+
@replaceObjectAtIndex(callback(@objects[index]), index)
|
36
|
+
|
37
|
+
replaceObjectAtIndex: (object, index) ->
|
38
|
+
@splice(index, 1, object)
|
39
|
+
|
40
|
+
removeObjectAtIndex: (index) ->
|
41
|
+
@splice(index, 1)
|
42
|
+
|
43
|
+
getObjectAtIndex: (index) ->
|
44
|
+
@objects[index]
|
45
|
+
|
46
|
+
getSplittableListInRange: (range) ->
|
47
|
+
[objects, leftIndex, rightIndex] = @splitObjectsAtRange(range)
|
48
|
+
new @constructor objects.slice(leftIndex, rightIndex + 1)
|
49
|
+
|
50
|
+
selectSplittableList: (test) ->
|
51
|
+
objects = (object for object in @objects when test(object))
|
52
|
+
new @constructor objects
|
53
|
+
|
54
|
+
removeObjectsInRange: (range) ->
|
55
|
+
[objects, leftIndex, rightIndex] = @splitObjectsAtRange(range)
|
56
|
+
new @constructor(objects).splice(leftIndex, rightIndex - leftIndex + 1)
|
57
|
+
|
58
|
+
transformObjectsInRange: (range, transform) ->
|
59
|
+
[objects, leftIndex, rightIndex] = @splitObjectsAtRange(range)
|
60
|
+
transformedObjects = for object, index in objects
|
61
|
+
if leftIndex <= index <= rightIndex
|
62
|
+
transform(object)
|
63
|
+
else
|
64
|
+
object
|
65
|
+
new @constructor transformedObjects
|
66
|
+
|
67
|
+
splitObjectsAtRange: (range) ->
|
68
|
+
[objects, leftInnerIndex, offset] = @splitObjectAtPosition(startOfRange(range))
|
69
|
+
[objects, rightOuterIndex] = new @constructor(objects).splitObjectAtPosition(endOfRange(range) + offset)
|
70
|
+
[objects, leftInnerIndex, rightOuterIndex - 1]
|
71
|
+
|
72
|
+
getObjectAtPosition: (position) ->
|
73
|
+
{index, offset} = @findIndexAndOffsetAtPosition(position)
|
74
|
+
@objects[index]
|
75
|
+
|
76
|
+
splitObjectAtPosition: (position) ->
|
77
|
+
{index, offset} = @findIndexAndOffsetAtPosition(position)
|
78
|
+
objects = @objects.slice(0)
|
79
|
+
if index?
|
80
|
+
if offset is 0
|
81
|
+
splitIndex = index
|
82
|
+
splitOffset = 0
|
83
|
+
else
|
84
|
+
object = @getObjectAtIndex(index)
|
85
|
+
[leftObject, rightObject] = object.splitAtOffset(offset)
|
86
|
+
objects.splice(index, 1, leftObject, rightObject)
|
87
|
+
splitIndex = index + 1
|
88
|
+
splitOffset = leftObject.getLength() - offset
|
89
|
+
else
|
90
|
+
splitIndex = objects.length
|
91
|
+
splitOffset = 0
|
92
|
+
|
93
|
+
[objects, splitIndex, splitOffset]
|
94
|
+
|
95
|
+
consolidate: ->
|
96
|
+
objects = []
|
97
|
+
pendingObject = @objects[0]
|
98
|
+
|
99
|
+
for object in @objects[1..]
|
100
|
+
if pendingObject.canBeConsolidatedWith?(object)
|
101
|
+
pendingObject = pendingObject.consolidateWith(object)
|
102
|
+
else
|
103
|
+
objects.push(pendingObject)
|
104
|
+
pendingObject = object
|
105
|
+
|
106
|
+
if pendingObject?
|
107
|
+
objects.push(pendingObject)
|
108
|
+
|
109
|
+
new @constructor objects
|
110
|
+
|
111
|
+
consolidateFromIndexToIndex: (startIndex, endIndex) ->
|
112
|
+
objects = @objects.slice(0)
|
113
|
+
objectsInRange = objects.slice(startIndex, endIndex + 1)
|
114
|
+
consolidatedInRange = new @constructor(objectsInRange).consolidate().toArray()
|
115
|
+
@splice(startIndex, objectsInRange.length, consolidatedInRange...)
|
116
|
+
|
117
|
+
findIndexAndOffsetAtPosition: (position) ->
|
118
|
+
currentPosition = 0
|
119
|
+
for object, index in @objects
|
120
|
+
nextPosition = currentPosition + object.getLength()
|
121
|
+
if currentPosition <= position < nextPosition
|
122
|
+
return index: index, offset: position - currentPosition
|
123
|
+
currentPosition = nextPosition
|
124
|
+
index: null, offset: null
|
125
|
+
|
126
|
+
findPositionAtIndexAndOffset: (index, offset) ->
|
127
|
+
position = 0
|
128
|
+
for object, currentIndex in @objects
|
129
|
+
if currentIndex < index
|
130
|
+
position += object.getLength()
|
131
|
+
else if currentIndex is index
|
132
|
+
position += offset
|
133
|
+
break
|
134
|
+
position
|
135
|
+
|
136
|
+
getEndPosition: ->
|
137
|
+
@endPosition ?= (
|
138
|
+
position = 0
|
139
|
+
position += object.getLength() for object in @objects
|
140
|
+
position
|
141
|
+
)
|
142
|
+
|
143
|
+
toString: ->
|
144
|
+
@objects.join("")
|
145
|
+
|
146
|
+
toArray: ->
|
147
|
+
@objects.slice(0)
|
148
|
+
|
149
|
+
toJSON: ->
|
150
|
+
@toArray()
|
151
|
+
|
152
|
+
isEqualTo: (splittableList) ->
|
153
|
+
super or objectArraysAreEqual(@objects, splittableList?.objects)
|
154
|
+
|
155
|
+
objectArraysAreEqual = (left, right = []) ->
|
156
|
+
return false unless left.length is right.length
|
157
|
+
result = true
|
158
|
+
result = false for object, index in left when result and not object.isEqualTo(right[index])
|
159
|
+
result
|
160
|
+
|
161
|
+
contentsForInspection: ->
|
162
|
+
objects: "[#{(object.inspect() for object in @objects).join(", ")}]"
|
163
|
+
|
164
|
+
startOfRange = (range) ->
|
165
|
+
range[0]
|
166
|
+
|
167
|
+
endOfRange = (range) ->
|
168
|
+
range[1]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#= require trix/models/piece
|
2
|
+
|
3
|
+
Trix.Piece.registerType "string", class Trix.StringPiece extends Trix.Piece
|
4
|
+
@fromJSON: (pieceJSON) ->
|
5
|
+
new this pieceJSON.string, pieceJSON.attributes
|
6
|
+
|
7
|
+
constructor: (string) ->
|
8
|
+
super
|
9
|
+
@string = string
|
10
|
+
@length = @string.length
|
11
|
+
|
12
|
+
getValue: ->
|
13
|
+
@string
|
14
|
+
|
15
|
+
toString: ->
|
16
|
+
@string.toString()
|
17
|
+
|
18
|
+
isBlockBreak: ->
|
19
|
+
@toString() is "\n" and @getAttribute("blockBreak") is true
|
20
|
+
|
21
|
+
toJSON: ->
|
22
|
+
result = super
|
23
|
+
result.string = @string
|
24
|
+
result
|
25
|
+
|
26
|
+
# Splittable
|
27
|
+
|
28
|
+
canBeConsolidatedWith: (piece) ->
|
29
|
+
piece? and @hasSameConstructorAs(piece) and @hasSameAttributesAsPiece(piece)
|
30
|
+
|
31
|
+
consolidateWith: (piece) ->
|
32
|
+
new @constructor @toString() + piece.toString(), @attributes
|
33
|
+
|
34
|
+
splitAtOffset: (offset) ->
|
35
|
+
if offset is 0
|
36
|
+
left = null
|
37
|
+
right = this
|
38
|
+
else if offset is @length
|
39
|
+
left = this
|
40
|
+
right = null
|
41
|
+
else
|
42
|
+
left = new @constructor @string.slice(0, offset), @attributes
|
43
|
+
right = new @constructor @string.slice(offset), @attributes
|
44
|
+
[left, right]
|
45
|
+
|
46
|
+
toConsole: ->
|
47
|
+
string = @string
|
48
|
+
string = string.slice(0, 14) + "…" if string.length > 15
|
49
|
+
JSON.stringify(string.toString())
|
@@ -0,0 +1,168 @@
|
|
1
|
+
#= require trix/models/attachment_piece
|
2
|
+
#= require trix/models/string_piece
|
3
|
+
#= require trix/models/splittable_list
|
4
|
+
|
5
|
+
class Trix.Text extends Trix.Object
|
6
|
+
@textForAttachmentWithAttributes: (attachment, attributes) ->
|
7
|
+
piece = new Trix.AttachmentPiece attachment, attributes
|
8
|
+
new this [piece]
|
9
|
+
|
10
|
+
@textForStringWithAttributes: (string, attributes) ->
|
11
|
+
piece = new Trix.StringPiece string, attributes
|
12
|
+
new this [piece]
|
13
|
+
|
14
|
+
@fromJSON: (textJSON) ->
|
15
|
+
pieces = for pieceJSON in textJSON
|
16
|
+
Trix.Piece.fromJSON pieceJSON
|
17
|
+
new this pieces
|
18
|
+
|
19
|
+
constructor: (pieces = []) ->
|
20
|
+
super
|
21
|
+
@pieceList = new Trix.SplittableList (piece for piece in pieces when not piece.isEmpty())
|
22
|
+
|
23
|
+
copy: ->
|
24
|
+
@copyWithPieceList @pieceList
|
25
|
+
|
26
|
+
copyWithPieceList: (pieceList) ->
|
27
|
+
new @constructor pieceList.consolidate().toArray()
|
28
|
+
|
29
|
+
copyUsingObjectMap: (objectMap) ->
|
30
|
+
pieces = for piece in @getPieces()
|
31
|
+
objectMap.find(piece) ? piece
|
32
|
+
new @constructor pieces
|
33
|
+
|
34
|
+
appendText: (text) ->
|
35
|
+
@insertTextAtPosition(text, @getLength())
|
36
|
+
|
37
|
+
insertTextAtPosition: (text, position) ->
|
38
|
+
@copyWithPieceList @pieceList.insertSplittableListAtPosition(text.pieceList, position)
|
39
|
+
|
40
|
+
removeTextAtRange: (range) ->
|
41
|
+
@copyWithPieceList @pieceList.removeObjectsInRange(range)
|
42
|
+
|
43
|
+
replaceTextAtRange: (text, range) ->
|
44
|
+
@removeTextAtRange(range).insertTextAtPosition(text, range[0])
|
45
|
+
|
46
|
+
moveTextFromRangeToPosition: (range, position) ->
|
47
|
+
return if range[0] <= position <= range[1]
|
48
|
+
text = @getTextAtRange(range)
|
49
|
+
length = text.getLength()
|
50
|
+
position -= length if range[0] < position
|
51
|
+
@removeTextAtRange(range).insertTextAtPosition(text, position)
|
52
|
+
|
53
|
+
addAttributeAtRange: (attribute, value, range) ->
|
54
|
+
attributes = {}
|
55
|
+
attributes[attribute] = value
|
56
|
+
@addAttributesAtRange(attributes, range)
|
57
|
+
|
58
|
+
addAttributesAtRange: (attributes, range) ->
|
59
|
+
@copyWithPieceList @pieceList.transformObjectsInRange range, (piece) ->
|
60
|
+
piece.copyWithAdditionalAttributes(attributes)
|
61
|
+
|
62
|
+
removeAttributeAtRange: (attribute, range) ->
|
63
|
+
@copyWithPieceList @pieceList.transformObjectsInRange range, (piece) ->
|
64
|
+
piece.copyWithoutAttribute(attribute)
|
65
|
+
|
66
|
+
setAttributesAtRange: (attributes, range) ->
|
67
|
+
@copyWithPieceList @pieceList.transformObjectsInRange range, (piece) ->
|
68
|
+
piece.copyWithAttributes(attributes)
|
69
|
+
|
70
|
+
getAttributesAtPosition: (position) ->
|
71
|
+
@pieceList.getObjectAtPosition(position)?.getAttributes() ? {}
|
72
|
+
|
73
|
+
getCommonAttributes: ->
|
74
|
+
objects = (piece.getAttributes() for piece in @pieceList.toArray())
|
75
|
+
Trix.Hash.fromCommonAttributesOfObjects(objects).toObject()
|
76
|
+
|
77
|
+
getCommonAttributesAtRange: (range) ->
|
78
|
+
@getTextAtRange(range).getCommonAttributes() ? {}
|
79
|
+
|
80
|
+
getExpandedRangeForAttributeAtOffset: (attributeName, offset) ->
|
81
|
+
left = right = offset
|
82
|
+
length = @getLength()
|
83
|
+
|
84
|
+
left-- while left > 0 and @getCommonAttributesAtRange([left - 1, right])[attributeName]
|
85
|
+
right++ while right < length and @getCommonAttributesAtRange([offset, right + 1])[attributeName]
|
86
|
+
|
87
|
+
[left, right]
|
88
|
+
|
89
|
+
getTextAtRange: (range) ->
|
90
|
+
@copyWithPieceList @pieceList.getSplittableListInRange(range)
|
91
|
+
|
92
|
+
getStringAtRange: (range) ->
|
93
|
+
@pieceList.getSplittableListInRange(range).toString()
|
94
|
+
|
95
|
+
getStringAtPosition: (position) ->
|
96
|
+
@getStringAtRange([position, position + 1])
|
97
|
+
|
98
|
+
startsWithString: (string) ->
|
99
|
+
@getStringAtRange([0, string.length]) is string
|
100
|
+
|
101
|
+
endsWithString: (string) ->
|
102
|
+
length = @getLength()
|
103
|
+
@getStringAtRange([length - string.length, length]) is string
|
104
|
+
|
105
|
+
getAttachmentPieces: ->
|
106
|
+
piece for piece in @pieceList.toArray() when piece.attachment?
|
107
|
+
|
108
|
+
getAttachments: ->
|
109
|
+
piece.attachment for piece in @getAttachmentPieces()
|
110
|
+
|
111
|
+
getAttachmentAndPositionById: (attachmentId) ->
|
112
|
+
position = 0
|
113
|
+
for piece in @pieceList.toArray()
|
114
|
+
if piece.attachment?.id is attachmentId
|
115
|
+
return { attachment: piece.attachment, position }
|
116
|
+
position += piece.length
|
117
|
+
attachment: null, position: null
|
118
|
+
|
119
|
+
getAttachmentById: (attachmentId) ->
|
120
|
+
{attachment, position} = @getAttachmentAndPositionById(attachmentId)
|
121
|
+
attachment
|
122
|
+
|
123
|
+
getRangeOfAttachment: (attachment) ->
|
124
|
+
{attachment, position} = @getAttachmentAndPositionById(attachment.id)
|
125
|
+
[position, position + 1] if attachment?
|
126
|
+
|
127
|
+
updateAttributesForAttachment: (attributes, attachment) ->
|
128
|
+
if range = @getRangeOfAttachment(attachment)
|
129
|
+
@addAttributesAtRange(attributes, range)
|
130
|
+
else
|
131
|
+
this
|
132
|
+
|
133
|
+
getLength: ->
|
134
|
+
@pieceList.getEndPosition()
|
135
|
+
|
136
|
+
isEmpty: ->
|
137
|
+
@getLength() is 0
|
138
|
+
|
139
|
+
isEqualTo: (text) ->
|
140
|
+
super or text?.pieceList?.isEqualTo(@pieceList)
|
141
|
+
|
142
|
+
isBlockBreak: ->
|
143
|
+
@getLength() is 1 and @pieceList.getObjectAtIndex(0).isBlockBreak()
|
144
|
+
|
145
|
+
eachPiece: (callback) ->
|
146
|
+
@pieceList.eachObject(callback)
|
147
|
+
|
148
|
+
getPieces: ->
|
149
|
+
@pieceList.toArray()
|
150
|
+
|
151
|
+
getPieceAtPosition: (position) ->
|
152
|
+
@pieceList.getObjectAtPosition(position)
|
153
|
+
|
154
|
+
contentsForInspection: ->
|
155
|
+
pieceList: @pieceList.inspect()
|
156
|
+
|
157
|
+
toSerializableText: ->
|
158
|
+
pieceList = @pieceList.selectSplittableList (piece) -> piece.isSerializable()
|
159
|
+
@copyWithPieceList(pieceList)
|
160
|
+
|
161
|
+
toString: ->
|
162
|
+
@pieceList.toString()
|
163
|
+
|
164
|
+
toJSON: ->
|
165
|
+
@pieceList.toJSON()
|
166
|
+
|
167
|
+
toConsole: ->
|
168
|
+
JSON.stringify(JSON.parse(piece.toConsole()) for piece in @pieceList.toArray())
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Trix.UndoManager extends Trix.BasicObject
|
2
|
+
constructor: (@composition) ->
|
3
|
+
@undoEntries = []
|
4
|
+
@redoEntries = []
|
5
|
+
|
6
|
+
recordUndoEntry: (description, {context, consolidatable} = {}) ->
|
7
|
+
previousEntry = @undoEntries[-1..][0]
|
8
|
+
|
9
|
+
unless consolidatable and entryHasDescriptionAndContext(previousEntry, description, context)
|
10
|
+
undoEntry = @createEntry({description, context})
|
11
|
+
@undoEntries.push(undoEntry)
|
12
|
+
@redoEntries = []
|
13
|
+
|
14
|
+
undo: ->
|
15
|
+
if undoEntry = @undoEntries.pop()
|
16
|
+
redoEntry = @createEntry(undoEntry)
|
17
|
+
@redoEntries.push(redoEntry)
|
18
|
+
@composition.loadSnapshot(undoEntry.snapshot)
|
19
|
+
|
20
|
+
redo: ->
|
21
|
+
if redoEntry = @redoEntries.pop()
|
22
|
+
undoEntry = @createEntry(redoEntry)
|
23
|
+
@undoEntries.push(undoEntry)
|
24
|
+
@composition.loadSnapshot(redoEntry.snapshot)
|
25
|
+
|
26
|
+
canUndo: ->
|
27
|
+
@undoEntries.length > 0
|
28
|
+
|
29
|
+
canRedo: ->
|
30
|
+
@redoEntries.length > 0
|
31
|
+
|
32
|
+
# Private
|
33
|
+
|
34
|
+
createEntry: ({description, context} = {}) ->
|
35
|
+
description: description?.toString()
|
36
|
+
context: JSON.stringify(context)
|
37
|
+
snapshot: @composition.getSnapshot()
|
38
|
+
|
39
|
+
entryHasDescriptionAndContext = (entry, description, context) ->
|
40
|
+
entry?.description is description?.toString() and entry?.context is JSON.stringify(context)
|
@@ -0,0 +1,131 @@
|
|
1
|
+
{findClosestElementFromNode, nodeIsEmptyTextNode, nodeIsBlockStartComment, normalizeSpaces, summarizeStringChange, tagName} = Trix
|
2
|
+
|
3
|
+
class Trix.MutationObserver extends Trix.BasicObject
|
4
|
+
mutableAttributeName = "data-trix-mutable"
|
5
|
+
mutableSelector = "[#{mutableAttributeName}]"
|
6
|
+
|
7
|
+
options =
|
8
|
+
attributes: true
|
9
|
+
childList: true
|
10
|
+
characterData: true
|
11
|
+
characterDataOldValue: true
|
12
|
+
subtree: true
|
13
|
+
|
14
|
+
constructor: (@element) ->
|
15
|
+
@observer = new window.MutationObserver @didMutate
|
16
|
+
@start()
|
17
|
+
|
18
|
+
start: ->
|
19
|
+
@reset()
|
20
|
+
@observer.observe(@element, options)
|
21
|
+
|
22
|
+
stop: ->
|
23
|
+
@observer.disconnect()
|
24
|
+
|
25
|
+
didMutate: (mutations) =>
|
26
|
+
@mutations.push(@findSignificantMutations(mutations)...)
|
27
|
+
|
28
|
+
if @mutations.length
|
29
|
+
@delegate?.elementDidMutate?(@getMutationSummary())
|
30
|
+
@reset()
|
31
|
+
|
32
|
+
# Private
|
33
|
+
|
34
|
+
reset: ->
|
35
|
+
@mutations = []
|
36
|
+
|
37
|
+
findSignificantMutations: (mutations) ->
|
38
|
+
mutation for mutation in mutations when @mutationIsSignificant(mutation)
|
39
|
+
|
40
|
+
mutationIsSignificant: (mutation) ->
|
41
|
+
return true for node in @nodesModifiedByMutation(mutation) when @nodeIsSignificant(node)
|
42
|
+
false
|
43
|
+
|
44
|
+
nodeIsSignificant: (node) ->
|
45
|
+
node isnt @element and not @nodeIsMutable(node) and not nodeIsEmptyTextNode(node)
|
46
|
+
|
47
|
+
nodeIsMutable: (node) ->
|
48
|
+
findClosestElementFromNode(node, matchingSelector: mutableSelector)
|
49
|
+
|
50
|
+
nodesModifiedByMutation: (mutation) ->
|
51
|
+
nodes = []
|
52
|
+
switch mutation.type
|
53
|
+
when "attributes"
|
54
|
+
unless mutation.attributeName is mutableAttributeName
|
55
|
+
nodes.push(mutation.target)
|
56
|
+
when "characterData"
|
57
|
+
# Changes to text nodes should consider the parent element
|
58
|
+
nodes.push(mutation.target.parentNode)
|
59
|
+
nodes.push(mutation.target)
|
60
|
+
when "childList"
|
61
|
+
# Consider each added or removed node
|
62
|
+
nodes.push(mutation.addedNodes...)
|
63
|
+
nodes.push(mutation.removedNodes...)
|
64
|
+
nodes
|
65
|
+
|
66
|
+
getMutationSummary: ->
|
67
|
+
@getTextMutationSummary()
|
68
|
+
|
69
|
+
getTextMutationSummary: ->
|
70
|
+
{additions, deletions} = @getTextChangesFromCharacterData()
|
71
|
+
|
72
|
+
textChanges = @getTextChangesFromChildList()
|
73
|
+
additions.push(addition) for addition in textChanges.additions when addition not in additions
|
74
|
+
deletions.push(textChanges.deletions...)
|
75
|
+
|
76
|
+
summary = {}
|
77
|
+
summary.textAdded = added if added = additions.join("")
|
78
|
+
summary.textDeleted = deleted if deleted = deletions.join("")
|
79
|
+
summary
|
80
|
+
|
81
|
+
getMutationsByType: (type) ->
|
82
|
+
mutation for mutation in @mutations when mutation.type is type
|
83
|
+
|
84
|
+
getTextChangesFromChildList: ->
|
85
|
+
addedNodes = []
|
86
|
+
removedNodes = []
|
87
|
+
|
88
|
+
for mutation in @getMutationsByType("childList")
|
89
|
+
addedNodes.push(mutation.addedNodes...)
|
90
|
+
removedNodes.push(mutation.removedNodes...)
|
91
|
+
|
92
|
+
singleBlockCommentRemoved =
|
93
|
+
addedNodes.length is 0 and
|
94
|
+
removedNodes.length is 1 and
|
95
|
+
nodeIsBlockStartComment(removedNodes[0])
|
96
|
+
|
97
|
+
if singleBlockCommentRemoved
|
98
|
+
textAdded = []
|
99
|
+
textRemoved = ["\n"]
|
100
|
+
else
|
101
|
+
textAdded = getTextForNodes(addedNodes)
|
102
|
+
textRemoved = getTextForNodes(removedNodes)
|
103
|
+
|
104
|
+
additions: (normalizeSpaces(text) for text, index in textAdded when text isnt textRemoved[index])
|
105
|
+
deletions: (normalizeSpaces(text) for text, index in textRemoved when text isnt textAdded[index])
|
106
|
+
|
107
|
+
getTextChangesFromCharacterData: ->
|
108
|
+
characterMutations = @getMutationsByType("characterData")
|
109
|
+
|
110
|
+
if characterMutations.length
|
111
|
+
[startMutation, ..., endMutation] = characterMutations
|
112
|
+
|
113
|
+
oldString = normalizeSpaces(startMutation.oldValue)
|
114
|
+
newString = normalizeSpaces(endMutation.target.data)
|
115
|
+
{added, removed} = summarizeStringChange(oldString, newString)
|
116
|
+
|
117
|
+
additions: if added then [added] else []
|
118
|
+
deletions: if removed then [removed] else []
|
119
|
+
|
120
|
+
getTextForNodes = (nodes = []) ->
|
121
|
+
text = []
|
122
|
+
for node in nodes
|
123
|
+
switch node.nodeType
|
124
|
+
when Node.TEXT_NODE
|
125
|
+
text.push(node.data)
|
126
|
+
when Node.ELEMENT_NODE
|
127
|
+
if tagName(node) is "br"
|
128
|
+
text.push("\n")
|
129
|
+
else
|
130
|
+
text.push(getTextForNodes(node.childNodes)...)
|
131
|
+
text
|