简体   繁体   中英

Making a custom blot in typescript

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';

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';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM