glebtv-ckeditor 4.7.3 → 4.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (380) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +13 -12
  3. data/README.md +358 -2
  4. data/Rakefile +17 -17
  5. data/app/assets/javascripts/ckeditor/config.js.erb +3 -3
  6. data/app/controllers/ckeditor/application_controller.rb +3 -0
  7. data/app/controllers/ckeditor/attachment_files_controller.rb +2 -0
  8. data/app/controllers/ckeditor/pictures_controller.rb +2 -0
  9. data/app/helpers/ckeditor/application_helper.rb +2 -0
  10. data/config/locales/bg.ckeditor.yml +9 -0
  11. data/config/locales/cs.ckeditor.yml +9 -0
  12. data/config/locales/da.ckeditor.yml +9 -0
  13. data/config/locales/de.ckeditor.yml +9 -0
  14. data/config/locales/el-GR.cdkeditor.yml +9 -0
  15. data/config/locales/es.ckeditor.yml +9 -0
  16. data/config/locales/fr.ckeditor.yml +9 -0
  17. data/config/locales/hu.ckeditor.yml +9 -0
  18. data/config/locales/it.ckeditor.yml +9 -0
  19. data/config/locales/ja.ckeditor.yml +9 -0
  20. data/config/locales/nb.ckeditor.yml +9 -0
  21. data/config/locales/nl.ckeditor.yml +9 -0
  22. data/config/locales/pl.ckeditor.yml +9 -0
  23. data/config/locales/pt-BR.ckeditor.yml +9 -0
  24. data/config/locales/pt-PT.ckeditor.yml +9 -0
  25. data/config/locales/pt.ckeditor.yml +9 -0
  26. data/config/locales/sq.ckeditor.yml +9 -0
  27. data/config/locales/sv-SE.ckeditor.yml +9 -0
  28. data/config/locales/tr.ckeditor.yml +9 -0
  29. data/config/locales/uk.ckeditor.yml +9 -0
  30. data/config/locales/zh-CN.ckeditor.yml +9 -0
  31. data/config/locales/zh-TW.ckeditor.yml +9 -0
  32. data/config/routes.rb +2 -0
  33. data/lib/ckeditor.rb +13 -16
  34. data/lib/ckeditor/asset_response.rb +15 -4
  35. data/lib/ckeditor/backend/active_storage.rb +68 -0
  36. data/lib/ckeditor/backend/carrierwave.rb +2 -12
  37. data/lib/ckeditor/backend/dragonfly.rb +2 -0
  38. data/lib/ckeditor/backend/paperclip.rb +2 -15
  39. data/lib/ckeditor/backend/shrine.rb +29 -0
  40. data/lib/ckeditor/helpers/controllers.rb +2 -0
  41. data/lib/ckeditor/helpers/form_builder.rb +2 -0
  42. data/lib/ckeditor/helpers/form_helper.rb +2 -0
  43. data/lib/ckeditor/helpers/view_helper.rb +2 -0
  44. data/lib/ckeditor/hooks/cancan.rb +4 -1
  45. data/lib/ckeditor/hooks/formtastic.rb +2 -0
  46. data/lib/ckeditor/hooks/pundit.rb +2 -0
  47. data/lib/ckeditor/hooks/simple_form.rb +2 -0
  48. data/lib/ckeditor/http.rb +8 -5
  49. data/lib/ckeditor/orm/active_record.rb +2 -0
  50. data/lib/ckeditor/orm/base.rb +11 -2
  51. data/lib/ckeditor/orm/mongoid.rb +2 -0
  52. data/lib/ckeditor/paginatable.rb +2 -0
  53. data/lib/ckeditor/rails.rb +2 -0
  54. data/lib/ckeditor/rails_admin/field.rb +16 -3
  55. data/lib/ckeditor/text_area.rb +2 -0
  56. data/lib/ckeditor/utils.rb +3 -16
  57. data/lib/ckeditor/utils/javascript_code.rb +1 -1
  58. data/lib/ckeditor/version.rb +4 -2
  59. data/lib/generators/ckeditor/install_generator.rb +16 -19
  60. data/lib/generators/ckeditor/pundit_policy_generator.rb +2 -0
  61. data/lib/generators/ckeditor/templates/active_record/active_storage/ckeditor/asset.rb +10 -0
  62. data/lib/generators/ckeditor/templates/active_record/{refile → active_storage}/ckeditor/attachment_file.rb +3 -1
  63. data/lib/generators/ckeditor/templates/active_record/active_storage/ckeditor/picture.rb +13 -0
  64. data/lib/generators/ckeditor/templates/active_record/{carrierwave/migration_versioned.rb → active_storage/migration.rb} +8 -5
  65. data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/asset.rb +2 -0
  66. data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/attachment_file.rb +2 -0
  67. data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/picture.rb +2 -0
  68. data/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb +7 -5
  69. data/lib/generators/ckeditor/templates/active_record/dragonfly/ckeditor/asset.rb +2 -0
  70. data/lib/generators/ckeditor/templates/active_record/dragonfly/ckeditor/attachment_file.rb +2 -0
  71. data/lib/generators/ckeditor/templates/active_record/dragonfly/ckeditor/picture.rb +2 -0
  72. data/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb +7 -5
  73. data/lib/generators/ckeditor/templates/active_record/paperclip/ckeditor/asset.rb +2 -0
  74. data/lib/generators/ckeditor/templates/active_record/paperclip/ckeditor/attachment_file.rb +2 -0
  75. data/lib/generators/ckeditor/templates/active_record/paperclip/ckeditor/picture.rb +2 -0
  76. data/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb +8 -6
  77. data/lib/generators/ckeditor/templates/active_record/{refile → shrine}/ckeditor/asset.rb +3 -1
  78. data/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/attachment_file.rb +21 -0
  79. data/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb +49 -0
  80. data/lib/generators/ckeditor/templates/active_record/shrine/migration.rb +22 -0
  81. data/lib/generators/ckeditor/templates/base/carrierwave/uploaders/ckeditor_attachment_file_uploader.rb +2 -1
  82. data/lib/generators/ckeditor/templates/base/carrierwave/uploaders/ckeditor_picture_uploader.rb +2 -3
  83. data/lib/generators/ckeditor/templates/base/dragonfly/initializer.rb +2 -0
  84. data/lib/generators/ckeditor/templates/base/shrine/initializer.rb +25 -0
  85. data/lib/generators/ckeditor/templates/ckeditor.rb +3 -6
  86. data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/asset.rb +2 -0
  87. data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/attachment_file.rb +2 -0
  88. data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/picture.rb +2 -0
  89. data/lib/generators/ckeditor/templates/mongoid/paperclip/ckeditor/asset.rb +2 -0
  90. data/lib/generators/ckeditor/templates/mongoid/paperclip/ckeditor/attachment_file.rb +2 -0
  91. data/lib/generators/ckeditor/templates/mongoid/paperclip/ckeditor/picture.rb +2 -0
  92. data/lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/asset.rb +8 -0
  93. data/lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/attachment_file.rb +21 -0
  94. data/lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/picture.rb +47 -0
  95. data/lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb +2 -0
  96. data/lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb +2 -0
  97. data/lib/tasks/ckeditor.rake +2 -0
  98. data/test/controllers/attachment_files_controller_test.rb +17 -15
  99. data/test/controllers/pictures_controller_test.rb +17 -15
  100. data/test/dummy/Rakefile +2 -0
  101. data/test/dummy/app/assets/javascripts/application.js +0 -2
  102. data/test/dummy/app/controllers/application_controller.rb +2 -0
  103. data/test/dummy/app/controllers/posts_controller.rb +2 -0
  104. data/test/dummy/app/helpers/application_helper.rb +2 -0
  105. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  106. data/test/dummy/app/models/post.rb +2 -0
  107. data/test/dummy/app/views/posts/index.html.erb +0 -3
  108. data/test/dummy/app/views/posts/show.html.erb +3 -0
  109. data/test/dummy/config.ru +2 -0
  110. data/test/dummy/config/application.rb +5 -1
  111. data/test/dummy/config/boot.rb +2 -0
  112. data/test/dummy/config/environment.rb +2 -0
  113. data/test/dummy/config/environments/development.rb +2 -0
  114. data/test/dummy/config/environments/production.rb +2 -0
  115. data/test/dummy/config/environments/test.rb +5 -3
  116. data/test/dummy/config/initializers/assets.rb +2 -0
  117. data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
  118. data/test/dummy/config/initializers/ckeditor.rb +2 -0
  119. data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
  120. data/test/dummy/config/initializers/inflections.rb +2 -0
  121. data/test/dummy/config/initializers/mime_types.rb +2 -0
  122. data/test/dummy/config/initializers/paperclip.rb +2 -0
  123. data/test/dummy/config/initializers/session_store.rb +2 -0
  124. data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
  125. data/test/dummy/config/routes.rb +2 -0
  126. data/test/dummy/config/storage.yml +3 -0
  127. data/test/dummy/db/migrate/20110623120047_create_posts.rb +5 -3
  128. data/test/dummy/db/migrate/20170806125915_create_active_storage_tables.rb +26 -0
  129. data/test/dummy/script/rails +2 -0
  130. data/test/functional/posts_controller_test.rb +18 -16
  131. data/test/generators/install_generator_test.rb +58 -56
  132. data/test/integration/navigation_test.rb +2 -0
  133. data/test/models/attachment_file_test.rb +4 -4
  134. data/test/models/ckeditor_test.rb +3 -21
  135. data/test/models/picture_test.rb +12 -10
  136. data/test/models/utils_test.rb +2 -0
  137. data/test/orm/active_record.rb +11 -1
  138. data/test/orm/mongoid.rb +2 -0
  139. data/test/support/helpers.rb +2 -0
  140. data/test/support/integration_case.rb +2 -0
  141. data/test/test_helper.rb +15 -9
  142. data/vendor/assets/javascripts/ckeditor/CHANGES.md +1404 -859
  143. data/vendor/assets/javascripts/ckeditor/LICENSE.md +8 -7
  144. data/vendor/assets/javascripts/ckeditor/README.md +5 -5
  145. data/vendor/assets/javascripts/ckeditor/adapters/jquery.js +7 -7
  146. data/vendor/assets/javascripts/ckeditor/build-config.js +12 -6
  147. data/vendor/assets/javascripts/ckeditor/ckeditor.js +1090 -907
  148. data/vendor/assets/javascripts/ckeditor/config.js +2 -2
  149. data/vendor/assets/javascripts/ckeditor/contents.css +7 -7
  150. data/vendor/assets/javascripts/ckeditor/lang/en.js +3 -3
  151. data/vendor/assets/javascripts/ckeditor/lang/ru.js +3 -3
  152. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +7 -7
  153. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/en.js +2 -2
  154. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ru.js +3 -3
  155. data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +5 -5
  156. data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/hidpi/logo_ckeditor.png +0 -0
  157. data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/logo_ckeditor.png +0 -0
  158. data/vendor/assets/javascripts/ckeditor/plugins/clipboard/dialogs/paste.js +11 -0
  159. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.min.css +1 -1
  160. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/autoformat.png +0 -0
  161. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/searchcode.png +0 -0
  162. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/uncommentselectedrange.png +0 -0
  163. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/autocomplete.png +0 -0
  164. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/autoformat.png +0 -0
  165. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/commentselectedrange.png +0 -0
  166. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/searchcode.png +0 -0
  167. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/uncommentselectedrange.png +0 -0
  168. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/beautify.min.js +2 -2
  169. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.min.js +2 -2
  170. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.search.min.js +1 -1
  171. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.min.js +1 -6
  172. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.bbcodemixed.min.js +1 -1
  173. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.handlebars.min.js +1 -0
  174. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.htmlmixed.min.js +2 -2
  175. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.javascript.min.js +1 -1
  176. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.php.min.js +3 -3
  177. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.twig.min.js +1 -1
  178. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/plugin.js +236 -218
  179. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/base16-light.css +1 -1
  180. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/darcula.css +51 -0
  181. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/gruvbox-dark.css +37 -0
  182. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/idea.css +42 -0
  183. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/lesser-dark.css +2 -2
  184. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/lucario.css +37 -0
  185. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/monokai.css +5 -0
  186. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/nord.css +42 -0
  187. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/oceanic-next.css +44 -0
  188. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/panda-syntax.css +1 -1
  189. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/shadowfox.css +52 -0
  190. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/solarized.css +0 -1
  191. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/ssms.css +16 -0
  192. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/vibrant-ink.css +1 -1
  193. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/yonce.css +59 -0
  194. data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.css +2 -2
  195. data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.js +12 -12
  196. data/vendor/assets/javascripts/ckeditor/plugins/dialog/dialogDefinition.js +2 -2
  197. data/vendor/assets/javascripts/ckeditor/plugins/dialog/styles/dialog.css +18 -0
  198. data/vendor/assets/javascripts/ckeditor/plugins/div/dialogs/div.js +9 -8
  199. data/vendor/assets/javascripts/ckeditor/plugins/find/dialogs/find.js +23 -23
  200. data/vendor/assets/javascripts/ckeditor/plugins/flash/dialogs/flash.js +17 -17
  201. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/button.js +6 -6
  202. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/checkbox.js +5 -5
  203. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/form.js +3 -3
  204. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/hiddenfield.js +5 -5
  205. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/radio.js +7 -7
  206. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/select.js +17 -16
  207. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textarea.js +7 -6
  208. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textfield.js +9 -9
  209. data/vendor/assets/javascripts/ckeditor/plugins/icons.png +0 -0
  210. data/vendor/assets/javascripts/ckeditor/plugins/icons_hidpi.png +0 -0
  211. data/vendor/assets/javascripts/ckeditor/plugins/iframe/dialogs/iframe.js +9 -8
  212. data/vendor/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +1271 -44
  213. data/vendor/assets/javascripts/ckeditor/plugins/image/icons/hidpi/image.png +0 -0
  214. data/vendor/assets/javascripts/ckeditor/plugins/image/icons/image.png +0 -0
  215. data/vendor/assets/javascripts/ckeditor/plugins/image/lang/en.js +25 -0
  216. data/vendor/assets/javascripts/ckeditor/plugins/image/lang/ru.js +25 -0
  217. data/vendor/assets/javascripts/ckeditor/plugins/image/plugin.js +184 -0
  218. data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/assets/image1.jpg +0 -0
  219. data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/assets/image2.jpg +0 -0
  220. data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/contents.css +35 -0
  221. data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/image2.html +339 -0
  222. data/vendor/assets/javascripts/ckeditor/plugins/image2/dialogs/image2.js +553 -0
  223. data/vendor/assets/javascripts/ckeditor/plugins/image2/icons/hidpi/image.png +0 -0
  224. data/vendor/assets/javascripts/ckeditor/plugins/image2/icons/image.png +0 -0
  225. data/vendor/assets/javascripts/ckeditor/plugins/image2/lang/en.js +21 -0
  226. data/vendor/assets/javascripts/ckeditor/plugins/image2/lang/ru.js +21 -0
  227. data/vendor/assets/javascripts/ckeditor/plugins/image2/plugin.js +1783 -0
  228. data/vendor/assets/javascripts/ckeditor/plugins/image2/samples/assets/image1.jpg +0 -0
  229. data/vendor/assets/javascripts/ckeditor/plugins/image2/samples/assets/image2.jpg +0 -0
  230. data/vendor/assets/javascripts/ckeditor/plugins/image2/samples/image2.html +69 -0
  231. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/plugin.js +1 -1
  232. data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/anchor.js +5 -5
  233. data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/link.js +27 -25
  234. data/vendor/assets/javascripts/ckeditor/plugins/liststyle/dialogs/liststyle.js +8 -8
  235. data/vendor/assets/javascripts/ckeditor/plugins/loremipsum/lang/fr.js +8 -0
  236. data/vendor/assets/javascripts/ckeditor/plugins/loremipsum/plugin.js +2 -2
  237. data/vendor/assets/javascripts/ckeditor/plugins/pastefromword/filter/default.js +41 -51
  238. data/vendor/assets/javascripts/ckeditor/plugins/pastetools/filter/common.js +22 -0
  239. data/vendor/assets/javascripts/ckeditor/plugins/pastetools/filter/image.js +6 -0
  240. data/vendor/assets/javascripts/ckeditor/plugins/preview/images/pagebreak.gif +0 -0
  241. data/vendor/assets/javascripts/ckeditor/plugins/preview/styles/screen.css +10 -0
  242. data/vendor/assets/javascripts/ckeditor/plugins/scayt/CHANGELOG.md +1 -17
  243. data/vendor/assets/javascripts/ckeditor/plugins/scayt/README.md +63 -7
  244. data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +32 -33
  245. data/vendor/assets/javascripts/ckeditor/plugins/smiley/dialogs/smiley.js +2 -2
  246. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/en.js +2 -2
  247. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ru.js +2 -2
  248. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/specialchar.js +12 -12
  249. data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/plugin.js +10 -10
  250. data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/stylesheetparser.html +8 -7
  251. data/vendor/assets/javascripts/ckeditor/plugins/table/dialogs/table.js +20 -19
  252. data/vendor/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +16 -15
  253. data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.css +2 -2
  254. data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.js +2 -2
  255. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/default.js +2 -2
  256. data/vendor/assets/javascripts/ckeditor/plugins/widget/images/handle.png +0 -0
  257. data/vendor/assets/javascripts/ckeditor/{samples/toolbarconfigurator/lib/codemirror/LICENSE → plugins/wordcount/LICENSE.md} +21 -19
  258. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/README.md +106 -0
  259. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/en.js +1 -0
  260. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/ru.js +2 -1
  261. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/plugin.js +475 -378
  262. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/samples/maxParagraphs.html +26 -0
  263. data/vendor/assets/javascripts/ckeditor/plugins/wsc/README.md +62 -7
  264. data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/tmpFrameset.html +1 -1
  265. data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +82 -82
  266. data/vendor/assets/javascripts/ckeditor/plugins/youtube/LICENSE.md +15 -0
  267. data/vendor/assets/javascripts/ckeditor/plugins/youtube/README.md +156 -0
  268. data/vendor/assets/javascripts/ckeditor/plugins/youtube/plugin.js +8 -7
  269. data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor.css +1 -1
  270. data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_gecko.css +1 -1
  271. data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_ie.css +1 -1
  272. data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_ie7.css +1 -1
  273. data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_ie8.css +1 -1
  274. data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_iequirks.css +1 -1
  275. data/vendor/assets/javascripts/ckeditor/skins/minimalist/icons.png +0 -0
  276. data/vendor/assets/javascripts/ckeditor/skins/minimalist/icons_hidpi.png +0 -0
  277. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog.css +3 -3
  278. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie.css +3 -3
  279. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie8.css +3 -3
  280. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_iequirks.css +3 -3
  281. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor.css +3 -3
  282. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_gecko.css +3 -3
  283. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie.css +3 -3
  284. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie8.css +3 -3
  285. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_iequirks.css +3 -3
  286. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/readme.md +3 -3
  287. data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/skin.js +2 -2
  288. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog.css +3 -3
  289. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie.css +3 -3
  290. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie7.css +3 -3
  291. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie8.css +3 -3
  292. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_iequirks.css +3 -3
  293. data/vendor/assets/javascripts/ckeditor/skins/moono/editor.css +3 -3
  294. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_gecko.css +3 -3
  295. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie.css +3 -3
  296. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie7.css +3 -3
  297. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie8.css +3 -3
  298. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_iequirks.css +3 -3
  299. data/vendor/assets/javascripts/ckeditor/skins/moono/readme.md +5 -5
  300. data/vendor/assets/javascripts/ckeditor/skins/moono/skin.js +2 -2
  301. data/vendor/assets/javascripts/ckeditor/styles.js +4 -4
  302. data/vendor/assets/javascripts/ckeditor/vendor/promise.js +13 -0
  303. metadata +143 -138
  304. data/lib/ckeditor/backend/refile.rb +0 -39
  305. data/lib/ckeditor/utils/content_type_detector.rb +0 -38
  306. data/lib/generators/ckeditor/templates/active_record/dragonfly/migration_versioned.rb +0 -23
  307. data/lib/generators/ckeditor/templates/active_record/paperclip/migration_versioned.rb +0 -23
  308. data/lib/generators/ckeditor/templates/active_record/refile/ckeditor/picture.rb +0 -11
  309. data/lib/generators/ckeditor/templates/active_record/refile/migration.rb +0 -23
  310. data/lib/generators/ckeditor/templates/active_record/refile/migration_versioned.rb +0 -23
  311. data/test/support/raw_post.rb +0 -9
  312. data/vendor/assets/javascripts/ckeditor/plugins/iframedialog/plugin.js +0 -169
  313. data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/ru.js +0 -3
  314. data/vendor/assets/javascripts/ckeditor/plugins/loremipsum/lang/ru.js +0 -8
  315. data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/en.js +0 -7
  316. data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/ru.js +0 -7
  317. data/vendor/assets/javascripts/ckeditor/plugins/notification/plugin.js +0 -929
  318. data/vendor/assets/javascripts/ckeditor/samples/css/samples.css +0 -1632
  319. data/vendor/assets/javascripts/ckeditor/samples/img/github-top.png +0 -0
  320. data/vendor/assets/javascripts/ckeditor/samples/img/header-bg.png +0 -0
  321. data/vendor/assets/javascripts/ckeditor/samples/img/header-separator.png +0 -0
  322. data/vendor/assets/javascripts/ckeditor/samples/img/logo.png +0 -0
  323. data/vendor/assets/javascripts/ckeditor/samples/img/navigation-tip.png +0 -0
  324. data/vendor/assets/javascripts/ckeditor/samples/index.html +0 -128
  325. data/vendor/assets/javascripts/ckeditor/samples/js/sample.js +0 -53
  326. data/vendor/assets/javascripts/ckeditor/samples/js/sf.js +0 -17
  327. data/vendor/assets/javascripts/ckeditor/samples/old/ajax.html +0 -85
  328. data/vendor/assets/javascripts/ckeditor/samples/old/api.html +0 -210
  329. data/vendor/assets/javascripts/ckeditor/samples/old/appendto.html +0 -59
  330. data/vendor/assets/javascripts/ckeditor/samples/old/assets/inlineall/logo.png +0 -0
  331. data/vendor/assets/javascripts/ckeditor/samples/old/assets/outputxhtml/outputxhtml.css +0 -204
  332. data/vendor/assets/javascripts/ckeditor/samples/old/assets/posteddata.php +0 -59
  333. data/vendor/assets/javascripts/ckeditor/samples/old/assets/sample.jpg +0 -0
  334. data/vendor/assets/javascripts/ckeditor/samples/old/assets/uilanguages/languages.js +0 -7
  335. data/vendor/assets/javascripts/ckeditor/samples/old/datafiltering.html +0 -508
  336. data/vendor/assets/javascripts/ckeditor/samples/old/dialog/assets/my_dialog.js +0 -48
  337. data/vendor/assets/javascripts/ckeditor/samples/old/dialog/dialog.html +0 -190
  338. data/vendor/assets/javascripts/ckeditor/samples/old/divreplace.html +0 -144
  339. data/vendor/assets/javascripts/ckeditor/samples/old/enterkey/enterkey.html +0 -106
  340. data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/assets/outputforflash/outputforflash.fla +0 -0
  341. data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/assets/outputforflash/outputforflash.swf +0 -0
  342. data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/assets/outputforflash/swfobject.js +0 -19
  343. data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/outputforflash.html +0 -283
  344. data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/outputhtml.html +0 -224
  345. data/vendor/assets/javascripts/ckeditor/samples/old/index.html +0 -131
  346. data/vendor/assets/javascripts/ckeditor/samples/old/inlineall.html +0 -314
  347. data/vendor/assets/javascripts/ckeditor/samples/old/inlinebycode.html +0 -124
  348. data/vendor/assets/javascripts/ckeditor/samples/old/inlinetextarea.html +0 -113
  349. data/vendor/assets/javascripts/ckeditor/samples/old/jquery.html +0 -103
  350. data/vendor/assets/javascripts/ckeditor/samples/old/magicline/magicline.html +0 -209
  351. data/vendor/assets/javascripts/ckeditor/samples/old/readonly.html +0 -76
  352. data/vendor/assets/javascripts/ckeditor/samples/old/replacebyclass.html +0 -60
  353. data/vendor/assets/javascripts/ckeditor/samples/old/replacebycode.html +0 -59
  354. data/vendor/assets/javascripts/ckeditor/samples/old/sample.css +0 -357
  355. data/vendor/assets/javascripts/ckeditor/samples/old/sample.js +0 -50
  356. data/vendor/assets/javascripts/ckeditor/samples/old/sample_posteddata.php +0 -16
  357. data/vendor/assets/javascripts/ckeditor/samples/old/tabindex.html +0 -78
  358. data/vendor/assets/javascripts/ckeditor/samples/old/toolbar/toolbar.html +0 -235
  359. data/vendor/assets/javascripts/ckeditor/samples/old/uicolor.html +0 -72
  360. data/vendor/assets/javascripts/ckeditor/samples/old/uilanguages.html +0 -122
  361. data/vendor/assets/javascripts/ckeditor/samples/old/wysiwygarea/fullpage.html +0 -80
  362. data/vendor/assets/javascripts/ckeditor/samples/old/xhtmlstyle.html +0 -234
  363. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/css/fontello.css +0 -55
  364. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/LICENSE.txt +0 -10
  365. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/config.json +0 -28
  366. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.eot +0 -0
  367. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.svg +0 -14
  368. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.ttf +0 -0
  369. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.woff +0 -0
  370. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/index.html +0 -446
  371. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/abstracttoolbarmodifier.js +0 -13
  372. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/fulltoolbareditor.js +0 -9
  373. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/toolbarmodifier.js +0 -33
  374. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/toolbartextmodifier.js +0 -14
  375. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/codemirror.css +0 -325
  376. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/codemirror.js +0 -288
  377. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/javascript.js +0 -25
  378. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/neo.css +0 -36
  379. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/show-hint.css +0 -38
  380. data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/show-hint.js +0 -16
