SammyLin / redactor-rails

This repo is deprecated. Please check out official gem for Redactor 2. https://github.com/Redactor2/redactor2_rails
MIT License
389 stars 253 forks source link

Adding a Non-Default Plugin #156

Open nfriend21 opened 9 years ago

nfriend21 commented 9 years ago

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!

morgan-blondellet commented 8 years ago

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 commented 8 years ago

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

morgan-blondellet commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

@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! :)