import 'quill/dist/quill.snow.css'
import QuillBetterTable from 'src/quill-better-table'
// import better-table styles file
import 'src/assets/quill-better-table.scss'

Quill.register({
  'modules/better-table': QuillBetterTable
}, true)
window.onload = () => {
  const quill = new Quill('#editor-wrapper', {
    theme: 'snow',
    readOnly: false,
    modules: {
      table: false,
      'better-table': {
        operationMenu: {
          items: {
            unmergeCells: {
              text: 'Another unmerge cells name'
            }
          },

          color: {
            colors: ['red', 'green', 'yellow', 'white', 'red', 'green', 'yellow', 'white']
          }
        }
      },
      keyboard: {
        bindings: QuillBetterTable.keyboardBindings
      }
    }
  })

  let tableModule = quill.getModule('better-table')
  document.body.querySelector('#insert-table')
    .onclick = () => {
      tableModule.insertTable(3, 3)
    }

  document.body.querySelector('#get-table')
    .onclick = () => {
      console.log(tableModule.getTable())
    }

  document.body.querySelector('#get-contents')
    .onclick = () => {
      console.log(quill.getContents())
    }
}
