Skip to content

Commit

Permalink
fix #1886
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jan 22, 2018
1 parent 6918897 commit 36b7b45
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ class Clipboard extends Module {

dangerouslyPasteHTML(index, html, source = Quill.sources.API) {
if (typeof index === 'string') {
return this.quill.setContents(this.convert(index), html);
this.quill.setContents(this.convert(index), html);
this.quill.setSelection(0, Quill.sources.SILENT);
} else {
let paste = this.convert(html);
return this.quill.updateContents(new Delta().retain(index).concat(paste), source);
this.quill.updateContents(new Delta().retain(index).concat(paste), source);
this.quill.setSelection(index, Quill.source.SILENT);
}
}

Expand Down

4 comments on commit 36b7b45

@alexkrolick
Copy link
Contributor

@alexkrolick alexkrolick commented on 36b7b45 Feb 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React-Quill uses dangerouslyPasteHTML to set the editor value from HTML. This change grabs focus when it isn't always needed. Is clipboard.convert considered part of the the public API such that we can use it instead?

See zenoamaro/react-quill#321

@jhchen
Copy link
Member Author

@jhchen jhchen commented on 36b7b45 Feb 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no plans to remove or change convert but it is not protected by semantic versioning. I will consider adding it to the official APIs after the dust settles in 2.0.

@kingslay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhchen you can add a parameter to decide whether or not to setSelection

@TheNeikos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also use dangerouslyPasteHTML, and just found out that it also sets the focus.

While I am sure there is a reason to set the selection, this is not documented.

Would you consider adding a parameter like @kingslay has suggested?

Please sign in to comment.