Created
April 19, 2018 13:37
-
-
Save fxmontigny/9fc427d0ccd16179982c2111cf2c999a to your computer and use it in GitHub Desktop.
Quilljs insert html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const editor = new Quill(...); | |
// defined method insert html | |
editor.insertHTML = (html) => { | |
const range = this.editor.getSelection(true), | |
date = Date.now(); | |
editor.insertEmbed(range.index, 'div', { id: date }, 'user'); | |
editor.setSelection(range.index + 1, Quill.sources.SILENT); | |
$(html).insertAfter('#' + date); | |
$('#' + date).remove(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment