How can I initialize table in quill js 2.0.?

Agustine Raj picture Agustine Raj · Sep 14, 2018 · Viewed 10.9k times · Source

How can I initialize table in quill js 2.0.?

I've tried by using table keyword in toolbar it shows table icon but I could not create the table.

enter image description here

Answer

Luchnik picture Luchnik · Apr 12, 2019

Try to provide table module when creating your editor like this:

var editor = new Quill( '#editor', {
    theme: 'snow',
    modules: {
        table: true
    }
} );

And then just reference table module:

const table = editor.getModule('table');

Using table variable you can trigger different methods for tables:

table.insertTable(2, 2);

Full example can be found here: https://codepen.io/quill/pen/QxypzX