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

Cut & paste not working #785

Closed
sachinrekhi opened this issue Jul 6, 2016 · 1 comment
Closed

Cut & paste not working #785

sachinrekhi opened this issue Jul 6, 2016 · 1 comment

Comments

@sachinrekhi
Copy link
Contributor

sachinrekhi commented Jul 6, 2016

While COPY & paste is working fine, CUT & paste does not seem to be working properly. When I CUT (using Command+X) the cut content is properly removed from the editor. But when I subsequently paste in the editor, the previous content in the clipboard is pasted as opposed to the recently cut content.

Steps for Reproduction

  1. Visit beta.quilljs.com
  2. Cut the first word in the editor, "Rich", using Command+X
  3. Go to the end of the line and press Command+V

Expected behavior:
The word Rich is pasted at the end of the line

Actual behavior:
What's actually pasted is whatever was previously in the clipboard before the cut of Rich

Platforms:
Chrome 51 on Mac 10.11

Version:
Quill 1.0 Beta 6

@webcarrot
Copy link

Change onCut in /modules/clipboard.js :

  onCut(e) {
    if (e.defaultPrevented) return;
    this.onCopy(e);
    let range = this.quill.getSelection();
    this.quill.deleteText(range, Quill.sources.USER);
    this.quill.setSelection(range.index, Quill.sources.SILENT);
  }

to:

  onCut(e) {
    if (e.defaultPrevented) return;
    this.onCopy(e);
  }

or ?:

  onCut(e) {
    if (e.defaultPrevented) return;
    this.onCopy(e);
    setTimeout(()=>{
        let range = this.quill.getSelection();
        this.quill.deleteText(range, Quill.sources.USER);
        this.quill.setSelection(range.index, Quill.sources.SILENT);
    },0);
  }

@jhchen jhchen closed this as completed in eb2709f Jul 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants