quill icon indicating copy to clipboard operation
quill copied to clipboard

register type error

Open chengfengfengwang opened this issue 1 year ago • 1 comments

function Counter(quill:Quill, options:{unit:string,container:string}) {
  const container = document.querySelector(options.container) as HTMLDivElement;
  quill.on(Quill.events.TEXT_CHANGE, () => {
    const text = quill.getText();
    if (options.unit === 'word') {
      container.innerText = text.split(/\s+/).length + ' words';
    } else {
      container.innerText = text.length + ' characters';
    }

  });
}

Quill.register('modules/counter', Counter); // type error 
new Quill('#editor', {
  modules: {
    counter: {
      container: '#counter',
      unit: 'word'
    }
  }
});

The above code come from quill's offical website. But, typescript has error: Argument of type '(quill: Quill, options: { unit: string; container: string; }) => void' is not assignable to parameter of type 'boolean | BlotConstructor | Attributor | undefined'. How can I fix it ?

chengfengfengwang avatar May 02 '24 03:05 chengfengfengwang

Might be fixed with https://github.com/quilljs/quill/pull/4127

luin avatar May 02 '24 10:05 luin