Ticket #7646: 7646.patch

File 7646.patch, 2.0 KB (added by Frederico Caldeira Knabben, 12 years ago)
  • _source/plugins/pastefromword/filter/default.js

     
    12901290                }
    12911291        };
    12921292
     1293        function finalCleanup( data )
     1294        {
     1295                var fragment = CKEDITOR.htmlParser.fragment.fromHtml( data, false ),
     1296                        filter = new CKEDITOR.htmlParser.filter(),
     1297                        writer = new CKEDITOR.htmlParser.basicWriter();
     1298
     1299                filter.addRules(
     1300                        {
     1301                                attributeNames :
     1302                                [
     1303                                        // Remove onmouseover and onmouseout events (from MS Word comments effect)
     1304                                        [ ( /^cke:.*/ ), '' ]
     1305                                ],
     1306                                attributes :
     1307                                {
     1308                                        'style' : function( value )
     1309                                        {
     1310                                                if ( !value )
     1311                                                        return false;
     1312                                        }
     1313                                },
     1314                                elements :
     1315                                {
     1316                                        'span' : function( element )
     1317                                        {
     1318                                                // Remove dummy spans (attribute-less).
     1319                                                if ( CKEDITOR.tools.isEmpty( element.attributes ) )
     1320                                                        element.name = '';
     1321                                        }
     1322                                }
     1323                        });
     1324
     1325                fragment.writeHtml( writer, filter );
     1326
     1327                return writer.getHtml( true );
     1328        }
     1329
    12931330        CKEDITOR.cleanWord = function( data, editor )
    12941331        {
    12951332                // Firefox will be confused by those downlevel-revealed IE conditional
     
    13101347                try
    13111348                {
    13121349                        data = dataProcessor.toHtml( data, false );
     1350
     1351                        /* A second round of processing is needed to cleanup undesirable results of the main filtering. */
     1352                        data = finalCleanup( data );
    13131353                }
    13141354                catch ( e )
    13151355                {
    13161356                        alert( editor.lang.pastefromword.error );
    13171357                }
    13181358
    1319                 /* Below post processing those things that are unable to delivered by filter rules. */
    1320 
    1321                 // Remove 'cke' namespaced attribute used in filter rules as marker.
    1322                 data = data.replace( /cke:.*?".*?"/g, '' );
    1323 
    1324                 // Remove empty style attribute.
    1325                 data = data.replace( /style=""/g, '' );
    1326 
    1327                 // Remove the dummy spans ( having no inline style ).
    1328                 data = data.replace( /<span>/g, '' );
    1329 
    13301359                return data;
    13311360        };
    13321361})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy