Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update demo for latest Redactor (currently 10.1.1) #72

Open
beaucox opened this issue May 6, 2015 · 1 comment
Open

Update demo for latest Redactor (currently 10.1.1) #72

beaucox opened this issue May 6, 2015 · 1 comment

Comments

@beaucox
Copy link

beaucox commented May 6, 2015

There were a bunch of API changes introduced in Redactor 10, and the demo code no longer works. I am struggling to make changes to the demo plugin but have had no success so far.

Has anyone been able to get the plugin working with version 10+? I am not the greatest javascript/JQuery coder!

@catphish
Copy link

Here's a modification to the javascript that works for me.

(function () {
  if (typeof RedactorPlugins === 'undefined') RedactorPlugins = {};

RedactorPlugins.spellchecker = function () {
    return {
      init: function () {
        var button = this.button.add('spellchecker', 'Spellchecker');
        this.button.addCallback(button, this.spellchecker.toggle);
      },
      create: function () {
        this.spellchecker.instance = new $.SpellChecker(this.$editor, {
          lang: 'en',
          parser: 'html',
          webservice: {
            path: "/spellcheck",
            driver: 'pspell'
          },
          suggestBox: {
            position: 'below'
          }
        });

        this.spellchecker.instance.on('check.success', function () {
          alert('There are no incorrectly spelt words.');
        });
      },
      toggle: function () {
        if (!this.spellchecker.instance) {
          this.button.setActive('spellchecker');
          this.spellchecker.create();
          this.spellchecker.instance.check();
        } else {
          this.button.setInactive('spellchecker');
          this.spellchecker.instance.destroy();
          this.spellchecker.instance = null;
        }
      }
    }
  };

})();

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

No branches or pull requests

2 participants