Opened 14 years ago

Closed 11 years ago

Last modified 10 years ago

#8103 closed Bug (fixed)

Problems when pasting lists from word

Reported by: Jakub Ś Owned by: Piotrek Koszuliński
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.

Attachments (2)

lists.doc (24.0 KB) - added by Jakub Ś 14 years ago.
nested-list-test.doc (21.5 KB) - added by Jakub Ś 13 years ago.

Download all attachments as: .zip

Change History (16)

Changed 14 years ago by Jakub Ś

Attachment: lists.doc added

comment:1 Changed 14 years ago by Jakub Ś

Status: newconfirmed

comment:2 Changed 14 years ago by Satya Minnekanti

Cc: satya_minnekanti@… added

Changed 13 years ago by Jakub Ś

Attachment: nested-list-test.doc added

comment:3 Changed 13 years ago by Jakub Ś

#8450 was marked as duplicate

comment:4 Changed 13 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.

comment:7 Changed 11 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 4.2.1

Thanks jorp. We gonna check this.

I'm tentatively targeting this ticket to the next release.

comment:8 Changed 11 years ago by Teresa Fairchild

I am having this exact same issue as well. I hope it gets resolved soon, because my users will be creating many outlines and lists.

comment:9 Changed 11 years ago by Piotrek Koszuliński

Owner: set to Piotrek Koszuliński
Status: confirmedassigned

comment:10 Changed 11 years ago by Piotrek Koszuliński

Status: assignedreview

Pushed t/8103 on dev and tests.

Note for a reviewer: 3rd level of lists indetation does not work (at least on Webkit), but this is a different issue, caused by the fact that 3rd level is hoisted by browser/MSWord from list structure to normal paragraphs.

@jorp: Thanks for this patch.

comment:11 Changed 11 years ago by Jakub Ś

Status: reviewreview_passed

I have checked branch t/8103 and it seems to work fine.

The only thing that doesn't work are these 3-rd level lists on webkit (although Safari 5.1 wors as expected).

comment:12 Changed 11 years ago by Piotrek Koszuliński

Resolution: fixed
Status: review_passedclosed

Fixed on master with git:acaffaa and a21a00a on tests.

comment:13 Changed 10 years ago by nikhil

i am using CKeditor 4.4,4 but still i am facing the same issue please help us to resolve it

comment:14 Changed 10 years ago by Jakub Ś

I have checked this in Webkit and Blink browsers on Windows and Mac but everything seems to be fine. I have tested this issue with lists in attachment.

  1. Please attach docx file with list that is causing problems for you
  2. Please tell in which browser and which Operating System does it happen
  3. Perhaps you are using some third-party plugins that influence this behaviour? Does it happen on demo page or with standard/full pre-set downloaded from our page?
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