Ticket #5145: 5145_3.patch

File 5145_3.patch, 8.9 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/plugins/scayt/plugin.js

     
    4141                        // syntax : AppName.AppVersion@AppRevision
    4242                        oParams.assocApp  = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision;
    4343                        oParams.customerid = editor.config.scayt_customerid  || "1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2";
    44                         oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds;
    45                         oParams.userDictionaryName = editor.config.scayt_userDictionaryName;
     44                        oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds || '';
     45                        oParams.userDictionaryName = editor.config.scayt_userDictionaryName || '';
    4646                        oParams.sLang = editor.config.scayt_sLang || "en_US";
    4747
    48                         if ( CKEDITOR._scaytParams )
     48                        if ( CKEDITOR.config._scaytParams )
    4949                        {
    50                                 for ( var k in CKEDITOR._scaytParams )
     50                                for ( var k in CKEDITOR.config._scaytParams )
    5151                                {
    52                                         oParams[ k ] = CKEDITOR._scaytParams[ k ];
     52                                        oParams[ k ] = CKEDITOR.config._scaytParams[ k ];
    5353                                }
    5454                        }
    5555
     
    103103
    104104                editor.on( 'beforeCommandExec', function( ev )          // Disable SCAYT before Source command execution.
    105105                        {
     106                                if ( ev.data.name == 'removeFormat' && editor.mode == 'wysiwyg' )
     107                                {
     108                                       
     109                                        if ( plugin.isScaytEnabled( editor ) )
     110                                                window.setTimeout(function(){plugin.getScayt(editor).refresh()},10);
     111                                       
     112                                }
    106113                                if ( (ev.data.name == 'source' ||  ev.data.name == 'newpage') && editor.mode == 'wysiwyg' )
    107114                                {
    108115                                        var scayt_instanse = plugin.getScayt( editor );
    109116                                        if ( scayt_instanse )
    110117                                        {
    111118                                                scayt_paused = scayt_instanse.paused = !scayt_instanse.disabled;
    112                                                 scayt_instanse.destroy();
    113                                                 delete plugin.instances[ editor.name ];
     119                                                scayt_instanse.destroy( true );
     120                                                delete plugin.instances[editor.name];
    114121                                        }
    115122                                }
    116123                        });
     
    118125
    119126                editor.on( 'destroy', function()
    120127                        {
    121                                 plugin.getScayt( editor ).destroy();
     128                                plugin.getScayt( editor ).destroy( true );
    122129                        });
    123130                // Listen to data manipulation to reflect scayt markup.
    124131                editor.on( 'afterSetData', function()
    125132                        {
    126133                                if ( plugin.isScaytEnabled( editor ) )
     134                                {
    127135                                        plugin.getScayt( editor ).refresh();
     136
     137                                        if( !editor.checkDirty() )
     138                                                setTimeout( function(){ editor.resetDirty(); } );
     139                                }
    128140                        });
    129141
    130142                // Reload spell-checking for current word after insertion completed.
     
    218230                },
    219231                loadEngine : function( editor )
    220232                {
     233                        if ( CKEDITOR.env.opera )
     234                                return;
    221235                        if ( this.engineLoaded === true )
    222236                                return onEngineLoad.apply( editor );    // Add new instance.
    223237                        else if ( this.engineLoaded == -1 )                     // We are waiting.
     
    238252                        var protocol = document.location.protocol;
    239253                        // Default to 'http' for unknown.
    240254                        protocol = protocol.search( /https?:/) != -1? protocol : 'http:';
    241                         var baseUrl  = "svc.spellchecker.net/spellcheck3/lf/scayt/scayt21.js";
     255                        var baseUrl  = "svc.spellchecker.net/spellcheck3/lf/scayt/scayt22.js";
    242256
    243257                        var scaytUrl  =  editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl );
    244258                        var scaytConfigBaseUrl =  plugin.parseUrl( scaytUrl ).path +  "/";
     
    457471                        // If the "contextmenu" plugin is loaded, register the listeners.
    458472                        if ( editor.contextMenu && editor.addMenuItems )
    459473                        {
    460                                 editor.contextMenu.addListener( function( element )
     474                                editor.contextMenu.addListener( function()
    461475                                        {
    462                                                 if ( !( plugin.isScaytEnabled( editor ) && element ) )
     476                                                if ( !plugin.isScaytEnabled( editor ) )
    463477                                                        return null;
    464478
    465479                                                var scayt_control = plugin.getScayt( editor ),
    466                                                         word = scayt_control.getWord( element.$ );
     480                                                        node = scayt_control.getScaytNode();
    467481
     482                                                if ( !node )
     483                                                        return null;
     484
     485                                                word = scayt_control.getWord( node );
     486
    468487                                                if ( !word )
    469488                                                        return null;
    470489
     
    508527                                                                                        scayt_control.replace(el, s);
    509528                                                                                }
    510529                                                                        };
    511                                                                 })( element.$, items_suggestion[i] );
     530                                                                })( node, items_suggestion[i] );
    512531
    513532                                                        if ( i < maxSuggestions )
    514533                                                        {
     
    546565                                                {
    547566                                                        var ignore_command = {
    548567                                                                exec: function(){
    549                                                                         scayt_control.ignore(element.$);
     568                                                                        scayt_control.ignore( node );
    550569                                                                }
    551570                                                        };
    552571                                                        addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1);
     
    557576                                                {
    558577                                                        var ignore_all_command = {
    559578                                                                exec: function(){
    560                                                                         scayt_control.ignoreAll(element.$);
     579                                                                        scayt_control.ignoreAll( node );
    561580                                                                }
    562581                                                        };
    563582                                                        addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2);
     
    568587                                                {
    569588                                                        var addword_command = {
    570589                                                                exec: function(){
    571                                                                         window.scayt.addWordToUserDictionary(element.$);
     590                                                                        window.scayt.addWordToUserDictionary( node );
    572591                                                                }
    573592                                                        };
    574593                                                        addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3);
     
    598617        });
    599618})();
    600619
    601 // TODO: Documentation
    602 // CKEDITOR.config.scayt_maxSuggestions
    603 // CKEDITOR.config.scayt_autoStartup
     620/**
     621 * If enabled (true), turns on SCAYT automatically after loading the editor.
     622 * @name CKEDITOR.config.scayt_autoStartup
     623 * @type Boolean
     624 * @default false
     625 * @example
     626 * config.scayt_autoStartup = true;
     627 */
     628
     629/**
     630 * Defines the number of SCAYT suggestions to show in the main context menu.
     631 * The possible values are:
     632 * <ul>
     633 *      <li>0 (zero): All suggestions are displayed in the main context menu.</li>
     634 *      <li>Positive number: The maximum number of suggestions to shown in context
     635 *              menu. Other entries will be shown in "More Suggestions" sub-menu.</li>
     636 *      <li>Negative number: No suggestions are shown in the main context menu. All
     637 *              entries will be listed in the "Suggestions" sub-menu.</li>
     638 * </ul>
     639 * @name CKEDITOR.config.scayt_maxSuggestions
     640 * @type Number
     641 * @default 5
     642 * @example
     643 * // Display only three suggestions in the main context menu.
     644 * config.scayt_maxSuggestions = 3;
     645 * @example
     646 * // Do not show the suggestions directly.
     647 * config.scayt_maxSuggestions = -1;
     648 */
     649
     650/**
     651 * Sets the customer ID for SCAYT.
     652 * @name CKEDITOR.config.scayt_customerid
     653 * @type String
     654 * @default ''
     655 * @example
     656 * // Load SCAYT using my customer ID.
     657 * config.scayt_customerid  = 'your-encrypted-customer-id';
     658 */
     659
     660/**
     661 * Enables/disables the "More Suggestions" sub-menu in the context menu.
     662 * The possible values are "on" or "off".
     663 * @name CKEDITOR.config.scayt_moreSuggestions
     664 * @type String
     665 * @default 'on'
     666 * @example
     667 * // Disables the "More Suggestions" sub-menu.
     668 * config.scayt_moreSuggestions = 'off';
     669 */
     670
     671/**
     672 * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore"
     673 * and "Ignore All"). It must be a string with one or more of the following
     674 * words separated by a pipe ("|"):
     675 * <ul>
     676 *      <li>"off": disables all options.</li>
     677 *      <li>"all": enables all options.</li>
     678 *      <li>"ignore": enables the "Ignore" option.</li>
     679 *      <li>"ignoreall": enables the "Ignore All" option.</li>
     680 *      <li>"add": enables the "Add Word" option.</li>
     681 * </ul>
     682 * @name CKEDITOR.config.scayt_contextCommands
     683 * @type String
     684 * @default 'all'
     685 * @example
     686 * // Show only "Add Word" and "Ignore All" in the context menu.
     687 * config.scayt_contextCommands = 'add|ignoreall';
     688 */
     689
     690/**
     691 * Sets the default spellchecking language for SCAYT.
     692 * @name CKEDITOR.config.scayt_sLang
     693 * @type String
     694 * @default 'en_US'
     695 * @example
     696 * // Sets SCAYT to German.
     697 * config.scayt_sLang = 'de_DE';
     698 */
     699
     700/**
     701 * Sets the visibility of the SCAYT tabs in the settings dialog and toolbar
     702 * button. The value must contain a "1" (enabled) or "0" (disabled) number for
     703 * each of the following entries, in this precise order, separated by a
     704 * comma (","): "Options", "Languages" and "Dictionary".
     705 * @name CKEDITOR.config.scayt_uiTabs
     706 * @type String
     707 * @default '1,1,1'
     708 * @example
     709 * // Hide the "Languages" tab.
     710 * config.scayt_uiTabs = '1,0,1';
     711 */
     712
     713/**
     714 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids
     715 * separared by commas (",").
     716 * @name CKEDITOR.config.scayt_customDictionaryIds
     717 * @type String
     718 * @default ''
     719 * @example
     720 * config.scayt_customDictionaryIds = '3021,3456,3478"';
     721 */
     722
     723/**
     724 * Makes it possible to activate a custom dictionary on SCAYT. The user
     725 * dictionary name must be used.
     726 * @name CKEDITOR.config.scayt_userDictionaryName
     727 * @type String
     728 * @default ''
     729 * @example
     730 * config.scayt_userDictionaryName = 'MyDictionary';
     731 */
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy