Ticket #4548: 4548_2.patch

File 4548_2.patch, 5.0 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/elementpath.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
    55
    66(function()
    77{
    8         // Elements that may be considered the "Block boundary" in an element path.
    9         var pathBlockElements = { address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,de:1 };
    108
    119        // Elements that may be considered the "Block limit" in an element path.
    1210        var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1 };
     
    4846
    4947                                if ( !blockLimit )
    5048                                {
    51                                         if ( !block && pathBlockElements[ elementName ] )
     49                                        if ( !block && e.isBlockBoundary() )
    5250                                                block = e;
    5351
    5452                                        if ( pathBlockLimitElements[ elementName ] )
  • _source/core/htmlparser/fragment.js

     
    107107                        // body (if fixForBody).
    108108                        if ( fixForBody && !target.type )
    109109                        {
    110                                 var elementName, realElementName;
     110                                var elementName, realElement, isKnown;
    111111                                if ( element.attributes
    112                                          && ( realElementName =
    113                                                   element.attributes[ '_cke_real_element_type' ] ) )
    114                                         elementName = realElementName;
    115                                 else
    116                                         elementName =  element.name;
    117                                 if ( !( elementName in CKEDITOR.dtd.$body ) )
     112                                         && element.attributes[ '_cke_real_element_type' ] )
     113                                        realElement = CKEDITOR.editor.restoreParserElement( element );
     114
     115                                elementName =  realElement ?
     116                                               ( realElement.isUnknown ?    // Don't fix for unknown elements.
     117                                                 '' : realElement.name ) : element.name;
     118
     119                                if ( elementName && !( elementName in CKEDITOR.dtd.$body ) )
    118120                                {
    119121                                        var savedCurrent = currentNode;
    120122
  • _source/plugins/fakeobjects/plugin.js

     
    55
    66(function()
    77{
    8         var htmlFilterRules =
    9         {
    10                 elements :
    11                 {
    12                         $ : function( element )
    13                         {
    14                                 var realHtml = element.attributes._cke_realelement,
    15                                         realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ),
    16                                         realElement = realFragment && realFragment.children[ 0 ];
    17 
    18                                 if ( realElement )
    19                                 {
    20                                         // If we have width/height in the element, we must move it into
    21                                         // the real element.
    22 
    23                                         var style = element.attributes.style;
    24 
    25                                         if ( style )
    26                                         {
    27                                                 // Get the width from the style.
    28                                                 var match = /(?:^|\s)width\s*:\s*(\d+)/.exec( style ),
    29                                                         width = match && match[1];
    30 
    31                                                 // Get the height from the style.
    32                                                 match = /(?:^|\s)height\s*:\s*(\d+)/.exec( style );
    33                                                 var height = match && match[1];
    34 
    35                                                 if ( width )
    36                                                         realElement.attributes.width = width;
    37 
    38                                                 if ( height )
    39                                                         realElement.attributes.height = height;
    40                                         }
    41                                 }
    42 
    43                                 return realElement;
    44                         }
    45                 }
    46         };
    47 
    488        CKEDITOR.plugins.add( 'fakeobjects',
    499        {
    5010                requires : [ 'htmlwriter' ],
     
    5515                                htmlFilter = dataProcessor && dataProcessor.htmlFilter;
    5616
    5717                        if ( htmlFilter )
    58                                 htmlFilter.addRules( htmlFilterRules );
    59                 }
    60         });
     18                                htmlFilter.addRules(
     19                                {
     20                                        elements :
     21                                        {
     22                                                $ : CKEDITOR.editor.restoreParserElement
     23                                        }
     24                                } );
     25                }
     26        });
    6127})();
    6228
    6329CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable )
     
    10975        var html = decodeURIComponent( fakeElement.getAttribute( '_cke_realelement' ) );
    11076        return CKEDITOR.dom.element.createFromHtml( html, this.document );
    11177};
     78
     79CKEDITOR.editor.restoreParserElement = function( fakeElement )
     80{
     81        var realHtml = fakeElement.attributes._cke_realelement,
     82                realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ),
     83                realElement = realFragment && realFragment.children[ 0 ];
     84
     85        if ( realElement )
     86        {
     87                // If we have width/height in the fakeElement, we must move it into
     88                // the real fakeElement.
     89
     90                var style = fakeElement.attributes.style;
     91
     92                if ( style )
     93                {
     94                        // Get the width from the style.
     95                        var match = /(?:^|\s)width\s*:\s*(\d+)/.exec( style ),
     96                                width = match && match[1];
     97
     98                        // Get the height from the style.
     99                        match = /(?:^|\s)height\s*:\s*(\d+)/.exec( style );
     100                        var height = match && match[1];
     101
     102                        if ( width )
     103                                realElement.attributes.width = width;
     104
     105                        if ( height )
     106                                realElement.attributes.height = height;
     107                }
     108        }
     109
     110        return realElement;
     111}
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy