Ticket #5546: 5546_2.patch

File 5546_2.patch, 4.1 KB (added by WebSpellChecker.net, 14 years ago)
  • _source/plugins/scayt/plugin.js

     
    141141                                        }
    142142                                }
    143143                        });
    144 
     144                editor.on( 'afterCommandExec', function( ev )
     145                        {
     146                               
     147                                if ( !plugin.isScaytEnabled(editor) )
     148                                        return;
     149                               
     150                                if ( ev.data.name == 'undo' || ev.data.name == 'redo' && editor.mode == 'wysiwyg' )
     151                                {
     152                                        window.setTimeout( function(){ plugin.getScayt( editor ).refresh(); }, 10 );
     153                                }
     154                               
     155                        });
    145156                editor.on( 'destroy', function( ev )
    146157                        {
    147158                                var editor = ev.editor,
     
    220231                                }
    221232                        );
    222233                }
     234               
     235                // Override Image.equals method avoid CK snapshot module to add SCAYT markup to snapshots ( 5546 ticket )
     236                var undoImagePrototype = CKEDITOR.plugins.undo.Image.prototype;
     237                undoImagePrototype.equals =      CKEDITOR.tools.override( undoImagePrototype.equals, function( org )
     238                {
     239                        return function( otherImage )
     240                        {
     241                                var thisContents = this.contents,
     242                                        otherContents = otherImage.contents;
     243                                var scayt_instance = plugin.getScayt( this.editor );
     244                                // Making the comparison based on content without SCAYT word markers.
     245                                if ( scayt_instance && plugin.isScaytReady( this.editor ) )
     246                                {
     247                                        this.contents = scayt_instance.reset( thisContents );
     248                                        otherImage.contents = scayt_instance.reset( otherContents );
     249                                }
     250                               
     251                                var retval = org.apply( this, arguments );
    223252
     253                                this.contents = thisContents;
     254                                otherImage.contents = otherContents;
     255                                return retval;
     256                        }
     257                });
     258               
    224259                if ( editor.document )
    225260                        createInstance();
    226261        };
  • _source/plugins/undo/plugin.js

     
    117117                }
    118118        });
    119119
    120         // Gets a snapshot image which represent the current document status.
    121         function Image( editor )
     120        CKEDITOR.plugins.undo = {};
     121
     122        /**
     123         * Undo snapshot which represents the current document status.
     124         * @name CKEDITOR.plugins.undo.Image
     125         * @param editor The editor instance on which the image is created.
     126         */
     127        var Image = CKEDITOR.plugins.undo.Image = function( editor )
    122128        {
     129                this.editor = editor;
    123130                var contents    = editor.getSnapshot(),
    124131                        selection       = contents && editor.getSelection();
    125132
    126133                // In IE, we need to remove the expando attributes.
    127134                CKEDITOR.env.ie && contents && ( contents = contents.replace( /\s+_cke_expando=".*?"/g, '' ) );
    128 
     135               
    129136                this.contents   = contents;
    130137                this.bookmarks  = selection && selection.createBookmarks2( true );
    131         }
     138        };
    132139
    133140        // Attributes that browser may changing them when setting via innerHTML.
    134141        var protectedAttrs = /\b(?:href|src|name)="[^"]*?"/gi;
     
    137144        {
    138145                equals : function( otherImage, contentOnly )
    139146                {
     147                       
    140148                        var thisContents = this.contents,
    141                                 otherContents = otherImage.contents;
     149                                otherContents = otherImage.contents,
     150                                // Registered filters makes Image to respond correct on service markup of SCAYT and any other plugins
     151                                // The editor object is absent in context of Image by default,
     152                                // so for prototyping we use hardcoded editor name "editor1"
     153                                thisEqualsFilters = CKEDITOR.instances.editor1._.imageEqualsFilters,
     154                                i,err;
    142155
    143156                        // For IE6/7 : Comparing only the protected attribute values but not the original ones.(#4522)
    144157                        if ( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) )
     
    146159                                thisContents = thisContents.replace( protectedAttrs, '' );
    147160                                otherContents = otherContents.replace( protectedAttrs, '' );
    148161                        }
    149 
     162                       
     163                       
     164                        // Run custom filters
     165                        if (thisEqualsFilters && thisEqualsFilters.length)
     166                                for ( i in thisEqualsFilters )
     167                                        try{
     168                                                filteredContents = thisEqualsFilters[i].apply(null,[thisContents,otherContents]);
     169                                                thisContents = filteredContents[0];
     170                                                otherContents = filteredContents[1];
     171                                        }catch (err){}
     172                       
     173                                       
    150174                        if ( thisContents != otherContents )
    151175                                return false;
    152176
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy