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.
- checksums.yaml +5 -5
- data/Gemfile +13 -12
- data/README.md +358 -2
- data/Rakefile +17 -17
- data/app/assets/javascripts/ckeditor/config.js.erb +3 -3
- data/app/controllers/ckeditor/application_controller.rb +3 -0
- data/app/controllers/ckeditor/attachment_files_controller.rb +2 -0
- data/app/controllers/ckeditor/pictures_controller.rb +2 -0
- data/app/helpers/ckeditor/application_helper.rb +2 -0
- data/config/locales/bg.ckeditor.yml +9 -0
- data/config/locales/cs.ckeditor.yml +9 -0
- data/config/locales/da.ckeditor.yml +9 -0
- data/config/locales/de.ckeditor.yml +9 -0
- data/config/locales/el-GR.cdkeditor.yml +9 -0
- data/config/locales/es.ckeditor.yml +9 -0
- data/config/locales/fr.ckeditor.yml +9 -0
- data/config/locales/hu.ckeditor.yml +9 -0
- data/config/locales/it.ckeditor.yml +9 -0
- data/config/locales/ja.ckeditor.yml +9 -0
- data/config/locales/nb.ckeditor.yml +9 -0
- data/config/locales/nl.ckeditor.yml +9 -0
- data/config/locales/pl.ckeditor.yml +9 -0
- data/config/locales/pt-BR.ckeditor.yml +9 -0
- data/config/locales/pt-PT.ckeditor.yml +9 -0
- data/config/locales/pt.ckeditor.yml +9 -0
- data/config/locales/sq.ckeditor.yml +9 -0
- data/config/locales/sv-SE.ckeditor.yml +9 -0
- data/config/locales/tr.ckeditor.yml +9 -0
- data/config/locales/uk.ckeditor.yml +9 -0
- data/config/locales/zh-CN.ckeditor.yml +9 -0
- data/config/locales/zh-TW.ckeditor.yml +9 -0
- data/config/routes.rb +2 -0
- data/lib/ckeditor.rb +13 -16
- data/lib/ckeditor/asset_response.rb +15 -4
- data/lib/ckeditor/backend/active_storage.rb +68 -0
- data/lib/ckeditor/backend/carrierwave.rb +2 -12
- data/lib/ckeditor/backend/dragonfly.rb +2 -0
- data/lib/ckeditor/backend/paperclip.rb +2 -15
- data/lib/ckeditor/backend/shrine.rb +29 -0
- data/lib/ckeditor/helpers/controllers.rb +2 -0
- data/lib/ckeditor/helpers/form_builder.rb +2 -0
- data/lib/ckeditor/helpers/form_helper.rb +2 -0
- data/lib/ckeditor/helpers/view_helper.rb +2 -0
- data/lib/ckeditor/hooks/cancan.rb +4 -1
- data/lib/ckeditor/hooks/formtastic.rb +2 -0
- data/lib/ckeditor/hooks/pundit.rb +2 -0
- data/lib/ckeditor/hooks/simple_form.rb +2 -0
- data/lib/ckeditor/http.rb +8 -5
- data/lib/ckeditor/orm/active_record.rb +2 -0
- data/lib/ckeditor/orm/base.rb +11 -2
- data/lib/ckeditor/orm/mongoid.rb +2 -0
- data/lib/ckeditor/paginatable.rb +2 -0
- data/lib/ckeditor/rails.rb +2 -0
- data/lib/ckeditor/rails_admin/field.rb +16 -3
- data/lib/ckeditor/text_area.rb +2 -0
- data/lib/ckeditor/utils.rb +3 -16
- data/lib/ckeditor/utils/javascript_code.rb +1 -1
- data/lib/ckeditor/version.rb +4 -2
- data/lib/generators/ckeditor/install_generator.rb +16 -19
- data/lib/generators/ckeditor/pundit_policy_generator.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/active_storage/ckeditor/asset.rb +10 -0
- data/lib/generators/ckeditor/templates/active_record/{refile → active_storage}/ckeditor/attachment_file.rb +3 -1
- data/lib/generators/ckeditor/templates/active_record/active_storage/ckeditor/picture.rb +13 -0
- data/lib/generators/ckeditor/templates/active_record/{carrierwave/migration_versioned.rb → active_storage/migration.rb} +8 -5
- data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/asset.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/attachment_file.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/picture.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb +7 -5
- data/lib/generators/ckeditor/templates/active_record/dragonfly/ckeditor/asset.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/dragonfly/ckeditor/attachment_file.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/dragonfly/ckeditor/picture.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb +7 -5
- data/lib/generators/ckeditor/templates/active_record/paperclip/ckeditor/asset.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/paperclip/ckeditor/attachment_file.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/paperclip/ckeditor/picture.rb +2 -0
- data/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb +8 -6
- data/lib/generators/ckeditor/templates/active_record/{refile → shrine}/ckeditor/asset.rb +3 -1
- data/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/attachment_file.rb +21 -0
- data/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb +49 -0
- data/lib/generators/ckeditor/templates/active_record/shrine/migration.rb +22 -0
- data/lib/generators/ckeditor/templates/base/carrierwave/uploaders/ckeditor_attachment_file_uploader.rb +2 -1
- data/lib/generators/ckeditor/templates/base/carrierwave/uploaders/ckeditor_picture_uploader.rb +2 -3
- data/lib/generators/ckeditor/templates/base/dragonfly/initializer.rb +2 -0
- data/lib/generators/ckeditor/templates/base/shrine/initializer.rb +25 -0
- data/lib/generators/ckeditor/templates/ckeditor.rb +3 -6
- data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/asset.rb +2 -0
- data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/attachment_file.rb +2 -0
- data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/picture.rb +2 -0
- data/lib/generators/ckeditor/templates/mongoid/paperclip/ckeditor/asset.rb +2 -0
- data/lib/generators/ckeditor/templates/mongoid/paperclip/ckeditor/attachment_file.rb +2 -0
- data/lib/generators/ckeditor/templates/mongoid/paperclip/ckeditor/picture.rb +2 -0
- data/lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/asset.rb +8 -0
- data/lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/attachment_file.rb +21 -0
- data/lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/picture.rb +47 -0
- data/lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb +2 -0
- data/lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb +2 -0
- data/lib/tasks/ckeditor.rake +2 -0
- data/test/controllers/attachment_files_controller_test.rb +17 -15
- data/test/controllers/pictures_controller_test.rb +17 -15
- data/test/dummy/Rakefile +2 -0
- data/test/dummy/app/assets/javascripts/application.js +0 -2
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/posts_controller.rb +2 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/models/post.rb +2 -0
- data/test/dummy/app/views/posts/index.html.erb +0 -3
- data/test/dummy/app/views/posts/show.html.erb +3 -0
- data/test/dummy/config.ru +2 -0
- data/test/dummy/config/application.rb +5 -1
- data/test/dummy/config/boot.rb +2 -0
- data/test/dummy/config/environment.rb +2 -0
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +2 -0
- data/test/dummy/config/environments/test.rb +5 -3
- data/test/dummy/config/initializers/assets.rb +2 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/test/dummy/config/initializers/ckeditor.rb +2 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/test/dummy/config/initializers/inflections.rb +2 -0
- data/test/dummy/config/initializers/mime_types.rb +2 -0
- data/test/dummy/config/initializers/paperclip.rb +2 -0
- data/test/dummy/config/initializers/session_store.rb +2 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/config/storage.yml +3 -0
- data/test/dummy/db/migrate/20110623120047_create_posts.rb +5 -3
- data/test/dummy/db/migrate/20170806125915_create_active_storage_tables.rb +26 -0
- data/test/dummy/script/rails +2 -0
- data/test/functional/posts_controller_test.rb +18 -16
- data/test/generators/install_generator_test.rb +58 -56
- data/test/integration/navigation_test.rb +2 -0
- data/test/models/attachment_file_test.rb +4 -4
- data/test/models/ckeditor_test.rb +3 -21
- data/test/models/picture_test.rb +12 -10
- data/test/models/utils_test.rb +2 -0
- data/test/orm/active_record.rb +11 -1
- data/test/orm/mongoid.rb +2 -0
- data/test/support/helpers.rb +2 -0
- data/test/support/integration_case.rb +2 -0
- data/test/test_helper.rb +15 -9
- data/vendor/assets/javascripts/ckeditor/CHANGES.md +1404 -859
- data/vendor/assets/javascripts/ckeditor/LICENSE.md +8 -7
- data/vendor/assets/javascripts/ckeditor/README.md +5 -5
- data/vendor/assets/javascripts/ckeditor/adapters/jquery.js +7 -7
- data/vendor/assets/javascripts/ckeditor/build-config.js +12 -6
- data/vendor/assets/javascripts/ckeditor/ckeditor.js +1090 -907
- data/vendor/assets/javascripts/ckeditor/config.js +2 -2
- data/vendor/assets/javascripts/ckeditor/contents.css +7 -7
- data/vendor/assets/javascripts/ckeditor/lang/en.js +3 -3
- data/vendor/assets/javascripts/ckeditor/lang/ru.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +7 -7
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/en.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ru.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +5 -5
- data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/hidpi/logo_ckeditor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/logo_ckeditor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/clipboard/dialogs/paste.js +11 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.min.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/autoformat.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/searchcode.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/uncommentselectedrange.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/autocomplete.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/autoformat.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/commentselectedrange.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/searchcode.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/images/uncommentselectedrange.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/beautify.min.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.min.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.search.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.min.js +1 -6
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.bbcodemixed.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.handlebars.min.js +1 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.htmlmixed.min.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.javascript.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.php.min.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.twig.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/plugin.js +236 -218
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/base16-light.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/darcula.css +51 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/gruvbox-dark.css +37 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/idea.css +42 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/lesser-dark.css +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/lucario.css +37 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/monokai.css +5 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/nord.css +42 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/oceanic-next.css +44 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/panda-syntax.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/shadowfox.css +52 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/solarized.css +0 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/ssms.css +16 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/vibrant-ink.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/yonce.css +59 -0
- data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.css +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.js +12 -12
- data/vendor/assets/javascripts/ckeditor/plugins/dialog/dialogDefinition.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/dialog/styles/dialog.css +18 -0
- data/vendor/assets/javascripts/ckeditor/plugins/div/dialogs/div.js +9 -8
- data/vendor/assets/javascripts/ckeditor/plugins/find/dialogs/find.js +23 -23
- data/vendor/assets/javascripts/ckeditor/plugins/flash/dialogs/flash.js +17 -17
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/button.js +6 -6
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/checkbox.js +5 -5
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/form.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/hiddenfield.js +5 -5
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/radio.js +7 -7
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/select.js +17 -16
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textarea.js +7 -6
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textfield.js +9 -9
- data/vendor/assets/javascripts/ckeditor/plugins/icons.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/icons_hidpi.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/iframe/dialogs/iframe.js +9 -8
- data/vendor/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +1271 -44
- data/vendor/assets/javascripts/ckeditor/plugins/image/icons/hidpi/image.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image/icons/image.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image/lang/en.js +25 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image/lang/ru.js +25 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image/plugin.js +184 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/assets/image1.jpg +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/assets/image2.jpg +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/contents.css +35 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/dev/image2.html +339 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/dialogs/image2.js +553 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/icons/hidpi/image.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/icons/image.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/lang/en.js +21 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/lang/ru.js +21 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/plugin.js +1783 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/samples/assets/image1.jpg +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/samples/assets/image2.jpg +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image2/samples/image2.html +69 -0
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/plugin.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/anchor.js +5 -5
- data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/link.js +27 -25
- data/vendor/assets/javascripts/ckeditor/plugins/liststyle/dialogs/liststyle.js +8 -8
- data/vendor/assets/javascripts/ckeditor/plugins/loremipsum/lang/fr.js +8 -0
- data/vendor/assets/javascripts/ckeditor/plugins/loremipsum/plugin.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/pastefromword/filter/default.js +41 -51
- data/vendor/assets/javascripts/ckeditor/plugins/pastetools/filter/common.js +22 -0
- data/vendor/assets/javascripts/ckeditor/plugins/pastetools/filter/image.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/preview/images/pagebreak.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/preview/styles/screen.css +10 -0
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/CHANGELOG.md +1 -17
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/README.md +63 -7
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +32 -33
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/dialogs/smiley.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/en.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ru.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/specialchar.js +12 -12
- data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/plugin.js +10 -10
- data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/stylesheetparser.html +8 -7
- data/vendor/assets/javascripts/ckeditor/plugins/table/dialogs/table.js +20 -19
- data/vendor/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +16 -15
- data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.css +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/default.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/widget/images/handle.png +0 -0
- data/vendor/assets/javascripts/ckeditor/{samples/toolbarconfigurator/lib/codemirror/LICENSE → plugins/wordcount/LICENSE.md} +21 -19
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/README.md +106 -0
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/en.js +1 -0
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/ru.js +2 -1
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/plugin.js +475 -378
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/samples/maxParagraphs.html +26 -0
- data/vendor/assets/javascripts/ckeditor/plugins/wsc/README.md +62 -7
- data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/tmpFrameset.html +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +82 -82
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/LICENSE.md +15 -0
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/README.md +156 -0
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/plugin.js +8 -7
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_gecko.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_ie.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_ie7.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_ie8.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/editor_iequirks.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/icons.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/minimalist/icons_hidpi.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie8.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_iequirks.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_gecko.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie8.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_iequirks.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/readme.md +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/skin.js +2 -2
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie7.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie8.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_iequirks.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_gecko.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie7.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie8.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_iequirks.css +3 -3
- data/vendor/assets/javascripts/ckeditor/skins/moono/readme.md +5 -5
- data/vendor/assets/javascripts/ckeditor/skins/moono/skin.js +2 -2
- data/vendor/assets/javascripts/ckeditor/styles.js +4 -4
- data/vendor/assets/javascripts/ckeditor/vendor/promise.js +13 -0
- metadata +143 -138
- data/lib/ckeditor/backend/refile.rb +0 -39
- data/lib/ckeditor/utils/content_type_detector.rb +0 -38
- data/lib/generators/ckeditor/templates/active_record/dragonfly/migration_versioned.rb +0 -23
- data/lib/generators/ckeditor/templates/active_record/paperclip/migration_versioned.rb +0 -23
- data/lib/generators/ckeditor/templates/active_record/refile/ckeditor/picture.rb +0 -11
- data/lib/generators/ckeditor/templates/active_record/refile/migration.rb +0 -23
- data/lib/generators/ckeditor/templates/active_record/refile/migration_versioned.rb +0 -23
- data/test/support/raw_post.rb +0 -9
- data/vendor/assets/javascripts/ckeditor/plugins/iframedialog/plugin.js +0 -169
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/ru.js +0 -3
- data/vendor/assets/javascripts/ckeditor/plugins/loremipsum/lang/ru.js +0 -8
- data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/en.js +0 -7
- data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/ru.js +0 -7
- data/vendor/assets/javascripts/ckeditor/plugins/notification/plugin.js +0 -929
- data/vendor/assets/javascripts/ckeditor/samples/css/samples.css +0 -1632
- data/vendor/assets/javascripts/ckeditor/samples/img/github-top.png +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/img/header-bg.png +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/img/header-separator.png +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/img/logo.png +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/img/navigation-tip.png +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/index.html +0 -128
- data/vendor/assets/javascripts/ckeditor/samples/js/sample.js +0 -53
- data/vendor/assets/javascripts/ckeditor/samples/js/sf.js +0 -17
- data/vendor/assets/javascripts/ckeditor/samples/old/ajax.html +0 -85
- data/vendor/assets/javascripts/ckeditor/samples/old/api.html +0 -210
- data/vendor/assets/javascripts/ckeditor/samples/old/appendto.html +0 -59
- data/vendor/assets/javascripts/ckeditor/samples/old/assets/inlineall/logo.png +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/old/assets/outputxhtml/outputxhtml.css +0 -204
- data/vendor/assets/javascripts/ckeditor/samples/old/assets/posteddata.php +0 -59
- data/vendor/assets/javascripts/ckeditor/samples/old/assets/sample.jpg +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/old/assets/uilanguages/languages.js +0 -7
- data/vendor/assets/javascripts/ckeditor/samples/old/datafiltering.html +0 -508
- data/vendor/assets/javascripts/ckeditor/samples/old/dialog/assets/my_dialog.js +0 -48
- data/vendor/assets/javascripts/ckeditor/samples/old/dialog/dialog.html +0 -190
- data/vendor/assets/javascripts/ckeditor/samples/old/divreplace.html +0 -144
- data/vendor/assets/javascripts/ckeditor/samples/old/enterkey/enterkey.html +0 -106
- data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/assets/outputforflash/outputforflash.fla +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/assets/outputforflash/outputforflash.swf +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/assets/outputforflash/swfobject.js +0 -19
- data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/outputforflash.html +0 -283
- data/vendor/assets/javascripts/ckeditor/samples/old/htmlwriter/outputhtml.html +0 -224
- data/vendor/assets/javascripts/ckeditor/samples/old/index.html +0 -131
- data/vendor/assets/javascripts/ckeditor/samples/old/inlineall.html +0 -314
- data/vendor/assets/javascripts/ckeditor/samples/old/inlinebycode.html +0 -124
- data/vendor/assets/javascripts/ckeditor/samples/old/inlinetextarea.html +0 -113
- data/vendor/assets/javascripts/ckeditor/samples/old/jquery.html +0 -103
- data/vendor/assets/javascripts/ckeditor/samples/old/magicline/magicline.html +0 -209
- data/vendor/assets/javascripts/ckeditor/samples/old/readonly.html +0 -76
- data/vendor/assets/javascripts/ckeditor/samples/old/replacebyclass.html +0 -60
- data/vendor/assets/javascripts/ckeditor/samples/old/replacebycode.html +0 -59
- data/vendor/assets/javascripts/ckeditor/samples/old/sample.css +0 -357
- data/vendor/assets/javascripts/ckeditor/samples/old/sample.js +0 -50
- data/vendor/assets/javascripts/ckeditor/samples/old/sample_posteddata.php +0 -16
- data/vendor/assets/javascripts/ckeditor/samples/old/tabindex.html +0 -78
- data/vendor/assets/javascripts/ckeditor/samples/old/toolbar/toolbar.html +0 -235
- data/vendor/assets/javascripts/ckeditor/samples/old/uicolor.html +0 -72
- data/vendor/assets/javascripts/ckeditor/samples/old/uilanguages.html +0 -122
- data/vendor/assets/javascripts/ckeditor/samples/old/wysiwygarea/fullpage.html +0 -80
- data/vendor/assets/javascripts/ckeditor/samples/old/xhtmlstyle.html +0 -234
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/css/fontello.css +0 -55
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/LICENSE.txt +0 -10
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/config.json +0 -28
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.eot +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.svg +0 -14
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.ttf +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/font/fontello.woff +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/index.html +0 -446
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/abstracttoolbarmodifier.js +0 -13
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/fulltoolbareditor.js +0 -9
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/toolbarmodifier.js +0 -33
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/js/toolbartextmodifier.js +0 -14
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/codemirror.css +0 -325
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/codemirror.js +0 -288
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/javascript.js +0 -25
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/neo.css +0 -36
- data/vendor/assets/javascripts/ckeditor/samples/toolbarconfigurator/lib/codemirror/show-hint.css +0 -38
- 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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
31
|
+
type = 'ckeditor.wordcount.' + type;
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
100
|
-
|
101
|
-
|
116
|
+
if (config.showParagraphs && (config.showWordCount || config.showCharCount)) {
|
117
|
+
defaultFormat += ", ";
|
118
|
+
}
|
102
119
|
|
103
|
-
|
104
|
-
|
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
|
-
|
108
|
-
|
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
|
-
|
122
|
-
|
123
|
-
|
134
|
+
if (config.showCharCount && config.showWordCount) {
|
135
|
+
defaultFormat += ", ";
|
136
|
+
}
|
124
137
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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
|
-
|
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
|
-
|
159
|
+
var format = defaultFormat;
|
146
160
|
|
147
|
-
|
148
|
-
return "cke_wordcount_" + editorInstance.name;
|
149
|
-
}
|
161
|
+
bbcodePluginLoaded = typeof editor.plugins.bbcode != 'undefined';
|
150
162
|
|
151
|
-
|
152
|
-
|
153
|
-
|
163
|
+
function counterId(editorInstance) {
|
164
|
+
return "cke_wordcount_" + editorInstance.name;
|
165
|
+
}
|
154
166
|
|
155
|
-
|
156
|
-
|
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
|
-
|
171
|
+
function strip(html) {
|
172
|
+
if (bbcodePluginLoaded) {
|
173
|
+
// stripping out BBCode tags [...][/...]
|
174
|
+
return html.replace(/\[.*?\]/gi, '');
|
175
|
+
}
|
162
176
|
|
163
|
-
|
164
|
-
html = filter(html);
|
177
|
+
var tmp = document.createElement("div");
|
165
178
|
|
166
|
-
|
179
|
+
// Add filter before strip
|
180
|
+
html = filter(html);
|
167
181
|
|
168
|
-
|
169
|
-
return "";
|
170
|
-
}
|
182
|
+
tmp.innerHTML = html;
|
171
183
|
|
172
|
-
|
173
|
-
|
184
|
+
if (tmp.textContent == "" && typeof tmp.innerText == "undefined") {
|
185
|
+
return "";
|
186
|
+
}
|
174
187
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
config.filter
|
185
|
-
|
186
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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 ?
|
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(/ /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(" ", " ");
|
244
|
-
|
245
|
-
normalizedText = strip(normalizedText);
|
246
|
-
|
247
|
-
var words = normalizedText.split(/\s+/);
|
248
240
|
|
249
|
-
|
250
|
-
|
251
|
-
|
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
|
-
|
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(/ /g, " ").replace(/(<([^>]+)>)/ig, "").replace(/^\s*$[\n\r]{1,}/gm, "++")
|
253
|
+
.split("++").length);
|
266
254
|
}
|
267
255
|
|
268
|
-
|
269
|
-
|
270
|
-
|
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(" ", " ");
|
279
259
|
|
280
|
-
|
281
|
-
}
|
260
|
+
normalizedText = strip(normalizedText);
|
282
261
|
|
283
|
-
|
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
|
-
|
305
|
-
|
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
|
-
|
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
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
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 (
|
324
|
-
|
325
|
-
|
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
|
-
|
333
|
-
|
289
|
+
function limitRestored(editorInstance) {
|
290
|
+
limitRestoredNotified = true;
|
291
|
+
limitReachedNotified = false;
|
334
292
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
293
|
+
if (!config.warnOnLimitOnly) {
|
294
|
+
editorInstance.fire('saveSnapshot');
|
295
|
+
}
|
296
|
+
|
297
|
+
counterElement(editorInstance).className = "cke_path_item";
|
339
298
|
}
|
340
299
|
|
341
|
-
|
342
|
-
if (
|
343
|
-
|
300
|
+
function updateCounter(editorInstance) {
|
301
|
+
if (!counterElement(editorInstance)) {
|
302
|
+
return;
|
344
303
|
}
|
345
|
-
return true;
|
346
|
-
}
|
347
304
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
305
|
+
var paragraphs = 0,
|
306
|
+
wordCount = 0,
|
307
|
+
charCount = 0,
|
308
|
+
text;
|
352
309
|
|
353
|
-
|
354
|
-
|
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
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
lastCharCount = charCount;
|
361
|
-
}
|
320
|
+
if (text) {
|
321
|
+
if (config.showCharCount) {
|
322
|
+
charCount = countCharacters(text);
|
323
|
+
}
|
362
324
|
|
363
|
-
|
364
|
-
|
365
|
-
|
325
|
+
if (config.showParagraphs) {
|
326
|
+
paragraphs = countParagraphs(text);
|
327
|
+
}
|
366
328
|
|
367
|
-
|
368
|
-
|
369
|
-
|
329
|
+
if (config.showWordCount) {
|
330
|
+
wordCount = countWords(text);
|
331
|
+
}
|
332
|
+
}
|
370
333
|
|
371
|
-
|
372
|
-
|
373
|
-
|
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
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
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
|
-
|
354
|
+
html = html.replace("%wordCount%", wordCount).replace("%charCount%", charCount).replace("%paragraphsCount%", paragraphs);
|
382
355
|
}
|
383
|
-
}
|
384
356
|
|
385
|
-
|
386
|
-
|
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
|
-
|
363
|
+
counterElement(editorInstance).innerText = html;
|
391
364
|
}
|
392
|
-
}
|
393
365
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
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\"> </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\"> </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
|
-
|
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
|
-
|
433
|
-
|
434
|
-
|
379
|
+
lastWordCount = wordCount;
|
380
|
+
lastCharCount = charCount;
|
381
|
+
lastParagraphs = paragraphs;
|
435
382
|
|
436
|
-
|
437
|
-
|
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
|
440
|
-
|
441
|
-
|
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
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
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
|
-
|
403
|
+
limitRestored(editorInstance);
|
404
|
+
} else {
|
405
|
+
editorInstance.fire('saveSnapshot');
|
406
|
+
}
|
454
407
|
|
455
|
-
|
456
|
-
|
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.
|
460
|
-
wordCount
|
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
|
-
|
465
|
-
if(
|
466
|
-
|
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 >
|
474
|
-
|
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.
|
481
|
-
|
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
|
-
|
490
|
-
|
491
|
-
|
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\"> </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\"> </span></div>";
|
502
|
+
}
|
503
|
+
}
|
492
504
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
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
|
+
});
|