vapid 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.gitmodules +6 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +133 -0
  6. data/.travis.yml +5 -0
  7. data/Gemfile +10 -0
  8. data/README.md +37 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/exe/vapid +7 -0
  13. data/lib/vapid.rb +24 -0
  14. data/lib/vapid/assets/javascripts/vapid/admin.coffee +2 -0
  15. data/lib/vapid/assets/stylesheets/vapid/admin.scss +72 -0
  16. data/lib/vapid/builder.rb +70 -0
  17. data/lib/vapid/cli.rb +96 -0
  18. data/lib/vapid/controllers/admin_controller.rb +282 -0
  19. data/lib/vapid/controllers/project_controller.rb +41 -0
  20. data/lib/vapid/db/migrate/20170202182310_create_groups.rb +12 -0
  21. data/lib/vapid/db/migrate/20170202183017_create_records.rb +11 -0
  22. data/lib/vapid/db/migrate/20170202185150_create_users.rb +11 -0
  23. data/lib/vapid/directive.rb +168 -0
  24. data/lib/vapid/directives.rb +30 -0
  25. data/lib/vapid/directives/audio.rb +27 -0
  26. data/lib/vapid/directives/group.rb +71 -0
  27. data/lib/vapid/directives/hide.rb +11 -0
  28. data/lib/vapid/directives/href.rb +11 -0
  29. data/lib/vapid/directives/image.rb +14 -0
  30. data/lib/vapid/directives/richtext.rb +15 -0
  31. data/lib/vapid/directives/show.rb +11 -0
  32. data/lib/vapid/directives/text.rb +24 -0
  33. data/lib/vapid/directives/video.rb +28 -0
  34. data/lib/vapid/generator_template/.gitignore +21 -0
  35. data/lib/vapid/generator_template/Gemfile.tt +13 -0
  36. data/lib/vapid/generator_template/README.md +0 -0
  37. data/lib/vapid/generator_template/assets/favicon.ico +0 -0
  38. data/lib/vapid/generator_template/assets/images/.keep +0 -0
  39. data/lib/vapid/generator_template/assets/javascripts/.keep +0 -0
  40. data/lib/vapid/generator_template/assets/stylesheets/.keep +0 -0
  41. data/lib/vapid/generator_template/assets/stylesheets/application.css +120 -0
  42. data/lib/vapid/generator_template/config.ru +3 -0
  43. data/lib/vapid/generator_template/config/database.yml +12 -0
  44. data/lib/vapid/generator_template/config/settings.yml.tt +11 -0
  45. data/lib/vapid/generator_template/templates/index.html.erb +25 -0
  46. data/lib/vapid/generator_template/templates/layouts/default.html.erb +22 -0
  47. data/lib/vapid/models.rb +18 -0
  48. data/lib/vapid/models/group.rb +36 -0
  49. data/lib/vapid/models/record.rb +30 -0
  50. data/lib/vapid/models/user.rb +16 -0
  51. data/lib/vapid/server.rb +93 -0
  52. data/lib/vapid/settings.rb +13 -0
  53. data/lib/vapid/template.rb +79 -0
  54. data/lib/vapid/template/node.rb +91 -0
  55. data/lib/vapid/template/parser.rb +50 -0
  56. data/lib/vapid/vendor/semantic-ui/.versions +4 -0
  57. data/lib/vapid/vendor/semantic-ui/LICENSE +22 -0
  58. data/lib/vapid/vendor/semantic-ui/README.md +7 -0
  59. data/lib/vapid/vendor/semantic-ui/components/accordion.css +252 -0
  60. data/lib/vapid/vendor/semantic-ui/components/accordion.js +610 -0
  61. data/lib/vapid/vendor/semantic-ui/components/accordion.min.css +9 -0
  62. data/lib/vapid/vendor/semantic-ui/components/accordion.min.js +10 -0
  63. data/lib/vapid/vendor/semantic-ui/components/ad.css +275 -0
  64. data/lib/vapid/vendor/semantic-ui/components/ad.min.css +10 -0
  65. data/lib/vapid/vendor/semantic-ui/components/api.js +1167 -0
  66. data/lib/vapid/vendor/semantic-ui/components/api.min.js +10 -0
  67. data/lib/vapid/vendor/semantic-ui/components/breadcrumb.css +124 -0
  68. data/lib/vapid/vendor/semantic-ui/components/breadcrumb.min.css +9 -0
  69. data/lib/vapid/vendor/semantic-ui/components/button.css +3450 -0
  70. data/lib/vapid/vendor/semantic-ui/components/button.min.css +9 -0
  71. data/lib/vapid/vendor/semantic-ui/components/card.css +964 -0
  72. data/lib/vapid/vendor/semantic-ui/components/card.min.css +9 -0
  73. data/lib/vapid/vendor/semantic-ui/components/checkbox.css +625 -0
  74. data/lib/vapid/vendor/semantic-ui/components/checkbox.js +831 -0
  75. data/lib/vapid/vendor/semantic-ui/components/checkbox.min.css +9 -0
  76. data/lib/vapid/vendor/semantic-ui/components/checkbox.min.js +10 -0
  77. data/lib/vapid/vendor/semantic-ui/components/colorize.js +274 -0
  78. data/lib/vapid/vendor/semantic-ui/components/colorize.min.js +11 -0
  79. data/lib/vapid/vendor/semantic-ui/components/comment.css +270 -0
  80. data/lib/vapid/vendor/semantic-ui/components/comment.min.css +9 -0
  81. data/lib/vapid/vendor/semantic-ui/components/container.css +147 -0
  82. data/lib/vapid/vendor/semantic-ui/components/container.min.css +9 -0
  83. data/lib/vapid/vendor/semantic-ui/components/dimmer.css +200 -0
  84. data/lib/vapid/vendor/semantic-ui/components/dimmer.js +708 -0
  85. data/lib/vapid/vendor/semantic-ui/components/dimmer.min.css +9 -0
  86. data/lib/vapid/vendor/semantic-ui/components/dimmer.min.js +10 -0
  87. data/lib/vapid/vendor/semantic-ui/components/divider.css +260 -0
  88. data/lib/vapid/vendor/semantic-ui/components/divider.min.css +9 -0
  89. data/lib/vapid/vendor/semantic-ui/components/dropdown.css +1442 -0
  90. data/lib/vapid/vendor/semantic-ui/components/dropdown.js +3767 -0
  91. data/lib/vapid/vendor/semantic-ui/components/dropdown.min.css +9 -0
  92. data/lib/vapid/vendor/semantic-ui/components/dropdown.min.js +11 -0
  93. data/lib/vapid/vendor/semantic-ui/components/embed.css +166 -0
  94. data/lib/vapid/vendor/semantic-ui/components/embed.js +696 -0
  95. data/lib/vapid/vendor/semantic-ui/components/embed.min.css +9 -0
  96. data/lib/vapid/vendor/semantic-ui/components/embed.min.js +10 -0
  97. data/lib/vapid/vendor/semantic-ui/components/feed.css +296 -0
  98. data/lib/vapid/vendor/semantic-ui/components/feed.min.css +9 -0
  99. data/lib/vapid/vendor/semantic-ui/components/flag.css +1031 -0
  100. data/lib/vapid/vendor/semantic-ui/components/flag.min.css +9 -0
  101. data/lib/vapid/vendor/semantic-ui/components/form.css +1067 -0
  102. data/lib/vapid/vendor/semantic-ui/components/form.js +1603 -0
  103. data/lib/vapid/vendor/semantic-ui/components/form.min.css +9 -0
  104. data/lib/vapid/vendor/semantic-ui/components/form.min.js +10 -0
  105. data/lib/vapid/vendor/semantic-ui/components/grid.css +2002 -0
  106. data/lib/vapid/vendor/semantic-ui/components/grid.min.css +9 -0
  107. data/lib/vapid/vendor/semantic-ui/components/header.css +721 -0
  108. data/lib/vapid/vendor/semantic-ui/components/header.min.css +9 -0
  109. data/lib/vapid/vendor/semantic-ui/components/icon.css +3292 -0
  110. data/lib/vapid/vendor/semantic-ui/components/icon.min.css +9 -0
  111. data/lib/vapid/vendor/semantic-ui/components/image.css +306 -0
  112. data/lib/vapid/vendor/semantic-ui/components/image.min.css +9 -0
  113. data/lib/vapid/vendor/semantic-ui/components/input.css +510 -0
  114. data/lib/vapid/vendor/semantic-ui/components/input.min.css +9 -0
  115. data/lib/vapid/vendor/semantic-ui/components/item.css +486 -0
  116. data/lib/vapid/vendor/semantic-ui/components/item.min.css +9 -0
  117. data/lib/vapid/vendor/semantic-ui/components/label.css +1307 -0
  118. data/lib/vapid/vendor/semantic-ui/components/label.min.css +9 -0
  119. data/lib/vapid/vendor/semantic-ui/components/list.css +951 -0
  120. data/lib/vapid/vendor/semantic-ui/components/list.min.css +9 -0
  121. data/lib/vapid/vendor/semantic-ui/components/loader.css +347 -0
  122. data/lib/vapid/vendor/semantic-ui/components/loader.min.css +9 -0
  123. data/lib/vapid/vendor/semantic-ui/components/menu.css +2002 -0
  124. data/lib/vapid/vendor/semantic-ui/components/menu.min.css +1 -0
  125. data/lib/vapid/vendor/semantic-ui/components/message.css +477 -0
  126. data/lib/vapid/vendor/semantic-ui/components/message.min.css +9 -0
  127. data/lib/vapid/vendor/semantic-ui/components/modal.css +502 -0
  128. data/lib/vapid/vendor/semantic-ui/components/modal.js +913 -0
  129. data/lib/vapid/vendor/semantic-ui/components/modal.min.css +9 -0
  130. data/lib/vapid/vendor/semantic-ui/components/modal.min.js +10 -0
  131. data/lib/vapid/vendor/semantic-ui/components/nag.css +147 -0
  132. data/lib/vapid/vendor/semantic-ui/components/nag.js +507 -0
  133. data/lib/vapid/vendor/semantic-ui/components/nag.min.css +9 -0
  134. data/lib/vapid/vendor/semantic-ui/components/nag.min.js +10 -0
  135. data/lib/vapid/vendor/semantic-ui/components/popup.css +733 -0
  136. data/lib/vapid/vendor/semantic-ui/components/popup.js +1475 -0
  137. data/lib/vapid/vendor/semantic-ui/components/popup.min.css +9 -0
  138. data/lib/vapid/vendor/semantic-ui/components/popup.min.js +10 -0
  139. data/lib/vapid/vendor/semantic-ui/components/progress.css +516 -0
  140. data/lib/vapid/vendor/semantic-ui/components/progress.js +931 -0
  141. data/lib/vapid/vendor/semantic-ui/components/progress.min.css +9 -0
  142. data/lib/vapid/vendor/semantic-ui/components/progress.min.js +10 -0
  143. data/lib/vapid/vendor/semantic-ui/components/rail.css +152 -0
  144. data/lib/vapid/vendor/semantic-ui/components/rail.min.css +9 -0
  145. data/lib/vapid/vendor/semantic-ui/components/rating.css +263 -0
  146. data/lib/vapid/vendor/semantic-ui/components/rating.js +508 -0
  147. data/lib/vapid/vendor/semantic-ui/components/rating.min.css +9 -0
  148. data/lib/vapid/vendor/semantic-ui/components/rating.min.js +10 -0
  149. data/lib/vapid/vendor/semantic-ui/components/reset.css +424 -0
  150. data/lib/vapid/vendor/semantic-ui/components/reset.min.css +9 -0
  151. data/lib/vapid/vendor/semantic-ui/components/reveal.css +284 -0
  152. data/lib/vapid/vendor/semantic-ui/components/reveal.min.css +9 -0
  153. data/lib/vapid/vendor/semantic-ui/components/search.css +408 -0
  154. data/lib/vapid/vendor/semantic-ui/components/search.js +1442 -0
  155. data/lib/vapid/vendor/semantic-ui/components/search.min.css +9 -0
  156. data/lib/vapid/vendor/semantic-ui/components/search.min.js +10 -0
  157. data/lib/vapid/vendor/semantic-ui/components/segment.css +798 -0
  158. data/lib/vapid/vendor/semantic-ui/components/segment.min.css +9 -0
  159. data/lib/vapid/vendor/semantic-ui/components/shape.css +157 -0
  160. data/lib/vapid/vendor/semantic-ui/components/shape.js +921 -0
  161. data/lib/vapid/vendor/semantic-ui/components/shape.min.css +9 -0
  162. data/lib/vapid/vendor/semantic-ui/components/shape.min.js +10 -0
  163. data/lib/vapid/vendor/semantic-ui/components/sidebar.css +634 -0
  164. data/lib/vapid/vendor/semantic-ui/components/sidebar.js +1036 -0
  165. data/lib/vapid/vendor/semantic-ui/components/sidebar.min.css +9 -0
  166. data/lib/vapid/vendor/semantic-ui/components/sidebar.min.js +10 -0
  167. data/lib/vapid/vendor/semantic-ui/components/site.css +160 -0
  168. data/lib/vapid/vendor/semantic-ui/components/site.js +487 -0
  169. data/lib/vapid/vendor/semantic-ui/components/site.min.css +9 -0
  170. data/lib/vapid/vendor/semantic-ui/components/site.min.js +10 -0
  171. data/lib/vapid/vendor/semantic-ui/components/state.js +708 -0
  172. data/lib/vapid/vendor/semantic-ui/components/state.min.js +10 -0
  173. data/lib/vapid/vendor/semantic-ui/components/statistic.css +569 -0
  174. data/lib/vapid/vendor/semantic-ui/components/statistic.min.css +9 -0
  175. data/lib/vapid/vendor/semantic-ui/components/step.css +623 -0
  176. data/lib/vapid/vendor/semantic-ui/components/step.min.css +9 -0
  177. data/lib/vapid/vendor/semantic-ui/components/sticky.css +78 -0
  178. data/lib/vapid/vendor/semantic-ui/components/sticky.js +942 -0
  179. data/lib/vapid/vendor/semantic-ui/components/sticky.min.css +9 -0
  180. data/lib/vapid/vendor/semantic-ui/components/sticky.min.js +10 -0
  181. data/lib/vapid/vendor/semantic-ui/components/tab.css +91 -0
  182. data/lib/vapid/vendor/semantic-ui/components/tab.js +952 -0
  183. data/lib/vapid/vendor/semantic-ui/components/tab.min.css +9 -0
  184. data/lib/vapid/vendor/semantic-ui/components/tab.min.js +10 -0
  185. data/lib/vapid/vendor/semantic-ui/components/table.css +1108 -0
  186. data/lib/vapid/vendor/semantic-ui/components/table.min.css +9 -0
  187. data/lib/vapid/vendor/semantic-ui/components/transition.css +1964 -0
  188. data/lib/vapid/vendor/semantic-ui/components/transition.js +1095 -0
  189. data/lib/vapid/vendor/semantic-ui/components/transition.min.css +9 -0
  190. data/lib/vapid/vendor/semantic-ui/components/transition.min.js +10 -0
  191. data/lib/vapid/vendor/semantic-ui/components/video.css +125 -0
  192. data/lib/vapid/vendor/semantic-ui/components/video.js +532 -0
  193. data/lib/vapid/vendor/semantic-ui/components/video.min.css +10 -0
  194. data/lib/vapid/vendor/semantic-ui/components/video.min.js +11 -0
  195. data/lib/vapid/vendor/semantic-ui/components/visibility.js +1288 -0
  196. data/lib/vapid/vendor/semantic-ui/components/visibility.min.js +10 -0
  197. data/lib/vapid/vendor/semantic-ui/components/visit.js +517 -0
  198. data/lib/vapid/vendor/semantic-ui/components/visit.min.js +11 -0
  199. data/lib/vapid/vendor/semantic-ui/package.js +34 -0
  200. data/lib/vapid/vendor/semantic-ui/package.json +20 -0
  201. data/lib/vapid/vendor/semantic-ui/semantic.css +36844 -0
  202. data/lib/vapid/vendor/semantic-ui/semantic.js +22617 -0
  203. data/lib/vapid/vendor/semantic-ui/semantic.min.css +364 -0
  204. data/lib/vapid/vendor/semantic-ui/semantic.min.js +19 -0
  205. data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.eot +0 -0
  206. data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.otf +0 -0
  207. data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.svg +2671 -0
  208. data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.ttf +0 -0
  209. data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff +0 -0
  210. data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
  211. data/lib/vapid/vendor/semantic-ui/themes/default/assets/images/flags.png +0 -0
  212. data/lib/vapid/vendor/trix/.blade.yml +45 -0
  213. data/lib/vapid/vendor/trix/.github/ISSUE_TEMPLATE.md +13 -0
  214. data/lib/vapid/vendor/trix/.gitignore +3 -0
  215. data/lib/vapid/vendor/trix/.ruby-version +1 -0
  216. data/lib/vapid/vendor/trix/.travis.yml +6 -0
  217. data/lib/vapid/vendor/trix/CONDUCT.md +79 -0
  218. data/lib/vapid/vendor/trix/Gemfile +17 -0
  219. data/lib/vapid/vendor/trix/Gemfile.lock +152 -0
  220. data/lib/vapid/vendor/trix/LICENSE +20 -0
  221. data/lib/vapid/vendor/trix/README.md +382 -0
  222. data/lib/vapid/vendor/trix/assets/index.html +55 -0
  223. data/lib/vapid/vendor/trix/assets/trix-core.coffee +2 -0
  224. data/lib/vapid/vendor/trix/assets/trix.coffee +3 -0
  225. data/lib/vapid/vendor/trix/assets/trix.scss +5 -0
  226. data/lib/vapid/vendor/trix/assets/trix/banner/index.coffee.erb +3 -0
  227. data/lib/vapid/vendor/trix/assets/trix/banner/index.scss.erb +3 -0
  228. data/lib/vapid/vendor/trix/assets/trix/banner/index.txt.erb +3 -0
  229. data/lib/vapid/vendor/trix/assets/trix/images/README.md +6 -0
  230. data/lib/vapid/vendor/trix/assets/trix/images/attach.svg +5 -0
  231. data/lib/vapid/vendor/trix/assets/trix/images/bold.svg +5 -0
  232. data/lib/vapid/vendor/trix/assets/trix/images/bullets.svg +5 -0
  233. data/lib/vapid/vendor/trix/assets/trix/images/code.svg +5 -0
  234. data/lib/vapid/vendor/trix/assets/trix/images/heading_1.svg +5 -0
  235. data/lib/vapid/vendor/trix/assets/trix/images/italic.svg +5 -0
  236. data/lib/vapid/vendor/trix/assets/trix/images/link.svg +6 -0
  237. data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_decrease.svg +5 -0
  238. data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_increase.svg +5 -0
  239. data/lib/vapid/vendor/trix/assets/trix/images/numbers.svg +5 -0
  240. data/lib/vapid/vendor/trix/assets/trix/images/quote.svg +5 -0
  241. data/lib/vapid/vendor/trix/assets/trix/images/redo.svg +5 -0
  242. data/lib/vapid/vendor/trix/assets/trix/images/remove.svg +4 -0
  243. data/lib/vapid/vendor/trix/assets/trix/images/strike.svg +6 -0
  244. data/lib/vapid/vendor/trix/assets/trix/images/trash.svg +5 -0
  245. data/lib/vapid/vendor/trix/assets/trix/images/undo.svg +5 -0
  246. data/lib/vapid/vendor/trix/assets/trix/stylesheets/attachments.scss +112 -0
  247. data/lib/vapid/vendor/trix/assets/trix/stylesheets/content.scss +88 -0
  248. data/lib/vapid/vendor/trix/assets/trix/stylesheets/editor.scss +8 -0
  249. data/lib/vapid/vendor/trix/assets/trix/stylesheets/icons.scss +14 -0
  250. data/lib/vapid/vendor/trix/assets/trix/stylesheets/media-queries.scss +7 -0
  251. data/lib/vapid/vendor/trix/assets/trix/stylesheets/toolbar.scss +194 -0
  252. data/lib/vapid/vendor/trix/bin/blade +16 -0
  253. data/lib/vapid/vendor/trix/bin/ci +21 -0
  254. data/lib/vapid/vendor/trix/bin/rackup +16 -0
  255. data/lib/vapid/vendor/trix/bin/rake +16 -0
  256. data/lib/vapid/vendor/trix/bin/release +139 -0
  257. data/lib/vapid/vendor/trix/bin/setup +69 -0
  258. data/lib/vapid/vendor/trix/bin/update-status-image +100 -0
  259. data/lib/vapid/vendor/trix/bower.json +34 -0
  260. data/lib/vapid/vendor/trix/config.ru +32 -0
  261. data/lib/vapid/vendor/trix/dist/trix-core.js +11 -0
  262. data/lib/vapid/vendor/trix/dist/trix.css +286 -0
  263. data/lib/vapid/vendor/trix/dist/trix.js +20 -0
  264. data/lib/vapid/vendor/trix/package.json +29 -0
  265. data/lib/vapid/vendor/trix/polyfills/polyfills.coffee +3 -0
  266. data/lib/vapid/vendor/trix/polyfills/set.coffee +24 -0
  267. data/lib/vapid/vendor/trix/polyfills/vendor/CustomElements.js +1029 -0
  268. data/lib/vapid/vendor/trix/polyfills/vendor/README.md +2 -0
  269. data/lib/vapid/vendor/trix/polyfills/vendor/promise.js +228 -0
  270. data/lib/vapid/vendor/trix/src/trix/VERSION +1 -0
  271. data/lib/vapid/vendor/trix/src/trix/config/block_attributes.coffee +37 -0
  272. data/lib/vapid/vendor/trix/src/trix/config/css.coffee +12 -0
  273. data/lib/vapid/vendor/trix/src/trix/config/file_size_formatting.coffee +22 -0
  274. data/lib/vapid/vendor/trix/src/trix/config/index.coffee +9 -0
  275. data/lib/vapid/vendor/trix/src/trix/config/lang.coffee +26 -0
  276. data/lib/vapid/vendor/trix/src/trix/config/selection_elements.coffee +26 -0
  277. data/lib/vapid/vendor/trix/src/trix/config/serialization.coffee +63 -0
  278. data/lib/vapid/vendor/trix/src/trix/config/text_attributes.coffee +25 -0
  279. data/lib/vapid/vendor/trix/src/trix/config/toolbar.coffee +41 -0
  280. data/lib/vapid/vendor/trix/src/trix/config/undo_interval.coffee +7 -0
  281. data/lib/vapid/vendor/trix/src/trix/controllers/attachment_editor_controller.coffee +104 -0
  282. data/lib/vapid/vendor/trix/src/trix/controllers/composition_controller.coffee +117 -0
  283. data/lib/vapid/vendor/trix/src/trix/controllers/controller.coffee +3 -0
  284. data/lib/vapid/vendor/trix/src/trix/controllers/editor_controller.coffee +369 -0
  285. data/lib/vapid/vendor/trix/src/trix/controllers/input/composition_input.coffee +57 -0
  286. data/lib/vapid/vendor/trix/src/trix/controllers/input_controller.coffee +473 -0
  287. data/lib/vapid/vendor/trix/src/trix/controllers/toolbar_controller.coffee +173 -0
  288. data/lib/vapid/vendor/trix/src/trix/core/basic_object.coffee +44 -0
  289. data/lib/vapid/vendor/trix/src/trix/core/collections/element_store.coffee +21 -0
  290. data/lib/vapid/vendor/trix/src/trix/core/collections/hash.coffee +98 -0
  291. data/lib/vapid/vendor/trix/src/trix/core/collections/index.coffee +4 -0
  292. data/lib/vapid/vendor/trix/src/trix/core/collections/object_group.coffee +37 -0
  293. data/lib/vapid/vendor/trix/src/trix/core/collections/object_map.coffee +10 -0
  294. data/lib/vapid/vendor/trix/src/trix/core/helpers/arrays.coffee +34 -0
  295. data/lib/vapid/vendor/trix/src/trix/core/helpers/config.coffee +23 -0
  296. data/lib/vapid/vendor/trix/src/trix/core/helpers/custom_elements.coffee +45 -0
  297. data/lib/vapid/vendor/trix/src/trix/core/helpers/dom.coffee +185 -0
  298. data/lib/vapid/vendor/trix/src/trix/core/helpers/extend.coffee +4 -0
  299. data/lib/vapid/vendor/trix/src/trix/core/helpers/functions.coffee +3 -0
  300. data/lib/vapid/vendor/trix/src/trix/core/helpers/global.coffee +23 -0
  301. data/lib/vapid/vendor/trix/src/trix/core/helpers/index.coffee +10 -0
  302. data/lib/vapid/vendor/trix/src/trix/core/helpers/objects.coffee +11 -0
  303. data/lib/vapid/vendor/trix/src/trix/core/helpers/ranges.coffee +33 -0
  304. data/lib/vapid/vendor/trix/src/trix/core/helpers/selection.coffee +25 -0
  305. data/lib/vapid/vendor/trix/src/trix/core/helpers/strings.coffee +46 -0
  306. data/lib/vapid/vendor/trix/src/trix/core/index.coffee +4 -0
  307. data/lib/vapid/vendor/trix/src/trix/core/object.coffee +33 -0
  308. data/lib/vapid/vendor/trix/src/trix/core/utilities/index.coffee +2 -0
  309. data/lib/vapid/vendor/trix/src/trix/core/utilities/operation.coffee +37 -0
  310. data/lib/vapid/vendor/trix/src/trix/core/utilities/utf16_string.coffee +93 -0
  311. data/lib/vapid/vendor/trix/src/trix/elements/trix_editor_element.coffee +166 -0
  312. data/lib/vapid/vendor/trix/src/trix/elements/trix_toolbar_element.coffee +28 -0
  313. data/lib/vapid/vendor/trix/src/trix/index.coffee.erb +14 -0
  314. data/lib/vapid/vendor/trix/src/trix/inspector/control_element.coffee +60 -0
  315. data/lib/vapid/vendor/trix/src/trix/inspector/debugger.coffee +104 -0
  316. data/lib/vapid/vendor/trix/src/trix/inspector/element.coffee +86 -0
  317. data/lib/vapid/vendor/trix/src/trix/inspector/index.coffee +17 -0
  318. data/lib/vapid/vendor/trix/src/trix/inspector/polyfills/vendor/details-element-polyfill.js +5 -0
  319. data/lib/vapid/vendor/trix/src/trix/inspector/templates/debug.jst.eco +17 -0
  320. data/lib/vapid/vendor/trix/src/trix/inspector/templates/document.jst.eco +33 -0
  321. data/lib/vapid/vendor/trix/src/trix/inspector/templates/performance.jst.eco +10 -0
  322. data/lib/vapid/vendor/trix/src/trix/inspector/templates/render.jst.eco +1 -0
  323. data/lib/vapid/vendor/trix/src/trix/inspector/templates/selection.jst.eco +5 -0
  324. data/lib/vapid/vendor/trix/src/trix/inspector/templates/undo.jst.eco +13 -0
  325. data/lib/vapid/vendor/trix/src/trix/inspector/view.coffee +58 -0
  326. data/lib/vapid/vendor/trix/src/trix/inspector/views/debug_view.coffee +33 -0
  327. data/lib/vapid/vendor/trix/src/trix/inspector/views/document_view.coffee +12 -0
  328. data/lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee +51 -0
  329. data/lib/vapid/vendor/trix/src/trix/inspector/views/render_view.coffee +21 -0
  330. data/lib/vapid/vendor/trix/src/trix/inspector/views/selection_view.coffee +33 -0
  331. data/lib/vapid/vendor/trix/src/trix/inspector/views/undo_view.coffee +12 -0
  332. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/deserializer.coffee +55 -0
  333. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/index.coffee +5 -0
  334. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player.coffee +60 -0
  335. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_controller.coffee +43 -0
  336. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_element.coffee +32 -0
  337. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_view.coffee +133 -0
  338. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recorder.coffee +82 -0
  339. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recording.coffee +54 -0
  340. data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/serializer.coffee +61 -0
  341. data/lib/vapid/vendor/trix/src/trix/models/attachment.coffee +157 -0
  342. data/lib/vapid/vendor/trix/src/trix/models/attachment_manager.coffee +24 -0
  343. data/lib/vapid/vendor/trix/src/trix/models/attachment_piece.coffee +47 -0
  344. data/lib/vapid/vendor/trix/src/trix/models/block.coffee +230 -0
  345. data/lib/vapid/vendor/trix/src/trix/models/composition.coffee +521 -0
  346. data/lib/vapid/vendor/trix/src/trix/models/document.coffee +538 -0
  347. data/lib/vapid/vendor/trix/src/trix/models/editor.coffee +141 -0
  348. data/lib/vapid/vendor/trix/src/trix/models/html_parser.coffee +335 -0
  349. data/lib/vapid/vendor/trix/src/trix/models/line_break_insertion.coffee +31 -0
  350. data/lib/vapid/vendor/trix/src/trix/models/location_mapper.coffee +156 -0
  351. data/lib/vapid/vendor/trix/src/trix/models/managed_attachment.coffee +28 -0
  352. data/lib/vapid/vendor/trix/src/trix/models/piece.coffee +95 -0
  353. data/lib/vapid/vendor/trix/src/trix/models/point_mapper.coffee +28 -0
  354. data/lib/vapid/vendor/trix/src/trix/models/selection_manager.coffee +129 -0
  355. data/lib/vapid/vendor/trix/src/trix/models/splittable_list.coffee +168 -0
  356. data/lib/vapid/vendor/trix/src/trix/models/string_piece.coffee +49 -0
  357. data/lib/vapid/vendor/trix/src/trix/models/text.coffee +168 -0
  358. data/lib/vapid/vendor/trix/src/trix/models/undo_manager.coffee +40 -0
  359. data/lib/vapid/vendor/trix/src/trix/observers/mutation_observer.coffee +131 -0
  360. data/lib/vapid/vendor/trix/src/trix/observers/selection_change_observer.coffee +56 -0
  361. data/lib/vapid/vendor/trix/src/trix/operations/file_verification_operation.coffee +15 -0
  362. data/lib/vapid/vendor/trix/src/trix/operations/image_preload_operation.coffee +15 -0
  363. data/lib/vapid/vendor/trix/src/trix/views/attachment_view.coffee +99 -0
  364. data/lib/vapid/vendor/trix/src/trix/views/block_view.coffee +37 -0
  365. data/lib/vapid/vendor/trix/src/trix/views/document_view.coffee +68 -0
  366. data/lib/vapid/vendor/trix/src/trix/views/object_group_view.coffee +23 -0
  367. data/lib/vapid/vendor/trix/src/trix/views/object_view.coffee +86 -0
  368. data/lib/vapid/vendor/trix/src/trix/views/piece_view.coffee +97 -0
  369. data/lib/vapid/vendor/trix/src/trix/views/previewable_attachment_view.coffee +49 -0
  370. data/lib/vapid/vendor/trix/src/trix/views/text_view.coffee +30 -0
  371. data/lib/vapid/vendor/trix/test/.gitignore +1 -0
  372. data/lib/vapid/vendor/trix/test/src/system/attachment_test.coffee +70 -0
  373. data/lib/vapid/vendor/trix/test/src/system/basic_input_test.coffee +68 -0
  374. data/lib/vapid/vendor/trix/test/src/system/block_formatting_test.coffee +602 -0
  375. data/lib/vapid/vendor/trix/test/src/system/caching_test.coffee +21 -0
  376. data/lib/vapid/vendor/trix/test/src/system/composition_input_test.coffee +138 -0
  377. data/lib/vapid/vendor/trix/test/src/system/cursor_movement_test.coffee +54 -0
  378. data/lib/vapid/vendor/trix/test/src/system/custom_element_test.coffee +314 -0
  379. data/lib/vapid/vendor/trix/test/src/system/html_loading_test.coffee +62 -0
  380. data/lib/vapid/vendor/trix/test/src/system/html_replacement_test.coffee +101 -0
  381. data/lib/vapid/vendor/trix/test/src/system/installation_process_test.coffee +59 -0
  382. data/lib/vapid/vendor/trix/test/src/system/list_formatting_test.coffee +70 -0
  383. data/lib/vapid/vendor/trix/test/src/system/mutation_input_test.coffee +73 -0
  384. data/lib/vapid/vendor/trix/test/src/system/pasting_test.coffee +215 -0
  385. data/lib/vapid/vendor/trix/test/src/system/text_formatting_test.coffee +151 -0
  386. data/lib/vapid/vendor/trix/test/src/system/undo_test.coffee +48 -0
  387. data/lib/vapid/vendor/trix/test/src/test.coffee +16 -0
  388. data/lib/vapid/vendor/trix/test/src/test_helpers/assertions.coffee +38 -0
  389. data/lib/vapid/vendor/trix/test/src/test_helpers/editor_helpers.coffee +37 -0
  390. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_empty.jst.eco +1 -0
  391. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_html.jst.eco +2 -0
  392. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_in_table.jst.eco +7 -0
  393. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_block_styles.jst.eco +6 -0
  394. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_bold_styles.jst.eco +7 -0
  395. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_image.jst.eco +2 -0
  396. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_styled_content.jst.eco +7 -0
  397. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_toolbar_and_input.jst.eco +5 -0
  398. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/fixtures.coffee +536 -0
  399. data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/logo.png +0 -0
  400. data/lib/vapid/vendor/trix/test/src/test_helpers/index.coffee +18 -0
  401. data/lib/vapid/vendor/trix/test/src/test_helpers/input_helpers.coffee +183 -0
  402. data/lib/vapid/vendor/trix/test/src/test_helpers/selection_helpers.coffee +91 -0
  403. data/lib/vapid/vendor/trix/test/src/test_helpers/test_helpers.coffee +72 -0
  404. data/lib/vapid/vendor/trix/test/src/test_helpers/test_stubs.coffee +31 -0
  405. data/lib/vapid/vendor/trix/test/src/test_helpers/toolbar_helpers.coffee +45 -0
  406. data/lib/vapid/vendor/trix/test/src/unit/attachment_test.coffee +23 -0
  407. data/lib/vapid/vendor/trix/test/src/unit/block_test.coffee +22 -0
  408. data/lib/vapid/vendor/trix/test/src/unit/composition_test.coffee +13 -0
  409. data/lib/vapid/vendor/trix/test/src/unit/document_test.coffee +11 -0
  410. data/lib/vapid/vendor/trix/test/src/unit/document_view_test.coffee +6 -0
  411. data/lib/vapid/vendor/trix/test/src/unit/html_parser_test.coffee +162 -0
  412. data/lib/vapid/vendor/trix/test/src/unit/location_mapper_test.coffee +185 -0
  413. data/lib/vapid/vendor/trix/test/src/unit/mutation_observer_test.coffee +84 -0
  414. data/lib/vapid/vendor/trix/test/src/unit/serialization_test.coffee +7 -0
  415. data/lib/vapid/vendor/trix/test/src/unit/string_change_summary_test.coffee +57 -0
  416. data/lib/vapid/vendor/trix/test/src/unit/text_test.coffee +19 -0
  417. data/lib/vapid/vendor/trix/test/vendor/rangy-core.js +3845 -0
  418. data/lib/vapid/vendor/trix/test/vendor/rangy-textrange.js +1930 -0
  419. data/lib/vapid/version.rb +4 -0
  420. data/lib/vapid/views/admin/install.html.erb +19 -0
  421. data/lib/vapid/views/admin/login.html.erb +11 -0
  422. data/lib/vapid/views/admin/overview/index.html.erb +1 -0
  423. data/lib/vapid/views/admin/records/_form.erb +9 -0
  424. data/lib/vapid/views/admin/records/edit.html.erb +5 -0
  425. data/lib/vapid/views/admin/records/index.html.erb +38 -0
  426. data/lib/vapid/views/admin/records/new.html.erb +3 -0
  427. data/lib/vapid/views/errors/404.html.erb +1 -0
  428. data/lib/vapid/views/errors/500.html.erb +1 -0
  429. data/lib/vapid/views/layouts/admin.html.erb +41 -0
  430. data/lib/vapid/views/layouts/admin_form.html.erb +22 -0
  431. data/lib/vapid/views/layouts/error.html.erb +11 -0
  432. data/vapid.gemspec +48 -0
  433. metadata +811 -0
