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,521 @@
|
|
1
|
+
#= require trix/models/document
|
2
|
+
#= require trix/models/line_break_insertion
|
3
|
+
|
4
|
+
{normalizeRange, rangesAreEqual, rangeIsCollapsed, objectsAreEqual, arrayStartsWith, summarizeArrayChange, getAllAttributeNames, getBlockConfig, getTextConfig, extend} = Trix
|
5
|
+
|
6
|
+
class Trix.Composition extends Trix.BasicObject
|
7
|
+
constructor: ->
|
8
|
+
@document = new Trix.Document
|
9
|
+
@attachments = []
|
10
|
+
@currentAttributes = {}
|
11
|
+
@revision = 0
|
12
|
+
|
13
|
+
setDocument: (document) ->
|
14
|
+
unless document.isEqualTo(@document)
|
15
|
+
@document = document
|
16
|
+
@refreshAttachments()
|
17
|
+
@revision++
|
18
|
+
@delegate?.compositionDidChangeDocument?(document)
|
19
|
+
|
20
|
+
# Snapshots
|
21
|
+
|
22
|
+
getSnapshot: ->
|
23
|
+
document: @document
|
24
|
+
selectedRange: @getSelectedRange()
|
25
|
+
|
26
|
+
loadSnapshot: ({document, selectedRange}) ->
|
27
|
+
@delegate?.compositionWillLoadSnapshot?()
|
28
|
+
@setDocument(document ? new Trix.Document)
|
29
|
+
@setSelection(selectedRange ? [0, 0])
|
30
|
+
@delegate?.compositionDidLoadSnapshot?()
|
31
|
+
|
32
|
+
# Responder protocol
|
33
|
+
|
34
|
+
insertText: (text, {updatePosition} = updatePosition: true) ->
|
35
|
+
selectedRange = @getSelectedRange()
|
36
|
+
@setDocument(@document.insertTextAtRange(text, selectedRange))
|
37
|
+
|
38
|
+
startPosition = selectedRange[0]
|
39
|
+
endPosition = startPosition + text.getLength()
|
40
|
+
|
41
|
+
@setSelection(endPosition) if updatePosition
|
42
|
+
@notifyDelegateOfInsertionAtRange([startPosition, endPosition])
|
43
|
+
|
44
|
+
insertBlock: (block = new Trix.Block) ->
|
45
|
+
document = new Trix.Document [block]
|
46
|
+
@insertDocument(document)
|
47
|
+
|
48
|
+
insertDocument: (document = new Trix.Document) ->
|
49
|
+
selectedRange = @getSelectedRange()
|
50
|
+
@setDocument(@document.insertDocumentAtRange(document, selectedRange))
|
51
|
+
|
52
|
+
startPosition = selectedRange[0]
|
53
|
+
endPosition = startPosition + document.getLength()
|
54
|
+
|
55
|
+
@setSelection(endPosition)
|
56
|
+
@notifyDelegateOfInsertionAtRange([startPosition, endPosition])
|
57
|
+
|
58
|
+
insertString: (string, options) ->
|
59
|
+
attributes = @getCurrentTextAttributes()
|
60
|
+
text = Trix.Text.textForStringWithAttributes(string, attributes)
|
61
|
+
@insertText(text, options)
|
62
|
+
|
63
|
+
insertBlockBreak: ->
|
64
|
+
selectedRange = @getSelectedRange()
|
65
|
+
@setDocument(@document.insertBlockBreakAtRange(selectedRange))
|
66
|
+
|
67
|
+
startPosition = selectedRange[0]
|
68
|
+
endPosition = startPosition + 1
|
69
|
+
|
70
|
+
@setSelection(endPosition)
|
71
|
+
@notifyDelegateOfInsertionAtRange([startPosition, endPosition])
|
72
|
+
|
73
|
+
insertLineBreak: ->
|
74
|
+
insertion = new Trix.LineBreakInsertion this
|
75
|
+
|
76
|
+
if insertion.shouldDecreaseListLevel()
|
77
|
+
@decreaseListLevel()
|
78
|
+
@setSelection(insertion.startPosition)
|
79
|
+
else if insertion.shouldPrependListItem()
|
80
|
+
document = new Trix.Document [insertion.block.copyWithoutText()]
|
81
|
+
@insertDocument(document)
|
82
|
+
else if insertion.shouldInsertBlockBreak()
|
83
|
+
@insertBlockBreak()
|
84
|
+
else if insertion.shouldRemoveLastBlockAttribute()
|
85
|
+
@removeLastBlockAttribute()
|
86
|
+
else if insertion.shouldBreakFormattedBlock()
|
87
|
+
@breakFormattedBlock(insertion)
|
88
|
+
else
|
89
|
+
@insertString("\n")
|
90
|
+
|
91
|
+
insertHTML: (html) ->
|
92
|
+
startPosition = @getPosition()
|
93
|
+
startLength = @document.getLength()
|
94
|
+
|
95
|
+
document = Trix.Document.fromHTML(html)
|
96
|
+
@setDocument(@document.mergeDocumentAtRange(document, @getSelectedRange()))
|
97
|
+
|
98
|
+
endLength = @document.getLength()
|
99
|
+
endPosition = startPosition + (endLength - startLength)
|
100
|
+
|
101
|
+
@setSelection(endPosition)
|
102
|
+
@notifyDelegateOfInsertionAtRange([endPosition, endPosition])
|
103
|
+
|
104
|
+
replaceHTML: (html) ->
|
105
|
+
document = Trix.Document.fromHTML(html).copyUsingObjectsFromDocument(@document)
|
106
|
+
locationRange = @getLocationRange(strict: false)
|
107
|
+
selectedRange = @document.rangeFromLocationRange(locationRange)
|
108
|
+
@setDocument(document)
|
109
|
+
@setSelection(selectedRange)
|
110
|
+
|
111
|
+
insertFile: (file) ->
|
112
|
+
if @delegate?.compositionShouldAcceptFile(file)
|
113
|
+
attachment = Trix.Attachment.attachmentForFile(file)
|
114
|
+
@insertAttachment(attachment)
|
115
|
+
|
116
|
+
insertFiles: (files) ->
|
117
|
+
text = new Trix.Text
|
118
|
+
for file in files when @delegate?.compositionShouldAcceptFile(file)
|
119
|
+
attachment = Trix.Attachment.attachmentForFile(file)
|
120
|
+
attachmentText = Trix.Text.textForAttachmentWithAttributes(attachment, @currentAttributes)
|
121
|
+
text = text.appendText(attachmentText)
|
122
|
+
@insertText(text)
|
123
|
+
|
124
|
+
insertAttachment: (attachment) ->
|
125
|
+
text = Trix.Text.textForAttachmentWithAttributes(attachment, @currentAttributes)
|
126
|
+
@insertText(text)
|
127
|
+
|
128
|
+
deleteInDirection: (direction) ->
|
129
|
+
locationRange = @getLocationRange()
|
130
|
+
range = @getSelectedRange()
|
131
|
+
selectionIsCollapsed = rangeIsCollapsed(range)
|
132
|
+
|
133
|
+
if selectionIsCollapsed
|
134
|
+
deletingIntoPreviousBlock = direction is "backward" and locationRange[0].offset is 0
|
135
|
+
else
|
136
|
+
selectionSpansBlocks = locationRange[0].index isnt locationRange[1].index
|
137
|
+
|
138
|
+
if deletingIntoPreviousBlock
|
139
|
+
if @canDecreaseBlockAttributeLevel()
|
140
|
+
block = @getBlock()
|
141
|
+
|
142
|
+
if block.isListItem()
|
143
|
+
@decreaseListLevel()
|
144
|
+
else
|
145
|
+
@decreaseBlockAttributeLevel()
|
146
|
+
|
147
|
+
@setSelection(range[0])
|
148
|
+
return false if block.isEmpty()
|
149
|
+
|
150
|
+
if selectionIsCollapsed
|
151
|
+
range = @getExpandedRangeInDirection(direction)
|
152
|
+
if direction is "backward"
|
153
|
+
attachment = @getAttachmentAtRange(range)
|
154
|
+
|
155
|
+
if attachment
|
156
|
+
@editAttachment(attachment)
|
157
|
+
false
|
158
|
+
else
|
159
|
+
@setDocument(@document.removeTextAtRange(range))
|
160
|
+
@setSelection(range[0])
|
161
|
+
false if deletingIntoPreviousBlock or selectionSpansBlocks
|
162
|
+
|
163
|
+
moveTextFromRange: (range) ->
|
164
|
+
[position] = @getSelectedRange()
|
165
|
+
@setDocument(@document.moveTextFromRangeToPosition(range, position))
|
166
|
+
@setSelection(position)
|
167
|
+
|
168
|
+
removeAttachment: (attachment) ->
|
169
|
+
if range = @document.getRangeOfAttachment(attachment)
|
170
|
+
@stopEditingAttachment()
|
171
|
+
@setDocument(@document.removeTextAtRange(range))
|
172
|
+
@setSelection(range[0])
|
173
|
+
|
174
|
+
removeLastBlockAttribute: ->
|
175
|
+
[startPosition, endPosition] = @getSelectedRange()
|
176
|
+
block = @document.getBlockAtPosition(endPosition)
|
177
|
+
@removeCurrentAttribute(block.getLastAttribute())
|
178
|
+
@setSelection(startPosition)
|
179
|
+
|
180
|
+
placeholder = " "
|
181
|
+
|
182
|
+
insertPlaceholder: ->
|
183
|
+
@placeholderPosition = @getPosition()
|
184
|
+
@insertString(placeholder)
|
185
|
+
|
186
|
+
selectPlaceholder: ->
|
187
|
+
if @placeholderPosition?
|
188
|
+
@setSelectedRange([@placeholderPosition, @placeholderPosition + placeholder.length])
|
189
|
+
@getSelectedRange()
|
190
|
+
|
191
|
+
forgetPlaceholder: ->
|
192
|
+
@placeholderPosition = null
|
193
|
+
|
194
|
+
# Current attributes
|
195
|
+
|
196
|
+
hasCurrentAttribute: (attributeName) ->
|
197
|
+
value = @currentAttributes[attributeName]
|
198
|
+
value? and value isnt false
|
199
|
+
|
200
|
+
toggleCurrentAttribute: (attributeName) ->
|
201
|
+
if value = not @currentAttributes[attributeName]
|
202
|
+
@setCurrentAttribute(attributeName, value)
|
203
|
+
else
|
204
|
+
@removeCurrentAttribute(attributeName)
|
205
|
+
|
206
|
+
canSetCurrentAttribute: (attributeName) ->
|
207
|
+
if getBlockConfig(attributeName)
|
208
|
+
@canSetCurrentBlockAttribute(attributeName)
|
209
|
+
else
|
210
|
+
@canSetCurrentTextAttribute(attributeName)
|
211
|
+
|
212
|
+
canSetCurrentTextAttribute: (attributeName) ->
|
213
|
+
switch attributeName
|
214
|
+
when "href"
|
215
|
+
not @selectionContainsAttachmentWithAttribute(attributeName)
|
216
|
+
else
|
217
|
+
true
|
218
|
+
|
219
|
+
canSetCurrentBlockAttribute: (attributeName) ->
|
220
|
+
return unless block = @getBlock()
|
221
|
+
not block.isTerminalBlock()
|
222
|
+
|
223
|
+
setCurrentAttribute: (attributeName, value) ->
|
224
|
+
if getBlockConfig(attributeName)
|
225
|
+
@setBlockAttribute(attributeName, value)
|
226
|
+
else
|
227
|
+
@setTextAttribute(attributeName, value)
|
228
|
+
@currentAttributes[attributeName] = value
|
229
|
+
@notifyDelegateOfCurrentAttributesChange()
|
230
|
+
|
231
|
+
setTextAttribute: (attributeName, value) ->
|
232
|
+
return unless selectedRange = @getSelectedRange()
|
233
|
+
[startPosition, endPosition] = selectedRange
|
234
|
+
if startPosition is endPosition
|
235
|
+
if attributeName is "href"
|
236
|
+
text = Trix.Text.textForStringWithAttributes(value, href: value)
|
237
|
+
@insertText(text)
|
238
|
+
else
|
239
|
+
@setDocument(@document.addAttributeAtRange(attributeName, value, selectedRange))
|
240
|
+
|
241
|
+
setBlockAttribute: (attributeName, value) ->
|
242
|
+
return unless selectedRange = @getSelectedRange()
|
243
|
+
if @canSetCurrentAttribute(attributeName)
|
244
|
+
block = @getBlock()
|
245
|
+
@setDocument(@document.applyBlockAttributeAtRange(attributeName, value, selectedRange))
|
246
|
+
@setSelection(selectedRange)
|
247
|
+
|
248
|
+
removeCurrentAttribute: (attributeName) ->
|
249
|
+
if getBlockConfig(attributeName)
|
250
|
+
@removeBlockAttribute(attributeName)
|
251
|
+
@updateCurrentAttributes()
|
252
|
+
else
|
253
|
+
@removeTextAttribute(attributeName)
|
254
|
+
delete @currentAttributes[attributeName]
|
255
|
+
@notifyDelegateOfCurrentAttributesChange()
|
256
|
+
|
257
|
+
removeTextAttribute: (attributeName) ->
|
258
|
+
return unless selectedRange = @getSelectedRange()
|
259
|
+
@setDocument(@document.removeAttributeAtRange(attributeName, selectedRange))
|
260
|
+
|
261
|
+
removeBlockAttribute: (attributeName) ->
|
262
|
+
return unless selectedRange = @getSelectedRange()
|
263
|
+
@setDocument(@document.removeAttributeAtRange(attributeName, selectedRange))
|
264
|
+
|
265
|
+
canDecreaseNestingLevel: ->
|
266
|
+
@getBlock()?.getNestingLevel() > 0
|
267
|
+
|
268
|
+
canIncreaseNestingLevel: ->
|
269
|
+
return unless block = @getBlock()
|
270
|
+
if getBlockConfig(block.getLastNestableAttribute())?.listAttribute
|
271
|
+
if previousBlock = @getPreviousBlock()
|
272
|
+
arrayStartsWith(previousBlock.getListItemAttributes(), block.getListItemAttributes())
|
273
|
+
else
|
274
|
+
block.getNestingLevel() > 0
|
275
|
+
|
276
|
+
decreaseNestingLevel: ->
|
277
|
+
return unless block = @getBlock()
|
278
|
+
@setDocument(@document.replaceBlock(block, block.decreaseNestingLevel()))
|
279
|
+
|
280
|
+
increaseNestingLevel: ->
|
281
|
+
return unless block = @getBlock()
|
282
|
+
@setDocument(@document.replaceBlock(block, block.increaseNestingLevel()))
|
283
|
+
|
284
|
+
canDecreaseBlockAttributeLevel: ->
|
285
|
+
@getBlock()?.getAttributeLevel() > 0
|
286
|
+
|
287
|
+
decreaseBlockAttributeLevel: ->
|
288
|
+
if attribute = @getBlock()?.getLastAttribute()
|
289
|
+
@removeCurrentAttribute(attribute)
|
290
|
+
|
291
|
+
decreaseListLevel: ->
|
292
|
+
[startPosition] = @getSelectedRange()
|
293
|
+
{index} = @document.locationFromPosition(startPosition)
|
294
|
+
endIndex = index
|
295
|
+
attributeLevel = @getBlock().getAttributeLevel()
|
296
|
+
|
297
|
+
while block = @document.getBlockAtIndex(endIndex + 1)
|
298
|
+
break unless block.isListItem() and block.getAttributeLevel() > attributeLevel
|
299
|
+
endIndex++
|
300
|
+
|
301
|
+
startPosition = @document.positionFromLocation(index: index, offset: 0)
|
302
|
+
endPosition = @document.positionFromLocation(index: endIndex, offset: 0)
|
303
|
+
@setDocument(@document.removeLastListAttributeAtRange([startPosition, endPosition]))
|
304
|
+
|
305
|
+
updateCurrentAttributes: ->
|
306
|
+
if selectedRange = @getSelectedRange(ignoreLock: true)
|
307
|
+
currentAttributes = @document.getCommonAttributesAtRange(selectedRange)
|
308
|
+
|
309
|
+
for attributeName in getAllAttributeNames()
|
310
|
+
unless currentAttributes[attributeName]
|
311
|
+
unless @canSetCurrentAttribute(attributeName)
|
312
|
+
currentAttributes[attributeName] = false
|
313
|
+
|
314
|
+
unless objectsAreEqual(currentAttributes, @currentAttributes)
|
315
|
+
@currentAttributes = currentAttributes
|
316
|
+
@notifyDelegateOfCurrentAttributesChange()
|
317
|
+
|
318
|
+
getCurrentAttributes: ->
|
319
|
+
extend.call({}, @currentAttributes)
|
320
|
+
|
321
|
+
getCurrentTextAttributes: ->
|
322
|
+
attributes = {}
|
323
|
+
attributes[key] = value for key, value of @currentAttributes when getTextConfig(key)
|
324
|
+
attributes
|
325
|
+
|
326
|
+
# Selection freezing
|
327
|
+
|
328
|
+
freezeSelection: ->
|
329
|
+
@setCurrentAttribute("frozen", true)
|
330
|
+
|
331
|
+
thawSelection: ->
|
332
|
+
@removeCurrentAttribute("frozen")
|
333
|
+
|
334
|
+
hasFrozenSelection: ->
|
335
|
+
@hasCurrentAttribute("frozen")
|
336
|
+
|
337
|
+
# Selection
|
338
|
+
|
339
|
+
@proxyMethod "getSelectionManager().getPointRange"
|
340
|
+
@proxyMethod "getSelectionManager().setLocationRangeFromPointRange"
|
341
|
+
@proxyMethod "getSelectionManager().locationIsCursorTarget"
|
342
|
+
@proxyMethod "getSelectionManager().selectionIsExpanded"
|
343
|
+
@proxyMethod "delegate?.getSelectionManager"
|
344
|
+
|
345
|
+
setSelection: (selectedRange) ->
|
346
|
+
locationRange = @document.locationRangeFromRange(selectedRange)
|
347
|
+
@delegate?.compositionDidRequestChangingSelectionToLocationRange(locationRange)
|
348
|
+
|
349
|
+
getSelectedRange: ->
|
350
|
+
if locationRange = @getLocationRange()
|
351
|
+
@document.rangeFromLocationRange(locationRange)
|
352
|
+
|
353
|
+
setSelectedRange: (selectedRange) ->
|
354
|
+
locationRange = @document.locationRangeFromRange(selectedRange)
|
355
|
+
@getSelectionManager().setLocationRange(locationRange)
|
356
|
+
|
357
|
+
getPosition: ->
|
358
|
+
if locationRange = @getLocationRange()
|
359
|
+
@document.positionFromLocation(locationRange[0])
|
360
|
+
|
361
|
+
getLocationRange: (options) ->
|
362
|
+
@getSelectionManager().getLocationRange(options) ? normalizeRange(index: 0, offset: 0)
|
363
|
+
|
364
|
+
getExpandedRangeInDirection: (direction) ->
|
365
|
+
[startPosition, endPosition] = @getSelectedRange()
|
366
|
+
if direction is "backward"
|
367
|
+
startPosition = @translateUTF16PositionFromOffset(startPosition, -1)
|
368
|
+
else
|
369
|
+
endPosition = @translateUTF16PositionFromOffset(endPosition, 1)
|
370
|
+
normalizeRange([startPosition, endPosition])
|
371
|
+
|
372
|
+
moveCursorInDirection: (direction) ->
|
373
|
+
if @editingAttachment
|
374
|
+
range = @document.getRangeOfAttachment(@editingAttachment)
|
375
|
+
else
|
376
|
+
selectedRange = @getSelectedRange()
|
377
|
+
range = @getExpandedRangeInDirection(direction)
|
378
|
+
canEditAttachment = not rangesAreEqual(selectedRange, range)
|
379
|
+
|
380
|
+
if direction is "backward"
|
381
|
+
@setSelectedRange(range[0])
|
382
|
+
else
|
383
|
+
@setSelectedRange(range[1])
|
384
|
+
|
385
|
+
if canEditAttachment
|
386
|
+
if attachment = @getAttachmentAtRange(range)
|
387
|
+
@editAttachment(attachment)
|
388
|
+
|
389
|
+
expandSelectionInDirection: (direction) ->
|
390
|
+
range = @getExpandedRangeInDirection(direction)
|
391
|
+
@setSelectedRange(range)
|
392
|
+
|
393
|
+
expandSelectionForEditing: ->
|
394
|
+
if @hasCurrentAttribute("href")
|
395
|
+
@expandSelectionAroundCommonAttribute("href")
|
396
|
+
|
397
|
+
expandSelectionAroundCommonAttribute: (attributeName) ->
|
398
|
+
position = @getPosition()
|
399
|
+
range = @document.getRangeOfCommonAttributeAtPosition(attributeName, position)
|
400
|
+
@setSelectedRange(range)
|
401
|
+
|
402
|
+
selectionContainsAttachmentWithAttribute: (attributeName) ->
|
403
|
+
if selectedRange = @getSelectedRange()
|
404
|
+
for attachment in @document.getDocumentAtRange(selectedRange).getAttachments()
|
405
|
+
return true if attachment.hasAttribute(attributeName)
|
406
|
+
false
|
407
|
+
|
408
|
+
selectionIsInCursorTarget: ->
|
409
|
+
@editingAttachment or @positionIsCursorTarget(@getPosition())
|
410
|
+
|
411
|
+
positionIsCursorTarget: (position) ->
|
412
|
+
if location = @document.locationFromPosition(position)
|
413
|
+
@locationIsCursorTarget(location)
|
414
|
+
|
415
|
+
positionIsBlockBreak: (position) ->
|
416
|
+
@document.getPieceAtPosition(position)?.isBlockBreak()
|
417
|
+
|
418
|
+
getSelectedDocument: ->
|
419
|
+
if selectedRange = @getSelectedRange()
|
420
|
+
@document.getDocumentAtRange(selectedRange)
|
421
|
+
|
422
|
+
# Attachments
|
423
|
+
|
424
|
+
getAttachments: ->
|
425
|
+
@attachments.slice(0)
|
426
|
+
|
427
|
+
refreshAttachments: ->
|
428
|
+
attachments = @document.getAttachments()
|
429
|
+
{added, removed} = summarizeArrayChange(@attachments, attachments)
|
430
|
+
@attachments = attachments
|
431
|
+
|
432
|
+
for attachment in removed
|
433
|
+
attachment.delegate = null
|
434
|
+
@delegate?.compositionDidRemoveAttachment?(attachment)
|
435
|
+
|
436
|
+
for attachment in added
|
437
|
+
attachment.delegate = this
|
438
|
+
@delegate?.compositionDidAddAttachment?(attachment)
|
439
|
+
|
440
|
+
# Attachment delegate
|
441
|
+
|
442
|
+
attachmentDidChangeAttributes: (attachment) ->
|
443
|
+
@revision++
|
444
|
+
@delegate?.compositionDidEditAttachment?(attachment)
|
445
|
+
|
446
|
+
attachmentDidChangePreviewURL: (attachment) ->
|
447
|
+
@revision++
|
448
|
+
@delegate?.compositionDidChangeAttachmentPreviewURL?(attachment)
|
449
|
+
|
450
|
+
# Attachment editing
|
451
|
+
|
452
|
+
editAttachment: (attachment) ->
|
453
|
+
return if attachment is @editingAttachment
|
454
|
+
@stopEditingAttachment()
|
455
|
+
@editingAttachment = attachment
|
456
|
+
@delegate?.compositionDidStartEditingAttachment?(@editingAttachment)
|
457
|
+
|
458
|
+
stopEditingAttachment: ->
|
459
|
+
return unless @editingAttachment
|
460
|
+
@delegate?.compositionDidStopEditingAttachment?(@editingAttachment)
|
461
|
+
@editingAttachment = null
|
462
|
+
|
463
|
+
canEditAttachmentCaption: ->
|
464
|
+
@editingAttachment?.isPreviewable()
|
465
|
+
|
466
|
+
updateAttributesForAttachment: (attributes, attachment) ->
|
467
|
+
@setDocument(@document.updateAttributesForAttachment(attributes, attachment))
|
468
|
+
|
469
|
+
removeAttributeForAttachment: (attribute, attachment) ->
|
470
|
+
@setDocument(@document.removeAttributeForAttachment(attribute, attachment))
|
471
|
+
|
472
|
+
# Private
|
473
|
+
|
474
|
+
breakFormattedBlock: (insertion) ->
|
475
|
+
{document, block} = insertion
|
476
|
+
position = insertion.startPosition
|
477
|
+
range = [position - 1, position]
|
478
|
+
|
479
|
+
if block.getBlockBreakPosition() is insertion.startLocation.offset
|
480
|
+
if block.breaksOnReturn() and insertion.nextCharacter is "\n"
|
481
|
+
position += 1
|
482
|
+
else
|
483
|
+
document = document.removeTextAtRange(range)
|
484
|
+
range = [position, position]
|
485
|
+
else if insertion.nextCharacter is "\n"
|
486
|
+
if insertion.previousCharacter is "\n"
|
487
|
+
range = [position - 1, position + 1]
|
488
|
+
else
|
489
|
+
range = [position, position + 1]
|
490
|
+
position += 1
|
491
|
+
else if insertion.startLocation.offset - 1 isnt 0
|
492
|
+
position += 1
|
493
|
+
|
494
|
+
newDocument = new Trix.Document [block.removeLastAttribute().copyWithoutText()]
|
495
|
+
@setDocument(document.insertDocumentAtRange(newDocument, range))
|
496
|
+
@setSelection(position)
|
497
|
+
|
498
|
+
getPreviousBlock: ->
|
499
|
+
if locationRange = @getLocationRange()
|
500
|
+
{index} = locationRange[0]
|
501
|
+
@document.getBlockAtIndex(index - 1) if index > 0
|
502
|
+
|
503
|
+
getBlock: ->
|
504
|
+
if locationRange = @getLocationRange()
|
505
|
+
@document.getBlockAtIndex(locationRange[0].index)
|
506
|
+
|
507
|
+
getAttachmentAtRange: (range) ->
|
508
|
+
document = @document.getDocumentAtRange(range)
|
509
|
+
if document.toString() is "#{Trix.OBJECT_REPLACEMENT_CHARACTER}\n"
|
510
|
+
document.getAttachments()[0]
|
511
|
+
|
512
|
+
notifyDelegateOfCurrentAttributesChange: ->
|
513
|
+
@delegate?.compositionDidChangeCurrentAttributes?(@currentAttributes)
|
514
|
+
|
515
|
+
notifyDelegateOfInsertionAtRange: (range) ->
|
516
|
+
@delegate?.compositionDidPerformInsertionAtRange?(range)
|
517
|
+
|
518
|
+
translateUTF16PositionFromOffset: (position, offset) ->
|
519
|
+
utf16string = @document.toUTF16String()
|
520
|
+
utf16position = utf16string.offsetFromUCS2Offset(position)
|
521
|
+
utf16string.offsetToUCS2Offset(utf16position + offset)
|