glebtv-ckeditor 4.5.10.3 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ckeditor/config.js.erb +1 -1
  3. data/lib/ckeditor.rb +1 -0
  4. data/lib/ckeditor/version.rb +2 -2
  5. data/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb +1 -1
  6. data/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb +1 -1
  7. data/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb +1 -1
  8. data/lib/generators/ckeditor/templates/active_record/refile/migration.rb +1 -1
  9. data/vendor/assets/javascripts/ckeditor/LICENSE.md +2 -2
  10. data/vendor/assets/javascripts/ckeditor/adapters/jquery.js +1 -1
  11. data/vendor/assets/javascripts/ckeditor/build-config.js +26 -26
  12. data/vendor/assets/javascripts/ckeditor/ckeditor.js +605 -576
  13. data/vendor/assets/javascripts/ckeditor/lang/en.js +2 -2
  14. data/vendor/assets/javascripts/ckeditor/lang/ru.js +2 -2
  15. data/vendor/assets/javascripts/ckeditor/plugins/CKCss/css/styles.css +9 -0
  16. data/vendor/assets/javascripts/ckeditor/plugins/CKCss/dialogs/ckcss.js +2 -1
  17. data/vendor/assets/javascripts/ckeditor/plugins/CKCss/plugin.js +3 -1
  18. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +6 -6
  19. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/en.js +3 -4
  20. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ru.js +4 -4
  21. data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +4 -3
  22. data/vendor/assets/javascripts/ckeditor/plugins/clipboard/dialogs/paste.js +1 -1
  23. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/LICENSE.md +21 -0
  24. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.ckeditor.css +183 -0
  25. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.css +341 -0
  26. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.min.css +1 -1
  27. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/comment/comment.js +206 -0
  28. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/comment/continuecomment.js +85 -0
  29. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/dialog/dialog.css +32 -0
  30. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/dialog/dialog.js +157 -0
  31. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/closebrackets.js +202 -0
  32. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/closetag.js +169 -0
  33. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/continuelist.js +51 -0
  34. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/matchbrackets.js +122 -0
  35. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/matchtags.js +66 -0
  36. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/trailingspace.js +27 -0
  37. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js +105 -0
  38. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/comment-fold.js +59 -0
  39. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/foldcode.js +150 -0
  40. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/foldgutter.css +20 -0
  41. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/foldgutter.js +146 -0
  42. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/indent-fold.js +44 -0
  43. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/markdown-fold.js +49 -0
  44. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/xml-fold.js +182 -0
  45. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/format/autoFormatAll.js +43 -0
  46. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/format/formatting.js +226 -0
  47. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/anyword-hint.js +41 -0
  48. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/css-hint.js +60 -0
  49. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/html-hint.js +348 -0
  50. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/javascript-hint.js +155 -0
  51. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/show-hint.css +36 -0
  52. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/show-hint.js +438 -0
  53. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/sql-hint.js +271 -0
  54. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/xml-hint.js +110 -0
  55. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/loadmode.js +64 -0
  56. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/multiplex.js +123 -0
  57. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/multiplex_test.js +33 -0
  58. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/overlay.js +85 -0
  59. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/simple.js +213 -0
  60. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/jump-to-line.js +49 -0
  61. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/match-highlighter.js +165 -0
  62. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/matchesonscrollbar.css +8 -0
  63. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/matchesonscrollbar.js +97 -0
  64. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/search.js +252 -0
  65. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/searchcursor.js +189 -0
  66. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/active-line.js +74 -0
  67. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/mark-selection.js +118 -0
  68. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/selection-pointer.js +98 -0
  69. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/beautify-html.js +952 -0
  70. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/beautify.js +2087 -0
  71. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.min.js +1 -1
  72. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.search.min.js +1 -1
  73. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.js +9109 -0
  74. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.min.js +1 -1
  75. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.htmlmixed.min.js +1 -1
  76. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.javascript.min.js +1 -1
  77. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.php.min.js +1 -1
  78. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcode/bbcode.js +137 -0
  79. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcode/index.html +73 -0
  80. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcodemixed/bbcodemixed.js +161 -0
  81. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcodemixed/index.html +128 -0
  82. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/clike.js +785 -0
  83. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/index.html +360 -0
  84. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/scala.html +767 -0
  85. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/test.js +55 -0
  86. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/css.js +825 -0
  87. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/gss.html +103 -0
  88. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/gss_test.js +17 -0
  89. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/index.html +75 -0
  90. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/less.html +152 -0
  91. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/less_test.js +54 -0
  92. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/scss.html +157 -0
  93. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/scss_test.js +110 -0
  94. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/test.js +200 -0
  95. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlembedded/htmlembedded.js +28 -0
  96. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlembedded/index.html +60 -0
  97. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlmixed/htmlmixed.js +152 -0
  98. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlmixed/index.html +89 -0
  99. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/index.html +114 -0
  100. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/javascript.js +784 -0
  101. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/json-ld.html +72 -0
  102. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/test.js +247 -0
  103. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/typescript.html +61 -0
  104. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/php/index.html +64 -0
  105. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/php/php.js +234 -0
  106. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/php/test.js +154 -0
  107. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/xml/index.html +61 -0
  108. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/xml/test.js +51 -0
  109. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/xml/xml.js +394 -0
  110. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/plugin.js +30 -24
  111. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/dracula.css +1 -1
  112. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/duotone-dark.css +35 -0
  113. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/duotone-light.css +36 -0
  114. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/panda-syntax.css +85 -0
  115. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/pastel-on-dark.css +0 -1
  116. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/solarized.css +21 -15
  117. data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.css +1 -1
  118. data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.js +1 -1
  119. data/vendor/assets/javascripts/ckeditor/plugins/dialog/dialogDefinition.js +1 -1
  120. data/vendor/assets/javascripts/ckeditor/plugins/find/dialogs/find.js +9 -9
  121. data/vendor/assets/javascripts/ckeditor/plugins/flash/dialogs/flash.js +12 -12
  122. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/button.js +1 -1
  123. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/checkbox.js +1 -1
  124. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/form.js +1 -1
  125. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/hiddenfield.js +1 -1
  126. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/radio.js +1 -1
  127. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/select.js +11 -11
  128. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textarea.js +1 -1
  129. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textfield.js +1 -1
  130. data/vendor/assets/javascripts/ckeditor/plugins/icons.png +0 -0
  131. data/vendor/assets/javascripts/ckeditor/plugins/icons_hidpi.png +0 -0
  132. data/vendor/assets/javascripts/ckeditor/plugins/iframe/dialogs/iframe.js +1 -1
  133. data/vendor/assets/javascripts/ckeditor/plugins/iframedialog/plugin.js +1 -1
  134. data/vendor/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +28 -28
  135. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/LICENSE +0 -0
  136. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/README.md +0 -0
  137. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/LANG.js +3 -0
  138. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/en.js +0 -0
  139. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/ru.js +3 -3
  140. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/plugin.js +1 -1
  141. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/readme.txt +0 -0
  142. data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/anchor.js +1 -1
  143. data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/link.js +25 -23
  144. data/vendor/assets/javascripts/ckeditor/plugins/link/images/anchor.png +0 -0
  145. data/vendor/assets/javascripts/ckeditor/plugins/link/images/hidpi/anchor.png +0 -0
  146. data/vendor/assets/javascripts/ckeditor/plugins/liststyle/dialogs/liststyle.js +1 -1
  147. data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/en.js +1 -1
  148. data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/ru.js +1 -1
  149. data/vendor/assets/javascripts/ckeditor/plugins/notification/plugin.js +2 -2
  150. data/vendor/assets/javascripts/ckeditor/plugins/pastefromword/filter/default.js +40 -29
  151. data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +19 -19
  152. data/vendor/assets/javascripts/ckeditor/plugins/scayt/skins/moono-lisa/scayt.css +20 -0
  153. data/vendor/assets/javascripts/ckeditor/plugins/smiley/dialogs/smiley.js +1 -1
  154. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/en.js +2 -2
  155. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ru.js +1 -1
  156. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/specialchar.js +1 -1
  157. data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/plugin.js +1 -1
  158. data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/assets/sample.css +70 -0
  159. data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/stylesheetparser.html +85 -0
  160. data/vendor/assets/javascripts/ckeditor/plugins/table/dialogs/table.js +1 -1
  161. data/vendor/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +1 -1
  162. data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.css +1 -1
  163. data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.js +1 -1
  164. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/default.js +2 -2
  165. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template1.gif +0 -0
  166. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template2.gif +0 -0
  167. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template3.gif +0 -0
  168. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/css/wordcount.css +0 -0
  169. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/en.js +1 -1
  170. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/ru.js +1 -1
  171. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/plugin.js +60 -13
  172. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/samples/wordcount.html +61 -0
  173. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/samples/wordcountWithMaxCount.html +110 -0
  174. data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +9 -9
  175. data/vendor/assets/javascripts/ckeditor/plugins/wsc/skins/moono-lisa/wsc.css +43 -0
  176. data/vendor/assets/javascripts/ckeditor/plugins/youtube/LICENSE.md +15 -0
  177. data/vendor/assets/javascripts/ckeditor/plugins/youtube/images/icon.png +0 -0
  178. data/vendor/assets/javascripts/ckeditor/plugins/youtube/lang/en.js +3 -1
  179. data/vendor/assets/javascripts/ckeditor/plugins/youtube/lang/ru.js +1 -0
  180. data/vendor/assets/javascripts/ckeditor/plugins/youtube/plugin.js +448 -388
  181. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons16.png +0 -0
  182. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons16.svg +175 -0
  183. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons32.png +0 -0
  184. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons32.svg +167 -0
  185. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/locations.json +145 -0
  186. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog.css +5 -0
  187. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie.css +5 -0
  188. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie8.css +5 -0
  189. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_iequirks.css +5 -0
  190. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor.css +5 -0
  191. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_gecko.css +5 -0
  192. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie.css +5 -0
  193. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie8.css +5 -0
  194. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_iequirks.css +5 -0
  195. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/arrow.png +0 -0
  196. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/close.png +0 -0
  197. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/close.png +0 -0
  198. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/lock-open.png +0 -0
  199. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/lock.png +0 -0
  200. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/refresh.png +0 -0
  201. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/lock-open.png +0 -0
  202. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/lock.png +0 -0
  203. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/refresh.png +0 -0
  204. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/spinner.gif +0 -0
  205. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/readme.md +46 -0
  206. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/skin.js +7 -0
  207. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog.css +1 -1
  208. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie.css +1 -1
  209. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie7.css +1 -1
  210. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie8.css +1 -1
  211. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_iequirks.css +1 -1
  212. data/vendor/assets/javascripts/ckeditor/skins/moono/editor.css +2 -2
  213. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_gecko.css +2 -2
  214. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie.css +2 -2
  215. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie7.css +2 -2
  216. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie8.css +2 -2
  217. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_iequirks.css +2 -2
  218. data/vendor/assets/javascripts/ckeditor/skins/moono/icons.png +0 -0
  219. data/vendor/assets/javascripts/ckeditor/skins/moono/icons_hidpi.png +0 -0
  220. data/vendor/assets/javascripts/ckeditor/skins/moono/images/anchor.png +0 -0
  221. data/vendor/assets/javascripts/ckeditor/skins/moono/images/close.png +0 -0
  222. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/anchor.png +0 -0
  223. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/close.png +0 -0
  224. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
  225. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
  226. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
  227. data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock-open.png +0 -0
  228. data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock.png +0 -0
  229. data/vendor/assets/javascripts/ckeditor/skins/moono/images/refresh.png +0 -0
  230. data/vendor/assets/javascripts/ckeditor/skins/moono/readme.md +3 -3
  231. data/vendor/assets/javascripts/ckeditor/styles.js +42 -16
  232. metadata +161 -105
  233. data/app/assets/javascripts/ckeditor/config_orig.js +0 -58
  234. data/vendor/assets/javascripts/ckeditor/README.md +0 -39
  235. data/vendor/assets/javascripts/ckeditor/config.js +0 -10
  236. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/af.js +0 -12
  237. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ar.js +0 -12
  238. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bg.js +0 -12
  239. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bn.js +0 -12
  240. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bs.js +0 -12
  241. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ca.js +0 -12
  242. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/cs.js +0 -12
  243. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/cy.js +0 -12
  244. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/da.js +0 -12
  245. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/de.js +0 -12
  246. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/el.js +0 -12
  247. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-au.js +0 -12
  248. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-ca.js +0 -12
  249. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-gb.js +0 -12
  250. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/eo.js +0 -12
  251. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/es.js +0 -12
  252. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/et.js +0 -12
  253. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/eu.js +0 -12
  254. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fa.js +0 -12
  255. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fi.js +0 -12
  256. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fo.js +0 -12
  257. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fr-ca.js +0 -12
  258. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fr.js +0 -12
  259. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/gl.js +0 -12
  260. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/gu.js +0 -12
  261. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/he.js +0 -12
  262. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hi.js +0 -12
  263. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hr.js +0 -12
  264. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hu.js +0 -12
  265. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/is.js +0 -12
  266. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/it.js +0 -12
  267. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ja.js +0 -12
  268. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ka.js +0 -12
  269. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/km.js +0 -12
  270. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ko.js +0 -12
  271. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ku.js +0 -12
  272. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/lt.js +0 -12
  273. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/lv.js +0 -12
  274. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/mk.js +0 -12
  275. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/mn.js +0 -12
  276. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ms.js +0 -12
  277. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/nb.js +0 -12
  278. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/nl.js +0 -12
  279. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/no.js +0 -12
  280. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pl.js +0 -12
  281. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pt-br.js +0 -12
  282. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pt.js +0 -12
  283. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ro.js +0 -12
  284. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sk.js +0 -12
  285. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sl.js +0 -12
  286. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sr-latn.js +0 -12
  287. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sr.js +0 -12
  288. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sv.js +0 -12
  289. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/th.js +0 -12
  290. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/tr.js +0 -12
  291. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ug.js +0 -12
  292. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/uk.js +0 -12
  293. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/vi.js +0 -12
  294. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/zh-cn.js +0 -12
  295. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/zh.js +0 -12
