plugin.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  2. // For licensing, see LICENSE.md or http://ckeditor.com/license
  3. CKEDITOR.plugins.add( 'wsc', {
  4. requires: 'dialog',
  5. lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en-au,en-ca,en-gb,en,eo,es,et,eu,fa,fi,fo,fr-ca,fr,gl,gu,he,hi,hr,hu,is,it,ja,ka,km,ko,lt,lv,mk,mn,ms,nb,nl,no,pl,pt-br,pt,ro,ru,sk,sl,sr-latn,sr,sv,th,tr,ug,uk,vi,zh-cn,zh', // %REMOVE_LINE_CORE%
  6. icons: 'spellchecker', // %REMOVE_LINE_CORE%
  7. hidpi: true, // %REMOVE_LINE_CORE%
  8. parseApi: function(editor) {
  9. editor.config.wsc_onFinish = (typeof editor.config.wsc_onFinish === 'function') ? editor.config.wsc_onFinish : function() {};
  10. editor.config.wsc_onClose = (typeof editor.config.wsc_onClose === 'function') ? editor.config.wsc_onClose : function() {};
  11. },
  12. parseConfig: function(editor) {
  13. editor.config.wsc_customerId = editor.config.wsc_customerId || CKEDITOR.config.wsc_customerId || '1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk';
  14. editor.config.wsc_customDictionaryIds = editor.config.wsc_customDictionaryIds || CKEDITOR.config.wsc_customDictionaryIds || '';
  15. editor.config.wsc_userDictionaryName = editor.config.wsc_userDictionaryName || CKEDITOR.config.wsc_userDictionaryName || '';
  16. editor.config.wsc_customLoaderScript = editor.config.wsc_customLoaderScript || CKEDITOR.config.wsc_customLoaderScript;
  17. CKEDITOR.config.wsc_cmd = editor.config.wsc_cmd || CKEDITOR.config.wsc_cmd || 'spell'; // spell, thes or grammar. default tab
  18. CKEDITOR.config.wsc_version="v4.3.0-master-d769233";
  19. CKEDITOR.config.wsc_removeGlobalVariable = true;
  20. },
  21. init: function( editor ) {
  22. var commandName = 'checkspell';
  23. var strNormalDialog = 'dialogs/wsc.js',
  24. strIeDialog = 'dialogs/wsc_ie.js',
  25. strDialog,
  26. self = this,
  27. env = CKEDITOR.env;
  28. self.parseConfig(editor);
  29. self.parseApi(editor);
  30. var command = editor.addCommand( commandName, new CKEDITOR.dialogCommand( commandName ) );
  31. // SpellChecker doesn't work in Opera, with custom domain, IE Compatibility Mode and IE (8 & 9) Quirks Mode
  32. command.modes = { wysiwyg: ( !CKEDITOR.env.opera && !CKEDITOR.env.air && document.domain == window.location.hostname &&
  33. !( env.ie && ( env.version < 8 || env.quirks ) ) ) };
  34. if(typeof editor.plugins.scayt == 'undefined'){
  35. editor.ui.addButton && editor.ui.addButton( 'SpellChecker', {
  36. label: editor.lang.wsc.toolbar,
  37. click: function(editor) {
  38. var inlineMode = (editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE),
  39. text = inlineMode ? editor.container.getText() : editor.document.getBody().getText();
  40. text = text.replace(/\s/g, '');
  41. if(text) {
  42. editor.execCommand('checkspell');
  43. } else {
  44. alert('Nothing to check!');
  45. }
  46. },
  47. toolbar: 'spellchecker,10'
  48. });
  49. }
  50. if ( CKEDITOR.env.ie && CKEDITOR.env.version <= 7 ){
  51. strDialog = strIeDialog;
  52. } else {
  53. if (!window.postMessage) {
  54. strDialog = strIeDialog;
  55. } else {
  56. strDialog = strNormalDialog;
  57. }
  58. }
  59. CKEDITOR.dialog.add( commandName, this.path + strDialog );
  60. }
  61. });
  62. /**
  63. * The parameter sets the customer ID for WSC. It is used for hosted users only. It is required for migration from free
  64. * to trial or paid versions.
  65. *
  66. * config.wsc_customerId = 'encrypted-customer-id';
  67. *
  68. * @cfg {String} [wsc_customerId='1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk']
  69. * @member CKEDITOR.config
  70. */
  71. /**
  72. * It links WSC to custom dictionaries. It should be a string with dictionary IDs
  73. * separated by commas (`','`). Available only for the licensed version.
  74. *
  75. * Further details at [http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed](http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed)
  76. *
  77. * config.wsc_customDictionaryIds = '1,3001';
  78. *
  79. * @cfg {String} [wsc_customDictionaryIds='']
  80. * @member CKEDITOR.config
  81. */
  82. /**
  83. * It activates a user dictionary for WSC. The user dictionary name should be used. Available only for the licensed version.
  84. *
  85. * config.wsc_userDictionaryName = 'MyUserDictionaryName';
  86. *
  87. * @cfg {String} [wsc_userDictionaryName='']
  88. * @member CKEDITOR.config
  89. */
  90. /**
  91. * The parameter sets the URL to WSC file. It is required to the licensed version of WSC application.
  92. *
  93. * Further details available at [http://wiki.webspellchecker.net/doku.php?id=migration:hosredfreetolicensedck](http://wiki.webspellchecker.net/doku.php?id=migration:hosredfreetolicensedck)
  94. *
  95. * config.wsc_customLoaderScript = "http://my-host/spellcheck/lf/22/js/wsc_fck2plugin.js";
  96. *
  97. * @cfg {String} [wsc_customLoaderScript='']
  98. * @member CKEDITOR.config
  99. */
  100. /**
  101. * The parameter sets the default spellchecking language for WSC.
  102. * Possible values are:
  103. * `'en_US'`, `'en_GB'`, `'pt_BR'`, `'da_DK'`,
  104. * `'nl_NL'`, `'en_CA'`, `'fi_FI'`, `'fr_FR'`,
  105. * `'fr_CA'`, `'de_DE'`, `'el_GR'`, `'it_IT'`,
  106. * `'nb_NO'`, `'pt_PT'`, `'es_ES'`, `'sv_SE'`.
  107. *
  108. * Further details available at [http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:supportedlanguages](http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:supportedlanguages)
  109. *
  110. * config.wsc_lang = 'de_DE';
  111. *
  112. * @cfg {String} [wsc_lang='en_US']
  113. * @member CKEDITOR.config
  114. */
  115. /**
  116. * The parameter sets the active tab, when the WSC dialog is opened.
  117. * Possible values are:
  118. * `'spell'`, `'thes'`, `'grammar'`.
  119. *
  120. * // Sets active tab thesaurus.
  121. * config.wsc_cmd = 'thes';
  122. *
  123. * @cfg {String} [wsc_cmd='spell']
  124. * @member CKEDITOR.config
  125. */