-
Notifications
You must be signed in to change notification settings - Fork 0
Writing an Etherpad Lite Plugin
Writing Etherpad Lite plugins is a relatively simple, and very rewarding experience. We try to make it as simple as possible for you to get started, so please follow this tutorial very carefully to learn as much as you can!
In order to get started quickly, we've created a simple example plugin for you. You can get it by cloning the git repository:
$ git clone https://github.com/niklasfi/ep_base.git
The rest of this tutorial will assume that you're using that project as your base, so it's in your best interest to use it!
There are two JSON files in the sample repository, and they're relatively short. You'll need to change both of them to get the package working properly!
ep.json is the file that Etherpad Lite uses to register your plugin's hooks. You should check out the plugin API hooks list for more information on the available hooks.
Change all of the UPPERCASE things in this file to better represent your own plugin's information.
package.json is used by the Node package manager (npm) to build and install your plugin. Even if you don't plan on distributing your plugin on the npm registry, you should change this file to make it easier for you to manage dependencies. As before, change the UPPERCASE things to better represent your plugin's information.
You can change this file if you'd like, to give your plugin a little bit of documentation. For now, though, you can leave the default text.
This is where the bulk of your changes should go. First, you should rename it to reflect the name of your plugin. You can choose any filename you'd like, really. The traditional "index.js" is also available, though some people choose not to use it.
Each export can either be the name of the hook, or any name you'd like. If you give the functions names other than the hook names, you'll need to specifically name which functions go to which hooks in ep.json; if you name the functions after the hooks, no such specification is necessary.
Now that you've changed things around, so long as you did it properly, you should be able to go into the base directory of your Etherpad Lite installation and run npm install PATH/TO/YOUR/PLUGIN. Restart Etherpad Lite and enjoy!