quill: TypeScript classes not compatible with quill dist
I’m having issues extending Parchment blots (specifically Inline, and Block) using TypeScript’s class definition transpilation to ES5.
When TypeScript is configured to output ES6 code (ie, does not transpile class definitions) the following code works as expected (should be called when formatting is logged to the console).
But when TypeScript is configured to output ES5 code (and does transpile class definitions), the formats method in SampleBlot is not called.
Steps for Reproduction
// editor.ts (TypeScript file)
import * as Quill from 'quill';
let Inline = Quill.import('blots/inline');
class SampleBlot extends Inline {
static formats(node) {
console.log('should be called when formatting');
return 'H1'; // just returning an h1 tag for demonstration purposes
}
}
HeaderBlot.blotName = 'sample';
HeaderBlot.tagName = 'H1';
setTimeout(() => {
quill.format('sample', 1);
}, 1000); // arbitrarily update format after 1 second (for demonstration)
Quill.register('formats/sample', SampleBlot); // have also tried Quill.register(SampleBlot);
const quill = new Quill(document.querySelector('#editor');
Expected behavior:
formats method is called and should be called when formatting is logged to the console.
Actual behavior: formats method is not called and the console is empty.
Platforms: Quill 1.1.5 TypeScript 2.1.4 Chrome 55
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 16 (1 by maintainers)
Hi we today got it. Let me show you:
@arahansen The workaround does not work when I try to extend
Containerfor example (actually when I try to usethisorsuperon the not static methods). @jhchen Any plans to rewritequillto TS? 😃Those interfaces are stubbed out as
I was able to get TypeScript compilation to work correctly with the following example:
What’s strange to me is that I had to include the scope as well as the create method.