@@ -0,0 +1,33 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function() {
5
+ CodeMirror.defineMode("markdown_with_stex", function(){
6
+ var inner = CodeMirror.getMode({}, "stex");
7
+ var outer = CodeMirror.getMode({}, "markdown");
8
+
9
+ var innerOptions = {
10
+ open: '$',
11
+ close: '$',
12
+ mode: inner,
13
+ delimStyle: 'delim',
14
+ innerStyle: 'inner'
15
+ };
16
+
17
+ return CodeMirror.multiplexingMode(outer, innerOptions);
18
+ });
19
+
20
+ var mode = CodeMirror.getMode({}, "markdown_with_stex");
21
+
22
+ function MT(name) {
23
+ test.mode(
24
+ name,
25
+ mode,
26
+ Array.prototype.slice.call(arguments, 1),
27
+ 'multiplexing');
28
+ }
29
+
30
+ MT(
31
+ "stexInsideMarkdown",
32
+ "[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]");
33
+ })();
@@ -0,0 +1,85 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Utility function that allows modes to be combined. The mode given
5
+ // as the base argument takes care of most of the normal mode
6
+ // functionality, but a second (typically simple) mode is used, which
7
+ // can override the style of text. Both modes get to parse all of the
8
+ // text, but when both assign a non-null style to a piece of code, the
9
+ // overlay wins, unless the combine argument was true and not overridden,
10
+ // or state.overlay.combineTokens was true, in which case the styles are
11
+ // combined.
12
+
13
+ (function(mod) {
14
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
15
+ mod(require("../../lib/codemirror"));
16
+ else if (typeof define == "function" && define.amd) // AMD
17
+ define(["../../lib/codemirror"], mod);
18
+ else // Plain browser env
19
+ mod(CodeMirror);
20
+ })(function(CodeMirror) {
21
+ "use strict";
22
+
23
+ CodeMirror.overlayMode = function(base, overlay, combine) {
24
+ return {
25
+ startState: function() {
26
+ return {
27
+ base: CodeMirror.startState(base),
28
+ overlay: CodeMirror.startState(overlay),
29
+ basePos: 0, baseCur: null,
30
+ overlayPos: 0, overlayCur: null,
31
+ streamSeen: null
32
+ };
33
+ },
34
+ copyState: function(state) {
35
+ return {
36
+ base: CodeMirror.copyState(base, state.base),
37
+ overlay: CodeMirror.copyState(overlay, state.overlay),
38
+ basePos: state.basePos, baseCur: null,
39
+ overlayPos: state.overlayPos, overlayCur: null
40
+ };
41
+ },
42
+
43
+ token: function(stream, state) {
44
+ if (stream != state.streamSeen ||
45
+ Math.min(state.basePos, state.overlayPos) < stream.start) {
46
+ state.streamSeen = stream;
47
+ state.basePos = state.overlayPos = stream.start;
48
+ }
49
+
50
+ if (stream.start == state.basePos) {
51
+ state.baseCur = base.token(stream, state.base);
52
+ state.basePos = stream.pos;
53
+ }
54
+ if (stream.start == state.overlayPos) {
55
+ stream.pos = stream.start;
56
+ state.overlayCur = overlay.token(stream, state.overlay);
57
+ state.overlayPos = stream.pos;
58
+ }
59
+ stream.pos = Math.min(state.basePos, state.overlayPos);
60
+
61
+ // state.overlay.combineTokens always takes precedence over combine,
62
+ // unless set to null
63
+ if (state.overlayCur == null) return state.baseCur;
64
+ else if (state.baseCur != null &&
65
+ state.overlay.combineTokens ||
66
+ combine && state.overlay.combineTokens == null)
67
+ return state.baseCur + " " + state.overlayCur;
68
+ else return state.overlayCur;
69
+ },
70
+
71
+ indent: base.indent && function(state, textAfter) {
72
+ return base.indent(state.base, textAfter);
73
+ },
74
+ electricChars: base.electricChars,
75
+
76
+ innerMode: function(state) { return {state: state.base, mode: base}; },
77
+
78
+ blankLine: function(state) {
79
+ if (base.blankLine) base.blankLine(state.base);
80
+ if (overlay.blankLine) overlay.blankLine(state.overlay);
81
+ }
82
+ };
83
+ };
84
+
85
+ });
@@ -0,0 +1,213 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ CodeMirror.defineSimpleMode = function(name, states) {
15
+ CodeMirror.defineMode(name, function(config) {
16
+ return CodeMirror.simpleMode(config, states);
17
+ });
18
+ };
19
+
20
+ CodeMirror.simpleMode = function(config, states) {
21
+ ensureState(states, "start");
22
+ var states_ = {}, meta = states.meta || {}, hasIndentation = false;
23
+ for (var state in states) if (state != meta && states.hasOwnProperty(state)) {
24
+ var list = states_[state] = [], orig = states[state];
25
+ for (var i = 0; i < orig.length; i++) {
26
+ var data = orig[i];
27
+ list.push(new Rule(data, states));
28
+ if (data.indent || data.dedent) hasIndentation = true;
29
+ }
30
+ }
31
+ var mode = {
32
+ startState: function() {
33
+ return {state: "start", pending: null,
34
+ local: null, localState: null,
35
+ indent: hasIndentation ? [] : null};
36
+ },
37
+ copyState: function(state) {
38
+ var s = {state: state.state, pending: state.pending,
39
+ local: state.local, localState: null,
40
+ indent: state.indent && state.indent.slice(0)};
41
+ if (state.localState)
42
+ s.localState = CodeMirror.copyState(state.local.mode, state.localState);
43
+ if (state.stack)
44
+ s.stack = state.stack.slice(0);
45
+ for (var pers = state.persistentStates; pers; pers = pers.next)
46
+ s.persistentStates = {mode: pers.mode,
47
+ spec: pers.spec,
48
+ state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state),
49
+ next: s.persistentStates};
50
+ return s;
51
+ },
52
+ token: tokenFunction(states_, config),
53
+ innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; },
54
+ indent: indentFunction(states_, meta)
55
+ };
56
+ if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop))
57
+ mode[prop] = meta[prop];
58
+ return mode;
59
+ };
60
+
61
+ function ensureState(states, name) {
62
+ if (!states.hasOwnProperty(name))
63
+ throw new Error("Undefined state " + name + " in simple mode");
64
+ }
65
+
66
+ function toRegex(val, caret) {
67
+ if (!val) return /(?:)/;
68
+ var flags = "";
69
+ if (val instanceof RegExp) {
70
+ if (val.ignoreCase) flags = "i";
71
+ val = val.source;
72
+ } else {
73
+ val = String(val);
74
+ }
75
+ return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
76
+ }
77
+
78
+ function asToken(val) {
79
+ if (!val) return null;
80
+ if (typeof val == "string") return val.replace(/\./g, " ");
81
+ var result = [];
82
+ for (var i = 0; i < val.length; i++)
83
+ result.push(val[i] && val[i].replace(/\./g, " "));
84
+ return result;
85
+ }
86
+
87
+ function Rule(data, states) {
88
+ if (data.next || data.push) ensureState(states, data.next || data.push);
89
+ this.regex = toRegex(data.regex);
90
+ this.token = asToken(data.token);
91
+ this.data = data;
92
+ }
93
+
94
+ function tokenFunction(states, config) {
95
+ return function(stream, state) {
96
+ if (state.pending) {
97
+ var pend = state.pending.shift();
98
+ if (state.pending.length == 0) state.pending = null;
99
+ stream.pos += pend.text.length;
100
+ return pend.token;
101
+ }
102
+
103
+ if (state.local) {
104
+ if (state.local.end && stream.match(state.local.end)) {
105
+ var tok = state.local.endToken || null;
106
+ state.local = state.localState = null;
107
+ return tok;
108
+ } else {
109
+ var tok = state.local.mode.token(stream, state.localState), m;
110
+ if (state.local.endScan && (m = state.local.endScan.exec(stream.current())))
111
+ stream.pos = stream.start + m.index;
112
+ return tok;
113
+ }
114
+ }
115
+
116
+ var curState = states[state.state];
117
+ for (var i = 0; i < curState.length; i++) {
118
+ var rule = curState[i];
119
+ var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
120
+ if (matches) {
121
+ if (rule.data.next) {
122
+ state.state = rule.data.next;
123
+ } else if (rule.data.push) {
124
+ (state.stack || (state.stack = [])).push(state.state);
125
+ state.state = rule.data.push;
126
+ } else if (rule.data.pop && state.stack && state.stack.length) {
127
+ state.state = state.stack.pop();
128
+ }
129
+
130
+ if (rule.data.mode)
131
+ enterLocalMode(config, state, rule.data.mode, rule.token);
132
+ if (rule.data.indent)
133
+ state.indent.push(stream.indentation() + config.indentUnit);
134
+ if (rule.data.dedent)
135
+ state.indent.pop();
136
+ if (matches.length > 2) {
137
+ state.pending = [];
138
+ for (var j = 2; j < matches.length; j++)
139
+ if (matches[j])
140
+ state.pending.push({text: matches[j], token: rule.token[j - 1]});
141
+ stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
142
+ return rule.token[0];
143
+ } else if (rule.token && rule.token.join) {
144
+ return rule.token[0];
145
+ } else {
146
+ return rule.token;
147
+ }
148
+ }
149
+ }
150
+ stream.next();
151
+ return null;
152
+ };
153
+ }
154
+
155
+ function cmp(a, b) {
156
+ if (a === b) return true;
157
+ if (!a || typeof a != "object" || !b || typeof b != "object") return false;
158
+ var props = 0;
159
+ for (var prop in a) if (a.hasOwnProperty(prop)) {
160
+ if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false;
161
+ props++;
162
+ }
163
+ for (var prop in b) if (b.hasOwnProperty(prop)) props--;
164
+ return props == 0;
165
+ }
166
+
167
+ function enterLocalMode(config, state, spec, token) {
168
+ var pers;
169
+ if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next)
170
+ if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p;
171
+ var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec);
172
+ var lState = pers ? pers.state : CodeMirror.startState(mode);
173
+ if (spec.persistent && !pers)
174
+ state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates};
175
+
176
+ state.localState = lState;
177
+ state.local = {mode: mode,
178
+ end: spec.end && toRegex(spec.end),
179
+ endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
180
+ endToken: token && token.join ? token[token.length - 1] : token};
181
+ }
182
+
183
+ function indexOf(val, arr) {
184
+ for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true;
185
+ }
186
+
187
+ function indentFunction(states, meta) {
188
+ return function(state, textAfter, line) {
189
+ if (state.local && state.local.mode.indent)
190
+ return state.local.mode.indent(state.localState, textAfter, line);
191
+ if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
192
+ return CodeMirror.Pass;
193
+
194
+ var pos = state.indent.length - 1, rules = states[state.state];
195
+ scan: for (;;) {
196
+ for (var i = 0; i < rules.length; i++) {
197
+ var rule = rules[i];
198
+ if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
199
+ var m = rule.regex.exec(textAfter);
200
+ if (m && m[0]) {
201
+ pos--;
202
+ if (rule.next || rule.push) rules = states[rule.next || rule.push];
203
+ textAfter = textAfter.slice(m[0].length);
204
+ continue scan;
205
+ }
206
+ }
207
+ }
208
+ break;
209
+ }
210
+ return pos < 0 ? 0 : state.indent[pos];
211
+ };
212
+ }
213
+ });
@@ -0,0 +1,49 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Defines jumpToLine command. Uses dialog.js if present.
5
+
6
+ (function(mod) {
7
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
8
+ mod(require("../../lib/codemirror"), require("../dialog/dialog"));
9
+ else if (typeof define == "function" && define.amd) // AMD
10
+ define(["../../lib/codemirror", "../dialog/dialog"], mod);
11
+ else // Plain browser env
12
+ mod(CodeMirror);
13
+ })(function(CodeMirror) {
14
+ "use strict";
15
+
16
+ function dialog(cm, text, shortText, deflt, f) {
17
+ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
18
+ else f(prompt(shortText, deflt));
19
+ }
20
+
21
+ var jumpDialog =
22
+ 'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>';
23
+
24
+ function interpretLine(cm, string) {
25
+ var num = Number(string)
26
+ if (/^[-+]/.test(string)) return cm.getCursor().line + num
27
+ else return num - 1
28
+ }
29
+
30
+ CodeMirror.commands.jumpToLine = function(cm) {
31
+ var cur = cm.getCursor();
32
+ dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) {
33
+ if (!posStr) return;
34
+
35
+ var match;
36
+ if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
37
+ cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
38
+ } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
39
+ var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
40
+ if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
41
+ cm.setCursor(line - 1, cur.ch);
42
+ } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
43
+ cm.setCursor(interpretLine(cm, match[1]), cur.ch);
44
+ }
45
+ });
46
+ };
47
+
48
+ CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
49
+ });
@@ -0,0 +1,165 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Highlighting text that matches the selection
5
+ //
6
+ // Defines an option highlightSelectionMatches, which, when enabled,
7
+ // will style strings that match the selection throughout the
8
+ // document.
9
+ //
10
+ // The option can be set to true to simply enable it, or to a
11
+ // {minChars, style, wordsOnly, showToken, delay} object to explicitly
12
+ // configure it. minChars is the minimum amount of characters that should be
13
+ // selected for the behavior to occur, and style is the token style to
14
+ // apply to the matches. This will be prefixed by "cm-" to create an
15
+ // actual CSS class name. If wordsOnly is enabled, the matches will be
16
+ // highlighted only if the selected text is a word. showToken, when enabled,
17
+ // will cause the current token to be highlighted when nothing is selected.
18
+ // delay is used to specify how much time to wait, in milliseconds, before
19
+ // highlighting the matches. If annotateScrollbar is enabled, the occurences
20
+ // will be highlighted on the scrollbar via the matchesonscrollbar addon.
21
+
22
+ (function(mod) {
23
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
24
+ mod(require("../../lib/codemirror"), require("./matchesonscrollbar"));
25
+ else if (typeof define == "function" && define.amd) // AMD
26
+ define(["../../lib/codemirror", "./matchesonscrollbar"], mod);
27
+ else // Plain browser env
28
+ mod(CodeMirror);
29
+ })(function(CodeMirror) {
30
+ "use strict";
31
+
32
+ var defaults = {
33
+ style: "matchhighlight",
34
+ minChars: 2,
35
+ delay: 100,
36
+ wordsOnly: false,
37
+ annotateScrollbar: false,
38
+ showToken: false,
39
+ trim: true
40
+ }
41
+
42
+ function State(options) {
43
+ this.options = {}
44
+ for (var name in defaults)
45
+ this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
46
+ this.overlay = this.timeout = null;
47
+ this.matchesonscroll = null;
48
+ this.active = false;
49
+ }
50
+
51
+ CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
52
+ if (old && old != CodeMirror.Init) {
53
+ removeOverlay(cm);
54
+ clearTimeout(cm.state.matchHighlighter.timeout);
55
+ cm.state.matchHighlighter = null;
56
+ cm.off("cursorActivity", cursorActivity);
57
+ cm.off("focus", onFocus)
58
+ }
59
+ if (val) {
60
+ var state = cm.state.matchHighlighter = new State(val);
61
+ if (cm.hasFocus()) {
62
+ state.active = true
63
+ highlightMatches(cm)
64
+ } else {
65
+ cm.on("focus", onFocus)
66
+ }
67
+ cm.on("cursorActivity", cursorActivity);
68
+ }
69
+ });
70
+
71
+ function cursorActivity(cm) {
72
+ var state = cm.state.matchHighlighter;
73
+ if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
74
+ }
75
+
76
+ function onFocus(cm) {
77
+ var state = cm.state.matchHighlighter
78
+ if (!state.active) {
79
+ state.active = true
80
+ scheduleHighlight(cm, state)
81
+ }
82
+ }
83
+
84
+ function scheduleHighlight(cm, state) {
85
+ clearTimeout(state.timeout);
86
+ state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
87
+ }
88
+
89
+ function addOverlay(cm, query, hasBoundary, style) {
90
+ var state = cm.state.matchHighlighter;
91
+ cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
92
+ if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
93
+ var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
94
+ state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
95
+ {className: "CodeMirror-selection-highlight-scrollbar"});
96
+ }
97
+ }
98
+
99
+ function removeOverlay(cm) {
100
+ var state = cm.state.matchHighlighter;
101
+ if (state.overlay) {
102
+ cm.removeOverlay(state.overlay);
103
+ state.overlay = null;
104
+ if (state.matchesonscroll) {
105
+ state.matchesonscroll.clear();
106
+ state.matchesonscroll = null;
107
+ }
108
+ }
109
+ }
110
+
111
+ function highlightMatches(cm) {
112
+ cm.operation(function() {
113
+ var state = cm.state.matchHighlighter;
114
+ removeOverlay(cm);
115
+ if (!cm.somethingSelected() && state.options.showToken) {
116
+ var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
117
+ var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
118
+ while (start && re.test(line.charAt(start - 1))) --start;
119
+ while (end < line.length && re.test(line.charAt(end))) ++end;
120
+ if (start < end)
121
+ addOverlay(cm, line.slice(start, end), re, state.options.style);
122
+ return;
123
+ }
124
+ var from = cm.getCursor("from"), to = cm.getCursor("to");
125
+ if (from.line != to.line) return;
126
+ if (state.options.wordsOnly && !isWord(cm, from, to)) return;
127
+ var selection = cm.getRange(from, to)
128
+ if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "")
129
+ if (selection.length >= state.options.minChars)
130
+ addOverlay(cm, selection, false, state.options.style);
131
+ });
132
+ }
133
+
134
+ function isWord(cm, from, to) {
135
+ var str = cm.getRange(from, to);
136
+ if (str.match(/^\w+$/) !== null) {
137
+ if (from.ch > 0) {
138
+ var pos = {line: from.line, ch: from.ch - 1};
139
+ var chr = cm.getRange(pos, from);
140
+ if (chr.match(/\W/) === null) return false;
141
+ }
142
+ if (to.ch < cm.getLine(from.line).length) {
143
+ var pos = {line: to.line, ch: to.ch + 1};
144
+ var chr = cm.getRange(to, pos);
145
+ if (chr.match(/\W/) === null) return false;
146
+ }
147
+ return true;
148
+ } else return false;
149
+ }
150
+
151
+ function boundariesAround(stream, re) {
152
+ return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) &&
153
+ (stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos)));
154
+ }
155
+
156
+ function makeOverlay(query, hasBoundary, style) {
157
+ return {token: function(stream) {
158
+ if (stream.match(query) &&
159
+ (!hasBoundary || boundariesAround(stream, hasBoundary)))
160
+ return style;
161
+ stream.next();
162
+ stream.skipTo(query.charAt(0)) || stream.skipToEnd();
163
+ }};
164
+ }
165
+ });