quill icon indicating copy to clipboard operation
quill copied to clipboard

Copy/Paste From MS Word get's truncated

Open jermahs opened this issue 11 years ago • 6 comments

In certain circumstances seemingly related to <ul> tags or some other odd formatting, the nextLineNode returns null when it shouldn't. The following code fixed the problem:

Wrapper.prototype.nextLineNode = function(root) {
var nextNode;
nextNode = this.node.nextSibling;
if ((nextNode == null) && this.node.parentNode !== root) {
  nextNode = this.node.parentNode.nextSibling;

    /*
        Ticket #16351 - copy paste word documents were getting truncated.
        To resolve this issue, I noticed a case where a list (i.e., <ul>...</ul>) had a nextSibling resolve to null. However,
        this shouldn't have been true. So, to solve we have to resolve the nextLineNode of the parentNode in the context of root.
        This finds the correct next node and then continues successfully.
     */
    if (nextNode == null) {
        nextNode = dom(this.node.parentNode).nextLineNode(this.root);
    }
}
if ((nextNode != null) && (dom.LIST_TAGS[nextNode.tagName] != null)) {
  nextNode = nextNode.firstChild;
}
return nextNode;
};

jermahs avatar May 14 '15 15:05 jermahs

This looks like a proposed fix? Can you submit a pull request with a previously failing test?

jhchen avatar May 14 '15 20:05 jhchen

I would, but tbh I'm not caught up on this coffee script stuff. haha.

jermahs avatar May 14 '15 20:05 jermahs

Can you provide the sample word document or snippet that triggers the error?

jhchen avatar May 15 '15 20:05 jhchen

@jhchen the document that cause the issue actually contains some sensitive info. I've redacted it the best I can while maintaining all of the formatting issues. However, I have been asked not to directly share on an open forum such as this; can I email it to you and then I must request that you don't post it on Github (or anywhere else for that matter). Rather, simply use it to figure out what formatting issue it results and and then build a fake document to duplicate the behavior.

Cheers.

jermahs avatar May 15 '15 20:05 jermahs

Sure [email protected] thanks!

jhchen avatar May 15 '15 20:05 jhchen

@jhchen this should be reopened and my change

if (nextNode == null) {
    nextNode = dom(this.node.parentNode).nextLineNode(this.root);
}

should be changed to

if (nextNode == null) {
    nextNode = dom(this.node.parentNode).nextLineNode(root);
}

root is what I wanted and this.root is undefined, which causes other errors. Not sure if your tests caught that or not, but wanted to make sure you were aware.

jermahs avatar May 22 '15 14:05 jermahs