Opened 13 years ago

Last modified 10 years ago

#8103 closed Bug

Problems when pasting lists from word — at Version 6

Reported by: Jakub Ś Owned by:
Priority: Normal Milestone: CKEditor 4.2.1
Component: Core : Lists Version: 3.6.1
Keywords: Cc: satya_minnekanti@…, john.barreiros@…

Description (last modified by Jakub Ś)

This issue was found when reproducing #7982

  1. Paste the list from the attached file to CKEditor
  2. The last second-level list items will be changed to first-level list items.

The file contains description how this list was created in WORD.

Pasting such lists worked till version 3.6.
From revision [6912] it got broken. All elements were pasted as first level list-items.
In rev [6977] there was a slight improvement. Items after first sub-list weren't pasted.
From rev [7008] it works as described above.

Change History (8)

Changed 13 years ago by Jakub Ś

Attachment: lists.doc added

comment:1 Changed 13 years ago by Jakub Ś

Status: newconfirmed

comment:2 Changed 13 years ago by Satya Minnekanti

Cc: satya_minnekanti@… added

Changed 12 years ago by Jakub Ś

Attachment: nested-list-test.doc added

comment:3 Changed 12 years ago by Jakub Ś

#8450 was marked as duplicate

comment:4 Changed 12 years ago by Jakub Ś

Possible duplicate was reported in #8754

Revisions are the same but the issue is reproducible in Firefox, when copying/pasting HTML and only with PasteFromWord.

comment:5 Changed 11 years ago by jorp

Cc: john.barreiros@… added

I finally got around to upgrading from 3.6 to 3.6.6.1 and unfortunately this is still an issue.

I dug into the code -- plugins/pastefromword/filter/default.js -- and I think the following is the problem:

In the flattenList() function, the variable children is set to element.children. When a sublist is processed, children gets set to an array. On the next for-loop iteration, the children variable does not have the expected values.

The fix is to reset children to element.children.

var children = element.children,
    child;

for ( var i = 0; i < children.length; i++ )
{
    child = children[ i ];
    
    if ( child.name in CKEDITOR.dtd.$listItem )
    {
        ...
    }
    // Flatten sub list.
    else if ( child.name in CKEDITOR.dtd.$list )
    {
        // Absorb sub list children.
        arguments.callee.apply( this, [ child, level + 1 ] );
        children = children.slice( 0, i ).concat( child.children ).concat( children.slice( i + 1 ) );
        element.children = [];
        for ( var j = 0, num = children.length; j < num ; j++ )
            element.add( children[ j ] );

        // BUGFIX: above, children set to an array, reset to reference element.children
        children = element.children;
    }
}

I hope that helps.

comment:6 Changed 11 years ago by Jakub Ś

Description: modified (diff)

#10672 was marked as duplicate.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy