]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blame - sources/plugins/wsc/plugin.js
Initial commit
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / wsc / plugin.js
CommitLineData
7adcb81e
IB
1// Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\r
2// For licensing, see LICENSE.md or http://ckeditor.com/license\r
3\r
4CKEDITOR.plugins.add( 'wsc', {\r
5 requires: 'dialog',\r
6 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%\r
7 icons: 'spellchecker', // %REMOVE_LINE_CORE%\r
8 hidpi: true, // %REMOVE_LINE_CORE%\r
9 parseApi: function(editor) {\r
10 editor.config.wsc_onFinish = (typeof editor.config.wsc_onFinish === 'function') ? editor.config.wsc_onFinish : function() {};\r
11 editor.config.wsc_onClose = (typeof editor.config.wsc_onClose === 'function') ? editor.config.wsc_onClose : function() {};\r
12 },\r
13 parseConfig: function(editor) {\r
14 editor.config.wsc_customerId = editor.config.wsc_customerId || CKEDITOR.config.wsc_customerId || '1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk';\r
15 editor.config.wsc_customDictionaryIds = editor.config.wsc_customDictionaryIds || CKEDITOR.config.wsc_customDictionaryIds || '';\r
16 editor.config.wsc_userDictionaryName = editor.config.wsc_userDictionaryName || CKEDITOR.config.wsc_userDictionaryName || '';\r
17 editor.config.wsc_customLoaderScript = editor.config.wsc_customLoaderScript || CKEDITOR.config.wsc_customLoaderScript;\r
18\r
19 CKEDITOR.config.wsc_cmd = editor.config.wsc_cmd || CKEDITOR.config.wsc_cmd || 'spell'; // spell, thes or grammar. default tab\r
20 CKEDITOR.config.wsc_version="v4.3.0-master-d769233";\r
21 CKEDITOR.config.wsc_removeGlobalVariable = true;\r
22 },\r
23 init: function( editor ) {\r
24 var commandName = 'checkspell';\r
25\r
26 var strNormalDialog = 'dialogs/wsc.js',\r
27 strIeDialog = 'dialogs/wsc_ie.js',\r
28 strDialog,\r
29 self = this,\r
30 env = CKEDITOR.env;\r
31\r
32 self.parseConfig(editor);\r
33 self.parseApi(editor);\r
34 var command = editor.addCommand( commandName, new CKEDITOR.dialogCommand( commandName ) );\r
35\r
36 // SpellChecker doesn't work in Opera, with custom domain, IE Compatibility Mode and IE (8 & 9) Quirks Mode\r
37 command.modes = { wysiwyg: ( !CKEDITOR.env.opera && !CKEDITOR.env.air && document.domain == window.location.hostname &&\r
38 !( env.ie && ( env.version < 8 || env.quirks ) ) ) };\r
39\r
40 if(typeof editor.plugins.scayt == 'undefined'){\r
41 editor.ui.addButton && editor.ui.addButton( 'SpellChecker', {\r
42 label: editor.lang.wsc.toolbar,\r
43 click: function(editor) {\r
44 var inlineMode = (editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE),\r
45 text = inlineMode ? editor.container.getText() : editor.document.getBody().getText();\r
46\r
47 text = text.replace(/\s/g, '');\r
48\r
49 if(text) {\r
50 editor.execCommand('checkspell');\r
51 } else {\r
52 alert('Nothing to check!');\r
53 }\r
54 },\r
55 toolbar: 'spellchecker,10'\r
56 });\r
57 }\r
58\r
59\r
60 if ( CKEDITOR.env.ie && CKEDITOR.env.version <= 7 ){\r
61 strDialog = strIeDialog;\r
62 } else {\r
63 if (!window.postMessage) {\r
64 strDialog = strIeDialog;\r
65 } else {\r
66 strDialog = strNormalDialog;\r
67 }\r
68 }\r
69 CKEDITOR.dialog.add( commandName, this.path + strDialog );\r
70 }\r
71\r
72});\r
73\r
74/**\r
75 * The parameter sets the customer ID for WSC. It is used for hosted users only. It is required for migration from free\r
76 * to trial or paid versions.\r
77 *\r
78 * config.wsc_customerId = 'encrypted-customer-id';\r
79 *\r
80 * @cfg {String} [wsc_customerId='1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk']\r
81 * @member CKEDITOR.config\r
82 */\r
83\r
84/**\r
85 * It links WSC to custom dictionaries. It should be a string with dictionary IDs\r
86 * separated by commas (`','`). Available only for the licensed version.\r
87 *\r
88 * Further details at [http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed](http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed)\r
89 *\r
90 * config.wsc_customDictionaryIds = '1,3001';\r
91 *\r
92 * @cfg {String} [wsc_customDictionaryIds='']\r
93 * @member CKEDITOR.config\r
94 */\r
95\r
96/**\r
97 * It activates a user dictionary for WSC. The user dictionary name should be used. Available only for the licensed version.\r
98 *\r
99 * config.wsc_userDictionaryName = 'MyUserDictionaryName';\r
100 *\r
101 * @cfg {String} [wsc_userDictionaryName='']\r
102 * @member CKEDITOR.config\r
103 */\r
104\r
105/**\r
106 * The parameter sets the URL to WSC file. It is required to the licensed version of WSC application.\r
107 *\r
108 * Further details available at [http://wiki.webspellchecker.net/doku.php?id=migration:hosredfreetolicensedck](http://wiki.webspellchecker.net/doku.php?id=migration:hosredfreetolicensedck)\r
109 *\r
110 * config.wsc_customLoaderScript = "http://my-host/spellcheck/lf/22/js/wsc_fck2plugin.js";\r
111 *\r
112 * @cfg {String} [wsc_customLoaderScript='']\r
113 * @member CKEDITOR.config\r
114 */\r
115\r
116/**\r
117 * The parameter sets the default spellchecking language for WSC.\r
118 * Possible values are:\r
119 * `'en_US'`, `'en_GB'`, `'pt_BR'`, `'da_DK'`,\r
120 * `'nl_NL'`, `'en_CA'`, `'fi_FI'`, `'fr_FR'`,\r
121 * `'fr_CA'`, `'de_DE'`, `'el_GR'`, `'it_IT'`,\r
122 * `'nb_NO'`, `'pt_PT'`, `'es_ES'`, `'sv_SE'`.\r
123 *\r
124 * Further details available at [http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:supportedlanguages](http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:supportedlanguages)\r
125 *\r
126 * config.wsc_lang = 'de_DE';\r
127 *\r
128 * @cfg {String} [wsc_lang='en_US']\r
129 * @member CKEDITOR.config\r
130 */\r
131\r
132/**\r
133 * The parameter sets the active tab, when the WSC dialog is opened.\r
134 * Possible values are:\r
135 * `'spell'`, `'thes'`, `'grammar'`.\r
136 *\r
137 * // Sets active tab thesaurus.\r
138 * config.wsc_cmd = 'thes';\r
139 *\r
140 * @cfg {String} [wsc_cmd='spell']\r
141 * @member CKEDITOR.config\r
142 */\r