quill
quill copied to clipboard
register type error
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 ?
Might be fixed with https://github.com/quilljs/quill/pull/4127