I'm using Markdown-it in my Angular 2 project. I want to create a plugin to extend Markdown-it. I have the basic Markdown-it working and can add a javascript plugin like this
PluginSetup(md) {
console.log('Enter PluginSetup');
md.inline.ruler.after('emphasis', 'cards', function x(state, silent) {
return false;
});
}
I see the console message and everything works fine. Now I want the callback to invoke some Typescript. I've tried
export class PlugIns {
CardSymbols(state, silent) {
console.log('Enter CardSymbols');
return false;
}
PluginSetup(md) {
console.log('Enter PluginSetp');
md.inline.ruler.after('emphasis', 'cards', function x(state, silent) {
console.log('Enter x');
return this.CardsSymbols(state, silent);
});
}
}
I see the 'Enter x' console message and then
EXCEPTION: Error in ./ArticleDisplayComponent class ArticleDisplayComponent - inline template:0:5 caused by: Object doesn't support property or method 'CardSymbols'
How do I call Typescript from a javascript callback?
RESOLVED
None of the suggestions or referenced articles changed the error message but I do have a resolution.
md.inline.ruler.after('emphasis', 'cards', Plugins.prototype.CardSymbols);
Thanks for all the suggestions