Ticket #3828: 3828.patch

File 3828.patch, 2.7 KB (added by Garry Yao, 15 years ago)
  • _source/core/dtd.js

     
    8585                $listItem : {dd:1,dt:1,li:1},
    8686
    8787                /**
     88             * List of list root elements.
     89             * @type Object
     90             * @example
     91             */
     92            $list: { ul:1,ol:1,dl:1},
     93
     94                /**
    8895                 * Elements that accept text nodes, but are not possible to edit into
    8996                 * the browser.
    9097                 * @type Object
  • _source/core/htmlparser/fragment.js

     
    4545        // parser fixing.
    4646        var nonBreakingBlocks = CKEDITOR.tools.extend(
    4747                        {table:1,ul:1,ol:1,dl:1},
    48                         CKEDITOR.dtd.table, CKEDITOR.dtd.ul, CKEDITOR.dtd.ol, CKEDITOR.dtd.dl );
     48                        CKEDITOR.dtd.table, CKEDITOR.dtd.ul, CKEDITOR.dtd.ol, CKEDITOR.dtd.dl ),
     49                listBlocks = CKEDITOR.dtd.$list, listItems = CKEDITOR.dtd.$listItem;
    4950
    5051        /**
    5152         * Creates a {@link CKEDITOR.htmlParser.fragment} from an HTML string.
     
    189190                                if ( !currentName )
    190191                                        return;
    191192
    192                                 var reApply = false;
     193                                var reApply = false,
     194                                        addPoint;   // New position to start adding nodes.
    193195
     196                                // Fixing malformed nested lists(#3828).
     197                                if( tagName in listBlocks
     198                                        && currentName in listBlocks )
     199                                {
     200                                        var children = currentNode.children,
     201                                                lastChild = children[ children.length - 1 ];
     202                                        // Move inner list into to previous list item if any.
     203                                        if( lastChild && lastChild.name in listItems )
     204                                                returnPoint = currentNode, addPoint = lastChild;
     205                                        // Move inner list outside in the worst case.
     206                                        else
     207                                                addElement( currentNode, currentNode.parent );
     208                                }
    194209                                // If the element name is the same as the current element name,
    195210                                // then just close the current one and append the new one to the
    196211                                // parent. This situation usually happens with <p>, <li>, <dt> and
    197212                                // <dd>, specially in IE. Do not enter in this if block in this case.
    198                                 if ( tagName == currentName )
     213                                else if ( tagName == currentName )
    199214                                {
    200215                                        addElement( currentNode, currentNode.parent );
    201216                                }
     
    222237                                        reApply = true;
    223238                                }
    224239
    225                                 // In any of the above cases, we'll be adding, or trying to
    226                                 // add it to the parent.
    227                                 currentNode = currentNode.returnPoint || currentNode.parent;
     240                                if( addPoint )
     241                                        currentNode = addPoint;
     242                                // Try adding it to the return point, or the parent element.
     243                                else
     244                                        currentNode = currentNode.returnPoint || currentNode.parent;
    228245
    229246                                if ( reApply )
    230247                                {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy