Making a custom blot in typescript

1.1k views Asked by At

I'd like to be able to extend native blots as seen in cloning medium w/ parchment. I am using angular2 with typescript, and typescript does not believe that BlockEmbed is a real constructor.

Using the following code (pretty much directly from above tutorial): let BlockEmbed = Quill.import('blots/block/embed');

class DividerBlot extends BlockEmbed { }
DividerBlot.blotName = 'divider';
DividerBlot.tagName = 'hr';
1

There are 1 answers

0
brianc On

Something like this has worked for me:

const BlockEmbed = Quill.import('blots/block/embed') as { new (node, value): Object };
export class DividerBlot extends BlockEmbed {
    static blotName = 'divider';
    static tagName = 'hr';
}