Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

[Limiter plugin] "Uncaught TypeError: this.core.editor is not a function" #55

Open
Alphare opened this issue Nov 16, 2015 · 3 comments
Open

Comments

@Alphare
Copy link

Alphare commented Nov 16, 2015

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);
@pydanny
Copy link
Owner

pydanny commented Nov 16, 2015

Hi @Alphare, would you like to submit a pull request for this fix and get full credit?

@Alphare
Copy link
Author

Alphare commented Nov 16, 2015

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?

@caffodian
Copy link
Contributor

This looks like a plugin for the Redactor editor itself - this repo merely provides convenience for integrating the editor w/ Django

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants