vapid 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,31 @@
1
+ class Trix.LineBreakInsertion
2
+ constructor: (@composition) ->
3
+ {@document} = @composition
4
+
5
+ [@startPosition, @endPosition] = @composition.getSelectedRange()
6
+ @startLocation = @document.locationFromPosition(@startPosition)
7
+ @endLocation = @document.locationFromPosition(@endPosition)
8
+
9
+ @block = @document.getBlockAtIndex(@endLocation.index)
10
+ @breaksOnReturn = @block.breaksOnReturn()
11
+ @previousCharacter = @block.text.getStringAtPosition(@endLocation.offset - 1)
12
+ @nextCharacter = @block.text.getStringAtPosition(@endLocation.offset)
13
+
14
+ shouldInsertBlockBreak: ->
15
+ if @block.hasAttributes() and @block.isListItem() and not @block.isEmpty()
16
+ @startLocation.offset isnt 0
17
+ else
18
+ @breaksOnReturn and @nextCharacter isnt "\n"
19
+
20
+ shouldBreakFormattedBlock: ->
21
+ @block.hasAttributes() and not @block.isListItem() and
22
+ ((@breaksOnReturn and @nextCharacter is "\n") or @previousCharacter is "\n")
23
+
24
+ shouldDecreaseListLevel: ->
25
+ @block.hasAttributes() and @block.isListItem() and @block.isEmpty()
26
+
27
+ shouldPrependListItem: ->
28
+ @block.isListItem() and @startLocation.offset is 0 and not @block.isEmpty()
29
+
30
+ shouldRemoveLastBlockAttribute: ->
31
+ @block.hasAttributes() and not @block.isListItem() and @block.isEmpty()
@@ -0,0 +1,156 @@
1
+ {elementContainsNode, findChildIndexOfNode, nodeIsBlockStart,
2
+ nodeIsBlockStartComment, nodeIsBlockContainer, nodeIsCursorTarget,
3
+ nodeIsEmptyTextNode, nodeIsTextNode, nodeIsAttachmentElement, tagName, walkTree} = Trix
4
+
5
+ class Trix.LocationMapper
6
+ constructor: (@element) ->
7
+
8
+ findLocationFromContainerAndOffset: (container, offset, {strict} = strict: true) ->
9
+ childIndex = 0
10
+ foundBlock = false
11
+ location = index: 0, offset: 0
12
+
13
+ if attachmentElement = @findAttachmentElementParentForNode(container)
14
+ container = attachmentElement.parentNode
15
+ offset = findChildIndexOfNode(attachmentElement)
16
+
17
+ walker = walkTree(@element, usingFilter: rejectAttachmentContents)
18
+
19
+ while walker.nextNode()
20
+ node = walker.currentNode
21
+
22
+ if node is container and nodeIsTextNode(container)
23
+ unless nodeIsCursorTarget(node)
24
+ location.offset += offset
25
+ break
26
+
27
+ else
28
+ if node.parentNode is container
29
+ break if childIndex++ is offset
30
+ else unless elementContainsNode(container, node)
31
+ break if childIndex > 0
32
+
33
+ if nodeIsBlockStart(node, {strict})
34
+ location.index++ if foundBlock
35
+ location.offset = 0
36
+ foundBlock = true
37
+ else
38
+ location.offset += nodeLength(node)
39
+
40
+ location
41
+
42
+ findContainerAndOffsetFromLocation: (location) ->
43
+ if location.index is 0 and location.offset is 0
44
+ container = @element
45
+ offset = 0
46
+
47
+ while container.firstChild
48
+ container = container.firstChild
49
+ if nodeIsBlockContainer(container)
50
+ offset = 1
51
+ break
52
+
53
+ return [container, offset]
54
+
55
+ [node, nodeOffset] = @findNodeAndOffsetFromLocation(location)
56
+ return unless node
57
+
58
+ if nodeIsTextNode(node)
59
+ container = node
60
+ string = node.textContent
61
+ offset = location.offset - nodeOffset
62
+
63
+ else
64
+ container = node.parentNode
65
+
66
+ unless nodeIsBlockStart(node.previousSibling)
67
+ unless nodeIsBlockContainer(container)
68
+ while node is container.lastChild
69
+ node = container
70
+ container = container.parentNode
71
+ break if nodeIsBlockContainer(container)
72
+
73
+ offset = findChildIndexOfNode(node)
74
+ offset++ unless location.offset is 0
75
+
76
+ [container, offset]
77
+
78
+ findNodeAndOffsetFromLocation: (location) ->
79
+ offset = 0
80
+
81
+ for currentNode in @getSignificantNodesForIndex(location.index)
82
+ length = nodeLength(currentNode)
83
+
84
+ if location.offset <= offset + length
85
+ if nodeIsTextNode(currentNode)
86
+ node = currentNode
87
+ nodeOffset = offset
88
+ break if location.offset is nodeOffset and nodeIsCursorTarget(node)
89
+
90
+ else if not node
91
+ node = currentNode
92
+ nodeOffset = offset
93
+
94
+ offset += length
95
+ break if offset > location.offset
96
+
97
+ [node, nodeOffset]
98
+
99
+ # Private
100
+
101
+ findAttachmentElementParentForNode: (node) ->
102
+ while node and node isnt @element
103
+ return node if nodeIsAttachmentElement(node)
104
+ node = node.parentNode
105
+
106
+ getSignificantNodesForIndex: (index) ->
107
+ nodes = []
108
+ walker = walkTree(@element, usingFilter: acceptSignificantNodes)
109
+ recordingNodes = false
110
+
111
+ while walker.nextNode()
112
+ node = walker.currentNode
113
+ if nodeIsBlockStartComment(node)
114
+ if blockIndex?
115
+ blockIndex++
116
+ else
117
+ blockIndex = 0
118
+
119
+ if blockIndex is index
120
+ recordingNodes = true
121
+ else if recordingNodes
122
+ break
123
+ else if recordingNodes
124
+ nodes.push(node)
125
+
126
+ nodes
127
+
128
+ nodeLength = (node) ->
129
+ if node.nodeType is Node.TEXT_NODE
130
+ if nodeIsCursorTarget(node)
131
+ 0
132
+ else
133
+ string = node.textContent
134
+ string.length
135
+ else if tagName(node) is "br" or nodeIsAttachmentElement(node)
136
+ 1
137
+ else
138
+ 0
139
+
140
+ acceptSignificantNodes = (node) ->
141
+ if rejectEmptyTextNodes(node) is NodeFilter.FILTER_ACCEPT
142
+ rejectAttachmentContents(node)
143
+ else
144
+ NodeFilter.FILTER_REJECT
145
+
146
+ rejectEmptyTextNodes = (node) ->
147
+ if nodeIsEmptyTextNode(node)
148
+ NodeFilter.FILTER_REJECT
149
+ else
150
+ NodeFilter.FILTER_ACCEPT
151
+
152
+ rejectAttachmentContents = (node) ->
153
+ if nodeIsAttachmentElement(node.parentNode)
154
+ NodeFilter.FILTER_REJECT
155
+ else
156
+ NodeFilter.FILTER_ACCEPT
@@ -0,0 +1,28 @@
1
+ #= require trix/models/attachment
2
+
3
+ class Trix.ManagedAttachment extends Trix.BasicObject
4
+ constructor: (@attachmentManager, @attachment) ->
5
+ {@id, @file} = @attachment
6
+
7
+ remove: ->
8
+ @attachmentManager.requestRemovalOfAttachment(@attachment)
9
+
10
+ @proxyMethod "attachment.getAttribute"
11
+ @proxyMethod "attachment.hasAttribute"
12
+ @proxyMethod "attachment.setAttribute"
13
+ @proxyMethod "attachment.getAttributes"
14
+ @proxyMethod "attachment.setAttributes"
15
+ @proxyMethod "attachment.isPending"
16
+ @proxyMethod "attachment.isPreviewable"
17
+ @proxyMethod "attachment.getURL"
18
+ @proxyMethod "attachment.getHref"
19
+ @proxyMethod "attachment.getFilename"
20
+ @proxyMethod "attachment.getFilesize"
21
+ @proxyMethod "attachment.getFormattedFilesize"
22
+ @proxyMethod "attachment.getExtension"
23
+ @proxyMethod "attachment.getContentType"
24
+ @proxyMethod "attachment.getFile"
25
+ @proxyMethod "attachment.setFile"
26
+ @proxyMethod "attachment.releaseFile"
27
+ @proxyMethod "attachment.getUploadProgress"
28
+ @proxyMethod "attachment.setUploadProgress"
@@ -0,0 +1,95 @@
1
+ class Trix.Piece extends Trix.Object
2
+ @types: {}
3
+
4
+ @registerType: (type, constructor) ->
5
+ constructor.type = type
6
+ @types[type] = constructor
7
+
8
+ @fromJSON: (pieceJSON) ->
9
+ if constructor = @types[pieceJSON.type]
10
+ constructor.fromJSON(pieceJSON)
11
+
12
+ constructor: (value, attributes = {}) ->
13
+ super
14
+ @attributes = Trix.Hash.box(attributes)
15
+
16
+ copyWithAttributes: (attributes) ->
17
+ new @constructor @getValue(), attributes
18
+
19
+ copyWithAdditionalAttributes: (attributes) ->
20
+ @copyWithAttributes(@attributes.merge(attributes))
21
+
22
+ copyWithoutAttribute: (attribute) ->
23
+ @copyWithAttributes(@attributes.remove(attribute))
24
+
25
+ copy: ->
26
+ @copyWithAttributes(@attributes)
27
+
28
+ getAttribute: (attribute) ->
29
+ @attributes.get(attribute)
30
+
31
+ getAttributesHash: ->
32
+ @attributes
33
+
34
+ getAttributes: ->
35
+ @attributes.toObject()
36
+
37
+ getCommonAttributes: ->
38
+ return {} unless piece = pieceList.getPieceAtIndex(0)
39
+ attributes = piece.attributes
40
+ keys = attributes.getKeys()
41
+
42
+ pieceList.eachPiece (piece) ->
43
+ keys = attributes.getKeysCommonToHash(piece.attributes)
44
+ attributes = attributes.slice(keys)
45
+
46
+ attributes.toObject()
47
+
48
+ hasAttribute: (attribute) ->
49
+ @attributes.has(attribute)
50
+
51
+ hasSameStringValueAsPiece: (piece) ->
52
+ piece? and @toString() is piece.toString()
53
+
54
+ hasSameAttributesAsPiece: (piece) ->
55
+ piece? and (@attributes is piece.attributes or @attributes.isEqualTo(piece.attributes))
56
+
57
+ isBlockBreak: ->
58
+ false
59
+
60
+ isEqualTo: (piece) ->
61
+ super or (
62
+ @hasSameConstructorAs(piece) and
63
+ @hasSameStringValueAsPiece(piece) and
64
+ @hasSameAttributesAsPiece(piece)
65
+ )
66
+
67
+ isEmpty: ->
68
+ @length is 0
69
+
70
+ isSerializable: ->
71
+ true
72
+
73
+ toJSON: ->
74
+ type: @constructor.type
75
+ attributes: @getAttributes()
76
+
77
+ contentsForInspection: ->
78
+ type: @constructor.type
79
+ attributes: @attributes.inspect()
80
+
81
+ # Grouping
82
+
83
+ canBeGrouped: ->
84
+ @hasAttribute("href")
85
+
86
+ canBeGroupedWith: (piece) ->
87
+ @getAttribute("href") is piece.getAttribute("href")
88
+
89
+ # Splittable
90
+
91
+ getLength: ->
92
+ @length
93
+
94
+ canBeConsolidatedWith: (piece) ->
95
+ false
@@ -0,0 +1,28 @@
1
+ {getDOMRange, setDOMRange} = Trix
2
+
3
+ class Trix.PointMapper
4
+ createDOMRangeFromPoint: ({x, y}) ->
5
+ if document.caretPositionFromPoint
6
+ {offsetNode, offset} = document.caretPositionFromPoint(x, y)
7
+ domRange = document.createRange()
8
+ domRange.setStart(offsetNode, offset)
9
+ domRange
10
+
11
+ else if document.caretRangeFromPoint
12
+ document.caretRangeFromPoint(x, y)
13
+
14
+ else if document.body.createTextRange
15
+ originalDOMRange = getDOMRange()
16
+ try
17
+ # IE 11 throws "Unspecified error" when using moveToPoint
18
+ # during a drag-and-drop operation.
19
+ textRange = document.body.createTextRange()
20
+ textRange.moveToPoint(x, y)
21
+ textRange.select()
22
+ domRange = getDOMRange()
23
+ setDOMRange(originalDOMRange)
24
+ domRange
25
+
26
+ getClientRectsForDOMRange: (domRange) ->
27
+ [start, ..., end] = [domRange.getClientRects()...]
28
+ [start, end]
@@ -0,0 +1,129 @@
1
+ #= require trix/models/location_mapper
2
+ #= require trix/models/point_mapper
3
+ #= require trix/observers/selection_change_observer
4
+
5
+ {getDOMSelection, getDOMRange, setDOMRange, elementContainsNode,
6
+ nodeIsCursorTarget, innerElementIsActive, handleEvent, normalizeRange,
7
+ rangeIsCollapsed, rangesAreEqual} = Trix
8
+
9
+ class Trix.SelectionManager extends Trix.BasicObject
10
+ constructor: (@element) ->
11
+ @locationMapper = new Trix.LocationMapper @element
12
+ @pointMapper = new Trix.PointMapper
13
+ @lockCount = 0
14
+ handleEvent("mousedown", onElement: @element, withCallback: @didMouseDown)
15
+
16
+ getLocationRange: (options = {}) ->
17
+ locationRange =
18
+ if options.strict is false
19
+ @createLocationRangeFromDOMRange(getDOMRange(), strict: false)
20
+ else if options.ignoreLock
21
+ @currentLocationRange
22
+ else
23
+ @lockedLocationRange ? @currentLocationRange
24
+
25
+ setLocationRange: (locationRange) ->
26
+ return if @lockedLocationRange
27
+ locationRange = normalizeRange(locationRange)
28
+ if domRange = @createDOMRangeFromLocationRange(locationRange)
29
+ setDOMRange(domRange)
30
+ @updateCurrentLocationRange(locationRange)
31
+
32
+ setLocationRangeFromPointRange: (pointRange) ->
33
+ pointRange = normalizeRange(pointRange)
34
+ startLocation = @getLocationAtPoint(pointRange[0])
35
+ endLocation = @getLocationAtPoint(pointRange[1])
36
+ @setLocationRange([startLocation, endLocation])
37
+
38
+ getClientRectAtLocationRange: (locationRange) ->
39
+ if domRange = @createDOMRangeFromLocationRange(locationRange)
40
+ @getClientRectsForDOMRange(domRange)[1]
41
+
42
+ locationIsCursorTarget: (location) ->
43
+ [node, offset] = @findNodeAndOffsetFromLocation(location)
44
+ nodeIsCursorTarget(node)
45
+
46
+ lock: ->
47
+ if @lockCount++ is 0
48
+ @updateCurrentLocationRange()
49
+ @lockedLocationRange = @getLocationRange()
50
+
51
+ unlock: ->
52
+ if --@lockCount is 0
53
+ lockedLocationRange = @lockedLocationRange
54
+ @lockedLocationRange = null
55
+ @setLocationRange(lockedLocationRange) if lockedLocationRange?
56
+
57
+ clearSelection: ->
58
+ getDOMSelection()?.removeAllRanges()
59
+
60
+ selectionIsCollapsed: ->
61
+ getDOMRange()?.collapsed is true
62
+
63
+ selectionIsExpanded: ->
64
+ not @selectionIsCollapsed()
65
+
66
+ # Private
67
+
68
+ @proxyMethod "locationMapper.findLocationFromContainerAndOffset"
69
+ @proxyMethod "locationMapper.findContainerAndOffsetFromLocation"
70
+ @proxyMethod "locationMapper.findNodeAndOffsetFromLocation"
71
+ @proxyMethod "pointMapper.createDOMRangeFromPoint"
72
+ @proxyMethod "pointMapper.getClientRectsForDOMRange"
73
+
74
+ didMouseDown: =>
75
+ @pauseTemporarily()
76
+
77
+ pauseTemporarily: ->
78
+ @paused = true
79
+
80
+ resume = =>
81
+ @paused = false
82
+ clearTimeout(resumeTimeout)
83
+ for handler in resumeHandlers
84
+ handler.destroy()
85
+ if elementContainsNode(document, @element)
86
+ @selectionDidChange()
87
+
88
+ resumeTimeout = setTimeout(resume, 200)
89
+ resumeHandlers = for eventName in ["mousemove", "keydown"]
90
+ handleEvent(eventName, onElement: document, withCallback: resume)
91
+
92
+ selectionDidChange: =>
93
+ unless @paused or innerElementIsActive(@element)
94
+ @updateCurrentLocationRange()
95
+
96
+ updateCurrentLocationRange: (locationRange) ->
97
+ if locationRange ?= @createLocationRangeFromDOMRange(getDOMRange())
98
+ if not rangesAreEqual(locationRange, @currentLocationRange)
99
+ @currentLocationRange = locationRange
100
+ @delegate?.locationRangeDidChange?(@currentLocationRange.slice(0))
101
+
102
+ createDOMRangeFromLocationRange: (locationRange) ->
103
+ rangeStart = @findContainerAndOffsetFromLocation(locationRange[0])
104
+ rangeEnd = if rangeIsCollapsed(locationRange)
105
+ rangeStart
106
+ else
107
+ @findContainerAndOffsetFromLocation(locationRange[1]) ? rangeStart
108
+
109
+ if rangeStart? and rangeEnd?
110
+ domRange = document.createRange()
111
+ domRange.setStart(rangeStart...)
112
+ domRange.setEnd(rangeEnd...)
113
+ domRange
114
+
115
+ createLocationRangeFromDOMRange: (domRange, options) ->
116
+ return unless domRange? and @domRangeWithinElement(domRange)
117
+ return unless start = @findLocationFromContainerAndOffset(domRange.startContainer, domRange.startOffset, options)
118
+ end = @findLocationFromContainerAndOffset(domRange.endContainer, domRange.endOffset, options) unless domRange.collapsed
119
+ normalizeRange([start, end])
120
+
121
+ getLocationAtPoint: (point) ->
122
+ if domRange = @createDOMRangeFromPoint(point)
123
+ @createLocationRangeFromDOMRange(domRange)?[0]
124
+
125
+ domRangeWithinElement: (domRange) ->
126
+ if domRange.collapsed
127
+ elementContainsNode(@element, domRange.startContainer)
128
+ else
129
+ elementContainsNode(@element, domRange.startContainer) and elementContainsNode(@element, domRange.endContainer)