X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fscayt%2Fplugin.js;h=967767fda6422e3bc21e0b318a31b55cfe44c773;hb=4e90e78dc97789709ee7404359a5517540c27553;hp=b789c5bc7ca0df14822655e13304628a4badd372;hpb=614511639979907ceb0da3614122a4d8eb963ad4;p=ckeditor.git diff --git a/_source/plugins/scayt/plugin.js b/_source/plugins/scayt/plugin.js index b789c5b..967767f 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-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -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 < l; i++ ) - fTabs.push( uiTabs[i] && plugin.uiTabs[i] ); - - plugin.uiTabs = fTabs; try { scayt_control.setDisabled( plugin.isPaused( editor ) === false ); } catch (e) {} @@ -356,10 +347,30 @@ CKEDITOR.plugins.scayt = var scayt_instance = this.getScayt( editor ); return ( scayt_instance ) ? scayt_instance.disabled === false : false; }, + getUiTabs : function( editor ) + { + var uiTabs = []; + + // read UI tabs value from config + var configUiTabs = editor.config.scayt_uiTabs || "1,1,1"; + + // convert string to array + configUiTabs = configUiTabs.split( ',' ); + + // "About us" should be always shown for standard config + configUiTabs[3] = "1"; + + for ( var i = 0; i < 4; i++ ) { + uiTabs[i] = (typeof window.scayt != "undefined" && typeof window.scayt.uiTags != "undefined") + ? (parseInt(configUiTabs[i],10) && window.scayt.uiTags[i]) + : parseInt(configUiTabs[i],10); + } + return uiTabs; + }, loadEngine : function( editor ) { - // SCAYT doesn't work with Firefox2, Opera. - if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 || CKEDITOR.env.opera ) + // SCAYT doesn't work with Firefox2, Opera and AIR. + if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 || CKEDITOR.env.opera || CKEDITOR.env.air ) return editor.fire( 'showScaytState' ); if ( this.engineLoaded === true ) @@ -504,6 +515,22 @@ CKEDITOR.plugins.scayt = init : function( editor ) { + // 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 = {}; @@ -512,27 +539,18 @@ CKEDITOR.plugins.scayt = // 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; i < l; i++ ) - { - var flag = parseInt( confuiTabs[i] || '1', 10 ); - uiTabs.push( flag ); - } + + var uiTabs = plugin.getUiTabs( editor ); var menuGroup = 'scaytButton'; editor.addMenuGroup( menuGroup ); // combine menu items to render - var uiMuneItems = {}; + var uiMenuItems = {}; var lang = editor.lang.scayt; // always added - uiMuneItems.scaytToggle = + uiMenuItems.scaytToggle = { label : lang.enable, command : commandName, @@ -540,7 +558,7 @@ CKEDITOR.plugins.scayt = }; if ( uiTabs[0] == 1 ) - uiMuneItems.scaytOptions = + uiMenuItems.scaytOptions = { label : lang.options, group : menuGroup, @@ -552,7 +570,7 @@ CKEDITOR.plugins.scayt = }; if ( uiTabs[1] == 1 ) - uiMuneItems.scaytLangs = + uiMenuItems.scaytLangs = { label : lang.langs, group : menuGroup, @@ -563,7 +581,7 @@ CKEDITOR.plugins.scayt = } }; if ( uiTabs[2] == 1 ) - uiMuneItems.scaytDict = + uiMenuItems.scaytDict = { label : lang.dictionariesTab, group : menuGroup, @@ -574,7 +592,7 @@ CKEDITOR.plugins.scayt = } }; // always added - uiMuneItems.scaytAbout = + uiMenuItems.scaytAbout = { label : editor.lang.scayt.about, group : menuGroup, @@ -585,10 +603,7 @@ CKEDITOR.plugins.scayt = } }; - uiTabs[3] = 1; // about us tab is always on - plugin.uiTabs = uiTabs; - - editor.addMenuItems( uiMuneItems ); + editor.addMenuItems( uiMenuItems ); editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON, { @@ -610,12 +625,14 @@ CKEDITOR.plugins.scayt = editor.getMenuItem( 'scaytToggle' ).label = lang[ isEnabled ? 'disable' : 'enable' ]; + var uiTabs = plugin.getUiTabs( editor ); + return { scaytToggle : CKEDITOR.TRISTATE_OFF, - scaytOptions : isEnabled && plugin.uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, - scaytLangs : isEnabled && plugin.uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, - scaytDict : isEnabled && plugin.uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, - scaytAbout : isEnabled && plugin.uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED + scaytOptions : isEnabled && uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, + scaytLangs : isEnabled && uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, + scaytDict : isEnabled && uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, + scaytAbout : isEnabled && uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED }; } }); @@ -626,7 +643,7 @@ CKEDITOR.plugins.scayt = editor.contextMenu.addListener( function( element, selection ) { if ( !plugin.isScaytEnabled( editor ) - || selection.getCommonAncestor().isReadOnly() ) + || selection.getRanges()[ 0 ].checkReadOnly() ) return null; var scayt_control = plugin.getScayt( editor ), @@ -758,7 +775,7 @@ CKEDITOR.plugins.scayt = { editor.removeListener( 'showScaytState', showInitialState ); - if ( !CKEDITOR.env.opera ) + if ( !CKEDITOR.env.opera && !CKEDITOR.env.air ) command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); else command.setState( CKEDITOR.TRISTATE_DISABLED ); @@ -766,7 +783,7 @@ CKEDITOR.plugins.scayt = editor.on( 'showScaytState', showInitialState ); - if ( CKEDITOR.env.opera ) + if ( CKEDITOR.env.opera || CKEDITOR.env.air ) { editor.on( 'instanceReady', function() {