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

Adding a Non-Default Plugin #156

Open
nfriend21 opened this issue Nov 8, 2015 · 6 comments
Open

Adding a Non-Default Plugin #156

nfriend21 opened this issue Nov 8, 2015 · 6 comments

Comments

@nfriend21
Copy link

Is it possible to add non-default plugins? I have tried everything, cant get it to work. Here's what I've done (let's use the "table" plugin as an example):

  1. Added the plugin file into vendor/assets/javascripts/redactor-rails
  2. added //= require redactor-rails/table to application.js
  3. added 'table' to the "plugins" attribute on config.js

The table button is appearing, but the dropdown menu list is empty (there are rows but no text is showing), and there's an error when I click on the first row to insert a table. The error is:

Uncaught TypeError: this.selection.current is not a function

Thanks!

@nfriend21 nfriend21 reopened this Nov 8, 2015
@morgan-blondellet
Copy link

Hey,

i was trying to implement this plugin on redactor version 10.2.3. I was able to get it to work by modifying the plugin code a bit. Now everything is working fine. If you need my source file just say so !

@asoap
Copy link

asoap commented Feb 6, 2016

Dude. Always add your code. Let us know what you modified.

@morgan-blondellet
Copy link

Sorry had not seen your comment. Here are my js file so you can try if it works for you. The issue was that we were using an old version of redactor and their plugin is based on the new Redactor version.

So i changed the call to some of the Redactor core functions.
diff_table.txt
table.js.txt

@jennywin
Copy link

@morgan-blondellet @nfriend21 Hi, thanks so much for this! You've gotten me one step closer, but I'm still unable to get the table button to properly display the table dropdown menu options. Could either of you point me in the right direction?

screen shot 2016-04-16 at 2 17 25 pm

@morgan-blondellet
Copy link

@jennycodes I guess you have no translation for the dropdown options. In my table.js file i added

            langs: {
                en: {
                    "table": "Table",
                    "insert-table": "Insert table",
                    "insert-row-above": "Insert row above",
                    "insert-row-below": "Insert row below",
                    "insert-column-left": "Insert column left",
                    "insert-column-right": "Insert column right",
                    "add-head": "Add head",
                    "delete-head": "Delete head",
                    "delete-column": "Delete column",
                    "delete-row": "Delete row",
                    "delete-table": "Delete table"
                }
            },

I also included a translation file from redactor : https://imperavi.com/redactor/docs/languages/

In this localized file i added and translated the previous keys in my language (french)

    "insert-table": "Inserer un tableau",
    "insert-row-above": "Insérer une ligne au dessus",
    "insert-row-below": "Insérer une ligne en dessous",
    "insert-column-left": "Insérer une colonne à gauche",
    "insert-column-right": "Insérer une colonne à gauche",
    "add-head": "Ajouter une entête",
    "delete-head": "Supprimer l'entête",
    "delete-column": "Supprimer la colonne",
    "delete-row": "Supprimer la ligne",
    "delete-table": "Supprimer le tableau",

Hope it helps !

@jennywin
Copy link

@morgan-blondellet Hi, thank you for getting back to me! I do have the dropdown options listed in my table.js file and do not need translations because I am using English.

Ahh, wait - I just realized that you are using Redactor version 10.2.3. I am using Redactor version 10.0.4, the same version as the redactor-rails gem. I'm not sure what to do now, so I guess I will give up the idea of allowing tables in my WYSIWYG.

Thanks anyways for your help! :)

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

4 participants