X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fscayt%2Fplugin.js;h=336fb3ab7ed85bfe1af818992db70581290cff33;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=ba42fa9159c754f04c09e5afd678fdbba5939c9e;hpb=66f4ae0bf0280ed56bf7c0f4ab175424dd1d47a0;p=ckeditor.git diff --git a/_source/plugins/scayt/plugin.js b/_source/plugins/scayt/plugin.js index ba42fa9..336fb3a 100644 --- a/_source/plugins/scayt/plugin.js +++ b/_source/plugins/scayt/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -10,18 +10,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license (function() { - var commandName = 'scaytcheck', - openPage = ''; + 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; } } @@ -34,16 +35,17 @@ 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 = {}; // 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.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() @@ -62,20 +64,18 @@ For licensing, see LICENSE.html or http://ckeditor.com/license oParams.onBeforeChange = function() { if ( plugin.getScayt( editor ) && !editor.checkDirty() ) - setTimeout( function(){ editor.resetDirty(); } ); + setTimeout( function(){ editor.resetDirty(); }, 0 ); }; var scayt_custom_params = window.scayt_custom_params; - if ( typeof scayt_custom_params == 'object') + 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); + if ( plugin.getControlId( editor ) ) + oParams.id = plugin.getControlId( editor ); var scayt_control = new window.scayt( oParams ); @@ -85,7 +85,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } ); // Copy config. - var lastInstance = plugin.instances[ editor.name ]; + var lastInstance = plugin.instances[ editor.name ]; if ( lastInstance ) { scayt_control.sLang = lastInstance.sLang; @@ -95,15 +95,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license plugin.instances[ editor.name ] = scayt_control; - //window.scayt.uiTags - var menuGroup = 'scaytButton'; - var uiTabs = window.scayt.uiTags; - var fTabs = []; - - for (var i = 0,l=4; i= 0 ) // Load first time + else if ( !editor.config.scayt_autoStartup && plugin.engineLoaded >= 0 ) // Load first time { this.setState( CKEDITOR.TRISTATE_DISABLED ); plugin.loadEngine( editor ); @@ -495,58 +505,62 @@ CKEDITOR.plugins.scayt = if ( items_order && items_order.length ) { - for ( var pos in items_order ) + for ( var pos = 0 ; pos < items_order.length ; pos++ ) items_order_str += 'scayt_' + items_order[ pos ] + ( items_order.length != parseInt( pos, 10 ) + 1 ? ',' : '' ); } - // Register scayt rbc menu group. - if ( editor.config.scayt_contextMenuOntop ) - // Put it on top of all context menu items - editor.config.menu_groups = items_order_str + ',' + editor.config.menu_groups; - else - // Put it down - editor.config.menu_groups = editor.config.menu_groups + ',' +items_order_str; + // 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 = {}; + // Delete span[data-scaytid] when text pasting in editor (#6921) + var dataFilter = editor.dataProcessor && editor.dataProcessor.dataFilter; + var dataFilterRules = + { + elements : + { + span : function( element ) + { + var attrs = element.attributes; + if ( attrs && attrs[ 'data-scaytid' ] ) + delete element.name; + } + } + }; + dataFilter && dataFilter.addRules( dataFilterRules ); + + var moreSuggestions = {}, + mainSuggestions = {}; // Scayt command. var command = editor.addCommand( commandName, commandDefinition ); // 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 uiTabs =[]; - // string to array convert - confuiTabs = confuiTabs.split( ',' ); - // check array length ! always must be 3 filled with 1 or 0 - for (var i=0,l=3; itrue), turns on SCAYT automatically + * after loading the editor. * @name CKEDITOR.config.scayt_autoStartup * @type Boolean - * @default true + * @default false * @example - * config.scayt_autoStartup = false; + * config.scayt_autoStartup = true; */ /** * Defines the number of SCAYT suggestions to show in the main context menu. - * The possible values are: + * Possible values are: * * @name CKEDITOR.config.scayt_maxSuggestions * @type Number - * @default 5 + * @default 5 * @example * // Display only three suggestions in the main context menu. * config.scayt_maxSuggestions = 3; @@ -838,11 +852,11 @@ CKEDITOR.plugins.scayt = */ /** - * Sets the customer ID for SCAYT. Required for migration from free version - * with banner to paid version. + * Sets the customer ID for SCAYT. Required for migration from free, + * ad-supported version to paid, ad-free version. * @name CKEDITOR.config.scayt_customerid * @type String - * @default '' + * @default '' * @example * // Load SCAYT using my customer ID. * config.scayt_customerid = 'your-encrypted-customer-id'; @@ -850,10 +864,10 @@ CKEDITOR.plugins.scayt = /** * Enables/disables the "More Suggestions" sub-menu in the context menu. - * The possible values are "on" or "off". + * Possible values are on and off. * @name CKEDITOR.config.scayt_moreSuggestions * @type String - * @default 'on' + * @default 'on' * @example * // Disables the "More Suggestions" sub-menu. * config.scayt_moreSuggestions = 'off'; @@ -861,100 +875,99 @@ CKEDITOR.plugins.scayt = /** * 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 ("|"): + * and "Ignore All"). This must be a string with one or more of the following + * words separated by a pipe character ("|"): * * @name CKEDITOR.config.scayt_contextCommands * @type String - * @default 'all' + * @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. + * Sets the default spell checking language for SCAYT. Possible values are: + * en_US, en_GB, pt_BR, da_DK, + * nl_NL, en_CA, fi_FI, fr_FR, + * fr_CA, de_DE, el_GR, it_IT, + * nb_NO, pt_PT, es_ES, sv_SE. * @name CKEDITOR.config.scayt_sLang * @type String - * @default 'en_US' + * @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". + * Sets the visibility of particular tabs in the SCAYT dialog window and toolbar + * button. This setting must contain a 1 (enabled) or 0 + * (disabled) value 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' + * @default '1,1,1' * @example - * // Hide the "Languages" tab. + * // Hides 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 . + * Sets the URL to SCAYT core. Required to switch to the licensed version of SCAYT application. + * Further details available at + * + * http://wiki.webspellchecker.net/doku.php?id=migration:hosredfreetolicensedck. * @name CKEDITOR.config.scayt_srcUrl * @type String - * @default '' + * @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 . + * Links SCAYT to custom dictionaries. This is a string containing dictionary IDs + * separared by commas (","). Available only for the licensed version. + * Further details at + * + * http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed. * @name CKEDITOR.config.scayt_customDictionaryIds * @type String - * @default '' + * @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. + * Makes it possible to activate a custom dictionary in SCAYT. The user + * dictionary name must be used. Available only for the licensed version. * @name CKEDITOR.config.scayt_userDictionaryName * @type String - * @default '' + * @default '' * @example * config.scayt_userDictionaryName = 'MyDictionary'; */ /** - * Makes it possible to place the SCAYT context menu items above others. - * @name CKEDITOR.config.scayt_contextMenuOntop - * @type Boolean - * @default false - * @example - * config.scayt_contextMenuOntop = true; - */ - -/** - * 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 ("|"): + * Defines the order SCAYT context menu items by groups. + * This must be a string with one or more of the following + * words separated by a pipe character ("|"): * * * @name CKEDITOR.config.scayt_contextMenuItemsOrder * @type String - * @default 'suggest|moresuggest|control' + * @default 'suggest|moresuggest|control' * @example * config.scayt_contextMenuItemsOrder = 'moresuggest|control|suggest'; */