jakiestfu / Medium.js

A tiny JavaScript library for making contenteditable beautiful (Like Medium's editor)
http://jakiestfu.github.io/Medium.js/
4.39k stars 404 forks source link

order of lines inversed on paste #168

Open pat123456 opened 8 years ago

pat123456 commented 8 years ago

Hello,

when copy a text, for example this one : a b c

and paste it, it became : c b a

pat123456 commented 8 years ago

this seem to resolve the problem ?, but don't know if it will have some bad repercussions in the rest of the code : (in Medium.Injector.prototype line 1732 )

    if (isConverted) {
        //make an array of elements that are about to be inserted, can't use html because they will
        while (i < html.length) {
            nodes.push(html[i]);
            i++;
        }
        /*while (html.length > 0) {
            console.log(html[html.length - 1])
            parent.insertBefore(html[html.length - 1], wedge);
        }*/
        for (var j=0; j<nodes.length ;j++) {
            parent.insertBefore(nodes[j], wedge);
        }
    }
pat123456 commented 8 years ago

sorry, didn't saw that the bug was already reported in the "closed issues" https://github.com/jakiestfu/Medium.js/issues/133 but the code doesn't seem to have been changed in the official medium.js file and in the doc page ? http://jakiestfu.github.io/Medium.js/docs/

jasoncavett commented 8 years ago

@pat123456 I believe this specific bug is still open. Bug #133 (which I just ran into) was causing the ability to paste to not work at all. (I saw this in release 1.0.1.)

I am still seeing this specific issue with copy and paste reversing the order.

Edit: Nevermind. I see you are referencing f8abd157565d within that chain. My mistake. I'm going to take a look at that now.

vhmth commented 7 years ago

I am seeing this issue when inserting HTML as well via insertHTML('<ul><li></li></ul>');.

vhmth commented 7 years ago

https://github.com/jakiestfu/Medium.js/issues/203