Closed Bug 1247483 Opened 7 years ago Closed 6 years ago
undo/redo doesn't work after copy/pasting a table [contenteditable]
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.13 Safari/537.36 Steps to reproduce: in http://output.jsbin.com/cacarew/5 select the whole first table with the mouse, ten copy it (ctrl+c), then place the cursor after the 3 dots, and paste it (ctrl+v) after that undo (ctrl+z) will remove the second row of the pasted table, the first row remains, redo (ctrl+y) won't work it actually corrupt/lose the whole undo history after pasting the table possibly related: https://bugzilla.mozilla.org/show_bug.cgi?id=1015433 Actual results: pasted <table> isn't undo-able, undo history is lost Expected results: it should have worked like any other html content pasted, being undo/redo-able
In nsHTMLEditor::ReplaceOrphanedStructure, we loop over |aNodeArray| removing nodes and checking if it is a descendant of the replacement node. If it is not, then the loop breaks but we continue to append the replacement node onto the list. I don't understand the overall picture of what this code is trying to do but that part looks wrong. It results in the same element being in |aNodeArray| twice (the replacement node is one of the nodes in the list). This results in creating multiple InsertNodeTxn for the same node. When we undo, the first transaction for the node will succeed, but the next one will fail (because the node is no longer a child).
Comment on attachment 8718628 [details] [diff] [review] Only replace nodes in nsHTMLEditor::ReplaceOrphanedStructure if all nodes in node list are descendants of replacement node Review of attachment 8718628 [details] [diff] [review]: ----------------------------------------------------------------- Please add a test too. Thanks!
Attachment #8718628 - Flags: review?(ehsan) → review+
Assignee: nobody → wchen
Attachment #8718628 - Attachment is obsolete: true
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
You need to log in before you can comment on or make changes to this bug.