Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paste content #392

Closed
snekbaev opened this issue Nov 4, 2014 · 12 comments
Closed

Paste content #392

snekbaev opened this issue Nov 4, 2014 · 12 comments
Labels
Milestone

Comments

@snekbaev
Copy link

snekbaev commented Nov 4, 2014

Hi,

didn't test in other browsers, but IE11: if I copy content/some part of it from the editor and try to paste back it crashes with:

SCRIPT5022: HierarchyRequestError
File: angular-textAngular.js, Line: 25, Column: 11246

P.S.: using 1.3.0-pre12

@SimeonC
Copy link
Collaborator

SimeonC commented Nov 4, 2014

Thanks, I'll have a look into it when I can.

@SimeonC
Copy link
Collaborator

SimeonC commented Nov 10, 2014

OK, this one I can't replicate at all. Can you replicate it in a plunkr or similar please?

@snekbaev
Copy link
Author

Can't quickly reproduce in plunkr, however if I modify the insertHtml function:

for (var _n in nodes) lastNode = frag.appendChild(nodes[_n]);

to

for (var _n = 0; _n < nodes.length; _n++) lastNode = frag.appendChild(nodes[_n]);

error is gone, this reminds me what I ran into another project: witoldsz/angular-http-auth#48

also that link mentions that regular for is faster :) maybe if you could change all foreach to for so that we could fix other similar issues and increase the performance? :)

@snekbaev
Copy link
Author

another thing related to pasting: if I keep on pressing Ctrl+V content is inconsistent. It starts pasting then at some point trims, so if you had 50 characters and continue pasting all of a sudden you may end up having 10 etc. And this keeps repeating. This dirty quick fix addresses it:

var waitforpastedata = function (savedcontent, _savedSelection, cb) {
    if (element[0].childNodes && element[0].childNodes.length > 0) {
        cb(savedcontent, _savedSelection);
    } else {
        that = {
            s: savedcontent,
            _: _savedSelection,
            cb: cb
        };
        that.callself = function () {
            waitforpastedata(that.s, that._, that.cb);
        };
        setTimeout(that.callself, 20);
    }
};

becomes

var waitforpastedata = function (savedcontent, _savedSelection, cb) {
    var that = {
        s: savedcontent,
        _: _savedSelection,
        cb: cb
    };
    that.callself = function () {
        cb(savedcontent, _savedSelection);
    };

    setTimeout(that.callself, 20);
};

@snekbaev
Copy link
Author

if you open this plunkr - http://plnkr.co/edit/9VK84LnXR5h9YnQvq00V?p=preview in Chrome and IE11, then select text from any textangular field in IE and do paste into any textangular field in Chrome, then that field in Chrome with get extra markup, basically you will end up inserting a textangular editor into textangular editor. Other side effects I've encountered include additional markup or even script tag content

@SimeonC
Copy link
Collaborator

SimeonC commented Nov 12, 2014

Thanks for the details, I'll look into it when I can.

@SimeonC SimeonC added this to the 1.3.0 milestone Nov 12, 2014
SimeonC pushed a commit that referenced this issue Nov 27, 2014
SimeonC pushed a commit that referenced this issue Nov 27, 2014
Fixes #407
Ref #392 Partial fix
@SimeonC
Copy link
Collaborator

SimeonC commented Nov 27, 2014

Just stuck on the multi-paste issue currently, not sure about the quick and dirty fix.

Biggest problem I'm finding with this is that the "Solution" is a hack from here: http://stackoverflow.com/questions/2176861/javascript-get-clipboard-data-on-paste-event-cross-browser/6804718#6804718

My concerns so far are:

  • Wouldn't reducing the timeout be better, say to 2ms or something like that?
  • How would this function if we pasted say 200 lines of text or something else stupidly large that would take longer than 20ms to render into the page.

@snekbaev
Copy link
Author

Well, can't really say much here, never tried to handle the paste data in the browser. Wild guess: maybe it is possible to disable any pasting while current paste operation is in progress?

@SimeonC
Copy link
Collaborator

SimeonC commented Dec 15, 2014

Thanks, Good suggestion, I'll see if I can do that.

@SimeonC
Copy link
Collaborator

SimeonC commented Dec 16, 2014

Helps if I push the fix up... Waiting on one more issue to come back and I'll push a pre-release.

@snekbaev
Copy link
Author

It is ok, I can wait for the new -pre.
Thank you!

@SimeonC
Copy link
Collaborator

SimeonC commented Dec 16, 2014

Ok, pre-release 18 is out and should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants