How to add image in Quill JS?

kidcapital picture kidcapital · Mar 12, 2015 · Viewed 24.3k times · Source

I can't figure out how to get images to work like in the example on http://quilljs.com/.

I tried adding <span title="Image" class="ql-format-button ql-image"></span> to the toolbar, which adds the button, but clicking on the button does nothing and I can't find anything in the documentation. Any suggestion?

Answer

Chris Hawkes picture Chris Hawkes · Nov 7, 2016

Updated Answer

As of version 1.0 and beyond you no longer need to add the tool-tip module it's included by default. An example of how to enable it would be this.

    <script>
            var toolbarOptions = [
                ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
                ['blockquote', 'code-block'],

                [{ 'header': 1 }, { 'header': 2 }],               // custom button values
                [{ 'list': 'ordered'}, { 'list': 'bullet' }],
                [{ 'script': 'sub'}, { 'script': 'super' }],      // superscript/subscript
                [{ 'indent': '-1'}, { 'indent': '+1' }],          // outdent/indent
                [{ 'direction': 'rtl' }],                         // text direction

                [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
                [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
                [ 'link', 'image', 'video', 'formula' ],          // add's image support
                [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
                [{ 'font': [] }],
                [{ 'align': [] }],

                ['clean']                                         // remove formatting button
            ];

        var quill = new Quill('#editor', {
            modules: {
                toolbar: toolbarOptions
            },

            theme: 'snow'
        });
    </script>