禁用Quill编辑器onclick

时间:2017-10-05 21:24:43

标签: javascript quill

Codepen

我正在尝试在工具栏上添加自定义按钮,这样一旦用户完成编辑,他们就可以删除文本区域。

var init = false;
var quill = null;
document.getElementById('editor-container').addEventListener('click', () => {
  console.log(quill);
  if(!init) {
    quill = new Quill('#editor-container', {  
      modules: {
        toolbar: '#toolbar-container'
      },
      placeholder: 'Compose an epic...',
      theme: 'snow' // or 'bubble'
    });
    init = true;
  };
  var Parchment = Quill.import("parchment");

  let CustomClass = new Parchment.Attributor.Class('custom', 'ql-custom', {
    scope: Parchment.Scope.INLINE
  });

  Quill.register(CustomClass, true);

  var customButton = document.querySelector('#custom-button');
  customButton.addEventListener('click', function(event) {
    event.stopPropagation();
    quill = null;
    console.log(quill);
  });
}) 

0 个答案:

没有答案