Ticket #9161: 4688.2.patch

File 4688.2.patch, 2.3 KB (added by WebSpellChecker.net, 11 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                        {
     
    131125                                                plugin.setPaused( editor, !scayt_instance.disabled );
    132126                                                // store a control id for restore a specific scayt control settings
    133127                                                plugin.setControlId( editor, scayt_instance.id );
     128                                                //remove SCAYT markup from editor._.previousValue before SCAYT destroy
     129                                                editor._.previousValue = scayt_instance.reset( editor._.previousValue );
    134130                                                scayt_instance.destroy( true );
    135131                                                delete plugin.instances[ editor.name ];
    136132                                        }
     
    272268                        };
    273269                });
    274270
     271                var editorCheckDirty = CKEDITOR.editor.prototype;
     272               
     273                // Override editor.checkDirty method avoid CK checkDirty functionality to fix SCAYT issues with incorrect checkDirty behavior.
     274                editorCheckDirty.checkDirty = CKEDITOR.tools.override(editorCheckDirty.checkDirty, function( org )
     275                        {
     276                                return function()
     277                                {
     278                                        var retval = null,
     279                                        scayt_instance = plugin.getScayt( editor );
     280                                         
     281                                        if ( scayt_instance && plugin.isScaytReady( editor ) )
     282                                        {               
     283                                                // save property state
     284                                                var saveGetSnapshot = editor.getSnapshot,
     285                                                        savePreviousValue = editor._.previousValue;
     286                                               
     287                                                // override property state
     288                                                editor.getSnapshot = function()
     289                                                {
     290                                                        return scayt_instance.reset( saveGetSnapshot.apply( this, arguments ) );
     291                                                }
     292                                               
     293                                                editor._.previousValue = scayt_instance.reset(editor._.previousValue);
     294
     295                                                // run real checkDirty method
     296                                                retval = org.apply( this, arguments );
     297                                               
     298                                                // restore changed property
     299                                                editor.getSnapshot = saveGetSnapshot;
     300                                                editor._.previousValue = savePreviousValue;
     301                                        }
     302                                        else
     303                                        {
     304                                                retval = org.apply(this);
     305                                        }
     306                                       
     307                                        return retval;
     308                                }
     309                        });
     310
    275311                if ( editor.document )
    276312                        createInstance();
    277313        };
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy