Opened 15 years ago
Last modified 12 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 )
This issue was found when reproducing #7982
- Paste the list from the attached file to CKEditor
- 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 15 years ago by
comment:1 Changed 15 years ago by
| Status: | new → confirmed |
|---|
comment:2 Changed 15 years ago by
| Cc: | satya_minnekanti@… added |
|---|
Changed 14 years ago by
| Attachment: | nested-list-test.doc added |
|---|
comment:3 Changed 14 years ago by
comment:4 Changed 14 years ago by
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 13 years ago by
| 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.

#8450 was marked as duplicate