The autosave plugin lets you save automatically the content created with CKEditor, what helps to protect you against losing your work.
The autosaving can be carried out in three ways:
- Change counter - Optional trigger which sends data to server only after specified amount changes was made in the editor.
- Interval - Optional trigger which sends data to server after specified amount of time.
- Toolbar button - sends data to server when user click on a button (This is not quite automatic ). As of version 1.0.2 it is possible to assign keystroke to button.
All communication between plugin and server is made with XML messages.
Plugin fires two events: "afterAutosave" (fired right after saving was finished) and "beforeAutosave" (fired right before AJAX request is made) which can be used to execute user specific functions while saving process takes place.
On the 8th of January 2012 AJAX autosave has been updated to version 1.0.1. It is now possible to use this plugin as simple manual AJAX save by switching off Interval and Change counter triggers. Special thanks to @lsdzung for bringing this up.
Licensed under the terms of any of the following licenses at your choice: GPL, LGPL and MPL.
Unpack downloaded zip file and copy autosave folder to /ckeditor/plugins/ or /ckeditor/_source/plugins/ folder (It all depends whether you use ckeditor_source.js or ckeditor.js script on your page). If you are interested only in using the plugin then the first path is what you are looking for.
Next you have to make three things which are in fact providing values for three parameters:
Register the plugin -
config.extraPlugins = 'autosave';
Add new toolbar button -
config.toolbar = [['Source','Save','Preview','-', 'Autosave']];
Specify URL for the data saving server-side script -
config.autosaveTargetUrl = 'http://example.com/path_to_script_that_saves_data';
More information can be found in readme files provided with zips archives.
There are three archives attached to this post. One containing the plugin (minified plus folders for making source version), second containing sample java application showing usage of the plugin and third containing sample PHP connector (Special thanks to Wiktor Walc for providing this one).
Sample Java Application
Sample PHP Connector
As I was saying before the above archives contain two sample connectors, for Java and PHP. If you would like to attach sample connector for other programming language you are welcome.
If you have found a bug, have got an idea for a new feature for this plugin or have a general idea how this plugin could be improved, please leave a comment.
If idea is interesting and possible to implement I will try to include it in future releases.
- Version 1.0.1 - It is now possible to use this plugin as manual AJAX save by simply setting autosaveSensitivity and autosaveRefreshTime configuration properties to 0. Special thanks to @lsdzung for bringing this up.
- Version 1.0.2 - It is now possible to define user specific request parameters with configuration option autosaveRequestParams, assign key shortcut to autosave button with configuration option autosaveKeystroke and execute user specific functions on two events fired by the plugin (afterAutosave and beforeAutosave). Special thanks to @petr82 for bringing this up.