diff --git a/core/quill.js b/core/quill.js index 1437449c46..e463099293 100644 --- a/core/quill.js +++ b/core/quill.js @@ -72,7 +72,8 @@ class Quill { this.clipboard = this.theme.addModule('clipboard'); this.history = this.theme.addModule('history'); this.theme.init(); - this.pasteHTML(`
${html}


`); + let contents = this.clipboard.convert(`
${html}


`); + this.setContents(contents); this.history.clear(); if (options.readOnly) { this.disable(); @@ -100,6 +101,15 @@ class Quill { this.selection.setRange(null); } + dangerouslyPasteHTML(index, html, source = Emitter.sources.API) { + if (typeof index === 'string') { + return this.setContents(this.clipboard.convert(index), html); + } else { + let paste = this.clipboard.convert(html); + return this.updateContents(new Delta().retain(index).concat(paste), source); + } + } + deleteText(index, length, source) { [index, length, , source] = overload(index, length, source); let range = this.getSelection(); @@ -234,13 +244,8 @@ class Quill { return this.emitter.once.apply(this.emitter, arguments); } - pasteHTML(index, html, source = Emitter.sources.API) { - if (typeof index === 'string') { - return this.setContents(this.clipboard.convert(index), html); - } else { - let paste = this.clipboard.convert(html); - return this.updateContents(new Delta().retain(index).concat(paste), source); - } + pasteHTML(index, html, source) { + this.dangerouslyPasteHTML(index, html, source); } removeFormat(index, length, source) {