django-wysiwyg
django-wysiwyg copied to clipboard
[Limiter plugin] "Uncaught TypeError: this.core.editor is not a function"
I was trying to use the limiter plugin and got a "Uncaught TypeError: this.core.editor is not a function" in the chrome console. I figured the plugin was not up to date, and surely enough, the function "editor()" does not exist anymore and has been replaced by "getEditor()". Fixing this allows the plugin to work.
At the time of writing this, the code is :
(function($)
{
$.Redactor.prototype.limiter = function()
{
return {
init: function()
{
if (!this.opts.limiter)
{
return;
}
this.core.getEditor().on('keydown.redactor-plugin-limiter', $.proxy(function(e)
{
var key = e.which;
var ctrl = e.ctrlKey || e.metaKey;
if (key === this.keyCode.BACKSPACE
|| key === this.keyCode.DELETE
|| key === this.keyCode.ESC
|| key === this.keyCode.SHIFT
|| (ctrl && key === 65)
|| (ctrl && key === 82)
|| (ctrl && key === 116)
)
{
return;
}
var text = this.core.getEditor().text();
text = text.replace(/\u200B/g, '');
var count = text.length;
if (count >= this.opts.limiter)
{
return false;
}
}, this));
}
};
};
})(jQuery);
Hi @Alphare, would you like to submit a pull request for this fix and get full credit?
Hi @pydanny : I have never sumbitted a pull request before, but surely I'd like to if it is possible. How can I do that?
Is the plugin part of this repository?
This looks like a plugin for the Redactor editor itself - this repo merely provides convenience for integrating the editor w/ Django