Skip to content

Instantly share code, notes, and snippets.

@fxmontigny
Created April 19, 2018 13:37
Show Gist options
  • Save fxmontigny/9fc427d0ccd16179982c2111cf2c999a to your computer and use it in GitHub Desktop.
Save fxmontigny/9fc427d0ccd16179982c2111cf2c999a to your computer and use it in GitHub Desktop.
Quilljs insert html
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