I'm trying to use tables with the Quill WYSIWYG editor. I'm trying to do it in the sandbox: https://quilljs.com/playground/snow . I've added ['table']
to the toolbar, so now it looks like this:
const quill = new Quill('#editor', {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image', 'code-block'],
['table']
],
},
placeholder: 'Compose an epic...',
theme: 'snow', // or 'bubble'
});
The table icon appeared, however I have no freakin' idea on how to add columns and rows to it. Does anyone know?
Sorry but Quill v2.0.2 doesn't really support table rendering and inserting/editing. For basic usage, I recommend using the module: https://github.com/soccerloway/quill-better-table
npm install quill-better-table
import QuillBetterTable from 'quill-better-table'
Quill.register({
'modules/better-table': QuillBetterTable
}, true)
const quill = new Quill('#editor-wrapper', {
theme: 'snow',
modules: {
table: false, // disable table module
'better-table': {
operationMenu: {
items: {
unmergeCells: {
text: 'Another unmerge cells name'
}
}
}
},
keyboard: {
bindings: QuillBetterTable.keyboardBindings
}
})
...
document.body.querySelector('#insert-table')
.onclick = () => {
let tableModule = quill.getModule('better-table')
tableModule.insertTable(3, 3)
}
If you're feeling adventurous, you could also check this cool project, where they re-write Quill in order to handle table.
Cheers,