X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fscayt%2Fplugin.js;h=0f3f3391d76907d8e7f700d0137e12c3bdc2a33d;hb=9afde8772159bd3436f1f5b7862960307710ae5a;hp=f64d25e8c994f68a68ce4b7600a30910557b7c03;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;p=ckeditor.git diff --git a/_source/plugins/scayt/plugin.js b/_source/plugins/scayt/plugin.js index f64d25e..0f3f339 100644 --- a/_source/plugins/scayt/plugin.js +++ b/_source/plugins/scayt/plugin.js @@ -10,20 +10,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license (function() { - var commandName = 'scaytcheck', - openPage = '', - scayt_paused = null, - scayt_control_id = 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; } } @@ -36,39 +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 = {}; // 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() + { + // 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(); + + }; oParams.onBeforeChange = function() { - if ( !editor.checkDirty() ) - setTimeout( function(){ editor.resetDirty(); } ); + 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') + 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 ( scayt_control_id ) - oParams.id = scayt_control_id; + 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; @@ -83,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 ); } } @@ -354,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 ); @@ -374,9 +518,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // 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; i + *
  • 'suggest' - main suggestion word list,
  • + *
  • 'moresuggest' - more suggestions word list,
  • + *
  • 'control' - SCAYT commands, such as 'Ignore' and 'Add Word'
  • + * + * + * @name CKEDITOR.config.scayt_contextMenuItemsOrder + * @type String + * @default 'suggest|moresuggest|control' + * @example + * config.scayt_contextMenuItemsOrder = 'moresuggest|control|suggest'; + */