I'm attempting to integrate Redactor with additional plugins, but I'm encountering an issue where the counter plugin displays 0 words and 0 characters after the page has loaded.
{
words: 0,
characters: 0,
spaces: 0
}
To address this problem, I've tried using the "init" callback to call the count() method of the counter plugin as per the documentation:
$('#content').redactor({
plugins: ['counter'],
callbacks: {
init: function()
{
this.counter.count();
},
counter: function(data)
{
console.log(data);
}
}
});
Everything appears fine without any compile errors in VSCode, but I'm receiving the following error in the console:
declare const $R: any;
...
...
$R('#editor', {
plugins: [
'counter',
...
],
callbacks: {
init: function() {
this.counter.count();
}
counter: function(data: any) {
console.log(data);
}
}
});
ERROR TypeError: Cannot read property 'count' of undefined
at App.changed (editor.component.ts:55)
at F._loop (scripts.bundle.js:2741)
at F.trigger (scripts.bundle.js:2711)
at App.broadcast (scripts.bundle.js:2185)
at F._syncing (scripts.bundle.js:10344)
at scripts.bundle.js:10316
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4724)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
What am I missing here?
Thanks,