@@ -0,0 +1,41 @@
1
+ {makeFragment} = Trix
2
+ {lang} = Trix.config
3
+
4
+ Trix.config.toolbar =
5
+ content: makeFragment """
6
+ <div class="button_row">
7
+ <span class="button_group text_tools">
8
+ <button type="button" class="icon bold" data-trix-attribute="bold" data-trix-key="b" title="#{lang.bold}">#{lang.bold}</button>
9
+ <button type="button" class="icon italic" data-trix-attribute="italic" data-trix-key="i" title="#{lang.italic}">#{lang.italic}</button>
10
+ <button type="button" class="icon strike" data-trix-attribute="strike" title="#{lang.strike}">#{lang.strike}</button>
11
+ <button type="button" class="icon link" data-trix-attribute="href" data-trix-action="link" data-trix-key="k" title="#{lang.link}">#{lang.link}</button>
12
+ </span>
13
+
14
+ <span class="button_group block_tools">
15
+ <button type="button" class="icon heading-1" data-trix-attribute="heading1" title="#{lang.heading1}">#{lang.heading1}</button>
16
+ <button type="button" class="icon quote" data-trix-attribute="quote" title="#{lang.quote}">#{lang.quote}</button>
17
+ <button type="button" class="icon code" data-trix-attribute="code" title="#{lang.code}">#{lang.code}</button>
18
+ <button type="button" class="icon list bullets" data-trix-attribute="bullet" title="#{lang.bullets}">#{lang.bullets}</button>
19
+ <button type="button" class="icon list numbers" data-trix-attribute="number" title="#{lang.numbers}">#{lang.numbers}</button>
20
+ <button type="button" class="icon nesting-level decrease" data-trix-action="decreaseNestingLevel" title="#{lang.outdent}">#{lang.outdent}</button>
21
+ <button type="button" class="icon nesting-level increase" data-trix-action="increaseNestingLevel" title="#{lang.indent}">#{lang.indent}</button>
22
+ </span>
23
+
24
+ <span class="button_group history_tools">
25
+ <button type="button" class="icon undo" data-trix-action="undo" data-trix-key="z" title="#{lang.undo}">#{lang.undo}</button>
26
+ <button type="button" class="icon redo" data-trix-action="redo" data-trix-key="shift+z" title="#{lang.redo}">#{lang.redo}</button>
27
+ </span>
28
+ </div>
29
+
30
+ <div class="dialogs">
31
+ <div class="dialog link_dialog" data-trix-attribute="href" data-trix-dialog="href">
32
+ <div class="link_url_fields">
33
+ <input type="url" required name="href" placeholder="#{lang.urlPlaceholder}">
34
+ <div class="button_group">
35
+ <input type="button" value="#{lang.link}" data-trix-method="setAttribute">
36
+ <input type="button" value="#{lang.unlink}" data-trix-method="removeAttribute">
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ """
@@ -0,0 +1,7 @@
1
+ # Not all changes to a Trix document result in an undo entry being added to
2
+ # the stack. Trix aggregates successive changes into a single undo entry for
3
+ # typing and for attribute changes to the same selected range. The "undo
4
+ # interval" specifies how often, in milliseconds, these aggregate entries are
5
+ # split (or prevents splitting them at all when set to 0).
6
+
7
+ Trix.config.undoInterval = 5000
@@ -0,0 +1,104 @@
1
+ #= require trix/controllers/attachment_editor_controller
2
+
3
+ {handleEvent, makeElement, tagName} = Trix
4
+ {keyNames} = Trix.InputController
5
+ {lang} = Trix.config
6
+ {classNames} = Trix.config.css
7
+
8
+ class Trix.AttachmentEditorController extends Trix.BasicObject
9
+ constructor: (@attachmentPiece, @element, @container) ->
10
+ {@attachment} = @attachmentPiece
11
+ @element = @element.firstChild if tagName(@element) is "a"
12
+ @install()
13
+
14
+ undoable = (fn) -> ->
15
+ commands = fn.apply(this, arguments)
16
+ commands.do()
17
+ @undos ?= []
18
+ @undos.push(commands.undo)
19
+
20
+ install: ->
21
+ @makeElementMutable()
22
+ @makeCaptionEditable() if @attachment.isPreviewable()
23
+ @addRemoveButton()
24
+
25
+ makeElementMutable: undoable ->
26
+ do: => @element.dataset.trixMutable = true
27
+ undo: => delete @element.dataset.trixMutable
28
+
29
+ makeCaptionEditable: undoable ->
30
+ figcaption = @element.querySelector("figcaption")
31
+ handler = null
32
+ do: => handler = handleEvent("click", onElement: figcaption, withCallback: @didClickCaption, inPhase: "capturing")
33
+ undo: => handler.destroy()
34
+
35
+ addRemoveButton: undoable ->
36
+ removeButton = makeElement
37
+ tagName: "button"
38
+ textContent: lang.remove
39
+ className: classNames.attachment.removeButton
40
+ attributes: type: "button", title: lang.remove
41
+ data: trixMutable: true
42
+ handleEvent("click", onElement: removeButton, withCallback: @didClickRemoveButton)
43
+ do: => @element.appendChild(removeButton)
44
+ undo: => @element.removeChild(removeButton)
45
+
46
+ editCaption: undoable ->
47
+ textarea = makeElement
48
+ tagName: "textarea"
49
+ className: classNames.attachment.captionEditor
50
+ attributes: placeholder: lang.captionPlaceholder
51
+ textarea.value = @attachmentPiece.getCaption()
52
+
53
+ textareaClone = textarea.cloneNode()
54
+ textareaClone.classList.add("trix-autoresize-clone")
55
+
56
+ autoresize = ->
57
+ textareaClone.value = textarea.value
58
+ textarea.style.height = textareaClone.scrollHeight + "px"
59
+
60
+ handleEvent("input", onElement: textarea, withCallback: autoresize)
61
+ handleEvent("keydown", onElement: textarea, withCallback: @didKeyDownCaption)
62
+ handleEvent("change", onElement: textarea, withCallback: @didChangeCaption)
63
+ handleEvent("blur", onElement: textarea, withCallback: @uninstall)
64
+
65
+ figcaption = @element.querySelector("figcaption")
66
+ editingFigcaption = figcaption.cloneNode()
67
+
68
+ do: ->
69
+ figcaption.style.display = "none"
70
+ editingFigcaption.appendChild(textarea)
71
+ editingFigcaption.appendChild(textareaClone)
72
+ editingFigcaption.classList.add(classNames.attachment.editingCaption)
73
+ figcaption.parentElement.insertBefore(editingFigcaption, figcaption)
74
+ autoresize()
75
+ textarea.focus()
76
+ undo: ->
77
+ editingFigcaption.parentNode.removeChild(editingFigcaption)
78
+ figcaption.style.display = null
79
+
80
+ didClickRemoveButton: (event) =>
81
+ event.preventDefault()
82
+ event.stopPropagation()
83
+ @delegate?.attachmentEditorDidRequestRemovalOfAttachment(@attachment)
84
+
85
+ didClickCaption: (event) =>
86
+ event.preventDefault()
87
+ @editCaption()
88
+
89
+ didChangeCaption: (event) =>
90
+ caption = event.target.value.replace(/\s/g, " ").trim()
91
+ if caption
92
+ @delegate?.attachmentEditorDidRequestUpdatingAttributesForAttachment?({caption}, @attachment)
93
+ else
94
+ @delegate?.attachmentEditorDidRequestRemovingAttributeForAttachment?("caption", @attachment)
95
+
96
+ didKeyDownCaption: (event) =>
97
+ if keyNames[event.keyCode] is "return"
98
+ event.preventDefault()
99
+ @didChangeCaption(event)
100
+ @delegate?.attachmentEditorDidRequestDeselectingAttachment?(@attachment)
101
+
102
+ uninstall: =>
103
+ undo() while undo = @undos.pop()
104
+ @delegate?.didUninstallAttachmentEditor(this)
@@ -0,0 +1,117 @@
1
+ #= require trix/controllers/attachment_editor_controller
2
+ #= require trix/views/document_view
3
+
4
+ {handleEvent, innerElementIsActive, defer} = Trix
5
+
6
+ {attachmentSelector} = Trix.AttachmentView
7
+
8
+ class Trix.CompositionController extends Trix.BasicObject
9
+ constructor: (@element, @composition) ->
10
+ @documentView = new Trix.DocumentView @composition.document, {@element}
11
+
12
+ handleEvent "focus", onElement: @element, withCallback: @didFocus
13
+ handleEvent "blur", onElement: @element, withCallback: @didBlur
14
+ handleEvent "click", onElement: @element, matchingSelector: "a[contenteditable=false]", preventDefault: true
15
+ handleEvent "mousedown", onElement: @element, matchingSelector: attachmentSelector, withCallback: @didClickAttachment
16
+ handleEvent "click", onElement: @element, matchingSelector: "a#{attachmentSelector}", preventDefault: true
17
+
18
+ didFocus: (event) =>
19
+ perform = =>
20
+ unless @focused
21
+ @focused = true
22
+ @delegate?.compositionControllerDidFocus?()
23
+
24
+ @blurPromise?.then(perform) ? perform()
25
+
26
+ didBlur: (event) =>
27
+ @blurPromise = new Promise (resolve) =>
28
+ defer =>
29
+ unless innerElementIsActive(@element)
30
+ @focused = null
31
+ @delegate?.compositionControllerDidBlur?()
32
+ @blurPromise = null
33
+ resolve()
34
+
35
+ didClickAttachment: (event, target) =>
36
+ attachment = @findAttachmentForElement(target)
37
+ @delegate?.compositionControllerDidSelectAttachment?(attachment)
38
+
39
+ render: ->
40
+ unless @revision is @composition.revision
41
+ @documentView.setDocument(@composition.document)
42
+ @documentView.render()
43
+ @revision = @composition.revision
44
+
45
+ unless @documentView.isSynced()
46
+ @delegate?.compositionControllerWillSyncDocumentView?()
47
+ @documentView.sync()
48
+ @reinstallAttachmentEditor()
49
+ @delegate?.compositionControllerDidSyncDocumentView?()
50
+
51
+ @delegate?.compositionControllerDidRender?()
52
+
53
+ rerenderViewForObject: (object) ->
54
+ @invalidateViewForObject(object)
55
+ @render()
56
+
57
+ invalidateViewForObject: (object) ->
58
+ @documentView.invalidateViewForObject(object)
59
+
60
+ isViewCachingEnabled: ->
61
+ @documentView.isViewCachingEnabled()
62
+
63
+ enableViewCaching: ->
64
+ @documentView.enableViewCaching()
65
+
66
+ disableViewCaching: ->
67
+ @documentView.disableViewCaching()
68
+
69
+ refreshViewCache: ->
70
+ @documentView.garbageCollectCachedViews()
71
+
72
+ # Attachment editor management
73
+
74
+ installAttachmentEditorForAttachment: (attachment) ->
75
+ return if @attachmentEditor?.attachment is attachment
76
+ return unless element = @documentView.findElementForObject(attachment)
77
+ @uninstallAttachmentEditor()
78
+ attachmentPiece = @composition.document.getAttachmentPieceForAttachment(attachment)
79
+ @attachmentEditor = new Trix.AttachmentEditorController attachmentPiece, element, @element
80
+ @attachmentEditor.delegate = this
81
+
82
+ uninstallAttachmentEditor: ->
83
+ @attachmentEditor?.uninstall()
84
+
85
+ reinstallAttachmentEditor: ->
86
+ if @attachmentEditor
87
+ attachment = @attachmentEditor.attachment
88
+ @uninstallAttachmentEditor()
89
+ @installAttachmentEditorForAttachment(attachment)
90
+
91
+ editAttachmentCaption: ->
92
+ @attachmentEditor?.editCaption()
93
+
94
+ # Attachment controller delegate
95
+
96
+ didUninstallAttachmentEditor: ->
97
+ @attachmentEditor = null
98
+ @render()
99
+
100
+ attachmentEditorDidRequestUpdatingAttributesForAttachment: (attributes, attachment) ->
101
+ @delegate?.compositionControllerWillUpdateAttachment?(attachment)
102
+ @composition.updateAttributesForAttachment(attributes, attachment)
103
+
104
+ attachmentEditorDidRequestRemovingAttributeForAttachment: (attribute, attachment) ->
105
+ @delegate?.compositionControllerWillUpdateAttachment?(attachment)
106
+ @composition.removeAttributeForAttachment(attribute, attachment)
107
+
108
+ attachmentEditorDidRequestRemovalOfAttachment: (attachment) ->
109
+ @delegate?.compositionControllerDidRequestRemovalOfAttachment?(attachment)
110
+
111
+ attachmentEditorDidRequestDeselectingAttachment: (attachment) ->
112
+ @delegate?.compositionControllerDidRequestDeselectingAttachment?(attachment)
113
+
114
+ # Private
115
+
116
+ findAttachmentForElement: (element) ->
117
+ @composition.document.getAttachmentById(parseInt(element.dataset.trixId, 10))
@@ -0,0 +1,3 @@
1
+ #= require trix/views/object_view
2
+
3
+ class Trix.Controller extends Trix.BasicObject
@@ -0,0 +1,369 @@
1
+ #= require trix/controllers/controller
2
+ #= require trix/controllers/input_controller
3
+ #= require trix/controllers/composition_controller
4
+ #= require trix/controllers/toolbar_controller
5
+ #= require trix/models/composition
6
+ #= require trix/models/editor
7
+ #= require trix/models/attachment_manager
8
+ #= require trix/models/selection_manager
9
+
10
+ {rangeIsCollapsed, rangesAreEqual, objectsAreEqual} = Trix
11
+
12
+ class Trix.EditorController extends Trix.Controller
13
+ constructor: ({@editorElement, document, html}) ->
14
+ @selectionManager = new Trix.SelectionManager @editorElement
15
+ @selectionManager.delegate = this
16
+
17
+ @composition = new Trix.Composition
18
+ @composition.delegate = this
19
+
20
+ @attachmentManager = new Trix.AttachmentManager @composition.getAttachments()
21
+ @attachmentManager.delegate = this
22
+
23
+ @inputController = new Trix.InputController @editorElement
24
+ @inputController.delegate = this
25
+ @inputController.responder = @composition
26
+
27
+ @compositionController = new Trix.CompositionController @editorElement, @composition
28
+ @compositionController.delegate = this
29
+
30
+ @toolbarController = new Trix.ToolbarController @editorElement.toolbarElement
31
+ @toolbarController.delegate = this
32
+
33
+ @editor = new Trix.Editor @composition, @selectionManager, @editorElement
34
+ if document?
35
+ @editor.loadDocument(document)
36
+ else
37
+ @editor.loadHTML(html)
38
+
39
+ registerSelectionManager: ->
40
+ Trix.selectionChangeObserver.registerSelectionManager(@selectionManager)
41
+
42
+ unregisterSelectionManager: ->
43
+ Trix.selectionChangeObserver.unregisterSelectionManager(@selectionManager)
44
+
45
+ # Composition delegate
46
+
47
+ compositionDidChangeDocument: (document) ->
48
+ @editorElement.notify("document-change")
49
+ @render() unless @handlingInput
50
+
51
+ compositionDidChangeCurrentAttributes: (@currentAttributes) ->
52
+ @toolbarController.updateAttributes(@currentAttributes)
53
+ @updateCurrentActions()
54
+ @editorElement.notify("attributes-change", attributes: @currentAttributes)
55
+
56
+ compositionDidPerformInsertionAtRange: (range) ->
57
+ @pastedRange = range if @pasting
58
+
59
+ compositionShouldAcceptFile: (file) ->
60
+ @editorElement.notify("file-accept", {file})
61
+
62
+ compositionDidAddAttachment: (attachment) ->
63
+ managedAttachment = @attachmentManager.manageAttachment(attachment)
64
+ @editorElement.notify("attachment-add", attachment: managedAttachment)
65
+
66
+ compositionDidEditAttachment: (attachment) ->
67
+ @compositionController.rerenderViewForObject(attachment)
68
+ managedAttachment = @attachmentManager.manageAttachment(attachment)
69
+ @editorElement.notify("attachment-edit", attachment: managedAttachment)
70
+ @editorElement.notify("change")
71
+
72
+ compositionDidChangeAttachmentPreviewURL: (attachment) ->
73
+ @compositionController.invalidateViewForObject(attachment)
74
+ @editorElement.notify("change")
75
+
76
+ compositionDidRemoveAttachment: (attachment) ->
77
+ managedAttachment = @attachmentManager.unmanageAttachment(attachment)
78
+ @editorElement.notify("attachment-remove", attachment: managedAttachment)
79
+
80
+ compositionDidStartEditingAttachment: (attachment) ->
81
+ @attachmentLocationRange = @composition.document.getLocationRangeOfAttachment(attachment)
82
+ @compositionController.installAttachmentEditorForAttachment(attachment)
83
+ @selectionManager.setLocationRange(@attachmentLocationRange)
84
+
85
+ compositionDidStopEditingAttachment: (attachment) ->
86
+ @compositionController.uninstallAttachmentEditor()
87
+ @attachmentLocationRange = null
88
+
89
+ compositionDidRequestChangingSelectionToLocationRange: (locationRange) ->
90
+ return if @loadingSnapshot and not @isFocused()
91
+ @requestedLocationRange = locationRange
92
+ @compositionRevisionWhenLocationRangeRequested = @composition.revision
93
+ @render() unless @handlingInput
94
+
95
+ compositionWillLoadSnapshot: ->
96
+ @loadingSnapshot = true
97
+
98
+ compositionDidLoadSnapshot: ->
99
+ @compositionController.refreshViewCache()
100
+ @render()
101
+ @loadingSnapshot = false
102
+
103
+ getSelectionManager: ->
104
+ @selectionManager
105
+
106
+ @proxyMethod "getSelectionManager().setLocationRange"
107
+ @proxyMethod "getSelectionManager().getLocationRange"
108
+
109
+ # Attachment manager delegate
110
+
111
+ attachmentManagerDidRequestRemovalOfAttachment: (attachment) ->
112
+ @removeAttachment(attachment)
113
+
114
+ # Document controller delegate
115
+
116
+ compositionControllerWillSyncDocumentView: ->
117
+ @inputController.editorWillSyncDocumentView()
118
+ @selectionManager.lock()
119
+ @selectionManager.clearSelection()
120
+
121
+ compositionControllerDidSyncDocumentView: ->
122
+ @inputController.editorDidSyncDocumentView()
123
+ @selectionManager.unlock()
124
+ @updateCurrentActions()
125
+ @editorElement.notify("sync")
126
+
127
+ compositionControllerDidRender: ->
128
+ if @requestedLocationRange?
129
+ if @compositionRevisionWhenLocationRangeRequested is @composition.revision
130
+ @selectionManager.setLocationRange(@requestedLocationRange)
131
+ @requestedLocationRange = null
132
+ @compositionRevisionWhenLocationRangeRequested = null
133
+
134
+ unless @renderedCompositionRevision is @composition.revision
135
+ @composition.updateCurrentAttributes()
136
+ @editorElement.notify("render")
137
+
138
+ @renderedCompositionRevision = @composition.revision
139
+
140
+ compositionControllerDidFocus: ->
141
+ @toolbarController.hideDialog()
142
+ @editorElement.notify("focus")
143
+
144
+ compositionControllerDidBlur: ->
145
+ @editorElement.notify("blur")
146
+
147
+ compositionControllerDidSelectAttachment: (attachment) ->
148
+ @composition.editAttachment(attachment)
149
+
150
+ compositionControllerDidRequestDeselectingAttachment: (attachment) ->
151
+ locationRange = @attachmentLocationRange ? @composition.document.getLocationRangeOfAttachment(attachment)
152
+ @selectionManager.setLocationRange(locationRange[1])
153
+
154
+ compositionControllerWillUpdateAttachment: (attachment) ->
155
+ @editor.recordUndoEntry("Edit Attachment", context: attachment.id, consolidatable: true)
156
+
157
+ compositionControllerDidRequestRemovalOfAttachment: (attachment) ->
158
+ @removeAttachment(attachment)
159
+
160
+ # Input controller delegate
161
+
162
+ inputControllerWillHandleInput: ->
163
+ @handlingInput = true
164
+ @requestedRender = false
165
+
166
+ inputControllerDidRequestRender: ->
167
+ @requestedRender = true
168
+
169
+ inputControllerDidHandleInput: ->
170
+ @handlingInput = false
171
+ if @requestedRender
172
+ @requestedRender = false
173
+ @render()
174
+
175
+ inputControllerDidAllowUnhandledInput: ->
176
+ @editorElement.notify("change")
177
+
178
+ inputControllerDidRequestReparse: ->
179
+ @reparse()
180
+
181
+ inputControllerWillPerformTyping: ->
182
+ @recordTypingUndoEntry()
183
+
184
+ inputControllerWillCutText: ->
185
+ @editor.recordUndoEntry("Cut")
186
+
187
+ inputControllerWillPasteText: (pasteData) ->
188
+ @editor.recordUndoEntry("Paste")
189
+ @pasting = true
190
+
191
+ inputControllerDidPaste: (pasteData) ->
192
+ range = @pastedRange
193
+ @pastedRange = null
194
+ @pasting = null
195
+ @editorElement.notify("paste", {pasteData, range})
196
+
197
+ inputControllerWillMoveText: ->
198
+ @editor.recordUndoEntry("Move")
199
+
200
+ inputControllerWillAttachFiles: ->
201
+ @editor.recordUndoEntry("Drop Files")
202
+
203
+ inputControllerDidReceiveKeyboardCommand: (keys) ->
204
+ @toolbarController.applyKeyboardCommand(keys)
205
+
206
+ inputControllerDidStartDrag: ->
207
+ @locationRangeBeforeDrag = @selectionManager.getLocationRange()
208
+
209
+ inputControllerDidReceiveDragOverPoint: (point) ->
210
+ @selectionManager.setLocationRangeFromPointRange(point)
211
+
212
+ inputControllerDidCancelDrag: ->
213
+ @selectionManager.setLocationRange(@locationRangeBeforeDrag)
214
+ @locationRangeBeforeDrag = null
215
+
216
+ # Selection manager delegate
217
+
218
+ locationRangeDidChange: (locationRange) ->
219
+ @composition.updateCurrentAttributes()
220
+ @updateCurrentActions()
221
+ if @attachmentLocationRange and not rangesAreEqual(@attachmentLocationRange, locationRange)
222
+ @composition.stopEditingAttachment()
223
+ @editorElement.notify("selection-change")
224
+
225
+ # Toolbar controller delegate
226
+
227
+ toolbarDidClickButton: ->
228
+ @setLocationRange(index: 0, offset: 0) unless @getLocationRange()
229
+
230
+ toolbarDidInvokeAction: (actionName) ->
231
+ @invokeAction(actionName)
232
+
233
+ toolbarDidToggleAttribute: (attributeName) ->
234
+ @recordFormattingUndoEntry()
235
+ @composition.toggleCurrentAttribute(attributeName)
236
+ @render()
237
+ @editorElement.focus() unless @selectionFrozen
238
+
239
+ toolbarDidUpdateAttribute: (attributeName, value) ->
240
+ @recordFormattingUndoEntry()
241
+ @composition.setCurrentAttribute(attributeName, value)
242
+ @render()
243
+ @editorElement.focus() unless @selectionFrozen
244
+
245
+ toolbarDidRemoveAttribute: (attributeName) ->
246
+ @recordFormattingUndoEntry()
247
+ @composition.removeCurrentAttribute(attributeName)
248
+ @render()
249
+ @editorElement.focus() unless @selectionFrozen
250
+
251
+ toolbarWillShowDialog: (dialogElement) ->
252
+ @composition.expandSelectionForEditing()
253
+ @freezeSelection()
254
+
255
+ toolbarDidShowDialog: (dialogName) ->
256
+ @editorElement.notify("toolbar-dialog-show", {dialogName})
257
+
258
+ toolbarDidHideDialog: (dialogName) ->
259
+ @thawSelection()
260
+ @editorElement.focus()
261
+ @editorElement.notify("toolbar-dialog-hide", {dialogName})
262
+
263
+ # Selection
264
+
265
+ freezeSelection: ->
266
+ unless @selectionFrozen
267
+ @selectionManager.lock()
268
+ @composition.freezeSelection()
269
+ @selectionFrozen = true
270
+ @render()
271
+
272
+ thawSelection: ->
273
+ if @selectionFrozen
274
+ @composition.thawSelection()
275
+ @selectionManager.unlock()
276
+ @selectionFrozen = false
277
+ @render()
278
+
279
+ # Actions
280
+
281
+ actions:
282
+ undo:
283
+ test: -> @editor.canUndo()
284
+ perform: -> @editor.undo()
285
+ redo:
286
+ test: -> @editor.canRedo()
287
+ perform: -> @editor.redo()
288
+ link:
289
+ test: -> @editor.canActivateAttribute("href")
290
+ increaseNestingLevel:
291
+ test: -> @editor.canIncreaseNestingLevel()
292
+ perform: -> @editor.increaseNestingLevel() and @render()
293
+ decreaseNestingLevel:
294
+ test: -> @editor.canDecreaseNestingLevel()
295
+ perform: -> @editor.decreaseNestingLevel() and @render()
296
+ increaseBlockLevel: # deprecated in favor of increaseNestingLevel
297
+ test: -> @editor.canIncreaseNestingLevel()
298
+ perform: -> @editor.increaseNestingLevel() and @render()
299
+ decreaseBlockLevel: # deprecated in favor of decreaseNestingLevel
300
+ test: -> @editor.canDecreaseNestingLevel()
301
+ perform: -> @editor.decreaseNestingLevel() and @render()
302
+
303
+ canInvokeAction: (actionName) ->
304
+ if @actionIsExternal(actionName)
305
+ true
306
+ else
307
+ !! @actions[actionName]?.test?.call(this)
308
+
309
+ invokeAction: (actionName) ->
310
+ if @actionIsExternal(actionName)
311
+ @editorElement.notify("action-invoke", {actionName})
312
+ else
313
+ @actions[actionName]?.perform?.call(this)
314
+
315
+ actionIsExternal: (actionName) ->
316
+ /^x-./.test(actionName)
317
+
318
+ getCurrentActions: ->
319
+ result = {}
320
+ for actionName of @actions
321
+ result[actionName] = @canInvokeAction(actionName)
322
+ result
323
+
324
+ updateCurrentActions: ->
325
+ currentActions = @getCurrentActions()
326
+ unless objectsAreEqual(currentActions, @currentActions)
327
+ @currentActions = currentActions
328
+ @toolbarController.updateActions(@currentActions)
329
+ @editorElement.notify("actions-change", actions: @currentActions)
330
+
331
+ # Private
332
+
333
+ reparse: ->
334
+ @composition.replaceHTML(@editorElement.innerHTML)
335
+
336
+ render: ->
337
+ @compositionController.render()
338
+
339
+ removeAttachment: (attachment) ->
340
+ @editor.recordUndoEntry("Delete Attachment")
341
+ @composition.removeAttachment(attachment)
342
+ @render()
343
+
344
+ recordFormattingUndoEntry: ->
345
+ locationRange = @selectionManager.getLocationRange()
346
+ unless rangeIsCollapsed(locationRange)
347
+ @editor.recordUndoEntry("Formatting", context: @getUndoContext(), consolidatable: true)
348
+
349
+ recordTypingUndoEntry: ->
350
+ @editor.recordUndoEntry("Typing", context: @getUndoContext(@currentAttributes), consolidatable: true)
351
+
352
+ getUndoContext: (context...) ->
353
+ [@getLocationContext(), @getTimeContext(), context...]
354
+
355
+ getLocationContext: ->
356
+ locationRange = @selectionManager.getLocationRange()
357
+ if rangeIsCollapsed(locationRange)
358
+ locationRange[0].index
359
+ else
360
+ locationRange
361
+
362
+ getTimeContext: ->
363
+ if Trix.config.undoInterval > 0
364
+ Math.floor(new Date().getTime() / Trix.config.undoInterval)
365
+ else
366
+ 0
367
+
368
+ isFocused: ->
369
+ @editorElement is @editorElement.ownerDocument?.activeElement