X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fscayt%2Fplugin.js;h=b789c5bc7ca0df14822655e13304628a4badd372;hb=614511639979907ceb0da3614122a4d8eb963ad4;hp=718aee613969e56883989baa7a193ed754c3ea00;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/scayt/plugin.js b/_source/plugins/scayt/plugin.js index 718aee6..b789c5b 100644 --- a/_source/plugins/scayt/plugin.js +++ b/_source/plugins/scayt/plugin.js @@ -10,19 +10,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license (function() { - var commandName = 'scaytcheck', - openPage = '', - scayt_paused = null; + var commandName = 'scaytcheck', + openPage = ''; // Checks if a value exists in an array - function in_array(needle, haystack) + function in_array( needle, haystack ) { - var found = false, key; - for (key in haystack) + var found = 0, + key; + for ( key in haystack ) { - if ((haystack[key] === needle) || ( haystack[key] == needle)) + if ( haystack[ key ] == needle ) { - found = true; + found = 1; break; } } @@ -35,28 +35,57 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var createInstance = function() // Create new instance every time Document is created. { + var config = editor.config; // Initialise Scayt instance. var oParams = {}; - oParams.srcNodeRef = editor.document.getWindow().$.frameElement; // Get the iframe. + // Get the iframe. + oParams.srcNodeRef = editor.document.getWindow().$.frameElement; // syntax : AppName.AppVersion@AppRevision - oParams.assocApp = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision; - oParams.customerid = editor.config.scayt_customerid || "1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2"; - oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds; - oParams.userDictionaryName = editor.config.scayt_userDictionaryName; - oParams.sLang = editor.config.scayt_sLang || "en_US"; + oParams.assocApp = 'CKEDITOR.' + CKEDITOR.version + '@' + CKEDITOR.revision; + oParams.customerid = config.scayt_customerid || '1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2'; + oParams.customDictionaryIds = config.scayt_customDictionaryIds || ''; + oParams.userDictionaryName = config.scayt_userDictionaryName || ''; + oParams.sLang = config.scayt_sLang || 'en_US'; + + // Introduce SCAYT onLoad callback. (#5632) + oParams.onLoad = function() + { + // Draw down word marker to avoid being covered by background-color style.(#5466) + if ( !( CKEDITOR.env.ie && CKEDITOR.env.version < 8 ) ) + this.addStyle( this.selectorCss(), 'padding-bottom: 2px !important;' ); + + // Call scayt_control.focus when SCAYT loaded + // and only if editor has focus and scayt control creates at first time (#5720) + if ( editor.focusManager.hasFocus && !plugin.isControlRestored( editor ) ) + this.focus(); - if ( CKEDITOR._scaytParams ) + }; + + oParams.onBeforeChange = function() { - for ( var k in CKEDITOR._scaytParams ) - { - oParams[ k ] = CKEDITOR._scaytParams[ k ]; - } + if ( plugin.getScayt( editor ) && !editor.checkDirty() ) + setTimeout( function(){ editor.resetDirty(); }, 0 ); + }; + + var scayt_custom_params = window.scayt_custom_params; + if ( typeof scayt_custom_params == 'object' ) + { + for ( var k in scayt_custom_params ) + oParams[ k ] = scayt_custom_params[ k ]; } + // needs for restoring a specific scayt control settings + if ( plugin.getControlId( editor ) ) + oParams.id = plugin.getControlId( editor ); var scayt_control = new window.scayt( oParams ); + scayt_control.afterMarkupRemove.push( function( node ) + { + ( new CKEDITOR.dom.element( node, scayt_control.document ) ).mergeSiblings(); + } ); + // Copy config. - var lastInstance = plugin.instances[ editor.name ]; + var lastInstance = plugin.instances[ editor.name ]; if ( lastInstance ) { scayt_control.sLang = lastInstance.sLang; @@ -71,12 +100,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var uiTabs = window.scayt.uiTags; var fTabs = []; - for (var i = 0,l=4; i= 0 ) // Load first time { this.setState( CKEDITOR.TRISTATE_DISABLED ); - - editor.on( 'showScaytState', function() - { - this.removeListener(); - this.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); - }, - this); - plugin.loadEngine( editor ); } } @@ -335,14 +486,26 @@ For licensing, see LICENSE.html or http://ckeditor.com/license beforeInit : function( editor ) { - // Register own rbc menu group. - editor.config.menu_groups = 'scayt_suggest,scayt_moresuggest,scayt_control,' + editor.config.menu_groups; + var items_order = editor.config.scayt_contextMenuItemsOrder + || 'suggest|moresuggest|control', + items_order_str = ""; + + items_order = items_order.split( '|' ); + + if ( items_order && items_order.length ) + { + for ( var pos = 0 ; pos < items_order.length ; pos++ ) + items_order_str += 'scayt_' + items_order[ pos ] + ( items_order.length != parseInt( pos, 10 ) + 1 ? ',' : '' ); + } + + // Put it on top of all context menu items (#5717) + editor.config.menu_groups = items_order_str + ',' + editor.config.menu_groups; }, init : function( editor ) { - var moreSuggestions = {}; - var mainSuggestions = {}; + var moreSuggestions = {}, + mainSuggestions = {}; // Scayt command. var command = editor.addCommand( commandName, commandDefinition ); @@ -350,14 +513,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Add Options dialog. CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) ); // read ui tags - var confuiTabs = editor.config.scayt_uiTabs || "1,1,1"; + var confuiTabs = editor.config.scayt_uiTabs || '1,1,1'; var uiTabs =[]; - // string tp array convert - confuiTabs = confuiTabs.split(","); - // check array length ! allwaays must be 3 filled with 1 or 0 - for (var i=0,l=3; i + *
  • 0 (zero): All suggestions are displayed in the main context menu.
  • + *
  • Positive number: The maximum number of suggestions to shown in context + * menu. Other entries will be shown in "More Suggestions" sub-menu.
  • + *
  • Negative number: No suggestions are shown in the main context menu. All + * entries will be listed in the "Suggestions" sub-menu.
  • + * + * @name CKEDITOR.config.scayt_maxSuggestions + * @type Number + * @default 5 + * @example + * // Display only three suggestions in the main context menu. + * config.scayt_maxSuggestions = 3; + * @example + * // Do not show the suggestions directly. + * config.scayt_maxSuggestions = -1; + */ + +/** + * Sets the customer ID for SCAYT. Required for migration from free version + * with banner to paid version. + * @name CKEDITOR.config.scayt_customerid + * @type String + * @default '' + * @example + * // Load SCAYT using my customer ID. + * config.scayt_customerid = 'your-encrypted-customer-id'; + */ + +/** + * Enables/disables the "More Suggestions" sub-menu in the context menu. + * The possible values are "on" or "off". + * @name CKEDITOR.config.scayt_moreSuggestions + * @type String + * @default 'on' + * @example + * // Disables the "More Suggestions" sub-menu. + * config.scayt_moreSuggestions = 'off'; + */ + +/** + * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore" + * and "Ignore All"). It must be a string with one or more of the following + * words separated by a pipe ("|"): + * + * @name CKEDITOR.config.scayt_contextCommands + * @type String + * @default 'all' + * @example + * // Show only "Add Word" and "Ignore All" in the context menu. + * config.scayt_contextCommands = 'add|ignoreall'; + */ + +/** + * Sets the default spellchecking language for SCAYT. + * @name CKEDITOR.config.scayt_sLang + * @type String + * @default 'en_US' + * @example + * // Sets SCAYT to German. + * config.scayt_sLang = 'de_DE'; + */ + +/** + * Sets the visibility of the SCAYT tabs in the settings dialog and toolbar + * button. The value must contain a "1" (enabled) or "0" (disabled) number for + * each of the following entries, in this precise order, separated by a + * comma (","): "Options", "Languages" and "Dictionary". + * @name CKEDITOR.config.scayt_uiTabs + * @type String + * @default '1,1,1' + * @example + * // Hide the "Languages" tab. + * config.scayt_uiTabs = '1,0,1'; + */ + + +/** + * Set the URL to SCAYT core. Required to switch to licensed version of SCAYT application. + * Further details at http://wiki.spellchecker.net/doku.php?id=3rd:wysiwyg:fckeditor:wscckf3l . + * @name CKEDITOR.config.scayt_srcUrl + * @type String + * @default '' + * @example + * config.scayt_srcUrl = "http://my-host/spellcheck/lf/scayt/scayt.js"; + */ + +/** + * Links SCAYT to custom dictionaries. It's a string containing dictionary ids + * separared by commas (","). Available only for licensed version. + * Further details at http://wiki.spellchecker.net/doku.php?id=custom_dictionary_support . + * @name CKEDITOR.config.scayt_customDictionaryIds + * @type String + * @default '' + * @example + * config.scayt_customDictionaryIds = '3021,3456,3478"'; + */ + +/** + * Makes it possible to activate a custom dictionary on SCAYT. The user + * dictionary name must be used. Available only for licensed version. + * @name CKEDITOR.config.scayt_userDictionaryName + * @type String + * @default '' + * @example + * config.scayt_userDictionaryName = 'MyDictionary'; + */ + +/** + * Define order of placing of SCAYT context menu items by groups. + * It must be a string with one or more of the following + * words separated by a pipe ("|"): + * + * + * @name CKEDITOR.config.scayt_contextMenuItemsOrder + * @type String + * @default 'suggest|moresuggest|control' + * @example + * config.scayt_contextMenuItemsOrder = 'moresuggest|control|suggest'; + */