@@ -10,6 +10,7 @@ CKEDITOR.plugins.setLang('wordcount', 'en', {
10
10
  CharCountWithHTML: 'Characters (with HTML):',
11
11
  CharCountWithHTMLRemaining: 'Characters (with HTML) remaining',
12
12
  Paragraphs: 'Paragraphs:',
13
+ ParagraphsRemaining: 'Paragraphs remaining',
13
14
  pasteWarning: 'Content cannot be pasted because it is above the allowed limit',
14
15
  Selected: 'Selected: ',
15
16
  title: 'Statistics'
@@ -5,8 +5,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
5
5
  CKEDITOR.plugins.setLang('wordcount', 'ru', {
6
6
  WordCount: 'Слов:',
7
7
  CharCount: 'Символов:',
8
- CharCountWithHTML: ' (включая HTML разметку):',
8
+ CharCountWithHTML: ' (включая HTML-разметку):',
9
9
  Paragraphs: 'Параграфов:',
10
+ ParagraphsRemaining: 'Параграфов осталось',
10
11
  pasteWarning: 'Контент не может быть вставлен, т.к. привышает допустимый лимит',
11
12
  Selected: 'Выделено: ',
12
13
  title: 'Статистика'
@@ -3,195 +3,212 @@
3
3
  * For licensing, see LICENSE.html or http://ckeditor.com/license
4
4
  */
5
5
 
6
- CKEDITOR.plugins.add("wordcount", {
7
- lang: "en,ru", // %REMOVE_LINE_CORE%
8
- version: 1.17,
9
- requires: 'htmlwriter,notification,undo',
10
- bbcodePluginLoaded: false,
11
- onLoad: function(editor) {
12
- CKEDITOR.document.appendStyleSheet(this.path + "css/wordcount.css");
13
- },
14
- init: function (editor) {
15
- var defaultFormat = "",
16
- intervalId,
17
- lastWordCount = -1,
18
- lastCharCount = -1,
19
- limitReachedNotified = false,
20
- limitRestoredNotified = false,
21
- snapShot = editor.getSnapshot(),
22
- notification = null;
23
-
24
-
25
- var dispatchEvent = function (type, currentLength, maxLength) {
26
- if (typeof document.dispatchEvent == 'undefined') {
27
- return;
28
- }
6
+ CKEDITOR.plugins.add("wordcount",
7
+ {
8
+ lang: "ar,bg,ca,cs,da,de,el,en,es,eu,fa,fi,fr,he,hr,hu,it,ko,ja,nl,no,pl,pt,pt-br,ru,sk,sv,tr,uk,zh-cn,zh,ro", // %REMOVE_LINE_CORE%
9
+ version: "1.17.6",
10
+ requires: 'htmlwriter,notification,undo',
11
+ bbcodePluginLoaded: false,
12
+ onLoad: function() {
13
+ CKEDITOR.document.appendStyleSheet(this.path + "css/wordcount.css");
14
+ },
15
+ init: function(editor) {
16
+ var defaultFormat = "",
17
+ lastWordCount = -1,
18
+ lastCharCount = -1,
19
+ lastParagraphs = -1,
20
+ limitReachedNotified = false,
21
+ limitRestoredNotified = false,
22
+ timeoutId = 0,
23
+ notification = null;
24
+
25
+
26
+ var dispatchEvent = function(type, currentLength, maxLength) {
27
+ if (typeof document.dispatchEvent == 'undefined') {
28
+ return;
29
+ }
29
30
 
30
- type = 'ckeditor.wordcount.' + type;
31
+ type = 'ckeditor.wordcount.' + type;
31
32
 
32
- var cEvent;
33
- var eventInitDict = {
34
- bubbles: false,
35
- cancelable: true,
36
- detail: {
37
- currentLength: currentLength,
38
- maxLength: maxLength
33
+ var cEvent;
34
+ var eventInitDict = {
35
+ bubbles: false,
36
+ cancelable: true,
37
+ detail: {
38
+ currentLength: currentLength,
39
+ maxLength: maxLength
40
+ }
41
+ };
42
+
43
+ try {
44
+ cEvent = new CustomEvent(type, eventInitDict);
45
+ } catch (o_O) {
46
+ cEvent = document.createEvent('CustomEvent');
47
+ cEvent.initCustomEvent(
48
+ type,
49
+ eventInitDict.bubbles,
50
+ eventInitDict.cancelable,
51
+ eventInitDict.detail
52
+ );
39
53
  }
54
+
55
+ document.dispatchEvent(cEvent);
40
56
  };
41
57
 
42
- try {
43
- cEvent = new CustomEvent(type, eventInitDict);
44
- } catch (o_O) {
45
- cEvent = document.createEvent('CustomEvent');
46
- cEvent.initCustomEvent(
47
- type,
48
- eventInitDict.bubbles,
49
- eventInitDict.cancelable,
50
- eventInitDict.detail
51
- );
52
- }
58
+ // Default Config
59
+ var defaultConfig = {
60
+ showRemaining: false,
61
+ showParagraphs: true,
62
+ showWordCount: true,
63
+ showCharCount: false,
64
+ countBytesAsChars: false,
65
+ countSpacesAsChars: false,
66
+ countHTML: false,
67
+ countLineBreaks: false,
68
+ hardLimit: true,
69
+ warnOnLimitOnly: false,
70
+
71
+ //MAXLENGTH Properties
72
+ maxWordCount: -1,
73
+ maxCharCount: -1,
74
+ maxParagraphs: -1,
75
+
76
+ // Filter
77
+ filter: null,
78
+
79
+ // How long to show the 'paste' warning
80
+ pasteWarningDuration: 0,
81
+
82
+ //DisAllowed functions
83
+ wordCountGreaterThanMaxLengthEvent: function(currentLength, maxLength) {
84
+ dispatchEvent('wordCountGreaterThanMaxLengthEvent', currentLength, maxLength);
85
+ },
86
+ charCountGreaterThanMaxLengthEvent: function(currentLength, maxLength) {
87
+ dispatchEvent('charCountGreaterThanMaxLengthEvent', currentLength, maxLength);
88
+ },
89
+
90
+ //Allowed Functions
91
+ wordCountLessThanMaxLengthEvent: function(currentLength, maxLength) {
92
+ dispatchEvent('wordCountLessThanMaxLengthEvent', currentLength, maxLength);
93
+ },
94
+ charCountLessThanMaxLengthEvent: function(currentLength, maxLength) {
95
+ dispatchEvent('charCountLessThanMaxLengthEvent', currentLength, maxLength);
96
+ }
97
+ };
53
98
 
54
- document.dispatchEvent(cEvent);
55
- };
56
-
57
- // Default Config
58
- var defaultConfig = {
59
- showRemaining: false,
60
- showParagraphs: true,
61
- showWordCount: true,
62
- showCharCount: false,
63
- countBytesAsChars: false,
64
- countSpacesAsChars: false,
65
- countHTML: false,
66
- countLineBreaks: false,
67
- hardLimit: true,
68
-
69
- //MAXLENGTH Properties
70
- maxWordCount: -1,
71
- maxCharCount: -1,
72
-
73
- // Filter
74
- filter: null,
75
-
76
- // How long to show the 'paste' warning
77
- pasteWarningDuration: 0,
78
-
79
- //DisAllowed functions
80
- wordCountGreaterThanMaxLengthEvent: function (currentLength, maxLength) {
81
- dispatchEvent('wordCountGreaterThanMaxLengthEvent', currentLength, maxLength);
82
- },
83
- charCountGreaterThanMaxLengthEvent: function (currentLength, maxLength) {
84
- dispatchEvent('charCountGreaterThanMaxLengthEvent', currentLength, maxLength);
85
- },
86
-
87
- //Allowed Functions
88
- wordCountLessThanMaxLengthEvent: function (currentLength, maxLength) {
89
- dispatchEvent('wordCountLessThanMaxLengthEvent', currentLength, maxLength);
90
- },
91
- charCountLessThanMaxLengthEvent: function (currentLength, maxLength) {
92
- dispatchEvent('charCountLessThanMaxLengthEvent', currentLength, maxLength);
99
+ // Get Config & Lang
100
+ var config = CKEDITOR.tools.extend(defaultConfig, editor.config.wordcount || {}, true);
101
+
102
+ if (config.showParagraphs) {
103
+ if (config.maxParagraphs > -1) {
104
+ if (config.showRemaining) {
105
+ defaultFormat += "%paragraphsCount% " + editor.lang.wordcount.ParagraphsRemaining;
106
+ } else {
107
+ defaultFormat += editor.lang.wordcount.Paragraphs + " %paragraphsCount%";
108
+
109
+ defaultFormat += "/" + config.maxParagraphs;
110
+ }
111
+ } else {
112
+ defaultFormat += editor.lang.wordcount.Paragraphs + " %paragraphsCount%";
113
+ }
93
114
  }
94
- };
95
-
96
- // Get Config & Lang
97
- var config = CKEDITOR.tools.extend(defaultConfig, editor.config.wordcount || {}, true);
98
115
 
99
- if (config.showParagraphs) {
100
- defaultFormat += editor.lang.wordcount.Paragraphs + " %paragraphs%";
101
- }
116
+ if (config.showParagraphs && (config.showWordCount || config.showCharCount)) {
117
+ defaultFormat += ", ";
118
+ }
102
119
 
103
- if (config.showParagraphs && (config.showWordCount || config.showCharCount)) {
104
- defaultFormat += ", ";
105
- }
120
+ if (config.showWordCount) {
121
+ if (config.maxWordCount > -1) {
122
+ if (config.showRemaining) {
123
+ defaultFormat += "%wordCount% " + editor.lang.wordcount.WordCountRemaining;
124
+ } else {
125
+ defaultFormat += editor.lang.wordcount.WordCount + " %wordCount%";
106
126
 
107
- if (config.showWordCount) {
108
- if (config.maxWordCount > -1) {
109
- if (config.showRemaining) {
110
- defaultFormat += "%wordCount% " + editor.lang.wordcount.WordCountRemaining;
127
+ defaultFormat += "/" + config.maxWordCount;
128
+ }
111
129
  } else {
112
130
  defaultFormat += editor.lang.wordcount.WordCount + " %wordCount%";
113
-
114
- defaultFormat += "/" + config.maxWordCount;
115
131
  }
116
- } else {
117
- defaultFormat += editor.lang.wordcount.WordCount + " %wordCount%";
118
132
  }
119
- }
120
133
 
121
- if (config.showCharCount && config.showWordCount) {
122
- defaultFormat += ", ";
123
- }
134
+ if (config.showCharCount && config.showWordCount) {
135
+ defaultFormat += ", ";
136
+ }
124
137
 
125
- if (config.showCharCount) {
126
- if (config.maxCharCount > -1) {
127
- if (config.showRemaining) {
128
- defaultFormat += "%charCount% " + editor.lang.wordcount[config.countHTML
129
- ? "CharCountWithHTMLRemaining"
130
- : "CharCountRemaining"];
138
+ if (config.showCharCount) {
139
+ if (config.maxCharCount > -1) {
140
+ if (config.showRemaining) {
141
+ defaultFormat += "%charCount% " +
142
+ editor.lang.wordcount[config.countHTML
143
+ ? "CharCountWithHTMLRemaining"
144
+ : "CharCountRemaining"];
145
+ } else {
146
+ defaultFormat += editor.lang.wordcount[config.countHTML
147
+ ? "CharCountWithHTML"
148
+ : "CharCount"] +
149
+ " %charCount%";
150
+
151
+ defaultFormat += "/" + config.maxCharCount;
152
+ }
131
153
  } else {
132
- defaultFormat += editor.lang.wordcount[config.countHTML
133
- ? "CharCountWithHTML"
134
- : "CharCount"] + " %charCount%";
135
-
136
- defaultFormat += "/" + config.maxCharCount;
154
+ defaultFormat += editor.lang.wordcount[config.countHTML ? "CharCountWithHTML" : "CharCount"] +
155
+ " %charCount%";
137
156
  }
138
- } else {
139
- defaultFormat += editor.lang.wordcount[config.countHTML ? "CharCountWithHTML" : "CharCount"] + " %charCount%";
140
157
  }
141
- }
142
-
143
- var format = defaultFormat;
144
158
 
145
- bbcodePluginLoaded = typeof editor.plugins.bbcode != 'undefined';
159
+ var format = defaultFormat;
146
160
 
147
- function counterId(editorInstance) {
148
- return "cke_wordcount_" + editorInstance.name;
149
- }
161
+ bbcodePluginLoaded = typeof editor.plugins.bbcode != 'undefined';
150
162
 
151
- function counterElement(editorInstance) {
152
- return document.getElementById(counterId(editorInstance));
153
- }
163
+ function counterId(editorInstance) {
164
+ return "cke_wordcount_" + editorInstance.name;
165
+ }
154
166
 
155
- function strip(html) {
156
- if (bbcodePluginLoaded) {
157
- // stripping out BBCode tags [...][/...]
158
- return html.replace(/\[.*?\]/gi, '');
167
+ function counterElement(editorInstance) {
168
+ return document.getElementById(counterId(editorInstance));
159
169
  }
160
170
 
161
- var tmp = document.createElement("div");
171
+ function strip(html) {
172
+ if (bbcodePluginLoaded) {
173
+ // stripping out BBCode tags [...][/...]
174
+ return html.replace(/\[.*?\]/gi, '');
175
+ }
162
176
 
163
- // Add filter before strip
164
- html = filter(html);
177
+ var tmp = document.createElement("div");
165
178
 
166
- tmp.innerHTML = html;
179
+ // Add filter before strip
180
+ html = filter(html);
167
181
 
168
- if (tmp.textContent == "" && typeof tmp.innerText == "undefined") {
169
- return "";
170
- }
182
+ tmp.innerHTML = html;
171
183
 
172
- return tmp.textContent || tmp.innerText;
173
- }
184
+ if (tmp.textContent == "" && typeof tmp.innerText == "undefined") {
185
+ return "";
186
+ }
174
187
 
175
- /**
176
- * Implement filter to add or remove before counting
177
- * @param html
178
- * @returns string
179
- */
180
- function filter(html) {
181
- if(config.filter instanceof CKEDITOR.htmlParser.filter) {
182
- var fragment = CKEDITOR.htmlParser.fragment.fromHtml(html),
183
- writer = new CKEDITOR.htmlParser.basicWriter();
184
- config.filter.applyTo( fragment );
185
- fragment.writeHtml( writer );
186
- return writer.getHtml();
188
+ return tmp.textContent || tmp.innerText;
189
+ }
190
+
191
+ /**
192
+ * Implement filter to add or remove before counting
193
+ * @param html
194
+ * @returns string
195
+ */
196
+ function filter(html) {
197
+ if (config.filter instanceof CKEDITOR.htmlParser.filter) {
198
+ var fragment = CKEDITOR.htmlParser.fragment.fromHtml(html),
199
+ writer = new CKEDITOR.htmlParser.basicWriter();
200
+ config.filter.applyTo(fragment);
201
+ fragment.writeHtml(writer);
202
+ return writer.getHtml();
203
+ }
204
+ return html;
187
205
  }
188
- return html;
189
- }
190
206
 
191
- function countCharacters(text, editorInstance) {
192
- if (config.countHTML) {
193
- return (filter(text).length);
194
- } else {
207
+ function countCharacters(text) {
208
+ if (config.countHTML) {
209
+ return config.countBytesAsChars ? countBytes(filter(text)) : filter(text).length;
210
+ }
211
+
195
212
  var normalizedText;
196
213
 
197
214
  // strip body tags
@@ -211,289 +228,369 @@ CKEDITOR.plugins.add("wordcount", {
211
228
  }
212
229
 
213
230
  if (config.countLineBreaks) {
214
- normalizedText = normalizedText.replace(/(\r\n|\n|\r)/gm, "");
231
+ normalizedText = normalizedText.replace(/(\r\n|\n|\r)/gm, " ");
215
232
  } else {
216
233
  normalizedText = normalizedText.replace(/(\r\n|\n|\r)/gm, "").replace(/ /gi, " ");
217
234
  }
218
235
 
219
236
  normalizedText = strip(normalizedText).replace(/^([\t\r\n]*)$/, "");
220
237
 
221
- return config.countBytesAsChars ? (countBytes(normalizedText)) : (normalizedText.length);
238
+ return config.countBytesAsChars ? countBytes(normalizedText) : normalizedText.length;
222
239
  }
223
- }
224
-
225
- function countBytes(text) {
226
- var count = 0, stringLength = text.length, i;
227
- text = String(text || "");
228
- for (i = 0; i < stringLength; i++) {
229
- var partCount = encodeURI(text[i]).split("%").length;
230
- count += partCount == 1 ? 1 : partCount - 1;
231
- }
232
- return count;
233
- }
234
-
235
- function countParagraphs(text) {
236
- return (text.replace(/&nbsp;/g, " ").replace(/(<([^>]+)>)/ig, "").replace(/^\s*$[\n\r]{1,}/gm, "++").split("++").length);
237
- }
238
-
239
- function countWords(text) {
240
- var normalizedText = text.
241
- replace(/(\r\n|\n|\r)/gm, " ").
242
- replace(/^\s+|\s+$/g, "").
243
- replace("&nbsp;", " ");
244
-
245
- normalizedText = strip(normalizedText);
246
-
247
- var words = normalizedText.split(/\s+/);
248
240
 
249
- for (var wordIndex = words.length - 1; wordIndex >= 0; wordIndex--) {
250
- if (words[wordIndex].match(/^([\s\t\r\n]*)$/)) {
251
- words.splice(wordIndex, 1);
241
+ function countBytes(text) {
242
+ var count = 0, stringLength = text.length, i;
243
+ text = String(text || "");
244
+ for (i = 0; i < stringLength; i++) {
245
+ var partCount = encodeURI(text[i]).split("%").length;
246
+ count += partCount == 1 ? 1 : partCount - 1;
252
247
  }
248
+ return count;
253
249
  }
254
250
 
255
- return (words.length);
256
- }
257
-
258
- function limitReached(editorInstance, notify) {
259
- limitReachedNotified = true;
260
- limitRestoredNotified = false;
261
-
262
- if (config.hardLimit) {
263
- editorInstance.loadSnapshot(snapShot);
264
- // lock editor
265
- editorInstance.config.Locked = 1;
251
+ function countParagraphs(text) {
252
+ return (text.replace(/&nbsp;/g, " ").replace(/(<([^>]+)>)/ig, "").replace(/^\s*$[\n\r]{1,}/gm, "++")
253
+ .split("++").length);
266
254
  }
267
255
 
268
- if (!notify) {
269
- counterElement(editorInstance).className = "cke_path_item cke_wordcountLimitReached";
270
- editorInstance.fire("limitReached", {firedBy: "wordCount.limitReached"}, editor);
271
- }
272
- }
273
-
274
- function limitRestored(editorInstance) {
275
- limitRestoredNotified = true;
276
- limitReachedNotified = false;
277
- editorInstance.config.Locked = 0;
278
- snapShot = editor.getSnapshot();
256
+ function countWords(text) {
257
+ var normalizedText = text.replace(/(\r\n|\n|\r)/gm, " ").replace(/^\s+|\s+$/g, "")
258
+ .replace("&nbsp;", " ");
279
259
 
280
- counterElement(editorInstance).className = "cke_path_item";
281
- }
260
+ normalizedText = strip(normalizedText);
282
261
 
283
- function updateCounter(editorInstance) {
284
- var paragraphs = 0,
285
- wordCount = 0,
286
- charCount = 0,
287
- text;
288
-
289
- // BeforeGetData and getData events are fired when calling
290
- // getData(). We can prevent this by passing true as an
291
- // argument to getData(). This allows us to fire the events
292
- // manually with additional event data: firedBy. This additional
293
- // data helps differentiate calls to getData() made by
294
- // wordCount plugin from calls made by other plugins/code.
295
- editorInstance.fire("beforeGetData", {firedBy: "wordCount.updateCounter"}, editor);
296
- text = editorInstance.getData(true);
297
- editorInstance.fire("getData", {dataValue: text, firedBy: "wordCount.updateCounter"}, editor);
298
-
299
- if (text) {
300
- if (config.showCharCount) {
301
- charCount = countCharacters(text, editorInstance);
302
- }
262
+ var words = normalizedText.split(/\s+/);
303
263
 
304
- if (config.showParagraphs) {
305
- paragraphs = countParagraphs(text);
264
+ for (var wordIndex = words.length - 1; wordIndex >= 0; wordIndex--) {
265
+ if (words[wordIndex].match(/^([\s\t\r\n]*)$/)) {
266
+ words.splice(wordIndex, 1);
267
+ }
306
268
  }
307
269
 
308
- if (config.showWordCount) {
309
- wordCount = countWords(text);
310
- }
270
+ return (words.length);
311
271
  }
312
272
 
273
+ function limitReached(editorInstance, notify) {
274
+ limitReachedNotified = true;
275
+ limitRestoredNotified = false;
313
276
 
314
- var html = format.replace("%paragraphs%", paragraphs);
315
-
316
- if (config.showRemaining) {
317
- if (config.maxCharCount >= 0) {
318
- html = html.replace("%charCount%", config.maxCharCount - charCount);
319
- } else {
320
- html = html.replace("%charCount%", charCount);
277
+ if (!config.warnOnLimitOnly) {
278
+ if (config.hardLimit) {
279
+ editorInstance.execCommand('undo');
280
+ }
321
281
  }
322
282
 
323
- if (config.maxWordCount >= 0) {
324
- html = html.replace("%wordCount%", config.maxWordCount - wordCount);
325
- } else {
326
- html = html.replace("%wordCount%", wordCount);
283
+ if (!notify) {
284
+ counterElement(editorInstance).className = "cke_path_item cke_wordcountLimitReached";
285
+ editorInstance.fire("limitReached", { firedBy: "wordCount.limitReached" }, editor);
327
286
  }
328
- } else {
329
- html = html.replace("%wordCount%", wordCount).replace("%charCount%", charCount);
330
287
  }
331
288
 
332
- (editorInstance.config.wordcount || (editorInstance.config.wordcount = {})).wordCount = wordCount;
333
- (editorInstance.config.wordcount || (editorInstance.config.wordcount = {})).charCount = charCount;
289
+ function limitRestored(editorInstance) {
290
+ limitRestoredNotified = true;
291
+ limitReachedNotified = false;
334
292
 
335
- if (CKEDITOR.env.gecko) {
336
- counterElement(editorInstance).innerHTML = html;
337
- } else {
338
- counterElement(editorInstance).innerText = html;
293
+ if (!config.warnOnLimitOnly) {
294
+ editorInstance.fire('saveSnapshot');
295
+ }
296
+
297
+ counterElement(editorInstance).className = "cke_path_item";
339
298
  }
340
299
 
341
- if (charCount == lastCharCount && wordCount == lastWordCount) {
342
- if (charCount == config.maxCharCount || wordCount == config.maxWordCount) {
343
- snapShot = editor.getSnapshot();
300
+ function updateCounter(editorInstance) {
301
+ if (!counterElement(editorInstance)) {
302
+ return;
344
303
  }
345
- return true;
346
- }
347
304
 
348
- //If the limit is already over, allow the deletion of characters/words. Otherwise,
349
- //the user would have to delete at one go the number of offending characters
350
- var deltaWord = wordCount - lastWordCount;
351
- var deltaChar = charCount - lastCharCount;
305
+ var paragraphs = 0,
306
+ wordCount = 0,
307
+ charCount = 0,
308
+ text;
352
309
 
353
- lastWordCount = wordCount;
354
- lastCharCount = charCount;
310
+ // BeforeGetData and getData events are fired when calling
311
+ // getData(). We can prevent this by passing true as an
312
+ // argument to getData(). This allows us to fire the events
313
+ // manually with additional event data: firedBy. This additional
314
+ // data helps differentiate calls to getData() made by
315
+ // wordCount plugin from calls made by other plugins/code.
316
+ editorInstance.fire("beforeGetData", { firedBy: "wordCount.updateCounter" }, editor);
317
+ text = editorInstance.getData(true);
318
+ editorInstance.fire("getData", { dataValue: text, firedBy: "wordCount.updateCounter" }, editor);
355
319
 
356
- if (lastWordCount == -1) {
357
- lastWordCount = wordCount;
358
- }
359
- if (lastCharCount == -1) {
360
- lastCharCount = charCount;
361
- }
320
+ if (text) {
321
+ if (config.showCharCount) {
322
+ charCount = countCharacters(text);
323
+ }
362
324
 
363
- // Check for word limit and/or char limit
364
- if ((config.maxWordCount > -1 && wordCount > config.maxWordCount && deltaWord > 0) ||
365
- (config.maxCharCount > -1 && charCount > config.maxCharCount && deltaChar > 0)) {
325
+ if (config.showParagraphs) {
326
+ paragraphs = countParagraphs(text);
327
+ }
366
328
 
367
- limitReached(editorInstance, limitReachedNotified);
368
- } else if ((config.maxWordCount == -1 || wordCount <= config.maxWordCount) &&
369
- (config.maxCharCount == -1 || charCount <= config.maxCharCount)) {
329
+ if (config.showWordCount) {
330
+ wordCount = countWords(text);
331
+ }
332
+ }
370
333
 
371
- limitRestored(editorInstance);
372
- } else {
373
- snapShot = editorInstance.getSnapshot();
374
- }
334
+ var html = format;
335
+ if (config.showRemaining) {
336
+ if (config.maxCharCount >= 0) {
337
+ html = html.replace("%charCount%", config.maxCharCount - charCount);
338
+ } else {
339
+ html = html.replace("%charCount%", charCount);
340
+ }
341
+
342
+ if (config.maxWordCount >= 0) {
343
+ html = html.replace("%wordCount%", config.maxWordCount - wordCount);
344
+ } else {
345
+ html = html.replace("%wordCount%", wordCount);
346
+ }
375
347
 
376
- // Fire Custom Events
377
- if (config.charCountGreaterThanMaxLengthEvent && config.charCountLessThanMaxLengthEvent) {
378
- if (charCount > config.maxCharCount && config.maxCharCount > -1) {
379
- config.charCountGreaterThanMaxLengthEvent(charCount, config.maxCharCount);
348
+ if (config.maxParagraphs >= 0) {
349
+ html = html.replace("%paragraphsCount%", config.maxParagraphs - paragraphs);
350
+ } else {
351
+ html = html.replace("%paragraphsCount%", paragraphs);
352
+ }
380
353
  } else {
381
- config.charCountLessThanMaxLengthEvent(charCount, config.maxCharCount);
354
+ html = html.replace("%wordCount%", wordCount).replace("%charCount%", charCount).replace("%paragraphsCount%", paragraphs);
382
355
  }
383
- }
384
356
 
385
- if (config.wordCountGreaterThanMaxLengthEvent && config.wordCountLessThanMaxLengthEvent) {
386
- if (wordCount > config.maxWordCount && config.maxWordCount > -1) {
387
- config.wordCountGreaterThanMaxLengthEvent(wordCount, config.maxWordCount);
357
+ (editorInstance.config.wordcount || (editorInstance.config.wordcount = {})).wordCount = wordCount;
358
+ (editorInstance.config.wordcount || (editorInstance.config.wordcount = {})).charCount = charCount;
388
359
 
360
+ if (CKEDITOR.env.gecko) {
361
+ counterElement(editorInstance).innerHTML = html;
389
362
  } else {
390
- config.wordCountLessThanMaxLengthEvent(wordCount, config.maxWordCount);
363
+ counterElement(editorInstance).innerText = html;
391
364
  }
392
- }
393
365
 
394
- return true;
395
- }
396
-
397
- editor.on("key", function (event) {
398
- if (editor.mode === "source") {
399
- updateCounter(event.editor);
400
- }
401
- }, editor, null, 100);
402
-
403
- editor.on("change", function (event) {
404
- updateCounter(event.editor);
405
- }, editor, null, 100);
406
-
407
- editor.on("uiSpace", function (event) {
408
- if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE) {
409
- if (event.data.space == "top") {
410
- event.data.html += "<div class=\"cke_wordcount\" style=\"\"" +
411
- " title=\"" +
412
- editor.lang.wordcount.title +
413
- "\"" +
414
- "><span id=\"" +
415
- counterId(event.editor) +
416
- "\" class=\"cke_path_item\">&nbsp;</span></div>";
417
- }
418
- } else {
419
- if (event.data.space == "bottom") {
420
- event.data.html += "<div class=\"cke_wordcount\" style=\"\"" +
421
- " title=\"" +
422
- editor.lang.wordcount.title +
423
- "\"" +
424
- "><span id=\"" +
425
- counterId(event.editor) +
426
- "\" class=\"cke_path_item\">&nbsp;</span></div>";
366
+ if (charCount == lastCharCount && wordCount == lastWordCount && paragraphs == lastParagraphs) {
367
+ if (charCount == config.maxCharCount || wordCount == config.maxWordCount || paragraphs > config.maxParagraphs) {
368
+ editorInstance.fire('saveSnapshot');
369
+ }
370
+ return true;
427
371
  }
428
- }
429
372
 
430
- }, editor, null, 100);
373
+ //If the limit is already over, allow the deletion of characters/words. Otherwise,
374
+ //the user would have to delete at one go the number of offending characters
375
+ var deltaWord = wordCount - lastWordCount;
376
+ var deltaChar = charCount - lastCharCount;
377
+ var deltaParagraphs = paragraphs - lastParagraphs;
431
378
 
432
- editor.on("dataReady", function (event) {
433
- updateCounter(event.editor);
434
- }, editor, null, 100);
379
+ lastWordCount = wordCount;
380
+ lastCharCount = charCount;
381
+ lastParagraphs = paragraphs;
435
382
 
436
- editor.on("paste", function(event) {
437
- if (config.maxWordCount > 0 || config.maxCharCount > 0) {
383
+ if (lastWordCount == -1) {
384
+ lastWordCount = wordCount;
385
+ }
386
+ if (lastCharCount == -1) {
387
+ lastCharCount = charCount;
388
+ }
389
+ if (lastParagraphs == -1) {
390
+ lastParagraphs = paragraphs;
391
+ }
438
392
 
439
- // Check if pasted content is above the limits
440
- var wordCount = -1,
441
- charCount = -1;
393
+ // Check for word limit and/or char limit
394
+ if ((config.maxWordCount > -1 && wordCount > config.maxWordCount && deltaWord > 0) ||
395
+ (config.maxCharCount > -1 && charCount > config.maxCharCount && deltaChar > 0) ||
396
+ (config.maxParagraphs > -1 && paragraphs > config.maxParagraphs && deltaParagraphs > 0)) {
442
397
 
443
- // BeforeGetData and getData events are fired when calling
444
- // getData(). We can prevent this by passing true as an
445
- // argument to getData(). This allows us to fire the events
446
- // manually with additional event data: firedBy. This additional
447
- // data helps differentiate calls to getData() made by
448
- // wordCount plugin from calls made by other plugins/code.
449
- event.editor.fire("beforeGetData", {firedBy: "wordCount.onPaste"}, event.editor);
450
- var text = event.editor.getData(true);
451
- event.editor.fire("getData", {dataValue: text, firedBy: "wordCount.onPaste"}, event.editor);
398
+ limitReached(editorInstance, limitReachedNotified);
399
+ } else if ((config.maxWordCount == -1 || wordCount <= config.maxWordCount) &&
400
+ (config.maxCharCount == -1 || charCount <= config.maxCharCount) &&
401
+ (config.maxParagraphs == -1 || paragraphs <= config.maxParagraphs)) {
452
402
 
453
- text += event.data.dataValue;
403
+ limitRestored(editorInstance);
404
+ } else {
405
+ editorInstance.fire('saveSnapshot');
406
+ }
454
407
 
455
- if (config.showCharCount) {
456
- charCount = countCharacters(text, event.editor);
408
+ // update instance
409
+ editorInstance.wordCount =
410
+ {
411
+ paragraphs: paragraphs,
412
+ wordCount: wordCount,
413
+ charCount: charCount
414
+ };
415
+
416
+
417
+ // Fire Custom Events
418
+ if (config.charCountGreaterThanMaxLengthEvent && config.charCountLessThanMaxLengthEvent) {
419
+ if (charCount > config.maxCharCount && config.maxCharCount > -1) {
420
+ config.charCountGreaterThanMaxLengthEvent(charCount, config.maxCharCount);
421
+ } else {
422
+ config.charCountLessThanMaxLengthEvent(charCount, config.maxCharCount);
423
+ }
457
424
  }
458
425
 
459
- if (config.showWordCount) {
460
- wordCount = countWords(text);
426
+ if (config.wordCountGreaterThanMaxLengthEvent && config.wordCountLessThanMaxLengthEvent) {
427
+ if (wordCount > config.maxWordCount && config.maxWordCount > -1) {
428
+ config.wordCountGreaterThanMaxLengthEvent(wordCount, config.maxWordCount);
429
+
430
+ } else {
431
+ config.wordCountLessThanMaxLengthEvent(wordCount, config.maxWordCount);
432
+ }
461
433
  }
462
434
 
435
+ return true;
436
+ }
463
437
 
464
- // Instantiate the notification when needed and only have one instance
465
- if(notification === null) {
466
- notification = new CKEDITOR.plugins.notification(event.editor, {
467
- message: event.editor.lang.wordcount.pasteWarning,
468
- type: 'warning',
469
- duration: config.pasteWarningDuration
470
- });
438
+ function isCloseToLimits() {
439
+ if (config.maxWordCount > -1 && config.maxWordCount - lastWordCount < 5) {
440
+ return true;
471
441
  }
472
442
 
473
- if (config.maxCharCount > 0 && charCount > config.maxCharCount && config.hardLimit) {
474
- if(!notification.isVisible()) {
475
- notification.show();
476
- }
477
- event.cancel();
443
+ if (config.maxCharCount > -1 && config.maxCharCount - lastCharCount < 20) {
444
+ return true;
478
445
  }
479
446
 
480
- if (config.maxWordCount > 0 && wordCount > config.maxWordCount && config.hardLimit) {
481
- if(!notification.isVisible()) {
482
- notification.show();
483
- }
484
- event.cancel();
447
+ if (config.maxParagraphs > -1 && config.maxParagraphs - lastParagraphs < 1) {
448
+ return true;
485
449
  }
450
+
451
+ return false;
486
452
  }
487
- }, editor, null, 100);
488
453
 
489
- editor.on("afterPaste", function (event) {
490
- updateCounter(event.editor);
491
- }, editor, null, 100);
454
+ editor.on("key",
455
+ function(event) {
456
+ if (editor.mode === "source") {
457
+ clearTimeout(timeoutId);
458
+ timeoutId = setTimeout(
459
+ updateCounter.bind(this, event.editor),
460
+ 250
461
+ );
462
+ }
463
+ },
464
+ editor,
465
+ null,
466
+ 100);
467
+
468
+ editor.on("change",
469
+ function(event) {
470
+ var ms = isCloseToLimits() ? 5 : 250;
471
+ clearTimeout(timeoutId);
472
+ timeoutId = setTimeout(
473
+ updateCounter.bind(this, event.editor),
474
+ ms
475
+ );
476
+ },
477
+ editor,
478
+ null,
479
+ 100);
480
+
481
+ editor.on("uiSpace",
482
+ function(event) {
483
+ if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE) {
484
+ if (event.data.space == "top") {
485
+ event.data.html += "<div class=\"cke_wordcount\" style=\"\"" +
486
+ " title=\"" +
487
+ editor.lang.wordcount.title +
488
+ "\"" +
489
+ "><span id=\"" +
490
+ counterId(event.editor) +
491
+ "\" class=\"cke_path_item\">&nbsp;</span></div>";
492
+ }
493
+ } else {
494
+ if (event.data.space == "bottom") {
495
+ event.data.html += "<div class=\"cke_wordcount\" style=\"\"" +
496
+ " title=\"" +
497
+ editor.lang.wordcount.title +
498
+ "\"" +
499
+ "><span id=\"" +
500
+ counterId(event.editor) +
501
+ "\" class=\"cke_path_item\">&nbsp;</span></div>";
502
+ }
503
+ }
492
504
 
493
- editor.on("blur", function () {
494
- if (intervalId) {
495
- window.clearInterval(intervalId);
496
- }
497
- }, editor, null, 300);
498
- }
499
- });
505
+ },
506
+ editor,
507
+ null,
508
+ 100);
509
+
510
+ editor.on("dataReady",
511
+ function(event) {
512
+ updateCounter(event.editor);
513
+ },
514
+ editor,
515
+ null,
516
+ 100);
517
+
518
+ editor.on("paste",
519
+ function(event) {
520
+ if (!config.warnOnLimitOnly && (config.maxWordCount > 0 || config.maxCharCount > 0 || config.maxParagraphs > 0)) {
521
+
522
+ // Check if pasted content is above the limits
523
+ var wordCount = -1,
524
+ charCount = -1,
525
+ paragraphs = -1;
526
+
527
+ // BeforeGetData and getData events are fired when calling
528
+ // getData(). We can prevent this by passing true as an
529
+ // argument to getData(). This allows us to fire the events
530
+ // manually with additional event data: firedBy. This additional
531
+ // data helps differentiate calls to getData() made by
532
+ // wordCount plugin from calls made by other plugins/code.
533
+ event.editor.fire("beforeGetData", { firedBy: "wordCount.onPaste" }, event.editor);
534
+ var text = event.editor.getData(true);
535
+ event.editor.fire("getData", { dataValue: text, firedBy: "wordCount.onPaste" }, event.editor);
536
+
537
+ text += event.data.dataValue;
538
+
539
+ if (config.showCharCount) {
540
+ charCount = countCharacters(text);
541
+ }
542
+
543
+ if (config.showWordCount) {
544
+ wordCount = countWords(text);
545
+ }
546
+
547
+ if (config.showParagraphs) {
548
+ paragraphs = countParagraphs(text);
549
+ }
550
+
551
+
552
+ // Instantiate the notification when needed and only have one instance
553
+ if (notification === null) {
554
+ notification = new CKEDITOR.plugins.notification(event.editor,
555
+ {
556
+ message: event.editor.lang.wordcount.pasteWarning,
557
+ type: 'warning',
558
+ duration: config.pasteWarningDuration
559
+ });
560
+ }
561
+
562
+ if (config.maxCharCount > 0 && charCount > config.maxCharCount && config.hardLimit) {
563
+ if (!notification.isVisible()) {
564
+ notification.show();
565
+ }
566
+ event.cancel();
567
+ }
568
+
569
+ if (config.maxWordCount > 0 && wordCount > config.maxWordCount && config.hardLimit) {
570
+ if (!notification.isVisible()) {
571
+ notification.show();
572
+ }
573
+ event.cancel();
574
+ }
575
+
576
+ if (config.maxParagraphs > 0 && paragraphs > config.maxParagraphs && config.hardLimit) {
577
+ if (!notification.isVisible()) {
578
+ notification.show();
579
+ }
580
+ event.cancel();
581
+ }
582
+ }
583
+ },
584
+ editor,
585
+ null,
586
+ 100);
587
+
588
+ editor.on("afterPaste",
589
+ function(event) {
590
+ updateCounter(event.editor);
591
+ },
592
+ editor,
593
+ null,
594
+ 100);
595
+ }
596
+ });