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