EditLive!'s Advanced API and plugin functionality is only supported with an EditLive! Enterprise Edition license.
The Advanced APIs provide the ability for developers to extend the functionality of EditLive! by accessing the program's underlying Java code.
In order to use the Advanced APIs, developers must first create a Java class utilizing the Tiny EditLive! Java APIs. For information on how to do this see the Coding with the Advanced APIs article.
After creating the Java class, developers need to perform the following steps:
- Compiling the Java class and storing the required .class files in a Java .jar file.
- Instantiating an instance of EditLive!, using the AddJar, AddPlugin, or AddPluginAsText load-time property to specify the new Java class to load.
Compiling Advanced API Java Files
Before compiling a Java file utilizing the Advanced APIs, you must ensure that the editlivejava.jar file is on the classpath so that the EditLive! classes can be found. The editlivejava.jar file is located in the INSTALL_HOME/redistributables/editlivejava directory, where INSTALL_HOME is the location where the EditLive! SDK has been installed to. The method for doing this will vary depending on your operating system and development environment. If you are using the command-line tools provided with the Java SDK, you can add the option -classpath /path/to/editlivejava.jar where /path/to/editlivejava.jar is the path to the editlivejava.jar file.
For example, to compile the BasicELJ.java file if the files BasicELJ.java and editlivejava.jar are both inside the /bin directory of your Java SDK:
javac -classpath .;editlivejava.jar BasicELJ.java
This will produce the file BasicELJ.class.
All the required .class files compiled for an example then need to be packaged in a .jar file. For example, to package the BasicELJ.class file into a jar called BasicELJ.jar, if the files BasicELJ.class and editlivejava.jar are both inside the /bin directory of your Java SDK:
jar cvf BasicELJ.jar BasicELJ.class
Created jar files now need to be signed. To sign a jar file you will need to use the Java jarsigner command. For detailed information on using the jarsigner command of Java see the Sun Microsystems website.
For example, for a private key file yourkey.p12, of a keystore type pkcs12, with a store password of yourpassword, a key password of yourpassword, and the alias for the private key keyuser, the following command would sign the BasicELJ.jar file.
jarsigner -keystore "yourket.p12" -storetype "pkcs12" -storepass "yourpassword" -keypass "yourpassword" BasicELJ.jar "keyuser"
Please consult the documentation included with your development environment or the Java SDK for more information.
Running Advanced API Java Files
After compiling a Java file that utilizes the Ephox EditLive! Advanced APIs, the AddJar, AddPlugin, or AddPluginAsText load time property of EditLive! can be used to specify this new Java class to load when instantiating the EditLive! applet.
Example
The following example shows how to load the Java class NewApplet.class, stored in the jar MyApplet.jar, when instantiating an instance of the EditLive! applet. For this example, MyApplet.jar would be located in the same directory as the webpage loading EditLive!.
This example specifies the Advanced API implementation of EditLive! by using the AddJar load-time property.
<script src="../../redistributables/editlivejava/editlivejava.js"></script> <script language="JavaScript"> var editlivejava1; editlivejava1 = new EditLiveJava("ELApplet1", "700", "400"); ... editlivejava1.addJar("MyApplet.jar", "NewApplet"); editlivejava1.show(); </script>
Example
The following example shows how to load the Java class NewApplet.class, stored in the jar MyApplet.jar, when instantiating an instance of the EditLive! applet. For this example, MyApplet.jar and MyPlugin.xml would be located in the same directory as the webpage loading EditLive!.
This example specifies the Advanced API implementation of EditLive! by using the AddPlugin load-time property.
<script src="../../redistributables/editlivejava/editlivejava.js"></script> <script language="JavaScript"> var editlivejava1; editlivejava1 = new EditLiveJava("ELApplet1", "700", "400"); ... editlivejava1.addPlugin("MyPlugin.xml"); editlivejava1.show(); </script>
MyPlugin.xml would define the location of the MyApplet.jar file and its main class as follows:
<?xml version="1.0" ?> <plugin> <advancedapis jar="MyApplet.jar" class="NewApplet" /> </plugin>
Example
The following example shows how to load the Java class NewApplet.class, stored in the jar MyApplet.jar, when instantiating an instance of the EditLive! applet. For this example, MyApplet.jar and MyPlugin.xml would be located in the same directory as the webpage loading EditLive!.
This example specifies the Advanced API implementation of EditLive! by using the AddPluginAsText load-time property.
<script src="../../redistributables/editlivejava/editlivejava.js"></script> <script language="JavaScript"> var editlivejava1; editlivejava1 = new EditLiveJava("ELApplet1", "700", "400"); ... editlivejava1.addPluginAsText("<?xml version=\"1.0\" ?><plugin><advancedapis jar=\"MyApplet.jar\" class=\"NewApplet\" /></plugin>"); editlivejava1.show(); </script>