Ticket #9161: 4688.patch

File 4688.patch, 2.0 KB (added by Jakub Ś, 12 years ago)
  • _source/plugins/scayt/plugin.js

     
    6161
    6262                                };
    6363
    64                         oParams.onBeforeChange = function()
    65                         {
    66                                 if ( plugin.getScayt( editor ) && !editor.checkDirty() )
    67                                         setTimeout( function(){ editor.resetDirty(); }, 0 );
    68                         };
    69 
    7064                        var scayt_custom_params = window.scayt_custom_params;
    7165                        if ( typeof scayt_custom_params == 'object' )
    7266                        {
     
    128122                                        var scayt_instance = plugin.getScayt( editor );
    129123                                        if ( scayt_instance )
    130124                                        {
     125                                                // Clear previousValue from SCAYT mark-up set by resetDirty() called by OnSelectionChange       
     126                                                if(!editor.checkDirty())
     127                                                        editor._.previousValue = scayt_instance.reset(editor._.previousValue);
     128
    131129                                                plugin.setPaused( editor, !scayt_instance.disabled );
    132130                                                // store a control id for restore a specific scayt control settings
    133131                                                plugin.setControlId( editor, scayt_instance.id );
     
    272270                        };
    273271                });
    274272
     273                var editorCheckDirty = CKEDITOR.editor.prototype;
     274               
     275                // Override editor.checkDirty method avoid CK checkDirty functionality to fix SCAYT issues with incorrect checkDirty behavior.
     276                editorCheckDirty.checkDirty = CKEDITOR.tools.override(editorCheckDirty.checkDirty, function( org )
     277                        {
     278                                return function()
     279                                {
     280                                        var retval = null,
     281                                        scayt_instance = plugin.getScayt( editor );
     282                                         
     283                                        if ( scayt_instance && plugin.isScaytReady( editor ) )
     284                                        {
     285                                                        var currentData = scayt_instance.reset(editor.getSnapshot());//.replace(/ /g, " ");
     286                                                        var prevData = scayt_instance.reset(editor._.previousValue);//.replace(/ /g, " ");
     287                                                        retval = ( editor.mayBeDirty && currentData !== prevData );
     288                                        }
     289                                        else
     290                                        {
     291                                                retval = org.apply(this);
     292                                        }
     293                                       
     294                                        return retval;
     295                                }
     296                        });
     297
    275298                if ( editor.document )
    276299                        createInstance();
    277300        };
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy